I'm still slowly tinkering away at modifying SupCom and I've come up with some rough ideas when thinking about unit veterancy. Ideally I would like to have two separate veterancy systems -- One for Comms, one for other Units. So far I've started by looking into the mod "Experimental Wars" and seeing how the author made use of BuffBlueprints to alter units when they reached a certain Veterancy. This mod also allows units to upgrade into different units upon certain veterancy levels -- something I wish to also incorporate into my own modifications, but done in a different manner.
His code however is.. Difficult to understand, being commented in French -- It also looks a little sloppy, so I've been writing my own following his style.
On a unit's Blueprint, I've added a section called "VetBonus", inside VetBonus is simply an entry that says "Enabled = true". In the unit's script, I check to see if vetBonus.enabled = true and then perform buffs depending on what the unit's current Veterancy level is. Below is my code. The function "OnVeteran" is used in Experimental Wars, called from the unit's "OnStopBeingBuilt" function using a callback "self:AddUnitCallback(self.OnVeteran, 'OnVeteran')" -- I'm unsure if vanilla units have this or if it's been added by the author of Experimental Wars, but I'm going to use it here because "It worked for him" (Unless there's a better way)
The unit has 14000 starting health, and as an example to see if this system would work I wanted the unit to simply gain 1000, 2000, 3000, 4000 or 5000 health based on his Veterancy level.
- Code: Select all
-- Tanksy's version of ExpWars' "OnVeteran" function
OnVeteran = function(self)
-- Get blueprint
local bp = self:GetBlueprint()
-- Get vet level
local vetLevel = self.VeteranLevel
-- Get vetBonus
local bpVetBonus = bp.Enabled
-- If no vetBonus in bp or disabled
if bpVetBonus != true then return end
if vetLevel == 1 then
BuffBlueprint {
Name = 'VetBuff',
DisplayName = 'VetBuff',
BuffType = 'MAXHEALTH',
Stacks = 'REPLACE',
Duration = -1,
Affects = {
MaxHealth = {
Add = 1000,
Mult = 1.0,
},
},
}
elseif vetLevel == 2 then
BuffBlueprint {
Name = 'VetBuff',
DisplayName = 'VetBuff',
BuffType = 'MAXHEALTH',
Stacks = 'REPLACE',
Duration = -1,
Affects = {
MaxHealth = {
Add = 2000,
Mult = 1.0,
},
},
}
elseif vetLevel == 3 then
BuffBlueprint {
Name = 'VetBuff',
DisplayName = 'VetBuff',
BuffType = 'MAXHEALTH',
Stacks = 'REPLACE',
Duration = -1,
Affects = {
MaxHealth = {
Add = 3000,
Mult = 1.0,
},
},
}
elseif vetLevel == 4 then
BuffBlueprint {
Name = 'VetBuff',
DisplayName = 'VetBuff',
BuffType = 'MAXHEALTH',
Stacks = 'REPLACE',
Duration = -1,
Affects = {
MaxHealth = {
Add = 4000,
Mult = 1.0,
},
},
}
elseif vetLevel == 5 then
BuffBlueprint {
Name = 'VetBuff',
DisplayName = 'VetBuff',
BuffType = 'MAXHEALTH',
Stacks = 'REPLACE',
Duration = -1,
Affects = {
MaxHealth = {
Add = 5000,
Mult = 1.0,
},
},
}
end
-- Apply buff
Buff.ApplyBuff(self, 'VetBuff')
-- End function
end,
I'm not entirely positive that this works, and I would like some advice, and really any information that anyone knows about BuffBlueprints and how they work and how to use them. I also have a rough idea of how I can "Turn off" the vanilla veterancy bonuses by overwriting their Buffblueprints, but I'm not sure if this would be a good idea or if there's a way I can simply set those buffs to only affect a specific unit by hooking into them, avoiding the overwrite.