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

CommandButtons dependent on multiple upgrades

This tutorial is currently hidden from the public.

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 {AE}Manveru

{AE}Manveru

Category: Code
Level: Intermediate
Created: Sunday February 21, 2010 - 16:21
Updated: Friday August 27, 2010 - 19:15
Views: 802
Summary: A way to add multiple dependencies for a commandbutton if one of them is a required level.

Rating

Staff says

-

Members say

4.0

Average

4.0/5.0

1 vote

Page 1 2 3 4 5
Most of the functionality can be fixed with a couple of tweaks to the existing CommandButton.

First, go to the CommandButton for the unit or power you're editing. For the purposes of this tutorial, I will be working with the Rohirrim.

              
Code
CommandButton Command_ConstructRohanRohirrimHorde
    Command                = UNIT_BUILD
    Object                = RohanRohirrimHorde
    Options                = CANCELABLE NEED_UPGRADE
NeededUpgrade = Upgrade_StructureLevel2
    TextLabel            = CONTROLBAR:ConstructRohanRohirrimHorde
    ButtonImage            = BRStables_RohirrimPike
    ButtonBorderType = BUILD ; Identifier for the User as to what kind of button this is
    DescriptLabel = CONTROLBAR:ToolTipBuildRohanRohirrimHorde
    Radial                = Yes
    InPalantir             =     Yes
    ShowProductionCount    = Yes
End

The code above shows the Construct Rohirrim CommandButton with a prerequisite of a Rank 2 Stables. If you only wanted your unit to depend on one upgrade, this is what your CommandButton would look like. However, since we want two upgrades for our unit, we're not done.

It should also be noted that simply adding another upgrade to the NeededUpgrade line will not work (e.g. NeededUpgrade = Upgrade_StructureLevel2 Upgrade_RohanHorseLords) What you need to do for this part of the process is change the CommandButton as follows.

              
Code
CommandButton Command_ConstructRohanRohirrimHorde
    Command                = UNIT_BUILD
    Object                = RohanRohirrimHorde
    Options                = CANCELABLE NEED_UPGRADE
NeededUpgrade = Upgrade_RohanHorseLords
RequireLevel = 2
    TextLabel            = CONTROLBAR:ConstructRohanRohirrimHorde
    ButtonImage            = BRStables_RohirrimPike
    ButtonBorderType = BUILD ; Identifier for the User as to what kind of button this is
    DescriptLabel = CONTROLBAR:ToolTipBuildRohanRohirrimHorde
    Radial                = Yes
    InPalantir             =     Yes
    ShowProductionCount    = Yes
End

Replace Upgrade_RohanHorseLords with your upgrade and RequireLevel = 2 with whatever level you want your unit to become available at.

In the above code, I added the line RequireLevel = 2 to set a required level. This freed up the NeededUpgrade = line for my new upgrade.

As of right now, the CommandButton works as soon as your building reaches rank 2, but until then the button is invisible. If you're OK with that, then you can stop here. It works. But if you'd like to be able to have the button show up disabled when the prerequisite level isn't met, then you should continue.

Next: Adding a fake CommandButton

Comments

Display order: Newest first

Rob38 (Team Chamber Member) - Friday August 27, 2010 - 19:17

Illuvatar is right. You made it way too complex. ;)

Marioverraeter - Friday July 2, 2010 - 2:59

Ah, I see what you mean. Well, in fact, in the meantime I figured out both this one and another option that add to each other in there use.

The solution you just explained is to simply bypass the actual (upgrade) commandbutton that was meant to have multiple dependencies, and rather just add multiple dependencies to the effects and outcomes the commandbutton should lead to.
While this technically works fine, it has two drawbacks:
1) the player does not get informed about such an upgrade, because it takes effect without being represented by a commandbutton and its tooltip. That means the mod gets less beginner friendly.
2) it is not possible to require an own actual buildcost and buildtime for that upgrade, as it is bypassed. At least, this can't be done without huge efforts and detours.

Fortunately, we therefore found another option to raise multiple dependencies on a commandbutton:
That is, to add a CommandSetUpgrade behavior block to the object.ini of the building whose commandset contains this commandbutton. You just need to add all the prequisite Upgrades into the TriggeredBy line, and add the RequiresAllTriggers line. Once the new commandset is defined, make sure to edit/add both the first(standard) commandset of that building not to contain the button, and the second (switched-to) commandset to contain it. To make it more beginnerfriendly, the button can be added to the first commandset as well, but with the additional Option UNPRESSABLE in its commandbutton block in the commandbutton.ini, so it actually is a FakeButton. In the tooltip of that fake button, all requirements can be explained.

So, I guess this topic should be clear now. Maybe I will post one or two own tutorials regarding this and related topics.

Illuvatar - Wednesday June 9, 2010 - 3:12

Marioverraeter: Well, in the case that I used it, I wanted a unit to reach a certain level as well as purchase a technology from a research building before it could attain a power I wanted it to have (you could think of it as purchasing an upgrade like Forged Blades but having to be level 2 or something). So in the power's unpause behavior block I put two upgrades in the TriggeredBy field: the level upgrade (object_level#) and the technology upgrade. Then you add the line I posted earlier so that it needs both triggers. See what I mean?

Marioverraeter - Sunday May 16, 2010 - 9:01

Interesting. In deed, this is exactly one problem I am bothering with at the time.

The method you present here is okay for only one upgrade + structure level requirement. However, it is not sufficient for commandbuttons dependent on multiple upgrades in general, with more than only one actual upgrade required.

When I was fiddling about with this, it seemed to work on adding NEED_UPGRADE multiple times in the Options line and then adding multiple NeededUpgrade lines. It "seemed" to work... but sometimes, it seemed to fail again. I am not sure about that.

Are there other experiences with this multiple dependencies issue? Would be great.

--------

P.S.: Illuvatar, could you explain this method further? I didn't actually get the point; a unit always has multiple behavior blocks. which one do you mean?

--------

Okay, so far... testing my own approach has resulted in a complete fail. It does not work either. Maybe it seemed to work because the last upgrade I got was randomly the one of those which was taken as *the* needed upgrade, I dont't know.

Anyway, it would be nice if someone has another idea or method to bring this to work. The inability to set dependencies on multiple upgrades just made my whole work of two weeks, an upgrade system for all factions, useless. Help appreciated.

Illuvatar - Sunday April 25, 2010 - 0:06

Uh... to shorten this tutorial up to about two sentences: You only need to put both upgrades in the TriggeredBy field in the behavior block (most likely in the unit ini file). Then just add the following field:

              
Code

RequiresAllTriggers = Yes

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

 
3:26:22