From 68509859c6ade517d9825af1bf5e100e4b97fa51 Mon Sep 17 00:00:00 2001 From: AnturK Date: Sat, 16 May 2015 23:46:23 +0200 Subject: [PATCH 1/4] Spellbook refactor --- code/game/gamemodes/wizard/spellbook.dm | 876 ++++++++++++++---------- 1 file changed, 515 insertions(+), 361 deletions(-) diff --git a/code/game/gamemodes/wizard/spellbook.dm b/code/game/gamemodes/wizard/spellbook.dm index 27c449dbb2f..ac77291eea5 100644 --- a/code/game/gamemodes/wizard/spellbook.dm +++ b/code/game/gamemodes/wizard/spellbook.dm @@ -1,3 +1,366 @@ +/datum/spellbook_entry + var/name = "Entry Name" + + var/spell_type = null + var/desc = "" + var/category = "Spells" + var/log_name = "XX" //What it shows up as in logs + var/cost = 1 + var/refundable = 1 + var/surplus = -1 // -1 for infinite, not used by anything atm + var/obj/effect/proc_holder/spell/S = null //Since spellbooks can be used by only one person anyway we can track the actual spell + var/buy_word = "Learn" + +/datum/spellbook_entry/proc/IsAvailible() // For config prefs / gamemode restrictions - these are round applied + return 1 +/datum/spellbook_entry/proc/CanBuy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) // Specific circumstances + if(book.uses= aspell.level_max) + user << "This spell cannot be improved further." + return 0 + else + aspell.name = initial(aspell.name) + aspell.spell_level++ + aspell.charge_max = round(initial(aspell.charge_max) - aspell.spell_level * (initial(aspell.charge_max) - aspell.cooldown_min)/ aspell.level_max) + if(aspell.charge_max < aspell.charge_counter) + aspell.charge_counter = aspell.charge_max + switch(aspell.spell_level) + if(1) + user << "You have improved [aspell.name] into Efficient [aspell.name]." + aspell.name = "Efficient [aspell.name]" + if(2) + user << "You have further improved [aspell.name] into Quickened [aspell.name]." + aspell.name = "Quickened [aspell.name]" + if(3) + user << "You have further improved [aspell.name] into Free [aspell.name]." + aspell.name = "Free [aspell.name]" + if(4) + user << "You have further improved [aspell.name] into Instant [aspell.name]." + aspell.name = "Instant [aspell.name]" + if(aspell.spell_level >= aspell.level_max) + user << "This spell cannot be strengthened any further." + return 1 + //No same spell found - just learn it + feedback_add_details("wizard_spell_learned",log_name) + user.mind.AddSpell(S) + user << "You have learned [S.name]." + return 1 + +/datum/spellbook_entry/proc/CanRefund(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + if(!refundable) + return 0 + if(!S) + S = new spell_type() + for(var/obj/effect/proc_holder/spell/aspell in user.mind.spell_list) + if(initial(S.name) == initial(aspell.name)) + return 1 + return 0 + +/datum/spellbook_entry/proc/Refund(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) //return point value or -1 for failure + var/area/wizard_station/A = locate() + if(!(user in A.contents)) + user << "You can only refund spells at the wizard lair" + return -1 + if(!S) + S = new spell_type() + var/spell_levels = 0 + for(var/obj/effect/proc_holder/spell/aspell in user.mind.spell_list) + if(initial(S.name) == initial(aspell.name)) + spell_levels = aspell.spell_level + user.mind.spell_list.Remove(aspell) + del(S) + return cost * (spell_levels+1) + return -1 +/datum/spellbook_entry/proc/GetInfo() + if(!S) + S = new spell_type() + var/dat ="" + dat += "[initial(S.name)] : Cost : [cost]
" + dat += "[S.desc][desc]
" + dat += "[S.clothes_req?"Needs wizard garb":"Can be cast without wizard garb"]
" + return dat + +/datum/spellbook_entry/fireball + name = "Fireball" + spell_type = /obj/effect/proc_holder/spell/dumbfire/fireball + log_name = "FB" + +/datum/spellbook_entry/magicm + name = "Magic Missile" + spell_type = /obj/effect/proc_holder/spell/targeted/projectile/magic_missile + log_name = "MM" + +/datum/spellbook_entry/disintegrate + name = "Disintegrate" + spell_type = /obj/effect/proc_holder/spell/targeted/inflict_handler/disintegrate + log_name = "DG" + +/datum/spellbook_entry/disabletech + name = "Disable Tech" + spell_type = /obj/effect/proc_holder/spell/targeted/emplosion/disable_tech + log_name = "DT" + +/datum/spellbook_entry/repulse + name = "Repulse" + spell_type = /obj/effect/proc_holder/spell/aoe_turf/repulse + log_name = "RP" + +/datum/spellbook_entry/smoke + name = "Smoke" + spell_type = /obj/effect/proc_holder/spell/targeted/smoke + log_name = "SM" + +/datum/spellbook_entry/blind + name = "Blind" + spell_type = /obj/effect/proc_holder/spell/targeted/trigger/blind + log_name = "BD" + +/datum/spellbook_entry/mindswap + name = "Mindswap" + spell_type = /obj/effect/proc_holder/spell/targeted/mind_transfer + log_name = "MT" + +/datum/spellbook_entry/forcewall + name = "Force Wall" + spell_type = /obj/effect/proc_holder/spell/aoe_turf/conjure/forcewall + log_name = "FW" + +/datum/spellbook_entry/blink + name = "Blink" + spell_type = /obj/effect/proc_holder/spell/targeted/turf_teleport/blink + log_name = "BL" + +/datum/spellbook_entry/teleport + name = "Teleport" + spell_type = /obj/effect/proc_holder/spell/targeted/area_teleport/teleport + log_name = "TP" + +/datum/spellbook_entry/mutate + name = "Mutate" + spell_type = /obj/effect/proc_holder/spell/targeted/genetic/mutate + log_name = "MU" + +/datum/spellbook_entry/jaunt + name = "Ethereal Jaunt" + spell_type = /obj/effect/proc_holder/spell/targeted/ethereal_jaunt + log_name = "EJ" + +/datum/spellbook_entry/knock + name = "Knock" + spell_type = /obj/effect/proc_holder/spell/aoe_turf/knock + log_name = "KN" + +/datum/spellbook_entry/fleshtostone + name = "Flesh to Stone" + spell_type = /obj/effect/proc_holder/spell/targeted/inflict_handler/flesh_to_stone + log_name = "FS" + +/datum/spellbook_entry/summonitem + name = "Summon Item" + spell_type = /obj/effect/proc_holder/spell/targeted/summonitem + log_name = "IS" + +/datum/spellbook_entry/lightningbolt + name = "Lightning Bolt" + spell_type = /obj/effect/proc_holder/spell/targeted/lightning + log_name = "LB" + +/datum/spellbook_entry/barnyard + name = "Barnyard Curse" + spell_type = /obj/effect/proc_holder/spell/targeted/barnyardcurse + log_name = "BC" + +/datum/spellbook_entry/item + name = "Buy Item" + category = "Artifacts" + refundable = 0 + buy_word = "Summon" + var/item_path= null + + +/datum/spellbook_entry/item/Buy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + new item_path(get_turf(user)) + feedback_add_details("wizard_spell_learned",log_name) + return 1 + +/datum/spellbook_entry/item/GetInfo() + var/dat ="" + dat += "[name] : Cost : [cost]
" + dat += "[desc]
" + if(surplus>=0) + dat += "[surplus] left.
" + return dat + +/datum/spellbook_entry/item/staffchange + name = "Staff of Change" + desc = "An artefact that spits bolts of coruscating energy which cause the target's very form to reshape itself." + item_path = /obj/item/weapon/gun/magic/staff/change + log_name = "ST" + +/datum/spellbook_entry/item/staffanimation + name = "Staff of Animation" + desc = "An arcane staff capable of shooting bolts of eldritch energy which cause inanimate objects to come to life. This magic doesn't affect machines." + item_path = /obj/item/weapon/gun/magic/staff/animate + log_name = "SA" + +/datum/spellbook_entry/item/staffchaos + name = "Staff of Chaos" + desc = "A caprious tool that can fire all sorts of magic without any rhyme or reason. Using it on people you care about is not recommended." + item_path = /obj/item/weapon/gun/magic/staff/chaos + log_name = "SC" + +/datum/spellbook_entry/item/staffdoor + name = "Staff of Door Creation" + desc = "A particular staff that can mold solid metal into ornate wooden doors. Useful for getting around in the absence of other transportation. Does not work on glass." + item_path = /obj/item/weapon/gun/magic/staff/door + log_name = "SD" + +/datum/spellbook_entry/item/scryingorb + name = "Scrying Orb" + desc = "An incandescent orb of crackling energy, using it will allow you to ghost while alive, allowing you to spy upon the station with ease. In addition, buying it will permanently grant you x-ray vision." + item_path = /obj/item/weapon/gun/magic/staff/chaos + log_name = "SO" + +/datum/spellbook_entry/item/scryingorb/Buy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + if(..()) + if (!(user.dna.check_mutation(XRAY))) + user.dna.add_mutation(XRAY) + return 1 + +/datum/spellbook_entry/item/soulstones + name = "Six Soul Stone Shards and the spell Artificer" + desc = "Soul Stone Shards are ancient tools capable of capturing and harnessing the spirits of the dead and dying. The spell Artificer allows you to create arcane machines for the captured souls to pilot." + item_path = /obj/item/weapon/storage/belt/soulstone/full + log_name = "SS" + +/datum/spellbook_entry/item/soulstones/Buy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + . =..() + if(.) + user.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/conjure/construct(null)) + return . + +/datum/spellbook_entry/item/necrostone + name = "A Necromantic Stone" + desc = "A Necromantic stone is able to resurrect three dead individuals as skeletal thralls for you to command." + item_path = /obj/item/device/necromantic_stone + log_name = "NS" + +/datum/spellbook_entry/item/wands + name = "Wand Assortment" + desc = "A collection of wands that allow for a wide variety of utility. Wands do not recharge, so be conservative in use. Comes in a handy belt." + item_path = /obj/item/weapon/storage/belt/wands/full + log_name = "WA" + +/datum/spellbook_entry/item/armor + name = "Mastercrafted Armor Set" + desc = "An artefact suit of armor that allows you to cast spells while providing more protection against attacks and the void of space." + item_path = /obj/item/clothing/suit/space/hardsuit/wizard + log_name = "HS" + +/datum/spellbook_entry/item/armor/Buy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + . = ..() + if(.) + new /obj/item/clothing/shoes/sandal(get_turf(user)) //In case they've lost them. + new /obj/item/clothing/gloves/color/purple(get_turf(user))//To complete the outfit + +/datum/spellbook_entry/item/contract + name = "Contract of Apprenticeship" + desc = "A magical contract binding an apprentice wizard to your service, using it will summon them to your side." + item_path = /obj/item/weapon/antag_spawner/contract + log_name = "CT" + +/datum/spellbook_entry/summon + name = "Summon Stuff" + category = "Rituals" + refundable = 0 + buy_word = "Cast" + var/active = 0 + +/datum/spellbook_entry/summon/CanBuy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + return ..() && !active + +/datum/spellbook_entry/summon/GetInfo() + var/dat ="" + dat += "[name] : " + if(cost>0) + dat += "Cost : [cost]
" + else + dat += "No Cost
" + dat += "[desc]
" + if(active) + dat += "Already cast!
" + return dat + +/datum/spellbook_entry/summon/guns + name = "Summon Guns" + category = "Challenges" + desc = "Nothing could possibly go wrong with arming a crew of lunatics just itching for an excuse to kill you. Just be careful not to stand still too long!" + cost = 0 + log_name = "SG" + +/datum/spellbook_entry/summon/guns/IsAvailible() + return !config.no_summon_guns + +/datum/spellbook_entry/summon/guns/Buy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + feedback_add_details("wizard_spell_learned",log_name) + rightandwrong(0, user, 0) + book.uses += 1 + active = 1 + user << "You have cast summon guns and gained an extra charge for your spellbook." + return 1 + +/datum/spellbook_entry/summon/magic + name = "Summon Magic" + category = "Challenges" + desc = "Share the wonders of magic with the crew and show them why they aren't to be trusted with it at the same time." + cost = 0 + log_name = "SU" + +/datum/spellbook_entry/summon/magic/IsAvailible() + return !config.no_summon_magic + +/datum/spellbook_entry/summon/magic/Buy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + feedback_add_details("wizard_spell_learned",log_name) + rightandwrong(1, user, 0) + book.uses += 1 + active = 1 + user << "You have cast summon magic and gained an extra charge for your spellbook." + return 1 + +/datum/spellbook_entry/summon/events + name = "Summon Events" + desc = "Give Murphy's law a little push and replace all events with special wizard ones that will confound and confuse everyone. Multiple castings increase the rate of these events." + cost = 1 + log_name = "SE" + var/times = 0 + +/datum/spellbook_entry/summon/events/IsAvailible() + return (ticker.mode.name != "ragin' mages" && !config.no_summon_events) + +/datum/spellbook_entry/summon/events/Buy(var/mob/living/carbon/human/user,var/obj/item/weapon/spellbook/book) + feedback_add_details("wizard_spell_learned",log_name) + summonevents() + times++ + user << "You have cast summon events." + return 1 + +/datum/spellbook_entry/summon/events/GetInfo() + . = ..() + if(times>0) + . += "You cast it [times] times.
" + return . + + + /obj/item/weapon/spellbook name = "spell book" desc = "The legendary book of spells of the wizard." @@ -8,11 +371,22 @@ w_class = 1.0 var/uses = 5 var/temp = null - var/max_uses = 5 var/op = 1 - var/activepage - var/list/active_challenges = list() var/mob/living/carbon/human/owner + var/list/datum/spellbook_entry/entries = list() + var/list/categories = list() + +/obj/item/weapon/spellbook/New() + ..() + var/entry_types = typesof(/datum/spellbook_entry) - /datum/spellbook_entry - /datum/spellbook_entry/item - /datum/spellbook_entry/summon + for(var/T in entry_types) + var/datum/spellbook_entry/E = new T + if(E.IsAvailible()) + entries |= E + categories |= E.category + else + del(E) + /obj/item/weapon/spellbook/attackby(obj/item/O as obj, mob/user as mob, params) if(istype(O, /obj/item/weapon/antag_spawner/contract)) @@ -21,12 +395,105 @@ user << "The contract has been used, you can't get your points back now!" else user << "You feed the contract back into the spellbook, refunding your points." - src.max_uses++ src.uses++ qdel(O) +/obj/item/weapon/spellbook/proc/GetCategoryHeader(var/category) + var/dat = "" + switch(category) + if("Spells") + dat += "Spells that can be reused endlessly.
" + dat += "The number after the spell name is the cooldown time. You can reduce this number by spending more points on the spell.
" + if("Artifacts") + dat += "Powerful items imbued with eldritch magics. Summoning one will count towards your maximum number of uses.
" + dat += "These items are not bound to you and can be stolen. Additionaly they cannot typically be returned once purchased.
" + if("Challenges") + dat += "The Wizard Federation typically has hard limits on the potency and number of spells brought to the station based on risk.
" + dat += "Arming the station against you will increases the risk, but will grant you one more charge for your spellbook.
" + if("Rituals") + dat += "These powerful spells change the very fabric of reality. Not always in your favour.
" + return dat +/obj/item/weapon/spellbook/proc/wrap(var/content) + var/dat = "" + dat +="Spellbook" + dat += {" + + + + + "} + dat += "" + dat += {"[content]"} + return dat /obj/item/weapon/spellbook/attack_self(mob/user as mob) if(!owner) @@ -37,159 +504,39 @@ user << "The [name] does not recognize you as it's owner and refuses to open!" return user.set_machine(src) - var/dat - if(temp) - dat = "[temp]

