mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-09 22:25:46 +01:00
eee8878024
* datumized spells * finished * last changes * conflict * Update code/datums/spells/alien_spells/transfer_plasma.dm * conflicts * shitty runtime fix until i get to this tomorrow * Update code/datums/spell.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spell_handler/alien_spell_handler.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/alien_spells/regurgitate.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/alien_spells/regurgitate.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/bloodcrawl.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/bloodcrawl.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/antagonists/vampire/vampire_powers/hemomancer_powers.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/antagonists/vampire/vampire_powers/vampire_powers.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/awaymissions/mission_code/ruins/wizardcrash.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/research/xenobiology/xenobiology.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/modules/mob/living/carbon/superheroes.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/conjure.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/ethereal_jaunt.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/emplosion.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/turf_teleport.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/wizard_spells.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/wizard_spells.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/game/dna/mutations/mutation_powers.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/wizard_spells.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/datums/spells/wizard_spells.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/game/dna/mutations/mutation_powers.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * Update code/game/gamemodes/miniantags/revenant/revenant_abilities.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> * guess who just rework the entire malf ai actionsf ai * gc better --------- Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
120 lines
4.1 KiB
Plaintext
120 lines
4.1 KiB
Plaintext
/**
|
|
* Books that teach things.
|
|
*
|
|
* (Intrinsic actions like bar flinging, spells like fireball or smoke, or martial arts)
|
|
*/
|
|
/obj/item/book/granter
|
|
/// 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 time it takes to read the book
|
|
var/reading_time = 5 SECONDS
|
|
/// 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 class='warning'>You're already reading this!</span>")
|
|
return FALSE
|
|
if(!user.has_vision())
|
|
to_chat(user, "<span class='warning'>You are blind and can't read anything!</span>")
|
|
return FALSE
|
|
if(!isliving(user))
|
|
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(user)
|
|
reading = FALSE
|
|
return
|
|
if(do_after(user, reading_time, 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 class='notice'>You start reading [name]...</span>")
|
|
|
|
/// Called when the reading is interrupted without finishing.
|
|
/obj/item/book/granter/proc/on_reading_stopped(mob/living/user)
|
|
to_chat(user, "<span class='notice'>You stop reading...</span>")
|
|
|
|
/// 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 class='notice'>You finish reading [name]!</span>")
|
|
|
|
/// 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, reading_time, src))
|
|
return FALSE
|
|
|
|
to_chat(user, "<span class='notice'>[length(remarks) ? pick(remarks) : "You keep reading..."]</span>")
|
|
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)
|
|
return
|
|
|
|
/// 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 class='warning'>You already know all about [action_name]!</span>")
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/obj/item/book/granter/action/on_reading_start(mob/living/user)
|
|
to_chat(user, "<span class='notice'>You start reading about [action_name]...</span>")
|
|
|
|
/obj/item/book/granter/action/on_reading_finished(mob/living/user)
|
|
to_chat(user, "<span class='notice'>You feel like you've got a good handle on [action_name]!</span>")
|
|
// 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)
|
|
|
|
// Generic action giver
|
|
/obj/item/book/granter/spell
|
|
/// The typepath of spell that is given
|
|
var/datum/spell/granted_spell
|
|
/// The name of the spell, formatted in a more text-friendly way
|
|
var/spell_name = ""
|
|
|
|
/obj/item/book/granter/spell/on_reading_finished(mob/living/user)
|
|
if(!user.mind)
|
|
return
|
|
to_chat(user, "<span class='notice'>You feel like you've got a good handle on [spell_name]!</span>")
|
|
user.mind.AddSpell(new granted_spell(null))
|