Welcome Guest ( Log In / Register ) |
![]() |
Quick Lists Top RatedTutorials Living World Map G… Ultimate beginner'… Arrow scaling bug… Raising Heroes max… Proper Fire Arrow… Creating an asset.… Simple Structure B… Making a simple Ma… Quick and easy sno… Making patrols nea… Mods The Dwarf Holds The Peloponnesian… RJ - RotWK The Elven Alliance… Helm's Deep Last H… The Elven Alliance Special Extended E… Kings of the West… RC Mod The Wars of Arda Downloads BFME1 1.06 Widescr… Enhanced W3D Impor… Fudge's Map Pack LotR/BfME HD Logos Osgiliath Shellmap Crystals Of Ancien… 2v1 Wold The forests of Dru… Converted BFME2 an… ROTWK animations f… |
||||||||||||||||||||||||||||||||||||||||||
![]() |
Register and log in to move these advertisements down In-depth AI Coding
B4. Practical Use of 'AutoAbilityBehavior' for the AI controlled unit. Now, here is one example, using Faramir, to show how the 'AutoAbilityBehavior' (from A1) can be put to use for an AI controlled unit (from B1), without forcing the human player controlling this unit to also be subject to the auto-triggering traits of this module. EXAMPLE: The 'usual' code to be used when you want a unit like a hero to use it's special powers is the 'AISpecialPowerUpdate'. The following piece is simple yet limiting.
The problem with this is the fact the rather 'wild' AI uses this at the most inopportune times, like when mounted or with a sword in hand. There are obviously no animations going to play when mounted, and you don't want the AI to use stuff that the unit should not be allowed to use. So we better use something (the 'AutoAbilityBehavior') to make the AI conform to all the usual limitations. The way to achieve this is to duplicate the power involved, but make it only available to the AI, while removing the AI's ability to use the normal power. Step 1: The SpecialPower - First, we need a carbon copy of this power:
- it will look like this (identical except for the name):
Step 2: The Ability Code - Next we adjust the following (original) code ...
... by making it unavailable to the AI:
The AI will use a new set of behaviors, identical but for the name of the SpecialPower used and with unique tags and a unique trigger:
The differences are ...
... and ...
The module 'AutoAbilityBehavior' is much more flexible when it comes to target acquisition. What i would like Faramir to do is use this power only on heroes and monster. So i changed the query line to something i liked better. But you can insert any KindOf you can think of Okay. So, even though the module 'AutoAbilityBehavior' references a SpecialPower, it actually runs from a CommandButton and is thus subject to all the CommandButton's restrictions and limitations (see below). Since we are using a new SpecialPower, the AI-only ability will need it's own CommandButton. I made one for you:
The line 'AutoAbility = Yes' is obviously of vital importance for the AutoAbilityBehavior to work at all. So remember to add it if you are duplicating CommandButtons that originally didn't have it! Now the new CommandButton needs to be added to his CommandSet, like this:
Yes, it will be invisible to the player. One important sidenote. As already noted on previous pages, a unit may have several CommandSets, for being mounted, for having a certain upgrade, etc. just to be save that the behavior 'grips'. The new button should be present on ALL OF THEM! The human player cannot use it anyway (they are missing the AI-upgrade), and the AI can't use it when it is not suitable anyway, because of the CommandButton's limitations (aye, they work now!):
Thank you for reading this far. This concludes the lesson for today. More is to come about creating different AI strategies and an in-depth look in how the AI prioritizes it's spending of cash. Good day! Sûlherokhh. ------------------------------------------------------------------------------------------------------------------------------------------------------------------- CommentsDisplay order: Newest first | Page: 1, 2 Prolong - Thursday July 29, 2010 - 9:21 Very nice guide, even though it never got finished there is still a ton of great information here. Elrond99 - Sunday February 15, 2009 - 7:52 Thanks for updating the Tutorial Sulherokhh (Team Chamber Member) - Saturday February 14, 2009 - 21:19 After 'D. The Faction Base and Fortress', i guess. jakonic - Saturday February 14, 2009 - 12:05 when will be finished Spell Purchase Scripts???please answer Sulherokhh (Team Chamber Member) - Thursday November 29, 2007 - 17:26 I sure will... Rob38 (Team Chamber Member) - Thursday November 29, 2007 - 11:00 This is by far one of my favorite tutorials on T3A! Please continue to add more :) Sulherokhh (Team Chamber Member) - Wednesday October 3, 2007 - 23:07 I am glad you can put it to use, Rob! Your feedback means a lot to me. :D Rob38 (Team Chamber Member) - Wednesday October 3, 2007 - 22:27 Amazing! I also found a way to recognize if a player is controlled by the AI, but this looks to be a much easier method to use. Thank you for all your wonderful knowledge as there is some really cool stuff in here. Sulherokhh (Team Chamber Member) - Wednesday October 3, 2007 - 19:18 I'll split it up. Let's see what would be a good way. - Edit: Done. I hope you like it. Crashdoc - Wednesday October 3, 2007 - 16:48 Nice findings and interesting ways to use them. Thanks for sharing the knowledge! |
![]() |
|||||||||||||||||||||||||||||||||||||||||
![]() "One site to rule them all, one site to find them, © All Rights Reserved Eric Edwards ©2013. |