Files
Bubberstation/code/datums/mutations/olfaction.dm
MrMelbert f8f3dbed98 Completely removes proc_holders from existence. Refactors all wizard, xeno, spider, and genetics powers to be actions. Also refactors and sorts ton of accompanying code. (#67083)
* destroy proc holder pt1
- change proc_holder/spell to action/cooldown/spell
- docs all the spell vars, renames some of them
- removes some useless vars
- start with pointed spells, as they're easy

* kill proc_holder pt2
- kill a buncha vars and replace it with flags
- convert a ton over
- general code improvements

* kill proc_holders pt3
- convert a good few more spells
- rename some signals
- handle statpanel
- better docs

* kiill proc_holder pt4:
- restructure the file system of action.dm, separating a good amount of item actions and miscellaneous garbage into files where they belong slightly better. Also splits off item actions, cooldown actions, innate actions, etc. into their own files, overlal making it much better to work with
- converts touch attacks to actions
- converts blood crawl, jaunt subtype

* kills proc_holder pt5
- clears up some icon issues so all the currently converted pages don't have errors
- shapeshift
- some more action cleanup

* kills proc_holder pt5.5:
- some documentation
- reworks feedback to prevent oversight with teleports and stuff

* kills proc_holder pt6:
- converted cult spells
- converted magic missile
- converted mime spells
- chipped away at the errors
- removed some vars which were too general, replaced them with more locally applicable vars. for example "range" which could mean "projectile range" or "aoe radius" or whatever - instead of having a broad net which everyone applies to in a confusing matter, instead lets each spell delegate on their own.
- merged magic/spell and magic/aoe, as the comment intended
- more unified behavior for spell levelling

* kill proc_holders pt 6.5:
- replacing a buncha old proc_holders that have been updated to reduce some errors. sub 900 baby

* kills proc_holder pt 6.75:
- minor fixes

* kills proc_holder pt7:
- cuts down on some errors
- refactors some wiz events

* kills proc_holder pt 7.5:
- malf ranged modules
- some minor errors

* kills proc_holder pt 7.75:
- mor eminor error handling, cleaning up changes

* kill proc_holder pt8:
- refactors spell book
- refactors spell implant
- some more minor error fixing

* kill proc_holder pt 8.5:
- scan ability

* Adds some robust documentation

* kill proc_holder pt9:
- converts some / most mutations over

* kill proc_holder pt10:
- sort out all the granters
- refactor them slightly
- fix some compile errors

* Some set-unset sanity - going to need to test removing Share()

* Removes transfer actions. It doesn't seem to do anything.
- Transfer_actions was called when current = new_character so locially speaking the early return in Grant() should cause it to NOOP. Test this in the future though

* Removes sharing from actions, docs actions better

* Some better documentation for spell and spell components

* Kills proc_holder pt11:
- Finally finishes ALL THE SPELLS IN THE SPELL FOLDER
- Fixes some more errors

* kills proc_holder pt11.5:
- minor error fixing and sanity

* Method of sharing actions. Can be improved  in the future, needs testing

* Implements a way to update the stat panel entry for a spell. Also gets rid of VV stuff, as you can update the bigflags directly in VV now.

* Curse of madness bug I put in.

* kills proc_holder pt12:
- sub 500 errors!
- converts cytology mobs
- converts and refactors spiders slightly
- some minor fixing around the place as usual

* kill proc_holder pt13
- Finishes heretic spells
- Sub 300 errors!
- some touch refactoring to account for mansus grasp

* kills proc_holder pt14:
- revenant
- minor bugfixing for heretic stuff

* kills proc_holder pt14.5:
- some missed stuff for revenant + heretic

* kills proc_holder pt15:
- alien abilities
- more minor fixing
- sub 100 errors. The end is nigh

* kill proc_holder pt16? 17:
- Finishes cult spells
- sub 50 errors!
- refactors the way charge works
- renames / moves some signals

* kills proc_holder pt final:
- sdql spells
- no more errors!

* Bugfixes round 1

* Various bugfixing
- documentation done
- give spell works
- can cast spell gives feedback conditionally
- is available takes into account casting ability

* Some accidental reversions + fixes

* Unit tests

* Completely refactors jaunting
- All bloodcrawling is now handled on the action itself instead of across various living procs
- slaughter demons have their own blood crawls
- jaunting dummies don't have side effects on destroy() anymore

* Wizard spell logging and even more refactoring
2022-07-01 02:01:02 -04:00

140 lines
5.2 KiB
Plaintext

/datum/mutation/human/olfaction
name = "Transcendent Olfaction"
desc = "Your sense of smell is comparable to that of a canine."
quality = POSITIVE
difficulty = 12
text_gain_indication = "<span class='notice'>Smells begin to make more sense...</span>"
text_lose_indication = "<span class='notice'>Your sense of smell goes back to normal.</span>"
power_path = /datum/action/cooldown/spell/olfaction
instability = 30
synchronizer_coeff = 1
/datum/mutation/human/olfaction/modify()
. = ..()
var/datum/action/cooldown/spell/olfaction/to_modify = .
if(!istype(to_modify)) // null or invalid
return
to_modify.sensitivity = GET_MUTATION_SYNCHRONIZER(src)
/datum/action/cooldown/spell/olfaction
name = "Remember the Scent"
desc = "Get a scent off of the item you're currently holding to track it. \
With an empty hand, you'll track the scent you've remembered."
button_icon_state = "nose"
cooldown_time = 10 SECONDS
spell_requirements = NONE
/// Weakref to the mob we're tracking
var/datum/weakref/tracking_ref
/// Our nose's sensitivity
var/sensitivity = 1
/datum/action/cooldown/spell/olfaction/is_valid_target(atom/cast_on)
if(!isliving(cast_on))
return FALSE
var/mob/living/living_cast_on = cast_on
if(ishuman(living_cast_on) && !living_cast_on.get_bodypart(BODY_ZONE_HEAD))
to_chat(owner, span_warning("You have no nose!"))
return FALSE
return TRUE
/datum/action/cooldown/spell/olfaction/cast(mob/living/cast_on)
. = ..()
// Can we sniff? is there miasma in the air?
var/datum/gas_mixture/air = cast_on.loc.return_air()
var/list/cached_gases = air.gases
if(cached_gases[/datum/gas/miasma])
cast_on.adjust_disgust(sensitivity * 45)
to_chat(cast_on, span_warning("With your overly sensitive nose, \
you get a whiff of stench and feel sick! Try moving to a cleaner area!"))
return
var/atom/sniffed = cast_on.get_active_held_item()
if(sniffed)
pick_up_target(cast_on, sniffed)
else
follow_target(cast_on)
/// Attempt to pick up a new target based on the fingerprints on [sniffed].
/datum/action/cooldown/spell/olfaction/proc/pick_up_target(mob/living/caster, atom/sniffed)
var/mob/living/carbon/old_target = tracking_ref?.resolve()
var/list/possibles = list()
var/list/prints = GET_ATOM_FINGERPRINTS(sniffed)
if(prints)
for(var/mob/living/carbon/to_check as anything in GLOB.carbon_list)
if(prints[md5(to_check.dna?.unique_identity)])
possibles |= to_check
// There are no finger prints on the atom, so nothing to track
if(!length(possibles))
to_chat(caster, span_warning("Despite your best efforts, there are no scents to be found on [sniffed]..."))
return
var/mob/living/carbon/new_target = tgui_input_list(caster, "Scent to remember", "Scent Tracking", sort_names(possibles))
if(QDELETED(src) || QDELETED(caster))
return
if(QDELETED(new_target))
// We don't have a new target OR an old target
if(QDELETED(old_target))
to_chat(caster, span_warning("You decide against remembering any scents. \
Instead, you notice your own nose in your peripheral vision. \
This goes on to remind you of that one time you started breathing manually and couldn't stop. \
What an awful day that was."))
tracking_ref = null
// We don't have a new target, but we have an old target to fall back on
else
to_chat(caster, span_notice("You return to tracking [old_target]. The hunt continues."))
on_the_trail(caster)
return
// We have a new target to track
to_chat(caster, span_notice("You pick up the scent of [new_target]. The hunt begins."))
tracking_ref = WEAKREF(new_target)
on_the_trail(caster)
/// Attempt to follow our current tracking target.
/datum/action/cooldown/spell/olfaction/proc/follow_target(mob/living/caster)
var/mob/living/carbon/current_target = tracking_ref?.resolve()
// Either our weakref failed to resolve (our target's gone),
// or we never had a target in the first place
if(QDELETED(current_target))
to_chat(caster, span_warning("You're not holding anything to smell, \
and you haven't smelled anything you can track. You smell your skin instead; it's kinda salty."))
tracking_ref = null
return
on_the_trail(caster)
/// Actually go through and give the user a hint of the direction our target is.
/datum/action/cooldown/spell/olfaction/proc/on_the_trail(mob/living/caster)
var/mob/living/carbon/current_target = tracking_ref?.resolve()
if(!current_target)
to_chat(caster, span_warning("You're not tracking a scent, but the game thought you were. \
Something's gone wrong! Report this as a bug."))
stack_trace("[type] - on_the_trail was called when no tracking target was set.")
tracking_ref = null
return
if(current_target == caster)
to_chat(caster, span_warning("You smell out the trail to yourself. Yep, it's you."))
return
if(caster.z < current_target.z)
to_chat(caster, span_warning("The trail leads... way up above you? Huh. They must be really, really far away."))
return
else if(caster.z > current_target.z)
to_chat(caster, span_warning("The trail leads... way down below you? Huh. They must be really, really far away."))
return
var/direction_text = span_bold("[dir2text(get_dir(caster, current_target))]")
if(direction_text)
to_chat(caster, span_notice("You consider [current_target]'s scent. The trail leads [direction_text]."))