Quests system + Elimination quest

This commit is contained in:
gotfishmakesticks 2023-11-16 10:43:32 +03:00
commit 2bca6b2fe5
6 changed files with 92 additions and 0 deletions

41
scripts/quest.gd Normal file
View file

@ -0,0 +1,41 @@
class_name Quest
enum TYPE {ELIMINATION, DELIVERY, ESCORT, RACE, DIVERSE}
enum RESTRICTIONS{NO_DEATHS,NO_WEAPON,TIMER}
var type : Quest.TYPE = Quest.TYPE.ELIMINATION
var progress_max : int = 1
var progress : int = 0
var reward_money : float
var restrictions : Array[RESTRICTIONS] = []
var data : Dictionary = {}
var new : bool = true
signal quest_added
signal quest_ended
signal quest_failed
func create(type : TYPE, progress_max : int, reward_money : float, restrictions : Array[RESTRICTIONS] = [], data : Dictionary = {}) -> void:
self.type = type
self.progress_max = progress_max
self.reward_money = reward_money
self.restrictions = restrictions
self.data = data
quest_added.emit(self)
self.new = false
func do_progress() -> void:
progress += 1
if progress >= progress_max:
quest_ended.emit(true)
func fail() -> void:
quest_failed.emit(false)
func _restriction_no_deaths():
if restrictions.has(RESTRICTIONS.NO_DEATHS):
fail()
func _restriction_no_weapon():
if restrictions.has(RESTRICTIONS.NO_WEAPON):
fail()