Fixed quest system path indicator
This commit is contained in:
@@ -5,6 +5,9 @@ var raycasts_count = 100
|
||||
var raycast_queue = []
|
||||
var astar: AStar
|
||||
|
||||
# Need to make more generic
|
||||
var exit_door: Node
|
||||
|
||||
func _ready():
|
||||
set_save_slot(0)
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ var quest_triggers = [
|
||||
"desc": "You wake up from noise. Explore the building to find the source.",
|
||||
"trigger": ["once", 0, 0, 10],
|
||||
"objectives": [
|
||||
["walkto_room", "Check enterance.", "Check enterance room.", "exit_room", 8.0]
|
||||
["walkto_room", "Check enterance.", "Check enterance room.", "exit_room", 8.0],
|
||||
["walkto_exit", "Check enteranc edoor is ok.", "Check the door.", 3.0]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -103,13 +104,12 @@ class Quest extends Reference:
|
||||
return _title
|
||||
class ObjectiveWalkto extends QuestObjective:
|
||||
var where = Vector3()
|
||||
var meta = ""
|
||||
var radius = 0.0
|
||||
var indicator = preload("res://ui/quest_indicator.tscn")
|
||||
var ind_i: Node2D
|
||||
var old_pos = Vector3()
|
||||
func _init(t, d, w, r).(t, d):
|
||||
meta = w
|
||||
where = w
|
||||
radius = r
|
||||
func activate():
|
||||
active = true
|
||||
@@ -128,6 +128,7 @@ class ObjectiveWalkto extends QuestObjective:
|
||||
func finish():
|
||||
active = false
|
||||
ind_i.queue_free()
|
||||
print(_title, " FINISHED")
|
||||
func update():
|
||||
if !active:
|
||||
return
|
||||
@@ -148,9 +149,11 @@ class ObjectiveWalkto extends QuestObjective:
|
||||
else:
|
||||
ind_i.target = where + Vector3(0, 1, 0) * 0.3
|
||||
old_pos = player_pos
|
||||
if old_pos.distance_to(where) < radius:
|
||||
complete = true
|
||||
func save():
|
||||
var save_data = {}
|
||||
save_data.create = ["walkto_room", _title, _desc, meta, radius]
|
||||
save_data.create = ["walkto_room", _title, _desc, where, radius]
|
||||
save_data.active = active
|
||||
save_data.complete = complete
|
||||
return save_data
|
||||
@@ -182,7 +185,24 @@ func create_objective(v):
|
||||
var o_desc = v[2]
|
||||
var o_meta = v[3]
|
||||
var o_radius = v[4]
|
||||
var obj = ObjectiveWalkto.new(o_title, o_desc, o_meta, o_radius)
|
||||
var where = Vector3()
|
||||
var rooms = global.get_tree().get_nodes_in_group("room")
|
||||
var room_set = false
|
||||
for e in rooms:
|
||||
print(e.name)
|
||||
if e.has_meta(o_meta):
|
||||
where = e.global_transform.origin
|
||||
room_set = true
|
||||
break
|
||||
assert(room_set == true)
|
||||
var obj = ObjectiveWalkto.new(o_title, o_desc, where, o_radius)
|
||||
return obj
|
||||
"walkto_exit":
|
||||
var o_title = v[1]
|
||||
var o_desc = v[2]
|
||||
var o_radius = v[3]
|
||||
var where = global.exit_door.global_transform.origin
|
||||
var obj = ObjectiveWalkto.new(o_title, o_desc, where, o_radius)
|
||||
return obj
|
||||
return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user