Event for start of each player turn?

MdREV

Chieftain
Joined
Apr 11, 2011
Messages
61
I've been getting some feedback on the Zombie Apocalypse mod that the Zombies can be too tough, specifically because they heal at the end of each combat so there is no way to overwhelm them with superior numbers to prevent healing. The fix would be that Zombie units heal/spawn only at the beginning of the Zombie turn, for the total of any outstanding healing from every combat between turns.

Has anyone identified an event that will be called reliably for each player turn (including minor civs, specifically barbarian) before the AI executes combat? It doesn't matter if it is called multiple times, I can put checks in place to ensure it only goes on to process the action once per turn, per civ.

Thanks in advance.
 
Based on analysis of DLC scenarios, the GameEvent PlayerDoTurn runs once a turn for each civ, on their turn. Not tried using it, and we have no info as yet on whether it's the beginning or end of turn.
 
Thanks. I'll work with that tonight and report back on my findings.
 
Has anyone identified an event that will be called reliably for each player turn (including minor civs, specifically barbarian) before the AI executes combat?

The GameEvent PlayerDoTurn is for the start of a given player's turn, but if you want this to trigger at the start of an individual combat, you use RunCombatSim. Similarly, EndCombatSim triggers at the end of a combat; the combination of the two allows for a lot of things; you can have Zombies spawning other zombies by triggering inside EndCombatSim, for instance, and my own mod heavily uses RunCombatSim to add a few unusual special abilities.
The only catch is that these two events ONLY apply when animations are shown; Strategic View or the Quick Combat option prevent it from triggering.

So it depends what exactly your custom zombie effect is. In my own mod, I'm using RunCombatSim for:
> A unit that has a 10% chance of healing 5 HP at the start of each fight
> A unit that has a "first strike" 10% chance of dealing 5 damage to its opponent at the start of each fight
> A unit that steals promotions from its opponent
> A series of units that adjust their base strength by up to 25% to match the opposing unit's strength (so they do better against strong units and weaker against weak ones... basically, SMAC's Psi units)
> Nuke interception, because the NukeInterceptionRate stub in the Projects file doesn't actually work. (If you kill a unit in RunCombatSim, it prevents the combat from happening. So killing a nuke in there prevents it from exploding.)

And a few other bits. The point is, if the Zombie unit is supposed to do something like turn the opposing unit into a zombie, then you need to trigger in RunCombatSim. If you want it to, say, return from the dead after being killed, that's EndCombatSim.
 
Thanks for the information Spatz. I currently make use of EndCombatSim for the logic and I'm aware of its unfortunate limitations.

As at now, my Zombies "heal" for the amount of damage they do in a combat, and if there is overflow then the remaining health is "healed" on an adjacent Zombie unit. Finally, if there are no adjacent Zombie units and still potential "healing" left over, a new unit of the same type as the Zombie is spawned in an adjacent tile with the appropriate damage set. If a Zombie unit is completely wiped out during a combat, then no healing takes place.

For the most part this works well, and the Zombies can be a lot of fun and quite challenging. The feedback I'm getting, which I tend to agree with, is that the healing takes place at the end of each combat. Even if surrounded by roughly equal units the 6 stalemate results end in a more or less unharmed Zombie unit, where weight of numbers should help whittle them down.

The solution I've come up with, which will play much better, is for any Zombie "healing" during combat to be saved up against the unit, and then processed at the start of the zombie units turn. This would also allow an alliance of Civ's or City States to assist eachother in wiping out Zombies.
 
I've done some testing, and the GameEvents.PlayerDoTurn() takes a single argument, being the index of the player in the Players[] table.

So some interesting behaviour I've noted is as follows:
- The Event does not execute for any Civ on the first turn
- The Event executes only for the Player on the second turn
- The Event executes for all Civs from the third turn onwards

First I thought that the event may only execute for Civs with at least one city, however this is not the case and it will follow the above pattern regardless.

Still, it will meet my needs as Players are not going to encounter Zombies in the opening turns of the game. Thanks for the suggestion.
 
I've done some testing, and the GameEvents.PlayerDoTurn() takes a single argument, being the index of the player in the Players[] table.

So some interesting behaviour I've noted is as follows:
- The Event does not execute for any Civ on the first turn
- The Event executes only for the Player on the second turn
- The Event executes for all Civs from the third turn onwards

First I thought that the event may only execute for Civs with at least one city, however this is not the case and it will follow the above pattern regardless.

Still, it will meet my needs as Players are not going to encounter Zombies in the opening turns of the game. Thanks for the suggestion.
Weird behaviour. I'll document it on the wiki (although the arguments already were). Have you tried it on multiple difficulty settings? Perhaps the non-humans have a delay before they start on some difficulties? I doubt it, but it's the only logical explanation I can think of.
 
The feedback I'm getting, which I tend to agree with, is that the healing takes place at the end of each combat. Even if surrounded by roughly equal units the 6 stalemate results end in a more or less unharmed Zombie unit, where weight of numbers should help whittle them down.

It sounds like the real problem is that a stalemate is even possible. I don't like the "saving up" idea, because it too heavily favors a human player (who knows to kill units outright instead of whittling away at multiple foes at once). The easier solution, then, is to add an inefficiency to the system. So maybe Zombies only heal HALF the damage they deal, or maybe only N-2 (minimum 1). That way, they can't simply break even against an equal-strength enemy indefinitely.

Or better yet, change the basic mechanism. How about this:
> A zombie deals N damage.
> N damage will try to be healed.
> However, no single zombie can heal more than 2 points at once, so if N>2, then the (N-2) overflow will apply to an adjacent Zombie unit (if any).
> If N>4, then some will go to a third Zombie (adjacent to the FIRST, not the second), and so on.
All of this can still be done in EndCombatSim, without the need to worry about start-of-turn events.

The result is that a full pack of zombies becomes VERY hard to destroy, because the damage healed to the group from combat will basically be equal to the damage taken. But get a zombie alone, and it's fairly easy to bring down because it'll only be healing 2 points at a time. And if you focus attacks on one zombie, to where the healing to nearby ones is being wasted, then you can make progress on a pack.

Of course, this does nothing to address bombardment of the zombies, where they're dealing no damage. So I'm assuming you have some sort of regeneration mechanism in place for that.
 
Spatzimaus: the other problem with that is that it's done through a combatSim event, which doesn't work in Strategic View or fast combat. I'd consider that a big issue, but I'm a bit of a stickler for architectural cleanness.

I wish GameEvents had been there since release, and that they'd listed all of the GameEvents available. As those are purely based on actual game-rule related aspects, they seem far more suited to behaviour modding.
 
I'm not having Zombies regenerate from bombardment, they instead are highly resistant to ranged attacks of all types.

There are lots of ideas I have around the Zombies that don't translate very well to a computer player. For example, when a Zombie pillages a worked tile I wanted to spawn an new Zombie unit and reduce the population of the working city by one. This means that you need to guard your workers, and adds to the "realism" of a Zombie plague. Problem is, I can't make the AI guard their workers...

Has anyone ever tried giving orders to AI units, perhaps within a DoPlayerTurn event? Would it be possible to "override" the AI in such a fashion?
 
Back
Top Bottom