Quest generating + quest adding interface + some bugfixes
This commit is contained in:
parent
008e74eba3
commit
f4cf1ef4e9
7 changed files with 71 additions and 20 deletions
|
|
@ -192,6 +192,7 @@ script = ExtResource("2_ld3o5")
|
||||||
|
|
||||||
[node name="CurrentQuest" type="NinePatchRect" parent="QuestMenu"]
|
[node name="CurrentQuest" type="NinePatchRect" parent="QuestMenu"]
|
||||||
visible = false
|
visible = false
|
||||||
|
layout_mode = 0
|
||||||
offset_left = 64.0
|
offset_left = 64.0
|
||||||
offset_top = 64.0
|
offset_top = 64.0
|
||||||
offset_right = 576.0
|
offset_right = 576.0
|
||||||
|
|
@ -204,6 +205,7 @@ patch_margin_right = 2
|
||||||
patch_margin_bottom = 2
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
[node name="Header" type="Label" parent="QuestMenu/CurrentQuest"]
|
[node name="Header" type="Label" parent="QuestMenu/CurrentQuest"]
|
||||||
|
layout_mode = 0
|
||||||
offset_right = 512.0
|
offset_right = 512.0
|
||||||
offset_bottom = 64.0
|
offset_bottom = 64.0
|
||||||
text = "Current Quest Status"
|
text = "Current Quest Status"
|
||||||
|
|
@ -236,6 +238,7 @@ offset_bottom = 511.0
|
||||||
text = "Abandon quest"
|
text = "Abandon quest"
|
||||||
|
|
||||||
[node name="CompleteQuest" type="Button" parent="QuestMenu/CurrentQuest"]
|
[node name="CompleteQuest" type="Button" parent="QuestMenu/CurrentQuest"]
|
||||||
|
layout_mode = 0
|
||||||
offset_left = 256.0
|
offset_left = 256.0
|
||||||
offset_top = 448.0
|
offset_top = 448.0
|
||||||
offset_right = 511.0
|
offset_right = 511.0
|
||||||
|
|
@ -245,6 +248,7 @@ text = "Complete quest"
|
||||||
|
|
||||||
[node name="NewQuest" type="NinePatchRect" parent="QuestMenu"]
|
[node name="NewQuest" type="NinePatchRect" parent="QuestMenu"]
|
||||||
visible = false
|
visible = false
|
||||||
|
layout_mode = 0
|
||||||
offset_left = 64.0
|
offset_left = 64.0
|
||||||
offset_top = 64.0
|
offset_top = 64.0
|
||||||
offset_right = 576.0
|
offset_right = 576.0
|
||||||
|
|
@ -257,6 +261,7 @@ patch_margin_right = 2
|
||||||
patch_margin_bottom = 2
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
[node name="Header" type="Label" parent="QuestMenu/NewQuest"]
|
[node name="Header" type="Label" parent="QuestMenu/NewQuest"]
|
||||||
|
layout_mode = 0
|
||||||
offset_right = 512.0
|
offset_right = 512.0
|
||||||
offset_bottom = 64.0
|
offset_bottom = 64.0
|
||||||
text = "New Quest"
|
text = "New Quest"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ var base
|
||||||
@onready var current_quest = $QuestMenu/CurrentQuest
|
@onready var current_quest = $QuestMenu/CurrentQuest
|
||||||
@onready var new_quest = $QuestMenu/NewQuest
|
@onready var new_quest = $QuestMenu/NewQuest
|
||||||
@onready var accept_quest = $QuestMenu/NewQuest/AcceptQuest
|
@onready var accept_quest = $QuestMenu/NewQuest/AcceptQuest
|
||||||
|
@onready var new_quest_status = $QuestMenu/NewQuest/QuestStatus
|
||||||
var base_types = ["Power Supply", "Mining", "Food Production", "Trading", "Modules"]
|
var base_types = ["Power Supply", "Mining", "Food Production", "Trading", "Modules"]
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
@ -28,6 +28,7 @@ func _ready():
|
||||||
abandon_quest.button_up.connect(quest_abandon)
|
abandon_quest.button_up.connect(quest_abandon)
|
||||||
complete_quest.button_up.connect(quest_complete)
|
complete_quest.button_up.connect(quest_complete)
|
||||||
accept_quest.button_up.connect(quest_accept)
|
accept_quest.button_up.connect(quest_accept)
|
||||||
|
quest_status_update()
|
||||||
|
|
||||||
func update_lists():
|
func update_lists():
|
||||||
buy_list.clear()
|
buy_list.clear()
|
||||||
|
|
@ -109,6 +110,7 @@ func quest_abandon():
|
||||||
ship.quest.fail()
|
ship.quest.fail()
|
||||||
current_quest.visible = false
|
current_quest.visible = false
|
||||||
new_quest.visible = true
|
new_quest.visible = true
|
||||||
|
quest_status_update()
|
||||||
|
|
||||||
func quest_complete():
|
func quest_complete():
|
||||||
if !ship.quest_completed:
|
if !ship.quest_completed:
|
||||||
|
|
@ -117,23 +119,31 @@ func quest_complete():
|
||||||
ship.quest_completed = false
|
ship.quest_completed = false
|
||||||
current_quest.visible = false
|
current_quest.visible = false
|
||||||
new_quest.visible = true
|
new_quest.visible = true
|
||||||
|
quest_status_update()
|
||||||
|
|
||||||
func quest_accept():
|
func quest_accept():
|
||||||
pass
|
ship.quest.create(base.quest.type, base.quest.progress_max, base.quest.reward_money, base.quest.restrictions, base.quest.data)
|
||||||
|
ship.quest.progress = 0
|
||||||
|
new_quest.visible = false
|
||||||
|
current_quest.visible = true
|
||||||
|
quest_status_update()
|
||||||
|
|
||||||
func quest_status_update():
|
func quest_status_update():
|
||||||
|
var ship_has_quest = !ship.quest.new or ship.quest_completed
|
||||||
|
var upd_quest = ship.quest if ship_has_quest else base.quest
|
||||||
|
var upd_text = current_quest_status if ship_has_quest else new_quest_status
|
||||||
var restriction_typing = {
|
var restriction_typing = {
|
||||||
Quest.RESTRICTIONS.NO_DEATHS : '- Destruction of your ship will lead to quest failure.',
|
Quest.RESTRICTIONS.NO_DEATHS : '- Destruction of your ship will lead to quest failure.',
|
||||||
Quest.RESTRICTIONS.NO_WEAPON : '- Using any weapon (even accidently) is prohibited.',
|
Quest.RESTRICTIONS.NO_WEAPON : '- Using any weapon (even accidently) is prohibited.',
|
||||||
Quest.RESTRICTIONS.TIMER : '- You have {sec} seconds to complete the quest since it is accepted.'
|
Quest.RESTRICTIONS.TIMER : '- You have {sec} seconds to complete the quest since it is accepted.'
|
||||||
}
|
}
|
||||||
if ship.quest.data.has('timer'):
|
if upd_quest.data.has('timer'):
|
||||||
restriction_typing[Quest.RESTRICTIONS.TIMER] = restriction_typing[Quest.RESTRICTIONS.TIMER].format(ship.quest.data['timer'])
|
restriction_typing[Quest.RESTRICTIONS.TIMER] = restriction_typing[Quest.RESTRICTIONS.TIMER].format({"sec" : upd_quest.data['timer']})
|
||||||
var template = "Type: {type}\n\nObjective: {objective_text}\n\nReward: {reward} money units\n\nRestrictions: {restrictions}"
|
var template = "Type: {type}\n\nObjective: {objective_text}\n\nReward: {reward} money units\n\nRestrictions: {restrictions}"
|
||||||
var typed_templates = {
|
var typed_templates = {
|
||||||
Quest.TYPE.ELIMINATION : {
|
Quest.TYPE.ELIMINATION : {
|
||||||
"type" : "Elimination",
|
"type" : "Elimination",
|
||||||
"objective" : "Destroy {req} hostile ships [ {cur} / {req} ]".format({"cur" : ship.quest.progress, "req" : ship.quest.progress_max})
|
"objective" : "Destroy {req} hostile ships [ {cur} / {req} ]".format({"cur" : upd_quest.progress, "req" : upd_quest.progress_max})
|
||||||
},
|
},
|
||||||
|
|
||||||
Quest.TYPE.DELIVERY : {
|
Quest.TYPE.DELIVERY : {
|
||||||
|
|
@ -142,16 +152,16 @@ func quest_status_update():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var restrictions = ""
|
var restrictions = ""
|
||||||
if len(ship.quest.restrictions) == 0 :
|
if len(upd_quest.restrictions) == 0 :
|
||||||
restrictions = "None"
|
restrictions = "None"
|
||||||
else:
|
else:
|
||||||
for restriction in ship.quest.restrictions:
|
for restriction in upd_quest.restrictions:
|
||||||
restrictions.append("\n", restriction_typing[restriction])
|
restrictions += "\n" + restriction_typing[restriction]
|
||||||
var formatting = {
|
var formatting = {
|
||||||
"type" : typed_templates[ship.quest.type]['type'],
|
"type" : typed_templates[upd_quest.type]['type'],
|
||||||
"objective_text" : typed_templates[ship.quest.type]['objective'],
|
"objective_text" : typed_templates[upd_quest.type]['objective'],
|
||||||
"reward" : ship.quest.reward_money,
|
"reward" : upd_quest.reward_money,
|
||||||
"restrictions" : restrictions
|
"restrictions" : restrictions
|
||||||
}
|
}
|
||||||
current_quest_status.text = template.format(formatting)
|
upd_text.text = template.format(formatting)
|
||||||
complete_quest.disabled = !ship.quest_completed
|
complete_quest.disabled = !ship.quest_completed
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@ func open():
|
||||||
menu = quest_menu
|
menu = quest_menu
|
||||||
var ship_has_quest = !base_menu.ship.quest.new or base_menu.ship.quest_completed
|
var ship_has_quest = !base_menu.ship.quest.new or base_menu.ship.quest_completed
|
||||||
submenu = base_menu.current_quest if ship_has_quest else base_menu.new_quest
|
submenu = base_menu.current_quest if ship_has_quest else base_menu.new_quest
|
||||||
if ship_has_quest:
|
base_menu.quest_status_update()
|
||||||
base_menu.quest_status_update()
|
|
||||||
"EquipmentMenuGoto":
|
"EquipmentMenuGoto":
|
||||||
menu = equipment_menu
|
menu = equipment_menu
|
||||||
"InfoMenuGoto":
|
"InfoMenuGoto":
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,14 @@ var want_to_buy : Array[Item] = []
|
||||||
var sell_prices : Array[float] = []
|
var sell_prices : Array[float] = []
|
||||||
var buy_prices : Array[float] = []
|
var buy_prices : Array[float] = []
|
||||||
|
|
||||||
|
var quest : Quest = Quest.new()
|
||||||
|
const available_quests : Array[Quest.TYPE]= [Quest.TYPE.ELIMINATION]
|
||||||
|
const restrictions_foreach_type : Dictionary = {
|
||||||
|
Quest.TYPE.ELIMINATION : [Quest.RESTRICTIONS.NO_DEATHS, Quest.RESTRICTIONS.TIMER]
|
||||||
|
}
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
randomize()
|
||||||
ship.minimap.add_marker(self, "base")
|
ship.minimap.add_marker(self, "base")
|
||||||
match type:
|
match type:
|
||||||
Game.BASE_TYPE.POWER:
|
Game.BASE_TYPE.POWER:
|
||||||
|
|
@ -38,6 +45,7 @@ func _ready():
|
||||||
want_to_buy.append(Game.get_item("Energy Cell"))
|
want_to_buy.append(Game.get_item("Energy Cell"))
|
||||||
want_to_buy.append(Game.get_item("Raw Materials"))
|
want_to_buy.append(Game.get_item("Raw Materials"))
|
||||||
update_prices()
|
update_prices()
|
||||||
|
generate_quest()
|
||||||
|
|
||||||
func update_prices():
|
func update_prices():
|
||||||
sell_prices = []
|
sell_prices = []
|
||||||
|
|
@ -55,3 +63,28 @@ func update_prices():
|
||||||
else:
|
else:
|
||||||
price = randi_range(item.min_price * 100, (item.max_price + item.min_price) / 2 * 100) / 100.0
|
price = randi_range(item.min_price * 100, (item.max_price + item.min_price) / 2 * 100) / 100.0
|
||||||
buy_prices.append(price)
|
buy_prices.append(price)
|
||||||
|
|
||||||
|
func generate_quest():
|
||||||
|
var difficulty : float = randi_range(100, 300) / 100.0
|
||||||
|
var reward_multi : float = randi_range(100, max(difficulty/1.5 * 100, 100)) / 100.0
|
||||||
|
var quest_type : Quest.TYPE = available_quests.pick_random()
|
||||||
|
var progress_max : int
|
||||||
|
var reward_money : int
|
||||||
|
var restrictions : Array[Quest.RESTRICTIONS] = []
|
||||||
|
var data : Dictionary = {}
|
||||||
|
for restriction in restrictions_foreach_type[quest_type]:
|
||||||
|
var hit = randi_range(0, 1)
|
||||||
|
if hit:
|
||||||
|
restrictions.append(restriction)
|
||||||
|
match quest_type:
|
||||||
|
Quest.TYPE.ELIMINATION:
|
||||||
|
progress_max = difficulty * 2
|
||||||
|
reward_money = 50 * progress_max * reward_multi
|
||||||
|
if restrictions.has(Quest.RESTRICTIONS.NO_DEATHS):
|
||||||
|
reward_money *= 1.5
|
||||||
|
if restrictions.has(Quest.RESTRICTIONS.NO_WEAPON):
|
||||||
|
reward_money *= 1.5
|
||||||
|
if restrictions.has(Quest.RESTRICTIONS.TIMER):
|
||||||
|
reward_money *= 1.5
|
||||||
|
data['timer'] = int(difficulty * 30)
|
||||||
|
quest.create(quest_type, progress_max, reward_money, restrictions, data)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ func _ready():
|
||||||
|
|
||||||
secondary_slot.add_child(Game.get_weapon("SingleRocketMk1").instantiate())
|
secondary_slot.add_child(Game.get_weapon("SingleRocketMk1").instantiate())
|
||||||
|
|
||||||
quest.create(Quest.TYPE.ELIMINATION, 2, 200)
|
#quest.create(Quest.TYPE.ELIMINATION, 2, 200)
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if hull.hp < 0: destroy()
|
if hull.hp < 0: destroy()
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,10 @@ func _physics_process(_delta):
|
||||||
runawaystate()
|
runawaystate()
|
||||||
var format = {"HP" : "%0.2f" % hull.hp, "SC" : "%0.2f" % shield.capacity}
|
var format = {"HP" : "%0.2f" % hull.hp, "SC" : "%0.2f" % shield.capacity}
|
||||||
healthbar.text = "{HP} HS + {SC} SC".format(format)
|
healthbar.text = "{HP} HS + {SC} SC".format(format)
|
||||||
if Vector2.ZERO.distance_to(global_position) > 5800 or hull.hp <= 0:
|
if hull.hp <= 0:
|
||||||
destroy()
|
destroy()
|
||||||
|
if Vector2.ZERO.distance_to(global_position) > 5800:
|
||||||
|
destroy(true)
|
||||||
|
|
||||||
func switchdestination():
|
func switchdestination():
|
||||||
engine.destination_angle = randi_range(0, 360)
|
engine.destination_angle = randi_range(0, 360)
|
||||||
|
|
@ -71,7 +73,7 @@ func runawaystate():
|
||||||
if global_position.distance_to(ship.global_position) > 1024 or !ship.allow_shooting:
|
if global_position.distance_to(ship.global_position) > 1024 or !ship.allow_shooting:
|
||||||
state = "idle"
|
state = "idle"
|
||||||
|
|
||||||
func destroy():
|
func destroy(silent : bool = false):
|
||||||
hull.hp = hull.max_hp
|
hull.hp = hull.max_hp
|
||||||
hull.fuel = hull.max_fuel
|
hull.fuel = hull.max_fuel
|
||||||
shield.capacity = shield.max_capacity
|
shield.capacity = shield.max_capacity
|
||||||
|
|
@ -82,4 +84,5 @@ func destroy():
|
||||||
bounty_inst.amount = randi_range(bounty_min, bounty_max)
|
bounty_inst.amount = randi_range(bounty_min, bounty_max)
|
||||||
bounty_inst.text.text = str(bounty_inst.amount) + " MU"
|
bounty_inst.text.text = str(bounty_inst.amount) + " MU"
|
||||||
global_position = Vector2(randi_range(-4096, 4096), randi_range(-4096, 4096))
|
global_position = Vector2(randi_range(-4096, 4096), randi_range(-4096, 4096))
|
||||||
destroyed.emit(self)
|
if !silent:
|
||||||
|
destroyed.emit(self)
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,17 @@ func create(type : TYPE, progress_max : int, reward_money : float, restrictions
|
||||||
|
|
||||||
func do_progress() -> void:
|
func do_progress() -> void:
|
||||||
progress += 1
|
progress += 1
|
||||||
|
print("sheesh")
|
||||||
if progress >= progress_max:
|
if progress >= progress_max:
|
||||||
quest_ended.emit(true)
|
quest_ended.emit(true)
|
||||||
|
|
||||||
func fail() -> void:
|
func fail() -> void:
|
||||||
quest_failed.emit(false)
|
quest_failed.emit(false)
|
||||||
|
|
||||||
func _restriction_no_deaths():
|
func _restriction_no_deaths() -> void:
|
||||||
if restrictions.has(RESTRICTIONS.NO_DEATHS):
|
if restrictions.has(RESTRICTIONS.NO_DEATHS):
|
||||||
fail()
|
fail()
|
||||||
|
|
||||||
func _restriction_no_weapon():
|
func _restriction_no_weapon() -> void:
|
||||||
if restrictions.has(RESTRICTIONS.NO_WEAPON):
|
if restrictions.has(RESTRICTIONS.NO_WEAPON):
|
||||||
fail()
|
fail()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue