aliens

Author Topic: Funny story  (Read 2793 times)

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6374
  • Aaand we're back!
    • View Profile
    • My Wiki
Funny story
« on: February 13, 2020, 12:12:42 am »
While debugging one of the issues found during my current PirateZ LP:

Turn 7 - PLAYER
======================
1. "Abel the Bagel" kills last standing Lobsterman #1000010. There is one more stunned Lobsterman #1000012 on the ground with _health=64 and _stunlevel=72
2. OXCE decides it is game over and auto-ends player's turn.

Turn 7 - ENEMY
======================
3. Lobsterman #1000012 recovers 10 stun and wakes up at _health=64 and _stunlevel=62
4. Lobsterman #1000012 attacks "Ivana Banana" (grrrrrrrrrr!)

Turn 8 - PLAYER
======================
5. Lobsterman #1000012 takes 7 health-damage from fire and falls unconscious at _health=57 and _stunlevel=62
6. OXCE decides it is game over and auto-ends player's turn. LOL :)

Turn 8 - ENEMY
======================
7. Lobsterman #1000012 recovers 9 stun and wakes up at _health=64 and _stunlevel=53
8. Lobsterman #1000012 attacks "Ivana Banana" again (motherfucker!!!)

Turn 9 - PLAYER
======================
9. Lobsterman #1000012 takes 6 stun-damage from smoke and falls unconscious at _health=57 and _stunlevel=59
10. OXCE decides it is game over and auto-ends player's turn. For the 3rd time :) Poor Meridian can just watch helplessly :P

Turn 9 - ENEMY
======================
11. Lobsterman #1000012 recovers 8 stun and wakes up at _health=57 and _stunlevel=51
12. Lobsterman #1000012 attacks "Ivana Banana" yet again, but she still lives somehow...

Turn 10 - PLAYER
======================
13. Lobsterman #1000012 takes 15 stun-damage from smoke and falls unconscious at _health=57 and _stunlevel=66
14. OXCE decides it is game over and auto-ends player's turn. This is getting repetitive...

Turn 10 - ENEMY
======================
15. Lobsterman #1000012 recovers 9 stun and stays unconscious at _health=57 and _stunlevel=57 ... phew, that was close
16. Mission ends.
« Last Edit: February 13, 2020, 12:20:01 am by Meridian »

Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 202
    • View Profile
Re: Funny story
« Reply #1 on: February 13, 2020, 07:38:32 am »
Heh, I've experienced this kind of thing a few times.  Just curious, is this working as intended or do you have any plans to address this?  It just doesn't make sense that game decides the battle is over when the last non-surrendering unit is knocked out and then allows them to wake up and keep the battle going.  It is really annoying when other surrending units had just awoken and the player planned to stun them all but made the mistake of stunning the non-surrendering unit first and then auto-end turn prevents the player from stunning the rest.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5296
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: Funny story
« Reply #2 on: February 13, 2020, 01:43:05 pm »
Looks like something broke in the code... This thing never happened to me, and statistically, it should have - with many enemies unconscious after end of all missions, multiplied by 100 or 200 missions...

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6374
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Funny story
« Reply #3 on: February 13, 2020, 02:03:30 pm »
Just curious, is this working as intended or do you have any plans to address this?

The engine is working as intended, there is no direct bug.
The situation is a result of using non-vanilla user options (e.g. auto-end battle), heavy modding (high stun regen, high smoke vulnerability) and map being both on fire and covered in smoke :)
It could theoretically happen in OXC/xcom1 too, but it is a trillion times less likely.

There are several naive workarounds/hacks for this... but they all lead to other (sometimes even more serious) side effects... I won't go into details, I would need to explain too much.

The only remaining thing I am considering is redefining how the "Auto-end battle" option works, because it actually doesn't end the battle, it just ends the turn.
Which is not in line with its description:

Code: [Select]
  STR_BATTLEAUTOEND: "Auto-end battle"
  STR_BATTLEAUTOEND_DESC: "Battles automatically end when the last living enemy is neutralized."

What happens -- in normal case -- is:
1. Game detects no remaining aliens and requests end of player turn (same as if you clicked on End Turn button yourself)
2. Grenades explode
3. Unit stats (e.g. HP, stun, morale, etc.) get updated
4. Fatal wounds happen, units burn if on fire
5. Environmental conditions get applied (OXCE only)
6. Alien turn starts -- but ends immediately because there is no standing alien -- in normal case
7. Battle ends

