The 3rd Age

Cobra Mod

Cobra Mod

A mod for BFME2 that removes some restrictions to recreate huge epic battles from the films.

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

Stat Variation

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

Avatar of zimoo

zimoo

Category: Code
Level: Intermediate
Created: Tuesday May 29, 2007 - 3:21
Updated: Tuesday May 29, 2007 - 5:34
Views: 6158
Summary: A short guide on how to give units variating stats

Rating

Staff says

4.4

Members say

4.2

Average

4.3/5.0

13 votes

Page 1 2
Now obviously those upgrades don't exist, so you'll need to create them. I don't see the point in posting out many lines of basic code, as I think it'll insult your intelligence. Basically just make clones of the following upgrade though:

              
Code
Upgrade Upgrade_WeaponVariation1
Type                = OBJECT
End


Now that's done, the next part is to actually make the stats change dependent on the upgrades. For this I use an #include file (to save myself repeating the same code in every INI). This #include (called statvariation.inc) contains the following code:

              
Code
    Behavior = WeaponSetUpgrade ModuleTag_WeaponVariation1
        TriggeredBy             = Upgrade_WeaponVariation1
        WeaponCondition         = WEAPONSET_CREATE_A_HERO_WS_01
    End
    
    Behavior = WeaponSetUpgrade ModuleTag_WeaponVariation2
        TriggeredBy             = Upgrade_WeaponVariation2
        WeaponCondition         = WEAPONSET_CREATE_A_HERO_WS_02
    End
    
    Behavior = WeaponSetUpgrade ModuleTag_WeaponVariation3
        TriggeredBy             = Upgrade_WeaponVariation3
        WeaponCondition         = WEAPONSET_CREATE_A_HERO_WS_03
    End
    
    Behavior = WeaponSetUpgrade ModuleTag_WeaponVariation4
        TriggeredBy             = Upgrade_WeaponVariation4
        WeaponCondition         = WEAPONSET_CREATE_A_HERO_WS_04
    End
    
    Behavior = WeaponSetUpgrade ModuleTag_WeaponVariation5
        TriggeredBy             = Upgrade_WeaponVariation5
        WeaponCondition         = WEAPONSET_CREATE_A_HERO_WS_05
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_ArmourVariation1
        TriggeredBy = Upgrade_ArmourVariation1
        AttributeModifier = ArmourVariation1
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_ArmourVariation2
        TriggeredBy = Upgrade_ArmourVariation2
        AttributeModifier = ArmourVariation2
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_ArmourVariation3
        TriggeredBy = Upgrade_ArmourVariation3
        AttributeModifier = ArmourVariation3
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_ArmourVariation4
        TriggeredBy = Upgrade_ArmourVariation4
        AttributeModifier = ArmourVariation4
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_ArmourVariation5
        TriggeredBy = Upgrade_ArmourVariation5
        AttributeModifier = ArmourVariation5
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_HealthVariation1
        TriggeredBy = Upgrade_HealthVariation1
        AttributeModifier = HealthVariation1
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_HealthVariation2
        TriggeredBy = Upgrade_HealthVariation2
        AttributeModifier = HealthVariation2
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_HealthVariation3
        TriggeredBy = Upgrade_HealthVariation3
        AttributeModifier = HealthVariation3
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_HealthVariation4
        TriggeredBy = Upgrade_HealthVariation4
        AttributeModifier = HealthVariation4
    End
    
    Behavior = AttributeModifierUpgrade ModuleTag_HealthVariation5
        TriggeredBy = Upgrade_HealthVariation5
        AttributeModifier = HealthVariation5
    End


The 'weapon' variable actually triggers a new weapon, so that units can get varying levels of accuracy/attack speed/poison damage etc. The same could be done for 'armour', but I was too lazy to make so many armour sets. 'Armour' and 'health' trigger simple attribute modifiers which give small positive/negative bonuses to the unit.

Now it's no good just leaving this include file around and not referencing it, so I saved it to the standard includes folder and put the following in the INI:

              
Code
#include "..\..\..\includes\StatVariation.inc"


That whole step isn't fully required (or possible for BFME1 modders), but it's just a nice way of making your task easier.

