Jump to content
Sign in to follow this  
strike0277

Player respawn at height ?

Recommended Posts

I'm putting together a defend mission. I have repawn working but, It's not in the room that the player starts in. What I need is for the player to respawn in the same place they started. The mission takes place in the Devil's Castel compund. The start and desired respawn point are both one lvl down from the roof. I think it's like 22m high. When the the player dies and repawns it's outside beside the building. Not sure how to make this work at all. Could some one please gude me? Thanks.

Share this post


Link to post
Share on other sites

How are you getting the initial spawn point to work properly on mission start? What are you currently doing for the respawn?

I would guess you need to setPos the player to the correct height/location but I'm not familiar with how respawn works in the general sense so don't have specific advise. How does the game decide where to respawn players in the normal case?

Share this post


Link to post
Share on other sites

There is a function called addEventHandler. This is what you need.

This comes into soldier1's init:

soldier1 addEventHandler ["killed", {_this exec "[b]respawnHeight.sqf[/b]"}]

And the respawnHeight.sqf can be something like that:

waitUntil {alive [b]soldier1[/b]};
sleep 0.1;
[b]soldier1[/b] setPos [(getPos this select 0),(getPos this select 1),[b]22.0[/b]];
if (true) exitWith {};

22 is the height.

Share this post


Link to post
Share on other sites

That didn't work. I'm still respawning outside beside the building instead of inside in the upper floor.

---------- Post added at 01:27 AM ---------- Previous post was at 01:09 AM ----------

Sorry Guy to anser your question for regular respawn

init.sqf included is respawn = "base"

and respawndelay = 5

named marker respawn_west

Respawn in and of it's self does work. I just will not allow me to spawn to my original starting point after I die. It's the last floor before the roof at Devi's Castel.

Share this post


Link to post
Share on other sites

Hi, dont know if this would work but its worth a shot; Place the marker on top off the building, make sure its in the right spot and the puth in the markers init: setPos [getPos this select 0,getPos this select 1,15];

So basicly its same what sxp2high mentioned but the height is applied on the respawn marker so it mayby make you respawn on that height.

Gone test it to see if it will work or not,

later

Edit: forget what i said about the marker cause if forgot you cant puth code in a marker , and placing it on a building will force you to respawn outside,it works on bunkers and small low lvl building, used plenty off times in my missions but no idea to get them to spawn on roof or something.

Edited by Sgt.Spoetnik
added more intel

Share this post


Link to post
Share on other sites

Note: it helps to use set/getPosATL instead of the set/getPos since the latter takes (some) big buildings into account when getting the height.

Create a gamelogic or an invisible H inside the building you want to respawn in, lets call it RespawnDummy for now...

in RespawnDummy's init put:

this setPosATL [(getPos this select 0),(getPos this select 1),1337];

Where it says 1337, put in the height (in meters) of the floor you want to spawn at (you will have to experiment with it a bit to get it right)

in a soldier's init:

this addEventHandler ["killed", {[_this, (getPosATL RespawnDummy)] execVM "respawnHeight.sqf";}]

and the respawnHeight.sqf will be:

_soldier = _this select 0;
_respawnPosition = _this select 1;
waitUntil {alive _soldier };
sleep 0.1;
_soldier setPosATL _respawnPosition;

and that should do it... When testing make sure you check the arma2.rpt for errors like a missing ; or ) or something just as silly... it makes the game completely ignore the file.

arma2.rpt is found in(for Windows Vista/7) \Users\AppData\Local\ArmA2,

or (for Earlier versions of windows) \Documents & Settings\YourUserName\Application Data\SomethingICantRemember\ArmA2

Edited by mrCurry

Share this post


Link to post
Share on other sites

Add a trigger: Radio alpha, repeatedly, onAct: diag_log format ["this setDir %1; this setPosASL %2;", getDir player, getPosASL player];

Preview the mission. Stand where you want the respawn point to be (and face the direction you want to face when you respawn as well). Activate the radio trigger.

At the end of your arma2.RPT file you should have the exact position typed out. Now all you have to do is to setPosASL the player back to that position every time he respawns.

Also I am not sure a sleep 0.1; is necessary nor good. I don't see any real reason to wait before setting the player's position.

Share this post


Link to post
Share on other sites

Also I am not sure a sleep 0.1; is necessary nor good. I don't see any real reason to wait before setting the player's position.

It's a "just incase", the time is so short anyways its not noticable when respawning

Share this post


Link to post
Share on other sites

Does this still work or is it busted?

I've tried it, but can't get it to work.

I'd appreciate an example mission file with just the respawn related stuff in it.

Share this post


Link to post
Share on other sites

This works for me, vpo1 is an invisibleH, player spawns 15.9m above sea level on the H. It's used on the LHD Carrier but should work in buildings or adapt it and try getPosATL:

player setPosASL [getPosASL vpo1 select 0, getPosASL vpo1 select 1, 15.9];

Share this post


Link to post
Share on other sites

Yes, i am trying to get it to spawn on the LHD, (the height is 12 meters for the cargo bay.) I am currently using =L2d= Curry's setup. But that didnt work. Now i am going to try configuring it to a trigger, that didnt work, any other suggestions. The goal is after someone dies they come back into the cargo bay

Share this post


Link to post
Share on other sites

Just set the respawn marker to the correct height.

For the deck it is

"respawn_west" setMarkerPosLocal [markerPos "respawn_west" select 0, markerPos "respawn_west" select 1, 15.9];

Add the code above into init.sqf, adjust it to your needs. But afair the height for the cargo bay is 9.26.

Works perfectly fine (anybody played co50 The Longest Day ? That's where I'm using it).

Edit: As long as you are talking about respawn :D

Spawning the player in the cargo deck at mission start:

player setPosASL [position player select 0, position player select 1, 9.26];

But be carefull if you spawn the LHD.

Xeno

Edited by Xeno

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  

×