Way to trigger event for all players before they end turn..any suggestions?

ww2commander

Emperor
Joined
Aug 23, 2003
Messages
1,243
Location
Australia
I have combed through the interface and various event types but nothing seems to stick out.

I am looking to run a single function prior to a player (human and AI) ending their turn. The function needs to process some unit specific info from that turn before it is reset in prep for the players next turn.

Any ideas on how I can do this in absence of a "PlayerDoTurnEnd"?

EDIT: Never-mind, I realized this is not possible as I had already asked something similar a while back.

Mods please delete this thread. Apology
 
Events.ActivePlayerTurnEnd()
Events.AIProcessingEndedForPlayer(playerID)
GameEvents.PlayerDoTurn(playerID)

Though I don't know what you precisely want to accomplish.
 
Events.ActivePlayerTurnEnd()
Events.AIProcessingEndedForPlayer(playerID)
GameEvents.PlayerDoTurn(playerID)

Though I don't know what you precisely want to accomplish.

All these events won't work as they either relate to the active 'human' player or process at the start of the next player's turn which is too late for what I need.

I am in effect looking for something that executes just before the player's turn as formally ended and all it's unit stats are reset. I dug up and old thread after some further searching and realised that there was no way (aside from DLL modding) to accomplish this.

For those curious as to what I am trying to do:
I am trying to track units that attack or defend in the turn to provide specialised promotions. This is easily accomplished through Events.SerialEventUnitSetDamage with the exception of ranged units which do not trigger the code as their damage is unaffected unlike the unit they are attacking. The only way to capture if these units have attacked is through the following function:

Code:
function ProcessRangedAttackCombat(playerID)

-- We need this function to detect which ranged units attacked in order
-- to keep a track of promotion checks. This is due to SerialEventUnitSetDamage
-- not triggering for ranged units (except aircraft which do trigger it!!!!!) 

-- Defending stats are processed through ProcessDamagedUnit and not here. This function is only for attack tracking
	
	local player = Players[playerID]

	for unit in player:Units() do

		local unitID = unit:GetID()
		if unit:IsRanged() and unit:IsOutOfAttacks() then
			local unitKey = GetUnitKeyFromUnitID(playerID, unitID)
			g_UnitData[playerID][unitKey].Attacked = true
		end
	end 
end

However, I don't want to constantly loop through this function as the units across major players can be over 100 on the map! Therefore attaching it to something like UnitSetXY might be to processing intensive for my mod :(

For the human player I could easily tie this event to something like unit being selected, but I need it to also process for the AI player.

Anyhow, unless there is some new event revelation I am unaware of, then best to close this thread ;)
 
IsOutOfAttacks() is not gonna detect combat if unit has ability to attack more than once in turn.
SerialEvent is quite a risky method for AI-friendly mod.
There is also a rare situation when defending unit doesn't take damage.

PlayerDoTurn, fake PostCombatPromotions (see Kris Swordsman for reference), basic logic. You should handle this.
I think in last patch, they added event upon Obtaining promotion. It may allow to detect every single combat.
 
IsOutOfAttacks() is not gonna detect combat if unit has ability to attack more than once in turn.
The number of times should not matter. As long as it has attacked.

SerialEvent is quite a risky method for AI-friendly mod.
As per previous statement, the order of Ui updating does not matter as long as combat is detected. I have tested SerialEventUnitSetDamage extensively enough to have 95% confidence (that's a lot for any civ functionality!) that all 'clashing type' combat is captured.

There is also a rare situation when defending unit doesn't take damage.
Can you provide examples? Note that all civilian type units have been disabled in my mod and it is purely military units restricted to ground and air domain. City attacks are irrelevent as the attacker will be detected either through SerialEventUnitSetDamage or the function above (assuming I ever use it).

PlayerDoTurn, fake PostCombatPromotions (see Kris Swordsman for reference), basic logic. You should handle this.
I think in last patch, they added event upon Obtaining promotion. It may allow to detect every single combat.
This sounds interesting. Will investigate as I have never played Indonesia before in the game.
 
Back
Top Bottom