(FAF_OKC) How to add useful data to damageTable w/ download

Talk about general things concerning Forged Alliance Forever.

Moderators: FtXCommando, Ze Dogfather

(FAF_OKC) How to add useful data to damageTable w/ download

Postby Resin_Smoker » 19 Feb 2014, 18:36

Weapon.lua

The below script populates the projectiles damageData table with info pulled from the attacker and it's weapon:

Code: Select all
   GetDamageTable = function(self)
      local myDebug = false   
      local damageTable = oldWeapon.GetDamageTable(self)

      if self and self.unit then
         --> Add Instigator info into damageTable so this is later passed to projectile      
         damageTable.Instigator = {}
         local unit_bp = self.unit:GetBlueprint()
         damageTable.Instigator.Army = self.unit:GetArmy() or ''
         damageTable.Instigator.Categories = unit_bp.Categories or ''         
         damageTable.Instigator.Description = unit_bp.Description or ''         
         damageTable.Instigator.EntityId = self.unit:GetEntityId() or ''
         damageTable.Instigator.GameTime = GetGameTimeSeconds()         
         damageTable.Instigator.Location = self.unit:GetPosition() or ''
         damageTable.Instigator.UnitName = unit_bp.General.UnitName or ''
         --> Add current target into damageTable so this is later passed to projectile         
         damageTable.Target = {}
         local target = self:GetCurrentTarget()
         if target and IsUnit(target) then
            local target_bp = target:GetBlueprint()
            damageTable.Target.Army = target:GetArmy() or ''
            damageTable.Target.EntityId = target:GetEntityId() or ''
            damageTable.Target.Description = target_bp.Description or ''
            damageTable.Target.Location = target:GetPosition() or ''
            damageTable.Target.UnitName = target_bp.General.UnitName or ''            
         end
         --> Add Weapon info into damageTable so this is later passed to projectile            
         damageTable.Weapon = {}         
         damageTable.Weapon.DisplayName = self:GetBlueprint().DisplayName or ''
         damageTable.Weapon.Label = self:GetBlueprint().Label or ''                                    
         damageTable.Weapon.MaxRadius = self:GetBlueprint().MaxRadius or ''
         damageTable.Weapon.MinRadius = self:GetBlueprint().MinRadius or ''         
         damageTable.Weapon.MuzzleVelocity = self:GetBlueprint().MuzzleVelocity or ''
         damageTable.Weapon.ProjectileId = self:GetBlueprint().ProjectileId or ''
         damageTable.Weapon.ProjectileLifetime = self:GetBlueprint().ProjectileLifetime or ''                           
         damageTable.Weapon.TargetPriorities = self:GetBlueprint().TargetPriorities or ''                           
         if myDebug or masterDebug then
            LOG('*** weapon.lua, GetDamageTable, Contents of damageTable to later pass to projectile***')
            LOG('   ', repr(damageTable) )
         end
      end
      return damageTable
   end,
Last edited by Resin_Smoker on 22 Feb 2014, 07:53, edited 7 times in total.
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: How to add useful data to damageTable

Postby Resin_Smoker » 19 Feb 2014, 18:38

Projectile.lua

This passes the new data to the projectile. Please note it is 100% possible to pass all this data to a unit or script to do some truly really awesome things.

Resin

Code: Select all
-------------------------------------------------------------------------------------------
--  File     :  /lua/weapon.lua
--  Modded by:  Resin_Smoker
--  Summary  :  Populates the projectiles damageData table with info pulled from the attacker and it's weapon   
--  Copyright © 2014 Gas Powered Games, Inc.  All rights reserved.
------------------------------------------------------------------------------------------

do

--> Triggers all logs to report if flag set true, otherwise use the local flags within each function for specific outputs
local masterDebug = false

local oldWeapon = Weapon
Weapon = Class(oldWeapon) {
   
   GetDamageTable = function(self)
      local myDebug = false
      --> run old   GetDamageTable and pass to our new table
      local damageTable = oldWeapon.GetDamageTable(self)

      if self and self.unit then
         --> Add Instigator info into damageTable so this is later passed to projectile      
         damageTable.Instigator = {}
         local unit_bp = self.unit:GetBlueprint()
         damageTable.Instigator.Army = self.unit:GetArmy() or ''
         damageTable.Instigator.Categories = unit_bp.Categories or ''         
         damageTable.Instigator.Description = unit_bp.Description or ''         
         damageTable.Instigator.EntityId = self.unit:GetEntityId() or ''
         damageTable.Instigator.GameTime = GetGameTimeSeconds()         
         damageTable.Instigator.Location = self.unit:GetPosition() or ''
         damageTable.Instigator.UnitName = unit_bp.General.UnitName or ''
         --> Add current target into damageTable so this is later passed to projectile         
         damageTable.Target = {}
         local target = self:GetCurrentTarget()
         if target and IsUnit(target) then
            local target_bp = target:GetBlueprint()
            damageTable.Target.Army = target:GetArmy() or ''
            damageTable.Target.Categories = target_bp.Categories or ''            
            damageTable.Target.EntityId = target:GetEntityId() or ''
            damageTable.Target.Description = target_bp.Description or ''
            damageTable.Target.Location = target:GetPosition() or ''
            damageTable.Target.UnitName = target_bp.General.UnitName or ''            
         end
         --> Add Weapon info into damageTable so this is later passed to projectile            
         damageTable.Weapon = {}
         local weapon_bp = self:GetBlueprint()
         damageTable.Weapon.DisplayName = weapon_bp.DisplayName or ''
         damageTable.Weapon.Label = weapon_bp.Label or ''                                    
         damageTable.Weapon.MaxRadius = weapon_bp.MaxRadius or 1
         damageTable.Weapon.MinRadius = weapon_bp.MinRadius or 0         
         damageTable.Weapon.MuzzleVelocity = weapon_bp.MuzzleVelocity or ''
         damageTable.Weapon.NukeWeapon = weapon_bp.NukeWeapon or false
         damageTable.Weapon.OKC_Retargeting = weapon_bp.OKC_Retargeting or false
         damageTable.Weapon.ProjectileId = weapon_bp.ProjectileId or ''
         damageTable.Weapon.ProjectileLifetime = weapon_bp.ProjectileLifetime or 0
         damageTable.Weapon.ProjectileLifetimeUsesMultiplier   = weapon_bp.ProjectileLifetimeUsesMultiplier or 0
         damageTable.Weapon.TargetPriorities = weapon_bp.TargetPriorities or ''                           
         if myDebug or masterDebug then
            LOG('*** weapon.lua, GetDamageTable, Contents of damageTable to later pass to projectile***')
            LOG('   ', repr(damageTable) )
         end
      end
      return damageTable
   end,     
     
}
end
Last edited by Resin_Smoker on 20 Feb 2014, 20:04, edited 2 times in total.
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: How to add useful data to damageTable

Postby Resin_Smoker » 19 Feb 2014, 18:48

This is what the damagetable looks like when "repr" is used...

Code: Select all
INFO: *** weapon.lua, GetDamageTable, Contents of damageTable to later pass to projectile***
INFO:         \000{
INFO:   Instigator={
INFO:     Army=1,
INFO:     Categories={
INFO:       "PRODUCTSC1",
INFO:       "SELECTABLE",
INFO:       "UEF",
INFO:       "MOBILE",
INFO:       "ECONOMIC",
INFO:       "COMMAND",
INFO:       "MASSPRODUCTION",
INFO:       "MASSFABRICATION",
INFO:       "ENERGYPRODUCTION",
INFO:       "REPAIR",
INFO:       "ENGINEER",
INFO:       "CONSTRUCTION",
INFO:       "RECLAIM",
INFO:       "CAPTURE",
INFO:       "DIRECTFIRE",
INFO:       "PODSTAGINGPLATFORM",
INFO:       "SILO",
INFO:       "VERIFYMISSILEUI",
INFO:       "LAND",
INFO:       "VISIBLETORECON",
INFO:       "PATROLHELPER",
INFO:       "SHOWQUEUE",
INFO:       "OVERLAYDIRECTFIRE",
INFO:       "OVERLAYINDIRECTFIRE",
INFO:       "OVERLAYOMNI",
INFO:       "OVERLAYDEFENSE"
INFO:     },
INFO:     Description="<LOC uel0001_desc>Armored Command Unit",
INFO:     EntityId="0",
INFO:     GameTime=20.200000762939,
INFO:     Location={ <metatable=table: 1D46F3E8> 148.5, 20.71044921875, 353.5 },
INFO:     UnitName=""
INFO:   },
INFO:   Target={
INFO:     Army=2,
INFO:     Categories={
INFO:       "PRODUCTSC1",
INFO:       "SELECTABLE",
INFO:       "BUILTBYTIER1FACTORY",
INFO:       "BUILTBYTIER2FACTORY",
INFO:       "BUILTBYTIER3FACTORY",
INFO:       "CYBRAN",
INFO:       "MOBILE",
INFO:       "LAND",
INFO:       "TECH1",
INFO:       "SCOUT",
INFO:       "INTELLIGENCE",
INFO:       "RADAR",
INFO:       "VISIBLETORECON",
INFO:       "RECLAIMABLE",
INFO:       "OVERLAYRADAR"
INFO:     },
INFO:     Description="<LOC url0101_desc>Land Scout",
INFO:     EntityId="1048584",
INFO:     Location={ <metatable=table: 1D46F3E8> 140.5, 20.69140625, 352.5 },
INFO:     UnitName="<LOC url0101_name>Mole"
INFO:   },
INFO:   Weapon={
INFO:     DisplayName="Zephyr Anti Matter Cannon",
INFO:     Label="RightZephyr",
INFO:     MaxRadius=22,
INFO:     MinRadius=1,
INFO:     MuzzleVelocity=35,
INFO:     NukeWeapon=false,
INFO:     OKC_Retargeting=false,
INFO:     ProjectileId="/projectiles/laserbotterran01/laserbotterran01_proj.bp",
INFO:     ProjectileLifetime=0,
INFO:     ProjectileLifetimeUsesMultiplier=2,
INFO:     TargetPriorities={
INFO:       "SPECIALHIGHPRI",
INFO:       "MOBILE",
INFO:       "STRUCTURE DEFENSE",
INFO:       "SPECIALLOWPRI",
INFO:       "ALLUNITS"
INFO:     }
INFO:   }
INFO: }


