Forum Jump :

Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location: Queensland
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-01-14 06:10        
     
Basically what is said in the Title, I am having major problems having AI being force ejected from a helicopter at an insertion point. I have followed guides and downloaded sample missions which are supposed to work, but don't. The only guess I can take as to why, is that BI have updated the game and the old methods no longer work.

This is what I want:
Have the Helicopter Move myself and another Rifleman to an insertion point where we will be force ejected and parachute to the ground. The Helicopter will then get lost, and run away somewhere else on the map

Here is what I've done:
Spawn 2 Ground Units (1 player, 1 AI) in the same group, named Rifleman1, and Rifleman2.
Spawn 1 Helicopter named 'Heli1';
The Rifleman1 (Player) Initialization field looks like this:
unit1 = group this; {_x moveincargo heli1} foreach units group this;
The Rifleman2 Initialization field looks like this:
unit1 = group this;
The Heli1 Initialization field looks like this:
heli1 flyInHeight 300;

The Helicopter has 4 waypoints.
The 1st one is a MOVE waypoint with no scripting or activation lines.
The 2nd is a MOVE Waypoint which sets its speed to limited.
The 3rd is a MOVE waypoint for the Insertion point with this in the Act Field;
unassignVehicle Rifleman1; unassignVehicle Rifleman2; Rifleman1 action ["eject", heli1];  rifleman2 action ["eject", vehicle heli1];
The 4th and Final Waypoint is a MOVE waypoint to take the helicopter away from the insertion point.

What is happening is 'I' (Rifleman 1) succesfully eject over Waypoint 3, whilst the other Rifleman2, is staying in the Helicopter. BUT, Rifleman2 ends up getting out when the Helicopter stops at it's final destination, Waypoint 4.
This has had me Baffled for quiet some time, and I have been reluctant to reach out to the community for help since so many scripting noobs like me get so much backlash for not trying and researching.
The truth is I have spent hours and hours looking for solutions to this and for months, and yet still no luck. Every solution I find is outdated and does not work with the current model of the game. So please if you can give me assistance and take it easy on me, that would be very very appreciated.

:)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#2 Posted at 2016-01-14 07:55        
     
The fact is you can suicide, jumping without parachute, but AIs are a little bit clever. :-)
Just add a parachute for each unit, and enjoy!
To be more precise (and allow to keep backpack for AT unit or else):
in init field of the player:
unit1 = group this;
{_x moveincargo heli1} foreach units unit1;
{[_x, [missionNamespace, "inv"+str(_foreachIndex)]] call BIS_fnc_saveInventory;
  removeBackpack _x;
  _x addBackPackGlobal "B_parachute";
} foreach units unit1;

optional, if you want to trigger an eject when you want, just add:
this addaction ["GO GO GO", {{_x action ["eject", heli1]} foreach units unit1;
 0 = [] spawn {
   waituntil {{isTouchingGround _x} count units unit1 == {alive _x} count units unit1};
  {[_x, [missionNamespace, "inv"+str(_foreachIndex)]] call BIS_fnc_loadInventory;
   } foreach units unit1;
 };
},nil,100,false,true,"", "{_x in helo1} count (units unit1) > 0"]

But if you want to eject at 3rd waypoint, in on act. field of the 3rd waypoint:
{_x action ["eject", heli1]} foreach units unit1;
0 = [] spawn {
   waituntil { {isTouchingGround _x} count units unit1 == {alive _x} count units unit1 };
   {[_x, [missionNamespace, "inv"+str(_foreachIndex)]] call BIS_fnc_loadInventory} foreach units unit1}

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 6
Rank:


Level: Member

Country: au
Location: Queensland
Occupation:
Age:
In-game name:

 
#3 Posted at 2016-01-14 15:13        
     
Pierre MGI:
The fact is you can suicide, jumping without parachute, but AIs are a little bit clever. :-) Just add a parachute for each unit, and enjoy!
No way, I never thought that'd be the reason. It's not like i didn't think of parachutes, i always ejected and died but that didn't bother me because i knew I could add them in at the end.
But I added the parachutes in, used your init field on the player and it worked. So thanks for that,
However, What didn't work was the addaction.
Have you tested the addaction? I tried it a few times and it never came up.

I think I might be doing something wrong but not sure.
Am I inserting it into the init field, to be clear, or should I make a script in the mission folder and call the script in game?

Thanks again!!! :D


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#4 Posted at 2016-01-14 15:50        
     
