In response to Elation
but in the attack proc/verb idunno what it is src is trying to kill M <.<.
In response to KillerGrand
KillerGrand wrote:
but in the attack proc/vebr idunno what it is src is trying to kill M <.<.

Yeah, src is trying to kill M. So in that proc, you should call M's death_check with src as the argument.

victim.death_check(attacker)

Then in the death_check, src would be victim (who M was in the attack proc), and M would be the attacker (who src was in the attack proc).

It'd probably be less confusing in this case not to use variables such as "M". Using a variable named "attacker" or "victim" might be a lot easier.
In response to Elation
I think i got confused i thought because your killing M wouldnt you be having to kill M in the death check also.
~Grand~
In response to KillerGrand
are you going to show me the proper way my coding should look or what ?
In response to Tomf and Tails5
first off did you add (#define DEBUG) like i todl you to?
In response to KillerGrand
yeah i did
In response to KillerGrand
KillerGrand wrote:
I think i got confused i thought because your killing M wouldnt you be having to kill M in the death check also.
~Grand~

Nope, they're not the same variables.

For example, the variable M in the Attack() proc only exists in that procedure's scope- it doesn't exist anywhere else.

The object that M referenced to had it's death_check called, in that death_check proc, the object that was formally called M in the Attack() proc is now referenced to by src. See how it works?

Like I said, it'd be a lot easier if we used variables that were more descriptive of what they are.
In response to Elation
Ok i understand it now.
In response to Tomf and Tails5
now post the error and the code with showing us what line its on.
In response to KillerGrand
runtime error: Cannot read null.strength
proc name: Attack (/mob/verb/Attack)
source file: Attack(1).dm,16
usr: the kinnggebbo (/mob)
src: the kinnggebbo (/mob)
call stack:
the kinnggebbo (/mob): Attack(null)
runtime error: Cannot read null.strength
proc name: Attack (/mob/verb/Attack)
source file: Attack(1).dm,16
usr: the kinnggebbo (/mob)
src: the kinnggebbo (/mob)
call stack:
the kinnggebbo (/mob): Attack(null)
runtime error: Cannot read null.strength
proc name: Attack (/mob/verb/Attack)
source file: Attack(1).dm,16
usr: the kinnggebbo (/mob)
src: the kinnggebbo (/mob)
call stack:
the kinnggebbo (/mob): Attack(null)
In response to Tomf and Tails5
Show us your Attack() proc again. Just that bit, nothing else.
In response to Elation
mob
verb
Attack(mob/M as mob in oview(1))
set hidden = 1
M.death_check(usr)
src.stamina()
src.icon_state = "attack"
src.exp +=rand(1,2)
src.stamina -=rand(1,2)
sleep(4)
src.icon_state = ""
src.Levelup()
sleep(15)
var/damage = M.strength
M.powerlevel -=damage
return
In response to Tomf and Tails5
Aaah, there's your problem.
DM executes code on a single thread- so if you make a call to M's death_check() proc, it'll run the entirety of death_check() before continuing with the rest of the code.

Since you only check the mob's health at the start of the attack proc it gets attacked after the check.
That means you've got mobs walking about with 0 or minus numbers of health, only to be released from this mortal coil the next time they get attacked!

So imagine this scenario.
We've got a guy named Bob and he'd just been in a nasty fight. He's got 0 health! Then his arch-nemesis (Dave) comes along and punches him. Dave's attack calls the death_check proc for Bob and Bob finally collapses in the dust- he's dead. The death_check proc stops running and it gets back to the Attack() proc from where it left off!

It continues and gets to here:
            var/damage = M.strength
M.powerlevel -=damage


Oh crud! First of all, let's get out of our story and address another problem- you're basing the variable "damage" off M's strength- the victim's strength. That means when Dave goes to attack the poor Bob, he attacks him with Bob's strength!? That should be changed to src.strength.

Back to the story. We're in the attack() proc and M's powerlevel is decreased by the amount of damage. But... M is Bob- and Bob's dead! It's trying to reference M's powerlevel, but the object M references to doesn't exist anymore. That's why it's saying "null.strength" and "null.powerlevel" - because M used to point to Bob, but Bob's dead, so M becomes "null"- i.e. nothing.

And that's your problem. Bob's dead and gone, man; you've gotta let it go. You can't go asking on Bob's powerlevel when he isn't alive anymore!

The moral of this story is never to assume something is, when it might not be. Make the death_check() call at the end of the Attack() proc, after the other references to M's powerlevel. :)
In response to Elation
SHOULD IT ALSO BE src powerlevel because i want bob to hurt other players powerlevel with his streangth


runtime error: Cannot read null.powerlevel
proc name: Attack (/mob/verb/Attack)
source file: Attack(1).dm,16
usr: Gebsbo (/mob)
src: Gebsbo (/mob)
call stack:
Gebsbo (/mob): Attack(null)
In response to Elation
mob
verb
Attack(mob/M as mob in oview(1))
set hidden = 1
src.stamina()
src.icon_state = "attack"
src.exp +=rand(1,2)
src.stamina -=rand(1,2)
sleep(4)
src.icon_state = ""
src.Levelup()
sleep(15)
var/damage = src.strength
src.powerlevel -=damage
M.death_check(usr)
return


...................................................

var/damage = src.strength
src.powerlevel -=damage


Should it be like that ?? because if i put src powerlevel is attacks the attackers powerlevel instead of the victim so it should be M. but it brings the error after
In response to Tomf and Tails5
You want Bob to hurt other people's powerlevel with his strength, and if Bob were to attack another person, "src" would be Bob, and M would be the person he's attacking.

So:
            var/damage = src.strength
M.powerlevel -=damage


That's what you want. Make sure the death_check() is done after changing the powerlevel too, because otherwise you'd have the same problem- referencing the powerlevel of someone who wasn't there.
In response to Elation
I DONT Get anymore errors i just get that one.



...................................................

runtime error: Cannot read null.powerlevel
proc name: Attack (/mob/verb/Attack)
source file: Attack(1).dm,16
usr: Gebsbo (/mob)
src: Gebsbo (/mob)
call stack:
Gebsbo (/mob): Attack(null)
In response to KillerGrand
KillerGrand wrote:
Well sense you know more about coding then me are u gonna try and help him fix his code if not then let me try <.<.

There's another side to that coin: If you're gonna try to help, you should actually have some idea what you're doing and not make the problem worse. Rewriting the deathcheck backwards isn't going to help him; if anything it will confuse him more and teach him even worse practices if he chooses to adopt the change. One way you might have helped more would be to search the forum for the umpteen zillion similar threads to this one, found sound code advice, and adapted that to help him.

Lummox JR
In response to KillerGrand
KillerGrand wrote:
Well im still learning, also isnt (usr,src) the same thing.

Gads no. usr initiated the verb; src is whoever owns the current proc. This is an important distinction. In procs, usr is usually bogus.

if so then why would you be using [src]/[key] got killed by [usr].?

Actually, that shouldn't be used at all. The deathcheck proc needs to be told who killed the mob. In any deathcheck, src should always be the victim, and the killer--if the proc needs to know who the killer is, which it usually does for most games--should be sent as an argument.

Lummox JR
In response to Tomf and Tails5
That's really strange.

            sleep(15)
var/damage = src.strength
world << "M is: [M]" //add this bit
M.powerlevel -=damage
M.death_check(usr)


M really should be there, y'know. :S
Page: 1 2 3