Unciv icon indicating copy to clipboard operation
Unciv copied to clipboard

Exploit with pillage and repair tile improvement on enemy's lands

Open NoobTutorial opened this issue 1 year ago • 19 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Game Version

Current from flatpak, Gods and Kings

Describe the bug

At first, thanks for authors/developers for this great game. I found now how I can cheat opponents with some sort of bug. Workers can repairs looted improvements on enemy's land. And player can use it as infinite heal resource for battle units.

Steps to Reproduce

  1. Go to battle or siege on enemy land, move syncronously your workers on same tiles where you move your warriors. These tiles must have improvements for looting.
  2. When your warrior takes damage – loot the improvement on tile where warrior stays. Warrior takes some heal. This is normal game logic.
  3. But, next starts some sort of cheating: give an order to worker to repair the improvement under warrior. It takes 1 turn only, so on next turn you can heal warrior one more time.
  4. Repeat this combination as many times as possible. Your warriors become forever healed while he stays on tile with improvement, and worker with him. Opponent can't kill workers, he can only try to kill virtually immortal warriors.
  5. In most cases you can do this indefinitely. Beat the opponent's unit, take some damage – heal – repair source of healing.

Screenshots

No response

Link to save file

No response

Operating System

Linux

Additional Information

Of course, this cheat only works if your workers can repair looted improvements in 1 turn. Though, they do this in 1 turn in most cases.

I think there should be some restrictions for such cheat. For example, workers can't repair improvements on enemy land. Or should the repair take more than 1 turn in time.

NoobTutorial avatar Feb 22 '24 06:02 NoobTutorial

The word "loot" has a meaning in Unciv elsewhere. This is "pillage". And "in sieges and battles" has no relevanve to the issue, not really. And "exploit" is a clearer term than cheating. Still, there are much more confusing issue titles...

That said, I'm pretty sure it's simply - pillage should not be allowed in enemy land, and I'm also pretty sure it must be a recent regression... Might investigate later.

SomeTroglodyte avatar Feb 22 '24 13:02 SomeTroglodyte

Pillage should be allowed only in enemy land! The repair should be limited, and I thought it was, we'll need to check this

yairm210 avatar Feb 22 '24 14:02 yairm210

I can confirm that it's possible to repair lands outside of your own borders. I take advantage of this to fix tile improvements in city-state territory if someone has been pillaging my allies, but it is also possible to repair tiles in enemy territory, allowing for endless pillaging.

SpacedOutChicken avatar Feb 22 '24 16:02 SpacedOutChicken

pillage should not be allowed in enemy land

Definitely a fumble. Meant repair.

I can confirm that it's possible

As in - current Unciv, older Unciv, or original Civ5?

I'd say: Pillage in any friendly (owned by anybody not at war with) - NO, pillage in unowned - ??? tend to yes, pillage in enemy - YES. Repair in own - YES, repair in friendly (including allied and neutral CS, or open borders???) - yes, repair in neutral - no, repair in enemy - NO.

SomeTroglodyte avatar Feb 22 '24 16:02 SomeTroglodyte

As in - current Unciv, older Unciv, or original Civ5?

Current Unciv. I don't know if it works in the original Civ V.

Repair in own - YES, repair in friendly (including allied and neutral CS, or open borders???) - yes, repair in neutral - no, repair in enemy - NO.

I can think of one case where you'd want to repair improvements in neutral territory: if you've got a road outside your borders and someone pillages it, you should be able to fix it. This might also apply to forts and roads within enemy territory, because you want to be able to fix those for your own sake.

SpacedOutChicken avatar Feb 22 '24 16:02 SpacedOutChicken

you'd want

Wishful thinking should not control the rules. Certainly, we can make it so. But for Unciv, reusing the balancing decisions of the original - and simplicity are also factors. See this issue - things go wrong too easily with complexity. Or should we make every aspect of this moddable through OnlyAvailable uniques with arbitrary conditionals as much as you want? Should be possible. Volunteers to do the coding? Warning: Initial effort estimate: coding 1% testing 11% finding all edge cases and ironing them out 111%...

Heh, now I want to buy a brooklyn bridge from the queen of england....

SomeTroglodyte avatar Feb 22 '24 17:02 SomeTroglodyte

At the very least, since it is possible to build roads and forts in neutral territory, it should be possible to maintain roads and forts in neutral territory. If you have to do so by building a new road or fort, that's fine, as long as you have some way of fixing things. I think that's both fair and realistic.

As for fixing pillaged improvements in enemy territory, it makes sense to disallow that, but would doing so complicate the code for the repair action?

SpacedOutChicken avatar Feb 22 '24 17:02 SpacedOutChicken

build ability = maintain ability

Good argument. Also strengthens the argument for Forts&Roads to have/be-allowed-to-have different pillage/repair rules vs Farms to Academies...

would doing so complicate the code

No idea at the moment - consensus is more important, my gut feeling just tends to "no" (no repair in hostile, no matter what) but could be wrong. As for what's a good balance of efficient, "KISS", and logical - would need to dig in, not relaxed enough right now.

SomeTroglodyte avatar Feb 22 '24 20:02 SomeTroglodyte

The word "loot" has a meaning in Unciv elsewhere. This is "pillage". And "in sieges and battles" has no relevanve to the issue, not really. And "exploit" is a clearer term than cheating. Still, there are much more confusing issue titles...

@SomeTroglodyte Excuse me for mistakes, english not my native language, I only try to describe situation in a few words. Of course, it's pillage, not looting. Yeah, it's not a clear bug, maybe exploit would be a good term. But there was no variant "exploit" when i created the issue.

NoobTutorial avatar Feb 23 '24 04:02 NoobTutorial

As in - current Unciv, older Unciv, or original Civ5?

