The 3rd Age

The Elven LegacY MoD

The Elven LegacY MoD

This mod for bfme 1 Mod based on Elvestar 5.5

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

Tunnel Logic

Tutorial for Battle for Middle-earth BFME

Avatar of GothmogtheOrc

GothmogtheOrc

Category: Code
Level: Expert
Created: Monday March 26, 2007 - 13:15
Updated: Friday March 30, 2007 - 17:31
Views: 5165
Summary: Adding Tunnels to BFME

Rating

Staff says

3.0

Members say

4.0

Average

3.6/5.0

8 votes

Tunnel Logic

Written by: Grim

Thanks to: Hostile for his brillant ideas, his courage and advice. T3A staff and members for their support.

The purpose of this tutorial is to give a building object a tunnel network ability.

Be ware that the code isn't developped for BFME specificly, it comes from C&C Generals and it has some restrictions:

-Entering units will be instantly full healed.
-No filter for entering units, anything can enter the tunnel.
-Horde logic does not count, so when a horde goes in the tunnel, it will spread into individuals, and while exiting the tunnel, they will remain as individuals.

We will see one alternative solution for the horde problem with an example: The Tunnel Guide. But first:

1) Give a building the tunnel Behavior:

Go in your building object code, and add this:

              
Code

Behavior = TunnelContain ModuleTag_Tunnel
; TimeForFullHeal = 10000 ;(in milliseconds) ; does not seem to work, adding this or not, units are full healed as soon as they enter the container
ObjectStatusOfContained = UNSELECTABLE ENCLOSED
DamagePercentToUnits = 0%
; PassengerFilter = NONE +INFANTRY ;Does not work, anything can enter
AllowAlliesInside = Yes
AllowEnemiesInside = No
AllowNeutralInside = No
NumberOfExitPaths = 1
ShowPips = No
End


Now any friendly unit can go in the building.

To set the number of units max can enter the tunnel, go into gamedata.ini and modify the line:

              
Code

MaxTunnelCapacity = <number of units max>


To make them able to go out, we have to add a evacuate button into the commandset of our building, and exitgarrison button to see what's in:

              
Code

CommandSet <YourBuilding>CommandSet
1 = Command_Sell
2 = Command_EvacuateGarrison ;click on this Button to make the units go out
3 = Command_ExitGarrison ;stop at this line if MaxTunnelCapacity = 1
4 = Command_ExitGarrison ;stop at this line if MaxTunnelCapacity = 2
5 = Command_ExitGarrison ;...
6 = Command_ExitGarrison ;...
7 = Command_ExitGarrison ;...
8 = Command_ExitGarrison ;...
9 = Command_ExitGarrison ;...
10 = Command_ExitGarrison ;...
11 = Command_ExitGarrison ;stop at this line if MaxTunnelCapacity = 9
12 = Command_ExitGarrison ;stop at this line if MaxTunnelCapacity = 10
End


If you have set the MaxTunnelCapacity high, you would probably like to hide the ExitGarrison buttons while empty.
To do so, go in commandbutton.ini, find Command_ExitGarrison and add HIDE_WHILE_DISABLED to the options like that:

              
Code

CommandButton Command_ExitGarrison
Command = EXIT_CONTAINER
Options = OK_FOR_MULTI_SELECT HIDE_WHILE_DISABLED
TextLabel = CONTROLBAR:GarrisonExit
ButtonImage = BRGoldenHall_Evacuate
ButtonBorderType = SYSTEM
DescriptLabel = CONTROLBAR:ToolTipStructureExit
Radial = Yes
InPalantir = Yes
RequiresValidContainer = Yes
End


Now your tunnel network is ready to work. If you build multiple buildings of that type over the map, you will be able to make a unit enter one and go out from another.

But remember, if a horde goes in, it will spread into individuals.>Here's an alternative solution i worked on: use a horde transport container object to carry your hordes through the tunnel network. As i was doing a dwarven faction, I made him a dwarf mine guide.


2) Alternative solution for horde problem - The Dwarf mine guide.

First, you have to build or use a mobile single unit. I built a dwarf named Dwarf mine guide. Then you have to give him the HordeTransportContain behavior, just add this into his object code:

              
Code

Behavior = HordeTransportContain ModuleTag_whatever
ObjectStatusOfContained = UNSELECTABLE
Slots = 2 ;can be more or less, set it as you want
DamagePercentToUnits = 0%
PassengerFilter = ANY +INFANTRY +CAVALRY ; set the filter how you want. This will allow any kind of traditionnal hordes to enter the unit
AllowOwnPlayerInsideOverride = Yes
AllowAlliesInside = No
AllowEnemiesInside = No
AllowNeutralInside = No
ExitDelay = 0
NumberOfExitPaths = 2
ForceOrientationContainer = No
ShowPips = Yes ;Yes: shows the little ticks of contained units. No: hides them
EjectPassengersOnDeath = Yes
KillPassengersOnDeath = No
FadeFilter = ALL
FadePassengerOnEnter = Yes ;Units will disappear when entering the container
EnterFadeTime = 1000
FadePassengerOnExit = Yes
ExitFadeTime = 1000
End


You can tune this how you want. This is one of the interests of the transition container.

Now, to allow hordes to exit the container/mine guide, we have to add a new button in commandbutton.ini:

              
Code

CommandButton Command_TransportEvacuateMineGuide ;You can name it differently
Command = EVACUATE
Options = OK_FOR_MULTI_SELECT HIDE_WHILE_DISABLED
TextLabel = CONTROLBAR:TransportEvacuate
ButtonImage = BRGoldenHall_Evacuate
ButtonBorderType = SYSTEM
DescriptLabel = CONTROLBAR:ToolTipTransportExitMumakil
InPalantir = Yes
End


Then add it to the container/mine guide's commandset:

              
Code

CommandSet MineGuideCommandSet
1 = Command_SpecialAbilityLightTorch
2 = Command_TransportEvacuateMineGuide ; <----here it is
3 = Command_GuardUnit
13 = Command_AttackMove
14 = Command_Stop
15 = Command_Guard
End


That's all!
Now you have a character unit able to transport/guide your hordes through the tunnel. You just have to make your horde go into it/him, move the container/guide through the tunnel, and when out use the exit button to make the horde go out in one piece.

This is all for the tutorial. If you have questions or suggestions go to the main forum and ask. Keep in mind the tunnel behavior is not made for BFME so it's far from perfect, but it can still allow nice possibilities.


Credits

GrimWriter

Comments

Display order: Newest first

Hostile (Administrator) - Tuesday March 31, 2009 - 16:24

Nothing really, but the horde will end up lost and come out as individuals. Not much more to add.

CNCM_BLITZ - Friday October 12, 2007 - 8:23

Would it make any difference if the tunnel logic was made as an upgrade, or a building add-on. Is that even possible? In other games I have used add-ons to bypass problems and perhaps if the base building has the object filter, and the add-on has tunnel logic they might work together.

Bart (Administrator) - Wednesday April 4, 2007 - 8:42

unfortunately nothing, as the passenger filter doesn't work

there is one solution, though it's more of a workaround. put an invisible wall around it that only a mineguide can cross. unfortunately:
- is that even possible?
- the tunnel can't be attacked up close
- the other units can still get an order to move in, but will just stop against the wall. not very user friendly

JEV3 - Tuesday April 3, 2007 - 20:55

Ok, that is pretty cool, but what is to stop the player from putting hordes directly into the tunnel instead of into the dwarf...

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