Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

Offline trinec

  • Members
  • *
  • I'm a llama!
Helo moves to random locations during flight
« on: 11 Apr 2008, 03:38:09 »
Was wondering how to make a helo fly to random locations and activate another script that I have that makes the helicopter go down in flight.  So you really never know were your going to go down at.  I have some code to make the chopper wait at base until a whole group has boarded.


Thanks

GI-Trinec

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Helo moves to random locations during flight
« Reply #1 on: 11 Apr 2008, 04:36:22 »
You could have a series of game logis in places around the map. Then tell the chopper to randomly choose from one of them with a script.
Better still might be invisible helipads to aid the landing.

I know it's not really as random as you want it but it would work.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #2 on: 11 Apr 2008, 04:59:39 »
ya I'm using this code in the init.sqf right now to have the helo wait for the group to join.

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};

I found this bit of code in the forums here but not sure how to make it work with the above.

Code: [Select]
[group pilots, 1] setWPPos getMarkerPos (["move_1", "move_2", "move_3", "move_4"] Select (floor(random 4)));
I tried putting the helo in the group pilots using
Code: [Select]
pilots = group this but it errors out must be object but if I use the helo's name it says it must be a group.  I created markers move_1 thru 4.



Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #3 on: 11 Apr 2008, 06:38:56 »
Don't use "group pilots", just use "pilots"

Code: [Select]

[pilots, 1] setWPPos getMarkerPos (["move_1", "move_2", "move_3", "move_4"] Select (floor(random 4)));


Offline Sparticus76

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #4 on: 12 Apr 2008, 04:26:39 »
what you could do is create an invisible H pad and chose a random location on the map that's terrain is checked as not being water or trees etc, setpos the H pad at that point and have the helo move to that point.

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #5 on: 12 Apr 2008, 22:44:25 »
Not sure how to get this part to execute after the waitUntil code line

Code: [Select]
[pilots, 1] setWPPos getMarkerPos (["move_1", "move_2", "move_3", "move_4"] Select (floor(random 4)));
I figure it would be that you had to say something like if all units are aboard then run the above line of code.  I'm just not sure on how to do this.

Ok I have this figured out now basicly you have to create a waypoint for the helicopter in the script to get it to move after this line of code

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

If you give the helicopter a waypoint in the editor it will start up and fly to a certain elevation then come back down.  Which I don't want. Thats why I created one in the script after the checking of the group boarding the helicopter.  I'm no scripting guru and it's probably better to create a different script file then using it in the init.sqf.  If anyone has a better way of starting this script at the start of the mission let me know. 

Here is the whole code

Code: [Select]
_uh1 = uh1;
_pilots = pilots;

{_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";
_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)));"];


Now if anyone has an idea on how to have a seperate script run randomly from the different areas on the map without them always being from the marker positions. Just randomly activates while the helicopter is flying betweens its random marker positions.

Thanks everyone for their help thus far.

GITrinec
« Last Edit: 13 Apr 2008, 02:01:22 by trinec »

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #6 on: 13 Apr 2008, 19:54:53 »
Is there a way to get an array of already created in the editor marker positions that are part of the areas that the helo flys too and compare that with the helos position and if in a the markers position within a radius create a trigger that launches a script.  I know you can use createtrigger in a script to create the triggers.

GiTrinec

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #7 on: 13 Apr 2008, 21:59:59 »
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 (_array select _i) > 200) then
      {
            //TRIGGER, SCRIPT, CODE Here
      };
};

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #8 on: 14 Apr 2008, 00:07:43 »
When I run the mission it gives me error missing ] at line 3 which is the _array line.  Also does > 200  mean when the helo is greater then 200 meters away the script or trigger activates?

Thanks

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #9 on: 14 Apr 2008, 01:05:31 »
Code: [Select]
If ((getPos _uh1) distance (getMarkerpos (_array select _i)) > 200) then
{
//TRIGGER, SCRIPT, CODE Here
};

That should fix it, sorry for the inconvience, forgot  ;).
Also try with non-double comma's if it still doesn't work.

