Jump to content
Sign in to follow this  
demonhunter212

Respawning Soldiers Question

Recommended Posts

Okay is there any possible way to create a bunch of soldiers, say about 20 Rebel soldiers (Tonal) and when they get killed they keep respawning from a certain position (from where they started) and keep attacking you... so it would seem like theres hundreds of them?

Just wondering thumbs-up.gif

Thanks

Share this post


Link to post
Share on other sites

In some way:

Combine createunit and deletevehicle, because you'll have to delete dead bodies to keep up the performance.

Also you'll need existing groups for the createunit command. Every group consists of max 12 soldiers, make sure you initiate enough for your purpose. Place a soldier somewhere and in his init line you'll write my1stgrp = group this, then deletevehicle him a few seconds after mission start. My1stgrp is now ready to accept 12 soldiers you'll spawn. Or you can just use the groups you want to "respawn" after their death.

Share this post


Link to post
Share on other sites
Quote[/b] ]In some way:

Combine createunit and deletevehicle, because you'll have to delete dead bodies to keep up the performance.

Also you'll need existing groups for the createunit command. Every group consists of max 12 soldiers, make sure you initiate enough for your purpose. Place a soldier somewhere and in his init line you'll write my1stgrp = group this, then deletevehicle him a few seconds after mission start. My1stgrp is now ready to accept 12 soldiers you'll spawn. Or you can just use the groups you want to "respawn" after their death.

Thanks Trapper but im kind of confused could you possibly give me a full script for this. thumbs-up.gif

Share this post


Link to post
Share on other sites

This is a demo mission.sqm for desert island (.intro), with one enemy group. Radio Alpha to start the enemy attack.

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

version=11;

class Mission

{

randomSeed=3229699;

class Intel

{

};

class Groups

{

items=4;

class Item0

{

side="EAST";

class Vehicles

{

items=9;

class Item0

{

position[]={9617.831055,34.669014,3158.891602};

id=0;

side="EAST";

vehicle="OfficerE";

leader=1;

rank="SERGEANT";

skill=0.466667;

init="grpE1 = group this";

};

class Item1

{

position[]={9620.831055,34.104477,3153.891602};

id=1;

side="EAST";

vehicle="SoldierEMG";

rank="CORPORAL";

skill=0.333333;

};

class Item2

{

position[]={9622.831055,34.048836,3153.891602};

id=2;

side="EAST";

vehicle="SoldierEG";

rank="CORPORAL";

skill=0.333333;

};

class Item3

{

position[]={9624.831055,33.984875,3153.891602};

id=3;

side="EAST";

vehicle="SoldierEB";

rank="CORPORAL";

skill=0.333333;

};

class Item4

{

position[]={9626.831055,33.999172,3153.891602};

id=4;

side="EAST";

vehicle="SoldierELAW";

rank="CORPORAL";

skill=0.333333;

};

class Item5

{

position[]={9628.831055,34.020699,3153.891602};

id=5;

side="EAST";

vehicle="SoldierEMG";

skill=0.200000;

};

class Item6

{

position[]={9630.831055,34.042229,3153.891602};

id=6;

side="EAST";

vehicle="SoldierEB";

skill=0.200000;

};

class Item7

{

position[]={9632.831055,34.063755,3153.891602};

id=7;

side="EAST";

vehicle="SoldierEB";

skill=0.200000;

};

class Item8

{

position[]={9634.831055,34.192184,3153.891602};

id=8;

side="EAST";

vehicle="SoldierEB";

skill=0.200000;

};

};

};

class Item1

{

side="WEST";

class Vehicles

{

items=9;

class Item0

{

position[]={9632.693359,29.834999,3475.286133};

azimut=182.546997;

id=9;

side="WEST";

vehicle="OfficerW";

player="PLAYER COMMANDER";

leader=1;

rank="SERGEANT";

skill=0.466667;

};

class Item1

{

position[]={9629.917969,29.834999,3480.413574};

azimut=182.547241;

id=10;

side="WEST";

vehicle="SoldierWMG";

rank="CORPORAL";

skill=0.333333;

};

class Item2

{

position[]={9627.915039,29.834999,3480.503662};

azimut=182.547241;

id=11;

side="WEST";

vehicle="SoldierWG";

rank="CORPORAL";

skill=0.333333;

};

class Item3

{

position[]={9625.920898,29.834999,3480.590820};

azimut=182.547241;

id=12;

side="WEST";

vehicle="SoldierWG";

rank="CORPORAL";

skill=0.333333;

};

class Item4

{

position[]={9623.921875,29.834999,3480.680664};

azimut=182.547241;

id=13;

side="WEST";

vehicle="SoldierWLAW";

rank="CORPORAL";

skill=0.333333;

};

class Item5

{

position[]={9621.923828,29.834999,3480.770508};

azimut=182.547241;

id=14;

side="WEST";

vehicle="SoldierWMG";

skill=0.200000;

};

class Item6

{

position[]={9619.922852,29.834999,3480.857910};

azimut=182.547241;

id=15;

side="WEST";

vehicle="SoldierWB";

skill=0.200000;

};

class Item7

{

position[]={9617.928711,29.834999,3480.949219};

azimut=182.547241;

id=16;

side="WEST";

vehicle="SoldierWB";

skill=0.200000;

};

class Item8

{

position[]={9615.930664,29.834999,3481.038574};

azimut=182.547241;

id=17;

side="WEST";

vehicle="SoldierWB";

skill=0.200000;

};

};

};

class Item2

{

side="LOGIC";

class Vehicles

{

items=1;

class Item0

{

position[]={9623.898438,37.602058,3179.255615};

azimut=182.546997;

id=18;

side="LOGIC";

vehicle="Logic";

leader=1;

skill=0.466667;

text="spawn";

};

};

};

class Item3

{

side="LOGIC";

class Vehicles

{

items=1;

class Item0

{

position[]={9623.898438,29.834999,3449.710205};

azimut=182.546997;

id=19;

side="LOGIC";

vehicle="Logic";

leader=1;

skill=0.466667;

text="combatzone";

};

};

};

};

class Sensors

{

items=1;

class Item0

{

position[]={9725.756836,29.834999,3418.098877};

activationBy="ALPHA";

age="UNKNOWN";

expActiv="grpE1 move getpos combatzone; grpE1 exec ""respawn.sqs""";

class Effects

{

};

};

};

};

