[Ohrrpgce] [ohrrpgce/ohrrpgce] Enemy spawned with 0 HP appears with sprite of dead enemy / disagreements about what enemies exist/are alive (#1221)

Ralph Versteegen notifications at github.com
Tue Sep 28 17:47:38 PDT 2021


If an enemy is spawned starting with 0 HP or die-without-boss, then loadfoe will partially initialising the enemy, then stops and calls `dead_enemy` before setting the sprite or many other things. As a result, if there was previously an enemy in the same slot it reappears with its old sprite. guo sent me a testcase (the battle ends the moment the enemy spawns, and it sticks around during victory) but we should be able to create a simpler one.

`dead_enemy` marks the formation slot as empty with `formdata.slots(enemynum).id = -1`, but few places in the code check `slots(...).id` to determine whether a hero/enemy exists, more commonly they check `.vis` and/or `.dissolve`. I can see a couple simple ways to fix this specific sprite problem, but that doesn't fix the underlying problem, that the code is incredibly inconsistent about which enemies exist or are alive, so there are probably other symptoms. Heroes are even worse!

```
SUB loadfoe(...)
   loadenemydata .enemy, formdata.slots(slot).id, YES

   setup_non_volatile_enemy_state bspr
   reset_enemy_state bspr

   '--Special handling for spawning already-dead enemies
   IF allow_dead = NO THEN
    'enemies which spawn already-dead should be killed off immediately
    'die without boss or 0 hp?
    IF dieWOboss(4 + slot, bslot()) OR .enemy.stat.hp <= 0 THEN
     'rewards and spawn enemies on death
     'enemy is only partially constructed, but already have everything needed.
     dead_enemy 4 + slot, -1, bat, bslot(), formdata
     EXIT SUB
    END IF
   END IF

   setup_enemy_slice bspr, bat

   '--Position
   .basepos = formdata.slots(slot).pos
   ...
```

Related to #663 (that bug isn't about enemies which start dead), #975,  #43,  #1007

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/ohrrpgce/ohrrpgce/issues/1221
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20210928/44b563d2/attachment.html>


More information about the Ohrrpgce mailing list