Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Nov 1st, 2010  |  syntax: None  |  size: 1.87 KB  |  hits: 34  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -- $Id: unit_nofriendlyfire.lua 3171 2008-11-06 09:06:29Z det $
  2. --------------------------------------------------------------------------------
  3. --------------------------------------------------------------------------------
  4.  
  5. function gadget:GetInfo()
  6.   return {
  7.     name      = "No Friendly Fire",
  8.     desc      = "Adds the nofriendlyfire custom param",
  9.     author    = "quantum",
  10.     date      = "June 24, 2008",
  11.     license   = "GNU GPL, v2 or later",
  12.     layer     = 0,
  13.     enabled   = true  --  loaded by default?
  14.   }
  15. end
  16.  
  17. --------------------------------------------------------------------------------
  18. --------------------------------------------------------------------------------
  19.  
  20. if (not gadgetHandler:IsSyncedCode()) then
  21.   return false  --  silent removal
  22. end
  23.  
  24. --------------------------------------------------------------------------------
  25. --------------------------------------------------------------------------------
  26.  
  27. -- Automatically generated local definitions
  28.  
  29. local spAreTeamsAllied = Spring.AreTeamsAllied
  30. local spGetUnitHealth  = Spring.GetUnitHealth
  31. local spSetUnitHealth  = Spring.SetUnitHealth
  32.  
  33. --------------------------------------------------------------------------------
  34. --------------------------------------------------------------------------------
  35.  
  36.  
  37. function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer,
  38.                             weaponID, attackerID, attackerDefID, attackerTeam)
  39.   if (attackerDefID and
  40.       UnitDefs[attackerDefID].customParams and
  41.       UnitDefs[attackerDefID].customParams.nofriendlyfire and
  42.       attackerID ~= unitID and
  43.       spAreTeamsAllied(unitTeam, attackerTeam)) then
  44.         return 0
  45.   end
  46.   return damage
  47. end
  48.  
  49. --------------------------------------------------------------------------------
  50. --------------------------------------------------------------------------------