Merge pull request #6153 from Citadel-Station-13/upstream-merge-36442

[MIRROR] Refactors Spell and Martial Art Books to use Action Granters!
This commit is contained in:
deathride58
2018-04-03 08:16:11 +00:00
committed by GitHub
25 changed files with 458 additions and 363 deletions
@@ -535,7 +535,6 @@
throw_speed = 2
throw_range = 5
w_class = WEIGHT_CLASS_TINY
persistence_replacement = /obj/item/spellbook/oneuse/random
var/uses = 10
var/temp = null
var/tab = null
@@ -715,198 +714,3 @@
tab = sanitize(href_list["page"])
attack_self(H)
return
//Single Use Spellbooks//
/obj/item/spellbook/oneuse
var/spell = /obj/effect/proc_holder/spell/targeted/projectile/magic_missile //just a placeholder to avoid runtimes if someone spawned the generic
var/spellname = "sandbox"
var/used = 0
name = "spellbook of "
uses = 1
desc = "This template spellbook was never meant for the eyes of man..."
persistence_replacement = null
/obj/item/spellbook/oneuse/prepare_spells()
name += spellname
/obj/item/spellbook/oneuse/attack_self(mob/user)
var/obj/effect/proc_holder/spell/S = new spell
for(var/obj/effect/proc_holder/spell/knownspell in user.mind.spell_list)
if(knownspell.type == S.type)
if(user.mind)
if(iswizard(user))
to_chat(user,"<span class='notice'>You're already far more versed in this spell than this flimsy how-to book can provide.</span>")
else
to_chat(user,"<span class='notice'>You've already read this one.</span>")
return
if(used)
recoil(user)
else
user.mind.AddSpell(S)
to_chat(user,"<span class='notice'>You rapidly read through the arcane book. Suddenly you realize you understand [spellname]!</span>")
user.log_message("<font color='orange'>learned the spell [spellname] ([S]).</font>", INDIVIDUAL_ATTACK_LOG)
onlearned(user)
/obj/item/spellbook/oneuse/proc/recoil(mob/user)
user.visible_message("<span class='warning'>[src] glows in a black light!</span>")
/obj/item/spellbook/oneuse/proc/onlearned(mob/user)
used = 1
user.visible_message("<span class='caution'>[src] glows dark for a second!</span>")
/obj/item/spellbook/oneuse/attackby()
return
/obj/item/spellbook/oneuse/fireball
spell = /obj/effect/proc_holder/spell/aimed/fireball
spellname = "fireball"
icon_state ="bookfireball"
desc = "This book feels warm to the touch."
/obj/item/spellbook/oneuse/fireball/recoil(mob/user)
..()
explosion(user.loc, -1, 0, 2, 3, 0, flame_range = 2)
qdel(src)
/obj/item/spellbook/oneuse/smoke
spell = /obj/effect/proc_holder/spell/targeted/smoke
spellname = "smoke"
icon_state ="booksmoke"
desc = "This book is overflowing with the dank arts."
/obj/item/spellbook/oneuse/smoke/lesser //Chaplain smoke book
spell = /obj/effect/proc_holder/spell/targeted/smoke/lesser
/obj/item/spellbook/oneuse/smoke/recoil(mob/user)
..()
to_chat(user,"<span class='caution'>Your stomach rumbles...</span>")
if(user.nutrition)
user.nutrition -= 200
if(user.nutrition <= 0)
user.nutrition = 0
/obj/item/spellbook/oneuse/blind
spell = /obj/effect/proc_holder/spell/targeted/trigger/blind
spellname = "blind"
icon_state ="bookblind"
desc = "This book looks blurry, no matter how you look at it."
/obj/item/spellbook/oneuse/blind/recoil(mob/user)
..()
to_chat(user,"<span class='warning'>You go blind!</span>")
user.blind_eyes(10)
/obj/item/spellbook/oneuse/mindswap
spell = /obj/effect/proc_holder/spell/targeted/mind_transfer
spellname = "mindswap"
icon_state ="bookmindswap"
desc = "This book's cover is pristine, though its pages look ragged and torn."
var/mob/stored_swap = null //Used in used book recoils to store an identity for mindswaps
/obj/item/spellbook/oneuse/mindswap/onlearned()
spellname = pick("fireball","smoke","blind","forcewall","knock","barnyard","charge")
icon_state = "book[spellname]"
name = "spellbook of [spellname]" //Note, desc doesn't change by design
..()
/obj/item/spellbook/oneuse/mindswap/recoil(mob/user)
..()
if(stored_swap in GLOB.dead_mob_list)
stored_swap = null
if(!stored_swap)
stored_swap = user
to_chat(user,"<span class='warning'>For a moment you feel like you don't even know who you are anymore.</span>")
return
if(stored_swap == user)
to_chat(user,"<span class='notice'>You stare at the book some more, but there doesn't seem to be anything else to learn...</span>")
return
var/obj/effect/proc_holder/spell/targeted/mind_transfer/swapper = new
swapper.cast(user, stored_swap, 1)
to_chat(stored_swap,"<span class='warning'>You're suddenly somewhere else... and someone else?!</span>")
to_chat(user,"<span class='warning'>Suddenly you're staring at [src] again... where are you, who are you?!</span>")
stored_swap = null
/obj/item/spellbook/oneuse/forcewall
spell = /obj/effect/proc_holder/spell/targeted/forcewall
spellname = "forcewall"
icon_state ="bookforcewall"
desc = "This book has a dedication to mimes everywhere inside the front cover."
/obj/item/spellbook/oneuse/forcewall/recoil(mob/living/user)
..()
to_chat(user,"<span class='warning'>You suddenly feel very solid!</span>")
user.Stun(40, ignore_canstun = TRUE)
user.petrify(30)
/obj/item/spellbook/oneuse/knock
spell = /obj/effect/proc_holder/spell/aoe_turf/knock
spellname = "knock"
icon_state ="bookknock"
desc = "This book is hard to hold closed properly."
/obj/item/spellbook/oneuse/knock/recoil(mob/living/user)
..()
to_chat(user,"<span class='warning'>You're knocked down!</span>")
user.Knockdown(40)
/obj/item/spellbook/oneuse/barnyard
spell = /obj/effect/proc_holder/spell/targeted/barnyardcurse
spellname = "barnyard"
icon_state ="bookhorses"
desc = "This book is more horse than your mind has room for."
/obj/item/spellbook/oneuse/barnyard/recoil(mob/living/carbon/user)
if(ishuman(user))
to_chat(user,"<font size='15' color='red'><b>HOR-SIE HAS RISEN</b></font>")
var/obj/item/clothing/mask/horsehead/magichead = new /obj/item/clothing/mask/horsehead
magichead.flags_1 |= NODROP_1 //curses!
magichead.flags_inv &= ~HIDEFACE //so you can still see their face
magichead.voicechange = 1 //NEEEEIIGHH
if(!user.dropItemToGround(user.wear_mask))
qdel(user.wear_mask)
user.equip_to_slot_if_possible(magichead, slot_wear_mask, 1, 1)
qdel(src)
else
to_chat(user,"<span class='notice'>I say thee neigh</span>") //It still lives here
/obj/item/spellbook/oneuse/charge
spell = /obj/effect/proc_holder/spell/targeted/charge
spellname = "charging"
icon_state ="bookcharge"
desc = "This book is made of 100% post-consumer wizard."
/obj/item/spellbook/oneuse/charge/recoil(mob/user)
..()
to_chat(user,"<span class='warning'>[src] suddenly feels very warm!</span>")
empulse(src, 1, 1)
/obj/item/spellbook/oneuse/summonitem
spell = /obj/effect/proc_holder/spell/targeted/summonitem
spellname = "instant summons"
icon_state ="booksummons"
desc = "This book is bright and garish, very hard to miss."
/obj/item/spellbook/oneuse/summonitem/recoil(mob/user)
..()
to_chat(user,"<span class='warning'>[src] suddenly vanishes!</span>")
qdel(src)
/obj/item/spellbook/oneuse/random
icon_state = "random_book"
/obj/item/spellbook/oneuse/random/Initialize()
..()
var/static/banned_spells = list(/obj/item/spellbook/oneuse/mimery_blockade, /obj/item/spellbook/oneuse/mimery_guns)
var/real_type = pick(subtypesof(/obj/item/spellbook/oneuse) - banned_spells)
new real_type(loc)
return INITIALIZE_HINT_QDEL
/obj/item/spellbook/oneuse/sacredflame
spell = /obj/effect/proc_holder/spell/targeted/sacred_flame
spellname = "sacred flame"
icon_state ="booksacredflame"
desc = "Become one with the flames that burn within... and invite others to do so as well."