Crazy Cossack wrote:
However, if I want to make slightly more complicated changes I cannot do them yet. For example, I want to give the ACU a speed of 0 at start of game (can't move) and I think I can do that in the unit.bp by setting speed to 0. However, then I want to tie the (re-)gaining of the ability to walk to certain upgrades. For example, I would want the gun upgrade or the T2 upgrade of the ACU to give back to the ACU the ability to walk at standard speed. How and where would I add the conditional statement that "if T2 upgrade or Gun upgrade is done then set ACU walk speed to speed x "? Actually, I would go further than that and any ACU upgrade except the super cheap one like UEF drone would give the ACU back his normal walking speed.
You'll need to hook into some methods in the unit class, besides setting the walk speed to 0 in the bp.
One way to do it would be to hook the OnWorkEnd function.
It looks like this:
- Code:
OnWorkEnd = function(self, work)
--LOG('CreateEnhancement workEND:'..tostring(work))
self:SetActiveConsumptionInactive()
self:PlayUnitSound('EnhanceEnd')
self:StopUnitAmbientSound('EnhanceLoop')
self:CleanupEnhancementEffects()
end
You can check if your current unit is a commandunit like so:
- Code:
if EntityCategoryContains(categories.COMMAND, self) then
...
end
So you'd have something along the lines of
- Code:
OnWorkEnd = function(self, work)
if EntityCategoryContains(categories.COMMAND, self) and tostring(work) == 'enhancement-you-want' then
... update whatever values for the unit
end
end
I've omitted how to hook the function properly. See Myxirs post for that.
Someone who knows the intricasies of the engine may say that there is a better more moho-like way of doing this, but I haven't coded enough with it to know.
Hope this gets you started.
Perhaps this should be moved to a more appropriate forum.Statistics: Posted by Sheeo — 07 Jun 2014, 10:34
]]>