class Intro

{

randomSeed=6726147;

class Intel

{

};

};

class OutroWin

{

randomSeed=2034179;

class Intel

{

};

};

class OutroLoose

{

randomSeed=15504899;

class Intel

{

};

};

The respawn.sqs script.

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

_g = _this

_t = "-"

_c = 0

_d = []

#l1

{if (!alive _x) then {_t = typeof _x; _d = _d + [_x]; [_x] join grpNull; _t createunit [getPos spawn, _g, {_g move getpos combatzone},(0.5 + (random 0.5))]}} foreach units _g

~0.5

_c = _c + 0.5

if (_c < 10) then {goto "l1"}

{deletevehicle _x} foreach _d

_d = []

_c = 0

goto "l1"

Share this post


Link to post
Share on other sites

Thanks but when i use the Respawn.sqs file do i need to change anything for a specific unit?

As stated in my other post in the other topic everytime i use that file i kill the guy but a message pops up at the top saying Error cannot use script or something like that. pistols.gif

Share this post


Link to post
Share on other sites

Scripts are completely custom made. Just because two scripts are named respawn.sqs it doesn't mean they are doing the same.

There is no script in the other topic, it's a special setup for respawn in multi player. It can't be used as a script.

This is full example mission above, including everything you need to know for one continously spawning ai group. You don't have to change anything for this whole example mission to work.

1. Create a folder ...\users\you\resexample.intro

2. Save the first code as mission.sqm in this folder

3. Save the second code as respawn.sqs in this folder

4. Start OFP and in the editor load resexample on desert island.

5. Preview the mission, Radio Alpha and watch the enemys respawn.

Adding more groups will be simple.

Share this post


Link to post
Share on other sites
This is a demo mission.sqm for desert island (.intro), with one enemy group. Radio Alpha to start the enemy attack.

...

The respawn.sqs script.

....

Trapper,

thanks a lot for these codes sample. I've added new groups, WP, triggers, etc. That's really easy.

Now, I need some help from You, PLEASE ...

1. how can I modifiy the time for respawn (i.e. after 10 seconds, or after 30 sec.). what's the parameter to modify in your code sample?

