diff --git a/config/fxdata/creature.cfg b/config/fxdata/creature.cfg index a2c89eb8fc..049684c598 100644 --- a/config/fxdata/creature.cfg +++ b/config/fxdata/creature.cfg @@ -72,9 +72,9 @@ RangeMax = 0 PrimaryTarget = 0 ; Instance used by creature "going postal" while working in a room ; Creature will only use available instances with the highest priority, -; If multiple instances have the same RagePriority, one is chosen randomly +; If multiple instances have the same PostalPriority, one is chosen randomly ; 0 disables the instance for beeing used while "going postal". -RagePriority = 0 +PostalPriority = 0 ; Instance properties flags: ; REPEAT_TRIGGER allows player to hold down the mouse button to cast. ; DISPLAY_SWIPE shows the swipe in possession loaded from the creatures 'PossessSwipeIndex'. @@ -185,7 +185,7 @@ Graphics = RANGEDATTACK RangeMin = 156 RangeMax = MAX PrimaryTarget = 3 -RagePriority = 1 +PostalPriority = 1 Properties = DESTRUCTIVE RANGED_ATTACK Function = creature_fire_shot SHOT_ARROW 0 @@ -205,7 +205,7 @@ Graphics = RANGEDATTACK RangeMin = 156 RangeMax = MAX PrimaryTarget = 3 -RagePriority = 1 +PostalPriority = 1 Properties = DESTRUCTIVE RANGED_ATTACK Function = creature_fire_shot SHOT_FIREBALL 0 @@ -282,7 +282,7 @@ Graphics = RANGEDATTACK RangeMin = 768 RangeMax = 5120 PrimaryTarget = 3 -RagePriority = 1 +PostalPriority = 1 Properties = DESTRUCTIVE RANGED_ATTACK Function = creature_fire_shot SHOT_LIGHTNING 0 @@ -340,7 +340,7 @@ Graphics = RANGEDATTACK RangeMin = 156 RangeMax = MAX PrimaryTarget = 4 -RagePriority = 1 +PostalPriority = 1 Properties = RANGED_ATTACK Function = creature_cast_spell SPELL_POISON_CLOUD 0 @@ -472,7 +472,7 @@ Graphics = RANGEDATTACK RangeMin = 156 RangeMax = MAX PrimaryTarget = 3 -RagePriority = 1 +PostalPriority = 1 Properties = DESTRUCTIVE RANGED_ATTACK Function = creature_fire_shot SHOT_MISSILE 0 @@ -492,7 +492,7 @@ Graphics = RANGEDATTACK RangeMin = 156 RangeMax = MAX PrimaryTarget = 3 -RagePriority = 0 +PostalPriority = 0 Properties = DESTRUCTIVE RANGED_ATTACK Function = creature_fire_shot SHOT_NAVI_MISSILE 0 @@ -604,7 +604,7 @@ TooltipTextID = 234 SymbolSprites = 440 Graphics = RANGEDATTACK PrimaryTarget = 3 -RagePriority = 1 +PostalPriority = 1 Properties = DANGEROUS DESTRUCTIVE RANGED_ATTACK Function = creature_fire_shot SHOT_GRENADE 0 @@ -624,7 +624,7 @@ Graphics = RANGEDATTACK RangeMin = 156 RangeMax = MAX PrimaryTarget = 3 -RagePriority = 1 +PostalPriority = 1 Properties = DESTRUCTIVE RANGED_ATTACK MELEE_ATTACK Function = creature_cast_spell SPELL_HAILSTORM 0 @@ -843,7 +843,7 @@ Graphics = RANGEDATTACK RangeMin = 1000 RangeMax = MAX PrimaryTarget = 3 -RagePriority = 1 +PostalPriority = 1 Properties = DANGEROUS DESTRUCTIVE RANGED_ATTACK Function = creature_fire_shot SHOT_LIZARD 0 diff --git a/src/config_creature.c b/src/config_creature.c index be42032527..6128f8812b 100644 --- a/src/config_creature.c +++ b/src/config_creature.c @@ -97,7 +97,7 @@ const struct NamedCommand creaturetype_instance_commands[] = { {"ValidateSourceFunc", 18}, {"ValidateTargetFunc", 19}, {"SearchTargetsFunc", 20}, - {"RagePriority", 21}, + {"PostalPriority", 21}, {NULL, 0}, }; @@ -841,7 +841,7 @@ TbBool parse_creaturetype_instance_blocks(char *buf, long len, const char *confi inst_inf->validate_target_func = 0; inst_inf->validate_target_func_params[0] = 0; inst_inf->validate_target_func_params[1] = 0; - inst_inf->rage_priority = 0; + inst_inf->postal_priority = 0; } } instance_desc[INSTANCE_TYPES_MAX - 1].name = NULL; // must be null for get_id @@ -1213,11 +1213,11 @@ TbBool parse_creaturetype_instance_blocks(char *buf, long len, const char *confi } } break; - case 21: // Rage Instance priority + case 21: // Postal Instance priority if (get_conf_parameter_single(buf, &pos, len, word_buf, sizeof(word_buf)) > 0) { k = atoi(word_buf); - inst_inf->rage_priority = k; + inst_inf->postal_priority = k; n++; } if (n < 1) @@ -1707,7 +1707,7 @@ TbBool load_creaturetypes_config_file(const char *textname, const char *fname, u game.conf.magic_conf.instance_info[i].reset_time = 0; game.conf.magic_conf.instance_info[i].fp_reset_time = 0; game.conf.magic_conf.instance_info[i].graphics_idx = 0; - game.conf.magic_conf.instance_info[i].rage_priority = 0; + game.conf.magic_conf.instance_info[i].postal_priority = 0; game.conf.magic_conf.instance_info[i].instance_property_flags = 0; game.conf.magic_conf.instance_info[i].force_visibility = 0; game.conf.magic_conf.instance_info[i].primary_target = 0; diff --git a/src/creature_instances.c b/src/creature_instances.c index 8aafdc3cf3..cd003c34b4 100644 --- a/src/creature_instances.c +++ b/src/creature_instances.c @@ -327,10 +327,15 @@ TbBool instance_is_ranged_weapon_vs_objects(CrInstance inum) return (((inst_inf->instance_property_flags & InstPF_RangedAttack) != 0) && ((inst_inf->instance_property_flags & InstPF_Destructive) != 0) && !(inst_inf->instance_property_flags & InstPF_Dangerous)); } -TbBool instance_is_rage_weapon(CrInstance inum) +/** + * Informs whether the creature has an instance which can be used when going postal. + * Going Postal is the behavior where creatures attack others at their job, like warlocks in the library + * @return True if it has a postal_priority value > 0. + */ +TbBool instance_is_used_for_going_postal(CrInstance inum) { struct InstanceInfo* inst_inf = creature_instance_info_get(inum); - return (inst_inf->rage_priority > 0); + return (inst_inf->postal_priority > 0); } TbBool instance_is_melee_attack(CrInstance inum) @@ -402,7 +407,7 @@ TbBool creature_has_ranged_object_weapon(const struct Thing *creatng) return false; } -TbBool creature_has_rage_weapon(const struct Thing *creatng) +TbBool creature_has_weapon_for_postal(const struct Thing *creatng) { TRACE_THING(creatng); const struct CreatureControl* cctrl = creature_control_get_from_thing(creatng); @@ -410,7 +415,7 @@ TbBool creature_has_rage_weapon(const struct Thing *creatng) { if (cctrl->instance_available[inum]) { - if (instance_is_rage_weapon(inum)) + if (instance_is_used_for_going_postal(inum)) return true; } } diff --git a/src/creature_instances.h b/src/creature_instances.h index 932e3b2229..baf2d32e56 100644 --- a/src/creature_instances.h +++ b/src/creature_instances.h @@ -105,7 +105,7 @@ struct InstanceInfo { long reset_time; long fp_reset_time; unsigned char graphics_idx; - char rage_priority; + char postal_priority; short instance_property_flags; short force_visibility; unsigned char primary_target; @@ -151,7 +151,7 @@ void creature_increase_available_instances(struct Thing *thing); TbBool creature_has_ranged_weapon(const struct Thing *thing); TbBool creature_has_disarming_weapon(const struct Thing* creatng); TbBool creature_has_ranged_object_weapon(const struct Thing *creatng); -TbBool creature_has_rage_weapon(const struct Thing *creatng); +TbBool creature_has_weapon_for_postal(const struct Thing *creatng); TbBool creature_has_melee_attack(const struct Thing *creatng); int creature_instance_get_available_pos_for_id(struct Thing *thing, CrInstance req_inst_id); diff --git a/src/creature_states_combt.c b/src/creature_states_combt.c index 1774ea9897..f2be3d7b79 100644 --- a/src/creature_states_combt.c +++ b/src/creature_states_combt.c @@ -1842,25 +1842,25 @@ CrInstance get_self_spell_casting(const struct Thing *thing) return CrInst_NULL; } -// Static array to store the IDs of "rage" instances -static CrInstance rage_inst[INSTANCE_TYPES_MAX]; -// Counter for the number of "rage" instances found -static short rage_inst_num = 0; +// Static array to store the IDs of "postal" instances +static CrInstance postal_inststance[INSTANCE_TYPES_MAX]; +// Counter for the number of "postal" instances found +static short postal_inst_num = 0; // Flag to indicate if the cache has been initialized static TbBool initial = false; -/** @brief Retrieves a random available "rage" instance within range for a given creature. +/** @brief Retrieves a random available "postal" instance within range for a given creature. * - * On the first call, the function creates a cache of all available "rage" instances. + * On the first call, the function creates a cache of all available "postal" instances. * It then loops through the cache to find instances available for the creature and fitting within the given range. * These available instances are added to a list. * The function then chooses a random instance from this list. * * @param thing Pointer to the creature for which the instance is to be retrieved. * @param dist Distance to the target. - * @return A random available "rage" CrInstance for the given range + * @return A random available "postal" CrInstance for the given range */ -CrInstance get_rage_instance_to_use(const struct Thing *thing, unsigned long dist) +CrInstance get_postal_instance_to_use(const struct Thing *thing, unsigned long dist) { struct InstanceInfo* inst_inf; @@ -1871,14 +1871,14 @@ CrInstance get_rage_instance_to_use(const struct Thing *thing, unsigned long dis for (short i = 0; i < game.conf.crtr_conf.instances_count; i++) { inst_inf = creature_instance_info_get(i); - // Check if the instance has a positive rage_priority - if (inst_inf->rage_priority > 0) + // Check if the instance has a positive postal_priority + if (inst_inf->postal_priority > 0) { // Ensure we don't exceed the maximum array size - if (rage_inst_num < INSTANCE_TYPES_MAX) + if (postal_inst_num < INSTANCE_TYPES_MAX) { // Add the instance ID to the cache - rage_inst[rage_inst_num++] = i; + postal_inststance[postal_inst_num++] = i; } else { break; @@ -1890,44 +1890,44 @@ CrInstance get_rage_instance_to_use(const struct Thing *thing, unsigned long dis } //List of usable instances - CrInstance av_rage_inst[INSTANCE_TYPES_MAX]; - short av_rage_inst_num = 0; + CrInstance av_postal_inst[INSTANCE_TYPES_MAX]; + short av_postal_inst_num = 0; char highest_prio = 0; short highest_prio_idx = CrInst_NULL; - // Loop through the cached rage instances - for (short j = 0; j < rage_inst_num; j++) + // Loop through the cached postal instances + for (short j = 0; j < postal_inst_num; j++) { - inst_inf = creature_instance_info_get(rage_inst[j]); + inst_inf = creature_instance_info_get(postal_inststance[j]); // Check if the instance is available - if (creature_instance_is_available(thing, rage_inst[j])) + if (creature_instance_is_available(thing, postal_inststance[j])) { // If this instance has higher priority than current highest, reset the list - if (inst_inf->rage_priority > highest_prio) + if (inst_inf->postal_priority > highest_prio) { - highest_prio = inst_inf->rage_priority; - av_rage_inst_num = 0; // Clear the list as we found a higher priority + highest_prio = inst_inf->postal_priority; + av_postal_inst_num = 0; // Clear the list as we found a higher priority } // If this instance matches the highest priority, check further conditions - if (inst_inf->rage_priority == highest_prio) + if (inst_inf->postal_priority == highest_prio) { // Check if the instance is reset and in range - if (creature_instance_has_reset(thing, rage_inst[j]) && + if (creature_instance_has_reset(thing, postal_inststance[j]) && inst_inf->range_min <= dist && dist <= inst_inf->range_max) { // Add to the list of available instances - av_rage_inst[av_rage_inst_num++] = rage_inst[j]; + av_postal_inst[av_postal_inst_num++] = postal_inststance[j]; } } } } // Choose a random index from the list of usable instances - if (av_rage_inst_num > 0) + if (av_postal_inst_num > 0) { - short rand_inst_idx = CREATURE_RANDOM(thing, av_rage_inst_num); - return av_rage_inst[rand_inst_idx]; + short rand_inst_idx = CREATURE_RANDOM(thing, av_postal_inst_num); + return av_postal_inst[rand_inst_idx]; } else { @@ -1936,12 +1936,12 @@ CrInstance get_rage_instance_to_use(const struct Thing *thing, unsigned long dis } } -void reset_rage_instance_cache() +void reset_postal_instance_cache() { // Reset the cache variables - rage_inst_num = 0; + postal_inst_num = 0; initial = false; - memset(rage_inst, 0, sizeof(rage_inst)); + memset(postal_inststance, 0, sizeof(postal_inststance)); } diff --git a/src/creature_states_combt.h b/src/creature_states_combt.h index 572dce18aa..6d0e9f4660 100644 --- a/src/creature_states_combt.h +++ b/src/creature_states_combt.h @@ -73,8 +73,8 @@ TbBool creature_would_benefit_from_healing(const struct Thing* thing); long project_creature_attack_target_damage(const struct Thing *firing, const struct Thing *target); -void reset_rage_instance_cache(); -CrInstance get_rage_instance_to_use(const struct Thing *thing, unsigned long dist); +void reset_postal_instance_cache(); +CrInstance get_postal_instance_to_use(const struct Thing *thing, unsigned long dist); TbBool creature_will_do_combat(const struct Thing *thing); TbBool creature_look_for_combat(struct Thing *creatng); diff --git a/src/creature_states_mood.c b/src/creature_states_mood.c index b99a6e7881..c5e51b9c51 100644 --- a/src/creature_states_mood.c +++ b/src/creature_states_mood.c @@ -514,7 +514,7 @@ TbBool process_job_causes_going_postal(struct Thing *creatng, struct Room *room, { SYNCDBG(8,"The %s index %d goes postal on %s index %d during %s",thing_model_name(creatng),(int)creatng->index,thing_model_name(combt_thing),(int)combt_thing->index,creature_job_code_name(going_postal_job)); - CrInstance inst_use = get_rage_instance_to_use(creatng, combt_dist); + CrInstance inst_use = get_postal_instance_to_use(creatng, combt_dist); if (inst_use <= 0) { SYNCDBG(8,"The %s index %d cannot go postal during %s; no ranged instance",thing_model_name(creatng),(int)creatng->index,creature_job_code_name(going_postal_job)); @@ -637,8 +637,7 @@ TbBool any_worker_will_go_postal_on_creature_in_room(const struct Room *room, co { if (creature_will_go_postal_on_victim_during_job(thing, victng, going_postal_job)) { - // We need rage instance to go postal - if (creature_has_rage_weapon(thing)) { + if (creature_has_weapon_for_postal(thing)) { return true; } } diff --git a/src/main.cpp b/src/main.cpp index cd6f668ba7..47f037972c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1579,7 +1579,7 @@ void reinit_level_after_load(void) sound_reinit_after_load(); music_reinit_after_load(); update_panel_colors(); - reset_rage_instance_cache(); + reset_postal_instance_cache(); } /** diff --git a/src/main_game.c b/src/main_game.c index 444d408af7..94d0057da8 100644 --- a/src/main_game.c +++ b/src/main_game.c @@ -237,7 +237,7 @@ static void init_level(void) game.manufactr_element = 0; game.manufactr_spridx = 0; game.manufactr_tooltip = 0; - reset_rage_instance_cache(); + reset_postal_instance_cache(); JUSTMSG("Started level %d from %s", get_selected_level_number(), campaign.name); api_event("GAME_STARTED");