Statistics: Posted by FunkOff — 18 Jan 2014, 17:38
Statistics: Posted by Ze_PilOt — 18 Jan 2014, 14:56
AddAutoRecall = function(self)
self.DoDeathWeapon = function(self)
local aiBrain = self:GetAIBrain()
aiBrain:OnAutoRecall()
self:PlayTeleportOutEffects()
self:CleanupTeleportChargeEffects()
self:StopUnitAmbientSound('TeleportLoop')
self:PlayUnitSound('TeleportEnd')
self:Destroy()
end
end,
AddAutoRecall = function(self)
self.DoTakeDamage = function(self, instigator, amount, vector, damageType)
local preAdjHealth = self:GetHealth()
self:AdjustHealth(instigator, -amount)
local health = self:GetHealth()
if( health <= 0 ) then
self:Recall()
return
elseif( damageType == 'Reclaimed' ) then
self:Destroy()
else
local excessDamageRatio = 0.0
# Calculate the excess damage amount
local excess = preAdjHealth - amount
local maxHealth = self:GetMaxHealth()
if(excess < 0 and maxHealth > 0) then
excessDamageRatio = -excess / maxHealth
end
self:Kill(instigator, damageType, excessDamageRatio)
end
end
if EntityCategoryContains(categories.COMMAND, self) then
local aiBrain = self:GetAIBrain()
if aiBrain then
aiBrain:OnPlayCommanderUnderAttackVO()
end
end
end,
self.Recall = function(self)
WARN('recalling')
SetInvincible(self, true)
self:HideBone(0, true)
self:PlayTeleportOutEffects()
self:StunAllMyArmyUnits()
Warp(self, self.SpawnPoint, self:GetOrientation())
WaitSeconds(2)
aiBrain:OnAutoRecall()
self:Destroy()
end,
Statistics: Posted by FunkOff — 16 Jan 2014, 05:08
DoTakeDamage = function(self, instigator, amount, vector, damageType)
WARN('acu take damage')
local preAdjHealth = self:GetHealth()
self:AdjustHealth(instigator, -amount)
local health = self:GetHealth()
if( health <= 0 ) then
if self:DoIHaveAnEnhancement() then
self:Recall()
return
elseif( damageType == 'Reclaimed' ) then
self:Destroy()
else
local excessDamageRatio = 0.0
# Calculate the excess damage amount
local excess = preAdjHealth - amount
local maxHealth = self:GetMaxHealth()
if(excess < 0 and maxHealth > 0) then
excessDamageRatio = -excess / maxHealth
end
self:Kill(instigator, damageType, excessDamageRatio)
end
end
if EntityCategoryContains(categories.COMMAND, self) then
local aiBrain = self:GetAIBrain()
if aiBrain then
aiBrain:OnPlayCommanderUnderAttackVO()
end
end
end,
##new for recall, lets me know if I have an enhancement
DoIHaveAnEnhancement = function(self)
WARN('DoIHaveanEnhancement')
local enh = self:GetBlueprint().Enhancements
if enh then
for k,v in enh do
if self:HasEnhancement(k) then
return true
end
end
end
end,
#recalls the commander
Recall = function(self)
WARN('recalling')
SetInvincible(self, true)
self:HideBone(0, true)
self:PlayTeleportOutEffects()
self:StunAllMyArmyUnits()
Warp(self, self.SpawnPoint, self:GetOrientation())
WaitSeconds(30)
self:ReSpawn()
end,
#stuns all the units in the army
StunAllMyArmyUnits = function(self)
WARN('stunning all my units')
local aiBrain = self:GetAIBrain()
local units = aiBrain:GetListOfUnits(categories.ALLUNITS - categories.WALL - categories.COMMAND, false)
for i,u in units do
u:SetStunned(30)
end
end,
ReSpawn = function(self)
WARN('respawning')
self:WarpInEffectThread()
local enh = self:WhatEnhancementsDoIHave()
local enhbp = self:GetBlueprint().Enhancements
for m,n in enhbp do
for o,p in enh do
if p.RemoveEnhancements and p.Prerequisite == m then
self:CreateEnhancement(p)
end
end
end
end,
WhatEnhancementsDoIHave = function(self)
WARN('whatenhancementdoIhave')
local enh = self:GetBlueprint().Enhancements
local TheOnesIHave = {}
if enh then
for k,v in enh do
if self:HasEnhancement(k) then
table.insert(TheOnesIHave, k)
end
end
end
return TheOnesIHave
end,
Statistics: Posted by FunkOff — 16 Jan 2014, 05:01