In our case, all that happens too, but continues even further because 1 alien managed to stand up in the meantime...


If we would change the implementation of that user option from "end turn" to "end battle"... this would solve the issue.
But what is not clear is WHEN to end the battle...
... after point 1?
... after point 2?
... after point 5?
... somewhere else?

For example I think grenades in point 2 should still explode... but fatal wounds in point 4 should not happen anymore.
And here's the problem... everyone will have a different opinion... and there is no reference point in OG to compare against (since OG didn't have this feature at all).
« Last Edit: February 13, 2020, 02:05:43 pm by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6374
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Funny story
« Reply #4 on: February 13, 2020, 02:11:48 pm »
Looks like something broke in the code... This thing never happened to me, and statistically, it should have - with many enemies unconscious after end of all missions, multiplied by 100 or 200 missions...

We have changed (slightly) when the unconscious units wake up recently... to fix bugs with units waking up in the middle of the turn like this: https://www.twitch.tv/comradeberic/clip/PerfectIntelligentSheepFunRun?filter=clips&range=7d&sort=time

It could have increased the statistical probability a bit, hard to say... but it was definitely possible before too.

It's still VERY unlikely to happen to anyone...
« Last Edit: February 13, 2020, 02:27:33 pm by Meridian »

Offline R1dO

  • Colonel
  • ****
  • Posts: 301
    • View Profile
Re: Funny story
« Reply #5 on: February 13, 2020, 06:18:31 pm »
I would consider it a feature .. since it leads to good stories ;)

Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 202
    • View Profile
Re: Funny story
« Reply #6 on: February 13, 2020, 06:55:35 pm »
Well when I have experienced something like this, it usually involved having a bunch of academy drones along with other academy mooks in Piratez stunned via a combination of zapper, lasso, and/or stun baton.  Fire, smoke, and wounds generally weren't involved.  When I'd stunned or killed the last enemy which I didn't know was the last enemy, auto-end battle kicks in.  If I hadn't restunned all the previously defeated units prior to knocking down the last enemy and then a drone woke up after auto-end, the battle continued with the enemy's turn where those enemy units that had been standing on my turn would either run away or attack my units.  The drone that woke up however, wouldn't do a thing since I assume it had no TUs yet.  Then it would be my turn and now IIRC the drone would have full TUs available for reaction fire.  I would then chase down and restun all the other mooks before restunning the drone from behind and thus triggering auto-end.  And then of course another drone would wake up and this might go on for another 4 turns before finally all the drones stayed down and the battle ends.  I don't think I've experienced enemy units that get to move on the same turn as they woke up.

Was the lobsterman adjacent and facing Ivanana at step 3 when it woke up or did it get to run up to Ivana on step 4 to attack?

At any rate, I've learned to always restun everything that woke up if they are nearby if I can prior to dealing with what I think might be the last unit.

Offline WaldoTheRanger

  • Captain
  • ***
  • Posts: 83
    • View Profile
Re: Funny story
« Reply #7 on: February 13, 2020, 07:15:38 pm »

If we would change the implementation of that user option from "end turn" to "end battle"... this would solve the issue.
But what is not clear is WHEN to end the battle...
...
For example I think grenades in point 2 should still explode... but fatal wounds in point 4 should not happen anymore.
And here's the problem... everyone will have a different opinion... and there is no reference point in OG to compare against (since OG didn't have this feature at all).

I would say end it even before grenades explode. without the auto-end option on, you would be able to use the rest of your turn to move away from any remaining active grenades (in the fringe cases where some still remain on the field).

But i'd be fine with right after grenades also. just so long as fatal wounds aren't applied.

sounds like a poll would be a good idea.
« Last Edit: February 13, 2020, 07:17:11 pm by WaldoTheRanger »

Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 202
    • View Profile
Re: Funny story
« Reply #8 on: February 13, 2020, 10:05:35 pm »
Don't units normally wake up with 0 TUs?  Are there special units that wake up with full TUs?

