Loading...
  OR  Zero-K Name:    Password:   

Post edit history

Script: alert when ally is reclaiming other ally frames

To display differences between versions, select one or more edits in the list using checkboxes and click "diff selected"
Post edit history
Date Editor Before After
11/4/2022 10:30:48 PMunknownrankTinySpider before revert after revert
11/4/2022 10:29:09 PMunknownrankTinySpider before revert after revert
8/11/2022 3:38:46 PMunknownrankTinySpider before revert after revert
Before After
1 An hour of copy pasting and I've made a functional script that marks trolls. 1 An hour of copy pasting and I've made a functional script that marks trolls.
2 \n 2 \n
3 {{{function widget:GetInfo() 3 {{{function widget:GetInfo()
4 return { 4 return {
5 name = "Ally Troll Reclaim Alert", 5 name = "Ally Troll Reclaim Alert",
6 desc = "", 6 desc = "",
7 author = "", 7 author = "",
8 date = "", 8 date = "",
9 license = "", 9 license = "",
10 layer = 20, 10 layer = 20,
11 enabled = true 11 enabled = true
12 } 12 }
13 end 13 end
14 \n 14 \n
15 local gameID_to_playerName 15 local gameID_to_playerName
16 \n 16 \n
17 function widget:Initialize() 17 function widget:Initialize()
18 gameID_to_playerName = {} 18 gameID_to_playerName = {}
19 local teamList = Spring.GetTeamList() --//check teamIDlist for AI 19 local teamList = Spring.GetTeamList() --//check teamIDlist for AI
20 for j= 1, #teamList do 20 for j= 1, #teamList do
21 local teamID = teamList[j] 21 local teamID = teamList[j]
22 local _,playerID, _, isAI = Spring.GetTeamInfo(teamID, false) 22 local _,playerID, _, isAI = Spring.GetTeamInfo(teamID, false)
23 if isAI then 23 if isAI then
24 local _, aiName = Spring.GetAIInfo(teamID) 24 local _, aiName = Spring.GetAIInfo(teamID)
25 gameID_to_playerName[teamID] = "[AI]"..aiName 25 gameID_to_playerName[teamID] = "[AI]"..aiName
26 elseif not isAI then 26 elseif not isAI then
27 local playerName = Spring.GetPlayerInfo(playerID, false) 27 local playerName = Spring.GetPlayerInfo(playerID, false)
28 gameID_to_playerName[teamID] = playerName or "Gaia" 28 gameID_to_playerName[teamID] = playerName or "Gaia"
29 end 29 end
30 end 30 end
31 end 31 end
32 \n 32 \n
33 function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOpts, cmdTag) 33 function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOpts, cmdTag)
34 if (not Spring.ValidUnitID(unitID)) then 34 if (not Spring.ValidUnitID(unitID)) then
35 return --invalid unit ID 35 return --invalid unit ID
36 end 36 end
37 \n 37 \n
38 if (cmdID ~= 90) then 38 if (cmdID ~= 90) then
39 return --not reclaim command 39 return --not reclaim command
40 end 40 end
41 41
42 if (type(cmdParams) ~= "table") then 42 if (type(cmdParams) ~= "table") then
43 return --corrupted command parameters 43 return --corrupted command parameters
44 end 44 end
45 45
46 if (cmdParams[2]) then
47 return --more than 1 param: not targetID but actually X,Y,Z position for area-reclaim
48 end
49
46 local targetUnitID = cmdParams[1] 50 local targetUnitID = cmdParams[1]
47 if ((type(cmdParams[1]) ~= "number") or (not Spring.ValidUnitID(targetUnitID))) then 51 if ((type(cmdParams[1]) ~= "number") or (not Spring.ValidUnitID(targetUnitID))) then
48 return --invalid unit ID 52 return --invalid unit ID
49 end
50
51 if (cmdParams[2]) then
52 return --more than 1 param: not targetID but actually X,Y,Z position for area-reclaim
53 end 53 end
54 54
55 local targetUnitTeamID = Spring.GetUnitTeam(targetUnitID) 55 local targetUnitTeamID = Spring.GetUnitTeam(targetUnitID)
56 if (targetUnitTeamID == unitTeam) then 56 if (targetUnitTeamID == unitTeam) then
57 return --target is on origin team 57 return --target is on origin team
58 end 58 end
59 59
60 local health,maxHealth,paralyzeDamage,captureProgress,buildProgress = Spring.GetUnitHealth(targetUnitID) 60 local health,maxHealth,paralyzeDamage,captureProgress,buildProgress = Spring.GetUnitHealth(targetUnitID)
61 if ((type(buildProgress) ~= "number") or (buildProgress >= 1)) then 61 if ((type(buildProgress) ~= "number") or (buildProgress >= 1)) then
62 return --not a unit frame 62 return --not a unit frame
63 end 63 end
64 64
65 local originAllyTeamID = Spring.GetUnitAllyTeam(unitID) 65 local originAllyTeamID = Spring.GetUnitAllyTeam(unitID)
66 local targetUnitAllyTeamID = Spring.GetUnitAllyTeam(targetUnitID) 66 local targetUnitAllyTeamID = Spring.GetUnitAllyTeam(targetUnitID)
67 67
68 if (originAllyTeamID ~= targetUnitAllyTeamID) then 68 if (originAllyTeamID ~= targetUnitAllyTeamID) then
69 return --not allied 69 return --not allied
70 end 70 end
71 71
72 local perpetratorName = gameID_to_playerName[unitTeam] 72 local perpetratorName = gameID_to_playerName[unitTeam]
73 local victimName = gameID_to_playerName[targetUnitTeamID] 73 local victimName = gameID_to_playerName[targetUnitTeamID]
74 74
75 local message = "ALERT: '"..perpetratorName.."' is attempting to reclaim property of '"..victimName.."'" 75 local message = "ALERT: '"..perpetratorName.."' is attempting to reclaim property of '"..victimName.."'"
76 76
77 local x,y,z = Spring.GetUnitPosition(unitID) 77 local x,y,z = Spring.GetUnitPosition(unitID)
78 Spring.MarkerAddPoint(x,y,z,perpetratorName,true) 78 Spring.MarkerAddPoint(x,y,z,perpetratorName,true)
79 Spring.MarkerErasePosition(x,y,z) 79 Spring.MarkerErasePosition(x,y,z)
80 80
81 x,y,z = Spring.GetUnitPosition(targetUnitID) 81 x,y,z = Spring.GetUnitPosition(targetUnitID)
82 Spring.MarkerAddPoint(x,y,z,message,true) 82 Spring.MarkerAddPoint(x,y,z,message,true)
83 Spring.MarkerErasePosition(x,y,z) 83 Spring.MarkerErasePosition(x,y,z)
84 end}}} 84 end}}}