Forged Alliance Forever Forged Alliance Forever Forums 2014-01-18T17:38:53+02:00 /feed.php?f=50&t=6316 2014-01-18T17:38:53+02:00 2014-01-18T17:38:53+02:00 /viewtopic.php?t=6316&p=62554#p62554 <![CDATA[Re: Auto-recall works wierd in-game]]>
self:PlayTeleportOutEffects()

It makes a cool little teleport out effect

Statistics: Posted by FunkOff — 18 Jan 2014, 17:38


]]>
2014-01-18T14:56:13+02:00 2014-01-18T14:56:13+02:00 /viewtopic.php?t=6316&p=62535#p62535 <![CDATA[Re: Auto-recall works wierd in-game]]>

New update should not play the death weapon anymore.

Statistics: Posted by Ze_PilOt — 18 Jan 2014, 14:56


]]>
2014-01-17T19:12:39+02:00 2014-01-17T19:12:39+02:00 /viewtopic.php?t=6316&p=62435#p62435 <![CDATA[Re: Auto-recall works wierd in-game]]> Statistics: Posted by FunkOff — 17 Jan 2014, 19:12


]]>
2014-01-16T05:08:10+02:00 2014-01-16T05:08:10+02:00 /viewtopic.php?t=6316&p=62240#p62240 <![CDATA[Re: Auto-recall works wierd in-game]]>
Code:
    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,


The teleport out effects look dumb and the death noise plays because this mods the death weapon, which is dumb lol.

Instead, do this:
Code:
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,
   


This code will give the game 2 seconds to process the teleportation effects and will NOT activate the death weapon. The ACU will be returned to the spawn point for 2 seconds, but will be invisible and invincible and players won't notice.

Statistics: Posted by FunkOff — 16 Jan 2014, 05:08


]]>
2014-01-16T05:01:40+02:00 2014-01-16T05:01:40+02:00 /viewtopic.php?t=6316&p=62238#p62238 <![CDATA[Auto-recall works wierd in-game]]>
Here's the code I used in my "Recall enabled" mod which recalled the ACU in a more smooth way. This code amends the DoTakeDamage function of the ACU unit.

Code:
    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,


Here are the other functions that the function above calls.
Code:
   
   ##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,
   


Note that my mod only recalled ACUs that had upgrades/enhancements. You should mess with the code slightly and make it so upgrades are not required to recall. You can put the script anywhere using this format: ACUUnit.DoTakeDamage = ModifiedFunction(args) so that only the ACUs with the recall item purchased will have the recall ability.

Statistics: Posted by FunkOff — 16 Jan 2014, 05:01


]]>