|
Feedback
If you've got any feedback, suggestions, or bugs to report regarding the Collective website, go here!
Feedback (301)
|
|
|
|
|
|
recent articles
NPC and Item Placement Theory
17/03/05 11:35pm PST
Non-Player Character (NPC) and item placement can influence both the gameflow and immersion of a level. This article aims to give some pointers on how to properly place them.
- Hugh 'Hugh' Lloyd
|
|
Got Props?
13/03/05 08:32am PST
A common problem in HL2 mapping is props not showing up in game. This article explains why and offers solutions.
- Jeff 'Yesukai' Pritchard
|
|
Simulating Randomness
18/12/04 11:29pm PST
This article focuses on how to properly simulate random events that should occur at a certain average frequency, or within a certain probability per period of time.
- Skyler 'Zipster' York
|
|
Your world in HL2
06/12/04 12:17am PST
This article gives tips and advice to anyone wanting to make custom photorealistic textures to be used in Half-Life 2.
- Oksid
|
|
Hiding in Shadow
21/08/04 01:11pm PDT
Describes how to create a function that has monsters disregard you if you are hiding in a certain level of "darkness," which can be set from within map properties.
- Anders [Wolf] Jenbo (NoBody)
|
|
Bump Mapping in Half-Life
08/08/04 11:58am PDT
Details a method of achieving real-time bump mapping in Half-Life, and provides an implementation of the algorithm.
- Francis 'DeathWish' Woodhouse
|
|
Real-Time "TRON 2.0" Glow For Low-Spec Hardware
19/06/04 02:06pm PDT
A sequel to the original "Real-Time 'TRON 2.0' Glow" article, this describes how to implement real-time glow that works on low-spec graphics cards.
- Francis 'DeathWish' Woodhouse
|
|
Hitboxes and Code
05/06/04 06:25pm PDT
How do I make only one part of a monster take damage? Learn about the relationship between model hitboxes and what you can do with them in a characters code.
- Jonathan 'Teh_Freak' Smith
|
|
|
|
|
|
|
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 to... 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. :) |
|
article created on Mon Jul 29, 2002 / 09:20am PDT
this item has been viewed 2104 times
|
[Half-Life / coding]
|
|
Only registered users can post comments. Have you registered yet?
user comments
displaying comments of normal or higher rating
1. |
MegaBrutal
Tue Mar 02, 2004 / 07:44am PST
|
|
|
COOL! I didn't know it! Thanks! Can I translate this article to my language, and upload to http://skin.half-life.hu ? |
|
2. |
Michiel "MuzzleFlash" Breddels
Mon Oct 04, 2004 / 10:11am PDT
|
|
|
This tutorial unclear, escpecially that grid part. Would post the whole grid with the BlackOps inccluded? I can't figure it out with only the first and last part. |
|
|
|
|
|