ID:145692
 
Code:
obj/spells
Flare
icon='Spells.dmi'
icon_state="fire"
layer=4
density=1
Bump(mob/M)
//here is the effects
if(M.client)//if it is a mob
world << "[usr.name]'s flare has burned [M] for 10 dmg!!"
M << "You have been hit by [usr.name]'s flare for 10 dmg!"
M.Health-=10
deathcheck(M)
del(src)


Problem description:
The src and usr variables are messed up, it has the usr as 0 and the src as flare. I dont knowhow to fix it.

its not messed just theres no usr
obj/spells
var
mob
caster = null // the player that cast the spell
Flare
icon='Spells.dmi'
icon_state="fire"
layer=4
density=1
Bump(mob/M)
//here is the effects
if(M.client)//if it is a mob
world << "[caster.name]'s flare has burned [M] for 10 dmg!!"
M << "You have been hit by [caster.name]'s flare for 10 dmg!"
M.Health-=10
caster.deathcheck(M)
del(src)

here we replaced usr with a var "caster" make sure to set the caster var up ^_^
They aren't messed up. That's what they should be.
In response to Zmadpeter
runtime error: Cannot read null.name
proc name: Bump (/obj/spells/Flare/Bump)
usr: 0
src: Flare (/obj/spells/Flare)
call stack:
Flare (/obj/spells/Flare): Bump(Fire Wizard (/mob/Fire_Wizard))

I get that error when I try to cast the spell and it hits a mob. Damage doesnt go through either.
In response to Drakiel
You need to set the caster variable when you create the fireball.
In response to Jp
Jp wrote:
You need to set the caster variable when you create the fireball.

what?? I just did exactly what madpeter put out, isnt that setting it?
In response to Drakiel
No, it isn't. Don't just copy the damned thing, THINK.
In response to Drakiel
No, the point of what Zmadpeter put wasn't for you just to copy into your game, but to rather understand what it does so you could implement it yourself. ZMP even told you that you need to remember to set the caster variable when the thing was created. >_>

Hiead
In response to Jp
I dont get it at all, were do I put up the var?
At login?
At my missile proc?
At the verb itself?
In response to Drakiel
THINK ABOUT IT.

How do you cast these spells - You use a verb, and that verb creates an object and makes it move. That object has a 'caster' variable that you need to set. You can't set it at login, because the object DOESN'T EXIST. I have no idea what you mean by 'My missile proc', but probably not there.
In response to Drakiel
How could it be login? The object doesn't even exist.

By missile proc, I HOPE you don't mean missile(). That proc is purely graphical and won't produce any Bump()s or anything.

I really wish you'd try thinking of a solution before asking. =/

Hiead
In response to Jp
mob/Fire_Wizard
icon='Players.dmi'
icon_state="fire wizard"
MaxHealth = 50
Health = 50
verb
Flare()
if(istype(usr.loc.loc,/area/no_spell)) {usr << "No casting spells in a no-spell area!"; return;} //In your spellcasting VERB
usr.projectile(new/obj/spells/Flare(usr.loc),usr.dir,5)

This is when the obj is created..
mob
proc
projectile(obj/projectile,var/dir,var/delay)
sleep(1)
walk(projectile,dir)
sleep(delay)
del(projectile)

Then it runs this proc, But i still dont know were caster is put up because you cant put ,caster = "[src.name]"
obj/spells
var
mob
caster = null

Flare
icon='Spells.dmi'
icon_state="fire"
layer=4
density=1
Bump(mob/M)
//here is the effects
if(M.client)//if it is a mob
world << "<b><font color=red>[caster.name]'s flare has burned [M] for 10 dmg!!"
M << "<b><font color=red>You have been hit by [caster.name]'s flare for 10 dmg!"
M.Health-=10
deathcheck(M)
if(istype(M,/mob))
world << "<b><font color=red>[caster.name]'s flare has burned [M] for 10 dmg!!"
M << "<b><font color=red>You have been hit by [caster.name]'s flare for 10 dmg!"
M.Health-=10
deathcheck(M)
del(src)

This is the object itself
In response to Drakiel
mob/var/obj/owner
mob/verb/Fireball()
var/obj/fireball/f = new
f.owner=usr
walk(f,usr.dir)

obj/fireball/Bump(mob/M)
if(istype(M))
M.hp--
M.deathcheck(src.owner)
In response to Mysame
That doesnt help me, your not defining F and I would like to stick with my projectile coding
In response to Drakiel
It's an example code :|
In response to Mysame
Pls can anyone help me, I cant decrease my usr's mana or display the right message because of this problem because the usr and src is the object...
In response to Zmadpeter
That's still wrong. (Surprise. >:|)

deathcheck() is exactly backwards here. That should be M.deathcheck(caster), and the deathcheck() proc accordingly should be operating on src (the victim), where the argument is the killer.

Lummox JR
In response to Lummox JR
Mine's alright :'(
In response to Mysame
Mysame wrote:
Mine's alright :'(

Actually it's not. There's also only one right way to set up a projectile: Put everything in new() that you possibly can. The fireball should be setting the owner based on the argument it is given, and should start walking on its own.

Lummox JR
In response to Lummox JR
that makes no sense...in my head of course.
Page: 1 2