ID:269021
 
        attack(mob/M as mob in oview(1))
set category = "Physical"
var/damage = usr.HitPoints/100*usr.Strength
damage -= M.Defense*100
if(damage > 0)
view(6) << "[usr] hits [M]!"
M.HitPoints -= damage
flick("punch",usr)
M.DeathCheck()
if(damage <= 0)
view(6) << "[M] blocks [usr]s attack!."
M.HitPoints -= 1
flick("punch",usr)
M.DeathCheck()


i think i did my damage right? i suck when it comes to that kind of stuff, but when my friend attacked me he killed me in one shot and it said i blocked his attack -_-
there is prob something wrong with the DeathCheck() proc
instead of
M.DeathCheck()

put

src.DeathCheck(M)

In response to VcentG
VcentG wrote:
instead of
M.DeathCheck()

put

src.DeathCheck(M)


We don't know if his deathcheck has args, though.
In response to Hell Ramen
Hell Ramen wrote:
VcentG wrote:
instead of
M.DeathCheck()

put

src.DeathCheck(M)


We don't know if his deathcheck has args, though.

If he doesn't, then he has OTHER problems he needs help with first.
In response to Teh Governator
heh forgot about this post my death check is


mob
proc
DeathCheck()
if(istype(src,/mob/Characters))
if(src.Dead==1)
src<<"<B><font size = 1><font color = green>You have died again!"
src.icon_state=""
src.Dead=1
src.Checker()
src.loc=locate(27,2,3)
src.density=1
src.HitPoints = src.MaxHitPoints
src.Ki=src.MaxKi
else
if(src.name==usr.name)
orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
world <<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has killed himself."
else
orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
world<<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has been killed by [usr]."
src.HitPoints=src.MaxHitPoints
src.Ki=src.MaxKi
src.icon_state=""
src.Dead=1
src.Checker()
src.Techcheck()
src.overlays += /obj/halo
src.density=1
src.loc=locate(27,2,3)
In response to Dranzer_Solo
Dranzer_Solo wrote:
heh forgot about this post my death check is


> mob
> proc
> DeathCheck()
> if(istype(src,/mob/Characters))
> if(src.Dead==1)
> src<<"<B><font size = 1><font color = green>You have died again!"
> src.icon_state=""
> src.Dead=1
> src.Checker()
> src.loc=locate(27,2,3)
> src.density=1
> src.HitPoints = src.MaxHitPoints
> src.Ki=src.MaxKi
> else
> if(src.name==usr.name)
> orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
> world <<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has killed himself."
> else
> orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
> world<<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has been killed by [usr]."
> src.HitPoints=src.MaxHitPoints
> src.Ki=src.MaxKi
> src.icon_state=""
> src.Dead=1
> src.Checker()
> src.Techcheck()
> src.overlays += /obj/halo
> src.density=1
> src.loc=locate(27,2,3)
>


What the hell? Lets run through what that snippet of code is doing:

