Quest system done
This commit is contained in:
parent
9bff79e019
commit
231ff2bb1d
10 changed files with 52 additions and 9 deletions
|
|
@ -29,6 +29,7 @@ func _process(_delta):
|
||||||
|
|
||||||
[node name="KamikazeShip" type="Node2D"]
|
[node name="KamikazeShip" type="Node2D"]
|
||||||
script = ExtResource("1_82bba")
|
script = ExtResource("1_82bba")
|
||||||
|
id = "SHIP_KAMIKAZE"
|
||||||
|
|
||||||
[node name="HullHolder" type="Node" parent="."]
|
[node name="HullHolder" type="Node" parent="."]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ func _process(_delta):
|
||||||
[node name="ShooterShip" type="Node2D"]
|
[node name="ShooterShip" type="Node2D"]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
script = ExtResource("1_o387g")
|
script = ExtResource("1_o387g")
|
||||||
|
id = "SHIP_SHOOTER"
|
||||||
|
|
||||||
[node name="HullHolder" type="Node" parent="."]
|
[node name="HullHolder" type="Node" parent="."]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ func _process(_delta):
|
||||||
[node name="PlayerShip" type="Node2D"]
|
[node name="PlayerShip" type="Node2D"]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
script = ExtResource("2_oqdd7")
|
script = ExtResource("2_oqdd7")
|
||||||
|
id = "SHIP_PLAYER"
|
||||||
|
|
||||||
[node name="InputController" type="Node2D" parent="."]
|
[node name="InputController" type="Node2D" parent="."]
|
||||||
script = ExtResource("3_0e84a")
|
script = ExtResource("3_0e84a")
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ color_background = Color(0.276474, 0.0962249, 0.200656, 1)
|
||||||
|
|
||||||
[node name="PlayerShip" parent="FactionPlayer" index="0" instance=ExtResource("7_jyplv")]
|
[node name="PlayerShip" parent="FactionPlayer" index="0" instance=ExtResource("7_jyplv")]
|
||||||
process_mode = 0
|
process_mode = 0
|
||||||
position = Vector2(19, 10)
|
position = Vector2(732, 100)
|
||||||
|
|
||||||
[node name="Base" parent="FactionPeaceful" index="0" instance=ExtResource("3_m5ica")]
|
[node name="Base" parent="FactionPeaceful" index="0" instance=ExtResource("3_m5ica")]
|
||||||
position = Vector2(719, -559)
|
position = Vector2(719, -559)
|
||||||
|
|
@ -42,7 +42,13 @@ base_name = "BASE_NAME_1"
|
||||||
quest = ExtResource("10_gy1bh")
|
quest = ExtResource("10_gy1bh")
|
||||||
|
|
||||||
[node name="KamikazeShip" parent="FactionAggressive" index="0" instance=ExtResource("4_i6rbg")]
|
[node name="KamikazeShip" parent="FactionAggressive" index="0" instance=ExtResource("4_i6rbg")]
|
||||||
position = Vector2(-1712, -608)
|
position = Vector2(-161, 851)
|
||||||
|
|
||||||
[node name="ShooterShip" parent="FactionAggressive" index="1" instance=ExtResource("5_o3ny8")]
|
[node name="ShooterShip" parent="FactionAggressive" index="1" instance=ExtResource("5_o3ny8")]
|
||||||
position = Vector2(-1852, 618)
|
position = Vector2(-1852, 618)
|
||||||
|
|
||||||
|
[node name="KamikazeShip2" parent="FactionAggressive" index="2" instance=ExtResource("4_i6rbg")]
|
||||||
|
position = Vector2(-190, 621)
|
||||||
|
|
||||||
|
[node name="KamikazeShip3" parent="FactionAggressive" index="3" instance=ExtResource("4_i6rbg")]
|
||||||
|
position = Vector2(-47, 1056)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ const ACCEPT_QUEST = "BASE_QUEST_ACCEPT"
|
||||||
const CANCEL_QUEST = "BASE_QUEST_CANCEL"
|
const CANCEL_QUEST = "BASE_QUEST_CANCEL"
|
||||||
## This message will trigger quest node to get quest info
|
## This message will trigger quest node to get quest info
|
||||||
const QUEST_INFO = "BASE_QUEST_INFO"
|
const QUEST_INFO = "BASE_QUEST_INFO"
|
||||||
|
## This message will trigger dialogue node to reward player
|
||||||
|
const QUEST_REWARD = "BASE_QUEST_REWARD"
|
||||||
|
|
||||||
## Quest progress template
|
## Quest progress template
|
||||||
const QUEST_PROGRESS = "{cur} / {max}"
|
const QUEST_PROGRESS = "{cur} / {max}"
|
||||||
|
|
@ -26,8 +28,7 @@ const QUEST_PROGRESS = "{cur} / {max}"
|
||||||
@onready var quest = $"../../Quest"
|
@onready var quest = $"../../Quest"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var tween = create_tween() \
|
create_tween().tween_property(dialogue,"visible_ratio",1.0, 2)
|
||||||
.tween_property(dialogue,"visible_ratio",1.0, 2)
|
|
||||||
|
|
||||||
func send_message(msg: Message):
|
func send_message(msg: Message):
|
||||||
var format = {}
|
var format = {}
|
||||||
|
|
@ -69,10 +70,14 @@ func send_message(msg: Message):
|
||||||
format["answer"] = quest.info
|
format["answer"] = quest.info
|
||||||
format["given_by"] = tr(cur_quest.data["given_by"])
|
format["given_by"] = tr(cur_quest.data["given_by"])
|
||||||
format["progress"] = QUEST_PROGRESS.format({"cur": cur_quest.progress, "max": cur_quest.progress_max})
|
format["progress"] = QUEST_PROGRESS.format({"cur": cur_quest.progress, "max": cur_quest.progress_max})
|
||||||
|
QUEST_REWARD:
|
||||||
|
var player_ship = actions_menu.player_ship
|
||||||
|
var reward = player_ship.quest.reward_money
|
||||||
|
player_ship.money += reward
|
||||||
|
player_ship.quest = null
|
||||||
|
format["reward"] = reward
|
||||||
var new_msg = tr(msg.fact + "_RECEIVED").format(format)
|
var new_msg = tr(msg.fact + "_RECEIVED").format(format)
|
||||||
var old_len = len(dialogue.get_parsed_text())
|
var old_len = len(dialogue.get_parsed_text())
|
||||||
dialogue.append_text(new_msg)
|
dialogue.append_text(new_msg)
|
||||||
dialogue.visible_characters = old_len
|
dialogue.visible_characters = old_len
|
||||||
var tween = create_tween() \
|
create_tween().tween_property(dialogue,"visible_ratio",1.0, 2)
|
||||||
.tween_property(dialogue,"visible_ratio",1.0, 2)
|
|
||||||
|
|
|
||||||
|
|
@ -66,5 +66,6 @@ func assign_to_player() -> Quest:
|
||||||
quest.status = Quest.Status.Taken
|
quest.status = Quest.Status.Taken
|
||||||
var temp_quest = quest
|
var temp_quest = quest
|
||||||
quest = null
|
quest = null
|
||||||
|
base.quest = null
|
||||||
make_answer(quest)
|
make_answer(quest)
|
||||||
return temp_quest
|
return temp_quest
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,13 @@ extends Control
|
||||||
|
|
||||||
## Base which provided this menu
|
## Base which provided this menu
|
||||||
var base: Base
|
var base: Base
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
get_tree().create_timer(0.05).timeout.connect(check_for_delivery)
|
||||||
|
|
||||||
|
func check_for_delivery():
|
||||||
|
var player_ship = get_tree().current_scene.player_ship
|
||||||
|
if player_ship.quest == null:
|
||||||
|
return
|
||||||
|
if player_ship.quest.type == Quest.Type.Delivery and player_ship.quest.data["base_name"] == base.base_name:
|
||||||
|
player_ship.quest.do_progress()
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,12 @@ enum Status{
|
||||||
@export var progress_max : int = 1
|
@export var progress_max : int = 1
|
||||||
var progress : int = 0:
|
var progress : int = 0:
|
||||||
set(value):
|
set(value):
|
||||||
if value >= progress_max:
|
if status == Status.Taken:
|
||||||
end()
|
if value >= progress_max:
|
||||||
|
progress = progress_max
|
||||||
|
end()
|
||||||
|
else:
|
||||||
|
progress = value
|
||||||
@export var reward_money : float
|
@export var reward_money : float
|
||||||
@export var restrictions : Array[Restriction] = []
|
@export var restrictions : Array[Restriction] = []
|
||||||
@export var data : Dictionary = {}
|
@export var data : Dictionary = {}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ class_name Ship
|
||||||
## Emits when hull hp reaches zero.
|
## Emits when hull hp reaches zero.
|
||||||
signal destroyed
|
signal destroyed
|
||||||
|
|
||||||
|
## Ship ID to define its type
|
||||||
|
@export var id: String
|
||||||
|
|
||||||
## Reference to the engine module
|
## Reference to the engine module
|
||||||
@onready var engine: ShipEngine = $Engine
|
@onready var engine: ShipEngine = $Engine
|
||||||
## Reference to the hull module
|
## Reference to the hull module
|
||||||
|
|
@ -24,6 +27,7 @@ var faction : Game.Faction
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
hull.global_position = global_position
|
hull.global_position = global_position
|
||||||
destroyed.connect(destroy_timeout)
|
destroyed.connect(destroy_timeout)
|
||||||
|
destroyed.connect(star_system.on_ship_destroyed.bind(self))
|
||||||
hull.mouse_entered.connect(star_system.set_targeted_node.bind(self))
|
hull.mouse_entered.connect(star_system.set_targeted_node.bind(self))
|
||||||
hull.mouse_exited.connect(star_system.clear_targeted_node)
|
hull.mouse_exited.connect(star_system.clear_targeted_node)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,3 +71,13 @@ func find_base_by_name(base_name: String) -> Base:
|
||||||
return base
|
return base
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
## Progress by elimination quest if destroyed ship is of required type
|
||||||
|
func on_ship_destroyed(ship: Ship):
|
||||||
|
if player_ship == null:
|
||||||
|
return
|
||||||
|
if player_ship.quest == null:
|
||||||
|
return
|
||||||
|
if player_ship.quest.type != Quest.Type.Elimination:
|
||||||
|
return
|
||||||
|
if player_ship.quest.data["target_class"] == ship.id:
|
||||||
|
player_ship.quest.do_progress()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue