Home   Help Search Login Register  

Author Topic: continuous ai spawns  (Read 2759 times)

0 Members and 1 Guest are viewing this topic.

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
continuous ai spawns
« on: 03 May 2008, 10:26:37 »
i have searched the forums with no luck.

i was sitting on a hill and thinking how nice it would be to watch ai's from each side spawn,  run to marker 1 and shoot each other.. and then respawn, creating an endless cycle.

how do i create a west unit that spawns, then moves to waypoint 1 and when killed, respawns and does it again, on 20 second intervals?
and the same for a east unit, so they have continuous enemies.

thank you
« Last Edit: 04 May 2008, 18:37:44 by loki72 »

Offline Rommel92

  • Members
  • *
Re: continuous ai spawns
« Reply #1 on: 04 May 2008, 01:29:17 »
One Trigger
Code: (RADIOALPHA - PRESENT) [Select]
Condition: True
OnAct: [] spawn {while {true} do {SPWN_W1 = createVehicle ["SoldierWB", ([(getpos maker1 select 0),(getpos maker1 select 1) + 200,0], [], 0, "FORM"]; SPWN_W1 doMove getpos maker1; waitUntil {!alive SPWN_W1};};}; [] spawn {while {true} do {SPWN_E1 = createVehicle ["SoldierEB", ([(getpos maker1 select 0),(getpos maker1 select 1) - 200,0], [], 0, "FORM"]; SPWN_E1 doMove getpos maker1; waitUntil {!alive SPWN_E1};};};
« Last Edit: 04 May 2008, 10:00:35 by Rommel92 »

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: continuous ai spawns
« Reply #2 on: 04 May 2008, 18:17:34 »
thanks for the reply... i couldn't get it to work.

it gives a syntax error.. type script, expected Nothing
(i  really am disliking ")" errors about now)

i split the code so maybe someone can see the missing syntax.

trigger RadioAlpha cond: true
Code: [Select]
[] spawn {while {true} do {SPWN_E1 = createVehicle ["SoldierEB", ([(getpos maker1 select 0),(getpos maker1 select 1) - 200,0], [], 0, "FORM"]; SPWN_E1 doMove getpos maker1; waitUntil {!alive SPWN_E1};};};

trigger RadioBravo cond: true
Code: [Select]
[] spawn {while {true} do {SPWN_W1 = createVehicle ["SoldierWB", ([(getpos maker1 select 0),(getpos maker1 select 1) - 200,0], [], 0, "FORM"]; SPWN_W1 doMove getpos maker1; waitUntil {!alive SPWN_W1};};};

« Last Edit: 04 May 2008, 18:47:14 by loki72 »

Offline Rommel92

  • Members
  • *
Re: continuous ai spawns
« Reply #3 on: 04 May 2008, 20:29:42 »
My fault, I do it everytime, prefix the statements with a variable.
Code: [Select]
nil = [] spawn {while {true} do {SPWN_E1 = createVehicle ["SoldierEB", [(getpos maker1 select 0),(getpos maker1 select 1) + 200,0], [], 0, "FORM"]; SPWN_E1 doMove getpos maker1; waitUntil {!alive SPWN_E1};};};
Code: [Select]
nil = [] spawn {while {true} do {SPWN_W1 = createVehicle ["SoldierWB", [(getpos maker1 select 0),(getpos maker1 select 1) - 200,0], [], 0, "FORM"]; SPWN_W1 doMove getpos maker1; waitUntil {!alive SPWN_W1};};};
« Last Edit: 04 May 2008, 20:32:10 by Rommel92 »

Offline Barbolani

  • Members
  • *
Re: continuous ai spawns
« Reply #4 on: 05 May 2008, 15:37:02 »
Hi,

I made this script with that purpose. It`s quite simple and rude (im not a scripting artist), just creates basic infantry.

You must previously create a soldier for each group you want to be in the field, place in the init nameofthegroup" = group this for each soldier / group you want to create.

After that, place two markers, one where the units will spawn and one at their destination, call them whatever.

The script initializes with [nameofmarkerspawnpoint, nameofmarkerdestination, nameofgroup, numberofunitsinthegroup] exec blahblah.sqs

The script:

Quote
_marker1 = _this select 0
_marker2 = _this select 1
_group = _this select 2
_units = _this select 3

_countunits = _units
_group = creategroup east

#Update1

"soldierEB" createUnit [getMarkerPos _marker1, _group]

_countunits = _countunits -1

? _countunits > 0 : goto "Update1"

_group move getMarkerPos _marker2
{_x allowFleeing 0} foreach units _group

_countunits = _units

#Update2

{alive _x} count units _group < 1: goto "Update1"

sleep 15

goto "Update2"

exit


If you want a "west" version, just place west when u find "east" and change the name of the soldier.

Can be easily modified to make it more random on the number of units, select more varieties of soldier types etc..


Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: continuous ai spawns
« Reply #5 on: 05 May 2008, 19:36:52 »
whoot!  :good:

thx for both your help... the last little script was what i needed to figure it out...

(now to learn how to convert from sqs to sqf...lol)

Offline Ironman

  • Former Staff
  • ****
    • {GSF} Home Page
Re: continuous ai spawns
« Reply #6 on: 05 May 2008, 19:53:01 »
for sqf all you need are the semi colons ";" at the end of the statements.
TS3 IP: tor.zebgames.com:9992

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: continuous ai spawns
« Reply #7 on: 05 May 2008, 20:30:33 »
hell ya.. thx ironman :D

Offline Ironman

  • Former Staff
  • ****
    • {GSF} Home Page
Re: continuous ai spawns
« Reply #8 on: 05 May 2008, 23:10:29 »
well that is the only difference in this code block, sometimes there are other coding standards that change.
TS3 IP: tor.zebgames.com:9992

Offline Rommel92

  • Members
  • *
Re: continuous ai spawns
« Reply #9 on: 05 May 2008, 23:16:17 »
Well if you really wanted it in script file form, all you had to do was ask, I just write things in trigger sometimes because its easier to manage.

Trigger (RADIO ALPHA - PRESENT):

Code: [Select]
nul = [WEST,"SoldierWB",(position LogicWEST),[],"FORM",10,(position LogicMoveTo)] execVM "make.sqf"; nul = [EAST,"SoldierEB",(position LogicEAST),[],"FORM",10,(position LogicMoveTo)] execVM "make.sqf";

Code: (make.sqf) [Select]
/* [side,type, position, markers, special, number of units, moveToPosition] execVM "make.sqf" */

_side = _this select 0;
_type = _this select 1;
_position = _this select 2;
_markers = _this select 3;
_special = _this select 4;
_number = _this select 5;
_moveTo = _this select 6;

_group = createGroup _side;

for [{_i=0}, {_i<_number}, {_i=_i+1}] do
{
_man = _group createUnit [_type, _position, _markers, 0, _special];
};
(leader _group) doMove position _moveTo;

While {count _group > 0} do {sleep 2.0};
{deleteVehicle _x} forEach units _group;
deleteGroup _group;

EDIT: IronMan, theres a lot more that changes in that script, because he has a set of scopes.
« Last Edit: 06 May 2008, 23:26:48 by Rommel92 »

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: continuous ai spawns
« Reply #10 on: 06 May 2008, 19:36:43 »
sry..rommel... i wasn't sure what i wanted.. just to know how to do it.

these last few days have given me many ideas.. with this script i can make civi's vs. civi's by joining them to a nonspawning east or west unit.

hatfield vs mccoy (Coop-PVP) the hillybilly way.
check it out at lokisnightmare.com
all are welcome to drop by and join on my dedicated server to beta test scripts and maps.

thanks again to both of you.. i am finally starting to get it...
« Last Edit: 06 May 2008, 19:50:44 by loki72 »

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: continuous ai spawns
« Reply #11 on: 08 May 2008, 23:32:38 »
 :weeping:
this sux... i have spent 30+ hours trying to get this to work.

it started with wanting to watch 2 opposing ai bots spawn, move to a marker and kill each other... respawn 20 sec later.
np... the script parts by rommel, ironman, and the AI_respawn_foot.sqf by norrin works great.. and even keeps the ai's weapons...

sometimes though, the spawn script putters out when all the individual units try to spawn back when 30+ start dying...

so i found the AIGroupRespawn.sqf which works even better for the groups... BUT!.. the civilians that are grouped to the blufor or the opfor side don't keep their weapons...

i can clearly see the weapon code in the one... but i don't quiet get the essence of the script language to merge the two.

i have tried and tried to paste and mush the two scripts together... only thing i have succeeded in, is a few more grey hairs in my beard.

so.. anyone please show me how to use the group respawn and have the civilians keep their weapons after respawning.

 an example map is included
« Last Edit: 09 May 2008, 00:12:22 by loki72 »

Offline Barbolani

  • Members
  • *
Re: continuous ai spawns
« Reply #12 on: 09 May 2008, 10:07:36 »
Hiya, just a suggestion

Youve got rommels script and mine (rommels is better and the code is more "pure").

Look out the createunit explanation at the comref.

All you need to do is to create a civ, group it on any side / group, and on its init, add the weapons you want. Thats the "dirty" way

That will give you a clue on how to solve this problem.

The "clean" way is some code like the one on "saveyourweapons" script that stores the quipment of a dead unit and adds it to the new created one...

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: continuous ai spawns
« Reply #13 on: 10 May 2008, 14:49:29 »
thx for the reply.. sorry for the delay. i have tried what you suggested with the save_gear scripts.. for some reason the gear will not spawn back with the civ's...

but i spent some time with the respawn_ai_foot scripts and got them to spawn a wee bit faster by making some clones of them... but i'm still not happy with an ai respawn script... wonder if i'll ever be. :D

i posted a version of the map that uses this idea in the mission beta area.. check it out.