[GS] Remove healing from promotions

Ieke

Chieftain
Joined
Oct 27, 2015
Messages
27
As the title says I want to create a simple mod that removes healing when you select a promotion, I would rather have healing as something you would select if that unit was up for a promotion. Just like in Civ V. I've looked through the "Promotions" and "ModifierArguments" but can't seem to fine anything about getting healed after selecting a promotion.

Thank you all
 
As the title says I want to create a simple mod that removes healing when you select a promotion, I would rather have healing as something you would select if that unit was up for a promotion. Just like in Civ V. I've looked through the "Promotions" and "ModifierArguments" but can't seem to fine anything about getting healed after selecting a promotion.

Thank you all
It's in <GlobalParameters> :

EXPERIENCE_PROMOTE_HEALED
EXPERIENCE_RETRAIN_HEALED
 
in <GlobalParameters> :
EXPERIENCE_PROMOTE_HEALED
EXPERIENCE_RETRAIN_HEALED
Is there any chance to set this Parameter different for the AI and for the human player / modify for the human player?

.
 
You can code the mechanism in Lua.

I suppose there is a way to use modifiers too, but I don't know them.
 
Last edited:
  • Like
Reactions: cvb
In Really Advanced Setup Lite there is a command he uses......AIMajPlayer=

<Row UnitType="UNIT_SCOUT" NumberExtraUnits="3" AIMajPlayer="false" EraType="ERA_ANCIENT"/>
<Row UnitType="UNIT_SCOUT" NumberExtraUnits="3" AIMajPlayer="true" EraType="ERA_ANCIENT"/>

I wanted to play with that and see if I could change other items like Maintenance and such. I know it does work good for units, gold, faith and technologies.
 
It will not work for what you are wanting without an lua script to implement the effect.

In Really Advanced Setup Lite I create new tables into the game's database and then the lua code within the mod implements the effects of these new game-tables. Without the lua code the game will not have any instructions on what to do with a column such as "AIMajPlayer".
 
[...] want to create a simple mod that removes healing when you select a promotion, I would rather have healing as something you would select if that unit was up for a promotion. [...] can't seem to fine anything about getting healed after selecting a promotion.
It's in <GlobalParameters>: / EXPERIENCE_PROMOTE_HEALED / EXPERIENCE_RETRAIN_HEALED
Is there any chance to set this Parameter different for the AI and for the human player / modify for the human player?
You can code the mechanism in Lua.
When I read the description of leke, I thought it may be about (strong) automatic healing with promotion OR no automatic healing with promotion (better).
By the keyword Lua I expected to set for the human player either EXPERIENCE_PROMOTE_HEALED or EXPERIENCE_RETRAIN_HEALED with a method like Players:GetResources:SetResourceAmount or
Players:GetTechs:SetResearchProgress
Found nothing appropriate in "Chimp & Chrisy's Effects & Reqs v2" or your "Lua-Objects"

Searched then the forum and found, that Experience gain for units are defined with them like this:
<Row Name="EXPERIENCE_PROMOTE_HEALED" Value="50" />
<Row Name="EXPERIENCE_RETRAIN_HEALED" Value="100" />
...??

"You can code the mechanism in Lua." means apply healing-changing in how the game works to the human Player via a Lua method? Which?
Or means: read the stored value from the database and do what I want with it in my private script? Like:
local iHealPoints:number = GlobalParameters.EXPERIENCE_PROMOTE_HEALED;

.
 
There is Events.UnitPromoted(playerID, unitID) but the vexed question here will be whether the event fires before the promotion and healing occur or afterwards. I would expect afterwards, in which case it would be impossible directly from this event to determine whether the unit healed for most cases of a promotion occurring. Events.UnitDamageChanged(playerID, unitID, newDamage, prevDamage) is also available but in order to make use of this an lua table would probably have to be kept tracking all the unit-damage values so it would be possible to determine whether (a) a unit healed and (b) it healed as a result of a promotion. It would be necessary then to also track each unit's Promotion-Level and compare the current unit Promotion Level against the old one whenever the unit healed. And then the code would have to address the healing that appeared to stem from being promoted, and also 'cache' the damage change for that unit when the damage-change was reversed by the lua script so that the code would be able to recognize a secondary firing of Events.UnitDamageChanged as a result of the lua script undoing the healing that occurred as part of a promotion. without this additional element the code could very easily result in an interminable processing loop.

The method for the damage change is Unit:ChangeDamage(iChangeAmount) but first you have to get the Unit-Object from the Player ID # and Unit ID # passed to either of the two events mentioned, as in
Code:
local pPlayer = Players[playerID]
if (pPlayer:IsHuman() == false) and (pPlayer:IsMajor() == true) then
       local pUnit = pPlayer:GetUnits():FindID(unitID)

     …..  some other code might be here …..

     pUnit:ChangeDamage(iChangeAmount)
end
This snippet would be part of a function that is triggered to fire off of one of the two events mentioned. It is not the entire code that would be needed. And the snippet as written is for making adjustments to units owned by AI Major Civilizations. In order to get the code to only work on units of the human player, you would alter the one line to
Code:
if pPlayer:IsHuman() then
 
Last edited:
  • Like
Reactions: cvb
I'd change health in a function called with Events.UnitPromoted, depending of the unit's owner and simply set both global parameters to 0.
 
  • Like
Reactions: cvb
Thank you a lot for your excellent explanation and statement, it helped me clearing up and better understand the situation now! Probably I begin with testing whether promotion and healing occur before or after the hook by calling Unit:GetDamage on those events
Code:
Events.LocalPlayerTurnBegin
Events.UnitPromoted
Events.LocalPlayerTurnEnd
and comparing for a heavily damaged unit far enough away from enemy units and Promotion available.

Depending on the results either Events.LocalPlayerTurnBegin & Events.UnitPromoted or
Events.UnitPromoted & Events.LocalPlayerTurnEnd are used then as pair in which first the unit damages are stored in a table and second the healing/damageDelta is set back (or just reduced). This applies only to the human Player, but maybe also the neglected barbarians get a bit care: small unconditional amount per turn.
---
Strangely the amount of health that is granted by promotion is not defined in GlobalParameters?

EXPERIENCE_PROMOTE_HEALED & EXPERIENCE_RETRAIN_HEALED define the amount of Experience that is gained by being healed. At least that worked in the beginning: #it was very annoying to try killing enemy units and thay get promoted very fast!!!# #changes I made to make the game enjoyable while constantly waging wars: UPDATE GlobalParameters SET Value = 25 WHERE Name="EXPERIENCE_PROMOTE_HEALED"#, but possibly not now #Since the Australia patch [...] several experience-related things in the Gameplay.xml file which no longer work. [...] <Row Name="EXPERIENCE_PROMOTE_HEALED" Value="100"/>#

Depending on tests perhaps also Experience has to be reduced for the human Player. If appropriate GlobalParameters.EXPERIENCE_PROMOTE_HEALED & EXPERIENCE_RETRAIN_HEALED should be increased for the AIplayers.

.
 
Last edited:
Top Bottom