Jump to content
Sign in to follow this  
st!gar

Respawn script?

Recommended Posts

I'm assuming there's a way for the player to script respawning entities, but have been unable to find any guide regarding it.

Essentially, what I would like to be able to do, is this: a character/squad/vehicle gets destroyed. Said character/squad/vehicle then respawns at one, (out of several?), pre-determined positions, and proceeds to a given waypoint. If the entity gets destroyed again, it will respawn once more, and so forth. A convenient (if at worst somewhat gamey) way to simulate "never-ending" reinforcements or firefights.

This sounds like the sort of thing the game has a function for doing, but I've been unable to find one.

If anyone has any answers, it would be deeply appreciated. I'm not a very experienced mission-maker or coder, so if you do have an answer, it would help me if you used somewhat simple language. Note that all help is received gratefully, regardless.

Thanks in advance.

Edited by St!gar

Share this post


Link to post
Share on other sites

There is the "respawn" class you can add to description.ext, unfortunately I think it is for players only.

Another option is to script your own AI respawns. You'll want some kind of loop, whether it's a while loop or for loop is up to you. You'll want to check to make sure all of the units are dead, then spawn new ones after a certain amount of time.

I hope this gets you started in the right direction

Share this post


Link to post
Share on other sites

It should perhaps be mentioned that I was talking strictly about singleplayer; not multiplayer. There are fifty thousand guides online on how to create respawns in multiplayer, which is not what I need.

Share this post


Link to post
Share on other sites

As I remember correctly, there has just been a AI script here in the forums, which handles respawn also.

Share this post


Link to post
Share on other sites
As I remember correctly, there has just been a AI script here in the forums, which handles respawn also.

Are you saying the game doesn't support AIs respawning in single-player?

Share this post


Link to post
Share on other sites
Are you saying the game doesn't support AIs respawning in single-player?

It probably does, but I've never used it. Maybe someone else knows more about it.

Share this post


Link to post
Share on other sites

Quick simple example for A unit,

Place down a unit in the editor, give it a waypoint for somewhere to move to and add the below to its init.

fnc_neverEnding = {

_this addEventHandler [ "killed", {

	_unit = _this select 0;

	_typeUnit = typeOf _unit;
	_oldGroup = group _unit;

	_spawnSpot = waypointPosition [ _oldGroup, 0 ];
	_newUnit = _oldGroup createUnit [ _typeUnit, _spawnSpot, [], 0, "FORM" ];

	_moveTo = waypointPosition [ _oldGroup, count ( waypoints _oldGroup ) - 1 ];
	_wp = _oldGroup addWaypoint [ _moveTo, 0 ];

	_newUnit call fnc_neverEnding;

}];
};

this call fnc_neverEnding;

When the unit is killed a new unit of the same type is spawned at the original units starting position (waypoint 0) and given a waypoint to goto of the original units last available waypoint position ( waypointPosition [ _oldGroup, count ( waypoints _oldGroup ) - 1 ] ).

Using something like the above along with some of the commands shown by DE should give you something to work from.

To god damn early in the morning when i should be sleeping, let us know how you get on.

  • Like 1

Share this post


Link to post
Share on other sites
Like I said, the modules in game work for ai respawns and work both SP and MP.

Actually you didn't say that EGW, you didn't say much of anything

Share this post


Link to post
Share on other sites
Actually you didn't say that EGW, you didn't say much of anything


Indeed. I never got much information from you, whatsoever. I'm not entirely sure what you're going for, here. I'm asking for information. If you have information, I'm grateful if you share it with me. Not all this "hint-hint" -nonsense. Either say what you know, or don't bother replying.

Quick simple example for A unit,
Place down a unit in the editor, give it a waypoint for somewhere to move to and add the below to its init.
PHP Code:
fnc_neverEnding = {

_this addEventHandler [ "killed", {

_unit = _this select 0;

_typeUnit = typeOf _unit;
_oldGroup = group _unit;

_spawnSpot = waypointPosition [ _oldGroup, 0 ];
_newUnit = _oldGroup createUnit [ _typeUnit, _spawnSpot, [], 0, "FORM" ];

_moveTo = waypointPosition [ _oldGroup, count ( waypoints _oldGroup ) - 1 ];
_wp = _oldGroup addWaypoint [ _moveTo, 0 ];

_newUnit call fnc_neverEnding;

}];
};

this call fnc_neverEnding;

When the unit is killed a new unit of the same type is spawned at the original units starting position (waypoint 0) and given a waypoint to goto of the original units last available waypoint position ( waypointPosition [ _oldGroup, count ( waypoints _oldGroup ) - 1 ] ).

Using something like the above along with some of the commands shown by DE should give you something to work from.
To god damn early in the morning when i should be sleeping, let us know how you get on.


This is the exact sort of thing I'm looking for. I'll try it out. Thanks for the reply.

Share this post


Link to post
Share on other sites

Here is a similar example to my last but using the spawnAI module instead. download

As for my last example, its always handy to know how to do it manually instead of relying on the modules.

  • Like 1

Share this post


Link to post
Share on other sites

Larrow, I just tried the Init-script you provided. It worked like a charm. Killed soldiers respawned where they started, joined their original groups, and proceeded to their original waypoint, assuming it hadn't been reached by the time they respawned. (Which, in the case of waypoints like "Search and Destroy", would be never.) Perfect.

If this forum had a way of adding Reputation, I would do it.

Share this post


Link to post
Share on other sites

Wow, who was the guy that mentioned modules?

Anyway its not a simple link link so thats why I'm not going to go into detail, I figured others could elaborate but it seems like theyre just regurgitating what I said.

Share this post


Link to post
Share on other sites
Here is a similar example to my last but using the spawnAI module instead. download
 
As for my last example, its always handy to know how to do it manually instead of relying on the modules.

 

 

Thank you for alerting me to the use of Modules, and the information regarding how to use them. I do have one question that I don't see answered in the guideline - how do you edit the properties of the soldiers spawned by the Modules? That is; their Skill levels, Behaviours, Formations and so forth? I'm assuming there is a way.

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  

×