Jump to content
Sign in to follow this  
kakagoegie

respawn script

Recommended Posts

Here is my respawn script, yes I know it's ver easy. But I still got some questions.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_team = _this select 0

_spawnpoint = _this select 1

#Begin

"FDF_russianOfficerNight" createunit [_spawnpoint,_team,"man1=this",1,"LIEUTENANT"]

"FDF_russianSoldier" createunit [_spawnpoint,_team,"man2=this",1,"SERGEANT"]

"FDF_russianSoldier" createunit [_spawnpoint,_team,"man3=this",1,"CORPORAL"]

"FDF_russianRPG7Vsoldier" createunit [_spawnpoint,_team,"man4=this",1,"PRIVATE"]

"FDF_russianGrenadier" createunit [_spawnpoint,_team,"man5=this",1,"PRIVATE"]

"FDF_russianSoldier" createunit [_spawnpoint,_team,"man6=this",1,"PRIVATE"]

"FDF_russianSoldier" createunit [_spawnpoint,_team,"man7=this",1,"PRIVATE"]

"FDF_russianMachinegunner" createunit [_spawnpoint,_team,"man8=this",1,"PRIVATE"]

"FDF_russiansvdsoldier" createunit [_spawnpoint,_team,"man9=this",1,"PRIVATE"]

"FDF_russianGrenadier" createunit [_spawnpoint,_team,"man10=this",1,"PRIVATE"]

~1

_un = units _team

#loop

?(("Alive _x" count _un) == 0): "deletevehicle _x" foreach _un; goto "Begin";

~random(10) + 10

goto "loop"

1) After "_un = units _team" I want to define that the group I just created moves to game logic "gohere". I also want them to do that in line formation and with fleeing set to 0.

2) How can I delay the bodies being deleted without delaying the respawn of the group (can somebody make the bodies sink in the ground).

3) If I have 6 spawnpoints for the enemy soldiers. How can I make them use all 6 of the. Now I only have 1 spawnpoint.

Share this post


Link to post
Share on other sites

C'mon people, the only thing I REALLY need to know is the first question.

Share this post


Link to post
Share on other sites

About the first question try this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_team move getpos gohere

{_x allowleeing 0} foreach units _team

_team setformation "Line"

Hope this help

Klavan

PS

A suggestion: add a little delay between the created units, just to avoid the they freezes in place.

Share this post


Link to post
Share on other sites
Quote[/b] ]2) How can I delay the bodies being deleted without delaying the respawn of the group (can somebody make the bodies sink in the ground).

By example, for one of your spawned soldier, change this

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"FDF_russianOfficerNight" createunit [_spawnpoint,_team,"man1=this",1,"LIEUTENANT"]

into this

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"FDF_russianOfficerNight" createunit [_spawnpoint,_team,"man1=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"LIEUTENANT"]

Then add a "decay.sqs" script in your mission that will have this

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_unit removealleventhandlers "killed"

~10

deletevehicle _unit

exit

instead of the 10 , change to whatever delay (in seconds) you want a dead unit to disappear.

This kind of script is perfect to fight lag with continuous spawning units.

Share this post


Link to post
Share on other sites
Quote[/b] ]3) If I have 6 spawnpoints for the enemy soldiers. How can I make them use all 6 of the. Now I only have 1 spawnpoint.

A random selection for the six places:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_spawnpoints = [sp1,sp2,sp3,sp4,sp5,sp6]

_ran = random 6

? _ran <= 1 : _spawnpoint = (_spawnpoints select 0); goto "jump"

? _ran <= 2 : _spawnpoint = (_spawnpoints select 1); goto "jump"

? _ran <= 3 : _spawnpoint = (_spawnpoints select 2); goto "jump"

? _ran <= 4 : _spawnpoint = (_spawnpoints select 3); goto "jump"

? _ran <= 5 : _spawnpoint = (_spawnpoints select 4); goto "jump"

? _ran <= 6 : _spawnpoint = (_spawnpoints select 5)

#jump

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_group = _this select 0

_spawnpoints = [sp1,sp2,sp3,sp4,sp5,sp6]

_ran = random 6

#Begin

? _ran <= 1 : _spawnpoint = (_spawnpoints select 0); goto "jump"

? _ran <= 2 : _spawnpoint = (_spawnpoints select 1); goto "jump"

? _ran <= 3 : _spawnpoint = (_spawnpoints select 2); goto "jump"

? _ran <= 4 : _spawnpoint = (_spawnpoints select 3); goto "jump"

? _ran <= 5 : _spawnpoint = (_spawnpoints select 4); goto "jump"

? _ran <= 6 : _spawnpoint = (_spawnpoints select 5)

#jump

~1

"FDF_russianOfficerNight" createunit [_spawnpoint,_group,"man1=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"LIEUTENANT"]

~1

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man2=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"SERGEANT"]

~1

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man3=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"CORPORAL"]

~1

"FDF_russianRPG7Vsoldier" createunit [_spawnpoint,_group,"man4=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~1

"FDF_russianGrenadier" createunit [_spawnpoint,_group,"man5=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~1

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man6=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~1

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man7=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~1

"FDF_russianMachinegunner" createunit [_spawnpoint,_group,"man8=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~1

"FDF_russiansvdsoldier" createunit [_spawnpoint,_group,"man9=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~1

"FDF_russianGrenadier" createunit [_spawnpoint,_group,"man10=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~1

_un = units _group

_group move getpos gohere

{_x allowfleeing 0} foreach units _group

_group setformation "Line"

#loop

?(("Alive _x" count _un) == 0): goto "Begin";

~random(10) + 10

goto "loop"

This is what I have now. But I still have some problems.

- The enemies always spawn at the same spawnpoint.

- When the squad is destroyed. Only an officer and a soldier spawn. If I kill them, the entire squad spawns.

- the gepos/allowfleeing/formation doesn't work. It looks to me like there isn't even a group.

Help!!!

Share this post


Link to post
Share on other sites

This is working, i tested.

the spawnscript

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_group = _this select 0

#Begin

_spawnpoints = [sp1,sp2,sp3,sp4,sp5,sp6]

_ran = random 6

? _ran <= 1 : _spawnpoint = (_spawnpoints select 0); goto "jump"

? _ran <= 2 : _spawnpoint = (_spawnpoints select 1); goto "jump"

? _ran <= 3 : _spawnpoint = (_spawnpoints select 2); goto "jump"

? _ran <= 4 : _spawnpoint = (_spawnpoints select 3); goto "jump"

? _ran <= 5 : _spawnpoint = (_spawnpoints select 4); goto "jump"

? _ran <= 6 : _spawnpoint = (_spawnpoints select 5)

#jump

~1

"FDF_russianOfficerNight" createunit [_spawnpoint,_group,"man1=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"LIEUTENANT"]

~0.5

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man2=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"SERGEANT"]

~0.5

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man3=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"CORPORAL"]

~0.5

"FDF_russianRPG7Vsoldier" createunit [_spawnpoint,_group,"man4=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"FDF_russianGrenadier" createunit [_spawnpoint,_group,"man5=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man6=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"FDF_russianSoldier" createunit [_spawnpoint,_group,"man7=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"FDF_russianMachinegunner" createunit [_spawnpoint,_group,"man8=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"FDF_russiansvdsoldier" createunit [_spawnpoint,_group,"man9=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"FDF_russianGrenadier" createunit [_spawnpoint,_group,"man10=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

_un = units _group

{_x allowfleeing 0} foreach units _group

_group setformation "Line"

;this is to force the group to stop to leave time to everyone to go in formation

_group move getpos leader _group

~6

#loop1

_group move getpos gohere

?(("Alive _x" count _un) == 0): goto "Begin";

~10

goto "loop1"

the decay.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_unit removealleventhandlers "killed"

~10

deletevehicle _unit

exit

hint : put in the mission editor (and in the sea) the same soldiers you will spawn, and for each of those soldier , put

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setdammage 4 in their initialisation line.

This way all the units will be "pre-cached" and you will have no lag at all each time the spawn script will create units for the first time.

So using this spawn script as an example , put in the sea , with the this setdammage 4 in each inits :

A FDF russian officer night

A FDF russian soldier

A FDF russian soldier (RPG7V)

A FDF russian grenadier

A FDF russian machinegunner

A FDF russian soldier (SVD)

And you will have no "freeze" when the spawn script does its job in your mission

Share this post


Link to post
Share on other sites

No idea if scripts like this can work in MP.

Trying will tell you the answer.

Share this post


Link to post
Share on other sites

Sorry to dig this up but I tried it and I can't get it working. I made 6 game logics called Sp1 to 6 and changed the unit names to Sebnam units. I have the correct units in game and they are in the sea with Setdammage 4s on them.

Here's my snippet. Any ideas?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_group = _this select 0

#Begin

_spawnpoints = [sp1,sp2,sp3,sp4,sp5,sp6]

_ran = random 6

? _ran <= 1 : _spawnpoint = (_spawnpoints select 0); goto "jump"

? _ran <= 2 : _spawnpoint = (_spawnpoints select 1); goto "jump"

? _ran <= 3 : _spawnpoint = (_spawnpoints select 2); goto "jump"

? _ran <= 4 : _spawnpoint = (_spawnpoints select 3); goto "jump"

? _ran <= 5 : _spawnpoint = (_spawnpoints select 4); goto "jump"

? _ran <= 6 : _spawnpoint = (_spawnpoints select 5)

#jump

~1

"sebnam_vcofficer" createunit [_spawnpoint,_group,"man1=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"LIEUTENANT"]

~0.5

"sebnam_vcsoldier" createunit [_spawnpoint,_group,"man2=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"SERGEANT"]

~0.5

"sebnam_vcsoldier" createunit [_spawnpoint,_group,"man3=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"CORPORAL"]

~0.5

"sebnam_vcsoldier" createunit [_spawnpoint,_group,"man4=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"sebnam_vcsoldier" createunit [_spawnpoint,_group,"man5=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"sebnam_vcmg" createunit [_spawnpoint,_group,"man6=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"sebnam_vcmg" createunit [_spawnpoint,_group,"man7=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"sebnam_vcmedic" createunit [_spawnpoint,_group,"man8=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"sebnam_vcmortar" createunit [_spawnpoint,_group,"man9=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

~0.5

"sebnam_vcrecon" createunit [_spawnpoint,_group,"man10=this; this addeventhandler [ {killed} , {_this exec {decay.sqs}} ]",1,"PRIVATE"]

_un = units _group

{_x allowfleeing 0} foreach units _group

_group setformation "Line"

;this is to force the group to stop to leave time to everyone to go in formation

_group move getpos leader _group

~6

#loop1

_group move getpos GLTarget

?(("Alive _x" count _un) == 0): goto "Begin";

~10

goto "loop1"

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×