The 3rd Age

BfME 1½ Mod

BfME 1½ Mod

A mod that makes BfME2 as it should have been with the building plot system from BfME1!

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

Fixing the Broken Weather Powers

No Avatar

Prolong

Category: Code
Level: Intermediate
Created: Wednesday May 20, 2009 - 15:46
Updated: Wednesday February 3, 2010 - 19:14
Views: 4288
Summary: Make weather powers affect units built after the spell is cast

Rating

Staff says

4.0

Members say

4.0

Average

4.0/5.0

4 votes

Page 1 2
In the official version of BFME II, casting Darkness affects all units on the map when the spell is cast with the attributemodifier SpellBookDarkness. However, any units built after the spell is cast will appear to be unaffected and will have no FX, even though the weather is still CLOUDY. (Evidence suggests that this is an FX bug only, and the units are still affected by Darkness even though there is no FX to indicate this.) Similarly, enemy units are only affected by the Freezing Rain FX if they are already on the map when it is cast: newly created units will not be affected. This guide will show how to mod the powers to make the FX affect units built after the spell is cast, as in RotWK 2.02. To do this, we will remove the original powers and replace them with powers that create new objects to cast the attributemodifiers again and again. We will also create a system for ForceKilling these objects when the weather is changed, so that the attributemodifiers end when the weather changes.

The first thing to do is to remove the original power behaviors in EvilSpellBook and replace them with new ones. Navigate to object\system\system.ini and search for Darkness. Remove the original Darkness behavior, then scroll down a few lines and remove the original Freezing Rain behavior as well:

              
Code
;    Behavior = DarknessSpecialPower ModuleTag_Darkness ;;,;; original 2.01 Darkness
;        SpecialPowerTemplate            = SpellBookDarkness
;        AttributeModifier                = SpellBookDarkness
;        AttributeModifierAffects        = ANY +INFANTRY +CAVALRY +MONSTER -HERO -HORDE -MordorBlackRider -MordorBlackRiderHorde -DwarvenZerker -NoldorWarrior -GondorKnightsofDol -GondorKnightsofDolHorde -WildBabyDrake -WildBabyDrakeHorde -IsengardFanatic ALLIES ;;.;; Removed MHH Horde objects
;        AttributeModifierWeatherBased    = Yes            
;        WeatherDuration                    = SPELL_DARKNESS_DURATION
;        ChangeWeather                    = CLOUDY
;        AvailableAtStart                = No
;        RequirementsFilterMPSkirmish = SPELL_BOOK_REQUIREMENTS_FILTER
;        RequirementsFilterStrategic = SPELL_BOOK_REQUIREMENTS_FILTER_STRATEGIC
;    End

//...

;    Behavior = FreezingRainSpecialPower ModuleTag_FreezingRain ;;,;; this is the old 2.01 Freezing Rain
;        SpecialPowerTemplate            = SpellBookFreezingRain
;        AttributeModifier                = RainDebuff ;;.;; Added
;        AttributeModifierAffects        = ANY +INFANTRY +CAVALRY +MONSTER -HERO -HORDE -MordorBlackRider -MordorBlackRiderHorde -DwarvenZerker -NoldorWarrior -GondorKnightsofDol -GondorKnightsofDolHorde -WildBabyDrake -WildBabyDrakeHorde -IsengardFanatic ENEMIES ;;.;; ALL ENEMIES
;        AntiCategory                    = BUFF LEADERSHIP ;;,;; added BUFF
;        AntiFX                            = FX_AntiLeadership ; FX for anti category
;        AttributeModifierWeatherBased    = Yes
;        WeatherDuration                    = SPELL_FREEZINGRAIN_DURATION
;        ChangeWeather                    = RAINY
;        AvailableAtStart                = No
;        BurnRateModifier                = -100
;        BurnDecayModifier                = 20
;        RequirementsFilterMPSkirmish = SPELL_BOOK_REQUIREMENTS_FILTER
;        RequirementsFilterStrategic = SPELL_BOOK_REQUIREMENTS_FILTER_STRATEGIC
;    End

