Home   Help Search Login Register  

Author Topic: MP compatible campaign, briefing etc.  (Read 3322 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
MP compatible campaign, briefing etc.
« on: 07 Apr 2011, 22:51:58 »
Hi all,

Does anyone have useful info or links on how to create a MP compatible campaign?
I'm NOT talking about basic campaign structure, only how to make it MP safe in terms of scripts/commands.
MP campaigns don't seem to follow the standard MP solutions.
A good start would be how to create a briefing on all players, Server AND Clients.

Found this: http://community.bistudio.com/wiki/Multiplayer_framework, but it is not very good  ::)

Thanks in advance,

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: MP compatible campaign, briefing etc.
« Reply #1 on: 23 Apr 2011, 11:51:52 »
The briefing should work quite normally, but you need to add waituntil-part to briefing.sqf:

Init.sqf:
Code: [Select]
_nul = [] execVM "briefing.sqf";
Briefing.sqf:
Code: [Select]
waitUntil {!isNull player};
task2 = player createSimpleTask [Localize "STR_T2H"];
task2 setSimpleTaskDescription [Localize "STR_T2", Localize "STR_T2H", Localize "STR_T2W"];
task2 setSimpleTaskDestination (getmarkerpos "UNm");
...

For "Join in Progress"-players you update the current task status(es) and add new tasks with:
Init.sqf
Code: [Select]
_nul = [] execVM "briefing.sqf";
if (isnil("Var2")) then {Var2=false;};
if (isnil("Var3")) then {Var3=false;};
if (isnil("VarOBJ2")) then {VarOBJ2 = 0;};
if (isnil("VarOBJ3")) then {VarOBJ3 = -1;};
if (local server) then {} else {_nul = [] execVM "History.sqf";};

History.sqf:
Code: [Select]
waitUntil {!isNull player};
//-1 not made, 0 created, 1 finished, 2 assigned, 3 failed
if (VarOBJ2==-1) then {};
if (VarOBJ2==0) then {};
if (VarOBJ2==1) then {task2 settaskstate "SUCCEEDED";};
if (VarOBJ2==2) then {player setCurrentTask task2;};
if (VarOBJ2==3) then {};

if (VarOBJ3==-1) then {};
if (VarOBJ3==0) then {
task3 = player createSimpleTask [Localize "STR_T3H"];
task3 setSimpleTaskDescription [Localize "STR_T3", Localize "STR_T3H", Localize "STR_T3W"];
task3 setSimpleTaskDestination (getmarkerpos "AAm");
player setCurrentTask task3;
        };
if (VarOBJ3==1) then {
task3 = player createSimpleTask [Localize "STR_T3H"];
task3 setSimpleTaskDescription [Localize "STR_T3", Localize "STR_T3H", Localize "STR_T3W"];
task3 setSimpleTaskDestination (getmarkerpos "AAm");
task3 settaskstate "SUCCEEDED";
};
if (VarOBJ3==2) then {};
if (VarOBJ3==3) then {};

First you need server logic placed on map. Then use publicVariables that are changed by server. E.g. when task is done:

A script for server to run (condition local server && this - e.g. "this" from seized area):
Code: [Select]
Var3=true; publicVariable "Var3";
VarOBJ3=0; publicVariable "VarOBJ3";
task3 = player createSimpleTask [Localize "STR_T3H"];
task3 setSimpleTaskDescription [Localize "STR_T3", Localize "STR_T3H", Localize "STR_T3W"];
task3 setSimpleTaskDestination (getmarkerpos "AAm");
player setCurrentTask task3;
sleep 5;
Var3=false; publicVariable "Var3";

For clients already in server a separate script (condition !(local server) && Var3):
Code: [Select]
task3 = player createSimpleTask [Localize "STR_T3H"];
task3 setSimpleTaskDescription [Localize "STR_T3", Localize "STR_T3H", Localize "STR_T3W"];
task3 setSimpleTaskDestination (getmarkerpos "AAm");
player setCurrentTask task3;

With VarOBJ3=true; publicVariable "VarOBJ3" then JIP-player have updated task data too.
« Last Edit: 23 Apr 2011, 12:51:44 by SaOk »

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: MP compatible campaign, briefing etc.
« Reply #2 on: 23 Apr 2011, 16:25:36 »
Thanks a lot SaOk !

Will try it soon...

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: MP compatible campaign, briefing etc.
« Reply #3 on: 23 Apr 2011, 17:55:25 »
In case you want more MP-scripting hints from MP-rookie like me - I noticed (while creating that Battle of Zargabad Coop) that its better to leave all conditions (e.g. alive unitname, seized areas, everything...) for server and then make the server run a script where it sends a simple signal (VarNUM=true; publicVariable "VarNUM";) to clients to run their own script (condition: !(local server) && VarNUM ) with radiochatting, sounds, cameras, tasks, music type commands.