Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] [MIRROR] Better UI for heretic research [MDB IGNORE] #808

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
138 changes: 104 additions & 34 deletions code/modules/antagonists/heretic/heretic_antag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@
/// Controls what types of turf we can spread rust to, increases as we unlock more powerful rust abilites
var/rust_strength = 0
/// Static list of what each path converts to in the UI (colors are TGUI colors)
var/static/list/path_to_ui_color = list(
PATH_START = "grey",
PATH_SIDE = "green",
PATH_RUST = "brown",
PATH_FLESH = "red",
PATH_ASH = "white",
PATH_VOID = "blue",
PATH_BLADE = "label", // my favorite color is label
PATH_COSMIC = "purple",
PATH_LOCK = "yellow",
PATH_MOON = "blue",
var/static/list/path_to_ui_bgr = list(
PATH_START = "node_side",
PATH_SIDE = "node_side",
PATH_RUST = "node_rust",
PATH_FLESH = "node_flesh",
PATH_ASH = "node_ash",
PATH_VOID = "node_void",
PATH_BLADE = "node_blade",
PATH_COSMIC = "node_cosmos",
PATH_LOCK = "node_lock",
PATH_MOON = "node_moon",
)

var/static/list/path_to_rune_color = list(
Expand All @@ -86,33 +86,115 @@
LAZYNULL(sac_targets)
return ..()

/datum/antagonist/heretic/proc/get_icon_of_knowledge(datum/heretic_knowledge/knowledge)
//basic icon parameters
var/icon_path = 'icons/mob/actions/actions_ecult.dmi'
var/icon_state = "eye"
var/icon_frame = knowledge.research_tree_icon_frame
var/icon_dir = knowledge.research_tree_icon_dir
//can't imagine why you would want this one, so it can't be overridden by the knowledge
var/icon_moving = 0

//item transmutation knowledge does not generate its own icon due to implementation difficulties, the icons have to be specified in the override vars

//if the knowledge has a special icon, use that
if(!isnull(knowledge.research_tree_icon_path))
icon_path = knowledge.research_tree_icon_path
icon_state = knowledge.research_tree_icon_state

//if the knowledge is a spell, use the spell's button
else if(ispath(knowledge,/datum/heretic_knowledge/spell))
var/datum/heretic_knowledge/spell/spell_knowledge = knowledge
var/datum/action/cooldown/spell/result_spell = spell_knowledge.spell_to_add
icon_path = result_spell.button_icon
icon_state = result_spell.button_icon_state

//if the knowledge is a summon, use the mob sprite
else if(ispath(knowledge,/datum/heretic_knowledge/summon))
var/datum/heretic_knowledge/summon/summon_knowledge = knowledge
var/mob/living/result_mob = summon_knowledge.mob_to_summon
icon_path = result_mob.icon
icon_state = result_mob.icon_state

//if the knowledge is an eldritch mark, use the mark sprite
else if(ispath(knowledge,/datum/heretic_knowledge/mark))
var/datum/heretic_knowledge/mark/mark_knowledge = knowledge
var/datum/status_effect/eldritch/mark_effect = mark_knowledge.mark_type
icon_path = mark_effect.effect_icon
icon_state = mark_effect.effect_icon_state

//if the knowledge is an ascension, use the achievement sprite
else if(ispath(knowledge,/datum/heretic_knowledge/ultimate))
var/datum/heretic_knowledge/ultimate/ascension_knowledge = knowledge
var/datum/award/achievement/misc/achievement = ascension_knowledge.ascension_achievement
if(!isnull(achievement))
icon_path = achievement.icon
icon_state = achievement.icon_state

var/list/result_parameters = list()
result_parameters["icon"] = icon_path
result_parameters["state"] = icon_state
result_parameters["frame"] = icon_frame
result_parameters["dir"] = icon_dir
result_parameters["moving"] = icon_moving
return result_parameters

/datum/antagonist/heretic/proc/get_knowledge_data(datum/heretic_knowledge/knowledge, done)

var/list/knowledge_data = list()

knowledge_data["path"] = knowledge
knowledge_data["icon_params"] = get_icon_of_knowledge(knowledge)
knowledge_data["name"] = initial(knowledge.name)
knowledge_data["gainFlavor"] = initial(knowledge.gain_text)
knowledge_data["cost"] = initial(knowledge.cost)
knowledge_data["disabled"] = (!done) && (initial(knowledge.cost) > knowledge_points)
knowledge_data["bgr"] = (path_to_ui_bgr[initial(knowledge.route)] || "side")
knowledge_data["finished"] = done
knowledge_data["ascension"] = ispath(knowledge,/datum/heretic_knowledge/ultimate)

//description of a knowledge might change, make sure we are not shown the initial() value in that case
if(done)
var/datum/heretic_knowledge/knowledge_instance = researched_knowledge[knowledge]
knowledge_data["desc"] = knowledge_instance.desc
else
knowledge_data["desc"] = initial(knowledge.desc)

return knowledge_data

/datum/antagonist/heretic/ui_data(mob/user)
var/list/data = list()

data["charges"] = knowledge_points
data["total_sacrifices"] = total_sacrifices
data["ascended"] = ascended

var/list/tiers = list()

// This should be cached in some way, but the fact that final knowledge
// has to update its disabled state based on whether all objectives are complete,
// makes this very difficult. I'll figure it out one day maybe
for(var/datum/heretic_knowledge/knowledge as anything in researched_knowledge)
var/list/knowledge_data = get_knowledge_data(knowledge,TRUE)

while(initial(knowledge.depth) > tiers.len)
tiers += list(list("nodes"=list()))

tiers[initial(knowledge.depth)]["nodes"] += list(knowledge_data)

for(var/datum/heretic_knowledge/knowledge as anything in get_researchable_knowledge())
var/list/knowledge_data = list()
knowledge_data["path"] = knowledge
knowledge_data["name"] = initial(knowledge.name)
knowledge_data["desc"] = initial(knowledge.desc)
knowledge_data["gainFlavor"] = initial(knowledge.gain_text)
knowledge_data["cost"] = initial(knowledge.cost)
knowledge_data["disabled"] = initial(knowledge.cost) > knowledge_points
var/list/knowledge_data = get_knowledge_data(knowledge,FALSE)

// Final knowledge can't be learned until all objectives are complete.
if(ispath(knowledge, /datum/heretic_knowledge/ultimate))
knowledge_data["disabled"] = !can_ascend()
knowledge_data["disabled"] ||= !can_ascend()

knowledge_data["hereticPath"] = initial(knowledge.route)
knowledge_data["color"] = path_to_ui_color[initial(knowledge.route)] || "grey"
while(initial(knowledge.depth) > tiers.len)
tiers += list(list("nodes"=list()))

data["learnableKnowledge"] += list(knowledge_data)
tiers[initial(knowledge.depth)]["nodes"] += list(knowledge_data)

data["knowledge_tiers"] = tiers

return data

Expand All @@ -122,18 +204,6 @@
data["objectives"] = get_objectives()
data["can_change_objective"] = can_assign_self_objectives

for(var/path in researched_knowledge)
var/list/knowledge_data = list()
var/datum/heretic_knowledge/found_knowledge = researched_knowledge[path]
knowledge_data["name"] = found_knowledge.name
knowledge_data["desc"] = found_knowledge.desc
knowledge_data["gainFlavor"] = found_knowledge.gain_text
knowledge_data["cost"] = found_knowledge.cost
knowledge_data["hereticPath"] = found_knowledge.route
knowledge_data["color"] = path_to_ui_color[found_knowledge.route] || "grey"

data["learnedKnowledge"] += list(knowledge_data)

return data

/datum/antagonist/heretic/ui_act(action, params)
Expand Down
24 changes: 24 additions & 0 deletions code/modules/antagonists/heretic/heretic_knowledge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
var/priority = 0
/// What path is this on. If set to "null", assumed to be unreachable (or abstract).
var/route
<<<<<<< HEAD

Check failure on line 41 in code/modules/antagonists/heretic/heretic_knowledge.dm

View workflow job for this annotation

GitHub Actions / Run Linters

got '<<', expected one of: newline, '/', identifier
=======
/// In case we want to override the default UI icon getter and plug in our own icon instead.
/// if research_tree_icon_path is not null, research_tree_icon_state must also be specified or things may break
var/research_tree_icon_path
var/research_tree_icon_state
var/research_tree_icon_frame = 1
var/research_tree_icon_dir = SOUTH
/// Level of knowledge tree where this knowledge should be in the UI
var/depth = 1
///Determines what kind of monster ghosts will ignore from here on out. Defaults to POLL_IGNORE_HERETIC_MONSTER, but we define other types of monsters for more granularity.
var/poll_ignore_define = POLL_IGNORE_HERETIC_MONSTER
>>>>>>> cb28aef24a5... [MIRROR] Better UI for heretic research [MDB IGNORE] (#3413)

/datum/heretic_knowledge/New()
if(!mutually_exclusive)
Expand Down Expand Up @@ -261,6 +274,7 @@
limit = 2
cost = 1
priority = MAX_KNOWLEDGE_PRIORITY - 5
depth = 2

/datum/heretic_knowledge/limited_amount/starting/New()
. = ..()
Expand All @@ -285,6 +299,7 @@
abstract_parent_type = /datum/heretic_knowledge/mark
mutually_exclusive = TRUE
cost = 2
depth = 5
/// The status effect typepath we apply on people on mansus grasp.
var/datum/status_effect/eldritch/mark_type

Expand Down Expand Up @@ -350,6 +365,7 @@
abstract_parent_type = /datum/heretic_knowledge/blade_upgrade
mutually_exclusive = TRUE
cost = 2
depth = 9

/datum/heretic_knowledge/blade_upgrade/on_gain(mob/user, datum/antagonist/heretic/our_heretic)
RegisterSignal(user, COMSIG_HERETIC_BLADE_ATTACK, PROC_REF(on_eldritch_blade))
Expand Down Expand Up @@ -577,6 +593,9 @@
mutually_exclusive = TRUE
cost = 1
priority = MAX_KNOWLEDGE_PRIORITY - 10 // A pretty important midgame ritual.
depth = 6
research_tree_icon_path = 'icons/obj/antags/eldritch.dmi'
research_tree_icon_state = "book_open"
/// Whether we've done the ritual. Only doable once.
var/was_completed = FALSE

Expand Down Expand Up @@ -670,6 +689,9 @@
cost = 2
priority = MAX_KNOWLEDGE_PRIORITY + 1 // Yes, the final ritual should be ABOVE the max priority.
required_atoms = list(/mob/living/carbon/human = 3)
depth = 11
//use this to store the achievement typepath
var/datum/award/achievement/misc/ascension_achievement

/datum/heretic_knowledge/ultimate/on_research(mob/user, datum/antagonist/heretic/our_heretic)
. = ..()
Expand Down Expand Up @@ -730,6 +752,8 @@
source = user,
header = "A Heretic is Ascending!",
)
if(!isnull(ascension_achievement))
user.client?.give_award(ascension_achievement, user)
heretic_datum.increase_rust_strength()
return TRUE

Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/items/eldritch_flask.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
name = "flask of eldritch essence"
desc = "Toxic to the closed minded, yet refreshing to those with knowledge of the beyond."
icon = 'icons/obj/antags/eldritch.dmi'
icon_state = "eldrich_flask"
icon_state = "eldritch_flask"
list_reagents = list(/datum/reagent/eldritch = 50)
17 changes: 16 additions & 1 deletion code/modules/antagonists/heretic/knowledge/ash_lore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
)
result_atoms = list(/obj/item/melee/sickly_blade/ash)
route = PATH_ASH
research_tree_icon_path = 'icons/obj/weapons/khopesh.dmi'
research_tree_icon_state = "ash_blade"

/datum/heretic_knowledge/ashen_grasp
name = "Grasp of Ash"
Expand All @@ -48,6 +50,9 @@
next_knowledge = list(/datum/heretic_knowledge/spell/ash_passage)
cost = 1
route = PATH_ASH
depth = 3
research_tree_icon_path = 'icons/ui_icons/antags/heretic/knowledge.dmi'
research_tree_icon_state = "grasp_ash"

/datum/heretic_knowledge/ashen_grasp/on_gain(mob/user, datum/antagonist/heretic/our_heretic)
RegisterSignal(user, COMSIG_HERETIC_MANSUS_GRASP_ATTACK, PROC_REF(on_mansus_grasp))
Expand Down Expand Up @@ -80,6 +85,7 @@
spell_to_add = /datum/action/cooldown/spell/jaunt/ethereal_jaunt/ash
cost = 1
route = PATH_ASH
depth = 4

/datum/heretic_knowledge/mark/ash_mark
name = "Mark of Ash"
Expand Down Expand Up @@ -119,6 +125,8 @@
spell_to_add = /datum/action/cooldown/spell/charged/beam/fire_blast
cost = 1
route = PATH_ASH
depth = 7
research_tree_icon_frame = 7


/datum/heretic_knowledge/mad_mask
Expand All @@ -142,6 +150,9 @@
result_atoms = list(/obj/item/clothing/mask/madness_mask)
cost = 1
route = PATH_ASH
research_tree_icon_path = 'icons/obj/clothing/masks.dmi'
research_tree_icon_state = "mad_mask"
depth = 8

/datum/heretic_knowledge/blade_upgrade/ash
name = "Fiery Blade"
Expand All @@ -150,6 +161,8 @@
His city, the people he swore to watch... and watch he did, as they all burnt to cinders."
next_knowledge = list(/datum/heretic_knowledge/spell/flame_birth)
route = PATH_ASH
research_tree_icon_path = 'icons/ui_icons/antags/heretic/knowledge.dmi'
research_tree_icon_state = "blade_upgrade_ash"

/datum/heretic_knowledge/blade_upgrade/ash/do_melee_effects(mob/living/source, mob/living/target, obj/item/melee/sickly_blade/blade)
if(source == target)
Expand All @@ -173,6 +186,8 @@
spell_to_add = /datum/action/cooldown/spell/aoe/fiery_rebirth
cost = 1
route = PATH_ASH
depth = 10
research_tree_icon_frame = 5

/datum/heretic_knowledge/ultimate/ash_final
name = "Ashlord's Rite"
Expand All @@ -187,6 +202,7 @@
for the Nightwatcher brought forth the rite to mankind! His gaze continues, as now I am one with the flames, \
WITNESS MY ASCENSION, THE ASHY LANTERN BLAZES ONCE MORE!"
route = PATH_ASH
ascension_achievement = /datum/award/achievement/misc/ash_ascension
/// A static list of all traits we apply on ascension.
var/static/list/traits_to_apply = list(
TRAIT_BOMBIMMUNE,
Expand Down Expand Up @@ -233,6 +249,5 @@
var/datum/action/cooldown/spell/aoe/fiery_rebirth/fiery_rebirth = locate() in user.actions
fiery_rebirth?.cooldown_time *= 0.16

user.client?.give_award(/datum/award/achievement/misc/ash_ascension, user)
if(length(traits_to_apply))
user.add_traits(traits_to_apply, MAGIC_TRAIT)
Loading
Loading