Page 1 of 1

[1.4.8] damage type values expected to be of type "number"

Posted: Thu Oct 06, 2016 5:23 pm
by Munin
In mod/class/object.lua the two functions

Code: Select all

getTextualDesc()
and

Code: Select all

getPriceFlags()
expect damage type values to be of type

Code: Select all

number
and will crash if it is a

Code: Select all

table
I fixed this locally by simply adding:

Code: Select all

local type_of_v=_G.type(v[1])
local tmp_v=0
if type_of_v=="number" then tmp_v=v[1]
elseif type_of_v=="table" then
--[[ MIND, WINTER, ARCANE_SILENCE, FIREBURN, FIRE_STUN, GOLEM_FIREBURN, FIRE_DRAIN, FLAMESHOCK, ICE, ICE_SLOW, COLDNEVERMOVE,
LIGHTNING_DAZE, WAVE, BLOODSPRING, FIREKNOCKBACK, FIREKNOCKBACK_MIND, DARKKNOCKBACK, SPELLKNOCKBACK, PHYSKNOCKBACK,
POISON, SPYDRIC_POISON, CRIPPLING_POISON, INSIDIOUS_POISON, SLIME, CONFUSION, RANDOM_CONFUSION, RANDOM_CONFUSION_PHYS,
RANDOM_BLIND, SAND, PINNING, DRAINEXP, DRAINLIFE, DRAIN_VIM, CORRUPTED_BLOOD, GRAVITY, GRASPING_MOSS, NOURISHING_MOSS,
SLIPPERY_MOSS, HALLUCINOGENIC_MOSS, IMPLOSION, CLOCK, WASTING, RETHREAD, DEVOUR_LIFE, CHRONOSLOW, RIGOR_MORTIS,
ABYSSAL_SHROUD, LEAVES, DISTORTION, DREAMFORGE, MUCUS, ACID_DISARM, ACID_CORRODE, BOUNCE_SLIME, CAUSTIC_MIRE, TK_PUSHPIN,
DIMENSIONAL_ANCHOR, STATIC_NET, BLIGHT_POISON
]]--
	if v[1].dam then tmp_v=v[1].dam
-- FREEZE
	elseif v[1].hp then tmp_v=v[1].hp
-- FEARKNOCKBACK
	elseif v[1].dist then tmp_v=v[1].dist
-- BREAK_STEALTH, BLINDCUSTOMMIND
	elseif v[1].power then tmp_v=v[1].power
-- SILENCE
	elseif v[1].power_check then tmp_v=v[1].power_check
-- CONGEAL_TIME
	elseif v[1].slow then tmp_v=v[1].slow
-- WEAKNESS
	elseif v[1].incDamage then tmp_v=v[1].incDamage
-- RANDOM_WARP
	elseif v[1].apply_power then tmp_v=v[1].apply_power
	end
end
This is sub-optimal, but works for vanilla ToME 1.4.8.
There're probably other places that need to be changed as well but I haven't triggered them yet.


I also changed

Code: Select all

getPrice()
in the same file by adding this line as the first:

Code: Select all

if self.__price_level_mod and self.__price_level_mod==0 then return 0 end
This because I made an artifact that is not supposed to give any money when sold or transmogrified, and the calculated value would be 'discarded' by

Code: Select all

base = base * self.__price_level_mod
at the end of the function anyway.
(the game seems not to be made with cursed items in mind - I haven't found a way yet to allow unequipping only after criteria are met)