Home   Help Search Login Register  

Author Topic: Ejecting Pilots  (Read 1994 times)

0 Members and 1 Guest are viewing this topic.

Offline Hellbender

  • Members
  • *
Ejecting Pilots
« on: 22 Nov 2007, 16:09:53 »
Is there any simple way I can prevent a chopper crew from ejecting once the chopper takes a hit?

I'm making a mission where a blackhawk takes a hit while flying over the player. I want the pilots to land, not eject!

Right now they eject at low altitude and get killed, while the chopper doesn't even explode when it hits the ground! That doesn't make sense!


Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Ejecting Pilots
« Reply #1 on: 22 Nov 2007, 16:51:36 »
its probable u cud script it...

like make a loping script dat moves da pilot inside da choper and also gives da choper a downisde velocity.... somin along da lines of

Code: [Select]
while {getpos chopername select 2 > 0.5} do
{
   pilotname moveindriver chopername;
   chopername setvelocity [0,0,-0.2];
   sleep 0.1;
};

play w/ da values and things... but dis is basicly wat u need :D

LCD OUT

"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Hellbender

  • Members
  • *
Re: Ejecting Pilots
« Reply #2 on: 22 Nov 2007, 22:09:18 »
Thanks LCD!

It seems "sleep" cannot be used in Arma 1.08! It gives the error message "error generic error in expression".

What can I use instead?
« Last Edit: 22 Nov 2007, 22:51:44 by Hellbender »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Ejecting Pilots
« Reply #3 on: 22 Nov 2007, 23:28:02 »
"sleep" is an accepted command. Did you saved it as .sqf file (not .sqs) and launched it with execVM and not exec?


Myke out

Offline Hellbender

  • Members
  • *
Re: Ejecting Pilots
« Reply #4 on: 23 Nov 2007, 00:27:54 »
No, I saved it as sqs and launched it with exec!
I'll try it the other way around!

The reason I said sleep doesn't work in 1.08 version is because someone entered it into the comRef as a comment. Check it out: http://community.bistudio.com/wiki/sleep



Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Ejecting Pilots
« Reply #5 on: 23 Nov 2007, 00:33:48 »
Said Biki entry has been amended.


Planck
I know a little about a lot, and a lot about a little.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Ejecting Pilots
« Reply #6 on: 23 Nov 2007, 00:42:30 »
You could just use "~0.1" in SQS, which is the equivalent of "sleep 0.1;" in SQF, but then you'd have to navigate gotos just to make a loop and that is just punishing yourself ;P

sleep will always raise an error when you use it within an event handler or object init (either directly in the init line, or in a function called directly from there. In these cases, you must start a script with execVM or call a function/block with spawn in order to be able to use the command.

CONJECTURE (I strongly suspect this is true, but please don't shoot me if I am off the mark): I think the reason that sleep is disallowed is because in both of these situations a single thread of execution runs a lot of bits of code, one after the other (Either during init, calling every object's init code, or calling all the event handlers attached to an event). If you could delay this process indefinitely, using sleep, then you would prevent other code from being run on time. The advantage, though, is that the engine doesn't have to start a new script running for every one of these bits of code, so it saves a lot of CPU power.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Hellbender

  • Members
  • *
Re: Ejecting Pilots
« Reply #7 on: 23 Nov 2007, 02:07:22 »
Okay, I guess that makes sense!

The way I've done it for now actually does what I want it to. It sets damage to the chopper and crew, and it makes the AI land the chopper without ejecting. However it still brings out an error message no matter what I try!

Here's how it looks now:

Code: [Select]
#start
while {getpos Hotel3 select 2 > 5}
{
   #crew
   pilot1 moveInDriver Hotel3;
   pilot1 setDamage 0.5;
   pilot2 moveInCargo Hotel3;
   pilot2 setDamage 0.4;
   crewChief moveInTurret [Hotel3,[1]];
   crewChief setDamage 0.4;
   doorGunner moveInGunner Hotel3;
   doorGunner setDamage 0.5;
   
   #chopper
   Hotel3 setDamage 0.8;
   Hotel3 setFuel 0.2;
   goto "start"
};

exit

2 problems:

1. The loop won't end and the crew stays in the chopper. Isn't the loop supposed to end and go to exit once the chopper drops below 5 ft?
2. I still get the error message. What do I change to get rid of it?

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Ejecting Pilots
« Reply #8 on: 23 Nov 2007, 02:25:07 »
ur actualy combining 2 codes (one from execVM and 1 from exec...) so it depends on how 2 do it... if u wanna use sqf file den u wud do

nul = [] execVM "scriptname.sqf"

Code: [Select]
while {getpos Hotel3 select 2 > 5} do
{
   pilot1 moveInDriver Hotel3;
   pilot1 setDamage 0.5;
   pilot2 moveInCargo Hotel3;
   pilot2 setDamage 0.4;
   crewChief moveInTurret [Hotel3,[1]];
   crewChief setDamage 0.4;
   doorGunner moveInGunner Hotel3;
   doorGunner setDamage 0.5;
   
   Hotel3 setDamage 0.8;
   Hotel3 setFuel 0.2;
   sleep 0.1;
};

and da less pretty sqs way wud b

[] exec "scriptname.sqs"

Code: [Select]
#start
? (getpos Hotel3 select 2 < 5) : goto "end"
pilot1 moveInDriver Hotel3;
pilot1 setDamage 0.5;
pilot2 moveInCargo Hotel3;
pilot2 setDamage 0.4;
crewChief moveInTurret [Hotel3,[1]];
crewChief setDamage 0.4;
doorGunner moveInGunner Hotel3;
doorGunner setDamage 0.5;
   
Hotel3 setDamage 0.8;
Hotel3 setFuel 0.2;
goto "start"
#end

exit


use execVM whereever u cant its pretier and beter :P ;)

LCD OUT
« Last Edit: 26 Nov 2007, 00:32:02 by LCD »
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Hellbender

  • Members
  • *
Re: Ejecting Pilots
« Reply #9 on: 24 Nov 2007, 00:29:30 »
Thanks LCD!

Offline Goullou

  • Members
  • *
Re: Ejecting Pilots
« Reply #10 on: 25 Nov 2007, 22:18:03 »
The syntax of your "while" loop was incorrect. "DO" was missing.

Code: [Select]
while {getpos Hotel3 select 2 > 5} do
{

...will work ...
Si vis pacem, para bellum.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Ejecting Pilots
« Reply #11 on: 26 Nov 2007, 00:32:45 »
w00t mising ? where ? :D

;)

LCD OUT

[note] da magic of editing :D
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta