Need to start some were in modding right? Why not try the Half-Life modding Kit. This Kit is designed to have all the tools you need to start your own Half-Life mod, simple mods can be made or advance ones like Base Defense with this small set of tools. If you want to start modding Half-Life you should try this.

Post tutorial Report RSS Makeing New Monster Class's

This is a quick tutorial on making new monsters class's thanks to Magic_Nipples for showing me how to do this.

Posted by on - Intermediate Server Side Coding


This is a pretty easy tutorial but it is pretty hard to figure out how to do, at least I thought so.

Lets start out by learning what monster class's are. A monster class is how a monster will behave to other monsters. For example the CLASS_PLAYER_ALLY is the class that is used for the monster barney. This class makes him non-hostile to the player and other CLASS_PLAYER_ALLY or CLASS_ALIEN_PASSIVE which are the scientists.


By default there are 14 Class's, I am not sure if they are all used by the actual game but I do know that there are 14. Here they are, I copied and pasted them directly from the code so some of the notes are still there

// For CLASSIFY
#define CLASS_NONE 0
#define CLASS_MACHINE 1
#define CLASS_PLAYER 2
#define CLASS_HUMAN_PASSIVE 3
#define CLASS_HUMAN_MILITARY 4
#define CLASS_ALIEN_MILITARY 5
#define CLASS_ALIEN_PASSIVE 6
#define CLASS_ALIEN_MONSTER 7
#define CLASS_ALIEN_PREY 8
#define CLASS_ALIEN_PREDATOR 9
#define CLASS_INSECT 10
#define CLASS_PLAYER_ALLY 11
#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players
#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace
#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures.

So lets get started

First in cbase.h

We need to classify the class. go around line 86 or search one of the class's above until you find them. Under #define CLASS_BARNACLE 99 we are going to add are new class. I am coding a demon class for a custom dll I am going to add in the next version of the modding kit. So mine would be

#define CLASS_DEMON 14

Remember to give it a unique number, I am not sure how many class you can add or why the Barnacle class is class 99.

Next thing we are going to do is the backbone of the code, open up monsters.cpp

Go to around line 2204 or search for /*HUMANMILITAR* here you will see this piece of code


/*HUMANMILITAR*/{ R_NO ,R_NO ,R_HT ,R_DL ,R_NO ,R_HT ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_HT, R_NO, R_NO, R_HT },

you will also see a bunch of other ones just moddb messed up the format pretty bad so I only put this piece. Scroll up and you should see

static int iEnemy[14[14] =

Change both of these numbers to 15, if you do not the file will not compile. For each class you add raise the number by 1. You might be able to have less class's then the number but I would not try it since it takes just a few seconds to change the number

Now copy one of the lines such as the /*HUMANMILTAR*/ line above and paste it. Something very important that is hard to see. the last line, the /*ABIOWEAPON*/ code does not have a comma, add a comma and remove the one from the line we just created. This is only if you put the fileon the bottom where I put it.

Now we will get down to the real part. This is what those funny R_NO and R_HT and stuff mean, I found it some were in the code. I would recommend to paste it at the bottom so you always can rember.

//#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable
//#define R_FR -1// (FEAR)will run
//#define R_NO 0// (NO RELATIONSHIP) disregard
//#define R_DL 1// (DISLIKE) will attack
//#define R_HT 2// (HATE)will attack this character instead of any visible DISLIKEd characters
//#define R_NM 3// (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter

Notice though R_NM is never used, I think it works still I never tested it though. Just another thing that was cut I guess Up top you can see that above each R_NO and stuff there is a note of which class it is marking, modify it to your liking.

Next we will add the code so the other class's can see your class, at the very last R_NO or what the class has set add a new R_NO or what ever you want. Do this for all of the lines even the new one you made.

Heres the final example of my new line of code

/*DEMON*/ { R_NO ,R_HT ,R_NM ,R_DL ,R_HT ,R_HT ,R_HT ,R_HT ,R_HT ,R_HT ,R_NO ,R_HT, R_DL, R_NO, R_NO }

This code makes the demon hate every thing but the player who is its nemesis and another demon who it will disregard. If you need any help just private message me and I will get back to you. I know this tutorial was a little hard to follow but I hope you find it usefull


Post comment Comments
D-Wanderer
D-Wanderer - - 136 comments

Wow. Very very useful. This whole modding kit's been very useful to me. Thanks a bunch!

Reply Good karma Bad karma+1 vote
Guest
Guest - - 691,381 comments

This comment is currently awaiting admin approval, join now to view.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: