ID:139050
 
In addition to my previous thread: http://www.byond.com/developer/forum/?id=785914#785903

I have a spell "thunderbolt" which when used creates an overlay over the target (in the shape of a thunder bolt!) plays an animation (striking the ground) then is deleted.

Problem description:
I'm having trouble overlaying my spells onto turfs. Overlaying them onto mobs and objs create no problems, however when I try to use a lightning bolt type spell no animation is played, just the last frame. The icon is 50x200 pixels and has 8 frames in the animation. It is set to loop once. When I set it to loop infinately, the animation plays. I've tried to use flick but when flick is used nothing overlays!
var/target = caster.lasttarget//a turf using turf/MouseEntered()
var/tmp/obj/attack/ThunderBolt/effect = new()

target:overlays += effect
sleep(10)
target:overlays -= effect


attack.Move(target) does what I want, it displays an object at the desired location however randomly, when I do use the spell the icon appears in completely random grid cells in my inventory or belt.
var/tmp/obj/attack/ThunderBolt/effect = new()
effect.Move(target)




I guess when you're doing <small>A.Move( B )</small>, you're locating the bolt in their contents.

Clicking a turf and creating the projectile would be done in <small>client/Click( turf/turf )</small>:

client

Click( turf/turf )

/* cast the spell. */ new/obj/projectiles/lightning_bolt( turf , src )

obj

projectiles

var

/* special effects. */ flick_time = 0

mob/owner

/* modify New(). */ New( position , caster )

..()

loc = position

owner = caster

/* check for lightning bolts. */ if( istype ( src , /obj/projectiles/lightning_bolt ) )

flick( "animation" , flick_time )

spawn( /* if you want to delete it after a set flick time do this: */ flick_time ) del src

lightning_bolt

flick_time = 8
In response to Neimo
Thank you very much! I've added New(position,caster) under the object and now it works without disturbing my grids! :D
In response to Farkas
I'm having the same problem again when I create my "mass" spells.

I've added in a mass healing spell to my game.

turf
MouseEntered()
..()
usr.lasttarget = src
mob
MouseEntered()
..()
usr.lasttarget = src
verb
MassHealing()
Cast_Spell(usr,"MassHealing")
proc
Cast_Spell(var/mob/caster,var/obj/attack/atk)
if(caster.casting)
return 0
caster.casting = 1
var/target = caster.lasttarget
var/obj/atktype = text2path("/obj/attack/[atk]")
atk = new atktype(target,caster)
if(atk.name == "MassHealing")
//CREATE THE ADDITIONAL HEAL OBJS AROUND THE TARGET
Mass_Spell(target,/obj/attack/MassHealing)
if(caster.minmp >= atk.mpcost)
flick("spell",caster)
caster.minmp -= atk.mpcost
caster.HPMP_Levels()
else
caster << "Not Enough MP"
spawn(15)
caster.casting = 0

Mass_Spell(var/target,var/obj/attack/atk)
//TARGET IS MOB OR TURF
var/x = target:x as num
var/y = target:y as num
var/z = target:z as num
//USING LOCATE IT'S SUCCESSFUL HOWEVER
//ALSO CREATES THE OBJ IN MY GRID(S)???
new atk(locate(x,y+1,z))
new atk(locate(x,y-1,z))
new atk(locate(x-1,y,z))
new atk(locate(x+1,y,z))
//USING A TEXT STRING AS A TEST TO FIX THE LOCATE() PROBS
//HOWEVER TO NO AVAIL. DOES NOT WORK.
new atk("[x+1],[y-1],[z]")
new atk("[x-1],[y-1],[z]")
new atk("[x-1],[y+1],[z]")
new atk("[x+1],[y+1],[z]")

Attack(var/mob/target,var/obj/attack/spell)
//ATTACK PROC
if(spell.creator != target)
target.minhp -= spell.dmg
if(target.minhp <= 0)
target.minhp = 0
if(target.minhp >= target.maxhp)
target.minhp = target.maxhp
target.HPMP_Levels()
obj
attack
New(target,mob/caster)
..()
if(!target)
return
if(istype(target,/mob))
loc = target:loc
else
loc = target

for(var/mob/M in view(22,caster))
if(M == target||M.loc == target)
M.Attack(M,src)
spawn(15) del src


When using new atk(locate(x,y+1,z)), the obj is created the mob is healed however the obj also appears in my belt or bag grids. I had this problem before and since I added the obj/New() code it disapeared however now I've added the Mass_Spell() proc the objs appear on the map and BACK in my grid controls!?!?

Can someone please tell me where I'm failing?!

Thank you :D