Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ config_version=4

_global_script_classes=[ {
"base": "Reference",
"class": "abstract_achievement",
"language": "GDScript",
"path": "res://scripts/game/achievements/achievement.gd"
}, {
"base": "Reference",
"class": "abstract_action",
"language": "GDScript",
"path": "res://characters/state/ai/action.gd"
Expand Down Expand Up @@ -465,6 +470,7 @@ _global_script_classes=[ {
"path": "res://characters/persons/vladimir.gd"
} ]
_global_script_class_icons={
"abstract_achievement": "",
"abstract_action": "",
"abstract_behavior": "",
"abstract_dialogue": "",
Expand Down
17 changes: 17 additions & 0 deletions scripts/game/achievements/achievement.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class_name abstract_achievement

static func id() -> String:
errors.debug_assert(false, "should not be called")
return ""

static func name() -> String:
errors.debug_assert(false, "should not be called")
return ""

static func description() -> String:
errors.debug_assert(false, "should not be called")
return ""

static func icon() -> Resource:
errors.debug_assert(false, "should not be called")
return null
41 changes: 41 additions & 0 deletions scripts/game/achievements/achievements.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extends Node

var achievement_data: Dictionary = {
"all_dialogues": {
"name": "Way too much talk",
"description": "See every dialogue text at least once.",
"condition": funcref(self, "_all_dialogues_unlock")
},
"high_speed": {
"name": "Light is my name",
"description": "Be fast.",
"condition": funcref(self, "_high_speed_unlock")
},
"all_dead": {
"name": "I bring death",
"description": "Kill them. All of them. Then yourself.",
"condition": funcref(self, "_all_dead_unlock")
}
}

var achievement_progress: Dictionary = {}

func _process(_delta: float):
for achievement in achievement_data.keys():
if(achievement_progress.get(achievement, false)):
continue
var unlock_func: FuncRef = achievement_data[achievement]["condition"]
if(unlock_func):
achievement_progress[achievement] = unlock_func.call_func()

func _all_dialogues_unlock() -> bool:
return true

func _all_dead_unlock() -> bool:
for x in game.mgmt.char_data.values():
if(!x.get("stats", {}).get("dead", false)):
return false
return true

func _high_speed_unlock() -> bool:
return game.mgmt.player.move.velocity.length_squared() > 1000.0