Home   Help Search Login Register  

Author Topic: that old chestnut JIP  (Read 4764 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.