This is a direct follow up to my earlier post here.
Right now my scripting efforts consist of a relatively small amount of changes. One of the very first thing I did was change what our player’s pilot character was going to be equipped with. Normally “pilots” come with an assault rifle which works a lot better for helicopter pilots than it does aircraft pilots. Our guy is stuck only with an M9 pistol, 4 magazines for it, a couple of smoke grenades, and the ever-trusty binoculars.
My biggest concern initially and what other than fine tuning the mission’s objectives originally inspired this whole excursion into scripting was communication. I felt the scenario would feel a bit more realistic if I could make the base/tower/controller/whoever be able to talk to our pilot while he was on the mission, particularly when around the airstrip and as objects changed. I also figured it would be nice to have our pilot respond – whole conversations in other words. Once I figured out how to do this it meant if I wanted to be fairly thorough with my communications, which I did, I’d have to do a lot of scripting to make trigger some of these messages.
Somewhere in here I developed my evacuation idea. After a few hours of working on it (which have included way too many tank-busting flight tests but I’m still trying to keep used to the flying mechanics and whatnot so I have an excuse!) here’s what I’ve got done:
“We now join our script already in progress.”
First off I’ve only added the escort attack chopper routines in so far. The player radios in for an evacuation. The game then spawns a helicopter and its crew in a predetermined location. We set a waypoint for the player’s location at the time they called us and head to it in seek and destroy mode. I also set a variable around this point to denote that an mission is in progress and added in a check which disallows a call if the previous mission hasn’t ended so they can’t summon 300 helicopter (which is damn fun by the way!) When the chopper gets semi close to the waypoint it kicks off a timer. The chopper will then hang around blowing enemies up or just hovering around like an idiot until it runs out at which point we’ll set another waypoint and make it active so that it can return back to its spawn site, land and then be deleted from existence. We’ve got a lot radio messages along the way too.
My next order of business is to add in some status checks for the health of the vehicle. My decision to add in radio messages meant that, in my mind, I’d need to do some scripting in order to account for some conditions in which we might expect messages but not be able to easily send them. Specifically in this case I’m going to send a message when the chopper gets damaged and when it gets destroyed.
The damage part was pretty easy. I added a trigger to check to see if the chopper had acquired a certain amount of damage yet was still alive and if so I had the chopper send a radio message to the effect that he was taking damage. I set this to run only once, so once it triggers the first time that’ll be all we get. I threw a couple of Shilkas on my test map and after playing it enough times to have them actually manage to damage it before it blew them to hell it worked perfectly.
“Runner up in the most boring screenshot of the year awards, 2008.”
The second part, checking to see if the chopper was down or not, was quite a bit harder as in the interest of more accurate radio messages I had to check if the chopper had been destroyed outright, if the chopper had been destroyed but the crew had survived, if the chopper was fine but the pilot was dead, and if the chopper was fine AND the crew was fine, but they had made an emegrency or crash landing.
To accomplish this I ended up having to add four separate triggers for the four conditions. I had considered making one simpler trigger set off a script to check the other conditions but ended up doing it this way. I also added a global variable which each of them would set on activation which they’d check so we wouldn’t get cascading messages if, say, the chopper started to crash-land, then the pilot got killed, then the chopper blew up, then the gunner died. I also used this new variable to abort the rest of the original script which meant that unneeded waypoints wouldn’t be set, invalid radio messages wouldn’t be sent, the crashed units wouldn’t be mysteriously deleted, and the “in progress” global variable I added wouldn’t be reset, therefore further evacuation requests would be unavailable.
“Another BMP-2 is sacrificed to the scripting gods.”
I think the script is pretty much done now. Next I’ll need to duplicate attack chopper script for the transport helicopter and then modify the hell out of it to take into account landing, loading, the additional waypoints, and all that fun stuff.