Home   Help Search Login Register  

Author Topic: that old chestnut JIP  (Read 4766 times)

0 Members and 1 Guest are viewing this topic.

Offline sharkattack

  • Former Staff
  • ****
that old chestnut JIP
« on: 19 Dec 2007, 20:07:45 »
guys ...

im having issues with jip on  a new co op  im trying to build

at the min the player group starts in a  pbx (named dinghy1)  as the mission progresses the opfor group transfers to a chopper (named bird1) ... my problem is that  on mission start  all units start in dinghy1
so if a player jip he starts in the pbx which is not good  (if other units are in chopper)

i have conditions which are met  once the player group  are  onboard the chopper 

(onboard=true;publiucvariable"onboard")

how  could i make it so that  if player group is "onboard"  the jip guy wont start in the pbx
but will start in the chopper ....

also  if chopper has  dropped player group (gogogo=true;publicvariable"gogogo")  how could i arrange it  so that  jip guy  spawns at a marker point

this has me  stumped   ???

many thanx  in advance


long live ofpec  :angel:
 




« Last Edit: 19 Dec 2007, 20:12:22 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: that old chestnut JIP
« Reply #1 on: 19 Dec 2007, 21:30:47 »
Edit: Warning: snippet below has several errors in it. Do not use!

Not 100% certain but here goes:

One variable called startPos.  Set it to 1 when mission starts. Set it to 2 when players in chopper. Set it to 3 otherwise. Do not set it in the init.sqf!
init.sqf
Code: [Select]
if isServer then {onPlayerConnected "publicVariable ""startPos""";};
if isPlayer then {nil = [] execVM "setPlayerStart.sqf";};

setPlayerStart.sqf
Code: [Select]
if not isNil startPos then {
   waitUntil {player == player}; // there probably is a better way of doing this!
   switch (startPos) do {
// player in boat
      case 1: {
         player moveInCargo myBoat;
      };
// player in chopper
      case 2: {
         player moveInCargo myChopper;
      };
// player at marker
      case 3: {
         player setPos getMarkerPos "markerStart";
      };
   };
else {
   exitWith {};
};


Edit : Warning: snippet above has several errors in it. Do not use!
« Last Edit: 12 May 2008, 17:04:37 by Mr.Peanut »
urp!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: that old chestnut JIP
« Reply #2 on: 19 Dec 2007, 21:45:44 »
You may check all that in init.sqf or init.sqs which, AFAIK, are executed also for JIP players.
Code: [Select]
// init.sqf
Sleep 1;
_leader = obNull;
if (alive player) then
{
   _leader = leader group player;
   if (((vehicle player) distance (vehicle _leader)) > 100) then
   {
   // The player is far away from the leader of his group
      if (vehicle _leader != _leader) then
      {
      // Player group leader is inside a vehicle
         if (((vehicle _leader) emptyPositions "cargo") > 0) then
         {
         // There are cargo positions left
            player moveInCargo vehicle _leader;       
         }
         else
         {
         // There are no cargo positions left, the new player is sent to a safe placement
            player setPos getMarkerPos "mk_safepoint";
         };
      }
      else
      {
      // The leader of player's group is on foot
         _poslead = getPos leader group player;
         _dirlead = 180 + getDir leader group player;
         player setDir _dirlead;
         player setPos [(_poslead select 0)+sin(_dirlead+180)*3, (_poslead select 1)+cos(_dirlead+180)*3, 0];
      };
   };
};

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: that old chestnut JIP
« Reply #3 on: 19 Dec 2007, 22:01:17 »
Code: [Select]
waitUntil {player == player}; // there probably is a better way of doing this!

Code: [Select]
waitUntil { not (isNull player) };
makes more sense to the reader (player != player as long as player is objNull).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #4 on: 20 Dec 2007, 18:41:00 »
thanx a million  guys
will try this out  asap  ...

nice one fellas .. :clap:
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: that old chestnut JIP
« Reply #5 on: 20 Dec 2007, 20:27:17 »
Init.sqf

Code: [Select]
// init.sqf
Sleep 1;
[] spawn
{
   _leader = obNull;
   waitUntil {alive player};

   _leader = leader group player;
   if (((vehicle player) distance (vehicle _leader)) > 100) then
   {
   // The player is far away from the leader of his group
      if (vehicle _leader != _leader) then
      {
      // Player group leader is inside a vehicle
         if (((vehicle _leader) emptyPositions "cargo") > 0) then
         {
         // There are cargo positions left
            player moveInCargo vehicle _leader;       
         }
         else
         {
         // There are no cargo positions left, the new player is sent to a safe placement
            player setPos getMarkerPos "mk_safepoint";
         };
      }
      else
      {
      // The leader of player's group is on foot
         _poslead = getPos leader group player;
         _dirlead = 180 + getDir leader group player;
         player setDir _dirlead;
         player setPos [(_poslead select 0)+sin(_dirlead+180)*3, (_poslead select 1)+cos(_dirlead+180)*3, 0];
      };
   };
};

// Rest of your init.sqs code here

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #6 on: 20 Dec 2007, 21:38:37 »
thanx a million mate 
  now i get you !!
   best wishes
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re: that old chestnut JIP
« Reply #7 on: 28 Dec 2007, 21:43:07 »
Are you sure "waitUntil {alive player}" works?! As far as I know when the map starts there is no player object... so if there's no player object.... then that command is just skipped over. The only way I've been able to successfully run a script ONLY IF player is an object (and playerSide as well) is to have a trigger that runs when "local player". The trigger will fail when player is null but it continues to check for it.. which is why this works.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: that old chestnut JIP
« Reply #8 on: 29 Dec 2007, 01:45:17 »
It depends what "no player object" means. If it means player is nil, then no, that line won't work at all (and will be simply ignored). However, as far as I am aware, player is objNull when it is not set to a real player object at the start of the game, so isNull player will be true and alive player will be false. This is why I prefer waitUntil { not (isNull player) } rather than waitUntil { alive player } or even waitUntil { player == player } since it is much clearer why you are waiting.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #9 on: 14 Jan 2008, 11:10:28 »
hi

the script  works fine  when the player units start on land
however if they start in transport ie boat insertion, the script is ignored. 
and the jip player starts in cargo of his vehicle .

is there a way to only move the player in cargo of his insertion vehicle
if say the first objective hadnt been completed ??

hope i make sense  ..

an excellent script   many thanx 
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: that old chestnut JIP
« Reply #10 on: 14 Jan 2008, 11:16:13 »
Do you mean that the JIP player may be already into a vehicle by default?
And in that case, if the JIP player's vehicle is far away from the position of the group leader you would expect the JIP player to leave its default vehicle and move close to the leader position or even into the vehicle of the leader?

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #11 on: 14 Jan 2008, 11:39:44 »
hi mate

thats exactly the problem  ....
 :)
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: that old chestnut JIP
« Reply #12 on: 14 Jan 2008, 11:57:03 »
Just after
Code: [Select]
_leader = leader group player;

insert the following:
Code: [Select]
if ((vehicle player != player) && (vehicle player != vehicle _leader)) then
{
   player action ["GETOUT", vehicle player];
   unassignVehicle player;
};

Problem is that if a unit is already inside a vehicle, you cannot directly move to a different position into a vehicle, a position outside the vehicle or into another vehicle unless you get out him first.

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #13 on: 14 Jan 2008, 13:01:31 »
will the moving of the unit be visible to the player who jip ?
 
if so would it be possible to add a blackout  to hide the movement when player connects ?

again many thanx for all your help   :)
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: that old chestnut JIP
« Reply #14 on: 14 Jan 2008, 13:34:30 »
Yes, you should put a BLACK FADED titletext at the very beginning of the init.sqf and a BLACK IN once the repositioning check is finished.

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #15 on: 14 Jan 2008, 22:42:09 »
many thanx mate ...
"HOLY SARDINE" - see Shark-Attack meet his match

Offline Sick

  • Members
  • *
    • Dev-Heaven.net
