OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Hellbender 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!
-
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
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
-
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?
-
"sleep" is an accepted command. Did you saved it as .sqf file (not .sqs) and launched it with execVM and not exec?
Myke out
-
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
-
Said Biki entry has been amended.
Planck
-
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.
-
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:
#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?
-
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"
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"
#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
-
Thanks LCD!
-
The syntax of your "while" loop was incorrect. "DO" was missing.
while {getpos Hotel3 select 2 > 5} do
{
...will work ...
-
w00t mising ? where ? :D
;)
LCD OUT
[note] da magic of editing :D