From f2f893d42af9f8a31d225bc2598e7187f8c5dae8 Mon Sep 17 00:00:00 2001 From: Neerti Date: Sun, 15 Feb 2015 23:52:39 -0500 Subject: [PATCH] Replaces the three atom procs with just one and a datum-based system. --- baystation12.dme | 1 + code/datums/descriptions.dm | 22 ++++++++ code/game/atoms.dm | 55 ++++++++++++------- code/modules/mob/living/carbon/human/human.dm | 2 +- code/modules/mob/living/living.dm | 8 +-- .../mob/living/silicon/robot/drone/drone.dm | 8 ++- code/modules/mob/mob.dm | 15 +++-- code/modules/mob/mob_defines.dm | 15 +++-- 8 files changed, 88 insertions(+), 38 deletions(-) create mode 100644 code/datums/descriptions.dm diff --git a/baystation12.dme b/baystation12.dme index 7031dd98066..903d556f3c0 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -100,6 +100,7 @@ #include "code\datums\computerfiles.dm" #include "code\datums\datacore.dm" #include "code\datums\datumvars.dm" +#include "code\datums\descriptions.dm" #include "code\datums\disease.dm" #include "code\datums\mind.dm" #include "code\datums\mixed.dm" diff --git a/code/datums/descriptions.dm b/code/datums/descriptions.dm new file mode 100644 index 00000000000..b6812d0576e --- /dev/null +++ b/code/datums/descriptions.dm @@ -0,0 +1,22 @@ +/* +This is what is supplied to the examine tab. Everything has a 'descriptions' variable, which is null by default. When it is not null, +it contains this datum. To add this datum to something, all you do is add this to the thing.. + + descriptions = new/datum/descriptions("I am some helpful blue text","I have backstory text about this obj.","You can use this to kill everyone.") + +First string is the 'info' var, second is the 'fluff' var, and third is the 'antag' var. All are optional. Just add it to the object you want to have it. + +If you are wondering, BYOND does not let you do desc = new/datum/descriptions . + +More strings can be added easily, but you will need to add a proc to retrieve it from the atom. The procs are defined in atoms.dm. + +*/ +/datum/descriptions + var/info + var/fluff + var/antag + +/datum/descriptions/New(var/info, var/fluff, var/antag) + src.info = info + src.fluff = fluff + src.antag = antag \ No newline at end of file diff --git a/code/game/atoms.dm b/code/game/atoms.dm index ce949cf6043..c3a13284b3b 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -12,10 +12,8 @@ var/throwpass = 0 var/germ_level = GERM_LEVEL_AMBIENT // The higher the germ level, the more germ on the atom. - //Examine tab vars - var/desc_info = null //Blue 'tutorial' text, which details how this atom works, and perhaps some tips and tricks. - var/desc_fluff = null //Green text, with quotes, to tell a short blurb or a paragraph about this atom's place in the fluff, should one exist. - + //Examine tab + var/datum/descriptions/descriptions = null //See code/datums/descriptions.dm for details. ///Chemistry. var/datum/reagents/reagents = null @@ -207,35 +205,52 @@ its easier to just keep the beam vertical. user << "\icon[src] That's [f_name] [suffix]" - if(name) //This shouldn't be needed but I'm paranoid. - user.desc_name_holder = "[src.name]" //\icon[src] + var/datum/descriptions/D = descriptions + if(istype(D)) + user.description_holders["info"] = get_descriptions_info() + user.description_holders["fluff"] = get_descriptions_fluff() + if(user.mind.special_role) + user.description_holders["antag"] = get_descriptions_antag() + else + user.description_holders["info"] = null + user.description_holders["fluff"] = null + user.description_holders["antag"] = null - user.desc_icon_holder = "\icon[src]" + if(name) //This shouldn't be needed but I'm paranoid. + user.description_holders["name"] = "[src.name]" //\icon[src] + + user.description_holders["icon"] = "\icon[src]" if(desc) user << desc - user.desc_holder = src.desc + user.description_holders["desc"] = src.desc else - user.desc_holder = null //This is needed, or else if you examine one thing with a desc, then another without, the panel will retain the first examined's desc. - - user.desc_info_holder = get_desc_info() - user.desc_fluff_holder = get_desc_fluff() + user.description_holders["desc"] = null //This is needed, or else if you examine one thing with a desc, then another without, the panel will retain the first examined's desc. return distance == -1 || (get_dist(src, user) <= distance) //Override these if you need special behaviour for a specific type. -/atom/proc/get_desc_info() - if(desc_info) - return desc_info +/atom/proc/get_descriptions_info() + var/datum/descriptions/D = descriptions + if(istype(D) && D.info) + return D.info else - return + return null -/atom/proc/get_desc_fluff() - if(desc_fluff) - return src.desc_fluff +/atom/proc/get_descriptions_fluff() + var/datum/descriptions/D = descriptions + if(istype(D) && D.fluff) + return D.fluff else - return + return null + +/atom/proc/get_descriptions_antag() + var/datum/descriptions/D = descriptions + if(istype(D) && D.antag) + return D.antag + else + return null // called by mobs when e.g. having the atom as their machine, pulledby, loc (AKA mob being inside the atom) or buckled var set. // see code/modules/mob/mob_movement.dm for more. diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index df6c3a16de8..5dee08e8af1 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1277,7 +1277,7 @@ else return ..() -/mob/living/carbon/human/get_desc_fluff() +/mob/living/carbon/human/get_descriptions_fluff() return print_flavor_text(0) /mob/living/carbon/human/getDNA() diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 08970a2ad97..e4caeb46630 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -172,13 +172,11 @@ // ++++ROCKDTBEN++++ MOB PROCS //END -/mob/living/get_desc_fluff() +/mob/living/get_descriptions_fluff() if(flavor_text) //Get flavor text for the green text. return flavor_text - else if(desc_fluff) //No flavor text? Try for hardcoded fluff instead. - return desc_fluff - else - return + else //No flavor text? Try for hardcoded fluff instead. + return ..() /mob/proc/get_contents() diff --git a/code/modules/mob/living/silicon/robot/drone/drone.dm b/code/modules/mob/living/silicon/robot/drone/drone.dm index 8bbf8c26f44..40db977b8ba 100644 --- a/code/modules/mob/living/silicon/robot/drone/drone.dm +++ b/code/modules/mob/living/silicon/robot/drone/drone.dm @@ -3,7 +3,13 @@ real_name = "drone" icon = 'icons/mob/robots.dmi' icon_state = "repairbot" - desc_info = "Drones are player-controlled synthetics which are lawed to maintain the station and not \ + descriptions = new/datum/descriptions("Drones are player-controlled synthetics which are lawed to maintain the station and not \ + interact with anyone else, except for other drones. They hold a wide array of tools to build, repair, maintain, and clean. \ + They fuction similarly to other synthetics, in that they require recharging regularly, have laws, and are resilient to many hazards, \ + such as fire, radiation, vacuum, and more. Ghosts can join the round as a maintenance drone by using the appropriate verb in the 'ghost' tab. \ + An inactive drone can be rebooted by swiping an ID card on it with engineering or robotics access.",\ + ,"An Electromagnetic Sequencer can be used to subvert the drone to your cause.") +// desc_info = "Drones are player-controlled synthetics which are lawed to maintain the station and not \ interact with anyone else, except for other drones. They hold a wide array of tools to build, repair, maintain, and clean. \ They fuction similarly to other synthetics, in that they require recharging regularly, have laws, and are resilient to many hazards, \ such as fire, radiation, vacuum, and more. Ghosts can join the round as a maintenance drone by using the appropriate verb in the 'ghost' tab." diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 33fe1e288ef..aac22528f43 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -835,12 +835,15 @@ note dizziness decrements automatically in the mob's Life() proc. statpanel("Spells","[S.holder_var_type] [S.holder_var_amount]",S) if(client) statpanel("Examine") - stat(null,"[desc_icon_holder] [desc_name_holder]") //The name, written in big letters. - stat(null,"[desc_holder]") //the default examine text. - if(desc_info_holder) - stat(null,"[desc_info_holder]") //Blue, informative text. - if(desc_fluff_holder) - stat(null,"[desc_fluff_holder]") //Yellow, fluff-related text. + stat(null,"[description_holders["icon"]] [description_holders["name"]]") //The name, written in big letters. + stat(null,"[description_holders["desc"]]") //the default examine text. + if(description_holders["info"]) + stat(null,"[description_holders["info"]]") //Blue, informative text. + if(description_holders["fluff"]) + stat(null,"[description_holders["fluff"]]") //Yellow, fluff-related text. + if(mind.special_role) + if(description_holders["antag"]) + stat(null,"[description_holders["antag"]]") //Red, malicious antag-related text diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 8fdc91dac0d..0b213d0b99c 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -226,8 +226,13 @@ //Examine tab vars //These hold the descriptions and other info, to relay to the actual tab. - var/desc_name_holder = null - var/desc_holder = null - var/desc_info_holder = null - var/desc_fluff_holder = null - var/desc_icon_holder = null + var/description_holders[0] + /* + description_holders["name"] = null + description_holders["icon"] = null + description_holders["desc"] = null + description_holders["info"] = null + description_holders["fluff"] = null + description_holders["antag"] = null + */ +