I experimented in quick battle (extended 5.1 v2018-10-14, x-piratez 0.99j8) and stunned one of my units Boney Loli with stun baton.  On turn 2, if I did nothing but press end turn she would wake up on turn 3 with full TUs.  But if I hit (misses had no effect) another unit with the stun baton on turn 2, Boney Loli would wake immediately on turn 2 with 0 TUs.  I don't know if this idiosyncracy has been fixed in a later version.  Save attached at the start of turn 2, Boney Loli is unconscious. (at least when I load this save)

Edit:
I saw similar effects in debug mode with enemy units, although it's easy to accidently refill TUs.
« Last Edit: February 13, 2020, 10:09:54 pm by Rubber Cannonball »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6374
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Funny story
« Reply #9 on: February 13, 2020, 10:42:40 pm »
sorry, I'm not going to look at anything from year 2018

Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 202
    • View Profile
Re: Funny story
« Reply #10 on: February 14, 2020, 12:46:08 am »
Sigh, ok I'll try again.  Same behavior as my previous post above at least in regard to stun batons and friendly troops in version x-piratez v.k2 OXCE version 6.3.4 v2020-01-11 save attached.  I didn't try the enemy troops.  Note that I started with a new quick battle and did not load the save from the old version.

PS For some reason, I couldn't get the openxcom extended executable that came with the Piratez k2 mod archive to run so I overwrote just the executable with the latest one downloaded from the stickied download and installation guide thread and it worked though I wouldn't be suprised if that isn't sufficient as there are 3 items I can't seem to unload from the shadowbat in quick battle.  You'll see them in the save file on the item pile.

Edit:
figured out why I had to replace the .exe; it was 64 bit

Edit2:  Ok, tried out the enemy units and experienced same as before but also noticed something else.  Attached qbturn4.sav which can be loaded to demonstrate the immediate wake up effect on a friendly unit's successful hit with stun baton even if does 0 points stun.  In debug mode on the enemy's turn, the enemy unit will immediately wake up if an enemy unit fires a gun at a tree.  On player's turn 5, player's mind probe of just awoken enemy will show 0 TUs.  But if on enemy turn 4 no enemy fires his weapon, the stunned enemy unit will be awake on player's turn 5 but player's mind probe will show full TUs.  All other enemy units will show partial TUs left as expected.  So if the stunned enemy unit wasn't woken up by enemy attacks during the enemy turn it will have full TUs available for reaction fire on the player's turn 5.  If the stunned unit enemy unit was woken up by enemy attacks during enemy turn 4, it will have 0 TU and not be able to reaction fire on player's turn 5.  This appears to be a bug.
« Last Edit: February 14, 2020, 05:17:04 am by Rubber Cannonball »

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6374
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Funny story
« Reply #11 on: February 14, 2020, 10:59:40 am »
1. revive by medikit => no TU
2. revive by new turn => full TU

that's how it worked in OG and OXC too

3. (OXCE only) revive by damage/hit (e.g. explosion) => no TU


Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 202
    • View Profile
Re: Funny story
« Reply #12 on: February 14, 2020, 08:23:55 pm »
1. revive by medikit => no TU
2. revive by new turn => full TU

that's how it worked in OG and OXC too

3. (OXCE only) revive by damage/hit (e.g. explosion) => no TU

Very interesting,  points 1 and 2 are fine.  But for point 3, doesn't the unit being revived need to be the unit that is being damaged, hit, or caught in the blast radius?  Why does a unit get to awaken middle of turn when the unit's stun level did not change in the middle of the turn nor was it hit by anything in the middle of the turn?  By middle of turn, I mean during the middle of the unit movement phase of the turn.

If point 3 means any damage to anything anywhere including even a bullet striking a wall, I think enemy units with built in weapons, e.g. academy drones, are getting screwed.  Why does the enemy drone not get to reaction fire on the player's turn just because the drone's teammate fired a bullet into a wall on the other side of the map nowhere near the drone?  Had the drone's teammate not fired, the enemy drone would have had full TUs available for reaction fire on the player's turn.

PS.  I don't mean to be a PITA and I do appreciate the time you put in to this.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6374
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Funny story
« Reply #13 on: February 14, 2020, 08:39:15 pm »
First of all, why we even do it: in OXC, damage can only do damage... in OXCE, damage can also "reverse damage", i.e. increase HP or decrease stun... thus we need to revive too

Second, we check all units (not just the hit ones)... because such procedure already exists and is easy to use... and in all normal cases, it should have the same result as reviving only hit units.

