The 3rd Age

The Wars of Arda

The Wars of Arda

A huge expansion for RotWK, adding multiple eras, numerous new factions and a full campaign.

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

2.02e Fuel the Fires

Tutorial for Battle for Middle-earth II BFME 2

No Avatar

Prolong

Category: Code
Level: Intermediate
Created: Sunday May 10, 2009 - 16:32
Updated: Tuesday May 26, 2009 - 17:06
Views: 4857
Summary: Alter Fuel the Fires to require the presence of a Fortress to function and to affect teammates

Rating

Staff says

3.3

Members say

4.0

Average

3.6/5.0

5 votes

Page 1 2
First we have to prevent the Lumber Mill from running its science check. To do this, go to civilianbuildings.ini and search for "science". You'll end up at the LumberMill object's SupplyCenterDockUpdate. This behavior is what allows the Orc Laborers to deposit the trees they chop at the Lumber Mill. We only want to remove the two lines "BonusScience" and "BonusScienceMultiplier", while leaving "AllowPassthrough" and "NumberApproachPositions". ("ValueMultiplier" is already removed.)

              
Code
Behavior = SupplyCenterDockUpdate ModuleTag_SupplyCenter
AllowsPassthrough = No
NumberApproachPositions = -1 ; No bones, just touch
; BonusScience = SCIENCE_FueltheFires ;;,;; removed for 2.02e
; BonusScienceMultiplier = 200% ;;,;; removed for 2.02e
; ValueMultiplier = 2.0 ; this value will be used to multiply the value set in gamedata.ini to get the final amount
End

That prevents the Lumber Mill from running its science check. Now that we've done that, we need to edit the Fuel the Fires power to grant the player upgrade that will trigger our fortress aura. In system.ini, comment the original Fuel the Fires code:

              
Code
;    Behavior = SpecialPowerModule        SpellBookFuelTheFires_ModuleTag ;;,;; original 2.01 Fuel the Fires, removed for 2.02e
;        SpecialPowerTemplate        = SpellBookFueltheFires
;        ; Done in science check on the lumber mill, so that this global effect will work on future lumber mills
;;        AttributeModifier            = SpellBookFueltheFires
;;        AttributeModifierRange        = 999999
;;        AttributeModifierAffects    = ANY +SUPPLY_GATHERING_CENTER
;        UpdateModuleStartsAttack    = No
;        AvailableAtStart            = No
;        RequirementsFilterMPSkirmish = SPELL_BOOK_REQUIREMENTS_FILTER
;        RequirementsFilterStrategic = SPELL_BOOK_REQUIREMENTS_FILTER_STRATEGIC
;    End

Then add in our new PlayerUpgradeSpecialPower. This power will grant the PLAYER-type upgrade Upgrade_GrantFueltheFires to the player who uses the SpecialPower:

              
Code
    Behavior = PlayerUpgradeSpecialPower    SpellBookFuelTheFires_ModuleTag    ;;,;; added for 2.02e, works =D
        SpecialPowerTemplate        = SpellBookFueltheFires
        UpgradeName             = Upgrade_GrantFueltheFires
        UpdateModuleStartsAttack    = No
        AffectAllies            = No
        AvailableAtStart        = No
        RequirementsFilterMPSkirmish     = SPELL_BOOK_REQUIREMENTS_FILTER
        RequirementsFilterStrategic     = SPELL_BOOK_REQUIREMENTS_FILTER_STRATEGIC
    End

Where an OBJECT-type upgrade is given to a specific object, a PLAYER-type upgrade is given to a player. This means it's specific to no object (if we gave an OBJECT upgrade to the Fortress, it would die with the Fortress), and unless we decide to remove it from the player somehow, it will stay throughout the entire game. Now, we have to actually create Upgrade_GrantFueltheFires in upgrade.ini. Note that you don't need the RequiredObjectFilter line. That line would turn off the upgrade whenever the Fortress isn't present, but it's not necessary because the Fortress has to be present to put off the aura we are going to give it.

              
Code
Upgrade Upgrade_GrantFueltheFires            ;;,;; added for 2.02e
    Type            = PLAYER ; OBJECT
;    RequiredObjectFilter    = ANY +IsengardFortressCitadel
End

Now that the upgrade that triggers the aura is defined, we can add our AttributeModifierAuraUpdate behavior to IsengardFortressCitadel in isengardfortress.ini:

              
Code
    Behavior = AttributeModifierAuraUpdate ModuleTag_AllowFuelTheFires ;;,;; added for 2.02e
        StartsActive    = No ;If no, requires upgrade to turn on.
        BonusName        = SpellBookFueltheFires
        TriggeredBy        = Upgrade_GrantFueltheFires ; Upgrade_FortressGrantFueltheFires
        RefreshDelay    = 2000
        Range            = 999999
        ;AffectAllies        = No
        TargetEnemy        = No ;
        ObjectFilter    = ANY +SUPPLY_GATHERING_CENTER
    End

This aura grants the attributemodifier SpellBookFueltheFires (which will be a production bonus) to all SUPPLY_GATHERING_CENTERs on the map. If the Fortress is destroyed, it can't give off the aura, and the Lumber Mills lose their production bonus. If a player then rebuilds the Fortress, it will notice that he still has Upgrade_GrantFueltheFires and begin passing out the SpellBookFueltheFires bonus to all Lumber Mills again. The downside - or upside, depending on what you want to do with your mod - of this implementation is that the SpellBookFueltheFires bonus will, in theory, affect all your allies' Lumber Mills in a team game.

The last thing we have to do is make the attributemodifier itself, in attributemodifier.ini:

              
Code
ModifierList SpellBookFueltheFires ;;,;; added for 2.02e
    Category = SPELL
    Modifier = PRODUCTION 175% ; 200%
    Duration = 3000
    ModelCondition = UPGRADE_ECONOMY_BONUS
End

Note that the Duration of the attributemodifier is longer than the RefreshDelay on the AttributeModifierAuraUpdate. For whatever reason, the attributemodifier will only be in effect some, but not all, of the time if the RefreshDelay matches the Duration. Making the Duration longer than the RefreshDelay causes no problems, as two attributemodifiers with the same name can never stack. Also, note the value of the production bonus: I lowered it to 175% for this early build of 2.02e, but if you want to keep it at the original value you'll want to use 200%. The LumberMill uses the ModelCondition UPGRADE_ECONOMY_BONUS to know when to display the orange cloud of FueltheFiresEmbers, so be sure not to forget that.

That's all there is to making Fuel the Fires respect the destruction of a Fortress!

Important Update: This won't work on certain Fortress/WotR maps unless the AttributeModifierAuraUpdate is added into the Fortress objects used on those maps. Chenoweth has left a list of objects to add the aura to from his code for passive Dwarven Riches, which works similarly to this in that it also uses a Fortress aura:

              
Code
;----------------------------------------------------------------------------------
; Adding aura behavior to pass out Dwarven Riches to mines
; *NOTE: Do NOT use a science check in TerrainResourceBehavior. While that is the
; clean and proper implementation, it doesn't prevent stacking with Industry.
;
;      Also, if we want this to work properly on all normal, fortress, and WotR
;     maps, we need to include this module in the following objects:
;     - AmonSulKeep
;     - AngForStronghold
;     - AngmarCitadelCarnDum
;     - DwarvenFortressCitadel
;     - WOR_DolGoldurCastle
;     - WOR_EreborThrone
;     - WOR_GondorCastleBaseKeep
;     - WOR_HelmsDeepArcade
;     - WOR_MBMMTower
;     - WOR_RivElHouse
;
;     And perhaps these as well (only if MP does not use the WOR map versions):
;     - DolGoldurCastle
;     - EreborThrone
;     - GondorCampKeep
;     - HelmsDeepArcade
;     - MBMMTower
;;.;;    
    Behavior = AttributeModifierAuraUpdate ModuleTag_DwarvenRiches
        StartsActive            = No
        TriggeredBy            = Upgrade_DwarvenRiches
        BonusName            = SpellBookPassiveDwarvenRiches
        RefreshDelay            = 2000
        Range                = 99999
        ObjectFilter            = ANY +DwarvenMineShaft
    End
;----------------------------------------------------------------------------------

Update: The aura should also be added to WOR_IsengardCastleBaseKeep.

Comments

Display order: Newest first

Sulherokhh (Team Chamber Member) - Thursday May 21, 2009 - 8:19

Great, but like in your other tutorial, replace the TAB characters with a single SPACE character to increase the visual accessibility of the tutorial. Same goes for use of the ';'. Make it's use uniformly the same for every instance.

Prolong - Sunday May 10, 2009 - 19:29

I was about five minutes away from finishing this guide, then accidentally navigated away from the page. On some other forums clicking the "back" button is enough to restore what you were writing; here it just brought me to a very unhappy looking "Empty Page", and I lost the entire second page of the guide. Guess I'll have to finish this later.

--------

Done. Don't know if anybody will really care to use this in his/her mod, but here it is if you want to.

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

 
10:49:17