While working on my mod, I thought it might make sense for players to be able to capture hostile resource-buildings rather than destroying them. I tried to get the flag-method (the one used for Inns, Outposts etc) to work and failed... and then suddenly had the idea to make the farms garrisonable and allow enemies inside. This way you can send infantry units in there just like into towers, and once they are in, the building is captured. There are only two things you have to do to make this possible:
- Add GARRISONABLE and GARRISONABLE_UNTIL_DESTROYED (not sure if the last one is really needed) to the KindOf-list of the building
- Add this block below:
Behavior = HordeGarrisonContain ModuleTag_hordeGarrison
ObjectStatusOfContained = UNSELECTABLE CAN_ATTACK ENCLOSED
ContainMax = 1; This handles how many batallions can be inside the strucutre at a time
DamagePercentToUnits = 0%
PassengerFilter = GENERIC_FACTION_GARRISONABLE
AllowEnemiesInside = Yes; This allows units to capture the building
AllowAlliesInside = Yes
AllowNeutralInside = No
AllowOwnPlayerInsideOverride = Yes
NumberOfExitPaths = 1
PassengerBonePrefix = PassengerBone:ARROW_ KindOf:INFANTRY
EntryOffset = X:50.0 Y:0.0 Z:0.0
EntryPosition = X:35.0 Y:0.0 Z:0.0
ExitOffset = X:75.0 Y:0.0 Z:0.0
End
You can also leave the "CAN_ATTACK" out if you don't want archers to be able to shoot from inside the building.
I also found out that if you move your units out again the building will be given back to the original owner. And for buildings which are not meant to be garrisoned (towers should need nothing more than changing "AllowEnemiesInside" switched from No to Yes) one might want to add a "Command_ExitGarrison" to the commandset.
Edited by Chachalon, 27 April 2006 - 12:20 PM.