Statistics: Posted by Franck83 — 19 Jan 2017, 22:30
Statistics: Posted by Tanksy — 19 Jan 2017, 02:47
OnCreate = function(self)
AWalkingLandUnit.OnCreate(self)
self:SetCapturable(false)
self:SetWeaponEnabledByLabel('ChronoDampener', false)
self:SetupBuildBones()
self:HideBone('Back_Upgrade', true)
self:HideBone('Right_Upgrade', true)
self:HideBone('Left_Upgrade', true)
# Restrict what enhancements will enable later
self:AddBuildRestriction( categories.AEON * (categories.BUILTBYTIER2COMMANDER + categories.BUILTBYTIER3COMMANDER) )
self.HasAdvancedEngineering = false
end,
Weapons = {
DeathWeapon = Class(AIFCommanderDeathWeapon) {},
RightDisruptor = Class(ADFDisruptorCannonWeapon) {},
ChronoDampener = Class(ADFChronoDampener) {},
OverCharge = Class(ADFOverchargeWeapon) {
OnCreate = function(self)
ADFOverchargeWeapon.OnCreate(self)
self:SetWeaponEnabled(false)
self.AimControl:SetEnabled(false)
self.AimControl:SetPrecedence(0)
self.unit:SetOverchargePaused(false)
end,
Statistics: Posted by Franck83 — 11 Jan 2017, 00:02
Yes, the self is because unit is an instance of a class object. The self report to the unit itself. So if you wanna ref to a unit in unit.lua, you may use self. Sometimes you may refer to instigator which is the unit that deal the event (the instigator deal damages for example). Sometimes in others files, you will need to catch the unit (from id for example like in ui with GetUnitById(id)) then call it like this Unit:GetVeteranLevel().
Do I use self:GetVeteranLevel() inside the unit's script ?
Yes. You can find the affects in buff.lua. It can be MaxHealth, Regen, Damage, DamageRadius, MaxRadius, MoveMult, Stun, WeaponsEnable, VisionRadius, RadarRadius, OmniRadius, BuildRate, EnergyActive, MassActive, EnergyMaintenance, MassMaintenance, EnergyProduction, MassProduction, EnergyWeapon, RateOfFire.
Do you think it would be possible to specify the exact buffs a unit gets?
BuffBlueprint {
Name = 'MyBuff',
DisplayName = 'MyBuff',
BuffType = 'VETERANCYHEALTH', -- (you need to use VETERANCYHEALTH if you want to replace the current veterancy health buff. If you use another name, it will create another buff category that will stack with the other buffs)
Stacks = 'REPLACE',
Duration = -1,
Affects = {
MaxHealth = {
DoNoFill = true,
Add = 1000 * veteranLevel , -- 1000 per veterancy level
Mult = 1,
},
RateOfFire= {
DoNoFill = true,
Add = 0 ,
Mult = 1.5,
},
MaxRadius= {
DoNoFill = true,
Add =5 * veteranLevel ,
Mult =1,
},
},
}
Buff.ApplyBuff( self, 'MyBuff' )
Statistics: Posted by Franck83 — 10 Jan 2017, 23:43
Statistics: Posted by Tanksy — 10 Jan 2017, 20:52
Statistics: Posted by Sprouto — 10 Jan 2017, 20:46
Ideally I would like to have two separate veterancy systems
if table.find(bp.Categories,'COMMAND') then self:AddXP( your_commander_xp) end
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.
local veteranLevel= self:GetVeteranLevel()
BuffBlueprint {
Name = 'MyBuff',
DisplayName = 'MyBuff',
BuffType = 'VETERANCYHEALTH', -- (you need to use VETERANCYHEALTH if you want to replace the current veterancy health buff. If you use another name, it will create another buff category that will stack with the other buffs)
Stacks = 'REPLACE',
Duration = -1,
Affects = {
MaxHealth = {
DoNoFill = true,
Add = 1000 * veteranLevel , -- 1000 per veterancy level
Mult = 1,
},
},
}
Buff.ApplyBuff( self, 'MyBuff' )
self.Sync.xp = your_xp
self.xp
Statistics: Posted by Franck83 — 10 Jan 2017, 16:54
-- 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,
Statistics: Posted by Tanksy — 10 Jan 2017, 15:28