Quest restrictions (2/3) and current quest info
This commit is contained in:
parent
c6d8ae8be0
commit
9bff79e019
13 changed files with 53 additions and 16 deletions
|
|
@ -30,6 +30,7 @@ position = Vector2(19, 10)
|
||||||
|
|
||||||
[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)
|
||||||
|
base_name = "BASE_NAME_0"
|
||||||
items_on_sell = Array[Resource("res://scripts/Classes/item.gd")]([ExtResource("4_xwim1"), ExtResource("5_oxe5h"), ExtResource("6_mrd6j")])
|
items_on_sell = Array[Resource("res://scripts/Classes/item.gd")]([ExtResource("4_xwim1"), ExtResource("5_oxe5h"), ExtResource("6_mrd6j")])
|
||||||
items_on_buy = Array[Resource("res://scripts/Classes/item.gd")]([ExtResource("7_x535v"), ExtResource("6_mrd6j")])
|
items_on_buy = Array[Resource("res://scripts/Classes/item.gd")]([ExtResource("7_x535v"), ExtResource("6_mrd6j")])
|
||||||
quest = ExtResource("8_i1pnu")
|
quest = ExtResource("8_i1pnu")
|
||||||
|
|
@ -37,6 +38,7 @@ quest = ExtResource("8_i1pnu")
|
||||||
[node name="Base2" parent="FactionPeaceful" index="1" instance=ExtResource("3_m5ica")]
|
[node name="Base2" parent="FactionPeaceful" index="1" instance=ExtResource("3_m5ica")]
|
||||||
position = Vector2(721, 785)
|
position = Vector2(721, 785)
|
||||||
rotation = 3.14159
|
rotation = 3.14159
|
||||||
|
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")]
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ const TAKE_QUEST = "BASE_TAKE_QUEST"
|
||||||
const ACCEPT_QUEST = "BASE_QUEST_ACCEPT"
|
const ACCEPT_QUEST = "BASE_QUEST_ACCEPT"
|
||||||
## This message will trigger quest node to take quest from player
|
## This message will trigger quest node to take quest from player
|
||||||
const CANCEL_QUEST = "BASE_QUEST_CANCEL"
|
const CANCEL_QUEST = "BASE_QUEST_CANCEL"
|
||||||
|
## This message will trigger quest node to get quest info
|
||||||
|
const QUEST_INFO = "BASE_QUEST_INFO"
|
||||||
|
|
||||||
|
## Quest progress template
|
||||||
|
const QUEST_PROGRESS = "{cur} / {max}"
|
||||||
|
|
||||||
@onready var dialogue = $DialogueView
|
@onready var dialogue = $DialogueView
|
||||||
@onready var buy_sell = $"../../BuySell"
|
@onready var buy_sell = $"../../BuySell"
|
||||||
|
|
@ -48,13 +53,22 @@ func send_message(msg: Message):
|
||||||
format["amount"] = actions_menu.buy_sell_amount
|
format["amount"] = actions_menu.buy_sell_amount
|
||||||
format["item_name"] = item_name
|
format["item_name"] = item_name
|
||||||
TAKE_QUEST:
|
TAKE_QUEST:
|
||||||
|
quest.make_answer(quest.quest)
|
||||||
format["answer"] = quest.answer
|
format["answer"] = quest.answer
|
||||||
if quest.answer == tr(quest.NO_QUEST):
|
if quest.answer == tr(quest.NO_QUEST):
|
||||||
get_tree().create_timer(0.05).timeout.connect(actions_menu.transit_menu.bind(0))
|
get_tree().create_timer(0.05).timeout.connect(actions_menu.transit_menu.bind(0))
|
||||||
ACCEPT_QUEST:
|
ACCEPT_QUEST:
|
||||||
actions_menu.player_ship.quest = quest.assign_to_player()
|
var player_ship = actions_menu.player_ship
|
||||||
|
player_ship.quest = quest.assign_to_player()
|
||||||
|
player_ship.quest.quest_failed.connect(player_ship.on_quest_failed)
|
||||||
CANCEL_QUEST:
|
CANCEL_QUEST:
|
||||||
actions_menu.player_ship.quest = null
|
actions_menu.player_ship.quest = null
|
||||||
|
QUEST_INFO:
|
||||||
|
var cur_quest = actions_menu.player_ship.quest
|
||||||
|
quest.get_info(cur_quest)
|
||||||
|
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})
|
||||||
|
|
||||||
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())
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,7 @@ extends Node
|
||||||
var base: Base
|
var base: Base
|
||||||
|
|
||||||
## Quest this node holds
|
## Quest this node holds
|
||||||
var quest: Quest:
|
var quest: Quest
|
||||||
set(value):
|
|
||||||
has_quest = value != null
|
|
||||||
quest = value
|
|
||||||
|
|
||||||
## Const of answer when quest is null
|
## Const of answer when quest is null
|
||||||
const NO_QUEST = "BASE_TAKE_QUEST_FAILED"
|
const NO_QUEST = "BASE_TAKE_QUEST_FAILED"
|
||||||
|
|
@ -23,8 +20,11 @@ const RESTRICTIONS = {
|
||||||
Quest.Restriction.NoWeapon: "BASE_QUEST_RESTRICTION_NO_WEAPON",
|
Quest.Restriction.NoWeapon: "BASE_QUEST_RESTRICTION_NO_WEAPON",
|
||||||
Quest.Restriction.Timer: "BASE_QUEST_RESTRICTION_TIMER"
|
Quest.Restriction.Timer: "BASE_QUEST_RESTRICTION_TIMER"
|
||||||
}
|
}
|
||||||
var has_quest: bool = false
|
|
||||||
|
## Answer about fetching quest
|
||||||
var answer: String = ""
|
var answer: String = ""
|
||||||
|
## Last quest info
|
||||||
|
var info: String = ""
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
get_tree().create_timer(0.05).timeout.connect(fetch_quest)
|
get_tree().create_timer(0.05).timeout.connect(fetch_quest)
|
||||||
|
|
@ -34,11 +34,17 @@ func fetch_quest():
|
||||||
quest = base.quest
|
quest = base.quest
|
||||||
make_answer(quest)
|
make_answer(quest)
|
||||||
|
|
||||||
|
## Makes quest fetch answer
|
||||||
func make_answer(quest: Quest):
|
func make_answer(quest: Quest):
|
||||||
var has_quest = quest != null
|
var has_quest = quest != null
|
||||||
if !has_quest:
|
if !has_quest:
|
||||||
answer = tr(NO_QUEST)
|
answer = tr(NO_QUEST)
|
||||||
return
|
return
|
||||||
|
get_info(quest)
|
||||||
|
answer = tr(HAS_QUEST).format({"quest_info": info})
|
||||||
|
|
||||||
|
## Gets quest info
|
||||||
|
func get_info(quest: Quest):
|
||||||
var quest_format = {}
|
var quest_format = {}
|
||||||
match quest.type:
|
match quest.type:
|
||||||
Quest.Type.Elimination:
|
Quest.Type.Elimination:
|
||||||
|
|
@ -52,11 +58,11 @@ func make_answer(quest: Quest):
|
||||||
quest_format["restrictions"] = restrictions
|
quest_format["restrictions"] = restrictions
|
||||||
quest_format["reward"] = quest.reward_money
|
quest_format["reward"] = quest.reward_money
|
||||||
var quest_info = tr(QUEST_TYPE[quest.type]).format(quest_format)
|
var quest_info = tr(QUEST_TYPE[quest.type]).format(quest_format)
|
||||||
var final_format = {"quest_info": quest_info}
|
info = quest_info
|
||||||
answer = tr(HAS_QUEST).format(final_format)
|
|
||||||
|
|
||||||
## Assigns quest to player by returning it and nullifying self quest
|
## Assigns quest to player by returning it and nullifying self quest
|
||||||
func assign_to_player() -> Quest:
|
func assign_to_player() -> Quest:
|
||||||
|
quest.data["given_by"] = base.base_name
|
||||||
quest.status = Quest.Status.Taken
|
quest.status = Quest.Status.Taken
|
||||||
var temp_quest = quest
|
var temp_quest = quest
|
||||||
quest = null
|
quest = null
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ signal dock_requested
|
||||||
@export var menu: PackedScene
|
@export var menu: PackedScene
|
||||||
## Faction that this base represents
|
## Faction that this base represents
|
||||||
@export var faction: Game.Faction
|
@export var faction: Game.Faction
|
||||||
|
## Name of this base
|
||||||
|
@export var base_name: String
|
||||||
|
|
||||||
## List of items that this base sells
|
## List of items that this base sells
|
||||||
@export var items_on_sell: Array[Item]
|
@export var items_on_sell: Array[Item]
|
||||||
|
|
@ -42,6 +44,7 @@ var touching_dock = false
|
||||||
var player_ship = null
|
var player_ship = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
get_tree().current_scene.bases.append(self)
|
||||||
mouse_entered.connect(star_system.set_targeted_node.bind(self))
|
mouse_entered.connect(star_system.set_targeted_node.bind(self))
|
||||||
mouse_exited.connect(star_system.clear_targeted_node)
|
mouse_exited.connect(star_system.clear_targeted_node)
|
||||||
gate_area.body_entered.connect(gate_area_body_entered)
|
gate_area.body_entered.connect(gate_area_body_entered)
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,8 @@ func destroy():
|
||||||
docking_base = null
|
docking_base = null
|
||||||
selected_node = null
|
selected_node = null
|
||||||
if quest != null:
|
if quest != null:
|
||||||
if Quest.Restriction.NoDeaths in quest.restrictions:
|
quest.trigger_restriction(Quest.Restriction.NoDeaths)
|
||||||
quest.fail()
|
|
||||||
|
func on_quest_failed(_bool: bool):
|
||||||
|
quest.quest_failed.disconnect(on_quest_failed)
|
||||||
|
quest = null
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,7 @@ func _process(_delta) -> void:
|
||||||
func shoot() -> void:
|
func shoot() -> void:
|
||||||
if ship is PlayerShip:
|
if ship is PlayerShip:
|
||||||
if ship.quest != null:
|
if ship.quest != null:
|
||||||
if Quest.Restriction.NoWeapon in ship.quest.restrictions:
|
ship.quest.trigger_restriction(Quest.Restriction.NoWeapon)
|
||||||
ship.quest.fail()
|
|
||||||
for spawner in spawner_points:
|
for spawner in spawner_points:
|
||||||
var projectile_instance = projectile.instantiate()
|
var projectile_instance = projectile.instantiate()
|
||||||
ProjectileContainer.instance.add_child(projectile_instance)
|
ProjectileContainer.instance.add_child(projectile_instance)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ var targeted_node: Node2D = null
|
||||||
var player_ship: PlayerShip
|
var player_ship: PlayerShip
|
||||||
## Pause controller reference
|
## Pause controller reference
|
||||||
var pause_controller: Control
|
var pause_controller: Control
|
||||||
|
## All bases in the system
|
||||||
|
var bases: Array[Base]
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
player_ship = get_node_or_null("FactionPlayer/PlayerShip")
|
player_ship = get_node_or_null("FactionPlayer/PlayerShip")
|
||||||
|
|
@ -61,3 +63,11 @@ func set_targeted_node(node):
|
||||||
|
|
||||||
func clear_targeted_node():
|
func clear_targeted_node():
|
||||||
targeted_node = null
|
targeted_node = null
|
||||||
|
|
||||||
|
## Returns base with given name
|
||||||
|
func find_base_by_name(base_name: String) -> Base:
|
||||||
|
for base in bases:
|
||||||
|
if base.base_name == base_name:
|
||||||
|
return base
|
||||||
|
return null
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ BASE_TAKE_QUEST_RECEIVED,Do you have any work for me?\n{answer},Есть ли у
|
||||||
BASE_TAKE_QUEST_FAILED,"No errands, I'm afraid.\nAnything else?\n> ","Боюсь, что нет.\nЧто-то ещё?\n> "
|
BASE_TAKE_QUEST_FAILED,"No errands, I'm afraid.\nAnything else?\n> ","Боюсь, что нет.\nЧто-то ещё?\n> "
|
||||||
BASE_TAKE_QUEST_SUCCEED,"Yes, we have one errand, that you can do\n{quest_info}\nDo you agree?\n> ","Да, у нас есть одно дельце, которое некому поручить.\n{quest_info}\nВы согласны?\n> "
|
BASE_TAKE_QUEST_SUCCEED,"Yes, we have one errand, that you can do\n{quest_info}\nDo you agree?\n> ","Да, у нас есть одно дельце, которое некому поручить.\n{quest_info}\nВы согласны?\n> "
|
||||||
BASE_QUEST_INFO_LOCAL,Ask about current errand state,Узнать состояние текущего поручения
|
BASE_QUEST_INFO_LOCAL,Ask about current errand state,Узнать состояние текущего поручения
|
||||||
BASE_QUEST_INFO_RECEIVED,"Can I ask about my errand state?\nYou errand was given by: {given_by}\n{answer}\nCurrent progress:\n{progress}\n> ","Можно узнать состояние моего поручения?\nПоручение было выдано: {given_by}\n{answer}\nТекущий прогресс:\n{progress}\n> "
|
BASE_QUEST_INFO_RECEIVED,"Can I ask about my errand state?\nYou errand was given by: {given_by}\n{answer}\nCurrent progress: {progress}\n> ","Можно узнать состояние моего поручения?\nПоручение было выдано: {given_by}\n{answer}\nТекущий прогресс: {progress}\n> "
|
||||||
BASE_QUEST_ACCEPT_LOCAL,Accept,Принять
|
BASE_QUEST_ACCEPT_LOCAL,Accept,Принять
|
||||||
BASE_QUEST_ACCEPT_RECEIVED,"I agree\nGood, I'll assign that errand to you.\nAnything else?\n> ","Я согласен\nХорошо, назначаю Вам это поручение.\nЧто-то ещё?\n> "
|
BASE_QUEST_ACCEPT_RECEIVED,"I agree\nGood, I'll assign that errand to you.\nAnything else?\n> ","Я согласен\nХорошо, назначаю Вам это поручение.\nЧто-то ещё?\n> "
|
||||||
BASE_QUEST_DECLINE_LOCAL,Decline,Отказаться
|
BASE_QUEST_DECLINE_LOCAL,Decline,Отказаться
|
||||||
|
|
@ -32,7 +32,7 @@ BASE_QUEST_CANCEL_RECEIVED,"I want to reject the errand\nIn that case, you won't
|
||||||
BASE_QUEST_REWARD_LOCAL,Receive reward,Получить награду
|
BASE_QUEST_REWARD_LOCAL,Receive reward,Получить награду
|
||||||
BASE_QUEST_REWARD_RECEIVED,"I've completed the assignment, what about reward?\nOne moment...\nThe work is done, I see. The reward will be transferred now.\n[RECEIVED SPINOTS: {reward}]\nAnything else?\n> ","Я выполнил ваше поручение, что насчёт награды?\nСекунду...\nДа, действительно, дело сделано, сейчас переведу вашу награду...\n[ПОЛУЧЕНЫ СПИНОТЫ: {reward}]\nЧто-то ещё?\n> "
|
BASE_QUEST_REWARD_RECEIVED,"I've completed the assignment, what about reward?\nOne moment...\nThe work is done, I see. The reward will be transferred now.\n[RECEIVED SPINOTS: {reward}]\nAnything else?\n> ","Я выполнил ваше поручение, что насчёт награды?\nСекунду...\nДа, действительно, дело сделано, сейчас переведу вашу награду...\n[ПОЛУЧЕНЫ СПИНОТЫ: {reward}]\nЧто-то ещё?\n> "
|
||||||
BASE_QUEST_ELIMINATION,"Eliminate {target_class} class ships: {amount}\n[ul]{restrictions}[/ul]\Reward: {reward}","Уничтожьте корабли класса {target_class}: {amount}\n[ul]{restrictions}[/ul]\nНаграда: {reward}"
|
BASE_QUEST_ELIMINATION,"Eliminate {target_class} class ships: {amount}\n[ul]{restrictions}[/ul]\Reward: {reward}","Уничтожьте корабли класса {target_class}: {amount}\n[ul]{restrictions}[/ul]\nНаграда: {reward}"
|
||||||
BASE_QUEST_DELIVERY,"We'll entrust you with a valuable cargo. Deliver it to the base {base_name}\n[ul]{restrictions}[/ul]\nReward: {reward}","Мы поручим вам ценный груз. Доставьте его на базу {base_name}.\n[ul]{restrictions}[/ul]\nНаграда: {reward}"
|
BASE_QUEST_DELIVERY,"We'll entrust you with a valuable cargo. Deliver it to the {base_name}\n[ul]{restrictions}[/ul]\nReward: {reward}","Мы поручим вам ценный груз. Доставьте его по адресу: {base_name}.\n[ul]{restrictions}[/ul]\nНаграда: {reward}"
|
||||||
BASE_QUEST_RESTRICTION_NO_DEATHS,"The reward is nullified if your ship is destroyed","При разрушении Вашего корабля награда аннулируется"
|
BASE_QUEST_RESTRICTION_NO_DEATHS,"The reward is nullified if your ship is destroyed","При разрушении Вашего корабля награда аннулируется"
|
||||||
BASE_QUEST_RESTRICTION_NO_WEAPON,"Usage of weaponry during errand is prohibited","Использовать вооружение корабля в процессе выполнения поручения запрещено"
|
BASE_QUEST_RESTRICTION_NO_WEAPON,"Usage of weaponry during errand is prohibited","Использовать вооружение корабля в процессе выполнения поручения запрещено"
|
||||||
BASE_QUEST_RESTRICTION_TIMER,"You have {time} s. to complete the errand","У вас есть {time} сек. на выполнение поручения"
|
BASE_QUEST_RESTRICTION_TIMER,"You have {time} s. to complete the errand","У вас есть {time} сек. на выполнение поручения"
|
||||||
|
|
|
||||||
|
Binary file not shown.
Binary file not shown.
|
|
@ -1,3 +1,3 @@
|
||||||
,en,ru
|
,en,ru
|
||||||
BASE_NAME_0,Zakozlennaja,Закозлённая
|
BASE_NAME_0,Base Zakozlennaja,Закозлённая база
|
||||||
BASE_NAME_1,Spinned,Покрученная
|
BASE_NAME_1,Base Spinned,Покрученная база
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue