Jump to content
Murklor

Editor based AI spawn script by trigger

Recommended Posts

I searched around for such a script before and really failed to find anything something like it. Norrins AI/vehicle respawn script work great, but uses icky markers. Dont like filling my map with markers even if they are invisible. If a simple editor based triggered spawn script already have been done - well then this is a repost, lol!

Download (sample mission): http://www.mediafire.com/?4dyjmzmnimy

How it works:

- Deletes units on mission starts and save them

- Spawn them again based on a trigger (note that its not instant, there is a 10 second loop waiting for the trigger, can be changed)

- REQUIRES THE BIS FUNCTIONS MODULE!

- Unlike my sample mission, the AI should be given more time to get "accustomed" to the world. Spawning enemies too close to each other can cause wierd behaviour.

- IT HAS ONLY BEEN TESTED IN *SINGLEPLAYER*. Multiplayer should work... in theory. Sleep delays may need to be adjusted there though.

Supports:

- Any unit

- Any group (infantry, land vehicle and air vehicle groups)

- Many waypoints supported, unfortunetly not all types and combos (synching a get in and load wont work and I dont really know why :(). I recommend keeping it simple.

- "once" mode (one shot), "repeated" mode (respawn), "wave" mode (fixed delay then respawn all), "reset" mode (units can be called again at will)

- Global boolean trigger variable, such as approaching a town, variable gets set to true and an ambush spawns or whatever.

- Any kind of unit/trigger variable combo (ie you can have units going once together with respawning units and wave units etc on the same trigger variable)

The sample mission should give everything needed to use in any mission. How to use the mission: Approach each backpack bag (yeah I'm real innovative with my design) and it will trigger a group of AI units going about their buisness: whatever they where supposed to do when you placed them in the editor. Note on the bottom right trigger: This uses units in reset spawn mode, move to the bags then back out. You can trigger it at will again some 20 secs later.

FINAL NOTE: I suck at readmes >.<

Edit: Armaholic mirror http://www.armaholic.com/page.php?id=7074, thanks to [MCF] Frantz

Edited by Murklor

Share this post


Link to post
Share on other sites

Great work Murk Thanks ! :D

Looking at the script, and messing around with the sample missuon, i think i can figure out how it works :)

Share this post


Link to post
Share on other sites

Updated version to V3: - link removed, see below -

Highligts:

- Reworked for smaller group scripts, less code to execute and better oversight (well sort of)

- Supports init strings (examples in the updated mission)

- Restore vehicle names in certain modes (once, respawn) though I suggest adding "yourwantedname = this" to the init string instead (I've had poor luck with vehicle var names)

- Cleans up dead groups a little better than before

Edit: Hm, I just realized I messed up the vehicle varname in the code... I'll update this later today.

Edited by Murklor

Share this post


Link to post
Share on other sites

Good to see the update. Thanks.

You didn't get much feedback in this thread, but lately I have been studying a lot of user missions to get better at my own scripting. I have seen your script used in a few of them and I look to forward to trying the mission you intended this for if you ever finish it ;-)

Share this post


Link to post
Share on other sites

Some additional feedback...

I must say I'm not sure it really beneficial here to use the functions module. Sure, you save some lines of code but the function scripts themselves are rather bloated and probably use more CPU time then just doing something simple in your own script and you also add the expense of calling out to another script at all. In addition we lose a nice feature in that the script no longer saves out and restores gear and there is no way I can see to add a feature I need which is to turn off "FORM" so units will stay in their positions.

Still, definitely useful but I'll see about doing some modifications to bring back flexibility and add a few more features like storing the unit's stance. I think for vehicles I would rather have it done without functions too so we could do some things like put in a dug in tank position which only has a gunner to prevent it from driving out of cover or an APC fully loaded with troops.

Share this post


Link to post
Share on other sites

i love this script and have been using your first version quite a lot, i like the fact i can make some extreamly good ambushes throughout the mission without the aircorps blowing everything to shit becuase the units dissapear untill i need them

10/10

Share this post


Link to post
Share on other sites

Updated script and removed the old file, now properly restore vehicle varname: V3.1 Download (well its still called V3)

Binesi, regarding the use of BIS functions... Well at least I dont see the bloat when using them ;)

I really wanted the script to be as simple and short as possible. But granted, if there is a wish to skip the BIS functions module and do it manually again, I will consider it. It wont change anything for the end user anyway.

Do note that you can do what you want (like only having a gunner in the tank or changing stance on spawn) by using the init string.

If I feel up for the flurry of coding, I might consider making a V4 tomorrow without the function module requirement.

Edited by Murklor

Share this post


Link to post
Share on other sites
Do note that you can do what you want (like only having a gunner in the tank or changing stance on spawn) by using the init string.

I've been playing with init strings and I did find I could change stance and do a doStop for the whole group, but hard to target just one member for customization. I was hoping to use a script like this to save out some nicely manned up and hand optimized defensive positions for a triggered spawn when in range of the player's group. With snipers on top of towers and such. Formation turned off, doStop orders, doWatch etc. Combine with some barracks or aircraft churning out out wave reinforcements to keep the pressure on.

I've been working on a very detailed mission which encompasses pretty much the whole Chernarus map with an ongoing battle and obviously I'm up against a lot of limitations and I need to use some good tricks like this. Hope you feel up for that flurry of coding - if not I'll try my hand on it and see what I can do.

Share this post


Link to post
Share on other sites
Hope you feel up for that flurry of coding

I've already spent the last 1.5 hours trying to rework it without the functions module, but it aint easy lol. Infantry is done, vehicles are trickier getting to work with groups when you have to create everything manually. Like 30 minutes worth of actual coding and 1 hour spent scratching my head and going "WTF!?" every minute. :p

Share this post


Link to post
Share on other sites
Like 30 minutes worth of actual coding and 1 hour spent scratching my head and going "WTF!?" every minute. :p

Haha - ya, I know that feeling very well.

Share this post


Link to post
Share on other sites

Got it done for both vehicles and infantry without the functions module, the spawning script is now a complete mess, lol (me thinks I need to comment more...). I just have to run through my example mission and check it for bugs, will upload V4 during the day unless I've made a catastrophic fail somewhere.

Share this post


Link to post
Share on other sites

Eh, I built V4 without the functions module, but something is wrong... Land vehicles and infantry seem to work fine, even the paradrop C130, but I get awfull choppiness from the helos (bottom right trigger in the editor).

For some reason helo behaviour is also complete different as opposed to using the BIS functions :confused:

I havent had the time to investigate either issue.

But I've uploaded it anyway for anyone daring to try it: Editor Based AI Spawn V4 (semi-broken)

Share this post


Link to post
Share on other sites

But I've uploaded it anyway for anyone daring to try it: Editor Based AI Spawn V4 (semi-broken)

I'll give it a whirl. My brain is already half melted from trying to develop a somewhat over ambitious transport type script today so I could use something new to look at.

---------- Post added at 06:19 AM ---------- Previous post was at 05:54 AM ----------

I see the choppiness with the errm, choppers. Also noticed you are using moveInGunner instead of moveInTurret. I didn't try yet but I'm guessing this script isn't going to handle multi turret vehicles. Have you looked at the source code for the function module to see what methods they are using?

I'll take a look at this again in the morning when my brain is a bit fresher. The infantry seem to be working great.

Share this post


Link to post
Share on other sites

Great script!

Strange observation: when used with UPS the UPS groups all of sudden go into combat mode (crawling on ground) instead of their usual patrol column safe? Only happens when I combine both in one mission.

Is it possible to have 7 or 8 triggers use different renamed copies of first_group.sqf to spawn different groups. first_group.sqf second_group.sqf ..

I have tried that but did not work?

Great work!

Share this post


Link to post
Share on other sites

Strange observation: when used with UPS the UPS groups all of sudden go into combat mode (crawling on ground) instead of their usual patrol column safe? Only happens when I combine both in one mission.

How do you combine them? Both spawning and UPS at the same time?

Is it possible to have 7 or 8 triggers use different renamed copies of first_group.sqf to spawn different groups. first_group.sqf second_group.sqf ..

I have tried that but did not work?

See the example mission. It uses 5 different triggers in 5 renamed copies of first_group.sqf, with the trigger in the first couple of lines changed (its hard to miss). The actual name of the file is irrelevant.

Share this post


Link to post
Share on other sites

Yeah it doesnt work on a dedicated server :( thats the lastest one, dont think the other one did too yet it works in my local editor mp. Really big shame could of been used for many good things :P

Share this post


Link to post
Share on other sites

Unfortunetly I have no dedicated server to try on (and I havent gotten a local dedicated to work, it just CTD). Theoretically I dont see any particular reason as to why it wouldnt work, but more than likely there is a design flaw somewhere that halt the script.

Someone with more knowledge about dedicated server scripting would have to give pointers: hey its my first ever real script for Arma 2, I've only coded in OFP before back in the good old days ;)

Share this post


Link to post
Share on other sites

Hey Murklor,

WIth the UPS, I have different of units sperate, UPS patrol units (only using UPS scripts) and then the other groups using your scripts. They both run from two different scripts. So I am not sure why there is conflect. If you remove your script, UPS works fine. Other wise, UPS groups go into combat/stealth mode and hardly do any patrol.

The only file they share is the description file so I wonder that could be the issue. Great script otherwise and makes mision design much simpler! Now only if I can figure out how to use with UPS ..

I saw the exmaple script .. I only wanted to use first one because it uses v4 your latest version. What I did, I copied the first_group.sqf and renamed 6 times and had it placed in 6 different triggers to spawen troops if activated. Only first group spawned but the ones with renamed script name did not. So what am I missing?

Thanks for your help.

Share this post


Link to post
Share on other sites

Did you change this line in each file:

#define SPAWN_TRIGGER_VARIABLE first_group // <<<<<<<<<<<<<<<<<<<<<<<<<< CHANGE THIS TRIGGER

Also, all files in the V4 example is V4, I just didnt update the comments section ;)

I will see if I can take a look at the UPS script, though I cant promise anything. Feeling like arse right now, damn flu period.

Edit: I tried a quick test with the UPS example mission, placing them on the runway to easily see them. Then I placed an infantry group with the spawn script and trigger. Unfortunetly, I was unable to reproduce the issue... The UPS guys seems to walk along like normal.

Edited by Murklor

Share this post


Link to post
Share on other sites

Thanks Murklor for your quick answers.

I will have to re do mission to see what else could be interefering with UPS script.

In the meantime, I am still having an issue running copied/renamed scripts from triggers.

I have 12 triggers all over a map and I want enemy to respawn when players enters triggers. So I copied first_group.sqf and just changed the name and placed in differnet triggers.

I have also changed on activation so sixth_group.sqf will have in trigger has sixth_group = true;

in activation field. Well iIt is not working. So what am I missing here :confused:

Thanks again for your help.

Edited by CaptainBravo

Share this post


Link to post
Share on other sites

Well the only real things I can think of offhand without seeing what you've done is this:

Have you set the triggers to false first?

Does sixth_group.sqf have the line #define SPAWN_TRIGGER_VARIABLE sixth_group?

Are the units calling the correct group script with the proper parameters?

Does your trigger fire (like tested it with a hint or something)? Its easy to make small mistakes.

Share this post


Link to post
Share on other sites

I finally figured the issue .. I did not add the additional groups into description file. :o

The only other thing I have noticed is if I moved plane to different position it just crashes! I have tried and tried with same result, move and it will crash. I have attahced same sample mission. Nothing has been changed about plane or group inside, only starting position.

http://www.filefront.com/14603769/spawn_exampleV4.utes.rar

Thanks for your help.

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

×