In response to LordJR
LordJR wrote:
Where does the MOB's reaction code go?
In the Block() proc?
Under the mob/npc/Bump()?
Under the mob/pc/Bump() code?


I still recommend changing your Block() proc to Bumped() or something else, since block() is a predefined proc that has nothing to do with Bump()ing. I'll refer to it as Bumped() through the rest of this post.

You could set the reactions in the mobs' Bump() procs if you wish. In that case, you want to check the type of thing the mob is bumping:

mob/Bump(ThingIBumpedInto) // the var name is a bit long, but it makes a point
if(istype(ThingIBumpedInto,/turf/mountain))
src << sound('bump.wav') // src is the mob bumping into the ThingIBumpedInto

If you have 50 different things they can bump, you would need 50 if blocks, which gets a bit combersome.


The primary reason for a Bumped() proc is so you can break up a huge centralized if/else tree and put the "reaction" to mountains with the mountains code.

mob/Bump(atom/ThingIBumpedInto)
ThingIBumpedInto.Bumped(src) // tell the ThingIBumpedInto that I (src) bumped into it
..() // this line is optional and allows normal Bump() processing as well

atom/Bumped(ThingThatBumpedMe)
// proc prototype. This just declares that all atoms have a Bumped() proc. Override it for things that do special things when bumped

turf/mountain/Bumped(ThingThatBumpedMe)
ThingThatBumpedMe << sound('bump.wav')

Greg wrote:
I want to make it so when you run into a mountain it makes a noise
this is what i have
Moutains
icon = 'Moutains.dmi'
density = 1
Bump(turf/Mountains)
usr<<sound('Bump.wav')
i am not sure how i could define it

As Shadowdarke and others said in a post, bumped() is a good idea. Think of it like the Mountain has been bumped. So you define bumped() in all turfs that has a chance to be bumped. Something like this:
turf
  proc
    bumped()
      // Default is 'do nothing'
  Mountains
    icon = 'Mountains.dmi'
    density = 1
    bumped() // Override the default 'do nothing' here.
      usr << sound('Bump.wav')

Now to the mob. It is using the Bump() proc when it hits something. Then check for a turf in the Bump proc and call the bumped proc from there:
mob
  Bump(atom/thing) // An atom since we can bump into all sorts of things.
    if(istype(thing,/turf))
      var/turf/T = thing
      T.bumped()

This might look like I use one more variable than I need to (var/turf/T), but I don't like to use the colon operator. It might lead to accidental mistakes.

Does this example makes sense to you?


/Andreas
Page: 1 2