OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: evil on 22 Aug 2003, 05:59:31

Title: Reliable AI Respawning?
Post by: evil on 22 Aug 2003, 05:59:31
I have a group of AI guys that I want to respawn when they all die.  I have tried setdammage 0 but that only seems to work on AI not in groups.  It might work every now and then with a guy in a group, but usually not.  The blood just dissappears, but they stay on the ground.

Is there any way around this?  Sorry if this is a common question.
Title: Re:Reliable AI Respawning?
Post by: Terox on 22 Aug 2003, 18:08:01
i aint a co op'r, but i dont think they try to respawn AI, they simply replace them by creating new ones


so something like

@ !alive W1
create a new unit thingy with dots splashes and fireworks

think its createunit

as per the comref
"SoldierWB" createunit [getmarkerpos "Barracks",groupAlpha]

and you can add skill and rank as well
Title: Re:Reliable AI Respawning?
Post by: evil on 22 Aug 2003, 20:19:23
I didn't want to use Createunit unless I had to.  But I suppose I can see how it works.

On another note I tried adding the "killed" eventhandler to a test subject, who was in a group.  It seemed to work well, but obviouslly it only worked once  :-\.  Maybe I can think of a way to make it work more than once.
Title: Re:Reliable AI Respawning?
Post by: evil on 22 Aug 2003, 21:54:55
I am trying to create a unit but it's not working.  What am I doing wrong?

"OfficerW" createUnit [getPos gwar, groupAlpha, 0.6, "SERGEANT"]

I think it's a problem with the group.  Here's what I'm using:

Alpha = group commander this; group this setgroupID ["Alpha","GroupColor0"]

Anyone?
Title: Re:Reliable AI Respawning?
Post by: DrStrangelove on 23 Aug 2003, 11:42:03
There's a "" missing in your creatunit line.
The basic command is: "SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha]
The last 3 values are optional: ["", 0.5, "PRIVATE"]
However, if you choose to use one of the last 3 values, you write all 3 values into the command:
"SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha,"", 0.5, "PRIVATE"]

More infos:
The group you want to spawn your 1st soldier into, has to exist from the start. What you need is to place a soldier in the editor with "alpha = group this" in its init-line. You may pull the dammage slider all to the left, so he's dead at mission start. The group alpha still exists however.

In my case, i use a group named 'eastdummygroup', because 'groupAlpha' is used by OpF automaticly when making new groups - could lead to problems when respawning again and again.

For example, this is how i spawn my officer:
Code: [Select]
"OfficerE" createUnit [getPos _mybase, eastdummygroup,"this exec {dead.sqs}"]Dead.sqs checks if he's alive every 30 sek, and if he's not, his body will disappear from the battlefield (reduces lag).


The eastdummygroup is only used for spawning the 1st member of a new group. Therefore i move the officer into a new group that is automaticly named by OpF itself (Bravo, Charly, etc):
Code: [Select]
_member = (units eastdummygroup) select 1
[_member] join grpNull
_grp = group _member

_grp is now the new group of the Officer (he's the leader). You can fill up the new group with more soldiers:
Code: [Select]
#spawn_patrolrest
~(random 1)
"SoldierEB" createUnit [getPos _mybase, _grp,"this exec {dead.sqs}"]

?(count units _grp == 12):goto "patrolteamfull"
goto "spawn_patrolrest"

#patrolteamfull
bla
bla
...


You'll end up with an Officer and 11 Soldiers in a new group, named Bravo for example.
eastdummygroup still exists, so you can respawn more groups over and over, until you hit the group barrier of OpF, which is 64 i believe.

Any more questions? try my spawn patrols script here:

http://www.ofpec.com/editors/resource_view.php?id=526
Title: Re:Reliable AI Respawning?
Post by: evil on 23 Aug 2003, 22:46:53
Thanks DrStrangelove.  That tip to prevent lag when they are created is invaluable!  Know I just have one quetion...  Is it possible to give units created ingame waypoints?  Right now all I can think of is to tell them to move to a marker/object using "move".
Title: Re:Reliable AI Respawning?
Post by: DrStrangelove on 27 Aug 2003, 18:02:55
Waypoints are created for groups in the editor right ? But a spawned group doesn't exist in the editor, so you can't make waypoints for them.

They can use waypoints of another group, but i'm not sure about that. I always send spawned groups to calculated positions around their homebase or give them the positions of spotted targets.
Title: Re:Reliable AI Respawning?
Post by: evil on 31 Aug 2003, 23:22:59
I can make it do a good enough job.  I make a single Hold waypoint for the guy I create the group with.  Even when he's deleted the group goes there.