forkserf / forkserf

a continuation of "FreeSerf"

Home Page:https://forkserf.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ideas for revamped combat/territory system

tlongstretch opened this issue · comments

The original game's combat design feels weak. The requirement build military buildings to be able to expand borders to build civilian buildings results in tons of wasted knight huts. The restriction on building military buildings too close to each other is a hack to limit an obvious exploit (building tons of huts to better defend territory) when it should instead be wasteful to build too many military buildings right next to each other.

Ideas for overhaul:

  • allow attacking knights to burn enemy buildings directly, and possibly chase down and kill serfs (though that would be cumbersome because of the one-serf-per-mappos limit). Attackers would no longer be required to attack enemy military buildings only.
  • possibly, instead of directly targeting buildings, allow knights to be sent to attack any enemy flag, with a game option to pillage/no-pillage and any enemy civilian buildings encountered along the way will be burned.
  • enemies entering friendly territory would automatically trigger garrisoned knights nearby to sally out and intercept the attackers, engaging in field combat. A new menu/mechanism would allow configuration of sally/no-sally and the ratio of knights to send out
  • no more "100 morale" for defenders, instead defenders use their existing morale, with a boost for being in friendly territory, an additional boost for being near a friendly military building, with increasing boosts for stronger military building types (tower, fortress/garrison, castle). Further, an even larger boost for actually being inside the building and defending it "the usual way" instead of sallying

Longer term ideas:

  • Perhaps eventually, the ability for knights to "camp" in enemy territory, or anywhere else, by allowing knights to construct a tent that acts like a knight hut for the purposes of being able to stay put and be sent back out to a new attack target so knights are able to attack things farther away from friendly military buildings. The tent would offer no defensive bonus. It would need a flag and would need to be attackable which might be complicated to code, resulting in enemy flags inside player territory.
  • Allow friendly knights to rally to a specific area for defense, and stay there until called back. Similar to camping above but in friendly territory. Possibly same mechanism
  • Allow building outside of "player borders", the player borders would instead only represent area that is protected by friendly military buildings in terms of the range of triggering auto-attacking against intruders.

These changes would make it mostly pointless to build military buildings very close to each other and that limitation could be removed.

in the new branch combatoverhaul, with commit ff465bd has a crude proof of concept:

pillaging

  • it is now possible to attack civilian buildings, defaults to sending one knight but any number can be sent as usual
  • if the attacking knight reaches the target building flag he burns the building then becomes lost and returns home
  • (make optional?) if the knight reaches any other enemy civilian/unprotected building flag along the way he will burn those too

auto-rallying defenders

  • when an enemy building sends knights to attack a friendly building, this immediately triggers nearby knights to go to the flag of the target building (to defend it). Upon arrival the become lost. If they happen to encounter an attacker along the way they will fight them as usual

There are a lot of complications with this:

  • currently it re-uses the attacking logic variables to determine which knights to send, how many, etc. It is possible this could also interfere with the player making his own attacks, I didn't look closely at the logic. It could be separated if necessary into its own variables
  • it isn't "fair" that the defenders know exactly where the attackeres are headed and that they know immediately the second they are dispatched
  • the rallying defenders become lost once they are done rallying, instead they should go back to their buildings if possible but the original game never had this kind of logic it would just replace them. Would have to handle the replacements-dispatch logic additionally
  • if the timing isn't right, the knights won't intercept the defenders
  • the rallying defenders should probably stick around a while at least before going home/becoming lost
  • the attackers could exploit this behavior to draw defenders from their military buildings before attacking the military buildings or attacking elsewhere. Though, this is limited by the fact that the attackers cannot be called back after dispatch so it would require the attackers to waste a lot of resources themselves

I think a better rallying design is:

  • when an enemy knight is visible and is free-walking within a certain range of friendly borders, it triggers intercept
  • the game checks the attackers target pos and uses it to calculate an intercept path
  • even though it is unfair that the defender would know the actual target, it is reasonable in that the attacker logic is known to be a straight line distance to the target and so it is simply a way to determine the general path the attacker will take. A human player would be able to easily infer the attacker's target or at least general target area be seeing the direction the attacker moves
  • the game would perform a pathfinding operation to determine the attacker's expected path, including usual routing around any current obstacles, and store the positions of their expected path along with the tile-distance travelled
  • the game would perform a pathfinding operation from the defender's dispatch building pos to the target pos... or perhaps the halfway point between the attacker pos and the target pos?
  • during the defender pathfinding operation, consider all positions found that include the attacker's expected path
  • attempt to intercept the attacker by sending the defender to a pos on the attacker's path that would result in the defender arriving just before the attacker, by targeting a pos that is slightly shorter along the attacker's path than it would take the defender to reach that pos. If possible.
  • if the defender cannot possibly intercept in time... don't send him? make this configurable?
  • keep re-checking to see if any attackers have targets?
  • call back the defenders immediately if attackers die or get re-routed outside of the friendly defense-triggering range (perhaps they accidentally go the wrong way around a lake and become too far away to be a threat, but are still listed having that target??)
  • or... have the defenders simply pace around the defense area for some fixed length of time regardless of what happens to the attackers
  • additionally.. if defenders can be sent back to their original military building, maybe trigger the logic that determines if stronger/weaker knights are desired currently to determine if the knight gets his garrison slot back or if the replacement (or some other knight) should be sent back

