Fix combat not working after logout; Fix DDS hits

* Removes the use of the MOB_STATE_CACHE and instead monkey patches a
  get_combat_state method onto Mob.
This commit is contained in:
Gary Tierney
2016-01-03 23:31:34 +00:00
parent 3082fade1d
commit 9f47fae6a9
5 changed files with 17 additions and 22 deletions
+10 -15
View File
@@ -1,13 +1,17 @@
def get_combat_state(mob)
mob.is_a?(Player) ? type = :player : type = :npc
java_import 'org.apollo.game.model.entity.Mob'
unless MOB_COMBAT_STATE_CACHE[type].key? mob.index
MOB_COMBAT_STATE_CACHE[type][mob.index] = CombatState.new(mob)
module MobCombatState
def get_combat_state
if @combat_state.nil?
@combat_state = CombatState.new(self, true)
end
@combat_state
end
MOB_COMBAT_STATE_CACHE[type][mob.index]
end
Mob.include MobCombatState
private
class CombatState
@@ -58,12 +62,3 @@ class CombatState
end
end
end
MOB_COMBAT_STATE_CACHE = {
player: {},
npc: {}
}
on :logout do |event|
MOB_COMBAT_STATE_CACHE[:player].delete event.player.index
end