In response to Immibis
Immibis wrote:
What you said [b]doesn't[/b] work. You need to pass a parameter to deathcheck. This parameter needs to be the thing that the player killed.

Actually that's backwards; the parameter should be the killer, and src should be the victim. src should always be the victim in a deathcheck because the victim is the primary figure involved in what the proc does. Zeppo's example didn't work for other reasons.

Also, just FYI, BBcode doesn't work in the forums. You can use HTML, so <b> and </b> is what you'd use instead for bold text.

Lummox JR
In response to Zeppo
For the sake of others who may run across this thread in the future, I will explain why this is wrong, and how to fix the original post.

Zeppo wrote:
mob
proc
Deathcheck()
if(src.hp <= 0)
...


This does not actually fix the whole problem, and introduces a new one: it won't compile. The main difference between this proc and the original was that usr was replaced with src, which was a correct change to make. The problem is it also took out the mob/M argument which is rather important, since M is the player (or perhaps monster) who made the kill. Without M defined, this code won't compile. Hence why Chico1 said it wasn't fixed.

Going back to Chico1's original post, there are three problems with the code:

1) usr is used in places where it should be src. In a death check proc, src should always be the victim, and the killer should be passed as an argument if that info has any importance to the game at all (which it usually does).

2) M, the killer, is used in some places where src should be used, so in some cases the killer is being told they killed themselves.

3) Since the runtime error makes it clear that M is null, the problem is that Deathcheck() is being called without an argument. It should be called as victim.Deathcheck(killer). So while the proc itself had significant problems, the more immediate issue was that it was called incorrectly.

The biggest problem in both posts is that the vars are being used indiscriminately. src, usr, and M are being mixed around or even discarded. This is the logic behind a death check:

- usr should not be used because this is a proc.
- Since the death routine primarily deals with handling the death of the victim, src should be the victim--without exception.
- Another piece of info is needed to say who killed the victim. Since usr is inappropriate and src is taken, the killer should sent to the proc as an argument.
- The proc must be called with the proper argument to work right.

Chico1 was just making a simple rookie mistake in handling all these vars. The fix presented above was more of a "throw stuff at the wall and see what sticks" approach to debugging, which seldom results in success but can at least tell you what doesn't work. However since this is the sort of problem that can be fixed by thinking it through, the see-what-sticks method is inappropriate. This is also not a good method to use when trying to help people.

For the help of both posters and those who will follow, I leave this advice:

Chico1: Everyone runs into this problem, so no worries. Stick with it. Just remember to take a moment to think it all through, and make sure you know what each var stands for and how it's used. If you do run into problems, remember to be as descriptive as possible. When you first told Zeppo that his code didn't fix your problem, you didn't mention that it was because it didn't compile. The more details you give, the better help you'll get.

Zeppo: The desire to help is a good thing, but always be sure you're being helpful. The posts you made in this thread showed you were as lost as the original poster. Since you both needed the same help, it would have been better for both of you to get help from someone who understood the problem. That the best way of learning is teaching is not fact, but a somewhat distorted philosophical truism; to teach, one must first understand. The main reason teaching is said to be a good way to learn is that the process of laying out how to explain a concept is a good way to cement that concept in one's own mind. Until you grasp it yourself, it's too soon to step up to the lectern. It's also ill-advised for a person in this position to shout down competing advice from those who understand the material.

Lummox JR
In response to Lummox JR
1. Make the proc call as:
killer.deathcheck(killed)

2. You mixed up M and usr up in the proc.

3. No usr in procs, use src.

4. Instead of using a load of if statements, create a spawn var so each guy goes to a spawn, saves a lot of work.

mob
proc
Deathcheck(mob/M)
if(M.hp<=0)
M.hp=0
if(M.client)
M<<"You have been killed by [src]"
src.hp=usr.Mhp
src.Death+=1
src<<"You have killed [M]"
src.kills+=1
M.loc=locate(M.spawn_loc)
else
//do stuff for killing a monster/ getting killed by a monster.

verb
Attack(mob/M in get_step(src,src.dir))
//Do stuff
src.Deathcheck(M)


Don't copy and paste that code, you'll get errors. Make your own with all thr advice everyone has given you.
In response to Howey
If you're going to provide examples, it'd help if they weren't completely ass-backwards.

The argument should be the KILLER. That's it. End of story -_-;
Here you go...

mob
proc
Deathcheck(mob/M)
if(src.hp<=0)
switch(src.Bendingability)
if("Water")
src.loc=locate(20,56,1)
if("Fire")
src.loc=locate(11,56,1)
if("Wind")
src.loc=locate(20,64,1)
else
src.loc=locate(16,64,1)//For earth and any exceptions
if(M&&istype(M,/mob))
src<<"You have been killed by [M]"
M<<"You have killed [M]"
M.kills++
else
src<<"You died"
src.hp=src.Mhp
src.Death++


Disclaimer removed 3:
In response to Howey
Howey wrote:
1. Make the proc call as:
killer.deathcheck(killed)

As several people have pointed out in this thread (myself twice, ironically including the post you replied to), that is the wrong way to define a death check. The victim should always be src because the victim is the one that the proc primarily deals with. The victim is the main party, and the killer is ancillary (but often quite relevant) information which belongs in an argument.

Failure to keep straight which var belongs in which role is also what got Chico1 and Zeppo into trouble. Aside from backwardizing the proc, you made the same mistake they did by mixing up src and M in a couple of spots and still leaving in a stray usr reference.

Lummox JR
In response to Chowder
Pointing out that the if() block in the middle there needs the middle two to be else if(), and that your disclaimer at the bottom is stupid and annoying. If you aren't confident in what you are posting, don't post.
In response to Garthor
Unless I'm failing to see what your pointing at.
Even if M is null It doesn't change the fact that they died and should get a message about it.
In response to Chowder
Whoops, didn't notice that you'd changed it to a switch(). Carry on, then.

Wait, no, you'd edited your post after mine. I call shenanigans.
In response to Garthor
I only edited it to remove the disclaimer. x3
In response to Chowder
thx all for helping me with this i realy appreciate that you all took the time to help me out
Page: 1 2