CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.27k stars 4.12k forks source link

(Some?) zombies have an absurd preference for their grab attack #75659

Open Terrorforge opened 1 month ago

Terrorforge commented 1 month ago

Describe the bug

I was messing around with the zombie breaker (mon_zombie_concentration_ender) from MoM for #75649 when I discovered something weird; even if I completely remove the cooldown on zombie_anti_concentration_spell, if I'm in melee it will only cast the spell very rarely, something like once every few minutes, maybe as often as every 30 seconds. Instead it just tries to grab, over and over and over. Rearranging the list of special attacks didn't help, so it's not a matter of it just preferrentially using the first special attack in its entry. The only way I could get it to consistently cast the spell was to remove the grab entirely.

This severely hampers our ability to create zombies that do anything unique and interesting.

Attach save file

N/A

Steps to reproduce

  1. Mess about with zombie breaker (and other zombies with special attacks) as described and let it whale on you

Expected behavior

Ideally there would be some way to manually weight a monster's special attacks so that some occur more than others, but failing that they should all occur at a more or less equal rate.

Screenshots

image Spell with no cooldown, grab removed. It casts the spell over and over, as expected.

image image Spell with no cooldown, grab present. It only uses the spell every few minutes, maybe as often as once every 30 seconds. I even moved the grab to the end of list of special attacks just to see if it was prioritizing the first listed special attack, but nope. If it was just picking a random attack that's off cooldown, this should be 50/50 grabs and spells, right?

Versions and configuration

Additional context

No response

Venera3 commented 1 month ago

Could you reproduce with debug mode - DF_MATTACK filter and paste the log messages? The base attack has a 10-turn cooldown, they shouldn't be able to chain them like that.

Terrorforge commented 1 month ago

Here you go: image And here's what it looks like after it successfully casts the spell: image

And just for good measure, I checked to see what happened if I manually add "cooldown": 10 to the breaker's grab. And yeah, it does now only occasionally grab and use the spell at about the intended cooldown: image image It looks to me like it only triggered because I failed to break the grab, which meant the grab attack didn't fire, and all the other valid attacks were on cooldown.

I also tried moving "grab" to the bottom of the breaker's list of special attacks to see if that would change the order of evaluation, but it did not. I noticed that the attacks seem to be listed in alphabetical order, so I added barbed_tentacle and cut_throat to the end of the entry to check, and lo and behold: image Now it's constantly using its barbed_tentacle attack every turn, despite the fact that it has a 5-turn cooldown defined in the base attack.

CONCLUSION:

  1. The game evaluates special attacks in alphabetical order. If the attack with the earliest alphabetical order is off cooldown and valid, it will always be used.
  2. Cooldowns are not preserved from base attacks, defaulting any monster attack without an explicitly defined cooldown to a cooldown of 0.

In combination, this means that if a monster has a valid low-alphabetical attack without a defined cooldown, it will use that attack to the exclusion of all other attacks. A quick tests confirms that basic zombies also just try to to grab repeatedly. I'm pretty sure that right now the only reason any zombie does literally anything other than grab is that grab has a failure mode (grab is already established).

Even if the cooldowns were passed down correctly, this seems like incorrect behavior to me. It wouldn't matter most of the time, but it means that if a monster has two attacks with the same cooldown it will always do them in the same order every time, and if it has two special attacks with no cooldown it will only ever use one of them.

Terrorforge commented 1 month ago

Oh and here's the .json for the final test version of the breaker with the extra attacks and such:

{ "id": "mon_zombie_concentration_ender", "copy-from": "mon_zombie_base", "type": "MONSTER", "name": { "str": "zombie breaker" }, "description": "An enormous hump takes up most of this zombie's back, fusing its head directly into its torso. It moves slowly but seems more aware than most of its kind, constantly looking around rather than staring blankly ahead. When you look directly at it, you feel a cold chill at the base of your skull.", "species": [ "ZOMBIE", "HUMAN", "PSI_NULL" ], "proportional": { "hp": 2 }, "symbol": "Z", "color": "dark_gray_white", "scents_tracked": [ "sc_human", "sc_fetid" ], "melee_skill": 4, "dodge": 1, "bleed_rate": 50, "vision_day": 35, "vision_night": 5, "emit_fields": [ { "emit_id": "emit_anti_psi", "delay": "1 s" } ], "grab_strength": 30, "special_attacks": [ { "id": "grab" }, { "id": "bite_humanoid", "cooldown": 5 }, { "id": "scratch", "cooldown": { "math": [ "5 + rand(13)" ] }, "damage_max_instance": [ { "damage_type": "bash", "amount": 6, "armor_multiplier": 0.8 } ], "hit_dmg_u": "%1$s strikes at your %2$s!", "hit_dmg_npc": "%1$s strikes at <npcname>!", "miss_msg_u": "%1$s strikes at you, but you dodge!", "miss_msg_npc": "%1$s tries to strike at <npcname>, but they dodge!", "no_dmg_msg_u": "%1$s strikes at your %2$s, but fails to penetrate armor.", "no_dmg_msg_npc": "%1$s tries to strike at <npcname>, but fails to penetrate armor." }, { "id": "zombie_anti_concentration_spell", "type": "spell", "spell_data": { "id": "null_break_concentration_spell" }, "cooldown": { "math": [ "7 + rand(19)" ] }, "monster_message": "%1$s looks at %3$s and the static on the edge of your vision flickers." },{ "id": "barbed_tentacle" }, { "id": "cut_throat" }

Venera3 commented 1 month ago

From a cursory I'm-at-work search I'd imagine #74139 moving the cooldown over to variable objects doesn't play nice with the mattack loading code. I'm not gonna be in a position to bisect it properly in the near future so pinging @Ramza13 - could this be related or was it broken before?

Standing-Storm commented 3 days ago

Note sure if this is the same or a different bug, I just noticed this:

Untitled

The mi-go used three psionic powers and a physical attack all within one second.