ID:170525
 
mob
NPC
Monster
Blue_Slime
name="Blue Jelly"//Name of mob
player=0
icon='monsters.dmi'//Mob's icon
icon_state="blue jelly"//Mob's icon state
Hp=14//Hit points
MaxHp=14//Maximum hit points
Goldgive=5//Gold
Exp_give=2//Experience
Str=5//Attack
Def=2//Defense
monsterattack="blue sludge"//Move enemy does
Bump(mob/M)
if(istype(M,/mob))
if(M.player==1)
var/damage = rand(1,usr.Str)
damage-=M.Def // Lets define a new var thats only for THIS verb... Its called damage and damage is a random number between 1 and 3
if(damage>0)
M << "[usr] attacks you for [damage] damage!" //Output this message to the victim, incase they are a PC and want to know they are being attacked
M.Hp -= damage //Subtract how much damage he did from the mobs HP
M.Death()
else
M<<"[usr] Missed!"
Giant_Moth
name="Moth"//Name of mob
player=0
icon='monsters.dmi'//Mob's icon
icon_state="moth"//Mob's icon state
Hp=14//Hit points
MaxHp=14//Maximum hit points
Goldgive=5//Gold
Exp_give=2//Experience
Str=5//Attack
Def=2//Defense
monsterattack="flutter"//Move enemy does
Bump(mob/M)
if(istype(M,/mob))
if(M.player==1)
var/damage = rand(1,usr.Str)
damage-=M.Def // Lets define a new var thats only for THIS verb... Its called damage and damage is a random number between 1 and 3
if(damage>0)
M << "[usr] attacks you for [damage] damage!" //Output this message to the victim, incase they are a PC and want to know they are being attacked
M.Hp -= damage //Subtract how much damage he did from the mobs HP
M.Death()
else
M<<"[usr] Missed!"


problem im having is..when it is compiled, the moth monster's icon shows for both the moth and the slime.

i know it might fix it if i have the monsters in seprate icon packs. but that would flood my list of icons with lots of single stated icons and take a long while to do.

any idea whats going on here?
Just a simple indetation error good buddy. =)

> mob
> NPC
> Monster
> Blue_Slime
> name="Blue Jelly"//Name of mob
> player=0
> icon='monsters.dmi'//Mob's icon
> icon_state="blue jelly"//Mob's icon state
> Hp=14//Hit points
> MaxHp=14//Maximum hit points
> Goldgive=5//Gold
> Exp_give=2//Experience
> Str=5//Attack
> Def=2//Defense
> monsterattack="blue sludge"//Move enemy does
> Bump(mob/M)
> if(istype(M,/mob))
> if(M.player==1)
> var/damage = rand(1,src.Str)
> damage-=M.Def // Lets define a new var thats only for THIS verb... Its called damage and damage is a random number between 1 and 3
> if(damage>0)
> M << "[src] attacks you for [damage] damage!" //Output this message to the victim, incase they are a PC and want to know they are being attacked
> M.Hp -= damage //Subtract how much damage he did from the mobs HP
> M.Death()
> else
> M<<"[src] Missed!"
> Giant_Moth
> name="Moth"//Name of mob
> player=0
> icon='monsters.dmi'//Mob's icon
> icon_state="moth"//Mob's icon state
> Hp=14//Hit points
> MaxHp=14//Maximum hit points
> Goldgive=5//Gold
> Exp_give=2//Experience
> Str=5//Attack
> Def=2//Defense
> monsterattack="flutter"//Move enemy does
> Bump(mob/M)
> if(istype(M,/mob))
> if(M.player==1)
> var/damage = rand(1,src.Str)
> damage-=M.Def // Lets define a new var thats only for THIS verb... Its called damage and damage is a random number between 1 and 3
> if(damage>0)
> M << "[src] attacks you for [damage] damage!" //Output this message to the victim, incase they are a PC and want to know they are being attacked
> M.Hp -= damage //Subtract how much damage he did from the mobs HP
> M.Death()
> else
> M<<"[src] Missed!"


Actually, you're using usr in Bump() too, which is a big no-no. Thankfully, in this instance, you can use src instead of usr because src is the owner of the Bump() proc. Also, you can just use one of those Bump() procs as the /mob/NPC/Monster/Bump() proc (as opposed to making the same Bump() for every Monster) and delete the other. =)
Besides the usr in Bump() issue which has already been mentioned, you have a few other problems:

  • Always put space between your code and a // comment. Otherwise it's nasty and hard to read.
  • if(M.player==1) is a bogus test. Never ever use if(var==1) and if(var==0) to test true/value values. This is called brittle code; if an unexpected value comes up, your code will break. Use if(var) and if(!var), which are robust. I think M.client or M.key would make a better test here, but I suppose if you have some NPCs counting as players it would be appropriate to have a var telling you that although no one directly controls this mob it's still counted as a character instead of a monster.
  • You're either calling your Death() proc wrong, or you've set it up wrong, or quite possibly both--unless of course Death() doesn't need to know who the killer is. If it needs to know that, send the killer as an argument, i.e. M.Death(src). If you've got usr anywhere in your Death() proc, replace it with the argument.
  • You've defined Bump() twice, once for each monster. Or would have if it was indented the way you intended. Just define Bump() the same way for all monsters, and override it only if necessary.

    Lummox JR