mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
5686a1dcd6
* Allows switching between different combat styles, and updates the combat tabs styles for every equipped weapon. If a weapon with a special attack is equipped, the special bar for that interface will be shown. * Adds a scheduled task which periodically restores special energy to the player and updates their special bar.
71 lines
2.4 KiB
Ruby
71 lines
2.4 KiB
Ruby
java_import 'org.apollo.game.model.inter.InterfaceConstants'
|
|
java_import 'org.apollo.game.model.entity.EquipmentConstants'
|
|
java_import 'org.apollo.game.message.impl.SetWidgetTextMessage'
|
|
java_import 'org.apollo.game.message.impl.SetInterfaceConfigMessage'
|
|
java_import 'org.apollo.game.message.impl.ConfigMessage'
|
|
java_import 'org.apollo.game.model.inv.SynchronizationInventoryListener'
|
|
|
|
|
|
on :message, :item_option do |player, message|
|
|
update_combat_tab(player) if message.option == 2 and message.interface_id == SynchronizationInventoryListener::INVENTORY_ID
|
|
end
|
|
|
|
on :login do |event|
|
|
update_combat_tab(event.player)
|
|
end
|
|
|
|
on :message, :item_action do |player, message|
|
|
update_combat_tab(player) if message.interface_id == SynchronizationInventoryListener::EQUIPMENT_ID and message.slot == EquipmentConstants::WEAPON
|
|
end
|
|
|
|
|
|
on :message, :button do |player, msg|
|
|
weapon = EquipmentUtil.equipped_weapon player
|
|
weapon_class = weapon.weapon_class
|
|
weapon_class_widget = weapon_class.widget
|
|
|
|
next unless weapon_class_widget == msg.interface_id
|
|
|
|
if weapon_class.special_bar? and msg.button == weapon_class.special_bar_button
|
|
player.using_special = !player.using_special
|
|
update_special_bar(player)
|
|
else
|
|
player.combat_style = msg.button
|
|
end
|
|
|
|
update_combat_style player
|
|
end
|
|
|
|
private
|
|
|
|
def update_combat_tab(player)
|
|
weapon = EquipmentUtil.equipped_weapon player
|
|
weapon_name = weapon.name
|
|
weapon_class = weapon.weapon_class
|
|
weapon_class_widget = weapon_class.widget
|
|
|
|
attack_style_interface_layer = InterfaceConstants::UserInterface::ATTACK_STYLE.layer
|
|
|
|
player.interface_set.send_user_interface(attack_style_interface_layer, weapon_class_widget)
|
|
player.send SetWidgetTextMessage.new(weapon_class_widget, 0, weapon_name)
|
|
|
|
if weapon_class.special_bar?
|
|
player.send SetInterfaceConfigMessage.new(weapon_class_widget, weapon_class.special_bar_config, !weapon.special_attack?)
|
|
end
|
|
|
|
update_combat_style player
|
|
end
|
|
|
|
def update_combat_style(player)
|
|
weapon = EquipmentUtil.equipped_weapon player
|
|
weapon_class = weapon.weapon_class
|
|
|
|
# Update the combat style in case we had an invalid style selected,
|
|
# and therefore reverted to the first combat style
|
|
selected_style = weapon_class.style_at(player.combat_style)
|
|
|
|
player.combat_style = weapon_class.button selected_style
|
|
player.send ConfigMessage.new(43, weapon_class.config(selected_style))
|
|
end
|
|
|