mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Fixes issue #65, adds support for emotes/anims in dialogue
Use block instead of lambda, add emotes.rb Proper tutorial island emote Add newline at end of emotes.rb Use block instead of lambda, fix send_generic_dialogue method to accept block
This commit is contained in:
@@ -5,13 +5,13 @@ java_import 'org.apollo.game.message.impl.CloseInterfaceMessage'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetItemModelMessage'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetNpcModelMessage'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetPlayerModelMessage'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetModelAnimationMessage'
|
||||
java_import 'org.apollo.game.message.impl.SetWidgetTextMessage'
|
||||
java_import 'org.apollo.game.action.DistancedAction'
|
||||
|
||||
# The map of conversation names to Conversations.
|
||||
CONVERSATIONS = {}
|
||||
|
||||
|
||||
# Declares a conversation.
|
||||
def conversation(name, &block)
|
||||
conversation = Conversation.new(name)
|
||||
@@ -419,23 +419,32 @@ end
|
||||
|
||||
# Sends a dialogue displaying the player's head.
|
||||
def send_player_dialogue(player, dialogue)
|
||||
send_generic_dialogue(player, dialogue, player.username, PLAYER_DIALOGUE_IDS, ->(id) { SetWidgetPlayerModelMessage.new(id + 1) })
|
||||
emote = dialogue.emote
|
||||
|
||||
send_generic_dialogue player, dialogue, player.username, PLAYER_DIALOGUE_IDS do |id|
|
||||
player.send(SetWidgetPlayerModelMessage.new(id + 1))
|
||||
player.send(SetWidgetModelAnimationMessage.new(id + 1, emote)) unless emote.nil?
|
||||
end
|
||||
end
|
||||
|
||||
# Sends a dialogue displaying the head of an npc.
|
||||
def send_npc_dialogue(player, dialogue)
|
||||
npc = dialogue.npc
|
||||
emote = dialogue.emote
|
||||
name = NpcDefinition.lookup(npc).name.to_s
|
||||
name = "" if (name.nil? || name == "null")
|
||||
|
||||
send_generic_dialogue(player, dialogue, name, NPC_DIALOGUE_IDS, ->(id) { SetWidgetNpcModelMessage.new(id + 1, npc)})
|
||||
send_generic_dialogue player, dialogue, name, NPC_DIALOGUE_IDS do |id|
|
||||
player.send(SetWidgetNpcModelMessage.new(id + 1, npc))
|
||||
player.send(SetWidgetModelAnimationMessage.new(id + 1, emote)) unless emote.nil?
|
||||
end
|
||||
end
|
||||
|
||||
# Sends a dialogue displaying an event.
|
||||
def send_generic_dialogue(player, dialogue, title, ids, event=nil)
|
||||
def send_generic_dialogue(player, dialogue, title, ids, &event)
|
||||
text = dialogue.text
|
||||
dialogue_id = ids[text.size - 1]
|
||||
player.send(event.call(dialogue_id)) unless event.nil?
|
||||
event.call(dialogue_id) if block_given?
|
||||
|
||||
set_text(player, dialogue_title_id(dialogue_id), title)
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Declares all of the possible emotes
|
||||
declare_emote(:calm, 588)
|
||||
declare_emote(:anxious, 589)
|
||||
declare_emote(:default, 591)
|
||||
|
||||
# TODO: Properly name the rest of the facial emotes.
|
||||
# Found at http://www.rune-server.org/runescape-development/rs2-server/tutorials/518991-pi-317-player-npc-facial-dialogue-expressions.html
|
||||
@@ -9,6 +9,7 @@
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>dialogue.rb</script>
|
||||
<script>emotes.rb</script>
|
||||
</scripts>
|
||||
<dependencies>
|
||||
<dependency>util</dependency>
|
||||
|
||||
@@ -37,6 +37,7 @@ conversation :tutorial_runescape_guide do
|
||||
dialogue :greetings do
|
||||
type :npc_speech
|
||||
npc :runescape_guide
|
||||
emote :calm
|
||||
|
||||
precondition { |player| player.tutorial_island_progress == :not_started }
|
||||
|
||||
@@ -53,6 +54,7 @@ conversation :tutorial_runescape_guide do
|
||||
dialogue :welcome_back do
|
||||
type :npc_speech
|
||||
npc :runescape_guide
|
||||
emote :calm
|
||||
|
||||
precondition { |player| player.tutorial_island_progress != :not_started }
|
||||
|
||||
@@ -65,6 +67,7 @@ conversation :tutorial_runescape_guide do
|
||||
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!',
|
||||
@@ -81,6 +84,7 @@ conversation :tutorial_runescape_guide do
|
||||
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.'
|
||||
|
||||
Reference in New Issue
Block a user