HomeWildfire Games

Don't apply team bonuses to defeated players, counterpart to rP19093 / D12.

Description

Don't apply team bonuses to defeated players, counterpart to rP19093 / D12.

From Differential_Revision: ​https://code.wildfiregames.com/D1426
Reviewed By: temple
Comments By: fatherbushido

Event Timeline

For any android reading that:

The idea is not to "Don't apply team bonuses to defeated players".
I guess it's to
"Don't apply auras affecting a player entity to defeated players (by team bonus or not)".
For those interested in unit tests, it's interesting to point out what catch that (as I guess it's not OnGlobalPlayerDefeated).

(To be more explicit, it doesn't solve the issue it aimed to solve)

(To be more explicit, it doesn't solve the issue it aimed to solve)

You mean because D1430 still exists?

Unit tests:


Test 1
aura source =player entity (player 1)
aura target = player entity (player 2)
aura diplomacy type = ally
player 1 and 2 are allies

After defeat of player 2, GetAffectedPlayers still returns [1]

--> OK


Test 2
aura source = not a player entity (owned by player 1)
aura target = player entity (player 2)
aura diplomacy type = ally
player 1 and 2 are allies

After defeat of player 2, GetAffectedPlayers still returns [1,2]

--> Not OK


Code:

Affected players are calculated on init and on clean.
Clean is called by OnGlobalPlayerDefeated when the aura source is a player. (The global listening was perhaps not needed in rP21712)
So test1 pass and test2 fails.


Something like what is below could do it:

if (!Engine.QueryInterface(this.entity, IID_Player))
-> if (!Engine.QueryInterface(this.entity, IID_Player) || !HasPlayerAura ())

(where HasPlayerAura() is to add)


If one want to see it, wonder aura should show that or better giving the ptolemian team bonus aura to a cc for example. (though I don't exactly know what the state of those things is).
Left to the reader as my 6min eggs are probably hard boiled now.

elexis added a comment.EditedApr 16 2018, 3:25 PM

I hope the eggs still came out palatable.

The global listening was perhaps not needed in rP21712

The global subscribtion is needed so that team bonuses of non-defeated players are cleaned too, no?

Test 2

I couldnt reproduce an issue. Unit and structure entity auras affecting player entities are still cleaned on defeat in the onOwnershipChange clean call, no?
I tried by giving the ptolemian bonus aura to CCs as you proposed, using

Index: binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml	(revision 21730)
+++ binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml	(working copy)
@@ -1,5 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Entity parent="template_structure_civic">
+  <Auras datatype="tokens">
+    teambonuses/ptol_player_teambonus
+  </Auras>
   <AlertRaiser>
     <List datatype="tokens">FemaleCitizen</List>
     <RaiseAlertRange>140</RaiseAlertRange>

When starting the game we can see the food count increasing if and only if there is an ally with a CC.
When typing "exodia 2" the ally is defeated and the trickle stops.

Edit: Nevermind, got it. The defeated player still receives the trickle because the CC of the non-defeated player wasn't cleaned.

The global listening was perhaps not needed in rP21712

not needed in rP21712, but needed in that one.