Author: fr33d0m
Author Website: http://www.tmnclan.com

Version: 1.0

Short description: This is intended as a little guide to making a Linear storyline / objective MP missions that are JIP compatible.

Date: 2014-04-29 17:10


Comments: (0)
Rating:



 

Multiplayer JIP Framework

by
Fr33d0m


Description:
This is intended as a little guide to making a Linear storyline / objective MP missions that are JIP compatible. I developed this after having a lot of trouble with the linear storyline missions I make, and when people JIP, they don't get a task.
This JIP framework will also make it possible to create long linear storylines that mimic persistent battlefields, and combines with the ALiVE Module well, as you can play through a few objectives, leave, and come back to the same objectives the next day (As long as someone didnt come while you were gone and progress the storyline!!)

This tutorial is going to attempt to make things understandable for those who don't write any SQF, but without some basic knowledge of SQF this is gonna be pretty difficult as pretty much all the task creation and triggering needs to be to via script or correctly using the BIS_fnc_MP function.

Disclaimer:
I'm not saying this is the best way, or ever the RIGHT way to do this. I'm sure there are ways to optimize this script. You are FREE to take my core work here and add to it. All I ask is that you share your improvements with me, so I can enjoy them too.


Installation / Usage:
briefing.sqf is for example only of static objectives assigned to every player on JIP.

In Your /documents/Mission Folder (Where your mission.sqm file is located for the mission you are editing) init.sqf: Add line as shown to your init.sqf. IF you dont have one, copy and pase this one.
leave initask.sqf and initask1.sqf in your root mission folder with the init.sqf file.
the missions folder is where all of your individual tasks will be, script by script.

You will need to call each script in the 2D editor via:
1) A trigger using the line:
M1= execVM "missions\mission2.sqf"; 
Explanations: M1= this is a variable name, and is required to execute a VM from the trigger. Syntax rules.
execVM "missions\mission2.sqf"; executes the mission2.sqf script inside of the missions folder as seen in your mission root folder (Where your mission.sqm is)

2) From within a script executed with the BIS_fnc_MP function.
Example:
["missions\mission4.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP; 
Explanation: This BIS_fnc_MP method executes the script on every client computer.

3) From an addAction executed with the BIS_fnc_MP function.
Example:
this addAction ["Collect Intel",{["missions\mission2.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];
Explanation: Normally ANYTHING executed via an AddAction is CLIENT SIDE ONLY, but executing the script like THIS makes is MP compatible! YAY BOHEMIA!

Basic Idea: We are setting a Public Variable that changes to a new and unique value every time a mission script is ran. This variable is created and declared as the first player(s) join before the first mission starts.
Once other players have joined, the late player is officially a JIP, and the script will evaluate they the PublicVariable exists already, to then it finds out what the unique value of the PublicVariable is, and assigns the current task to the JIP player.

First, we want to add to our init.sqf:
execVM "initask.sqf";
now every player that joins will be evaluated by the init task, which will use:
if (isNil "missionStatus") then {execVM "initask1.sqf";}else{hint "Welcome, JIP Player...TMN JIP Module is locating the progression of the Game In Progress. Standby."; execVM "scripts\JIPhandle.sqf";};
to find out if the missionStatus PV has been created already by players starting the mission.If it hasn't, you get the prologue task in initask1.sqf,

So, players that join at mission start should have this task. This task can be used to make a player see a CO or do something small prior to mission kick off, giving all players time to join before you have an icon to go somewhere.
Use your imagination, you can assign any kind of task.

For the first time, we are defining the publicVariable "missionStatus. From now on, every player who joins after this script is ran will do the JIPhandle script, not this one.
missionStatus= 11;
publicVariable "missionStatus";

//creating the "prologue" mission tasks

M1 = player createSimpleTask ["Prologue"];
M1 setSimpleTaskDescription ["This is the initial mission for players who didn.t JIP.","Mission 1","Map Text Mission 1"];
M1 setSimpleTaskDestination (getMarkerPos "M1");
M1 setTaskState "Assigned";
player setCurrentTask M1;

Otherwise, if it finds the variable DOES exists, then you MUST be a JIPper, and it handles you accordingly.
***so I'm a JIPper....now what?***
here's what JIPhandle.sqf is looking like:

//Now we're at the JIPhandle scripts. This script takes each JIP player and
//evaluates where the PublicVariable is at in global space, then executes //the right mission for the JP player
//based on that info.

//let's let the player know he's being JIP handled:

hint "JIP Manager is working....";
sleep 3.0;

//The evaluation begins... checking current PV value of missionStatus and //figuring out which mission to run for JIPper.
//to add a mission, just copy my CASE format, and add a new number
//(any number will work but 0 or 1 (interpreted by the machine as True of //false ITC)

switch (missionStatus) do
{
case 11:
{
execVM "missions\mission1.sqf"
};

case 22: {
execVM "missions\mission2.sqf"
};

case 33: {
execVM "missions\mission3.sqf"
};

case 44: {
execVM "missions\mission4.sqf"
};

case 55: {
execVM "missions\mission5.sqf"
};

case 66: {
execVM "missions\mission5.9.sqf"
};

case 77: {
execVM "missions\mission6.sqf"
};

case 88: {
execVM "missions\mission7.sqf"
};

default
{
hint "Something went horribly wrong. Could not assign JIP task";
};
};

Remember the publicVariable we assigned as 11? Well, the JIPhandle.sqf script is using s "switch do" statement to evaluate the current mission as indicated by the last PV the players in game have already set, so if for example, the players complete the objective for mission 11 and the misions2.sqf script gets ran:

//this script gets activated via something in the map, like a trigger or an addAction [BIS_fnc_MP style]
//Make sure if you call via BIS_fnc_MP that you set isPersistant to FALSE or every time a player JIPS
//you will get your PublicVariable set back to the last mission that was executed via BIS_fnc_MP.

//since mission 11 was complete, we can now set PublicVariable to mission= 22
missionStatus= 22;
//Below is the line of code that actually send this out to other players.
publicVariable "missionStatus";

//and now we can deal with the tasks assignment.
mil1 setTaskState "Succeeded";
deleteVehicle docs1;
sleep 2.0;
M3 = player createSimpleTask ["Mission 3 Title"];
M3 setSimpleTaskDescription ["Mission 3 Description ","Mission 3 ","Mission Task Title"];
M3 setSimpleTaskDestination (getMarkerPos "Mission3MK");
M3 setTaskState "Assigned";
player setCurrentTask M3;
sleep 20.0;
hint "You may RTB to rearm and seek medical care at the infirmary.";
sleep 6.0;
hint "";

Players have already made it to mission 2 and missionStatus now = 22, it will know to execute the script that assigns the mission 2 task to the player when he joins, giving him the same task as the rest of the players are currently on!

On the mission side: Setting the PublicVariable
Each mission is separated on a different SQF script (This was the easiest way IMO). Every time a mission is completed, the next mission script gets activated via something in the map, like a trigger or an addAction [BIS_fnc_MP style] Make sure if you call via BIS_fnc_MP that you set isPersistant to FALSE or every time a player JIPS
you will get your PublicVariable set back to the last mission that was executed via BIS_fnc_MP.

Now since missionStatus was set to 22 by this mission2.sqf script, every player who JIPS from now on will get assigned mission 3 as indicated by the JIPHandle script executing that mission on the JIP clients computer when he joins.

And it just goes on and on!! You can add as many linear story objectives as you want with this method, and will add JIP clients in the right place for the duration.




Enable javascript to be able to download from Armaholic please!



Tags: Jip,   Mp,   Tasks