Guest User

Untitled

a guest
Apr 8th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. function widget:GetInfo()
  2. return {a
  3. name = "Area attack",
  4. version = "0.1",
  5. desc = "replace outdated unsynced engine area attack handling",
  6. author = "Pako",
  7. date = "2013.04.07 - 2013.04.09", --YYYY.MM.DD, created - updated
  8. license = "GPL", --Spring widgets should always be GPL compatible
  9. layer = 0, --higher layer is loaded last
  10. enabled = false -- loaded by default?
  11. }
  12. end
  13.  
  14. local CMD_AREA_ATTACK,CMD_ATTACK = CMD.AREA_ATTACK,CMD.ATTACK
  15. local gaiaTeam = Spring.GetGaiaTeamID()
  16.  
  17. function widget:CommandNotify(cmdId, cmdParams, cmdOpts)
  18. if cmdId == CMD_AREA_ATTACK or (cmdId == CMD_ATTACK and cmdParams[4] and cmdParams[4]~=0) then
  19. local enemyUnits = Spring.GetUnitsInCylinder( cmdParams[1], cmdParams[3], cmdParams[4], Spring.ENEMY_UNITS)
  20. local orders = {}
  21. local Spring_GetUnitTeam = Spring.GetUnitTeam
  22. for _,UnitID in pairs(enemyUnits) do
  23. if gaiaTeam ~= Spring_GetUnitTeam(UnitID) then
  24. orders[#orders+1] = {CMD_ATTACK, {UnitID}, {"shift"}}
  25. end
  26. end
  27. if #orders > 0 then
  28. orders[1][3] = cmdOpts
  29. local selUnits = Spring.GetSelectedUnits()
  30. Spring.GiveOrderArrayToUnitArray(selUnits,orders)
  31. end
  32. return true --always return true
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment