Files
pomchronicles/data/quests/feral_pigs.gd
2025-11-19 14:42:59 -05:00

50 lines
1.8 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)