ID:262766
 
Code:
    Bump(mob/M)
if(M.type == /mob)
M.powerlevel -= usr.powerlevel
if(src.owner)
M.Death(src.owner)
else
M.Death()


Problem description:Well my beam system works and all but when i target someone it doesnt do damage nor does it kill them.I have tried many ways to solve it but all seem not to work.

I haven't used the bump function alot in my experience but it is possible that you are using usr and src improperly, I have done that before a decent number of times. What exactly is the src you are refering to? If you are still having problems with it let me know, I might be able to help.
Fire Dynasty wrote:
Code:
>   Bump(mob/M)
> if(M.type == /mob)
> M.powerlevel -= usr.powerlevel
> if(src.owner)
> M.Death(src.owner)
> else
> M.Death()
>


Eww.. Usr abuse and using type to check wether M is a mob..

    Bump(mob/M)
if(ismob(M))
M.powerlevel -= src.powerlevel
if(src.owner) M.Death(src.owner)
else M.Death()


That's much better..

O-matic
In response to O-matic
Yo O-matic thanks for the reply but i get this error:
Beam.dm:121:error: proc definition not allowed inside another proc

The Lost DragonBalls.dmb - 1 error, 0 warnings (double-click on an error to jump to it)
In response to Fire Dynasty
What's line 121?

O-matic

This part is redundant:
            if(src.owner)
M.Death(src.owner)
else
M.Death()

Instead, just use M.Death(owner). If owner is null, then you get the same effect as calling M.Death() with no argument.

Lummox JR
In response to Fire Dynasty
probably an indentation error. Check your indentation on or around that line.
In response to Lummox JR
Lummox JR wrote:
This part is redundant:
            if(src.owner)
> M.Death(src.owner)
> else
> M.Death()

Instead, just use M.Death(owner). If owner is null, then you get the same effect as calling M.Death() with no argument.

Lummox JR

Just in case Fire Dynasty didn't understand: Add an if() statement in your Death() proc to check wether M exists(just like you did in your Bump() proc). . This will prevent you from runtime errors. Or you could look for another suitable solution... :/

O-matic
In response to O-matic

>     Bump(mob/M)
> if(ismob(M))
> M.powerlevel -= src.powerlevel
> if(src.owner) M.Death(src.owner)
> else M.Death()
>

That's much better..

O-matic

O-matic i used your code it seemed to work when i was compiling but when i used my beam in the game i got a lot of run time errors.

proc name: Bump (/obj/straightbeam/Bump)
source file: Beam.dm,125
runtime error: undefined proc or verb /turf/Turfs/hard_parth/Death().
In response to Fire Dynasty
    Bump(mob/M)
if(istype(M, /mob/))
M.powerlevel -= src.powerlevel
if(src.owner) M.Death(src.owner)
else M.Death()
In response to Mysame
Mysame wrote:
>     Bump(mob/M)
> if(istype(M, /mob/))
> M.powerlevel -= src.powerlevel
> if(src.owner) M.Death(src.owner)
> else M.Death()


Msame i get the same error with that code too when i use it
In response to Fire Dynasty
Seems like you're trying to call the death() verb on a turf.. Mhmz.

Try to call it like this:
Bump()

instead of Bump(mob/M), since you already have the istype :|
In response to Mysame
Euhm, that won't help.. :/ Why did you replace ismob() with istype(). In the way you're using it it'll do exact the same...

And dynasty, in the future please show the lines the runtime errors link you to... >:/

"<font color=red>proc name: Bump (/obj/straightbeam/Bump)
source file: Beam.dm,125
runtime error: undefined proc or verb /turf/Turfs/hard_parth/Death().</font>"

You need to how line 125, it isn't quite easy to help you with your problem if we don't know line 125..


O-matic
In response to O-matic
O-matic wrote:
Euhm, that won't help.. :/ Why did you replace ismob() with istype(). In the way you're using it it'll do exact the same...

And dynasty, in the future please show the lines the runtime errors link you to... >:/

"<font color=red>proc name: Bump (/obj/straightbeam/Bump)
source file: Beam.dm,125
runtime error: undefined proc or verb /turf/Turfs/hard_parth/Death().</font>"

You need to how line 125, it isn't quite easy to help you with your problem if we don't know line 125..


O-matic

The error line is
Bump(mob/M)
if(istype(M, /mob/))
M.powerlevel -= usr.powerlevel
if(src.owner) M.Death(src.owner)
------> else M.Death()
if(M.type == src.type)
del(M)
del(src)
del(src)