VERC: Adding new monster factions Last edited 15 years ago2002-07-29 17:32:00 UTC by Penguinboy Penguinboy

This article was recovered from an archive and needs to be reviewed

  1. The formatting may be incorrect as it was automatically converted to WikiCode from HTML, it needs to be revised and reformatted
  2. Some information may be out of date as it was written before Half-Life was available on Steam
  3. After the article is re-formatted and updated for Steam HL, remove this notice
  4. Please do not remove the archive notice from the bottom of the article.
  5. Some archive articles are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
Alrighty, this tutorial will show you how to add new factions to monsters. Ex. a human grunt uses a faction type of CLASS_HUMAN_MILITARY . Lets say you added in Black Ops from Op4. If they were CLASS_HUMAN_MILITARY then they would be friends with human grunts, but that isn''t the way it worked in Op4, so lets add a CLASS_BLACK_OP. First open up cbase.h , scroll down a little and you should see this:
// 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 ...
#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks ...
#define CLASS_BARNACLE 99 // special because ...
Now, between CLASS_ALIEN_BIOWEAPON and CLASS_BARNACLE add in this:

#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks ...
#define CLASS_BLACK_OP 14 // <-- new Black Op faction!
#define CLASS_BARNACLE 99 // special because ...
Now that we have our new class declared, we have to open up monsters.cpp . Find the IRelationship function for the class CBaseMonster. Close to the top of the function you should see a grid of code like this (only first part shown):

static int iEnemy[14][14] =
{ // NONE MACH PLYR HPASS
*NONE* { R_NO ,R_NO ,R_NO ,R_NO
*MACHINE* { R_NO ,R_NO ,R_DL ,R_DL
*PLAYER* { R_NO ,R_DL ,R_NO ,R_NO
*HUMANPASSIVE* { R_NO ,R_NO ,R_AL ,R_AL
*HUMANMILITAR* { R_NO ,R_NO ,R_HT ,R_DL
*ALIENMILITAR* { R_NO ,R_DL ,R_HT ,R_DL
*ALIENPASSIVE* { R_NO ,R_NO ,R_NO ,R_NO
*ALIENMONSTER* { R_NO ,R_DL ,R_DL ,R_DL
*ALIENPREY * { R_NO ,R_NO ,R_DL ,R_DL
*ALIENPREDATO* { R_NO ,R_NO ,R_DL ,R_DL
*INSECT* { R_FR ,R_FR ,R_FR ,R_FR
*PLAYERALLY* { R_NO ,R_DL ,R_AL ,R_AL
*PBIOWEAPON* { R_NO ,R_NO ,R_DL ,R_DL
*ABIOWEAPON* { R_NO ,R_NO ,R_DL ,R_DL
};
As you can see, not all the code for the grid is shown . Ok, next is the main part of the tutorial. Examine the grid, first, change the iEnemy[14][14]
to... iEnemy[15][15]
Now you need to add one row and one column to the code grid. Just copy and paste the last column and row onto the grid. Change the labels to *BLACKOP* and BLKOP or whatever. Your grid should look like this:

static int iEnemy[15][15] =
{ // NONE MACH PLYR HPASS
*NONE* { R_NO ,R_NO ,R_NO ,R_NO
*MACHINE* { R_NO ,R_NO ,R_DL ,R_DL
*PLAYER* { R_NO ,R_DL ,R_NO ,R_NO
*HUMANPASSIVE* { R_NO ,R_NO ,R_AL ,R_AL
*HUMANMILITAR* { R_NO ,R_NO ,R_HT ,R_DL
*ALIENMILITAR* { R_NO ,R_DL ,R_HT ,R_DL
*ALIENPASSIVE* { R_NO ,R_NO ,R_NO ,R_NO
*ALIENMONSTER* { R_NO ,R_DL ,R_DL ,R_DL
*ALIENPREY * { R_NO ,R_NO ,R_DL ,R_DL
*ALIENPREDATO* { R_NO ,R_NO ,R_DL ,R_DL
*INSECT* { R_FR ,R_FR ,R_FR ,R_FR
*PLAYERALLY* { R_NO ,R_DL ,R_AL ,R_AL
*PBIOWEAPON* { R_NO ,R_NO ,R_DL ,R_DL
*ABIOWEAPON* { R_NO ,R_NO ,R_DL ,R_DL
*BLACKOP* { R_NO ,R_NO ,R_HT ,R_DL
};
And the last part of the array...

PLRALY PBWPN ABWPN BLKOP
R_NO, R_NO, R_NO, R_NO },
R_DL, R_DL, R_DL, R_NO },
R_NO, R_DL, R_DL, R_DL },
R_AL, R_NO, R_NO, R_HT },
R_HT, R_NO, R_NO, R_NM },
R_DL, R_NO, R_NO, R_HT },
R_NO, R_NO, R_NO, R_HT },
R_DL, R_NO, R_NO, R_DL },
R_DL, R_NO, R_NO, R_DL },
R_DL, R_NO, R_NO, R_HT },
R_FR, R_NO, R_NO, R_NO },
R_NO, R_NO, R_NO, R_HT },
R_DL, R_NO, R_DL, R_DL },
R_DL, R_DL, R_NO, R_DL },
R_HT, R_NO, R_NO, R_NO }
};
Now we are almost done. If you look at the grid you see a lot of R_ this and R_ that. In monsters.h take a look at this code:

// monster to monster relationship types
#define R_AL -2 // (ALLY) pals. Good alternative ...
#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 ...
#define R_NM 3 // (NEMESIS) A monster Will ...
Those are the monster relationship types. Using those defines set up your Black Op to have its enemies and friends. It works just like a normal grid, take ALIENMILITAR for example, going across it's grid section, it will dislike machines, hate players, dislike passive humans, etc. Now the only thing you have to do is go into your monsters Classify() function and have it return CLASS_BLACK_OP and your all set. I hope you learned from the tutorial. Now good luck. :)
This article was originally published on the Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

Comments

You must log in to post a comment. You can login or register a new account.