NPCs can take quests!
This commit is contained in:
@@ -3,11 +3,12 @@ class_name QuestBoard extends Interactable
|
||||
|
||||
@onready var polygon : CollisionPolygon2D = $CollisionPolygon2D
|
||||
@onready var window : QuestBoardWindow = $QuestBoardWindow
|
||||
@onready var btplayer : BTPlayer = $BTPlayer
|
||||
|
||||
signal interaction_complete()
|
||||
|
||||
func _ready() -> void:
|
||||
register_board.call_deferred()
|
||||
super._ready()
|
||||
|
||||
func register_board() -> void:
|
||||
Guild.hall.register_interactables(self)
|
||||
@@ -25,7 +26,19 @@ func interact(interactor, type : String = "") -> void:
|
||||
window.populate(Guild.quests.keys())
|
||||
window.popup_centered()
|
||||
elif type == "quest":
|
||||
var viable_quests : Dictionary[Quest,int] = {}
|
||||
#Go through all quests and create a list of open quests suitable for their level
|
||||
for quest in Guild.quests:
|
||||
if quest.is_eligible(interactor.data):
|
||||
#TODO: Make them weight different quests differently.
|
||||
viable_quests[quest] = 1
|
||||
#If that list is zero, return without giving them a quest
|
||||
if viable_quests.size() != 0:
|
||||
var rnd_quest = []
|
||||
for quest in viable_quests.keys():
|
||||
for i in range(viable_quests[quest]):
|
||||
rnd_quest.append(quest)
|
||||
var quest = rnd_quest.pick_random()
|
||||
Guild.assign_quest(interactor.data, quest)
|
||||
interaction_complete.emit()
|
||||
#Else pick a random quest from the list and assign it to them
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user