Quest system done
This commit is contained in:
parent
9bff79e019
commit
231ff2bb1d
10 changed files with 52 additions and 9 deletions
|
|
@ -16,6 +16,8 @@ const ACCEPT_QUEST = "BASE_QUEST_ACCEPT"
|
|||
const CANCEL_QUEST = "BASE_QUEST_CANCEL"
|
||||
## This message will trigger quest node to get 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
|
||||
const QUEST_PROGRESS = "{cur} / {max}"
|
||||
|
|
@ -26,8 +28,7 @@ const QUEST_PROGRESS = "{cur} / {max}"
|
|||
@onready var quest = $"../../Quest"
|
||||
|
||||
func _ready():
|
||||
var tween = create_tween() \
|
||||
.tween_property(dialogue,"visible_ratio",1.0, 2)
|
||||
create_tween().tween_property(dialogue,"visible_ratio",1.0, 2)
|
||||
|
||||
func send_message(msg: Message):
|
||||
var format = {}
|
||||
|
|
@ -69,10 +70,14 @@ func send_message(msg: Message):
|
|||
format["answer"] = quest.info
|
||||
format["given_by"] = tr(cur_quest.data["given_by"])
|
||||
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 old_len = len(dialogue.get_parsed_text())
|
||||
dialogue.append_text(new_msg)
|
||||
dialogue.visible_characters = old_len
|
||||
var tween = create_tween() \
|
||||
.tween_property(dialogue,"visible_ratio",1.0, 2)
|
||||
create_tween().tween_property(dialogue,"visible_ratio",1.0, 2)
|
||||
|
|
|
|||
|
|
@ -66,5 +66,6 @@ func assign_to_player() -> Quest:
|
|||
quest.status = Quest.Status.Taken
|
||||
var temp_quest = quest
|
||||
quest = null
|
||||
base.quest = null
|
||||
make_answer(quest)
|
||||
return temp_quest
|
||||
|
|
|
|||
|
|
@ -2,3 +2,13 @@ extends Control
|
|||
|
||||
## Base which provided this menu
|
||||
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
|
||||
var progress : int = 0:
|
||||
set(value):
|
||||
if value >= progress_max:
|
||||
end()
|
||||
if status == Status.Taken:
|
||||
if value >= progress_max:
|
||||
progress = progress_max
|
||||
end()
|
||||
else:
|
||||
progress = value
|
||||
@export var reward_money : float
|
||||
@export var restrictions : Array[Restriction] = []
|
||||
@export var data : Dictionary = {}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ class_name Ship
|
|||
## Emits when hull hp reaches zero.
|
||||
signal destroyed
|
||||
|
||||
## Ship ID to define its type
|
||||
@export var id: String
|
||||
|
||||
## Reference to the engine module
|
||||
@onready var engine: ShipEngine = $Engine
|
||||
## Reference to the hull module
|
||||
|
|
@ -24,6 +27,7 @@ var faction : Game.Faction
|
|||
func _ready() -> void:
|
||||
hull.global_position = global_position
|
||||
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_exited.connect(star_system.clear_targeted_node)
|
||||
|
||||
|
|
|
|||
|
|
@ -71,3 +71,13 @@ func find_base_by_name(base_name: String) -> Base:
|
|||
return base
|
||||
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