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
This commit is contained in:
Incoming
2013-12-10 01:04:16 -05:00
parent 51d12a7512
commit b7b05d53ec
5 changed files with 122 additions and 225 deletions
+2 -2
View File
@@ -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()
..()
+21 -107
View File
@@ -29,6 +29,20 @@
user << "<span class='warning'>The [name] whizzles quietly.<span>"
..()
/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 << "<span class='warning'>The [name] whizzles quietly.<span>"
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 << "<B>Your form morphs into that of a [randomize].</B>"
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.x<outer_tele_radius) continue
if(T.y>world.maxy-outer_tele_radius || T.y<outer_tele_radius) continue
turfs += T
if(!turfs.len)
var/list/turfs_to_pick_from = list()
for(var/turf/T in orange(user,outer_tele_radius))
if(!(T in orange(user,inner_tele_radius)))
turfs_to_pick_from += T
turfs += pick(/turf in turfs_to_pick_from)
var/turf/picked = pick(turfs)
if(!picked || !isturf(picked))
return
user.loc = picked
do_teleport(user, user, 10)
var/datum/effect/effect/system/harmless_smoke_spread/smoke = new /datum/effect/effect/system/harmless_smoke_spread()
smoke.set_up(10, 0, user.loc)
smoke.start()
charges--
..()
+96 -114
View File
@@ -76,28 +76,9 @@
/obj/item/projectile/magic/teleport/on_hit(var/mob/target)
if(isturf(target))
return
var/list/turfs = new/list()
for(var/turf/T in range(target,outer_tele_radius))
if(T in range(target,inner_tele_radius)) continue
if(T.x>world.maxx-outer_tele_radius || T.x<outer_tele_radius) continue
if(T.y>world.maxy-outer_tele_radius || T.y<outer_tele_radius) continue
turfs += T
if(!turfs.len)
var/list/turfs_to_pick_from = list()
for(var/turf/T in orange(target,outer_tele_radius))
if(!(T in orange(target,inner_tele_radius)))
turfs_to_pick_from += T
turfs += pick(/turf in turfs_to_pick_from)
var/turf/picked = pick(turfs)
if(!picked || !isturf(picked))
return
target.loc = picked
do_teleport(target, target, 10)
var/datum/effect/effect/system/harmless_smoke_spread/smoke = new /datum/effect/effect/system/harmless_smoke_spread()
smoke.set_up(10, 0, picked)
smoke.set_up(10, 0, target.loc)
smoke.start()
/obj/item/projectile/magic/door
@@ -130,105 +111,106 @@
/obj/item/projectile/magic/change/on_hit(var/atom/change)
wabbajack(change)
/obj/item/projectile/magic/change/proc/wabbajack (mob/M as mob in living_mob_list)
if(istype(M, /mob/living) && M.stat != DEAD)
if(M.monkeyizing) return
M.monkeyizing = 1
M.canmove = 0
M.icon = null
M.overlays.Cut()
M.invisibility = 101
proc/wabbajack(mob/living/M)
if(istype(M))
if(istype(M, /mob/living) && M.stat != DEAD)
if(M.monkeyizing) return
M.monkeyizing = 1
M.canmove = 0
M.icon = null
M.overlays.Cut()
M.invisibility = 101
if(istype(M, /mob/living/silicon/robot))
var/mob/living/silicon/robot/Robot = M
if(Robot.mmi) del(Robot.mmi)
else
for(var/obj/item/W in M)
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 = M.loc
W.dropped(M)
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(M.loc)
new_mob.universal_speak = 1
if("robot")
new_mob = new /mob/living/silicon/robot(M.loc)
new_mob.gender = M.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(M) //Does not transfer key/client.
if("slime")
if(prob(50)) new_mob = new /mob/living/carbon/slime/adult(M.loc)
else new_mob = new /mob/living/carbon/slime(M.loc)
new_mob.universal_speak = 1
if("xeno")
if(prob(50))
new_mob = new /mob/living/carbon/alien/humanoid/hunter(M.loc)
else
new_mob = new /mob/living/carbon/alien/humanoid/sentinel(M.loc)
new_mob.universal_speak = 1
/*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)
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()
if(istype(M, /mob/living/silicon/robot))
var/mob/living/silicon/robot/Robot = M
if(Robot.mmi) del(Robot.mmi)
else
return
for(var/obj/item/W in M)
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 = M.loc
W.dropped(M)
for (var/obj/effect/proc_holder/spell/S in M.spell_list)
new_mob.spell_list += new S.type
var/mob/living/new_mob
new_mob.a_intent = "harm"
if(M.mind)
M.mind.transfer_to(new_mob)
else
new_mob.key = M.key
var/randomize = pick("monkey","robot","slime","xeno","human","animal")
switch(randomize)
if("monkey")
new_mob = new /mob/living/carbon/monkey(M.loc)
new_mob.universal_speak = 1
if("robot")
new_mob = new /mob/living/silicon/robot(M.loc)
new_mob.gender = M.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(M) //Does not transfer key/client.
if("slime")
if(prob(50)) new_mob = new /mob/living/carbon/slime/adult(M.loc)
else new_mob = new /mob/living/carbon/slime(M.loc)
new_mob.universal_speak = 1
if("xeno")
if(prob(50))
new_mob = new /mob/living/carbon/alien/humanoid/hunter(M.loc)
else
new_mob = new /mob/living/carbon/alien/humanoid/sentinel(M.loc)
new_mob.universal_speak = 1
new_mob << "<B>Your form morphs into that of a [randomize].</B>"
/*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 << "<B>Your form morphs into that of a [randomize].</B>"
del(M)
return new_mob
/obj/item/projectile/magic/animate
name = "bolt of animation"