world
turf = /turf/grass
mob
Login()
src.LoadPlayer()
..()
var
Hp = 0
proc
LoadPlayer()
var/mob/Player/P = new()
P.client = src.client
P.Move(locate(/turf/grassStart))
TakeDamage(D,H)
H = H - D
view() << "[H]"
DeathCheck(M)
if(Hp < 1)
del(M)
mob/Player
Hp = 100
var
Str = 5
Damage = 0
verb
say(msg as text in view())
view() <<"[usr] says: [msg]"
OOC(msg as text)
world << "[usr]: [msg]"
Attack(mob/M in oview(1))
Damage = Str
view() << "[usr] hit [M] for [Damage] Damage!"
M.TakeDamage(Damage,M.Hp)
M.DeathCheck(M)
icon = 'player.dmi'
Problem description:
So in my Main.dmi I have a TakeDamage() proc and a DeathCheck() proc.
Take Damage gets called by the player when he attacks the enemy.
then the players attack calls the deathcheck.
My problem is the take damage only happens the first time I attack and I cant seem to get it to happen again.
I feel like I'm only setting the Hp to HP - Str but Im not sure.
Also the mob/Player is in its own PlayerMain.dmi
Consider your TakeDamage proc's code:
You're setting H to H - D, instead of setting Hp to Hp - D. You're subtracting from H instead of Hp
Revised, this looks like:
Notice how we don't need the "H" argument anymore?
It seems like you got tripped up because the names of your arguments are ambiguous. "H" and "D" aren't very descriptive. I would recommend renaming your arguments to something better understood in the future. In this example, I would have chosen names like "damage" and "currentHealth" or something similar. It sounds like it's not relevant, but your future self will love you for keeping your code readable, and it helps you avoid situations like this.
One more thing to touch on: Your DeathCheck proc doesn't need M passed as an argument if all you're going to do is delete it. Instead, consider passing src as an argument so you could shout out to nearby mobs that (this) mob killed (that) mob.
Here's how that would look: