alarm9k 14 Posted August 24, 2014 (edited) Download: v.1.8 From Dropbox v.1.8 From Armaholic Description: Have you ever been irritated by stupid far from optimal AI controlling the tank and being destroyed by one RPG shot in the rear? Only because it didn't bother to rotate the hull to that AT soldier? Or because it was firing at a harmless rifleman instead of taking care of enemy APC? Well, this script is for you. Features: Vehicles assess the threat/value of the targets and fire at the most dangerous/valueable target it range. It will prefer AT rifleman over autorifleman, tank over MRAP etc. Threat and value calculations use the type of target, distance and ammo types available (for tanks only). For example: AT rifleman 700m away is a more valuable target for the tank than MRAP-HMG at the same distance, but only if the tank has HE rounds. Otherwise it will prefer to fire AP round at MRAP, as the infantry unit is unreachable with current weapons. But AT rifleman still remains more dangerous than MRAP. Tanks will use appropriate rounds (if available) for different types of targets: HE for infantry and static weapons, HEAT for lightly armored targets (MRAPs, trucks), AP for heavily armored (tanks, APCs etc). Tanks will identify groups of infantry and use HE rounds agains them. A group is 3+ men in 15m radius. By default the tanks will not spend HE rounds on a single infantry unit (unless it's a high-threat AT soldier). If the vehicle is a tracked vehicle (tank, tracked APC etc), it rotates the hull to face the most dangerous target. If the threat is too high (for example an AT soldier at a close range), the moving vehicle will stop immediately, rotate the hull and fire. When the immediate threat is eliminated, it will proceed with the previous move order. This will presumably save the vehicle in situations when a hit is inevitable and the best decision is to stop and take the hit to the frontal armor rather than continue moving and take the hit to the side/rear. Notes: It does not cheat and it uses line of sight calculations and perceived position of the targets. So the tanks will not fire at and rotate to the targets they don't know about. Only tracked vehicles rotate the hull. Target assignment works best with MBTs (Slammer, Varsuk) as they switch targets immediately. With APCs and MRAPs there can be a delay before they leave that poor rifleman alone and target an AT soldier. Real Armor Mod or a similar one is highly recommended. I haven't found a way so far to override default behaviour in ATTACK (Engaging) mode, so when Engaging the vehicle will not stop, rotate etc. Currently 'smart' behaviour covers all ground vehicles that have weapons, from all factions, found in game. There is no separate config file to include/exclude particular vehicles/types/factions for now. It will be implemented later though. The vehicles list is hardcoded for now, which means that addon doesn't cover modded vehicles that have non-standard types and names. Installation: Unzip the archive Put the @smarter_tanks folder into your Arma3 folder (usually C:\Program Files (x86)\Steam\steamapps\common\Arma 3\) Usage: Some of the use cases below assume that the vehicle is in the player's group and the player can issue direct commands to the vehicle's crew, which is not always the case. If it's not then some of the options won't be available: for example, changing default round type. Smart behaviour is activated automatically if the vehicle has an AI crew. This includes the vehicles created with the crew inside, or empty vehicles occupied after the mission start etc. Smart behaviour is activated for all factions and all groups: AI groups, vehicles in the player's group and High Command. If either gunner, driver or commander is a human player, the smart behaviour is suspended and manual control is assumed. If the human player is replaced by AI at any moment, the smart behaviour is re-enabled. Vehicle commander's behaviour must be either Stealth, Aware or Combat. To disable 'smart' behaviour set the commander to Relaxed. This is just a sort of 'switch' for dynamically enabling or disabling the smart behaviour during the mission, until I implement a separate action menu. To disable hull rotation but keep picking priority targets issue a Stop order (Action menu 1-6). The vehicle will go into Waiting state. To resume full 'smart' behaviour, including hull rotation, issue a Move order at the vehicle's current location: the vehicle will not actually move but will go into Ready state. If you don't want the tank to halt after encountering an immediate threat, set the commander's behaviour to Stealth. It will continue to execute its move order regardless. For tanks there is such thing as 'default round type'. Tanks start with AP as the default. Tanks will have default round loaded unless they fire at a different type of target. If you manually give the tank commander to 'Reload HE-T`, the HE round will become default. Having HE as default makes the tanks fire HE rounds at single infantry units (not only groups). So if you expect armored targets around, its a good idea to have AP as default, as the tanks will have AP loaded and won't waste time reloading the round. If, however, you want the tanks to use cannon against every soldier they see, make HE default. Manually ordering the tank to target an infantry unit (action menu 2-x) will make him use HE round against assigned target, even if it's not a group of infantry. Changelog: v.1.8 -Fixed: commander stuck watching the same direction forever after has been given doTarget order. -Fixed: 'lazy' target switching. Will now immediately switch to more valueable target. -Fixed: setup.sqf non starting for vehicles with non-standard names (modded). Should now work for any vehicle that has weapons (list of weapons is still hardcoded though). -Fixed: small fixes here and there. -Added: vehicle commander (or gunner, if no commander) will 'scan the horizon' for targets when idle. Commander will use his optics independently of gunner's main turret. v.1.7.1 -Added public key to archive (forgot to do that) v.1.7 -Hardcoded unit classes replaced with dynamic threat assessment based on available weapons: both target and our vehicle (a 'sniper' infantry class that has aquired AT launcher will be given threat value as an AT rifleman). Should now work with modded vehicles with non-standard names, as long as they belong to standard base classes (Man, Car, Tank etc) and use standard weapons names. -Tanks will fire HE rounds at helicopters. -Added signature. v.1.6 -Fixed multiplayer bugs (locality shifts). Now works properly in multiplayer and on dedicated server. -Small bugfixes v.1.5 -Improvements to targeting algorithm. -Tanks load appropriate rounds for different target types. -Tanks identify groups of infantry and use HE against them. v.1.4 Distributed in a form of addon now. v.1.3 Smart behaviour is now determined by the commander's combat mode, not driver's. This way tank's driver can be set to RELAXED (to stick to roads while moving) without disabling hull rotatation and target aquisition. v.1.2 -Fixed: doesn't require human player in faction any more for the script to work. v.1.1 -Added compatibility with High Command. -Small fixes v.1.0 -Initial release. License: Do whatever you want with this script. Even claim it your own if you really need to. Credits and thanks: This script could not be made without the help of my wife Natalie. She kindly didn't interfere in exchange for my promise to mention her in the credits :) Edited October 24, 2014 by alarm9k 4 Share this post Link to post Share on other sites
Rydygier 1309 Posted August 24, 2014 (edited) Oh, great, most welcome idea, it's one of the main gaps in the vanilla vehicle's AI. I'll test that soon. For now only reading some code parts. Few things so far: - may be hard/not worthy to script, but IMHH&HO (I do not now RL doctrines on that) sometimes, when tanks is moving and crew suddenly see serious threat, may be not always wisest thing to do to stop on plain sight and engage (there is a risk, so threat will be able to fire before tank may be ready to do same, if hostiles saw tank first, which is probable, if tank was on the move, and they not. In such case stopping may only facilitate the attack for hostiles). If possible to do it fast, sometimes may be considered get out of the line of fire - seek for some LOS obstacle near ahead and hide there to assess the situation and plan next move. I thik so at least. - in the future would be nice to heave threat calculation taking into acount also vehicles from custom mods, without need of manual expanding hardcoded classnames arrays. Maybe something based on weaponry config? Trick is to determine, which config entries/combination of entries gives as a result reliable info, if/how serious threat given unit poses. A single formula seems better than manually written lists. - if-then series may be replaced with switch-do for some performance gain. - from own experience - addon version automatically controlling all found on the map/spawn later armored vehicles may be desired option too. With option for manual exclusion of chosen vehicles from the control any time. - reflexes (reaction delay) and misjudgement factors based on crew skill? Some randomization here would be nice, to make eg tank platoon reactions more human-like and diversed, less "as one". And respects for your Wife. :) Edited August 24, 2014 by Rydygier Share this post Link to post Share on other sites
alarm9k 14 Posted August 24, 2014 (edited) Thanks for your feedback and advice. I'll try to gradually implement all of the above and improve overall code quality (I'm rather new to Arma scripting). Yes the idea about the tanks that could use obstacles to hide behind is what I have in mind too. Like hopping from behind an obstacle, firing and moving back to cover like in real life. Bugged backward movement for tanks makes it hard though :( The whole idea behind halting after encountering an 'immediate threat' is that the tank would most likely be destroyed if it continued moving. For example when we encounter an AT soldier at 300 meters who is most likely aware of our presence, and it would take him 2 seconds to swtich to AT launcher, aim and fire. If the same AT soldier is 1000 meters away, he is not considered an immediate threat though, because he may or (most likely) may not be aware of our presence. But still... teaching the tanks to use cover is what I dream of too :) Edited August 24, 2014 by alarm9k Share this post Link to post Share on other sites
serjames 357 Posted August 24, 2014 Very exciting development and clear requirment for such based on my experience to date. Features that I would love to see - Please bear i mind I'm no coder so these are mearly desires as opposed to things I know might be possible - you tell me. Mod features - Use vehicle type based on PhysX i.e tracked to determine if a vehicle should run the script (should allow modded tanks like Reyhard's excellent T- series tanks to work) - Make it a modular addon as opposed to a script - easier to implement etc - Give it capability to see vehicles spawned by 3rd party i.e. ALiVE - we rarely manually place vehicles these days, preferring the excitement of a more dynamic placement - Modular - i.e. we can turn on features if appropriate. So I would want russian or Nato Tanks to follow all the proper tactics as below, but probably not some Jihadest in T-55 he can simply charge around as needed... Vehicle Tactical features. - Go to Hull down position. if near escarpments or rocks or other obstacles can the vehicle position itself "hull down" - Break contact under file - smoke then rapid reverse course still facing the enemy Hull/cannon - Bounding over watch - in tank formations allow covering move and fire... Very effective for Ai Soldiers would be doubly effective for vehicles - Prefer Infantry support - stick with infantry if near and follow their lead on movements or SAD - Road formations - no idea how you code it, but could you get vehicles to use standard formations i.e. stop and Herringbone etc ? Angle coverage - 1st vehicle covers front, next left, next right etc etc Sure there are more - will have to ask some of our Tanker/apc vets what they recommend. Very excited to see this done finally !! Great start SJ p.s. Thanks Natalie !!! keep the coffees coming ---------- Post added at 10:00 ---------- Previous post was at 09:53 ---------- Thinking aloud - if someone could model a berm/tank trench maybe we could script a function that had the tank rock forward and backwards to Simulate digging a trench and then spawn the trench model around it... http://www.legionsivhire.ca/media/catalog/product/cache/1/image/f1e76205c79b172c8662621d7cd8558b/e/c/ec026.jpg Might look contrived... I don't know.. Would be cool possibly SJ Share this post Link to post Share on other sites
Rydygier 1309 Posted August 24, 2014 a function that had the tank rock forward and backwards Yeah, but: Bugged backward movement for tanks the tank would most likely be destroyed if it continued moving. Often indeed, question is, if/to what extend script should consider opposite situation, where breaking LOS, when possible fast enough, seems better idea than stopping. In my gameplays, as a tank driver, I can say, that by choosing the second option I few times saved tank from destruction, inevitable, if I would halt the vehicle in plain sight instead of continue run to the cover. Share this post Link to post Share on other sites
kremator 1065 Posted August 24, 2014 Very exciting indeed. There have been some worthwhile attempts to do this in the past with varying success. Good to see if being worked on. AI are not very I at the moment! Share this post Link to post Share on other sites
pulstar 55 Posted August 24, 2014 Very exciting development and clear requirment for such based on my experience to date.Features that I would love to see - Please bear i mind I'm no coder so these are mearly desires as opposed to things I know might be possible - you tell me. Mod features - Use vehicle type based on PhysX i.e tracked to determine if a vehicle should run the script (should allow modded tanks like Reyhard's excellent T- series tanks to work) - Make it a modular addon as opposed to a script - easier to implement etc - Give it capability to see vehicles spawned by 3rd party i.e. ALiVE - we rarely manually place vehicles these days, preferring the excitement of a more dynamic placement - Modular - i.e. we can turn on features if appropriate. So I would want russian or Nato Tanks to follow all the proper tactics as below, but probably not some Jihadest in T-55 he can simply charge around as needed... Vehicle Tactical features. - Go to Hull down position. if near escarpments or rocks or other obstacles can the vehicle position itself "hull down" - Break contact under file - smoke then rapid reverse course still facing the enemy Hull/cannon - Bounding over watch - in tank formations allow covering move and fire... Very effective for Ai Soldiers would be doubly effective for vehicles - Prefer Infantry support - stick with infantry if near and follow their lead on movements or SAD - Road formations - no idea how you code it, but could you get vehicles to use standard formations i.e. stop and Herringbone etc ? Angle coverage - 1st vehicle covers front, next left, next right etc etc Sure there are more - will have to ask some of our Tanker/apc vets what they recommend. Very excited to see this done finally !! Great start SJ p.s. Thanks Natalie !!! keep the coffees coming ---------- Post added at 10:00 ---------- Previous post was at 09:53 ---------- Thinking aloud - if someone could model a berm/tank trench maybe we could script a function that had the tank rock forward and backwards to Simulate digging a trench and then spawn the trench model around it... http://www.legionsivhire.ca/media/catalog/product/cache/1/image/f1e76205c79b172c8662621d7cd8558b/e/c/ec026.jpg Might look contrived... I don't know.. Would be cool possibly SJ Good suggestions, start coding! Or alternatively, play SB Pro PE :rolleyes: Share this post Link to post Share on other sites
kremator 1065 Posted August 24, 2014 I think there is a berm model already in Arma 2 that could be used. If course it would need AiA or the like. If only we had deformable terrains! Share this post Link to post Share on other sites
alarm9k 14 Posted August 25, 2014 Okay, voice of the customer has been heard. I will make current features more production quality and user-friendly first before moving on to more complex tasks. So this is what the approximate roadmap looks like: Higher priority (easier to do, reasonable impact): "Use vehicle type based on PhysX i.e tracked to determine if a vehicle should run the script..." I would appreciate a hint about this, a link for example. "Make it a modular addon as opposed to a script - easier to implement etc..." "...addon version automatically controlling all found on the map/spawn later armored vehicles..." Again, a coding hint would be appreciated. Is there any other way rather than looping through all vehicles in the game every X seconds? "...reflexes (reaction delay) and misjudgement factors based on crew skill..." A reasonable thing, I totally forgot about skill. "Modular - i.e. we can turn on features if appropriate..." A separate config file specifying factions and maybe particular vehicles to include/exclude. Normal priority (harder/longer to do, good impact): Analyzing terrain for cover. More sofisticated decision making, based on current combat behaviour, threat type and value, availability of nearby cover and distance to it, type of cover (can fire from behind or cannot), relative direction to cover (whether we have to expose vulnerable spots -- side, rear -- while moving to cover). Proper execution of 'Find cover' order for tanks. For example you indicate the direction from which you expect the threat by giving "Watch direction" order to gunner, followed by 'Find cover' order. The vehicle then is trying to position itself behind the appropriate cover. Lower priority/most likely impossible: Anything that involves reverse movement of tracked vehicles (sadly). Backward movement probably could be simulated by setting vehicle position every .01 sec and playing tracks animation (could be?), but I strongly dislike such dirty hacks. This means no hopping left/right from behind cover. Share this post Link to post Share on other sites
reyhard 2082 Posted August 25, 2014 I took different approach when I was making some scripts for rhs tanks. As in 99% of cases it most likely that tanks are crewed by Crews I used they danger fsm script and hooked some code so for example BMD4 commander is unloaded in combat too. Take a look at options you have there http://reyhard.armacenter.pl/arma3/fsm.jpg and then in unload function you can detect kind of vehicle (i.e. general tank may be used instead of APC) _u = _this select 0; _v = vehicle _u; if ( //check if vehicle is deisred kind of _v isKindOf "rhs_bmd_base" OR _v isKindOf "rhs_bmd4_vdv" )then { //execute some code }; alternative, you may check also if vehicle is APC by looking at nameSound config entry (transportSoldier may not work as merkava has capability to unload carog :P) nameSound="veh_vehicle_APC_s"; _nameSound = getText (configFile >> "CfgVehicles" >> typeOf _v >> "nameSound"); if(_nameSound=="veh_vehicle_APC_s")then{hint "doing something"}; if(_nameSound=="veh_vehicle_armor_s")then{hint "tadabum"}; etc. Share this post Link to post Share on other sites
serjames 357 Posted August 25, 2014 Regarding type TrackX... I'm honestly not sure but I found this: simulation = "tankx"; here https://community.bistudio.com/wiki/Arma_3_Tanks_Config_Guidelines perhaps you can "look" for that feature ? Here's another one to consider - When a vehicle is hit a routine is run to weigh up vehicle damage/survivability with the immediate threat and the crew may decide to stay in the vehcile... i.e. opposition is infantry as opposed to Tanks / helicopter Weapon still functional etc ? SJ Share this post Link to post Share on other sites
kremator 1065 Posted August 25, 2014 Unless the tank is in imminent danger that the next shot will kill the tank or crew, the crew should remain inside. Sometimes even playing dead is a useful trick! Is the plan to have this as an addon eventually? Share this post Link to post Share on other sites
Rydygier 1309 Posted August 25, 2014 (edited) I would appreciate a hint about this, a link for example. If I understood this correctly, type of vehicle may be procedurally determined via it's config, like: _isArmored = toLower ((getText (configFile >> "CfgVehicles" >> (typeOf _veh) >> "simulation"))) in ["tankx"];//true or false But wheeled APCs have "carX" simulation, and this may be a problem, if you want to include also these. Alternatively however may be used mentioned way based on isKindOf: _isArmored = (_veh isKindOf "Tank") or (_veh isKindOf "wheeled_apc_f"); See also entities command. This: _allTanks = entities "Tank"; gives array of objects of kind "Tank" currently on map. Again, a coding hint would be appreciated. Is there any other way rather than looping through all vehicles in the game every X seconds? If there is - never heard about. Except messing via addon with armored vehicles config to set there script executed at vehicle creation via init EHs (Iron Front's Damage System seems to work this way, but that's another story). But then again, affected vehicles are not dynamically determined, but hardcoded, so this leads nowhere, if script should work also with custom addon vehicles. Certainly, kind of "onCreation" EH for scripts could be very useful... In general - you may find useful analyzing one of my early works for A2, expanding Tank Damage System by Nice_Boat, where this and other things may be studied as reference: NBT TDS (all but script init itself done purely on sqf scripting level) Edited August 25, 2014 by Rydygier Share this post Link to post Share on other sites
alarm9k 14 Posted August 25, 2014 (edited) "...Use vehicle type based on PhysX..." I was confused by mentioning of PhysX in regards to determining the vehicle type. Now I understand. "...When a vehicle is hit a routine is run to weigh up vehicle damage/survivability..." Added to roadmap. Although I'm afraid it will have a lower priority. Please, don't expect too much from me, gentlemen. I can only spend a couple of hours per week developing this. Edited September 13, 2014 by alarm9k Share this post Link to post Share on other sites
serjames 357 Posted August 25, 2014 Heh no problem ANYTHING is better than the current state of affairs.. There are lots of experienced Coders out there; Rydygier for instance ! don't be afriad to bounce ideas around and get help where needed ! SJ Share this post Link to post Share on other sites
Guest Posted August 25, 2014 I love the idea of this as Tank Crew AI is absolutely moronic in arma. Please please attempt to 'teach'them to REVERSE when moving away from enemy instead of turning their whole hull around. Things like this as so basic in tank combat that it makes Arma a bit of a farce regarding armored warfare... Share this post Link to post Share on other sites
Guest Posted August 27, 2014 New version frontpaged on the Armaholic homepage. Smarter tanks v1.2 ================================================ We have also "connected" these pages to your account on Armaholic. This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
alarm9k 14 Posted September 15, 2014 (edited) v.1.4: now with banana flavor an addon. ---------- Post added at 05:53 ---------- Previous post was at 05:38 ---------- Also, if you know how to do this, I will gladly use your help. Edited September 15, 2014 by alarm9k added download link Share this post Link to post Share on other sites
alarm9k 14 Posted September 15, 2014 You are most welcome :) Share this post Link to post Share on other sites
Jackson Snow 10 Posted September 15, 2014 This sounds great. Hoping that it'll work good in multiplayer, going to try it on our server at the weekend. Share this post Link to post Share on other sites
alarm9k 14 Posted September 15, 2014 Hoping that it'll work good in multiplayer It's been tested in single player, multiplayer and dedicated server, so I don't expect any multiplayer specific issues. Hopefully. Share this post Link to post Share on other sites
Guest Posted September 15, 2014 Thanks for informing us about the update :cool: New version frontpaged on the Armaholic homepage. Smarter tanks v1.4 ================================================ We have also "connected" these pages to your account on Armaholic. This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
Jackson Snow 10 Posted September 15, 2014 It's been tested in single player, multiplayer and dedicated server, so I don't expect any multiplayer specific issues. Hopefully. Even better! Share this post Link to post Share on other sites
SavageCDN 231 Posted September 15, 2014 Thanks for the addon-version!! I would recommend signing your addon so server operators can use it on their servers. Do you think this mod could run server-side only? (assuming all AI spawn on the server) 1 Share this post Link to post Share on other sites