The 3rd Age

Wars of the East

Wars of the East

A mod for RotWK that adds new factions, units, heroes, stuctures, powers and more.

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

Eowyn Disguise/Camouflage (Scripts)

Tutorial for Battle for Middle-earth II BFME 2, Battle for Middle-earth II: Rise of the Witch-king ROTWK

Avatar of Sulherokhh

Sulherokhh

Category: Code
Level: Expert
Created: Sunday May 20, 2007 - 3:21
Updated: Friday October 5, 2007 - 6:00
Views: 6157
Summary: How to make Eowyn's Disguise unique and useful, finally!

Rating

Staff says

3.8

Members say

3.8

Average

3.8/5.0

13 votes

Page 1 2 3 4 5
All the ModelCondition stuff for scripting:


First we give Eowyn a ScriptFuncion. Go back inside her Object-Code and look for this:

              
Code
    Behavior = AIUpdateInterface ModuleTag_03
        AutoAcquireEnemiesWhenIdle = Yes ATTACK_BUILDINGS
        MoodAttackCheckRate = 500
    End



Now we add a line, so it looks like this:

              
Code
    Behavior = AIUpdateInterface ModuleTag_03
        AutoAcquireEnemiesWhenIdle = Yes ATTACK_BUILDINGS STEALTHED
        AILuaEventsList            = RohanEowynFunctions
        MoodAttackCheckRate = 500
    End


The new 'RohanEowynFunctions' will be defined in 'scriptevents.xml', which is were we will go now! :-)


We need the following two files:
data\scripts\scriptevents.xml
data\scripts\scripts.lua

Open the first one. At the head you will find:

              
Code
<?xml version="1.0"?>
<SageLuaScriptSection xmlns="http://tempuri.org/ScriptEvents.xsd">
<Events>
...


Then follows a list of 'Events', condition definitions that can be used as a trigger for a scripted action.

Right after that follows a list of internal events, describing very specific situations. Here are the first 3:               
Code
...
<InternalEvent Name="OnDamaged" />
<InternalEvent Name="OnDestroyed" />
<InternalEvent Name="OnArrived" />
...
etc...

Next section is the scripted events:               
Code
...
        <ScriptedEvent Name="BeAfraidOfBalrog" /> <!-- Becoming afraid of balrog -->
        <ScriptedEvent Name="BeAfraidOfRampage" /> <!-- Becoming afraid of rampage -->
        <ScriptedEvent Name="BeAfraidOfPhial" /> <!-- Becoming afraid of Frodo -->
...
etc...

I guess you can imagine what they are used for, right? :-)

What now follows it the really interesting part, the 'modelcondition events'! Here are the first 3 so you have an example:

              
Code
...
<ModelConditionEvent Name="OnFire">
<Conditions>-DYING +AFLAME</Conditions>
</ModelConditionEvent>

<ModelConditionEvent Name="ExampleMovingDamaged">
<Conditions>+MOVING +DAMAGED -AFLAME</Conditions>
</ModelConditionEvent>

<ModelConditionEvent Name="Moving">
<Conditions>+MOVING</Conditions>
</ModelConditionEvent>
...
etc...


This is where we can custom define certain ModelConditions as a trigger for stuff to happen! And that's what we will do now. The following needs to be inserted somewhere just before between or after all other ModelCondtionEvents:

              
Code
        <ModelConditionEvent Name="OnDisguised">
                <Conditions>+DISGUISED</Conditions>
        </ModelConditionEvent>

        <ModelConditionEvent Name="OnDisguiseCanceled">
                <Conditions>-DISGUISED</Conditions>
        </ModelConditionEvent>

        <ModelConditionEvent Name="ModelConditionUSER_1">
            <Conditions>+USER_1</Conditions>
        </ModelConditionEvent>

        <ModelConditionEvent Name="NOTModelConditionUSER_1">
            <Conditions>-USER_1</Conditions>
        </ModelConditionEvent>


The PLUS and MINUS before the ModelCondition signifies the 'presence' or 'absence' of the ModelCondtion, which can be combined with other ModelConditions like in the first three examples. But these simple ones will do the job.

NOTE: The whole Event-List starts with this:               
Code
<Events>

...
It closes right after the last ModelConditonEvent-Line with this:               
Code
...
    </Events>

This is basicall the Begin/End block for the Events. Make sure any further custom Events are located in between those two lines.


