ID:174324
 
Hello!
I want this object, which has density 1, when it Bumps into something, if it is a mob with certain vars, to hurt it, or if it is a certain Turf, to delete itself, else carry on. Here is my code:
obj
kame
icon = 'kame.dmi'
icon_state = ""
layer = MOB_LAYER + 99
Bump(mob/M)
if(istype(M,/mob))
if(M.npp == 1||M.npc == 1)
else
M.powerlevel -= ((3500 * usr.Str)/M.Def)
else
if(istype(M,/turf))
if(M.dif == 0)
step(src,src.dir)
else
del(src)
else
step(src,src.dir)
del(src)
It is quite obvious what I am doing wrong : if(istype(M,/turf)) but how SHOULD I do it? I see no possible way!

Any help would be greatly appreciated!

~GokuSS4Neo~
What problem are you actually having here? You never said what's going wrong for you.

A few tips I can give you:

  • Use ismob() and isturf() for base-type checks. It's quick.
  • Don't use ==1 and ==0 to check a true/false value. Use use thevar or !thevar instead.
  • Instead of deleting the turf, try creating a new world.turf at that spot.

    Lummox JR
In response to Lummox JR
The problem was that couldn't have the turf bit after Bump(mob/M), but now I have different problems with this code:
        Bump()
ismob()
if(M.npp||M.npc)
M.powerlevel += 0
else
M.powerlevel -= ((3500 * usr.Str)/M.Def)
isturf()
if(!M.dif)
step(src,src.dir)
else
del(src)
else
step(src,src.dir)

Please note, I am completely new to ismob() and isturf(), (I have never used them before) and I am not familiar to Bump. Now I have changed the code what do I put in the Bump bit? And why does it say M.npp, M.npc, M.dif are undefined, when I HAVE defined them?

~GokuSS4Neo~

P.s. I am really sorry to bother you with something that is so simple to you! My apologies and thanks again!
In response to Lummox JR
*Punches Lummox JR in the gut for forgetting to mention the use of usr in procs*
In response to Garthor
Garthor wrote:
*Punches Lummox JR in the gut for forgetting to mention the use of usr in procs*

Ah. I looked it over but didn't see it. He has one isolated use of usr in there.

Lummox JR
In response to Gokuss4neo
Gokuss4neo wrote:
The problem was that couldn't have the turf bit after Bump(mob/M), but now I have different problems with this code:
Bump()
ismob()
No. That is not how ismob() is used. If you don't know how it's used, you need to look it up. I suggested ismob() and isturf() as replacements for istype().
  if(M.npp||M.npc)
M.powerlevel += 0
else
M.powerlevel -= ((3500 * usr.Str)/M.Def)
Um... +=0? That will do nothing. Why not just use "if(!M.npp && !M.npc)" and just put the M.powerlevel-=... line right after it? This if() doesn't really need an else with it.

Also, you've got a stray usr in there. That should be src or M, I believe. If this is a projectile, then it should have some reference to the owner, or src.Str should be set to match the owner's Str when you create it.
  isturf()
Again, not the way to use isturf().
  if(!M.dif)
step(src,src.dir)
else
del(src)
else
step(src,src.dir)
When you took out the if() that went with your old istype() call, you screwed this part up royally; you can't have two elses in the same if(). The first else went with the if(!M.dif), but the second went with the if() that was before that. You need to change this part back to something closer to your original code.

Please note, I am completely new to ismob() and isturf(), (I have never used them before) and I am not familiar to Bump. Now I have changed the code what do I put in the Bump bit?

You'd put in the same thing as before, I would think.

And why does it say M.npp, M.npc, M.dif are undefined, when I HAVE defined them?

At the moment it's M that's undefined, because you took it out of the arguments to Bump().

Lummox JR
In response to Lummox JR
You said my Bump bit should be the same as before (mob/M) but then how will isturf work?

Also I looked up ismob and it said :

Format:
ismob(Loc1, Loc2 ...)
Returns:
1 if all args are valid mobs; 0 otherwise
Args:
Any number of locations to test.

but that means almost nothing to me! What do I put in the loc bit? And how should I use indentation?

I am very sorry to be such a pest, but I am trying to make a different projectile system instead of using some Zeta rip!

~GokuSS4Neo~
In response to Gokuss4neo
Now, using one of Lummox Jr's amazing help files I have this code:
obj
Bullet
icon = Bullet.dmi'
icon_state = ""
layer = MOB_LAYER + 99
Bump(A)
if(ismob(A))
if(!A.npp&&!A.npc)
A.Health-= ((3500 * usr.Str)/A.Def)
if(isturf(A))
if(A.dif == 0)
step(src,src.dir)
else
del(src)
else
step(src,src.dir)

It says the vars are undefined. I know this is because A is undefined, but how do I define it?

~GokuSS4Neo~

[Edit]After reading another one of Lummox Jr's amazing help files, I worked it out!

Thank you Lummox!