Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Attack_Target_Priority, script for AI Bots?
Attack_Target_Priority, script for AI Bots? [message #436439] Sun, 12 September 2010 00:09 Go to next message
TNaismith
Messages: 86
Registered: May 2006
Location: Canada
Karma: 0
Recruit
I've been working around some co-op maps and have been exploring different possibilities for adding bots to maps in connection to map/mission objectives. Browsing through the JFW scripts, and then briefly through others such as KAK, TDA and z, I haven't come across any particular scripts that allow for a dynamic 'attack target priority' system to be set. Let me describe in detail what I mean:

http://img265.imageshack.us/img265/1161/testbe.gif



Scenario:

The (blue) bot vehicle has the primary objective of destroying the (red) building. The infantry (light orange) and vehicle (dark orange) are defending the (red) building and trying to stop the (blue) bot vehicle.


How the scripting is setup:

To simulate the (blue) bot vehicle having a primary objective to destroy the (red) building, a "Daves_Arrow" object is placed on the (red) building, perhaps just a little bit inside the interior walls. Attached to the "Daves_Arrow" object is some kind of 'Attack_Target_Priority' script that says "I am something bots [can 'see' and] will decide to attack based on an assigned priority number and weapon/sight proximity range. I also have a on/off setting that can tell AI Bots to mark me as attack even if there are enemy infantry or vehicles nearby.'. If I am sent a custom, I become deactivated/activated, meaning AI Bots will no longer 'see' me, or shoot me...and vice versa"

For the (blue) bot vehicle, a script that could be named 'Attack_Target_Priority_AI' would be attached, and it would allow the bot to interact with 'Attack_Target_Priority' scripts. It would be able to prioritize to fire at any 'Attack_Target_Priority' objects nearby, or to fire at nearby enemy infantry or vehicles.

In this scenario, the bot vehicle would fire at the (red) building, but will also fire at the (light orange) infantry and (dark orange) vehicle. It will follow this plan until there are no 'Attack_Target_Priority' objects in range, and also no enemy units.



Attack_Target_Priority
    Here are the possible settings for the 'Attack_Target_Priority' script attached to the "Daves_Arrows" object:
    • Priority_Number: Variable (Number placed here will tell corresponding AI Bots how high to rank as a priority target to attack compared to any other nearby priority targets and their relative Priority_Number)
    • Absolute_Priority: Boolean (Yes/No. If Yes, then AI Bots will attack target even if there are enemy infantry or vehicles around. If No, then AI Bots will attack enemy infantry or vehicles nearby, then return to attack the target if area is clear.
    • Custom_Enable: Variable (Input the custom message to listen for to activate this script.)
    • Custom_Disable: Variable (Input the custom message to listen for to deactivate this script.)

    Additional Thoughts: Absolute Priority could be divided into 'Absolute_Priority_Infantry' and 'Absolute_Priority_Vehicles'. 'Absolute_Priority_Air' might be a consideration too.


Attack_Target_Priority_AI
    Here are the possible settings for the 'Attack_Target_Priority_AI' script attached to the (blue) bot vehicle:
    • ID1: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • ID2: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • ID3: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • ID4: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • ID5: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • ID6: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • ID7: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • ID8: Variable (Input the object ID that has 'Attack_Target_Priority' attached to it)
    • Priority_Mode: Boolean (Sets the script's target priority. 0 = Attack_Target_Priority scripted objects before Infantry and Vehicles, 1 = Infantry before Attack_Target_Priority scripted objects. 2 = Vehicles before Attack_Target_Priority objects. 3 = Infantry and Vehicles before Attack_Target_Priority scripted objects. Anything else will cause the script to ignore infantry/vehicle distinctions and rely solely on range/health/player/attack_target_priority scripted objects for prioritizing. Default is 0. If there are two Attack_Target_Priority objects with the same priority numbers, the AI will treat both equal and alternate between attacking both objects.)
    • Min_Range: Variable (The minimum range to attack a target. Targets closer than this will be ignored. Default is 0.0.)
    • MaxRange: Variable (The maximum range to attack a target. Targets further than this will be ignored. Default is 100.0.)

    Additional Thoughts: 'Attack_Target_Priority_AI' could also include parameters for a bot following a waypath; Deciding to stop, hunt, pursue, destroy and fire at any 'Attack_Target_Priority' objects (Or enemy infantry/vehicles) while following a waypath, or to continue moving on the waypath while simultaneously firing at 'Attack_Target_Priority' objects (or enemy infantry/vehicles) until the bot moves out of weapon/sight range of the said objects and/or enemy infantry and vehicles.



Bonus Example, An Advanced Scenario:

http://img641.imageshack.us/img641/8176/test2c.gif


Given what we know now about how these scripts could work and how they could be setup, here is how the scenario shown above would unfold:

The (blue) bot vehicle (with 'Attack_Target_Priority_AI' script attached) would focus on firing at the two priority = 1 ATTACK TARGET objects (ideally setup as Daves_Arrows with 'Attack_Target_Priority' script attached) until they become deactivated, treating both as equal priority targets to attack. It will also attack any of the defending (light orange) infantry and (dark orange)vehicle(s) that are inside it's weapon/attack range. In addition to the first two ATTACK TARGET objects (Which have a priority of 1 assigned to each), the (blue) bot vehicle will also proceed to fire at the 3rd ATTACK TARGET object in the top-left corner, with a Priority number of '2'. It will fire at this object less regularly than at the first two ATTACK TARGET objects (with priority of 1), but it will shuffle it's attention around all three ATTACK TARGET objects (unequally) until each one is deactivated (no longer on the AI bot's radar, figuratively speaking), and it will also attack any enemy infantry or vehicles nearby.


Similar Concepts:

- JFW_Engineer_Repair (www.Game-maps.net, update344 documentation)
- JFW_Engineer_Target (www.Game-maps.net, update344 documentation)
    Quote:

    JFW_Engineer_Target (clone of M03_Engineer_Target)

    JFW_Engineer_Repair (clone of M03_Engineer_Repair)
    Repair_Priority (priority for repairing)

    To prevent the problem where when you get out of a vehicle, it is no longer being repaired by the bots, use NH_SetTeam_OnLeave, it should work.
    Also, in addition, JFW_Engineer_Target has been modified to check the Shield Strength (i.e. armour) of the object in addition to the health.
    The repair object can be any vehicle or infantry that has a repair gun weapon and wheels/legs/tracks/whatever so it can move.
    Also, there is a limit to how far away the repair script will detect a damaged target (since I can't find the sound presets it's using, I can't identify how far that is)

    JFW_Engineer_Target_2 (clone of JFW_Engineer_Target)

    JFW_Engineer_Repair_2 (clone of JFW_Engineer_Repair)
    Repair_Priority (priority for repairing)
    Target_ID (the actual ID of the object that will get repaired)
    This is intended so you can stick e.g. a Daves Arrow such that its "inside" the MCT and the engineer will repair that (and hit the MCT since the MCT is in the way)

- RA_Base_Defense_Simple (www.sourceforge.net, Readme4 documentation)
    Quote:

    Script Name: "RA_Base_Defense_Simple"


    Description:

    A simplified version of a prototype script for a threat assessing Base Defense. It is capable of basic target prioritizing and can adjust its aim when firing at infantry. The script can be set to prioritize infantry, vehicles, or both equally. It will also rate targets based on remaining health, range, and if the target is a player or AI. Players are considered a higher priority than AI. The lower a target's health, the more likely it will be prioritized. The closer a unit is, the higher its priority is.

    Script Parameters:

    -MinRange: The minimum range to attack a target. Targets closer than this will be ignored. Default is 0.0.

    -MaxRange: The maximum range to attack a target. Targets further than this will be ignored. Default is 100.0.

    -AntiAir: Sets if the script targets aircraft. 1 = Yes, 0 = No. Default is 0.

    -AntiGround: Sets if the script targets ground units. 1 = Yes, 0 = No. Default is 1.

    -AdjustAim: Sets if the script will adjust its aim for infantry. 1 = Yes, 0 = No. Default is 0.

    -TargetMode: Sets the script's target priority. 0 = Vehicles before Infantry, 1 = Infantry before Vehicles. Anything else will cause script to ignore infantry/vehicle distinctions and rely solely on range/health/player for prioritizing. Default is 0.

    Notes:

    Adjusting aim for infantry is useful for base defenses that fire "slow" projectiles, like a cannon. Infantry can typically sidestep these kinds of attacks. The adjusted aim targets the ground the soldier is standing on instead of the soldier. This causes the projectile to explode right next to a soldier instead of traveling another 20 or so meters before impacting the ground. For base defenses that fire "fast" projectiles or non-explosive projectiles, like a machine gun, do not adjust aim for soldiers, as the adjustment would likely cause the projectile to miss completely.


Acknowledgments

I would like to openly embrace the fact that this idea isn't foolproof. I do not have experience with coding, programming, writing scripts, C++, or any other special 'technical know-how'. I only use the knowledge and observations made from constantly browsing through scripts while setting up co-op missions + maps in Level Edit, and also from reading documentation about the scripts in 3.4.4 where available. Realizing this, there are probably a lot of possible 'What-ifs' and 'This won't work because...'. I encourage you to point out any flaws or improvements for the idea, and if there is anything similar that already exists for this, please feel free to let me know as well. Smile

Why is this written?

With new maps being made for co-op gameplay over at A Path Beyond, I have found renewed interest in learning to make maps and script co-op missions using the community tools both Renegade and A Path Beyond share in common.


http://img33.imageshack.us/img33/7928/t2010021mcsig140.gif

[Updated on: Sun, 12 September 2010 02:23]

Report message to a moderator

Re: Attack_Target_Priority, script for AI Bots? [message #436444 is a reply to message #436439] Sun, 12 September 2010 01:18 Go to previous messageGo to next message
Sladewill is currently offline  Sladewill
Messages: 291
Registered: January 2009
Location: United Kingdom
Karma: 0
Recruit

Sounds interesting.

FT-Owners - Sladewill,Snazy2007,Willdy
http://FT-Gaming.com for more info...
Re: Attack_Target_Priority, script for AI Bots? [message #436446 is a reply to message #436439] Sun, 12 September 2010 01:38 Go to previous messageGo to next message
Spyder
Messages: 1070
Registered: March 2006
Karma: 0
General (1 Star)
This would come in handy for a real skirmish map. The "Multiplayer Practice" mode that Westwood designed is just not like the online experience. If there is a possibility to make the scripts you just mentioned above, you might be able to create a more realistic multiplayer experience for several maps, so new players can practice more efficient before joining the online scene.

[Updated on: Sun, 12 September 2010 01:39]

Report message to a moderator

Re: Attack_Target_Priority, script for AI Bots? [message #436510 is a reply to message #436439] Mon, 13 September 2010 04:28 Go to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
My AI scripts already handle targetting priority for AR and APB base defences in our development builds and are designed to be easily extensible to infantry / vehicles... there is in fact an AI for tanks already implemented although it needs some tweaking.




My stuff works by assigning a 'base priority' to each target type (infantry, vtol, light vehicle, heavy vehicle, building) and then adjusting that based on a set of modifiers including distance to target, value of target and targets health status. It then picks the highest priority target to attack and continually re-evaluates the priorities of all available targets.




All the implementation specific classes inherit from the base class which handles the actual priority calculation, so it's easy to re-use it across other scripts. For instance dp88_AI_Tesla_Coil inherits from dp88_AI_Turret which in turn inherits from dp88_customAI (not actually a script since it's partially pure virtual) which itself inherits from PublicScriptImpClass.

dp88_AI_Turret is the base class for all turret type AI's and provides virtual functions to check the base power status etc, allowing scripts like dp88_AI_Tesla_Coil to override the base power status with its own implementation which allows the defence to be 'powered' by tesla troopers (this is for the AR mod) OR by the standard base power without rewriting all the targetting and priority calculation code to take it into account.



Example of script parameters in use currently;

Quote:


Priority_Infantry <- Base priority for attacking infantry (0 = do not attack infantry)
Weapon_Infantry <- Weapon for attacking infantry (1 = primary, 2 = secondary)
Splash_Infantry <- Set to 1 to attempt to damage infantry with splash (NOT recommended for high ROF weapons, it will slightly decrease accuracy due to targeting a location rather than the unit)
Priority_Light_Vehicle <- Base priority for attacking light vehicles (0 = do not attack light vehicles)
Weapon_Light_Vehicle <- Weapon for attacking light vehicles (1 = primary, 2 = secondary)
Priority_Heavy_Vehicle <- Base priority for attacking heavy vehicles (0 = do not attack heavy vehicles)
Weapon_Heavy_Vehicle <- Weapon for attacking heavy vehicles (1 = primary, 2 = secondary)
Priority_VTOL <- Base priority for attacking VTOLs (0 = do not attack VTOLs)
Weapon_VTOL <- Weapon for attacking VTOLs (1 = primary, 2 = secondary)
Min_Attack_Range <- Minimum attack range for primary weapon
Max_Attack_Range <- Maximum attack range for primary weapon
Min_Attack_Range_Secondary <- Minimum attack range for secondary weapon
Max_Attack_Range_Secondary <- Maximum attack range for secondary weapon
Requires_Power <- Require power to attack (Checked against base power state)
Distance_Modifier <- Sets the value for the distance-to-target priority modifier, higher values increase the priority of closer targets (recommendation: higher value for inaccurate weapons, lower for accurate weapons)
Target_Damage_Modifier <- Sets the value for the target damage priority modifier, higher values increase the priority of damaged targets (ie: more likely to attempt to finish off a heavily damaged unit instead of a healthy unit)
Target_Value_Modifier <- Sets the value for the target value priority modifier, higher values increase the priority of high value targets (ie: purchase cost)
Debug <- Set to 1 to instruct the script to create a text file logging how its calculated priority for different targets. This will allow fine tuning of modifiers and priorities since devs can get an idea of how its working internally.



http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Mon, 13 September 2010 04:34]

Report message to a moderator

Previous Topic: Little help JBServ
Next Topic: Tortoise SVN Public Repository
Goto Forum:
  


Current Time: Mon May 13 02:10:33 MST 2024

Total time taken to generate the page: 0.01114 seconds