Jump to content
Sign in to follow this  
AngusHeaf

Random ai spawning within boundry

Recommended Posts

So I've got this mission that I'm working on and basic idea is as follows....  

A chopper has been shot down carrying a platoon of soldiers and 4 crew. The crash site needs to be secured and survivors need to be rescued. The crash site is a simple C&H type thing and the chopper will serve as the "flag" with a capture radius. Each team will have the option to also find the survivors (AI from team A) and escort them back to either a rescue convoy (team A) or a POW camp (team B).

I need help with the AI stuff though. I've come up with the scripts to allow players to walk up to the survivors and take control of them and add them to the player's group, and scoring the AIs is already done also.

What I want to do is only spawn 2 or 3 AIs at a time in a given radius around the crash site, and do so at random locations within that radius so you actually have to look for the guys. Obviously, doing this for the first 3 guys is easy within the editor, but respawning them after they've been used to score is what I'm having problems with. This is the first big step in scripting that kind of stuff and I'm 100% clueless how to do it. I've done a good bit of scripting for OFP multiplayer missions in the past though, so I'm not exactly a noob (thank god).

My next step after that is to hopefully give the AIs some bit of intelligence so that they actually go and hide themselves. But first I gotta get this respawning thing working.

Please...does anyone have any ideas?

Share this post


Link to post
Share on other sites

What do you want to limit the respawn to? Minimum number of guys triggers respawn? If so I think you could use a trigger that counts the guys alive and when they are below a certain number your trigger fires a respawn script. (you could also randomize the time in the trigger. In your script you could use the location of just about anything for a reference point (I like game logics for that) and randomize the x and y placement up to your maximum limit. You'll probably want to use 2 random numbers for each axis, the first to decide to add or subtract. For example. First random number from 0 to 2. If less than 1 subtract from the x axis, if greater than 1 add to the x axis. Second random number from 0 to 100 used to offset the x axis. Now your placement will be within 200 of the reference point. Then do the same thing for the y axis. If the trigger is set to repeatedly it could go on forever making a richly populated map, but then you could put a counter in the script that would limit it to a maximum number of respawns. If I had more time I'd do a sample for you but right now it's a little late for that.

Share this post


Link to post
Share on other sites

I'll run through a little example of what I'm trying to accomplish...

Start the game...3 AIs with big ol' radius are all centered over the crash site of my chopper (the C&H flag). This will make them appear within a radius (of say, 100) but not at the same spot every game.

West team finds an AI...player uses an action script I wrote to walk up to the AI and join it to his group (so it will follow the player around).

West player leads the AI to safety...AI gets to scoring zone, score increases, AI disappears into building (or into thin air for all I care).

AI that was just used to score respawns...I want the AI to respawn, but NOT in the same place. I do however, want the AI to respawn somewhere random within a given radius around that C&H chopper crash site.

I figure I'll set it so that there's no more than 3 AIs capable of being rescued at any one time. The system will run indefinitely supplying the mission with an endless supply of 3 rescueable AIs for scoring. Well, I guess I could set it to be a fixed number (like 15 total) and that would work too. Doesn't really matter. I'm mostly unsure about how to do the 'respawn within a radius, at a random position' function.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×