mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 00:38:18 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user