Enjoy!

Resin
Last edited by Resin_Smoker on 20 Feb 2014, 20:05, edited 2 times in total.
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: How to add useful data to damageTable

Postby IceDreamer » 19 Feb 2014, 18:57

When you say truly really awesome things... What kind of things?

Also mate, if I can persuade pip and Brute51 to give some Nomads units your funky black hole explosions and weight of fire, is that OK with you?
IceDreamer
Supreme Commander
 
Posts: 2607
Joined: 27 Dec 2011, 07:01
Has liked: 138 times
Been liked: 488 times

Re: How to add useful data to damageTable

Postby Resin_Smoker » 19 Feb 2014, 19:03

IceDreamer wrote:When you say truly really awesome things... What kind of things?

Also mate, if I can persuade pip and Brute51 to give some Nomads units your funky black hole explosions and weight of fire, is that OK with you?


Well if you know who shot you and all the data of the attacker and the projectile you can...

-Reflect a projectile
-Redirect a projectile in flight
-Assign a new target to a projectile in flight
-Add effects to existing events
-Pass kills to add veterancy
-Change who gets credit and veterancy for a kill
-Keep track of who attacked last and have the defending unit counter attack

Those are just a few things but honestly there is no real limit to this sorta thing...

As for WOF... you can play with it but I'd rather it be a stand alone mod as not everyone may like it.

BTW: Brute51 was one of the major contributors on WOF and as such can work wonders with that script. The script I've just posted could make is work a whole lot easier too boot!

Resin
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: How to add useful data to damageTable

Postby Plasma_Wolf » 19 Feb 2014, 19:06

How exactly do you mean "pass kills to add veterancy"?

We're using kill counters to add vet, are you suggesting now that you can directly use a damage counter instead of a kill counter?
User avatar
Plasma_Wolf
Supreme Commander
 
Posts: 1335
Joined: 20 Oct 2011, 11:28
Has liked: 23 times
Been liked: 91 times
FAF User Name: Plasma_Wolf

Re: How to add useful data to damageTable

Postby Exotic_Retard » 19 Feb 2014, 19:08

Resin_Smoker wrote:-Assign a new target to a projectile in flight


this... and t3 AA overkilling...
i think someones found a solution
User avatar
Exotic_Retard
Contributor
 
Posts: 1470
Joined: 21 Mar 2013, 22:51
Has liked: 557 times
Been liked: 626 times
FAF User Name: Exotic_Retard

Re: How to add useful data to damageTable

Postby Resin_Smoker » 19 Feb 2014, 19:17

Plasma_Wolf wrote:How exactly do you mean "pass kills to add veterancy"?

We're using kill counters to add vet, are you suggesting now that you can directly use a damage counter instead of a kill counter?


I can script anything i want pretty much...

But what i was refering to is "who" did the damage and that unit gets credit for the kills. Granted I'd have to mod OnDamage to pass this new instigator but the tools to do this are here.

Resin
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Re: How to add useful data to damageTable

Postby IceDreamer » 19 Feb 2014, 19:19

Resin, if you feel like it the most urgent use for this code is what SAKO_X pointed out - Making SAMs no longer overkill. If you can do that, we're in business :p
IceDreamer
Supreme Commander
 
Posts: 2607
Joined: 27 Dec 2011, 07:01
Has liked: 138 times
Been liked: 488 times

Re: How to add useful data to damageTable

Postby burnstreet » 19 Feb 2014, 19:31

There is already a mod doing that, Ultimate Overkill Control. Don't know if it uses the mechanics described here.
burnstreet
Crusader
 
Posts: 36
Joined: 23 Mar 2013, 00:36
Has liked: 2 times
Been liked: 3 times
FAF User Name: Burnstreet

Next

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest