(fixed) crash at collision

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

(fixed) crash at collision

Post by Joramun »

LUA ERROR: Lua Function sys_base_impact: base/system.lua:63: Invalid instance 1064

I thrown a shuriken at a mummy inside "Creature Cavern" in DM.
They had no exvar or inventory whatsoever.
Id : RTC_2186, RTC_2187 and RTC_2188 in dm/dungeon.lua
What Is Your Quest ?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Fixed.

The problem was that it was trying to put the projectile in the monster's inventory (getting "stuck," as it were), but the monster was already dead. This was happened due to Lua using floating point numbers internally.

The code was, roughly:

Code: Select all

damage = calculate_damage()
hp = hp - damage
dsb_set_hp(monster, hp)
if (hp > 0) then
  -- put projectile in monster's inventory
end
So, if it ended up that hp was between 0 and 1, it would evalulate down to 0 for the dsb_set_hp but it would be > 0 and try to get put in the inventory.
Post Reply