Home   Help Search Login Register  

Author Topic: moving respawn point in MP  (Read 1673 times)

0 Members and 1 Guest are viewing this topic.

Offline fleepee

  • Members
  • *
  • Enter the Matrix!
moving respawn point in MP
« on: 10 Oct 2008, 20:41:21 »
I have another problem for you to solve!
I've got several long missions in wich I want to have moving respawn points...
at each stage, a trigger (bluefor present, or opfor not present) sets a variable: (1,2,3,4)
Quote
respawnpos=1; publicVariable "respawnpos"; drapeau1_1 setFlagTexture "\ca\misc\data\usa_vlajka.paa"; hint "Respawn point updated";

then, another trigger is activated: condition: respawnpos==1 (then 2,3,4)
Quote
"respawn_west" setMarkerPos getPos drapeau1_1;

The problem is that when a player "join in progress" occurs, the player joining the game starts at the first position of the respawn_west marker, and when he enters the trigger "bluefor present", the respawn point moves, of course!
How can I force the player incoming to start at the current respawn position? :blink:
If I fix a starting value of the respawnpos in the init file, is that value changed with the publicvariable command?
can I use the "getvariable" command?
thanks!
« Last Edit: 10 Oct 2008, 20:43:26 by fleepee »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: moving respawn point in MP
« Reply #1 on: 13 Oct 2008, 21:26:12 »
I guess you can't set the position in the init.sqs becuase the person joining will read the init.sqs. Spooner or mandoble might have a solution.
Xbox Rocks

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: moving respawn point in MP
« Reply #2 on: 14 Oct 2008, 16:51:13 »
Code: (initFlags.sqf) [Select]
// Run from init.sqf with:
//  [[drapeau1_1, drapeau1_2, drapeau1_3, drapeau1_4]] execVM "initFlags.sqf";

flags = _this select 0; // List of flags in order of capture.

// Request that the position be moved on all machines.
setRespawnPos =
{
    private ["_pos"];
    _pos = _this select 0;

    // Move on all remote machines:
    respawnPos = [_pos];
    publicVariable "respawnPos";

    // Move on the local machine as well (needed for MP host):
    respawnPos call handleSetRespawnPos;
};

// Handle a global request to move the flags on the local machine.
handleSetRespawnPos =
{
    private ["_pos"];
    _pos = _this select 0;

    // Set all the flags up to this point as US held.
    for "_i" from 0 to _pos do
    {
        (flags select _i) setFlagTexture "\ca\misc\data\usa_vlajka.paa";
    };

    // Set all the flags after this point as sla side.
    for "_i" from (_pos + 1) to ((count drapeau) - 1) do
    {
        (flags select _i) setFlagTexture "\ca\misc\data\sever_vlajka.paa";
    };

    // Move the respawn point marker to the last US position.
    "respawn_west" setMarkerPosLocal (getPos (flags select _pos));
};

"respawnPos" addPublicVariableEventHandler { (_this select 1) call handleSetRespawnPos; };

if (isServer) then
{
    [0] call setRespawnPos; // Make sure the first position will be used initially.
};

When you want to move the respawn (e.g. from trigger):
Code: [Select]
[2] call setRespawnPos; // drapeau1_3 in our example.

Respawn position goes from 0 to 3 in this example, rather than 1 to 4, since it uses the appropriate flag from the list given to the script. You can, of course, name the flags however you want.

You can move the respawn point forwards and backwards, using this code, but when you think about it, it isn't as simple as just having repeatable triggers. But that is another issue ;P

Only tested in MP editor, but reasonably confident that it will work with players and in JIP.

EDIT: You might want to use a SEIZED BY BLUFOR trigger with a delay rather than just BLUFOR PRESENT, or you haven't actually defeated the defenders (could have just crept up near the flag ignoring the enemies).
« Last Edit: 14 Oct 2008, 17:22:29 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline fleepee

  • Members
  • *
  • Enter the Matrix!
Re: moving respawn point in MP
« Reply #3 on: 14 Oct 2008, 17:52:55 »
 :good:thanks a lot!
I will update with that codes the missions, great! :clap:

Offline thewarnerfi

  • Members
  • *
Re: moving respawn point in MP
« Reply #4 on: 17 Oct 2008, 09:03:00 »
I have use a respawn truck where the players are respawning to (moveincargo after death). And A counter for total "reserves". When a player dies, reserves is reduced by 1. when reserves reaches zero, game over.

You get more to reserves when the team gains levels(team total score). Or when they free prisoners.

-Thewarner