Site hosted by Angelfire.com: Build your free website today!

 

Multi-Tiled Mobs (Set #1)

 

By: Vortezz

 


So, you want to make multi-tiled mobs in BYOND, eh? I'll assume that you've learned thebasics. After you've done that, continue with this tutorial.


This tutorial is designed to teach you how to make mobs have multiple tiles. If you have any comments, please e-mail me at vortezz@eskimobob.com. Let's get started.


For example's sake, in this tutorial I will use the bottom tile as a body, and the top tile as the head of a human.

Step 1 - Creating the Icons

Start up a new environment, or open your existing environment. If you've already got the icons made and lined up, you can skip by this part. For this tutorial, I'm going to only have one direction you can face. Of course, you can have multiple directions if you'd like.
First, make a body icon. It should look something like this. Then, make a head icon (these can be in one icon, but for the example I made them as different icons) Make sure the head is at the lowest possible point. Use the down arrow to move the head down. You should also make sure that the head and the body will line up at the neck. My head looks like this. Note that it's as far down as possible, and I've pre-aligned it with the body.


Lastly, for testing purposes, make a grass turf (void this if you've already got turfs) with flooded green. Now, we should have all the icons drawn.


 

Step 2 - Making the Head, and Manipulating It

 

So, we've got all the icons set up, right? I'll assume so, as I can't really ask you right now. Okay, so now, we're going to make the head object. We're not going to declare an icon for it, yet... I'll explain that later.


obj/head
    density = 0 //we can walk through the head.. we're looking at a diablo-style layout here
    layer = 5 //the head will appear above everything else

There. We've made the head obj, but now we've got to make it work for something. We're going to give every mob a obj/head/top var, to refer to the top of the mob (in this case, the head). While we're at it, we may as well create a movetimer var, used to control the player's walking speeds.


mob

    var

        obj/head/top //top (head) of the mob

        movetimer // used to limit how quickly the player walks


Now that we've got that all settled, and the top is always referred to as the path /obj/head, then we should be set. Now, we’re going to override the <code>mob/Move()</code> proc to take the head into account.. Here’s what we’ll have after that.

 

mob

    var

        obj/head/top //top (head) of the mob

        movetimer // used to limit how quickly the player walks

    Move(loc)

        if(world.time < movetimer) return

        movetimer += 5  //short for movetimer = movetimer + 5

        ..() //carry on regularly

        

        var/turf/T = locate(src.x,src.y + 1,src.z)  //store the turf above the mob as a var

        if(T)  //if the turf exists

            top.loc = T     //then make the moving mob’s top’s loc the turf above it.

        else //if the turf doesn’t exist

            top.loc = null  //don’t make the moving mob’s top’s loc anything

 

There! Now, whenever a mob moves, it places the top (head) above it! Now, to finish up the whole thing, and when a new mob is created, make a new top. In the next section, I’ll finish it up.

 


Step 3 - Finishing Up

 

Alrighty then. Now that we do the necessary Move() checking, it's now time to finish up the project. We need to make a new top(head) whenever a new mob is created. We accomplish this with the following code:

mob
    New()
        ..() //do the regular New() behavior
        top = new() //make the new top

Finally, here is how you would declare the mobs:


mob

    Samuel

        icon = 'body.dmi'

        top.icon = 'head.dmi'

NOTE: THIS LAST BIT OF CODE'S SPACING IS ODD. DON'T MIND IT. PLEASE, IF YOU KNOW HOW, SEND A FIX TO THE E-MAIL ABOVE/BELOW. THANKS!

If you made multiple different mob icons, bodies and heads, you could just change the icon and top.icon. The end result should look something like this.

There! Now, we have successfully created multi-tiled mobs. If you would like to contact me, please do so in the following ways:

Contacts

E-mail: vortezz@eskimobob.com
ICQ: 109564169
MSN: vortezz@eskimobob.com




Special Thanks to:


Thanks for reading! The following is the COMPLETE code used in this tutorial.


 

 

obj/head

            density = 0

            layer = 5

 

 

mob

            var

                        obj/head/top // this is the top of the mob

                        movetimer // used to limit how quickly the player walks

 

 

            Move(Loc)

                        // delay movement

                        if(world.time < movetimer) return

                        movetimer = world.time + 5

                        ..()

 

                        var/turf/T = locate(x,y + 1,z)

                        if(T)

                                    top.loc = T

                        else

                                    top.loc = null

 

 

            New(Loc)

                        ..()

                        top = new()

 

 

            joe

                        icon = 'body.dmi'

                        New()

                                    ..()

                                    top.icon = 'head.dmi'