Oups! sorry for the typo! I often use helo1 in my scripts then I added lately a condition to "erase" addaction when units are ejected: read "{_x in heli1} count (units unit1) > 0" at the end of addAction instead of helo1.

Yes, you can insert the both codes in the init field of player, or in a init.sqf file if you want but you'll have to replace: this (which refers to the edited unit) with: player (variable player in fact), everywhere.

If you're working in MP, the script is a little bit more complex. Tell me.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 4
Rank:


Level: Member

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

 
#5 Posted at 2016-02-09 23:35        
     
I have a script which used to work just fine in multiplayer. But since recent changes in Arma, no longer works.
This it seems is due to the NO SUICIDE AI. ie they won't eject without a parachute.

This script is called from a waypoint.
_drop = [UH80, 100] execVM "eject.sqf"
There are two further waypoints after this with the final waypoint set as
{deleteVehicle _x} forEach crew UH80 + [UH80];

As I said script used to work fine.
See my comments in the script at my attempts to get this script to work. Units land and are equipped with their correct loadouts etc. so BIS_fnc_saveInventory and BIS_fnc_loadInventory work fine. The problem is the chopper will absolutely NOT move onto it's next waypoint.

Any help much appreciated.

eject.sqf
/* Paradrop Script. Called from Waypoint.

 _drop = [UH80, 100] execVM "eject.sqf"
*/
if (!isServer) exitWith {};
private ["_chopper","_chuteheight","_paras","_unit","_inv"];
_chopper = _this select 0;
_chuteheight = if ( count _this > 1 ) then { _this select 1 } else {100};
_paras = assignedcargo _chopper;
_vel = velocity _chopper;
_dir = direction _chopper;
enableSentences false;//Shutup about having no ammo.
_chopper animateDoor ["Door_L", 1];
_chopper animateDoor ["Door_R", 1];

paraLandSafe = 
{
    _unit = _this select 0;
//	if (isNull (unitBackpack _unit)) then {_unit addBackpack "B_parachute"};// Sometimes unit does NOT have any backpack. even though I have _x addbackpack "B_Parachute"
    (vehicle _unit) allowDamage false;// Set parachute invincible to prevent exploding if it hits buildings
    waitUntil {isTouchingGround _unit || (position _unit select 2) < 1 };
	_unit setvelocity [0,0,0];// Para Units sometimes get damaged on landing. all this fuss just to stop getting damage.
	_unit setPosASL getPosASL _unit;
	sleep 2;
	_inv = name _unit;
    [_unit, [missionNamespace, format["%1%2", "Inventory",_inv]]] call BIS_fnc_loadInventory;
	_unit allowdamage true;// Now you can take damage.
};

{
	_inv = name _x;
    [_x, [missionNamespace, format["%1%2", "Inventory",_inv]]] call BIS_fnc_saveInventory;
	removeBackpack _x;
	_x addBackPack "B_parachute";// Sometimes does't work.
	_x disableCollisionWith _chopper;// Sometimes units take damage when being ejected.
	_x allowdamage false;// Trying to prevent damage.
	[_x] ordergetin false;// Stop unit trying to board Chopper
	[_x] allowGetIn false;// Stop unit trying to board Chopper again as they still try.
	sleep 0.1;
} forEach _paras;
	
{	
	unassignvehicle _x;
	_x action ["EJECT", _chopper];
	_x setDir (_dir + 90);// Exit the chopper at right angles.
	_x setdamage 0;// They still take damage even if I set to allow damage false.
	sleep 0.3;
} forEach _paras;

{
	waitUntil {(getPos _x select 2) <= _chuteheight};
	_x action ["openParachute", _x];//Force unit to open thier parachute
} forEach _paras;

{ 
  [_x] spawn paraLandSafe;
} forEach _paras;

//The following is my attempts to get the helo to move on to it's next waypoint. What happens is Paras eject, but the helo then stops and hovers indefinately.
// No matter what I try i cannot get it to move on.
sleep 15;
enableSentences true;//You have ammo so now you can speak.
group ((crew _chopper) select 0) setCurrentWaypoint [group ((crew _chopper) select 0), 1];// Set next waypoint as complete. Still won't move choppper
{[_x] joinSilent grpNull} foreach crew _chopper;// Attempt to disassociate chopper group and paras. 
_dir = direction _chopper;// prepare to force the chopper to move
_speed = 10;
//_chopper setVelocity [(_vel select 0) + (sin _dir * _speed),(_vel select 1) + (cos _dir * _speed),(_vel select 2)];// Works but crude.
sleep 10;
//{_x setdamage 0.7} foreach crew _chopper;//Now try to get rid of the chopper and crew.. This was initially in the last waypoint
//{deleteVehicle _x} forEach crew _chopper + [_chopper];
//{[_x] joinSilent grpNull;} foreach _paras;// Again try to stop paras from trying to board the chopper once they land
//{doStop _x;doFollow leader _paras; }foreach _paras;// What do I have to do yo get you boysd to follow the leader and not return to the chopper.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#6 Posted at 2016-02-10 00:58        
     
