Squad stuff gadgets

Squad stuff gadgets

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Squad stuff gadgets

Post by KDR_11k »

[url]http://kdr_11k.from-hell.net/squads.7z[/url]

Comes with two gadgets, the squadSpawner.lua allows making the construction of one unit spawn a bunch of other ones, the squadHandler.lua makes the squad act as one unit. The statusArrow.tga is only needed for the squadHandler. You can use just the squadSpawner to get a bunch of units in one build order that can still be controlled individually and you can use just the squadHandler if you have a custom build system, you have to call RegisterSquad then though.

To use the squadSpawner you create entries called squadMember1, squadMember2, etc on a unit. The numbers must be contiguous (cannot have one missing) and their value has to be the unitdef name of the squad member. The members are spawned in addition to the unit that was built. Only units that have gone through the TA build process get their squad members, it's possible to give a unit its own kind as squadmembers without causing any infinite recursions.

The squadHandler automatically acts on the squads made by the squadSpawner. It can use the customParam tag formation but doesn't require it (defaults to "circle" with the tag absent). The built unit becomes the leader of the squad with the spawned units being the followers. The player can only select and command the leader of the squad, the followers will automatically arrange themselves in a formation around the leader. If the leader dies a follower becomes the new leader. Squad leaders are marked with an arrow above their head. It might get annoying if the squadmembers have a stopping sound...

To use the squadHandler on your own build system you just call its RegisterSquad function. The parameters are the unitID of the leader, the unitDefID of the unit that defines the formation (probably the leader?) and a table containing the follower unitIDs like {[1]=unit1,[2]=unit2]}, the index numbers match the formation spots. Make sure your chosen formation has enough spots for all the units you put in.

There are no upgrades or reinforcements for the squads yet.

The squadhandler will probably cause issues with units that change their maxSpeed, it'd probably need adjustments for that in such mods...
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Squad stuff gadgets

Post by Hoi »

this sounds cool:)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Squad stuff gadgets

Post by Argh »

I'll take a look at this, and see if it runs faster than what I stuck into P.U.R.E., for sure.

Speed is one of the big problems I ran into, when you have large numbers of squads, and I'm interested in comparing performance figures- you have a lot of stuff in there that I ended up removing, but you're doing it differently, so hopefully it works better. The biggest problem I had was table-search times, when you get past 50 or so units, it gets increasingly nasty.

Also, Factories do pass the OPT.SHIFT- you can, for example, give something a move order, then a Guard order. So you probably want to preserve that.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Squad stuff gadgets

Post by Forboding Angel »

This is hardcore sex kdr. Thank you!
User avatar
Tribulexrenamed
Posts: 775
Joined: 22 Apr 2008, 19:06

Re: Squad stuff gadgets

Post by Tribulexrenamed »

Just the other day i was talking to someone who said you were a lua nazi who only did luas for his own stuff.


Guess this proves him wrong. Cool stuff thanks. Ill put it in my flash mod.
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: Squad stuff gadgets

Post by REVENGE »

Tribulex wrote:Just the other day i was talking to someone who said you were a lua nazi who only did luas for his own stuff.


Guess this proves him wrong. Cool stuff thanks. Ill put it in my flash mod.
That's total bullshit, alot of KDR's stuff is public domain. He simply works on what he feels like, which is great as far as we should be concerned, since his ideas are pretty original and innovative (at least with illustrating the possibilities of Spring's lua engine).
SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1948
Joined: 21 Sep 2004, 08:25

Re: Squad stuff gadgets

Post by SpikedHelmet »

Hi,

I can't get the squad spawning action to work. I have placed the squadmember# unitdefs in the FBI files of the "leader", ie:

squadMember1=GERMP40;
squadMember2=GERMP40;
squadMember3=GERMP40;
squadMember4=GERMP40;

I placed both inside and outside of the customparams section. I also tried various units. I am not very knowledgable about LUA but I've managed to make my way around some stuff, but apparently not this...

I've placed the squadSpawner.locals.lua in LuaRules/Gadgets; placed the above unitdefs in the leader unit; had the leader unit built; nothing, nadda. What am I doing wrong?
User avatar
Otherside
Posts: 2296
Joined: 21 Feb 2006, 14:09

Re: Squad stuff gadgets

Post by Otherside »

Tribulex wrote:Just the other day i was talking to someone who said you were a lua nazi who only did luas for his own stuff.


Guess this proves him wrong. Cool stuff thanks. Ill put it in my flash mod.
lol idiot

KDR makes mod to showcase how LUA can be used and he PD's it
User avatar
Tribulexrenamed
Posts: 775
Joined: 22 Apr 2008, 19:06

Re: Squad stuff gadgets

Post by Tribulexrenamed »

ZOMG IM SORRY
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Re: Squad stuff gadgets

Post by Nemo »

Ignore Spiked, I got it working with a few minutes of playing around.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Squad stuff gadgets

Post by KDR_11k »

For the record, Lua sees unit names as all lower case.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Squad stuff gadgets

Post by KDR_11k »

I've updated the scripts, fixed a mistake in the squadhandler that would cause error messages (but no actual game errors I think) later in the game and added the "loosesquad" tag that, when set to "1", makes a squad exempt from the squad handler so you can mix handled and unhandled squads in a mod.

I guess I should mention that the handler cannot deal with air units since it uses the unit's pathing to predict movement.
Post Reply

Return to “Lua Scripts”