#2749 closed enhancement (fixed)
[PATCH] Ceasefire
Reported by: | Stan | Owned by: | sanderd17 |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
Currently you can't set a time for the players to be unable to attack each others. I used to play with that on other games and I found it interesting, cause you have a stronger economy and you can make more interesting battles.
It's not really needed so nice to have.
How I see it :
_ Buttons on the game setup menu (15-25-45min) _ A Timer near the FPS counter with the time remaining _ Complete inability to attack your enemy (This should be a different state than ally cause no shared vision, and no winning if both on the same team.
Attachments (9)
Change History (27)
comment:1 by , 10 years ago
Component: | Core engine → UI & Simulation |
---|
comment:2 by , 9 years ago
Summary: | [GAMEMODE] Peace Time → Ceasefire |
---|
comment:3 by , 9 years ago
According to leper and sanderd17, the best way to implement this is to make all players neutral for that time and to prevent neutral players from attacking each other (like allies).
Some relevant code: GuiInterface::1742 and Capturable::67,77,119.
by , 9 years ago
Attachment: | t2749_prevent_neutral_players_from_attacking_each_other.patch added |
---|
Implemented that neutral players can't attack each other with the code changes suggested by sanderd17 above. Tested and boats, CCs and units won't attack and can't start capture attacks. As soon as one sets the neutral player to enemy, both diplomacy states will be reset to enemy and attacks start immediately. Not sure about the distribution of capture points though.
by , 9 years ago
Attachment: | t2749_ceasefire_v1.patch added |
---|
comment:4 by , 9 years ago
Keywords: | patch review added |
---|---|
Milestone: | Backlog → Alpha 19 |
Priority: | Nice to Have → Should Have |
Summary: | Ceasefire → [PATCH] Ceasefire |
comment:5 by , 9 years ago
Description for the patch above:
Logic: -When ceasefire starts, all enemies will be set to neutral. -Neutral players can't attack each other. -While ceasefire is active, you can tribute resources, but not change the diplomacy or request allied attacks. -When ceasefire ends, all earlier enemies will be set back to enemy and the diplomacy options are enabled again. -When reporting the game to the wildfiregames server, report ceasefiretime too.
New Options: -An option in the gamesetup allows you to chose the ceasefire timeout in minutes (0, 5, 10, 15, 20, 30, 45, 60). This option will be saved correctly with persist match settings. For quick debugging, a 15 second ceasefire timeout has been added. -In the game settings, there is an other option that enables an overlay counter.
Countdown Messages: -While ceasefire is active, an optional overlay counter will be displayed at the top right. -For the last 10 seconds, a message will appear in the middle of the screen ("Ceasefire will end in %(time)s") -When ceasefire stops, another message will appear for 5 seconds ("Ceasefire has ended!") -In the diplomacy tab, a counter will be displayed too ("Time remaining until ceasefire is over: %(time)s.")
Tests -Tested with r16605. -Works with teams locked. -Works if a player resigns before ceasefire has ended.
Open questions
The code should be refactored and moved into a single component CeasefireManager, since StartCeasefire (in LoadPlayerSettings in the player component) and GetCeasefireTime (in GetSimulationState in GuiInterface) must be called for only one player (currently the last player).FIXED- Why is displaying the chat notification ("You have declared war on player X") slow? They immediately start fighting after ceasefire ended, but the chat messages take a while.
- This patch cleans some code in gamesetup.js for scenario maps. Maybe add a ceasefire option to atlas and let scenario maps determine the ceasefire timeout?
- Send a message when the ceasefire starts / ends? Maybe the AI can use it.
This patch will fix #3195 too :-)
by , 9 years ago
Attachment: | t2749_ceasefire_v2.patch added |
---|
comment:6 by , 9 years ago
Patch works for r16614.
-Refactored. Moved the ceasefire code to a new component called CeasefireManager. -Should support activating ceasefire multiple times (will extend ceasefire then). -Simplified loops using GetAllPlayerEntities()
Notice that gaia doesn't abide ceasefire.
Tested with two instances of 0ad, one host and client. Tested rejoining too and surprisingly no oos on rejoin.
by , 9 years ago
Attachment: | topright_corner.jpg added |
---|
The following patch will also move the fps + ceasefire counter and ingame + realtime overlay to the right, so that all tech upgrades are displayed properly.
by , 9 years ago
Attachment: | t2749_ceasefire_v3.patch added |
---|
comment:7 by , 9 years ago
The third version of the patch has the following changes:
[x] AI doesn't attack anymore before ceasefire is over (At least in all my testcases) [x] Chat messages slow (cause identified and patch attached #3222) [x] "You are now at war with player X" was shown for allies, not enemies. [x] Moved all overlays (fps, ingame time, realtime, ceasefire countdown) see http://trac.wildfiregames.com/attachment/ticket/2749/topright_corner.jpg [x] Sends an internal message when ceasefire starts or stops. Will probably be needed for AI. [x] using cmpTimer.GetTime() instead of GetSimState().timeElapsed [x] changed "Ceasefire has ended" message to "You can attack now" (the other message accordingly) [x] fixed missing semicolons [x] updated wrong comment in CeasefireManager.js L49
With this patch I couldn't reproduce the issue that the last patch had, where chat messages don't appear at all. With this version they appeared in each of my tests.
by , 9 years ago
Attachment: | t2749_ceasefire_v3.2.patch added |
---|
comment:9 by , 9 years ago
Keywords: | review removed |
---|
by , 9 years ago
Attachment: | t2749_ceasefire_cleanup.patch added |
---|
(1) Shows ceasefire message for observers; (2) fixes GuiInterface test error caused by missing CeasefireManager; (3) cleans some code in CeasefireManager.
by , 9 years ago
Attachment: | t2749_ceasefire_cleanup_v2.patch added |
---|
Same patch as the other cleanup before, but also does more simplifications, (4) remove two unused variables and (5) removes some unneeded brackets.
comment:10 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopened as the test is currently broken. The patches above fix it and clean the code as well.
comment:11 by , 9 years ago
Keywords: | review added |
---|
comment:12 by , 9 years ago
I think the IsOwnedByNeutralOfPlayer check in UnitAI.prototype.CanAttack should be removed as well, since neutral players aren't supposed to be able to attack each other.
comment:13 by , 9 years ago
Before its forgotton i post it here:
(19:36:09) sanderd17: mimo, I think it's safe to remove the IsNeutral* from (UnitAI.js) 5586, and change 5588 to IsOwnedByAlliedPlayer. That would make neutral players only attackable when they attacked, and not make allied players attackable.
comment:16 by , 9 years ago
Keywords: | review removed |
---|
by , 9 years ago
Attachment: | t2749_ceaefire_add_3minute_limit.patch added |
---|
Adds another ceasefire timeout option (3 minutes).
Probably better phrased as ceasefire.
Also see #77.