Quest system base
This commit is contained in:
parent
37cd28d611
commit
8a40de576e
20 changed files with 178 additions and 9 deletions
20
menus/Base Menu/Quest/menu_quest_current.tres
Normal file
20
menus/Base Menu/Quest/menu_quest_current.tres
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
[gd_resource type="Resource" script_class="Menu" load_steps=6 format=3 uid="uid://b53q1848yjrr2"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="1_miou6"]
|
||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_n1rfm"]
|
||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu_menu_resource.gd" id="2_38cjf"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ygiya"]
|
||||
script = ExtResource("1_n1rfm")
|
||||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||
item_menu = &"res://menus/Base Menu/root_menu.tres"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_xno7g"]
|
||||
script = ExtResource("2_38cjf")
|
||||
item = &"res://menus/Base Menu/root_menu.tres"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_miou6")
|
||||
item_ids = Array[String](["BASE_QUEST_CANCEL", "BASE_QUEST_REWARD", "BASE_RETURN", "NULL", "NULL", "NULL", "NULL", "NULL"])
|
||||
item_actions = Array[int]([3, 3, 1, 0, 0, 0, 0, 0])
|
||||
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_ygiya"), SubResource("Resource_ygiya"), SubResource("Resource_xno7g"), null, null, null, null, null])
|
||||
15
menus/Base Menu/Quest/menu_quest_new.tres
Normal file
15
menus/Base Menu/Quest/menu_quest_new.tres
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_resource type="Resource" script_class="Menu" load_steps=4 format=3 uid="uid://cech3n8fidoek"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_7q3gu"]
|
||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="1_fwjxd"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_slbna"]
|
||||
script = ExtResource("1_7q3gu")
|
||||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||
item_menu = &"res://menus/Base Menu/root_menu.tres"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_fwjxd")
|
||||
item_ids = Array[String](["BASE_QUEST_ACCEPT", "BASE_QUEST_DECLINE", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"])
|
||||
item_actions = Array[int]([3, 3, 0, 0, 0, 0, 0, 0])
|
||||
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_slbna"), SubResource("Resource_slbna"), null, null, null, null, null, null])
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Resource" script_class="Menu" load_steps=5 format=3 uid="uid://2ohcxoor22hr"]
|
||||
[gd_resource type="Resource" script_class="Menu" load_steps=7 format=3 uid="uid://2ohcxoor22hr"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_d2x8v"]
|
||||
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="1_h4chp"]
|
||||
|
|
@ -13,8 +13,18 @@ script = ExtResource("1_d2x8v")
|
|||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||
item_menu = &"res://menus/Base Menu/BuySell/menu_sell.tres"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_huqnt"]
|
||||
script = ExtResource("1_d2x8v")
|
||||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||
item_menu = &"res://menus/Base Menu/Quest/menu_quest_new.tres"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vkoj2"]
|
||||
script = ExtResource("1_d2x8v")
|
||||
item_script = &"res://scripts/Base/Menu/send_message.gd"
|
||||
item_menu = &"res://menus/Base Menu/Quest/menu_quest_current.tres"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_h4chp")
|
||||
item_ids = Array[String](["BASE_FETCH_BUY", "BASE_FETCH_SELL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"])
|
||||
item_actions = Array[int]([3, 3, 0, 0, 0, 0, 0, 0])
|
||||
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_iiy7m"), SubResource("Resource_pbhiw"), null, null, null, null, null, null])
|
||||
item_ids = Array[String](["BASE_FETCH_BUY", "BASE_FETCH_SELL", "BASE_TAKE_QUEST", "BASE_QUEST_INFO", "NULL", "NULL", "NULL", "NULL"])
|
||||
item_actions = Array[int]([3, 3, 3, 3, 0, 0, 0, 0])
|
||||
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_iiy7m"), SubResource("Resource_pbhiw"), SubResource("Resource_huqnt"), SubResource("Resource_vkoj2"), null, null, null, null])
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ dock={
|
|||
|
||||
[internationalization]
|
||||
|
||||
locale/translations=PackedStringArray("res://translations/gui.en.translation", "res://translations/gui.ru.translation", "res://translations/base_dialogue.en.translation", "res://translations/base_dialogue.ru.translation", "res://translations/items.en.translation", "res://translations/items.ru.translation")
|
||||
locale/translations=PackedStringArray("res://translations/gui.en.translation", "res://translations/gui.ru.translation", "res://translations/base_dialogue.en.translation", "res://translations/base_dialogue.ru.translation", "res://translations/items.en.translation", "res://translations/items.ru.translation", "res://translations/bases.en.translation", "res://translations/bases.ru.translation", "res://translations/ships.en.translation", "res://translations/ships.ru.translation")
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
|
|
|||
13
quests/test1.tres
Normal file
13
quests/test1.tres
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="Quest" load_steps=2 format=3 uid="uid://6s288ijcp7f"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Classes/quest.gd" id="1_8c3mr"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_8c3mr")
|
||||
type = 0
|
||||
progress_max = 3
|
||||
reward_money = 150.0
|
||||
restrictions = Array[int]([0])
|
||||
data = {
|
||||
"target_class": "SHIP_KAMIKAZE"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://crneq2enhxsw5"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://crneq2enhxsw5"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bsnrcw64qr2hr" path="res://scenes/Star System/star_system_template.tscn" id="1_2ai1l"]
|
||||
[ext_resource type="PackedScene" uid="uid://dk3nvl8f0v24e" path="res://scenes/Base/base_template.tscn" id="3_m5ica"]
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
[ext_resource type="Resource" uid="uid://dlnl6w416qylo" path="res://items/Valuables/raw_materials.tres" id="6_mrd6j"]
|
||||
[ext_resource type="PackedScene" uid="uid://dok3i8u5t1ka4" path="res://scenes/Ships/player_ship.tscn" id="7_jyplv"]
|
||||
[ext_resource type="Resource" uid="uid://16xqvcrmuga6" path="res://items/Valuables/energy_cell.tres" id="7_x535v"]
|
||||
[ext_resource type="Resource" uid="uid://6s288ijcp7f" path="res://quests/test1.tres" id="8_6tapm"]
|
||||
|
||||
[node name="StarSystem" instance=ExtResource("1_2ai1l")]
|
||||
width = 16384
|
||||
|
|
@ -30,6 +31,7 @@ position = Vector2(19, 10)
|
|||
position = Vector2(719, -559)
|
||||
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")])
|
||||
quest = ExtResource("8_6tapm")
|
||||
|
||||
[node name="KamikazeShip" parent="FactionAggressive" index="0" instance=ExtResource("4_i6rbg")]
|
||||
position = Vector2(-1712, -608)
|
||||
|
|
|
|||
|
|
@ -8,10 +8,13 @@ const SELL_FETCH = "BASE_FETCH_SELL"
|
|||
const BUY_ITEM = "BASE_BUY_ITEM"
|
||||
## This message will trigger dialogue to get selected item data
|
||||
const SELL_ITEM = "BASE_SELL_ITEM"
|
||||
## This message will trigger quest node to make answer format
|
||||
const TAKE_QUEST = "BASE_TAKE_QUEST"
|
||||
|
||||
@onready var dialogue = $DialogueView
|
||||
@onready var buy_sell = $"../../BuySell"
|
||||
@onready var actions_menu = $"../Actions/ActionsMenu"
|
||||
@onready var quest = $"../../Quest"
|
||||
|
||||
func _ready():
|
||||
var tween = create_tween() \
|
||||
|
|
@ -40,6 +43,8 @@ func send_message(msg: Message):
|
|||
var item_name = list[id].name
|
||||
format["amount"] = actions_menu.buy_sell_amount
|
||||
format["item_name"] = item_name
|
||||
TAKE_QUEST:
|
||||
format["answer"] = quest.answer
|
||||
var new_msg = tr(msg.fact + "_RECEIVED").format(format)
|
||||
var old_len = len(dialogue.get_parsed_text())
|
||||
dialogue.append_text(new_msg)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,44 @@ var base: Base
|
|||
|
||||
var quest: Quest
|
||||
|
||||
const NO_QUEST = "BASE_TAKE_QUEST_FAILED"
|
||||
const HAS_QUEST = "BASE_TAKE_QUEST_SUCCEED"
|
||||
const QUEST_TYPE = {
|
||||
Quest.Type.Elimination: "BASE_QUEST_ELIMINATION",
|
||||
Quest.Type.Delivery: "BASE_QUEST_DELIVERY"
|
||||
}
|
||||
const RESTRICTIONS = {
|
||||
Quest.Restriction.NoDeaths: "BASE_QUEST_RESTRICTION_NO_DEATHS",
|
||||
Quest.Restriction.NoWeapon: "BASE_QUEST_RESTRICTION_NO_WEAPON",
|
||||
Quest.Restriction.Timer: "BASE_QUEST_RESTRICTION_TIMER"
|
||||
}
|
||||
var has_quest: bool = false
|
||||
var answer: String = ""
|
||||
|
||||
func _ready():
|
||||
get_tree().create_timer(0.05).timeout.connect(fetch_quest)
|
||||
|
||||
func fetch_quest():
|
||||
base = get_parent().base
|
||||
quest = base.quest
|
||||
make_answer(quest)
|
||||
|
||||
func make_answer(quest: Quest):
|
||||
has_quest = quest != null
|
||||
if !has_quest:
|
||||
answer = tr(NO_QUEST)
|
||||
return
|
||||
var quest_format = {}
|
||||
match quest.type:
|
||||
Quest.Type.Elimination:
|
||||
quest_format["amount"] = quest.progress_max
|
||||
quest_format["target_class"] = tr(quest.data["target_class"])
|
||||
Quest.Type.Delivery:
|
||||
quest_format["base_name"] = tr(quest.data["base_name"])
|
||||
var restrictions = ""
|
||||
for restriction in quest.restrictions:
|
||||
restrictions += tr(RESTRICTIONS[restriction]) + "\n"
|
||||
quest_format["restrictions"] = restrictions
|
||||
var quest_info = tr(QUEST_TYPE[quest.type]).format(quest_format)
|
||||
var final_format = {"quest_info": quest_info}
|
||||
answer = tr(HAS_QUEST).format(final_format)
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ enum Status{
|
|||
var progress : int = 0:
|
||||
set(value):
|
||||
if value >= progress_max:
|
||||
quest_ended.emit(true)
|
||||
end()
|
||||
@export var reward_money : float
|
||||
@export var restrictions : Array[Restriction] = []
|
||||
@export var data : Dictionary = {}
|
||||
@export var status: Status
|
||||
var status: Status = Status.Idle
|
||||
|
||||
## Emits when quest was given to player
|
||||
signal quest_added
|
||||
|
|
@ -55,7 +55,7 @@ signal quest_ended
|
|||
signal quest_failed
|
||||
|
||||
## Creates quest with given parameters
|
||||
static func create(type : Type, progress_max : int, reward_money : float, restrictions : Array[Restriction] = [], data : Dictionary = {}) -> void:
|
||||
static func create(type : Type, progress_max : int, reward_money : float, restrictions : Array[Restriction] = [], data : Dictionary = {}) -> Quest:
|
||||
var quest = Quest.new()
|
||||
quest.type = type
|
||||
quest.progress_max = progress_max
|
||||
|
|
@ -64,6 +64,7 @@ static func create(type : Type, progress_max : int, reward_money : float, restri
|
|||
quest.data = data
|
||||
quest.status = Status.Taken
|
||||
quest.quest_added.emit(quest)
|
||||
return quest
|
||||
|
||||
## Progress by quest
|
||||
func do_progress() -> void:
|
||||
|
|
@ -74,6 +75,14 @@ func fail() -> void:
|
|||
quest_failed.emit(false)
|
||||
status = Status.Idle
|
||||
|
||||
func end() -> void:
|
||||
quest_ended.emit(true)
|
||||
status = Status.Reward
|
||||
|
||||
func reward() -> float:
|
||||
status = Status.Idle
|
||||
return reward_money
|
||||
|
||||
## Trigger restriction
|
||||
func trigger_restriction(restriction: Restriction) -> void:
|
||||
if restrictions.has(restriction):
|
||||
|
|
|
|||
|
|
@ -17,4 +17,24 @@ BASE_BUY_ITEM_RECEIVED,"[BOUGHT {amount}x{item_name}]\nThanks, anything else?\n>
|
|||
BASE_SELL_ITEM_LOCAL,Sell {amount}x{item_name} ({total_cost}),Продать {amount}x{item_name} ({total_cost})
|
||||
BASE_SELL_ITEM_RECEIVED,"[SOLD {amount}x{item_name}]\nThanks, anything else?\n> ","[ПРОДАНО {amount}x{item_name}]\nСпасибо, что-то ещё?\n> "
|
||||
BUY_SELL_ITEM,{item_id}. {item_name},{item_id}. {item_name}
|
||||
BASE_TAKE_QUEST_LOCAL,Ask about assignments,Спросить насчёт поручений
|
||||
BASE_TAKE_QUEST_RECEIVED,Do you have any work for me?\n{answer},Есть ли у вас работа для меня?\n{answer}
|
||||
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_QUEST_INFO_LOCAL,Ask about current errand state,Узнать состояние текущего поручения
|
||||
BASE_QUEST_INFO_RECEIVED,"Can I ask about my errand state?\nYou errand was:\n{answer}\nCurrent progress:\n{progress}\n> ","Можно узнать состояние моего поручения?\nВаше поручение звучало так:\n{answer}\nТекущий прогресс:\n{progress}\n> "
|
||||
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_DECLINE_LOCAL,Decline,Отказаться
|
||||
BASE_QUEST_DECLINE_RECEIVED,"Maybe another time\nAs you wish.\nAnything else?\n> ","Может быть, в другой раз\nКак Вам угодно.\nЧто-то ещё?\n> "
|
||||
BASE_QUEST_CANCEL_LOCAL,Reject the errand,Отказаться от поручения
|
||||
BASE_QUEST_CANCEL_RECEIVED,"I want to reject the errand\nIn that case, you won't get any reward.\nAnything else?\n> ","Я хочу отказаться от поручения\nВ таком случае, никакой награды Вам не положено.\nЧто-то ещё?\n> "
|
||||
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 {reward} SPINOTS]\nAnything else?\n> ","Я выполнил ваше поручение, что насчёт награды?\nСекунду...\nДа, действительно, дело сделано, сейчас переведу вашу награду...\n[ПОЛУЧЕНО {reward} СПИНОТОВ]\nЧто-то ещё?\n> "
|
||||
BASE_QUEST_ELIMINATION,"Eliminate {target_class} class ships: {amount}\n[ul]{restrictions}[/ul]","Уничтожьте корабли класса {target_class}: {amount}\n[ul]{restrictions}[/ul]"
|
||||
BASE_QUEST_DELIVERY,"We'll entrust you with a valuable cargo. Deliver it to the base {base_name}\n[ul]{restrictions}[/ul]","Мы поручим вам ценный груз. Доставьте его на базу {base_name}.\n[ul]{restrictions}[/ul]"
|
||||
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_TIMER,"You have {time} s. to complete the errand","У вас есть {time} сек. на выполнение поручения"
|
||||
BASE_RETURN,Back,Назад
|
||||
NULL, ,
|
||||
|
Binary file not shown.
Binary file not shown.
3
translations/bases.csv
Normal file
3
translations/bases.csv
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
,en,ru
|
||||
BASE_NAME_0,Zakozlennaja,Закозлённая
|
||||
BASE_NAME_1,Spinned,Покрученная
|
||||
|
17
translations/bases.csv.import
Normal file
17
translations/bases.csv.import
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[remap]
|
||||
|
||||
importer="csv_translation"
|
||||
type="Translation"
|
||||
uid="uid://neu2fqwajpmd"
|
||||
|
||||
[deps]
|
||||
|
||||
files=["res://translations/bases.en.translation", "res://translations/bases.ru.translation"]
|
||||
|
||||
source_file="res://translations/bases.csv"
|
||||
dest_files=["res://translations/bases.en.translation", "res://translations/bases.ru.translation"]
|
||||
|
||||
[params]
|
||||
|
||||
compress=true
|
||||
delimiter=0
|
||||
BIN
translations/bases.en.translation
Normal file
BIN
translations/bases.en.translation
Normal file
Binary file not shown.
BIN
translations/bases.ru.translation
Normal file
BIN
translations/bases.ru.translation
Normal file
Binary file not shown.
3
translations/ships.csv
Normal file
3
translations/ships.csv
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
,en,ru
|
||||
SHIP_KAMIKAZE,Kamikaze,Камикадзе
|
||||
SHIP_SHOOTER,Shooter,Стрелок
|
||||
|
17
translations/ships.csv.import
Normal file
17
translations/ships.csv.import
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[remap]
|
||||
|
||||
importer="csv_translation"
|
||||
type="Translation"
|
||||
uid="uid://dliy5u8hemcej"
|
||||
|
||||
[deps]
|
||||
|
||||
files=["res://translations/ships.en.translation", "res://translations/ships.ru.translation"]
|
||||
|
||||
source_file="res://translations/ships.csv"
|
||||
dest_files=["res://translations/ships.en.translation", "res://translations/ships.ru.translation"]
|
||||
|
||||
[params]
|
||||
|
||||
compress=true
|
||||
delimiter=0
|
||||
BIN
translations/ships.en.translation
Normal file
BIN
translations/ships.en.translation
Normal file
Binary file not shown.
BIN
translations/ships.ru.translation
Normal file
BIN
translations/ships.ru.translation
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue