InsertCoins

Help with script, doesn't run can't see why

11 posts in this topic

OK, so I've seen that in an earlier version of Exile there were jets flying around on intervals. This is something I rather liked so I started searching around and found this:

http://epochmod.com/forum/index.php?/topic/28685-release-flyby/

 

I've modified it so it's called from somewhere after an event happens. The script starts up without a problem (dial_log tells me so), but no jets to be seen. What am I missing here?

Spoiler

private["_model","_startpos","_endpos"];

_model          = ["I_Plane_Fighter_03_AA_F","I_Plane_Fighter_03_CAS_F","B_Plane_CAS_01_F"] call BIS_fnc_selectRandom;
_startpos       = [6000.0,2.0];

if (IsServer) then {
    diag_log format ["Jets starting up"];
    _rand_num        = ceil(random 5);
    _number            = 0;

    for "_i" from 1 to _rand_num do {
    
        _number = (_number + 1);

        [_number,_model,_startpos] spawn {

            private["_aircraft","_aigroup","_pilot","_wp1","_wp2","_wp3","_cor_y","_cor_x"];
        
            
            _number     = _this select 0;
            _model         = _this select 1;
            _startpos     = _this select 2;
            _endpos        = [0,16000,200];

            call {
                if(_number == 1) exitWith {
                    _cor_y = 0;
                    _cor_x = 0;
                };

                if(_number == 2) exitWith {
                    _cor_y = -60;
                    _cor_x = -60;
                };

                if(_number == 3) exitWith {
                    _cor_y = -60;
                    _cor_x = 60;
                };

                if(_number == 4) exitWith {
                    _cor_y = -120;
                    _cor_x = -120;
                };

                if(_number == 5) exitWith {
                    _cor_y = -120;
                    _cor_x = 120;
                };
            };

            _aircraft     = createVehicle [_model,[((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),200],[],0,"FLY"];
            _aircraft     engineOn true;
            _aircraft     flyInHeight 200;

            _aigroup     = creategroup civilian;

            _pilot         = _aigroup createUnit ["I_pilot_F",[_aircraft] call FNC_GetPos,[],0,"FORM"];
            _pilot         setCombatMode "BLUE";
            _pilot         moveindriver _aircraft;
            _pilot         assignAsDriver _aircraft;

            _wp1         = _aigroup addWaypoint [[3986.85,8465.81,200],0];
            _wp1         setWaypointType "MOVE";
            _wp1        setWaypointBehaviour "CARELESS";

            _wp2         = _aigroup addWaypoint [[6287.57,9387.58,200],0];
            _wp2         setWaypointType "MOVE";
            _wp2         setWaypointBehaviour "CARELESS";
            
            _wp3         = _aigroup addWaypoint [[(_endpos select 0),(_endpos select 1),200],0];
            _wp3         setWaypointType "MOVE";
            _wp3         setWaypointBehaviour "CARELESS";

            waitUntil { (_aircraft distance _endpos < 500) };

            deleteVehicle _aircraft;
            deleteGroup _aigroup;
            deleteVehicle _pilot;
            diag_log format ["jets down"];
        };
    };
};

 

Share this post


Link to post
Share on other sites

Do you get any errors in your log files?

Instead of doing this

_aigroup = createGroup civilian

_pilot = _aigroup createUnit ["I_pilot_F",[_aircraft] call FNC_GetPos,[],0,"FORM"];
_pilot setCombatMode "BLUE";
_pilot moveindriver _aircraft;
_pilot assignAsDriver _aircraft;

I would do

_aigroup = createGroup civilian;
createVehicleCrew _heli;

(crew _aircraft) joinSilent _aigroup;
_aigroup selectLeader ((crew _aircraft) select 0);
_aigroup setCombatMode "BLUE";
_aigroup setBehaviour "SAFE";

If you use "CARELESS" they probably drove in to a mountain or something else. 

Share this post


Link to post
Share on other sites
Advertisement

Alright, they spawn but crash into the ocean upon spawning. Think it's because they have no speed when spawning in. Any ideas?

Share this post


Link to post
Share on other sites

tried adding 

setVelocity [200, 0, 0]


still crashing into ocean upon spawning

Share this post


Link to post
Share on other sites

try spawning them higher above the ground initially:

_aircraft     = createVehicle [_model,[((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),200],[],0,"FLY"];

change to 

_aircraft     = createVehicle [_model,[((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),500],[],0,"FLY"];

 

Share this post


Link to post
Share on other sites
20 minutes ago, second_coming said:

try spawning them higher above the ground initially:


_aircraft     = createVehicle [_model,[((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),200],[],0,"FLY"];

change to 


_aircraft     = createVehicle [_model,[((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),500],[],0,"FLY"];

 

Hmm, no that still brought them down upon spawning.

full script again:

Spoiler

private["_model","_startpos","_endpos"];

_model            = ["I_Plane_Fighter_03_AA_F","I_Plane_Fighter_03_CAS_F","B_Plane_CAS_01_F"] call BIS_fnc_selectRandom;
_startpos        = [79.3215,113.73];

if (IsServer) then {
    
    diag_log format ["Jets starting up"];
    _rand_num        = ceil(random 5);
    _number            = 0;

    for "_i" from 1 to _rand_num do {
    
        _number = (_number + 1);

        [_number,_model,_startpos] spawn {

            private["_aircraft","_aigroup","_pilot","_wp1","_wp2","_wp3","_cor_y","_cor_x"];
        
            
            _number     = _this select 0;
            _model         = _this select 1;
            _startpos     = _this select 2;
            _endpos        = [0,16000,200];

            call {
                if(_number == 1) exitWith {
                    _cor_y = 0;
                    _cor_x = 0;
                };

                if(_number == 2) exitWith {
                    _cor_y = -60;
                    _cor_x = -60;
                };

                if(_number == 3) exitWith {
                    _cor_y = -60;
                    _cor_x = 60;
                };

                if(_number == 4) exitWith {
                    _cor_y = -120;
                    _cor_x = -120;
                };

                if(_number == 5) exitWith {
                    _cor_y = -120;
                    _cor_x = 120;
                };
            };

            _aircraft     = createVehicle [_model,[((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),500],[],0,"FLY"];
            _aircraft     engineOn true;
            _aircraft     flyInHeight 200;
            _aircraft      setVelocity [200, 0, 0];

            _aigroup     = creategroup civilian;

            _pilot         = _aigroup createUnit ["I_pilot_F",[_aircraft] call FNC_GetPos,[],0,"FORM"];
            _pilot         setCombatMode "BLUE";
            _pilot         moveindriver _aircraft;
            _pilot         assignAsDriver _aircraft;

            _wp1         = _aigroup addWaypoint [[3986.85,8465.81,200],0];
            _wp1         setWaypointType "MOVE";
            _wp1        setWaypointBehaviour "SAFE";

            _wp2         = _aigroup addWaypoint [[6287.57,9387.58,200],0];
            _wp2         setWaypointType "MOVE";
            _wp2         setWaypointBehaviour "SAFE";
            
            _wp3         = _aigroup addWaypoint [[(_endpos select 0),(_endpos select 1),200],0];
            _wp3         setWaypointType "MOVE";
            _wp3         setWaypointBehaviour "SAFE";

            waitUntil { (_aircraft distance _endpos < 500) };

            deleteVehicle _aircraft;
            deleteGroup _aigroup;
            deleteVehicle _pilot;
            diag_log format ["Jets deleted"];

        };
    };
};

 

Could it be that the pilot is created too late?

Share this post


Link to post
Share on other sites

try changing

_pilot         = _aigroup createUnit ["I_pilot_F",[_aircraft] call FNC_GetPos,[],0,"FORM"];

for

_pilot         = "I_pilot_F" createUnit [ getPos _aircraft, _aigroup];

 

Share this post


Link to post
Share on other sites

this..

private["_model","_startpos","_endpos"];

_model = ["I_Plane_Fighter_03_AA_F","I_Plane_Fighter_03_CAS_F","B_Plane_CAS_01_F"] call BIS_fnc_selectRandom;
_startpos = [6000.0,2,500];


if (IsServer) then {
    diag_log format ["Jets starting up"];
    _rand_num = ceil(random 5);
    _number = 0;

    for "_i" from 1 to _rand_num do {
    
        _number = (_number + 1);

        [_number,_model,_startpos] spawn {

            private["_aircraft","_aigroup","_pilot","_wp1","_wp2","_wp3","_cor_y","_cor_x","_aircraft_found","_groupNPC","_planeposition"];
        
            
            _number = _this select 0;
            _model = _this select 1;
            _startpos = _this select 2;
            _endpos = [0,16000,200];

            call {
                if(_number == 1) exitWith {
                    _cor_y = 0;
                    _cor_x = 0;
                };

                if(_number == 2) exitWith {
                    _cor_y = -60;
                    _cor_x = -60;
                };

                if(_number == 3) exitWith {
                    _cor_y = -60;
                    _cor_x = 60;
                };

                if(_number == 4) exitWith {
                    _cor_y = -120;
                    _cor_x = -120;
                };

                if(_number == 5) exitWith {
                    _cor_y = -120;
                    _cor_x = 120;
                };
            };
			_groupNPC = createGroup East;
			_planeposition = [((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),(_startpos select 2)];
			
			[_planeposition, 180,_model, _groupNPC] call bis_fnc_spawnvehicle;
			_aircraft_found = nearestObjects [_planeposition, ["air"], 50];
			_aircraft = _aircraft_found select 0;
            _aircraft flyInHeight 300;
			
			_groupNPC setCombatMode "BLUE";
			{
				_x disableAI "AUTOTARGET";
				_x disableAI "TARGET";
				_x disableAI "SUPPRESSION";
				removeBackpackGlobal _x;
				removeAllWeapons _x;
			} forEach units _groupNPC;
			

			_wp1 = _groupNPC addWaypoint [[3986.85+_cor_y,8465.81+_cor_x],0];
			_wp1 setWaypointType "MOVE";
			_wp1 setWaypointBehaviour "CARELESS";
			_wp1 setWaypointSpeed "NORMAL";

            _wp2 = _groupNPC addWaypoint [[6287.57+_cor_y,9387.58+_cor_x],0];
            _wp2 setWaypointType "MOVE";
            _wp2 setWaypointBehaviour "CARELESS";
            
            _wp3 = _groupNPC addWaypoint [[(_endpos select 0),(_endpos select 1)],0];
            _wp3 setWaypointType "MOVE";
            _wp3 setWaypointBehaviour "CARELESS";

            waitUntil { (_aircraft distance _endpos < 500) };
			
			_aircraft deleteVehicleCrew driver _aircraft;
            deleteVehicle _aircraft;
            deleteGroup _groupNPC;
            diag_log format ["jets down"];
        };
    };
};

let me know

2 people like this

Share this post


Link to post
Share on other sites
12 hours ago, Andrew_S90 said:

this..


private["_model","_startpos","_endpos"];

_model = ["I_Plane_Fighter_03_AA_F","I_Plane_Fighter_03_CAS_F","B_Plane_CAS_01_F"] call BIS_fnc_selectRandom;
_startpos = [6000.0,2,500];


if (IsServer) then {
    diag_log format ["Jets starting up"];
    _rand_num = ceil(random 5);
    _number = 0;

    for "_i" from 1 to _rand_num do {
    
        _number = (_number + 1);

        [_number,_model,_startpos] spawn {

            private["_aircraft","_aigroup","_pilot","_wp1","_wp2","_wp3","_cor_y","_cor_x","_aircraft_found","_groupNPC","_planeposition"];
        
            
            _number = _this select 0;
            _model = _this select 1;
            _startpos = _this select 2;
            _endpos = [0,16000,200];

            call {
                if(_number == 1) exitWith {
                    _cor_y = 0;
                    _cor_x = 0;
                };

                if(_number == 2) exitWith {
                    _cor_y = -60;
                    _cor_x = -60;
                };

                if(_number == 3) exitWith {
                    _cor_y = -60;
                    _cor_x = 60;
                };

                if(_number == 4) exitWith {
                    _cor_y = -120;
                    _cor_x = -120;
                };

                if(_number == 5) exitWith {
                    _cor_y = -120;
                    _cor_x = 120;
                };
            };
			_groupNPC = createGroup East;
			_planeposition = [((_startpos select 0) + _cor_y),((_startpos select 1) + _cor_x),(_startpos select 2)];
			
			[_planeposition, 180,_model, _groupNPC] call bis_fnc_spawnvehicle;
			_aircraft_found = nearestObjects [_planeposition, ["air"], 50];
			_aircraft = _aircraft_found select 0;
            _aircraft flyInHeight 300;
			
			_groupNPC setCombatMode "BLUE";
			{
				_x disableAI "AUTOTARGET";
				_x disableAI "TARGET";
				_x disableAI "SUPPRESSION";
				removeBackpackGlobal _x;
				removeAllWeapons _x;
			} forEach units _groupNPC;
			

			_wp1 = _groupNPC addWaypoint [[3986.85+_cor_y,8465.81+_cor_x],0];
			_wp1 setWaypointType "MOVE";
			_wp1 setWaypointBehaviour "CARELESS";
			_wp1 setWaypointSpeed "NORMAL";

            _wp2 = _groupNPC addWaypoint [[6287.57+_cor_y,9387.58+_cor_x],0];
            _wp2 setWaypointType "MOVE";
            _wp2 setWaypointBehaviour "CARELESS";
            
            _wp3 = _groupNPC addWaypoint [[(_endpos select 0),(_endpos select 1)],0];
            _wp3 setWaypointType "MOVE";
            _wp3 setWaypointBehaviour "CARELESS";

            waitUntil { (_aircraft distance _endpos < 500) };
			
			_aircraft deleteVehicleCrew driver _aircraft;
            deleteVehicle _aircraft;
            deleteGroup _groupNPC;
            diag_log format ["jets down"];
        };
    };
};

let me know

Thanks @Andrew_S90, this worked. Could you, if it's not too much to ask, explain what and why you changed?

Share this post


Link to post
Share on other sites

Posted (edited)

 

@InsertCoins

I added a higher Z value in the start coords because it spawns on terrain not sea level so it needs to be high if its water spawns

 

create the group inside the loop because it is waiting to delete it and once you get there it deletes the group so no groups to delete on the others.. Thats minor..

 

then i pull the initial plane start position by adding the offsets and setting that to a new variable just because, then i use the pre ceated bis function that spawns the vehicle and the required full amount of crew in one motion, no need to place inside the vehicle

 

 

then you detect the plane on spawn in so u can delete it later, and then set the units to no gear and combat neutral

 

then u had extra value in set waypoint, its x,y and the radius of a circle that the waypoint is set in, so 0 is like exact position..

 

next all waypoints have been offset for each jet because they would hit eachother when they got close so that was needed

 

then delete everything when you end.

 

let me know if that explains everything, sorry for bad formatting/spelling errors.. On my phone lol

Edited by Andrew_S90

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.