Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function widget:GetInfo()
- return {a
- name = "Area attack",
- version = "0.1",
- desc = "replace outdated unsynced engine area attack handling",
- author = "Pako",
- date = "2013.04.07 - 2013.04.09", --YYYY.MM.DD, created - updated
- license = "GPL", --Spring widgets should always be GPL compatible
- layer = 0, --higher layer is loaded last
- enabled = false -- loaded by default?
- }
- end
- local CMD_AREA_ATTACK,CMD_ATTACK = CMD.AREA_ATTACK,CMD.ATTACK
- local gaiaTeam = Spring.GetGaiaTeamID()
- function widget:CommandNotify(cmdId, cmdParams, cmdOpts)
- if cmdId == CMD_AREA_ATTACK or (cmdId == CMD_ATTACK and cmdParams[4] and cmdParams[4]~=0) then
- local enemyUnits = Spring.GetUnitsInCylinder( cmdParams[1], cmdParams[3], cmdParams[4], Spring.ENEMY_UNITS)
- local orders = {}
- local Spring_GetUnitTeam = Spring.GetUnitTeam
- for _,UnitID in pairs(enemyUnits) do
- if gaiaTeam ~= Spring_GetUnitTeam(UnitID) then
- orders[#orders+1] = {CMD_ATTACK, {UnitID}, {"shift"}}
- end
- end
- if #orders > 0 then
- orders[1][3] = cmdOpts
- local selUnits = Spring.GetSelectedUnits()
- Spring.GiveOrderArrayToUnitArray(selUnits,orders)
- end
- return true --always return true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment