Announcement: Be excellent to each other.


Caravel Forum : DROD RPG Boards : RPG Bugs : Problem with changing enemy HP during combat
New Topic New Poll Post Reply
Poster Message
hyperme
Level: Smitemaster
Avatar
Rank Points: 1485
Registered: 06-23-2006
IP: Logged
icon Problem with changing enemy HP during combat (+2)  
Here is a script:

Label 1
  Set var "_MyATK" = 11
  Set var "_ATK" + 10
  Set var "_MyHP" = 1000
  Each defend 1


This results in an enemy that takes a while to kill, and at the end of combat the player will have around 1000 ATK.

However, this result only occurs if you let the combat rounds play out. If you have the fastest combat speed, or skip to the end of the combat at any point, it plays out as if the HP changes don't happen. Even more strangley, if you do an "instant" combat and undo after making some moves, your stats stay consistent. But if you have a less than instant combat speed, your stats will correct to reflect doing the entire combat.

This is bad because it means the UI can affect how the actual game logic runs.

EDIT: This is the tip of the iceberg for a lot of terrible problems you can cause by changing stats during combat. oh no.

____________________________
[Insert witty comment here]
Qzvlkx?

[Last edited by hyperme at 05-08-2025 08:35 PM]
05-08-2025 at 08:02 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
hyperme
Level: Smitemaster
Avatar
Rank Points: 1485
Registered: 06-23-2006
IP: Logged
icon Re: Problem with changing enemy HP during combat (+1)  
Here is another script:

  Each attack 1
  Set var "_MyDEF" = 1000
  Set var "_MyATK" = 20
  Set var "_MyHP" = 1000
Label 1
  Set var "_HP" = 1000


If you don't have enough ATK to damage the NPC, this creates an endless combat. You can undo out of it, unless you're at the fastest combat speed, or try to skip the combat. That causes the game to hang.

This is obviously less than ideal. Unfortunately, it's impossible to determine if a combat involving stat changes will end (the halting problem strikes again). So there needs to be some "good enough" way to decide that a combat has gone on for an unreasonable amount of time. When such a combat is ended, it should probably undo the move that lead to it, with a message.

____________________________
[Insert witty comment here]
Qzvlkx?
05-09-2025 at 10:11 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Chaco
Level: Smitemaster
Rank Points: 3764
Registered: 10-06-2005
IP: Logged
icon Re: Problem with changing enemy HP during combat (+2)  
hyperme wrote:
Unfortunately, it's impossible to determine if a combat involving stat changes will end (the halting problem strikes again). So there needs to be some "good enough" way to decide that a combat has gone on for an unreasonable amount of time. When such a combat is ended, it should probably undo the move that lead to it, with a message.

I'd probably settle for something like "if, on the Nth time the player is about to attack the NPC (N = 20 or 50 or something appropriate), the NPC still has HP that is >= their original HP just as this combat started, combat should be auto-ended". That would at least handle HP regeneration.

The player's attack being reduced to 0 (or less than the NPC's defense) mid-combat is the only other "delayed infinity" problem I can think of at the moment, everything else should probably result in the player dying eventually.

____________________________
Quick links to my stuff (in case you forgot where it was):
Click here to view the secret text

05-09-2025 at 04:18 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Dragon Fogel
Level: Smitemaster
Rank Points: 2805
Registered: 06-21-2014
IP: Logged
icon Re: Problem with changing enemy HP during combat (+3)  
Well, there's also the case of an overly elaborate and highly chaotic script, such as "change attack based on defense the previous step, then change defense based on attack the previous step" or "increment a variable on each attack, do different things depending on the value of the variable" or "attempt to implement a random number generator so that attacks do highly volatile damage and sometimes miss". Not sensible to do at all, but I think it's technically possible and it would be extremely hard to predict if combat would end.

So we're basically asking "what's the failsafe if some foolish architect actually does this", and I think the best answer I can suggest is to track the number of attacks needed to win at current stats, and recalculate when a stat change happens mid-combat. Then track the number of times it increases or stays the same (normally it should be decreasing by 1 each attack), and if it goes above some threshold, either the combat isn't getting anywhere or the process is needlessly complex.
05-09-2025 at 05:02 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
greenscience
Level: Master Delver
Rank Points: 168
Registered: 02-27-2015
IP: Logged
icon Re: Problem with changing enemy HP during combat (+1)  
Chaco wrote:
The player's attack being reduced to 0 (or less than the NPC's defense) mid-combat is the only other "delayed infinity" problem I can think of at the moment, everything else should probably result in the player dying eventually.
This can happen when using custom equipment with the Surprised from behind behavior without additional scripting.
05-09-2025 at 09:04 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
Someone Else
Level: Smitemaster
Avatar
Rank Points: 2393
Registered: 06-14-2005
IP: Logged
icon Re: Problem with changing enemy HP during combat (+1)  
My suggestion is super simple: every 100 turns, check that one combatant's HP has decreased (or ATK - Enemy DEF has increased) since the last time you checked.

This will nearly always terminate (because it uses integers), but it won't get tripped up by weird scripts that aren't chaotic, and it has the benefit of not being complex and not being likely to end fights that the player knows will terminate in a win.

[Last edited by Someone Else at 05-09-2025 09:19 PM]
05-09-2025 at 09:15 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5437
Registered: 02-04-2003
IP: Logged
icon Re: Problem with changing enemy HP during combat (0)  
PR (thanks, hyperme!)
05-12-2025 at 08:28 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD RPG Boards : RPG Bugs : Problem with changing enemy HP during combat
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.9
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.