Well this topic is rather generally written as Script designs; how to do x, and y etc as I was just playing MP mission and was thinking how to do this stuff and just decided that its time to make a topic to keep me reminded later.
- If I have script created helicopter / aircraft (lets just call them helo now) with pilot / crew to fly it, is there some simple way to keep track if this helo is shot down and the crew alive, so then something else could be done like crew rescued or crew would return back to base instead of continuing the "helos" waypoints on foot which would be totally silly?
My first instinct was a killed eventhandler, but no, in my mission there are many situations where the helo is shot down with engines or other parts of it broken, yet it even looks totally intact from a distance. Actually this starts to come a bit nuisance in my mission as the landscape seems unnaturally filled with downed helos here and there after several hours of playing (but that's besides the point, sorry).
- had some other scripting issue in mind while in-game, but of course I forgot about it when I exited to post this, sigh... I'll try to post it later
Script designs; how to do x, and y etc?
Moderators: Lone Wolf, Snake Man
-
- Commander-In-Chief
- Posts: 9368
- Joined: 2000-07-31 22:01:01
- Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
- Editing Interests: All, I (try) to edit everything.
- Location: PMC
Script designs; how to do x, and y etc?
PMC Tactical Forum New User Registration please read new info here.
PMC since 1984
Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel
PMC Tactical forum Advanced Search is power.
"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."
PMC since 1984
Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel
PMC Tactical forum Advanced Search is power.
"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."
-
- FreeFalcon
- Posts: 848
- Joined: 2001-03-04 23:01:01
- Location: here
Re: Script designs; how to do x, and y etc?
My first thought was the dammaged or hit EH, but then when I went to check the reference, perhaps what you really want is the engine EH.
I guess it depends on whether you want a rescue mission. If you need the helo to keep flying, you could use the hit EH and just reset the damage to 0.
Hope that helps.
So, the EH script could start with a conditional that if the engineState is true (turned on) to just exit. But, if the engineState is false (turned off), then place a marker and send a message or something that the helo is down.Triggered when the engine of the unit is turned on/off.
Global.
Passed array: [vehicle, engineState]
* vehicle: Object - Vehicle the event handler is assigned to
* engineState: Boolean - True when the engine is turned on, false when turned off
I guess it depends on whether you want a rescue mission. If you need the helo to keep flying, you could use the hit EH and just reset the damage to 0.
Hope that helps.
Sic Semper tyrannosauro.
-
- Commander-In-Chief
- Posts: 9368
- Joined: 2000-07-31 22:01:01
- Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
- Editing Interests: All, I (try) to edit everything.
- Location: PMC
Re: Script designs; how to do x, and y etc?
Heh I could count on you to reply for this hehe
Okay so engine is ON and were good, if OFF we activate our eventhandler. Hmm yes I believe this would work, unless there is few (milli) seconds of delay in the start. When I create the helo with scripts, create the crew afterward (well instantly on the same script but procedure wise after), do the eventhandler fire already in that time before the pilot issues engine on command?
Well that should be no problem, give it like 5sec or even more delay to attach the engine eventhandler to it.
Yep, I think that would work.
What do you think of keeping an array of created helos, then like very minute or so (very relaxed CPU wise) check that helo is alive, can move, can fire, has fuel and is at altitude more than 0m so it really is flying and doing stuff, although I'm pretty sure the initial canMove, canFire are enough to establish if hes okay or not. I'm sort of thinking this would be more transparent and hmm intelligent way to do that, the eventhandlers always seem like magic to me that I would definitely break something if I mess with those
Speaking of eventhandlers, if we are not using XEH, isn't the scenario that if you add eventhandler, you disable the previous one, like I'm sure BIS has the incoming missile one because in stock OA the helos launch flares when you shoot stinger at them. Now I'm of course thinking that does BIS use any engine eventhandlers, hmm.
Okay so engine is ON and were good, if OFF we activate our eventhandler. Hmm yes I believe this would work, unless there is few (milli) seconds of delay in the start. When I create the helo with scripts, create the crew afterward (well instantly on the same script but procedure wise after), do the eventhandler fire already in that time before the pilot issues engine on command?
Well that should be no problem, give it like 5sec or even more delay to attach the engine eventhandler to it.
Yep, I think that would work.
What do you think of keeping an array of created helos, then like very minute or so (very relaxed CPU wise) check that helo is alive, can move, can fire, has fuel and is at altitude more than 0m so it really is flying and doing stuff, although I'm pretty sure the initial canMove, canFire are enough to establish if hes okay or not. I'm sort of thinking this would be more transparent and hmm intelligent way to do that, the eventhandlers always seem like magic to me that I would definitely break something if I mess with those
Speaking of eventhandlers, if we are not using XEH, isn't the scenario that if you add eventhandler, you disable the previous one, like I'm sure BIS has the incoming missile one because in stock OA the helos launch flares when you shoot stinger at them. Now I'm of course thinking that does BIS use any engine eventhandlers, hmm.
PMC Tactical Forum New User Registration please read new info here.
PMC since 1984
Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel
PMC Tactical forum Advanced Search is power.
"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."
PMC since 1984
Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel
PMC Tactical forum Advanced Search is power.
"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."
-
- FreeFalcon
- Posts: 848
- Joined: 2001-03-04 23:01:01
- Location: here
Re: Script designs; how to do x, and y etc?
hehe
You know me too well! Post an interesting problem, and I'll come like a moth to a flame....
Couple things.
1 - You can add the EH right when you create it. You can handle what to do with it in the script it calls, depending on what happened to trigger the EH. For instance:
Then, in PMC_heloEngineEH.sqf
(Obviously untested code.)
I don't think the addEventHandler replaces any EHs that already exist. But, I haven't tested that.
2 - I like arrays, so there's nothing particularly wrong with that (the current mine implementation relies heavily on global/published arrays). I know what you mean about EHs, though. They get their own 'namespace' so I've found it difficult to use them to change variables that are in the 'game' namespace. You might want to try the EH first, and see if you get the gameplay you're looking for that way.
One thing an array can do, too, though is allow you to limit the number of spawned helos. Before the spawning, check the count of the array, and if it is too much, then skip it.
You know me too well! Post an interesting problem, and I'll come like a moth to a flame....
Couple things.
1 - You can add the EH right when you create it. You can handle what to do with it in the script it calls, depending on what happened to trigger the EH. For instance:
Code: Select all
_helo =(spawned helo);
_heloEH = _helo addEventHandler ["engine", {_this execVM ""PMC_heloEngineEH.sqf"}];
Code: Select all
diag_log text "Engine EH fired";
_helo = _this select 0;
_engineBool = _this select 1;
// check if engine turned on
if (_engineBool) exitWith {diag_log text format ["%1 turned engine on", _helo];};
// to get passed this, the engine was turned off
diag_log text format ["%1 engine off", _helo];
// do other stuff
I don't think the addEventHandler replaces any EHs that already exist. But, I haven't tested that.
2 - I like arrays, so there's nothing particularly wrong with that (the current mine implementation relies heavily on global/published arrays). I know what you mean about EHs, though. They get their own 'namespace' so I've found it difficult to use them to change variables that are in the 'game' namespace. You might want to try the EH first, and see if you get the gameplay you're looking for that way.
One thing an array can do, too, though is allow you to limit the number of spawned helos. Before the spawning, check the count of the array, and if it is too much, then skip it.
Sic Semper tyrannosauro.
Who is online
Users browsing this forum: ClaudeBot [Bot] and 0 guests