Add support for specifying the option for events in the declaration (where applicable).

This commit is contained in:
Major-
2014-08-08 02:00:01 +01:00
parent a863d8ea71
commit 22f712da23
9 changed files with 89 additions and 96 deletions
+11 -13
View File
@@ -47,21 +47,19 @@ on :event, :item_on_item do |ctx, player, event|
end
# The ItemOptionEvent handler for all Herblore-related functions.
on :event, :item_option do |ctx, player, event|
if event.option == 1
id = event.id
method = HERBLORE_ITEM[id]
on :event, :first_item_option do |ctx, player, event|
id = event.id
method = HERBLORE_ITEM[id]
if method != nil
method.invoke(player, id, event.slot)
ctx.break_handler_chain
end
method = DRINK_ITEM[id]
if method != nil
method.invoke(player, id, event.slot)
ctx.break_handler_chain
end
method = DRINK_ITEM[id]
if method != nil
method.invoke(player, id, event.slot)
ctx.break_handler_chain
end
if method != nil
method.invoke(player, id, event.slot)
ctx.break_handler_chain
end
end
+10 -14
View File
@@ -141,22 +141,18 @@ class ProspectingAction < DistancedAction
end
end
on :event, :object_action do |ctx, mob, event|
if event.option == 1
ore = ORES[event.id]
if ore != nil
mob.start_action(MiningAction.new(mob, event.position, ore))
end
on :event, :first_object_action do |ctx, mob, event|
ore = ORES[event.id]
if ore != nil
mob.start_action(MiningAction.new(mob, event.position, ore))
end
end
on :event, :object_action do |ctx, mob, event|
if event.option == 2
ore = ORES[event.id]
if ore != nil
mob.start_action(ProspectingAction.new(mob, event.position, ore))
elsif EXPIRED_ORES[event.id] != nil
mob.start_action(ExpiredProspectingAction.new(mob, event.position))
end
on :event, :second_object_action do |ctx, mob, event|
ore = ORES[event.id]
if ore != nil
mob.start_action(ProspectingAction.new(mob, event.position, ore))
elsif EXPIRED_ORES[event.id] != nil
mob.start_action(ExpiredProspectingAction.new(mob, event.position))
end
end
+5 -7
View File
@@ -43,13 +43,11 @@ class BuryBoneAction < Action
end
# Intercepts the first item option event,
on :event, :item_option do |ctx, player, event|
if event.option == 1
bone = BONES[event.id]
unless bone == nil
player.start_action(BuryBoneAction.new(player, event.slot, bone))
ctx.break_handler_chain
end
on :event, :first_item_option do |ctx, player, event|
bone = BONES[event.id]
unless bone == nil
player.start_action(BuryBoneAction.new(player, event.slot, bone))
ctx.break_handler_chain
end
end
+5 -7
View File
@@ -30,13 +30,11 @@ def append_talisman(hash)
end
# Intercepts the item option event.
on :event, :item_option do |ctx, player, event|
if (event.option == 4)
talisman = TALISMANS[event.id]
if (talisman != nil)
player.send_message(talisman.get_message(player.position))
ctx.break_handler_chain
end
on :event, :fourth_item_option do |ctx, player, event|
talisman = TALISMANS[event.id]
if (talisman != nil)
player.send_message(talisman.get_message(player.position))
ctx.break_handler_chain
end
end
+22 -28
View File
@@ -48,7 +48,7 @@ on :login do |player|
hat = player.equipment.get(EquipmentConstants::HAT)
if hat != nil
tiara = TIARAS_BY_ID[hat]
if(tiara != nil)
if (tiara != nil)
tiara.send_config
return
end
@@ -57,42 +57,36 @@ on :login do |player|
end
#Accesses the altar with 1 click when wielding the correct tiara.
on :event, :object_action do |ctx, player, event|
if (event.option == 1)
object_id = event.id
tiara = TIARAS_BY_ALTAR[object_id]
if(tiara != nil)
hat = player.equipment.get(EquipmentConstants::HAT)
if(hat != nil && hat.id == tiara.tiara_id)
altar = ENTRANCE_ALTARS[tiara.altar]
if(altar != nil)
player.start_action(TeleportAction.new(player, event.position, 2, altar.entrance_position))
end
ctx.break_handler_chain
end
on :event, :second_object_action do |ctx, player, event|
object_id = event.id
tiara = TIARAS_BY_ALTAR[object_id]
if (tiara != nil)
hat = player.equipment.get(EquipmentConstants::HAT)
if (hat != nil && hat.id == tiara.tiara_id)
altar = ENTRANCE_ALTARS[tiara.altar]
if (altar != nil)
player.start_action(TeleportAction.new(player, event.position, 2, altar.entrance_position))
end
ctx.break_handler_chain
end
end
end
#Equip tiara
on :event, :item_option do |ctx, player, event|
if (event.option == 2)
tiara = TIARAS_BY_ID[event.id]
if(tiara != nil)
tiara.send_config(player)
ctx.break_handler_chain
end
on :event, :second_item_option, item_option do |ctx, player, event|
tiara = TIARAS_BY_ID[event.id]
if (tiara != nil)
tiara.send_config(player)
ctx.break_handler_chain
end
end
#Unequip tiara
on :event, :item_action do |ctx, player, event|
if (event.option == 1)
tiara = TIARAS_BY_ID[event.id]
if(tiara != nil)
send_empty_config(player)
ctx.break_handler_chain
end
on :event, :first_item_action do |ctx, player, event|
tiara = TIARAS_BY_ID[event.id]
if (tiara != nil)
send_empty_config(player)
ctx.break_handler_chain
end
end