2. how can I set the number of respawn for AI group? (i.e. I'd like to stop AI group respawn after 2 respawns, or after 4 respawns? what's the parameter to modify in your code sample?

3. how can I synchronize respawn stop with any trigger? (i.e. I'd like stop AI group respawn when my group is finally in the middle of the village).

I believe You can help me. Any tips will be very appreciate. best regards.

ops.. another question. I'd like to delete a group when all its members are dead. (i.e. group name is "InsertOne". Please, what's code sample to delete it after 120 seconds all members are dead?)

I've searched and tried some codes, but syntax, scripts, ... are beyond my  understanding and some of them are really complex. I'm just a geometer. I'd like to learn some easy code and work about them. Your demo scripts are really EASY. thanks again.

Share this post


Link to post
Share on other sites

This easy script is very compact and doesn't offer many possibilities for modification. For some requests you're better off starting from scratch.

1.

This is the timing part. It's nested...

~0.5

This holds the script for 0.5 seconds. It's the real <s>re</s>spawn (loop) intervall.

_c = _c + 0.5

if (_c < 10) then {goto "l1"}

First line is a counter variable. Every loop it's increased by 0.5.

In the second line the script is looped back to #l1 until the counter reaches 10. That's equal to 10 seconds.

{deletevehicle _x} foreach _d

After these 10sec dead bodies are deleted.

_d = []

The array in which I stored the dead bodies until now is reset.

_c = 0

The counter is reset to 0.

goto "l1"

Script is looped back to #l1.

Pratically the spawn time is immediately. Scripts need to be slowed down to reduce CPU load. 0.5secs is the interval time of triggers waiting for something, too.

Waiting would require a complex array solution to store the unit type information because dead units are removed from the checked group (_g) after a while.

The easy way is to increase the distance between the game logics.

2.

Would have to turn the script from easy to very complicated.

3.

In Trigger OnActivation:

endspawn = true

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

endspawn = false

_g = _this

_t = "-"

_c = 0

_d = []

#l1

{if (!alive _x) then {_t = typeof _x; _d = _d + [_x]; [_x] join grpNull; _t createunit [getPos spawn, _g, {_g move getpos combatzone},(0.5 + (random 0.5))]}} foreach units _g

~0.5

_c = _c + 0.5

if (endspawn) then {exit}

if (_c < 10) then {goto "l1"}

{deletevehicle _x} foreach _d

_d = []

_c = 0

goto "l1"

4.

That approach makes it quite difficult. Deads are deleted from their groups sooner or later.

I suggest every member of the group is deleted 120sec after it's death. Even better for performance.

In the init line of all the group leaders you want to use it for write:

{_x exec "delscript.sqs"} foreach units group this

(Anywhere else you would call it like this for group "InsertOne":

{_x exec "delscript.sqs"} foreach units InsertOne)

delscript.sqs

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

#l1

~5

if (alive _this) then {goto "l1"}

~120

deletevehicle _this

exit

PS: Everything not tested.

Share this post


Link to post
Share on other sites
.....

This is the timing part. It's nested...

....

wow... THANK YOU VERY MUCH.

Now, I'll try to investigate about them ...

best regards.

Share this post


Link to post
Share on other sites

Trapper,

I'm in trouble with point 3. "endspawn script"

when condition trigger is meet, the game zoom around as for ending !?!? I've tried some modifications, but ...

maybe an error in this line?

if (endspawn) then {exit}

Please, can You help me again?

thanks in advance

Share this post


Link to post
Share on other sites

Check the effects menu of the trigger and deselect the camera zoom effect(?) smile_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]Okay is there any possible way to create a bunch of soldiers, say about 20 Rebel soldiers (Tonal) and when they get killed they keep respawning from a certain position (from where they started) and keep attacking you... so it would seem like theres hundreds of them?

Isn't that what one of the demo missions that Nagual made for (and IIRC came with) Tonal did?

Basically, three or so groups attack you and as you killed them they respawned three times.

Take a look in the Tonal D/L for the mission. If you cannot find it (and actually want it), lemme know and I will track it down and send it to you.

Wadmann

Share this post


Link to post
Share on other sites
Trapper,

I'm in trouble with point 3. "endspawn script"

when condition trigger is meet, the game zoom around as for ending !?!? I've tried some modifications, but ...

maybe an error in this line?

if (endspawn) then {exit}

Please, can You help me again?

thanks in advance

Trapper, I'm so sorry ...

I've forgotten to delete old script before to add the new one.

Please, excuse me. All your scripts work very well.

Thanks again.

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  

×