Welcome, Guest! Login | Register

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

Introduction
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.


NONEMACHPLYRHPASSHMILAMILAPASSAMONSTAPREYAPREDINSECTPLRALLYPBWPNABWP
NONER_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NO
MACHINER_NOR_NOR_DLR_DLR_NOR_DLR_DLR_DLR_DLR_DLR_NOR_DLR_DLR_DL
PLAYERR_NOR_DLR_NOR_NOR_DLR_DLR_DLR_DLR_DLR_DLR_NOR_NOR_DLR_DL
HUMANPASSIVER_NOR_NOR_ALR_ALR_HTR_FRR_NOR_HTR_DLR_FRR_NOR_ALR_NOR_NO
HUMANMILITARYR_NOR_NOR_HTR_DLR_NOR_HTR_DLR_DLR_DLR_DLR_NOR_HTR_NOR_NO
ALIENMILITARYR_NOR_DLR_HTR_DLR_HTR_NOR_NOR_NOR_NOR_NOR_NOR_DLR_NOR_NO
ALIENPASSIVER_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NOR_NO
ALIENMONSTERR_NOR_DLR_DLR_DLR_DLR_NOR_NOR_NOR_NOR_NOR_NOR_DLR_NOR_NO
ALIENPREYR_NOR_NOR_DLR_DLR_DLR_NOR_NOR_NOR_NOR_FRR_NOR_DLR_NOR_NO
ALIENPREDATORR_NOR_NOR_DLR_DLR_DLR_NOR_NOR_NOR_HTR_DLR_NOR_DLR_NOR_NO
INSECTR_FRR_FRR_FRR_FRR_FRR_NOR_FRR_FRR_FRR_FRR_NOR_FRR_NOR_NO
PLAYERALLYR_NOR_DLR_ALR_ALR_DLR_DLR_DLR_DLR_DLR_DLR_NOR_NOR_NOR_NO
PBIOWEAPONR_NOR_NOR_DLR_DLR_DLR_DLR_DLR_DLR_DLR_DLR_NOR_DLR_NOR_DL
ABIOWEAPONR_NOR_NOR_DLR_DLR_DLR_ALR_NOR_DLR_DLR_NOR_NOR_DLR_DLR_NO

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_PLAYERCBasePlayer
CLASS_HUMAN_PASSIVECScientist, CSittingScientist
CLASS_HUMAN_MILITARYCApache, CHAssassin, CHGrunt, CDeadHGrunt, CDeadHEV
CLASS_ALIEN_MILITARYCAgrunt, CController, CIslave, CNihilanth, CSqueakGrenade*
CLASS_ALIEN_PASSIVE
CLASS_ALIEN_MONSTERCBarnacle, CBigMomma, CBloater, CGargantua, CHoundeye, CIchthyosaur, CTentacle, CZombie
CLASS_ALIEN_PREYCHeadCrab
CLASS_ALIEN_PREDATORCBullsquid
CLASS_INSECTCLeech, CRat, CRoach, CSqueakGrenade*
CLASS_PLAYER_ALLYCBarney, CDeadBarney, CGenericMonster
CLASS_PLAYER_BIOWEAPONCHornet*
CLASS_ALIEN_BIOWEAPONCHornet*, CSqueakGrenade*


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

Tips
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 :
 QUOTE  

       int CBasePlayer::Classify ( void )
       {

        if ( m_i HasKey )
         {

       return CLASS_PLAYER;
         }
       else
         {

       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 06:12:42
hmm i could also use the code for team based npcs thx

Posted By: MIFUNE on Jan 29 2005 at 08: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 04 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
Spinning Corpses Simple Fix
Half-Life | Coding | Snippets
By: darkPhoenix | Sep 05 2008
 
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
2 People Online (37 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!