actor_binder:reinit()
function actor_binder:reinit()
object_binder.reinit(self)
local npc_id = self.object:id()
db.storage[npc_id] = { }
self.st = db.storage[npc_id]
self.st.pstor = nil
self.next_restrictors_update_time = -10000
self.object:set_callback(callback.inventory_info, self.info_callback, self)
self.object:set_callback(callback.article_info, self.article_callback, self)
self.object:set_callback(callback.on_item_take, self.on_item_take, self)
self.object:set_callback(callback.on_item_drop, self.on_item_drop, self)
self.object:set_callback(callback.trade_sell_buy_item, self.on_trade, self) -- for game stats
--self.object:set_callback(callback.actor_sleep, self.sleep_callback, self)
self.object:set_callback(callback.task_state, self.task_callback, self)
--self.object:set_callback(callback.map_location_added, self.map_location_added_callback, self)
self.object:set_callback(callback.level_border_enter, self.level_border_enter, self)
self.object:set_callback(callback.level_border_exit, self.level_border_exit, self)
self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)
self.object:set_callback(callback.use_object, self.on_use_item, self)
end
-- new method, will be called every time you use item in inventory
function actor_binder:on_use_item(obj)
item_usage.on_use_item(obj)
end
local items =
{
bread = "food",
kolbasa = "food",
conserva = "food",
energy_drink = "drink",
vodka = "vodka",
bandage = "bandage",
medkit = "meds",
medkit_army = "meds",
medkit_scientic = "meds",
antirad = "antirad"
}
-- set proper path to sound files
local sounds =
{
vodka = {"actor\\cop_vodka1", "actor\\cop_vodka2", "actor\\cop_vodka3"},
drink = {"actor\\cop_drink"},
food = {"actor\\cop_eat"},
meds = {"actor\\cop_heal"},
bandage = {"actor\\cop_bandage"},
antirad = {"actor\\cop_antirad"},
}
function get_item_sound(i_type)
return sounds[i_type][math.random(1, #sounds[i_type])]
end
function on_use_item(obj)
local i_type = items[obj:section()]
if i_type ~= nil then
local snd = get_item_sound(i_type)
snd = sound_object(snd)
snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
end
end
Użytkownicy przeglądający to forum: Brak zarejestrowanych użytkowników oraz 1 gość