Jump to content
Sign in to follow this  
Bunny75

Teleporting respawned units

Recommended Posts

I'm making a MP mission where players are respawned normally via the description.ext respawn=3; method, but I need to teleport them to different locations right after they respawn to the respawn_(side) marker according to the game status.

So one method is to place trigger around the respawn marker and make it teleport everybody in it, but how exactly? How do I get the unit name respawning and exec it to a script that teleports that unit?

Is there any other method?

Thanks!

Share this post


Link to post
Share on other sites

Add differents Killed EventHandler with a location parameter on the players that you want to move on respawn.

//OPFORBase & BLUFORBase refer to an Object.
//--- Ex OPFOR
player addEventHandler ["Killed",{[OPFORBase]ExecVM "Respawn.sqf"}];
//--- Ex BLUFOR
player addEventHandler ["Killed",{[bLUFORBase]ExecVM "Respawn.sqf"}];

Respawn.sqf

//--- Respawn.sqf
//--- We give an object, you can freely adapt it to a location or something else.
_location = getPos (_this select 0);

waitUntil {alive player};
player setPos _location;

Edited by Benny.

Share this post


Link to post
Share on other sites

Thank you! Will try that.

---------- Post added at 10:05 AM ---------- Previous post was at 08:15 AM ----------

-So I put this into a player:

player addEventHandler ["Killed",{[bLUFORBase]ExecVM "Respawn.sqf"}];

-I made 1 invisible H named BLUFORBase and placed it far away from the start.

-I made respawn.sqs with this:

_location = getPos (_this select 0);
waitUntill {alive player};
player setPos _location

end

-and in description I have:

respawn=3;
respawndelay=4;

I exported it into MP mission and tried it, but the player keeps respawning near to the point it was killed?

Edited by Bunny75

Share this post


Link to post
Share on other sites

Waops my bad on a syntax error it's waitUntil and not waitUntill.

Also, please use SQF :).

As you cannot use a waitUntil with SQS (SQS use @ instead of waitUntil).

Rename your respawn.sqs Respawn.sqf

_location = getPos (_this select 0);

waitUntil {alive player};
player setPos _location;

Share this post


Link to post
Share on other sites

Crap! Typo. It was the sqf I made :)

Thanks...testing...

---------- Post added at 10:35 AM ---------- Previous post was at 10:10 AM ----------

Nope :( Keeps respawning to the same point it was killed.

The player is a part of a group. Does that affect?

---------- Post added at 11:31 AM ---------- Previous post was at 10:35 AM ----------

Doesn't work with a .sqs either

_location = getPos (_this select 0);

@ {alive player};
player setPos _location;
end

:butbut:

Share this post


Link to post
Share on other sites

Hmm, i don't have A2 around here, may you look into your .rpt file?

(C:\Users\username\AppData\Local\ArmA2\ for vista)

(C:\Documents and Settings\username\Local Settings\Application Data\ArmA2\ for XP)

Being in a group doesn't affect a setPos.

Can you clear the rpt, launch the mission in mp, kill yourself, and copy paste the stuff that your rpt shows (essential ones), also add the following line (localize/sidechat) for debug purpose.

_location = getPos (_this select 0);

//--- Debug
player sidechat format ["%1 || Respawn waiting || Respawning AT:%2",time,_location];
localize format ["%1 || Respawn waiting || Respawning AT:%2",time,_location];

waitUntil {alive player};

//--- Debug
player sidechat format ["%1 || Respawn done",time];
localize format ["%1 || Respawn done",time];

player setPos _location;

Share this post


Link to post
Share on other sites

:confused: no such folder visible as appData and I can't find any option to show all files and folders...

I have Vista.

Share this post


Link to post
Share on other sites

2 solutions.

1. Startup Menu --> Run --> type in the field: %APPDATA%

2. In explorer, in Tools --> Folder Options --> Display --> (around the midle of the list) Show hidden folder.

Share this post


Link to post
Share on other sites

I only get this:

Creating debriefing
Mission RespawnTest.utes: Missing 'description.ext::Header'
Creating debriefing

Share this post


Link to post
Share on other sites

onPlayerKilled

Launched when the player dies permanently, and does not become a seagull.

This script replaces the default death sequence. Make sure you place the command enableEndDialog somewhere in your script, as this will then cause the dialog that allows you to load, retry, or quit to appear.

In Armed Assault, this script is only executed if Respawn in Description.ext is set to NONE (0). If respawn is set to some other value, then the onPlayerKilled script is not executed

I aint sure if add event killed does the same. Anyway , down under is how i did it:

Make a script called "RESPAWN CONTROL SHIT"

That script contains a loop

Wait {alive player}

-> player is jip or simple spawned

-> wait {!alive player}

-> he died , do what ya like

this loop is started from init file. Needs be worked out.

Share this post


Link to post
Share on other sites

Did some 'blue' sidechat message shown during your death? (ONLY if you've added the debug line i've written above)

If not then it mean that the script wasn't triggered.

Make sure it's SQF.

if you use SQS you've gotta use Exec instead of ExecVM.

if it's SQF it's ExecVM.

Share this post


Link to post
Share on other sites

No sidechat text, nothing.

I am missing somethig relevant here.

I have the sqf file and description file here:

Documents\ArmA 2 Other Profiles\user_name\missions\RespawnTest.utes. When I export the mission to mp mission from the editor, do I have to copy those files manually somewhere too?

Or as I was wondering the other possibility to do this, does anyone know how to make a trigger around respawn_west marker that detects west forces respawning in it and relocate them? What kind of script goes to the on act field and does it need some script file also?

Share this post


Link to post
Share on other sites

Did you name the character you want to respawn correctly?

The exec of the scrips is

player addEventHandler ["Killed",{[bLUFORBase]ExecVM "Respawn.sqf"}];

that means you have to name the object "player" or it will not work, since the script is calling for the object named player.

player = the object/player you want to move

BLUFORBase = name of the object that is the place you want to move "player" to

it's better to change the exec and script to:

this addEventHandler ["Killed",{[this,BLUFORBase] execVM "Respawn.sqf"}];

and change the Respawn.sqf to

_man = _this select 0;
_location = getPos (_man select 1);

waitUntil {alive _this};
_man setPos _location;

That should work. And you can use it on ANY player object you want to teleport. Also, you do not need to name the player object :)

