The 3rd Age

Men's Knives

Men's Knives

Good mod in BFME2?With more Factions? and its coming? It's MEN'S KNIVES!

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

Horde Mount/Dismount Ability

Avatar of Rob38

Rob38

Category: Code
Level: Expert
Created: Wednesday December 19, 2007 - 14:55
Updated: Saturday June 27, 2009 - 18:18
Views: 12781
Summary: Giving hordes the ability to toggle between horse and foot.

Rating

Staff says

4.8

Members say

4.0

Average

4.3/5.0

11 votes

Page 1 2 3 4 5 6 7
10. We need to set up and work on both the scriptevents and LUA files. First, create a behavior in your unit with a newly defined function.
              
Code
Behavior = AIUpdateInterface ModuleTag_03
    AutoAcquireEnemiesWhenIdle     = Yes ATTACK_BUILDINGS
    MoodAttackCheckRate     = 500
    HoldGroundCloseRangeDistance = 40
    AttackPriority            = AttackPriority_Cavalry
    AILuaEventsList = HelmDefenderFunctions ;InfantryFunctions
End

11. Open up scriptevents.xml and near the top you should see a list of <ModelConditionEvent>. You need to have two of these conditions for our mount power to work and two for the AI to work. Here are the four you need:
              
Code
<ModelConditionEvent Name="OnEnemyNear">     <Conditions>+SPECIAL_ENEMY_NEAR</Conditions>
</ModelConditionEvent>
    
<ModelConditionEvent Name="OnEnemyNOTNear">
    <Conditions>-SPECIAL_ENEMY_NEAR</Conditions>
</ModelConditionEvent>

<ModelConditionEvent Name="UsingSpecialThree">
    <Conditions>+SPECIAL_POWER_3 -UNPACKING -PACKING </Conditions>
</ModelConditionEvent>

<ModelConditionEvent Name="UsingSpecialThreeMounted">
    <Conditions>+SPECIAL_POWER_3 -UNPACKING -PACKING +MOUNTED </Conditions>
</ModelConditionEvent>

NOTE: In BFME2, "UsingSpecialThree" should already exist ;)

12. Still in scriptevents.xml, create an event list with the name you gave in AILuaEventsList.
              
Code
<EventList Name="HelmDefenderFunctions" Inherit="BaseScriptFunctions">
    <EventHandler EventName="OnEnemyNear" ScriptFunctionName="BecomeDismountedAI" DebugSingleStep="false"/>
    <EventHandler EventName="OnEnemyNOTNear" ScriptFunctionName="BecomeMountedAI" DebugSingleStep="false"/>
    <EventHandler EventName="UsingSpecialThree" ScriptFunctionName="OnHelmDefenderMounting" DebugSingleStep="false"/>
    <EventHandler EventName="UsingSpecialThreeMounted" ScriptFunctionName="OnHelmDefenderDismounting" DebugSingleStep="false"/>
</EventList>


13. Now open up scripts.lua and makes functions for all the scripts we have named above.
              
Code

function OnHelmDefenderMounting(self)
    ObjectRemoveUpgrade( self, "Upgrade_HelmDefenderDisMount" )
    ObjectGrantUpgrade( self, "Upgrade_HelmDefenderMount" )
end

function OnHelmDefenderDismounting(self)
    ObjectRemoveUpgrade( self, "Upgrade_HelmDefenderMount" )
    ObjectGrantUpgrade( self, "Upgrade_HelmDefenderDisMount" )
end

function BecomeDismountedAI(self)
    ObjectRemoveUpgrade( self, "Upgrade_MountAI" )
    ObjectGrantUpgrade( self, "Upgrade_DisMountAI" )
end

function BecomeMountedAI(self)
    ObjectRemoveUpgrade( self, "Upgrade_DisMountAI" )
    ObjectGrantUpgrade( self, "Upgrade_MountAI" )
end


That should do it for all the scripts part.

Links / Downloads

 HitsAdded
In-Depth AI Coding2138December 23, 2007 - 20:00

Comments

Display order: Newest first

Rob38 (Team Chamber Member) - Sunday December 23, 2007 - 21:00

Ugh... ok, Sul, I tried your method and I was able to improve everything except for one thing. The animation will play when it's just an individual unit, but when it's a horde, it refuses to play one. I have tried tons of things but nothing works. I'll update this tutorial after I try some other things out.

EDIT: Yeah, I'm stumped. Unless someone can find a way to get the animation to work for the horde, it looks like we'll have to do without them :( Once I clean up and double check to make sure everything runs correctly, I'll edit and fix up the tutorial.

--------

Re-did the tutorial. If you find a solution to any of the problems on Page 7, please let me know :)

Sulherokhh (Team Chamber Member) - Friday December 21, 2007 - 19:59

Sweet! :) It sure looks perfectly functional, and since you tested it, we now all know it works!! :D

For further ideas on switching commandsets (which are identical, except for the single button that buys upgrades) and the use of specific animations to play for mounting /dismounting (by using a special power instead of an OBJECT_UPGRADE button), refer to 'blackrider_SEE.ini' from S.E.E. The specialpower (and LocomotorUpgrades) would have to be installed in both horde AND hordemember, but the LuaFunctions would only be needed in the horde, just like the CommandSetMonitor) These black riders don't mount horses the usual way, as the normal mount behavior has been reserved for mounting fellbeasts.

Rob38 (Team Chamber Member) - Friday December 21, 2007 - 14:19

Yeah, the commandset is quite an annoyance but I can't find any other solution to the problem :(

JEV3 - Friday December 21, 2007 - 11:50

Pity the commandset is so unfriendly... But to have a horde be able to mount and dismount is worth it.

Rob38 (Team Chamber Member) - Thursday December 20, 2007 - 22:35

Please leave comments :)

EDIT: Fixed an error in article... HorseHordeContain is the behavior you want to use for the horde behavior

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

 
7:55:49