Announcement

Collapse
No announcement yet.

Editing question: Inits, JIP and Flashlights.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Editing question: Inits, JIP and Flashlights.

    I'm working on a mission and had some questions for some editors about the best means to accomplish my various scripting/editor related goals. I would like to accomplish the following:

    1. Restore specific unit's init line on respawn (to preserve an addaction 'call artillery' which inits when the unit joins the game. Right now when the unit dies, it respawns without the addaction. I'm already using the weapon respawn script, but units still respawn without whatever is in their backpacks or other elements of their init line. The script works for preserving weapons but I need something that will run the entire init line including the backpack and unit-specific init commands.

    2. Have objectives update for JIP players. Right now I have created objectives showing for JIP players but completed objectives are 'uncompleted' for JIP players. I've asked in the editing channel but have only been told it's complicated. How complicated? What do I need to search for to start doing this?

    3. Has anybody successfully implemented the flashlight signalling script from Nightstrike in their own missions? I Unpbo'd it and exported all flashlight specific scripting to my own mission, but still can't get it to work right (no addaction appears for the players). Just wondering if anybody has experience with this particular script.


    If the leader is filled with high ambition and if he pursues his aims with audacity and strength of will, he will reach them in spite of all obstacles.
    -Carl Von Clausewitz



    'The Great Game' -Blog on War in Afghanistan:

  • #2
    Re: Editing question: Inits, JIP and Flashlights.

    1. Check out the TG Script Bank thread and look for Respawn Script/Ticket system script. Only changes you need to do is remove the ticket system if you do not wish to use it by removing any lines that has "TICKETS". It includes preserving backpack and weapon-on-back.

    Now for the actions... you have to readd the action after
    Code:
     if (player != player) exitWith {};
    and before the close brackets of the while loop, i.e. ("};")

    NOTE: I am referring to the respawn script on the TG Script Bank. Also, note the correction I made. (made a mistake for the code in the init.sqf)

    2. player is NULL at first for JIP players.

    use this line of code to make certain that w/e code you have that involves "player" will run after player has successfully synchronized
    Code:
    if (!isDedicated && isNull player) then { waitUntil {!isNull player}; };
    // Rest of code


    IN GAME ARMA: |TG-Irr| Lq.Snake

    Comment


    • #3
      Re: Editing question: Inits, JIP and Flashlights.

      Thank you for that, Snake. I checked it out. Question though:

      The action I'm adding is specific to only one unit named 'ratelo' can I put an if statement in an if statement like:

      Code:
      while {true} do
      {
      	if (!alive player) then
      	{
      		waitUntil {alive player}; /* Wait until player respawns */
      		sleep 0.1; /* Small delay to make sure player has respawned */
      		if (player != player) exitWith {]}; /* Checks to see if player has not gone back to the lobby screen (who knows?) */
      		TICKETS = TICKETS - 1; /* Decrementing tickets */
      		publicVariable "TICKETS"; /* Broadcasting variable through the network */
      		if (player == "ratelo") then
      		{
      			player addAction ["Call Artillery","bon_artillery\dialog\openMenu.sqf",["Arti_dlg"],-1,false,true,"",""]
      		};
      		// Rearming player
      		removeAllWeapons player;
      		removeAllItems player;
      		{player addMagazine _x} forEach _magazinesinit;
      		{player addWeapon _x} forEach _weaponsinit;
      		{player addweapon _x} forEach _itemsinit;
      		// Checking to see if player has rucksack
      		if (player call ACE_Sys_Ruck_fnc_hasRuck) then {{[player, _x] call ACE_Sys_Ruck_fnc_AddMagToRuck} forEach _arrayRuck;};
      		// Checking if player had weapon on back
      		if (format["%1", _weaponOnBack] != "<NULL>") then {player setVariable ["ACE_WeaponOnBack", _weaponOnBack];};
      		player selectWeapon primaryWeapon player;
      	};
      	sleep 5;
      }; /* End of while loop */
      Am I even on the right track here? This last didn't work but I sense I'm close to a solution. Thanks again.


      If the leader is filled with high ambition and if he pursues his aims with audacity and strength of will, he will reach them in spite of all obstacles.
      -Carl Von Clausewitz



      'The Great Game' -Blog on War in Afghanistan:

      Comment


      • #4
        Re: Editing question: Inits, JIP and Flashlights.

        you have the right concept but here is how you would check for the name:

        Code:
        if (format["%1", player] == "ratelo") then { //code };


        IN GAME ARMA: |TG-Irr| Lq.Snake

        Comment


        • #5
          Re: Editing question: Inits, JIP and Flashlights.

          respawn.sqf
          Code:
          // By Lq.Snake
          // Questions?  PM nthamma on TG forums
          
          // Should only be run client side since player does not exist in dedicated servers
          
          // Checking if player has successfully synchronized (for JIPs)
          if (!isDedicated && isNull player) then
          {
          	waitUntil {!isNull player};
          };
          
          sleep 5; /* Small delay that will wait until the gear of each unit initializes */
          
          private ["_weaponsinit", "_itemsinit", "_magazinesinit", "_weaponOnBack"];
          
          // Initializing/Declaration of local variables
          _weaponsinit = weapons player; /* Returns all the weapons of the player and assigns it to the variable */
          _itemsinit = items player; /* Returns all items of the player and assigns it to the variable */
          _magazinesinit = magazines player; /* Returns all magazines of player and assigns it to the variable */
          _arrayRuck = player call ACE_Sys_Ruck_fnc_RuckMagazines; /* Returns all ruck items and stores them into variable */
          _weaponOnBack = player getVariable "ACE_WeaponOnBack"; /* Returns the weapon on back and stores it into a variable */
          
          while {true} do
          {
          	if (!alive player) then
          	{
          		waitUntil {alive player}; /* Wait until player respawns */
          		sleep 0.1; /* Small delay to make sure player has respawned */
          		if (player != player) exitWith {]}; /* Checks to see if player has not gone back to the lobby screen (who knows?) */
          		TICKETS = TICKETS - 1; /* Decrementing tickets */
          		publicVariable "TICKETS"; /* Broadcasting variable through the network */
          		if (format["%1", player] == "ratelo") then 
          		{
          			player addAction ["Call Artillery","bon_artillery\dialog\openMenu.sqf",["Arti_dlg"],-1,false,true,"",""]
          		};
          		// Rearming player
          		removeAllWeapons player;
          		removeAllItems player;
          		{player addMagazine _x} forEach _magazinesinit;
          		{player addWeapon _x} forEach _weaponsinit;
          		{player addweapon _x} forEach _itemsinit;
          		// Checking to see if player has rucksack
          		if (player call ACE_Sys_Ruck_fnc_hasRuck) then {{[player, _x] call ACE_Sys_Ruck_fnc_AddMagToRuck} forEach _arrayRuck;};
          		// Checking if player had weapon on back
          		if (format["%1", _weaponOnBack] != "<NULL>") then {player setVariable ["ACE_WeaponOnBack", _weaponOnBack];};
          		player selectWeapon primaryWeapon player;
          	};
          	sleep 5;
          }; /* End of while loop */

          init.sqf
          Code:
          ace_sys_tracking_markers_enabled = false;
          //objective variables
          if (isNil "OBJ0") then {OBJ1 = false;};
          if (isNil "OBJ1") then {OBJ1 = false;};
          if (isNil "OBJ2") then {OBJ2 = false;};
          onPlayerConnected "[] exec ""scripts\TargetUpdate.sqs"" ";
          //begin init.sqf
          if (isServer) then { //server
          finishMissionInit;
          [] execVM "agincourt.sqf";
          if (isServer) then { TICKETS = 30; publicVariable "TICKETS"; };
          HW_Arti_CannonNumber = 9;			// Number cannons
          HW_number_artilleryshells_per_hour = 50;	// Number rounds per hour
          };
          if (not isDedicated) then
          {
          	waitUntil{(not isNull player) and (player == player)};
          };
          
          if (!(isNull player)) then  //non-JIP player
          {
          	[] execVM "briefing.sqf";
          	[] execVM "bon_artillery\bon_arti_init.sqf";
          	if (!isDedicated) then { [] execVM "respawn.sqf"; };
          
          	[] spawn
          	{
          		titleText [" ", "BLACK FADED"];
          		sleep 5;
          		titleText ["'We few, we happy few, we band of brothers, For he to-day that sheds his blood with me shall be my brother...' - 
          
          Shakespeare's Henry V", "BLACK FADED"];
          		sleep 5;
          		cutText ["Operation Agincourt","BLACK FADED", 3];
          		sleep 4;
          		titleText ["Mission by H. Rearden", "PLAIN DOWN", 0.6];
          		sleep 5;
          		cutText ["Brought to you by TacticalGamer.com - The PREMIERE online community for mature gamers", "BLACK IN", 6];
          		sleep 5;
          		titleText ["Special Thanks to: Lq.Snake, PCLIPSE, Mikee and Beita for their scripts and knowledge.", "PLAIN DOWN", 0.6];
          		sleep 5;
          	};
          };
          
          if (!isServer && isNull player) then  //JIP player
          {
          	waitUntil {!isNull player};
          	
          	[] execVM "briefing.sqf";
          	[] execVM "bon_artillery\bon_arti_init.sqf";
          	if (!isDedicated) then { [] execVM "respawn.sqf"; };
          	if (!isNil "obj0") then {MAG_tskObj0 setTaskState "SUCCEEDED"};
          	if (!isNil "obj1") then {MAG_tskObj1 setTaskState "SUCCEEDED"};
          	if (obj1 == true) then {MAG_tskObj2 = player createSimpleTask["Clear Russian Reconnaissance Post"];  
          MAG_tskObj2 setSimpleTaskDescription["Given the evidence, we can justify a pre-emptive strike against a Russian Army reconnaissance listening post 
          
          located at <marker=dvlc>Devil's Castle<marker> prosecute this attack at your own discretion","Clear Russian Reconnaissance Post"," "];
          player setCurrentTask MAG_tskObj2; 
          casus = execVM "comref2.sqf";
          MAG_tskObj2 setSimpleTaskDestination (getMarkerPos "dvlc");
          
          };
          
          	[] spawn
          	{
          		titleText [" ", "BLACK FADED"];
          		sleep 5;
          		titleText ["'We few, we happy few, we band of brothers, For he to-day that sheds his blood with me shall be my brother...' - 
          
          Shakespeare's Henry V", "BLACK FADED"];
          		sleep 5;
          		cutText ["Operation Agincourt","BLACK FADED", 3];
          		sleep 4;
          		titleText ["Mission by H. Rearden", "PLAIN DOWN", 0.6];
          		sleep 5;
          		cutText ["Brought to you by TacticalGamer.com - The PREMIERE online community for mature gamers", "BLACK IN", 6];
          		sleep 5;
          		titleText ["Special Thanks to: Lq.Snake, PCLIPSE and Beita for their scripts and knowledge.", "PLAIN DOWN", 0.6];
          		sleep 5;
          	};
          };
          Script is not putting ammunition back in units packs -or- restoring the addAction. So I think I screwed up somewhere. My init is a mess, but it -sort of- works. I don't think the problem is in the init per se.

          On the upside, the action does show for JIP's, so do ruck contents. Thanks for the help again, Snake.


          If the leader is filled with high ambition and if he pursues his aims with audacity and strength of will, he will reach them in spite of all obstacles.
          -Carl Von Clausewitz



          'The Great Game' -Blog on War in Afghanistan:

          Comment


          • #6
            Re: Editing question: Inits, JIP and Flashlights.

            I'll just show what I've stolen from KidDynamite, and what has been recycled from Domination (probably originally written by Xeno?). Look at exactly what it does:

            First, the trigger to execute a script when a player joins or a player is spawned at mission start is here:

            http://www.tacticalgamer.com/armed-a...ml#post1434918

            Then the "x_jip.sqf" from Untern is below. There are a few things to notice that pertain to what you posted:

            x_jip.sqf:

            a) Notice that he calls his tasks "Ziel" (German), so a JIP will have the red markers turned green if the boolean Ziel1 2 3 etc have already been completed

            b) execVM "x_scripts\x_playerweapons.sqf";
            --a while loop waiting until player !alive then strips weapons from bodies (if you want) and then takes weapons away and puts them back on (not sure why)

            c) He defines have the action (in this case, "x_repair_service" and the important classname is "ACE_usarmy_sapper" ie-- engineers... this can be very similar to your artillery action, just a different classname will be there)

            d) He checks if you are in the "x_repair_service" and adds a trigger
            --x_sfunc = compile preprocessFile "x_scripts\x_pservicefunc.sqf";
            --this returns a boolean, it checks if the action should be available in the action menu (does a nearestObject for repairable vehicles, and checks if the current player is an engineer, since they can repair stuff with their hands and also flip vehicles)

            Anyway, notice that this is all done with setTriggerStatements which also comes with it's own "on deactivation" parameter.

            http://community.bistudio.com/wiki/setTriggerStatements

            ...and here is a ton of code (see Untern Lehrgang in your MPCache to see it all, it's a great mission to study, or open Domination if you really want to flip your wig)...

            Code:
            //x_jip.sqf
            
            if (!(local player)) exitWith{};
            [] execVM "intro.sqf";
            
            player setVariable ["BIS_noCoreConversations", true];
            
            if (Ziel1) then {
            	"t4" setMarkerColorLocal "ColorGreen";
            	"t1" setMarkerColorLocal "ColorGreen";
            	task1 settaskstate "Succeeded";
            } else {
            	"Ziel1" addPublicVariableEventHandler {
            		"t4" setMarkerColorLocal "ColorGreen";
            		"t1" setMarkerColorLocal "ColorGreen";
            		hint "Grishino is cleared!!";
            		playmusic "Ambient05_Cobalt";
            		task1 settaskstate "Succeeded";
            		[objNull, ObjNull, task1, "SUCCEEDED"] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";
            	};
            };
            
            if (Ziel2) then {
            ...etc...
            } else {
            	"Ziel2" addPublicVariableEventHandler {
            		"t2" setMarkerColorLocal "ColorGreen";
            		...etc...
            	};
            };
            
            if (Ziel3) then {
            	"t3" setMarkerColorLocal "ColorGreen";
            	task2 settaskstate "Succeeded";
            } else {
            	"Ziel3" addPublicVariableEventHandler {
            		"t3" setMarkerColorLocal "ColorGreen";
            		...etc...
            	};
            };
            
            execVM "x_scripts\x_playerweapons.sqf";
            
            x_repair_service = ["SoldierESaboteurPipe","ACE_usarmy_sapper"];
            
            if (count x_repair_service > 0) then {
            	if ((typeOf player) in x_repair_service) then {
            		player sideChat "You are an engineer. You can restore wrecked vehicles with the repair truck .  You can repair damaged vehicles using only your hands.";
            		x_sfunc = compile preprocessFile "x_scripts\x_pservicefunc.sqf";
            		x_ffunc = compile preprocessFile "x_scripts\x_fflip.sqf";
            		d_rep_truck = (
            			if (playerSide == east) then {"UralRepair"} else {"MtvrRepair"}
            		);
            		x_repair_obj = objNull;
            
            //create an action to flip vehicles
            		_trigger = createTrigger["EmptyDetector" ,position player];
            		_trigger setTriggerArea [0, 0, 0, false];
            		_trigger setTriggerActivation ["NONE", "PRESENT", true];
            		_trigger setTriggerStatements["call x_ffunc", "unflip_actionID=player addAction [""Unflip Vehicle"", ""x_scripts\unflipVehicle.sqf"",[unflip_objectID],-1,false];", "player removeAction unflip_actionID"];
            
            //create an action to repair vehicles
            		_trigger = createTrigger["EmptyDetector" ,position player];
            		_trigger setTriggerArea [0, 0, 0, true];
            		_trigger setTriggerActivation ["NONE", "PRESENT", true];
            		_trigger setTriggerStatements["call x_sfunc", "rep_actionID = player addAction [""Repair Vehicle"", ""x_scripts\x_repengineer.sqf"",[],-1,false]", "player removeAction rep_actionID"];
            	};
            };
            
            if (true) exitWith {};
            Code:
            //x_playerweapons.sqf
            //while {true} do {
            //   waitUntil {!alive player};
            //the above is a bit cynical, but we all gotta die some day...
            
            private ["_p", "_weapons", "_magazines", "_hasruck", "_ruckmags", "_ruckweapons", "_primw", "_muzzles", "_items"];
            if (!(local player)) exitWith {};
            
            [] spawn {
               _endtime = time + 100;
               waitUntil {!(isNil "ace_sys_ruck_fnc_killedEH") || (time >= _endtime)};
               if (!isNil "ace_sys_ruck_fnc_killedEH") then {
                  ace_sys_ruck_fnc_killedEH = {};
               };
            };
            
            while {true} do {
               waitUntil {!alive player};
               _p = player;
               _items = items _p;
               _weapons = weapons _p;
               _magazines = magazines _p;
               _hasruck = false;
               _ruckmags = [];
               _ruckweapons = [];
               if (_p call ace_sys_ruck_fnc_hasRuck) then {
                  _ruckmags = _p getvariable "ACE_RuckMagContents";
                  _hasruck = true;
                  _ruckweapons = _p getvariable "ACE_RuckWepContents";
               };
               //removeAllItems _p;//uncomment if you want to strip weapons from dead bodies
               //removeAllWeapons _p;//this too
               waitUntil {alive player};
               player setVariable ["BIS_noCoreConversations", true];
               _p = player;
            
            //remove all player weapons
               removeAllItems _p;
               removeAllWeapons _p;
               removeMagazines _p;
            
            //...and put them all back (not perfect alone, but works well with weapons respawn script)
               {_p addMagazine _x;} forEach _magazines;
               {_p addWeapon _x;} forEach _weapons;
               {_p addItem _x;} forEach _items;
                _primw = primaryWeapon _p;
               if (_primw != "") then {
                    _p selectWeapon _primw;
                  //  Fix for weapons with grenade launcher
                    _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
                    _p selectWeapon (_muzzles select 0);
                };
               if (_hasruck) then {
            		if (!isNil "_ruckmags") then {
            			_p setvariable ["ACE_RuckMagContents", _ruckmags];
            		};
            		if (!isNil "_ruckweapons") then {
            			_p setvariable ["ACE_RuckWepContents", _ruckweapons];
            		};
               };
               "RadialBlur" ppEffectAdjust [0.0, 0.0, 0.0, 0.0];
               "RadialBlur" ppEffectCommit 0;
               "RadialBlur" ppEffectEnable false;
               "DynamicBlur" ppEffectEnable false;
            };
            ...and just so you can see how these two lines work together up in x_jip.sqf, x_sfunc will return a boolean, and in the setTriggerStatements when that boolean is true the action will appear in the players action menu:

            Code:
            //the call that will return a bool
            x_sfunc = compile preprocessFile "x_scripts\x_pservicefunc.sqf";
            
            //the bool is used as the first param in this setTriggerStatements
            _trigger setTriggerStatements["call x_sfunc", "rep_actionID = player addAction [""Repair Vehicle"", ""x_scripts\x_repengineer.sqf"",[],-1,false]", "player removeAction rep_actionID"];
            
            //so here's that file which returns a bool:
            
            //x_pservicefunc.sqf
            //are we near an alive but damaged land vehicle?
            private ["_objs"];
            if ((vehicle player) == player)then{
            	_objs = nearestObjects [player,["LandVehicle","Air"],5];
            	if (count _objs > 0) then {
            		x_repair_obj = _objs select 0;
            		if (alive x_repair_obj) then {
            			if(damage x_repair_obj > 0.05 || fuel x_repair_obj<1)then{
            				true
            			}else{
            				false
            			};
            		}else{
            			false
            		};
            	};
            }else{
            	false
            }
            Lots to look at there, hope it helps. This code ends up with players that persistently have a certain action in their action menu and, with the weapons respawn script in their init line (and whatever weapon you want them to have there too) the gear is persistent as well.

            ...and again, I didn't write this code, I just sweated over it long enough to understand it decently to steal.

            Comment

            Connect

            Collapse

            TeamSpeak 3 Server

            Collapse

            Advertisement

            Collapse

            Twitter Feed

            Collapse

            Working...
            X