The 3rd Age

Westernesse

Westernesse

Numenor awaits, with new armies, units, factions and heroes; witness the darkest Age of Middle-earth

Button for The 3rd AgeButton for The Dwarf HoldsButton for The Elven AllianceButton for Helm's Deep Last HopeButton for GothmogtheOrcButton for BFME+Button for The Four AgesButton for HDR HeadquartersButton for Middle Earth CenterButton for Project Perfect Mod

Become an affiliate!

   

Quick Lists

Top Rated Popular New Updated Last Comments Users

Register and log in to move these advertisements down

In-depth AI Coding

Avatar of Sulherokhh

Sulherokhh

Category: Code
Level: Expert
Created: Wednesday October 3, 2007 - 6:28
Updated: Friday August 27, 2010 - 19:26
Views: 29239
Summary: The beginning of a comprehensive guide to AI-modding for BfME2

Rating

Staff says

4.8

Members say

4.9

Average

4.9/5.0

20 votes

Page 1 2 3 4 5 6 7 8 9 10 11
B2. Straightforward uses of the AI-Upgrade.

Here are a few examples of how to use 'Upgrade_ObjectUnderAIControl' to give YOU more control over what the AI does and doesn't do:

FortressBuildPlots. If you know how to modify the Fortress base files (explained elsewhere in a tutorial by ROBNKARLA but picked up again by me in a later chapter of this tutorial) you can do what i did. Make almost identical but disparate FortressPlots.
This is useful if you are fed up with the random way the AI has when it comes to choosing an expansion type.

The standard FortressBuildPlot for the ElvenFortress is called 'ElvenFortressExpansionPadCorner'.
I made some ChildObjects and put those in the spots that i found appropriate.
The names are pretty descriptive i guess.

              
Code
ChildObject ElvenFortressExpansionPadVigilantAI ElvenFortressExpansionPadCorner

    CommandSet = ElvenFortressExpansionPadCornerCommandSet

    Behavior = CommandSetUpgrade ModuleTag_FortressPadCommandSetAI
        TriggeredBy = Upgrade_ObjectUnderAIControl
        CommandSet = ElvenFortressExpansionPadCommandSetVigilantAI
    End

End


              
Code
ChildObject ElvenFortressExpansionPadFloodGateAI ElvenFortressExpansionPadCorner
    
    CommandSet = ElvenFortressExpansionPadCornerCommandSet

    Behavior = CommandSetUpgrade ModuleTag_FortressPadCommandSetAI
        TriggeredBy = Upgrade_ObjectUnderAIControl
        CommandSet = ElvenFortressExpansionPadCommandSetFloodGateAI
    End

End


              
Code
ChildObject ElvenFortressExpansionPadTowerAI ElvenFortressExpansionPadCorner
    
    CommandSet = ElvenFortressExpansionPadCornerCommandSet

    Behavior = CommandSetUpgrade ModuleTag_FortressPadCommandSetAI
        TriggeredBy = Upgrade_ObjectUnderAIControl
        CommandSet = ElvenFortressExpansionPadCommandSetWatchtowerAI
    End

End


And these are their CommandSets, which are ONLY used by the AI!

              
Code
CommandSet ElvenFortressExpansionPadCommandSetWatchtowerAI
    1 = Command_ConstructElvenWatchtowerExpansion
End
CommandSet ElvenFortressExpansionPadCommandSetVigilantAI
    1 = Command_ConstructElvenVigilantEntExpansion
End
CommandSet ElvenFortressExpansionPadCommandSetFloodGateAI
    1 = Command_ConstructElvenFloodgateExpansion
End


This way, the AI builds exactly what you want it to build on exactly the Plot you choose.
For the HUMAN-Player, the different plots are all equal because it always uses the commandset 'CommandSet = ElvenFortressExpansionPadCornerCommandSet' for players without the upgrade 'Upgrade_ObjectUnderAIControl'.


Here is another example:

Tired of having AI controlled heroes run around on foot all the time? So, you want a hero to mount his horse when his mounting SpecialPower is finally available at say level 3?
Plug this in:

              
Code
// Switch CommandSet when MOUNTED
Behavior = MonitorConditionUpdate ModuleTag_CommandSetSwapper
    WeaponSetFlags = MOUNTED
    WeaponToggleCommandSet = GondorFaramirCommandSetMounted
End
// When reaching level 3, automatically mount horse
Behavior = DoCommandUpgrade Module_DoCommandUpgrade    
    TriggeredBy = Upgrade_ObjectLevel3 Upgrade_ObjectUnderAIControl
    RequiresAllTriggers = Yes
    GetUpgradeCommandButtonName = Command_ToggleMount
End


You will need a second CommandSet with a differently named DISMOUNT-Button, so he doesn't accidentally dismount.


Read on if you want to make this last thing a bit more elaborate than that!

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

Comments

Display 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
It´s great to hear that it´s possible to make a new AI from scratch

Can´t wait for section F, custom AI scripts, that sounds really interesting
Especially since I know D and E already ;)

Sulherokhh (Team Chamber Member) - Saturday February 14, 2009 - 21:19

After 'D. The Faction Base and Fortress', i guess.
If you are asking for a date, you are asking the wrong guy. I don't have one. I work on modding related stuff mostly when i find the time and the mood strikes me. It's supposed to be fun, right? :)

Edit: But i might do it before the fortress and base setup. Depends on, well, which kind of work is going to be most interesting to me at the time. Scripts should be easier to do then the Basebuilding stuff, but a bit more to write as well, at least if i am going to do it right. I am starting to ramble... :O

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...

Edit: Do you have any particular requests? If i have done it already, it shouldn't be hard to post a solution here. If it's not, chances are that i was going to look into it anyway. Except for the general skirmishsetup and bases, since those will require extesive explanations which i was planning to do anyway when i find the time.

So shoot! :)

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!

Go to top

 

"One site to rule them all, one site to find them,
one site to host them all, and on the network bind them."

 
0:24:43