Home   Help Search Login Register  

Author Topic: Helo moves to random locations during flight  (Read 6400 times)

0 Members and 1 Guest are viewing this topic.

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #15 on: 17 Apr 2008, 05:31:31 »
Could you post how your executing it, and anything other than it related to it, (ie any preProcessFile commands etc etc).

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #16 on: 17 Apr 2008, 05:53:41 »
I'm probably doing this all wrong but this is what is in the init.sqf

Code: [Select]
_uh1 = uh1;
_pilots = pilots;
_array = ["move_1","move_2","move_3","move_4"];
_i = 0;
for [{_i=0}, {_i < count _array}, {_i=_i+1}] do
{
If ((getPos _uh1) distance (getMarkerpos (_array select _i)) < 200) then
{
hint format ["Near Marker: %1 (%2m)",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];
}
else
{
hint format ["Marker: %1 (%2m) is to far away.",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];
};
sleep 1.0;
};

{_x assignAsCargo uh1} forEach units group gfldr;
units group gfldr orderGetIn true;
waitUntil {{_x in uh1} count units group gfldr == count units group gfldr};

hint "all aboard";

playsound "radiochatter";

_wp114 = _pilots addWaypoint [getMarkerPos "uh1pos", 0];
_wp114 setWaypointType "MOVE";
_wp114 setWayPointStatements ["true", "[pilots, 1] setWPPos getMarkerPos ([""move_1"", ""move_2"", ""move_3"", ""move_4""] Select (floor(random 4)));"];

And i've tried calling it at the end of the init.sqf using this

Code: [Select]
call {[] execVM "chkdistance.sqf";};
which just has the code you gave me.  Trying to get the format of the code used in sqf and sqs files figured out and were things go. I know certain things need to be called a certain way to get it to execute on all the diff client machines and such just trying to figure it all out.

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #17 on: 17 Apr 2008, 06:18:29 »
 :no:
Code: [Select]
[] execVM "chkdistance.sqf";
Don't know why you did the call...  ???

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #18 on: 17 Apr 2008, 06:42:59 »
Wasn't sure if a call was needed or not.  But this line of code just never executes the helo flys to the marker and at that point it is <200 meters from the marker.

Code: [Select]
hint format ["Near Marker: %1 (%2m)",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];

This one does once the helo takes off and tells me that im too far away like it should.

Code: [Select]
hint format ["Marker: %1 (%2m) is to far away.",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];
It seems almost like the loop doesnt keep running in the for statement like it runs once and thats it.

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #19 on: 17 Apr 2008, 06:50:20 »
It does only check once...  :P.

I made it as a function, not a constant loop, heres the edited code if you want to be a constant loop.

Code: [Select]
_uh1 = uh1;
_pilots = pilots;
_array = ["move_1","move_2","move_3","move_4"];
_i = 0;
while {alive _uh1} do
{
for [{_i=0}, {_i < count _array}, {_i=_i+1}] do
{
If ((getPos _uh1) distance (getMarkerpos (_array select _i)) < 200) then
{
hint format ["Near Marker: %1 (%2m)",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];
}
else
{
hint format ["Marker: %1 (%2m) is to far away.",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];
};
sleep 1.0;
};
sleep 2.0;
};

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #20 on: 17 Apr 2008, 07:04:54 »
That runs great rommel92 thanks for all the help.  I knew it needed some kind of extra loop but didn't know were to add it or it's format.

I cleaned up the init.sqf as well

Code: [Select]
{_x assignAsCargo uh1} forEach units group gfldr;
units group gfldr orderGetIn true;
waitUntil {{_x in uh1} count units group gfldr == count units group gfldr};

hint "all aboard";

playsound "radiochatter";

_wp114 = pilots addWaypoint [getMarkerPos "uh1pos", 0];
_wp114 setWaypointType "MOVE";
_wp114 setWayPointStatements ["true", "[pilots, 1] setWPPos getMarkerPos ([""move_1"", ""move_2"", ""move_3"", ""move_4""] Select (floor(random 4)));"];


[] execVM "chkdistance.sqf";

GI-Trinec

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #21 on: 18 Apr 2008, 06:38:00 »
I've ran into an issue were I am trying to end the loop that is running and checking the distance .  My idea is to run the tailrotor failure script like this.

Code: [Select]
_uh1 = uh1;
_pilots = pilots;
_array = ["move_1", "move_2", "move_3", "move_4"];
_i = 0;
_dammage = getDammage _uh1;
while {alive _uh1} do
{
for [{_i=0}, {_i < count _array}, {_i=_i+1}] do
{
If ((getPos _uh1) distance (getMarkerpos (_array select _i)) < 200) then
{
hint format ["Near Marker: %1 (%2m)",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];

[uh1,false] exec "tailrotor.sqs";
}
else
{
hint format ["Marker: %1 (%2m) is to far away.",_array select _i,(getPos _uh1) distance (getMarkerpos (_array select _i))];

};
sleep 1.0;
};
sleep 2.0;
};
The hint's are still there just to see that the script is still running.

The tailrotor script run's fine but since the helo is still alive when it goes down so that everyone doesnt die. The chkdistance script keeps running the loop.  I would like to have when the helo is landed and after the troops are all out then the vehicle explodes hince ending the chkdistance script.  This is the tailrotor failure script that I found that runs fine.

Code: [Select]
; tail-rotor fail script by Vektorboson
; SYNTAX
; [CHOPPER, <RANDOMKILLS, MAXKILLS>] exec "effects\tailrotor.sqs"
; CHOPPER is the helicopter
; RANDOMKILLS is either true or false (random people are killed)
; MAXKILLS is maximum of randomkills
playsound "instalarm";
_heli   = _this select 0
_random = true
_maxkills = 4
?count _this == 2: _random = _this select 1; _maxkills = 4
?count _this == 3: _random = _this select 1; _maxkills = _this select 2

; Position of helicopter engine (adjust this for different helicopters!)
_enginePos = [0, -7, 1]

drop ["\ca\data\cl_fired", "", "Billboard", 1, 1, _enginePos, [0,-3,1], 0, 1, 1, 0.001, [1,5], [[1,1,1,1],[1,1,1,0]], [0], 0.1, 0.2, "", "", _heli]
~0.05
drop ["\ca\data\cl_fired", "", "Billboard", 1, 1, _enginePos, [0,-3,1], 0, 1, 1, 0.001, [1,5], [[1,1,1,1],[1,1,1,0]], [0], 0.1, 0.2, "", "", _heli]
~0.02
drop ["\ca\data\cl_fired", "", "Billboard", 1, 1, _enginePos, [0,-3,1], 0, 1, 1, 0.001, [1,5], [[1,1,1,1],[1,1,1,0]], [0], 0.1, 0.2, "", "", _heli]
_AddDir = 0.1
~(random 1)

#loop
_dir = getDir _heli
?_AddDir < 5: _AddDir = _AddDir + 0.05
_heli setDir (_dir + _AddDir)
_v = Velocity _heli
_heli setVelocity  [((_v select 0) / 1.001), ((_v select 1) / 1.001), -5]
drop ["\ca\data\cl_basic", "", "Billboard", 7, 7, _enginePos, [0,0,0], 0, 1, 1, 0.001, [1,5], [[0,0,0,0],[0,0,0,0.7],[0,0,0,0]], [0], 0.1, 0.2, "", "", _heli]
~0.01
?getPos _heli select 2 > 2: goto "loop"
 
?alive _heli: _heli setDammage 0.8; _heli setFuel 0;

?!alive _heli: exit

?!_random: exit
; now the randomkills
_crew = crew _heli
_c = count _crew
_i = 0
_kills = 0
#crew
_unit = _crew select _i
?random 1 > 0.8 && _unit != player: _unit setdammage (random 1)
?random 1 > 0.8 && _unit != player && _kills < _maxkills: _unit setdammage 1; _kills = _kills + 1
_i = _i + 1
?_i < _c: goto "crew"

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #22 on: 18 Apr 2008, 08:46:10 »
Just set the chopper damage to 0.7 for ArmA tail-rotor, I'm almost 100% sure that that is from OFP...

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #23 on: 19 Apr 2008, 10:22:29 »
yes it was originally from ofp but someone modified it to work in arma.  How do you setdammage to just the tailrotor?

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #24 on: 19 Apr 2008, 16:07:41 »
A rocket created at the back  :P, otherwise, it has to be universally done. (Ie the entire chopper takes damage, however 0.7 will not disable the chopper, I believe it causes a very sluggish fuel leak, but the more obvious effect is the Tail-rotor.)

