ID:143564
 
Code:
obj/addons/bomb
icon = 'explode.dmi'
icon_state="bomb"
name="Bomb Trap"
description="A nice handy trap. Attack based on hunter skill."
verb
Get()
set src in oview(1)
if(usr.bombskill==1)
view() << "[usr] disarms [src]"
src.name="Bomb Trap"
Move(usr)
else
usr.HP -= src.bomba
view() << "[src] deals [bomba] damage to [usr]"
src.icon_state="explode"
sleep(10)
usr:death_check()
del(src)
Drop()
if(usr.bombskill==0)
usr << "Maybe I should learn how to use these first."
return
else
src.bomba=usr.hunt
src.name="???"
src.loc = usr.loc
view() << "[usr] drops [src]."
Description()
usr << "[src.description]"


Problem description:
It is supposed to kill them but it kills them makes there health a negetive and bugs them! I am totally lost on this one... Please help!
Perhaps there's an issue in your death_check()...
Not to mention you probably shouldn't be using the ":" when you're calling it...
usr:death_check()
In response to PiRSquared
mob
var
xx=0
yy=0
zz=0
proc/death_check(mob/M as mob)//handles death
if(src.HP <= 0)
if(src.client)
src <<"[M] killed you!"
world<<"[src] has been killed by [M]."
new/obj/b/groupable/resources/Bar/Hazium_Crystal(rand(1,5),src.loc)
M.coins += 5
M << "You win 5 coins!"
src.loc = locate(43,11,1)
src.HP = src.MaxHP
src.hunger=0
if(M)
M <<"You killed [src]!"
M.kills += 1
else
src.hunger=0
src.HP = src.MaxHP
M.level_up()
src.loc = locate(xx,yy,zz)
src.dead = 1
sleep(M.delay)
M.attkdel = 0
sleep(300 - M.delay)
src.spawn_check()

I tried what you said and can't figure it out... Heres the death check proc
In response to Hellonagol
I'm not sure if this is causing the issue you're having but you have your proc defined as death_check(mob/M) and when you call it in your bomb information, you fail to to supply it with an arguement (The usr.death_check() <--- no arguement). You would either need to write a seperate death_check that handle either no arguement or one for an obj.
In response to Rifthaven
The only time he uses the argument is to add a kill count, so what you mentioned is completely unnecessary.

Arguments do not always have to be defined.
In response to GhostAnime
No, since he doesn't supply an argument for the mob the proc has nothing to use for M and will give a run-time error when it's trying to use M. Can't access M.coins when M is null.

So what you mentioned is completely unnecessary.
In response to Rifthaven
Look at what he placed in the procedure prior to using anything to M (such as adding the kill count):
if(M)

Which is a boolean type of checking to see if the value is TRUE (which is implied by DM if the value is not null, 0 (or FALSE) and "" ).

If M is not defined, the argument null is passed through. And since null is a FALSE value, whatever is under the if(M) does not happen.


Simply put: he is checking if M exists or not. If it does, the kill count goes up. if M does not exist (such as if it was not defined), the if() is not called thus a runtime error does not occur.

The places where a runtime may happen is in the 'else' section (for the non-client mobs)
In response to GhostAnime
Let's look at what's before that, namely the

M.coins += 5


Since M is not supplied it is null, since it is null it cannot read M.coins

You'll get something similar to

runtime error: Cannot read null.coins
In response to Rifthaven
Hm strange, i didn't notice that, my bad >_> I thought he had M only defined under if(M) and in the else section
Hellonagol wrote:
Code:
> obj/addons/bomb
> icon = 'explode.dmi'
> icon_state="bomb"
> name="Bomb Trap"
> description="A nice handy trap. Attack based on hunter skill."
> verb
> Get()
> set src in oview(1)
> if(usr.bombskill==1)
> view() << "[usr] disarms [src]"
> src.name="Bomb Trap"
> Move(usr)
> else
> usr.HP -= src.bomba
> view() << "[src] deals [bomba] damage to [usr]"
> src.icon_state="explode"
> sleep(10)
> usr:death_check()
> del(src)
> Drop()
> if(usr.bombskill==0)
> usr << "Maybe I should learn how to use these first."
> return
> else
> src.bomba=usr.hunt
> src.name="???"
> src.loc = usr.loc
> view() << "[usr] drops [src]."
> Description()
> usr << "[src.description]"
>

