Files
Bubberstation/code/game/objects/items/granters/_granters.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

107 lines
3.5 KiB
Plaintext

/**
* Books that teach things.
*
* (Intrinsic actions like bar flinging, spells like fireball or smoke, or martial arts)
*/
/obj/item/book/granter
due_date = 0
unique = 1
/// Flavor messages displayed to mobs reading the granter
var/list/remarks = list()
/// Controls how long a mob must keep the book in his hand to actually successfully learn
var/pages_to_mastery = 3
/// Sanity, whether it's currently being read
var/reading = FALSE
/// The amount of uses on the granter.
var/uses = 1
/// The sounds played as the user's reading the book.
var/list/book_sounds = list(
'sound/effects/pageturn1.ogg',
'sound/effects/pageturn2.ogg',
'sound/effects/pageturn3.ogg',
)
/obj/item/book/granter/attack_self(mob/living/user)
if(reading)
to_chat(user, span_warning("You're already reading this!"))
return FALSE
if(user.is_blind())
to_chat(user, span_warning("You are blind and can't read anything!"))
return FALSE
if(!isliving(user) || !user.can_read(src))
return FALSE
if(!can_learn(user))
return FALSE
if(uses <= 0)
recoil(user)
return FALSE
on_reading_start(user)
reading = TRUE
for(var/i in 1 to pages_to_mastery)
if(!turn_page(user))
on_reading_stopped()
reading = FALSE
return
if(do_after(user, 5 SECONDS, src))
uses--
on_reading_finished(user)
reading = FALSE
return TRUE
/// Called when the user starts to read the granter.
/obj/item/book/granter/proc/on_reading_start(mob/living/user)
to_chat(user, span_notice("You start reading [name]..."))
/// Called when the reading is interrupted without finishing.
/obj/item/book/granter/proc/on_reading_stopped(mob/living/user)
to_chat(user, span_notice("You stop reading..."))
/// Called when the reading is completely finished. This is where the actual granting should happen.
/obj/item/book/granter/proc/on_reading_finished(mob/living/user)
to_chat(user, span_notice("You finish reading [name]!"))
/// The actual "turning over of the page" flavor bit that happens while someone is reading the granter.
/obj/item/book/granter/proc/turn_page(mob/living/user)
playsound(user, pick(book_sounds), 30, TRUE)
if(!do_after(user, 5 SECONDS, src))
return FALSE
to_chat(user, span_notice("[length(remarks) ? pick(remarks) : "You keep reading..."]"))
return TRUE
/// Effects that occur whenever the book is read when it has no uses left.
/obj/item/book/granter/proc/recoil(mob/living/user)
/// Checks if the user can learn whatever this granter... grants
/obj/item/book/granter/proc/can_learn(mob/living/user)
return TRUE
// Generic action giver
/obj/item/book/granter/action
/// The typepath of action that is given
var/datum/action/granted_action
/// The name of the action, formatted in a more text-friendly way.
var/action_name = ""
/obj/item/book/granter/action/can_learn(mob/living/user)
if(!granted_action)
CRASH("Someone attempted to learn [type], which did not have an action set.")
if(locate(granted_action) in user.actions)
to_chat(user, span_warning("You already know all about [action_name]!"))
return FALSE
return TRUE
/obj/item/book/granter/action/on_reading_start(mob/living/user)
to_chat(user, span_notice("You start reading about [action_name]..."))
/obj/item/book/granter/action/on_reading_finished(mob/living/user)
to_chat(user, span_notice("You feel like you've got a good handle on [action_name]!"))
// Action goes on the mind as the user actually learns the thing in your brain
var/datum/action/new_action = new granted_action(user.mind || user)
new_action.Grant(user)
new_action.UpdateButtons()