Clear" - else if (!activepage || activepage == "return") - dat = "The Book of Magic:
" - dat += "Uses remaining: [uses]
" - dat += "
" - dat += "Learn and Improve Magical Abilities
" - dat += "Summon Magical Tools and Weapons
" - if(ticker.mode.name != "ragin' mages") // we totally need summon guns x100 - dat += "Raise The Stakes For More Power
" - dat += "
" - dat += "Re-memorize Spells
" + var/dat = "" + dat += "Uses remaining : [uses]
" + + dat += "" + + var/datum/spellbook_entry/E + for(var/i=1,i<=entries.len,i++) + var/spell_info = "" + E = entries[i] + spell_info += E.GetInfo() + if(E.CanBuy(user,src)) + spell_info+= "[E.buy_word]
" + else + spell_info+= "Can't [E.buy_word]
" + if(E.CanRefund(user,src)) + spell_info+= "Refund
" + spell_info += "
" + if(cat_dat[E.category]) + cat_dat[E.category] += spell_info - else if (activepage == "spells") - dat += "Spells:
" - dat += "Spells that can be reused endlessly. Unless stated otherwise all spells require full wizard garb as a focus.
" - dat += "The number after the spell name is the cooldown time. You can reduce this number by spending more points on the spell.
" + for(var/category in categories) + dat += "
" + dat += GetCategoryHeader(category) + dat += cat_dat[category] + dat += "
" - dat += "
" - - dat += "Magic Missile (15)
" - dat += "This spell fires several, slow moving, magic projectiles at nearby targets. If they hit a target, it is paralyzed and takes minor damage.
" - - dat += "Fireball (10)
" - dat += "This spell fires a fireball in the direction you're facing and does not require wizard garb. Be careful not to fire it at people that are standing next to you.
" - - dat += "Disintegrate (60)
" - dat += "This spell instantly kills somebody adjacent to you with the vilest of magick. It has a long cooldown.
" - - dat += "Disable Technology (60)
" - dat += "This spell disables all weapons, cameras and most other technology in range.
" - - dat += "Repulse (40)
" - dat += "This spell throws nearby objects away from you and knocks creatures down.
" - - dat += "Smoke (10)
" - dat += "This spell spawns a cloud of choking smoke at your location and does not require wizard garb.
" - - dat += "Blind (30)
" - dat += "This spell temporarly blinds a single person and does not require wizard garb.
" - - dat += "Mind Transfer (60)
" - dat += "This spell allows the user to switch bodies with a target. Careful to not lose your memory in the process.
" - - dat += "Forcewall (10)
" - dat += "This spell creates an unbreakable wall that lasts for 30 seconds and does not need wizard garb.
" - - dat += "Blink (2)
" - dat += "This spell randomly teleports you a short distance. Useful for evasion or getting into areas if you have patience.
" - - dat += "Teleport (60)
" - dat += "This spell teleports you to a type of area of your selection. Very useful if you are in danger, but has a decent cooldown, and is unpredictable.
" - - dat += "Mutate (60)
" - dat += "This spell causes you to turn into a hulk and gain telekinesis for a short while.
" - - dat += "Ethereal Jaunt (30)
" - dat += "This spell creates your ethereal form, temporarily making you invisible and able to pass through walls.
" - - dat += "Knock (10)
" - dat += "This spell opens nearby doors and does not require wizard garb.
" - - dat += "Curse of the Barnyard (15)
" - dat += " This Spell dooms any unlucky soul to the life of a barnyard animal. Well not exactly but you still get to laugh at them when they MOO!. It does not require a wizard garb.
" - - dat += "Flesh to Stone (60)
" - dat += "This spell will curse a person to immediately turn into an unmoving statue. The effect will eventually wear off if the statue is not destroyed.
" - - dat += "Lightning Bolt (30)
" - dat += "Charge up and throw lightning bolt at the nearby enemy. Classic. The longer you charge the more powerful the spell, beware of overcharge however!
" - - dat += "Instant Summons (10)
" - dat += "This spell can be used to bind a valuable item to you, bringing it to your hand at will. Using this spell while holding the bound item will allow you to unbind it. It does not require wizard garb.
" - if(ticker.mode.name != "ragin' mages" && !config.no_summon_events) // we totally need summon greentext x100 - dat += "Summon Events (One time use, persistent global spell)
" - dat += "Give Murphy's law a little push and replace all events with special wizard ones that will confound and confuse everyone. Multiple castings increase the rate of these events.
" - - dat += "
" - - dat += "Return
" - - else if (activepage == "challenge") - - dat += "Challenges:
" - dat += "The Wizard Federation typically has hard limits on the potency and number of spells brought to the station based on risk.
" - dat += "Arming the station against you will increases the risk, but will grant you one more charge for your spellbook.
" - - dat += "
" - - if(!("summon guns" in active_challenges) && !config.no_summon_guns) - dat += "Summon Guns (Single use only, global spell)
" - dat += "Nothing could possibly go wrong with arming a crew of lunatics just itching for an excuse to kill you. Just be careful not to stand still too long!
" - - if(!("summon magic" in active_challenges) && !config.no_summon_magic) - dat += "Summon Magic (Single use only, global spell)
" - dat += "Share the wonders of magic with the crew and show them why they aren't to be trusted with it at the same time.
" - - dat += "
" - - dat += "Return
" - - else if (activepage == "artifacts") - - dat += "Artifacts:
" - dat += "Powerful items imbued with eldritch magics. Summoning one will count towards your maximum number of uses.
" - dat += "These items are not bound to you and can be stolen. Additionaly they cannot typically be returned once purchased.
" - dat += "
" - - dat += "Staff of Change
" - dat += "An artefact that spits bolts of coruscating energy which cause the target's very form to reshape itself.
" - dat += "
" - - dat += "Staff of Animation
" - dat += "An arcane staff capable of shooting bolts of eldritch energy which cause inanimate objects to come to life. This magic doesn't affect machines.
" - dat += "
" - - dat += "Staff of Door Creation
" - dat += "A particular staff that can mold solid metal into ornate wooden doors. Useful for getting around in the absence of other transportation. Does not work on glass.
" - dat += "
" - - dat += "Staff of Chaos
" - dat += "A caprious tool that can fire all sorts of magic without any rhyme or reason. Using it on people you care about is not recommended.
" - dat += "
" - - dat += "Six Soul Stone Shards and the spell Artificer
" - dat += "Soul Stone Shards are ancient tools capable of capturing and harnessing the spirits of the dead and dying. The spell Artificer allows you to create arcane machines for the captured souls to pilot.
" - dat += "
" - - dat += "A Necromantic Stone
" - dat += "A Necromantic stone is able to resurrect three dead individuals as skeletal thralls for you to command." - dat += "
" - - dat += "Wand Assortment
" - dat += "A collection of wands that allow for a wide variety of utility. Wands do not recharge, so be conservative in use. Comes in a handy belt.
" - dat += "
" - - dat += "Mastercrafted Armor Set
" - dat += "An artefact suit of armor that allows you to cast spells while providing more protection against attacks and the void of space.
" - dat += "
" - - dat += "Contract of Apprenticeship
" - dat += "A magical contract binding an apprentice wizard to your service, using it will summon them to your side.
" - dat += "
" - - dat += "Scrying Orb
" - dat += "An incandescent orb of crackling energy, using it will allow you to ghost while alive, allowing you to spy upon the station with ease. In addition, buying it will permanently grant you x-ray vision.
" - - dat += "
" - - dat += "Return
" - user << browse(dat, "window=radio") - onclose(user, "radio") + user << browse(wrap(dat), "window=spellbook") + onclose(user, "spellbook") return /obj/item/weapon/spellbook/Topic(href, href_list) @@ -205,213 +552,21 @@ temp = "If you got caught sneaking a peak from your teacher's spellbook, you'd likely be expelled from the Wizard Academy. Better not." return + var/datum/spellbook_entry/E = null if(loc == H || (in_range(src, H) && istype(loc, /turf))) H.set_machine(src) - if(href_list["spell_choice"]) - if(href_list["spell_choice"] == "rememorize") - var/area/wizard_station/A = locate() - if(usr in A.contents) - uses = max_uses - H.spellremove(usr) - temp = "All spells have been removed. You may now memorize a new set of spells." - feedback_add_details("wizard_spell_learned","UM") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - else - temp = "You may only re-memorize spells whilst located inside the wizard sanctuary." - else if(href_list["spell_choice"] == "spells" || href_list["spell_choice"] == "artifacts" || href_list["spell_choice"] == "challenge" || href_list["spell_choice"] == "return") - activepage = href_list["spell_choice"] - else if(uses >= 1 && max_uses >=1) - uses-- - /* - */ - var/list/available_spells = list(magicmissile = "Magic Missile", fireball = "Fireball", disintegrate = "Disintegrate", disabletech = "Disable Tech", repulse = "Repulse", smoke = "Smoke", blind = "Blind", mindswap = "Mind Transfer", forcewall = "Forcewall", blink = "Blink", teleport = "Teleport", mutate = "Mutate", etherealjaunt = "Ethereal Jaunt", knock = "Knock", barnyard = "Curse of the Barnyard", fleshtostone = "Flesh to Stone", summonitem = "Instant Summons", summonguns = "Summon Guns", summonmagic = "Summon Magic", summonevents = "Summon Events", staffchange = "Staff of Change", soulstone = "Six Soul Stone Shards and the spell Artificer", necrostone = "A Necromantic Stone", armor = "Mastercrafted Armor Set", staffanimate = "Staff of Animation", staffchaos = "Staff of Chaos", staffdoor = "Staff of Door Creation", wands = "Wand Assortment", lightningbolt = "Lightning Bolt") - var/already_knows = 0 - for(var/obj/effect/proc_holder/spell/aspell in H.mind.spell_list) - if(available_spells[href_list["spell_choice"]] == initial(aspell.name)) - already_knows = 1 - if(aspell.spell_level >= aspell.level_max) - temp = "This spell cannot be improved further." - uses++ - break - else - aspell.name = initial(aspell.name) - aspell.spell_level++ - aspell.charge_max = round(initial(aspell.charge_max) - aspell.spell_level * (initial(aspell.charge_max) - aspell.cooldown_min)/ aspell.level_max) - if(aspell.charge_max < aspell.charge_counter) - aspell.charge_counter = aspell.charge_max - switch(aspell.spell_level) - if(1) - temp = "You have improved [aspell.name] into Efficient [aspell.name]." - aspell.name = "Efficient [aspell.name]" - if(2) - temp = "You have further improved [aspell.name] into Quickened [aspell.name]." - aspell.name = "Quickened [aspell.name]" - if(3) - temp = "You have further improved [aspell.name] into Free [aspell.name]." - aspell.name = "Free [aspell.name]" - if(4) - temp = "You have further improved [aspell.name] into Instant [aspell.name]." - aspell.name = "Instant [aspell.name]" - if(aspell.spell_level >= aspell.level_max) - temp += " This spell cannot be strengthened any further." - /* - */ - if(!already_knows) - switch(href_list["spell_choice"]) - if("magicmissile") - feedback_add_details("wizard_spell_learned","MM") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/projectile/magic_missile(null)) - temp = "You have learned magic missile." - if("fireball") - feedback_add_details("wizard_spell_learned","FB") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/dumbfire/fireball(null)) - temp = "You have learned fireball." - if("disintegrate") - feedback_add_details("wizard_spell_learned","DG") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/inflict_handler/disintegrate(null)) - temp = "You have learned disintegrate." - if("disabletech") - feedback_add_details("wizard_spell_learned","DT") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/emplosion/disable_tech(null)) - temp = "You have learned disable technology." - if("repulse") - feedback_add_details("wizard_spell_learned","RP") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/repulse(null)) - temp = "You have learned repulse." - if("smoke") - feedback_add_details("wizard_spell_learned","SM") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/smoke(null)) - temp = "You have learned smoke." - if("blind") - feedback_add_details("wizard_spell_learned","BD") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/trigger/blind(null)) - temp = "You have learned blind." - if("mindswap") - feedback_add_details("wizard_spell_learned","MT") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/mind_transfer(null)) - temp = "You have learned mindswap." - if("forcewall") - feedback_add_details("wizard_spell_learned","FW") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/conjure/forcewall(null)) - temp = "You have learned forcewall." - if("blink") - feedback_add_details("wizard_spell_learned","BL") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/turf_teleport/blink(null)) - temp = "You have learned blink." - if("teleport") - feedback_add_details("wizard_spell_learned","TP") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/area_teleport/teleport(null)) - temp = "You have learned teleport." - if("mutate") - feedback_add_details("wizard_spell_learned","MU") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/genetic/mutate(null)) - temp = "You have learned mutate." - if("etherealjaunt") - feedback_add_details("wizard_spell_learned","EJ") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/ethereal_jaunt(null)) - temp = "You have learned ethereal jaunt." - if("knock") - feedback_add_details("wizard_spell_learned","KN") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/knock(null)) - temp = "You have learned knock." - if("fleshtostone") - feedback_add_details("wizard_spell_learned","FS") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/inflict_handler/flesh_to_stone(null)) - temp = "You have learned flesh to stone." - if("summonitem") - feedback_add_details("wizard_spell_learned","IS") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/summonitem(null)) - temp = "You have learned instant summons." - if("lightningbolt") - feedback_add_details("wizard_spell_learned","LB") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/lightning(null)) - temp = "You have learned lightning bolt." - if("summonguns") - feedback_add_details("wizard_spell_learned","SG") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - rightandwrong(0, H, 0) - max_uses++ - uses = uses + 2 //refund plus a free point - active_challenges += "summon guns" - playsound(get_turf(H),"sound/magic/CastSummon.ogg",50,1) - temp = "You have cast summon guns and gained an extra charge for your spellbook." - if("summonmagic") - feedback_add_details("wizard_spell_learned","SU") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - rightandwrong(1, H, 0) - max_uses++ - uses = uses + 2 //refund plus a free point - active_challenges += "summon magic" - playsound(get_turf(H),"sound/magic/CastSummon.ogg",50,1) - temp = "You have cast summon magic and gained an extra charge for your spellbook." - if("summonevents") - feedback_add_details("wizard_spell_learned","SE") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - summonevents() - playsound(get_turf(H),"sound/magic/CastSummon.ogg",50,1) - max_uses-- - temp = "You have cast summon events." - if("staffchange") - feedback_add_details("wizard_spell_learned","ST") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/gun/magic/staff/change(get_turf(H)) - temp = "You have purchased a staff of change." - max_uses-- - if("soulstone") - feedback_add_details("wizard_spell_learned","SS") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/storage/belt/soulstone/full(get_turf(H)) - H.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/conjure/construct(null)) - temp = "You have purchased a belt full of soulstones and have learned the artificer spell." - max_uses-- - if("necrostone") - feedback_add_details("wizard_spell_learned","NS") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/device/necromantic_stone(get_turf(H)) - temp = "You have purchased a necromantic stone." - max_uses-- - if("armor") - feedback_add_details("wizard_spell_learned","HS") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/clothing/shoes/sandal(get_turf(H)) //In case they've lost them. - new /obj/item/clothing/gloves/color/purple(get_turf(H))//To complete the outfit - new /obj/item/clothing/suit/space/hardsuit/wizard(get_turf(H)) - temp = "You have purchased a suit of wizard armor." - max_uses-- - if("staffanimation") - feedback_add_details("wizard_spell_learned","SA") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/gun/magic/staff/animate(get_turf(H)) - temp = "You have purchased a staff of animation." - max_uses-- - if("staffchaos") - feedback_add_details("wizard_spell_learned","SC") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/gun/magic/staff/chaos(get_turf(H)) - temp = "You have purchased a staff of chaos." - max_uses-- - if("staffdoor") - feedback_add_details("wizard_spell_learned","SD") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/gun/magic/staff/door(get_turf(H)) - temp = "You have purchased a staff of door creation." - max_uses-- - if("barnyard") - feedback_add_details("wizard_spell_learned","BC") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/barnyardcurse(null)) - temp = "You have learned the curse of the barnyard." - if("wands") - feedback_add_details("wizard_spell_learned","WA") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/storage/belt/wands/full(get_turf(H)) - temp = "You have purchased an assortment of wands." - max_uses-- - if("contract") - feedback_add_details("wizard_spell_learned","CT") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/antag_spawner/contract(get_turf(H)) - temp = "You have purchased a contract of apprenticeship." - max_uses-- - if("scrying") - feedback_add_details("wizard_spell_learned","SO") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells - new /obj/item/weapon/scrying(get_turf(H)) - if (!(H.dna.check_mutation(XRAY))) - H.dna.add_mutation(XRAY) - temp = "You have purchased a scrying orb, and gained x-ray vision." - max_uses-- - else - if(href_list["temp"]) - temp = null - activepage = null - attack_self(H) - + if(href_list["buy"]) + E = entries[text2num(href_list["buy"])] + if(E && E.CanBuy(H,src)) + if(E.Buy(H,src)) + uses -= E.cost + else if(href_list["refund"]) + E = entries[text2num(href_list["refund"])] + if(E && E.refundable) + var/result = E.Refund(H,src) + if(result > 0) + uses += result + attack_self(H) return //Single Use Spellbooks// @@ -422,7 +577,6 @@ var/used = 0 name = "spellbook of " uses = 1 - max_uses = 1 desc = "This template spellbook was never meant for the eyes of man..." /obj/item/weapon/spellbook/oneuse/New() From e18a39da476e91c279ef2db87de08e4f0f5f3d5b Mon Sep 17 00:00:00 2001 From: AnturK Date: Sun, 17 May 2015 13:47:25 +0200 Subject: [PATCH 2/4] Splits the Spells into Offensive/Utility Moves Uses to fake tab Drops js implementation --- code/game/gamemodes/wizard/spellbook.dm | 111 ++++++++---------------- 1 file changed, 37 insertions(+), 74 deletions(-) diff --git a/code/game/gamemodes/wizard/spellbook.dm b/code/game/gamemodes/wizard/spellbook.dm index ac77291eea5..819aa8a467f 100644 --- a/code/game/gamemodes/wizard/spellbook.dm +++ b/code/game/gamemodes/wizard/spellbook.dm @@ -3,7 +3,7 @@ var/spell_type = null var/desc = "" - var/category = "Spells" + var/category = "Offensive Spells" var/log_name = "XX" //What it shows up as in logs var/cost = 1 var/refundable = 1 @@ -84,7 +84,10 @@ if(!S) S = new spell_type() var/dat ="" - dat += "[initial(S.name)] : Cost : [cost]
" + dat += "[initial(S.name)]" + if(S.charge_type == "recharge") + dat += " Cooldown:[S.charge_max/10]" + dat += " Cost:[cost]
" dat += "[S.desc][desc]
" dat += "[S.clothes_req?"Needs wizard garb":"Can be cast without wizard garb"]
" return dat @@ -108,6 +111,7 @@ name = "Disable Tech" spell_type = /obj/effect/proc_holder/spell/targeted/emplosion/disable_tech log_name = "DT" + category = "Utility Spells" /datum/spellbook_entry/repulse name = "Repulse" @@ -118,6 +122,7 @@ name = "Smoke" spell_type = /obj/effect/proc_holder/spell/targeted/smoke log_name = "SM" + category = "Utility Spells" /datum/spellbook_entry/blind name = "Blind" @@ -128,36 +133,43 @@ name = "Mindswap" spell_type = /obj/effect/proc_holder/spell/targeted/mind_transfer log_name = "MT" + category = "Utility Spells" /datum/spellbook_entry/forcewall name = "Force Wall" spell_type = /obj/effect/proc_holder/spell/aoe_turf/conjure/forcewall log_name = "FW" + category = "Utility Spells" /datum/spellbook_entry/blink name = "Blink" spell_type = /obj/effect/proc_holder/spell/targeted/turf_teleport/blink log_name = "BL" + category = "Utility Spells" /datum/spellbook_entry/teleport name = "Teleport" spell_type = /obj/effect/proc_holder/spell/targeted/area_teleport/teleport log_name = "TP" + category = "Utility Spells" /datum/spellbook_entry/mutate name = "Mutate" spell_type = /obj/effect/proc_holder/spell/targeted/genetic/mutate log_name = "MU" + category = "Utility Spells" /datum/spellbook_entry/jaunt name = "Ethereal Jaunt" spell_type = /obj/effect/proc_holder/spell/targeted/ethereal_jaunt log_name = "EJ" + category = "Utility Spells" /datum/spellbook_entry/knock name = "Knock" spell_type = /obj/effect/proc_holder/spell/aoe_turf/knock log_name = "KN" + category = "Utility Spells" /datum/spellbook_entry/fleshtostone name = "Flesh to Stone" @@ -168,6 +180,7 @@ name = "Summon Item" spell_type = /obj/effect/proc_holder/spell/targeted/summonitem log_name = "IS" + category = "Utility Spells" /datum/spellbook_entry/lightningbolt name = "Lightning Bolt" @@ -194,7 +207,8 @@ /datum/spellbook_entry/item/GetInfo() var/dat ="" - dat += "[name] : Cost : [cost]
" + dat += "[name]" + dat += " Cost:[cost]
" dat += "[desc]
" if(surplus>=0) dat += "[surplus] left.
" @@ -290,11 +304,11 @@ /datum/spellbook_entry/summon/GetInfo() var/dat ="" - dat += "[name] : " + dat += "[name]" if(cost>0) - dat += "Cost : [cost]
" + dat += " Cost:[cost]
" else - dat += "No Cost
" + dat += " No Cost
" dat += "[desc]
" if(active) dat += "Already cast!
" @@ -372,6 +386,7 @@ var/uses = 5 var/temp = null var/op = 1 + var/tab = null var/mob/living/carbon/human/owner var/list/datum/spellbook_entry/entries = list() var/list/categories = list() @@ -386,6 +401,7 @@ categories |= E.category else del(E) + tab = categories[1] /obj/item/weapon/spellbook/attackby(obj/item/O as obj, mob/user as mob, params) @@ -401,9 +417,14 @@ /obj/item/weapon/spellbook/proc/GetCategoryHeader(var/category) var/dat = "" switch(category) - if("Spells") + if("Offensive Spells") dat += "Spells that can be reused endlessly.
" - dat += "The number after the spell name is the cooldown time. You can reduce this number by spending more points on the spell.
" + dat += "The number after the spell name is the cooldown time.
" + dat += "You can reduce this number by spending more points on the spell.
" + if("Utility Spells") + dat += "Spells that can be reused endlessly.
" + dat += "The number after the spell name is the cooldown time.
" + dat += "You can reduce this number by spending more points on the spell.
" if("Artifacts") dat += "Powerful items imbued with eldritch magics. Summoning one will count towards your maximum number of uses.
" dat += "These items are not bound to you and can be stolen. Additionaly they cannot typically be returned once purchased.
" @@ -429,69 +450,8 @@ div.tabContent { border: 1px solid #c9c3ba; padding: 0.5em; background-color: #f1f0ee; } div.tabContent.hide { display: none; } - - "} - dat += "" dat += {"[content]"} return dat @@ -505,13 +465,14 @@ return user.set_machine(src) var/dat = "" - dat += "Uses remaining : [uses]
" - + dat += "" var/datum/spellbook_entry/E @@ -530,12 +491,12 @@ cat_dat[E.category] += spell_info for(var/category in categories) - dat += "
" + dat += "
" dat += GetCategoryHeader(category) dat += cat_dat[category] dat += "
" - user << browse(wrap(dat), "window=spellbook") + user << browse(wrap(dat), "window=spellbook;size=600x300") onclose(user, "spellbook") return @@ -566,6 +527,8 @@ var/result = E.Refund(H,src) if(result > 0) uses += result + else if(href_list["page"]) + tab = href_list["page"] attack_self(H) return From d9d5b99724bdf4b8a060959d044d2a35c2a28f8b Mon Sep 17 00:00:00 2001 From: AnturK Date: Tue, 19 May 2015 15:40:23 +0200 Subject: [PATCH 3/4] Just in case --- code/game/gamemodes/wizard/spellbook.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/gamemodes/wizard/spellbook.dm b/code/game/gamemodes/wizard/spellbook.dm index 819aa8a467f..747e302d6ec 100644 --- a/code/game/gamemodes/wizard/spellbook.dm +++ b/code/game/gamemodes/wizard/spellbook.dm @@ -528,7 +528,7 @@ if(result > 0) uses += result else if(href_list["page"]) - tab = href_list["page"] + tab = sanitize(href_list["page"]) attack_self(H) return From a4fbd97528bae1bf20953f4f1423c913a332b42a Mon Sep 17 00:00:00 2001 From: AnturK Date: Wed, 3 Jun 2015 16:32:56 +0200 Subject: [PATCH 4/4] Adds summon sounds back --- code/game/gamemodes/wizard/spellbook.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/game/gamemodes/wizard/spellbook.dm b/code/game/gamemodes/wizard/spellbook.dm index 747e302d6ec..8a58076e663 100644 --- a/code/game/gamemodes/wizard/spellbook.dm +++ b/code/game/gamemodes/wizard/spellbook.dm @@ -329,6 +329,7 @@ rightandwrong(0, user, 0) book.uses += 1 active = 1 + playsound(get_turf(user),"sound/magic/CastSummon.ogg",50,1) user << "You have cast summon guns and gained an extra charge for your spellbook." return 1 @@ -347,6 +348,7 @@ rightandwrong(1, user, 0) book.uses += 1 active = 1 + playsound(get_turf(user),"sound/magic/CastSummon.ogg",50,1) user << "You have cast summon magic and gained an extra charge for your spellbook." return 1 @@ -364,6 +366,7 @@ feedback_add_details("wizard_spell_learned",log_name) summonevents() times++ + playsound(get_turf(user),"sound/magic/CastSummon.ogg",50,1) user << "You have cast summon events." return 1