Re: that old chestnut JIP
« Reply #16 on: 24 Jan 2008, 15:10:00 »
It depends what "no player object" means. If it means player is nil, then no, that line won't work at all (and will be simply ignored). However, as far as I am aware, player is objNull when it is not set to a real player object at the start of the game, so isNull player will be true and alive player will be false. This is why I prefer waitUntil { not (isNull player) } rather than waitUntil { alive player } or even waitUntil { player == player } since it is much clearer why you are waiting.
I think you are mistaken mate, im not 100% sure, can't test it atm, but afaik, a waitUntil will always wait until the condition is true,
even if the condition contains nil variables. It will simply wait until the variables are not nil and the condition becomes true.
« Last Edit: 24 Jan 2008, 15:29:39 by Sick »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: that old chestnut JIP
« Reply #17 on: 24 Jan 2008, 23:42:04 »
Actually, on testing I find that you are right about the operation of waitUntil. Sorry! waitUntil does wait until the condition is actually true, rather than just being non-false as I suspected. Still, I think my other statements are correct in spite of this error (specifically that player is defined as a null object, rather than being undefined/nil, on a dedicated server throughout a game or a dedicated client at the start of a game). I'm sure I've successfully used this particular value directly in if statements as well as in waitUntil (both then and else clauses of an if statement are ignored if there is an undefined value anywhere in the logical expression). Still, I haven't done a specific MP test on this, so I might still be wrong in the other parts of my original statement.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #18 on: 26 Mar 2008, 20:18:02 »
the script  posted by MAN THE MAN  works great  however during testing  when using Norrins revive script
we have found if the leader is awaiting revive   then the jip will spawn at startpont
(if he is lucky ... could be anywhere )

would it be possible to have jip start at a  marker pos
(which is moved in conjunction with completed objectives )

thanks in advance guys    :)

trying to include in an upcoming co op pack
« Last Edit: 26 Mar 2008, 20:20:59 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline paritybit

  • Members
  • *
Re: that old chestnut JIP
« Reply #19 on: 26 Mar 2008, 22:15:51 »
I was integrating the multiple respawn points script into my mission and had problems until I made the "main" respawn marker "respawn_west".  The problem was similar to what you are describing -- occasionally players would spawn in what seemed to be random locations (in the ocean mostly).  Once I changed the main respawn point (I think "base_respawn" or something") to "respawn_west" I didn't have any more trouble.
Heroes don't die -- they just respawn.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: that old chestnut JIP
« Reply #20 on: 27 Mar 2008, 01:49:44 »
would it be possible to have jip start at a  marker pos

Well, a JIP will execute init.sqf so you might try something like:
Code: [Select]
// whateverelse in init.sqf
waitUntil {local player};
Sleep 0.1;
player setPos getMarkerPos "mk_respawn1";

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #21 on: 28 Mar 2008, 16:53:37 »
thanks mate ...
will give it a go
cheers   :)
"HOLY SARDINE" - see Shark-Attack meet his match

Offline sharkattack

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #22 on: 26 Apr 2008, 14:01:10 »
im trying to have  players join in progress at a marker (startpoint)..  the marker will move as objectives are cleared

"mk_startpoint" setMarkerPos getMarkerPos "mk_pos_two";

this seems to work as the marker shifts position  when  conditions are met
however the jip still starts at the markers origional position

anyone see what im doing wrong

// init.sqf

if (isServer) then {intro = true; publicVariable "intro";};
server execVM "revive_init.sqf";
waitUntil {local player};
Sleep 0.1;
player setPos getMarkerPos "mk_startpoint";


many thanks  in advance     ???





"HOLY SARDINE" - see Shark-Attack meet his match

Offline Loyalguard

  • Former Staff
  • ****
Re: that old chestnut JIP
« Reply #23 on: 27 Apr 2008, 00:56:34 »
I am assuming that for JIP Players that the marker position has not been updated as it has moved so it is wherever it was when you placed it at mission start.

The only solution that immediately comes to mind is to store/update mk_startpoint's position as a public variable so when a JIP player joins you can use public variable to update the marker position then setPos the player to it.  So, whenever you move the marker also re-broadcast the pv and then add a move marker sequence using the pv for JIP players.  This solution requires 1.09 or above since it was only after 1.09 that public variable could be used for arrays.  If not using 1.09 or later then you would have to use a separate pv for the x, y, and z elements of the position array.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: that old chestnut JIP
« Reply #24 on: 27 Apr 2008, 08:42:51 »
I think the markers, as any other global object in the game which position has changed, are synced with any new client connecting.
Try the following, change the Sleep 0.1 by Sleep 2