More work on quests

This commit is contained in:
2025-11-19 14:42:59 -05:00
parent 379fa4bd70
commit 4ed4ab95f3
36 changed files with 3911 additions and 75 deletions

View File

@@ -14,11 +14,13 @@ enum Status{
}
enum Locations{
VOID,
NESTORS_WOODS
}
class Event:
var enemy_types: Dictionary[String, PackedScene] = {
"feral pig": preload("res://templates/enemies/feral_pig.tscn"),
"goo": preload("res://templates/enemies/goo.tscn")
}
enum Type{
@@ -299,11 +301,15 @@ func is_eligible(member : Adventurer) -> bool:
func is_taken() -> bool:
return status == Status.TAKEN
func location_name() -> String:
static func location_name(location : Locations) -> String:
match(location):
Locations.VOID: return "The Endless Void"
Locations.NESTORS_WOODS: return "Nestor's Woods"
return "ERROR"
func get_location_name() -> String:
return Quest.location_name(location)
func difficulty_name() -> String:
match(difficulty):
0: return "None"
@@ -330,7 +336,16 @@ static func load_quest_list() -> void:
dir.list_dir_end()
static func generate(parameters : Dictionary) -> Quest:
return null
var candidates : Array[Quest] = []
var l = list
for q in list:
if parameters.location != -1 and q.location != parameters.location:
continue
if q.difficulty < parameters.min_difficulty or q.difficulty > parameters.max_difficulty:
continue
candidates.append(q)
var choice : Quest = candidates.pick_random()
return choice.duplicate()
func save() -> Dictionary:
var d : Dictionary = {}

View File

@@ -0,0 +1,42 @@
extends Quest
func _init() -> void:
name = "[1] A Quest for Nestor's Woods that Ann Marie Promised Me"
super._init()
func setup() -> void:
var event_weights = [1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,4,4,5]
var num_events = 3 # event_weights.pick_random()
#The first event is guaranteed to be at the 50% mark.
var first : bool = true
var pranges : Array = []
var margin : float = 0.1
for i in range(num_events):
var evt : Quest.Event = Quest.Event.new()
evt.type = Quest.Event.Type.COMBAT
evt.enemies = ["goo"]
evt.time = 5
if first:
#Make invisible
evt.progress_point = .5
pranges.append([margin, evt.progress_point-margin])
pranges.append([evt.progress_point+margin, 1 - margin])
first = false
else:
evt.hidden = true
pranges.shuffle()
var range = pranges.pop_back()
evt.progress_point = randf_range(range[0], range[1])
if evt.progress_point - range[0] >= 2 * margin:
pranges.append([range[0], evt.progress_point - margin])
if range[1] - evt.progress_point >= 2 * margin:
pranges.append([evt.progress_point + margin, range[1]])
events.append(evt)
events.sort_custom(func(a,b): return a.progress_point < b.progress_point)
desc = "One day Ann Marie will write me."
location = Quest.Locations.NESTORS_WOODS
rewards = {"exp":10, "gold":5}
guild_rewards = {"glory":10, "gold":5}
covenant_cost = 5

View File

@@ -0,0 +1 @@
uid://w6t0lkkxmbl2

49
data/quests/feral_pigs.gd Normal file
View File

@@ -0,0 +1,49 @@
extends Quest
func _init() -> void:
name = "Fight of the Feral Pigs"
location = Quest.Locations.NESTORS_WOODS
difficulty = 1
super._init()
func setup() -> void:
var event_weights = [1,1,1,1,1,1,1,1,2,2,2,2,3,3,3]
var num_events = event_weights.pick_random()
#The first event is guaranteed to be at the 50% mark.
var first : bool = true
var pranges : Array = []
var margin : float = 0.1
for i in range(num_events):
var evt : Quest.Event = Quest.Event.new()
evt.type = Quest.Event.Type.COMBAT
evt.enemies = []
for j in range(randi() %3 + 1):
evt.enemies.append("feral pig")
evt.time = 600
evt.completed.connect(_on_combat_complete.bind(evt))
if first:
#Make invisible
evt.progress_point = .5
pranges.append([margin, evt.progress_point-margin])
pranges.append([evt.progress_point+margin, 1 - margin])
first = false
else:
evt.hidden = true
pranges.shuffle()
var range = pranges.pop_back()
evt.progress_point = randf_range(range[0], range[1])
if evt.progress_point - range[0] >= 2 * margin:
pranges.append([range[0], evt.progress_point - margin])
if range[1] - evt.progress_point >= 2 * margin:
pranges.append([evt.progress_point + margin, range[1]])
events.append(evt)
events.sort_custom(func(a,b): return a.progress_point < b.progress_point)
desc = "Pigs got out of Old Johns farm again. Poor fella dont know up from down at his age, he cant help it. Trouble is, pigs are causing trouble in them there woods and John sure aint takin care of it. Handle 'em for us, would you?"
location = Quest.Locations.NESTORS_WOODS
rewards = {"exp":10, "gold":5}
guild_rewards = {"glory":5, "gold":5}
covenant_cost = 5
func _on_combat_complete(event : Quest.Event) -> void:
rewards.gold += 2 * len(event.enemies)

View File

@@ -0,0 +1 @@
uid://nnl5qvb3csr0

View File

@@ -1,7 +1,11 @@
extends Quest
func setup() -> void:
func _init() -> void:
name = "A Sticky Situation"
location = Quest.Locations.VOID
super._init()
func setup() -> void:
var event_weights = [1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,4,4,5]
var num_events = 3 # event_weights.pick_random()
#The first event is guaranteed to be at the 50% mark.