What now follows are the Event-Lists. These are loaded by objects that need them and it loads a list of the abovementioned triggers and a reference for the file 'scripts.lua' so that it knows WHAT to trigger. I won't give anymore examples here, just our new list, RohanEowynFunctions.

              
Code
<EventList Name="RohanEowynFunctions" Inherit="BaseScriptFunctions">

<EventHandler EventName="OnCreated" ScriptFunctionName="OnRohanEowynCreated_SEE" DebugSingleStep="false"/>

<EventHandler EventName="OnDisguised" ScriptFunctionName="OnRohanEowynDisguised_SEE" DebugSingleStep="false"/>

<EventHandler EventName="OnDisguiseCanceled" ScriptFunctionName="OnRohanEowynDisguiseCanceled_SEE" DebugSingleStep="false"/>

<EventHandler EventName="ModelConditionUSER_1" ScriptFunctionName="OnRohanEowynStealthed_SEE" DebugSingleStep="false"/>

<EventHandler EventName="NOTModelConditionUSER_1" ScriptFunctionName="OnRohanEowynNotStealthed_SEE" DebugSingleStep="false"/>

</EventList>


Just put it somewhere among the other EventLists. If you look closely, you see that the list contains 'OnCreated', an Event who's condition is fullfilled by building Eowyn, PLUS the custom items we have implemented just before this. Every single Event will trigger a different script function. Those are described in the file 'scripts.lua' where we will go now. If you could follow so far, well done! :-)


The file 'scripts.lua' contains functions that are mostly used upon the Event 'OnCreated' to PreHide certain subobjects, like 'flaming arrows etc.' that are only shown when something ingame happens. Also all the panic reactions and other emotional behavior has some functions listed here. This way you make the Troll rampage, the burning Mûmak run amok, etc. The new functions for Eowyn just do something straight forward. They provide all the upgrades needed for the Disguise and Invisibility to work. Just insert the following new functions somewhere among the list. The end of the file would be suitable:

              
Code
function OnRohanEowynCreated_SEE(self)
    ObjectRemoveUpgrade( self, "Upgrade_EowynConditionDisguised_SEE" )
end


function OnRohanEowynDisguised_SEE(self)
    ObjectGrantUpgrade( self, "Upgrade_EowynConditionDisguised_SEE" )
end

function OnRohanEowynDisguiseCanceled_SEE(self)
    ObjectRemoveUpgrade( self, "Upgrade_EowynConditionDisguised_SEE" )
    end

function OnRohanEowynStealthed_SEE(self)
    ObjectRemoveUpgrade( self, "Upgrade_EowynConditionNotStealthed_SEE" )
    ObjectGrantUpgrade( self, "Upgrade_EowynConditionStealthed_SEE" )
end

function OnRohanEowynNotStealthed_SEE(self)
    ObjectRemoveUpgrade( self, "Upgrade_EowynConditionStealthed_SEE" )
    ObjectGrantUpgrade( self, "Upgrade_EowynConditionNotStealthed_SEE" )
end



The first one 'OnRohanEowynCreated_SEE' removes the Upgrade that signifies that she currently uses disguise. This is important as she could die while disguised. Now when she is created (and not disguised), the upgrade will be removed.

Functions 2 and 3 are granting and removing the just mentioned upgrade depending on if she currently has the ModelCondtion DISGUISED, which will be set by the 'SpecialDisguiseUpdate' in Eowyn's Object Code and removed if it ends. Remember, the Upgrade triggers the AuraUpdate of the Rohirrim, so that they can provide Eowyn with the ModelCondition USER_1 once she is in range.

Functions 4 and 5 are Eowyn reactions to gaining and losing ModelCondition USER_1. When she gains it, she will also gain all she needs to trigger her 'InvisibilityUpdate'. When she loses USER_1, the 'InvisibilityUpdate' goes inert again.



That's it for now! Have fun with beautiful Eowyn, hehe. :-)

Sûlherokhh.

Credits

PhilFor hinting at the 'scriptevents.xml'

Comments

Display order: Newest first

Mouth of Sauron - Thursday January 14, 2010 - 5:49

Thank you, this is most useful generally ; about Eowyn however... I never understood this ability and I cannot see for what should it be used - she was not hiding before the ennemy, she was hiding before Theoden, wasn't she...

MoS

--------

Thank you, this is most useful generally ; about Eowyn however... I never understood this ability and I cannot see for what should it be used - she was not hiding before the ennemy, she was hiding before Theoden, wasn't she...

MoS

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

 
8:33:58