Edited by Pellejones

Share this post


Link to post
Share on other sites

:confused:

Nope. Still respawning to the point I died.

I also tried this (no underscore for this in _location =):

_this = this select 0;
_location = getPos ([color="Red"][b]this[/b][/color] select 1);

waitUntil {alive _this};
_this setPos _location;

no success :(

Share this post


Link to post
Share on other sites

Sorry I did a wrong post:

this is the correct code!

_man = _this select 0;
_location = getPos (_man select 1);

waitUntil {alive _this};
_man setPos _location;

Share this post


Link to post
Share on other sites

Nope :( No effect.

but doesn't that take the position of the player object, not the BLUFORBase?

Share this post


Link to post
Share on other sites

OK I can't get the script to work. After some debugging it seems that the script will not move past "waitUntil {alive _man}"

So here is a simple way to do it, it's a bit more .... well it takes more time.

1. Add a marker named respawn_(side)

2. Add an invisible H object where you want the new location to be at

3. Name the invisible H "location1" (without " ").

4. Add the player - name him p1.

5. Add a trigger over the respawn_(side) marker

6. Group the marker with the man you want to teleport (the man named p1).

7. Make the trigger activate repeatedly.

8. Add the following to the "On Act." field:

p1 setPos (getPos location1)

This will teleport the man to the new place. If you want to do this with more than one player, do this for ALL the players/men you want to teleport. Name them p1, p2, p3 etc. and just change the CODE in the trigger - so that the Grouped trigger code matches the name of the object to teleport.

Enjoy!

Share this post


Link to post
Share on other sites

Yep, that was one idea I was thinking. Only that I need the trigger to get the players id (this is going to be a MP) somehow dynamically.

Why do I have to group the player?

Share this post


Link to post
Share on other sites

If you group the man with the trigger, the trigger will only activate when that man walks into the trigger.

But this only works if we are using a single man. if you have, say a 5 man squad, I dont know how to check which man triggered the trigger.

Share this post


Link to post
Share on other sites

You needn't name the player. Get rid of this [sidebase] in the event handler. Put a location in the location field :rolleyes:. You might put a marker in named 'here', so location is '_location = getMarkerPos "here"; ', then move the marker depending on the objective. Don't forget to update the tasks in the killed handler. When I went to test this, I just ripped the briefing update out and whacked the setpos in:

init:

[] execVM "Respawn.sqf";

Respawn.sqf:

if ( isNil{player getVariable "mk_killedEHadded"} ) then
{
player addEventHandler ["killed",
{
[] spawn 	{
waitUntil { alive player };
player setPos getMarkerPos "here";
		};
}];
player setVariable ["mk_killedEHadded", true];
}; 

Then stick in whatever else - tasks update, spawn resistance maybe, valkyries riding off, i don't know - whatever it is you lot do when you get risen from the dead/ drop fresh troops at the front line. Then just move the 'here' marker around with the objective.

Share this post


Link to post
Share on other sites

init:

[] execVM "Respawn.sqf";

Respawn.sqf:

if ( isNil{player getVariable "mk_killedEHadded"} ) then
{
player addEventHandler ["killed",
{
[] spawn 	{
waitUntil { alive player };
player setPos getMarkerPos "here";
		};
}];
player setVariable ["mk_killedEHadded", true];
}; 

When i put this in the init field:

[] execVM "Respawn.sqf";

the editor says "Type Script, Expected Nothing" ?

Doesn't that take more cpu or slow down MP if the sqf is running all the time? If the objects init field has something like on "killed" and runs the script only when the obj is destroyed, wouldn't that be the proper, more efficient way?

Edited by Bunny75

Share this post


Link to post
Share on other sites

init.sqf, not the box in the editor. What Tigga said for the box thing, but it's better to run it from init file I reckon. And just after I posted that I realised you could just as easily move the respawn_west marker around the same way (more or less), which would probably be a preferred way. Anyhow, this IS 'on killed' - it's an event handler, not a looping script.

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  

×