Now we will create new OCLSpecialPower behaviors that will spawn WeatherChanger objects. The powers also change the weather, since that can't be done by the objects themselves:

              
Code
    Behavior = OCLSpecialPower ModuleTag_Darkness ;;,;; 2.02e Darkness
        SpecialPowerTemplate        = SpellBookDarkness
        OCL                = OCL_DarknessWeatherChanger
        CreateLocation            = CREATE_AT_LOCATION
        AttributeModifierWeatherBased    = Yes
        WeatherDuration            = SPELL_DARKNESS_DURATION
        ChangeWeather            = CLOUDY
        AvailableAtStart        = No
        RequirementsFilterMPSkirmish     = SPELL_BOOK_REQUIREMENTS_FILTER
        RequirementsFilterStrategic    = SPELL_BOOK_REQUIREMENTS_FILTER_STRATEGIC
    End

    Behavior = OCLSpecialPower ModuleTag_FreezingRain ;;,;; new 2.02e Freezing Rain
        SpecialPowerTemplate        = SpellBookFreezingRain
        OCL                = OCL_FreezingRainWeatherChanger
        CreateLocation            = CREATE_AT_LOCATION
        AttributeModifierWeatherBased    = Yes
        WeatherDuration            = SPELL_FREEZINGRAIN_DURATION
        ChangeWeather            = RAINY
        AvailableAtStart        = No
        RequirementsFilterMPSkirmish     = SPELL_BOOK_REQUIREMENTS_FILTER
        RequirementsFilterStrategic    = SPELL_BOOK_REQUIREMENTS_FILTER_STRATEGIC
    End

Since we have new OCLs, we obviously need to add them into the ObjectCreationList. We'll add two more here that we'll need soon, too:

              
Code
;--------------------------------------------------------------------------------------- ;;,;;
ObjectCreationList OCL_DarknessCaster ;;,;; added for 2.02e
    CreateObject
        ObjectNames = DarknessCaster
    End
End

;--------------------------------------------------------------------------------------- ;;,;;
ObjectCreationList OCL_FreezingRainCaster ;;,;; added for 2.02e
    CreateObject
        ObjectNames = FreezingRainCaster
    End
End

;--------------------------------------------------------------------------------------- ;;,;;
ObjectCreationList OCL_DarknessWeatherChanger ;;,;; added
    CreateObject
        ObjectNames = DarknessWeatherChanger
    End
End

;--------------------------------------------------------------------------------------- ;;,;;
ObjectCreationList OCL_FreezingRainWeatherChanger ;;,;; added
    CreateObject
        ObjectNames = FreezingRainWeatherChanger
    End
End

Add the following two WeatherChanger objects to system.ini. When spawned, these objects will fire a weapon named "WeatherKiller" that will kill any existing WeatherCaster objects (canceling the attributemodifiers of your opponent's or ally's Darkness or Freezing Rain), then, after a short delay, fire a second weapon that will spawn a new WeatherCaster object (which will provide your own attributemodifier). After this, the WeatherChanger object dies. Here is the code:
              
Code

;------------------------------------------------------------------------------ ;;,;; added for 2.02e
Object DarknessWeatherChanger

    Draw = W3DScriptedModelDraw ModuleTag_Draw
        DefaultModelConditionState
            Model = none
        End
    End
    
    EvaEnemyObjectSightedEvent = None ; Not a real unit

    ; ***DESIGN parameters ***
    EditorSorting = SYSTEM
    KindOf = NO_COLLIDE IMMOBILE UNATTACKABLE INERT
    

    ; *** ENGINEERING Parameters ***
    Body = ImmortalBody ModuleTag_02
        MaxHealth = 1
        InitialHealth = 1
    End

    Behavior = DeletionUpdate ModuleTag_03 ; Not LifetimeUpdate, since I can't die. This will DestroyObject me.
        MinLifetime = 1000
        MaxLifetime = 1000
    End

    Behavior = FireWeaponUpdate ModuleTag_KillAllCurrentWeather
        FireWeaponNugget
            WeaponName    = WeatherKiller
            Offset = X:0 Y:0 Z:0
            FireDelay    = 0
            OneShot        = Yes
        End
    End

    Behavior = FireWeaponUpdate ModuleTag_MakeTheDarknessCaster
        FireWeaponNugget
            WeaponName    = MakeDarknessCaster
            Offset = X:0 Y:0 Z:0
            FireDelay    = 50
            OneShot        = Yes
        End
    End

End