Code: [Select]
_array = ["move_1", "move_2", "move_3", "move_4"];
« Last Edit: 14 Apr 2008, 01:07:48 by Rommel92 »

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #10 on: 14 Apr 2008, 06:27:10 »
well basicly my helo flys to the points randomly as usual but nothing will activate inside the trigger, script, code area even just a hint "say anything"; doesnt activate.  Does >200 mean when uh1 is greater then 200 meters from the marker then activate?

If ((getPos _uh1) distance (getMarkerpos (_array select _i)) > 200) then
{
//TRIGGER, SCRIPT, CODE Here
hint "say anything";
};

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #11 on: 14 Apr 2008, 07:18:58 »
Code: [Select]
If ((getPos _uh1) distance (getMarkerpos (_array select _i)) < 200) then
{
};
I used > to test if it would work on my PC originally, sorry my mistake for leaving it there.

If you could just use this and see what it returns, and perhaps debug it yourself:
Code: [Select]
hint format ["%1",(getPos _uh1) distance (getMarkerPos (_array select _i))];
Outside of the If statement, inside the For loop.

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #12 on: 15 Apr 2008, 08:05:34 »
It seems that the If statement is not being evaluated inside the for loop the
Code: [Select]
hint "do something"; does not ever appear.  I do get the distance to the marker using the hint format command that you gave me using it outside of the if statement.

Thanks 

Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #13 on: 15 Apr 2008, 08:19:30 »
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;
};

Tested and works, don't know where your going wrong, heres my version if its necessary:
« Last Edit: 15 Apr 2008, 08:25:50 by Rommel92 »

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #14 on: 17 Apr 2008, 05:29:39 »
It does appear to work from the radio call while I'm flying. but I can't seem to get it to work by adding the script into the init.sqf or even calling it from init.sqf using the call command.  It does run the script and tell me that the locations are too far away and the distance.  However when I get closer to the markers at < 200 the hint does not display saying that I am close enough.  It appears that the for statement runs once in the script and doesnt loop.    I wonder if the helo flying around on it's random markers positions is causing a problem for some reason.

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.



Offline Rommel92

  • Members
  • *
Re: Helo moves to random locations during flight
« Reply #30 on: 20 Apr 2008, 23:49:47 »
Code: [Select]
_heli removeEventHandler ["dammaged",_HEid];
Sorry, forgot the index of the removeEventHandler. Give that one a burl now.
(Above post edited for easy Ctrl - C)

EDIT:
Also, what is "_spd" For?
(Its defined as 1100 mid-section of script)
« Last Edit: 20 Apr 2008, 23:51:53 by Rommel92 »

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #31 on: 20 Apr 2008, 23:59:14 »
Not sure about the _spd part it was already there in the script .  It didnt look like it was in use to me, but I didnt delete it .

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #32 on: 21 Apr 2008, 00:32:27 »
New update now it gives an error on the same line

Code: [Select]
_heli removeEventHandler ["dammaged",_HEid];
Error type any, expected number

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Helo moves to random locations during flight
« Reply #33 on: 21 Apr 2008, 06:49:11 »
Trinec, do not post consecutively.
If you have something to add after a short period of time (less than 2-3 days) modify your post instead of 'replying to yourself'.


Anyhoo, there's a typo in the addEventhandler line, should be
Code: [Select]
_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]
};
}];
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #34 on: 22 Apr 2008, 01:19:56 »
Sorry about the overposting.  Wasn't sure if I should have put that last message together with the other message or not.  But now I know. 

Well I still get the same error message.


Code: [Select]
_heli removeEventHandler ["dammaged",_HEid];
Error type any, expected number

Also all of the hint format messages some across as null not sure if they are suppose to or not.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Helo moves to random locations during flight
« Reply #35 on: 22 Apr 2008, 08:59:04 »
I must need new glasses  :D
There are more typos in the add eventhandler part (even though I had no errors even with all teh typos in  ??? ).

It should be
Code: [Select]
_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];
};
}];

The script doesn't do anything though, dunno if trying to use it the right way or not..
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 #36 on: 22 Apr 2008, 09:14:26 »
Somehow... If you had no errors, then clearly its either, not launching the event handler, or this select 1 doesn't equal mala vrtule.

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #37 on: 24 Apr 2008, 06:28:10 »
If you replace the rpg ammo line

Code: [Select]
_bullet = "pg7v" createvehicle _pos1;
with this line of code you should see multiple tracer rounds hitting near the rotor of the helicopter atleast on the blackhawk anyways.