You need to set up the attributemodifiers/weapons now, so I have this code in attributemodifers.ini:

              
Code
ModifierList ArmourVariation1
    Category = LEVEL
    Modifier = ARMOR 10%
    Duration = 0
End

ModifierList ArmourVariation2
    Category = LEVEL
    Modifier = ARMOR 20%
    Duration = 0
End

ModifierList ArmourVariation3
    Category = LEVEL
    Modifier = ARMOR -10%
    Duration = 0
End

ModifierList ArmourVariation4
    Category = LEVEL
    Modifier = ARMOR -20%
    Duration = 0
End

ModifierList ArmourVariation5
    Category = LEVEL
    Modifier = ARMOR 5%
    Duration = 0
End

ModifierList HealthVariation1
    Category = LEVEL
    Modifier = HEALTH_MULT 105%
    Duration = 0
End

ModifierList HealthVariation2
    Category = LEVEL
    Modifier = HEALTH_MULT 110%
    Duration = 0
End

ModifierList HealthVariation3
    Category = LEVEL
    Modifier = HEALTH_MULT 95%
    Duration = 0
End

ModifierList HealthVariation4
    Category = LEVEL
    Modifier = HEALTH_MULT 90%
    Duration = 0
End

ModifierList HealthVariation5
    Category = LEVEL
    Modifier = HEALTH_MULT 115%
    Duration = 0
End


Do whatever you want here, although note that if you use the 'HEALTH' modifier as opposed to 'HEALTH_MULT' then you can't use negative values (well you can, but it won't work).

For the last stage I want to set up the weapons:

              
Code
WeaponSet
        Conditions = None
        Weapon = PRIMARY DoriathWarriorSword
        AutoChooseSources = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End
    WeaponSet
        Conditions             = WEAPONSET_CREATE_A_HERO_WS_01        
        Weapon                 = PRIMARY DoriathWarriorSword1
        AutoChooseSources     = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End
    WeaponSet
        Conditions             = WEAPONSET_CREATE_A_HERO_WS_02        
        Weapon                 = PRIMARY DoriathWarriorSword2
        AutoChooseSources     = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End
    WeaponSet
        Conditions             = WEAPONSET_CREATE_A_HERO_WS_03        
        Weapon                 = PRIMARY DoriathWarriorSword3
        AutoChooseSources     = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End
    WeaponSet
        Conditions             = WEAPONSET_CREATE_A_HERO_WS_04        
        Weapon                 = PRIMARY DoriathWarriorSword4
        AutoChooseSources     = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End
    WeaponSet
        Conditions             = WEAPONSET_CREATE_A_HERO_WS_05        
        Weapon                 = PRIMARY DoriathWarriorSword5
        AutoChooseSources     = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End


This basically links to 6 different items in weapon.ini, dependant on the Conditions (defined earlier in statvariations.inc). Feel free to alter these weapons as much (or as little) as you like. Generally I do the following:

Melee units - Varying levels of damage, occassional changes of DamageTypes to make them more/less effective.
Archer units - Different accuracy ratings as well as varying levels of damage. Means you might get a really skilled marksman who can't deal much damage alongside a poorly skilled one who deals heavy damage.
Evil units - Some randomly get poisoned weapons.

And that's all. Nothing too complicated here, it's basically just 'teaching an old dog new tricks', using old code in new and exciting ways.

Feel free to use this in anyway you see fit.

Credits

zimooIdea and implementation
PhilTips on how to do it, Teaching me LUA

Comments

Display order: Newest first

zimoo - Tuesday May 29, 2007 - 7:07

Well what you could do is do the uniquer variations (accuracy, radius damage, poison etc) through use of various weaponstates (I don't know if WEAPONSET_HERO_MODE would work with units, but it'd be worth a try) then do all the 'standard' damage variations through attributemodifiers.

Bart (Administrator) - Tuesday May 29, 2007 - 5:43

Very original. I do wonder, how to do this in BFME 1, where there aren't hundreds of CaH weapon states?

I guess you're limited to just damage variations then :-/

Sulherokhh (Team Chamber Member) - Tuesday May 29, 2007 - 4:35

Great idea! Sweet and neat! That lends itself to those units that have already lua-coded weapon/armor differentiation. I guess this will be useful many times! :)

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

 
23:26:32