Object Spell System v1.12

Added trigger spell, which basically activates two or more spells at once. Used that to fix fireball and blind to what they were pre-change (not code-wise, but the same for the end user).
Projectiles aren't limited to default spells now.
All spells now use a user argument (=usr by default) instead of usr.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@1474 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
uporotiy
2011-04-19 20:03:17 +00:00
parent 9da4bf5c63
commit 4c73d22458
11 changed files with 140 additions and 130 deletions
+25 -25
View File
@@ -28,7 +28,7 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
var/smoke_spread = 0 //1 - harmless, 2 - harmful
var/smoke_amt = 0 //cropped at 10
/obj/spell/proc/cast_check() //checks if the spell can be cast based on its settings
/obj/spell/proc/cast_check(mob/user = usr) //checks if the spell can be cast based on its settings
if(!(src in usr.spell_list))
usr << "\red You shouldn't have this spell! Something's wrong."
@@ -67,7 +67,7 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
return 1
/obj/spell/proc/invocation() //spelling the spell out and setting it on recharge/reducing charges amount
/obj/spell/proc/invocation(mob/user = usr) //spelling the spell out and setting it on recharge/reducing charges amount
switch(invocation_type)
if("shout")
@@ -92,7 +92,7 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
choose_targets()
/obj/spell/proc/choose_targets() //depends on subtype - /targeted or /aoe_turf
/obj/spell/proc/choose_targets(mob/user = usr) //depends on subtype - /targeted or /aoe_turf
return
/obj/spell/proc/start_recharge()
@@ -100,11 +100,11 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
sleep(1)
charge_counter++
/obj/spell/proc/perform(list/targets)
/obj/spell/proc/perform(list/targets, recharge = 1) //if recharge is started is important for the trigger spells
before_cast(targets)
invocation()
spawn(0)
if(charge_type == "recharge")
if(charge_type == "recharge" && recharge)
start_recharge()
cast(targets)
after_cast(targets)
@@ -164,31 +164,31 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
/obj/spell/targeted //can mean aoe for mobs (limited/unlimited number) or one target mob
var/max_targets = 1 //leave 0 for unlimited targets in range, 1 for one selectable target in range, more for limited number of casts (can all target one guy, depends on target_ignore_prev) in range
var/target_ignore_prev = 1 //only important if max_targets > 1, affects if the spell can be cast multiple times at one person from one cast
var/include_usr = 0 //if it includes usr in the target list
var/include_user = 0 //if it includes usr in the target list
/obj/spell/aoe_turf //affects all turfs in view or range (depends)
var/inner_radius = -1 //for all your ring spell needs
/obj/spell/targeted/choose_targets()
/obj/spell/targeted/choose_targets(mob/user = usr)
var/list/targets = list()
switch(selection_type)
if("range")
switch(max_targets)
if(0)
for(var/mob/target in range(usr,range))
for(var/mob/target in range(user,range))
targets += target
if(1)
if(range < 0)
targets += usr
targets += user
else
var/possible_targets = range(usr,range)
if(!include_usr && usr in possible_targets)
possible_targets -= usr
var/possible_targets = range(user,range)
if(!include_user && user in possible_targets)
possible_targets -= user
targets += input("Choose the target for the spell.", "Targeting") as mob in possible_targets
else
var/list/possible_targets = list()
for(var/mob/target in range(usr,range))
for(var/mob/target in range(user,range))
possible_targets += target
for(var/i=1,i<=max_targets,i++)
if(!possible_targets.len)
@@ -202,15 +202,15 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
if("view")
switch(max_targets)
if(0)
for(var/mob/target in view(usr,range))
for(var/mob/target in view(user,range))
targets += target
if(1)
if(range < 0)
targets += usr
targets += user
else
var/possible_targets = view(usr,range)
if(!include_usr && usr in possible_targets)
possible_targets -= usr
var/possible_targets = view(user,range)
if(!include_user && user in possible_targets)
possible_targets -= user
targets += input("Choose the target for the spell.", "Targeting") as mob in possible_targets
else
var/list/possible_targets = list()
@@ -226,8 +226,8 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
else
targets += pick(possible_targets)
if(!include_usr && (usr in targets))
targets -= usr
if(!include_user && (user in targets))
targets -= user
if(!targets.len) //doesn't waste the spell
revert_cast()
@@ -237,17 +237,17 @@ var/list/spells = typesof(/obj/spell) //needed for the badmin verb for now
return
/obj/spell/aoe_turf/choose_targets()
/obj/spell/aoe_turf/choose_targets(mob/user = usr)
var/list/targets = list()
switch(selection_type)
if("range")
for(var/turf/target in range(usr,range))
if(!(target in range(usr,inner_radius)))
for(var/turf/target in range(user,range))
if(!(target in range(user,inner_radius)))
targets += target
if("view")
for(var/turf/target in view(usr,range))
if(!(target in view(usr,inner_radius)))
for(var/turf/target in view(user,range))
if(!(target in view(user,inner_radius)))
targets += target
if(!targets.len) //doesn't waste the spell
+2 -2
View File
@@ -5,14 +5,14 @@
var/randomise_selection = 0 //if it lets the usr choose the teleport loc or picks it from the list
var/invocation_area = 1 //if the invocation appends the selected area
/obj/spell/targeted/area_teleport/perform(list/targets)
/obj/spell/targeted/area_teleport/perform(list/targets, recharge = 1)
var/thearea = before_cast(targets)
if(!thearea)
revert_cast()
return
invocation(thearea)
spawn(0)
if(charge_type == "recharge")
if(charge_type == "recharge" && recharge)
start_recharge()
cast(targets,thearea)
after_cast(targets)
-46
View File
@@ -1,46 +0,0 @@
/obj/spell/blind
name = "Blind"
desc = "This spell temporarly blinds a single person and does not require wizard garb."
school = "transmutation"
charge_max = 300
clothes_req = 0
invocation = "STI KALY"
invocation_type = "whisper"
message = "\blue Your eyes cry out in pain!"
var/blind_time = 300 //in deciseconds
var/eye_blind = 10 //I have no idea what these two do
var/eye_blurry = 20 //but eh, they're in the code
//I would add the ability to choose different disabilities (do ho ho), but I have no idea which bit corresponds to which disability
/obj/spell/blind/Click()
..()
if(!cast_check())
return
var/mob/M = input("Choose whom to blind", "ABRAKADABRA") as mob in oview(usr,range)
if(!M)
return
invocation()
var/obj/overlay/B = new /obj/overlay( M.loc )
B.icon_state = "blspell"
B.icon = 'wizard.dmi'
B.name = "spell"
B.anchored = 1
B.density = 0
B.layer = 4
M.canmove = 0
spawn(5)
del(B)
M.canmove = 1
M << text("[message]")
M.disabilities |= 1
spawn(blind_time)
M.disabilities &= ~1
M.eye_blind = eye_blind
M.eye_blurry = eye_blurry
return
+1 -1
View File
@@ -8,7 +8,7 @@
invocation = "none"
invocation_type = "none"
range = -1
include_usr = 1
include_user = 1
var/jaunt_duration = 50 //in deciseconds
+8 -2
View File
@@ -1,6 +1,6 @@
/obj/spell/targeted/inflict_handler
name = "Inflict Handler"
desc = "This spell destroys/damages/heals and/or weakens/stuns the target."
desc = "This spell blinds and/or destroys/damages/heals and/or weakens/stuns the target."
var/amt_weaken = 0
var/amt_paralysis = 0 //stun
@@ -11,6 +11,9 @@
var/amt_dam_oxy = 0
var/amt_dam_tox = 0
var/amt_eye_blind = 0
var/amt_eye_blurry = 0
var/destroys = "none" //can be "none", "gib" or "disintegrate"
/obj/spell/targeted/inflict_handler/cast(list/targets)
@@ -41,4 +44,7 @@
target.oxyloss += amt_dam_oxy
//disabling
target.weakened += amt_weaken
target.paralysis += amt_paralysis
target.paralysis += amt_paralysis
target.eye_blind += amt_eye_blind
target.eye_blurry += amt_eye_blurry
+8 -8
View File
@@ -17,35 +17,35 @@
var/paralysis_amount_caster = 20 //how much the caster is paralysed for after the spell
var/paralysis_amount_victim = 20 //how much the victim is paralysed for after the spell
/obj/spell/targeted/mind_transfer/cast(list/targets) //magnets, so mostly hardcoded
/obj/spell/targeted/mind_transfer/cast(list/targets,mob/user = usr) //magnets, so mostly hardcoded
if(!targets.len)
usr << "No mind found"
user << "No mind found"
return
if(targets.len > 1)
usr << "Too many minds! You're not a hive damnit!"
user << "Too many minds! You're not a hive damnit!"
return
var/mob/target = targets[1]
if(!target.client || !target.mind)
usr << "They appear to be brain-dead."
user << "They appear to be brain-dead."
return
if(target.mind.special_role in protected_roles)
usr << "Their mind is resisting your spell."
user << "Their mind is resisting your spell."
return
if(!target.type in compatible_mobs)
usr << "Their mind isn't compatible with yours."
user << "Their mind isn't compatible with yours."
return
if(target.stat == 2)
usr << "You didn't study necromancy back at the Space Wizard Federation academy."
user << "You didn't study necromancy back at the Space Wizard Federation academy."
return
var/mob/victim = target //mostly copypastaed, I have little idea how this works
var/mob/caster = usr
var/mob/caster = user
//losing spells
if(usr.spell_list.len)
+8 -3
View File
@@ -21,12 +21,17 @@
var/proj_lifespan = 15 //in deciseconds * proj_step_delay
var/proj_step_delay = 1 //lower = faster
/obj/spell/targeted/projectile/cast(list/targets)
/obj/spell/targeted/projectile/cast(list/targets, mob/user = usr)
for(var/mob/target in targets)
spawn(0)
var/projectile_type = text2path(proj_type)
var/obj/spell/targeted/projectile = new projectile_type(usr)
var/obj/spell/targeted/projectile
if(istext(proj_type))
var/projectile_type = text2path(proj_type)
projectile = new projectile_type(user)
if(istype(proj_type,/obj/spell))
projectile = new /obj/spell/targeted/trigger(user)
projectile:linked_spells += proj_type
projectile.icon = proj_icon
projectile.icon_state = proj_icon_state
projectile.dir = get_dir(target,projectile)
+28
View File
@@ -0,0 +1,28 @@
/obj/spell/targeted/trigger
name = "Trigger"
desc = "This spell triggers another spell or a few."
var/list/linked_spells = list() //those are just referenced by the trigger spell and are unaffected by it directly
var/list/starting_spells = list() //those are added on New() to contents from default spells and are deleted when the trigger spell is deleted to prevent memory leaks
/obj/spell/targeted/trigger/New()
..()
for(var/spell in starting_spells)
var/spell_to_add = text2path(spell)
new spell_to_add(src) //should result in adding to contents, needs testing
/obj/spell/targeted/trigger/Del()
for(var/spell in contents)
del(spell)
..()
/obj/spell/targeted/trigger/cast(list/targets)
for(var/mob/target in targets)
for(var/obj/spell/spell in contents)
spell.perform(list(target),0)
for(var/obj/spell/spell in linked_spells)
spell.perform(list(target),0)
return
+58 -41
View File
@@ -1,24 +1,3 @@
/obj/spell/targeted/projectile/fireball
name = "Fireball"
desc = "This spell fires a fireball at a target and does not require wizard garb."
school = "evocation"
charge_max = 200
clothes_req = 0
invocation = "ONI SOMA"
invocation_type = "shout"
proj_icon_state = "fireball"
proj_name = "a fireball"
proj_lingering = 1
proj_type = "/obj/spell/targeted/explosion/fireball"
/obj/spell/targeted/explosion/fireball
ex_severe = -1
ex_heavy = -1
ex_light = 3
ex_flash = 5
/obj/spell/targeted/projectile/magic_missile
name = "Magic Missile"
desc = "This spell fires several, slow moving, magic projectiles at nearby targets."
@@ -48,20 +27,6 @@
amt_weaken = 5
amt_dam_fire = 10
/obj/spell/targeted/genetic/blind //doesn't work properly
name = "Blind"
desc = "This spell temporarily blinds a single person and does not require wizard garb."
school = "transmutation"
charge_max = 300
clothes_req = 0
invocation = "STI KALY"
invocation_type = "whisper"
message = "\blue Your eyes cry out in pain!"
disabilities = 1
duration = 300
/obj/spell/targeted/genetic/mutate
name = "Mutate"
desc = "This spell causes you to turn into a hulk and gain telekinesis for a short while."
@@ -73,7 +38,7 @@
invocation_type = "shout"
message = "\blue You feel strong! Your mind expands!"
range = -1
include_usr = 1
include_user = 1
mutations = 9
duration = 300
@@ -104,7 +69,7 @@
invocation = "none"
invocation_type = "none"
range = -1
include_usr = 1
include_user = 1
smoke_spread = 2
smoke_amt = 10
@@ -117,7 +82,7 @@
invocation = "NEC CANTIO"
invocation_type = "shout"
range = -1
include_usr = 1
include_user = 1
emp_heavy = 5
emp_light = 7
@@ -132,7 +97,7 @@
invocation = "none"
invocation_type = "none"
range = -1
include_usr = 1
include_user = 1
smoke_spread = 1
smoke_amt = 10
@@ -150,7 +115,7 @@
invocation = "SCYAR NILA"
invocation_type = "shout"
range = -1
include_usr = 1
include_user = 1
smoke_spread = 1
smoke_amt = 5
@@ -180,4 +145,56 @@
invocation_type = "shout"
range = 1
summon_type = list("/obj/livestock/spesscarp/elite")
summon_type = list("/obj/livestock/spesscarp/elite")
/obj/spell/targeted/trigger/blind
name = "Blind"
desc = "This spell temporarily blinds a single person and does not require wizard garb."
school = "transmutation"
charge_max = 300
clothes_req = 0
invocation = "STI KALY"
invocation_type = "whisper"
message = "\blue Your eyes cry out in pain!"
starting_spells = list("/obj/spell/targeted/inflict_handler/blind","/obj/spell/targeted/genetic/blind")
/obj/spell/targeted/inflict_handler/blind
amt_eye_blind = 10
amt_eye_blurry = 20
/obj/spell/targeted/genetic/blind
disabilities = 1
duration = 300
/obj/spell/targeted/projectile/fireball
name = "Fireball"
desc = "This spell fires a fireball at a target and does not require wizard garb."
school = "evocation"
charge_max = 200
clothes_req = 0
invocation = "ONI SOMA"
invocation_type = "shout"
proj_icon_state = "fireball"
proj_name = "a fireball"
proj_lingering = 1
proj_type = "/obj/spell/targeted/trigger/fireball"
proj_lifespan = 200
proj_step_delay = 1
/obj/spell/targeted/trigger/fireball
starting_spells = list("/obj/spell/targeted/inflict_handler/fireball","/obj/spell/targeted/explosion/fireball")
/obj/spell/targeted/inflict_handler/fireball
amt_dam_brute = 20
amt_dam_fire = 25
/obj/spell/targeted/explosion/fireball
ex_severe = -1
ex_heavy = -1
ex_light = 2
ex_flash = 5