ID:178141
 
Ok I've had these for a while and I'm getting annoyed by them. Whenever a player kills a mob with a macro on it causes tons of runtime errors. How do I get rid of them? I'm thinking about adding a delay or something but how do i do that?

Alienman


P.S. I don't want people to not be able to use marcos I just want it to have a delay.

Alienman22774 wrote:
Ok I've had these for a while and I'm getting annoyed by them. Whenever a player kills a mob with a macro on it causes tons of runtime errors. How do I get rid of them? I'm thinking about adding a delay or something but how do i do that?

Alienman


P.S. I don't want people to not be able to use marcos I just want it to have a delay.


Could you paste the runtime errors your are getting in here please?

--Lee
In response to Mellifluous
runtime error: Cannot read null.Health
proc name: Attack (/mob/verb/Attack)
source file: obj.dm,58
usr: \[Creator/Master GM]Alienman (/mob/HarvestMoonDude)
src: \[Creator/Master GM]Alienman (/mob/HarvestMoonDude)
call stack:
\[Creator/Master GM]Alienman (/mob/HarvestMoonDude): Attack(null)

Thats it
In response to Alienman22774
Alienman22774 wrote:
runtime error: Cannot read null.Health
proc name: Attack (/mob/verb/Attack)
source file: obj.dm,58
usr: \[Creator/Master GM]Alienman (/mob/HarvestMoonDude)
src: \[Creator/Master GM]Alienman (/mob/HarvestMoonDude)
call stack:
\[Creator/Master GM]Alienman (/mob/HarvestMoonDude): Attack(null)

Thats it

Well, from what I can see your problem is occuring on line 58 of your obj.dm file.

Paste what is on line 58 of your obj.dm file so I and others can see or at least find out whats wrong.

--Lee
In response to Mellifluous
verb
Attack(mob/M as mob in oview(1))
usr << "You attack [M]!"
var/damage = Strength
view(6) << "at [damage] damage!"
M:Health -= damage
if(usr.Health<=0)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)//Change these numbers to the location you want the defeated person to go after he/she dies
Levelup()//This calls the Levelup proc as defined in the other file
M:DeathCheck()

DeathCheck()

I'm pretty sure this is it. The Attack Verb
In response to Alienman22774
Alienman22774 wrote:
verb
Attack(mob/M as mob in oview(1))
usr << "You attack [M]!"
var/damage = Strength
view(6) << "at [damage] damage!"
M:Health -= damage
if(usr.Health<=0)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)//Change these numbers to the location you want the defeated person to go after he/she dies
Levelup()//This calls the Levelup proc as defined in the other file
M:DeathCheck()

DeathCheck()

I'm pretty sure this is it. The Attack Verb

Which is line 58?
In response to Mellifluous
I'm not sure exatcly I think its the Death Check


[EDIT] i just checked its....
if(usr.Health<=0)
In response to Alienman22774
Alienman22774 wrote:
I'm not sure exatcly I think its the Death Check


[EDIT] i just checked its....
if(usr.Health<=0)

So you have fixed the runtime error now?

If so, good on you :)

--Lee
In response to Mellifluous
oh i think i see it. if(usr.Health<=0) needs to be
if(usr.Health<=1)

Is that correct?
In response to Alienman22774
Alienman22774 wrote:
oh i think i see it. if(usr.Health<=0) needs to be
if(usr.Health<=1)

Is that correct?

Well, I don't really think that changing the "0" to "1" will do anything there.

I haven't use "Attack" verbs in a while but let me have a think about this one ;)

Try making the "var/damage = Strength" to "var/damage = usr.Strength".

--Lee
In response to Mellifluous
still getting the Runtime errors and now the mobs kill me in one hit. I think it gave the mobs my Str.
In response to Alienman22774
Alienman22774 wrote:
still getting the Runtime errors and now the mobs kill me in one hit. I think it gave the mobs my Str.

Hmm...

Well, seing as I don't really know whats wrong, why don't you just copy your full attack code and your deathcheck code as that might make things alittle more clearer for me.
In response to Mellifluous
verb
Attack(mob/M as mob in oview(1))
usr << "You attack [M]!"
var/damage = Strength
view(6) << "at [damage] damage!"
M:Health -= damage
if(usr.Health<=1)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)//Change these numbers to the location you want the defeated person to go after he/she dies
Levelup()//This calls the Levelup proc as defined in the other file
M:DeathCheck()

DeathCheck()

proc
DeathCheck()
if (Health <= 0)
loc = locate(1,1,3)
Health = MaxHealth
usr << "[src] has died!"

for the mob i'm attacking when testing the Death Check is..

DeathCheck()
if (Health <= 0)
usr << "[src] has died!"
usr.gold+=2
usr<<"U found 2 Gold!"
usr.Exp+=30
usr<<"U got 30 experience points!!"
del(src)

I have a Death Check for all my mobs because every mob gives something different.
In response to Alienman22774
Alienman22774 wrote:
verb
Attack(mob/M as mob in oview(1))
usr << "You attack [M]!"
var/damage = Strength
view(6) << "at [damage] damage!"
M:Health -= damage
if(usr.Health<=1)
src.Health=src.MaxHealth
src.loc=locate(33,24,1)//Change these numbers to the location you want the defeated person to go after he/she dies
Levelup()//This calls the Levelup proc as defined in the other file
M:DeathCheck()

DeathCheck()

proc
DeathCheck()
if (Health <= 0)
loc = locate(1,1,3)
Health = MaxHealth
usr << "[src] has died!"

for the mob i'm attacking when testing the Death Check is..

DeathCheck()
if (Health <= 0)
usr << "[src] has died!"
usr.gold+=2
usr<<"U found 2 Gold!"
usr.Exp+=30
usr<<"U got 30 experience points!!"
del(src)

I have a Death Check for all my mobs because every mob gives something different.

You have two of the same DeathCheck() procs...Why?
In response to Mellifluous
I have one Death Check for each mob. That way if a Monkey you kill gives you 50 Exp points a Demon you kill gives you 200 Exp points. It just helps me organize code.

Alienman
In response to Alienman22774
It would be easier to use one proc and check the mob with istype() for certain stat boosts. As for the runtime error ir's caused when a mob tries to attack a mob that isn't there anymore (usally when a macro buffer reaches it's end after the mob is dead) so you'll need a delay:

mob
var
attacking = 0

verb
attack()
if(usr.attacking)//already attacking
..()//you want them to not attack but do it without stoping the proc
else
usr.attacking = 1
//rest of attack here
sleep(20)//2 second delay
usr.attacking = 0
In response to Nadrew
I get a bunch of Inconsistent Indentation errors which when i fix it gives me a TON of different errors. How would i just add that into my attack verb i already have?
Just to give a broad sweep over the problems you're having:

  • Any place where you're getting "Cannot read null.something", find out what the null item is and put in a line like this before it:
if(!M) return   // e.g., if it was trying to read M.Health

Put lines like that at the beginning of your proc, and after a sleep or spawn if there's a chance something else might delete the mob in the meantime.

  • Change your <=1 back to <=0. <=1 didn't fix your problem, but it did create a new one: Now when you get down to 1 health, you die, instead of dying when you get down to 0. This is nonsensical and I don't think it's what you wanted.
  • Inconsistent indentation errors often come from copying and pasting code from the forums. The solution is not to do that, or to correct the indentation manually if you do.

    Lummox JR
In response to Alienman22774
When you post on these forums most of the time you'll get an example, in which you should never paste to your own code because the forum uses spaces not tabs, study my code and learn how to put that into your own code, it's not very hard, and it would help you if you did it yourself.