Commit f75f4b0ee361a8e6353118e99de7d5a78100a30e

Authored by Ryan Yappert
1 parent 3a06daa0

Makes objects know what inventory they're in.

... ... @@ -313,6 +313,8 @@ function _M:onAddObject(o, inven_id, item)
313 313 end
314 314 end
315 315 end
  316 +
  317 + o.in_inven = {actor = self, id = inven_id}
316 318 end
317 319
318 320 --- Called upon removing an object
... ... @@ -323,6 +325,7 @@ function _M:onRemoveObject(o, inven_id, item)
323 325 end
324 326 end
325 327 o.carried = nil
  328 + o.in_inven = nil
326 329 end
327 330
328 331 --- Called upon dropping an object
... ...
... ... @@ -68,8 +68,9 @@ It is said the Conclave created this weapon for their warmaster during the dark
68 68 local Map = require "engine.Map"
69 69
70 70 -- special_on_hit doesn't know what item triggered it, so find it
71   - local self, item, inven_id = who:findInAllInventoriesBy("define_as", "LONGSWORD_WINTERTIDE")
72   - if not self or not who:getInven(inven_id).worn then return end
  71 + local self = combat.self
  72 + local inven_id = self and self.in_inven and self.in_inven.id
  73 + if not self or not inven_id or not who:getInven(inven_id).worn then return end
73 74
74 75 if who.turn_procs.wintertide_sword then return end
75 76
... ...