The problem with this however is its unpredictability as... unless that's the effect wanted.

Code: [Select]
bigBird setdammage 1
note: I've recently noticed, I've started spelling dammaged wrong in emails / letters / essays... eek!  :weeping:
« Last Edit: 19 Apr 2008, 16:09:21 by Rommel92 »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Helo moves to random locations during flight
« Reply #25 on: 19 Apr 2008, 16:24:26 »
Then why use dammage?
The spelling was corrected in OFP: Resistance already (dammaged eventhandler is still misspelled though)..  ::) :whistle:

setDamage
damage
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #26 on: 19 Apr 2008, 16:31:02 »
Cause its a habit and BIS the bastards made it still work in ArmA, so I still use it...   :no:

 :P

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #27 on: 19 Apr 2008, 23:00:57 »
well I found this code but it's format seems kind of mest up due to some errors I get with it but from what I can see is that it creates bullets at the tail rotor, I tried to change the bullets for an rpg7v round but it never shows an rpg hitting the helo.  The bullets do. 

Code: [Select]
//_heli = _this select 0;
_heli = vehicle player;
rotordead = false;
_HEid = _heli addEventHandler ["dammaged",_HEid];
{
if((_this select 1)=="mala vrtule"and(_this select 2)==1)then
{
rotordead=true
hint format ["s0: %1\ns1: %2\ns2: %3",_this select 0,_this select 1,_this select 2]
};];
sleep 0.5;


_spd = 1100;
for [{_lp=0},{_lp<5},{_lp=_lp+1}] do
{

_pos1 = _heli modelToWorld [1,-7.9,0.95];
_pos2 = _heli modelToWorld [-1,-7.9,0.95];
_vx = (_pos2 select 0) - (_pos1 select 0);
_vy = (_pos2 select 1) - (_pos1 select 1);
_vz = (_pos2 select 2) - (_pos1 select 2);
_bullet = "pg7v" createvehicle _pos1;
_bullet setpos _pos1;

_cvel = velocity _heli;
_fact = 50;

_bullet setvelocity [(_cvel select 0) + _vx * _fact,(_cvel select 1) + _vy * _fact,(_cvel select 2) + _vz * _fact];

sleep 0.1;
if(rotordead) then
{
_lp=5;

};

_heli removeEventHandler ["dammaged",_HEid];



Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #28 on: 20 Apr 2008, 01:50:21 »
Code: [Select]
//_heli = _this select 0;
_heli = vehicle player;
rotordead = false;
_HEid = _heli addEventHandler ["dammaged",
{
if((_this select 1)=="mala vrtule"and(_this select 2)==1)then
{
rotordead=true
hint format ["s0: %1\ns1: %2\ns2: %3",_this select 0,_this select 1,_this select 2]
};
];
sleep 0.5;

_spd = 1100;
for [{_lp=0},{_lp<5},{_lp=_lp+1}] do
{

_pos1 = _heli modelToWorld [1,-7.9,0.95];
_pos2 = _heli modelToWorld [-1,-7.9,0.95];
_vx = (_pos2 select 0) - (_pos1 select 0);
_vy = (_pos2 select 1) - (_pos1 select 1);
_vz = (_pos2 select 2) - (_pos1 select 2);
_bullet = "pg7v" createvehicle _pos1;
_bullet setpos _pos1;

_cvel = velocity _heli;
_fact = 50;

_bullet setvelocity [(_cvel select 0) + _vx * _fact,(_cvel select 1) + _vy * _fact,(_cvel select 2) + _vz * _fact];

sleep 0.1;
if(rotordead) then
{
_lp=5;
};
};

_heli removeEventHandler ["dammaged",_HEid];

Sure that should work, gotta run tho so was just a quick edit to fix the visible syntax errors, will give it a further look in 6hrs time.  ;)

« Last Edit: 20 Apr 2008, 23:50:04 by Rommel92 »

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #29 on: 20 Apr 2008, 23:26:14 »
It errors out on
Code: [Select]
_heli removeEventHandler ["dammaged"]; Error 1 elements provided, 2 expected.