Page 1 of 1

Canselfdestruct=0/1

Posted: 19 Nov 2007, 00:35
by Gnomre
Please?

And before you even think of posting, AF, I asked Maelstrom if he could write a lua script for it. He said he could intercept the self-d commands and remove them, but that it would be far more efficient to do it engine-side and disallow the command to be sent in the first place.

Posted: 19 Nov 2007, 00:50
by trepan
Easily done using LuaRules.
You could also set the unitDef SelfDestructCountdown value to something ridiculously large.

Posted: 19 Nov 2007, 00:56
by Gnomre
The impossibly high self-destruct time is what we currently use, but it's not exactly ideal. We need it for our flags: it's lame if the defender self-destructs the flag before the enemy captures it just so they have to manually waste time to re-cap the point (because the entire point of the capturing system we had Maelstrom code is to get rid of the rebuilding part). The high self-destruct time is a somewhat hacky workaround.

How would we go about doing it in Luarules, if the situation has changed regarding my small text in my previous post?

Posted: 19 Nov 2007, 01:17
by trepan
Is the tiny text supposed to be cute? If you have something to
say, say it; don't waste everyone's time by obfuscating it.

You can edit the unit command descriptions to remove the
self-d command as well as blocking the commands themselves.

P.S. It would be an easy feature to add to the engine ;-)

To save others the bother:
Gnome wrote:And before you even think of posting, AF, I asked Maelstrom if he could
write a lua script for it. He said he could intercept the self-d commands
and remove them, but that it would be far more efficient to do it
engine-side and disallow the command to be sent in the first place

Posted: 19 Nov 2007, 01:21
by Gnomre
Cuter than a misspelled four page analogy that has nothing to do with the feature request, anyway.

Posted: 19 Nov 2007, 01:22
by trepan
Two wrongs make a right? Be the better person.
(and how does making it difficult to read help avoid the 4 page rant? :-) )

Posted: 19 Nov 2007, 01:32
by rattle
I added it a minute ago, just need to test it. It's a oneliner... :P

http://spring.clan-sy.com/mantis/view.php?id=687

Posted: 19 Nov 2007, 02:52
by AF
*_*

Now I did have a 1 line answer, the same answer I've been trying to hammer in the last month or two, that trepan also seems to be saying 20 times a month.

However maybe I should give an analogy anyway as you decided to be so rude? As trepan rightly said small text is not good, and it doesn't hide derogatory comments very well.

Anyways there're lots of requests that can be done there and then with a single line of lua code using the method trepan suggests.

Code: Select all

function gadget:AllowCommand(unitID, unitDefID, teamID,
                             cmdID, cmdParams, cmdOptions)
  if (cmdID == CMD.SELFD) then
    return false -- command was blocked
  end
  return true
end
feel free anyone to correct my code which would block any self destruct command regardles of the unit.

Even better:

Code: Select all

local function SetCommand(unitID, CommandId, isdisabled)
  local editID = FindUnitCmdDesc(unitID, CommandId)
  if(editID) then
    Spring.EditUnitCmdDesc(unitID, editID, {disabled=isdisabled})
  end
end

function gadget:UnitCreated(unitID, unitDefID)
  local ud = UnitDefs[unitDefID]
  if (ud.name == 'armmex') then
    SetCommand(unitID,CMD.SELFD,true);
  end
end
That would remove the self destruct command from any metal extractor built.

Posted: 19 Nov 2007, 03:39
by Maelstrom
A Lua way of doing it is definately possible, I know. Gnome stated that i knew how. I was just wondering, why cant this be an engine thing? We have canAttack, canBuild, canMove, canEverythingElse, but not canSelfDestruct. It just seems slightly unnecessary to have yet another Lua gadget running to block this command, when every other command can be blocked engine side...

Posted: 19 Nov 2007, 06:38
by KDR_11k
Why disable the CmdDesc? AFAIK a unit doesn't need a CmdDesc to receive an order anyway. When I introduced special abilities into KP Div0 I had to attach a safeguard that only the proper units can get the command, selecting a terminal and a crapload of bits would make every selected unit launch a bomber instead of only the terminal (which was the only one with the CmdDesc)