ForbodingAngel

Untitled

Mar 8th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  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. --------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment