ID:143576
 
Code:


Problem description:



hi uhh i made a code andd i want it to determin how much damage it hits on the other person due to how much power the mob has i did the code and it seemed to work but like it keeps giving run time error here is the code


Bump(mob/M)
var/damage =usr.power
M.Hp -= damage
M:deathcheck()



it worked but it gave me a run time error saying

runtime error: Cannot read 0.power
proc name: Bump (/obj/projectile/Bump)
usr: 0
src: Kurosaki power (/obj/projectile/Kurosaki_power)
call stack:
Kurosaki power (/obj/projectile/Kurosaki_power): Bump(the mob (/mob))
Kurosaki power (/obj/projectile/Kurosaki_power): Move(the grass (6,102,2) (/turf/grass), 1)



can anyone help me?its sorta like every time it bumps into something the runtime error comes up i need some help plz


Try showing your whole code. It seems like what's bumping the mob is a obj, so you need to define a obj var.

obj/var/power

obj/projectile/Kurosaki_power
power=1000

Once the obj bumps the player you'd do, var/damage =src.power
In response to Crunched
omg now it says


runtime error: Cannot read 0.power
proc name: Bump (/obj/projectile/Bump)
In response to Agrey123
Show the whole code please, it's kind of hard guessing what you have done.
In response to Crunched
obj/projectile
icon = 'projectiles.dmi'
density = 1
var
delay = 2

length=20
dmg=2
splash
mob/owner
New(_loc,mob/_owner)

if(_owner)
src.dir = _owner.dir
if(!src.loc) src.loc = get_step(_owner,_owner.dir)
src.owner = _owner
Move()
src.length--
if(!src.length) del src
return ..()
Bump(mob/M)
var/damage = usr.Str - M.Def
M.Hp -= damage
M:deathcheck()
if(ismob(M)) //if O is a mob...
//O.TakeDamage(src.damage,src.owner) //if you have some custom take-damage proc
//O:HP = max(O:HP-src.dmg,0)
//O:DeathCheck()
viewers(M) << "[src.owner] has hit [M:name] with \his [src]!"
else if(isobj(M)) del M //you may not want this :D
else if(isturf(M)) ;//overlay it to be exploded, or whatever
/*var/image/I = image('effects.dmi',"rubble")
O.overlays += I
spawn(100) if(O) O.overlays -= I //remove overlay after some time
*/
//if(src.splash) Explosion(src.loc,src.splash) //if it has a splash, make an explosion (an explosion proc is not included here)
del src

In response to Agrey123
Agrey123 wrote:
> obj/projectile
> icon = 'projectiles.dmi'
> density = 1
> var
> delay = 2
>
> length=20
> dmg=2
> splash
> mob/owner
> New(_loc,mob/_owner)
>
> if(_owner)
> src.dir = _owner.dir
> if(!src.loc) src.loc = get_step(_owner,_owner.dir)
> src.owner = _owner
> Move()
> src.length--
> if(!src.length) del src
> return ..()
> Bump(mob/M)
> var/damage = usr.Str - M.Def
> M.Hp -= damage
> M:deathcheck()
> if(ismob(M)) //if O is a mob...
> //O.TakeDamage(src.damage,src.owner) //if you have some custom take-damage proc
> //O:HP = max(O:HP-src.dmg,0)
> //O:DeathCheck()
> viewers(M) << "[src.owner] has hit [M:name] with \his [src]!"
> else if(isobj(M)) del M //you may not want this :D
> else if(isturf(M)) ;//overlay it to be exploded, or whatever
> /*var/image/I = image('effects.dmi',"rubble")
> O.overlays += I
> spawn(100) if(O) O.overlays -= I //remove overlay after some time
> */

> //if(src.splash) Explosion(src.loc,src.splash) //if it has a splash, make an explosion (an explosion proc is not included here)
> del src

One thing I saw was: var/damage = usr.Str - M.Def

You're trying to get the users strength, but the problem is that there is no user. You should maybe create a mob/var/Str and a obj/var/Str, make the projectile's owner = usr.key when the bullet is shot, then once it bumps it can search for the bullets owner.

for(var/mob/A in world) if(src.owner==A.key) src.str=A.str

then

var/damage = src.Str - M.Def

In response to Crunched
dude i have NO IDEA what u just said can u mind just coding it into my code i sent u
In response to Agrey123
Agrey123 wrote:
dude i have NO IDEA what u just said can u mind just coding it into my code i sent u

PL0x
In response to Agrey123
Ok, here's what you do:

1) Find the folder with your game in it.
2) Press the "Delete" key, answer "Yes".
3) Empty the recycle bin (it's the desktop, right click it)
4) Go to the BYOND hub
5) Find a nice DBZ, Naruto, or Bleach game (rip).
6) Enjoy
Its because you're using 'usr' in a proc like everyone here has said not to do a million times. Even the DM Reference says it. Go read the DM Reference under 'usr'.

http://developer.byond.com/docs/ref/info.html#/proc/var/usr
In response to PiRSquared
this is what u do..
1)take off ur cloths
2)BEND DOWN
3)enjoy