Help adding exclusion list to game_controlVictory.lua

Help adding exclusion list to game_controlVictory.lua

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Help adding exclusion list to game_controlVictory.lua

Post by Forboding Angel »

https://github.com/EvolutionRTS/Evoluti ... y.lua#L142

At this line is where it looks for unit inside the points. I need to be able to define a list of units that are unable to initiate capture. At the moment I intend to make it so that air units cannot capture, which could be done by simply checking for canfly, but with a list of units, that is in the end a lot more robust and futureproof. Can someone help me add this functionality?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Help adding exclusion list to game_controlVictory.lua

Post by FLOZi »

https://github.com/SpringMCLegacy/Sprin ... r.lua#L234

+

Code: Select all

local ignored = {"foo" = true, "bar" = true}

	for unitDefID, ud in pairs(UnitDefs) do -- cache ignored unitDefIDs
		if ignored[ud.name] then
			unitDefsToIgnore[unitDefID] = true
		end
	end
Not the most elegant solution just cobbling together from what I have laying around already
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Help adding exclusion list to game_controlVictory.lua

Post by Forboding Angel »

Unfortunately, I don't know how to apply this. I did try by putting the get units in cylinder loop inside the loop checking for ignored unitdefs. My thinking was that we could check for ignored unitdefs and then just not do the unitsincylinder check at all if the units were in the list. However, that made things worse, not better. And thinking about it, that logic wouldn't make sense anyway.

Can you be a bit more explicit?

edit: I just pushed the file with fixed indentation. Kdr's weird indentation was driving me crazy.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Help adding exclusion list to game_controlVictory.lua

Post by FLOZi »

My function removes unwanted units from the result you get from unitsincylinder, so, in brief.

1. demUnits = GetUnitsInCylinder(blah)
2. StripUnits(demUnits)
3. do WhateverYouWantedDemUnitsFor()

See here onwards: https://github.com/SpringMCLegacy/Sprin ... r.lua#L323
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Help adding exclusion list to game_controlVictory.lua

Post by zwzsg »

Forboding Angel wrote:which could be done by simply checking for canfly, but with a list of units, that is in the end a lot more robust and futureproof
I'd say checking for canfly is the more robust and futureproof way, compared to listing unitdefs! :wink:
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Help adding exclusion list to game_controlVictory.lua

Post by Forboding Angel »

zwzsg wrote:
Forboding Angel wrote:which could be done by simply checking for canfly, but with a list of units, that is in the end a lot more robust and futureproof
I'd say checking for canfly is the more robust and futureproof way, compared to listing unitdefs! :wink:
And what happens when you want to make a special flying unit that can capture? Now you're whitelisting units on your blacklist? Overall, listing units that cannot cap (blacklist), is more scale-able (if not slightly more irritating to deal with).
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Help adding exclusion list to game_controlVictory.lua

Post by Jools »

Why use UnitsInCylinder? Why not just use AllowCommand() to prevent the capture command, or CreateUnit() to remove the command from the unit when it is created?

Or why not just set capture = 0 in the respective unitdefs? Config file is more robust than a script.
Post Reply

Return to “Help & Bugs”