I personally worry that capturing buildings would be extremely overpowered: the strong get stronger. After all, if magic captures a castle, they can build the entire techtree. Well, kinda. They'd have to capture a farm as well. No farm? You won't make a single unit. Same thing for tech capturing magic. No energy source? No production. I don't really think it's a good idea to let a faction capture the main buildings, though. However, without the food-style resource, it might be impossible to create a single unit from the captured buildings. As a result, capturing should not be a default option, but something that must be enabled on a techtree level.
Concept
What I think would work best is giving buildings a
<capturable> parameter. There's a few things we need to configure to make a captured building any use. First of all, we have to have a resource requirements tag. This is the same as the existing resource cost for units. Presumably we'd normally use it to give negative amounts of food or energy. For example, suppose I gave the barracks a negative -10 food. As a result, capturing a barracks would allow producing up to ten units from it. Without that food bonus, I wouldn't be able to produce anything if I was playing as magic (or any other faction that doesn't use food). A possible problem is the lack of storage for food. The simplest solution would be to simply give the building the ability to store some food (as can already be done in the unit's parameters). It's not like most players ever run out of storage for food, anyway. Alternatively, we could have another option to change the storage parameter when a building is captured, but that might overcomplicate things (for the programmer).
Anyway, we'd also need a way to determine what happens to the building's health when captured. I think we should simply allow the modder to state the health as a percentage (a decimal value from zero to one). So a captured building might default to half health. Or maybe 10% of the health or full health, at the modder's discretion.
And should capturing be permitted if there are other units or buildings nearby? It seems very unusual to me to attack a base and capture a building while enemies are still swarming around you. Not to mention it'd just paint that building as a big bullseye. I think there should be a parameter that states how many enemy units can be within a specific radius before the building can be captured. For example, maybe I can only capture buildings if there's less than three enemies around? Or maybe there has to be no enemies around.
We probably should also set a capture rate. Do we capture this building 100% of the time? Or 50%, 80%, or what?
Should capturing a building allow upgrades to be performed? I'd make that an option as well. Upgrades are a bit problematic. We don't want the capturing player to be too powerful, not to mention many upgrades apply for different types of buildings, which wouldn't necessarily be captured.
On a side note, we should keep track of the original owner, as recapturing a building should negate disabled upgrades. I also think recapturing should have a 100% chance to recapture the building and the nearby units should be ignored.
Now, that's the building being captured. What about the capturing unit? I think the simplest way to do it would be to add an optional element to the attack command. Let's keep it simple: can the attack capture and if so, let's give it a multiplier. As previously stated, buildings have a capture rate, so the multiplier would multiply the capture rate. A multiplier of one means I have the "regular" chance to capture that building. A multiplier of 0.5 would half the chance that particular attack would capture the building. For example, if the building has a 0.8 capture rate (80%) and my unit has a multiplier of 0.8 as well, then my final capture rate is 0.8 * 0.8, or 0.64 (64%). This could also be used so that some units are better at capturing. A possible application would be to make melee units more likely to capture a building than a ranged unit. Or perhaps swarm units (like the daemon or swordman) has a better chance than an archmage (which would theoretically be more likely to damage the building).
How is the building captured? Simple: the last blow has to be dealt be an attack with a capture flag.
Syntax
For the capturable unit, in the
<parameters> element of a unit:
<capturable value="true">
<resource-requirements>
<resource name="food" amount="-10" />
</resource-requirements>
<capture-health value="0.5" />
<nearby-enemies radius="5" maximum="2" />
<capture-rate value="0.75" />
<allow-upgrades value="false" />
</capturable>
Let's break that down:
- capturable: Straightforward enough; true if the unit can be captured and false otherwise. Defaults to false. The entire element is optional.
- resource-requirements: This is the exact same syntax as the element in the parameters of existing units. Its purpose is to provide resources that the capturing faction might need, but can't access. It could also be used to penalize capturing factions.
- capture-health: A percentage between zero and one that denotes what percentage of the maximum health the building will start with once captured.
- nearby-enemies: The radius to check for nearby enemies and the maximum enemies that can be nearby. Note that we are only counting non-buildings as enemies.
- capture-rate: A percentage between zero and one that denotes the capture rate of the building.
- allow-upgrades: If true, upgrades may be purchased as normally; if false, upgrades are disabled (preferably hide the icons).
So in this example syntax, the building can be captured and capturing it rewards the capturing team with 10 food (and hopefully this building also stores at least 10 food). Capturing this building would put it at half health (note that it might not be possible to repair this, but that's a strong gameplay element, in my opinion and more on repair later). In order to capture this building, there cannot be more than two non-building enemies with a radius of five cells. The capture rate is 75% (although changes with the unit as well). Finally, upgrades are disabled on this building.
Now for the capturing syntax. This would go in the
<command> element of an attack command:
<can-capture value="true" multiplier="0.8" />
That was nice and simple, right? The
value simply tells us whether or not that attack can capture a capturable unit. It defaults to false and this entire element is optional. The multiplier will be multiplied against the building's capture rate. So with our previous example's 75% capture rate, we multiply that by 0.8 to get a final capture rate of 60%. The multiplier defaults to one and is optional.
Other notes
- Upon capturing a building, there should be a popup dialogue (akin to the "game over" dialogue) asking if we want to keep it. If the game can be paused, we should do so. Why offer a choice? Because there's no way to delete a unit (we should look at that, too, though) and the building might have penalties to capture set by the modder (resource costs; for repair or whatever). If the building isn't captured, it's destroyed as normal.
- We should consider a way to repair capturable units. Perhaps simply allow the repair skill to list units that are not in the faction. This becomes problematic since we might not be loading the faction that contains these units. In which case, we should ignore the extra units. The biggest issue would probably be buildings that have the same name. To fix this, we could add a faction attribute to repairable unit list. This would also permit the error reporting to continue to function properly.
- I heavily mentioned the fact that factions often use a different type of food-style resource. Supplying this is difficult, as the capturing forces might not have captured a farm. For most buildings, the easiest way to do this would be by giving the building the normal ability to store the resource. We could add alternatives, like changing the resources stored by the building after capture or by automatically adding storage for supplied resources, but I think it's more trouble than it's worth and possibly an issue because...
- I've been mentioning buildings only here, but this should work fine with regular units, too. The problem then is the resources. If magic captures a swordman, that swordman is going to starve, because magic has no food resource. A possible fix would be to ignore consumable resource costs for captured units. Might be necessary to ignore static resources too? I'm not sure if they'd be consumed.
- On a side note, capturing a unit should not enforce the unit's resource costs. So maybe the above fears about food wouldn't matter for capturing units. At the very least, though, we don't want to lose several hundred resources because we captured an enemy building. The building already exists, we're not spending resources on it. However, the resource costs element could be used to make capturing use some resources. In which case, insufficient resources should just use what there is.
- As mentioned, we need to keep track of who the building's owner was. I think recapturing your own buildings should have a 100% success rate (ignore the capture rate, multiplier, nearby-enemies, allow-upgrades, and resource requirements). However, the original owner should be the person who built it. Consider this scenario: player 1's barracks is captured by player 2. Later, player 3 captures this barracks. Player 1 is still the original owner and has the advantages for getting it back.
- This system has a heavy reliance on the last blow to a building. This is a shortcoming, but then again, that's also an issue with the kill counter. If you want to maximize capturing a building, you'd have to micromanage so the low (or no) capture rate units attack first and units with high capture rates are making the final blows. There isn't really an easy way to change this, but I don't think that's an issue. If a real life building is cleared by a navy team only to be bombed heavily, you're not capturing that building. The last attack is important (although the experience system could still be revamped).
- AI is an issue. If the implementation can be done in such a way that the AI can handle it, great. Otherwise, we could just have the AI choose to never capture a building.
For modders
- One issue I have with capturing is that the winning team becomes stronger. That's bad, because then whoever wins the first battle quickly becomes unstoppable. We're already giving them the ability to diversify their army more, so let's not give them a free pass to win the game. Thus, I don't think it's ideal to let an entire techtree be built up via capturing. Avoid 100% capture rates and don't set the main building or workers as capturable.
- One interesting way to balance out capturing dynamics is to add a resource cost. Think of it as a cost to repair the building. After all, the building was reduced to zero health and we're healing it up when capturing. It would also make modders think about whether or not capturing the building is worth it.
- If units can be captured, their capture rates should be low and they should not be captured at full health. Directly capturing units would be the quickest path to becoming overpowered. On a side note, if the unit doesn't have regeneration, it might be stuck with its capture health. Regeneration is a good idea.
- I'd personally disable all upgrades unless the faction is heavily dependant on upgrades. The problem with upgrades is that they could contribute again to overpoweredness and many upgrades affect different buildings, which might not end up captured (rendering the upgrade useless).
Implementation difficulties
- Units aren't respawned, but saved from death, healed, and have their control changed. Yet, the faction is not changed, so there needs to be a way to allow a player to control multiple factions. Before we do this, it might be worth implementing the long awaited "let the human control more than one player" feature.
- Resources, resources, resources. They're a huge pain. Normally we don't display resources like food for magic, since we can easily see that their units and upgrades don't use the resource. If possible, we should dynamically change the HUD when we gain a new resource. Hopefully that's possible.
- Also on resources, the food-style resources (consumable and static) should still be used on captured units. If I capture a swordman, he shouldn't be getting a free meal. However, none of the other resources should be applied (the gold and wood have already been spent on him!). It might be necessary to have the modder specify what the food-style resource is (if there is one). We might be able to just simply use up static or consumable resources based on their type, but that seems problematic. To be honest, though, the first implementation of a capturing dynamic should focus on just buildings. Worry about units after.
- Multiplayer code: will it need changes to accommodate modifying the control?
Too complex?
I think an implementation like this would be the most functional and useable. However, if we need to simplify the system (preferably just to make baby steps towards capturing), we could cut out the nearby enemies feature and simply go by the capture rate. We could also remove the ability to chose if upgrades are enabled or disabled. We could forget about the recapturing stuff. However, I think the ability to manage resources is crucial for a cross-faction capturing system to work. If we wanted to really simplify it, we could also remove the need to flag certain attacks as can-capture, but I think that's a bad idea.
That was way too freaking long!
I know, I'm sorry. Here's a summary for those of us with shorter attention spans:
- Buildings can be designated as capturable; we can set things like how many enemies can be around, the chance of capture, their health after capture, resources after capture, and if they can perform upgrades.
- Attack commands can be designated as can-capture. We also add a multiplier so some units/attacks are better at capturing than others
- Resources are a big concern nobody addressed in this thread. For example, magic uses energy and Tech uses food. In order to ensure that a captured building can actually produce stuff, we have to supply that food-style resource.
- We've also glossed over the fact that capturing can be overpowered. To combat that, modders shouldn't let the main building or worker be captured. This ensures you can't build up an entirely new faction, but rather just claim parts of an existing one.
- Preventing things from being overpowered is also why we should consider disabling upgrades
- It should be easier to recapture your own lost buildings (100% capture rate)
- This applies to units, too; not just buildings. Capturing units shouldn't give them free meals, though, so the food-style resource is still used