Home   Help Search Login Register  

Author Topic: Spawning group w/ custom weapons?  (Read 1255 times)

0 Members and 1 Guest are viewing this topic.

gatordev

  • Guest
Spawning group w/ custom weapons?
« on: 10 Oct 2005, 04:41:03 »
I've searched through the boards over the last two years and haven't found anything about this, so if I missed something, I appologize.

I'm trying set up a spawning of a group using Strangelove's SpawnManager2 (which is awesome, btw).  But I'm also trying to have the units that are spawned have specific loadouts.  So, for example, let's say I'm trying to spawn MAP Marines, but have them loaded w/ Kammak's JAM script.  If I call Strangelove's script, it just calls the default units of whatever I specify.  Is there a way to integrate the loadout script into this?

The problem I see is that something like the JAM Loadout script uses "this" or "<group name>" in the init line.  Since the units are being spawned, I don't see how you can name them.  But my knowledge on this stuff is pretty limited.  Hopefully I've made some sense here.

Offline Hawkins

  • Former Staff
  • ****
  • Team 2-2
Re:Spawning group w/ custom weapons?
« Reply #1 on: 10 Oct 2005, 08:17:11 »
If I wasn't at work, I could give you specific information on how to do it. I'm not sure about the following syntaxt, so feel free to correct me if I'm wrong. :) There's many ways of doing the thing you want, here is one option. If anyone has another way, post. ;)

Look at the spawnmanager script which spawns the enemy units.
At the start, add the following: _spawnedunits = []
Then find the line which creates the unit, it's something like: "_unit" createunit [_pos, _group...etc etc...
If there isn't already, edit the line so that it's something like: _soldat = "_unit...etcetc...
or, alternatively, you can give the unit a name. To do so, you need to add the name to the init line. It's the third one on the line, here's a caption of the line from the offcial comref: [pos (Position),group (Group), init (String), skill (Number), rank (String)]
So, in this case it could look like: "_unit" createunit [_pos,_group,"soldat = this",_skill...etcetc...

Still with me? :)

Using the first option with the _soldat line at the start, after the creation line add:
_spawnedunits = _spawnedunits + _soldat
Then, before the script exits, execute the custom weapons script on the array, like this:
"[_x] exec {customguns.sqs}" foreach _spawnedunits

Or, using the second option by naming the unit from the creation line, soldat = this, execute the custom weapons script after the creation line, sth like:
[soldat] exec "customguns.sqs"

If this was hard to understand, I apologize. It's 9am here and I'm at work so I can't use my stuff as reference. :) If no one else responds after I get home, I can give you more information if you need.
« Last Edit: 10 Oct 2005, 08:19:19 by Hawkins »

gatordev

  • Guest
Re:Spawning group w/ custom weapons?
« Reply #2 on: 10 Oct 2005, 17:17:07 »
I think I follow the theory of what you're saying, I just don't know if I have the skills to implement right off hand.  Let me take a look at the script and see if I can figure it out.  However, if you have the time, a quick look at your examples at home would be appreciated too.

Thanks for the reply and sending me in the right direction.

Offline Hawkins

  • Former Staff
  • ****
  • Team 2-2
Re:Spawning group w/ custom weapons?
« Reply #3 on: 10 Oct 2005, 18:35:32 »
I just took a quick look at the scripts, and implementing the custom weapons option is easier than I thought. Here's how it can be done:

Find the following in the spawnman.sqs (It's under SPAWN TEAM headline):
Code: [Select]
(_units select 1+(random(count _units - 1))) createUnit [_basepos,_team,"this exec {patroldead.sqs}"]
Edit that line so it looks like:

Code: [Select]
(_units select 1+(random(count _units - 1))) createUnit [_basepos,_team,"this exec {patroldead.sqs};[this] exec {custguns.sqs}"]
See the ;[this] exec {custguns.sqs} ? Here I execute a script which gives the soldier an AK74 and one magazine. You can change the script name to the one you have in your mission folder. :)
If you have any more questions, post here. ;)
« Last Edit: 10 Oct 2005, 18:36:59 by Hawkins »

gatordev

  • Guest
Re:Spawning group w/ custom weapons?
« Reply #4 on: 10 Oct 2005, 23:54:07 »
Thank you so much for the help.  That seems to make sense when I read it.  I'll give it a shot tonight.  Again, thanks.

gatordev

  • Guest
Re:Spawning group w/ custom weapons?
« Reply #5 on: 11 Oct 2005, 05:14:38 »
Looks like it's working.  The only issue I'm having is that the first guy spawned doesn't have the custom weapons, but the others do.  For some reason, the Rebel CO just doesn't want a RHS AKS.  Go figure...

Thanks again for your help.

Offline Hawkins

  • Former Staff
  • ****
  • Team 2-2
Re:Spawning group w/ custom weapons?
« Reply #6 on: 11 Oct 2005, 07:41:27 »
Hmm, I did see that it created another unit, and he had a set of binocs which I didn't assign to him in the script, when I tested. I think the creation line for him was a bit up from the line we talked about, so you could also add the custom weapons script for him too. I can post an example once I get home (damn early mornings at work, heh :) )