Ugh it gets deeper. Interception logic has a lot of tradeoffs.

Basic intercept logic might be something like this:

  • for each attacker detected approaching/inside borders
    • pathfind a route from attacker to target
    • for each pos along the expected attacker route
      • for each defender military building with a range of about as many tiles as the attacker would to reach that pos along the expected attacker route
        • pathfind an intercept path to the pos along the attack route and send allowed number of defender out
        • if the defender could intercept in time, send him out
        • if he cannot intercept in time, should he go out anyway? or do nothing?

But that would expend the maximum number of defenders to the first attacker found before considering next attacker

A better way would be to score each combination of attacker, target, defender, intercept pos. Scoring could consider the target being attacked to prioritize defending more valuable buildings, or areas with lots of buildings. It could consider pos where a defender might intercept multiple attackers. Player options could allow choosing between logic of trying to intercept each attacker with at least one knight or instead trying to protect the most valuable targets with the most defenders.

If an attacker believes the enemy is using "intercept most targets" he could send diversionary attacks to drain defenders, then send attackers to the true target

If an attacker believes the enemy is using "strongly defend high scoring buildings/areas" he could send a single knight to attack a high value target to drain many defenders, then send many knights to pillage other targets

The attacker could even estimate how long it would take for additional forces to restaff the garrison based on the paths visible to the defender's nearest castle/stock. Further, the attacker could estimate if the defender even has more knights available to send out based on the staffing level of visible buildings threat indicator flags. If all buildings of the same threat level have the same staffing level the owner has a reserve of knights. If they do not have the same staffing and/or are not immediately restaffed as knights are sent out the player is out of knights, at least in the nearest castle/stock.

All of this logic could eventually be optional based on AI intelligence/difficulty setting

in current state this works pretty well, but one fault is that intercepting knights
might travel slightly into enemy territory when trying to intercept enemies (and suffering a morale penalty), even if
their intercept pos is inside friendly borders. Perhaps a new intercepting serf state
makes sense, and if a knight is intercepting they can try to avoid entering enemy borders?

I've noticed that attackers are now appearing directly at their building flag instead of being seen walking out of the building to their flag, I must have introduced a bug somewhere with the states

the interception logic works well enough now that I can playtest it. I ran some 1v1 AI simulations and it results it lots of great combat. I think this is going to be a success. I need to make it multi-threaded and make the interception more efficient as it causes game pauses while it does the pathfinding.

Once all the code is there I need to make the AI logic consider the new risk and benefits of pillaging, which will be quite a bit of work.

I am realizing after watching the simulation that giving a benefit to a knight for being in their own territory is kind of silly because much combat happens right around the borders where ours vs theirs is a matter of only a few tiles. I think a better approach is to have zero benefits for being in friendly territory, and perhaps also zero benefit from being near friendly buildings, and simply let contested border areas be dangerous no-man's land where it is unwise to have civilian buildings

one thing to consider is that it becomes essential to occupy friendly military buildings as quickly as possible to avoid them being burnt before completion, or worse captured after completion before occuption! It seems unfair that a player can send an attacker at any point during construction but the builder/owner cannot even dispatch a knight until the building is fully completed.

This comes back to the "camping" or rallying idea... it seems like a requirement to be able to instruct your knights to stand in or mill about around a pos to defend it. Perhaps knights could be posted along borders. Or a knight could be assigned to defend new construction or directly defend civilian buildings. But, if it is possible to arbitrarily post knights in your borders it would result in each player having knights stand right along his borders all the time which is boring.

EDIT - perhaps new military buildings should dispatch their garrison knights once the building is partly constructed. The number of knights can increase as building progresses. The defensive bonus for being in a building could be limited to a fraction of the normal value, such as half the normal value and only after framing completed. This would allow more rapid claiming of even uncontested territory also as a knight would be dispatched. Also, knights could only be sent once the building has its builder on site and all materials delivered? Or, if building is in a high threat level knights would be sent early, but if no threat they would not? Or only one would be to speed occupation?

Need to find a balance that prevents player from having fine-grained control over knights and garrison levels, but also avoids having knights standing outside or occupying incomplete buildings for long. It should make them unhappy, and could be part of the overall happiness/rank idea I had. And higher ranking knights would get unhappier more quickly.

Yet another idea, have knights get a morale boost for having other knights nearby. For example being alone would cause a penalty, having one knight nearby no penalty, having two or more knights nearby a boost.

Or, lowest ranking knight alone would get an extra penalty unless a higher ranking knight was near him.

All ways to discourage sending suicidal small attacks to try to pillage or steal buildings.

And/or having a higher ranking knight nearby gives a boost, or maybe just champions.