;------------------------------------------------------------------------------ ;;,;; added for 2.02e
Object FreezingRainWeatherChanger

    Draw = W3DScriptedModelDraw ModuleTag_Draw
        DefaultModelConditionState
            Model = none
        End
    End
    
    EvaEnemyObjectSightedEvent = None ; Not a real unit

    ; ***DESIGN parameters ***
    EditorSorting = SYSTEM
    KindOf = NO_COLLIDE IMMOBILE UNATTACKABLE INERT
    

    ; *** ENGINEERING Parameters ***
    Body = ImmortalBody ModuleTag_02
        MaxHealth = 1
        InitialHealth = 1
    End

    Behavior = DeletionUpdate ModuleTag_03 ; Not LifetimeUpdate, since I can't die. This will DestroyObject me.
        MinLifetime = 1000
        MaxLifetime = 1000
    End

    Behavior = FireWeaponUpdate ModuleTag_KillAllCurrentWeather
        FireWeaponNugget
            WeaponName    = WeatherKiller
            Offset = X:0 Y:0 Z:0
            FireDelay    = 0
            OneShot        = Yes
        End
    End

    Behavior = FireWeaponUpdate ModuleTag_MakeTheRainCaster
        FireWeaponNugget
            WeaponName    = MakeFreezingRainCaster
            Offset = X:0 Y:0 Z:0
            FireDelay    = 50
            OneShot        = Yes
        End
    End

End

Now it's time to add the weapons to weapon.ini. The WeatherKiller weapon uses a ForceKillObjectFilter to kill any existing WeatherCaster objects, so that only one weather power is in effect at a time:

              
Code
;------------------------------------------------------------------------------
Weapon WeatherKiller ;;,;; added for 2.02e
RadiusDamageAffects    = ENEMIES NEUTRALS ALLIES            ; Self for when this warhead is attached to an already grabbed unit being thrown as projectile instead of a rock
DamageNugget
    DamageType    = FROST
    DeathType    = CRUSHED
    SpecialObjectFilter        = ANY +DarknessCaster +FreezingRainCaster
    Radius         = 999999            ; Second damage nugget does instant death for only the direct target (which will be the unit thrown)
    ForceKillObjectFilter    = ANY +DarknessCaster +FreezingRainCaster
End
End


The MakeWeatherCaster weapons use a WeaponOCLNugget to spawn the actual WeatherCaster objects:

              
Code
;------------------------------------------------------------------------------
Weapon MakeDarknessCaster ;;,;; added for 2.02e
    AttackRange             = 999999

    WeaponOCLNugget
        WeaponOCLName = OCL_DarknessCaster
    End
End

;------------------------------------------------------------------------------
Weapon MakeFreezingRainCaster ;;,;; added for 2.02e
    AttackRange             = 999999

    WeaponOCLNugget
        WeaponOCLName = OCL_FreezingRainCaster
    End
End

Links / Downloads

 HitsAdded
Unofficial Patch 2.021298May 20, 2009 - 16:57

Credits

RyderFound that AttributeModifierNuggets have an AntiCategories line

Comments

Display order: Newest first

Imdrar - Wednesday November 24, 2010 - 4:00

One of the best written tutorials I've read so far. Very helpful.

Prolong - Tuesday July 14, 2009 - 21:11

Does that happen all the time? Sometimes the rain doesn't seem to appear, but I don't think that's related to this fix as I'm sure that happened before and it usually/often doesn't now; certainly I've seen the rain appear multiple times on the current version of 2.02.

Also, I'm going to update the tutorial to indicate that this is issue is probably with the FX not affecting units that actually are affected, given that the BT2DC patch has fixed Freezing Rain in a different way by tweaking the FX.

--------

Also updated a bit on the second page regarding the objectfilters of the attributemodifiers, as 2.02's are different from what they were originally and I had forgotten to mention that I'd changed that in the posted code.

--------

And now I've added a third page showing an alternative way to fix Freezing Rain, which MaDDoX and Rainmaker developed BT2DC. It's a lot easier than my method, that's for sure. Doesn't work for Darkness for whatever reason (not sure why) so my tricks are still good for something though. :D

TroDuS - Monday July 13, 2009 - 6:59

Îf I try to follow this tutorial it works except to the prob that I won´t show any rain during the cast of Freezing Rain.

Rob38 (Team Chamber Member) - Saturday June 27, 2009 - 13:50

Nice job :)

Sulherokhh (Team Chamber Member) - Thursday May 21, 2009 - 7:32

Clear, logical, just the way i like it. :)

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:52:32