Housekeeping

This commit is contained in:
KeepBotting
2019-03-26 14:05:40 -04:00
parent a0c78ced90
commit 739c331860
135 changed files with 4 additions and 4 deletions
@@ -0,0 +1,158 @@
require 'java'
java_import 'org.apollo.game.message.impl.HintIconMessage'
java_import 'org.apollo.game.message.impl.MobHintIconMessage'
java_import 'org.apollo.game.message.impl.PositionHintIconMessage'
java_import 'org.apollo.game.message.impl.SwitchTabInterfaceMessage'
java_import 'org.apollo.game.model.entity.EntityType'
java_import 'org.apollo.game.model.Position'
private
# Contains constants used during the Runescape Guide part of Tutorial Island.
module GuideConstants
# The Runescape Guide Npc.
RUNESCAPE_GUIDE = spawn_npc name: :runescape_guide, x: 3093, y: 3107
# The character design interface id.
CHARACTER_DESIGN_INTERFACE = 3559
# The id of the door of the house new players spawn in.
DOOR_ID = 3014
# The Position of the door of the house new players spawn in.
DOOR_POSITION = Position.new(3098, 3107)
# The HintIconMessage sent to display a hint arrow above the door of the house new players spawn
# in.
DOOR_HINT = PositionHintIconMessage.new(HintIconMessage::Type::WEST, DOOR_POSITION, 120)
# The ids of tabs that are displayed when the player has yet to start the tutorial.
INITIAL_TABS = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2449, 904, -1, -1].freeze
# The HintIconMessage sent to remove a hint arrow from above the door.
RESET_DOOR_HINT = PositionHintIconMessage.reset
# The HintIconMessage sent to remove a hint arrow from an Npc.
RESET_NPC_HINT = MobHintIconMessage.reset(EntityType::NPC)
end
# Sends the appropriate data to the client when the player logs in to the game.
on :login do |_event, player|
if player.in_tutorial_island && player.privilege_level != RIGHTS_ADMIN
TutorialInstructions.show_instruction(player)
GuideConstants::INITIAL_TABS.each_with_index do |tab, index|
player.send(SwitchTabInterfaceMessage.new(index, tab))
end
if player.tutorial_island_progress == :not_started
player.interface_set.open_window(GuideConstants::CHARACTER_DESIGN_INTERFACE)
player.send(MobHintIconMessage.create(GuideConstants::RUNESCAPE_GUIDE))
end
end
end
# The conversation with the Runescape Guide, when on tutorial island.
conversation :tutorial_runescape_guide do
# The first dialogue of the Runescape Guide, greeting the Player.
dialogue :greetings do
type :npc_speech
npc :runescape_guide
emote :calm
precondition { |player| player.tutorial_island_progress == :not_started }
text 'Greetings! I see you are a new arrival to this land. My job is to welcome all new '\
'visitors. So welcome!'
continue dialogue: :talk_to_people do |player|
player.tutorial_island_progress = :talk_to_people
end
end
# The Guide welcomes back the Player if they speak to him after they have already gone through
# the conversation once.
dialogue :welcome_back do
type :npc_speech
npc :runescape_guide
emote :calm
precondition { |player| player.tutorial_island_progress != :not_started }
text 'Welcome back.'
continue dialogue: :talk_to_people
end
# The Guide tells Players to speak to people in order to succeed.
dialogue :talk_to_people do
type :npc_speech
npc :runescape_guide
emote :calm
text 'You have already learned the first thing you need to succeed in this world: talking to '\
'people!',
'You will find many inhabitants of this world have useful things to say to you. By '\
'clicking on them with your mouse you can talk to them.',
'I would also suggest reading through some of the supporting information on the website.'\
' There you can find maps, a bestiary, and much more.'
continue dialogue: :go_through_door
end
# The Guide tells Players to go through the door, advancing the tutorial progress if this is the
# first time the Player has heard this.
dialogue :go_through_door do
type :npc_speech
npc :runescape_guide
emote :calm
text 'To continue the tutorial go through that door over there, and speak to your first '\
'instructor.'
close do |player|
if player.tutorial_island_progress < :runescape_guide_finished
player.send(GuideConstants::RESET_NPC_HINT)
player.send(GuideConstants::DOOR_HINT)
player.tutorial_island_progress = :runescape_guide_finished
end
TutorialInstructions.show_instruction(player)
end
end
# The dialogue displayed if the player attempts to leave the Runescape Guide's house before they
# have spoken to him.
dialogue :talk_to_guide do
type :text
text 'You need to talk to the Runescape Guide before you are allowed to proceed through this '\
'door.'
close do |player|
TutorialInstructions.show_instruction(player)
end
end
end
on :open_door do |event, player|
door = event.door
if player.in_tutorial_island && door.position.equals(GuideConstants::DOOR_POSITION)
if player.tutorial_island_progress < :runescape_guide_finished
send_dialogue(player, get_dialogue(:tutorial_runescape_guide, :talk_to_guide))
event.terminate
elsif player.tutorial_island_progress == :runescape_guide_finished
player.tutorial_island_progress = :moving_around
player.send(GuideConstants::RESET_DOOR_HINT)
TutorialInstructions.show_instruction(player)
end
end
end
@@ -0,0 +1,141 @@
# Contains members related to the instructions issues during tutorial island.
module TutorialInstructions
# Sends the appropriate instruction to the player.
def self.show_instruction(player)
instructions = CONVERSATIONS[:tutorial_island_instructions]
progress = player.tutorial_island_progress.name
name = case progress
# The Runescape Guide instructions.
when :not_started then :getting_started
when :runescape_guide_finished then :scenery
when :moving_around then :moving_around
# The Survival Guide instructions.
when :given_axe then :viewing_items
when :cut_tree then :cut_tree
when :cutting_tree then :please_wait
else raise "No dialogue for current stage #{progress} exists."
end
dialogue = instructions.part(name)
send_dialogue(player, dialogue)
end
# The one-sided 'conversation' of instruction instructions.
conversation :tutorial_island_instructions do
# The initial instruction displayed when the player logs in, before they have spoken to the
# guide.
dialogue :getting_started do
type :text
title 'Getting started'
text 'To start the tutorial, use your left mouse button to click on the Runescape Guide in '\
'this room. He is indicated by a flashing yellow arrow above his head. If you can\'t '\
'see him, use your keyboard\'s arrow keys to rotate the view.'
end
# The instruction displayed after the player has spoken to the Runescape Guide.
dialogue :scenery do
type :text
title 'Interacting with scenery'
text 'You can interact with many items of the scenery by simply clicking on them. Right '\
'clicking will also give more options. Click on the door indicated with the yellow '\
'arrow to go through to the next area and speak with your next instructor.'
end
# The instruction displayed after the player has left the initial building.
dialogue :moving_around do
type :text
title 'Moving around'
text 'Follow the path to find the next instructor. Clicking on the ground will walk you to '\
'that point. Talk to the survival expert by the pond to continue the tutorial. '\
'Remember you can rotate the view by pressing the arrow keys.'
end
# The instruction displayed after the player has been given the tinderbox and bronze axe by the
# Survival Guide.
dialogue :viewing_items do
type :text
title 'Viewing the items you were given'
text 'Click on the flashing backpack icon to the right side of the main window to view your '\
'inventory. Your inventory is a list of everything you have in your backpack.'
end
# The instruction displayed if the player tries to cut a tree before having the axe.
dialogue :try_cut_tree do
type :text
title 'Follow the guide\'s instructions'
text 'You cannot cut down this tree, you must first follow the guide\'s instructions.'
end
# The instruction displayed before the player has begun to cut the tree.
dialogue :cut_tree do
type :text
title 'Cut down a tree'
text 'You can click on the backpack icon at any time to view the items that you currently '\
'have in your inventory. You will see that you now have an axe in your inventory. '\
'Use this to get some logs by clicking on the indicated tree.'
end
# The instruction displayed when the player begins to cut the tree.
dialogue :please_wait do
type :text
title 'Please wait...'
text 'Your character is now attempting to cut down the tree. Sit back for a moment whilst '\
'he does all the hard work.' # TODO: she instead of he if applicable
end
# The instruction displayed after the player has successfully cut logs from the tree.
dialogue :make_a_fire do
type :text
title 'Making a fire'
text 'Well done! You managed to cut some logs from the tree! Next, use the tinderbox in '\
'your inventory to light the logs. First click on the tinderbox to \'use\' it.'\
'Then click on the logs in your inventory to light them.'
end
# The instruction displayed when the player begins to light the fire.
dialogue :lighting_fire do
type :text
title 'Please wait...'
# TODO: she instead of he if applicable
text 'Your character is now attempting to light the logs. Sit back for a moment whilst he '\
'does all the hard work.'
end
# The instruction displayed when the has lit the logs.
dialogue :gained_experience do
type :text
text 'You gained some experience.'\
'Click on the flashing bar graph icon near the inventory button to see your skill '\
'stats.'
end
# The dialogue displayed when the Player has clicked the flashing skill tab icon.
dialogue :skill_stats do
type :text
title 'Your skill stats.'
text 'Here you will see how good your skills are. As you move your mouse over any of the '\
'icons in this panel, the small yellow popup box will show you the exact amount of '\
'experience you have and how much is needed to get to the next level. Speak to the '\
'Survival Expert to continue.'
end
end
end
@@ -0,0 +1,40 @@
# Functional npcs
# 'Above-ground' npcs
spawn_npc name: :master_chef, x: 3076, y: 3085
spawn_npc name: :quest_guide, x: 3086, y: 3122, face: :north
spawn_npc name: :financial_advisor, x: 3127, y: 3124, face: :west
spawn_npc name: :brother_brace, x: 3124, y: 3107, face: :east
spawn_npc name: :magic_instructor, x: 3140, y: 3085
# 'Below-ground' npcs
# Note: They aren't actually on a different plane, they're just in a different location that
# pretends to be underground.
spawn_npc name: :mining_instructor, x: 3081, y: 9504
spawn_npc name: :combat_instructor, x: 3104, y: 9506
# Non-humanoid npcs
spawn_npc name: :fishing_spot_316, x: 3102, y: 3093
spawn_npc name: :chicken, x: 3140, y: 3095
spawn_npc name: :chicken, x: 3140, y: 3093
spawn_npc name: :chicken, x: 3138, y: 3092
spawn_npc name: :chicken, x: 3137, y: 3094
spawn_npc name: :chicken, x: 3138, y: 3095
# 'Below-ground' npcs
# Note: They aren't actually on a different plane, they're just in a different location that
# pretends to be underground.
spawn_npc name: :giant_rat_87, x: 3105, y: 9514
spawn_npc name: :giant_rat_87, x: 3105, y: 9517
spawn_npc name: :giant_rat_87, x: 3106, y: 9514
spawn_npc name: :giant_rat_87, x: 3104, y: 9514
spawn_npc name: :giant_rat_87, x: 3105, y: 9519
spawn_npc name: :giant_rat_87, x: 3109, y: 9516
spawn_npc name: :giant_rat_87, x: 3108, y: 9520
spawn_npc name: :giant_rat_87, x: 3102, y: 9517
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<plugin>
<id>location-tutorial-island</id>
<version>0.1</version>
<name>Tutorial Island</name>
<description>Adds functionality to Tutorial island.</description>
<authors>
<author>Major</author>
</authors>
<scripts>
<script>instructions.rb</script>
<script>guide.rb</script>
<script>npcs.rb</script>
<script>stages.rb</script>
<script>survival.rb</script>
<script>utils.rb</script>
</scripts>
<dependencies>
<dependency>dialogue</dependency>
<dependency>door</dependency>
<dependency>entity-spawning</dependency>
<dependency>quest</dependency>
</dependencies>
</plugin>
@@ -0,0 +1,16 @@
private
# The array of stages in tutorial island.
@stages = []
# The stages that are used when interacting with the Runescape Guide.
RUNESCAPE_GUIDE = [:not_started, :talk_to_people, :go_through_door, :runescape_guide_finished,
:moving_around].freeze
@stages.concat(RUNESCAPE_GUIDE)
# The stages that are used when interacting with the Survival Expert.
SURVIVAL_EXPERT = [:given_axe, :cut_tree, :cutting_tree].freeze
@stages.concat(SURVIVAL_EXPERT)
quest :tutorial_island, @stages
@@ -0,0 +1,154 @@
require 'java'
java_import 'org.apollo.game.message.impl.FlashTabInterfaceMessage'
java_import 'org.apollo.game.message.impl.FlashingTabClickedMessage'
java_import 'org.apollo.game.message.impl.SwitchTabInterfaceMessage'
private
# Contains Survival Expert-related constants.
module SurvivalConstants
# The Survival Expert Npc.
@survival_expert = spawn_npc name: :survival_expert, x: 3104, y: 3095, face: :north
# The inventory tab index.
INVENTORY_TAB_INDEX = 3
# The inventory tab id.
INVENTORY_TAB_ID = 3213
# The id of the tree the Player will cut down.
TREE_ID = 3033
# The id of the bronze axe.
BRONZE_AXE = lookup_item(:bronze_axe)
# The id of the tinderbox.
TINDERBOX = lookup_item(:tinderbox)
end
# The conversation with the Survival Expert, when on tutorial island.
conversation :tutorial_survival_expert do
dialogue :introduction do
type :npc_speech
npc :survival_expert
precondition { |player| player.tutorial_island_progress == :moving_around }
text 'Hello there, newcomer. My name is Brynna. My job is to teach you a few survival tips and'\
' tricks. First off we\'re going to start with the most basic survival skill of all: '\
'making a fire.'
close { |player| add_survival_items(player) }
end
dialogue :hello_again do
type :npc_speech
npc :survival_expert
precondition { |player| player.tutorial_island_progress == :moving_around }
text 'Hello again. I\'m here to teach you a few survival tips and tricks. First off we\'re '\
'going to start with the most basic survival skill of all: making a fire.'
close { |player| add_survival_items(player) }
end
# The dialogue displayed when the Survival Expert gives the player a bronze axe.
dialogue :give_bronze_axe do
type :message_with_item
item :bronze_axe
text 'The Survival Expert gives you a bronze axe!'
close { |player| TutorialInstructions.show_instruction(player) }
end
# The dialogue displayed when the Survival Expert gives the player a tinderbox.
dialogue :give_tinderbox do
type :message_with_item
item :tinderbox
text 'The Survival Expert gives you a tinderbox!'
close { |player| TutorialInstructions.show_instruction(player) }
end
# The dialogue displayed when the Survival Expert gives the player both a bronze axe and a
# tinderbox.
dialogue :give_axe_and_tinderbox do
type :message_with_item
item :bronze_axe
# TODO: the tinderbox is also displayed - find this dialogue id. Scale looks like the default
# http://i.imgur.com/i1abN5X.png
text 'The Survival Expert gives you a tinderbox and a bronze axe!'
close do |player|
if player.tutorial_island_progress < :given_axe
player.tutorial_island_progress = :given_axe
index = SurvivalConstants::INVENTORY_TAB_INDEX
player.send(SwitchTabInterfaceMessage.new(index, SurvivalConstants::INVENTORY_TAB_ID))
player.send(FlashTabInterfaceMessage.new(index))
end
TutorialInstructions.show_instruction(player)
end
end
# The dialogue displayed when the player has succesfully cut down a tree.
dialogue :get_logs do
type :message_with_item
item :logs
text 'You get some logs.'
close { |player| TutorialInstructions.show_instruction(player) }
end
end
# Add the survival items (bronze axe and tinderbox) to the inventory of the player, if they do not
# already have them.
def add_survival_items(player)
inventory = player.inventory
unless inventory.contains(SurvivalConstants::BRONZE_AXE)
inventory.add(SurvivalConstants::BRONZE_AXE)
dialogue = :give_bronze_axe
end
unless inventory.contains(SurvivalConstants::TINDERBOX)
inventory.add(SurvivalConstants::TINDERBOX)
dialogue = (dialogue == :give_bronze_axe) ? :give_axe_and_tinderbox : :give_tinderbox
end
send_dialogue(player, get_dialogue(:tutorial_survival_expert, dialogue))
end
# Intercept the FirstObjectActionMessage to send tutorial-only events if the player is chopping
# down a tree.
on :message, :first_object_action do |player, message|
if player.in_tutorial_island && message.id == SurvivalConstants::TREE_ID
progress = player.tutorial_island_progress
if progress < :cut_tree
send_dialogue(player, get_dialogue(:tutorial_island_instructions, :try_cut_tree))
elsif player.tutorial_island_progress == :cut_tree
# Don't break the chain, so that the Woodcutting event actually happens.
player.tutorial_island_progress = :cutting_tree
end
end
end
# Intercept the FlashingTabClickedMessage to update the player's progress, if applicable.
on :message, :flashing_tab_clicked do |player, message|
if player.in_tutorial_island && message.tab == SurvivalConstants::INVENTORY_TAB_INDEX &&
player.tutorial_island_progress == :given_axe
player.tutorial_island_progress = :cut_tree
message.terminate
end
end
@@ -0,0 +1,30 @@
require 'java'
java_import 'org.apollo.game.model.entity.Player'
# Declare the tutorial island progress attribute.
declare_attribute(:tutorial_island_progress, :not_started, :persistent)
# The existing player class.
class Player
# Returns whether or not this Player is currently on tutorial island.
def in_tutorial_island
x = position.x
y = position.y
above_ground(x, y) || below_ground(x, y)
end
end
private
# Returns whether or not the specified coordinate pair is above ground on tutorial island.
def above_ground(x, y)
x >= 3053 && x <= 3156 && y >= 3056 && y <= 3136
end
# Returns whether or not the specified coordinate pair is 'below' ground on tutorial island.
def below_ground(x, y)
x >= 3072 && x <= 3118 && y >= 9492 && y <= 9535
end