mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Add magic plugin, more decoders and commands.
This commit is contained in:
@@ -79,4 +79,26 @@
|
||||
<handler>org.apollo.game.event.handler.impl.ItemOnItemVerificationHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.MagicOnItemEvent</type>
|
||||
<chain>
|
||||
<handler>org.apollo.game.event.handler.impl.ItemVerificationHandler</handler>
|
||||
</chain>
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.SpamPacketEvent</type>
|
||||
<chain />
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.MouseClickEvent</type>
|
||||
<chain />
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.ArrowKeyEvent</type>
|
||||
<chain />
|
||||
</event>
|
||||
<event>
|
||||
<type>org.apollo.game.event.impl.FocusUpdateEvent</type>
|
||||
<chain />
|
||||
</event>
|
||||
</events>
|
||||
@@ -3,4 +3,4 @@ java_import 'org.apollo.game.model.inter.bank.BankUtils'
|
||||
|
||||
on :command, :bank, RIGHTS_ADMIN do |player, command|
|
||||
BankUtils.open_bank player
|
||||
end
|
||||
end
|
||||
@@ -11,4 +11,4 @@
|
||||
<script>bank.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
</plugin>
|
||||
@@ -1,27 +1,29 @@
|
||||
require 'java'
|
||||
|
||||
on :command, :item, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
if (1..2).include? args.length
|
||||
id = args[0].to_i
|
||||
amount = args.length == 2 ? args[1].to_i : 1
|
||||
|
||||
player.inventory.add id, amount
|
||||
player.inventory.add(id, amount)
|
||||
else
|
||||
player.send_message "Syntax: ::item [id] [amount=1]"
|
||||
end
|
||||
end
|
||||
|
||||
on :command, :destroy, RIGHTS_ADMIN do |player, command|
|
||||
on :command, :remove, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
if (1..2).include? args.length
|
||||
id = args[0].to_i
|
||||
amount = args.length == 2 ? args[1].to_i : 1
|
||||
|
||||
player.inventory.remove id, amount
|
||||
player.inventory.remove(id, amount)
|
||||
else
|
||||
player.send_message "Syntax: ::destroy [id] [amount=1]"
|
||||
player.send_message "Syntax: ::remove [id] [amount=1]"
|
||||
end
|
||||
end
|
||||
|
||||
on :command, :empty, RIGHTS_ADMIN do |player, command|
|
||||
on :command, :empty, RIGHTS_MOD do |player, command|
|
||||
player.inventory.clear
|
||||
end
|
||||
end
|
||||
@@ -3,7 +3,7 @@
|
||||
<id>cmd-item</id>
|
||||
<version>1</version>
|
||||
<name>Item Commands</name>
|
||||
<description>Adds ::item, ::destroy and ::empty commands.</description>
|
||||
<description>Adds ::item, ::remove and ::empty commands.</description>
|
||||
<authors>
|
||||
<author>Graham</author>
|
||||
</authors>
|
||||
@@ -11,4 +11,4 @@
|
||||
<script>item.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
</plugin>
|
||||
@@ -0,0 +1,42 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.Player'
|
||||
|
||||
on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments.to_a
|
||||
unless args.length > 1
|
||||
player.send_message("Invalid syntax - ::lookup [npc/object/item] [name]")
|
||||
return
|
||||
end
|
||||
|
||||
type = args.shift.downcase
|
||||
name = args.join(" ").downcase
|
||||
|
||||
if ["npc","object","item"].index(type) == nil
|
||||
player.send_message("Invalid syntax - ::lookup [npc/object/item] [name]")
|
||||
return
|
||||
end
|
||||
|
||||
Kernel.const_get("#{type.capitalize}Definition").definitions.each do |definition|
|
||||
if definition.name.to_s.downcase == name
|
||||
player.send_message("That #{type} has id #{definition.id}.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
player.send_message("Could not find an #{type} called #{name}.")
|
||||
end
|
||||
|
||||
on :command, :iteminfo, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 1
|
||||
player.send_message("Invalid syntax - ::iteminfo [item id]")
|
||||
return
|
||||
end
|
||||
|
||||
id = args[0].to_i
|
||||
definition = ItemDefinition.lookup(id)
|
||||
|
||||
members = definition.is_members_only ? "members" : "not members"
|
||||
player.send_message("Item #{id} is called #{definition.name}, is #{members} only, and a has a team of #{definition.team}.")
|
||||
player.send_message("Its description is \"#{definition.description}\".")
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>cmd-lookup</id>
|
||||
<version>1</version>
|
||||
<name>Lookup Command</name>
|
||||
<description>Adds a ::lookup command.</description>
|
||||
<authors>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>lookup.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -3,9 +3,10 @@
|
||||
<id>cmd-skill</id>
|
||||
<version>1</version>
|
||||
<name>Skill Commands</name>
|
||||
<description>Adds a ::max command.</description>
|
||||
<description>Adds skill-related commands.</description>
|
||||
<authors>
|
||||
<author>Graham</author>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>skill.rb</script>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.SkillSet'
|
||||
java_import 'org.apollo.game.model.Skill'
|
||||
|
||||
on :command, :max, RIGHTS_ADMIN do |player, command|
|
||||
skills = player.skill_set
|
||||
@@ -7,3 +8,40 @@ on :command, :max, RIGHTS_ADMIN do |player, command|
|
||||
skills.add_experience(skill, SkillSet::MAXIMUM_EXP)
|
||||
end
|
||||
end
|
||||
|
||||
on :command, :level, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 2
|
||||
player.send_message("Invalid syntax - ::level [skill id] [level]")
|
||||
return
|
||||
end
|
||||
|
||||
skill = args[0].to_i
|
||||
level = args[1].to_i
|
||||
|
||||
unless (0..20).include? skill and (1..99).include? level
|
||||
player.send_message("Invalid syntax - ::level [skill id] [level]")
|
||||
return
|
||||
end
|
||||
|
||||
experience = SkillSet.experience_for_level(level)
|
||||
player.skill_set.set_skill(skill, Skill.new(experience, level, level))
|
||||
end
|
||||
|
||||
on :command, :xp, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 2
|
||||
player.send_message("Invalid syntax - ::xp [skill id] [experience]")
|
||||
return
|
||||
end
|
||||
|
||||
skill = args[0].to_i
|
||||
experience = args[1].to_i
|
||||
|
||||
unless (0..20).include? skill
|
||||
player.send_message("Invalid syntax - ::xp [skill id] [experience]")
|
||||
return
|
||||
end
|
||||
|
||||
player.skill_set.add_experience(skill, experience)
|
||||
end
|
||||
@@ -1,19 +1,20 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
|
||||
on :command, :pos, RIGHTS_ADMIN do |player, command|
|
||||
on :command, :pos, RIGHTS_MOD do |player, command|
|
||||
player.send_message "You are at: " + player.position.to_s
|
||||
end
|
||||
|
||||
on :command, :tele, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
if (2..3).include? args.length
|
||||
x = args[0].to_i
|
||||
y = args[1].to_i
|
||||
z = args.length == 3 ? args[2].to_i : 0
|
||||
|
||||
player.teleport Position.new(x, y, z)
|
||||
else
|
||||
player.send_message "Syntax: ::tele [x] [y] [z=0]"
|
||||
unless (2..3).include? args.length
|
||||
player.send_message "Invalid syntax - ::tele [x] [y] [optional-z]"
|
||||
return
|
||||
end
|
||||
|
||||
x = args[0].to_i
|
||||
y = args[1].to_i
|
||||
z = args.length == 3 ? args[2].to_i : 0
|
||||
|
||||
player.teleport Position.new(x, y, z)
|
||||
end
|
||||
@@ -0,0 +1,70 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
java_import 'org.apollo.game.model.Graphic'
|
||||
|
||||
ALCHEMY_SPELLS = {}
|
||||
|
||||
LOW_ALC_ANIM = Animation.new(712)
|
||||
LOW_ALC_GFX = Graphic.new(112, 0, 100)
|
||||
LOW_ALC_MULTIPLIER = 0.4
|
||||
|
||||
HIGH_ALC_ANIM = Animation.new(713)
|
||||
HIGH_ALC_GFX = Graphic.new(113, 0, 100)
|
||||
HIGH_ALC_MULTIPLIER = 0.6
|
||||
|
||||
ILLEGAL_ALC_ITEMS = [ 995, 6529, 6306, 6307, 6308, 6309, 6310 ]
|
||||
|
||||
class AlchemySpell < Spell
|
||||
attr_reader :high, :animation, :graphic, :multiplier, :experience, :delay
|
||||
|
||||
def initialize(level, elements, high, animation, graphic, multiplier, experience, delay)
|
||||
super level, elements, experience
|
||||
|
||||
@high = high
|
||||
@animation = animation
|
||||
@graphic = graphic
|
||||
@multiplier = multiplier
|
||||
@delay = delay
|
||||
end
|
||||
end
|
||||
|
||||
class AlchemyAction < ItemSpellAction
|
||||
|
||||
def initialize(player, alchemy, slot, item)
|
||||
super player, alchemy, slot, item
|
||||
end
|
||||
|
||||
def illegal_item?
|
||||
return ILLEGAL_ALC_ITEMS.include? @item.id
|
||||
end
|
||||
|
||||
def execute_action
|
||||
player = character
|
||||
if @pulses == 0
|
||||
player.play_animation(@spell.animation)
|
||||
player.play_graphic(@spell.graphic)
|
||||
player.send(DISPLAY_SPELLBOOK)
|
||||
|
||||
inventory = player.inventory
|
||||
gold = (item.definition.value * @spell.multiplier)
|
||||
|
||||
inventory.remove(inventory.get(@slot).id, 1)
|
||||
inventory.add(995, gold)
|
||||
|
||||
player.skill_set.add_experience(MAGIC_ID, @spell.experience)
|
||||
|
||||
set_delay(@spell.delay)
|
||||
elsif @pulses == 1
|
||||
player.stop_animation
|
||||
player.stop_graphic
|
||||
stop
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def append_alchemy(button, level, elements, high, animation, graphic, multiplier, experience, delay)
|
||||
ALCHEMY_SPELLS[button] = AlchemySpell.new(level, elements, high, animation, graphic, multiplier, experience, delay)
|
||||
end
|
||||
|
||||
append_alchemy(1162, 21, { FIRE => 3, NATURE => 1 }, false, LOW_ALC_ANIM, LOW_ALC_GFX, 0.48, 31, 1) # Low level alchemy
|
||||
append_alchemy(1178, 55, { FIRE => 5, NATURE => 1 }, true, HIGH_ALC_ANIM, HIGH_ALC_GFX, 0.72, 65, 4) # High level alchemy
|
||||
@@ -0,0 +1,91 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
java_import 'org.apollo.game.model.Graphic'
|
||||
java_import 'org.apollo.game.model.Item'
|
||||
|
||||
CONVERT_SPELLS = {}
|
||||
BONES_ID = 526
|
||||
|
||||
CONVERT_ANIM = Animation.new(722)
|
||||
CONVERT_GFX = Graphic.new(141, 0, 100)
|
||||
|
||||
class ConvertSpell < Spell
|
||||
attr_reader :reward
|
||||
|
||||
def initialize(level, elements, experience, reward)
|
||||
super(level, elements, experience)
|
||||
|
||||
@reward = Item.new(reward)
|
||||
end
|
||||
end
|
||||
|
||||
class ConvertingAction < SpellAction
|
||||
attr_reader :slots
|
||||
|
||||
def initialize(player, spell, slots)
|
||||
super(player, spell)
|
||||
|
||||
@slots = slots
|
||||
end
|
||||
|
||||
def execute_action
|
||||
player = character
|
||||
if @pulses == 0
|
||||
player.play_animation CONVERT_ANIM
|
||||
player.play_graphic CONVERT_GFX
|
||||
|
||||
inventory = player.inventory
|
||||
firing = (@slots.length * 2) < inventory.capacity
|
||||
|
||||
inventory.stop_firing_events unless firing # In the case of many changes, wait with firing events
|
||||
|
||||
reward = @spell.reward
|
||||
@slots.each do |slot|
|
||||
inventory.set(slot, reward) # Share the instance
|
||||
end
|
||||
|
||||
unless firing # If we waited with firing events, restore it now and force a refresh
|
||||
inventory.start_firing_events
|
||||
inventory.force_refresh
|
||||
end
|
||||
|
||||
player.skill_set.add_experience MAGIC_ID, @spell.experience
|
||||
|
||||
set_delay 2
|
||||
elsif @pulses == 1
|
||||
player.stop_animation
|
||||
player.stop_graphic
|
||||
|
||||
stop
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def bone_slots(player)
|
||||
inventory = player.inventory
|
||||
items = inventory.items
|
||||
size = inventory.size
|
||||
|
||||
counter = 0
|
||||
slots = []
|
||||
(0...inventory.capacity).each do |slot|
|
||||
break unless counter <= size
|
||||
|
||||
item = items[slot]
|
||||
if item != nil and item.id == BONES_ID
|
||||
slots << slot
|
||||
end
|
||||
|
||||
counter += 1
|
||||
end
|
||||
|
||||
return slots
|
||||
end
|
||||
|
||||
def append_convert(button, level, elements, experience, reward)
|
||||
convert = ConvertSpell.new(level, elements, experience, reward)
|
||||
CONVERT_SPELLS[button] = convert
|
||||
end
|
||||
|
||||
append_convert 1159, 15, { EARTH => 2, WATER => 2, NATURE => 1 }, 25, 1963 # Bones to bananas
|
||||
append_convert 15877, 60, { NATURE => 2, WATER => 4, EARTH => 4 }, 35.5, 6883 # Bones to peaches
|
||||
@@ -0,0 +1,110 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.EquipmentConstants'
|
||||
|
||||
AIR_ELEMENTS = {}
|
||||
WATER_ELEMENTS = {}
|
||||
EARTH_ELEMENTS = {}
|
||||
FIRE_ELEMENTS = {}
|
||||
|
||||
AIR_RUNE = 556
|
||||
WATER_RUNE = 555
|
||||
EARTH_RUNE = 557
|
||||
FIRE_RUNE = 554
|
||||
|
||||
MIND_RUNE = 558
|
||||
CHAOS_RUNE = 562
|
||||
DEATH_RUNE = 560
|
||||
BLOOD_RUNE = 565
|
||||
|
||||
COSMIC_RUNE = 564
|
||||
LAW_RUNE = 563
|
||||
NATURE_RUNE = 561
|
||||
SOUL_RUNE = 566
|
||||
|
||||
MIST_RUNE = 4695
|
||||
DUST_RUNE = 4696
|
||||
SMOKE_RUNE = 4697
|
||||
MUD_RUNE = 4698
|
||||
STEAM_RUNE = 4694
|
||||
LAVA_RUNE = 4699
|
||||
|
||||
class Element
|
||||
attr_reader :runes, :staffs, :name
|
||||
|
||||
def initialize(runes, staffs, name="Null")
|
||||
@runes = runes
|
||||
@staffs = staffs
|
||||
@name = name
|
||||
end
|
||||
|
||||
def check_remove(player, amount, remove)
|
||||
weapon = player.equipment.get(EquipmentConstants::WEAPON)
|
||||
if @staffs != nil && weapon != nil
|
||||
@staffs.each do |staff|
|
||||
return true if weapon.id == staff
|
||||
end
|
||||
end
|
||||
|
||||
inventory = player.inventory
|
||||
|
||||
found = {}
|
||||
counter = 0
|
||||
|
||||
inventory.items.each do |item|
|
||||
break unless counter < amount
|
||||
next if item == nil
|
||||
|
||||
amt = item.amount
|
||||
@runes.each do |rune|
|
||||
break unless counter < amount
|
||||
|
||||
id = item.id
|
||||
if id == rune
|
||||
if amt >= amount
|
||||
inventory.remove(id, amount) if remove
|
||||
return true
|
||||
else
|
||||
found[id] = amt
|
||||
counter += amt
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if counter >= amount
|
||||
if remove
|
||||
found.each do |id, amt|
|
||||
inventory.remove(id, amt)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
AIR_RUNES = [ 556, 4695, 4696, 4697 ]
|
||||
WATER_RUNES = [ 555, 4695, 4698, 4694 ]
|
||||
EARTH_RUNES = [ 557, 4696, 4697, 4698 ]
|
||||
FIRE_RUNES = [ 554, 4697, 4694, 4699 ]
|
||||
|
||||
AIR_STAFFS = [ 1381, 1397, 1405 ]
|
||||
WATER_STAFFS = [ 1383, 1395, 1403 ]
|
||||
EARTH_STAFFS = [ 1385, 1399, 1407, 3053, 3054 ]
|
||||
FIRE_STAFFS = [ 1387, 1393, 1401, 3053, 3054 ]
|
||||
|
||||
AIR = Element.new(AIR_RUNES, AIR_STAFFS, "Air rune")
|
||||
WATER = Element.new(WATER_RUNES, WATER_STAFFS, "Water rune")
|
||||
EARTH = Element.new(EARTH_RUNES, EARTH_STAFFS, "Earth rune")
|
||||
FIRE = Element.new(FIRE_RUNES, FIRE_STAFFS, "Fire rune")
|
||||
|
||||
MIND = Element.new([MIND_RUNE], nil, "Mind rune")
|
||||
CHAOS = Element.new([CHAOS_RUNE], nil, "Chaos rune")
|
||||
DEATH = Element.new([DEATH_RUNE], nil, "Death rune")
|
||||
BLOOD = Element.new([BLOOD_RUNE], nil, "Blood rune")
|
||||
|
||||
COSMIC = Element.new([COSMIC_RUNE], nil, "Cosmic rune")
|
||||
LAW = Element.new([LAW_RUNE], nil, "Law rune")
|
||||
NATURE = Element.new([NATURE_RUNE], nil, "Nature rune")
|
||||
SOUL = Element.new([SOUL_RUNE], nil, "Soul rune")
|
||||
@@ -0,0 +1,111 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
java_import 'org.apollo.game.model.Graphic'
|
||||
java_import 'org.apollo.game.model.Item'
|
||||
|
||||
ENCHANT_SPELLS = {}
|
||||
ENCHANT_ITEMS = {}
|
||||
|
||||
RING_GFX = Graphic.new(238, 0, 100)
|
||||
RING_ANIM = Animation.new(713) # TODO: No way we need one of the alchemy anims for enchanting...
|
||||
|
||||
LOW_NECK_GFX = Graphic.new(114, 0, 100)
|
||||
LOW_NECK_ANIM = Animation.new(719)
|
||||
|
||||
MED_NECK_GFX = Graphic.new(115, 0, 100)
|
||||
MED_NECK_ANIM = Animation.new(720)
|
||||
|
||||
HIGH_NECK_GFX = Graphic.new(116, 0, 100)
|
||||
HIGH_NECK_ANIM = Animation.new(721)
|
||||
|
||||
ONYX_NECK_GFX = Graphic.new(452, 0, 100)
|
||||
|
||||
class EnchantSpell < Spell
|
||||
attr_reader :button, :animation, :graphic, :delay
|
||||
|
||||
def initialize(button, level, elements, animation, graphic, delay, experience)
|
||||
super level, elements, experience
|
||||
|
||||
@button = button
|
||||
@animation = animation
|
||||
@graphic = graphic
|
||||
@delay = delay
|
||||
end
|
||||
end
|
||||
|
||||
class EnchantAction < ItemSpellAction
|
||||
attr_reader :reward
|
||||
|
||||
def initialize(player, enchant, slot, item, reward)
|
||||
super(player, enchant, slot, item)
|
||||
|
||||
@reward = Item.new(reward)
|
||||
end
|
||||
|
||||
def illegal_item?
|
||||
return ENCHANT_ITEMS[@item.id] == nil
|
||||
end
|
||||
|
||||
def execute_action
|
||||
player = character
|
||||
if @pulses == 0
|
||||
player.play_animation @spell.animation
|
||||
player.play_graphic @spell.graphic
|
||||
player.send DISPLAY_SPELLBOOK
|
||||
|
||||
player.inventory.set @slot, @reward
|
||||
player.skill_set.add_experience MAGIC_ID, @spell.experience
|
||||
|
||||
set_delay @spell.delay
|
||||
elsif @pulses == 1
|
||||
player.stop_animation
|
||||
player.stop_graphic
|
||||
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def append_enchant(button, level, elements, item, animation, graphic, delay, experience, reward)
|
||||
enchant = EnchantSpell.new(button, level, elements, animation, graphic, delay, experience)
|
||||
ENCHANT_SPELLS[item] = enchant
|
||||
ENCHANT_ITEMS[item] = reward
|
||||
end
|
||||
|
||||
SAPPHIRE_ELEMENTS = { WATER => 1, COSMIC => 1 }
|
||||
EMERALD_ELEMENTS = { AIR => 1, COSMIC => 1 }
|
||||
RUBY_ELEMENTS = { FIRE => 5, COSMIC => 1 }
|
||||
DIAMOND_ELEMENTS = { EARTH => 10, COSMIC => 1 }
|
||||
DSTONE_ELEMENTS = { WATER => 15, EARTH => 15, COSMIC => 1 }
|
||||
ONYX_ELEMENTS = { EARTH => 20, FIRE => 20, COSMIC => 1 }
|
||||
|
||||
# Sapphire
|
||||
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1637, RING_ANIM, RING_GFX, 2, 17.5, 2550 # Ring
|
||||
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1656, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 3853 # Necklace
|
||||
append_enchant 1155, 7, SAPPHIRE_ELEMENTS, 1692, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 17.5, 1727 # Amulet
|
||||
|
||||
# Emerald
|
||||
append_enchant 1165, 27, EMERALD_ELEMENTS, 1639, RING_ANIM, RING_GFX, 2, 37, 2552 # Ring
|
||||
append_enchant 1165, 27, EMERALD_ELEMENTS, 1658, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 5521 # Necklace
|
||||
append_enchant 1165, 27, EMERALD_ELEMENTS, 1696, LOW_NECK_ANIM, LOW_NECK_GFX, 1, 37, 1729 # Amulet
|
||||
|
||||
# Ruby
|
||||
append_enchant 1176, 49, RUBY_ELEMENTS, 1641, RING_ANIM, RING_GFX, 2, 59, 2568 # Ring
|
||||
# append_enchant 1176, 49, RUBY_ELEMENTS, 1660, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, # Necklace - not found in 317 or 377
|
||||
append_enchant 1176, 49, RUBY_ELEMENTS, 1698, MED_NECK_ANIM, MED_NECK_GFX, 2, 59, 1725 # Amulet
|
||||
|
||||
# Diamond
|
||||
append_enchant 1180, 57, DIAMOND_ELEMENTS, 1643, RING_ANIM, RING_GFX, 2, 67, 2570 # Ring
|
||||
# append_enchant 1180, 57, DIAMOND_ELEMENTS, 1662, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, # Necklace - not found in 317 or 377
|
||||
append_enchant 1180, 57, DIAMOND_ELEMENTS, 1700, MED_NECK_ANIM, MED_NECK_GFX, 2, 67, 1731 # Amulet
|
||||
|
||||
# Dragonstone
|
||||
append_enchant 1187, 68, DSTONE_ELEMENTS, 1645, RING_ANIM, RING_GFX, 2, 78, 2572 # Ring
|
||||
# append_enchant 1187, 68, DSTONE_ELEMENTS, 1664, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, # Necklace - not found in 317 or 377
|
||||
append_enchant 1187, 68, DSTONE_ELEMENTS, 1702, HIGH_NECK_ANIM, HIGH_NECK_GFX, 3, 78, 1712 # Amulet
|
||||
|
||||
# Onyx
|
||||
append_enchant 6003, 87, ONYX_ELEMENTS, 6575, RING_ANIM, RING_GFX, 2, 97, 6583 # Ring
|
||||
# append_enchant 6003, 87, ONYX_ELEMENTS, 6577, HIGH_NECK_ANIM, ONYX_NECK_GFX, 3, 97, # Necklace - not found in 317 or 377
|
||||
append_enchant 6003, 87, ONYX_ELEMENTS, 6581, HIGH_NECK_ANIM, ONYX_NECK_GFX, 2, 97, 6585 # Amulet
|
||||
@@ -0,0 +1,159 @@
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.action.Action'
|
||||
java_import 'org.apollo.game.event.impl.DisplayTabInterfaceEvent'
|
||||
java_import 'org.apollo.game.model.EquipmentConstants'
|
||||
java_import 'org.apollo.game.model.Skill'
|
||||
|
||||
MAGIC_ID = Skill::MAGIC
|
||||
DISPLAY_SPELLBOOK = DisplayTabInterfaceEvent.new 6
|
||||
|
||||
class Spell
|
||||
attr_reader :level, :elements, :experience
|
||||
|
||||
def initialize(level, elements, experience)
|
||||
@level = level
|
||||
@elements = elements
|
||||
@experience = experience
|
||||
end
|
||||
end
|
||||
|
||||
class SpellAction < Action
|
||||
attr_reader :spell, :pulses
|
||||
|
||||
def initialize(character, spell)
|
||||
super(0, true, character)
|
||||
|
||||
@spell = spell
|
||||
@pulses = 0
|
||||
end
|
||||
|
||||
def execute
|
||||
if @pulses == 0
|
||||
unless (check_skill and process_elements)
|
||||
stop
|
||||
return
|
||||
end
|
||||
end
|
||||
execute_action
|
||||
@pulses += 1
|
||||
end
|
||||
|
||||
def execute_action
|
||||
stop
|
||||
end
|
||||
|
||||
def check_skill
|
||||
required = @spell.level
|
||||
if required > character.skill_set.skill(MAGIC_ID).maximum_level
|
||||
character.send_message "You need a Magic level of at least #{required} to cast this spell."
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
def process_elements
|
||||
elements = @spell.elements
|
||||
|
||||
elements.each do |element, amount|
|
||||
unless element.check_remove(character, amount, false)
|
||||
character.send_message "You do not have enough #{element.name}s to cast this spell."
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
elements.each do |element, amount|
|
||||
element.check_remove(character, amount, true)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class and @spell == other.spell)
|
||||
end
|
||||
end
|
||||
|
||||
class ItemSpellAction < SpellAction
|
||||
attr_reader :slot, :item
|
||||
|
||||
def initialize(character, spell, slot, item)
|
||||
super(character, spell)
|
||||
|
||||
@slot = slot
|
||||
@item = item
|
||||
end
|
||||
|
||||
# We override SpellAction#execute to implement an illegal item check (e.g. coins for alchemy)
|
||||
def execute
|
||||
if @pulses == 0
|
||||
if illegal_item?
|
||||
character.send_message "You cannot use that spell on this item!"
|
||||
stop
|
||||
return
|
||||
end
|
||||
|
||||
id = @item.id
|
||||
|
||||
# TODO: There has to be a better way to do this.
|
||||
@spell.elements.each do |element, amount|
|
||||
element.runes.each do |rune|
|
||||
if id == rune && !element.check_remove(character, amount + 1, false)
|
||||
character.send_message("You do not have enough " + element.name + "s to cast this spell.")
|
||||
stop
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def illegal_item?
|
||||
# Override this method if necessary
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# MagicOnItemEvent handling
|
||||
on :event, :magic_on_item do |ctx, player, event|
|
||||
spell = event.spell_id
|
||||
|
||||
alch = ALCHEMY_SPELLS[spell]
|
||||
if alch != nil
|
||||
slot = event.slot
|
||||
item = player.inventory.get slot
|
||||
player.start_action AlchemyAction.new(player, alch, slot, item)
|
||||
ctx.break_handler_chain
|
||||
return
|
||||
end
|
||||
|
||||
ench = ENCHANT_SPELLS[event.id]
|
||||
if ench != nil and ench.button == spell
|
||||
slot = event.slot
|
||||
item = player.inventory.get slot
|
||||
player.start_action EnchantAction.new(player, ench, slot, item, ENCHANT_ITEMS[item.id])
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
|
||||
# ButtonEvent handling
|
||||
on :event, :button do |ctx, player, event|
|
||||
button = event.widget_id
|
||||
|
||||
tele = TELEPORT_SPELLS[button]
|
||||
if tele != nil
|
||||
player.start_action TeleportingAction.new(player, tele)
|
||||
ctx.break_handler_chain
|
||||
return
|
||||
end
|
||||
|
||||
conv = CONVERT_SPELLS[button]
|
||||
if conv != nil
|
||||
slots = bone_slots player
|
||||
if slots.length == 0 then player.send_message("You cant convert these bones!") else player.start_action(ConvertingAction.new(player, conv, slots)) end
|
||||
ctx.break_handler_chain
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>skill-magic</id>
|
||||
<version>1</version>
|
||||
<name>Magic</name>
|
||||
<description>Adds the Magic skill.</description>
|
||||
<authors>
|
||||
<author>Chris Fletcher</author>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>magic.rb</script>
|
||||
<script>element.rb</script>
|
||||
<script>teleport.rb</script>
|
||||
<script>alchemy.rb</script>
|
||||
<script>enchant.rb</script>
|
||||
<script>convert.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,96 @@
|
||||
# Thanks to phl0w <http://www.rune-server.org/members/phl0w/> for providing
|
||||
# the correct destination coordinates of the ancient teleports.
|
||||
|
||||
require 'java'
|
||||
java_import 'org.apollo.game.model.Animation'
|
||||
java_import 'org.apollo.game.model.Graphic'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
|
||||
TELEPORT_SPELLS = {}
|
||||
|
||||
MODERN_TELE_ANIM = Animation.new(714)
|
||||
MODERN_TELE_END_ANIM = Animation.new(715)
|
||||
MODERN_TELE_GFX = Graphic.new(308, 15, 100)
|
||||
|
||||
ANCIENT_TELE_END_GFX = Graphic.new(455)
|
||||
ANCIENT_TELE_ANIM = Animation.new(1979)
|
||||
ANCIENT_TELE_GFX = Graphic.new(392)
|
||||
|
||||
class TeleportSpell < Spell
|
||||
attr_reader :ancient, :destination, :experience, :name
|
||||
|
||||
def initialize(ancient, level, elements, destination, experience, name)
|
||||
super(level, elements, experience)
|
||||
@ancient = ancient
|
||||
@destination = destination
|
||||
@name = name
|
||||
end
|
||||
end
|
||||
|
||||
class TeleportingAction < SpellAction
|
||||
|
||||
def initialize(character, spell)
|
||||
super(character, spell)
|
||||
end
|
||||
|
||||
def execute_action
|
||||
@spell.ancient ? execute_modern : execute_ancient
|
||||
end
|
||||
|
||||
def execute_modern
|
||||
player = character
|
||||
if @pulses == 0
|
||||
player.play_animation(MODERN_TELE_ANIM)
|
||||
elsif @pulses == 1
|
||||
player.play_graphic(MODERN_TELE_GFX)
|
||||
delay = 1
|
||||
elsif @pulses == 2
|
||||
player.stop_graphic
|
||||
player.play_animation(MODERN_TELE_END_ANIM)
|
||||
|
||||
destination = @spell.destination
|
||||
player.teleport(destination)
|
||||
player.skill_set.add_experience(MAGIC_ID, @spell.experience)
|
||||
stop
|
||||
end
|
||||
end
|
||||
|
||||
def execute_ancient
|
||||
player = character
|
||||
if @pulses == 0
|
||||
player.play_graphic(ANCIENT_TELE_GFX)
|
||||
player.play_animation(ANCIENT_TELE_ANIM)
|
||||
delay = 2
|
||||
elsif @pulses == 1
|
||||
player.stop_graphic
|
||||
player.stop_animation
|
||||
player.teleport(@spell.destination)
|
||||
player.skill_set.add_experience(MAGIC_ID, @spell.experience)
|
||||
stop
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def append_tele(ancient, button, level, elements, x, y, experience, name)
|
||||
TELEPORT_SPELLS[button] = TeleportSpell.new(ancient, level, elements, Position.new(x, y), experience, name)
|
||||
end
|
||||
|
||||
# Modern teleports
|
||||
append_tele(false, 1164, 25, { FIRE => 1, AIR => 3, LAW => 1 }, 3213, 3424, 35, "Varrock")
|
||||
append_tele(false, 1167, 31, { EARTH => 1, AIR => 3, LAW => 1 }, 3222, 3219, 41, "Lumbridge")
|
||||
append_tele(false, 1170, 37, { WATER => 1, AIR => 3, LAW => 1 }, 2965, 3379, 47, "Falador")
|
||||
append_tele(false, 1174, 45, { AIR => 5, LAW => 1 }, 2757, 3478, 55.5, "Camelot")
|
||||
append_tele(false, 1540, 51, { WATER => 2, LAW => 2 }, 2662, 3306, 61, "Ardougne")
|
||||
append_tele(false, 1541, 58, { EARTH => 2, LAW => 2 }, 2549, 3114, 68, "the Watchtower")
|
||||
append_tele(false, 7455, 61, { FIRE => 2, LAW => 2 }, 2871, 3590, 68, "Trollheim")
|
||||
append_tele(false, 18470, 64, { FIRE => 2, WATER => 2, LAW => 2, Element.new([1963], nil, "Banana") => 1 }, 2754, 2785, 76, "Ape Atoll")
|
||||
|
||||
# Ancient teleports
|
||||
append_tele(true, 13035, 54, { LAW => 2, FIRE => 1, AIR => 1 }, 3098, 9882, 64, "Paddewwa")
|
||||
append_tele(true, 13045, 60, { LAW => 2, SOUL => 2 }, 3320, 3338, 70, "Senntisten")
|
||||
append_tele(true, 13053, 66, { LAW => 2, BLOOD => 1 }, 3493, 3472, 76, "Kharyll")
|
||||
append_tele(true, 13061, 72, { LAW => 2, WATER => 4 }, 3003, 3470, 82, "Lassar")
|
||||
append_tele(true, 13069, 78, { LAW => 2, FIRE => 3, AIR => 2 }, 2966, 3696, 88, "Dareeyak")
|
||||
append_tele(true, 13079, 84, { LAW => 2, SOUL => 2 }, 3163, 3664, 94, "Carrallangar")
|
||||
append_tele(true, 13087, 90, { LAW => 2, BLOOD => 2 }, 3287, 3883, 100, "Annakarl")
|
||||
append_tele(true, 13095, 96, { LAW => 2, WATER => 8 }, 2972, 3873, 106, "Ghorrock")
|
||||
@@ -67,93 +67,90 @@ public final class ItemDefinitionDecoder {
|
||||
private ItemDefinition decode(int id, ByteBuffer buffer) {
|
||||
ItemDefinition definition = new ItemDefinition(id);
|
||||
while (true) {
|
||||
int code = buffer.get() & 0xFF;
|
||||
int opcode = buffer.get() & 0xFF;
|
||||
|
||||
if (code == 0) {
|
||||
if (opcode == 0) {
|
||||
return definition;
|
||||
} else if (code == 1) {
|
||||
} else if (opcode == 1) {
|
||||
buffer.getShort();// & 0xFFFF; // model Id
|
||||
} else if (code == 2) {
|
||||
} else if (opcode == 2) {
|
||||
definition.setName(ByteBufferUtil.readString(buffer));
|
||||
} else if (code == 3) {
|
||||
} else if (opcode == 3) {
|
||||
definition.setDescription(ByteBufferUtil.readString(buffer));
|
||||
} else if (code == 4) {
|
||||
} else if (opcode == 4) {
|
||||
buffer.getShort();// & 0xFFFF; // sprite scale
|
||||
} else if (code == 5) {
|
||||
} else if (opcode == 5) {
|
||||
buffer.getShort();// & 0xFFFF; // sprite pitch
|
||||
} else if (code == 6) {
|
||||
} else if (opcode == 6) {
|
||||
buffer.getShort();// & 0xFFFF; //sprite camera roll
|
||||
} else if (code == 7) {
|
||||
} else if (opcode == 7) {
|
||||
buffer.getShort(); // sprite dX
|
||||
} else if (code == 8) {
|
||||
} else if (opcode == 8) {
|
||||
buffer.getShort(); // sprite dY
|
||||
} else if (code == 10) {
|
||||
} else if (opcode == 10) {
|
||||
buffer.getShort();
|
||||
} else if (code == 11) {
|
||||
} else if (opcode == 11) {
|
||||
definition.setStackable(true);
|
||||
} else if (code == 12) {
|
||||
buffer.getInt(); // model height
|
||||
} else if (code == 16) {
|
||||
} else if (opcode == 12) {
|
||||
definition.setValue(buffer.getInt());
|
||||
} else if (opcode == 16) {
|
||||
definition.setMembersOnly(true);
|
||||
} else if (code == 23) {
|
||||
} else if (opcode == 23) {
|
||||
buffer.getShort(); // & 0xFFFF; //primaryMaleEquipModelId
|
||||
buffer.get(); // maleEquipYTranslation
|
||||
} else if (code == 24) {
|
||||
} else if (opcode == 24) {
|
||||
buffer.getShort(); // & 0xFFFF; // secondaryMaleEquipModelId
|
||||
} else if (code == 25) {
|
||||
} else if (opcode == 25) {
|
||||
buffer.getShort(); // & 0xFFFF; // primaryFemaleEquipModelId
|
||||
buffer.get(); // femaleEquipYTranslation
|
||||
} else if (code == 26) {
|
||||
} else if (opcode == 26) {
|
||||
buffer.getShort(); // & 0xFFFF; // secondaryFemaleEquipModelId
|
||||
} else if (code >= 30 && code < 35) {
|
||||
} else if (opcode >= 30 && opcode < 35) {
|
||||
String str = ByteBufferUtil.readString(buffer);
|
||||
if (str.equalsIgnoreCase("hidden")) {
|
||||
str = null;
|
||||
}
|
||||
definition.setGroundAction(code - 30, str);
|
||||
} else if (code >= 35 && code < 40) {
|
||||
String str = ByteBufferUtil.readString(buffer);
|
||||
definition.setInventoryAction(code - 35, str);
|
||||
} else if (code == 40) {
|
||||
definition.setGroundAction(opcode - 30, str);
|
||||
} else if (opcode >= 35 && opcode < 40) {
|
||||
definition.setInventoryAction(opcode - 35, ByteBufferUtil.readString(buffer));
|
||||
} else if (opcode == 40) {
|
||||
int colourCount = buffer.get() & 0xFF;
|
||||
for (int i = 0; i < colourCount; i++) {
|
||||
buffer.getShort(); // & 0xFFFF; // original colour
|
||||
buffer.getShort(); // & 0xFFFF; // replacement colour
|
||||
}
|
||||
} else if (code == 78) {
|
||||
} else if (opcode == 78) {
|
||||
buffer.getShort(); // & 0xFFFF; // tertiaryMaleEquipModelId
|
||||
} else if (code == 79) {
|
||||
} else if (opcode == 79) {
|
||||
buffer.getShort(); // & 0xFFFF; // tertiaryFemaleEquipModelId
|
||||
} else if (code == 90) {
|
||||
} else if (opcode == 90) {
|
||||
buffer.getShort(); // & 0xFFFF; // primaryMaleHeadPiece
|
||||
} else if (code == 91) {
|
||||
} else if (opcode == 91) {
|
||||
buffer.getShort(); // & 0xFFFF; // primaryFemaleHeadPiece
|
||||
} else if (code == 92) {
|
||||
} else if (opcode == 92) {
|
||||
buffer.getShort(); // & 0xFFFF; // secondaryMaleHeadPiece
|
||||
} else if (code == 93) {
|
||||
} else if (opcode == 93) {
|
||||
buffer.getShort(); // & 0xFFFF; // secondaryFemaleHeadPiece
|
||||
} else if (code == 95) {
|
||||
} else if (opcode == 95) {
|
||||
buffer.getShort(); // & 0xFFFF; // spriteCameraYaw
|
||||
} else if (code == 97) {
|
||||
int noteInfoId = buffer.getShort() & 0xFFFF;
|
||||
definition.setNoteInfoId(noteInfoId);
|
||||
} else if (code == 98) {
|
||||
int noteGraphicId = buffer.getShort() & 0xFFFF;
|
||||
definition.setNoteGraphicId(noteGraphicId);
|
||||
} else if (code >= 100 && code < 110) {
|
||||
} else if (opcode == 97) {
|
||||
definition.setNoteInfoId(buffer.getShort() & 0xFFFF);
|
||||
} else if (opcode == 98) {
|
||||
definition.setNoteGraphicId(buffer.getShort() & 0xFFFF);
|
||||
} else if (opcode >= 100 && opcode < 110) {
|
||||
buffer.getShort(); // & 0xFFFF; // stack id
|
||||
buffer.getShort(); // & 0xFFFF; // stack size
|
||||
} else if (code == 110) {
|
||||
} else if (opcode == 110) {
|
||||
buffer.getShort(); // & 0xFFFF; // groundScaleX
|
||||
} else if (code == 111) {
|
||||
} else if (opcode == 111) {
|
||||
buffer.getShort(); // & 0xFFFF; // groundScaleY
|
||||
} else if (code == 112) {
|
||||
} else if (opcode == 112) {
|
||||
buffer.getShort(); // & 0xFFFF; // groundScaleZ
|
||||
} else if (code == 113) {
|
||||
} else if (opcode == 113) {
|
||||
buffer.get(); // light ambiance
|
||||
} else if (code == 114) {
|
||||
} else if (opcode == 114) {
|
||||
buffer.getShort(); // * 5; // light diffusion
|
||||
} else if (code == 115) {
|
||||
} else if (opcode == 115) {
|
||||
definition.setTeam(buffer.get() & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} sent by the client when the user has pressed an arrow key.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class ArrowKeyEvent extends Event {
|
||||
|
||||
/**
|
||||
* The camera roll.
|
||||
*/
|
||||
private final int roll;
|
||||
|
||||
/**
|
||||
* The camera yaw.
|
||||
*/
|
||||
private final int yaw;
|
||||
|
||||
/**
|
||||
* Creates a new arrow key event.
|
||||
*/
|
||||
public ArrowKeyEvent(int roll, int yaw) {
|
||||
this.roll = roll;
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the roll of the camera.
|
||||
*
|
||||
* @return The roll.
|
||||
*/
|
||||
public int getRoll() {
|
||||
return roll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the yaw of the camera.
|
||||
*
|
||||
* @return The yaw.
|
||||
*/
|
||||
public int getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An event sent when the user moves the camera.
|
||||
*
|
||||
* @author Toby
|
||||
*/
|
||||
public class CameraMovementEvent extends Event {
|
||||
|
||||
/**
|
||||
* The camera x.
|
||||
*/
|
||||
private final int cameraX;
|
||||
|
||||
/**
|
||||
* The camera y.
|
||||
*/
|
||||
private final int cameraY;
|
||||
|
||||
/**
|
||||
* Creates a new camera movement event.
|
||||
*
|
||||
* @param cameraX The camera x.
|
||||
* @param cameraY The camera y.
|
||||
*/
|
||||
public CameraMovementEvent(int cameraX, int cameraY) {
|
||||
this.cameraX = cameraX;
|
||||
this.cameraY = cameraY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the camera x.
|
||||
*
|
||||
* @return The camera x.
|
||||
*/
|
||||
public int getCameraX() {
|
||||
return cameraX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the camera y.
|
||||
*
|
||||
* @return The camera y.
|
||||
*/
|
||||
public int getCameraY() {
|
||||
return cameraY;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An outgoing event sent to reset the animations of every character.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class CharacterAnimationResetEvent extends Event {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An event which is sent to the client to switch the currently displayed tab interface.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class DisplayTabInterfaceEvent extends Event {
|
||||
|
||||
/**
|
||||
* The tab index.
|
||||
*/
|
||||
private final int tab;
|
||||
|
||||
/**
|
||||
* Creates a new display tab interface event.
|
||||
*
|
||||
* @param tab The index of the tab to display.
|
||||
*/
|
||||
public DisplayTabInterfaceEvent(int tab) {
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the tab to display.
|
||||
*
|
||||
* @return The tab index.
|
||||
*/
|
||||
public int getTab() {
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The first {@link NpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class FirstNpcActionEvent extends NpcActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a new first npc action event.
|
||||
*
|
||||
* @param npcIndex The index of the npc.
|
||||
*/
|
||||
public FirstNpcActionEvent(int npcIndex) {
|
||||
super(1, npcIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* Represents a change in the client's focus (if it is the active window).
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class FocusUpdateEvent extends Event {
|
||||
|
||||
/**
|
||||
* Dictates whether the client is focused or not.
|
||||
*/
|
||||
private final boolean focused;
|
||||
|
||||
/**
|
||||
* Creates a new focus update event.
|
||||
*
|
||||
* @param update The data received.
|
||||
*/
|
||||
public FocusUpdateEvent(boolean focused) {
|
||||
this.focused = focused;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not the client is focused.
|
||||
*
|
||||
* @return {@code true} if the client is focused, otherwise {@code false}.
|
||||
*/
|
||||
public boolean isFocused() {
|
||||
return focused;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* An event sent by the client when a player casts a spell on an inventory item.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
public final class MagicOnItemEvent extends InventoryItemEvent {
|
||||
|
||||
/**
|
||||
* The spell id.
|
||||
*/
|
||||
private final int spell;
|
||||
|
||||
/**
|
||||
* Creates a new magic on item event.
|
||||
*
|
||||
* @param interfaceId The interface id.
|
||||
* @param id The item id.
|
||||
* @param slot The item slot.
|
||||
* @param spell The spell id.
|
||||
*/
|
||||
public MagicOnItemEvent(int interfaceId, int id, int slot, int spell) {
|
||||
super(0, interfaceId, id, slot);
|
||||
this.spell = spell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spell id.
|
||||
*
|
||||
* @return The spell id.
|
||||
*/
|
||||
public int getSpellId() {
|
||||
return spell;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An{@link Event} sent when the player has clicked on something. TODO
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class MouseClickEvent extends Event {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* An {@link Event} representing the clicking of an npc menu action.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class NpcActionEvent extends Event {
|
||||
|
||||
/**
|
||||
* The action number .
|
||||
*/
|
||||
private final int action;
|
||||
|
||||
/**
|
||||
* The npc index.
|
||||
*/
|
||||
private final int npcIndex;
|
||||
|
||||
/**
|
||||
* Creates a new npc action event.
|
||||
*
|
||||
* @param action The action number.
|
||||
* @param npcIndex The index of the npc.
|
||||
*/
|
||||
public NpcActionEvent(int action, int npcIndex) {
|
||||
this.action = action;
|
||||
this.npcIndex = npcIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the menu action number clicked.
|
||||
*
|
||||
* @return The action number.
|
||||
*/
|
||||
public int getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the npc clicked.
|
||||
*
|
||||
* @return The npc index.
|
||||
*/
|
||||
public int getNpcIndex() {
|
||||
return npcIndex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The second {@link NpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class SecondNpcActionEvent extends NpcActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a new second npc action event.
|
||||
*
|
||||
* @param npcIndex The index of the npc.
|
||||
*/
|
||||
public SecondNpcActionEvent(int npcIndex) {
|
||||
super(2, npcIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
import org.apollo.game.event.Event;
|
||||
|
||||
/**
|
||||
* A message sent after a short period of time containing random data.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class SpamPacketEvent extends Event {
|
||||
|
||||
/**
|
||||
* Data sent by the spam packet.
|
||||
*/
|
||||
private final byte[] data;
|
||||
|
||||
/**
|
||||
* Creates a new spam packet event.
|
||||
*
|
||||
* @param data The data sent.
|
||||
*/
|
||||
public SpamPacketEvent(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data sent.
|
||||
*
|
||||
* @return The data.
|
||||
*/
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
// 0
|
||||
// random * 256
|
||||
// 101
|
||||
// 233
|
||||
// 45092 (short)
|
||||
// 35784 if random * 2= 0
|
||||
// random * 256
|
||||
// 64
|
||||
// 38
|
||||
// Math.random() * 65536
|
||||
// Math.random() * 65536
|
||||
// offset - start offset (exc. the first 0 sent) - size byte.
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.game.event.impl;
|
||||
|
||||
/**
|
||||
* The third {@link NpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class ThirdNpcActionEvent extends NpcActionEvent {
|
||||
|
||||
/**
|
||||
* Creates a new third npc action event.
|
||||
*
|
||||
* @param npcIndex The index of the npc.
|
||||
*/
|
||||
public ThirdNpcActionEvent(int npcIndex) {
|
||||
super(3, npcIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,4 +47,10 @@ public class InterfaceConstants {
|
||||
12201, 12202, 12203, 12204, 12205, 12206, 12207, 12208, 12209, 12210, 12211, 12212, 12213, 12214, 12215,
|
||||
12216, 12217, 12218, 12219, 12220, 12221, 12222, 12223 };
|
||||
|
||||
/**
|
||||
* Prevent instantiation.
|
||||
*/
|
||||
private InterfaceConstants() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -325,9 +325,8 @@ public final class Inventory implements Cloneable {
|
||||
return true;
|
||||
} else if (mode == StackMode.STACK_STACKABLE_ITEMS) {
|
||||
return def.isStackable();
|
||||
} else { // will be STACK_NEVER
|
||||
return false;
|
||||
}
|
||||
return false; // will be STACK_NEVER
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,15 @@ public final class ItemDefinition {
|
||||
return definitions.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the array of item definitions.
|
||||
*
|
||||
* @return The definitions.
|
||||
*/
|
||||
public static ItemDefinition[] getDefinitions() {
|
||||
return definitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the class with the specified set of definitions.
|
||||
*
|
||||
@@ -121,7 +130,7 @@ public final class ItemDefinition {
|
||||
/**
|
||||
* A flag indicating if this item is members only.
|
||||
*/
|
||||
private boolean members;
|
||||
private boolean members = false;
|
||||
|
||||
/**
|
||||
* The name of the item.
|
||||
@@ -149,9 +158,9 @@ public final class ItemDefinition {
|
||||
private int team;
|
||||
|
||||
/**
|
||||
* The value of the item.
|
||||
* The item's floor value.
|
||||
*/
|
||||
private int value;
|
||||
private int value = 1;
|
||||
|
||||
/**
|
||||
* Creates an item definition with the default values.
|
||||
@@ -186,9 +195,9 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item's id.
|
||||
* Gets this item's id.
|
||||
*
|
||||
* @return The item's id.
|
||||
* @return The id.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
@@ -209,16 +218,16 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this item.
|
||||
* Gets this item's name.
|
||||
*
|
||||
* @return The name of this item, or {@code null} if it has no name.
|
||||
* @return The name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the note graphic id.
|
||||
* Gets this item's note graphic id.
|
||||
*
|
||||
* @return The note graphic id.
|
||||
*/
|
||||
@@ -227,7 +236,7 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the note info id.
|
||||
* Gets this item's note info id.
|
||||
*
|
||||
* @return The note info id.
|
||||
*/
|
||||
@@ -245,9 +254,9 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of this item.
|
||||
* Gets this item's value.
|
||||
*
|
||||
* @return The value of this item.
|
||||
* @return The value.
|
||||
*/
|
||||
public int getValue() {
|
||||
return value;
|
||||
@@ -281,9 +290,9 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description of this item.
|
||||
* Sets this item's description.
|
||||
*
|
||||
* @param description The item's description.
|
||||
* @param description The description.
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
@@ -318,25 +327,25 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the members only flag.
|
||||
* Sets this item's members only flag.
|
||||
*
|
||||
* @param members The members only flag.
|
||||
* @param members The flag.
|
||||
*/
|
||||
public void setMembersOnly(boolean members) {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of this item.
|
||||
* Sets this item's name.
|
||||
*
|
||||
* @param name The item's name.
|
||||
* @param name The name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the note graphic id.
|
||||
* Sets this item's note graphic id.
|
||||
*
|
||||
* @param noteGraphicId The note graphic id.
|
||||
*/
|
||||
@@ -345,7 +354,7 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the note info id.
|
||||
* Sets this item's note info id.
|
||||
*
|
||||
* @param noteInfoId The note info id.
|
||||
*/
|
||||
@@ -354,7 +363,7 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stackable flag.
|
||||
* Sets this item's stackable flag.
|
||||
*
|
||||
* @param stackable The stackable flag.
|
||||
*/
|
||||
@@ -363,7 +372,7 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this items team.
|
||||
* Sets this item's team.
|
||||
*
|
||||
* @param team The team.
|
||||
*/
|
||||
@@ -372,9 +381,9 @@ public final class ItemDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of this item.
|
||||
* sets this item's value.
|
||||
*
|
||||
* @param value The value of this item.
|
||||
* @param value The value.
|
||||
*/
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
@@ -394,7 +403,6 @@ public final class ItemDefinition {
|
||||
ItemDefinition infoDef = lookup(noteInfoId);
|
||||
name = infoDef.name;
|
||||
members = infoDef.members;
|
||||
value = infoDef.value;
|
||||
|
||||
String prefix = "a";
|
||||
char firstChar = name == null ? 'n' : name.charAt(0);
|
||||
|
||||
@@ -23,6 +23,15 @@ public final class NpcDefinition {
|
||||
return definitions.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the array of npc definitions.
|
||||
*
|
||||
* @return The definitions.
|
||||
*/
|
||||
public static NpcDefinition[] getDefinitions() {
|
||||
return definitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the class with the specified set of definitions.
|
||||
*
|
||||
|
||||
@@ -36,9 +36,10 @@ public final class GameEventDecoder extends OneToOneDecoder {
|
||||
if (decoder != null) {
|
||||
return decoder.decode(packet);
|
||||
}
|
||||
System.out.println("Unidentified packet received - opcode: " + packet.getOpcode() + ".");
|
||||
return null;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -64,4 +64,4 @@ public final class GamePacketEncoder extends OneToOneEncoder {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -111,4 +111,4 @@ public abstract class Release {
|
||||
decoders[opcode] = decoder;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.ArrowKeyEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link ArrowKeyEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class ArrowKeyEventDecoder extends EventDecoder<ArrowKeyEvent> {
|
||||
|
||||
@Override
|
||||
public ArrowKeyEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int roll = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
int yaw = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new ArrowKeyEvent(roll, yaw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.CameraMovementEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link CameraMovementEvent}.
|
||||
*
|
||||
* @author Toby
|
||||
*/
|
||||
public class CameraMovementEventDecoder extends EventDecoder<CameraMovementEvent> {
|
||||
|
||||
@Override
|
||||
public CameraMovementEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int cameraY = (int) reader.getUnsigned(DataType.SHORT);
|
||||
int cameraX = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
return new CameraMovementEvent(cameraX, cameraY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.CharacterAnimationResetEvent;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.release.EventEncoder;
|
||||
|
||||
/**
|
||||
* An {@link EventEncoder} for the {@link CharacterAnimationResetEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class CharacterAnimationResetEventEncoder extends EventEncoder<CharacterAnimationResetEvent> {
|
||||
|
||||
@Override
|
||||
public GamePacket encode(CharacterAnimationResetEvent event) {
|
||||
return new GamePacketBuilder(1).toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.DisplayTabInterfaceEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.release.EventEncoder;
|
||||
|
||||
/**
|
||||
* An {@link EventEncoder} for the {@link DisplayTabInterfaceEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
final class DisplayTabInterfaceEventEncoder extends EventEncoder<DisplayTabInterfaceEvent> {
|
||||
|
||||
@Override
|
||||
public GamePacket encode(DisplayTabInterfaceEvent event) {
|
||||
GamePacketBuilder builder = new GamePacketBuilder(106);
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, event.getTab());
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.FocusUpdateEvent;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FocusUpdateEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class FocusUpdateEventDecoder extends EventDecoder<FocusUpdateEvent> {
|
||||
|
||||
@Override
|
||||
public FocusUpdateEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
boolean focused = (byte) reader.getUnsigned(DataType.BYTE) == 1;
|
||||
return new FocusUpdateEvent(focused);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.MagicOnItemEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link MagicOnItemEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
final class MagicOnItemEventDecoder extends EventDecoder<MagicOnItemEvent> {
|
||||
|
||||
@Override
|
||||
public MagicOnItemEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
int slot = (int) reader.getUnsigned(DataType.SHORT);
|
||||
int id = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
int interfaceId = (int) reader.getUnsigned(DataType.SHORT);
|
||||
int spell = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
|
||||
return new MagicOnItemEvent(interfaceId, id, slot, spell);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.MouseClickEvent;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link MouseClickEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class MouseClickEventDecoder extends EventDecoder<MouseClickEvent> {
|
||||
|
||||
@Override
|
||||
public MouseClickEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
reader.getUnsigned(DataType.INT);
|
||||
return new MouseClickEvent();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.CloseInterfaceEvent;
|
||||
import org.apollo.game.event.impl.ConfigEvent;
|
||||
import org.apollo.game.event.impl.DisplayTabInterfaceEvent;
|
||||
import org.apollo.game.event.impl.EnterAmountEvent;
|
||||
import org.apollo.game.event.impl.IdAssignmentEvent;
|
||||
import org.apollo.game.event.impl.LogoutEvent;
|
||||
@@ -23,6 +24,9 @@ import org.apollo.game.event.impl.UpdateSkillEvent;
|
||||
import org.apollo.game.event.impl.UpdateSlottedItemsEvent;
|
||||
import org.apollo.net.meta.PacketMetaDataGroup;
|
||||
import org.apollo.net.release.Release;
|
||||
import org.apollo.net.release.r377.FirstNpcActionEventDecoder;
|
||||
import org.apollo.net.release.r377.SecondNpcActionEventDecoder;
|
||||
import org.apollo.net.release.r377.ThirdNpcActionEventDecoder;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Release} for the 317 protocol.
|
||||
@@ -106,6 +110,17 @@ public final class Release317 extends Release {
|
||||
register(130, new ClosedInterfaceEventDecoder());
|
||||
register(208, new EnteredAmountEventDecoder());
|
||||
register(53, new ItemOnItemEventDecoder());
|
||||
register(237, new MagicOnItemEventDecoder());
|
||||
|
||||
register(3, new FocusUpdateEventDecoder());
|
||||
register(241, new MouseClickEventDecoder());
|
||||
register(86, new ArrowKeyEventDecoder());
|
||||
SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder();
|
||||
register(77, spamEventDecoder);
|
||||
|
||||
register(72, new FirstNpcActionEventDecoder());
|
||||
register(155, new SecondNpcActionEventDecoder());
|
||||
register(17, new ThirdNpcActionEventDecoder());
|
||||
|
||||
// register encoders
|
||||
register(IdAssignmentEvent.class, new IdAssignmentEventEncoder());
|
||||
@@ -129,6 +144,7 @@ public final class Release317 extends Release {
|
||||
register(SetWidgetPlayerModelEvent.class, new SetWidgetPlayerModelEventEncoder());
|
||||
register(SetWidgetModelAnimationEvent.class, new SetWidgetModelAnimationEventEncoder());
|
||||
register(ConfigEvent.class, new ConfigEventEncoder());
|
||||
register(DisplayTabInterfaceEvent.class, new DisplayTabInterfaceEventEncoder());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.net.release.r317;
|
||||
|
||||
import org.apollo.game.event.impl.SpamPacketEvent;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link SpamPacketEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class SpamPacketEventDecoder extends EventDecoder<SpamPacketEvent> {
|
||||
|
||||
@Override
|
||||
public SpamPacketEvent decode(GamePacket packet) {
|
||||
return new SpamPacketEvent(packet.getPayload().array());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.ArrowKeyEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link ArrowKeyEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class ArrowKeyEventDecoder extends EventDecoder<ArrowKeyEvent> {
|
||||
|
||||
@Override
|
||||
public ArrowKeyEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int roll = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
int yaw = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new ArrowKeyEvent(roll, yaw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.CharacterAnimationResetEvent;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.release.EventEncoder;
|
||||
|
||||
/**
|
||||
* An {@link EventEncoder} for the {@link CharacterAnimationResetEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class CharacterAnimationResetEventEncoder extends EventEncoder<CharacterAnimationResetEvent> {
|
||||
|
||||
@Override
|
||||
public GamePacket encode(CharacterAnimationResetEvent event) {
|
||||
return new GamePacketBuilder(13).toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.DisplayTabInterfaceEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.release.EventEncoder;
|
||||
|
||||
/**
|
||||
* An {@link EventEncoder} for the {@link DisplayTabInterfaceEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
final class DisplayTabInterfaceEventEncoder extends EventEncoder<DisplayTabInterfaceEvent> {
|
||||
|
||||
@Override
|
||||
public GamePacket encode(DisplayTabInterfaceEvent event) {
|
||||
GamePacketBuilder builder = new GamePacketBuilder(252);
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, event.getTab());
|
||||
return builder.toGamePacket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.FirstNpcActionEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* The {@link EventDecoder} for the {@link FirstNpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class FirstNpcActionEventDecoder extends EventDecoder<FirstNpcActionEvent> {
|
||||
|
||||
@Override
|
||||
public FirstNpcActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
return new FirstNpcActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.FocusUpdateEvent;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link FocusUpdateEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class FocusUpdateEventDecoder extends EventDecoder<FocusUpdateEvent> {
|
||||
|
||||
@Override
|
||||
public FocusUpdateEvent decode(GamePacket packet) {
|
||||
GamePacketReader decoder = new GamePacketReader(packet);
|
||||
return new FocusUpdateEvent(decoder.getUnsigned(DataType.BYTE) == 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.MagicOnItemEvent;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link MagicOnItemEvent}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
final class MagicOnItemEventDecoder extends EventDecoder<MagicOnItemEvent> {
|
||||
|
||||
@Override
|
||||
public MagicOnItemEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
|
||||
int spell = (int) reader.getUnsigned(DataType.SHORT);
|
||||
int interfaceId = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
int slot = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
int id = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
|
||||
|
||||
return new MagicOnItemEvent(interfaceId, id, slot, spell);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.MouseClickEvent;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link MouseClickEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class MouseClickEventDecoder extends EventDecoder<MouseClickEvent> {
|
||||
|
||||
@Override
|
||||
public MouseClickEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
reader.getUnsigned(DataType.INT);
|
||||
return new MouseClickEvent();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.CloseInterfaceEvent;
|
||||
import org.apollo.game.event.impl.ConfigEvent;
|
||||
import org.apollo.game.event.impl.DisplayTabInterfaceEvent;
|
||||
import org.apollo.game.event.impl.EnterAmountEvent;
|
||||
import org.apollo.game.event.impl.IdAssignmentEvent;
|
||||
import org.apollo.game.event.impl.LogoutEvent;
|
||||
@@ -106,6 +107,19 @@ public final class Release377 extends Release {
|
||||
register(110, new ClosedInterfaceEventDecoder());
|
||||
register(75, new EnteredAmountEventDecoder());
|
||||
register(1, new ItemOnItemEventDecoder());
|
||||
register(36, new MagicOnItemEventDecoder());
|
||||
|
||||
register(187, new FocusUpdateEventDecoder());
|
||||
register(19, new MouseClickEventDecoder());
|
||||
register(140, new ArrowKeyEventDecoder());
|
||||
|
||||
SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder();
|
||||
register(40, spamEventDecoder);
|
||||
register(244, spamEventDecoder);
|
||||
|
||||
register(67, new FirstNpcActionEventDecoder());
|
||||
register(112, new SecondNpcActionEventDecoder());
|
||||
register(13, new ThirdNpcActionEventDecoder());
|
||||
|
||||
// register encoders
|
||||
register(IdAssignmentEvent.class, new IdAssignmentEventEncoder());
|
||||
@@ -129,6 +143,7 @@ public final class Release377 extends Release {
|
||||
register(SetWidgetPlayerModelEvent.class, new SetWidgetPlayerModelEventEncoder());
|
||||
register(SetWidgetModelAnimationEvent.class, new SetWidgetModelAnimationEventEncoder());
|
||||
register(ConfigEvent.class, new ConfigEventEncoder());
|
||||
register(DisplayTabInterfaceEvent.class, new DisplayTabInterfaceEventEncoder());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.SecondNpcActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* The {@link EventDecoder} for the {@link SecondNpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class SecondNpcActionEventDecoder extends EventDecoder<SecondNpcActionEvent> {
|
||||
|
||||
@Override
|
||||
public SecondNpcActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
|
||||
return new SecondNpcActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.SpamPacketEvent;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* An {@link EventDecoder} for the {@link SpamPacketEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class SpamPacketEventDecoder extends EventDecoder<SpamPacketEvent> {
|
||||
|
||||
@Override
|
||||
public SpamPacketEvent decode(GamePacket packet) {
|
||||
return new SpamPacketEvent(packet.getPayload().array());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.apollo.net.release.r377;
|
||||
|
||||
import org.apollo.game.event.impl.ThirdNpcActionEvent;
|
||||
import org.apollo.net.codec.game.DataOrder;
|
||||
import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketReader;
|
||||
import org.apollo.net.release.EventDecoder;
|
||||
|
||||
/**
|
||||
* The {@link EventDecoder} for the {@link ThirdNpcActionEvent}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public class ThirdNpcActionEventDecoder extends EventDecoder<ThirdNpcActionEvent> {
|
||||
|
||||
@Override
|
||||
public ThirdNpcActionEvent decode(GamePacket packet) {
|
||||
GamePacketReader reader = new GamePacketReader(packet);
|
||||
int index = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
|
||||
return new ThirdNpcActionEvent(index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -167,10 +167,10 @@ public final class PluginManager {
|
||||
String[] scripts = plugin.getScripts();
|
||||
|
||||
for (String script : scripts) {
|
||||
File f = new File("./data/plugins/" + plugin.getId() + "/" + script); // TODO get from metadata obj?
|
||||
File f = new File("./data/plugins/" + plugin.getId() + "/" + script);
|
||||
InputStream is = new FileInputStream(f);
|
||||
env.parse(is, f.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user