[GS] Is there a better way to reset a unit's turn?

Jakamo Jones

Chieftain
Joined
Sep 4, 2022
Messages
3
I had a simple requirement... I wanted to create a unit with some amount of XP and promotions already chosen. I had searched the forums but mostly just people saying it can't be done. After trying out a million things, I found the way to do it.

here's some pseudo code. for example if you wanted to level up a melee unit to have 50/90 XP and Battlecry + Commando:
-First you gotta give the unit 15 xp
Code:
myNewUnit:GetExperience():ChangeExperience(15)
-Then you simulate what the UI does to pick Battlecry
Code:
UnitManager.RequestComand(myNewUnit, UnitCommandTypes.PROMOTE, {UnitCommandTypes.PARAM_PROMOTION_TYPE = "BATTLECRY"})
-Then you give the unit another 30 xp (for a total of 45 now)
Code:
myNewUnit:GetExperience():ChangeExperience(30)
-Then you use UnitManager.RequestCommand to pick Commando
Code:
UnitManager.RequestComand(myNewUnit, UnitCommandTypes.PROMOTE, {UnitCommandTypes.PARAM_PROMOTION_TYPE = "COMMANDO"})
-And then finally top it off to get to 50
Code:
myNewUnit:GetExperience():ChangeExperience(5)

but bad news! Unless you're playing as Gran Colombia, the 2nd command will fail because your unit has already completed its turn!

So we need a way to reset a unit's turn... HEY I HAVE AN IDEA. I'll just spawn Hippolyta next to my new unit and activate her ability to restore movement.
Now I can pick Commando!



Feels really dumb though, has anybody else had luck with resetting a unit's turn from script?
 

Zegangani

King
Joined
Oct 9, 2020
Messages
830
If what you want is simply to grant a Promotion/Ability to a Unit then you can do that without all those many steps. Firetuner has a Unit Panel that can immediately give promotions to Units, without needing them to have the required XP, and the Promotions don't even need to be given in respect to their prereqs.

If you're not Familiar with Firetuner I'm sure there is a guide here somewhere that explains how you enable it and how it works.

Also, if you just want to "reset" a Unit's Turn, or rather grant it another one in the same turn as it doesn't redo the previous action, by restoring the Unit's Movement, the Unit can make another move (by that I mean any command/operation), even attack again. the only thing that I encountered that doesn't work for that, is when the Unit taps into a ZoC of an enemy Unit, where it can attack and do things countless times, but can't move out of the ZOC tile till the enemy Unit dies or till next turn.
 

Jakamo Jones

Chieftain
Joined
Sep 4, 2022
Messages
3
you can certainly just set promotions regardless of xp, but that ends up being a totally different outcome as the unit now gets more promotions just 15xp later.

and sadly restoring unit movement does not let a unit act again after giving it a promotion :sad:
 
Top Bottom