The 3rd Age

JUS_SAURON - The Power Of The Ring

JUS_SAURON - The Power Of  The Ring

New Powers , Heroes and Units for all Factions

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

Modboy451's Article of Code-Snippets

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

Avatar of modboy451

modboy451

Category: Code
Level: Beginner
Created: Monday February 14, 2011 - 8:52
Updated: Monday November 14, 2011 - 17:40
Views: 4810
Summary: a bunch of little code behaviors and lines that come in handy once and a while

Rating

Staff says

-

Members say

4.0

Average

4.0/5.0

1 vote

Page 1 2 3 4
You can use the docommandupgrade to do a neat trick with toggle weapons.

When a Hero/CAH/Unit Is built you can have him start with as he has just toggled weapon!

This is what the CAH Archer class uses so it starts with a Bow out instead of a sword...
              
Code

Behavior = DoCommandUpgrade ModuleTag_CreateAHeroMakeSureArcherUsesBowInitially
TriggeredBy                        = Upgrade_CreateAHero_ClassArcher
GetUpgradeCommandButtonName        = Command_CreateAHero_A_ToggleWeapon
RemoveUpgradeCommandButtonName    = Command_CreateAHero_A_ToggleWeapon
    End

what this Code is saying is that if if you are using the CAH class archer:
we want you to put the toggle button on the commandset if its not already there and do the toggle once and then take it of the commandset, unless it was already there.

(the character starts with a sword so if you removed the code createahero.ini he/she would start with a sword instead)


BUT.........................


If you were using this on say...faramir then it might look like this
              
Code

Behavior = DoCommandUpgrade ModuleTag_UseSwordInitially
TriggeredBy = Upgrade_StartWithSword
GetUpgradeCommandButtonName = Command_ToggleFaramirWeapon
End

(MUST put Upgrade_StartWithSword in the Proper Experience Level and define it in upgrade.ini, it dosent have to be Upgrade_StartWithSword it can be anything you want)
Basically This Code is Saying that when he is built he will automatcally toggle weapon once.

You still With Me???

Now... say you took the toggleweapon command off of faramir's commandset but you wanted to have him start with a sword (starts with bow by default)
you would need to add this line in the docommandupgrade behavior:
              
Code

RemoveUpgradeCommandButtonName    = Command_ToggleFaramirWeapon


so it would look like this:
              
Code

Behavior = DoCommandUpgrade ModuleTag_UseSwordInitially
TriggeredBy = Upgrade_StartWithSword
GetUpgradeCommandButtonName = Command_ToggleFaramirWeapon
RemoveUpgradeCommandButtonName    = Command_ToggleFaramirWeapon
End


you could also just put the toggle weapon in the commandset assinged to a button number that is 7+

EX:
              
Code

CommandSet GondorFaramirCommandSet
1 = Command_ToggleStance
2 = Command_xxxxxxxxxxxxxxxxxxxxxx ; <<<command that replaces toggle weapon goes here
3 = Command_SpecialAbilityWoundArrow
4 = Command_ToggleMounted
5 = Command_FaramirFakeLeadershipButton
6 = Command_SpecialAbilityCaptainOfGondor
7 = Command_ToggleFaramirWeapon ; <<<<<toggle weapon goes in slot 7+ therefore does not appear in palantir
12 = Command_CaptureBuilding
13 = Command_AttackMove
14 = Command_Stop
16 = Command_SetStanceBattle
17 = Command_SetStanceAggressive
18 = Command_SetStanceHoldGround
End


if you did it like this you would not need the line:
              
Code

RemoveUpgradeCommandButtonName    = Command_ToggleFaramirWeapon



That's it for toggle weapon!
the next page is shorter

Next Up: Triggering Powers
-------------------------------------------------------------------------------------------------

Here im going to show you how you can use the "triggered by feature in the docommandupgrade beahvior to automatically have the hero use his power

Im going to use Aragorn Use his Blade master ability once he reaches Level 7

First:
Put this in aragorn.ini
              
Code

Behavior = DoCommandUpgrade ModuleTag_UseSwordInitially
TriggeredBy = Upgrade_UseBladeMaster
GetUpgradeCommandButtonName = Command_SpecialAbilityBladeMaster
End


Second:
Put this in Upgrade.ini
              
Code

Upgrade Upgrade_UseBladeMaster
Type = OBJECT
End


Third and Finally:
GO to experiencelevels.ini and find this code:
              
Code

ExperienceLevel    AragornLevelMP7
TargetNames                        =    ARAGORN    
RequiredExperience                =    ARAGORN_LVL7_EXP_NEEDED
ExperienceAward                    =    ARAGORN_LVL7_EXP_AWARD     
LevelUpFx                        =    FX:GandalfLevelUp1FX
;LevelUpOCL                        =    OCL_GandalfLevelUp1OCL
Rank                            =    7
AttributeModifiers                =    HeroLevelUpDamage6
SelectionDecal
Texture                        =    decal_hero_good
    Style                        =    SHADOW_ALPHA_DECAL
    OpacityMin                    =    50%
    OpacityMax                    =    100%
    MinRadius                    =    40
    MaxRadius                    =    200
    MaxSelectedUnits            =    40
    End    
End


and add:

              
Code

Upgrades = Upgrade_UseBladeMaster


Above:

              
Code

SelectionDecal


it will look something like this:

              
Code

ExperienceLevel    AragornLevelMP7
TargetNames                        =    ARAGORN    
RequiredExperience                =    ARAGORN_LVL7_EXP_NEEDED
ExperienceAward                    =    ARAGORN_LVL7_EXP_AWARD     
LevelUpFx                        =    FX:GandalfLevelUp1FX
;LevelUpOCL                        =    OCL_GandalfLevelUp1OCL
Rank                            =    7
AttributeModifiers                =    HeroLevelUpDamage6
Upgrades = Upgrade_UseBladeMaster
SelectionDecal
Texture                        =    decal_hero_good
    Style                        =    SHADOW_ALPHA_DECAL
    OpacityMin                    =    50%
    OpacityMax                    =    100%
    MinRadius                    =    40
    MaxRadius                    =    200
    MaxSelectedUnits            =    40
    End    
End


now i will go through what each file does...

experiencelevels.ini code:
              
Code

Upgrades = Upgrade_UseBladeMaster

tell the game that when aragorn reaches level 7 give him this upgrade:


aragorn.ini code
              
Code

Behavior = DoCommandUpgrade ModuleTag_UseSwordInitially
TriggeredBy = Upgrade_UseBladeMaster
GetUpgradeCommandButtonName = Command_SpecialAbilityBladeMaster
End

the TriggeredBy line tells that when this unit will do the GetUpgradeCommandButtonName when aragorn receives the upgrade "Upgrade_UseBladeMaster"

Upgrade.ini code
              
Code

Upgrade Upgrade_UseBladeMaster
Type = OBJECT
End


defines the upgrade referenced in experiencelevels.ini and in aragorn.ini

-------------------------------------------------------------------------------------------------


ADDED 1/7/2011

Here I'm going to show you how to make someone come with an upgrade when they are built but with some cool twists

              
Code

Behavior = DoCommandUpgrade ModuleTag_UseSwordInitially
GetUpgradeCommandButtonName = Upgrade_IsengardForgedBlades
End

/\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
this will automatically give the unit this upgrade when they are built

              
Code

Behavior = DoCommandUpgrade ModuleTag_ForgedBlades
TriggeredBy = Upgrade_HardAIMultiPlayer
GetUpgradeCommandButtonName = Upgrade_IsengardForgedBlades
End


the line i added here is the upgrade the AI gets when it is set to hard difficulty...
so if you add this to the isengard fighter and the computer to hard and as faction isengard when they build isengard fighters they will come with forged blades


Note:

I have not tested this personally, Nevertheless it should work...
I hope you enjoyed this article...PLEASE LET ME KNOW IF YOU FIND ANY MORE USES FOR THE DOCOMMANDUPGRADE BEHAVIOR SO I CAN LIST THEM!!!

Modboy451

Credits

a bunch of people that have told me to add all of my usless little tutorials into one tutorial...

Comments

Display order: Newest first

modboy451 - Monday November 14, 2011 - 17:41

^_^ removed.

Prolong - Sunday May 1, 2011 - 5:56

Nice tips for intermediate coders. :-) You should remove the empty last page of the guide!

Radspakr Wolfbane (Team Chamber Member) - Monday February 14, 2011 - 18:49

The majority of all this is only for BFME2/ROTWK.

modboy451 - Monday February 14, 2011 - 9:21

an article on spell books may be coming soon!

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:27:38