From b7b05d53ecf2dc8adf1939fce947fbc23d55cd9f Mon Sep 17 00:00:00 2001 From: Incoming Date: Tue, 10 Dec 2013 01:04:16 -0500 Subject: [PATCH] Code optimization and copypasta removal: the teleport wand now uses do_teleport the polymorph wand now uses wabbajack in both instances You can now click on yourself while holding a wand to cast it on yourself in addition to clicking on the wand itself. Changed how guns/magic are given out slightly. Previously no antag could get a gun/magic thing (including survivors made by the spell in the case of multicasting) but now antags who aren't the wizard or an apprentice of the wizard also get one. Fixed a few bugs on accidentally burning charges by click in places tht wouldn't actually fire the wand/staff --- code/game/gamemodes/wizard/rightandwrong.dm | 3 +- code/game/gamemodes/wizard/spellbook.dm | 2 +- code/modules/projectiles/guns/magic.dm | 4 +- code/modules/projectiles/guns/magic/wand.dm | 128 ++--------- code/modules/projectiles/projectile/magic.dm | 210 +++++++++---------- 5 files changed, 122 insertions(+), 225 deletions(-) diff --git a/code/game/gamemodes/wizard/rightandwrong.dm b/code/game/gamemodes/wizard/rightandwrong.dm index 4b0d7633e82..891a2dbff7c 100644 --- a/code/game/gamemodes/wizard/rightandwrong.dm +++ b/code/game/gamemodes/wizard/rightandwrong.dm @@ -5,7 +5,8 @@ message_admins("[key_name_admin(usr, 1)] summoned [summon_type ? "magic" : "guns"]!") for(var/mob/living/carbon/human/H in player_list) if(H.stat == 2 || !(H.client)) continue - if(is_special_character(H)) continue + if(H.mind) + if(H.mind.special_role == "Wizard" || H.mind.special_role == "apprentice") continue if(prob(25)) ticker.mode.traitors += H.mind H.mind.special_role = "traitor" diff --git a/code/game/gamemodes/wizard/spellbook.dm b/code/game/gamemodes/wizard/spellbook.dm index 6254b9e3725..cdc1610aebb 100644 --- a/code/game/gamemodes/wizard/spellbook.dm +++ b/code/game/gamemodes/wizard/spellbook.dm @@ -323,7 +323,7 @@ for(var/obj/effect/proc_holder/spell/knownspell in user.spell_list) if(knownspell.type == S.type) if(user.mind) - if(user.mind.special_role == "apprentice" || user.mind.special_role == "wizard") + if(user.mind.special_role == "apprentice" || user.mind.special_role == "Wizard") user <<"\blue You're already far more versed in this spell than this flimsy how-to book can provide." else user <<"\blue You've already read this one." diff --git a/code/modules/projectiles/guns/magic.dm b/code/modules/projectiles/guns/magic.dm index 29ea645df6b..c38d46822d5 100644 --- a/code/modules/projectiles/guns/magic.dm +++ b/code/modules/projectiles/guns/magic.dm @@ -26,9 +26,9 @@ in_chamber = new projectile_type(src) return 1 -/obj/item/weapon/gun/magic/afterattack() +/obj/item/weapon/gun/magic/afterattack(atom/target as mob, mob/living/user as mob, flag) ..() - if(charges && !in_chamber) charges-- + if(charges && !in_chamber && !flag) charges-- /obj/item/weapon/gun/magic/New() ..() diff --git a/code/modules/projectiles/guns/magic/wand.dm b/code/modules/projectiles/guns/magic/wand.dm index 7ca916232c9..5896ecb4f58 100644 --- a/code/modules/projectiles/guns/magic/wand.dm +++ b/code/modules/projectiles/guns/magic/wand.dm @@ -29,6 +29,20 @@ user << "The [name] whizzles quietly." ..() +/obj/item/weapon/gun/magic/wand/attack(atom/target as mob, mob/living/user as mob) + if(target == user) + return + ..() + +/obj/item/weapon/gun/magic/wand/afterattack(atom/target as mob, mob/living/user as mob) + if(target == user) + if(charges) + zap_self(user) + else + user << "The [name] whizzles quietly." + else + ..() + /obj/item/weapon/gun/magic/wand/proc/zap_self(mob/living/user as mob) user.visible_message("\blue [user] zaps \himself with [src]!") @@ -71,99 +85,16 @@ /obj/item/weapon/gun/magic/wand/polymorph name = "wand of polymorph" - desc = "This wand inflicts is attuned to chaos and will radically alter the victim's form." + desc = "This wand is attuned to chaos and will radically alter the victim's form." projectile_type = "/obj/item/projectile/magic/change" icon_state = "wand5" max_charges = 10 //10, 5, 5, 4 /obj/item/weapon/gun/magic/wand/polymorph/zap_self(mob/living/user as mob) if(alert(user, "Your new form might not have arms to zap with... Continue?",, "Yes", "No") == "Yes" && charges && user.get_active_hand() == src && isliving(user)) - if(user.monkeyizing) return - user.monkeyizing = 1 - user.canmove = 0 - user.icon = null - user.overlays.Cut() - user.invisibility = 101 - for(var/obj/item/W in user) - if(istype(W, /obj/item/weapon/implant)) //TODO: Carn. give implants a dropped() or something - del(W) - continue - W.layer = initial(W.layer) - W.loc = user.loc - W.dropped(user) - - var/mob/living/new_mob - - var/randomize = pick("monkey","robot","slime","xeno","human","animal") - switch(randomize) - if("monkey") - new_mob = new /mob/living/carbon/monkey(user.loc) - new_mob.universal_speak = 1 - if("robot") - new_mob = new /mob/living/silicon/robot(user.loc) - new_mob.gender = user.gender - new_mob.invisibility = 0 - new_mob.job = "Cyborg" - var/mob/living/silicon/robot/Robot = new_mob - Robot.mmi = new /obj/item/device/mmi(new_mob) - Robot.mmi.transfer_identity(user) //Does not transfer key/client. - if("slime") - if(prob(50)) new_mob = new /mob/living/carbon/slime/adult(user.loc) - else new_mob = new /mob/living/carbon/slime(user.loc) - new_mob.universal_speak = 1 - if("xeno") - if(prob(50)) - new_mob = new /mob/living/carbon/alien/humanoid/hunter(user.loc) - else - new_mob = new /mob/living/carbon/alien/humanoid/sentinel(user.loc) - new_mob.universal_speak = 1 - if("animal") - var/animal = pick("parrot","corgi","crab","pug","cat","carp","bear","mushroom","tomato","mouse","chicken","cow","lizard","chick") - switch(animal) - if("parrot") new_mob = new /mob/living/simple_animal/parrot(user.loc) - if("corgi") new_mob = new /mob/living/simple_animal/corgi(user.loc) - if("crab") new_mob = new /mob/living/simple_animal/crab(user.loc) - if("pug") new_mob = new /mob/living/simple_animal/pug(user.loc) - if("cat") new_mob = new /mob/living/simple_animal/cat(user.loc) - if("carp") new_mob = new /mob/living/simple_animal/hostile/carp(user.loc) - if("bear") new_mob = new /mob/living/simple_animal/hostile/bear(user.loc) - if("mushroom") new_mob = new /mob/living/simple_animal/mushroom(user.loc) - if("tomato") new_mob = new /mob/living/simple_animal/tomato(user.loc) - if("mouse") new_mob = new /mob/living/simple_animal/mouse(user.loc) - if("chicken") new_mob = new /mob/living/simple_animal/chicken(user.loc) - if("cow") new_mob = new /mob/living/simple_animal/cow(user.loc) - if("lizard") new_mob = new /mob/living/simple_animal/lizard(user.loc) - else new_mob = new /mob/living/simple_animal/chick(user.loc) - new_mob.universal_speak = 1 - if("human") - new_mob = new /mob/living/carbon/human(user.loc) - - var/datum/preferences/A = new() //Randomize appearance for the human - A.copy_to(new_mob) - - var/mob/living/carbon/human/H = new_mob - ready_dna(H) - if(H.dna) - H.dna.mutantrace = pick("lizard","golem","slime","plant","fly","shadow","adamantine","skeleton",8;"") - H.update_body() - else - return - - for (var/obj/effect/proc_holder/spell/S in user.spell_list) - new_mob.spell_list += new S.type - - new_mob.a_intent = "harm" - if(user.mind) - user.mind.transfer_to(new_mob) - else - new_mob.key = user.key - - new_mob << "Your form morphs into that of a [randomize]." - - del(user) - return new_mob + ..() //because the user mob ceases to exists by the time wabbajack fully resolves + wabbajack(user) charges-- - ..() /obj/item/weapon/gun/magic/wand/teleport name = "wand of teleportation" @@ -173,27 +104,10 @@ max_charges = 10 //10, 5, 5, 4 /obj/item/weapon/gun/magic/wand/teleport/zap_self(mob/living/user as mob) - var/list/turfs = new/list() - var/inner_tele_radius = 0 - var/outer_tele_radius = 6 - for(var/turf/T in range(user,outer_tele_radius)) - if(T in range(user,inner_tele_radius)) continue - if(T.x>world.maxx-outer_tele_radius || T.xworld.maxy-outer_tele_radius || T.yworld.maxx-outer_tele_radius || T.xworld.maxy-outer_tele_radius || T.yYour form morphs into that of a [randomize]." + /*var/alien_caste = pick("Hunter","Sentinel","Drone","Larva") + switch(alien_caste) + if("Hunter") new_mob = new /mob/living/carbon/alien/humanoid/hunter(M.loc) + if("Sentinel") new_mob = new /mob/living/carbon/alien/humanoid/sentinel(M.loc) + if("Drone") new_mob = new /mob/living/carbon/alien/humanoid/drone(M.loc) + else new_mob = new /mob/living/carbon/alien/larva(M.loc) + new_mob.universal_speak = 1*/ + if("animal") + var/animal = pick("parrot","corgi","crab","pug","cat","carp","bear","mushroom","tomato","mouse","chicken","cow","lizard","chick") + switch(animal) + if("parrot") new_mob = new /mob/living/simple_animal/parrot(M.loc) + if("corgi") new_mob = new /mob/living/simple_animal/corgi(M.loc) + if("crab") new_mob = new /mob/living/simple_animal/crab(M.loc) + if("pug") new_mob = new /mob/living/simple_animal/pug(M.loc) + if("cat") new_mob = new /mob/living/simple_animal/cat(M.loc) + if("carp") new_mob = new /mob/living/simple_animal/hostile/carp(M.loc) + if("bear") new_mob = new /mob/living/simple_animal/hostile/bear(M.loc) + if("mushroom") new_mob = new /mob/living/simple_animal/mushroom(M.loc) + if("tomato") new_mob = new /mob/living/simple_animal/tomato(M.loc) + if("mouse") new_mob = new /mob/living/simple_animal/mouse(M.loc) + if("chicken") new_mob = new /mob/living/simple_animal/chicken(M.loc) + if("cow") new_mob = new /mob/living/simple_animal/cow(M.loc) + if("lizard") new_mob = new /mob/living/simple_animal/lizard(M.loc) + else new_mob = new /mob/living/simple_animal/chick(M.loc) + new_mob.universal_speak = 1 + if("human") + new_mob = new /mob/living/carbon/human(M.loc) - del(M) - return new_mob + var/datum/preferences/A = new() //Randomize appearance for the human + A.copy_to(new_mob) + + var/mob/living/carbon/human/H = new_mob + ready_dna(H) + if(H.dna) + H.dna.mutantrace = pick("lizard","golem","slime","plant","fly","shadow","adamantine","skeleton",8;"") + H.update_body() + else + return + + for (var/obj/effect/proc_holder/spell/S in M.spell_list) + new_mob.spell_list += new S.type + + new_mob.a_intent = "harm" + if(M.mind) + M.mind.transfer_to(new_mob) + else + new_mob.key = M.key + + new_mob << "Your form morphs into that of a [randomize]." + + del(M) + return new_mob /obj/item/projectile/magic/animate name = "bolt of animation"