New lua callin UnitBeginCmd

New lua callin UnitBeginCmd

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

New lua callin UnitBeginCmd

Post by Niobium »

Basically, UnitBeginCmd would be fired when a unit starts executing a command.

Attempting to do it using UnitCommand/UnitCmdDone is very difficult (I tried, up to 50 lines atm), mainly due to insert/remove commands and wait toggling. And then there's all the special cases, like inserted waits.. Also the lua (if done) would need to appear in every widget/gadget that needed this functionality, making them very messy / hard to update (I would probably use it in half a dozen at least)
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: New lua callin UnitBeginCmd

Post by Niobium »

An example;

If I give a unit 5 queued move commands, at the point in time where it actually starts /executing/ each of those commands, it will fire UnitBeginCmd, so you'd get 5 calls spaced over some period of time, one for each move.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: New lua callin UnitBeginCmd

Post by aegis »

you can fake it in current spring using UnitCommand and UnitCmdDone, checking the queue on each one (when a command finishes, a unit is working on the next command?)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New lua callin UnitBeginCmd

Post by Argh »

Why not keep track of commands issued, instead? Then you know when Wait has ceased, and can evaluate the list at that time.
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: New lua callin UnitBeginCmd

Post by Niobium »

I wouldn't have posted this if those very simple methods suggested worked.

Another example...

I have a unit with a move command, I insert a fight command at the front of queue. This is what happens:

UnitCommand: cmd=Insert (param=FIGHT). Queue: Move, max_speed
UnitCmdDone: cmd=Move. Queue: Move, max_speed
UnitCommand: cmd=max_speed. Queue: Fight, move, max_speed

Problems:
a) Need to extract fight command from the insert
- Including insert position, + is it now at front of queue
b) UnitCmdDone is bugged. It says that the move command is complete (which it is, as it now isn't the current command), yet GetUnitCommands will return the queue with the move still in it, and missing the inserted command.
c) There are max_speed commands scattered all over the place, which could cause more special case problems.

As I mentioned in first post, I tried writing code that used UnitCommand/UnitCmdDone and I got up to 50 lines in order to handle all these cases. It /apparently/ works, but it is too large and I don't trust it enough to go ahead and copy-paste it into half a dozen other widgets. It would be much nicer if there was a simple UnitBeginCmd callin which gets called in the source when a unit starts working on a command.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: New lua callin UnitBeginCmd

Post by KDR_11k »

The easiest way I know would be to use a custom command and handle it in CommandFallback.
Pako
Posts: 174
Joined: 12 Jul 2009, 18:57

Re: New lua callin UnitBeginCmd

Post by Pako »

+1
Post Reply

Return to “Feature Requests”