This script is too much complicated for nuts!
First consider your waypoints. You didn't mention them but the context is important. How, when, where, type of landing? , why land?...
Some considerations:
add / removeBackpackGlobal in MP.
orderGetIn..AllowGetIn false: you don't need to write that anymore with:
{ unassignVehicle _x } forEach .... (works for all vehicles till you decide to assign again!)
parachute invincible... bof! Do you really need that? how much time it serves?
On the other hand _unit allowdamage false is important from (inside helo to grounded)

sleep command: avoid if you can wait for something. Sleep 0.1 at the end of a script is absolutely usefulness.
Keep on mind, all the spawned scripts are running (together) as soon as you fire (them).
So simplify in a global {....} forEach _paras; for all simultaneous actions (backpack damage unAssign...)
Use waitUntil for scheduling events. Example:
waitUntil { {alive _x && !(_x in helo)} count units group == {alive _x} count units group};

you don't need any more to say your unit to open their chute! remove that stuff;

When units are in cargo (assigned), they don't need to belong to the same group of the crew. So all stuff with join group or else: remove! Have your units in a group different from crew.

Manage waypoints for helo group (crew) and paras group separately.

By the way, the method for saving an inventory / adding a chute / loading inventory after landing.. is OK. It's a good way for players jumping when they want.

For AI units, there is an alternate solution: move them out and attach a parachute:
Here is a part of code I use for para reinforcement from a C130:

waitUntil { (C130 distance _drop) <650};
sleep 3;
{
unAssignVehicle _x;
   _x allowDamage false;
   moveOut _x;
   sleep 0.3;
   _chute = createVehicle ["NonSteerable_Parachute_F", (getPosatl _x), [], 0, "NONE"];
   _chute setPosATL (getPosatl _x);
   _x moveinDriver _chute;
   _x allowDamage true;
   sleep 0.4;
} forEach units _blueteam1 + units _blueteam2;

_c130_grp allowFleeing 0.5;
_c130_grp setcombatmode "YELLOW";
_c130_grp setbehaviour "AWARE";
waitUntil {({_x in C130 && alive _x} count (units _blueteam1 + units _blueteam2)==0) or diag_tickTime > _timer + 120};
wp2C130 = _c130_grp addWaypoint [[7000,  1000, 300],0];
C130 flyInHeight 300;
_c130_grp move [7000,  1000, 300];
//_c130leader domove wp2C130;

waituntil {({isTouchingGround _x} count (units _blueteam1 + units _blueteam2) == {alive _x}count (units _blueteam1 + units _blueteam2))  or diag_tickTime > _timer + 140};

 wp1RT1 = _blueteam1 addWaypoint [getMarkerPos "mk2",0];
 wp1RT1 setWaypointType "SAD";

This post was edited by Pierre MGI (2016-02-10 01:15, 615 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#7 Posted at 2016-02-10 02:05        
     
Whouldn't all this boil down to a much simple thing for kingkungfo1's specific case?

kingkungfo1 you can actually force the AI to jump out with the moveOut command.

The only init field you'd need for the units is the one in Rifleman1, your second statement should be enough:
{_x moveincargo heli1} foreach units group this;

unit1 = group this; Doesn't do anything. Even if it does something in a separate place, it's enough that you put it in the init field of only one of the units.


And for the ON ACT field of the 3rd waypoint, you can use this smaller script:
[Rifleman1, Rifleman2] execVM "heli_drop.sqf";

heli_drop.sqf:
{
	if (local _x) then {
		moveOut _x;
		sleep 0.2;
		_chute = createVehicle ["Steerable_Parachute_F", getPos _x, [], 0, "CAN_COLLIDE"];
		_x moveinDriver _chute;
	};
} forEach _this;

Also at the 4th waypoint, you might want to use something like this if you want to completely dump the chopper:
deleteVehicle Heli1;

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage