Home   Help Search Login Register  

Author Topic: Spawning script help please  (Read 1198 times)

0 Members and 1 Guest are viewing this topic.

mjb

  • Guest
Spawning script help please
« on: 04 Dec 2005, 02:36:59 »
G'day All,
Well I'm having trouble making up a script and decided to turn to the forums.  Anyone who has some constructive advice is welcome to add their $0.02 worth!
The situation: making a 'psuedo ops' mission on BAS Tonal 1 along the lines of Rhodesian SAS or Selous Scouts.  I plan to make a long 'behind enemy lines' SP mission and populate the whole island with spawn scripts so that groups can be created with random unit members (for replay value).  So far I have looked at other people's spawn scripts and have found they (a) do not work at all, (b) are more suitable to MP, or (c) are helpful for ideas but do not quite do what I want.  Therefore I've attempted to write my own script (first time) picking the best bits out of other people's.

First, thanks to: Snypir, doolittle, TJ and Dr Strangelove cause I've been pulling your scripts apart and using bits I thought might work.

The script:
Code: [Select]
;[0,1,2,3,4,5] exec "spawnreb.sqs"
;0   name of team: "teamx"
;1   x,y,z (getMarkerpos "m")   marker position where troops are spawned
;2   from 2 - 12         how many soldiers are in group ?
;3   1 - 500 (whatever)   patrol radius around  marker position in m
;4   1 - 99999 (whatever)   how many seconds group will pause between patrols

;=================GET PARAMETERS========================
;get parameters
_team = _this select 0
_base = _this select 1
_scale = _this select 2
_radius = _this select 3
_pause = _this select 4

;============INIT VALUES================================
_cycle = 0
_types=["BAS_RebelOfficerHD","BAS_RebelSoldierHD","BAS_RebelSoldier2HD","BAS_RebelSoldier3HD","BAS_RebelSoldier4HD","BAS_RebelSoldier5HD","BAS_RebelMGunnerHD","BAS_RebelRPGSoldierHD","BAS_RebelRTOHD","BAS_RebelMedicHD","BAS_MilitiaAKMHD", "BAS_MilitiaSKSHD","BAS_MilitiaFALHD","BAS_MilitiaG3HD","BAS_MilitiaRPDHD","BAS_MilitiaPKMHD","BAS_MilitiaRPGHD", "BAS_MilitiaRPGAAHD","BAS_MilitiaRPGAPHD","BAS_MilitiaWAKMHD","BAS_MilitiaWSKSHD","BAS_MilitiaWFALHD","BAS_MilitiaWG3HD","BAS_MilitiaWRPDHD","BAS_MilitiaWPKMHD","BAS_MilitiaWRPGHD","BAS_MilitiaWRPGAAHD","BAS_MilitiaWRPGAPHD"]

;=============================SPAWN TEAM=====================
#spawnteam
_z = (random (count _types))
_z = (_z -(_z mod 1))
_guy = _types select _z
_guy createUnit [_base,_team]
_cycle = _cycle + 1
?(_cycle < _scale):goto "spawnteam"

;====================START PATROLSCRIPT===================
[_team,_radius,_pause,_base] exec "randpatrol.sqs"

In the mission I set up a trigger and a marker.
Its a detection trigger for a given radius that runs [0,1,2,3,4,5] exec "spawnreb.sqs".
The group is supposed to spawn around the marker.
The spawn script then runs the patrol script.

The spawn script is not working - can anyone see where I've gone wrong?

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:Spawning script help please
« Reply #1 on: 04 Dec 2005, 11:37:53 »
Just a quick thought:

Do you have a group (_team in your script) initialized before you use your spawn script? You need to have an existing group where to put the spawned units. The group may be an empty group, but it has to have existed before you can start feeding it any new units.

EDIT  Sorry if this is not the case, but I need to make sure: your trigger really does not run exactly [0,1,2,3,4,5] exec "spawnreb.sqs", or does it? If it does, then I can tell you it is not quite right... If you just shortened it in your post, then I apologize. If that was the case, please don't do it because we can't guess what is actually written to your trigger. Write it exactly like it is in your trigger. And your script takes 5, not 6 arguments.
« Last Edit: 04 Dec 2005, 12:23:29 by Baddo »

Offline 456820

  • Contributing Member
  • **
Re:Spawning script help please
« Reply #2 on: 04 Dec 2005, 16:56:07 »
from what i see i think your activating it wrong

Quote
;[0,1,2,3,4,5] exec "spawnreb.sqs"
;0   name of team: "teamx"
;1   x,y,z (getMarkerpos "m")   marker position where troops are spawned
;2   from 2 - 12         how many soldiers are in group ?
;3   1 - 500 (whatever)   patrol radius around  marker position in m
;4   1 - 99999 (whatever)   how many seconds group will pause between patrols

it should be like this i think
[grp1,getmarkerpos "markername", 12, 200, 40] exec "spawnreb.sqs"

i think thats more along the lines of it
its not guranteed
does the script come with an example mission if so use their trigger in it and modify it to work with groups

[0,1,2,3,4,5] wont do anything becuase unless your group is called "0" and the marker is called "1" and so on

hope it helps im still not sure if its right

mjb

  • Guest
Re:Spawning script help please
« Reply #3 on: 06 Dec 2005, 10:26:09 »
To avoid confusion, I've re-written the script.
1. To avoid complexity, I've dropped the goto patrol script.
2. This is the whole script (what can I say? I'm a noob and I like to keep things simple).
3. How do I initialise an empty group?
4. It still doesn't work.
Code: [Select]
; init command line is: [0,1,2] exec "spawnreb.sqs"
; where:
; value 0 is name of group, e.g. "teamx"
; value 1 is the marker position where troops are spawned (x,y,z), e.g getMarker Pos "markerx"
; value 2 is the number of units to be spawned,from 2-12, e.g. 4
; so e.g. would be [teamx, getMarkerPos "markerx", 4] exec "spawnreb.sqs"

;=================GET PARAMETERS========================
;get parameters
_team = _this select 0
_base = _this select 1
_scale = _this select 2

;============INIT VALUES================================
_cycle = 0
_types=["BAS_RebelOfficerHD","BAS_RebelSoldierHD","BAS_RebelSoldier2HD","BAS_RebelSoldier3HD","BAS_RebelSoldier4HD","BAS_RebelSoldier5HD","BAS_RebelMGunnerHD","BAS_RebelRPGSoldierHD","BAS_RebelRTOHD","BAS_RebelMedicHD","BAS_MilitiaAKMHD", "BAS_MilitiaSKSHD","BAS_MilitiaFALHD","BAS_MilitiaG3HD","BAS_MilitiaRPDHD","BAS_MilitiaPKMHD","BAS_MilitiaRPGHD", "BAS_MilitiaRPGAAHD","BAS_MilitiaRPGAPHD","BAS_MilitiaWAKMHD","BAS_MilitiaWSKSHD","BAS_MilitiaWFALHD","BAS_MilitiaWG3HD","BAS_MilitiaWRPDHD","BAS_MilitiaWPKMHD","BAS_MilitiaWRPGHD","BAS_MilitiaWRPGAAHD","BAS_MilitiaWRPGAPHD"]

;=============================SPAWN TEAM=====================
#spawnteam
_z = (random (count _types))
_z = (_z -(_z mod 1))
_guy = _types select _z
_guy createUnit [_base,_team]
_cycle = _cycle + 1
?(_cycle < _scale):goto "spawnteam"

exit

Any suggestions?
« Last Edit: 06 Dec 2005, 10:34:02 by mjb »

Offline Trapper

  • Honoured Contributor
  • ***
  • I'm a llama!
Re:Spawning script help please
« Reply #4 on: 06 Dec 2005, 10:51:48 »
Your script is working.

3. I don't know how to initalize an empty group, but after initalizing a group with one member your script worked. (teamx =  group this in the init line of the soldier)
Maybe you delete the soldier afterwards and group teamx remains.

4. Also call the script like this:
[teamx, getMarkerPos "markerx", 4] exec "spawnreb.sqs"

"teamx" is always a string, not a group
(looks like you've just edited your post for that? :) )

LoTekK

  • Guest
Re:Spawning script help please
« Reply #5 on: 06 Dec 2005, 10:53:46 »
Try:
Quote
_team = grpNull
_team = _this select 0
(Added line in bold)

mjb

  • Guest
Re:Spawning script help please
« Reply #6 on: 06 Dec 2005, 12:04:22 »
Thanks for the suggestions guys.

First I added the grpNull line and it still didn't work.

Second, keeping line above, I added an on-map leader with the init line teamx = group this and it worked!

So, do I place a "null' leader in an out of the way place, or can this script be reworked so I don't have to place a leader unit?

I'm thinking in the mission init file.... can I create a few empty groups?

Thanks again,

Mat.

Offline Trapper

  • Honoured Contributor
  • ***
  • I'm a llama!
Re:Spawning script help please
« Reply #7 on: 06 Dec 2005, 13:18:21 »
I think grpNull isn't working, otherwise createUnit would be used with it most of the time.

Like I wrote above, place a leader unit on map. It's the only way to define a group. Then deletevehicle the leader to have an empty group.

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:Spawning script help please
« Reply #8 on: 09 Dec 2005, 20:59:05 »
I think grpNull isn't working, otherwise createUnit would be used with it most of the time.

Like I wrote above, place a leader unit on map. It's the only way to define a group. Then deletevehicle the leader to have an empty group.

Additional information: in multiplayer, you would need to put a delay between defining a group and deleting the unit that was used to define the group. The delay because otherwise the unit might get deleted before all computers in the session have the group name defined. This means you couldn't delete the unit straight from the initialization field, but for example from a script file (which would additionally check that only the server computer will delete the unit because deleteVehicle command is global and affects all computers if used in one).

mjb

  • Guest
Re:Spawning script help please
« Reply #9 on: 10 Dec 2005, 05:39:21 »
Thanks to everyone who replied.
Here is the finished script that works:
Code: [Select]
; init command line is: [0,1,2] exec "spawnreb.sqs"
; where:
; value 0 is name of group, e.g. teamx
; value 1 is the marker position where troops are spawned (x,y,z), e.g getMarker Pos "markerx"
; value 2 is the number of units to be spawned,from 2-12, e.g. 4
; so e.g. would be [teamx, getMarkerPos "markerx", 4] exec "spawnreb.sqs"

;=================GET PARAMETERS========================
;get parameters
_team = grpNull
_team = _this select 0
_base = _this select 1
_scale = _this select 2

;============INIT VALUES================================
_cycle = 0
_types=["BAS_RebelOfficerHD","BAS_RebelSoldierHD","BAS_RebelSoldier2HD","BAS_RebelSoldier3HD","BAS_RebelSoldier4HD","BAS_RebelSoldier5HD","BAS_RebelMGunnerHD","BAS_RebelRPGSoldierHD","BAS_RebelRTOHD","BAS_RebelMedicHD","BAS_MilitiaAKMHD", "BAS_MilitiaSKSHD","BAS_MilitiaFALHD","BAS_MilitiaG3HD","BAS_MilitiaRPDHD","BAS_MilitiaPKMHD","BAS_MilitiaRPGHD", "BAS_MilitiaRPGAAHD","BAS_MilitiaRPGAPHD","BAS_MilitiaWAKMHD","BAS_MilitiaWSKSHD","BAS_MilitiaWFALHD","BAS_MilitiaWG3HD","BAS_MilitiaWRPDHD","BAS_MilitiaWPKMHD","BAS_MilitiaWRPGHD","BAS_MilitiaWRPGAAHD","BAS_MilitiaWRPGAPHD"]

;=============================SPAWN TEAM=====================
#spawnteam
_z = (random (count _types))
_z = (_z -(_z mod 1))
_guy = _types select _z
_guy createUnit [_base,_team]
_cycle = _cycle + 1
?(_cycle < _scale):goto "spawnteam"

exit

In the mission I created a leader and deleted him with this init line:
Code: [Select]
teamx = group this; deleteVehicle officerx
So far I'm only going to use it for SP.
Am working on a patrol script, so may be asking for help again in the near future  ;)