Check if the mob who owns the DeathCheck proc is a character. If they are dead, inform them of this fact. If they are not dead, check if the owner of the proc is the same as the thing that called it (see http://bwicki.byond.com/ByondBwicki.dmb?UsrIsEvil), if it is, assume that the owner of the proc has killed himself. Otherwise, the owner of the proc has been killed by the person who eventually called it, which may be null. Then, kill src.

It doesn't do any checking: IT ALWAYS KILLS SRC.

You want to do something like this:
proc/DeathCheck(var/mob/checkee,var/mob/PossibleKiller)
if(checkee.health<=0)
// kill checkee here. PossibleKiller killed him.


That's what a deathcheck proc should do. You would then call it like this:

mob
verb/Attack(var/mob/m in view(src,1))
// Calculate damage
if(damage>0)
// Do damage
DeathCheck(m,src)


Okay? You see why that works?
In response to Jp
Yes i do my way was just easier but it didnt work lol ill try it out and see what i get

but what i dont get is how im going to edit my code now to work with your soulution
In response to Dranzer_Solo
Dranzer_Solo wrote:
Yes i do my way was just easier but it didnt work lol ill try it out and see what i get


Your way is less efficient, and may not work sometimes.
In response to Hell Ramen
as i have noticed lol


ive been trying to work with the new way for the past 5 mins but i cant seem to get it in there
In response to Dranzer_Solo
You just need to check whether the person you just attacked is actually dead in your procedure. At the moment you always kill them. That's just a design flaw. Or maybe a feature.

The arguments are th important bit. Don't ever assume that usr is the mob doing the attacking. Anywhere outside a verb, usr is evil and trying to destroy your program and take over the world. Repeatedly.
In response to Jp
mob
proc
DeathCheck(var/mob/check,var/mob/PossibleKiller)
if(check.HitPoints<=0)
if(src.Dead==1)
src<<"<B><font size = 1><font color = green>You have died again!"
src.icon_state=""
src.Dead=1
src.Checker()
src.loc=locate(27,2,3)
src.density=1
src.HitPoints = src.MaxHitPoints
src.Ki=src.MaxKi
else
if(src.name==usr.name)
orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
world <<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has killed himself."
else
orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
world<<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has been killed by [usr]."
src.HitPoints=src.MaxHitPoints
src.Ki=src.MaxKi
src.icon_state=""
src.Dead=1
src.Checker()
src.Techcheck()
src.overlays += /obj/halo
src.density=1
src.loc=locate(27,2,3)


ok hows that looking?

I took out

if(istype(src,/mob/Characters))

and replaced it with

if(checkee.HitPoints<=0)

was that bad? or is it fine?
In response to Dranzer_Solo
Dranzer_Solo wrote:
> mob
> proc
> DeathCheck(var/mob/check,var/mob/PossibleKiller)
> if(check.HitPoints<=0)
> if(src.Dead==1)
> src<<"<B><font size = 1><font color = green>You have died again!"
> src.icon_state=""
> src.Dead=1
> src.Checker()
> src.loc=locate(27,2,3)
> src.density=1
> src.HitPoints = src.MaxHitPoints
> src.Ki=src.MaxKi
> else
> if(src.name==usr.name)
> orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
> world <<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has killed himself."
> else
> orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
> world<<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has been killed by [usr]."
> src.HitPoints=src.MaxHitPoints
> src.Ki=src.MaxKi
> src.icon_state=""
> src.Dead=1
> src.Checker()
> src.Techcheck()
> src.overlays += /obj/halo
> src.density=1
> src.loc=locate(27,2,3)
>

ok hows that looking?

I took out

if(istype(src,/mob/Characters))

and replaced it with

if(checkee.HitPoints<=0)

was that bad? or is it fine?

Well, first. You are using usr in a proc. Second, why have 2 arguements, you only need one for a death proc. You could use an arguement if you want, but you are doing it wrong. First you supply 2 arguements, but don't use one of them and the other one you don't use at all.
In response to N1ghtW1ng
Where do i have usr ion proc?
In response to Dranzer_Solo
You have one in your third if check
if(src.name==usr.name)
and again in the else below it
world<<"src] has been killed by [usr]."

In response to Madcrackfiend
-_- i cant make it if(src.name==src.name)
In response to Dranzer_Solo
Of course you cant, so you make it check to see if src.name is = to one of your arguments, I sugjest possible killer.

if(src.name = PossibleKiller.name)

Also I'm not sure if this is the best way to check for this, if any one has a better sugjestion.
In response to Dranzer_Solo
Urm, I am pretty sure you can. If not try something like this:

mob/verb/Attack(mob/A)
if(A==src)
//blah
else
//blah


In response to Madcrackfiend
That wouldn't compile =P You need 2 == to make it a check. The single = means set it equal to.
In response to N1ghtW1ng
so by all this info my code should look like this...


Attack/////////
mob
verb
attack(var/mob/M in view(src,1))
set category = "Physical"
var/damage = usr.HitPoints/100*usr.Strength
damage -= M.Defense*100
if(damage > 0)
view(6) << "[usr] hits [M]!"
M.HitPoints -= damage
flick("punch",usr)
M.DeathCheck()
if(damage <= 0)
view(6) << "[M] blocks [usr]s attack!."
M.HitPoints -= 1
flick("punch",usr)
M.DeathCheck()
</dm

Deathcheck/////////
<dm>
mob
proc
DeathCheck(var/mob/check,var/mob/Killer)
if(check.HitPoints<=0)
if(src.Dead==1)
src<<"<B><font size = 1><font color = green>You have died again!"
src.icon_state=""
src.Dead=1
src.Checker()
src.loc=locate(27,2,3)
src.density=1
src.HitPoints = src.MaxHitPoints
src.Ki=src.MaxKi
else
if(src.name == Killer.name)
orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
world <<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has killed himself."
else
orange(6)<<"<B><font size = 1><font color = red>[src] dies right infront of you!"
world<<"<B><font size = 1><font color = red>Info:<i><font color = white>[src] has been killed by [Killer]."
src.HitPoints=src.MaxHitPoints
src.Ki=src.MaxKi
src.icon_state=""
src.Dead=1
src.Checker()
src.Techcheck()
src.overlays += /obj/halo
src.density=1
src.loc=locate(27,2,3)




P.S you gotta use == not =



Bla forgot to fix that Usr ....FIXED


hows that?
Page: 1 2