Page 1 of 1
Help adding exclusion list to game_controlVictory.lua
Posted: 13 Apr 2016, 21:39
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?
Re: Help adding exclusion list to game_controlVictory.lua
Posted: 13 Apr 2016, 21:52
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
Re: Help adding exclusion list to game_controlVictory.lua
Posted: 13 Apr 2016, 22:28
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.
Re: Help adding exclusion list to game_controlVictory.lua
Posted: 13 Apr 2016, 22:54
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
Re: Help adding exclusion list to game_controlVictory.lua
Posted: 13 Apr 2016, 23:05
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!

Re: Help adding exclusion list to game_controlVictory.lua
Posted: 14 Apr 2016, 07:03
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!

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).
Re: Help adding exclusion list to game_controlVictory.lua
Posted: 14 Apr 2016, 11:37
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.