I've just tried to do your stuff : being able to upgrade structure to level 2 with a button AND/OR earning XP when buying units to level up. With a choice for the different prices for that.
On the vanilla, there is the only thing you have to do :
In the GoblinCave, you have this behavior :
Behavior = ProductionUpdate ProductionUpdateModuleTag ConstructionCompleteDuration = 250 ;in mSeconds wait time so if you have multiple units they don't run over each other VeteranUnitsFromVeteranFactory = No ;I am higher than my default level, I will give a free level to those I produce GiveNoXP = Yes ;trying to disable granting xp when producing units. BonusForType = GoblinFighterHorde SetBonusModelConditionOnSpeedBonus = Yes ; set the UPGRADE_ECONOMY_BONUS if there is any production bonus End
You only have to set "GiveNoXP" from "Yes" to "No" to activate the fact that producing unit will give XP to the structure.
After that, all is working.
For example I tried that :
In gamedata :
#define GOBLIN_CAVE_LVL2_EXP_NEEDED 200 ;;2400 #define GOBLIN_CAVE_LVL3_EXP_NEEDED 400 ;;4800By default :
- GoblinFighter cost 80
- GoblinArcher cost 250
- upgrading from level 1 to 2 cost 100.
-> After that I tested this on a GoblinCave:
I bought 3 GoblinFighter to level up to level 2 (3 x 80 = 240 > 200 needed), and 2 GoblinFighter to level up to level 3 (2 x 80 = 160 + 240 = 400 = 400 needed).
Finally I spent 400 to have a Goblin cave level 3.
-> And I tested that too on another GoblinCave:
I bought the upgrade to level 2, and I bought 2 GoblinArchers to level up to level 3 (250 + 250 = 500 > 400 needed).
Here I spent 600 to have a Goblin cave level 3.
I didn't have to change anything like CommandSetUpgrade, ExperienceLevels.INI or LevelUpUpgrade. ONLY WHAT I SAID.
I hope it will work good for you.