Canselfdestruct=0/1

Canselfdestruct=0/1

Requests for features in the spring code.

Moderator: Moderators

Post Reply
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Canselfdestruct=0/1

Post 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.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Easily done using LuaRules.
You could also set the unitDef SelfDestructCountdown value to something ridiculously large.
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post 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?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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
Last edited by trepan on 19 Nov 2007, 01:21, edited 1 time in total.
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

Cuter than a misspelled four page analogy that has nothing to do with the feature request, anyway.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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? :-) )
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post 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
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post 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...
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post 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)
Post Reply

Return to “Feature Requests”