Jump to content
Sign in to follow this  
majorexperimental

Random respawn within a certain area relative from death location

Recommended Posts

I searched but not found exactly what I want yet; perhaps someone here have any ideas?

When dying I whish the player to respawn, not at base, and not at the spot where he died but at random point within a certain area relative from death location. Why? I'm not sure the ideas will work but I think spawning at a fixed base ruins the game flow to much and spawning at the exact same spot as dying has many disadvantage as for example you will spawn back into the same situation that killed you in the first place, a loop situation, but if spawning for example at 200-600 meters away you get way from that immediate scene you died in and it still "cost" something to die but you still have some sort of contact with the situation. If you are shot down from helicopter/plane the teamates will have to pick you up = more fun/interesting than if you simply spawn at base.

Any ideas?

Share this post


Link to post
Share on other sites

Try this:

in init.sqf

fnc_respawn = 
{
        _killedpos = _this select 0;
       _randomPos = [[[_killedpos,500]],["water","out"]] call BIS_fnc_randomPos;
       waitUntil {player distance (getmarkerpos "urrespawnmarkerhere") < 50};
       player setpos _randomPos;
};

player addeventhandler ["Killed",{[getpos _this] call fnc_respawn}];

where you see 500 is the distance from the killed position. Put in your respawn marker name where urrespawnmarkerhere is. It probably will work, but might not. I haven't tested it...

Share this post


Link to post
Share on other sites

Instead of waiting for the player to respawn, it would be easier to simply place a respawn marker in your mission and move that around when a player dies. The trick to that is to do it locally for each player, so everyone has a different respawn marker.

Furthermore, for placement of the marker try this:

http://community.bistudio.com/wiki/findEmptyPosition

fnc_respawn = 
{
        _killedpos = _this select 0;
       "respawn_west" setMarkerPosLocal (_killedpos findEmptyPosition[ 50 , 100 , "Man" ]);
};

player addeventhandler ["Killed",{[getpos _this] call fnc_respawn}];

^- This has the advantage that you also have a minimum distance, so you dont risk respawning right where you died (just to get shot again).

Share this post


Link to post
Share on other sites
Instead of waiting for the player to respawn, it would be easier to simply place a respawn marker in your mission and move that around when a player dies. The trick to that is to do it locally for each player, so everyone has a different respawn marker.

Furthermore, for placement of the marker try this:

http://community.bistudio.com/wiki/findEmptyPosition

fnc_respawn = 
{
        _killedpos = _this select 0;
       "respawn_west" setMarkerPosLocal (_killedpos findEmptyPosition[ 50 , 100 , "Man" ]);
};

player addeventhandler ["Killed",{[getpos _this] call fnc_respawn}];

^- This has the advantage that you also have a minimum distance, so you dont risk respawning right where you died (just to get shot again).

I like the sound of that, but it didn't seem to work for me. I was previewing in MP editor. I have respawn = "BASE" in my description.ext. And your code in my init.sqf.

Is this working for anyone else, did I do something wrong?

Also, will it (or can it) also work for the AI in my squad?

So many questions, so little time to play :) Wish the day was longer.

Share this post


Link to post
Share on other sites

Please forgive the double-post, it's just that I have new info as a result of the latest dev release, and I'd really like to see this working.

Both of the above suggestions give this error;

'[|#|getpos _this] call fnc_respawn'
Error getpos: Type Array, expected Object, Location

Would be a nice feature to have for those sandboxy-walkabout type missions, where respawn_west isn't always gonna be anywhere near where you wanna be.

Can it still be made to work?

Share this post


Link to post
Share on other sites

Oh, didn't even notice that.

There:

fnc_respawn =  
{ 
        _killedpos = _this select 0; 
       "respawn_west" setMarkerPosLocal (_killedpos findEmptyPosition[ 50 , 100 , "Man" ]); 
}; 

player addeventhandler ["Killed",{[getpos (_this select 0)] call fnc_respawn}]; 

Share this post


Link to post
Share on other sites

Thanks for the reply, I do appreciate it. But, this time I got

'...dpos = _this select 0;
"respawn_west" |#|setMarkerPosLocal (_killedpos findEmptyP...'
Error 0 elements provided, 3 expected

btw- forgive me for talking out my rear (I'm clearly not a coder), but I"m also wondering if this attempt should even be worrying about moving the respawn marker anyway. Because if you think about the initial request, it sounds more like a request to modify the INSTANT respawn type, than the BASE respawn type (which uses the marker). And that's what sounds cool to me too. Instant is kinda what I think he/we are after, just not INSTANT on the exact same spot of dying, due to the death loop thingy.

So maybe we do want to do the old findEmptyPosition bit, and the whole [radius,maxDistance,vehicleType] bit, but not worry about moving around a respawn marker. :confused:

Just thinking out loud I guess.

Share this post


Link to post
Share on other sites

Good luck. I tried a bunch of various syntax changes (guesses based on other code bits I've seen), but haven't had success with any of them yet.

Still think this is an almost 'required fix' for when making an INSTANT type of respawn mission.

(I miss norrin)

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  

×