Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/sites/a/ on line 20
Wavelength | Your Game Editing Resource | Relation between monsters
Welcome, Guest! Login | Register

Relation between monsters [Print this Article]
Posted by: Bob le Pointu
Date posted: May 22 2003
User Rating: 5 out of 5.0
Number of views: 5277
Number of comments: 2
Description: Relations between monsters, and a tip to
2°)Relations between classes
3°)Classes of monsters

Relations between monsters, and a tip to make them interact with the player

Relations between classes
Here there is the ladder of relation levels, and what they do :
R_AL (Ally) Monster will help player.
R_FR (Fear) Monster will run away.
R_NO (None relation) Monster won't do anything.
R_DL (Dislike) Monster will attack the player.
R_HT (Hatred) Monster will attack the player in first.
R_NM (NEMESIS) Monster will ALWAYS attack the player.


To read this table, begin by the left : HUMANPASSVIE R_AL PLYR, but PLAYER R_NO HPASS, it's important.

Classes of monsters
CLASS_NONECCrossbowBolt, CGman, CFurniture, CBaseTurret*,CSentry, CTurret, CMiniTurret
CLASS_MACHINECOsprey, CGunTarget, CBaseTurret*
CLASS_HUMAN_PASSIVECScientist, CSittingScientist
CLASS_HUMAN_MILITARYCApache, CHAssassin, CHGrunt, CDeadHGrunt, CDeadHEV
CLASS_ALIEN_MILITARYCAgrunt, CController, CIslave, CNihilanth, CSqueakGrenade*
CLASS_ALIEN_MONSTERCBarnacle, CBigMomma, CBloater, CGargantua, CHoundeye, CIchthyosaur, CTentacle, CZombie
CLASS_INSECTCLeech, CRat, CRoach, CSqueakGrenade*
CLASS_PLAYER_ALLYCBarney, CDeadBarney, CGenericMonster

* : These can have more than one classe. Now you can see this tutorial is helpfull ;>

Imagine we want to do this scenario:
The hero enters into a temple to steal a key. This temple is full of zombies. Lucky guy, it seems they don't do anything when they see him. Hero steals the key, and he will see all the zombies coming towards him.
Let's code: First, the zombies need to have no reaction with player, so they must be R_NO. Zombie is CLASS_ALIEN_MONSTER and player is CLASS_PLAYER. Look at the relations table, ALIENMONSTER R_DL PLYR, so the zombie dislike player. We must change the player class to make the zombie have no reaction, for example CLASS_ALIEN_PASSIVE.

Now, in CBasePlayer class, go to Classifyfunction and change CLASS_PLAYER byCLASS_ALIEN_PASSIVE.
Since he has taken the key, we want him to be attacked by zombies, so
we will make the player class : CLASS_PLAYER.

In this same function, check if he has the key, and return the good result.
For example it could be like this :

       int CBasePlayer::Classify ( void )

        if ( m_i HasKey )

       return CLASS_PLAYER;

       return CLASS_ALIEN_PASSIVE;


It's all now, if you see errors or want explanations, just ask.

Rate This Article
This article is currently rated: 5 out of 5.0 (2 Votes)

You have to register to rate this article.
User Comments Showing comments 1-2

Posted By: mathew on Mar 12 2004 at 12:12:42
hmm i could also use the code for team based npcs thx

Posted By: MIFUNE on Jan 29 2005 at 14:36:45
I wonder If itĀ“s possible to do the Turrets attack only your foes, and certain monsters attack only a specific ally.

You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 05 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005

Latest Comments
knock knock
General | News
By: MIFUNE | Dec 31 2017
knock knock
General | News
By: omega | Dec 22 2016
knock knock
General | News
By: MIFUNE | Oct 10 2015
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
knock knock
General | News
By: Whistler | Nov 05 2011
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (8 guests)
About - Credits - Contact Us

Wavelength version:
Valid XHTML 1.0! Valid CSS!