Code: [Select]
_bullet = "B_127x99_Ball_noTracer" createvehicle _pos1;
I still get the same error even with the changes so not sure what i'm doing wrong.

I really don't know what "mala vrtule" means to be honest but it was part of this script.  But basicly I was trying to get a rpg to hit the tailrotor so the helicopter will go into a spin and hopefully not kill everyone on the way down.  The other script that I tried did this but basicly it just starts spinning and goes down with a smoking tail rotor.  However unrealistic as it is I might have to go back to that.  I know that this part of the code maybe able to re-use to get the rpg to hit the rotor at a decent spot not sure though.

Code: [Select]
_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;

Thanks

GiTrinec

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Helo moves to random locations during flight
« Reply #38 on: 24 Apr 2008, 09:19:38 »
I only see a couple of soke puffs/hear a couple of 'tunk' sounds to indicate some sort of impact.
The other ammo originally used doesn't do anything.

But, I had to use the _heli = _this select 0; part instead of the _heli = vehicle player;, because if I used the latter there were no bullets fired at all.
But still no errors.

Quote
I really don't know what "mala vrtule" means
The models in the game can have many so called 'named selections', parts of the model are specially named so that the game knows what do with them.
"mala vrtule" is the tail rotor selection.

Which leads me to this, don't use modelToWorld alone, use selectionPosition as well.
This way you get the bullets to impact the desired selection without any "trial 'n' error".

So, replace this both _pos lines with:
Code: [Select]
_pos1 = _heli modelToWorld (_heli selectionPosition "mala vrtule");
_pos2 = _heli modelToWorld (_heli selectionPosition "mala vrtule");

EDIT:
Oh, and of course the pg7v doesn't show up because it's the weapons magazine class, you need to use the ammo class to create the rocket. In this case it's R_PG7V_AT. But that blows the chopper to pieces so something less powerfull is needed..

EDIT2:
Ok, changed your code a bit:
Code: [Select]
_heli = _this;
_rotordead = false;

_HEid = _heli addEventHandler ["dammaged",
{
if ((_this select 1)=="mala vrtule" && (_this select 2)>0.8) 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;

while {!_rotordead}
 do {
_pos1 = _heli modelToWorld (_heli selectionPosition "mala vrtule");
_pos2 = _heli modelToWorld (_heli selectionPosition "mala vrtule");
_vx = (_pos2 select 0) - (_pos1 select 0);
_vy = (_pos2 select 1) - (_pos1 select 1);
_vz = (_pos2 select 2) - (_pos1 select 2);
_bullet = "B_127x99_Ball_noTracer" 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;
    };
   
_heli removeEventHandler ["dammaged",_HEid];

execute with
Code: [Select]
heloname execVM "script.sqf"
But using those bullets it takes up to the doomsday before the chopper gets any damage..
« Last Edit: 24 Apr 2008, 09:29:02 by h- »
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 #39 on: 24 Apr 2008, 10:46:04 »
Quote
But using those bullets it takes up to the doomsday before the chopper gets any damage..

Not necessarily, the higher the velocity you give the bullets the more it will damage, damage is based on speed in ArmA remember, so you can make a pistol bullet going mach 8 kill a tank (tested and worked hilariously.)

 :whistle:

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Helo moves to random locations during flight
« Reply #40 on: 24 Apr 2008, 11:00:31 »
Oh?
I just thought it was one of those features that never made it to the game..

I'm a complete maths retard so setting a velocity for a bullet is completely out of my grasp so I never tested it.  :confused:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline trinec

  • Members
  • *
  • I'm a llama!
Re: Helo moves to random locations during flight
« Reply #41 on: 26 Apr 2008, 05:45:54 »
Not sure but it seems the

Code: [Select]
if ((_this select 1)=="mala vrtule" && (_this select 2)>0.8) then
doesnt detect dammage because the helo keeps constantly being hit even with heavier ammo. 



Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Helo moves to random locations during flight
« Reply #42 on: 26 Apr 2008, 11:59:53 »
You can try to change the 0.8 to some lower value.

It did work when the chopper was hit with a missile instead of bullets so it should detect damage.  :scratch:
You could also try what Rommel was talking about, speed up the bullets..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.