Forum Jump :

Author Message


Posts: 2
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2014-02-20 11:41        
     
I am no script wiz kid but i cant seem to come up with a valid script that detects the player position (i want it to ping every 20 seconds), whilst at say at a distance of 200 they have a combat aware stance, and 100m they change to stealth etc.

Now my units are dynamically spawned into the game. Can you guys give me points ive looked everywhere im perfectly comfortable with anything except if else statements do my head in pretty much.

I know exactly what i want i simply dont know how to go about it.

if (!isServer) exitwith {};
private ["_mygroup"];  

_mygroup = [getmarkerpos "spawnn", WEST, ["B_mas_usr_Soldier_F","B_mas_usr_Soldier_F","B_mas_usr_Soldier_F","B_mas_usr_Soldier_F"],[],[],[],[]] call BIS_fnc_spawnGroup;


Author Message


Posts: 1484
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2014-02-20 16:52        
     
Being MP it's more of a guess than anything else and not tested.



if (!isServer) exitwith {};
private ["_mygroup"];  

_mygroup = [getmarkerpos "spawnn", WEST, ["B_mas_usr_Soldier_F","B_mas_usr_Soldier_F","B_mas_usr_Soldier_F","B_mas_usr_Soldier_F"],[],[],[],[]] call BIS_fnc_spawnGroup;


while {alive player} do {
	
	{// start foreach

		switch (true) do {
	case player distance _x < 100 : {_x setbehaviour "STEALTH"};
	case player distance _x < 200 : {_x setbehaviour "COMBAT"};
	case player distance _x > 200 : {_x setbehaviour "AWARE"};
	
	};// end switch
				
		} foreach  units _mygroup;
	sleep 20;	
	};// endwhile


Advertisement


Author Message


Posts: 2
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2014-02-20 19:39        
     
Awesome mate thanks alot i went in a similar direction but i referenced the players position every 30 seconds then they just go to that position (waypoint). So basically this unit links in with another script called patrol paths (randomized).


if (!isServer) exitwith {};

private ["_mygroup"];  

_mygroup = [getmarkerpos "spawnn", WEST, 
["B_mas_usr_Soldier_F","B_mas_usr_Soldier_F","B_mas_usr_Soldier_F","B_mas_usr_Soldier_F"],[],[],[],[]] call BIS_fnc_spawnGroup;

while {{alive _x} count units _mygroup > 0 } do { 
    { 
        _x doMove getPosATL player; 
    } forEach units _mygroup;  
     
	if ((leader _mygroup) distance player < 40) then { 
        _mygroup setBehaviour "STEALTH"; 
        _mygroup setCombatMode "RED"; 
        _mygroup setSpeedMode "LIMITED"; 
    }

	else { 
        _mygroup setBehaviour "CARELESS"; 
        _mygroup setCombatMode "GREEN"; 
        _mygroup setSpeedMode "NORMAL"; 
    }; 
     
    sleep 30; 
};