ChatStart.gd removed and Player now does it all! (;

Player.greeting and greeting_wait to say hello! ^.^
3B/0 NPCs talking well (; cleaned up greetings in all maps
now 2C/0! (=
This commit is contained in:
Harmony Honey 2023-04-04 18:26:29 -04:00
parent 81ee250b50
commit d3db80e6a0
10 changed files with 86 additions and 87 deletions

View file

@ -28,6 +28,13 @@ var arrow
var key_up := false
var key_hold := false
func _ready():
Shared.connect("scene_before", self, "scene")
func scene():
is_show = false
show_easy.clock = 0.0
func _physics_process(delta):
if Engine.editor_hint and !is_editor: return
@ -73,7 +80,7 @@ func _physics_process(delta):
is_show = false
if !is_show:
if arrow: arrow.is_locked = false
if is_instance_valid(arrow): arrow.is_locked = false
func set_dialog(arg := dialog):
dialog = arg
@ -95,7 +102,7 @@ func set_dialog(arg := dialog):
func set_is_show(arg := is_show):
is_show = arg
if is_show:
if is_show and Engine.editor_hint:
set_dialog()
func open(_dialog := dialog, _arrow := arrow, _gt := global_transform):
@ -107,3 +114,5 @@ func open(_dialog := dialog, _arrow := arrow, _gt := global_transform):
if rect: rect.size = Vector2.ONE * panel_min.x
global_transform = _gt
self.dialog = _dialog
Audio.play("menu_joy", 0.5, 0.8)

View file

@ -1,30 +0,0 @@
extends Node2D
export var arrow_path : NodePath
onready var arrow := get_node_or_null(arrow_path)
export (Array, String, MULTILINE) var lines := ["Lovely day!", "I do adore the flowers", "Hello (="]
export (String, MULTILINE) var queue_write := "" setget set_queue_write
var line := -1
var queue := []
func _ready():
if arrow:
arrow.connect("open", self, "open")
func set_queue_write(arg := queue_write):
queue_write = arg
queue = queue_write.split_floats(",", false)
func open():
Audio.play("menu_joy", 0.5, 0.8)
if queue.size() == 0:
queue = range(lines.size())
queue.shuffle()
queue.erase(line)
line = posmod(int(queue.pop_front()), lines.size())
Shared.chat.open(lines[line], arrow, global_transform)

View file

@ -128,14 +128,19 @@ var blink_time := 10.0
var blink_range := Vector2(1, 20)
export var is_npc := false
export (Array, String, MULTILINE) var lines := ["Lovely day!", "I do adore the flowers", "Hello (="] setget set_lines
export (String, MULTILINE) var queue_write := "" setget set_queue_write
export (Array, String, MULTILINE) var lines := ["Lovely day!", "I do adore the flowers", "Hello (="]
export var greeting := -1
export var greeting_wait := Vector2(30, 45)
var greeting_clock := 0.0
export (String, MULTILINE) var queue_write := ""
export var chat_offset := Vector2(0, -110) setget set_chat_offset
onready var arrow := get_node_or_null("Arrow")
onready var chat := get_node_or_null("Arrow/Chat")
export var ready_z_index := 50
export var ready_dir_x := 0
var line := -1
var queue := []
var snowball_scene : PackedScene = preload("res://src/actor/Snowball.tscn")
var snowballs = []
@ -158,7 +163,9 @@ func _ready():
if Engine.editor_hint: return
solve_jump()
if arrow: connect("turn", arrow, "set_dir")
if arrow:
connect("turn", arrow, "set_dir")
arrow.connect("open", self, "arrow_open")
# create idle animiations facing left
var l = anim.get_animation("idle").duplicate()
@ -175,8 +182,6 @@ func _ready():
if is_npc:
z_index = min(ready_z_index, 45)
spr_easy.clock = spr_easy.time
set_lines()
set_queue_write()
var coy = chat_offset.y
if hat == 1:
coy = min(coy, -160)
@ -543,6 +548,10 @@ func _physics_process(delta):
blink_ease.show = true
blink_clock = 0.0
blink_time = rand_range(blink_range.x, blink_range.y)
if is_npc:
if greeting_clock > 0:
greeting_clock = max(0, greeting_clock - delta)
func physics_frame():
# hold animation
@ -639,17 +648,8 @@ func set_hat(arg := hat):
hat = posmod(arg, hats.size())
hairdo(hat_node, hats, hat)
func set_queue_write(arg := queue_write):
queue_write = arg
if chat: chat.queue_write = queue_write
func set_lines(arg := lines):
lines = arg
if chat: chat.lines = lines
func set_chat_offset(arg := chat_offset):
chat_offset = arg
if chat: chat.position = chat_offset
if arrow: arrow.image_pos = chat_offset
### Movement
@ -849,3 +849,24 @@ func unpause():
func footstep_sound():
if !audio_walk.playing and !audio_land.playing:
Audio.play(audio_walk, 1.5, 3.0)
func arrow_open():
if greeting_clock == 0 and greeting > -1 and greeting < lines.size():
queue.erase(greeting)
queue.push_front(greeting)
if queue.size() == 0:
queue = range(lines.size())
queue.shuffle()
queue.erase(line)
if greeting > -1: queue.erase(greeting)
if queue_write != "":
var qw = Array(PoolIntArray(Array(queue_write.split_floats(",", false))))
for i in qw.size():
var b = qw.pop_back()
queue.erase(b)
queue.push_front(b)
line = posmod(int(queue.pop_front()), lines.size())
Shared.chat.open(lines[line], arrow, Transform2D(dir * PI * 0.5, global_position + rot(chat_offset)))
greeting_clock = rand_range(greeting_wait.x, greeting_wait.y)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=2]
[gd_scene load_steps=22 format=2]
[ext_resource path="res://src/class/shape/Rectangle.gd" type="Script" id=1]
[ext_resource path="res://src/actor/Player.gd" type="Script" id=2]
@ -6,7 +6,6 @@
[ext_resource path="res://src/detail/Visible.gd" type="Script" id=4]
[ext_resource path="res://media/audio/sfx/player_land.wav" type="AudioStream" id=5]
[ext_resource path="res://src/actor/door/Arrow.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/actor/ChatStart.gd" type="Script" id=7]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 17, 17 )
@ -937,6 +936,19 @@ collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/HitArea"]
shape = SubResource( 3 )
[node name="Visible" type="VisibilityNotifier2D" parent="."]
visible = false
modulate = Color( 1, 0, 0, 1 )
rect = Rect2( -100, -100, 200, 200 )
script = ExtResource( 4 )
node_path = NodePath("../Sprites")
[node name="Arrow" parent="." instance=ExtResource( 6 )]
is_turn = true
col_size = Vector2( 150, 50 )
col_pos = Vector2( 0, -33 )
image_pos = Vector2( 0, -110 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "RESET"
playback_default_blend_time = 0.2
@ -954,25 +966,6 @@ anims/tree_behind = SubResource( 21 )
anims/walk = SubResource( 8 )
next/jump = "jump"
[node name="Visible" type="VisibilityNotifier2D" parent="."]
visible = false
modulate = Color( 1, 0, 0, 1 )
rect = Rect2( -100, -100, 200, 200 )
script = ExtResource( 4 )
node_path = NodePath("../Sprites")
[node name="Arrow" parent="." instance=ExtResource( 6 )]
is_turn = true
col_size = Vector2( 150, 50 )
col_pos = Vector2( 0, -33 )
image_pos = Vector2( 0, -110 )
[node name="Chat" type="Node2D" parent="Arrow"]
modulate = Color( 1, 1, 1, 0 )
position = Vector2( 0, -110 )
script = ExtResource( 7 )
arrow_path = NodePath("..")
[node name="Sprites" type="Node2D" parent="."]
[node name="Root" type="Node2D" parent="Sprites"]

View file

@ -107,7 +107,7 @@ hairstyle_back = 2
hairstyle_front = 7
is_npc = true
lines = [ "I've been through that big door!", "I lost a few gems, now I'm locked out..", "I tried knocking.. no answer 0:", "Finding a white flower is good luck!" ]
queue_write = "0"
greeting = 0
[node name="NPC3" parent="Actors" instance=ExtResource( 16 )]
position = Vector2( 1500, 450 )

View file

@ -85,7 +85,7 @@ hairstyle_front = 0
hat = 1
is_npc = true
lines = [ "It's always handy having a light", "Feel the delight of candle light!", "I'm not afraid of the dark! I swear..", "Candle candle candle candle..", "I've been trying to open that big door!", "They call me Candle Randall", "I get a lil spooked without my candy", "Need a light?" ]
queue_write = "5"
greeting = 5
chat_offset = Vector2( 0, -160 )
[node name="NPC2" parent="Actors" instance=ExtResource( 5 )]

View file

@ -72,7 +72,7 @@ rotation = 1.5708
dir = 1
scene_path = "res://src/map/worlds/2A/7.tscn"
[node name="Player" parent="Actors" instance=ExtResource( 8 )]
[node name="NPC" parent="Actors" instance=ExtResource( 8 )]
position = Vector2( 200, 1350 )
__meta__ = {
"_editor_description_": ""
@ -91,7 +91,7 @@ hat = 3
is_npc = true
lines = [ "Aren't they marvelous?", "I rolled em up myself!", "Yeah, I'm pretty sick at rollin snow (;", "Balancing the last snowball is tricky!", "Now i feel tiny next to Snowbo", "I named them Snowbo!" ]
[node name="Player2" parent="Actors" instance=ExtResource( 8 )]
[node name="NPC2" parent="Actors" instance=ExtResource( 8 )]
position = Vector2( 1150, 150 )
__meta__ = {
"_editor_description_": ""
@ -108,9 +108,9 @@ hairstyle_front = 6
hat = 3
is_npc = true
lines = [ "Wanna have a snowball fight? (:", "I'm gonna crush you!", "The snow is light and fluffy!", "It won't hurt thaat bad ;P", "I haven't seen Robbi since my astonishing victory (;", "Watch your back..", "Snowball Snowball Snooowbaaall", "Ooo yeah right in the face!" ]
queue_write = "0"
greeting = 0
[node name="Player3" parent="Actors" instance=ExtResource( 8 )]
[node name="NPC3" parent="Actors" instance=ExtResource( 8 )]
position = Vector2( 650, 700 )
__meta__ = {
"_editor_description_": ""
@ -128,11 +128,11 @@ hairstyle_front = 5
hat = 3
is_npc = true
lines = [ "You found me! 0:", "I've been hiding in here all day!", "Tell my mom I'm fine!", "Psst.. can you bring me a soda?", "My friend rolled me up in here..", "Snow surrounds me in every direction..", "That's not yellow snow!.. I'ts something else", "*oof* Can you poke another air hole?", "Sure beats chores", "You gotta try this!", "I'm chillin!", "It's me, Robbi!", "Snowballs can't hurt me now!" ]
queue_write = "0"
greeting = 0
chat_offset = Vector2( 0, -220 )
ready_z_index = -50
[node name="Player4" parent="Actors" instance=ExtResource( 8 )]
[node name="NPC4" parent="Actors" instance=ExtResource( 8 )]
position = Vector2( 350, 750 )
__meta__ = {
"_editor_description_": ""
@ -150,7 +150,7 @@ hairstyle_front = 8
is_npc = true
lines = [ "Cozy up and feel the candle warmth!", "I'm a lover not a snowball fighter..", "Hmm this puzzle has me stumped..", "Love that pine tree scent! Mmm..", "These are my flower friends (=", "Take a moment to relax and reflect..", "Do I really need that gem?" ]
[node name="Player5" parent="Actors" instance=ExtResource( 8 )]
[node name="NPC5" parent="Actors" instance=ExtResource( 8 )]
position = Vector2( -350, 400 )
__meta__ = {
"_editor_description_": ""

View file

@ -92,7 +92,7 @@ hairstyle_back = 0
hairstyle_front = 10
is_npc = true
lines = [ "You found my shortcut!", "I'm watching the door for new friends (:", "I can see it all from up here!", "Which way is up?..", "Spikes! Be careful..", "Have you seen the snow? I hear it's lovely (:" ]
queue_write = "0"
greeting = 0
[node name="NPC2" parent="Actors" instance=ExtResource( 9 )]
position = Vector2( 1300, 2250 )
@ -126,8 +126,8 @@ dye = {
hairstyle_back = 0
hairstyle_front = 10
is_npc = true
lines = [ "Welcome to our home!", "Shake my hand! Don't mind the sting", "Watch your head...", "These blocks make my head spin!", "Ooo that cool desert breeze...", "Come to check out the rocks?", "Saguaro-k!" ]
queue_write = "0"
lines = [ "Welcome to Dry Land!", "Shake my hand! Don't mind the sting", "Watch your head...", "These blocks make my head spin!", "Ooo that cool desert breeze...", "Come to check out the rocks?", "Saguaro-k!" ]
greeting = 0
[node name="NPC4" parent="Actors" instance=ExtResource( 9 )]
position = Vector2( 1600, 1650 )
@ -143,7 +143,8 @@ dye = {
hairstyle_back = 6
hairstyle_front = 8
is_npc = true
lines = [ "24... 25... 26...", "I've been saving up my gems to open this door!", "I almost have enough...", "Have you seen these rotating blocks? Marvelous..", "Now, how can I reach that gem?...", "I found a smooth rock (:", "Turn this block, push that block over top... hmm", "Bask in the sunlight!" ]
lines = [ "24... 25... 26...", "I've been saving up my gems to open this door!", "I almost have enough...", "Have you seen these rotating blocks? Marvelous..", "Now, how can I reach that gem?...", "I found a smooth rock (:", "Turn this block, push that block over top... hmm", "Bask in the starlight!" ]
greeting = 7
[node name="NPC5" parent="Actors" instance=ExtResource( 9 )]
position = Vector2( 2250, 2450 )

View file

@ -116,7 +116,7 @@ dye = {
hairstyle_back = 3
is_npc = true
lines = [ "I'm training for the handstand olympics (:", "My cousin has been training too..", "I'm staying upside down the longest!!", "Last year I sneezed at the last second..", "This year I'm taking home the gold ;P", "Hold it... hold it... I WILL WIN! (=" ]
queue_write = "0"
greeting = 0
[node name="NPC4" parent="Actors" instance=ExtResource( 15 )]
position = Vector2( 2025, 1550 )

View file

@ -88,7 +88,8 @@ dye = {
"skin": 4
}
is_npc = true
lines = [ "Can I braid your hair? (:", "Havin a cute sit on a cute bench (;", "Benchy benchy bench... ;P", "Hello (=", "This is my cozy little corner...", "Join me!", "I come here to feel the breeze [:", "Ooo look at that cloud...", "Ahh the sky makes me cry (':" ]
lines = [ "Can I braid your hair? (:", "Havin a cute sit on a cute bench (;", "Benchy benchy bench... ;P", "Hiii ^.^", "This is my cozy little corner...", "Join me!", "I come here to feel the breeze [:", "Ooo look at that cloud...", "Ahh the sky makes me cry (':" ]
greeting = 3
[node name="NPC3" parent="Actors" instance=ExtResource( 15 )]
position = Vector2( 1020, 950 )
@ -102,21 +103,24 @@ dye = {
hairstyle_back = 0
hairstyle_front = 10
is_npc = true
lines = [ "I have mastered these twisty blocks (;", "You'll get it eventually!", "I believe in you <3", "Step back and change your perspective (:", "There's always another angle...", "Have you tried the old twisty-slidey?", "I've seen plenty of gems around here (:", "Good luck! ^.^" ]
lines = [ "I have mastered these twisty blocks (;", "You'll get it eventually!", "I believe in you <3", "Step back and change your perspective (:", "There's always another angle...", "Have you tried the old twisty-slidey?", "I've seen plenty of gems around here (:", "Good luck! ^.^", "Greetings puzzler! [-:" ]
greeting = 8
[node name="NPC4" parent="Actors" instance=ExtResource( 15 )]
position = Vector2( -250, 450 )
dir = 3
idle_anim = "ponder"
dye = {
"eye": 18,
"fit": 3,
"eye": 5,
"fit": 2,
"hair": 14,
"skin": 6
}
hairstyle_back = 0
hairstyle_front = 8
is_npc = true
lines = [ "The desert is so peaceful..", "I love these hot days and cool nights (:", "Maybe I'll visit the snow next!", "I've travelled all over ROTA!", "What's your favorite destination? (;", "I'm afraid of heights! 0=", "This last puzzle is a long way down!", "I saw someone levitating blocks! I wonder how..", "How to bridge the gap? hmm..", "Hello friend! (=" ]
greeting = 9
[node name="NPC2" parent="Actors" instance=ExtResource( 15 )]
position = Vector2( 445, 1450 )
@ -131,7 +135,8 @@ dye = {
hairstyle_back = 3
hairstyle_front = 10
is_npc = true
lines = [ "My hands are stuck to the pricklies!", "I climbed up here last night...", "Oh! That tickles 0=", "Want to play hide and seek?", "This is my cuddle cactus ;P", "I feel safe here...", "Grab a cactus and cuddle up! (;", "Hiiiiiii (:" ]
lines = [ "My hands are stuck to the pricklies!", "I climbed up here last night...", "Oh! That tickles 0=", "Want to play hide and seek?", "This is my cuddle cactus ;P", "I feel safe here...", "Grab a cactus and cuddle up! (;", "Hey.. up here! (:" ]
greeting = 7
ready_z_index = -21
ready_dir_x = -1