Lua an only-heal-category
Moderator: Moderators
Lua an only-heal-category
So... I want to have a builder unit only healing a certain a type of other units. With "AllowCommand" and a check of "customParams.isinfantry" it is easy to block direct healing orders. Buuut... how can automated healing orders of patrolling units be accesed and blocked?
Re: Lua an only-heal-category
All commands go through AllowCommandazaremoth wrote:With "AllowCommand" and a check of "customParams.isinfantry" it is easy to block direct healing orders. Buuut... how can automated healing orders of patrolling units be accesed and blocked?
And patrolling does nothing else than inserting proper CMD_ATTACKS, CMD_REPAIR, ... cmds
Re: Lua an only-heal-category
Well - this code is blocking direct heal commands, but the patrol command is still allows automated healing. What am I doing wrong here?
Code: Select all
function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions)
if (cmdID == 40) then
local RepairedUnit = (cmdParams[1])
local RepairedUnitDefID = Spring.GetUnitDefID(RepairedUnit)
if (UnitDefs[RepairedUnitDefID].customParams.isinfantry) then
return false
else
return true
end
end
return true -- allowed
end
Re: Lua an only-heal-category
NEVER USE MAGIC NUMBERS
Re: Lua an only-heal-category
What is the name of cmdid 40 azare?
Re: Lua an only-heal-category
That is CMD.REPAIR - but that does not change a thing... So this does exactly same - I am checking the code events with Echos sometimes
.

Code: Select all
function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions)
if (cmdID == CMD.REPAIR) then
local RepairedUnit = (cmdParams[1])
local RepairedUnitDefID = Spring.GetUnitDefID(RepairedUnit)
if (UnitDefs[RepairedUnitDefID].customParams.isinfantry) then
return false
else
return true
end
end
return true -- allowed
end
Re: Lua an only-heal-category
Code: Select all
if (cmdID == CMD.REPAIR) then
Spring.Echo("WAAAAAAAAAAFLES")
Re: Lua an only-heal-category
Yes - for manual commands. When units are patrolling the AllowCommand obviously is not called. Is it a bug or just my incodepetence?
http://azaremoth.supremedesign.org/img/ ... otheal.png
http://azaremoth.supremedesign.org/img/ ... gnores.png
Code: Select all
function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions)
if (cmdID == CMD.REPAIR) then
Spring.Echo("WAAAFLES!")
local RepairedUnit = (cmdParams[1])
local RepairedUnitDefID = Spring.GetUnitDefID(RepairedUnit)
if (UnitDefs[RepairedUnitDefID].customParams.isinfantry ~= nil) then
Spring.Echo("WITHOUT CREME FOR YOU!")
return false
else
Spring.Echo("CREME AND CHERRIES!")
return true
end
end
return true -- allowed
end
http://azaremoth.supremedesign.org/img/ ... gnores.png
Re: Lua an only-heal-category
Right, use enumsjK wrote:NEVER USE MAGIC NUMBERS

Re: Lua an only-heal-category
k checked the code patrol cmds aren't passed via AllowCommand, which seems to a missing feature then.
You can pool all units for their to top queue cmd and remove them then, still this will cause the engine to just readd them (eating performance and causing ugly sim behavior)
You can pool all units for their to top queue cmd and remove them then, still this will cause the engine to just readd them (eating performance and causing ugly sim behavior)