Third, there is a bug in OXC that units don't get revived even if they should... this doesn't happen much in OXC, because there are not so many ways to get revived... but it happens a lot more in OXCE, which has many more ways of units getting revived. This was recently fixed (few weeks ago: https://github.com/MeridianOXC/OpenXcom/commit/df27d66e4a2ef74dddc7399424c9ae8caf42e67f)... and you should now see a lot less "late revivals", if any.

In your save for example, unit "Boney Loli" is technically not stunned anymore (health > stunlevel)... it just didn't realize it yet... which was/is an OXC bug.

Code: [Select]
    - id: 5
      genUnitType: SOLDIER
      genUnitArmor: STR_BASIC_ARMOR_UC
      faction: 0
      status: 7            # <-------------------- unconscious
      wantsToSurrender: true
      isSurrendering: false
      position:
        - 4
        - 33
        - 1
      direction: 3
      directionTurret: 0
      tu: 46
      health: 61           # <-------------------- but not unconscious
      stunlevel: 56        # <--------------------
      energy: 55
      morale: 100
      kneeled: false
      floating: false

Offline Rubber Cannonball

  • Colonel
  • ****
  • Posts: 202
    • View Profile
Re: Funny story
« Reply #14 on: February 14, 2020, 09:52:51 pm »
First of all, why we even do it: in OXC, damage can only do damage... in OXCE, damage can also "reverse damage", i.e. increase HP or decrease stun... thus we need to revive too

I expected that to be the whole point of the revive by damage.
Second, we check all units (not just the hit ones)... because such procedure already exists and is easy to use... and in all normal cases, it should have the same result as reviving only hit units.

Third, there is a bug in OXC that units don't get revived even if they should... this doesn't happen much in OXC, because there are not so many ways to get revived... but it happens a lot more in OXCE, which has many more ways of units getting revived. This was recently fixed (few weeks ago: https://github.com/MeridianOXC/OpenXcom/commit/df27d66e4a2ef74dddc7399424c9ae8caf42e67f)... and you should now see a lot less "late revivals", if any.

Ok, so the middle of turn unexpected revivals will be much rarer in the next OXCE version.

First of all, why we even do it: in OXC, damage can only do damage... in OXCE, damage can also "reverse damage", i.e. increase HP or decrease stun... thus we need to revive too

Second, we check all units (not just the hit ones)... because such procedure already exists and is easy to use... and in all normal cases, it should have the same result as reviving only hit units.

Third, there is a bug in OXC that units don't get revived even if they should... this doesn't happen much in OXC, because there are not so many ways to get revived... but it happens a lot more in OXCE, which has many more ways of units getting revived. This was recently fixed (few weeks ago: https://github.com/MeridianOXC/OpenXcom/commit/df27d66e4a2ef74dddc7399424c9ae8caf42e67f)... and you should now see a lot less "late revivals", if any.

In your save for example, unit "Boney Loli" is technically not stunned anymore (health > stunlevel)... it just didn't realize it yet... which was/is an OXC bug.

I'm actually surprised you bothered to look at that one since it was from an older version.  qbturn4.sav had both a friendly and an enemy unit (in this case a PCM not a drone) ready to awaken.

So with the fix thats been committed, if qbturn4.sav is loaded with a freshly compiled OXCE will the PCM have full TUs when the player mind probes him on turn 5 or no TUs or will that still depend on whether an enemy unit shoots or not?  Note, I'm not concerned with the unconscious gal.

As for the save file snippet you attached, I was guessing that the stats didn't change mid turn but instead that the program hadn't gotten around to standing the unit up.

Finally, with regards to your original post and your question in your next post, perhaps auto-end battle should be replaced with a pop up stating something like "no standing or undefeated enemies left press end turn when ready."  Now the player can decide whether he wants to do anything more like move away from grenades, heal units, etc before pressing end turn.  He will know he doesn't have to keep scouting for enemy, so it will speed up the end of the battle.  I have no problem if it actually takes 4 more turns before the battle ends, the player will still be able to do things each turn if he wants to instead of watch helplessly as the enemy units recover and slaughter his squad.  In the simple case, all he has to do after he sees the pop up is press end turn and the battle ends.  It still speeds up the battle end, usually.