After a series of try-and-error work, I found out the key codes (in other words, the difference between the new and old versions) to solve the healing problem for adventurer is:
TD.T_POSSESS.info = function(self, t)
local text = t.addon.possessor_fixes.orig_info(self, t)
-- Strip out the bit about limited body types. >;)
local idx = text:find('You may only steal the body of creatures of the following types:')
if idx then text = text:sub(1, idx-1) end
-- Add in current capacity of body storage.
if self.bodies_storage then local repl = ('new body in your storage (currently %d/%d).'):format(#self.bodies_storage, self.bodies_storage.max)
text = text:gsub('new body in your storage.', repl)
end return text
end
However, I cannot understand why this is the problem. As you can see this is not even related to removing healing preventer. So could you please explain what happend in the old version and how the problem is solved? Thanks.
Zizzo wrote:
wuxiangjinxing wrote:
The bodies storage problem you mentioned could be solved by learning Bodies Reserve before Possess.
Well, yeah, but I tripped over it often enough during testing, and we don't want to depend on the player doing that in the right order.
wuxiangjinxing wrote:
Besides, could you please spend some time explaining what you did? It may be a good opportunity for me to learn something in modding. Thanks.
Umm… okay? Most of what I did in this release involved modifying existing talents in place, which can be a bit tricky if you're not careful. So for instance, this is a rough mockup of two of the talent changes I made in this release:
Code:
-- We do our work in the ToME:load hook, after talent definitions have been
-- loaded.
class:bindHook('ToME:load', function(self, data)
local Talents = require 'engine.interface.ActorTalents'
-- This is where talent definitions are placed by the newEffect{} method.
-- It's indexed by the talent ID, which is usually "T_" followed by the
-- talent name in all caps, unless the talent definition specifies
-- something different.
local TD = Talents.talents_def
-- Destroy Body's on_pre_use() method [which, among other things, is used
-- to determine the highlighting of the talent icon on the hotkeys
-- toolbar, and thus can break stuff immediately if something goes wrong]
-- assumes the bodies_storage{} subtable is present. We modify it to
-- check first.
-- We keep the original method so we can call it from our new method. We
-- can get away with stowing it in a local variable because it doesn't
-- have to be persisted into the savefile.
local orig_destroy_body_on_pre_use = TD.T_DESTROY_BODY.on_pre_use
-- Now we replace it with our new method.
TD.T_DESTROY_BODY.on_pre_use = function(self, t, silent)
-- If we don't have a bodies storage, we obviously can't destroy
-- anything out of it. ;)
if not self.bodies_storage then
if not silent then
game.logPlayer(self, 'You do not have a bodies storage.')
end
return false
end
-- Now that we know bodies_storage{} is present, we can safely pass
-- through to the original method.
return orig_destroy_body_on_pre_use(self, t, silent)
end
-- Similarly, Bodies Reserve has a utility method hasRoom() that's used
-- in a couple places, and it also assumes bodies_storage{} has been set.
local orig_bodies_reserve_hasRoom = TD.T_BODIES_RESERVE.hasRoom
TD.T_BODIES_RESERVE.hasRoom = function(self, t)
-- In this case we can just check for bodies_storage{} and pass through
-- to the original method immediately.
return self.bodies_storage and orig_bodies_reserve_hasRoom(self, t)
end
end)