norrin 9 Posted January 24, 2007 Scripts for non-playable AI respawn, respawned AI waypoints, progressive respawn point updating and flag captured. Using KaRRiLLioN's excellent vehicle respawn script as a model I have written a script in sqf format that allows the respawning of non-playable AI units at a specific location and then by using a linked sqs script they are given waypoints (using the doMove cmd) to a another location.  This is also linked to a progressive respawn location script that updates the respawn point location based on the condition of certain mission objectives.  This script also allows the retaking of spawn locations by enemy forces once they are lost.  Finally, I have written a simple script that will change the textures of a flag when conditions are met and hint flag captured "by side". Before I go too far with this let me warn you that so far these scripts have only been tested on a local server in single player.  I may not get to test it on a dedicated server for a couple more days but if anybody gets a chance and checks out the simple mission (see link below) could they please post their experience here. Here's the sqf script. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //***************************************************** //** Operation Flashpoint Script File //***************************************************** //BEGIN AI_respawn.sqf //adapted from KaRRiLLioN's vehicle respawn script //IMPORTANT: ADD A GAMELOGIC NAMED Server //to the mission to prevent multispawn private ["_unit","_type","_group","_size","_name","_respawnDelay","_delay"]; if (!local Server) exitWith {}; _unit = _this; _type = typeOf _unit; _group = group _unit; _size = count units _group; _name = format ["%1",_unit]; _respawnDelay = 2; _run = TRUE; sleep 1; for [{}, {_run}, {_run}] do { while {Alive _unit} do   {     sleep 1;   }; while {!Alive _unit && count units _group >= _size} do   {     sleep 1;   }; while {!Alive _unit && count units _group < _size -1} do   {     sleep 1;   }; _delay = Time + _respawnDelay; while {!Alive _unit && count units _group <= _size -1 && Time < _delay} do   {     sleep 1;   }; if (!Alive _unit && count units _group == _size -1) then   {  deleteVehicle _unit;     _name = _type createUnit [(getMarkerPos "Respawn_east"), _group];  [this] exec "Do_Move.sqs";  sleep 1;   }; if (!Alive _unit && count units _group == _size -2) then   {  deleteVehicle _unit;     _name = _type createUnit [(getMarkerPos "Respawn_east"), _group];  [this] exec "Do_Move.sqs";  sleep 1;   }; if (!Alive _unit && count units _group == _size -3) then   {  deleteVehicle _unit;     _name = _type createUnit [(getMarkerPos "Respawn_east"), _group];  [this] exec "Do_Move_B.sqs";  sleep 0.5;   }; };  The last part of the script is a little messy but when I initially coded the script using <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (!Alive _unit && count units _group < _size) then it resulted in an exponential increase in the number of respawning AI units so I had to move to the not so neat method given here. There are still some problems, namely that the respawn delay doesn't always give consistent results in terms of respawn delay time and sometimes due to the way the script is written if three AI units dies at almost the same instant you get three AI units all respawning at once so if anyone has any suggestions on how to improve this script it would be appreciated.  I kind of like the randomness of all of this though as you can't always predict when and how many units are going to respawn at once.  The good thing is that you never have anymore than the starting number of AI units. An important thing to remember is that the AI_respawn.sqf shown is designed for groups comprising 3 units if you want to have groups of a larger size you need to include extra <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (!Alive _unit && count units _group == _size -n) then etcstatements up to the number of units in the group (ie. where n = the number of units in the group).</b>  Also don't forget to check KaRRiLLioN's post here if you are interested in implementing this script in your own missions. In the doMove script I ran into problems when I set the unit waypoint locations using the setWaypoint cmd as it would cause all alive units in the group to execute the waypoints every time the script was triggered and therefore I had to use the doMove method given.  Its important not to set waypoints for your AI units in the editor as these seem to override the doMove cmds for the progressive respawn points. You could also possibly use the setBehaviour and setCombatMode cmds in the doMove script but I haven't had a chance to try that yet.  I did try setting it in the AI_respawn.sqf after the unit was created but for some reason it seemed to stop the AI units from respawning after a couple of respawn cycles. Assuming that it works in MP this sort of script may be good for CTI scenarios in that it would allow non-playable-AI units to defend a specific position before falling back, which would be a boring job for playable units as they'd have to wait around for a possible attack that may never come and it would therefore free up playable units to lead the assault.  In SP it could allow for a more measured challenge than having to attack a position defended by let say a 100 AI units as using this respawn method you could start with a smaller number of AI defenders and with a constant flow of reinforcements the battle would never become too overwhelming. You can down load a very simple example mission that incorporates all of these scripts from here In the mission example given the non-player AI respawn points are set to the playable respawn points but they could of course be set progressively to completely different respawn locations to the playable units by setting a different marker position in both the AI_respawn.sqf and respawn_point_update.sqs scripts. The mission also incorporates two AI_respawn.sqf and two DoMove.sqs scripts.  This was done so that the two enemy AI groups could have different waypoints to the same location just to mix things up a bit. If anybody's interested on how I got to this point and see who helped along the way please see the following two threads. http://www.flashpoint1985.com/cgi-bin....t=57067 http://www.flashpoint1985.com/cgi-bin....t=57314 EDIT: The mission file has been slightly tweaked (ie. waypoints moved) to make it a bit harder for BLUFOR. Share this post Link to post Share on other sites
norrin 9 Posted January 25, 2007 You can simplify the sqf script by replacing it with this <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//***************************************************** //** Operation Flashpoint Script File //***************************************************** //BEGIN AI_respawn_B.sqf //adapted from KaRRiLLioN's vehicle respawn script //IMPORTANT: ADD A GAMELOGIC NAMED Server //to the mission to prevent multispawn private ["_unit_B","_type_B","_group_B","_size_B","_name_B","_respawnDelay_B","_delay_B"]; if (!local Server) exitWith {}; _unit_B = _this; _type_B = typeOf _unit_B; _group_B = group _unit_B; _size_B = count units _group_B; _name_B = format ["%1",_unit_B]; _respawnDelay_B = 3; _run_B = TRUE; sleep 1; for [{}, {_run_B}, {_run_B}] do { while {Alive _unit_B} do   {     sleep 0.5;   }; _delay_B = Time + _respawnDelay_B; while {!Alive _unit_B && Time < _delay_B} do   {     sleep 0.5;   }; while {!Alive _unit_B && count units _group_B > _size_B -1} do   {     sleep 0.5;   }; if (!Alive _unit_B) then   {      deleteVehicle _unit_B;      _name_B = _type_B createUnit [(getMarkerPos "Respawn_east"), _group_B];      [this] exec "Do_Move_B.sqs";      sleep 10;   }; }; One significant problem I've noticed with more playtesting is that when multiple units spawn at the same time the last spawning unit of the group is the only one that executes the doMove script.  Whereas, if only one unit respawns at a time this is not a problem.  I'm currently trying to think of a way around this but any suggestions would be appreciated. EDIT:  It looks like by increasing the sleep time to 10 (it was previously set to 1) after the <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this] exec "Do_Move_B.sqs"; line may have solved this problem. Share this post Link to post Share on other sites
strango 5 Posted January 26, 2007 If you're wanting to run the script for the new unit I would do: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[_name_B] exec "Do_Move_B.sqs"; Using it's specific name to run the script will be more reliable than this. I'm not totally certain what Do_Move_B.sqs looks like, so I can't be certain which data you're passing as a parameter. Share this post Link to post Share on other sites
norrin 9 Posted January 26, 2007 @Strango As a far as I can tell it seems to be running OK now that I've set the "sleep 10" after the doMove exec but if I run into any more probs I'll be sure to try what you suggested. A new version of the mission with the updated scripts is now available from here Share this post Link to post Share on other sites
colligpip 0 Posted January 26, 2007 Is it posible to make it so that the AI get into respawned vehicles??? dl works below now thanks Share this post Link to post Share on other sites
norrin 9 Posted January 26, 2007 Sorry m8 try here if that doesn't work I may have exceeded my bandwidth on my account and I'll try and get some one else to host. EDIT @colligpip Sorry didn't see your edit but for the life of me can't make a respawning non player AI unit get in a vehicle as the Addwaypoint cmd doesn't seem to work in this case and I can't work out a variation of doMove cmd that allows you to do it either sorry m8. Â Please if anybody else knows how to do this could you post here. Share this post Link to post Share on other sites
norrin 9 Posted January 28, 2007 @ colligpip OK I have now made some progress with a respawning non playable AI unit getting in a respawned vehicle.  One way to get a non-playable AI unit into a vehicle is to have the vehicle grouped with the AI unit.  Make sure that you have this in each AI units <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">s = this execVM "AI_respawn.sqf"; init line and assuming that you've also set this or something similar <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> blue_1 = group this of your lead AI unit and the vehicle is a HMMWV you'd then put something like this in the do_move.sqs script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;Do_Move.sqs' _unit = _this select 0 _group = group _unit _group AddWayPoint [nearestObject  [_unit, "HMMWV"], 0] [_group, 1] setWayPointType "GETIN" exit Then whenever an AI unit respawns it will get in the closest HMMWV that is a member of its group. You could then set more waypoints to your destination using the doMove cmd in your doMove.sqs.  Don't use the set Waypoint cmd as it may make all the alive units in the group even those still at the front execute the waypoints.  Come to think of it this may also be a problem when telling spawning units to get in the vehicle by using the AddWaypoint cmd for the group.  So you may have to put some kind of delay in so that the respawning units hold until all the AI units have been killed and respawned before getting in the vehicle and speeding off. A second problem you may run into using KaRRiLLioN's vehicle respawn script is it respawns an empty vehicle and as far as I can tell you can't make an empty vehicle a member of a group. I clearly need to think about this more.  Maybe try the MoveIn cmd instead. Share this post Link to post Share on other sites
norrin 9 Posted January 30, 2007 Respawning AI moving in respawning vehicles Colligpip I’ve done it, well for a HMMWV50 anyway.  I now have unplayable respawning AI units getting in a respawning vehicle and then moving through a series of waypoints.  None of this would have been possible of course without KaRRiLLioN’s vehicle respawn script as a starting point. I’m sorry to keep posting in my own thread but I know at least two people who are interested in seeing the result of this and it may be of some interest to others as well.  More importantly my multiple scripts have a couple of bugs and someone may know just what needs to be tweaked to resolve these problems. You can get a simple example mission that shows these scripts in action from here You can play this mission from three perspectives: a BLUFOR unit just next to where the vehicle spawns; a civilian near where the BLUFOR forces disembark or an OPFOR unit that is attacked by the BLUFOR forces. The scripts are designed so that the respawning vehicle waits until its has four passengers onboard before moving towards its destination.  The units are placed in the respawning empty vehicle using the MoveIn commands.  There were a multitude of challenges for a novice scripter like myself but one of the hardest was to find some way to ensure that the units kept moving towards their objective even if their leader spawned back at the home base as they had a tendency to turn round and run all the way back home when this happened which not only affected the realism of what was happening but really stuffed up the scripting as the respawned vehicle could not be properly repopulated and hence would never move to the designated waypoints.  This was finally achieved by using the unassignTeam keyword and removing the commander from the group once the command for the final waypoint had been given.  I also used a variation of this (the unAssignVehicle cmd) to get the units to disembark. The hints that appear in game are there just to give you an idea of what the script is currently doing so feel free to remove them. Bugs encountered so far: I’ve only set this up so far for a HMMWV50 but if the gunner is killed enroute to the waypoint his corpse won’t disappear and this prevents the vehicle from respawning.  I’ve tried scripting it so that the gunners corpse is deleted the moment he dies but for some reason his corpse just won’t disappear.  Is this a bug in the game? If the vehicle is destroyed with a rocket while there is the gunner’s corpse present it completely locks up the the game. Occasionally, if the vehicle is under fire or threat in some instances a couple of BLUFOR units will bail out prior to the vehicle reaching the waypoint if you give it time though the HMMWV will get there and the respawning will continue to cycle. So when playing as OPFOR try not to go too far beyond the crossed line as it may seriously distract the BLUFOR from their initial waypoints and hence upset the scripting. Note: This has not yet been tested on a dedicated server. Share this post Link to post Share on other sites
colligpip 0 Posted January 30, 2007 Had a quick look good job although the dead gunner bug happend a few times this will be relaly good if thats sorted out . If you keep this up we can have a  persistant multiplayer war running!! :-)) Share this post Link to post Share on other sites
Espectro (DayZ) 0 Posted January 30, 2007 Nice I will have a look later when i have time. If you keep this up we can have a  persistant multiplayer war running!! :-)) You read my mind... Although sickboy is upto something as well using DAC.... Which reminds you I think I ow you an essay, sickboy ? Share this post Link to post Share on other sites
colligpip 0 Posted January 31, 2007 @norrin I think your prog spawn points and AI vehicle respawn would be good in this sort of C&H mission. http://www.flashpoint1985.com/cgi-bin....y998496 I would love to see the two ideas combined. Share this post Link to post Share on other sites
norrin 9 Posted January 31, 2007 @colligpip I agree m8 that would be an excellent scenario in which to implement these scripts but I need to sort out the bugs with the latest lot of AI/vehicle respawn scripts first. Â I think I know what's causing the dead gunner vehicle respawn and the rocket bugs (here) but as I was out on the sauce last night I haven't had a chance to work out a solution yet. Â I think what it comes down to in the first instance is the vehicle respawn script is seeing the dead gunner as crew and in the second there is no option in the script for when a crewed vehicle is destroyed outright by something like a rocket and therefore its doesn't know what to do and locks up the game. I've been trying to use these scripts in a different way though and the mission I'm currently writing is more like Sickboy's Pilot Rescue Mission described here which is made using a combination of scripts including the DAC scripts mentioned by Espectro. Â My co-op mission is on a much smaller scale (it takes place in a single city) and utilises semi-random mission insertion points and then semi-random enemy placements with respawning AI with editor defined specific waypoints etc rather than dynamically created units etc. Â There's still a few other things I'd like to work out however and they include: (i) specific waypoint paths for respawning AI chosen randomly using a random no generator (which should be easy), (ii) to have respawning AI wait until all of a group has respawned before moving off together through the waypoints to an objective and combining this with individual AI units that move through waypoints by themselves just to mix things up a bit, (iii) and not forgetting trying my system with other types of vehicles as well as ramping up the scale of things eg multiple vehicles and groups and seeing if it all works with out putting too much strain on the old PC. To complete the BF2 analogy you'd really need to allow respawning AI to respawn on their group leader if he was still alive. Â If he wasn't they'd respawn out of the action and wait until the whole group was alive before moving back into the action. Â I don't think this would be too hard to implement (lol famous last words) but I'd probably prefer to use some variation on PRiMe revive/respawn script so that if the team leader was still standing after a fire fight he could go round and revive his fallen comrades. Â This is on the "to do" list but it may take some time to get to. Share this post Link to post Share on other sites
twisted 128 Posted February 1, 2007 this is very interesting. don't like the respawn on leader (like BF2) but if you make that sorta an option hey no problem. damn interesting scripts though. hope you persevere. Share this post Link to post Share on other sites
norrin 9 Posted February 4, 2007 Its taken a bit of time but I've managed to iron the bugs from the vehicle respawn script so that the vehicles will respawn if the dead gunners corpse is present and you can now destroy the vehicle with an AT rocket without the game locking up.  You can down load the latest bug free version of the mission (fingers crossed ) from  here (make sure its ver 3). I essentially had to rewrite KaRRiLLioN's Vehicle respawn script to get it to work.  You can see the modified script and read about what it took to get there here if you're interested. Now to start working on the next lot of features. Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted February 4, 2007 If you want to test on a dedicated server, all you need to do is start ArmA on your machine using the -server parameter and then start up your client as you normally do. Then you can change the server browser to LAN and you'll see your dedicated server. Even though it's on the same machine, the server will treat your client as remote and you should get reliable test results. Share this post Link to post Share on other sites
=jps=sgtrock 4 Posted February 4, 2007 It would be interesting to see what happens with multiple players, though. When he said dedicated server, I assumed he meant that it needed testing that way. Share this post Link to post Share on other sites
norrin 9 Posted February 4, 2007 @KaRRiLLioN Thanks m8 that's a priceless tip @SgtRock You're absolutely right this has not yet be tested AFAIK on a dedicated server with multiple players. Â Its still very early days and at this point more proof of concept than anything else. Â I've still got a couple more things I want to sort out over the next few days (see a couple of posts back) and then I'll start upping the scale of thing in missions using multiple AI groups and vehicles. For a simple mission with the latest version (currently ver 3) of the scripts see here Share this post Link to post Share on other sites
gassybutt 0 Posted February 5, 2007 Hey Norrin - i'm interested in seeing this in a multiplayer 'skirmish' type of mission with many units on each side. Regarding the dead gunner problem that causes crashes - does this happen in all vehicles or just the jeeps w/mounted machine guns? Â What about in for example, a tank - I'm assuming the gunner is treated the same as in a jeep but would a dead commander cause the same issues as well? Keep up the good work. Share this post Link to post Share on other sites
norrin 9 Posted February 5, 2007 The dead gunner spawn thing is hopefully fixed in the latest version -Â I was playing around with this on a dedicated server last night and it worked, dare I say, perfectly. My heavily revised version of the VRS.sqf script thats now included in the mission should work with any AI vehicle, a m8's been using it with choppers and it seems to be working well. There still a couple of scripts I want to write before I get heavily into the mission making, for instance I want my unplayable AI to respawn with the weapons that they started with and also I want to be able to get groups of AI foot sloggers to wait until the team has respwned before they move out together in formation but I agree these scripts would work well in a MP skirmish type situation. Share this post Link to post Share on other sites
norrin 9 Posted February 15, 2007 Well finally I'm back with my latest iteration of the respawning AI scripts for vehicles and foot soldiers. Â This time we've got 2 Hummers and two groups of AI ground soldiers attacking a OPFOR defended cross roads. Â Once the cross roads are taken the spawn points update and the units attack the town. Â You can get a copy of latest version of the mission here(version 12 with jip) When a member of one of the groups of ground troops respawns it waits unit the rest of the group respawns and then moves onto the waypoints. The same happens for the vehicle based troops. The mission also uses a one way progressive respawn point that moves spawn locations of the units forward and updates the WPs for the new objective which is in the centre of the town. For the ground troops I've also set it up so that each time the group respawns they approach the target via one of three randomly selected paths (couldn't be bothered setting it up for the vehicles but its just the same principle). The AI troops also respawn with whatever weapons they were carrying at the start of the mission (their maybe a bug with the vehicle based troops but more on that later). Theres still one problem that I'm racking my brain over and that is it takes a lot longer for the vehicles to move on a dedicated server eg several minutes before they move compared to seconds on a local server. Â It also takes longer for the units to respawn. If any one has any ideas on how to fix these problems please let me know. PS: I can see Gonza has made real progress with his mission and I think these scripts would work very well in conjunction with what he's doing, we just need to get them working better on a dedicated server. Â Mission details Plan: Attack and secure the crosss roads outside of town prior to moving on the town itself. Example mission demonstrating respawning nonplayable AI units boarding an empty respawning vehicle and then moving to a waypoint before disembarking and attacking an objective. Â Also groups of respawning AI ground troops moving via semi randomised waypoints to objective. Â Mission also uses one way progressive respawn points. Â This mission uses several new scripts for respawning AI soldiers and vehicles including a highly modified version of KaRRiLLioN's Vehicle Respawn Script that works with non playable AI units Notes: You can play this mission from the perspectives of a BLUFOR unit or as a civilian friendly to both sides so you can watch the action unfold. Bugs so far encountered 1. it takes a much longer time before the vehicles move on a dedicated server. EDIT: Problem with disembarking units fixed updated mission to ver 12_jip (here). Â However, still problems with units respawning much more slowly and vehicles taking much longer to start moving on a dedicated server. EDIT: Just had a thought, I am running both the dedicated server and client on the same box and I wonder whether its putting too much strain on my processor Share this post Link to post Share on other sites
MeNeZ 0 Posted February 26, 2007 Hi, You guys seem to know what youre talking about lol, can you please help me with one little thing plz plz plz Im almost finished a map, one of 3 which I have spent countless hours on...I just need to know how to make a flag/city/area cappable like a CTF map where there are points and the flag changes sides. I have searched many forums and this thread looks pretty close but the initial script looks more like a vehicle respawn thing than flag capture stuff. Can you please point me in the right direction???! Baring in mind, scripting is very new to some of us lesser mortals I tried to edit one of the MPTemplates like sector control and flagfight to get an example but when I open the maps EVERY object is stacked ontop of eachother and not at there propper positions so I cant see how the flags, zones and logic all work together and how you space them... Share this post Link to post Share on other sites
norrin 9 Posted February 26, 2007 I'm not entirely sure what you are after Menez. Do you want a capturable area with a flag that changes textures when the zone is held? Maybe if you could email me your mission with a bit more explanation on what you are trying to achieve I'll see if I can help out. I've PM'd you my email address so you can send your stuff. Share this post Link to post Share on other sites
MeNeZ 0 Posted February 28, 2007 Hey thanks, I sent you the mission. I think you will see what I mean. Basically I just want to set capturable flags like in BF2. I havent found good tutorials or scripts on how to make an area cappable... Share this post Link to post Share on other sites
MeNeZ 0 Posted March 1, 2007 Bump* I've made an even better mission!! seriously!! I played OFP since the early days and I knowwhat this game is capable of and how to make it fun. My new map is really cool, very diverse. I just need help with the capture zones then its finished. Can I like team up with someone to finish it and share credit???! Share this post Link to post Share on other sites
norrin 9 Posted March 4, 2007 Just tested version 12 of the respawning AI controlling respawning vehicles mission (get it here(new improved, now with jip see edit) on an ArmA ver 1.05 dedicated server and the delay with the AI vehicles moving seems to have disappeared in 1.05. Â So this mission is now working very well on both dedicated and local servers. I just need to tidy up the init.sqs so that it works with JIP in progress and Bobs your uncle. This method can then be used for missions that need many respawning unplayable AI unit controlled vehicles EDIT: Edited sample mission you can now play with a buddy and join in progress seems to be working. Â Get new version here here. Also updated previous links. Please let me know if you run into any problems Share this post Link to post Share on other sites