@SomeTroglodyte, I don't remember I could use such exploit in original Civ5 (or Civ4/3/2/1).

NoobTutorial avatar Feb 23 '24 04:02 NoobTutorial

OK, time to code this, weekend and release approaching:

Simplest common denominator?

  • Block repair altogether in enemy land.

Desirable but could get complicated?

  • Block repair in enemy land if and only if the improvement has a tangible benefit through a set of uniques: PillageYieldRandom, PillageYieldFixed, and a newly to be created one that backs the currently hardcoded healing effect...

Volunteers? Use 'assign yourself' top right.

@NoobTutorial - good first issue!

SomeTroglodyte avatar Feb 23 '24 13:02 SomeTroglodyte

I think you can only see that because of your repo privilege 😜 A comment will suffice :)

yairm210 avatar Feb 23 '24 13:02 yairm210

🙈 of course assignments are collaborator-level.... But with our coder shortage, isn't there only one coder left without, Oscar?

SomeTroglodyte avatar Feb 23 '24 14:02 SomeTroglodyte

...Still, if I'm still awake after my soup, my movie, my 666 miles on bike, and a summit or two - you might see someone assigned up there.

SomeTroglodyte avatar Feb 23 '24 14:02 SomeTroglodyte

Looked into it, and there's too much stuff that puzzles me.. But at least it looks like @SpacedOutChicken 's argument "should be able to repair what I can build" should be no harder than my simple "no repair in hostile land".

  • Why does MapUnit.canBuildImprovement check for repair from the improvementInProgress and not its improvement parameter? Like - "yes, Legionary, you can build a Farm here, because you have any BuildImprovements unique and on the Tile there's currently a Mine being repaired???"
  • Looking through call trees shows that some automation code does not go through UnitActionType.Repair... But that would be the place to lay down these rules??? Example: automateConnectRoad - is it possible there are more?
  • Why does automateImprovementPlacer not return the success or failure of invokeUnitAction to its caller?

Otherwise, looks like one or two of the commented clauses, likely the improvementFunctions one, in the following:

        val damagedImprovement = tile.getTileImprovement() ?: return null
        val couldConstruct = unit.currentMovement > 0
            && !tile.isCityCenter()
            && tile.improvementInProgress != Constants.repair
            && !tile.isEnemyTerritory(unit.civ)  // Simple allow repair in friendly or neutral land only ??
            && tile.improvementFunctions.canBuildImprovement(damagedImprovement, unit.civ)  // Does enemy land checks through the improvement's uniques - would allow repairing forts ?? Also includes isCityCenter check
            && unit.canBuildImprovement(damagedImprovement)  // Only repair the kinds of improvements we can build from scratch ?? canBuildImprovement looks like that's not intended..

...? Also, I haven't got any saves allowing to test this!

SomeTroglodyte avatar Mar 01 '24 10:03 SomeTroglodyte

@SomeTroglodyte, or maybe simply just checking tile.isEnemyTerritory(unit.civ) — and if its true — add some value to the number of turns required to repair the improvement. Of course, the number of turns added should depend on the difficulty level of the game, the speed of the game, and so on. Maybe, add a method like .getTileRepairImprovementCostTurns(tile) which returns correct value.

Over the days, I've played at different difficulty levels and game speeds. And I'll say this: even if a worker can fix an improvement in 2 turns (at the epic speed of the game), this already complicates the use of the exploit.

My main idea is not to remove the possibility of this exploit altogether, but to make the bonus of using it insignificant.

NoobTutorial avatar Mar 01 '24 16:03 NoobTutorial

add some value to the number of turns required to repair the improvement

That's mod territory. We try to be faithful to some original somewhere... Only for this there's no clear sources, or are there? Hey, come to think of it, a few hours of digging in the dll sources might turn up something clear. IIRC, Unciv had 2-turn repairs long ago, so someone must have successfully argumented that was not the Civ5 way - if you find that please link.

The rest is compromising on that faithfulness and implementation detail...

Letting mods decide who can repair what where in what time - could require some new UniqueTypes...

SomeTroglodyte avatar Mar 01 '24 17:03 SomeTroglodyte

That's mod territory. Letting mods decide who can repair what where in what time

@SomeTroglodyte, from this point of view — agree and support such decision.

I've dig into undocumented Civ5 features and found that, really, worker in original Civ could repair improvements on enemy territory. Proof on Russian forum https://www.strategium.ru/forum/topic/51753-nedokumentirovannyie-osobennosti-igryi-v-tsiv5/, that's quote:

  1. Рабочие могут чинить улучшения на чужой территории. То есть, имея пирамиды+политику из воли, можно каждый ход на стандартной скорости чинить улучшение, его тут же грабить и восстанавливать по 25 хп. И ещё останутся очки движения, чтобы пострелять по городу, например.

translation:

  1. Workers can repair improvements on someone else's territory. That is, having pyramids + a policy of will, you can fix an improvement every turn at standard speed, immediately rob it and restore it by 25 hp. And there will still be movement points to shoot around the city, for example.

Now i have clear understanding this exploit was part of original mechanic of the game. So, changing this is really modder's territory.

NoobTutorial avatar Mar 02 '24 13:03 NoobTutorial

OK, if this exploit was part of Civ5 - open to discussion, but I would vote fix it anyway = allow repair only where you could build the thing from scratch.

But - that link talks about BNW, and some parts (me no russkiy read) sound like they contain info that may point out other deviations of our rules from the original... Ruins no Faith until turn 20? Maybe we have that. Gifted Great People? I'm sure ours are more frequent. Then again - BNW, at least some city-state quest rules will be different from G&K which we emulate. Care to analyze and make a List of what may be worth checking?

SomeTroglodyte avatar Mar 02 '24 14:03 SomeTroglodyte