Problem description:
It is supposed to kill them but it kills them makes there health a negetive and bugs them! I am totally lost on this one... Please help!

You're subtracting src.bomba from the person's HP; if bomba is greater than the HP it will go negative. Try replacing it with
usr.hp -= min(usr.hp, src.bomba)


This will ensure that you never remove more than the current hp from the person.
In response to CriticalBotch
If I understand correctly,

It's not so much that the hp is going negative that's bad, it's the fact that it remains negative (and this would be because his death_check proc gives a run-time error and halts because a mob argument is not supplied).
In response to Rifthaven
So it is, so it is. My mistake (browsing quickly while at work). Still, it's a good practice to hold on to.
Hellonagol wrote:
Code:
> obj/addons/bomb
> icon = 'explode.dmi'
> icon_state="bomb"
> name="Bomb Trap"
> description="A nice handy trap. Attack based on hunter skill."
> verb
> Get()
> set src in oview(1)
> if(usr.bombskill==1)
> view() << "[usr] disarms [src]"
> src.name="Bomb Trap"
> Move(usr)
> else
> usr.HP -= src.bomba
> view() << "[src] deals [bomba] damage to [usr]"
> src.icon_state="explode"
> sleep(10)
> usr:death_check()
> del(src)
> Drop()
> if(usr.bombskill==0)
> usr << "Maybe I should learn how to use these first."
> return
> else
> src.bomba=usr.hunt
> src.name="???"
> src.loc = usr.loc
> view() << "[usr] drops [src]."
> Description()
> usr << "[src.description]"
>

Problem description:
It is supposed to kill them but it kills them makes there health a negetive and bugs them! I am totally lost on this one... Please help!

Under mob/Stat() put...

if(HP<0) HP=0
In response to PiRSquared
PiRSquared wrote:
Perhaps there's an issue in your death_check()...
Not to mention you probably shouldn't be using the ":" when you're calling it...
usr:death_check()


You people must think every game is a rip... Not every death proc is called death_check()...
In response to Dragonn
Who said anything about ripping besides you? He was talking about abusing the colon : operator while type casting would of been more appropriate
In response to Dragonn
Why? In his death proc, which he showed in [link], the HP is set back to the max amount. As Rift mentioned, it probably wasn't set back to the max because of a runtime error occurring due to no M being defined around the area of M.coins += in the Death Proc.
In response to GhostAnime
mob/var
bombskill=0
kills=0
obj/var
bomba=0
obj/addons/bomb
icon = 'explode.dmi'
icon_state="bomb"
name="Bomb Trap"
saveable=1
description="A nice handy trap. Attack based on hunter skill."
verb
Get()
set src in oview(1)
if(usr.bombskill==1)
view() << "[usr] disarms [src]"
src.name="Bomb Trap"
Move(usr)
else
usr.HP -= min(usr.HP, src.bomba)
view() << "[src] deals [bomba] damage to [usr]"
src.icon_state="explode"
sleep(10)
usr.death_check(src)
del(src)
Drop()
if(usr.bombskill==0)
usr << "Maybe I should learn how to use these first."
return
else
src.bomba=usr.hunt
src.name="???"
src.loc = usr.loc
view() << "[usr] drops [src]."
Description()
usr << "[src.description]"

and the death proc
mob
var
xx=0
yy=0
zz=0
proc/death_check(mob/M as mob)//handles death
if(src.HP <= 0)
if(src.client)
src <<"[M] killed you!"
world<<"[src] has been killed by [M]."
new/obj/b/groupable/resources/Bar/Hazium_Crystal(rand(1,5),src.loc)
src.loc = locate(43,11,1)
src.HP = src.MaxHP
src.hunger=0
if(M)
M <<"You killed [src]!"
M.kills += 1
M.coins += 5
M << "You win 5 coins!"
else
src.hunger=0
src.HP = src.MaxHP
M.level_up()
src.loc = locate(xx,yy,zz)
src.dead = 1
sleep(M.delay)
M.attkdel = 0
sleep(300 - M.delay)
src.spawn_check()

I fixed it all I did was move M.coins += 5 to where it says M<<"You killed [src]!"
In response to Hellonagol
You might want to move
                src <<"[M] killed you!"
world<<"[src] has been killed by [M]."M/DM> under if(M) as well ifyou don't want any runtime errors still