Jump to content

sabot10.5mm

Member
  • Content Count

    125
  • Joined

  • Last visited

  • Medals

Posts posted by sabot10.5mm


  1. i have a script here that checks if a player is connected to an object named uav, but instead of checking one; how can i make it check 2 or more object? sort of like [uav, uav1]. i already tried this it didnt work, it said generic error.

    ((player == UAVControl uav select 0) && (isplayer _x) && (uav in thisList))} count allUnits > 0";};};
    

  2.  

    Try this, play around with the 3 - random 3 to adjust your distance.

    // Get the destination.
    _dest = (_this select 3) select 0;
    
    // Get a random direction
    _dir = random 359;
    
    // Get destination
    _spot =  getPosATL _dest;
    
    // Move the person a few meters away from the destination then turn in the direction of _dir)
    player setDir _dir;
    player SetPosATL (_spot vectorAdd [3 - random 3, 3 - random 3,0]);
    
    
    _dest = (_this select 3) select 0;
    player setPosATL [getPosATL _dest select 0, getPosATL _dest select 1, getPosATL _dest select 2]; 
    

    works just fine i just didnt do it right. typos...

    thanks anyway


  3. // time required to full healing, hours
    #define HEALFULLTIME 24
    // critical damage blocking background healing
    #define HEALBLOCKLVL 0.75
    
    Fn_BackgroundHealing = {
    	private _now = dateToNumber date;
    	{
    		if (alive _x) then {
    			private _dmg = damage _x;
    			if (_dmg > 0 and _dmg < HEALBLOCKLVL) then {
    				private _hpr = _now - (_x getVariable ["BackgroundHealingState", _now]);
    				private _dmn = _dmg - _hpr / 0.00273973 * 24 / HEALFULLTIME;
    				_x setDamage _dmn;
    				_x setVariable ["BackgroundHealingState", if (_dmn > 0) then {_now} else {nil}];
    			}
    		}
    	} forEach allUnits
    };
    
    Fn_GameMainLoop = {
    	while {true} do {
    		sleep 1;
    		call Fn_BackgroundHealing;
    		// do something else
    	}
    };
    

    thats a very nice script, but a little problem i see is - it takes 24 hours to heal fully? i really want the script to work only for blufor and to take around 10 seconds to heal from 0.99 to 0. dont get me wrong thanks for this script.


  4. how i can teleport to the top of a tower. i tried but i cant get it to work.

     

        //this addAction ["Teleport -destinationName","teleport.sqf",[objectName]];

    // Get the destination.
    _dest = (_this select 3) select 0;


    // Get a random direction
    _dir = random 359;

    // Move the person a few meters away from the destination (in the direction of _dir)
    player SetPos [(getPos _dest select 0)-3*sin(_dir),(getPos _dest select 1)-3*cos(_dir)];
    player setPosATL [getPosATL _dest select 0, getPosATL _dest select 1, getPosATL _dest select 2];          <-------------------------------------------------------------------------------

     

    i can teleport to ground lvl but i want to get the "above terrain lvl" of the object and teleport to the top of a tower.

    edit. nevermind the setposatl works perfectly..

    oh and patterson i just anwsered youre question.. getPosATL _dest select 2 gets the height based on the height of the object you put the init code in.

     

     

    here is my example. its a firing range with an endless supply of ai being heli dropped in once they lose 70% of its force. i use the teleport script to teleport the player to different parts of the range to get better vantage points

    http://steamcommunity.com/sharedfiles/filedetails/?id=267375554


  5.  

    i have a script to regen the players health in a mission shown below, once the player dies and respawns using a script. the regen health script stops working, i have an idea how to make it work but pretty new to coding. something along the lines of having a (waituntil) player dead command then start the loop over? is this the right track?

    private ["_newDamage","_t"];
    while {alive player} do 
    {
    	_t = time;
    	waitUntil {time - _t > 1};
    	if (damage player > 0) then 
    		{
    		_newDamage = (damage player) - 0.2;
    		player setdamage _newDamage;
    		//hintSilent format["Current Damage %1",_newdamage];
    		};
    	sleep 0.50;
    };
    
    

    waituntil wont work since the script stops until its met {blah}. so i just terminate the regen script on player death and exe on player spawn


  6. Use a respawn event handler:

     

    //in your initPlayerLocal.sqfplayer addEventHandler [    "Respawn",    {[] execVM "yourScript.sqf";}];
    EDIT: Can you post the script you use for respawn?

     

    /*
    A script for SP Respawn.
    By Twirly - 6th July 2011
    */
    
    private ["_plyr","_kilr","_type","_group","_dist","_camera","_found","_rand","_unit"];
    
    _plyr = _this select 0;
    _kilr = _this select 1;
    _mrkr = if (count _this >2) then {_this select 2};
    
    if (isNil "_kilr") then {_kilr = objNull};
    
    //grab some stuff we need later
    _type = typeOf _plyr;
    _group = group _plyr;
    _dist = _plyr distance _kilr;
    
    if (count _this > 2) then {
    //if (not (isNil _mrkr)) then {
    	//create the new unit.... same group
    	_unit = _group createUnit [_type, (getMarkerPos _mrkr), [], 1, "COLONEL"];
    	sleep 2;
    	addSwitchableUnit _unit;
    	selectPlayer _unit;
    	_unit setUnitRank "COLONEL";
    	waitUntil {_unit == player};
    	_found = true;
        _oldUnit = _this select 1;
        _oldGroup = group _oldUnit;
            
        //We dont care if he was not the leader
        if (leader _oldGroup == _oldUnit) then {
            
            h = [_oldUnit, _oldGroup] spawn {
                
                _oldUnit = _this select 0;
                _oldGroup = _this select 1;
                
                _oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules",[]];
                _HQ = _oldUnit getVariable ["BIS_SUPP_HQ",nil];
    
                //Wait for a new leader to be assigned            
                waitUntil { leader _oldGroup != _oldUnit };
                _leader = leader _oldGroup;
        
                if ((count _oldProviders) > 0) then {
                  {
                        _providerModule = _x;
                        {
                             if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then {
                                  [_leader, _x, _providerModule] call BIS_fnc_addSupportLink;
                             };
                        }forEach synchronizedObjects _providerModule;
                  }forEach _oldProviders;
                };
               
                {
                  _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0];
                  _leader setVariable [format ["BIS_SUPP_used_%1", _x], _used, true]
                } forEach [
                  "Artillery",
                  "CAS_Heli",
                  "CAS_Bombing",
                  "UAV",
                  "Drop",
                  "Transport"
                ];
                _leader setVariable ["BIS_SUPP_transmitting", false];
                _leader kbAddTopic ["BIS_SUPP_protocol", "A3\Modules_F\supports\kb\protocol.bikb", "A3\Modules_F\supports\kb\protocol.fsm", {call compile preprocessFileLineNumbers "A3\Modules_F\supports\kb\protocol.sqf"}];
                if (!(isNil "_HQ")) then {
                  _leader setVariable ["BIS_SUPP_HQ", _HQ];
                };
            };
        };  
    
    
    execVM "light.sqf";
            
       
            
    } else {
    	//try to find a random playable unit
    	while {(not (_found)) and ((count switchableunits) >=1)} do {
    		_unit = switchableunits select (floor (random (count switchableunits)));
    		if (alive _unit) then {
    			_found = true;
    			selectplayer _unit;
    		};
    		sleep 1;
    	};
    };
    
    private ["_newDamage","_t"];
    while {alive player} do 
    {
    	_t = time;
    	waitUntil {time - _t > 1};
    	if (damage player > 0) then 
    		{
    		_newDamage = (damage player) - 0.2;
    		player setdamage _newDamage;
    		//hintSilent format["Current Damage %1",_newdamage];
    		};
    	sleep 0.50;
    };
    
    
    
    
    
    
    
    • Like 2

  7. i have a script to regen the players health in a mission shown below, once the player dies and respawns using a script. the regen health script stops working, i have an idea how to make it work but pretty new to coding. something along the lines of having a (waituntil) player dead command then start the loop over? is this the right track?

    private ["_newDamage","_t"];
    while {alive player} do 
    {
    	_t = time;
    	waitUntil {time - _t > 1};
    	if (damage player > 0) then 
    		{
    		_newDamage = (damage player) - 0.2;
    		player setdamage _newDamage;
    		//hintSilent format["Current Damage %1",_newdamage];
    		};
    	sleep 0.50;
    };
    
    

  8. this is the code i am using to respawn the player. supports sometimes isnt synced to the player on respawn

    /*
    A script for SP Respawn.
    By Twirly - 6th July 2011
    */
    
    private ["_plyr","_kilr","_type","_group","_dist","_camera","_found","_rand","_unit"];
    
    _plyr = _this select 0;
    _kilr = _this select 1;
    _mrkr = if (count _this >2) then {_this select 2};
    
    if (isNil "_kilr") then {_kilr = objNull};
    
    //grab some stuff we need later
    _type = typeOf _plyr;
    _group = group _plyr;
    _dist = _plyr distance _kilr;
    
    if (count _this > 2) then {
    //if (not (isNil _mrkr)) then {
    	//create the new unit.... same group
    	_unit = _group createUnit [_type, (getMarkerPos _mrkr), [], 1, "COLONEL"];
    	sleep 2;
    	addSwitchableUnit _unit;
    	selectPlayer _unit;
    	_unit setUnitRank "COLONEL";
    	waitUntil {_unit == player};
    	_found = true;
        _oldUnit = _this select 1;
        _oldGroup = group _oldUnit;
            
        //We dont care if he was not the leader
        if (leader _oldGroup == _oldUnit) then {
            
            h = [_oldUnit, _oldGroup] spawn {
                
                _oldUnit = _this select 0;
                _oldGroup = _this select 1;
                
                _oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules",[]];
                _HQ = _oldUnit getVariable ["BIS_SUPP_HQ",nil];
    
                //Wait for a new leader to be assigned            
                waitUntil { leader _oldGroup != _oldUnit };
                _leader = leader _oldGroup;
        
                if ((count _oldProviders) > 0) then {
                  {
                        _providerModule = _x;
                        {
                             if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then {
                                  [_leader, _x, _providerModule] call BIS_fnc_addSupportLink;
                             };
                        }forEach synchronizedObjects _providerModule;
                  }forEach _oldProviders;
                };
               
                {
                  _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0];
                  _leader setVariable [format ["BIS_SUPP_used_%1", _x], _used, true]
                } forEach [
                  "Artillery",
                  "CAS_Heli",
                  "CAS_Bombing",
                  "UAV",
                  "Drop",
                  "Transport"
                ];
                _leader setVariable ["BIS_SUPP_transmitting", false];
                _leader kbAddTopic ["BIS_SUPP_protocol", "A3\Modules_F\supports\kb\protocol.bikb", "A3\Modules_F\supports\kb\protocol.fsm", {call compile preprocessFileLineNumbers "A3\Modules_F\supports\kb\protocol.sqf"}];
                if (!(isNil "_HQ")) then {
                  _leader setVariable ["BIS_SUPP_HQ", _HQ];
                };
            };
        };  
    
            
       
            
    } else {
    	//try to find a random playable unit
    	while {(not (_found)) and ((count switchableunits) >=1)} do {
    		_unit = switchableunits select (floor (random (count switchableunits)));
    		if (alive _unit) then {
    			_found = true;
    			selectplayer _unit;
    		};
    		sleep 1;
    	};
    };
    
    
    

  9. i created a single player mission with player respawn, synced with a few support modules. i have a problem with syncing the modules back to the player, it just wont work. even manualy syncing using THIS wont work.. 

     
    player addAction ["sync arty", {
    [player, req, arty] call bis_fnc_addsupportlink;
    }];
     
    player addAction ["sync drop", {
    [player, req, supply] call bis_fnc_addsupportlink;
    }];
     
    there is a carvate to this. it works after killing the ai then killing the player
    i suspect the ai leader is taking control of support

  10. im making a range mission that needs a ability to reinforce an area once the enemy loses 70% of its force using the reinforcementchopper... can anybody help me.

    ***Originally Posted by***spunFIN

    Okay, then one way to identify the militarize units would be using ID parameter of militarize. Basicly it works like this:

    1. Set ID parameter, for example to 4

    2. Now there's global variable created: LVgroup4 which refers to the group you spawn with that instance of militarize where you set ID to 4

    3. Using that variable you can now count alive militarize units with line:

    {alive _x} count units LVgroup4Then there's few ways to use this information; triggers or custom scripts. As script would give you way more possibilities, let's walk thru it with simple way:

    1: Create custom script in your mission folder, like "countMilitarize.sqf". And inside of it:

     private["_originalCount","_limit"]; //good habit to private local variables
    
    sleep 30; //script waits 30 secs at this point - to make sure militarize had enough time to spawn all units
    
    _originalCount = {alive _x} count units LVgroup4; //count units and save this data to _originalCount
    _limit = round(_originalCount * .70); //_limit = how many units is 70% of _originalCount
    
    waitUntil{sleep 4; ({alive _x} count units LVgroup4) <= _limit}; //this line makes this script to wait here until this condition is true (checks every 4 secs)
    
    //And here you do all the magic you want. You can call other scripts here the same way as in editor.
    hint "LVgroup4 has only 70% units left!";

    2: If you call your militarize instance with ID 4 in editor from some init line, you probably want to call countMilitarize.sqf from the same init field, so just use: nul = execVM "countMilitarize.sqf";

    Basicly ideal way would be calling this custom script from inside of militarize.sqf, just when it has spawned all units, but I guess you'll get started with this. Oh btw, this wont work if you're using simpleCache or simpleCacheV2.

    I hope this helps even a bit. I actually made a mission template where's few different dynamic reinforcement events with many different options, but it wont work with current version of AISSP.***

    The code below is a loop for reinforcing

    (all this goes below that waitUntil in the original piece)

    nul = [player,true,2,2,false,true,player,"random",1000,true,false,8,"default",[false,true,false,false],nil,nil,8,false] execVM "LV\reinforcementChopper.sqf"; //first reinforcements
    waitUntil{sleep 1; !isNil("LVgroup8")}; //make script wait until its group is created
    
    _Count = {alive _x} count units LVgroup8; //that same math again
    _Limit = round(_Count * .30);
    
    while{true}do{ //infinite loop
    _Count = {alive _x} count units LVgroup8; //update alive count on each time this loops
    if(_Count <= _Limit)then{ //if less than 30%, create new instance of reinforcementChopper with same ID (8)
    nul = [player,true,2,2,false,true,player,"random",1000,true,false,8,"default",[false,true,false,false],nil,nil,8,false] execVM "LV\reinforcementChopper.sqf";
    waitUntil{sleep 1; ({alive _x} count units LVgroup8)>_Limit}; //to be safe, let's again wait for units to spawn before script continues
    };
     sleep 4; //loops in 4s cycle
    };
    

    That's quite pseudo code, I hope I didn't make typos.***

    And this is very simple way, but it has one bug: we're using here only LVgroup8 now, so when new instance of reinforcementChopper is created, it overwrites original variable "LVgroup8". So if there's still those alive units from last chopper, it wont take them to next count of 30%. But I don't know, it might not be too bad thing, having like a cheap increasing difficulty level. :P

    If it works, maybe next there could be some random factors like possibility for 2 choppers to spawn, or maybe a chance for heliParadrop or something, etc.

    Thanks a bunch! spunFIN for the scripts

×