EDIT2 - I think having knights occupy incomplete buildings is goofy, and allowing knights to gather and stand outdoors is not much fun. A better approach is to make it clear to the player that it is foolish to build new buildings, especially important military buildings, near enough to the enemy borders that the enemy could walk in an burn or occupy them. A strategy for the builder wanting, say a Garrison/Fortress, is to build Huts first to defend the desired important building pos, destroying them later if desired. Also, placing them far enough back that attackers would have to pass a number of intercepting buildings and if the attackers are disadvantaged it would be suicidal or at least incur very heavy losses, discouraging it

Have knights flee if their morale drops too low?

Have "morale" or kingdom-wide happiness/morale/prestige be something that matters highly to high ranking knights, less to low ranking knights, and not at all to serfs.

Along with the idea of matching higher ranked knights to higher tier military buildings, need some way to temporarily allow higher ranking knights to occupy areas/buildings for defense, much like how they can be sent to attack, but only for some period of time before they leave. Maybe the "send knights in/out" function that is mostly useless because of the contention it causes could be used to FORCE a run every so often. Or, it could be a timer per knight for under-housed knights not controllable by player.

The current "strongest/weakest fights" setting seems kind of useless, it seems to me like you would always want strongest fighting because equipment is so expensive it isn't worth wasting low ranked knights. What if this setting also controlled garrison staffing:

  • with "weakest fight" on, buildings would be occupied according to the normal "no threat" minimums, for example:
    • hut can have rank0, tower requires rank2, fortress requires rank3
    • lowest ranking knights available would be assigned to fill garrisons beyond the initial minimum knight requirement
  • with "strongest fight" on, highest threat level buildings would be occupied by the best knights available, with higher ranking knights "preferring" higher tier buildings

OR, leave the strongest/weakest fight as-is and create a new option that assigns the best knights available to high threat buildings, but the game mechanic of under-housed knights automatically returning to castle after some period of time (that scales with the degree of under-housing, so they don't all leave suddenly. Maybe randomize it slightly). With this option active, knights would continue to be replenished from the castle if available, but the constant churn of knights would clog roads. I like this idea

maybe it could be possible for under-ranking knights to occupy higher tier buildings but they would lose the defensive bonus, or they would only receive a defensive bonus equivalent to the tier they are normally suited for

If military buildings/knights consumed food, beseiging and starving out fortresses would be a viable option!

How to justify that only miners and knights get food, though?

I am not sure if lowest rank knights should be thought of as untrained troops or respectable soldiers. Because "armies of rabble" aren't viable in this game in the same way that hordes of famers, woodcutters, miners, etc. aren't viable, maybe it is a mistake to think of lowest tier knights as expendable. Allow them to hold Huts, require they get sword+shield (and later food), and don't give them fear/cowardice when fighting alone any more than other knights

performance enhancement - use same ai roadbuilder/pathfinder caching for interception plotting

improved performance of interceptions, and now if the target knight being intercepted dies the interceptors "go home"... by becoming Lost unfortunately. Still need to look into the logic on how to send them home (and the complications of reserving their spot in their garrison building)

while playtesting I notice that it seems odd that knights can travel off-road to intercept (and attack) at will, but can only follow roads while travelling to/from garrison duty, despite quickly occupying military buildings being critically important. The case that stood out was when I saw a friendly knight who was off to intercept an attacker who was attempting to pillage an almost-built new Hut. While en route, the Hut was completed and the intercepting knight passed right through its flag. Him occupying it would have made a lot more sense, meanwhile the actual garrison was just dispatched and had to follow roads and pass through traffic to reach it. It sort of breaks immersion on the whole road-travel system. The obvious approach is to make road travel much faster than off-road travel, but that would be a huge programming effort I think, and even so managing road congestion is one of the main game challenges. It seems in many or even most cases going off-road would make far more sense to avoid congestion, but that breaks the entire game concept of a road management system. Also, it would make an obvious strategy to create temporary roads constantly to improve knight speed only to destroy them immedately after

Some possible remedies:

  • the previously mentioned idea of having a knight accompany a builder, or otherwise be dispatched early so that he can immediately occupy the newly completed military building... assuming this is a high threat area
  • shorten the interception range so that it is less likely to have friendly interceptors walking all over in ways that make the road system look pathetic
  • add AI logic to build a most direct road (temporary, or otherwise) to a new military building near contested borders to get a knight there faster
  • have the morale concept updated to prevent your knights from being able to make suicidal attacks, so that sending knights into enemy territory to hopefully pillage buildings when their chance of winning any fight against interceptors is tiny... results in them fleeing or refusing to go
  • don't allow solo knights or even small numbers of knights to attack, require a minimum attack party size
  • to avoid "temporary road strategy", make creating roads take time and/or resources. Huge coding effort
  • only allow attackers (or interceptors) to attack from the highest threat level / shortest range, not from far away. This makes the entire threat level concept mostly pointless, but it always was anyway as only the highest really mattered much. This hides the immersion breaking effect of seeing your knights walk far across the map to attack/intercept while their resupply/garrison is stuck using roads. It might make more sense if the player borders corresponded to attack/intercept distance. If intercept distance is very short it means it isn't even possible to protect buildings in your territory unless they are extremely close to military buildings, while enemies are free to pillage them