ID:139619
 
Code:
obj
neutralpaintball
icon = 'Paintballs.dmi'
icon_state = "neutral"
density = 1
Bump(A)
if(ismob(A))
var/mob/M = A
if(M.name != src.owner)
M.hp -= 1
if(M.hp < 1)
Death(M, src)
del(src)
if(istype(A, /obj))
del(src)
del(A)

proc/Death(mob/M, obj/O)
M.hp = 3
M.WO += 1
for(var/mob/N in world)
if(N.name == O.owner)
N.KO += 1
Spawn(M)


Problem description:During run-time, when a user kills another player, instead of the killed player's WO var being upped by 1, the player that killed's WO var goes up, as well as their KO var.

What have I done wrong?

EDIT - I'd aslo like to add that this is all i need to sort before packaging my Isometric Lego Paintball Game! :D
Darkoro wrote:
What have I done wrong?

Taken generally - plenty. In terms of maintainability (and readability, a little), flexibility and robustness, your implementation is bad. For a good way to go about implementing a "battle system", follow this post: [link]
Of course, if you're just starting out and don't quite know what you're doing yet, you could forget about this until you're better.

Just fixing your logical error should be easy. Just make sure that you DON'T identify objects by name (it's a silly method) - just pass a reference instead (this also means owner should store a mob reference rather than a text string), and then make sure you're passing the right arguments to your proc.

Also, note that when a proc's src is deleted, it stops. So trying to do anything after a del src will always fail.
In response to Kaioken
Thanks, i guess. However, that still doesn't help me particualarly. Sorry.

As for the reference to my implementability, i suppose that is far enough. I go to college studying a HNC in Computer Games Development, and have only been there for 10 weeks, so i don't have the information i need quite yet on good implementation strategies, etc. However, (although i have seen the article stating "It works, so it must be good.") This method (apart from the WO part) works fine for me at the moment. Hopefully i shall improve over time, as i still have between 5 and 7 years of education in this subject (providing i get into university after next years HND course) and will be able to sort this out on my own.

The part about using name as a reference, i dont understand what you mean. Could you possibly post an example? I'd also like to point out that the owner var is assigned in my projectile proc. And for the del(src) section, thanks for pointing that out. I was wondering why the other paintballs wouldn't delete :S.

Anyway, i think i will just take out the WO system at the moment with comments, until i figure out what is wrong properly. I will still be open to suggestions though, so feel free to add replys people. ^.^

Thanks again Kaioken.
In response to Darkoro
Darkoro wrote:
Thanks, i guess. However, that still doesn't help me particualarly. Sorry.

As for the reference to my implementability, i suppose that is far enough. I go to college studying a HNC in Computer Games Development, and have only been there for 10 weeks, so i don't have the information i need quite yet on good implementation strategies, etc. However, (although i have seen the article stating "It works, so it must be good.") This method (apart from the WO part) works fine for me at the moment. Hopefully i shall improve over time, as i still have between 5 and 7 years of education in this subject (providing i get into university after next years HND course) and will be able to sort this out on my own.

The part about using name as a reference, i dont understand what you mean. Could you possibly post an example? I'd also like to point out that the owner var is assigned in my projectile proc. And for the del(src) section, thanks for pointing that out. I was wondering why the other paintballs wouldn't delete :S.

Anyway, i think i will just take out the WO system at the moment with comments, until i figure out what is wrong properly. I will still be open to suggestions though, so feel free to add replys people. ^.^

Thanks again Kaioken.

... Looking at the code again, about to comment out my WO system, i just realised that i screwed up. Big time.

My Stat() section, which is used as a who panel showing who is in what team, and shows the game info, contained the following piece of code:

stat(M.name, "KO: [M.KO]   WO: [M.KO]   HP: [M.hp]/[M.mhp]")


Hence, my problem. it should be WO: [M.WO] instead.

This deserves many facepalms in a corner. Sigh.