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

Script: alert when ally is reclaiming other ally frames

22 posts, 886 views
Post comment
Filter:    Player:  
Page of 2 (22 records)
sort
I'd like to be alerted if there's someone on my team reclaiming ally build frames. It's 99% of the time sabotage of your own team to gain metal and goes unnoticed since the build effect looks so similar.

EDIT: I've made a script that does what I wanted https://zero-k.info/Forum/Post/251698#251698
+1 / -0
you know, there is a github page where you can create and discuss issues and/or find duplicates
+2 / -0

19 months ago
Is that something a widget could watch?
+0 / -0
19 months ago
But I can't get upvotes on github, how will I find meaning in life?
+1 / -0

19 months ago
upvotes dont matter. life is meaningless.
+0 / -0

19 months ago
+1 / -0
An hour of copy pasting and I've made a functional script that marks trolls.

function widget:GetInfo()
	return {
		name      = "Ally Troll Reclaim Alert",
		desc      = "",
		author    = "",
		date      = "",
		license   = "",
		layer     = 20,
		enabled   = true
	}
end

local gameID_to_playerName

function widget:Initialize()
	gameID_to_playerName = {}
	local teamList = Spring.GetTeamList() --//check teamIDlist for AI
	for j= 1, #teamList do
		local teamID = teamList[j]
		local _,playerID, _, isAI = Spring.GetTeamInfo(teamID, false)
		if isAI then
			local _, aiName = Spring.GetAIInfo(teamID)
			gameID_to_playerName[teamID] = "[AI]"..aiName
		elseif not isAI then
			local playerName = Spring.GetPlayerInfo(playerID, false)
			gameID_to_playerName[teamID] = playerName or "Gaia"
		end
	end
end

function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOpts, cmdTag)
	if (not Spring.ValidUnitID(unitID)) then
		return --invalid unit ID
	end

	if (cmdID ~= 90) then
		return --not reclaim command
	end
	
	if (type(cmdParams) ~= "table") then
		return --corrupted command parameters
	end
	
	if (cmdParams[2]) then
		return --more than 1 param: not targetID but actually X,Y,Z position for area-reclaim
	end
	
	local targetUnitID = cmdParams[1]
	if ((type(cmdParams[1]) ~= "number") or (not Spring.ValidUnitID(targetUnitID))) then
		return --invalid unit ID
	end
	
	local targetUnitTeamID = Spring.GetUnitTeam(targetUnitID)
	if (targetUnitTeamID == unitTeam) then
		return --target is on origin team
	end
	
	local health,maxHealth,paralyzeDamage,captureProgress,buildProgress = Spring.GetUnitHealth(targetUnitID)
	if ((type(buildProgress) ~= "number") or (buildProgress >= 1)) then
		return --not a unit frame
	end
	
	local originAllyTeamID = Spring.GetUnitAllyTeam(unitID)
	local targetUnitAllyTeamID = Spring.GetUnitAllyTeam(targetUnitID)
	
	if (originAllyTeamID ~= targetUnitAllyTeamID) then
		return --not allied
	end
	
	local perpetratorName = gameID_to_playerName[unitTeam]
	local victimName = gameID_to_playerName[targetUnitTeamID]
	
	local message = "ALERT: '"..perpetratorName.."' is attempting to reclaim property of '"..victimName.."'"
	
	local x,y,z = Spring.GetUnitPosition(unitID)
	Spring.MarkerAddPoint(x,y,z,perpetratorName,true)
	Spring.MarkerErasePosition(x,y,z)
	
	x,y,z = Spring.GetUnitPosition(targetUnitID)
	Spring.MarkerAddPoint(x,y,z,message,true)
	Spring.MarkerErasePosition(x,y,z)
end
+9 / -0
Sweet, that looks like it could work. Thats an excellent effort, I say.

Related: is it possible to create markers that only you see, or specific named players see?
+0 / -0
It only creates markers you can see according to documentation. Zero testing in a real game but it worked when I gifted to AI and tried reclaiming it. I don't know how to check if a unit order is "valid", that is whether the target is a frame and not a finished building (which would be an invalid order that never executes) so it might display some false positives.

I've now tested it on a replay https://zero-k.info/Battles/Detail/1426584 and it has detected multiple instances where RUranklKomandante sneakily reclaims ally unit frames inside factories. I think it's working fine.
+0 / -0

19 months ago
Ah yes, one or more personal weaknesses caused me to not look up the docs:

https://springrts.com/wiki/Lua_UnsyncedCtrl#MarkerAddPoint

That final parameter seems to switch between local and networked handling:

https://github.com/spring/spring/blob/a8cf33ad1d2ac775e6008cd04baa7e859d1f23ec/rts/Lua/LuaUnsyncedCtrl.cpp#L2698

So there it is, your widget will at least not annoy anyone if there is a problem with it.
+0 / -0
quote:
I don't know how to check if a unit order is "valid", that is whether the target is a frame and not a finished building

GetUnitHealth returns a tuple which includes buildProgress. Anything below 1 is a nanoframe.
+0 / -0
Thanks added that check, shouldn't have false positives now. It marks when the order is issued though, not when it's initiated. Probably hard to convince a team that someone is about to reclaim something before it's actually happening, but the queued order should be visible to all.

If anyone cares, I claim no ownership of this script and it can be freely licensed into the game/modified by whoever wants.
+1 / -0
Since it's so easy to detect this, and it is only ever done by trolls to steal from team, it should be prevented from happening at all. There's no valid reason to ever start reclaiming what an ally is building inside their factory.

Just don't allow the command to be issued.
+1 / -0


19 months ago
The thing that disallows reclaiming allies is already an engine option. I would rather have that option extended than mess about with command blocking.
+0 / -0
19 months ago
Perfect is the enemy of good, it can be a temporary measure to block malicious commands until the feature you mentioned catches up.
+0 / -0

19 months ago
Perfect is the enemy of good can equally be applied to the urgency of the fix, in light of your ability (or other users of the widget) to catch perps in the act. I assume anyway that people who get caught will think twice about doing it again.
+0 / -1
19 months ago
Punishing people is not the goal, it's the most destructive bandaid on an issue that can be easily prevented.
+1 / -0


19 months ago
I'd accept a decent pull request.
+0 / -0
I'm seeing false positives when someone issues an area reclaim order of some sort, assuming centered on a unit. I don't know why it's happening. It detected DErankkatastrophe trying to reclaim GBrankSab in https://zero-k.info/Battles/Detail/1487169 but the units had no such orders when I checked, they were reclaiming wrecks.
+0 / -0

16 months ago
	if cmdParams[2] then
		return -- more than 1 param: not targetID but actually X,Y,Z position for area-reclaim
	end

	local targetUnitID = cmdParams[1]
	if ((type(cmdParams[1]) ~= "number") or (not Spring.ValidUnitID(targetUnitID))) then
		return --invalid unit ID
	end
+1 / -0
Page of 2 (22 records)