Fix windows compilation.

This commit is contained in:
Giegue
2023-02-01 01:07:35 -03:00
parent 87210e5f6c
commit 0fd2d27b6f
144 changed files with 59972 additions and 59705 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +1,52 @@
/*** /***
* *
* Copyright (c) 1999, 2000, Valve LLC. All rights reserved. * Copyright (c) 1999, 2000, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* crc.h */ /* crc.h */
#ifndef CRC_H #ifndef CRC_H
#define CRC_H #define CRC_H
#ifdef _WIN32 #ifdef _WIN32
#pragma once #pragma once
#endif #endif
// MD5 Hash // MD5 Hash
typedef struct typedef struct
{ {
unsigned int buf[4]; unsigned int buf[4];
unsigned int bits[2]; unsigned int bits[2];
unsigned char in[64]; unsigned char in[64];
} MD5Context_t; } MD5Context_t;
typedef unsigned long CRC32_t; typedef unsigned long CRC32_t;
void CRC32_Init(CRC32_t *pulCRC); void CRC32_Init(CRC32_t *pulCRC);
CRC32_t CRC32_Final(CRC32_t pulCRC); CRC32_t CRC32_Final(CRC32_t pulCRC);
void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len);
void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch);
int CRC_File(CRC32_t *crcvalue, char *pszFileName); int CRC_File(CRC32_t *crcvalue, char *pszFileName);
unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence); unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence);
void MD5Init(MD5Context_t *context); void MD5Init(MD5Context_t *context);
void MD5Update(MD5Context_t *context, unsigned char const *buf, void MD5Update(MD5Context_t *context, unsigned char const *buf,
unsigned int len); unsigned int len);
void MD5Final(unsigned char digest[16], MD5Context_t *context); void MD5Final(unsigned char digest[16], MD5Context_t *context);
void Transform(unsigned int buf[4], unsigned int const in[16]); void Transform(unsigned int buf[4], unsigned int const in[16]);
int MD5_Hash_File(unsigned char digest[16], char *pszFileName, int bUsefopen, int bSeed, unsigned int seed[4]); int MD5_Hash_File(unsigned char digest[16], char *pszFileName, int bUsefopen, int bSeed, unsigned int seed[4]);
char *MD5_Print(unsigned char hash[16]); char *MD5_Print(unsigned char hash[16]);
int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]); int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]);
int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName); int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName);
#endif #endif

View File

@@ -1,36 +1,36 @@
/*** /***
* *
* Copyright (c) 1999, 2000, Valve LLC. All rights reserved. * Copyright (c) 1999, 2000, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef CVARDEF_H #ifndef CVARDEF_H
#define CVARDEF_H #define CVARDEF_H
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc #define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO (1<<1) // changes the client's info string #define FCVAR_USERINFO (1<<1) // changes the client's info string
#define FCVAR_SERVER (1<<2) // notifies players when changed #define FCVAR_SERVER (1<<2) // notifies players when changed
#define FCVAR_EXTDLL (1<<3) // defined by external DLL #define FCVAR_EXTDLL (1<<3) // defined by external DLL
#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll #define FCVAR_CLIENTDLL (1<<4) // defined by the client dll
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value #define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. #define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). #define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log #define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
typedef struct cvar_s typedef struct cvar_s
{ {
char *name; char *name;
char *string; char *string;
int flags; int flags;
float value; float value;
struct cvar_s *next; struct cvar_s *next;
} cvar_t; } cvar_t;
#endif #endif

View File

@@ -1,193 +1,193 @@
/*** /***
* *
* Copyright (c) 1999, 2000 Valve LLC. All rights reserved. * Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( ENTITY_STATEH ) #if !defined( ENTITY_STATEH )
#define ENTITY_STATEH #define ENTITY_STATEH
#ifdef _WIN32 #ifdef _WIN32
#pragma once #pragma once
#endif #endif
// For entityType below // For entityType below
#define ENTITY_NORMAL (1<<0) #define ENTITY_NORMAL (1<<0)
#define ENTITY_BEAM (1<<1) #define ENTITY_BEAM (1<<1)
// Entity state is used for the baseline and for delta compression of a packet of // Entity state is used for the baseline and for delta compression of a packet of
// entities that is sent to a client. // entities that is sent to a client.
typedef struct entity_state_s entity_state_t; typedef struct entity_state_s entity_state_t;
struct entity_state_s struct entity_state_s
{ {
// Fields which are filled in by routines outside of delta compression // Fields which are filled in by routines outside of delta compression
int entityType; int entityType;
// Index into cl_entities array for this entity. // Index into cl_entities array for this entity.
int number; int number;
float msg_time; float msg_time;
// Message number last time the player/entity state was updated. // Message number last time the player/entity state was updated.
int messagenum; int messagenum;
// Fields which can be transitted and reconstructed over the network stream // Fields which can be transitted and reconstructed over the network stream
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
int modelindex; int modelindex;
int sequence; int sequence;
float frame; float frame;
int colormap; int colormap;
short skin; short skin;
short solid; short solid;
int effects; int effects;
float scale; float scale;
byte eflags; byte eflags;
// Render information // Render information
int rendermode; int rendermode;
int renderamt; int renderamt;
color24 rendercolor; color24 rendercolor;
int renderfx; int renderfx;
int movetype; int movetype;
float animtime; float animtime;
float framerate; float framerate;
int body; int body;
byte controller[4]; byte controller[4];
byte blending[4]; byte blending[4];
vec3_t velocity; vec3_t velocity;
// Send bbox down to client for use during prediction. // Send bbox down to client for use during prediction.
vec3_t mins; vec3_t mins;
vec3_t maxs; vec3_t maxs;
int aiment; int aiment;
// If owned by a player, the index of that player ( for projectiles ). // If owned by a player, the index of that player ( for projectiles ).
int owner; int owner;
// Friction, for prediction. // Friction, for prediction.
float friction; float friction;
// Gravity multiplier // Gravity multiplier
float gravity; float gravity;
// PLAYER SPECIFIC // PLAYER SPECIFIC
int team; int team;
int playerclass; int playerclass;
int health; int health;
qboolean spectator; qboolean spectator;
int weaponmodel; int weaponmodel;
int gaitsequence; int gaitsequence;
// If standing on conveyor, e.g. // If standing on conveyor, e.g.
vec3_t basevelocity; vec3_t basevelocity;
// Use the crouched hull, or the regular player hull. // Use the crouched hull, or the regular player hull.
int usehull; int usehull;
// Latched buttons last time state updated. // Latched buttons last time state updated.
int oldbuttons; int oldbuttons;
// -1 = in air, else pmove entity number // -1 = in air, else pmove entity number
int onground; int onground;
int iStepLeft; int iStepLeft;
// How fast we are falling // How fast we are falling
float flFallVelocity; float flFallVelocity;
float fov; float fov;
int weaponanim; int weaponanim;
// Parametric movement overrides // Parametric movement overrides
vec3_t startpos; vec3_t startpos;
vec3_t endpos; vec3_t endpos;
float impacttime; float impacttime;
float starttime; float starttime;
// For mods // For mods
int iuser1; int iuser1;
int iuser2; int iuser2;
int iuser3; int iuser3;
int iuser4; int iuser4;
float fuser1; float fuser1;
float fuser2; float fuser2;
float fuser3; float fuser3;
float fuser4; float fuser4;
vec3_t vuser1; vec3_t vuser1;
vec3_t vuser2; vec3_t vuser2;
vec3_t vuser3; vec3_t vuser3;
vec3_t vuser4; vec3_t vuser4;
}; };
#include "pm_info.h" #include "pm_info.h"
typedef struct clientdata_s typedef struct clientdata_s
{ {
vec3_t origin; vec3_t origin;
vec3_t velocity; vec3_t velocity;
int viewmodel; int viewmodel;
vec3_t punchangle; vec3_t punchangle;
int flags; int flags;
int waterlevel; int waterlevel;
int watertype; int watertype;
vec3_t view_ofs; vec3_t view_ofs;
float health; float health;
int bInDuck; int bInDuck;
int weapons; // remove? int weapons; // remove?
int flTimeStepSound; int flTimeStepSound;
int flDuckTime; int flDuckTime;
int flSwimTime; int flSwimTime;
int waterjumptime; int waterjumptime;
float maxspeed; float maxspeed;
float fov; float fov;
int weaponanim; int weaponanim;
int m_iId; int m_iId;
int ammo_shells; int ammo_shells;
int ammo_nails; int ammo_nails;
int ammo_cells; int ammo_cells;
int ammo_rockets; int ammo_rockets;
float m_flNextAttack; float m_flNextAttack;
int tfstate; int tfstate;
int pushmsec; int pushmsec;
int deadflag; int deadflag;
char physinfo[ MAX_PHYSINFO_STRING ]; char physinfo[ MAX_PHYSINFO_STRING ];
// For mods // For mods
int iuser1; int iuser1;
int iuser2; int iuser2;
int iuser3; int iuser3;
int iuser4; int iuser4;
float fuser1; float fuser1;
float fuser2; float fuser2;
float fuser3; float fuser3;
float fuser4; float fuser4;
vec3_t vuser1; vec3_t vuser1;
vec3_t vuser2; vec3_t vuser2;
vec3_t vuser3; vec3_t vuser3;
vec3_t vuser4; vec3_t vuser4;
} clientdata_t; } clientdata_t;
#include "weaponinfo.h" #include "weaponinfo.h"
typedef struct local_state_s typedef struct local_state_s
{ {
entity_state_t playerstate; entity_state_t playerstate;
clientdata_t client; clientdata_t client;
weapon_data_t weapondata[ 32 ]; weapon_data_t weapondata[ 32 ];
} local_state_t; } local_state_t;
#endif // !ENTITY_STATEH #endif // !ENTITY_STATEH

View File

@@ -1,47 +1,47 @@
/*** /***
* *
* Copyright (c) 1999, 2000, Valve LLC. All rights reserved. * Copyright (c) 1999, 2000, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( EVENT_FLAGSH ) #if !defined( EVENT_FLAGSH )
#define EVENT_FLAGSH #define EVENT_FLAGSH
#ifdef _WIN32 #ifdef _WIN32
#pragma once #pragma once
#endif #endif
// Skip local host for event send. // Skip local host for event send.
#define FEV_NOTHOST (1<<0) #define FEV_NOTHOST (1<<0)
// Send the event reliably. You must specify the origin and angles and use // Send the event reliably. You must specify the origin and angles and use
// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything // PLAYBACK_EVENT_FULL for this to work correctly on the server for anything
// that depends on the event origin/angles. I.e., the origin/angles are not // that depends on the event origin/angles. I.e., the origin/angles are not
// taken from the invoking edict for reliable events. // taken from the invoking edict for reliable events.
#define FEV_RELIABLE (1<<1) #define FEV_RELIABLE (1<<1)
// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC // Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC
// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ). // sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ).
#define FEV_GLOBAL (1<<2) #define FEV_GLOBAL (1<<2)
// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate // If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate
// //
#define FEV_UPDATE (1<<3) #define FEV_UPDATE (1<<3)
// Only send to entity specified as the invoker // Only send to entity specified as the invoker
#define FEV_HOSTONLY (1<<4) #define FEV_HOSTONLY (1<<4)
// Only send if the event was created on the server. // Only send if the event was created on the server.
#define FEV_SERVER (1<<5) #define FEV_SERVER (1<<5)
// Only issue event client side ( from shared code ) // Only issue event client side ( from shared code )
#define FEV_CLIENT (1<<6) #define FEV_CLIENT (1<<6)
#endif #endif

View File

@@ -1,38 +1,38 @@
/*** /***
* *
* Copyright (c) 1999, 2000, Valve LLC. All rights reserved. * Copyright (c) 1999, 2000, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef IN_BUTTONS_H #ifndef IN_BUTTONS_H
#define IN_BUTTONS_H #define IN_BUTTONS_H
#ifdef _WIN32 #ifdef _WIN32
#pragma once #pragma once
#endif #endif
#define IN_ATTACK (1 << 0) #define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1) #define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2) #define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3) #define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4) #define IN_BACK (1 << 4)
#define IN_USE (1 << 5) #define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6) #define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7) #define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8) #define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9) #define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10) #define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11) #define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12) #define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13) #define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14) #define IN_ALT1 (1 << 14)
#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down #define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down
#endif // IN_BUTTONS_H #endif // IN_BUTTONS_H

View File

@@ -1,15 +1,15 @@
//========= Copyright <20> 1996-2001, Valve LLC, All rights reserved. ============ //========= Copyright <20> 1996-2001, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#ifndef INC_NOWIN_H #ifndef INC_NOWIN_H
#define INC_NOWIN_H #define INC_NOWIN_H
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>
#endif //!_WIN32 #endif //!_WIN32
#endif //INC_NOWIN_H #endif //INC_NOWIN_H

View File

@@ -1,29 +1,29 @@
/*** /***
* *
* Copyright (c) 1999, 2000, Valve LLC. All rights reserved. * Copyright (c) 1999, 2000, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( STUDIO_EVENTH ) #if !defined( STUDIO_EVENTH )
#define STUDIO_EVENTH #define STUDIO_EVENTH
#ifdef _WIN32 #ifdef _WIN32
#pragma once #pragma once
#endif #endif
typedef struct mstudioevent_s typedef struct mstudioevent_s
{ {
int frame; int frame;
int event; int event;
int type; int type;
char options[64]; char options[64];
} mstudioevent_t; } mstudioevent_t;
#endif // STUDIO_EVENTH #endif // STUDIO_EVENTH

8
src/dlls/.gitignore vendored
View File

@@ -1,5 +1,5 @@
msgs/ msgs/
opt.*/ opt.*/
debug.*/ debug.*/
*.o *.o
*.so *.so

File diff suppressed because it is too large Load Diff

View File

@@ -1,109 +1,109 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef ACTIVITY_H #ifndef ACTIVITY_H
#define ACTIVITY_H #define ACTIVITY_H
typedef enum { typedef enum {
ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity
ACT_IDLE = 1, ACT_IDLE = 1,
ACT_GUARD, ACT_GUARD,
ACT_WALK, ACT_WALK,
ACT_RUN, ACT_RUN,
ACT_FLY, // Fly (and flap if appropriate) ACT_FLY, // Fly (and flap if appropriate)
ACT_SWIM, ACT_SWIM,
ACT_HOP, // vertical jump ACT_HOP, // vertical jump
ACT_LEAP, // long forward jump ACT_LEAP, // long forward jump
ACT_FALL, ACT_FALL,
ACT_LAND, ACT_LAND,
ACT_STRAFE_LEFT, ACT_STRAFE_LEFT,
ACT_STRAFE_RIGHT, ACT_STRAFE_RIGHT,
ACT_ROLL_LEFT, // tuck and roll, left ACT_ROLL_LEFT, // tuck and roll, left
ACT_ROLL_RIGHT, // tuck and roll, right ACT_ROLL_RIGHT, // tuck and roll, right
ACT_TURN_LEFT, // turn quickly left (stationary) ACT_TURN_LEFT, // turn quickly left (stationary)
ACT_TURN_RIGHT, // turn quickly right (stationary) ACT_TURN_RIGHT, // turn quickly right (stationary)
ACT_CROUCH, // the act of crouching down from a standing position ACT_CROUCH, // the act of crouching down from a standing position
ACT_CROUCHIDLE, // holding body in crouched position (loops) ACT_CROUCHIDLE, // holding body in crouched position (loops)
ACT_STAND, // the act of standing from a crouched position ACT_STAND, // the act of standing from a crouched position
ACT_USE, ACT_USE,
ACT_SIGNAL1, ACT_SIGNAL1,
ACT_SIGNAL2, ACT_SIGNAL2,
ACT_SIGNAL3, ACT_SIGNAL3,
ACT_TWITCH, ACT_TWITCH,
ACT_COWER, ACT_COWER,
ACT_SMALL_FLINCH, ACT_SMALL_FLINCH,
ACT_BIG_FLINCH, ACT_BIG_FLINCH,
ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK1,
ACT_RANGE_ATTACK2, ACT_RANGE_ATTACK2,
ACT_MELEE_ATTACK1, ACT_MELEE_ATTACK1,
ACT_MELEE_ATTACK2, ACT_MELEE_ATTACK2,
ACT_RELOAD, ACT_RELOAD,
ACT_ARM, // pull out gun, for instance ACT_ARM, // pull out gun, for instance
ACT_DISARM, // reholster gun ACT_DISARM, // reholster gun
ACT_EAT, // monster chowing on a large food item (loop) ACT_EAT, // monster chowing on a large food item (loop)
ACT_DIESIMPLE, ACT_DIESIMPLE,
ACT_DIEBACKWARD, ACT_DIEBACKWARD,
ACT_DIEFORWARD, ACT_DIEFORWARD,
ACT_DIEVIOLENT, ACT_DIEVIOLENT,
ACT_BARNACLE_HIT, // barnacle tongue hits a monster ACT_BARNACLE_HIT, // barnacle tongue hits a monster
ACT_BARNACLE_PULL, // barnacle is lifting the monster ( loop ) ACT_BARNACLE_PULL, // barnacle is lifting the monster ( loop )
ACT_BARNACLE_CHOMP, // barnacle latches on to the monster ACT_BARNACLE_CHOMP, // barnacle latches on to the monster
ACT_BARNACLE_CHEW, // barnacle is holding the monster in its mouth ( loop ) ACT_BARNACLE_CHEW, // barnacle is holding the monster in its mouth ( loop )
ACT_SLEEP, ACT_SLEEP,
ACT_INSPECT_FLOOR, // for active idles, look at something on or near the floor ACT_INSPECT_FLOOR, // for active idles, look at something on or near the floor
ACT_INSPECT_WALL, // for active idles, look at something directly ahead of you ( doesn't HAVE to be a wall or on a wall ) ACT_INSPECT_WALL, // for active idles, look at something directly ahead of you ( doesn't HAVE to be a wall or on a wall )
ACT_IDLE_ANGRY, // alternate idle animation in which the monster is clearly agitated. (loop) ACT_IDLE_ANGRY, // alternate idle animation in which the monster is clearly agitated. (loop)
ACT_WALK_HURT, // limp (loop) ACT_WALK_HURT, // limp (loop)
ACT_RUN_HURT, // limp (loop) ACT_RUN_HURT, // limp (loop)
ACT_HOVER, // Idle while in flight ACT_HOVER, // Idle while in flight
ACT_GLIDE, // Fly (don't flap) ACT_GLIDE, // Fly (don't flap)
ACT_FLY_LEFT, // Turn left in flight ACT_FLY_LEFT, // Turn left in flight
ACT_FLY_RIGHT, // Turn right in flight ACT_FLY_RIGHT, // Turn right in flight
ACT_DETECT_SCENT, // this means the monster smells a scent carried by the air ACT_DETECT_SCENT, // this means the monster smells a scent carried by the air
ACT_SNIFF, // this is the act of actually sniffing an item in front of the monster ACT_SNIFF, // this is the act of actually sniffing an item in front of the monster
ACT_BITE, // some large monsters can eat small things in one bite. This plays one time, EAT loops. ACT_BITE, // some large monsters can eat small things in one bite. This plays one time, EAT loops.
ACT_THREAT_DISPLAY, // without attacking, monster demonstrates that it is angry. (Yell, stick out chest, etc ) ACT_THREAT_DISPLAY, // without attacking, monster demonstrates that it is angry. (Yell, stick out chest, etc )
ACT_FEAR_DISPLAY, // monster just saw something that it is afraid of ACT_FEAR_DISPLAY, // monster just saw something that it is afraid of
ACT_EXCITED, // for some reason, monster is excited. Sees something he really likes to eat, or whatever. ACT_EXCITED, // for some reason, monster is excited. Sees something he really likes to eat, or whatever.
ACT_SPECIAL_ATTACK1, // very monster specific special attacks. ACT_SPECIAL_ATTACK1, // very monster specific special attacks.
ACT_SPECIAL_ATTACK2, ACT_SPECIAL_ATTACK2,
ACT_COMBAT_IDLE, // agitated idle. ACT_COMBAT_IDLE, // agitated idle.
ACT_WALK_SCARED, ACT_WALK_SCARED,
ACT_RUN_SCARED, ACT_RUN_SCARED,
ACT_VICTORY_DANCE, // killed a player, do a victory dance. ACT_VICTORY_DANCE, // killed a player, do a victory dance.
ACT_DIE_HEADSHOT, // die, hit in head. ACT_DIE_HEADSHOT, // die, hit in head.
ACT_DIE_CHESTSHOT, // die, hit in chest ACT_DIE_CHESTSHOT, // die, hit in chest
ACT_DIE_GUTSHOT, // die, hit in gut ACT_DIE_GUTSHOT, // die, hit in gut
ACT_DIE_BACKSHOT, // die, hit in back ACT_DIE_BACKSHOT, // die, hit in back
ACT_FLINCH_HEAD, ACT_FLINCH_HEAD,
ACT_FLINCH_CHEST, ACT_FLINCH_CHEST,
ACT_FLINCH_STOMACH, ACT_FLINCH_STOMACH,
ACT_FLINCH_LEFTARM, ACT_FLINCH_LEFTARM,
ACT_FLINCH_RIGHTARM, ACT_FLINCH_RIGHTARM,
ACT_FLINCH_LEFTLEG, ACT_FLINCH_LEFTLEG,
ACT_FLINCH_RIGHTLEG, ACT_FLINCH_RIGHTLEG,
} Activity; } Activity;
typedef struct { typedef struct {
int type; int type;
char *name; char *name;
} activity_map_t; } activity_map_t;
extern activity_map_t activity_map[]; extern activity_map_t activity_map[];
#endif //ACTIVITY_H #endif //ACTIVITY_H

View File

@@ -1,97 +1,97 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#define _A( a ) { a, #a } #define _A( a ) { a, #a }
activity_map_t activity_map[] = activity_map_t activity_map[] =
{ {
_A( ACT_IDLE ), _A( ACT_IDLE ),
_A( ACT_GUARD ), _A( ACT_GUARD ),
_A( ACT_WALK ), _A( ACT_WALK ),
_A( ACT_RUN ), _A( ACT_RUN ),
_A( ACT_FLY ), _A( ACT_FLY ),
_A( ACT_SWIM ), _A( ACT_SWIM ),
_A( ACT_HOP ), _A( ACT_HOP ),
_A( ACT_LEAP ), _A( ACT_LEAP ),
_A( ACT_FALL ), _A( ACT_FALL ),
_A( ACT_LAND ), _A( ACT_LAND ),
_A( ACT_STRAFE_LEFT ), _A( ACT_STRAFE_LEFT ),
_A( ACT_STRAFE_RIGHT ), _A( ACT_STRAFE_RIGHT ),
_A( ACT_ROLL_LEFT ), _A( ACT_ROLL_LEFT ),
_A( ACT_ROLL_RIGHT ), _A( ACT_ROLL_RIGHT ),
_A( ACT_TURN_LEFT ), _A( ACT_TURN_LEFT ),
_A( ACT_TURN_RIGHT ), _A( ACT_TURN_RIGHT ),
_A( ACT_CROUCH ), _A( ACT_CROUCH ),
_A( ACT_CROUCHIDLE ), _A( ACT_CROUCHIDLE ),
_A( ACT_STAND ), _A( ACT_STAND ),
_A( ACT_USE ), _A( ACT_USE ),
_A( ACT_SIGNAL1 ), _A( ACT_SIGNAL1 ),
_A( ACT_SIGNAL2 ), _A( ACT_SIGNAL2 ),
_A( ACT_SIGNAL3 ), _A( ACT_SIGNAL3 ),
_A( ACT_TWITCH ), _A( ACT_TWITCH ),
_A( ACT_COWER ), _A( ACT_COWER ),
_A( ACT_SMALL_FLINCH ), _A( ACT_SMALL_FLINCH ),
_A( ACT_BIG_FLINCH ), _A( ACT_BIG_FLINCH ),
_A( ACT_RANGE_ATTACK1 ), _A( ACT_RANGE_ATTACK1 ),
_A( ACT_RANGE_ATTACK2 ), _A( ACT_RANGE_ATTACK2 ),
_A( ACT_MELEE_ATTACK1 ), _A( ACT_MELEE_ATTACK1 ),
_A( ACT_MELEE_ATTACK2 ), _A( ACT_MELEE_ATTACK2 ),
_A( ACT_RELOAD ), _A( ACT_RELOAD ),
_A( ACT_ARM ), _A( ACT_ARM ),
_A( ACT_DISARM ), _A( ACT_DISARM ),
_A( ACT_EAT ), _A( ACT_EAT ),
_A( ACT_DIESIMPLE ), _A( ACT_DIESIMPLE ),
_A( ACT_DIEBACKWARD ), _A( ACT_DIEBACKWARD ),
_A( ACT_DIEFORWARD ), _A( ACT_DIEFORWARD ),
_A( ACT_DIEVIOLENT ), _A( ACT_DIEVIOLENT ),
_A( ACT_BARNACLE_HIT ), _A( ACT_BARNACLE_HIT ),
_A( ACT_BARNACLE_PULL ), _A( ACT_BARNACLE_PULL ),
_A( ACT_BARNACLE_CHOMP ), _A( ACT_BARNACLE_CHOMP ),
_A( ACT_BARNACLE_CHEW ), _A( ACT_BARNACLE_CHEW ),
_A( ACT_SLEEP ), _A( ACT_SLEEP ),
_A( ACT_INSPECT_FLOOR ), _A( ACT_INSPECT_FLOOR ),
_A( ACT_INSPECT_WALL ), _A( ACT_INSPECT_WALL ),
_A( ACT_IDLE_ANGRY ), _A( ACT_IDLE_ANGRY ),
_A( ACT_WALK_HURT ), _A( ACT_WALK_HURT ),
_A( ACT_RUN_HURT ), _A( ACT_RUN_HURT ),
_A( ACT_HOVER ), _A( ACT_HOVER ),
_A( ACT_GLIDE ), _A( ACT_GLIDE ),
_A( ACT_FLY_LEFT ), _A( ACT_FLY_LEFT ),
_A( ACT_FLY_RIGHT ), _A( ACT_FLY_RIGHT ),
_A( ACT_DETECT_SCENT ), _A( ACT_DETECT_SCENT ),
_A( ACT_SNIFF ), _A( ACT_SNIFF ),
_A( ACT_BITE ), _A( ACT_BITE ),
_A( ACT_THREAT_DISPLAY ), _A( ACT_THREAT_DISPLAY ),
_A( ACT_FEAR_DISPLAY ), _A( ACT_FEAR_DISPLAY ),
_A( ACT_EXCITED ), _A( ACT_EXCITED ),
_A( ACT_SPECIAL_ATTACK1 ), _A( ACT_SPECIAL_ATTACK1 ),
_A( ACT_SPECIAL_ATTACK2 ), _A( ACT_SPECIAL_ATTACK2 ),
_A( ACT_COMBAT_IDLE ), _A( ACT_COMBAT_IDLE ),
_A( ACT_WALK_SCARED ), _A( ACT_WALK_SCARED ),
_A( ACT_RUN_SCARED ), _A( ACT_RUN_SCARED ),
_A( ACT_VICTORY_DANCE ), _A( ACT_VICTORY_DANCE ),
_A( ACT_DIE_HEADSHOT ), _A( ACT_DIE_HEADSHOT ),
_A( ACT_DIE_CHESTSHOT ), _A( ACT_DIE_CHESTSHOT ),
_A( ACT_DIE_GUTSHOT ), _A( ACT_DIE_GUTSHOT ),
_A( ACT_DIE_BACKSHOT ), _A( ACT_DIE_BACKSHOT ),
_A( ACT_FLINCH_HEAD ), _A( ACT_FLINCH_HEAD ),
_A( ACT_FLINCH_CHEST ), _A( ACT_FLINCH_CHEST ),
_A( ACT_FLINCH_STOMACH ), _A( ACT_FLINCH_STOMACH ),
_A( ACT_FLINCH_LEFTARM ), _A( ACT_FLINCH_LEFTARM ),
_A( ACT_FLINCH_RIGHTARM ), _A( ACT_FLINCH_RIGHTARM ),
_A( ACT_FLINCH_LEFTLEG ), _A( ACT_FLINCH_LEFTLEG ),
_A( ACT_FLINCH_RIGHTLEG ), _A( ACT_FLINCH_RIGHTLEG ),
0, NULL 0, NULL
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -1,306 +1,306 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
===== monsters.cpp ======================================================== ===== monsters.cpp ========================================================
Monster-related utility code Monster-related utility code
*/ */
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "animation.h" #include "animation.h"
//========================================================= //=========================================================
// StudioFrameAdvance - advance the animation frame up to the current time // StudioFrameAdvance - advance the animation frame up to the current time
// if an flInterval is passed in, only advance animation that number of seconds // if an flInterval is passed in, only advance animation that number of seconds
//========================================================= //=========================================================
float CMBaseAnimating :: StudioFrameAdvance ( float flInterval ) float CMBaseAnimating :: StudioFrameAdvance ( float flInterval )
{ {
if (flInterval == 0.0) if (flInterval == 0.0)
{ {
flInterval = (gpGlobals->time - pev->animtime); flInterval = (gpGlobals->time - pev->animtime);
if (flInterval <= 0.001) if (flInterval <= 0.001)
{ {
pev->animtime = gpGlobals->time; pev->animtime = gpGlobals->time;
return 0.0; return 0.0;
} }
} }
if (! pev->animtime) if (! pev->animtime)
flInterval = 0.0; flInterval = 0.0;
pev->frame += flInterval * m_flFrameRate * pev->framerate; pev->frame += flInterval * m_flFrameRate * pev->framerate;
pev->animtime = gpGlobals->time; pev->animtime = gpGlobals->time;
if (pev->frame < 0.0 || pev->frame >= 256.0) if (pev->frame < 0.0 || pev->frame >= 256.0)
{ {
if (m_fSequenceLoops) if (m_fSequenceLoops)
pev->frame -= (int)(pev->frame / 256.0) * 256.0; pev->frame -= (int)(pev->frame / 256.0) * 256.0;
else else
pev->frame = (pev->frame < 0.0) ? 0 : 255; pev->frame = (pev->frame < 0.0) ? 0 : 255;
m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents
} }
return flInterval; return flInterval;
} }
//========================================================= //=========================================================
// LookupActivity // LookupActivity
//========================================================= //=========================================================
int CMBaseAnimating :: LookupActivity ( int activity ) int CMBaseAnimating :: LookupActivity ( int activity )
{ {
ASSERT( activity != 0 ); ASSERT( activity != 0 );
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupActivity( pmodel, pev, activity ); return ::LookupActivity( pmodel, pev, activity );
} }
//========================================================= //=========================================================
// LookupActivityHeaviest // LookupActivityHeaviest
// //
// Get activity with highest 'weight' // Get activity with highest 'weight'
// //
//========================================================= //=========================================================
int CMBaseAnimating :: LookupActivityHeaviest ( int activity ) int CMBaseAnimating :: LookupActivityHeaviest ( int activity )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupActivityHeaviest( pmodel, pev, activity ); return ::LookupActivityHeaviest( pmodel, pev, activity );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
int CMBaseAnimating :: LookupSequence ( const char *label ) int CMBaseAnimating :: LookupSequence ( const char *label )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::LookupSequence( pmodel, label ); return ::LookupSequence( pmodel, label );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CMBaseAnimating :: ResetSequenceInfo ( ) void CMBaseAnimating :: ResetSequenceInfo ( )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed ); GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed );
m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0); m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0);
pev->animtime = gpGlobals->time; pev->animtime = gpGlobals->time;
pev->framerate = 1.0; pev->framerate = 1.0;
m_fSequenceFinished = FALSE; m_fSequenceFinished = FALSE;
m_flLastEventCheck = gpGlobals->time; m_flLastEventCheck = gpGlobals->time;
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
BOOL CMBaseAnimating :: GetSequenceFlags( ) BOOL CMBaseAnimating :: GetSequenceFlags( )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::GetSequenceFlags( pmodel, pev ); return ::GetSequenceFlags( pmodel, pev );
} }
//========================================================= //=========================================================
// DispatchAnimEvents // DispatchAnimEvents
//========================================================= //=========================================================
void CMBaseAnimating :: DispatchAnimEvents ( float flInterval ) void CMBaseAnimating :: DispatchAnimEvents ( float flInterval )
{ {
MonsterEvent_t event; MonsterEvent_t event;
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
if ( !pmodel ) if ( !pmodel )
{ {
ALERT( at_aiconsole, "Gibbed monster is thinking!\n" ); ALERT( at_aiconsole, "Gibbed monster is thinking!\n" );
return; return;
} }
// FIXME: I have to do this or some events get missed, and this is probably causing the problem below // FIXME: I have to do this or some events get missed, and this is probably causing the problem below
flInterval = 0.1; flInterval = 0.1;
// FIX: this still sometimes hits events twice // FIX: this still sometimes hits events twice
float flStart = pev->frame + (m_flLastEventCheck - pev->animtime) * m_flFrameRate * pev->framerate; float flStart = pev->frame + (m_flLastEventCheck - pev->animtime) * m_flFrameRate * pev->framerate;
float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate; float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate;
m_flLastEventCheck = pev->animtime + flInterval; m_flLastEventCheck = pev->animtime + flInterval;
m_fSequenceFinished = FALSE; m_fSequenceFinished = FALSE;
if (flEnd >= 256 || flEnd <= 0.0) if (flEnd >= 256 || flEnd <= 0.0)
m_fSequenceFinished = TRUE; m_fSequenceFinished = TRUE;
int index = 0; int index = 0;
while ( (index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 ) while ( (index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 )
{ {
HandleAnimEvent( &event ); HandleAnimEvent( &event );
} }
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
float CMBaseAnimating :: SetBoneController ( int iController, float flValue ) float CMBaseAnimating :: SetBoneController ( int iController, float flValue )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
return SetController( pmodel, pev, iController, flValue ); return SetController( pmodel, pev, iController, flValue );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CMBaseAnimating :: InitBoneControllers ( void ) void CMBaseAnimating :: InitBoneControllers ( void )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
SetController( pmodel, pev, 0, 0.0 ); SetController( pmodel, pev, 0, 0.0 );
SetController( pmodel, pev, 1, 0.0 ); SetController( pmodel, pev, 1, 0.0 );
SetController( pmodel, pev, 2, 0.0 ); SetController( pmodel, pev, 2, 0.0 );
SetController( pmodel, pev, 3, 0.0 ); SetController( pmodel, pev, 3, 0.0 );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
float CMBaseAnimating :: SetBlending ( int iBlender, float flValue ) float CMBaseAnimating :: SetBlending ( int iBlender, float flValue )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
return ::SetBlending( pmodel, pev, iBlender, flValue ); return ::SetBlending( pmodel, pev, iBlender, flValue );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CMBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) void CMBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles )
{ {
GET_BONE_POSITION( ENT(pev), iBone, origin, angles ); GET_BONE_POSITION( ENT(pev), iBone, origin, angles );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CMBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) void CMBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles )
{ {
GET_ATTACHMENT( ENT(pev), iAttachment, origin, angles ); GET_ATTACHMENT( ENT(pev), iAttachment, origin, angles );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
int CMBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) int CMBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir )
{ {
void *pmodel = GET_MODEL_PTR( ENT(pev) ); void *pmodel = GET_MODEL_PTR( ENT(pev) );
if (piDir == NULL) if (piDir == NULL)
{ {
int iDir; int iDir;
int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir ); int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir );
if (iDir != 1) if (iDir != 1)
return -1; return -1;
else else
return sequence; return sequence;
} }
return ::FindTransition( pmodel, iEndingSequence, iGoalSequence, piDir ); return ::FindTransition( pmodel, iEndingSequence, iGoalSequence, piDir );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CMBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) void CMBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval )
{ {
} }
void CMBaseAnimating :: SetBodygroup( int iGroup, int iValue ) void CMBaseAnimating :: SetBodygroup( int iGroup, int iValue )
{ {
::SetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup, iValue ); ::SetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup, iValue );
} }
int CMBaseAnimating :: GetBodygroup( int iGroup ) int CMBaseAnimating :: GetBodygroup( int iGroup )
{ {
return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup ); return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup );
} }
int CMBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs ) int CMBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs )
{ {
return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs ); return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CMBaseAnimating :: SetSequenceBox( void ) void CMBaseAnimating :: SetSequenceBox( void )
{ {
Vector mins, maxs; Vector mins, maxs;
// Get sequence bbox // Get sequence bbox
if ( ExtractBbox( pev->sequence, mins, maxs ) ) if ( ExtractBbox( pev->sequence, mins, maxs ) )
{ {
// expand box for rotation // expand box for rotation
// find min / max for rotations // find min / max for rotations
float yaw = pev->angles.y * (M_PI / 180.0); float yaw = pev->angles.y * (M_PI / 180.0);
Vector xvector, yvector; Vector xvector, yvector;
xvector.x = cos(yaw); xvector.x = cos(yaw);
xvector.y = sin(yaw); xvector.y = sin(yaw);
yvector.x = -sin(yaw); yvector.x = -sin(yaw);
yvector.y = cos(yaw); yvector.y = cos(yaw);
Vector bounds[2]; Vector bounds[2];
bounds[0] = mins; bounds[0] = mins;
bounds[1] = maxs; bounds[1] = maxs;
Vector rmin( 9999, 9999, 9999 ); Vector rmin( 9999, 9999, 9999 );
Vector rmax( -9999, -9999, -9999 ); Vector rmax( -9999, -9999, -9999 );
Vector base, transformed; Vector base, transformed;
for (int i = 0; i <= 1; i++ ) for (int i = 0; i <= 1; i++ )
{ {
base.x = bounds[i].x; base.x = bounds[i].x;
for ( int j = 0; j <= 1; j++ ) for ( int j = 0; j <= 1; j++ )
{ {
base.y = bounds[j].y; base.y = bounds[j].y;
for ( int k = 0; k <= 1; k++ ) for ( int k = 0; k <= 1; k++ )
{ {
base.z = bounds[k].z; base.z = bounds[k].z;
// transform the point // transform the point
transformed.x = xvector.x*base.x + yvector.x*base.y; transformed.x = xvector.x*base.x + yvector.x*base.y;
transformed.y = xvector.y*base.x + yvector.y*base.y; transformed.y = xvector.y*base.x + yvector.y*base.y;
transformed.z = base.z; transformed.z = base.z;
if (transformed.x < rmin.x) if (transformed.x < rmin.x)
rmin.x = transformed.x; rmin.x = transformed.x;
if (transformed.x > rmax.x) if (transformed.x > rmax.x)
rmax.x = transformed.x; rmax.x = transformed.x;
if (transformed.y < rmin.y) if (transformed.y < rmin.y)
rmin.y = transformed.y; rmin.y = transformed.y;
if (transformed.y > rmax.y) if (transformed.y > rmax.y)
rmax.y = transformed.y; rmax.y = transformed.y;
if (transformed.z < rmin.z) if (transformed.z < rmin.z)
rmin.z = transformed.z; rmin.z = transformed.z;
if (transformed.z > rmax.z) if (transformed.z > rmax.z)
rmax.z = transformed.z; rmax.z = transformed.z;
} }
} }
} }
rmin.z = 0; rmin.z = 0;
rmax.z = rmin.z + 1; rmax.z = rmin.z + 1;
UTIL_SetSize( pev, rmin, rmax ); UTIL_SetSize( pev, rmin, rmax );
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,47 +1,47 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef ANIMATION_H #ifndef ANIMATION_H
#define ANIMATION_H #define ANIMATION_H
#define ACTIVITY_NOT_AVAILABLE -1 #define ACTIVITY_NOT_AVAILABLE -1
#ifndef MONSTEREVENT_H #ifndef MONSTEREVENT_H
#include "monsterevent.h" #include "monsterevent.h"
#endif #endif
extern int IsSoundEvent( int eventNumber ); extern int IsSoundEvent( int eventNumber );
int LookupActivity( void *pmodel, entvars_t *pev, int activity ); int LookupActivity( void *pmodel, entvars_t *pev, int activity );
int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity ); int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity );
int LookupSequence( void *pmodel, const char *label ); int LookupSequence( void *pmodel, const char *label );
void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed ); void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed );
int GetSequenceFlags( void *pmodel, entvars_t *pev ); int GetSequenceFlags( void *pmodel, entvars_t *pev );
int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd ); int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd );
float SetController( void *pmodel, entvars_t *pev, int iController, float flValue ); float SetController( void *pmodel, entvars_t *pev, int iController, float flValue );
float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ); float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue );
void GetEyePosition( void *pmodel, float *vecEyePosition ); void GetEyePosition( void *pmodel, float *vecEyePosition );
void SequencePrecache( void *pmodel, const char *pSequenceName ); void SequencePrecache( void *pmodel, const char *pSequenceName );
int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ); int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir );
void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue ); void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue );
int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup ); int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup );
int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index ); int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index );
int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ); int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs );
// From /engine/studio.h // From /engine/studio.h
#define STUDIO_LOOPING 0x0001 #define STUDIO_LOOPING 0x0001
#endif //ANIMATION_H #endif //ANIMATION_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,46 +1,46 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cdll_dll.h // cdll_dll.h
// this file is included by both the game-dll and the client-dll, // this file is included by both the game-dll and the client-dll,
#ifndef CDLL_DLL_H #ifndef CDLL_DLL_H
#define CDLL_DLL_H #define CDLL_DLL_H
#define MAX_WEAPONS 32 // ??? #define MAX_WEAPONS 32 // ???
#define MAX_WEAPON_SLOTS 5 // hud item selection slots #define MAX_WEAPON_SLOTS 5 // hud item selection slots
#define MAX_ITEM_TYPES 6 // hud item selection slots #define MAX_ITEM_TYPES 6 // hud item selection slots
#define MAX_ITEMS 5 // hard coded item types #define MAX_ITEMS 5 // hard coded item types
#define HIDEHUD_WEAPONS ( 1<<0 ) #define HIDEHUD_WEAPONS ( 1<<0 )
#define HIDEHUD_FLASHLIGHT ( 1<<1 ) #define HIDEHUD_FLASHLIGHT ( 1<<1 )
#define HIDEHUD_ALL ( 1<<2 ) #define HIDEHUD_ALL ( 1<<2 )
#define HIDEHUD_HEALTH ( 1<<3 ) #define HIDEHUD_HEALTH ( 1<<3 )
#define MAX_AMMO_TYPES 32 // ??? #define MAX_AMMO_TYPES 32 // ???
#define MAX_AMMO_SLOTS 32 // not really slots #define MAX_AMMO_SLOTS 32 // not really slots
#define HUD_PRINTNOTIFY 1 #define HUD_PRINTNOTIFY 1
#define HUD_PRINTCONSOLE 2 #define HUD_PRINTCONSOLE 2
#define HUD_PRINTTALK 3 #define HUD_PRINTTALK 3
#define HUD_PRINTCENTER 4 #define HUD_PRINTCENTER 4
#define WEAPON_SUIT 31 #define WEAPON_SUIT 31
#endif #endif

View File

@@ -1,306 +1,306 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "decals.h" #include "decals.h"
extern Vector VecBModelOrigin( entvars_t* pevBModel ); extern Vector VecBModelOrigin( entvars_t* pevBModel );
extern DLL_GLOBAL Vector g_vecAttackDir; extern DLL_GLOBAL Vector g_vecAttackDir;
edict_t * EHANDLE::Get( void ) edict_t * EHANDLE::Get( void )
{ {
if (m_pent) if (m_pent)
{ {
if (m_pent->serialnumber == m_serialnumber) if (m_pent->serialnumber == m_serialnumber)
return m_pent; return m_pent;
else else
return NULL; return NULL;
} }
return NULL; return NULL;
}; };
edict_t * EHANDLE::Set( edict_t *pent ) edict_t * EHANDLE::Set( edict_t *pent )
{ {
m_pent = pent; m_pent = pent;
if (pent) if (pent)
m_serialnumber = m_pent->serialnumber; m_serialnumber = m_pent->serialnumber;
return pent; return pent;
}; };
EHANDLE :: operator edict_t *() EHANDLE :: operator edict_t *()
{ {
return Get( ); return Get( );
}; };
edict_t * EHANDLE :: operator = (edict_t *pEntity) edict_t * EHANDLE :: operator = (edict_t *pEntity)
{ {
if (pEntity) if (pEntity)
{ {
m_pent = pEntity; m_pent = pEntity;
if (m_pent) if (m_pent)
m_serialnumber = m_pent->serialnumber; m_serialnumber = m_pent->serialnumber;
} }
else else
{ {
m_pent = NULL; m_pent = NULL;
m_serialnumber = 0; m_serialnumber = 0;
} }
return pEntity; return pEntity;
} }
edict_t * EHANDLE :: operator -> () edict_t * EHANDLE :: operator -> ()
{ {
return Get( ); return Get( );
} }
void *CMBaseEntity::operator new( size_t stAllocateBlock ) void *CMBaseEntity::operator new( size_t stAllocateBlock )
{ {
void *mem = ::operator new( stAllocateBlock ); void *mem = ::operator new( stAllocateBlock );
memset( mem, 0, stAllocateBlock ); memset( mem, 0, stAllocateBlock );
return mem; return mem;
} }
edict_t *CMBaseEntity::CreateEntity(char *classname) edict_t *CMBaseEntity::CreateEntity(char *classname)
{ {
int istr = MAKE_STRING(classname); int istr = MAKE_STRING(classname);
edict_t *pent = CREATE_NAMED_ENTITY(istr); edict_t *pent = CREATE_NAMED_ENTITY(istr);
if ( FNullEnt( pent ) ) if ( FNullEnt( pent ) )
return NULL; return NULL;
pev = VARS(pent); pev = VARS(pent);
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->flags = 0; pev->flags = 0;
m_pfnThink = NULL; m_pfnThink = NULL;
m_pfnTouch = NULL; m_pfnTouch = NULL;
m_pfnUse = NULL; m_pfnUse = NULL;
m_pfnBlocked = NULL; m_pfnBlocked = NULL;
pev->euser4 = (edict_t *)this; pev->euser4 = (edict_t *)this;
return pent; return pent;
} }
// give health // give health
int CMBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) int CMBaseEntity :: TakeHealth( float flHealth, int bitsDamageType )
{ {
if (!pev->takedamage) if (!pev->takedamage)
return 0; return 0;
// heal // heal
if ( pev->health >= pev->max_health ) if ( pev->health >= pev->max_health )
return 0; return 0;
pev->health += flHealth; pev->health += flHealth;
if (pev->health > pev->max_health) if (pev->health > pev->max_health)
pev->health = pev->max_health; pev->health = pev->max_health;
return 1; return 1;
} }
// inflict damage on this entity. bitsDamageType indicates type of damage inflicted, ie: DMG_CRUSH // inflict damage on this entity. bitsDamageType indicates type of damage inflicted, ie: DMG_CRUSH
int CMBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ) int CMBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType )
{ {
Vector vecTemp; Vector vecTemp;
if (!pev->takedamage) if (!pev->takedamage)
return 0; return 0;
// UNDONE: some entity types may be immune or resistant to some bitsDamageType // UNDONE: some entity types may be immune or resistant to some bitsDamageType
// if Attacker == Inflictor, the attack was a melee or other instant-hit attack. // if Attacker == Inflictor, the attack was a melee or other instant-hit attack.
// (that is, no actual entity projectile was involved in the attack so use the shooter's origin). // (that is, no actual entity projectile was involved in the attack so use the shooter's origin).
if ( pevAttacker == pevInflictor ) if ( pevAttacker == pevInflictor )
{ {
vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) ); vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) );
} }
else else
// an actual missile was involved. // an actual missile was involved.
{ {
vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) ); vecTemp = pevInflictor->origin - ( VecBModelOrigin(pev) );
} }
// this global is still used for glass and other non-monster killables, along with decals. // this global is still used for glass and other non-monster killables, along with decals.
g_vecAttackDir = vecTemp.Normalize(); g_vecAttackDir = vecTemp.Normalize();
// save damage based on the target's armor level // save damage based on the target's armor level
// figure momentum add (don't let hurt brushes or other triggers move player) // figure momentum add (don't let hurt brushes or other triggers move player)
if ((!FNullEnt(pevInflictor)) && (pev->movetype == MOVETYPE_WALK || pev->movetype == MOVETYPE_STEP) && (pevAttacker->solid != SOLID_TRIGGER) ) if ((!FNullEnt(pevInflictor)) && (pev->movetype == MOVETYPE_WALK || pev->movetype == MOVETYPE_STEP) && (pevAttacker->solid != SOLID_TRIGGER) )
{ {
Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5;
vecDir = vecDir.Normalize(); vecDir = vecDir.Normalize();
float flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; float flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5;
if (flForce > 1000.0) if (flForce > 1000.0)
flForce = 1000.0; flForce = 1000.0;
pev->velocity = pev->velocity + vecDir * flForce; pev->velocity = pev->velocity + vecDir * flForce;
} }
// do the damage // do the damage
pev->health -= flDamage; pev->health -= flDamage;
if (pev->health <= 0) if (pev->health <= 0)
{ {
Killed( pevAttacker, GIB_NORMAL ); Killed( pevAttacker, GIB_NORMAL );
return 0; return 0;
} }
return 1; return 1;
} }
void CMBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) void CMBaseEntity :: Killed( entvars_t *pevAttacker, int iGib )
{ {
pev->takedamage = DAMAGE_NO; pev->takedamage = DAMAGE_NO;
pev->deadflag = DEAD_DEAD; pev->deadflag = DEAD_DEAD;
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
} }
// Initialize absmin & absmax to the appropriate box // Initialize absmin & absmax to the appropriate box
void SetObjectCollisionBox( entvars_t *pev ) void SetObjectCollisionBox( entvars_t *pev )
{ {
if ( (pev->solid == SOLID_BSP) && if ( (pev->solid == SOLID_BSP) &&
(pev->angles.x || pev->angles.y|| pev->angles.z) ) (pev->angles.x || pev->angles.y|| pev->angles.z) )
{ // expand for rotation { // expand for rotation
float max, v; float max, v;
int i; int i;
max = 0; max = 0;
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
{ {
v = fabs( ((float *)pev->mins)[i]); v = fabs( ((float *)pev->mins)[i]);
if (v > max) if (v > max)
max = v; max = v;
v = fabs( ((float *)pev->maxs)[i]); v = fabs( ((float *)pev->maxs)[i]);
if (v > max) if (v > max)
max = v; max = v;
} }
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
{ {
((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max; ((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max;
((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max; ((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max;
} }
} }
else else
{ {
pev->absmin = pev->origin + pev->mins; pev->absmin = pev->origin + pev->mins;
pev->absmax = pev->origin + pev->maxs; pev->absmax = pev->origin + pev->maxs;
} }
pev->absmin.x -= 1; pev->absmin.x -= 1;
pev->absmin.y -= 1; pev->absmin.y -= 1;
pev->absmin.z -= 1; pev->absmin.z -= 1;
pev->absmax.x += 1; pev->absmax.x += 1;
pev->absmax.y += 1; pev->absmax.y += 1;
pev->absmax.z += 1; pev->absmax.z += 1;
} }
void CMBaseEntity::SetObjectCollisionBox( void ) void CMBaseEntity::SetObjectCollisionBox( void )
{ {
::SetObjectCollisionBox( pev ); ::SetObjectCollisionBox( pev );
} }
int CMBaseEntity :: Intersects( CMBaseEntity *pOther ) int CMBaseEntity :: Intersects( CMBaseEntity *pOther )
{ {
if ( pOther->pev->absmin.x > pev->absmax.x || if ( pOther->pev->absmin.x > pev->absmax.x ||
pOther->pev->absmin.y > pev->absmax.y || pOther->pev->absmin.y > pev->absmax.y ||
pOther->pev->absmin.z > pev->absmax.z || pOther->pev->absmin.z > pev->absmax.z ||
pOther->pev->absmax.x < pev->absmin.x || pOther->pev->absmax.x < pev->absmin.x ||
pOther->pev->absmax.y < pev->absmin.y || pOther->pev->absmax.y < pev->absmin.y ||
pOther->pev->absmax.z < pev->absmin.z ) pOther->pev->absmax.z < pev->absmin.z )
return 0; return 0;
return 1; return 1;
} }
void CMBaseEntity :: MakeDormant( void ) void CMBaseEntity :: MakeDormant( void )
{ {
SetBits( pev->flags, FL_DORMANT ); SetBits( pev->flags, FL_DORMANT );
// Don't touch // Don't touch
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
// Don't move // Don't move
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
// Don't draw // Don't draw
SetBits( pev->effects, EF_NODRAW ); SetBits( pev->effects, EF_NODRAW );
// Don't think // Don't think
pev->nextthink = 0; pev->nextthink = 0;
// Relink // Relink
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
} }
int CMBaseEntity :: IsDormant( void ) int CMBaseEntity :: IsDormant( void )
{ {
return FBitSet( pev->flags, FL_DORMANT ); return FBitSet( pev->flags, FL_DORMANT );
} }
BOOL CMBaseEntity :: IsInWorld( void ) BOOL CMBaseEntity :: IsInWorld( void )
{ {
// position // position
if (pev->origin.x >= 4096) return FALSE; if (pev->origin.x >= 4096) return FALSE;
if (pev->origin.y >= 4096) return FALSE; if (pev->origin.y >= 4096) return FALSE;
if (pev->origin.z >= 4096) return FALSE; if (pev->origin.z >= 4096) return FALSE;
if (pev->origin.x <= -4096) return FALSE; if (pev->origin.x <= -4096) return FALSE;
if (pev->origin.y <= -4096) return FALSE; if (pev->origin.y <= -4096) return FALSE;
if (pev->origin.z <= -4096) return FALSE; if (pev->origin.z <= -4096) return FALSE;
// speed // speed
if (pev->velocity.x >= 2000) return FALSE; if (pev->velocity.x >= 2000) return FALSE;
if (pev->velocity.y >= 2000) return FALSE; if (pev->velocity.y >= 2000) return FALSE;
if (pev->velocity.z >= 2000) return FALSE; if (pev->velocity.z >= 2000) return FALSE;
if (pev->velocity.x <= -2000) return FALSE; if (pev->velocity.x <= -2000) return FALSE;
if (pev->velocity.y <= -2000) return FALSE; if (pev->velocity.y <= -2000) return FALSE;
if (pev->velocity.z <= -2000) return FALSE; if (pev->velocity.z <= -2000) return FALSE;
return TRUE; return TRUE;
} }
int CMBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) int CMBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState )
{ {
if ( useType != USE_TOGGLE && useType != USE_SET ) if ( useType != USE_TOGGLE && useType != USE_SET )
{ {
if ( (currentState && useType == USE_ON) || (!currentState && useType == USE_OFF) ) if ( (currentState && useType == USE_ON) || (!currentState && useType == USE_OFF) )
return 0; return 0;
} }
return 1; return 1;
} }
int CMBaseEntity :: DamageDecal( int bitsDamageType ) int CMBaseEntity :: DamageDecal( int bitsDamageType )
{ {
if ( pev->rendermode == kRenderTransAlpha ) if ( pev->rendermode == kRenderTransAlpha )
return -1; return -1;
if ( pev->rendermode != kRenderNormal ) if ( pev->rendermode != kRenderNormal )
return DECAL_BPROOF1; return DECAL_BPROOF1;
return DECAL_GUNSHOT1 + RANDOM_LONG(0,4); return DECAL_GUNSHOT1 + RANDOM_LONG(0,4);
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,53 +1,53 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
// Base class for flying monsters. This overrides the movement test & execution code from CBaseMonster // Base class for flying monsters. This overrides the movement test & execution code from CBaseMonster
#ifndef FLYINGMONSTER_H #ifndef FLYINGMONSTER_H
#define FLYINGMONSTER_H #define FLYINGMONSTER_H
class CMFlyingMonster : public CMBaseMonster class CMFlyingMonster : public CMBaseMonster
{ {
public: public:
int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, edict_t *pTarget, float *pflDist );// check validity of a straight move through space int CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, edict_t *pTarget, float *pflDist );// check validity of a straight move through space
BOOL FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, edict_t *pTargetEnt, Vector *pApex ); BOOL FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, edict_t *pTargetEnt, Vector *pApex );
Activity GetStoppedActivity( void ); Activity GetStoppedActivity( void );
void Killed( entvars_t *pevAttacker, int iGib ); void Killed( entvars_t *pevAttacker, int iGib );
void Stop( void ); void Stop( void );
float ChangeYaw( int speed ); float ChangeYaw( int speed );
void HandleAnimEvent( MonsterEvent_t *pEvent ); void HandleAnimEvent( MonsterEvent_t *pEvent );
void MoveExecute( edict_t *pTargetEnt, const Vector &vecDir, float flInterval ); void MoveExecute( edict_t *pTargetEnt, const Vector &vecDir, float flInterval );
void Move( float flInterval = 0.1 ); void Move( float flInterval = 0.1 );
BOOL ShouldAdvanceRoute( float flWaypointDist ); BOOL ShouldAdvanceRoute( float flWaypointDist );
inline void SetFlyingMomentum( float momentum ) { m_momentum = momentum; } inline void SetFlyingMomentum( float momentum ) { m_momentum = momentum; }
inline void SetFlyingFlapSound( const char *pFlapSound ) { m_pFlapSound = pFlapSound; } inline void SetFlyingFlapSound( const char *pFlapSound ) { m_pFlapSound = pFlapSound; }
inline void SetFlyingSpeed( float speed ) { m_flightSpeed = speed; } inline void SetFlyingSpeed( float speed ) { m_flightSpeed = speed; }
float CeilingZ( const Vector &position ); float CeilingZ( const Vector &position );
float FloorZ( const Vector &position ); float FloorZ( const Vector &position );
BOOL ProbeZ( const Vector &position, const Vector &probe, float *pFraction ); BOOL ProbeZ( const Vector &position, const Vector &probe, float *pFraction );
// UNDONE: Save/restore this stuff!!! // UNDONE: Save/restore this stuff!!!
protected: protected:
Vector m_vecTravel; // Current direction Vector m_vecTravel; // Current direction
float m_flightSpeed; // Current flight speed (decays when not flapping or gliding) float m_flightSpeed; // Current flight speed (decays when not flapping or gliding)
float m_stopTime; // Last time we stopped (to avoid switching states too soon) float m_stopTime; // Last time we stopped (to avoid switching states too soon)
float m_momentum; // Weight for desired vs. momentum velocity float m_momentum; // Weight for desired vs. momentum velocity
const char *m_pFlapSound; const char *m_pFlapSound;
}; };
#endif //FLYINGMONSTER_H #endif //FLYINGMONSTER_H

View File

@@ -1,178 +1,178 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
#ifndef TALKMONSTER_H #ifndef TALKMONSTER_H
#define TALKMONSTER_H #define TALKMONSTER_H
#ifndef MONSTERS_H #ifndef MONSTERS_H
#include "monsters.h" #include "monsters.h"
#endif #endif
//========================================================= //=========================================================
// Talking monster base class // Talking monster base class
// Used for scientists and barneys // Used for scientists and barneys
//========================================================= //=========================================================
#define TALKRANGE_MIN 500.0 // don't talk to anyone farther away than this #define TALKRANGE_MIN 500.0 // don't talk to anyone farther away than this
#define TLK_STARE_DIST 128 // anyone closer than this and looking at me is probably staring at me. #define TLK_STARE_DIST 128 // anyone closer than this and looking at me is probably staring at me.
#define bit_saidDamageLight (1<<0) // bits so we don't repeat key sentences #define bit_saidDamageLight (1<<0) // bits so we don't repeat key sentences
#define bit_saidDamageMedium (1<<1) #define bit_saidDamageMedium (1<<1)
#define bit_saidDamageHeavy (1<<2) #define bit_saidDamageHeavy (1<<2)
#define bit_saidHelloPlayer (1<<3) #define bit_saidHelloPlayer (1<<3)
#define bit_saidWoundLight (1<<4) #define bit_saidWoundLight (1<<4)
#define bit_saidWoundHeavy (1<<5) #define bit_saidWoundHeavy (1<<5)
#define bit_saidHeard (1<<6) #define bit_saidHeard (1<<6)
#define bit_saidSmelled (1<<7) #define bit_saidSmelled (1<<7)
#define TLK_CFRIENDS 3 #define TLK_CFRIENDS 3
typedef enum typedef enum
{ {
TLK_ANSWER = 0, TLK_ANSWER = 0,
TLK_QUESTION, TLK_QUESTION,
TLK_IDLE, TLK_IDLE,
TLK_STARE, TLK_STARE,
TLK_USE, TLK_USE,
TLK_UNUSE, TLK_UNUSE,
TLK_STOP, TLK_STOP,
TLK_NOSHOOT, TLK_NOSHOOT,
TLK_HELLO, TLK_HELLO,
TLK_PHELLO, TLK_PHELLO,
TLK_PIDLE, TLK_PIDLE,
TLK_PQUESTION, TLK_PQUESTION,
TLK_PLHURT1, TLK_PLHURT1,
TLK_PLHURT2, TLK_PLHURT2,
TLK_PLHURT3, TLK_PLHURT3,
TLK_SMELL, TLK_SMELL,
TLK_WOUND, TLK_WOUND,
TLK_MORTAL, TLK_MORTAL,
TLK_CGROUPS, // MUST be last entry TLK_CGROUPS, // MUST be last entry
} TALKGROUPNAMES; } TALKGROUPNAMES;
enum enum
{ {
SCHED_CANT_FOLLOW = LAST_COMMON_SCHEDULE + 1, SCHED_CANT_FOLLOW = LAST_COMMON_SCHEDULE + 1,
SCHED_MOVE_AWAY, // Try to get out of the player's way SCHED_MOVE_AWAY, // Try to get out of the player's way
SCHED_MOVE_AWAY_FOLLOW, // same, but follow afterward SCHED_MOVE_AWAY_FOLLOW, // same, but follow afterward
SCHED_MOVE_AWAY_FAIL, // Turn back toward player SCHED_MOVE_AWAY_FAIL, // Turn back toward player
LAST_TALKMONSTER_SCHEDULE, // MUST be last LAST_TALKMONSTER_SCHEDULE, // MUST be last
}; };
enum enum
{ {
TASK_CANT_FOLLOW = LAST_COMMON_TASK + 1, TASK_CANT_FOLLOW = LAST_COMMON_TASK + 1,
TASK_MOVE_AWAY_PATH, TASK_MOVE_AWAY_PATH,
TASK_WALK_PATH_FOR_UNITS, TASK_WALK_PATH_FOR_UNITS,
TASK_TLK_RESPOND, // say my response TASK_TLK_RESPOND, // say my response
TASK_TLK_SPEAK, // question or remark TASK_TLK_SPEAK, // question or remark
TASK_TLK_HELLO, // Try to say hello to player TASK_TLK_HELLO, // Try to say hello to player
TASK_TLK_HEADRESET, // reset head position TASK_TLK_HEADRESET, // reset head position
TASK_TLK_STOPSHOOTING, // tell player to stop shooting friend TASK_TLK_STOPSHOOTING, // tell player to stop shooting friend
TASK_TLK_STARE, // let the player know I know he's staring at me. TASK_TLK_STARE, // let the player know I know he's staring at me.
TASK_TLK_LOOK_AT_CLIENT,// faces player if not moving and not talking and in idle. TASK_TLK_LOOK_AT_CLIENT,// faces player if not moving and not talking and in idle.
TASK_TLK_CLIENT_STARE, // same as look at client, but says something if the player stares. TASK_TLK_CLIENT_STARE, // same as look at client, but says something if the player stares.
TASK_TLK_EYECONTACT, // maintain eyecontact with person who I'm talking to TASK_TLK_EYECONTACT, // maintain eyecontact with person who I'm talking to
TASK_TLK_IDEALYAW, // set ideal yaw to face who I'm talking to TASK_TLK_IDEALYAW, // set ideal yaw to face who I'm talking to
TASK_FACE_PLAYER, // Face the player TASK_FACE_PLAYER, // Face the player
LAST_TALKMONSTER_TASK, // MUST be last LAST_TALKMONSTER_TASK, // MUST be last
}; };
class CMTalkMonster : public CMBaseMonster class CMTalkMonster : public CMBaseMonster
{ {
public: public:
void TalkInit( void ); void TalkInit( void );
edict_t *FindNearestFriend(BOOL fPlayer); edict_t *FindNearestFriend(BOOL fPlayer);
float TargetDistance( void ); float TargetDistance( void );
void StopTalking( void ) { SentenceStop(); } void StopTalking( void ) { SentenceStop(); }
// Base Monster functions // Base Monster functions
void Precache( void ); void Precache( void );
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
void TalkTouch( edict_t *pOther ); void TalkTouch( edict_t *pOther );
void Killed( entvars_t *pevAttacker, int iGib ); void Killed( entvars_t *pevAttacker, int iGib );
int IRelationship ( CMBaseEntity *pTarget ); int IRelationship ( CMBaseEntity *pTarget );
virtual int CanPlaySentence( BOOL fDisregardState ); virtual int CanPlaySentence( BOOL fDisregardState );
virtual void PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ); virtual void PlaySentence( const char *pszSentence, float duration, float volume, float attenuation );
void PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, edict_t *pListener ); void PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, edict_t *pListener );
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
// AI functions // AI functions
void SetActivity ( Activity newActivity ); void SetActivity ( Activity newActivity );
Schedule_t *GetScheduleOfType ( int Type ); Schedule_t *GetScheduleOfType ( int Type );
void StartTask( Task_t *pTask ); void StartTask( Task_t *pTask );
void RunTask( Task_t *pTask ); void RunTask( Task_t *pTask );
void HandleAnimEvent( MonsterEvent_t *pEvent ); void HandleAnimEvent( MonsterEvent_t *pEvent );
void PrescheduleThink( void ); void PrescheduleThink( void );
// Conversations / communication // Conversations / communication
int GetVoicePitch( void ); int GetVoicePitch( void );
void IdleRespond( void ); void IdleRespond( void );
int FIdleSpeak( void ); int FIdleSpeak( void );
int FIdleStare( void ); int FIdleStare( void );
int FIdleHello( void ); int FIdleHello( void );
void IdleHeadTurn( Vector &vecFriend ); void IdleHeadTurn( Vector &vecFriend );
int FOkToSpeak( void ); int FOkToSpeak( void );
void TrySmellTalk( void ); void TrySmellTalk( void );
edict_t *EnumFriends( edict_t *pentPrevious, int listNumber, BOOL bTrace ); edict_t *EnumFriends( edict_t *pentPrevious, int listNumber, BOOL bTrace );
void AlertFriends( void ); void AlertFriends( void );
void ShutUpFriends( void ); void ShutUpFriends( void );
BOOL IsTalking( void ); BOOL IsTalking( void );
void Talk( float flDuration ); void Talk( float flDuration );
// For following // For following
BOOL CanFollow( void ); BOOL CanFollow( void );
BOOL IsFollowing( void ) { return m_hTargetEnt != NULL && UTIL_IsPlayer(m_hTargetEnt); } BOOL IsFollowing( void ) { return m_hTargetEnt != NULL && UTIL_IsPlayer(m_hTargetEnt); }
void StopFollowing( BOOL clearSchedule ); void StopFollowing( BOOL clearSchedule );
void StartFollowing( edict_t *pLeader ); void StartFollowing( edict_t *pLeader );
virtual void DeclineFollowing( void ) {} virtual void DeclineFollowing( void ) {}
void LimitFollowers( edict_t *pPlayer, int maxFollowers ); void LimitFollowers( edict_t *pPlayer, int maxFollowers );
void EXPORT FollowerUse( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value ); void EXPORT FollowerUse( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value );
virtual void SetAnswerQuestion( edict_t *pSpeaker ); virtual void SetAnswerQuestion( edict_t *pSpeaker );
virtual int FriendNumber( int arrayNumber ) { return arrayNumber; } virtual int FriendNumber( int arrayNumber ) { return arrayNumber; }
static char *m_szFriends[TLK_CFRIENDS]; // array of friend names static char *m_szFriends[TLK_CFRIENDS]; // array of friend names
static float g_talkWaitTime; static float g_talkWaitTime;
int m_bitsSaid; // set bits for sentences we don't want repeated int m_bitsSaid; // set bits for sentences we don't want repeated
int m_nSpeak; // number of times initiated talking int m_nSpeak; // number of times initiated talking
int m_voicePitch; // pitch of voice for this head int m_voicePitch; // pitch of voice for this head
const char *m_szGrp[TLK_CGROUPS]; // sentence group names const char *m_szGrp[TLK_CGROUPS]; // sentence group names
float m_useTime; // Don't allow +USE until this time float m_useTime; // Don't allow +USE until this time
int m_iszUse; // Custom +USE sentence group (follow) int m_iszUse; // Custom +USE sentence group (follow)
int m_iszUnUse; // Custom +USE sentence group (stop following) int m_iszUnUse; // Custom +USE sentence group (stop following)
float m_flLastSaidSmelled;// last time we talked about something that stinks float m_flLastSaidSmelled;// last time we talked about something that stinks
float m_flStopTalkTime;// when in the future that I'll be done saying this sentence. float m_flStopTalkTime;// when in the future that I'll be done saying this sentence.
EHANDLE m_hTalkTarget; // who to look at while talking EHANDLE m_hTalkTarget; // who to look at while talking
CUSTOM_SCHEDULES; CUSTOM_SCHEDULES;
}; };
// Clients can push talkmonsters out of their way // Clients can push talkmonsters out of their way
#define bits_COND_CLIENT_PUSH ( bits_COND_SPECIAL1 ) #define bits_COND_CLIENT_PUSH ( bits_COND_SPECIAL1 )
// Don't see a client right now. // Don't see a client right now.
#define bits_COND_CLIENT_UNSEEN ( bits_COND_SPECIAL2 ) #define bits_COND_CLIENT_UNSEEN ( bits_COND_SPECIAL2 )
#endif //TALKMONSTER_H #endif //TALKMONSTER_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,75 +1,75 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef DECALS_H #ifndef DECALS_H
#define DECALS_H #define DECALS_H
// //
// Dynamic Decals // Dynamic Decals
// //
enum decal_e enum decal_e
{ {
DECAL_GUNSHOT1 = 0, DECAL_GUNSHOT1 = 0,
DECAL_GUNSHOT2, DECAL_GUNSHOT2,
DECAL_GUNSHOT3, DECAL_GUNSHOT3,
DECAL_GUNSHOT4, DECAL_GUNSHOT4,
DECAL_GUNSHOT5, DECAL_GUNSHOT5,
DECAL_LAMBDA1, DECAL_LAMBDA1,
DECAL_LAMBDA2, DECAL_LAMBDA2,
DECAL_LAMBDA3, DECAL_LAMBDA3,
DECAL_LAMBDA4, DECAL_LAMBDA4,
DECAL_LAMBDA5, DECAL_LAMBDA5,
DECAL_LAMBDA6, DECAL_LAMBDA6,
DECAL_SCORCH1, DECAL_SCORCH1,
DECAL_SCORCH2, DECAL_SCORCH2,
DECAL_BLOOD1, DECAL_BLOOD1,
DECAL_BLOOD2, DECAL_BLOOD2,
DECAL_BLOOD3, DECAL_BLOOD3,
DECAL_BLOOD4, DECAL_BLOOD4,
DECAL_BLOOD5, DECAL_BLOOD5,
DECAL_BLOOD6, DECAL_BLOOD6,
DECAL_YBLOOD1, DECAL_YBLOOD1,
DECAL_YBLOOD2, DECAL_YBLOOD2,
DECAL_YBLOOD3, DECAL_YBLOOD3,
DECAL_YBLOOD4, DECAL_YBLOOD4,
DECAL_YBLOOD5, DECAL_YBLOOD5,
DECAL_YBLOOD6, DECAL_YBLOOD6,
DECAL_GLASSBREAK1, DECAL_GLASSBREAK1,
DECAL_GLASSBREAK2, DECAL_GLASSBREAK2,
DECAL_GLASSBREAK3, DECAL_GLASSBREAK3,
DECAL_BIGSHOT1, DECAL_BIGSHOT1,
DECAL_BIGSHOT2, DECAL_BIGSHOT2,
DECAL_BIGSHOT3, DECAL_BIGSHOT3,
DECAL_BIGSHOT4, DECAL_BIGSHOT4,
DECAL_BIGSHOT5, DECAL_BIGSHOT5,
DECAL_SPIT1, DECAL_SPIT1,
DECAL_SPIT2, DECAL_SPIT2,
DECAL_BPROOF1, // Bulletproof glass decal DECAL_BPROOF1, // Bulletproof glass decal
DECAL_GARGSTOMP1, // Gargantua stomp crack DECAL_GARGSTOMP1, // Gargantua stomp crack
DECAL_SMALLSCORCH1, // Small scorch mark DECAL_SMALLSCORCH1, // Small scorch mark
DECAL_SMALLSCORCH2, // Small scorch mark DECAL_SMALLSCORCH2, // Small scorch mark
DECAL_SMALLSCORCH3, // Small scorch mark DECAL_SMALLSCORCH3, // Small scorch mark
DECAL_MOMMABIRTH, // Big momma birth splatter DECAL_MOMMABIRTH, // Big momma birth splatter
DECAL_MOMMASPLAT, DECAL_MOMMASPLAT,
}; };
typedef struct typedef struct
{ {
char *name; char *name;
int index; int index;
} DLL_DECALLIST; } DLL_DECALLIST;
extern DLL_DECALLIST gDecals[]; extern DLL_DECALLIST gDecals[];
#endif // DECALS_H #endif // DECALS_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,98 +1,98 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
#ifndef DEFAULTAI_H #ifndef DEFAULTAI_H
#define DEFAULTAI_H #define DEFAULTAI_H
//========================================================= //=========================================================
// Failed // Failed
//========================================================= //=========================================================
extern Schedule_t slFail[]; extern Schedule_t slFail[];
//========================================================= //=========================================================
// Idle Schedules // Idle Schedules
//========================================================= //=========================================================
extern Schedule_t slIdleStand[]; extern Schedule_t slIdleStand[];
extern Schedule_t slIdleTrigger[]; extern Schedule_t slIdleTrigger[];
extern Schedule_t slIdleWalk[]; extern Schedule_t slIdleWalk[];
//========================================================= //=========================================================
// Wake Schedules // Wake Schedules
//========================================================= //=========================================================
extern Schedule_t slWakeAngry[]; extern Schedule_t slWakeAngry[];
//========================================================= //=========================================================
// AlertTurn Schedules // AlertTurn Schedules
//========================================================= //=========================================================
extern Schedule_t slAlertFace[]; extern Schedule_t slAlertFace[];
//========================================================= //=========================================================
// AlertIdle Schedules // AlertIdle Schedules
//========================================================= //=========================================================
extern Schedule_t slAlertStand[]; extern Schedule_t slAlertStand[];
//========================================================= //=========================================================
// CombatIdle Schedule // CombatIdle Schedule
//========================================================= //=========================================================
extern Schedule_t slCombatStand[]; extern Schedule_t slCombatStand[];
//========================================================= //=========================================================
// CombatFace Schedule // CombatFace Schedule
//========================================================= //=========================================================
extern Schedule_t slCombatFace[]; extern Schedule_t slCombatFace[];
//========================================================= //=========================================================
// reload schedule // reload schedule
//========================================================= //=========================================================
extern Schedule_t slReload[]; extern Schedule_t slReload[];
//========================================================= //=========================================================
// Attack Schedules // Attack Schedules
//========================================================= //=========================================================
extern Schedule_t slRangeAttack1[]; extern Schedule_t slRangeAttack1[];
extern Schedule_t slRangeAttack2[]; extern Schedule_t slRangeAttack2[];
extern Schedule_t slTakeCoverFromBestSound[]; extern Schedule_t slTakeCoverFromBestSound[];
// primary melee attack // primary melee attack
extern Schedule_t slMeleeAttack[]; extern Schedule_t slMeleeAttack[];
// Chase enemy schedule // Chase enemy schedule
extern Schedule_t slChaseEnemy[]; extern Schedule_t slChaseEnemy[];
//========================================================= //=========================================================
// small flinch, used when a relatively minor bit of damage // small flinch, used when a relatively minor bit of damage
// is inflicted. // is inflicted.
//========================================================= //=========================================================
extern Schedule_t slSmallFlinch[]; extern Schedule_t slSmallFlinch[];
//========================================================= //=========================================================
// Die! // Die!
//========================================================= //=========================================================
extern Schedule_t slDie[]; extern Schedule_t slDie[];
//========================================================= //=========================================================
// Universal Error Schedule // Universal Error Schedule
//========================================================= //=========================================================
extern Schedule_t slError[]; extern Schedule_t slError[];
//========================================================= //=========================================================
// Scripted sequences // Scripted sequences
//========================================================= //=========================================================
extern Schedule_t slWalkToScript[]; extern Schedule_t slWalkToScript[];
extern Schedule_t slRunToScript[]; extern Schedule_t slRunToScript[];
extern Schedule_t slWaitScript[]; extern Schedule_t slWaitScript[];
#endif // DEFAULTAI_H #endif // DEFAULTAI_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +1,33 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef DOORS_H #ifndef DOORS_H
#define DOORS_H #define DOORS_H
// doors // doors
#define SF_DOOR_ROTATE_Y 0 #define SF_DOOR_ROTATE_Y 0
#define SF_DOOR_START_OPEN 1 #define SF_DOOR_START_OPEN 1
#define SF_DOOR_ROTATE_BACKWARDS 2 #define SF_DOOR_ROTATE_BACKWARDS 2
#define SF_DOOR_PASSABLE 8 #define SF_DOOR_PASSABLE 8
#define SF_DOOR_ONEWAY 16 #define SF_DOOR_ONEWAY 16
#define SF_DOOR_NO_AUTO_RETURN 32 #define SF_DOOR_NO_AUTO_RETURN 32
#define SF_DOOR_ROTATE_Z 64 #define SF_DOOR_ROTATE_Z 64
#define SF_DOOR_ROTATE_X 128 #define SF_DOOR_ROTATE_X 128
#define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button. #define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button.
#define SF_DOOR_NOMONSTERS 512 // Monster can't open #define SF_DOOR_NOMONSTERS 512 // Monster can't open
#define SF_DOOR_SILENT 0x80000000 #define SF_DOOR_SILENT 0x80000000
#endif //DOORS_H #endif //DOORS_H

View File

@@ -1,446 +1,446 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "customentity.h" #include "customentity.h"
#include "effects.h" #include "effects.h"
#include "weapons.h" #include "weapons.h"
#include "decals.h" #include "decals.h"
#include "func_break.h" #include "func_break.h"
#include "shake.h" #include "shake.h"
#define SF_GIBSHOOTER_REPEATABLE 1 // allows a gibshooter to be refired #define SF_GIBSHOOTER_REPEATABLE 1 // allows a gibshooter to be refired
#define SF_FUNNEL_REVERSE 1 // funnel effect repels particles instead of attracting them. #define SF_FUNNEL_REVERSE 1 // funnel effect repels particles instead of attracting them.
// -------------------------------------------------- // --------------------------------------------------
// //
// Beams // Beams
// //
// -------------------------------------------------- // --------------------------------------------------
void CMBeam::Spawn( void ) void CMBeam::Spawn( void )
{ {
pev->solid = SOLID_NOT; // Remove model & collisions pev->solid = SOLID_NOT; // Remove model & collisions
Precache( ); Precache( );
} }
void CMBeam::Precache( void ) void CMBeam::Precache( void )
{ {
if ( pev->owner ) if ( pev->owner )
SetStartEntity( ENTINDEX( pev->owner ) ); SetStartEntity( ENTINDEX( pev->owner ) );
if ( pev->aiment ) if ( pev->aiment )
SetEndEntity( ENTINDEX( pev->aiment ) ); SetEndEntity( ENTINDEX( pev->aiment ) );
} }
void CMBeam::SetStartEntity( int entityIndex ) void CMBeam::SetStartEntity( int entityIndex )
{ {
pev->sequence = (entityIndex & 0x0FFF) | ((pev->sequence&0xF000)<<12); pev->sequence = (entityIndex & 0x0FFF) | ((pev->sequence&0xF000)<<12);
pev->owner = g_engfuncs.pfnPEntityOfEntIndex( entityIndex ); pev->owner = g_engfuncs.pfnPEntityOfEntIndex( entityIndex );
} }
void CMBeam::SetEndEntity( int entityIndex ) void CMBeam::SetEndEntity( int entityIndex )
{ {
pev->skin = (entityIndex & 0x0FFF) | ((pev->skin&0xF000)<<12); pev->skin = (entityIndex & 0x0FFF) | ((pev->skin&0xF000)<<12);
pev->aiment = g_engfuncs.pfnPEntityOfEntIndex( entityIndex ); pev->aiment = g_engfuncs.pfnPEntityOfEntIndex( entityIndex );
} }
// These don't take attachments into account // These don't take attachments into account
const Vector &CMBeam::GetStartPos( void ) const Vector &CMBeam::GetStartPos( void )
{ {
if ( GetType() == BEAM_ENTS ) if ( GetType() == BEAM_ENTS )
{ {
edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetStartEntity() ); edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetStartEntity() );
return pent->v.origin; return pent->v.origin;
} }
return pev->origin; return pev->origin;
} }
const Vector &CMBeam::GetEndPos( void ) const Vector &CMBeam::GetEndPos( void )
{ {
int type = GetType(); int type = GetType();
if ( type == BEAM_POINTS || type == BEAM_HOSE ) if ( type == BEAM_POINTS || type == BEAM_HOSE )
{ {
return pev->angles; return pev->angles;
} }
edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetEndEntity() ); edict_t *pent = g_engfuncs.pfnPEntityOfEntIndex( GetEndEntity() );
if ( pent ) if ( pent )
return pent->v.origin; return pent->v.origin;
return pev->angles; return pev->angles;
} }
CMBeam *CMBeam::BeamCreate( const char *pSpriteName, int width ) CMBeam *CMBeam::BeamCreate( const char *pSpriteName, int width )
{ {
// Create a new entity with CMBeam private data // Create a new entity with CMBeam private data
CMBeam *pBeam = CreateClassPtr( (CMBeam *)NULL ); CMBeam *pBeam = CreateClassPtr( (CMBeam *)NULL );
if (pBeam == NULL) if (pBeam == NULL)
return NULL; return NULL;
pBeam->pev->classname = MAKE_STRING("beam"); pBeam->pev->classname = MAKE_STRING("beam");
pBeam->BeamInit( pSpriteName, width ); pBeam->BeamInit( pSpriteName, width );
return pBeam; return pBeam;
} }
void CMBeam::BeamInit( const char *pSpriteName, int width ) void CMBeam::BeamInit( const char *pSpriteName, int width )
{ {
pev->flags |= FL_CUSTOMENTITY; pev->flags |= FL_CUSTOMENTITY;
SetColor( 255, 255, 255 ); SetColor( 255, 255, 255 );
SetBrightness( 255 ); SetBrightness( 255 );
SetNoise( 0 ); SetNoise( 0 );
SetFrame( 0 ); SetFrame( 0 );
SetScrollRate( 0 ); SetScrollRate( 0 );
pev->model = MAKE_STRING( pSpriteName ); pev->model = MAKE_STRING( pSpriteName );
SetTexture( PRECACHE_MODEL( (char *)pSpriteName ) ); SetTexture( PRECACHE_MODEL( (char *)pSpriteName ) );
SetWidth( width ); SetWidth( width );
pev->skin = 0; pev->skin = 0;
pev->sequence = 0; pev->sequence = 0;
pev->rendermode = 0; pev->rendermode = 0;
} }
void CMBeam::PointsInit( const Vector &start, const Vector &end ) void CMBeam::PointsInit( const Vector &start, const Vector &end )
{ {
SetType( BEAM_POINTS ); SetType( BEAM_POINTS );
SetStartPos( start ); SetStartPos( start );
SetEndPos( end ); SetEndPos( end );
SetStartAttachment( 0 ); SetStartAttachment( 0 );
SetEndAttachment( 0 ); SetEndAttachment( 0 );
RelinkBeam(); RelinkBeam();
} }
void CMBeam::HoseInit( const Vector &start, const Vector &direction ) void CMBeam::HoseInit( const Vector &start, const Vector &direction )
{ {
SetType( BEAM_HOSE ); SetType( BEAM_HOSE );
SetStartPos( start ); SetStartPos( start );
SetEndPos( direction ); SetEndPos( direction );
SetStartAttachment( 0 ); SetStartAttachment( 0 );
SetEndAttachment( 0 ); SetEndAttachment( 0 );
RelinkBeam(); RelinkBeam();
} }
void CMBeam::PointEntInit( const Vector &start, int endIndex ) void CMBeam::PointEntInit( const Vector &start, int endIndex )
{ {
SetType( BEAM_ENTPOINT ); SetType( BEAM_ENTPOINT );
SetStartPos( start ); SetStartPos( start );
SetEndEntity( endIndex ); SetEndEntity( endIndex );
SetStartAttachment( 0 ); SetStartAttachment( 0 );
SetEndAttachment( 0 ); SetEndAttachment( 0 );
RelinkBeam(); RelinkBeam();
} }
void CMBeam::EntsInit( int startIndex, int endIndex ) void CMBeam::EntsInit( int startIndex, int endIndex )
{ {
SetType( BEAM_ENTS ); SetType( BEAM_ENTS );
SetStartEntity( startIndex ); SetStartEntity( startIndex );
SetEndEntity( endIndex ); SetEndEntity( endIndex );
SetStartAttachment( 0 ); SetStartAttachment( 0 );
SetEndAttachment( 0 ); SetEndAttachment( 0 );
RelinkBeam(); RelinkBeam();
} }
void CMBeam::RelinkBeam( void ) void CMBeam::RelinkBeam( void )
{ {
const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); const Vector &startPos = GetStartPos(), &endPos = GetEndPos();
pev->mins.x = min( startPos.x, endPos.x ); pev->mins.x = min( startPos.x, endPos.x );
pev->mins.y = min( startPos.y, endPos.y ); pev->mins.y = min( startPos.y, endPos.y );
pev->mins.z = min( startPos.z, endPos.z ); pev->mins.z = min( startPos.z, endPos.z );
pev->maxs.x = max( startPos.x, endPos.x ); pev->maxs.x = max( startPos.x, endPos.x );
pev->maxs.y = max( startPos.y, endPos.y ); pev->maxs.y = max( startPos.y, endPos.y );
pev->maxs.z = max( startPos.z, endPos.z ); pev->maxs.z = max( startPos.z, endPos.z );
pev->mins = pev->mins - pev->origin; pev->mins = pev->mins - pev->origin;
pev->maxs = pev->maxs - pev->origin; pev->maxs = pev->maxs - pev->origin;
UTIL_SetSize( pev, pev->mins, pev->maxs ); UTIL_SetSize( pev, pev->mins, pev->maxs );
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
} }
#if 0 #if 0
void CMBeam::SetObjectCollisionBox( void ) void CMBeam::SetObjectCollisionBox( void )
{ {
const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); const Vector &startPos = GetStartPos(), &endPos = GetEndPos();
pev->absmin.x = min( startPos.x, endPos.x ); pev->absmin.x = min( startPos.x, endPos.x );
pev->absmin.y = min( startPos.y, endPos.y ); pev->absmin.y = min( startPos.y, endPos.y );
pev->absmin.z = min( startPos.z, endPos.z ); pev->absmin.z = min( startPos.z, endPos.z );
pev->absmax.x = max( startPos.x, endPos.x ); pev->absmax.x = max( startPos.x, endPos.x );
pev->absmax.y = max( startPos.y, endPos.y ); pev->absmax.y = max( startPos.y, endPos.y );
pev->absmax.z = max( startPos.z, endPos.z ); pev->absmax.z = max( startPos.z, endPos.z );
} }
#endif #endif
void CMBeam::TriggerTouch( edict_t *pOther ) void CMBeam::TriggerTouch( edict_t *pOther )
{ {
if ( pOther->v.flags & (FL_CLIENT | FL_MONSTER) ) if ( pOther->v.flags & (FL_CLIENT | FL_MONSTER) )
{ {
if ( pev->owner ) if ( pev->owner )
{ {
if (pev->owner->v.euser4 != NULL) if (pev->owner->v.euser4 != NULL)
{ {
CMBaseEntity *pOwner = GetClassPtr((CMBaseEntity *)VARS(pev->owner)); CMBaseEntity *pOwner = GetClassPtr((CMBaseEntity *)VARS(pev->owner));
pOwner->Use( pOther, this->edict(), USE_TOGGLE, 0 ); pOwner->Use( pOther, this->edict(), USE_TOGGLE, 0 );
} }
} }
ALERT( at_console, "Firing targets!!!\n" ); ALERT( at_console, "Firing targets!!!\n" );
} }
} }
edict_t *CMBeam::RandomTargetname( const char *szName ) edict_t *CMBeam::RandomTargetname( const char *szName )
{ {
int total = 0; int total = 0;
edict_t *pEntity = NULL; edict_t *pEntity = NULL;
edict_t *pNewEntity = NULL; edict_t *pNewEntity = NULL;
while ((pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName )) != NULL) while ((pNewEntity = UTIL_FindEntityByTargetname( pNewEntity, szName )) != NULL)
{ {
total++; total++;
if (RANDOM_LONG(0,total-1) < 1) if (RANDOM_LONG(0,total-1) < 1)
pEntity = pNewEntity; pEntity = pNewEntity;
} }
return pEntity; return pEntity;
} }
void CMBeam::DoSparks( const Vector &start, const Vector &end ) void CMBeam::DoSparks( const Vector &start, const Vector &end )
{ {
if ( pev->spawnflags & (SF_BEAM_SPARKSTART|SF_BEAM_SPARKEND) ) if ( pev->spawnflags & (SF_BEAM_SPARKSTART|SF_BEAM_SPARKEND) )
{ {
if ( pev->spawnflags & SF_BEAM_SPARKSTART ) if ( pev->spawnflags & SF_BEAM_SPARKSTART )
{ {
UTIL_Sparks( start ); UTIL_Sparks( start );
} }
if ( pev->spawnflags & SF_BEAM_SPARKEND ) if ( pev->spawnflags & SF_BEAM_SPARKEND )
{ {
UTIL_Sparks( end ); UTIL_Sparks( end );
} }
} }
} }
void CMBeam::BeamDamage( TraceResult *ptr ) void CMBeam::BeamDamage( TraceResult *ptr )
{ {
RelinkBeam(); RelinkBeam();
if ( ptr->flFraction != 1.0 && ptr->pHit != NULL ) if ( ptr->flFraction != 1.0 && ptr->pHit != NULL )
{ {
if (UTIL_IsPlayer(ptr->pHit)) if (UTIL_IsPlayer(ptr->pHit))
{ {
ClearMultiDamage(); ClearMultiDamage();
UTIL_TraceAttack(ptr->pHit, pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM ); UTIL_TraceAttack(ptr->pHit, pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM );
ApplyMultiDamage( pev, pev ); ApplyMultiDamage( pev, pev );
if ( pev->spawnflags & SF_BEAM_DECALS ) if ( pev->spawnflags & SF_BEAM_DECALS )
{ {
if ( UTIL_IsBSPModel(ptr->pHit) ) if ( UTIL_IsBSPModel(ptr->pHit) )
UTIL_DecalTrace( ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0,4) ); UTIL_DecalTrace( ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0,4) );
} }
} }
else if (ptr->pHit->v.euser4 != NULL) else if (ptr->pHit->v.euser4 != NULL)
{ {
ClearMultiDamage(); ClearMultiDamage();
CMBaseEntity *pMonster = GetClassPtr((CMBaseEntity *)VARS(ptr->pHit)); CMBaseEntity *pMonster = GetClassPtr((CMBaseEntity *)VARS(ptr->pHit));
pMonster->TraceAttack( pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM ); pMonster->TraceAttack( pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM );
ApplyMultiDamage( pev, pev ); ApplyMultiDamage( pev, pev );
if ( pev->spawnflags & SF_BEAM_DECALS ) if ( pev->spawnflags & SF_BEAM_DECALS )
{ {
if ( pMonster->IsBSPModel() ) if ( pMonster->IsBSPModel() )
UTIL_DecalTrace( ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0,4) ); UTIL_DecalTrace( ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0,4) );
} }
} }
} }
pev->dmgtime = gpGlobals->time; pev->dmgtime = gpGlobals->time;
} }
void CMSprite::Spawn( void ) void CMSprite::Spawn( void )
{ {
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
pev->effects = 0; pev->effects = 0;
pev->frame = 0; pev->frame = 0;
Precache(); Precache();
SET_MODEL( ENT(pev), STRING(pev->model) ); SET_MODEL( ENT(pev), STRING(pev->model) );
m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1;
if ( pev->targetname && !(pev->spawnflags & SF_SPRITE_STARTON) ) if ( pev->targetname && !(pev->spawnflags & SF_SPRITE_STARTON) )
TurnOff(); TurnOff();
else else
TurnOn(); TurnOn();
// Worldcraft only sets y rotation, copy to Z // Worldcraft only sets y rotation, copy to Z
if ( pev->angles.y != 0 && pev->angles.z == 0 ) if ( pev->angles.y != 0 && pev->angles.z == 0 )
{ {
pev->angles.z = pev->angles.y; pev->angles.z = pev->angles.y;
pev->angles.y = 0; pev->angles.y = 0;
} }
} }
void CMSprite::Precache( void ) void CMSprite::Precache( void )
{ {
PRECACHE_MODEL( (char *)STRING(pev->model) ); PRECACHE_MODEL( (char *)STRING(pev->model) );
// Reset attachment after save/restore // Reset attachment after save/restore
if ( pev->aiment ) if ( pev->aiment )
SetAttachment( pev->aiment, pev->body ); SetAttachment( pev->aiment, pev->body );
else else
{ {
// Clear attachment // Clear attachment
pev->skin = 0; pev->skin = 0;
pev->body = 0; pev->body = 0;
} }
} }
void CMSprite::SpriteInit( const char *pSpriteName, const Vector &origin ) void CMSprite::SpriteInit( const char *pSpriteName, const Vector &origin )
{ {
pev->model = MAKE_STRING(pSpriteName); pev->model = MAKE_STRING(pSpriteName);
pev->origin = origin; pev->origin = origin;
Spawn(); Spawn();
} }
CMSprite *CMSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ) CMSprite *CMSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate )
{ {
CMSprite *pSprite = CreateClassPtr( (CMSprite *)NULL ); CMSprite *pSprite = CreateClassPtr( (CMSprite *)NULL );
pSprite->SpriteInit( pSpriteName, origin ); pSprite->SpriteInit( pSpriteName, origin );
pSprite->pev->classname = MAKE_STRING("env_sprite"); pSprite->pev->classname = MAKE_STRING("env_sprite");
pSprite->pev->solid = SOLID_NOT; pSprite->pev->solid = SOLID_NOT;
pSprite->pev->movetype = MOVETYPE_NOCLIP; pSprite->pev->movetype = MOVETYPE_NOCLIP;
if ( animate ) if ( animate )
pSprite->TurnOn(); pSprite->TurnOn();
return pSprite; return pSprite;
} }
void CMSprite::AnimateThink( void ) void CMSprite::AnimateThink( void )
{ {
Animate( pev->framerate * (gpGlobals->time - m_lastTime) ); Animate( pev->framerate * (gpGlobals->time - m_lastTime) );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
m_lastTime = gpGlobals->time; m_lastTime = gpGlobals->time;
} }
void CMSprite::AnimateUntilDead( void ) void CMSprite::AnimateUntilDead( void )
{ {
if ( gpGlobals->time > pev->dmgtime ) if ( gpGlobals->time > pev->dmgtime )
UTIL_Remove(this->edict()); UTIL_Remove(this->edict());
else else
{ {
AnimateThink(); AnimateThink();
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
} }
void CMSprite::Expand( float scaleSpeed, float fadeSpeed ) void CMSprite::Expand( float scaleSpeed, float fadeSpeed )
{ {
pev->speed = scaleSpeed; pev->speed = scaleSpeed;
pev->health = fadeSpeed; pev->health = fadeSpeed;
SetThink( &CMSprite::ExpandThink ); SetThink( &CMSprite::ExpandThink );
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
m_lastTime = gpGlobals->time; m_lastTime = gpGlobals->time;
} }
void CMSprite::ExpandThink( void ) void CMSprite::ExpandThink( void )
{ {
float frametime = gpGlobals->time - m_lastTime; float frametime = gpGlobals->time - m_lastTime;
pev->scale += pev->speed * frametime; pev->scale += pev->speed * frametime;
pev->renderamt -= pev->health * frametime; pev->renderamt -= pev->health * frametime;
if ( pev->renderamt <= 0 ) if ( pev->renderamt <= 0 )
{ {
pev->renderamt = 0; pev->renderamt = 0;
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
} }
else else
{ {
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
m_lastTime = gpGlobals->time; m_lastTime = gpGlobals->time;
} }
} }
void CMSprite::Animate( float frames ) void CMSprite::Animate( float frames )
{ {
pev->frame += frames; pev->frame += frames;
if ( pev->frame > m_maxFrame ) if ( pev->frame > m_maxFrame )
{ {
if ( pev->spawnflags & SF_SPRITE_ONCE ) if ( pev->spawnflags & SF_SPRITE_ONCE )
{ {
TurnOff(); TurnOff();
} }
else else
{ {
if ( m_maxFrame > 0 ) if ( m_maxFrame > 0 )
pev->frame = fmod( pev->frame, m_maxFrame ); pev->frame = fmod( pev->frame, m_maxFrame );
} }
} }
} }
void CMSprite::TurnOff( void ) void CMSprite::TurnOff( void )
{ {
pev->effects = EF_NODRAW; pev->effects = EF_NODRAW;
pev->nextthink = 0; pev->nextthink = 0;
} }
void CMSprite::TurnOn( void ) void CMSprite::TurnOn( void )
{ {
pev->effects = 0; pev->effects = 0;
if ( (pev->framerate && m_maxFrame > 1.0) || (pev->spawnflags & SF_SPRITE_ONCE) ) if ( (pev->framerate && m_maxFrame > 1.0) || (pev->spawnflags & SF_SPRITE_ONCE) )
{ {
SetThink( &CMSprite::AnimateThink ); SetThink( &CMSprite::AnimateThink );
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
m_lastTime = gpGlobals->time; m_lastTime = gpGlobals->time;
} }
pev->frame = 0; pev->frame = 0;
} }
void CMSprite::Use( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value ) void CMSprite::Use( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value )
{ {
int on = pev->effects != EF_NODRAW; int on = pev->effects != EF_NODRAW;
if ( ShouldToggle( useType, on ) ) if ( ShouldToggle( useType, on ) )
{ {
if ( on ) if ( on )
{ {
TurnOff(); TurnOff();
} }
else else
{ {
TurnOn(); TurnOn();
} }
} }
} }

View File

@@ -1,203 +1,203 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef EFFECTS_H #ifndef EFFECTS_H
#define EFFECTS_H #define EFFECTS_H
#define SF_BEAM_STARTON 0x0001 #define SF_BEAM_STARTON 0x0001
#define SF_BEAM_TOGGLE 0x0002 #define SF_BEAM_TOGGLE 0x0002
#define SF_BEAM_RANDOM 0x0004 #define SF_BEAM_RANDOM 0x0004
#define SF_BEAM_RING 0x0008 #define SF_BEAM_RING 0x0008
#define SF_BEAM_SPARKSTART 0x0010 #define SF_BEAM_SPARKSTART 0x0010
#define SF_BEAM_SPARKEND 0x0020 #define SF_BEAM_SPARKEND 0x0020
#define SF_BEAM_DECALS 0x0040 #define SF_BEAM_DECALS 0x0040
#define SF_BEAM_SHADEIN 0x0080 #define SF_BEAM_SHADEIN 0x0080
#define SF_BEAM_SHADEOUT 0x0100 #define SF_BEAM_SHADEOUT 0x0100
#define SF_BEAM_TEMPORARY 0x8000 #define SF_BEAM_TEMPORARY 0x8000
#define SF_SPRITE_STARTON 0x0001 #define SF_SPRITE_STARTON 0x0001
#define SF_SPRITE_ONCE 0x0002 #define SF_SPRITE_ONCE 0x0002
#define SF_SPRITE_TEMPORARY 0x8000 #define SF_SPRITE_TEMPORARY 0x8000
class CMSprite : public CMPointEntity class CMSprite : public CMPointEntity
{ {
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
int ObjectCaps( void ) int ObjectCaps( void )
{ {
int flags = 0; int flags = 0;
if ( pev->spawnflags & SF_SPRITE_TEMPORARY ) if ( pev->spawnflags & SF_SPRITE_TEMPORARY )
flags = FCAP_DONT_SAVE; flags = FCAP_DONT_SAVE;
return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
} }
void EXPORT AnimateThink( void ); void EXPORT AnimateThink( void );
void EXPORT ExpandThink( void ); void EXPORT ExpandThink( void );
void Use( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value ); void Use( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value );
void Animate( float frames ); void Animate( float frames );
void Expand( float scaleSpeed, float fadeSpeed ); void Expand( float scaleSpeed, float fadeSpeed );
void SpriteInit( const char *pSpriteName, const Vector &origin ); void SpriteInit( const char *pSpriteName, const Vector &origin );
inline void SetAttachment( edict_t *pEntity, int attachment ) inline void SetAttachment( edict_t *pEntity, int attachment )
{ {
if ( pEntity ) if ( pEntity )
{ {
pev->skin = ENTINDEX(pEntity); pev->skin = ENTINDEX(pEntity);
pev->body = attachment; pev->body = attachment;
pev->aiment = pEntity; pev->aiment = pEntity;
pev->movetype = MOVETYPE_FOLLOW; pev->movetype = MOVETYPE_FOLLOW;
} }
} }
void TurnOff( void ); void TurnOff( void );
void TurnOn( void ); void TurnOn( void );
inline float Frames( void ) { return m_maxFrame; } inline float Frames( void ) { return m_maxFrame; }
inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx ) inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx )
{ {
pev->rendermode = rendermode; pev->rendermode = rendermode;
pev->rendercolor.x = r; pev->rendercolor.x = r;
pev->rendercolor.y = g; pev->rendercolor.y = g;
pev->rendercolor.z = b; pev->rendercolor.z = b;
pev->renderamt = a; pev->renderamt = a;
pev->renderfx = fx; pev->renderfx = fx;
} }
inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; }
inline void SetScale( float scale ) { pev->scale = scale; } inline void SetScale( float scale ) { pev->scale = scale; }
inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } inline void SetBrightness( int brightness ) { pev->renderamt = brightness; }
inline void AnimateAndDie( float framerate ) inline void AnimateAndDie( float framerate )
{ {
SetThink(&CMSprite::AnimateUntilDead); SetThink(&CMSprite::AnimateUntilDead);
pev->framerate = framerate; pev->framerate = framerate;
pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate); pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate);
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
void EXPORT AnimateUntilDead( void ); void EXPORT AnimateUntilDead( void );
static CMSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ); static CMSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate );
private: private:
float m_lastTime; float m_lastTime;
float m_maxFrame; float m_maxFrame;
}; };
class CMBeam : public CMBaseEntity class CMBeam : public CMBaseEntity
{ {
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
int ObjectCaps( void ) int ObjectCaps( void )
{ {
int flags = 0; int flags = 0;
if ( pev->spawnflags & SF_BEAM_TEMPORARY ) if ( pev->spawnflags & SF_BEAM_TEMPORARY )
flags = FCAP_DONT_SAVE; flags = FCAP_DONT_SAVE;
return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
} }
void EXPORT TriggerTouch( edict_t *pOther ); void EXPORT TriggerTouch( edict_t *pOther );
// These functions are here to show the way beams are encoded as entities. // These functions are here to show the way beams are encoded as entities.
// Encoding beams as entities simplifies their management in the client/server architecture // Encoding beams as entities simplifies their management in the client/server architecture
inline void SetType( int type ) { pev->rendermode = (pev->rendermode & 0xF0) | (type&0x0F); } inline void SetType( int type ) { pev->rendermode = (pev->rendermode & 0xF0) | (type&0x0F); }
inline void SetFlags( int flags ) { pev->rendermode = (pev->rendermode & 0x0F) | (flags&0xF0); } inline void SetFlags( int flags ) { pev->rendermode = (pev->rendermode & 0x0F) | (flags&0xF0); }
inline void SetStartPos( const Vector& pos ) { pev->origin = pos; } inline void SetStartPos( const Vector& pos ) { pev->origin = pos; }
inline void SetEndPos( const Vector& pos ) { pev->angles = pos; } inline void SetEndPos( const Vector& pos ) { pev->angles = pos; }
void SetStartEntity( int entityIndex ); void SetStartEntity( int entityIndex );
void SetEndEntity( int entityIndex ); void SetEndEntity( int entityIndex );
inline void SetStartAttachment( int attachment ) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment&0xF)<<12); } inline void SetStartAttachment( int attachment ) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment&0xF)<<12); }
inline void SetEndAttachment( int attachment ) { pev->skin = (pev->skin & 0x0FFF) | ((attachment&0xF)<<12); } inline void SetEndAttachment( int attachment ) { pev->skin = (pev->skin & 0x0FFF) | ((attachment&0xF)<<12); }
inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; }
inline void SetWidth( int width ) { pev->scale = width; } inline void SetWidth( int width ) { pev->scale = width; }
inline void SetNoise( int amplitude ) { pev->body = amplitude; } inline void SetNoise( int amplitude ) { pev->body = amplitude; }
inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } inline void SetBrightness( int brightness ) { pev->renderamt = brightness; }
inline void SetFrame( float frame ) { pev->frame = frame; } inline void SetFrame( float frame ) { pev->frame = frame; }
inline void SetScrollRate( int speed ) { pev->animtime = speed; } inline void SetScrollRate( int speed ) { pev->animtime = speed; }
inline int GetType( void ) { return pev->rendermode & 0x0F; } inline int GetType( void ) { return pev->rendermode & 0x0F; }
inline int GetFlags( void ) { return pev->rendermode & 0xF0; } inline int GetFlags( void ) { return pev->rendermode & 0xF0; }
inline int GetStartEntity( void ) { return pev->sequence & 0xFFF; } inline int GetStartEntity( void ) { return pev->sequence & 0xFFF; }
inline int GetEndEntity( void ) { return pev->skin & 0xFFF; } inline int GetEndEntity( void ) { return pev->skin & 0xFFF; }
const Vector &GetStartPos( void ); const Vector &GetStartPos( void );
const Vector &GetEndPos( void ); const Vector &GetEndPos( void );
Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam
inline int GetTexture( void ) { return pev->modelindex; } inline int GetTexture( void ) { return pev->modelindex; }
inline int GetWidth( void ) { return pev->scale; } inline int GetWidth( void ) { return pev->scale; }
inline int GetNoise( void ) { return pev->body; } inline int GetNoise( void ) { return pev->body; }
// inline void GetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } // inline void GetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
inline int GetBrightness( void ) { return pev->renderamt; } inline int GetBrightness( void ) { return pev->renderamt; }
inline int GetFrame( void ) { return pev->frame; } inline int GetFrame( void ) { return pev->frame; }
inline int GetScrollRate( void ) { return pev->animtime; } inline int GetScrollRate( void ) { return pev->animtime; }
// Call after you change start/end positions // Call after you change start/end positions
void RelinkBeam( void ); void RelinkBeam( void );
// void SetObjectCollisionBox( void ); // void SetObjectCollisionBox( void );
void DoSparks( const Vector &start, const Vector &end ); void DoSparks( const Vector &start, const Vector &end );
edict_t *RandomTargetname( const char *szName ); edict_t *RandomTargetname( const char *szName );
void BeamDamage( TraceResult *ptr ); void BeamDamage( TraceResult *ptr );
// Init after BeamCreate() // Init after BeamCreate()
void BeamInit( const char *pSpriteName, int width ); void BeamInit( const char *pSpriteName, int width );
void PointsInit( const Vector &start, const Vector &end ); void PointsInit( const Vector &start, const Vector &end );
void PointEntInit( const Vector &start, int endIndex ); void PointEntInit( const Vector &start, int endIndex );
void EntsInit( int startIndex, int endIndex ); void EntsInit( int startIndex, int endIndex );
void HoseInit( const Vector &start, const Vector &direction ); void HoseInit( const Vector &start, const Vector &direction );
static CMBeam *BeamCreate( const char *pSpriteName, int width ); static CMBeam *BeamCreate( const char *pSpriteName, int width );
inline void LiveForTime( float time ) { SetThink(&CMBeam::SUB_Remove); pev->nextthink = gpGlobals->time + time; } inline void LiveForTime( float time ) { SetThink(&CMBeam::SUB_Remove); pev->nextthink = gpGlobals->time + time; }
inline void BeamDamageInstant( TraceResult *ptr, float damage ) inline void BeamDamageInstant( TraceResult *ptr, float damage )
{ {
pev->dmg = damage; pev->dmg = damage;
pev->dmgtime = gpGlobals->time - 1; pev->dmgtime = gpGlobals->time - 1;
BeamDamage(ptr); BeamDamage(ptr);
} }
}; };
#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out #define SF_MESSAGE_ONCE 0x0001 // Fade in, not out
#define SF_MESSAGE_ALL 0x0002 // Send to all clients #define SF_MESSAGE_ALL 0x0002 // Send to all clients
class CMLaser : public CMBeam class CMLaser : public CMBeam
{ {
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
void TurnOn( void ); void TurnOn( void );
void TurnOff( void ); void TurnOff( void );
int IsOn( void ); int IsOn( void );
void FireAtPoint( TraceResult &point ); void FireAtPoint( TraceResult &point );
void EXPORT StrikeThink( void ); void EXPORT StrikeThink( void );
void Use( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value ); void Use( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value );
CMSprite *m_pSprite; CMSprite *m_pSprite;
int m_iszSpriteName; int m_iszSpriteName;
Vector m_firePosition; Vector m_firePosition;
}; };
#endif //EFFECTS_H #endif //EFFECTS_H

View File

@@ -1,158 +1,158 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef ENGINECALLBACK_H #ifndef ENGINECALLBACK_H
#define ENGINECALLBACK_H #define ENGINECALLBACK_H
#pragma once #pragma once
#include "event_flags.h" #include "event_flags.h"
// Must be provided by user of this code // Must be provided by user of this code
extern enginefuncs_t g_engfuncs; extern enginefuncs_t g_engfuncs;
// The actual engine callbacks // The actual engine callbacks
#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId) #define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId)
#define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel) #define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel)
#define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound) #define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound)
#define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric) #define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric)
#define SET_MODEL (*g_engfuncs.pfnSetModel) #define SET_MODEL (*g_engfuncs.pfnSetModel)
#define MODEL_INDEX (*g_engfuncs.pfnModelIndex) #define MODEL_INDEX (*g_engfuncs.pfnModelIndex)
#define MODEL_FRAMES (*g_engfuncs.pfnModelFrames) #define MODEL_FRAMES (*g_engfuncs.pfnModelFrames)
#define SET_SIZE (*g_engfuncs.pfnSetSize) #define SET_SIZE (*g_engfuncs.pfnSetSize)
#define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel) #define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel)
#define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms) #define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms)
#define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms) #define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms)
#define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw) #define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw)
#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) #define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles)
#define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin) #define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin)
#define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw) #define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw)
#define CHANGE_PITCH (*g_engfuncs.pfnChangePitch) #define CHANGE_PITCH (*g_engfuncs.pfnChangePitch)
#define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors) #define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors)
#define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity) #define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity)
#define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity) #define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity)
#define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity) #define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity)
#define MAKE_STATIC (*g_engfuncs.pfnMakeStatic) #define MAKE_STATIC (*g_engfuncs.pfnMakeStatic)
#define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor) #define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor)
#define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor) #define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor)
#define WALK_MOVE (*g_engfuncs.pfnWalkMove) #define WALK_MOVE (*g_engfuncs.pfnWalkMove)
#define SET_ORIGIN (*g_engfuncs.pfnSetOrigin) #define SET_ORIGIN (*g_engfuncs.pfnSetOrigin)
#define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound) #define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound)
#define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg) #define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg)
#define TRACE_LINE (*g_engfuncs.pfnTraceLine) #define TRACE_LINE (*g_engfuncs.pfnTraceLine)
#define TRACE_TOSS (*g_engfuncs.pfnTraceToss) #define TRACE_TOSS (*g_engfuncs.pfnTraceToss)
#define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull) #define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull)
#define TRACE_HULL (*g_engfuncs.pfnTraceHull) #define TRACE_HULL (*g_engfuncs.pfnTraceHull)
#define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector) #define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector)
#define SERVER_COMMAND (*g_engfuncs.pfnServerCommand) #define SERVER_COMMAND (*g_engfuncs.pfnServerCommand)
#define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute) #define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute)
#define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand) #define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand)
#define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect) #define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect)
#define LIGHT_STYLE (*g_engfuncs.pfnLightStyle) #define LIGHT_STYLE (*g_engfuncs.pfnLightStyle)
#define DECAL_INDEX (*g_engfuncs.pfnDecalIndex) #define DECAL_INDEX (*g_engfuncs.pfnDecalIndex)
#define POINT_CONTENTS (*g_engfuncs.pfnPointContents) #define POINT_CONTENTS (*g_engfuncs.pfnPointContents)
#define CRC32_INIT (*g_engfuncs.pfnCRC32_Init) #define CRC32_INIT (*g_engfuncs.pfnCRC32_Init)
#define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer) #define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer)
#define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte) #define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte)
#define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final) #define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final)
#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) #define RANDOM_LONG (*g_engfuncs.pfnRandomLong)
#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) #define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat)
#define GETPLAYERWONID (*g_engfuncs.pfnGetPlayerWONId) #define GETPLAYERWONID (*g_engfuncs.pfnGetPlayerWONId)
inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL ) { inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL ) {
(*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed); (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed);
} }
#define MESSAGE_END (*g_engfuncs.pfnMessageEnd) #define MESSAGE_END (*g_engfuncs.pfnMessageEnd)
#define WRITE_BYTE (*g_engfuncs.pfnWriteByte) #define WRITE_BYTE (*g_engfuncs.pfnWriteByte)
#define WRITE_CHAR (*g_engfuncs.pfnWriteChar) #define WRITE_CHAR (*g_engfuncs.pfnWriteChar)
#define WRITE_SHORT (*g_engfuncs.pfnWriteShort) #define WRITE_SHORT (*g_engfuncs.pfnWriteShort)
#define WRITE_LONG (*g_engfuncs.pfnWriteLong) #define WRITE_LONG (*g_engfuncs.pfnWriteLong)
#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle) #define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle)
#define WRITE_COORD (*g_engfuncs.pfnWriteCoord) #define WRITE_COORD (*g_engfuncs.pfnWriteCoord)
#define WRITE_STRING (*g_engfuncs.pfnWriteString) #define WRITE_STRING (*g_engfuncs.pfnWriteString)
#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity) #define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity)
#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister) #define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister)
#define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat) #define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat)
#define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString) #define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString)
#define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat) #define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat)
#define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString) #define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString)
#define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer) #define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer)
#define ALERT (*g_engfuncs.pfnAlertMessage) #define ALERT (*g_engfuncs.pfnAlertMessage)
#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) #define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf)
#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) #define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData)
inline void *GET_PRIVATE( edict_t *pent ) inline void *GET_PRIVATE( edict_t *pent )
{ {
if ( pent ) if ( pent )
return pent->pvPrivateData; return pent->pvPrivateData;
return NULL; return NULL;
} }
#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData) #define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData)
//#define STRING (*g_engfuncs.pfnSzFromIndex) //#define STRING (*g_engfuncs.pfnSzFromIndex)
#define ALLOC_STRING (*g_engfuncs.pfnAllocString) #define ALLOC_STRING (*g_engfuncs.pfnAllocString)
#define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString) #define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString)
#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum) #define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum)
#define FIND_ENTITY_IN_SPHERE (*g_engfuncs.pfnFindEntityInSphere) #define FIND_ENTITY_IN_SPHERE (*g_engfuncs.pfnFindEntityInSphere)
#define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS) #define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS)
#define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound) #define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound)
#define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr) #define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr)
#define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg) #define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg)
#define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition) #define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition)
#define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName) #define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName)
#define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction) #define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction)
#define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture) #define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture)
#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf) #define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf)
#define CMD_ARGS (*g_engfuncs.pfnCmd_Args) #define CMD_ARGS (*g_engfuncs.pfnCmd_Args)
#define CMD_ARGC (*g_engfuncs.pfnCmd_Argc) #define CMD_ARGC (*g_engfuncs.pfnCmd_Argc)
#define CMD_ARGV (*g_engfuncs.pfnCmd_Argv) #define CMD_ARGV (*g_engfuncs.pfnCmd_Argv)
#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment) #define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment)
#define SET_VIEW (*g_engfuncs.pfnSetView) #define SET_VIEW (*g_engfuncs.pfnSetView)
#define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle) #define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle)
#define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe) #define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe)
#define FREE_FILE (*g_engfuncs.pfnFreeFile) #define FREE_FILE (*g_engfuncs.pfnFreeFile)
#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime) #define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime)
#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) #define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir)
#define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid) #define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid)
#define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities) #define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities)
#define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer) #define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer)
#define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent) #define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent)
#define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent) #define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent)
#define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS) #define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS)
#define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS) #define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS)
#define ENGINE_CHECK_VISIBILITY (*g_engfuncs.pfnCheckVisibility) #define ENGINE_CHECK_VISIBILITY (*g_engfuncs.pfnCheckVisibility)
#define DELTA_SET ( *g_engfuncs.pfnDeltaSetField ) #define DELTA_SET ( *g_engfuncs.pfnDeltaSetField )
#define DELTA_UNSET ( *g_engfuncs.pfnDeltaUnsetField ) #define DELTA_UNSET ( *g_engfuncs.pfnDeltaUnsetField )
#define DELTA_ADDENCODER ( *g_engfuncs.pfnDeltaAddEncoder ) #define DELTA_ADDENCODER ( *g_engfuncs.pfnDeltaAddEncoder )
#define ENGINE_CURRENT_PLAYER ( *g_engfuncs.pfnGetCurrentPlayer ) #define ENGINE_CURRENT_PLAYER ( *g_engfuncs.pfnGetCurrentPlayer )
#define ENGINE_CANSKIP ( *g_engfuncs.pfnCanSkipPlayer ) #define ENGINE_CANSKIP ( *g_engfuncs.pfnCanSkipPlayer )
#define DELTA_FINDFIELD ( *g_engfuncs.pfnDeltaFindField ) #define DELTA_FINDFIELD ( *g_engfuncs.pfnDeltaFindField )
#define DELTA_SETBYINDEX ( *g_engfuncs.pfnDeltaSetFieldByIndex ) #define DELTA_SETBYINDEX ( *g_engfuncs.pfnDeltaSetFieldByIndex )
#define DELTA_UNSETBYINDEX ( *g_engfuncs.pfnDeltaUnsetFieldByIndex ) #define DELTA_UNSETBYINDEX ( *g_engfuncs.pfnDeltaUnsetFieldByIndex )
#define ENGINE_GETPHYSINFO ( *g_engfuncs.pfnGetPhysicsInfoString ) #define ENGINE_GETPHYSINFO ( *g_engfuncs.pfnGetPhysicsInfoString )
#define ENGINE_SETGROUPMASK ( *g_engfuncs.pfnSetGroupMask ) #define ENGINE_SETGROUPMASK ( *g_engfuncs.pfnSetGroupMask )
#define ENGINE_INSTANCE_BASELINE ( *g_engfuncs.pfnCreateInstancedBaseline ) #define ENGINE_INSTANCE_BASELINE ( *g_engfuncs.pfnCreateInstancedBaseline )
#define ENGINE_FORCE_UNMODIFIED ( *g_engfuncs.pfnForceUnmodified ) #define ENGINE_FORCE_UNMODIFIED ( *g_engfuncs.pfnForceUnmodified )
#define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats ) #define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats )
#endif //ENGINECALLBACK_H #endif //ENGINECALLBACK_H

602
src/dlls/explode.cpp Executable file → Normal file
View File

@@ -1,301 +1,301 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
===== explode.cpp ======================================================== ===== explode.cpp ========================================================
Explosion-related code Explosion-related code
*/ */
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "decals.h" #include "decals.h"
#include "explode.h" #include "explode.h"
// Spark Shower // Spark Shower
class CMShower : public CMBaseEntity class CMShower : public CMBaseEntity
{ {
void Spawn( void ); void Spawn( void );
void Think( void ); void Think( void );
void Touch( CMBaseEntity *pOther ); void Touch( CMBaseEntity *pOther );
int ObjectCaps( void ) { return FCAP_DONT_SAVE; } int ObjectCaps( void ) { return FCAP_DONT_SAVE; }
}; };
void CMShower::Spawn( void ) void CMShower::Spawn( void )
{ {
pev->velocity = RANDOM_FLOAT( 200, 300 ) * pev->angles; pev->velocity = RANDOM_FLOAT( 200, 300 ) * pev->angles;
pev->velocity.x += RANDOM_FLOAT(-100.f,100.f); pev->velocity.x += RANDOM_FLOAT(-100.f,100.f);
pev->velocity.y += RANDOM_FLOAT(-100.f,100.f); pev->velocity.y += RANDOM_FLOAT(-100.f,100.f);
if ( pev->velocity.z >= 0 ) if ( pev->velocity.z >= 0 )
pev->velocity.z += 200; pev->velocity.z += 200;
else else
pev->velocity.z -= 200; pev->velocity.z -= 200;
pev->movetype = MOVETYPE_BOUNCE; pev->movetype = MOVETYPE_BOUNCE;
pev->gravity = 0.5; pev->gravity = 0.5;
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
SET_MODEL( edict(), "models/grenade.mdl"); // Need a model, just use the grenade, we don't draw it anyway SET_MODEL( edict(), "models/grenade.mdl"); // Need a model, just use the grenade, we don't draw it anyway
UTIL_SetSize(pev, g_vecZero, g_vecZero ); UTIL_SetSize(pev, g_vecZero, g_vecZero );
pev->effects |= EF_NODRAW; pev->effects |= EF_NODRAW;
pev->speed = RANDOM_FLOAT( 0.5, 1.5 ); pev->speed = RANDOM_FLOAT( 0.5, 1.5 );
pev->angles = g_vecZero; pev->angles = g_vecZero;
pev->classname = MAKE_STRING( "_spark_shower" ); pev->classname = MAKE_STRING( "_spark_shower" );
} }
void CMShower::Think( void ) void CMShower::Think( void )
{ {
UTIL_Sparks( pev->origin ); UTIL_Sparks( pev->origin );
pev->speed -= 0.1; pev->speed -= 0.1;
if ( pev->speed > 0 ) if ( pev->speed > 0 )
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
else else
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
pev->flags &= ~FL_ONGROUND; pev->flags &= ~FL_ONGROUND;
} }
void CMShower::Touch( CMBaseEntity *pOther ) void CMShower::Touch( CMBaseEntity *pOther )
{ {
if ( pev->flags & FL_ONGROUND ) if ( pev->flags & FL_ONGROUND )
pev->velocity = pev->velocity * 0.1; pev->velocity = pev->velocity * 0.1;
else else
pev->velocity = pev->velocity * 0.6; pev->velocity = pev->velocity * 0.6;
if ( (pev->velocity.x*pev->velocity.x+pev->velocity.y*pev->velocity.y) < 10.0 ) if ( (pev->velocity.x*pev->velocity.x+pev->velocity.y*pev->velocity.y) < 10.0 )
pev->speed = 0; pev->speed = 0;
} }
class CMEnvExplosion : public CMBaseMonster class CMEnvExplosion : public CMBaseMonster
{ {
public: public:
void Spawn( ); void Spawn( );
void EXPORT Smoke ( void ); void EXPORT Smoke ( void );
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
void DelayUse( void ); void DelayUse( void );
void Use( CMBaseEntity *pActivator, CMBaseEntity *pCaller, USE_TYPE useType, float value ); void Use( CMBaseEntity *pActivator, CMBaseEntity *pCaller, USE_TYPE useType, float value );
int m_iMagnitude;// how large is the fireball? how much damage? int m_iMagnitude;// how large is the fireball? how much damage?
int m_spriteScale; // what's the exact fireball sprite scale? int m_spriteScale; // what's the exact fireball sprite scale?
}; };
void CMEnvExplosion::KeyValue( KeyValueData *pkvd ) void CMEnvExplosion::KeyValue( KeyValueData *pkvd )
{ {
if (FStrEq(pkvd->szKeyName, "iMagnitude")) if (FStrEq(pkvd->szKeyName, "iMagnitude"))
{ {
m_iMagnitude = atoi(pkvd->szValue); m_iMagnitude = atoi(pkvd->szValue);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
CMBaseEntity::KeyValue( pkvd ); CMBaseEntity::KeyValue( pkvd );
} }
void CMEnvExplosion::Spawn( void ) void CMEnvExplosion::Spawn( void )
{ {
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
pev->effects = EF_NODRAW; pev->effects = EF_NODRAW;
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
/* /*
if ( m_iMagnitude > 250 ) if ( m_iMagnitude > 250 )
{ {
m_iMagnitude = 250; m_iMagnitude = 250;
} }
*/ */
float flSpriteScale; float flSpriteScale;
flSpriteScale = ( m_iMagnitude - 50) * 0.6; flSpriteScale = ( m_iMagnitude - 50) * 0.6;
/* /*
if ( flSpriteScale > 50 ) if ( flSpriteScale > 50 )
{ {
flSpriteScale = 50; flSpriteScale = 50;
} }
*/ */
if ( flSpriteScale < 10 ) if ( flSpriteScale < 10 )
{ {
flSpriteScale = 10; flSpriteScale = 10;
} }
m_spriteScale = (int)flSpriteScale; m_spriteScale = (int)flSpriteScale;
pev->classname = MAKE_STRING( "_env_explosion" ); pev->classname = MAKE_STRING( "_env_explosion" );
} }
void CMEnvExplosion::DelayUse( void ) void CMEnvExplosion::DelayUse( void )
{ {
Use( NULL, NULL, USE_TOGGLE, 0 ); Use( NULL, NULL, USE_TOGGLE, 0 );
} }
void CMEnvExplosion::Use( CMBaseEntity *pActivator, CMBaseEntity *pCaller, USE_TYPE useType, float value ) void CMEnvExplosion::Use( CMBaseEntity *pActivator, CMBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
TraceResult tr; TraceResult tr;
pev->model = iStringNull;//invisible pev->model = iStringNull;//invisible
pev->solid = SOLID_NOT;// intangible pev->solid = SOLID_NOT;// intangible
Vector vecSpot;// trace starts here! Vector vecSpot;// trace starts here!
vecSpot = pev->origin + Vector ( 0 , 0 , 8 ); vecSpot = pev->origin + Vector ( 0 , 0 , 8 );
UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr); UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr);
// Pull out of the wall a bit // Pull out of the wall a bit
if ( tr.flFraction != 1.0 ) if ( tr.flFraction != 1.0 )
{ {
pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6); pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6);
} }
else else
{ {
pev->origin = pev->origin; pev->origin = pev->origin;
} }
// draw decal // draw decal
if (! ( pev->spawnflags & SF_ENVEXPLOSION_NODECAL)) if (! ( pev->spawnflags & SF_ENVEXPLOSION_NODECAL))
{ {
if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 ) if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 )
{ {
UTIL_DecalTrace( &tr, DECAL_SCORCH1 ); UTIL_DecalTrace( &tr, DECAL_SCORCH1 );
} }
else else
{ {
UTIL_DecalTrace( &tr, DECAL_SCORCH2 ); UTIL_DecalTrace( &tr, DECAL_SCORCH2 );
} }
} }
// draw fireball // draw fireball
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) ) if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) )
{ {
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_EXPLOSION); WRITE_BYTE( TE_EXPLOSION);
WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->origin.z );
WRITE_SHORT( g_sModelIndexFireball ); WRITE_SHORT( g_sModelIndexFireball );
WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10 WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10
WRITE_BYTE( 15 ); // framerate WRITE_BYTE( 15 ); // framerate
WRITE_BYTE( TE_EXPLFLAG_NONE ); WRITE_BYTE( TE_EXPLFLAG_NONE );
MESSAGE_END(); MESSAGE_END();
} }
else else
{ {
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_EXPLOSION); WRITE_BYTE( TE_EXPLOSION);
WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->origin.z );
WRITE_SHORT( g_sModelIndexFireball ); WRITE_SHORT( g_sModelIndexFireball );
WRITE_BYTE( 0 ); // no sprite WRITE_BYTE( 0 ); // no sprite
WRITE_BYTE( 15 ); // framerate WRITE_BYTE( 15 ); // framerate
WRITE_BYTE( TE_EXPLFLAG_NONE ); WRITE_BYTE( TE_EXPLFLAG_NONE );
MESSAGE_END(); MESSAGE_END();
} }
// do damage // do damage
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) ) if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) )
{ {
RadiusDamage ( pev, pev->owner == NULL ? pev : VARS( pev->owner ), m_iMagnitude, CLASS_NONE, DMG_BLAST ); RadiusDamage ( pev, pev->owner == NULL ? pev : VARS( pev->owner ), m_iMagnitude, CLASS_NONE, DMG_BLAST );
} }
SetThink( &CMEnvExplosion::Smoke ); SetThink( &CMEnvExplosion::Smoke );
pev->nextthink = gpGlobals->time + 0.3; pev->nextthink = gpGlobals->time + 0.3;
// draw sparks // draw sparks
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) ) if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) )
{ {
int sparkCount = RANDOM_LONG(0,3); int sparkCount = RANDOM_LONG(0,3);
for ( int i = 0; i < sparkCount; i++ ) for ( int i = 0; i < sparkCount; i++ )
{ {
CMBaseEntity *pSpark = CreateClassPtr((CMShower *)NULL); CMBaseEntity *pSpark = CreateClassPtr((CMShower *)NULL);
if ( pSpark == NULL ) if ( pSpark == NULL )
{ {
ALERT( at_console, "Failed to spawn spark_shower!" ); ALERT( at_console, "Failed to spawn spark_shower!" );
} }
else else
{ {
UTIL_SetOrigin( pSpark->pev, pev->origin ); UTIL_SetOrigin( pSpark->pev, pev->origin );
pSpark->pev->angles = tr.vecPlaneNormal; pSpark->pev->angles = tr.vecPlaneNormal;
pSpark->Spawn(); pSpark->Spawn();
} }
// Create( "spark_shower", pev->origin, tr.vecPlaneNormal, NULL ); // Create( "spark_shower", pev->origin, tr.vecPlaneNormal, NULL );
} }
} }
} }
void CMEnvExplosion::Smoke( void ) void CMEnvExplosion::Smoke( void )
{ {
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSMOKE ) ) if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSMOKE ) )
{ {
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_SMOKE ); WRITE_BYTE( TE_SMOKE );
WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->origin.z );
WRITE_SHORT( g_sModelIndexSmoke ); WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10 WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10
WRITE_BYTE( 12 ); // framerate WRITE_BYTE( 12 ); // framerate
MESSAGE_END(); MESSAGE_END();
} }
if ( !(pev->spawnflags & SF_ENVEXPLOSION_REPEATABLE) ) if ( !(pev->spawnflags & SF_ENVEXPLOSION_REPEATABLE) )
{ {
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
} }
} }
// Stock to quickly create a one-time explosion // Stock to quickly create a one-time explosion
void ExplosionCreate( const Vector &center, const Vector &angles, edict_t *pOwner, int magnitude, int flags, float delay ) void ExplosionCreate( const Vector &center, const Vector &angles, edict_t *pOwner, int magnitude, int flags, float delay )
{ {
KeyValueData kvd; KeyValueData kvd;
char buf[128]; char buf[128];
//CMBaseEntity *pExplosion = CMBaseEntity::Create( "env_explosion", center, angles, pOwner ); //CMBaseEntity *pExplosion = CMBaseEntity::Create( "env_explosion", center, angles, pOwner );
CMBaseEntity *pExplosion = CreateClassPtr((CMEnvExplosion *)NULL); CMBaseEntity *pExplosion = CreateClassPtr((CMEnvExplosion *)NULL);
if ( pExplosion == NULL ) if ( pExplosion == NULL )
{ {
ALERT( at_console, "Failed to create env_explosion!" ); ALERT( at_console, "Failed to create env_explosion!" );
} }
else else
{ {
sprintf( buf, "%3d", magnitude ); sprintf( buf, "%3d", magnitude );
kvd.szKeyName = "iMagnitude"; kvd.szKeyName = "iMagnitude";
kvd.szValue = buf; kvd.szValue = buf;
pExplosion->KeyValue( &kvd ); pExplosion->KeyValue( &kvd );
pExplosion->pev->owner = pOwner; pExplosion->pev->owner = pOwner;
pExplosion->pev->spawnflags |= flags; pExplosion->pev->spawnflags |= flags;
UTIL_SetOrigin( pExplosion->pev, center ); UTIL_SetOrigin( pExplosion->pev, center );
pExplosion->pev->angles = angles; pExplosion->pev->angles = angles;
// This is a temporary entity, filter out the flag // This is a temporary entity, filter out the flag
pExplosion->pev->spawnflags &= ~SF_ENVEXPLOSION_REPEATABLE; pExplosion->pev->spawnflags &= ~SF_ENVEXPLOSION_REPEATABLE;
pExplosion->Spawn(); pExplosion->Spawn();
if ( delay > 0.0f ) if ( delay > 0.0f )
{ {
//pExplosion->SetThink( &CMBaseEntity::SUB_CallUseToggle ); // i don't trust you //pExplosion->SetThink( &CMBaseEntity::SUB_CallUseToggle ); // i don't trust you
pExplosion->SetThink( &CMEnvExplosion::DelayUse ); pExplosion->SetThink( &CMEnvExplosion::DelayUse );
pExplosion->pev->nextthink = gpGlobals->time + delay; pExplosion->pev->nextthink = gpGlobals->time + delay;
} }
else else
{ {
pExplosion->Use( NULL, NULL, USE_TOGGLE, 0 ); pExplosion->Use( NULL, NULL, USE_TOGGLE, 0 );
} }
} }
} }

View File

@@ -1,32 +1,32 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef EXPLODE_H #ifndef EXPLODE_H
#define EXPLODE_H #define EXPLODE_H
#define SF_ENVEXPLOSION_NODAMAGE ( 1 << 0 ) // when set, ENV_EXPLOSION will not actually inflict damage #define SF_ENVEXPLOSION_NODAMAGE ( 1 << 0 ) // when set, ENV_EXPLOSION will not actually inflict damage
#define SF_ENVEXPLOSION_REPEATABLE ( 1 << 1 ) // can this entity be refired? #define SF_ENVEXPLOSION_REPEATABLE ( 1 << 1 ) // can this entity be refired?
#define SF_ENVEXPLOSION_NOFIREBALL ( 1 << 2 ) // don't draw the fireball #define SF_ENVEXPLOSION_NOFIREBALL ( 1 << 2 ) // don't draw the fireball
#define SF_ENVEXPLOSION_NOSMOKE ( 1 << 3 ) // don't draw the smoke #define SF_ENVEXPLOSION_NOSMOKE ( 1 << 3 ) // don't draw the smoke
#define SF_ENVEXPLOSION_NODECAL ( 1 << 4 ) // don't make a scorch mark #define SF_ENVEXPLOSION_NODECAL ( 1 << 4 ) // don't make a scorch mark
#define SF_ENVEXPLOSION_NOSPARKS ( 1 << 5 ) // don't make a scorch mark #define SF_ENVEXPLOSION_NOSPARKS ( 1 << 5 ) // don't make a scorch mark
extern DLL_GLOBAL short g_sModelIndexFireball; extern DLL_GLOBAL short g_sModelIndexFireball;
extern DLL_GLOBAL short g_sModelIndexSmoke; extern DLL_GLOBAL short g_sModelIndexSmoke;
extern DLL_GLOBAL short g_sModelIndexTinySpit; extern DLL_GLOBAL short g_sModelIndexTinySpit;
extern void ExplosionCreate( const Vector &center, const Vector &angles, edict_t *pOwner, int magnitude, int flags, float delay ); extern void ExplosionCreate( const Vector &center, const Vector &angles, edict_t *pOwner, int magnitude, int flags, float delay );
#endif //EXPLODE_H #endif //EXPLODE_H

View File

@@ -1,87 +1,88 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef EXTDLL_H #ifndef EXTDLL_H
#define EXTDLL_H #define EXTDLL_H
// //
// Global header file for extension DLLs // Global header file for extension DLLs
// //
// Allow "DEBUG" in addition to default "_DEBUG" // Allow "DEBUG" in addition to default "_DEBUG"
#ifdef _DEBUG #ifdef _DEBUG
#define DEBUG 1 #define DEBUG 1
#endif #endif
// Silence certain warnings // Silence certain warnings
#pragma warning(disable : 4244) // int or float down-conversion #pragma warning(disable : 4244) // int or float down-conversion
#pragma warning(disable : 4305) // int or float data truncation #pragma warning(disable : 4305) // int or float data truncation
#pragma warning(disable : 4201) // nameless struct/union #pragma warning(disable : 4201) // nameless struct/union
#pragma warning(disable : 4514) // unreferenced inline function removed #pragma warning(disable : 4514) // unreferenced inline function removed
#pragma warning(disable : 4100) // unreferenced formal parameter #pragma warning(disable : 4100) // unreferenced formal parameter
#pragma warning(disable : 4390) // empty controlled statement (seems to work fine? monster_api.cpp[101/115])
// Prevent tons of unused windows definitions
#ifdef _WIN32 // Prevent tons of unused windows definitions
#define WIN32_LEAN_AND_MEAN #ifdef _WIN32
#define NOWINRES #define WIN32_LEAN_AND_MEAN
#define NOSERVICE #define NOWINRES
#define NOMCX #define NOSERVICE
#define NOIME #define NOMCX
#include "windows.h" #define NOIME
#else // _WIN32 #include "windows.h"
#define FALSE 0 #else // _WIN32
#define TRUE (!FALSE) #define FALSE 0
typedef unsigned long ULONG; #define TRUE (!FALSE)
typedef unsigned char BYTE; typedef unsigned long ULONG;
typedef int BOOL; typedef unsigned char BYTE;
#define MAX_PATH PATH_MAX typedef int BOOL;
#include <limits.h> #define MAX_PATH PATH_MAX
#include <stdarg.h> #include <limits.h>
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) #include <stdarg.h>
#endif //_WIN32 #define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
#endif //_WIN32
// Misc C-runtime library headers
#include "stdio.h" // Misc C-runtime library headers
#include "stdlib.h" #include "stdio.h"
#include "math.h" #include "stdlib.h"
#include "math.h"
// min/max is not on math.h library
// move outside win32 scope so it can compile on both platforms // min/max is not on math.h library
#define min(a,b) (((a) < (b)) ? (a) : (b)) // move outside win32 scope so it can compile on both platforms
#define max(a,b) (((a) > (b)) ? (a) : (b)) #define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
// Header file containing definition of globalvars_t and entvars_t
typedef int func_t; // // Header file containing definition of globalvars_t and entvars_t
typedef int string_t; // from engine's pr_comp.h; typedef int func_t; //
typedef float vec_t; // needed before including progdefs.h typedef int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h
// Vector class
#include "vector.h" // Vector class
#include "vector.h"
// Defining it as a (bogus) struct helps enforce type-checking
#define vec3_t Vector // Defining it as a (bogus) struct helps enforce type-checking
#define vec3_t Vector
// Shared engine/DLL constants
#include "const.h" // Shared engine/DLL constants
#include "progdefs.h" #include "const.h"
#include "edict.h" #include "progdefs.h"
#include "edict.h"
// Shared header describing protocol between engine and DLLs
#include "eiface.h" // Shared header describing protocol between engine and DLLs
#include "eiface.h"
// Shared header between the client DLL and the game DLLs
#include "cdll_dll.h" // Shared header between the client DLL and the game DLLs
#include "cdll_dll.h"
#endif //EXTDLL_H
#endif //EXTDLL_H

View File

@@ -1,281 +1,281 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "schedule.h" #include "schedule.h"
#define FLYING_AE_FLAP (8) #define FLYING_AE_FLAP (8)
#define FLYING_AE_FLAPSOUND (9) #define FLYING_AE_FLAPSOUND (9)
extern DLL_GLOBAL edict_t *g_pBodyQueueHead; extern DLL_GLOBAL edict_t *g_pBodyQueueHead;
int CMFlyingMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, edict_t *pTarget, float *pflDist ) int CMFlyingMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, edict_t *pTarget, float *pflDist )
{ {
// UNDONE: need to check more than the endpoint // UNDONE: need to check more than the endpoint
if (FBitSet(pev->flags, FL_SWIM) && (UTIL_PointContents(vecEnd) != CONTENTS_WATER)) if (FBitSet(pev->flags, FL_SWIM) && (UTIL_PointContents(vecEnd) != CONTENTS_WATER))
{ {
// ALERT(at_aiconsole, "can't swim out of water\n"); // ALERT(at_aiconsole, "can't swim out of water\n");
return FALSE; return FALSE;
} }
TraceResult tr; TraceResult tr;
UTIL_TraceHull( vecStart + Vector( 0, 0, 32 ), vecEnd + Vector( 0, 0, 32 ), dont_ignore_monsters, large_hull, edict(), &tr ); UTIL_TraceHull( vecStart + Vector( 0, 0, 32 ), vecEnd + Vector( 0, 0, 32 ), dont_ignore_monsters, large_hull, edict(), &tr );
// ALERT( at_console, "%.0f %.0f %.0f : ", vecStart.x, vecStart.y, vecStart.z ); // ALERT( at_console, "%.0f %.0f %.0f : ", vecStart.x, vecStart.y, vecStart.z );
// ALERT( at_console, "%.0f %.0f %.0f\n", vecEnd.x, vecEnd.y, vecEnd.z ); // ALERT( at_console, "%.0f %.0f %.0f\n", vecEnd.x, vecEnd.y, vecEnd.z );
if (pflDist) if (pflDist)
{ {
*pflDist = ( (tr.vecEndPos - Vector( 0, 0, 32 )) - vecStart ).Length();// get the distance. *pflDist = ( (tr.vecEndPos - Vector( 0, 0, 32 )) - vecStart ).Length();// get the distance.
} }
// ALERT( at_console, "check %d %d %f\n", tr.fStartSolid, tr.fAllSolid, tr.flFraction ); // ALERT( at_console, "check %d %d %f\n", tr.fStartSolid, tr.fAllSolid, tr.flFraction );
if (tr.fStartSolid || tr.flFraction < 1.0) if (tr.fStartSolid || tr.flFraction < 1.0)
{ {
if ( pTarget && (pTarget == gpGlobals->trace_ent) ) if ( pTarget && (pTarget == gpGlobals->trace_ent) )
return LOCALMOVE_VALID; return LOCALMOVE_VALID;
return LOCALMOVE_INVALID; return LOCALMOVE_INVALID;
} }
return LOCALMOVE_VALID; return LOCALMOVE_VALID;
} }
BOOL CMFlyingMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, edict_t *pTargetEnt, Vector *pApex ) BOOL CMFlyingMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, edict_t *pTargetEnt, Vector *pApex )
{ {
return CMBaseMonster::FTriangulate( vecStart, vecEnd, flDist, pTargetEnt, pApex ); return CMBaseMonster::FTriangulate( vecStart, vecEnd, flDist, pTargetEnt, pApex );
} }
Activity CMFlyingMonster :: GetStoppedActivity( void ) Activity CMFlyingMonster :: GetStoppedActivity( void )
{ {
if ( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else if ( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else
return ACT_IDLE; return ACT_IDLE;
return ACT_HOVER; return ACT_HOVER;
} }
void CMFlyingMonster :: Stop( void ) void CMFlyingMonster :: Stop( void )
{ {
Activity stopped = GetStoppedActivity(); Activity stopped = GetStoppedActivity();
if ( m_IdealActivity != stopped ) if ( m_IdealActivity != stopped )
{ {
m_flightSpeed = 0; m_flightSpeed = 0;
m_IdealActivity = stopped; m_IdealActivity = stopped;
} }
pev->angles.z = 0; pev->angles.z = 0;
pev->angles.x = 0; pev->angles.x = 0;
m_vecTravel = g_vecZero; m_vecTravel = g_vecZero;
} }
float CMFlyingMonster :: ChangeYaw( int speed ) float CMFlyingMonster :: ChangeYaw( int speed )
{ {
if ( pev->movetype == MOVETYPE_FLY ) if ( pev->movetype == MOVETYPE_FLY )
{ {
float diff = FlYawDiff(); float diff = FlYawDiff();
float target = 0; float target = 0;
if ( m_IdealActivity != GetStoppedActivity() ) if ( m_IdealActivity != GetStoppedActivity() )
{ {
if ( diff < -20 ) if ( diff < -20 )
target = 90; target = 90;
else if ( diff > 20 ) else if ( diff > 20 )
target = -90; target = -90;
} }
pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0 * gpGlobals->frametime ); pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0 * gpGlobals->frametime );
} }
return CMBaseMonster::ChangeYaw( speed ); return CMBaseMonster::ChangeYaw( speed );
} }
void CMFlyingMonster :: Killed( entvars_t *pevAttacker, int iGib ) void CMFlyingMonster :: Killed( entvars_t *pevAttacker, int iGib )
{ {
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_STEP;
ClearBits( pev->flags, FL_ONGROUND ); ClearBits( pev->flags, FL_ONGROUND );
pev->angles.z = 0; pev->angles.z = 0;
pev->angles.x = 0; pev->angles.x = 0;
CMBaseMonster::Killed( pevAttacker, iGib ); CMBaseMonster::Killed( pevAttacker, iGib );
} }
void CMFlyingMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) void CMFlyingMonster :: HandleAnimEvent( MonsterEvent_t *pEvent )
{ {
switch( pEvent->event ) switch( pEvent->event )
{ {
case FLYING_AE_FLAP: case FLYING_AE_FLAP:
m_flightSpeed = 400; m_flightSpeed = 400;
break; break;
case FLYING_AE_FLAPSOUND: case FLYING_AE_FLAPSOUND:
if ( m_pFlapSound ) if ( m_pFlapSound )
EMIT_SOUND( edict(), CHAN_BODY, m_pFlapSound, 1, ATTN_NORM ); EMIT_SOUND( edict(), CHAN_BODY, m_pFlapSound, 1, ATTN_NORM );
break; break;
default: default:
CMBaseMonster::HandleAnimEvent( pEvent ); CMBaseMonster::HandleAnimEvent( pEvent );
break; break;
} }
} }
void CMFlyingMonster :: Move( float flInterval ) void CMFlyingMonster :: Move( float flInterval )
{ {
if ( pev->movetype == MOVETYPE_FLY ) if ( pev->movetype == MOVETYPE_FLY )
m_flGroundSpeed = m_flightSpeed; m_flGroundSpeed = m_flightSpeed;
CMBaseMonster::Move( flInterval ); CMBaseMonster::Move( flInterval );
} }
BOOL CMFlyingMonster:: ShouldAdvanceRoute( float flWaypointDist ) BOOL CMFlyingMonster:: ShouldAdvanceRoute( float flWaypointDist )
{ {
// Get true 3D distance to the goal so we actually reach the correct height // Get true 3D distance to the goal so we actually reach the correct height
if ( m_Route[ m_iRouteIndex ].iType & bits_MF_IS_GOAL ) if ( m_Route[ m_iRouteIndex ].iType & bits_MF_IS_GOAL )
flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length(); flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length();
if ( flWaypointDist <= 64 + (m_flGroundSpeed * gpGlobals->frametime) ) if ( flWaypointDist <= 64 + (m_flGroundSpeed * gpGlobals->frametime) )
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
void CMFlyingMonster::MoveExecute( edict_t *pTargetEnt, const Vector &vecDir, float flInterval ) void CMFlyingMonster::MoveExecute( edict_t *pTargetEnt, const Vector &vecDir, float flInterval )
{ {
if ( pev->movetype == MOVETYPE_FLY ) if ( pev->movetype == MOVETYPE_FLY )
{ {
if ( gpGlobals->time - m_stopTime > 1.0 ) if ( gpGlobals->time - m_stopTime > 1.0 )
{ {
if ( m_IdealActivity != m_movementActivity ) if ( m_IdealActivity != m_movementActivity )
{ {
m_IdealActivity = m_movementActivity; m_IdealActivity = m_movementActivity;
m_flGroundSpeed = m_flightSpeed = 200; m_flGroundSpeed = m_flightSpeed = 200;
} }
} }
Vector vecMove = pev->origin + (( vecDir + (m_vecTravel * m_momentum) ).Normalize() * (m_flGroundSpeed * flInterval)); Vector vecMove = pev->origin + (( vecDir + (m_vecTravel * m_momentum) ).Normalize() * (m_flGroundSpeed * flInterval));
if ( m_IdealActivity != m_movementActivity ) if ( m_IdealActivity != m_movementActivity )
{ {
m_flightSpeed = UTIL_Approach( 100, m_flightSpeed, 75 * gpGlobals->frametime ); m_flightSpeed = UTIL_Approach( 100, m_flightSpeed, 75 * gpGlobals->frametime );
if ( m_flightSpeed < 100 ) if ( m_flightSpeed < 100 )
m_stopTime = gpGlobals->time; m_stopTime = gpGlobals->time;
} }
else else
m_flightSpeed = UTIL_Approach( 20, m_flightSpeed, 300 * gpGlobals->frametime ); m_flightSpeed = UTIL_Approach( 20, m_flightSpeed, 300 * gpGlobals->frametime );
if ( CheckLocalMove ( pev->origin, vecMove, pTargetEnt, NULL ) ) if ( CheckLocalMove ( pev->origin, vecMove, pTargetEnt, NULL ) )
{ {
m_vecTravel = (vecMove - pev->origin); m_vecTravel = (vecMove - pev->origin);
m_vecTravel = m_vecTravel.Normalize(); m_vecTravel = m_vecTravel.Normalize();
UTIL_MoveToOrigin(ENT(pev), vecMove, (m_flGroundSpeed * flInterval), MOVE_STRAFE); UTIL_MoveToOrigin(ENT(pev), vecMove, (m_flGroundSpeed * flInterval), MOVE_STRAFE);
} }
else else
{ {
m_IdealActivity = GetStoppedActivity(); m_IdealActivity = GetStoppedActivity();
m_stopTime = gpGlobals->time; m_stopTime = gpGlobals->time;
m_vecTravel = g_vecZero; m_vecTravel = g_vecZero;
} }
} }
else else
CMBaseMonster::MoveExecute( pTargetEnt, vecDir, flInterval ); CMBaseMonster::MoveExecute( pTargetEnt, vecDir, flInterval );
} }
float CMFlyingMonster::CeilingZ( const Vector &position ) float CMFlyingMonster::CeilingZ( const Vector &position )
{ {
TraceResult tr; TraceResult tr;
Vector minUp = position; Vector minUp = position;
Vector maxUp = position; Vector maxUp = position;
maxUp.z += 4096.0; maxUp.z += 4096.0;
UTIL_TraceLine(position, maxUp, ignore_monsters, NULL, &tr); UTIL_TraceLine(position, maxUp, ignore_monsters, NULL, &tr);
if (tr.flFraction != 1.0) if (tr.flFraction != 1.0)
maxUp.z = tr.vecEndPos.z; maxUp.z = tr.vecEndPos.z;
if ((pev->flags) & FL_SWIM) if ((pev->flags) & FL_SWIM)
{ {
return UTIL_WaterLevel( position, minUp.z, maxUp.z ); return UTIL_WaterLevel( position, minUp.z, maxUp.z );
} }
return maxUp.z; return maxUp.z;
} }
BOOL CMFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float *pFraction) BOOL CMFlyingMonster::ProbeZ( const Vector &position, const Vector &probe, float *pFraction)
{ {
int conPosition = UTIL_PointContents(position); int conPosition = UTIL_PointContents(position);
if ( (((pev->flags) & FL_SWIM) == FL_SWIM) ^ (conPosition == CONTENTS_WATER)) if ( (((pev->flags) & FL_SWIM) == FL_SWIM) ^ (conPosition == CONTENTS_WATER))
{ {
// SWIMING & !WATER // SWIMING & !WATER
// or FLYING & WATER // or FLYING & WATER
// //
*pFraction = 0.0; *pFraction = 0.0;
return TRUE; // We hit a water boundary because we are where we don't belong. return TRUE; // We hit a water boundary because we are where we don't belong.
} }
int conProbe = UTIL_PointContents(probe); int conProbe = UTIL_PointContents(probe);
if (conProbe == conPosition) if (conProbe == conPosition)
{ {
// The probe is either entirely inside the water (for fish) or entirely // The probe is either entirely inside the water (for fish) or entirely
// outside the water (for birds). // outside the water (for birds).
// //
*pFraction = 1.0; *pFraction = 1.0;
return FALSE; return FALSE;
} }
Vector ProbeUnit = (probe-position).Normalize(); Vector ProbeUnit = (probe-position).Normalize();
float ProbeLength = (probe-position).Length(); float ProbeLength = (probe-position).Length();
float maxProbeLength = ProbeLength; float maxProbeLength = ProbeLength;
float minProbeLength = 0; float minProbeLength = 0;
float diff = maxProbeLength - minProbeLength; float diff = maxProbeLength - minProbeLength;
while (diff > 1.0) while (diff > 1.0)
{ {
float midProbeLength = minProbeLength + diff/2.0; float midProbeLength = minProbeLength + diff/2.0;
Vector midProbeVec = midProbeLength * ProbeUnit; Vector midProbeVec = midProbeLength * ProbeUnit;
if (UTIL_PointContents(position+midProbeVec) == conPosition) if (UTIL_PointContents(position+midProbeVec) == conPosition)
{ {
minProbeLength = midProbeLength; minProbeLength = midProbeLength;
} }
else else
{ {
maxProbeLength = midProbeLength; maxProbeLength = midProbeLength;
} }
diff = maxProbeLength - minProbeLength; diff = maxProbeLength - minProbeLength;
} }
*pFraction = minProbeLength/ProbeLength; *pFraction = minProbeLength/ProbeLength;
return TRUE; return TRUE;
} }
float CMFlyingMonster::FloorZ( const Vector &position ) float CMFlyingMonster::FloorZ( const Vector &position )
{ {
TraceResult tr; TraceResult tr;
Vector down = position; Vector down = position;
down.z -= 2048; down.z -= 2048;
UTIL_TraceLine( position, down, ignore_monsters, NULL, &tr ); UTIL_TraceLine( position, down, ignore_monsters, NULL, &tr );
if ( tr.flFraction != 1.0 ) if ( tr.flFraction != 1.0 )
return tr.vecEndPos.z; return tr.vecEndPos.z;
return down.z; return down.z;
} }

View File

@@ -1,70 +1,70 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef FUNC_BREAK_H #ifndef FUNC_BREAK_H
#define FUNC_BREAK_H #define FUNC_BREAK_H
typedef enum { expRandom, expDirected} Explosions; typedef enum { expRandom, expDirected} Explosions;
typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial } Materials; typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial } Materials;
#define NUM_SHARDS 6 // this many shards spawned when breakable objects break; #define NUM_SHARDS 6 // this many shards spawned when breakable objects break;
class CMBreakable : public CMBaseDelay class CMBreakable : public CMBaseDelay
{ {
public: public:
// basic functions // basic functions
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
void KeyValue( KeyValueData* pkvd); void KeyValue( KeyValueData* pkvd);
void EXPORT BreakTouch( CMBaseEntity *pOther ); void EXPORT BreakTouch( CMBaseEntity *pOther );
void Use( CMBaseEntity *pActivator, CMBaseEntity *pCaller, USE_TYPE useType, float value ); void Use( CMBaseEntity *pActivator, CMBaseEntity *pCaller, USE_TYPE useType, float value );
void DamageSound( void ); void DamageSound( void );
// breakables use an overridden takedamage // breakables use an overridden takedamage
virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
// To spark when hit // To spark when hit
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType );
BOOL IsBreakable( void ); BOOL IsBreakable( void );
BOOL SparkWhenHit( void ); BOOL SparkWhenHit( void );
int DamageDecal( int bitsDamageType ); int DamageDecal( int bitsDamageType );
void EXPORT Die( void ); void EXPORT Die( void );
virtual int ObjectCaps( void ) { return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } virtual int ObjectCaps( void ) { return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; } inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; }
inline int ExplosionMagnitude( void ) { return pev->impulse; } inline int ExplosionMagnitude( void ) { return pev->impulse; }
inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; } inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; }
static void MaterialSoundPrecache( Materials precacheMaterial ); static void MaterialSoundPrecache( Materials precacheMaterial );
static void MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume ); static void MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume );
static const char **MaterialSoundList( Materials precacheMaterial, int &soundCount ); static const char **MaterialSoundList( Materials precacheMaterial, int &soundCount );
static const char *pSoundsWood[]; static const char *pSoundsWood[];
static const char *pSoundsFlesh[]; static const char *pSoundsFlesh[];
static const char *pSoundsGlass[]; static const char *pSoundsGlass[];
static const char *pSoundsMetal[]; static const char *pSoundsMetal[];
static const char *pSoundsConcrete[]; static const char *pSoundsConcrete[];
static const char *pSpawnObjects[]; static const char *pSpawnObjects[];
Materials m_Material; Materials m_Material;
Explosions m_Explosion; Explosions m_Explosion;
int m_idShard; int m_idShard;
float m_angle; float m_angle;
int m_iszGibModel; int m_iszGibModel;
int m_iszSpawnObject; int m_iszSpawnObject;
}; };
#endif // FUNC_BREAK_H #endif // FUNC_BREAK_H

3684
src/dlls/gargantua.cpp Executable file → Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,466 +1,466 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
===== generic grenade.cpp ======================================================== ===== generic grenade.cpp ========================================================
*/ */
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "weapons.h" #include "weapons.h"
#include "nodes.h" #include "nodes.h"
#include "decals.h" #include "decals.h"
#include "explode.h" #include "explode.h"
//===================grenade //===================grenade
// Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges // Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges
#define SF_DETONATE 0x0001 #define SF_DETONATE 0x0001
// //
// Grenade Explode // Grenade Explode
// //
void CMGrenade::Explode( Vector vecSrc, Vector vecAim ) void CMGrenade::Explode( Vector vecSrc, Vector vecAim )
{ {
TraceResult tr; TraceResult tr;
UTIL_TraceLine ( pev->origin, pev->origin + Vector ( 0, 0, -32 ), ignore_monsters, ENT(pev), & tr); UTIL_TraceLine ( pev->origin, pev->origin + Vector ( 0, 0, -32 ), ignore_monsters, ENT(pev), & tr);
Explode( &tr, DMG_BLAST ); Explode( &tr, DMG_BLAST );
} }
// UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution. // UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution.
void CMGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) void CMGrenade::Explode( TraceResult *pTrace, int bitsDamageType )
{ {
float flRndSound;// sound randomizer float flRndSound;// sound randomizer
pev->model = iStringNull;//invisible pev->model = iStringNull;//invisible
pev->solid = SOLID_NOT;// intangible pev->solid = SOLID_NOT;// intangible
pev->takedamage = DAMAGE_NO; pev->takedamage = DAMAGE_NO;
// Pull out of the wall a bit // Pull out of the wall a bit
if ( pTrace->flFraction != 1.0 ) if ( pTrace->flFraction != 1.0 )
{ {
pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6); pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6);
} }
int iContents = UTIL_PointContents ( pev->origin ); int iContents = UTIL_PointContents ( pev->origin );
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound
WRITE_COORD( pev->origin.x ); // Send to PAS because of the sound WRITE_COORD( pev->origin.x ); // Send to PAS because of the sound
WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->origin.z );
if (iContents != CONTENTS_WATER) if (iContents != CONTENTS_WATER)
{ {
WRITE_SHORT( g_sModelIndexFireball ); WRITE_SHORT( g_sModelIndexFireball );
} }
else else
{ {
WRITE_SHORT( g_sModelIndexWExplosion ); WRITE_SHORT( g_sModelIndexWExplosion );
} }
WRITE_BYTE( (pev->dmg - 50) * .60 ); // scale * 10 WRITE_BYTE( (pev->dmg - 50) * .60 ); // scale * 10
WRITE_BYTE( 15 ); // framerate WRITE_BYTE( 15 ); // framerate
WRITE_BYTE( TE_EXPLFLAG_NONE ); WRITE_BYTE( TE_EXPLFLAG_NONE );
MESSAGE_END(); MESSAGE_END();
entvars_t *pevOwner; entvars_t *pevOwner;
if ( pev->owner ) if ( pev->owner )
pevOwner = VARS( pev->owner ); pevOwner = VARS( pev->owner );
else else
pevOwner = NULL; pevOwner = NULL;
pev->owner = NULL; // can't traceline attack owner if this is set pev->owner = NULL; // can't traceline attack owner if this is set
RadiusDamage ( pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType ); RadiusDamage ( pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType );
if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 ) if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 )
{ {
UTIL_DecalTrace( pTrace, DECAL_SCORCH1 ); UTIL_DecalTrace( pTrace, DECAL_SCORCH1 );
} }
else else
{ {
UTIL_DecalTrace( pTrace, DECAL_SCORCH2 ); UTIL_DecalTrace( pTrace, DECAL_SCORCH2 );
} }
flRndSound = RANDOM_FLOAT( 0 , 1 ); flRndSound = RANDOM_FLOAT( 0 , 1 );
switch ( RANDOM_LONG( 0, 2 ) ) switch ( RANDOM_LONG( 0, 2 ) )
{ {
case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris1.wav", 0.55, ATTN_NORM); break; case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris1.wav", 0.55, ATTN_NORM); break;
case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris2.wav", 0.55, ATTN_NORM); break; case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris2.wav", 0.55, ATTN_NORM); break;
case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris3.wav", 0.55, ATTN_NORM); break; case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris3.wav", 0.55, ATTN_NORM); break;
} }
pev->effects |= EF_NODRAW; pev->effects |= EF_NODRAW;
SetThink( &CMGrenade::Smoke ); SetThink( &CMGrenade::Smoke );
pev->velocity = g_vecZero; pev->velocity = g_vecZero;
pev->nextthink = gpGlobals->time + 0.3; pev->nextthink = gpGlobals->time + 0.3;
/*jlb /*jlb
if (iContents != CONTENTS_WATER) if (iContents != CONTENTS_WATER)
{ {
int sparkCount = RANDOM_LONG(0,3); int sparkCount = RANDOM_LONG(0,3);
for ( int i = 0; i < sparkCount; i++ ) for ( int i = 0; i < sparkCount; i++ )
Create( "spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL ); Create( "spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL );
} }
jlb*/ jlb*/
} }
void CMGrenade::Smoke( void ) void CMGrenade::Smoke( void )
{ {
if (UTIL_PointContents ( pev->origin ) == CONTENTS_WATER) if (UTIL_PointContents ( pev->origin ) == CONTENTS_WATER)
{ {
UTIL_Bubbles( pev->origin - Vector( 64, 64, 64 ), pev->origin + Vector( 64, 64, 64 ), 100 ); UTIL_Bubbles( pev->origin - Vector( 64, 64, 64 ), pev->origin + Vector( 64, 64, 64 ), 100 );
} }
else else
{ {
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_SMOKE ); WRITE_BYTE( TE_SMOKE );
WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->origin.z );
WRITE_SHORT( g_sModelIndexSmoke ); WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( (pev->dmg - 50) * 0.80 ); // scale * 10 WRITE_BYTE( (pev->dmg - 50) * 0.80 ); // scale * 10
WRITE_BYTE( 12 ); // framerate WRITE_BYTE( 12 ); // framerate
MESSAGE_END(); MESSAGE_END();
} }
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
} }
void CMGrenade::Killed( entvars_t *pevAttacker, int iGib ) void CMGrenade::Killed( entvars_t *pevAttacker, int iGib )
{ {
Detonate( ); Detonate( );
} }
// Timed grenade, this think is called when time runs out. // Timed grenade, this think is called when time runs out.
void CMGrenade::DetonateUse( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value ) void CMGrenade::DetonateUse( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value )
{ {
SetThink( &CMGrenade::Detonate ); SetThink( &CMGrenade::Detonate );
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
void CMGrenade::PreDetonate( void ) void CMGrenade::PreDetonate( void )
{ {
SetThink( &CMGrenade::Detonate ); SetThink( &CMGrenade::Detonate );
pev->nextthink = gpGlobals->time + 1; pev->nextthink = gpGlobals->time + 1;
} }
void CMGrenade::Detonate( void ) void CMGrenade::Detonate( void )
{ {
TraceResult tr; TraceResult tr;
Vector vecSpot;// trace starts here! Vector vecSpot;// trace starts here!
vecSpot = pev->origin + Vector ( 0 , 0 , 8 ); vecSpot = pev->origin + Vector ( 0 , 0 , 8 );
UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr); UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr);
Explode( &tr, DMG_BLAST ); Explode( &tr, DMG_BLAST );
} }
// //
// Contact grenade, explode when it touches something // Contact grenade, explode when it touches something
// //
void CMGrenade::ExplodeTouch( edict_t *pOther ) void CMGrenade::ExplodeTouch( edict_t *pOther )
{ {
TraceResult tr; TraceResult tr;
Vector vecSpot;// trace starts here! Vector vecSpot;// trace starts here!
pev->enemy = pOther; pev->enemy = pOther;
vecSpot = pev->origin - pev->velocity.Normalize() * 32; vecSpot = pev->origin - pev->velocity.Normalize() * 32;
UTIL_TraceLine( vecSpot, vecSpot + pev->velocity.Normalize() * 64, ignore_monsters, ENT(pev), &tr ); UTIL_TraceLine( vecSpot, vecSpot + pev->velocity.Normalize() * 64, ignore_monsters, ENT(pev), &tr );
Explode( &tr, DMG_BLAST ); Explode( &tr, DMG_BLAST );
} }
void CMGrenade::DangerSoundThink( void ) void CMGrenade::DangerSoundThink( void )
{ {
if (!IsInWorld()) if (!IsInWorld())
{ {
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
return; return;
} }
pev->nextthink = gpGlobals->time + 0.2; pev->nextthink = gpGlobals->time + 0.2;
if (pev->waterlevel != 0) if (pev->waterlevel != 0)
{ {
pev->velocity = pev->velocity * 0.5; pev->velocity = pev->velocity * 0.5;
} }
} }
void CMGrenade::BounceTouch( edict_t *pOther ) void CMGrenade::BounceTouch( edict_t *pOther )
{ {
// don't hit the guy that launched this grenade // don't hit the guy that launched this grenade
if ( pOther == pev->owner ) if ( pOther == pev->owner )
return; return;
// only do damage if we're moving fairly fast // only do damage if we're moving fairly fast
if (m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 100) if (m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 100)
{ {
entvars_t *pevOwner = VARS( pev->owner ); entvars_t *pevOwner = VARS( pev->owner );
if (pevOwner) if (pevOwner)
{ {
TraceResult tr = UTIL_GetGlobalTrace( ); TraceResult tr = UTIL_GetGlobalTrace( );
ClearMultiDamage( ); ClearMultiDamage( );
if (UTIL_IsPlayer(pOther)) if (UTIL_IsPlayer(pOther))
UTIL_TraceAttack(pOther, pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB ); UTIL_TraceAttack(pOther, pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB );
else if (pOther->v.euser4 != NULL) else if (pOther->v.euser4 != NULL)
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
pMonster->TraceAttack(pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB ); pMonster->TraceAttack(pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB );
} }
ApplyMultiDamage( pev, pevOwner); ApplyMultiDamage( pev, pevOwner);
} }
m_flNextAttack = gpGlobals->time + 1.0; // debounce m_flNextAttack = gpGlobals->time + 1.0; // debounce
} }
Vector vecTestVelocity; Vector vecTestVelocity;
// pev->avelocity = Vector (300, 300, 300); // pev->avelocity = Vector (300, 300, 300);
// this is my heuristic for modulating the grenade velocity because grenades dropped purely vertical // this is my heuristic for modulating the grenade velocity because grenades dropped purely vertical
// or thrown very far tend to slow down too quickly for me to always catch just by testing velocity. // or thrown very far tend to slow down too quickly for me to always catch just by testing velocity.
// trimming the Z velocity a bit seems to help quite a bit. // trimming the Z velocity a bit seems to help quite a bit.
vecTestVelocity = pev->velocity; vecTestVelocity = pev->velocity;
vecTestVelocity.z *= 0.45; vecTestVelocity.z *= 0.45;
if ( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 ) if ( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 )
{ {
//ALERT( at_console, "Grenade Registered!: %f\n", vecTestVelocity.Length() ); //ALERT( at_console, "Grenade Registered!: %f\n", vecTestVelocity.Length() );
// grenade is moving really slow. It's probably very close to where it will ultimately stop moving. // grenade is moving really slow. It's probably very close to where it will ultimately stop moving.
// go ahead and emit the danger sound. // go ahead and emit the danger sound.
// register a radius louder than the explosion, so we make sure everyone gets out of the way // register a radius louder than the explosion, so we make sure everyone gets out of the way
m_fRegisteredSound = TRUE; m_fRegisteredSound = TRUE;
} }
if (pev->flags & FL_ONGROUND) if (pev->flags & FL_ONGROUND)
{ {
// add a bit of static friction // add a bit of static friction
pev->velocity = pev->velocity * 0.8; pev->velocity = pev->velocity * 0.8;
pev->sequence = RANDOM_LONG( 1, 1 ); pev->sequence = RANDOM_LONG( 1, 1 );
} }
else else
{ {
// play bounce sound // play bounce sound
BounceSound(); BounceSound();
} }
pev->framerate = pev->velocity.Length() / 200.0; pev->framerate = pev->velocity.Length() / 200.0;
if (pev->framerate > 1.0) if (pev->framerate > 1.0)
pev->framerate = 1; pev->framerate = 1;
else if (pev->framerate < 0.5) else if (pev->framerate < 0.5)
pev->framerate = 0; pev->framerate = 0;
} }
void CMGrenade::SlideTouch( edict_t *pOther ) void CMGrenade::SlideTouch( edict_t *pOther )
{ {
// don't hit the guy that launched this grenade // don't hit the guy that launched this grenade
if ( pOther == pev->owner ) if ( pOther == pev->owner )
return; return;
// pev->avelocity = Vector (300, 300, 300); // pev->avelocity = Vector (300, 300, 300);
if (pev->flags & FL_ONGROUND) if (pev->flags & FL_ONGROUND)
{ {
// add a bit of static friction // add a bit of static friction
pev->velocity = pev->velocity * 0.95; pev->velocity = pev->velocity * 0.95;
if (pev->velocity.x != 0 || pev->velocity.y != 0) if (pev->velocity.x != 0 || pev->velocity.y != 0)
{ {
// maintain sliding sound // maintain sliding sound
} }
} }
else else
{ {
BounceSound(); BounceSound();
} }
} }
void CMGrenade :: BounceSound( void ) void CMGrenade :: BounceSound( void )
{ {
switch ( RANDOM_LONG( 0, 2 ) ) switch ( RANDOM_LONG( 0, 2 ) )
{ {
case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM); break; case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM); break;
case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit2.wav", 0.25, ATTN_NORM); break; case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit2.wav", 0.25, ATTN_NORM); break;
case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit3.wav", 0.25, ATTN_NORM); break; case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit3.wav", 0.25, ATTN_NORM); break;
} }
} }
void CMGrenade :: TumbleThink( void ) void CMGrenade :: TumbleThink( void )
{ {
if (!IsInWorld()) if (!IsInWorld())
{ {
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
return; return;
} }
StudioFrameAdvance( ); StudioFrameAdvance( );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
if (pev->dmgtime <= gpGlobals->time) if (pev->dmgtime <= gpGlobals->time)
{ {
SetThink( &CMGrenade::Detonate ); SetThink( &CMGrenade::Detonate );
} }
if (pev->waterlevel != 0) if (pev->waterlevel != 0)
{ {
pev->velocity = pev->velocity * 0.5; pev->velocity = pev->velocity * 0.5;
pev->framerate = 0.2; pev->framerate = 0.2;
} }
} }
void CMGrenade:: Spawn( void ) void CMGrenade:: Spawn( void )
{ {
pev->movetype = MOVETYPE_BOUNCE; pev->movetype = MOVETYPE_BOUNCE;
pev->classname = MAKE_STRING( "grenade" ); pev->classname = MAKE_STRING( "grenade" );
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pev), "models/grenade.mdl"); SET_MODEL(ENT(pev), "models/grenade.mdl");
UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0));
pev->dmg = 100; pev->dmg = 100;
m_fRegisteredSound = FALSE; m_fRegisteredSound = FALSE;
} }
CMGrenade *CMGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ) CMGrenade *CMGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{ {
CMGrenade *pGrenade = CreateClassPtr( (CMGrenade *)NULL ); CMGrenade *pGrenade = CreateClassPtr( (CMGrenade *)NULL );
if (pGrenade == NULL) // no free monster edicts left? if (pGrenade == NULL) // no free monster edicts left?
return NULL; return NULL;
pGrenade->Spawn(); pGrenade->Spawn();
// contact grenades arc lower // contact grenades arc lower
pGrenade->pev->gravity = 0.5;// lower gravity since grenade is aerodynamic and engine doesn't know it. pGrenade->pev->gravity = 0.5;// lower gravity since grenade is aerodynamic and engine doesn't know it.
UTIL_SetOrigin( pGrenade->pev, vecStart ); UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity; pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles (pGrenade->pev->velocity); pGrenade->pev->angles = UTIL_VecToAngles (pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner); pGrenade->pev->owner = ENT(pevOwner);
// make monsters afaid of it while in the air // make monsters afaid of it while in the air
pGrenade->SetThink( &CMGrenade::DangerSoundThink ); pGrenade->SetThink( &CMGrenade::DangerSoundThink );
pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->nextthink = gpGlobals->time;
// Tumble in air // Tumble in air
pGrenade->pev->avelocity.x = RANDOM_FLOAT ( -100, -500 ); pGrenade->pev->avelocity.x = RANDOM_FLOAT ( -100, -500 );
// Explode on contact // Explode on contact
pGrenade->SetTouch( &CMGrenade::ExplodeTouch ); pGrenade->SetTouch( &CMGrenade::ExplodeTouch );
pGrenade->pev->dmg = gSkillData.monDmgM203Grenade; pGrenade->pev->dmg = gSkillData.monDmgM203Grenade;
return pGrenade; return pGrenade;
} }
CMGrenade * CMGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ) CMGrenade * CMGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time )
{ {
CMGrenade *pGrenade = CreateClassPtr( (CMGrenade *)NULL ); CMGrenade *pGrenade = CreateClassPtr( (CMGrenade *)NULL );
if (pGrenade == NULL) // no free monster edicts left? if (pGrenade == NULL) // no free monster edicts left?
return NULL; return NULL;
pGrenade->Spawn(); pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart ); UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity; pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner); pGrenade->pev->owner = ENT(pevOwner);
pGrenade->SetTouch( &CMGrenade::BounceTouch ); // Bounce if touched pGrenade->SetTouch( &CMGrenade::BounceTouch ); // Bounce if touched
// Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate // Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
// will insert a DANGER sound into the world sound list and delay detonation for one second so that // will insert a DANGER sound into the world sound list and delay detonation for one second so that
// the grenade explodes after the exact amount of time specified in the call to ShootTimed(). // the grenade explodes after the exact amount of time specified in the call to ShootTimed().
pGrenade->pev->dmgtime = gpGlobals->time + time; pGrenade->pev->dmgtime = gpGlobals->time + time;
pGrenade->SetThink( &CMGrenade::TumbleThink ); pGrenade->SetThink( &CMGrenade::TumbleThink );
pGrenade->pev->nextthink = gpGlobals->time + 0.1; pGrenade->pev->nextthink = gpGlobals->time + 0.1;
if (time < 0.1) if (time < 0.1)
{ {
pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->nextthink = gpGlobals->time;
pGrenade->pev->velocity = Vector( 0, 0, 0 ); pGrenade->pev->velocity = Vector( 0, 0, 0 );
} }
pGrenade->pev->sequence = RANDOM_LONG( 3, 6 ); pGrenade->pev->sequence = RANDOM_LONG( 3, 6 );
pGrenade->pev->framerate = 1.0; pGrenade->pev->framerate = 1.0;
// Tumble through the air // Tumble through the air
// pGrenade->pev->avelocity.x = -400; // pGrenade->pev->avelocity.x = -400;
pGrenade->pev->gravity = 0.5; pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.8; pGrenade->pev->friction = 0.8;
SET_MODEL(ENT(pGrenade->pev), "models/w_grenade.mdl"); SET_MODEL(ENT(pGrenade->pev), "models/w_grenade.mdl");
pGrenade->pev->dmg = 100; pGrenade->pev->dmg = 100;
return pGrenade; return pGrenade;
} }
CMGrenade * CMGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ) CMGrenade * CMGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{ {
CMGrenade *pGrenade = CreateClassPtr( (CMGrenade *)NULL ); CMGrenade *pGrenade = CreateClassPtr( (CMGrenade *)NULL );
if (pGrenade == NULL) // no free monster edicts left? if (pGrenade == NULL) // no free monster edicts left?
return NULL; return NULL;
pGrenade->pev->movetype = MOVETYPE_BOUNCE; pGrenade->pev->movetype = MOVETYPE_BOUNCE;
pGrenade->pev->classname = MAKE_STRING( "grenade" ); pGrenade->pev->classname = MAKE_STRING( "grenade" );
pGrenade->pev->solid = SOLID_BBOX; pGrenade->pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pGrenade->pev), "models/grenade.mdl"); // Change this to satchel charge model SET_MODEL(ENT(pGrenade->pev), "models/grenade.mdl"); // Change this to satchel charge model
UTIL_SetSize(pGrenade->pev, Vector( 0, 0, 0), Vector(0, 0, 0)); UTIL_SetSize(pGrenade->pev, Vector( 0, 0, 0), Vector(0, 0, 0));
pGrenade->pev->dmg = 200; pGrenade->pev->dmg = 200;
UTIL_SetOrigin( pGrenade->pev, vecStart ); UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity; pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = g_vecZero; pGrenade->pev->angles = g_vecZero;
pGrenade->pev->owner = ENT(pevOwner); pGrenade->pev->owner = ENT(pevOwner);
// Detonate in "time" seconds // Detonate in "time" seconds
pGrenade->SetThink( &CMGrenade::SUB_DoNothing ); pGrenade->SetThink( &CMGrenade::SUB_DoNothing );
pGrenade->SetUse( &CMGrenade::DetonateUse ); pGrenade->SetUse( &CMGrenade::DetonateUse );
pGrenade->SetTouch( &CMGrenade::SlideTouch ); pGrenade->SetTouch( &CMGrenade::SlideTouch );
pGrenade->pev->spawnflags = SF_DETONATE; pGrenade->pev->spawnflags = SF_DETONATE;
pGrenade->pev->friction = 0.9; pGrenade->pev->friction = 0.9;
return pGrenade; return pGrenade;
} }
//======================end grenade //======================end grenade

File diff suppressed because it is too large Load Diff

View File

@@ -1,199 +1,199 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
h_ai.cpp - halflife specific ai code h_ai.cpp - halflife specific ai code
*/ */
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#define NUM_LATERAL_CHECKS 13 // how many checks are made on each side of a monster looking for lateral cover #define NUM_LATERAL_CHECKS 13 // how many checks are made on each side of a monster looking for lateral cover
#define NUM_LATERAL_LOS_CHECKS 6 // how many checks are made on each side of a monster looking for lateral cover #define NUM_LATERAL_LOS_CHECKS 6 // how many checks are made on each side of a monster looking for lateral cover
//float flRandom = RANDOM_FLOAT(0,1); //float flRandom = RANDOM_FLOAT(0,1);
DLL_GLOBAL BOOL g_fDrawLines = FALSE; DLL_GLOBAL BOOL g_fDrawLines = FALSE;
//========================================================= //=========================================================
// //
// AI UTILITY FUNCTIONS // AI UTILITY FUNCTIONS
// //
// !!!UNDONE - move CBaseMonster functions to monsters.cpp // !!!UNDONE - move CBaseMonster functions to monsters.cpp
//========================================================= //=========================================================
//========================================================= //=========================================================
// FBoxVisible - a more accurate ( and slower ) version // FBoxVisible - a more accurate ( and slower ) version
// of FVisible. // of FVisible.
// //
// !!!UNDONE - make this CBaseMonster? // !!!UNDONE - make this CBaseMonster?
//========================================================= //=========================================================
BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize ) BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize )
{ {
// don't look through water // don't look through water
if ((pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3) if ((pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3)
|| (pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0)) || (pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0))
return FALSE; return FALSE;
TraceResult tr; TraceResult tr;
Vector vecLookerOrigin = pevLooker->origin + pevLooker->view_ofs;//look through the monster's 'eyes' Vector vecLookerOrigin = pevLooker->origin + pevLooker->view_ofs;//look through the monster's 'eyes'
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
Vector vecTarget = pevTarget->origin; Vector vecTarget = pevTarget->origin;
vecTarget.x += RANDOM_FLOAT( pevTarget->mins.x + flSize, pevTarget->maxs.x - flSize); vecTarget.x += RANDOM_FLOAT( pevTarget->mins.x + flSize, pevTarget->maxs.x - flSize);
vecTarget.y += RANDOM_FLOAT( pevTarget->mins.y + flSize, pevTarget->maxs.y - flSize); vecTarget.y += RANDOM_FLOAT( pevTarget->mins.y + flSize, pevTarget->maxs.y - flSize);
vecTarget.z += RANDOM_FLOAT( pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize); vecTarget.z += RANDOM_FLOAT( pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize);
UTIL_TraceLine(vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT(pevLooker)/*pentIgnore*/, &tr); UTIL_TraceLine(vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT(pevLooker)/*pentIgnore*/, &tr);
if (tr.flFraction == 1.0) if (tr.flFraction == 1.0)
{ {
vecTargetOrigin = vecTarget; vecTargetOrigin = vecTarget;
return TRUE;// line of sight is valid. return TRUE;// line of sight is valid.
} }
} }
return FALSE;// Line of sight is not established return FALSE;// Line of sight is not established
} }
// //
// VecCheckToss - returns the velocity at which an object should be lobbed from vecspot1 to land near vecspot2. // VecCheckToss - returns the velocity at which an object should be lobbed from vecspot1 to land near vecspot2.
// returns g_vecZero if toss is not feasible. // returns g_vecZero if toss is not feasible.
// //
Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj ) Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj )
{ {
TraceResult tr; TraceResult tr;
Vector vecMidPoint;// halfway point between Spot1 and Spot2 Vector vecMidPoint;// halfway point between Spot1 and Spot2
Vector vecApex;// highest point Vector vecApex;// highest point
Vector vecScale; Vector vecScale;
Vector vecGrenadeVel; Vector vecGrenadeVel;
Vector vecTemp; Vector vecTemp;
float flGravity = g_psv_gravity->value * flGravityAdj; float flGravity = g_psv_gravity->value * flGravityAdj;
if (vecSpot2.z - vecSpot1.z > 500) if (vecSpot2.z - vecSpot1.z > 500)
{ {
// to high, fail // to high, fail
return g_vecZero; return g_vecZero;
} }
UTIL_MakeVectors (pev->angles); UTIL_MakeVectors (pev->angles);
// toss a little bit to the left or right, not right down on the enemy's bean (head). // toss a little bit to the left or right, not right down on the enemy's bean (head).
vecSpot2 = vecSpot2 + gpGlobals->v_right * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) ); vecSpot2 = vecSpot2 + gpGlobals->v_right * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) );
vecSpot2 = vecSpot2 + gpGlobals->v_forward * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) ); vecSpot2 = vecSpot2 + gpGlobals->v_forward * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) );
// calculate the midpoint and apex of the 'triangle' // calculate the midpoint and apex of the 'triangle'
// UNDONE: normalize any Z position differences between spot1 and spot2 so that triangle is always RIGHT // UNDONE: normalize any Z position differences between spot1 and spot2 so that triangle is always RIGHT
// How much time does it take to get there? // How much time does it take to get there?
// get a rough idea of how high it can be thrown // get a rough idea of how high it can be thrown
vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5;
UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0,0,500), ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0,0,500), ignore_monsters, ENT(pev), &tr);
vecMidPoint = tr.vecEndPos; vecMidPoint = tr.vecEndPos;
// (subtract 15 so the grenade doesn't hit the ceiling) // (subtract 15 so the grenade doesn't hit the ceiling)
vecMidPoint.z -= 15; vecMidPoint.z -= 15;
if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z) if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z)
{ {
// to not enough space, fail // to not enough space, fail
return g_vecZero; return g_vecZero;
} }
// How high should the grenade travel to reach the apex // How high should the grenade travel to reach the apex
float distance1 = (vecMidPoint.z - vecSpot1.z); float distance1 = (vecMidPoint.z - vecSpot1.z);
float distance2 = (vecMidPoint.z - vecSpot2.z); float distance2 = (vecMidPoint.z - vecSpot2.z);
// How long will it take for the grenade to travel this distance // How long will it take for the grenade to travel this distance
float time1 = sqrt( distance1 / (0.5 * flGravity) ); float time1 = sqrt( distance1 / (0.5 * flGravity) );
float time2 = sqrt( distance2 / (0.5 * flGravity) ); float time2 = sqrt( distance2 / (0.5 * flGravity) );
if (time1 < 0.1) if (time1 < 0.1)
{ {
// too close // too close
return g_vecZero; return g_vecZero;
} }
// how hard to throw sideways to get there in time. // how hard to throw sideways to get there in time.
vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2); vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2);
// how hard upwards to reach the apex at the right time. // how hard upwards to reach the apex at the right time.
vecGrenadeVel.z = flGravity * time1; vecGrenadeVel.z = flGravity * time1;
// find the apex // find the apex
vecApex = vecSpot1 + vecGrenadeVel * time1; vecApex = vecSpot1 + vecGrenadeVel * time1;
vecApex.z = vecMidPoint.z; vecApex.z = vecMidPoint.z;
UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr);
if (tr.flFraction != 1.0) if (tr.flFraction != 1.0)
{ {
// fail! // fail!
return g_vecZero; return g_vecZero;
} }
// UNDONE: either ignore monsters or change it to not care if we hit our enemy // UNDONE: either ignore monsters or change it to not care if we hit our enemy
UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr);
if (tr.flFraction != 1.0) if (tr.flFraction != 1.0)
{ {
// fail! // fail!
return g_vecZero; return g_vecZero;
} }
return vecGrenadeVel; return vecGrenadeVel;
} }
// //
// VecCheckThrow - returns the velocity vector at which an object should be thrown from vecspot1 to hit vecspot2. // VecCheckThrow - returns the velocity vector at which an object should be thrown from vecspot1 to hit vecspot2.
// returns g_vecZero if throw is not feasible. // returns g_vecZero if throw is not feasible.
// //
Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj ) Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj )
{ {
float flGravity = g_psv_gravity->value * flGravityAdj; float flGravity = g_psv_gravity->value * flGravityAdj;
Vector vecGrenadeVel = (vecSpot2 - vecSpot1); Vector vecGrenadeVel = (vecSpot2 - vecSpot1);
// throw at a constant time // throw at a constant time
float time = vecGrenadeVel.Length( ) / flSpeed; float time = vecGrenadeVel.Length( ) / flSpeed;
vecGrenadeVel = vecGrenadeVel * (1.0 / time); vecGrenadeVel = vecGrenadeVel * (1.0 / time);
// adjust upward toss to compensate for gravity loss // adjust upward toss to compensate for gravity loss
vecGrenadeVel.z += flGravity * time * 0.5; vecGrenadeVel.z += flGravity * time * 0.5;
Vector vecApex = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; Vector vecApex = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5;
vecApex.z += 0.5 * flGravity * (time * 0.5) * (time * 0.5); vecApex.z += 0.5 * flGravity * (time * 0.5) * (time * 0.5);
TraceResult tr; TraceResult tr;
UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr);
if (tr.flFraction != 1.0) if (tr.flFraction != 1.0)
{ {
// fail! // fail!
return g_vecZero; return g_vecZero;
} }
UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr);
if (tr.flFraction != 1.0) if (tr.flFraction != 1.0)
{ {
// fail! // fail!
return g_vecZero; return g_vecZero;
} }
return vecGrenadeVel; return vecGrenadeVel;
} }

View File

@@ -1,50 +1,50 @@
// //
// Monster Mod is a modification based on Botman's original "Monster" plugin. // Monster Mod is a modification based on Botman's original "Monster" plugin.
// The "forgotten" modification was made by Rick90. // The "forgotten" modification was made by Rick90.
// This is an attempt to recreate the plugin so it does not become lost again. // This is an attempt to recreate the plugin so it does not become lost again.
// //
// Recreated by Giegue. // Recreated by Giegue.
// //
// h_export.cpp // h_export.cpp
// //
/*** /***
* *
* Copyright (c) 1999, 2000 Valve LLC. All rights reserved. * Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
===== h_export.cpp ======================================================== ===== h_export.cpp ========================================================
Entity classes exported by Halflife. Entity classes exported by Halflife.
*/ */
#include "extdll.h" #include "extdll.h"
#include "h_export.h" #include "h_export.h"
// From SDK dlls/h_export.cpp: // From SDK dlls/h_export.cpp:
//! Holds engine functionality callbacks //! Holds engine functionality callbacks
enginefuncs_t g_engfuncs; enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals; globalvars_t *gpGlobals;
// Receive engine function table from engine. // Receive engine function table from engine.
// This appears to be the _first_ DLL routine called by the engine, so we // This appears to be the _first_ DLL routine called by the engine, so we
// do some setup operations here. // do some setup operations here.
void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{ {
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals; gpGlobals = pGlobals;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,384 +1,384 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
//========================================================= //=========================================================
// Hornets // Hornets
//========================================================= //=========================================================
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "weapons.h" #include "weapons.h"
#include "hornet.h" #include "hornet.h"
int iHornetTrail; int iHornetTrail;
int iHornetPuff; int iHornetPuff;
//========================================================= //=========================================================
// don't let hornets gib, ever. // don't let hornets gib, ever.
//========================================================= //=========================================================
int CMHornet :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) int CMHornet :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{ {
// filter these bits a little. // filter these bits a little.
bitsDamageType &= ~ ( DMG_ALWAYSGIB ); bitsDamageType &= ~ ( DMG_ALWAYSGIB );
bitsDamageType |= DMG_NEVERGIB; bitsDamageType |= DMG_NEVERGIB;
return CMBaseMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType ); return CMBaseMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType );
} }
//========================================================= //=========================================================
//========================================================= //=========================================================
void CMHornet :: Spawn( void ) void CMHornet :: Spawn( void )
{ {
Precache(); Precache();
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
pev->takedamage = DAMAGE_YES; pev->takedamage = DAMAGE_YES;
pev->flags |= FL_MONSTER; // I have a bad feeling about this pev->flags |= FL_MONSTER; // I have a bad feeling about this
pev->health = 1;// weak! pev->health = 1;// weak!
// hornets don't live as long in multiplayer // hornets don't live as long in multiplayer
m_flStopAttack = gpGlobals->time + 3.5; m_flStopAttack = gpGlobals->time + 3.5;
m_flFieldOfView = 0.9; // +- 25 degrees m_flFieldOfView = 0.9; // +- 25 degrees
if ( RANDOM_LONG ( 1, 5 ) <= 2 ) if ( RANDOM_LONG ( 1, 5 ) <= 2 )
{ {
m_iHornetType = HORNET_TYPE_RED; m_iHornetType = HORNET_TYPE_RED;
m_flFlySpeed = HORNET_RED_SPEED; m_flFlySpeed = HORNET_RED_SPEED;
} }
else else
{ {
m_iHornetType = HORNET_TYPE_ORANGE; m_iHornetType = HORNET_TYPE_ORANGE;
m_flFlySpeed = HORNET_ORANGE_SPEED; m_flFlySpeed = HORNET_ORANGE_SPEED;
} }
SET_MODEL(ENT( pev ), "models/hornet.mdl"); SET_MODEL(ENT( pev ), "models/hornet.mdl");
UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) ); UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) );
SetTouch( &CMHornet::DieTouch ); SetTouch( &CMHornet::DieTouch );
SetThink( &CMHornet::StartTrack ); SetThink( &CMHornet::StartTrack );
edict_t *pSoundEnt = pev->owner; edict_t *pSoundEnt = pev->owner;
if ( !pSoundEnt ) if ( !pSoundEnt )
pSoundEnt = edict(); pSoundEnt = edict();
// no real owner, or owner isn't a client. // no real owner, or owner isn't a client.
pev->dmg = gSkillData.monDmgHornet; pev->dmg = gSkillData.monDmgHornet;
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
ResetSequenceInfo( ); ResetSequenceInfo( );
pev->classname = MAKE_STRING( "hornet" ); pev->classname = MAKE_STRING( "hornet" );
} }
void CMHornet :: Precache() void CMHornet :: Precache()
{ {
PRECACHE_MODEL("models/hornet.mdl"); PRECACHE_MODEL("models/hornet.mdl");
PRECACHE_SOUND( "agrunt/ag_fire1.wav" ); PRECACHE_SOUND( "agrunt/ag_fire1.wav" );
PRECACHE_SOUND( "agrunt/ag_fire2.wav" ); PRECACHE_SOUND( "agrunt/ag_fire2.wav" );
PRECACHE_SOUND( "agrunt/ag_fire3.wav" ); PRECACHE_SOUND( "agrunt/ag_fire3.wav" );
PRECACHE_SOUND( "hornet/ag_buzz1.wav" ); PRECACHE_SOUND( "hornet/ag_buzz1.wav" );
PRECACHE_SOUND( "hornet/ag_buzz2.wav" ); PRECACHE_SOUND( "hornet/ag_buzz2.wav" );
PRECACHE_SOUND( "hornet/ag_buzz3.wav" ); PRECACHE_SOUND( "hornet/ag_buzz3.wav" );
PRECACHE_SOUND( "hornet/ag_hornethit1.wav" ); PRECACHE_SOUND( "hornet/ag_hornethit1.wav" );
PRECACHE_SOUND( "hornet/ag_hornethit2.wav" ); PRECACHE_SOUND( "hornet/ag_hornethit2.wav" );
PRECACHE_SOUND( "hornet/ag_hornethit3.wav" ); PRECACHE_SOUND( "hornet/ag_hornethit3.wav" );
iHornetPuff = PRECACHE_MODEL( "sprites/muz1.spr" ); iHornetPuff = PRECACHE_MODEL( "sprites/muz1.spr" );
iHornetTrail = PRECACHE_MODEL("sprites/laserbeam.spr"); iHornetTrail = PRECACHE_MODEL("sprites/laserbeam.spr");
} }
//========================================================= //=========================================================
// hornets will never get mad at each other, no matter who the owner is. // hornets will never get mad at each other, no matter who the owner is.
//========================================================= //=========================================================
int CMHornet::IRelationship ( CMBaseEntity *pTarget ) int CMHornet::IRelationship ( CMBaseEntity *pTarget )
{ {
if ( pTarget->pev->modelindex == pev->modelindex ) if ( pTarget->pev->modelindex == pev->modelindex )
{ {
return R_NO; return R_NO;
} }
return CMBaseMonster :: IRelationship( pTarget ); return CMBaseMonster :: IRelationship( pTarget );
} }
//========================================================= //=========================================================
// ID's Hornet as their owner // ID's Hornet as their owner
//========================================================= //=========================================================
int CMHornet::Classify ( void ) int CMHornet::Classify ( void )
{ {
/* /*
if ( pev->owner && pev->owner->v.flags & FL_CLIENT) if ( pev->owner && pev->owner->v.flags & FL_CLIENT)
{ {
return CLASS_PLAYER_BIOWEAPON; return CLASS_PLAYER_BIOWEAPON;
} }
return CLASS_ALIEN_BIOWEAPON; return CLASS_ALIEN_BIOWEAPON;
*/ */
// Ensure classify is consistent with the owner, in the event // Ensure classify is consistent with the owner, in the event
// it's classification was overriden. // it's classification was overriden.
if ( pev->owner == NULL ) if ( pev->owner == NULL )
return CLASS_ALIEN_BIOWEAPON; return CLASS_ALIEN_BIOWEAPON;
// Ain't this going to make the hornets code "slow"? // Ain't this going to make the hornets code "slow"?
CMBaseMonster *pOwner = GetClassPtr((CMBaseMonster *)VARS(pev->owner)); CMBaseMonster *pOwner = GetClassPtr((CMBaseMonster *)VARS(pev->owner));
return pOwner->Classify(); return pOwner->Classify();
} }
//========================================================= //=========================================================
// StartTrack - starts a hornet out tracking its target // StartTrack - starts a hornet out tracking its target
//========================================================= //=========================================================
void CMHornet :: StartTrack ( void ) void CMHornet :: StartTrack ( void )
{ {
IgniteTrail(); IgniteTrail();
SetTouch( &CMHornet::TrackTouch ); SetTouch( &CMHornet::TrackTouch );
SetThink( &CMHornet::TrackTarget ); SetThink( &CMHornet::TrackTarget );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
} }
//========================================================= //=========================================================
// StartDart - starts a hornet out just flying straight. // StartDart - starts a hornet out just flying straight.
//========================================================= //=========================================================
void CMHornet :: StartDart ( void ) void CMHornet :: StartDart ( void )
{ {
IgniteTrail(); IgniteTrail();
SetTouch( &CMHornet::DartTouch ); SetTouch( &CMHornet::DartTouch );
SetThink( &CMHornet::SUB_Remove ); SetThink( &CMHornet::SUB_Remove );
pev->nextthink = gpGlobals->time + 4; pev->nextthink = gpGlobals->time + 4;
} }
void CMHornet::IgniteTrail( void ) void CMHornet::IgniteTrail( void )
{ {
/* /*
ted's suggested trail colors: ted's suggested trail colors:
r161 r161
g25 g25
b97 b97
r173 r173
g39 g39
b14 b14
old colors old colors
case HORNET_TYPE_RED: case HORNET_TYPE_RED:
WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 128 ); // r, g, b WRITE_BYTE( 128 ); // r, g, b
WRITE_BYTE( 0 ); // r, g, b WRITE_BYTE( 0 ); // r, g, b
break; break;
case HORNET_TYPE_ORANGE: case HORNET_TYPE_ORANGE:
WRITE_BYTE( 0 ); // r, g, b WRITE_BYTE( 0 ); // r, g, b
WRITE_BYTE( 100 ); // r, g, b WRITE_BYTE( 100 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b
break; break;
*/ */
// trail // trail
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_BEAMFOLLOW ); WRITE_BYTE( TE_BEAMFOLLOW );
WRITE_SHORT( entindex() ); // entity WRITE_SHORT( entindex() ); // entity
WRITE_SHORT( iHornetTrail ); // model WRITE_SHORT( iHornetTrail ); // model
WRITE_BYTE( 10 ); // life WRITE_BYTE( 10 ); // life
WRITE_BYTE( 2 ); // width WRITE_BYTE( 2 ); // width
switch ( m_iHornetType ) switch ( m_iHornetType )
{ {
case HORNET_TYPE_RED: case HORNET_TYPE_RED:
WRITE_BYTE( 179 ); // r, g, b WRITE_BYTE( 179 ); // r, g, b
WRITE_BYTE( 39 ); // r, g, b WRITE_BYTE( 39 ); // r, g, b
WRITE_BYTE( 14 ); // r, g, b WRITE_BYTE( 14 ); // r, g, b
break; break;
case HORNET_TYPE_ORANGE: case HORNET_TYPE_ORANGE:
WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 128 ); // r, g, b WRITE_BYTE( 128 ); // r, g, b
WRITE_BYTE( 0 ); // r, g, b WRITE_BYTE( 0 ); // r, g, b
break; break;
} }
WRITE_BYTE( 128 ); // brightness WRITE_BYTE( 128 ); // brightness
MESSAGE_END(); MESSAGE_END();
} }
//========================================================= //=========================================================
// Hornet is flying, gently tracking target // Hornet is flying, gently tracking target
//========================================================= //=========================================================
void CMHornet :: TrackTarget ( void ) void CMHornet :: TrackTarget ( void )
{ {
Vector vecFlightDir; Vector vecFlightDir;
Vector vecDirToEnemy; Vector vecDirToEnemy;
float flDelta; float flDelta;
StudioFrameAdvance( ); StudioFrameAdvance( );
if (gpGlobals->time > m_flStopAttack) if (gpGlobals->time > m_flStopAttack)
{ {
SetTouch( NULL ); SetTouch( NULL );
SetThink( &CMHornet::SUB_Remove ); SetThink( &CMHornet::SUB_Remove );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
return; return;
} }
// UNDONE: The player pointer should come back after returning from another level // UNDONE: The player pointer should come back after returning from another level
if ( m_hEnemy == NULL ) if ( m_hEnemy == NULL )
{// enemy is dead. {// enemy is dead.
Look( 512 ); Look( 512 );
m_hEnemy = BestVisibleEnemy( ); m_hEnemy = BestVisibleEnemy( );
} }
if ( m_hEnemy != NULL && UTIL_FVisible( m_hEnemy, ENT(pev) )) if ( m_hEnemy != NULL && UTIL_FVisible( m_hEnemy, ENT(pev) ))
{ {
m_vecEnemyLKP = UTIL_BodyTarget( m_hEnemy, pev->origin ); m_vecEnemyLKP = UTIL_BodyTarget( m_hEnemy, pev->origin );
} }
else else
{ {
m_vecEnemyLKP = m_vecEnemyLKP + pev->velocity * m_flFlySpeed * 0.1; m_vecEnemyLKP = m_vecEnemyLKP + pev->velocity * m_flFlySpeed * 0.1;
} }
vecDirToEnemy = ( m_vecEnemyLKP - pev->origin ).Normalize(); vecDirToEnemy = ( m_vecEnemyLKP - pev->origin ).Normalize();
if (pev->velocity.Length() < 0.1) if (pev->velocity.Length() < 0.1)
vecFlightDir = vecDirToEnemy; vecFlightDir = vecDirToEnemy;
else else
vecFlightDir = pev->velocity.Normalize(); vecFlightDir = pev->velocity.Normalize();
// measure how far the turn is, the wider the turn, the slow we'll go this time. // measure how far the turn is, the wider the turn, the slow we'll go this time.
flDelta = DotProduct ( vecFlightDir, vecDirToEnemy ); flDelta = DotProduct ( vecFlightDir, vecDirToEnemy );
if ( flDelta < 0.5 ) if ( flDelta < 0.5 )
{// hafta turn wide again. play sound {// hafta turn wide again. play sound
switch (RANDOM_LONG(0,2)) switch (RANDOM_LONG(0,2))
{ {
case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break; case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
} }
} }
if ( flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED ) if ( flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED )
{// no flying backwards, but we don't want to invert this, cause we'd go fast when we have to turn REAL far. {// no flying backwards, but we don't want to invert this, cause we'd go fast when we have to turn REAL far.
flDelta = 0.25; flDelta = 0.25;
} }
pev->velocity = ( vecFlightDir + vecDirToEnemy).Normalize(); pev->velocity = ( vecFlightDir + vecDirToEnemy).Normalize();
if ( pev->owner && (pev->owner->v.flags & FL_MONSTER) ) if ( pev->owner && (pev->owner->v.flags & FL_MONSTER) )
{ {
// random pattern only applies to hornets fired by monsters, not players. // random pattern only applies to hornets fired by monsters, not players.
pev->velocity.x += RANDOM_FLOAT ( -0.10, 0.10 );// scramble the flight dir a bit. pev->velocity.x += RANDOM_FLOAT ( -0.10, 0.10 );// scramble the flight dir a bit.
pev->velocity.y += RANDOM_FLOAT ( -0.10, 0.10 ); pev->velocity.y += RANDOM_FLOAT ( -0.10, 0.10 );
pev->velocity.z += RANDOM_FLOAT ( -0.10, 0.10 ); pev->velocity.z += RANDOM_FLOAT ( -0.10, 0.10 );
} }
switch ( m_iHornetType ) switch ( m_iHornetType )
{ {
case HORNET_TYPE_RED: case HORNET_TYPE_RED:
pev->velocity = pev->velocity * ( m_flFlySpeed * flDelta );// scale the dir by the ( speed * width of turn ) pev->velocity = pev->velocity * ( m_flFlySpeed * flDelta );// scale the dir by the ( speed * width of turn )
pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.3 ); pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.3 );
break; break;
case HORNET_TYPE_ORANGE: case HORNET_TYPE_ORANGE:
pev->velocity = pev->velocity * m_flFlySpeed;// do not have to slow down to turn. pev->velocity = pev->velocity * m_flFlySpeed;// do not have to slow down to turn.
pev->nextthink = gpGlobals->time + 0.1;// fixed think time pev->nextthink = gpGlobals->time + 0.1;// fixed think time
break; break;
} }
pev->angles = UTIL_VecToAngles (pev->velocity); pev->angles = UTIL_VecToAngles (pev->velocity);
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
} }
//========================================================= //=========================================================
// Tracking Hornet hit something // Tracking Hornet hit something
//========================================================= //=========================================================
void CMHornet :: TrackTouch ( edict_t *pOther ) void CMHornet :: TrackTouch ( edict_t *pOther )
{ {
if ( (pOther == pev->owner) || pOther->v.modelindex == pev->modelindex ) if ( (pOther == pev->owner) || pOther->v.modelindex == pev->modelindex )
{// bumped into the guy that shot it. {// bumped into the guy that shot it.
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
return; return;
} }
// is this NOT a player and IS a monster? // is this NOT a player and IS a monster?
if (!UTIL_IsPlayer(pOther) && (pOther->v.euser4 != NULL)) if (!UTIL_IsPlayer(pOther) && (pOther->v.euser4 != NULL))
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
if ( IRelationship( pMonster ) <= R_NO ) if ( IRelationship( pMonster ) <= R_NO )
{ {
// hit something we don't want to hurt, so turn around. // hit something we don't want to hurt, so turn around.
pev->velocity = pev->velocity.Normalize(); pev->velocity = pev->velocity.Normalize();
pev->velocity.x *= -1; pev->velocity.x *= -1;
pev->velocity.y *= -1; pev->velocity.y *= -1;
pev->origin = pev->origin + pev->velocity * 4; // bounce the hornet off a bit. pev->origin = pev->origin + pev->velocity * 4; // bounce the hornet off a bit.
pev->velocity = pev->velocity * m_flFlySpeed; pev->velocity = pev->velocity * m_flFlySpeed;
return; return;
} }
} }
DieTouch( pOther ); DieTouch( pOther );
} }
void CMHornet::DartTouch( edict_t *pOther ) void CMHornet::DartTouch( edict_t *pOther )
{ {
DieTouch( pOther ); DieTouch( pOther );
} }
void CMHornet::DieTouch ( edict_t *pOther ) void CMHornet::DieTouch ( edict_t *pOther )
{ {
if ( pOther && pOther->v.takedamage ) if ( pOther && pOther->v.takedamage )
{// do the damage {// do the damage
switch (RANDOM_LONG(0,2)) switch (RANDOM_LONG(0,2))
{// buzz when you plug someone {// buzz when you plug someone
case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit1.wav", 1, ATTN_NORM); break; case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit1.wav", 1, ATTN_NORM); break;
case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit2.wav", 1, ATTN_NORM); break; case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit2.wav", 1, ATTN_NORM); break;
case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit3.wav", 1, ATTN_NORM); break; case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit3.wav", 1, ATTN_NORM); break;
} }
if (UTIL_IsPlayer(pOther)) if (UTIL_IsPlayer(pOther))
UTIL_TakeDamage( pOther, pev, VARS( pev->owner ), pev->dmg, DMG_BULLET ); UTIL_TakeDamage( pOther, pev, VARS( pev->owner ), pev->dmg, DMG_BULLET );
else if (pOther->v.euser4 != NULL) else if (pOther->v.euser4 != NULL)
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
pMonster->TakeDamage( pev, VARS( pev->owner ), pev->dmg, DMG_BULLET ); pMonster->TakeDamage( pev, VARS( pev->owner ), pev->dmg, DMG_BULLET );
} }
} }
pev->modelindex = 0;// so will disappear for the 0.1 secs we wait until NEXTTHINK gets rid pev->modelindex = 0;// so will disappear for the 0.1 secs we wait until NEXTTHINK gets rid
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
SetThink ( &CMHornet::SUB_Remove ); SetThink ( &CMHornet::SUB_Remove );
pev->nextthink = gpGlobals->time + 1;// stick around long enough for the sound to finish! pev->nextthink = gpGlobals->time + 1;// stick around long enough for the sound to finish!
} }

View File

@@ -1,55 +1,55 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
//========================================================= //=========================================================
// Hornets // Hornets
//========================================================= //=========================================================
//========================================================= //=========================================================
// Hornet Defines // Hornet Defines
//========================================================= //=========================================================
#define HORNET_TYPE_RED 0 #define HORNET_TYPE_RED 0
#define HORNET_TYPE_ORANGE 1 #define HORNET_TYPE_ORANGE 1
#define HORNET_RED_SPEED (float)600 #define HORNET_RED_SPEED (float)600
#define HORNET_ORANGE_SPEED (float)800 #define HORNET_ORANGE_SPEED (float)800
#define HORNET_BUZZ_VOLUME (float)0.8 #define HORNET_BUZZ_VOLUME (float)0.8
extern int iHornetPuff; extern int iHornetPuff;
//========================================================= //=========================================================
// Hornet - this is the projectile that the Alien Grunt fires. // Hornet - this is the projectile that the Alien Grunt fires.
//========================================================= //=========================================================
class CMHornet : public CMBaseMonster class CMHornet : public CMBaseMonster
{ {
public: public:
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
int Classify ( void ); int Classify ( void );
int IRelationship ( CMBaseEntity *pTarget ); int IRelationship ( CMBaseEntity *pTarget );
void IgniteTrail( void ); void IgniteTrail( void );
void EXPORT StartTrack ( void ); void EXPORT StartTrack ( void );
void EXPORT StartDart ( void ); void EXPORT StartDart ( void );
void EXPORT TrackTarget ( void ); void EXPORT TrackTarget ( void );
void EXPORT TrackTouch ( edict_t *pOther ); void EXPORT TrackTouch ( edict_t *pOther );
void EXPORT DartTouch( edict_t *pOther ); void EXPORT DartTouch( edict_t *pOther );
void EXPORT DieTouch ( edict_t *pOther ); void EXPORT DieTouch ( edict_t *pOther );
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
float m_flStopAttack; float m_flStopAttack;
int m_iHornetType; int m_iHornetType;
float m_flFlySpeed; float m_flFlySpeed;
}; };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,311 +1,311 @@
// HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository! // HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository!
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// Black Ops - Male Assassin // Black Ops - Male Assassin
//========================================================= //=========================================================
#include "extdll.h" #include "extdll.h"
#include "plane.h" #include "plane.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "schedule.h" #include "schedule.h"
#include "animation.h" #include "animation.h"
#include "weapons.h" #include "weapons.h"
#include "cmtalkmonster.h" #include "cmtalkmonster.h"
#include "effects.h" #include "effects.h"
#include "customentity.h" #include "customentity.h"
//========================================================= //=========================================================
// monster-specific DEFINE's // monster-specific DEFINE's
//========================================================= //=========================================================
#define MASSN_CLIP_SIZE 36 // how many bullets in a clip? - NOTE: 3 round burst sound, so keep as 3 * x! #define MASSN_CLIP_SIZE 36 // how many bullets in a clip? - NOTE: 3 round burst sound, so keep as 3 * x!
// Weapon flags // Weapon flags
#define MASSN_9MMAR (1 << 0) #define MASSN_9MMAR (1 << 0)
#define MASSN_HANDGRENADE (1 << 1) #define MASSN_HANDGRENADE (1 << 1)
#define MASSN_GRENADELAUNCHER (1 << 2) #define MASSN_GRENADELAUNCHER (1 << 2)
#define MASSN_SNIPERRIFLE (1 << 3) #define MASSN_SNIPERRIFLE (1 << 3)
// Body groups. // Body groups.
#define HEAD_GROUP 1 #define HEAD_GROUP 1
#define GUN_GROUP 2 #define GUN_GROUP 2
// Head values // Head values
#define HEAD_WHITE 0 #define HEAD_WHITE 0
#define HEAD_BLACK 1 #define HEAD_BLACK 1
#define HEAD_GOGGLES 2 #define HEAD_GOGGLES 2
// Gun values // Gun values
#define GUN_MP5 0 #define GUN_MP5 0
#define GUN_SNIPERRIFLE 1 #define GUN_SNIPERRIFLE 1
#define GUN_NONE 2 #define GUN_NONE 2
//========================================================= //=========================================================
// Monster's Anim Events Go Here // Monster's Anim Events Go Here
//========================================================= //=========================================================
#define MASSN_AE_KICK ( 3 ) #define MASSN_AE_KICK ( 3 )
#define MASSN_AE_BURST1 ( 4 ) #define MASSN_AE_BURST1 ( 4 )
#define MASSN_AE_CAUGHT_ENEMY ( 10 ) // grunt established sight with an enemy (player only) that had previously eluded the squad. #define MASSN_AE_CAUGHT_ENEMY ( 10 ) // grunt established sight with an enemy (player only) that had previously eluded the squad.
#define MASSN_AE_DROP_GUN ( 11 ) // grunt (probably dead) is dropping his mp5. #define MASSN_AE_DROP_GUN ( 11 ) // grunt (probably dead) is dropping his mp5.
//========================================================= //=========================================================
// Override a few behaviours to make this grunt silent // Override a few behaviours to make this grunt silent
//========================================================= //=========================================================
BOOL CMMassn::FOkToSpeak(void) BOOL CMMassn::FOkToSpeak(void)
{ {
return FALSE; return FALSE;
} }
void CMMassn::IdleSound(void) void CMMassn::IdleSound(void)
{ {
} }
void CMMassn::PainSound(void) void CMMassn::PainSound(void)
{ {
} }
void CMMassn::DeathSound(void) void CMMassn::DeathSound(void)
{ {
} }
//========================================================= //=========================================================
// Classify - indicates this monster's place in the // Classify - indicates this monster's place in the
// relationship table. // relationship table.
//========================================================= //=========================================================
int CMMassn::Classify(void) int CMMassn::Classify(void)
{ {
if ( m_iClassifyOverride == -1 ) // helper if ( m_iClassifyOverride == -1 ) // helper
return CLASS_NONE; return CLASS_NONE;
else if ( m_iClassifyOverride > 0 ) else if ( m_iClassifyOverride > 0 )
return m_iClassifyOverride; // override return m_iClassifyOverride; // override
return CLASS_HUMAN_MILITARY; return CLASS_HUMAN_MILITARY;
} }
//========================================================= //=========================================================
// Shoot // Shoot
//========================================================= //=========================================================
void CMMassn::Sniperrifle(void) void CMMassn::Sniperrifle(void)
{ {
if (m_hEnemy == 0) if (m_hEnemy == 0)
{ {
return; return;
} }
Vector vecShootOrigin = GetGunPosition(); Vector vecShootOrigin = GetGunPosition();
Vector vecShootDir = ShootAtEnemy(vecShootOrigin); Vector vecShootDir = ShootAtEnemy(vecShootOrigin);
UTIL_MakeVectors(pev->angles); UTIL_MakeVectors(pev->angles);
Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40, 90) + gpGlobals->v_up * RANDOM_FLOAT(75, 200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40); Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40, 90) + gpGlobals->v_up * RANDOM_FLOAT(75, 200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40);
EjectBrass(vecShootOrigin - vecShootDir * 24, vecShellVelocity, pev->angles.y, m_iBrassShell, TE_BOUNCE_SHELL); EjectBrass(vecShootOrigin - vecShootDir * 24, vecShellVelocity, pev->angles.y, m_iBrassShell, TE_BOUNCE_SHELL);
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_1DEGREES, 2048, BULLET_MONSTER_762, 0); // shoot +-7.5 degrees FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_1DEGREES, 2048, BULLET_MONSTER_762, 0); // shoot +-7.5 degrees
pev->effects |= EF_MUZZLEFLASH; pev->effects |= EF_MUZZLEFLASH;
// BUG - For some reason that still eludes me, grunts are completely unable to reload their weapons. // BUG - For some reason that still eludes me, grunts are completely unable to reload their weapons.
// As a temporary fix, give them infinite ammo. It will look bad I know... I gotta find a solution. -Giegue // As a temporary fix, give them infinite ammo. It will look bad I know... I gotta find a solution. -Giegue
//m_cAmmoLoaded--;// take away a bullet! //m_cAmmoLoaded--;// take away a bullet!
Vector angDir = UTIL_VecToAngles(vecShootDir); Vector angDir = UTIL_VecToAngles(vecShootDir);
SetBlending(0, angDir.x); SetBlending(0, angDir.x);
} }
//========================================================= //=========================================================
// HandleAnimEvent - catches the monster-specific messages // HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played. // that occur when tagged animation frames are played.
//========================================================= //=========================================================
void CMMassn::HandleAnimEvent(MonsterEvent_t *pEvent) void CMMassn::HandleAnimEvent(MonsterEvent_t *pEvent)
{ {
Vector vecShootDir; Vector vecShootDir;
Vector vecShootOrigin; Vector vecShootOrigin;
switch (pEvent->event) switch (pEvent->event)
{ {
case MASSN_AE_DROP_GUN: case MASSN_AE_DROP_GUN:
{ {
Vector vecGunPos; Vector vecGunPos;
Vector vecGunAngles; Vector vecGunAngles;
GetAttachment(0, vecGunPos, vecGunAngles); GetAttachment(0, vecGunPos, vecGunAngles);
// switch to body group with no gun. // switch to body group with no gun.
SetBodygroup(GUN_GROUP, GUN_NONE); SetBodygroup(GUN_GROUP, GUN_NONE);
} }
break; break;
case MASSN_AE_BURST1: case MASSN_AE_BURST1:
{ {
if (FBitSet(pev->weapons, MASSN_9MMAR)) if (FBitSet(pev->weapons, MASSN_9MMAR))
{ {
Shoot(); Shoot();
// the first round of the three round burst plays the sound and puts a sound in the world sound list. // the first round of the three round burst plays the sound and puts a sound in the world sound list.
if (RANDOM_LONG(0, 1)) if (RANDOM_LONG(0, 1))
{ {
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun1.wav", 1, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun1.wav", 1, ATTN_NORM);
} }
else else
{ {
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun2.wav", 1, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun2.wav", 1, ATTN_NORM);
} }
} }
else if (FBitSet(pev->weapons, MASSN_SNIPERRIFLE)) else if (FBitSet(pev->weapons, MASSN_SNIPERRIFLE))
{ {
Sniperrifle(); Sniperrifle();
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/sniper_fire.wav", 1, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/sniper_fire.wav", 1, ATTN_NORM);
} }
} }
break; break;
case MASSN_AE_KICK: case MASSN_AE_KICK:
{ {
edict_t *pHurt = Kick(); edict_t *pHurt = Kick();
if (pHurt) if (pHurt)
{ {
// SOUND HERE! // SOUND HERE!
UTIL_MakeVectors(pev->angles); UTIL_MakeVectors(pev->angles);
pHurt->v.punchangle.x = 15; pHurt->v.punchangle.x = 15;
pHurt->v.velocity = pHurt->v.velocity + gpGlobals->v_forward * 100 + gpGlobals->v_up * 50; pHurt->v.velocity = pHurt->v.velocity + gpGlobals->v_forward * 100 + gpGlobals->v_up * 50;
if (UTIL_IsPlayer(pHurt)) if (UTIL_IsPlayer(pHurt))
UTIL_TakeDamage( pHurt, pev, pev, gSkillData.massnDmgKick, DMG_CLUB ); UTIL_TakeDamage( pHurt, pev, pev, gSkillData.massnDmgKick, DMG_CLUB );
else if (pHurt->v.euser4 != NULL) else if (pHurt->v.euser4 != NULL)
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pHurt)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pHurt));
pMonster->TakeDamage( pev, pev, gSkillData.massnDmgKick, DMG_CLUB ); pMonster->TakeDamage( pev, pev, gSkillData.massnDmgKick, DMG_CLUB );
} }
} }
} }
break; break;
case MASSN_AE_CAUGHT_ENEMY: case MASSN_AE_CAUGHT_ENEMY:
break; break;
default: default:
CMHGrunt::HandleAnimEvent(pEvent); CMHGrunt::HandleAnimEvent(pEvent);
break; break;
} }
} }
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CMMassn::Spawn() void CMMassn::Spawn()
{ {
Precache(); Precache();
SET_MODEL(ENT(pev), "models/massn.mdl"); SET_MODEL(ENT(pev), "models/massn.mdl");
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_RED; m_bloodColor = BLOOD_COLOR_RED;
pev->effects = 0; pev->effects = 0;
pev->health = gSkillData.massnHealth; pev->health = gSkillData.massnHealth;
m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE; m_MonsterState = MONSTERSTATE_NONE;
m_flNextGrenadeCheck = gpGlobals->time + 1; m_flNextGrenadeCheck = gpGlobals->time + 1;
m_flNextPainTime = gpGlobals->time; m_flNextPainTime = gpGlobals->time;
m_iSentence = -1; m_iSentence = -1;
//m_afCapability = bits_CAP_SQUAD | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; //m_afCapability = bits_CAP_SQUAD | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP;
m_afCapability = bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; m_afCapability = bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP;
//m_fEnemyEluded = FALSE; //m_fEnemyEluded = FALSE;
m_fFirstEncounter = TRUE;// this is true when the grunt spawns, because he hasn't encountered an enemy yet. m_fFirstEncounter = TRUE;// this is true when the grunt spawns, because he hasn't encountered an enemy yet.
m_HackedGunPos = Vector(0, 0, 55); m_HackedGunPos = Vector(0, 0, 55);
if (pev->weapons == 0) if (pev->weapons == 0)
{ {
// weapons not specified, randomize // weapons not specified, randomize
switch ( RANDOM_LONG( 0, 2 ) ) switch ( RANDOM_LONG( 0, 2 ) )
{ {
case 0: case 0:
pev->weapons = MASSN_9MMAR | MASSN_HANDGRENADE; pev->weapons = MASSN_9MMAR | MASSN_HANDGRENADE;
break; break;
case 1: case 1:
pev->weapons = MASSN_9MMAR | MASSN_GRENADELAUNCHER; pev->weapons = MASSN_9MMAR | MASSN_GRENADELAUNCHER;
break; break;
case 2: case 2:
pev->weapons = MASSN_SNIPERRIFLE; pev->weapons = MASSN_SNIPERRIFLE;
break; break;
} }
} }
if (FBitSet(pev->weapons, MASSN_SNIPERRIFLE)) if (FBitSet(pev->weapons, MASSN_SNIPERRIFLE))
{ {
SetBodygroup(GUN_GROUP, GUN_SNIPERRIFLE); SetBodygroup(GUN_GROUP, GUN_SNIPERRIFLE);
m_cClipSize = 5; m_cClipSize = 5;
} }
else else
{ {
m_cClipSize = MASSN_CLIP_SIZE; m_cClipSize = MASSN_CLIP_SIZE;
} }
m_cAmmoLoaded = m_cClipSize; m_cAmmoLoaded = m_cClipSize;
if (RANDOM_LONG(0, 99) < 80) if (RANDOM_LONG(0, 99) < 80)
pev->skin = 0; // light skin pev->skin = 0; // light skin
else else
pev->skin = 1; // dark skin pev->skin = 1; // dark skin
CMTalkMonster::g_talkWaitTime = 0; CMTalkMonster::g_talkWaitTime = 0;
MonsterInit(); MonsterInit();
pev->classname = MAKE_STRING( "monster_male_assassin" ); pev->classname = MAKE_STRING( "monster_male_assassin" );
if ( strlen( STRING( m_szMonsterName ) ) == 0 ) if ( strlen( STRING( m_szMonsterName ) ) == 0 )
{ {
// default name // default name
m_szMonsterName = MAKE_STRING( "Male Assassin" ); m_szMonsterName = MAKE_STRING( "Male Assassin" );
} }
} }
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CMMassn::Precache() void CMMassn::Precache()
{ {
PRECACHE_MODEL("models/massn.mdl"); PRECACHE_MODEL("models/massn.mdl");
PRECACHE_SOUND("hgrunt/gr_mgun1.wav"); PRECACHE_SOUND("hgrunt/gr_mgun1.wav");
PRECACHE_SOUND("hgrunt/gr_mgun2.wav"); PRECACHE_SOUND("hgrunt/gr_mgun2.wav");
PRECACHE_SOUND("hgrunt/gr_reload1.wav"); PRECACHE_SOUND("hgrunt/gr_reload1.wav");
PRECACHE_SOUND("weapons/glauncher.wav"); PRECACHE_SOUND("weapons/glauncher.wav");
PRECACHE_SOUND("weapons/sniper_bolt1.wav"); PRECACHE_SOUND("weapons/sniper_bolt1.wav");
PRECACHE_SOUND("weapons/sniper_fire.wav"); PRECACHE_SOUND("weapons/sniper_fire.wav");
PRECACHE_SOUND("zombie/claw_miss2.wav");// because we use the basemonster SWIPE animation event PRECACHE_SOUND("zombie/claw_miss2.wav");// because we use the basemonster SWIPE animation event
// get voice pitch // get voice pitch
if (RANDOM_LONG(0, 1)) if (RANDOM_LONG(0, 1))
m_voicePitch = 109 + RANDOM_LONG(0, 7); m_voicePitch = 109 + RANDOM_LONG(0, 7);
else else
m_voicePitch = 100; m_voicePitch = 100;
m_iBrassShell = PRECACHE_MODEL("models/shell.mdl");// brass shell m_iBrassShell = PRECACHE_MODEL("models/shell.mdl");// brass shell
} }

View File

@@ -1,163 +1,163 @@
// //
// Monster Mod is a modification based on Botman's original "Monster" plugin. // Monster Mod is a modification based on Botman's original "Monster" plugin.
// The "forgotten" modification was made by Rick90. // The "forgotten" modification was made by Rick90.
// This is an attempt to recreate the plugin so it does not become lost again. // This is an attempt to recreate the plugin so it does not become lost again.
// //
// Recreated by Giegue. // Recreated by Giegue.
// //
// monster_api.cpp // monster_api.cpp
// //
/* /*
* This is free software; you can redistribute it and/or modify it * This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* This is distributed in the hope that it will be useful, but * This is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this code; if not, write to the Free Software Foundation, * along with this code; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL * link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
* *
*/ */
#include "extdll.h" #include "extdll.h"
#include "meta_api.h" #include "meta_api.h"
#include "sdk_util.h" // UTIL_LogPrintf, etc #include "sdk_util.h" // UTIL_LogPrintf, etc
// Must provide at least one of these.. // Must provide at least one of these..
static META_FUNCTIONS gMetaFunctionTable = static META_FUNCTIONS gMetaFunctionTable =
{ {
NULL, // pfnGetEntityAPI HL SDK; called before game DLL NULL, // pfnGetEntityAPI HL SDK; called before game DLL
NULL, // pfnGetEntityAPI_Post META; called after game DLL NULL, // pfnGetEntityAPI_Post META; called after game DLL
GetEntityAPI2, // pfnGetEntityAPI2 HL SDK2; called before game DLL GetEntityAPI2, // pfnGetEntityAPI2 HL SDK2; called before game DLL
GetEntityAPI2_Post, // pfnGetEntityAPI2_Post META; called after game DLL GetEntityAPI2_Post, // pfnGetEntityAPI2_Post META; called after game DLL
NULL, // pfnGetNewDLLFunctions HL SDK2; called before game DLL NULL, // pfnGetNewDLLFunctions HL SDK2; called before game DLL
NULL, // pfnGetNewDLLFunctions_Post META; called after game DLL NULL, // pfnGetNewDLLFunctions_Post META; called after game DLL
GetEngineFunctions, // pfnGetEngineFunctions META; called before HL engine GetEngineFunctions, // pfnGetEngineFunctions META; called before HL engine
GetEngineFunctions_Post, // pfnGetEngineFunctions_Post META; called after HL engine GetEngineFunctions_Post, // pfnGetEngineFunctions_Post META; called after HL engine
}; };
// Description of plugin // Description of plugin
plugin_info_t Plugin_info = { plugin_info_t Plugin_info = {
META_INTERFACE_VERSION, // interface version META_INTERFACE_VERSION, // interface version
"MonsterMod", // name "MonsterMod", // name
"2.0", // version "2.0", // version
"03/06/2020", // date in DD/MM/YYYY format "03/06/2020", // date in DD/MM/YYYY format
"botman, Rick90, Giegue", // original authors + recreation by... "botman, Rick90, Giegue", // original authors + recreation by...
"https://github.com/JulianR0/monstermod-redo", // url "https://github.com/JulianR0/monstermod-redo", // url
"MONSTER", // logtag "MONSTER", // logtag
PT_CHANGELEVEL, // (when) loadable PT_CHANGELEVEL, // (when) loadable
PT_CHANGELEVEL, // (when) unloadable PT_CHANGELEVEL, // (when) unloadable
}; };
char *VNAME=Plugin_info.name; char *VNAME=Plugin_info.name;
char *VVERSION=Plugin_info.version; char *VVERSION=Plugin_info.version;
char *VDATE=Plugin_info.date; char *VDATE=Plugin_info.date;
char *VAUTHOR=Plugin_info.author; char *VAUTHOR=Plugin_info.author;
char *VURL=Plugin_info.url; char *VURL=Plugin_info.url;
char *VLOGTAG=Plugin_info.logtag; char *VLOGTAG=Plugin_info.logtag;
char *COMPILE_TIME=__DATE__ ", " __TIME__; char *COMPILE_TIME=__DATE__ ", " __TIME__;
// Global vars from metamod: // Global vars from metamod:
meta_globals_t *gpMetaGlobals; // metamod globals meta_globals_t *gpMetaGlobals; // metamod globals
gamedll_funcs_t *gpGamedllFuncs; // gameDLL function tables gamedll_funcs_t *gpGamedllFuncs; // gameDLL function tables
mutil_funcs_t *gpMetaUtilFuncs; // metamod utility functions mutil_funcs_t *gpMetaUtilFuncs; // metamod utility functions
// CVars // CVars
cvar_t init_dllapi_log = {"monster_log", "0", FCVAR_EXTDLL, 0, NULL}; cvar_t init_dllapi_log = {"monster_log", "0", FCVAR_EXTDLL, 0, NULL};
cvar_t *dllapi_log = NULL; cvar_t *dllapi_log = NULL;
cvar_t init_monster_spawn = {"monster_spawn", "1", FCVAR_EXTDLL, 0, NULL}; cvar_t init_monster_spawn = {"monster_spawn", "1", FCVAR_EXTDLL, 0, NULL};
cvar_t *monster_spawn = NULL; cvar_t *monster_spawn = NULL;
cvar_t init_monster_show_deaths = {"monster_show_deaths", "1", FCVAR_EXTDLL, 0, NULL}; cvar_t init_monster_show_deaths = {"monster_show_deaths", "1", FCVAR_EXTDLL, 0, NULL};
cvar_t *monster_show_deaths = NULL; cvar_t *monster_show_deaths = NULL;
cvar_t init_monster_show_info = {"monster_show_info", "1", FCVAR_EXTDLL, 0, NULL}; cvar_t init_monster_show_info = {"monster_show_info", "1", FCVAR_EXTDLL, 0, NULL};
cvar_t *monster_show_info = NULL; cvar_t *monster_show_info = NULL;
// Metamod requesting info about this plugin: // Metamod requesting info about this plugin:
// ifvers (given) interface_version metamod is using // ifvers (given) interface_version metamod is using
// pPlugInfo (requested) struct with info about plugin // pPlugInfo (requested) struct with info about plugin
// pMetaUtilFuncs (given) table of utility functions provided by metamod // pMetaUtilFuncs (given) table of utility functions provided by metamod
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo,
mutil_funcs_t *pMetaUtilFuncs) mutil_funcs_t *pMetaUtilFuncs)
{ {
if(ifvers); // to satisfy gcc -Wunused if(ifvers); // to satisfy gcc -Wunused
// Give metamod our plugin_info struct // Give metamod our plugin_info struct
*pPlugInfo=&Plugin_info; *pPlugInfo=&Plugin_info;
// Get metamod utility function table. // Get metamod utility function table.
gpMetaUtilFuncs=pMetaUtilFuncs; gpMetaUtilFuncs=pMetaUtilFuncs;
return(TRUE); return(TRUE);
} }
// Metamod attaching plugin to the server. // Metamod attaching plugin to the server.
// now (given) current phase, ie during map, during changelevel, or at startup // now (given) current phase, ie during map, during changelevel, or at startup
// pFunctionTable (requested) table of function tables this plugin catches // pFunctionTable (requested) table of function tables this plugin catches
// pMGlobals (given) global vars from metamod // pMGlobals (given) global vars from metamod
// pGamedllFuncs (given) copy of function tables from game dll // pGamedllFuncs (given) copy of function tables from game dll
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs) C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{ {
if(now); // to satisfy gcc -Wunused if(now); // to satisfy gcc -Wunused
if(!pMGlobals) if(!pMGlobals)
{ {
LOG_ERROR(PLID, "Meta_Attach called with null pMGlobals"); LOG_ERROR(PLID, "Meta_Attach called with null pMGlobals");
return(FALSE); return(FALSE);
} }
gpMetaGlobals=pMGlobals; gpMetaGlobals=pMGlobals;
if(!pFunctionTable) if(!pFunctionTable)
{ {
LOG_ERROR(PLID, "Meta_Attach called with null pFunctionTable"); LOG_ERROR(PLID, "Meta_Attach called with null pFunctionTable");
return(FALSE); return(FALSE);
} }
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS)); memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
gpGamedllFuncs=pGamedllFuncs; gpGamedllFuncs=pGamedllFuncs;
LOG_MESSAGE(PLID, "%s %s, %s", VNAME, VVERSION, VDATE); LOG_MESSAGE(PLID, "%s %s, %s", VNAME, VVERSION, VDATE);
LOG_MESSAGE(PLID, "by %s", VAUTHOR); LOG_MESSAGE(PLID, "by %s", VAUTHOR);
LOG_MESSAGE(PLID, "%s", VURL); LOG_MESSAGE(PLID, "%s", VURL);
LOG_MESSAGE(PLID, "compiled: %s CDT", COMPILE_TIME); LOG_MESSAGE(PLID, "compiled: %s CDT", COMPILE_TIME);
LOG_CONSOLE(PLID, "[%s] %s v%s, %s", VLOGTAG, VNAME, VVERSION, VDATE); LOG_CONSOLE(PLID, "[%s] %s v%s, %s", VLOGTAG, VNAME, VVERSION, VDATE);
LOG_CONSOLE(PLID, "[%s] by %s", VLOGTAG, VAUTHOR); LOG_CONSOLE(PLID, "[%s] by %s", VLOGTAG, VAUTHOR);
CVAR_REGISTER(&init_dllapi_log); CVAR_REGISTER(&init_dllapi_log);
dllapi_log = CVAR_GET_POINTER("monster_log"); dllapi_log = CVAR_GET_POINTER("monster_log");
CVAR_REGISTER(&init_monster_spawn); CVAR_REGISTER(&init_monster_spawn);
monster_spawn = CVAR_GET_POINTER("monster_spawn"); monster_spawn = CVAR_GET_POINTER("monster_spawn");
CVAR_REGISTER(&init_monster_show_deaths); CVAR_REGISTER(&init_monster_show_deaths);
monster_show_deaths = CVAR_GET_POINTER("monster_show_deaths"); monster_show_deaths = CVAR_GET_POINTER("monster_show_deaths");
CVAR_REGISTER(&init_monster_show_info); CVAR_REGISTER(&init_monster_show_info);
monster_show_info = CVAR_GET_POINTER("monster_show_info"); monster_show_info = CVAR_GET_POINTER("monster_show_info");
return(TRUE); return(TRUE);
} }
extern void monster_unload(void); extern void monster_unload(void);
// Metamod detaching plugin from the server. // Metamod detaching plugin from the server.
// now (given) current phase, ie during map, etc // now (given) current phase, ie during map, etc
// reason (given) why detaching (refresh, console unload, forced unload, etc) // reason (given) why detaching (refresh, console unload, forced unload, etc)
C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) { C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) {
// remove all the monsters currently in the level... // remove all the monsters currently in the level...
monster_unload(); monster_unload();
return(TRUE); return(TRUE);
} }

View File

@@ -1,433 +1,431 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#ifndef __linux__ #ifndef __linux__
#include <io.h> #include <io.h>
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "extdll.h" #include "extdll.h"
#include "dllapi.h" #include "dllapi.h"
#include "meta_api.h" #include "meta_api.h"
#include "monster_plugin.h" #include "monster_plugin.h"
extern cvar_t *dllapi_log; extern cvar_t *dllapi_log;
extern monster_type_t monster_types[]; extern monster_type_t monster_types[];
extern int monster_spawn_count; extern int monster_spawn_count;
extern int node_spawn_count; extern int node_spawn_count;
bool get_input(FILE *fp, char *input) bool get_input(FILE *fp, char *input)
{ {
char line[1024]; char line[1024];
int len, pos; int len, pos;
while (!feof(fp)) while (!feof(fp))
{ {
if (fgets(line, 1023, fp) != NULL) if (fgets(line, 1023, fp) != NULL)
{ {
len = strlen(line); len = strlen(line);
if (len == 0) if (len == 0)
continue; // skip any null lines continue; // skip any null lines
// remove any trailing newline, carriage return or whitespace... // remove any trailing newline, carriage return or whitespace...
while ((line[len-1] == '\n') || (line[len-1] == '\r') || isspace(line[len-1])) while ((line[len-1] == '\n') || (line[len-1] == '\r') || isspace(line[len-1]))
{ {
line[len-1] = 0; line[len-1] = 0;
len--; len--;
if (len == 0) if (len == 0)
break; break;
} }
pos = 0; pos = 0;
while (isspace(line[pos])) while (isspace(line[pos]))
pos++; // skip leading blanks pos++; // skip leading blanks
if ((line[pos] == '/') && (line[pos+1] == '/')) if ((line[pos] == '/') && (line[pos+1] == '/'))
continue; // skip comment lines continue; // skip comment lines
if (line[pos] == 0) if (line[pos] == 0)
continue; // skip empty lines continue; // skip empty lines
strcpy(input, &line[pos]); strcpy(input, &line[pos]);
return TRUE; return TRUE;
} }
} }
return FALSE; // no input found return FALSE; // no input found
} }
void scan_monster_cfg(FILE *fp) void scan_monster_cfg(FILE *fp)
{ {
// Let's make a full rework of this. -Giegue // Let's make a full rework of this. -Giegue
char input[1024]; char input[1024];
float x, y, z; float x, y, z;
bool badent, monster, node; bool badent, monster, node;
while (get_input(fp, input)) while (get_input(fp, input))
{ {
badent = monster = node = FALSE; badent = monster = node = FALSE;
if (input[0] == '{') if (input[0] == '{')
{ {
// Proper start, initialize entity creation // Proper start, initialize entity creation
// Temporary variables to store entity data // Temporary variables to store entity data
pKVD *data = (pKVD*)malloc(MAX_KEYVALUES*sizeof(*data)); // Entities should not have more than this many keyvalues pKVD *data = (pKVD*)malloc(MAX_KEYVALUES*sizeof(*data)); // Entities should not have more than this many keyvalues
int kvd_index = 0; int kvd_index = 0;
while (get_input(fp, input)) while (get_input(fp, input))
{ {
// It's the end of the entity structure? // It's the end of the entity structure?
if (input[0] == '}') if (input[0] == '}')
{ {
// Check if the classname of whatever we want to spawn is valid. // Check if the classname of whatever we want to spawn is valid.
if (strcmp(data[kvd_index-1].key, "classname") == 0) if (strcmp(data[kvd_index-1].key, "classname") == 0)
{ {
int mIndex; int mIndex;
for (mIndex = 0; monster_types[mIndex].name[0]; mIndex++) for (mIndex = 0; monster_types[mIndex].name[0]; mIndex++)
{ {
if (strcmp(data[kvd_index-1].value, monster_types[mIndex].name) == 0) if (strcmp(data[kvd_index-1].value, monster_types[mIndex].name) == 0)
{ {
// Now that I think about it this looks slow and bad code >.> // Now that I think about it this looks slow and bad code >.>
// A match is found. What is this? // A match is found. What is this?
if (strncmp(monster_types[mIndex].name, "monster", 7) == 0) if (strncmp(monster_types[mIndex].name, "monster", 7) == 0)
{ {
// It's a monster, add it to the list // It's a monster, add it to the list
if (monster_spawn_count == MAX_MONSTERS) if (monster_spawn_count == MAX_MONSTERS)
{ {
// Ouch! Not enough room. // Ouch! Not enough room.
LOG_MESSAGE(PLID, "ERROR: can't add monster, reached MAX_MONSTERS!"); // It will get spammy, sadly. LOG_MESSAGE(PLID, "ERROR: can't add monster, reached MAX_MONSTERS!"); // It will get spammy, sadly.
badent = TRUE; badent = TRUE;
} }
else else
{ {
monster_spawnpoint[monster_spawn_count].monster = mIndex; monster_spawnpoint[monster_spawn_count].monster = mIndex;
monster_types[mIndex].need_to_precache = TRUE; monster_types[mIndex].need_to_precache = TRUE;
monster = TRUE; monster = TRUE;
} }
} }
else if (strcmp(monster_types[mIndex].name, "info_node") == 0) else if (strcmp(monster_types[mIndex].name, "info_node") == 0)
{ {
// Normal node // Normal node
if (node_spawn_count == MAX_NODES) if (node_spawn_count == MAX_NODES)
{ {
// The map can't be THAT big can it? // The map can't be THAT big can it?
LOG_MESSAGE(PLID, "ERROR: can't add node, reached MAX_NODES!"); // zee spam bOi LOG_MESSAGE(PLID, "ERROR: can't add node, reached MAX_NODES!"); // zee spam bOi
badent = TRUE; badent = TRUE;
} }
else else
node = TRUE; node = TRUE;
} }
else if (strcmp(monster_types[mIndex].name, "info_node_air") == 0) else if (strcmp(monster_types[mIndex].name, "info_node_air") == 0)
{ {
// Aerial node // Aerial node
if (node_spawn_count == MAX_NODES) if (node_spawn_count == MAX_NODES)
{ {
// Ctrl+C --> Ctrl+V // Ctrl+C --> Ctrl+V
LOG_MESSAGE(PLID, "ERROR: can't add node, reached MAX_NODES!"); // poppo was here. LOG_MESSAGE(PLID, "ERROR: can't add node, reached MAX_NODES!"); // poppo was here.
badent = TRUE; badent = TRUE;
} }
else else
{ {
node_spawnpoint[node_spawn_count].is_air_node = TRUE; node_spawnpoint[node_spawn_count].is_air_node = TRUE;
node = TRUE; node = TRUE;
} }
} }
break; break;
} }
} }
if (monster_types[mIndex].name[0] == 0) if (monster_types[mIndex].name[0] == 0)
{ {
LOG_MESSAGE(PLID, "ERROR: unknown classname: %s", input); // print conflictive line LOG_MESSAGE(PLID, "ERROR: unknown classname: %s", input); // print conflictive line
LOG_MESSAGE(PLID, "ERROR: nothing will spawn here!"); LOG_MESSAGE(PLID, "ERROR: nothing will spawn here!");
badent = TRUE; badent = TRUE;
} }
} }
else else
{ {
// What are you doing?! // What are you doing?!
LOG_MESSAGE(PLID, "ERROR: BAD ENTITY STRUCTURE! Last line was %s", input); // print conflictive line LOG_MESSAGE(PLID, "ERROR: BAD ENTITY STRUCTURE! Last line was %s", input); // print conflictive line
LOG_MESSAGE(PLID, "ERROR: nothing will spawn here!"); LOG_MESSAGE(PLID, "ERROR: nothing will spawn here!");
badent = TRUE; badent = TRUE;
} }
if (!badent) if (!badent)
{ {
// Make room for entity-specific keyvalues. // Make room for entity-specific keyvalues.
if (monster) if (monster)
{ {
// The line is a little too long, no? // The line is a little too long, no?
monster_spawnpoint[monster_spawn_count].keyvalue = (pKVD*)calloc(MAX_KEYVALUES, sizeof(*monster_spawnpoint[monster_spawn_count].keyvalue)); monster_spawnpoint[monster_spawn_count].keyvalue = (pKVD*)calloc(MAX_KEYVALUES, sizeof(*monster_spawnpoint[monster_spawn_count].keyvalue));
} }
// Done. Let's process the keyvalues. // Done. Let's process the keyvalues.
for (int i = 0; i < (kvd_index-1); i++) for (int i = 0; i < (kvd_index-1); i++)
{ {
// Any duplicate keyvalue is overwritten. // Any duplicate keyvalue is overwritten.
if (strcmp(data[i].key, "origin") == 0) if (strcmp(data[i].key, "origin") == 0)
{ {
if (sscanf(data[i].value, "%f %f %f", &x, &y, &z) != 3) if (sscanf(data[i].value, "%f %f %f", &x, &y, &z) != 3)
{ {
LOG_MESSAGE(PLID, "ERROR: invalid origin: %s", input); // print conflictive line LOG_MESSAGE(PLID, "ERROR: invalid origin: %s", input); // print conflictive line
// reset origin to g_vecZero // reset origin to g_vecZero
LOG_MESSAGE(PLID, "ERROR: entity will spawn at 0 0 0"); LOG_MESSAGE(PLID, "ERROR: entity will spawn at 0 0 0");
x = y = z = 0; x = y = z = 0;
} }
if (monster) if (monster)
{ {
monster_spawnpoint[monster_spawn_count].origin[0] = x; monster_spawnpoint[monster_spawn_count].origin[0] = x;
monster_spawnpoint[monster_spawn_count].origin[1] = y; monster_spawnpoint[monster_spawn_count].origin[1] = y;
monster_spawnpoint[monster_spawn_count].origin[2] = z; monster_spawnpoint[monster_spawn_count].origin[2] = z;
} }
else if (node) else if (node)
{ {
node_spawnpoint[node_spawn_count].origin[0] = x; node_spawnpoint[node_spawn_count].origin[0] = x;
node_spawnpoint[node_spawn_count].origin[1] = y; node_spawnpoint[node_spawn_count].origin[1] = y;
node_spawnpoint[node_spawn_count].origin[2] = z; node_spawnpoint[node_spawn_count].origin[2] = z;
} }
} }
else if (strcmp(data[i].key, "delay") == 0) else if (strcmp(data[i].key, "delay") == 0)
{ {
// ToDo: Remove this keyvalue. // ToDo: Remove this keyvalue.
// Monsters spawned directly should not respawn. // Monsters spawned directly should not respawn.
if (monster) if (monster)
{ {
if (sscanf(data[i].value, "%f", &x) != 1) if (sscanf(data[i].value, "%f", &x) != 1)
{ {
LOG_MESSAGE(PLID, "ERROR: invalid delay: %s", input); // print conflictive line LOG_MESSAGE(PLID, "ERROR: invalid delay: %s", input); // print conflictive line
// default to 30 seconds // default to 30 seconds
LOG_MESSAGE(PLID, "ERROR: entity respawn frequency will be set to 30 seconds"); LOG_MESSAGE(PLID, "ERROR: entity respawn frequency will be set to 30 seconds");
x = 30; x = 30;
} }
monster_spawnpoint[monster_spawn_count].delay = x; monster_spawnpoint[monster_spawn_count].delay = x;
} }
} }
else if (strcmp(data[i].key, "angles") == 0) else if (strcmp(data[i].key, "angles") == 0)
{ {
if (monster) if (monster)
{ {
if (sscanf(data[i].value, "%f %f %f", &x, &y, &z) != 3) if (sscanf(data[i].value, "%f %f %f", &x, &y, &z) != 3)
{ {
LOG_MESSAGE(PLID, "ERROR: invalid angles: %s", input); // print conflictive line LOG_MESSAGE(PLID, "ERROR: invalid angles: %s", input); // print conflictive line
// reset angles to g_vecZero // reset angles to g_vecZero
LOG_MESSAGE(PLID, "ERROR: entity angles will be set to 0 0 0"); LOG_MESSAGE(PLID, "ERROR: entity angles will be set to 0 0 0");
x = y = z = 0; x = y = z = 0;
} }
monster_spawnpoint[monster_spawn_count].angles[0] = x; monster_spawnpoint[monster_spawn_count].angles[0] = x;
monster_spawnpoint[monster_spawn_count].angles[1] = y; monster_spawnpoint[monster_spawn_count].angles[1] = y;
monster_spawnpoint[monster_spawn_count].angles[2] = z; monster_spawnpoint[monster_spawn_count].angles[2] = z;
} }
} }
else if (strcmp(data[i].key, "spawnflags") == 0) else if (strcmp(data[i].key, "spawnflags") == 0)
{ {
if (monster) if (monster)
{ {
if (sscanf(data[i].value, "%f", &x) != 1) if (sscanf(data[i].value, "%f", &x) != 1)
{ {
LOG_MESSAGE(PLID, "ERROR: invalid spawnflags: %s", input); // print conflictive line LOG_MESSAGE(PLID, "ERROR: invalid spawnflags: %s", input); // print conflictive line
// default to no spawnflags // default to no spawnflags
LOG_MESSAGE(PLID, "ERROR: entity spawnflags will be set to none (0)"); LOG_MESSAGE(PLID, "ERROR: entity spawnflags will be set to none (0)");
x = 0; x = 0;
} }
monster_spawnpoint[monster_spawn_count].spawnflags = x; monster_spawnpoint[monster_spawn_count].spawnflags = x;
} }
} }
else else
{ {
// We do not know this keyvalue, but an specific entity might use it. // We do not know this keyvalue, but an specific entity might use it.
// Save it for later // Save it for later
if (monster) if (monster)
{ {
strcpy(monster_spawnpoint[monster_spawn_count].keyvalue[i].key, data[i].key); strcpy(monster_spawnpoint[monster_spawn_count].keyvalue[i].key, data[i].key);
strcpy(monster_spawnpoint[monster_spawn_count].keyvalue[i].value, data[i].value); strcpy(monster_spawnpoint[monster_spawn_count].keyvalue[i].value, data[i].value);
} }
} }
} }
if (monster) if (monster)
{ {
// Init monster // Init monster
monster_spawnpoint[monster_spawn_count].respawn_time = gpGlobals->time + 0.1; // spawn (nearly) right away monster_spawnpoint[monster_spawn_count].respawn_time = gpGlobals->time + 0.1; // spawn (nearly) right away
monster_spawnpoint[monster_spawn_count].need_to_respawn = TRUE; monster_spawnpoint[monster_spawn_count].need_to_respawn = TRUE;
monster_spawn_count++; monster_spawn_count++;
} }
else if (node) else if (node)
{ {
// Increase node count // Increase node count
node_spawn_count++; node_spawn_count++;
} }
// Log on? Print all the entities that were added // Log on? Print all the entities that were added
if (dllapi_log->value) if (dllapi_log->value)
{ {
// Classname only, or we will flood the server! // Classname only, or we will flood the server!
// No, I'm not making this idiotproof. Classname should be the last KVD entry on an entity! // No, I'm not making this idiotproof. Classname should be the last KVD entry on an entity!
LOG_CONSOLE(PLID, "[DEBUG] Added entity: %s", data[kvd_index-1].value); LOG_CONSOLE(PLID, "[DEBUG] Added entity: %s", data[kvd_index-1].value);
} }
} }
free( data ); free( data );
break; break;
} }
// Bruteforce to remove quotes // Bruteforce to remove quotes
char parse[66] = {0}; char parse[66] = {0};
int skip = 0; int skip = 0;
for (int i = 0; i < strlen(input); i++) for (unsigned i = 0; i < strlen(input); i++)
{ {
if (input[i] == '"') if (input[i] == '"')
{ {
skip++; skip++;
continue; continue;
} }
parse[i-skip] = input[i]; parse[i-skip] = input[i];
} }
parse[strlen(parse)] = '\0'; parse[strlen(parse)] = '\0';
// Copy all keyvalues to the tempvar // Copy all keyvalues to the tempvar
// Key // Key
char *copy = strtok(parse, " "); char *copy = strtok(parse, " ");
strcpy(data[kvd_index].key, copy); strcpy(data[kvd_index].key, copy);
// Value // Value
copy = strtok(NULL, " "); copy = strtok(NULL, " ");
strcpy(data[kvd_index].value, ""); strcpy(data[kvd_index].value, "");
while (copy != NULL) while (copy != NULL)
{ {
// If the value is a vector, append necessary whitespaces // If the value is a vector, append necessary whitespaces
strcat(data[kvd_index].value, copy); strcat(data[kvd_index].value, copy);
copy = strtok(NULL, " "); copy = strtok(NULL, " ");
if (copy != NULL) if (copy != NULL)
strcat(data[kvd_index].value, " "); strcat(data[kvd_index].value, " ");
} }
// Next KVD // Next KVD
kvd_index++; kvd_index++;
} }
} }
} }
} }
void process_monster_cfg(void) bool process_monster_cfg(void)
{ {
char game_dir[256]; char game_dir[256];
char filename[256]; char filename[256];
FILE *fp = NULL; FILE *fp = NULL;
bool status = FALSE; // no error
monster_spawn_count = 0;
monster_spawn_count = 0;
// find the directory name of the currently running MOD...
// find the directory name of the currently running MOD... (*g_engfuncs.pfnGetGameDir)(game_dir);
(*g_engfuncs.pfnGetGameDir)(game_dir);
strcpy(filename, game_dir);
strcpy(filename, game_dir); #ifdef __linux__
#ifdef __linux__ strcat(filename, "/maps/");
strcat(filename, "/maps/"); #else
#else strcat(filename, "\\maps\\");
strcat(filename, "\\maps\\"); #endif
#endif strcat(filename, STRING(gpGlobals->mapname));
strcat(filename, STRING(gpGlobals->mapname)); strcat(filename, "_monster.cfg");
strcat(filename, "_monster.cfg");
// check if the map specific filename exists...
// check if the map specific filename exists... if (access(filename, 0) == 0)
if (access(filename, 0) == 0) {
{ if (dllapi_log->value)
if (dllapi_log->value) {
{ //META_CONS("[MONSTER] Processing config file=%s", filename);
//META_CONS("[MONSTER] Processing config file=%s", filename); LOG_MESSAGE(PLID, "Processing config file=%s", filename);
LOG_MESSAGE(PLID, "Processing config file=%s", filename); }
}
if ((fp = fopen(filename, "r")) == NULL)
if ((fp = fopen(filename, "r")) == NULL) {
{ //META_CONS("[MONSTER] ERROR: Could not open \"%s\"!", filename);
//META_CONS("[MONSTER] ERROR: Could not open \"%s\"!", filename); LOG_MESSAGE(PLID, "ERROR: Could not open \"%s\" file!", filename);
LOG_MESSAGE(PLID, "ERROR: Could not open \"%s\" file!", filename); return TRUE; // error
}
return;
} scan_monster_cfg(fp);
scan_monster_cfg(fp); fclose(fp);
}
fclose(fp);
} return FALSE; // all ok
}
return;
}
bool scan_monster_precache_cfg(FILE *fp)
{
bool scan_monster_precache_cfg(FILE *fp) char input[1024];
{ bool found;
char input[1024];
bool found; while (get_input(fp, input))
{
while (get_input(fp, input)) found = FALSE;
{
found = FALSE; for (int index=0; monster_types[index].name[0]; index++)
{
for (int index=0; monster_types[index].name[0]; index++) if (strcmp(input, monster_types[index].name) == 0)
{ {
if (strcmp(input, monster_types[index].name) == 0) monster_types[index].need_to_precache = TRUE;
{ found = TRUE;
monster_types[index].need_to_precache = TRUE; break;
found = TRUE; }
break; }
}
} if (found == FALSE)
{
if (found == FALSE) //META_CONS("[MONSTER] ERROR: invalid precache monster name: %s", input);
{ LOG_MESSAGE(PLID, "ERROR: invalid precache monster name: %s", input);
//META_CONS("[MONSTER] ERROR: invalid precache monster name: %s", input); }
LOG_MESSAGE(PLID, "ERROR: invalid precache monster name: %s", input); }
}
} return FALSE;
}
return FALSE;
}
bool process_monster_precache_cfg(void)
{
bool process_monster_precache_cfg(void) char game_dir[256];
{ char filename[256];
char game_dir[256]; FILE *fp = NULL;
char filename[256]; bool status = FALSE; // no error
FILE *fp = NULL;
bool status = FALSE; // no error // find the directory name of the currently running MOD...
(*g_engfuncs.pfnGetGameDir)(game_dir);
// find the directory name of the currently running MOD...
(*g_engfuncs.pfnGetGameDir)(game_dir); strcpy(filename, game_dir);
strcat(filename, "/monster_precache.cfg");
strcpy(filename, game_dir);
strcat(filename, "/monster_precache.cfg"); // check if the map specific filename exists...
if (access(filename, 0) == 0)
// check if the map specific filename exists... {
if (access(filename, 0) == 0) if (dllapi_log->value)
{ {
if (dllapi_log->value) //META_CONS("[MONSTER] Processing config file=%s", filename);
{ LOG_MESSAGE(PLID, "Processing config file=%s", filename);
//META_CONS("[MONSTER] Processing config file=%s", filename); }
LOG_MESSAGE(PLID, "Processing config file=%s", filename);
} if ((fp = fopen(filename, "r")) == NULL)
{
if ((fp = fopen(filename, "r")) == NULL) //META_CONS("[MONSTER] ERROR: Could not open \"%s\"!", filename);
{ LOG_MESSAGE(PLID, "ERROR: Could not open \"%s\" file!", filename);
//META_CONS("[MONSTER] ERROR: Could not open \"%s\"!", filename);
LOG_MESSAGE(PLID, "ERROR: Could not open \"%s\" file!", filename); return TRUE; // return bad status
}
return TRUE; // return bad status
} status = scan_monster_precache_cfg(fp);
status = scan_monster_precache_cfg(fp); fclose(fp);
}
fclose(fp);
} return status;
}
return status;
}

View File

@@ -1,5 +1,5 @@
LIBRARY monster_mm LIBRARY monster_mm
EXPORTS EXPORTS
GiveFnptrsToDll @1 GiveFnptrsToDll @1
SECTIONS SECTIONS
.data READ WRITE .data READ WRITE

View File

@@ -1,378 +1,417 @@
# Microsoft Developer Studio Project File - Name="monster_mm" - Package Owner=<4> # Microsoft Developer Studio Project File - Name="monster_mm" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00 # Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT ** # ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=monster_mm - Win32 Debug CFG=monster_mm - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run !MESSAGE use the Export Makefile command and run
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "monster_mm.mak". !MESSAGE NMAKE /f "monster_mm.mak".
!MESSAGE !MESSAGE
!MESSAGE You can specify a configuration when running NMAKE !MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "monster_mm.mak" CFG="monster_mm - Win32 Debug" !MESSAGE NMAKE /f "monster_mm.mak" CFG="monster_mm - Win32 Debug"
!MESSAGE !MESSAGE
!MESSAGE Possible choices for configuration are: !MESSAGE Possible choices for configuration are:
!MESSAGE !MESSAGE
!MESSAGE "monster_mm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "monster_mm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "monster_mm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "monster_mm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE !MESSAGE
# Begin Project # Begin Project
# PROP AllowPerConfigDependencies 0 # PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "" # PROP Scc_ProjName ""
# PROP Scc_LocalPath "" # PROP Scc_LocalPath ""
CPP=cl.exe CPP=cl.exe
MTL=midl.exe MTL=midl.exe
RSC=rc.exe RSC=rc.exe
!IF "$(CFG)" == "monster_mm - Win32 Release" !IF "$(CFG)" == "monster_mm - Win32 Release"
# PROP BASE Use_MFC 0 # PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0 # PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release" # PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release" # PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir "" # PROP BASE Target_Dir ""
# PROP Use_MFC 0 # PROP Use_MFC 0
# PROP Use_Debug_Libraries 0 # PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release" # PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release" # PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /YX /FD /c # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\dlls" /I "..\common" /I "..\engine" /I "..\pm_shared" /I "..\..\metamod" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /D strcasecmp=stricmp /D strncasecmp=_strnicmp /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\dlls" /I "..\common" /I "..\engine" /I "..\pm_shared" /I "..\metamod" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /D strcasecmp=stricmp /D strncasecmp=_strnicmp /FD /c
# SUBTRACT CPP /YX # SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /def:".\monster_mm.def" # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /def:".\monster_mm.def"
# Begin Custom Build - Copying to DLL folder
TargetPath=.\Release\monster_mm.dll !ELSEIF "$(CFG)" == "monster_mm - Win32 Debug"
TargetName=monster_mm
InputPath=.\Release\monster_mm.dll # PROP BASE Use_MFC 0
SOURCE="$(InputPath)" # PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
"$(TargetName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" # PROP BASE Intermediate_Dir "Debug"
copy $(TargetPath) D:\Half-Life\valve\dlls # PROP BASE Target_Dir ""
copy $(TargetPath) D:\Half-Life\tfc\dlls # PROP Use_MFC 0
copy $(TargetPath) D:\Half-Life\cstrike\dlls # PROP Use_Debug_Libraries 1
copy $(TargetPath) D:\Half-Life\dmc\dlls # PROP Output_Dir "Debug"
copy $(TargetPath) D:\Half-Life\dod\dlls # PROP Intermediate_Dir "Debug"
copy $(TargetPath) D:\Half-Life\firearms\dlls # PROP Ignore_Export_Lib 0
copy $(TargetPath) D:\Half-Life\frontline\dlls # PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /YX /FD /GZ /c
# End Custom Build # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\engine" /I "..\pm_shared" /I "..\metamod" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /D strcasecmp=stricmp /D strncasecmp=_strnicmp /FD /GZ /c
# SUBTRACT CPP /YX
!ELSEIF "$(CFG)" == "monster_mm - Win32 Debug" # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# PROP BASE Use_MFC 0 # ADD BASE RSC /l 0x409 /d "_DEBUG"
# PROP BASE Use_Debug_Libraries 1 # ADD RSC /l 0x409 /d "_DEBUG"
# PROP BASE Output_Dir "Debug" BSC32=bscmake.exe
# PROP BASE Intermediate_Dir "Debug" # ADD BASE BSC32 /nologo
# PROP BASE Target_Dir "" # ADD BSC32 /nologo
# PROP Use_MFC 0 LINK32=link.exe
# PROP Use_Debug_Libraries 1 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# PROP Output_Dir "Debug" # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /def:".\monster_mm.def" /pdbtype:sept
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0 !ENDIF
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /YX /FD /GZ /c # Begin Target
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\engine" /I "..\pm_shared" /I "..\..\metamod" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "monster_mm_EXPORTS" /D strcasecmp=stricmp /D strncasecmp=_strnicmp /FD /GZ /c
# SUBTRACT CPP /YX # Name "monster_mm - Win32 Release"
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # Name "monster_mm - Win32 Debug"
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # Begin Group "Source Files"
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
BSC32=bscmake.exe # Begin Source File
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo SOURCE=.\agrunt.cpp
LINK32=link.exe # End Source File
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # Begin Source File
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /def:".\monster_mm.def" /pdbtype:sept
# Begin Custom Build - Copying to DLL folder SOURCE=.\AI_BaseNPC_Schedule.cpp
TargetPath=.\Debug\monster_mm.dll # End Source File
TargetName=monster_mm # Begin Source File
InputPath=.\Debug\monster_mm.dll
SOURCE="$(InputPath)" SOURCE=.\animating.cpp
# End Source File
"$(TargetName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" # Begin Source File
copy $(TargetPath) D:\Half-Life\valve\dlls
copy $(TargetPath) D:\Half-Life\tfc\dlls SOURCE=.\animation.cpp
copy $(TargetPath) D:\Half-Life\cstrike\dlls # End Source File
copy $(TargetPath) D:\Half-Life\dmc\dlls # Begin Source File
copy $(TargetPath) D:\Half-Life\dod\dlls
copy $(TargetPath) D:\Half-Life\firearms\dlls SOURCE=.\apache.cpp
copy $(TargetPath) D:\Half-Life\frontline\dlls # End Source File
copy $(TargetPath) D:\Half-Life\gearbox\dlls # Begin Source File
# End Custom Build SOURCE=.\barney.cpp
# End Source File
!ENDIF # Begin Source File
# Begin Target SOURCE=.\bigmomma.cpp
# End Source File
# Name "monster_mm - Win32 Release" # Begin Source File
# Name "monster_mm - Win32 Debug"
# Begin Group "Source Files" SOURCE=.\bullsquid.cpp
# End Source File
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File
# Begin Source File
SOURCE=.\cmbase.cpp
SOURCE=.\agrunt.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\combat.cpp
SOURCE=.\AI_BaseNPC_Schedule.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\controller.cpp
SOURCE=.\animating.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\defaultai.cpp
SOURCE=.\animation.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\dllapi.cpp
SOURCE=.\apache.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\effects.cpp
SOURCE=.\barney.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\explode.cpp
SOURCE=.\bigmomma.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\flyingmonster.cpp
SOURCE=.\bullsquid.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\gargantua.cpp
SOURCE=.\cmbase.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\ggrenade.cpp
SOURCE=.\combat.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\gonome.cpp
SOURCE=.\controller.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\h_ai.cpp
SOURCE=.\defaultai.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\h_export.cpp
SOURCE=.\dllapi.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\hassassin.cpp
SOURCE=.\effects.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\headcrab.cpp
SOURCE=.\flyingmonster.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\hgrunt.cpp
SOURCE=.\ggrenade.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\hornet.cpp
SOURCE=.\h_ai.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\houndeye.cpp
SOURCE=.\h_export.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\islave.cpp
SOURCE=.\hassassin.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\massn.cpp
SOURCE=.\headcrab.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\monster_api.cpp
SOURCE=.\hgrunt.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\monster_config.cpp
SOURCE=.\hornet.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\monsters.cpp
SOURCE=.\houndeye.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\monsterstate.cpp
SOURCE=.\islave.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\nodes.cpp
SOURCE=.\monster_api.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\otis.cpp
SOURCE=.\monster_config.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\pitdrone.cpp
SOURCE=.\monsters.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\scientist.cpp
SOURCE=.\monsterstate.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\shock.cpp
SOURCE=.\nodes.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\shockroach.cpp
SOURCE=.\scientist.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\skill.cpp
SOURCE=.\skill.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\sound.cpp
SOURCE=.\sound.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\sporegrenade.cpp
SOURCE=.\squeakgrenade.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\squeakgrenade.cpp
SOURCE=.\subs.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\strooper.cpp
SOURCE=.\talkmonster.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\subs.cpp
SOURCE=.\util.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\talkmonster.cpp
SOURCE=.\weapons.cpp # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\turret.cpp
SOURCE=.\zombie.cpp # End Source File
# End Source File # Begin Source File
# End Group
# Begin Group "Header Files" SOURCE=.\util.cpp
# End Source File
# PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File
# Begin Source File
SOURCE=.\voltigore.cpp
SOURCE=.\activity.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\weapons.cpp
SOURCE=.\animation.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\zombie.cpp
SOURCE=.\cdll_dll.h # End Source File
# End Source File # End Group
# Begin Source File # Begin Group "Header Files"
SOURCE=.\cmbase.h # PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\activity.h
SOURCE=.\cmbasemonster.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\activitymap.h
SOURCE=.\cmflyingmonster.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\animation.h
SOURCE=.\cmtalkmonster.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\cdll_dll.h
SOURCE=.\decals.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\cmbase.h
SOURCE=.\doors.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\cmbasemonster.h
SOURCE=.\effects.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\cmflyingmonster.h
SOURCE=.\enginecallback.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\cmtalkmonster.h
SOURCE=.\explode.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\decals.h
SOURCE=.\extdll.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\defaultai.h
SOURCE=.\func_break.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\doors.h
SOURCE=.\monster_plugin.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\effects.h
SOURCE=.\monsters.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\enginecallback.h
SOURCE=.\nodes.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\explode.h
SOURCE=.\schedule.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\extdll.h
SOURCE=.\skill.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\func_break.h
SOURCE=.\util.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\hornet.h
SOURCE=.\vector.h # End Source File
# End Source File # Begin Source File
# Begin Source File
SOURCE=.\monster_plugin.h
SOURCE=.\weapons.h # End Source File
# End Source File # Begin Source File
# End Group
# Begin Group "Resource Files" SOURCE=.\monsterevent.h
# End Source File
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File
# End Group
# End Target SOURCE=.\monsters.h
# End Project # End Source File
# Begin Source File
SOURCE=.\nodes.h
# End Source File
# Begin Source File
SOURCE=.\plane.h
# End Source File
# Begin Source File
SOURCE=.\schedule.h
# End Source File
# Begin Source File
SOURCE=.\shock.h
# End Source File
# Begin Source File
SOURCE=.\skill.h
# End Source File
# Begin Source File
SOURCE=.\util.h
# End Source File
# Begin Source File
SOURCE=.\vector.h
# End Source File
# Begin Source File
SOURCE=.\weapons.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -1,74 +1,74 @@
// //
// monster_plugin.h // monster_plugin.h
// //
#ifndef MONSTER_PLUGIN_H #ifndef MONSTER_PLUGIN_H
#define MONSTER_PLUGIN_H #define MONSTER_PLUGIN_H
typedef struct pKVD typedef struct
{ {
char key[33]; char key[33];
char value[33]; char value[33];
}; } pKVD;
#define MAX_KEYVALUES 32 #define MAX_KEYVALUES 32
typedef struct typedef struct
{ {
char *name; char *name;
bool need_to_precache; bool need_to_precache;
} monster_type_t; } monster_type_t;
class CMBaseMonster; class CMBaseMonster;
typedef struct typedef struct
{ {
int monster_index; int monster_index;
edict_t *monster_pent; edict_t *monster_pent;
bool killed; bool killed;
int respawn_index; int respawn_index;
CMBaseMonster *pMonster; CMBaseMonster *pMonster;
} monster_t; } monster_t;
#define MAX_MONSTER_ENTS 400 // increased from 200 so it can hold non-monster entities #define MAX_MONSTER_ENTS 400 // increased from 200 so it can hold non-monster entities
extern monster_t monsters[MAX_MONSTER_ENTS]; extern monster_t monsters[MAX_MONSTER_ENTS];
typedef struct { typedef struct {
Vector origin; Vector origin;
Vector angles; Vector angles;
float delay; float delay;
unsigned char monster; unsigned char monster;
int spawnflags; int spawnflags;
pKVD *keyvalue; pKVD *keyvalue;
float respawn_time; float respawn_time;
bool need_to_respawn; bool need_to_respawn;
} monster_spawnpoint_t; } monster_spawnpoint_t;
#define MAX_MONSTERS 100 #define MAX_MONSTERS 100
extern monster_spawnpoint_t monster_spawnpoint[MAX_MONSTERS]; extern monster_spawnpoint_t monster_spawnpoint[MAX_MONSTERS];
// this is here to store if a node we want to spawn is an ordinary one, or a flying one // this is here to store if a node we want to spawn is an ordinary one, or a flying one
typedef struct typedef struct
{ {
Vector origin; Vector origin;
bool is_air_node; bool is_air_node;
} node_spawnpoint_t; } node_spawnpoint_t;
// nodes.cpp defines 1024 max nodes, but that amount is likely to trigger a // nodes.cpp defines 1024 max nodes, but that amount is likely to trigger a
// no free edicts crash if the server num_edicts is low. Increase if needed. // no free edicts crash if the server num_edicts is low. Increase if needed.
#define MAX_NODES 256 #define MAX_NODES 256
extern node_spawnpoint_t node_spawnpoint[MAX_NODES]; extern node_spawnpoint_t node_spawnpoint[MAX_NODES];
extern DLL_GLOBAL short g_sModelIndexFireball;// holds the index for the fireball extern DLL_GLOBAL short g_sModelIndexFireball;// holds the index for the fireball
extern DLL_GLOBAL short g_sModelIndexSmoke;// holds the index for the smoke cloud extern DLL_GLOBAL short g_sModelIndexSmoke;// holds the index for the smoke cloud
extern DLL_GLOBAL short g_sModelIndexWExplosion;// holds the index for the underwater explosion extern DLL_GLOBAL short g_sModelIndexWExplosion;// holds the index for the underwater explosion
extern DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles model extern DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles model
extern DLL_GLOBAL short g_sModelIndexBloodDrop;// holds the sprite index for the initial blood extern DLL_GLOBAL short g_sModelIndexBloodDrop;// holds the sprite index for the initial blood
extern DLL_GLOBAL short g_sModelIndexBloodSpray;// holds the sprite index for splattered blood extern DLL_GLOBAL short g_sModelIndexBloodSpray;// holds the sprite index for splattered blood
extern DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam extern DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam
extern DLL_GLOBAL const char *g_pModelNameLaser; extern DLL_GLOBAL const char *g_pModelNameLaser;
extern DLL_GLOBAL short g_sModelIndexLaserDot;// holds the index for the laser beam dot extern DLL_GLOBAL short g_sModelIndexLaserDot;// holds the index for the laser beam dot
#endif #endif

View File

@@ -1,34 +1,34 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef MONSTEREVENT_H #ifndef MONSTEREVENT_H
#define MONSTEREVENT_H #define MONSTEREVENT_H
typedef struct typedef struct
{ {
int event; int event;
char *options; char *options;
} MonsterEvent_t; } MonsterEvent_t;
#define EVENT_SPECIFIC 0 #define EVENT_SPECIFIC 0
#define EVENT_SCRIPTED 1000 #define EVENT_SCRIPTED 1000
#define EVENT_SHARED 2000 #define EVENT_SHARED 2000
#define EVENT_CLIENT 5000 #define EVENT_CLIENT 5000
#define MONSTER_EVENT_BODYDROP_LIGHT 2001 #define MONSTER_EVENT_BODYDROP_LIGHT 2001
#define MONSTER_EVENT_BODYDROP_HEAVY 2002 #define MONSTER_EVENT_BODYDROP_HEAVY 2002
#define MONSTER_EVENT_SWISHSOUND 2010 #define MONSTER_EVENT_SWISHSOUND 2010
#endif // MONSTEREVENT_H #endif // MONSTEREVENT_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,181 +1,181 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
#ifndef MONSTERS_H #ifndef MONSTERS_H
#define MONSTERS_H #define MONSTERS_H
/* /*
===== monsters.h ======================================================== ===== monsters.h ========================================================
Header file for monster-related utility code Header file for monster-related utility code
*/ */
// CHECKLOCALMOVE result types // CHECKLOCALMOVE result types
#define LOCALMOVE_INVALID 0 // move is not possible #define LOCALMOVE_INVALID 0 // move is not possible
#define LOCALMOVE_INVALID_DONT_TRIANGULATE 1 // move is not possible, don't try to triangulate #define LOCALMOVE_INVALID_DONT_TRIANGULATE 1 // move is not possible, don't try to triangulate
#define LOCALMOVE_VALID 2 // move is possible #define LOCALMOVE_VALID 2 // move is possible
// Hit Group standards // Hit Group standards
#define HITGROUP_GENERIC 0 #define HITGROUP_GENERIC 0
#define HITGROUP_HEAD 1 #define HITGROUP_HEAD 1
#define HITGROUP_CHEST 2 #define HITGROUP_CHEST 2
#define HITGROUP_STOMACH 3 #define HITGROUP_STOMACH 3
#define HITGROUP_LEFTARM 4 #define HITGROUP_LEFTARM 4
#define HITGROUP_RIGHTARM 5 #define HITGROUP_RIGHTARM 5
#define HITGROUP_LEFTLEG 6 #define HITGROUP_LEFTLEG 6
#define HITGROUP_RIGHTLEG 7 #define HITGROUP_RIGHTLEG 7
// Monster Spawnflags // Monster Spawnflags
#define SF_MONSTER_WAIT_TILL_SEEN 1// spawnflag that makes monsters wait until player can see them before attacking. #define SF_MONSTER_WAIT_TILL_SEEN 1// spawnflag that makes monsters wait until player can see them before attacking.
#define SF_MONSTER_GAG 2 // no idle noises from this monster #define SF_MONSTER_GAG 2 // no idle noises from this monster
#define SF_MONSTER_HITMONSTERCLIP 4 #define SF_MONSTER_HITMONSTERCLIP 4
// 8 // 8
#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. #define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him.
// 32 // 32
// 64 // 64
#define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked #define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked
#define SF_MONSTER_PREDISASTER 256 //this is a predisaster scientist or barney. Influences how they speak. #define SF_MONSTER_PREDISASTER 256 //this is a predisaster scientist or barney. Influences how they speak.
#define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death #define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death
#define SF_MONSTER_FALL_TO_GROUND 0x80000000 #define SF_MONSTER_FALL_TO_GROUND 0x80000000
// specialty spawnflags // specialty spawnflags
#define SF_MONSTER_TURRET_AUTOACTIVATE 32 #define SF_MONSTER_TURRET_AUTOACTIVATE 32
#define SF_MONSTER_TURRET_STARTINACTIVE 64 #define SF_MONSTER_TURRET_STARTINACTIVE 64
#define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked #define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked
// MoveToOrigin stuff // MoveToOrigin stuff
#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal #define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal
#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. #define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck.
// MoveToOrigin stuff // MoveToOrigin stuff
#define MOVE_NORMAL 0// normal move in the direction monster is facing #define MOVE_NORMAL 0// normal move in the direction monster is facing
#define MOVE_STRAFE 1// moves in direction specified, no matter which way monster is facing #define MOVE_STRAFE 1// moves in direction specified, no matter which way monster is facing
// spawn flags 256 and above are already taken by the engine // spawn flags 256 and above are already taken by the engine
extern void UTIL_MoveToOrigin( edict_t* pent, const Vector &vecGoal, float flDist, int iMoveType ); extern void UTIL_MoveToOrigin( edict_t* pent, const Vector &vecGoal, float flDist, int iMoveType );
Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0 ); Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0 );
Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0 ); Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0 );
extern DLL_GLOBAL Vector g_vecAttackDir; extern DLL_GLOBAL Vector g_vecAttackDir;
extern DLL_GLOBAL CONSTANT float g_flMeleeRange; extern DLL_GLOBAL CONSTANT float g_flMeleeRange;
extern DLL_GLOBAL CONSTANT float g_flMediumRange; extern DLL_GLOBAL CONSTANT float g_flMediumRange;
extern DLL_GLOBAL CONSTANT float g_flLongRange; extern DLL_GLOBAL CONSTANT float g_flLongRange;
extern void EjectBrass (const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); extern void EjectBrass (const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype );
extern void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ); extern void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count );
BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget ); BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget );
BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0.0 ); BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0.0 );
// monster to monster relationship types // monster to monster relationship types
#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. #define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable.
#define R_FR -1// (FEAR)will run #define R_FR -1// (FEAR)will run
#define R_NO 0// (NO RELATIONSHIP) disregard #define R_NO 0// (NO RELATIONSHIP) disregard
#define R_DL 1// (DISLIKE) will attack #define R_DL 1// (DISLIKE) will attack
#define R_HT 2// (HATE)will attack this character instead of any visible DISLIKEd characters #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 what #define R_NM 3// (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what
// these bits represent the monster's memory // these bits represent the monster's memory
#define MEMORY_CLEAR 0 #define MEMORY_CLEAR 0
#define bits_MEMORY_PROVOKED ( 1 << 0 )// right now only used for houndeyes. #define bits_MEMORY_PROVOKED ( 1 << 0 )// right now only used for houndeyes.
#define bits_MEMORY_INCOVER ( 1 << 1 )// monster knows it is in a covered position. #define bits_MEMORY_INCOVER ( 1 << 1 )// monster knows it is in a covered position.
#define bits_MEMORY_SUSPICIOUS ( 1 << 2 )// Ally is suspicious of the player, and will move to provoked more easily #define bits_MEMORY_SUSPICIOUS ( 1 << 2 )// Ally is suspicious of the player, and will move to provoked more easily
#define bits_MEMORY_PATH_FINISHED ( 1 << 3 )// Finished monster path (just used by big momma for now) #define bits_MEMORY_PATH_FINISHED ( 1 << 3 )// Finished monster path (just used by big momma for now)
#define bits_MEMORY_ON_PATH ( 1 << 4 )// Moving on a path #define bits_MEMORY_ON_PATH ( 1 << 4 )// Moving on a path
#define bits_MEMORY_MOVE_FAILED ( 1 << 5 )// Movement has already failed #define bits_MEMORY_MOVE_FAILED ( 1 << 5 )// Movement has already failed
#define bits_MEMORY_FLINCHED ( 1 << 6 )// Has already flinched #define bits_MEMORY_FLINCHED ( 1 << 6 )// Has already flinched
#define bits_MEMORY_KILLED ( 1 << 7 )// HACKHACK -- remember that I've already called my Killed() #define bits_MEMORY_KILLED ( 1 << 7 )// HACKHACK -- remember that I've already called my Killed()
#define bits_MEMORY_CUSTOM4 ( 1 << 28 ) // Monster-specific memory #define bits_MEMORY_CUSTOM4 ( 1 << 28 ) // Monster-specific memory
#define bits_MEMORY_CUSTOM3 ( 1 << 29 ) // Monster-specific memory #define bits_MEMORY_CUSTOM3 ( 1 << 29 ) // Monster-specific memory
#define bits_MEMORY_CUSTOM2 ( 1 << 30 ) // Monster-specific memory #define bits_MEMORY_CUSTOM2 ( 1 << 30 ) // Monster-specific memory
#define bits_MEMORY_CUSTOM1 ( 1 << 31 ) // Monster-specific memory #define bits_MEMORY_CUSTOM1 ( 1 << 31 ) // Monster-specific memory
// trigger conditions for scripted AI // trigger conditions for scripted AI
// these MUST match the CHOICES interface in halflife.fgd for the base monster // these MUST match the CHOICES interface in halflife.fgd for the base monster
enum enum
{ {
AITRIGGER_NONE = 0, AITRIGGER_NONE = 0,
AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER, AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER,
AITRIGGER_TAKEDAMAGE, AITRIGGER_TAKEDAMAGE,
AITRIGGER_HALFHEALTH, AITRIGGER_HALFHEALTH,
AITRIGGER_DEATH, AITRIGGER_DEATH,
AITRIGGER_SQUADMEMBERDIE, AITRIGGER_SQUADMEMBERDIE,
AITRIGGER_SQUADLEADERDIE, AITRIGGER_SQUADLEADERDIE,
AITRIGGER_HEARWORLD, AITRIGGER_HEARWORLD,
AITRIGGER_HEARPLAYER, AITRIGGER_HEARPLAYER,
AITRIGGER_HEARCOMBAT, AITRIGGER_HEARCOMBAT,
AITRIGGER_SEEPLAYER_UNCONDITIONAL, AITRIGGER_SEEPLAYER_UNCONDITIONAL,
AITRIGGER_SEEPLAYER_NOT_IN_COMBAT, AITRIGGER_SEEPLAYER_NOT_IN_COMBAT,
}; };
/* /*
0 : "No Trigger" 0 : "No Trigger"
1 : "See Player" 1 : "See Player"
2 : "Take Damage" 2 : "Take Damage"
3 : "50% Health Remaining" 3 : "50% Health Remaining"
4 : "Death" 4 : "Death"
5 : "Squad Member Dead" 5 : "Squad Member Dead"
6 : "Squad Leader Dead" 6 : "Squad Leader Dead"
7 : "Hear World" 7 : "Hear World"
8 : "Hear Player" 8 : "Hear Player"
9 : "Hear Combat" 9 : "Hear Combat"
*/ */
// //
// A gib is a chunk of a body, or a piece of wood/metal/rocks/etc. // A gib is a chunk of a body, or a piece of wood/metal/rocks/etc.
// //
class CMGib : public CMBaseEntity class CMGib : public CMBaseEntity
{ {
public: public:
void Spawn( const char *szGibModel ); void Spawn( const char *szGibModel );
void EXPORT BounceGibTouch ( edict_t *pOther ); void EXPORT BounceGibTouch ( edict_t *pOther );
void EXPORT StickyGibTouch ( edict_t *pOther ); void EXPORT StickyGibTouch ( edict_t *pOther );
void EXPORT WaitTillLand( void ); void EXPORT WaitTillLand( void );
void LimitVelocity( void ); void LimitVelocity( void );
virtual int ObjectCaps( void ) { return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } virtual int ObjectCaps( void ) { return (CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; }
static void SpawnHeadGib( entvars_t *pevVictim ); static void SpawnHeadGib( entvars_t *pevVictim );
static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ); static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human );
static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, const char *pGibModel, int human ); static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, const char *pGibModel, int human );
static void SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ); static void SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs );
int m_bloodColor; int m_bloodColor;
int m_cBloodDecals; int m_cBloodDecals;
int m_material; int m_material;
float m_lifeTime; float m_lifeTime;
}; };
#define CUSTOM_SCHEDULES\ #define CUSTOM_SCHEDULES\
virtual Schedule_t *ScheduleFromName( const char *pName );\ virtual Schedule_t *ScheduleFromName( const char *pName );\
static Schedule_t *m_scheduleList[]; static Schedule_t *m_scheduleList[];
#define DEFINE_CUSTOM_SCHEDULES(derivedClass)\ #define DEFINE_CUSTOM_SCHEDULES(derivedClass)\
Schedule_t *derivedClass::m_scheduleList[] = Schedule_t *derivedClass::m_scheduleList[] =
#define IMPLEMENT_CUSTOM_SCHEDULES(derivedClass, baseClass)\ #define IMPLEMENT_CUSTOM_SCHEDULES(derivedClass, baseClass)\
Schedule_t *derivedClass::ScheduleFromName( const char *pName )\ Schedule_t *derivedClass::ScheduleFromName( const char *pName )\
{\ {\
Schedule_t *pSchedule = ScheduleInList( pName, m_scheduleList, ARRAYSIZE(m_scheduleList) );\ Schedule_t *pSchedule = ScheduleInList( pName, m_scheduleList, ARRAYSIZE(m_scheduleList) );\
if ( !pSchedule )\ if ( !pSchedule )\
return baseClass::ScheduleFromName(pName);\ return baseClass::ScheduleFromName(pName);\
return pSchedule;\ return pSchedule;\
} }
#endif //MONSTERS_H #endif //MONSTERS_H

View File

@@ -1,214 +1,214 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// monsterstate.cpp - base class monster functions for // monsterstate.cpp - base class monster functions for
// controlling core AI. // controlling core AI.
//========================================================= //=========================================================
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "nodes.h" #include "nodes.h"
#include "monsters.h" #include "monsters.h"
#include "animation.h" #include "animation.h"
//========================================================= //=========================================================
// SetState // SetState
//========================================================= //=========================================================
void CMBaseMonster :: SetState ( MONSTERSTATE State ) void CMBaseMonster :: SetState ( MONSTERSTATE State )
{ {
/* /*
if ( State != m_MonsterState ) if ( State != m_MonsterState )
{ {
ALERT ( at_aiconsole, "State Changed to %d\n", State ); ALERT ( at_aiconsole, "State Changed to %d\n", State );
} }
*/ */
switch( State ) switch( State )
{ {
// Drop enemy pointers when going to idle // Drop enemy pointers when going to idle
case MONSTERSTATE_IDLE: case MONSTERSTATE_IDLE:
if (( m_hEnemy != NULL ) && if (( m_hEnemy != NULL ) &&
( strcmp(STRING(pev->model), "models/scientist.mdl") != 0)) ( strcmp(STRING(pev->model), "models/scientist.mdl") != 0))
{ {
m_hEnemy = NULL;// not allowed to have an enemy anymore. m_hEnemy = NULL;// not allowed to have an enemy anymore.
ALERT ( at_aiconsole, "Stripped\n" ); ALERT ( at_aiconsole, "Stripped\n" );
} }
break; break;
} }
m_MonsterState = State; m_MonsterState = State;
m_IdealMonsterState = State; m_IdealMonsterState = State;
} }
//========================================================= //=========================================================
// RunAI // RunAI
//========================================================= //=========================================================
void CMBaseMonster :: RunAI ( void ) void CMBaseMonster :: RunAI ( void )
{ {
// to test model's eye height // to test model's eye height
//UTIL_ParticleEffect ( pev->origin + pev->view_ofs, g_vecZero, 255, 10 ); //UTIL_ParticleEffect ( pev->origin + pev->view_ofs, g_vecZero, 255, 10 );
// IDLE sound permitted in ALERT state is because monsters were silent in ALERT state. Only play IDLE sound in IDLE state // IDLE sound permitted in ALERT state is because monsters were silent in ALERT state. Only play IDLE sound in IDLE state
// once we have sounds for that state. // once we have sounds for that state.
if ( ( m_MonsterState == MONSTERSTATE_IDLE || m_MonsterState == MONSTERSTATE_ALERT ) && RANDOM_LONG(0,99) == 0 && !(pev->flags & SF_MONSTER_GAG) ) if ( ( m_MonsterState == MONSTERSTATE_IDLE || m_MonsterState == MONSTERSTATE_ALERT ) && RANDOM_LONG(0,99) == 0 && !(pev->flags & SF_MONSTER_GAG) )
{ {
IdleSound(); IdleSound();
} }
if ( m_MonsterState != MONSTERSTATE_NONE && if ( m_MonsterState != MONSTERSTATE_NONE &&
m_MonsterState != MONSTERSTATE_PRONE && m_MonsterState != MONSTERSTATE_PRONE &&
m_MonsterState != MONSTERSTATE_DEAD )// don't bother with this crap if monster is prone. m_MonsterState != MONSTERSTATE_DEAD )// don't bother with this crap if monster is prone.
{ {
// collect some sensory Condition information. // collect some sensory Condition information.
// don't let monsters outside of the player's PVS act up, or most of the interesting // don't let monsters outside of the player's PVS act up, or most of the interesting
// things will happen before the player gets there! // things will happen before the player gets there!
// UPDATE: We now let COMBAT state monsters think and act fully outside of player PVS. This allows the player to leave // UPDATE: We now let COMBAT state monsters think and act fully outside of player PVS. This allows the player to leave
// an area where monsters are fighting, and the fight will continue. // an area where monsters are fighting, and the fight will continue.
if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) || ( m_MonsterState == MONSTERSTATE_COMBAT ) ) if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) || ( m_MonsterState == MONSTERSTATE_COMBAT ) )
{ {
Look( m_flDistLook ); Look( m_flDistLook );
//jlb Listen();// check for audible sounds. //jlb Listen();// check for audible sounds.
// now filter conditions. // now filter conditions.
ClearConditions( IgnoreConditions() ); ClearConditions( IgnoreConditions() );
GetEnemy(); GetEnemy();
} }
// do these calculations if monster has an enemy. // do these calculations if monster has an enemy.
if ( m_hEnemy != NULL ) if ( m_hEnemy != NULL )
{ {
CheckEnemy( m_hEnemy ); CheckEnemy( m_hEnemy );
} }
CheckAmmo(); CheckAmmo();
} }
FCheckAITrigger(); FCheckAITrigger();
PrescheduleThink(); PrescheduleThink();
MaintainSchedule(); MaintainSchedule();
// if the monster didn't use these conditions during the above call to MaintainSchedule() or CheckAITrigger() // if the monster didn't use these conditions during the above call to MaintainSchedule() or CheckAITrigger()
// we throw them out cause we don't want them sitting around through the lifespan of a schedule // we throw them out cause we don't want them sitting around through the lifespan of a schedule
// that doesn't use them. // that doesn't use them.
m_afConditions &= ~( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ); m_afConditions &= ~( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE );
} }
//========================================================= //=========================================================
// GetIdealState - surveys the Conditions information available // GetIdealState - surveys the Conditions information available
// and finds the best new state for a monster. // and finds the best new state for a monster.
//========================================================= //=========================================================
MONSTERSTATE CMBaseMonster :: GetIdealState ( void ) MONSTERSTATE CMBaseMonster :: GetIdealState ( void )
{ {
int iConditions; int iConditions;
iConditions = IScheduleFlags(); iConditions = IScheduleFlags();
// If no schedule conditions, the new ideal state is probably the reason we're in here. // If no schedule conditions, the new ideal state is probably the reason we're in here.
switch ( m_MonsterState ) switch ( m_MonsterState )
{ {
case MONSTERSTATE_IDLE: case MONSTERSTATE_IDLE:
/* /*
IDLE goes to ALERT upon hearing a sound IDLE goes to ALERT upon hearing a sound
-IDLE goes to ALERT upon being injured -IDLE goes to ALERT upon being injured
IDLE goes to ALERT upon seeing food IDLE goes to ALERT upon seeing food
-IDLE goes to COMBAT upon sighting an enemy -IDLE goes to COMBAT upon sighting an enemy
IDLE goes to HUNT upon smelling food IDLE goes to HUNT upon smelling food
*/ */
{ {
if ( iConditions & bits_COND_NEW_ENEMY ) if ( iConditions & bits_COND_NEW_ENEMY )
{ {
// new enemy! This means an idle monster has seen someone it dislikes, or // new enemy! This means an idle monster has seen someone it dislikes, or
// that a monster in combat has found a more suitable target to attack // that a monster in combat has found a more suitable target to attack
m_IdealMonsterState = MONSTERSTATE_COMBAT; m_IdealMonsterState = MONSTERSTATE_COMBAT;
} }
else if ( iConditions & bits_COND_LIGHT_DAMAGE ) else if ( iConditions & bits_COND_LIGHT_DAMAGE )
{ {
MakeIdealYaw ( m_vecEnemyLKP ); MakeIdealYaw ( m_vecEnemyLKP );
m_IdealMonsterState = MONSTERSTATE_ALERT; m_IdealMonsterState = MONSTERSTATE_ALERT;
} }
else if ( iConditions & bits_COND_HEAVY_DAMAGE ) else if ( iConditions & bits_COND_HEAVY_DAMAGE )
{ {
MakeIdealYaw ( m_vecEnemyLKP ); MakeIdealYaw ( m_vecEnemyLKP );
m_IdealMonsterState = MONSTERSTATE_ALERT; m_IdealMonsterState = MONSTERSTATE_ALERT;
} }
else if ( iConditions & bits_COND_HEAR_SOUND ) else if ( iConditions & bits_COND_HEAR_SOUND )
{ {
} }
else if ( iConditions & (bits_COND_SMELL | bits_COND_SMELL_FOOD) ) else if ( iConditions & (bits_COND_SMELL | bits_COND_SMELL_FOOD) )
{ {
m_IdealMonsterState = MONSTERSTATE_ALERT; m_IdealMonsterState = MONSTERSTATE_ALERT;
} }
break; break;
} }
case MONSTERSTATE_ALERT: case MONSTERSTATE_ALERT:
/* /*
ALERT goes to IDLE upon becoming bored ALERT goes to IDLE upon becoming bored
-ALERT goes to COMBAT upon sighting an enemy -ALERT goes to COMBAT upon sighting an enemy
ALERT goes to HUNT upon hearing a noise ALERT goes to HUNT upon hearing a noise
*/ */
{ {
if ( iConditions & (bits_COND_NEW_ENEMY|bits_COND_SEE_ENEMY) ) if ( iConditions & (bits_COND_NEW_ENEMY|bits_COND_SEE_ENEMY) )
{ {
// see an enemy we MUST attack // see an enemy we MUST attack
m_IdealMonsterState = MONSTERSTATE_COMBAT; m_IdealMonsterState = MONSTERSTATE_COMBAT;
} }
else if ( iConditions & bits_COND_HEAR_SOUND ) else if ( iConditions & bits_COND_HEAR_SOUND )
{ {
m_IdealMonsterState = MONSTERSTATE_ALERT; m_IdealMonsterState = MONSTERSTATE_ALERT;
} }
break; break;
} }
case MONSTERSTATE_COMBAT: case MONSTERSTATE_COMBAT:
/* /*
COMBAT goes to HUNT upon losing sight of enemy COMBAT goes to HUNT upon losing sight of enemy
COMBAT goes to ALERT upon death of enemy COMBAT goes to ALERT upon death of enemy
*/ */
{ {
if ( m_hEnemy == NULL ) if ( m_hEnemy == NULL )
{ {
m_IdealMonsterState = MONSTERSTATE_ALERT; m_IdealMonsterState = MONSTERSTATE_ALERT;
// pev->effects = EF_BRIGHTFIELD; // pev->effects = EF_BRIGHTFIELD;
ALERT ( at_aiconsole, "***Combat state with no enemy!\n" ); ALERT ( at_aiconsole, "***Combat state with no enemy!\n" );
} }
break; break;
} }
case MONSTERSTATE_HUNT: case MONSTERSTATE_HUNT:
/* /*
HUNT goes to ALERT upon seeing food HUNT goes to ALERT upon seeing food
HUNT goes to ALERT upon being injured HUNT goes to ALERT upon being injured
HUNT goes to IDLE if goal touched HUNT goes to IDLE if goal touched
HUNT goes to COMBAT upon seeing enemy HUNT goes to COMBAT upon seeing enemy
*/ */
{ {
break; break;
} }
case MONSTERSTATE_DEAD: case MONSTERSTATE_DEAD:
m_IdealMonsterState = MONSTERSTATE_DEAD; m_IdealMonsterState = MONSTERSTATE_DEAD;
break; break;
} }
return m_IdealMonsterState; return m_IdealMonsterState;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,397 +1,397 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// nodes.h // nodes.h
//========================================================= //=========================================================
//========================================================= //=========================================================
// DEFINE // DEFINE
//========================================================= //=========================================================
#define MAX_STACK_NODES 100 #define MAX_STACK_NODES 100
#define NO_NODE -1 #define NO_NODE -1
#define MAX_NODE_HULLS 4 #define MAX_NODE_HULLS 4
#define bits_NODE_LAND ( 1 << 0 ) // Land node, so nudge if necessary. #define bits_NODE_LAND ( 1 << 0 ) // Land node, so nudge if necessary.
#define bits_NODE_AIR ( 1 << 1 ) // Air node, don't nudge. #define bits_NODE_AIR ( 1 << 1 ) // Air node, don't nudge.
#define bits_NODE_WATER ( 1 << 2 ) // Water node, don't nudge. #define bits_NODE_WATER ( 1 << 2 ) // Water node, don't nudge.
#define bits_NODE_GROUP_REALM (bits_NODE_LAND | bits_NODE_AIR | bits_NODE_WATER) #define bits_NODE_GROUP_REALM (bits_NODE_LAND | bits_NODE_AIR | bits_NODE_WATER)
//========================================================= //=========================================================
// Instance of a node. // Instance of a node.
//========================================================= //=========================================================
class CNode class CNode
{ {
public: public:
Vector m_vecOrigin;// location of this node in space Vector m_vecOrigin;// location of this node in space
Vector m_vecOriginPeek; // location of this node (LAND nodes are NODE_HEIGHT higher). Vector m_vecOriginPeek; // location of this node (LAND nodes are NODE_HEIGHT higher).
BYTE m_Region[3]; // Which of 256 regions do each of the coordinate belong? BYTE m_Region[3]; // Which of 256 regions do each of the coordinate belong?
int m_afNodeInfo;// bits that tell us more about this location int m_afNodeInfo;// bits that tell us more about this location
int m_cNumLinks; // how many links this node has int m_cNumLinks; // how many links this node has
int m_iFirstLink;// index of this node's first link in the link pool. int m_iFirstLink;// index of this node's first link in the link pool.
// Where to start looking in the compressed routing table (offset into m_pRouteInfo). // Where to start looking in the compressed routing table (offset into m_pRouteInfo).
// (4 hull sizes -- smallest to largest + fly/swim), and secondly, door capability. // (4 hull sizes -- smallest to largest + fly/swim), and secondly, door capability.
// //
int m_pNextBestNode[MAX_NODE_HULLS][2]; int m_pNextBestNode[MAX_NODE_HULLS][2];
// Used in finding the shortest path. m_fClosestSoFar is -1 if not visited. // Used in finding the shortest path. m_fClosestSoFar is -1 if not visited.
// Then it is the distance to the source. If another path uses this node // Then it is the distance to the source. If another path uses this node
// and has a closer distance, then m_iPreviousNode is also updated. // and has a closer distance, then m_iPreviousNode is also updated.
// //
float m_flClosestSoFar; // Used in finding the shortest path. float m_flClosestSoFar; // Used in finding the shortest path.
int m_iPreviousNode; int m_iPreviousNode;
short m_sHintType;// there is something interesting in the world at this node's position short m_sHintType;// there is something interesting in the world at this node's position
short m_sHintActivity;// there is something interesting in the world at this node's position short m_sHintActivity;// there is something interesting in the world at this node's position
float m_flHintYaw;// monster on this node should face this yaw to face the hint. float m_flHintYaw;// monster on this node should face this yaw to face the hint.
}; };
//========================================================= //=========================================================
// CLink - A link between 2 nodes // CLink - A link between 2 nodes
//========================================================= //=========================================================
#define bits_LINK_SMALL_HULL ( 1 << 0 )// headcrab box can fit through this connection #define bits_LINK_SMALL_HULL ( 1 << 0 )// headcrab box can fit through this connection
#define bits_LINK_HUMAN_HULL ( 1 << 1 )// player box can fit through this connection #define bits_LINK_HUMAN_HULL ( 1 << 1 )// player box can fit through this connection
#define bits_LINK_LARGE_HULL ( 1 << 2 )// big box can fit through this connection #define bits_LINK_LARGE_HULL ( 1 << 2 )// big box can fit through this connection
#define bits_LINK_FLY_HULL ( 1 << 3 )// a flying big box can fit through this connection #define bits_LINK_FLY_HULL ( 1 << 3 )// a flying big box can fit through this connection
#define bits_LINK_DISABLED ( 1 << 4 )// link is not valid when the set #define bits_LINK_DISABLED ( 1 << 4 )// link is not valid when the set
#define NODE_SMALL_HULL 0 #define NODE_SMALL_HULL 0
#define NODE_HUMAN_HULL 1 #define NODE_HUMAN_HULL 1
#define NODE_LARGE_HULL 2 #define NODE_LARGE_HULL 2
#define NODE_FLY_HULL 3 #define NODE_FLY_HULL 3
class CLink class CLink
{ {
public: public:
int m_iSrcNode;// the node that 'owns' this link ( keeps us from having to make reverse lookups ) int m_iSrcNode;// the node that 'owns' this link ( keeps us from having to make reverse lookups )
int m_iDestNode;// the node on the other end of the link. int m_iDestNode;// the node on the other end of the link.
entvars_t *m_pLinkEnt;// the entity that blocks this connection (doors, etc) entvars_t *m_pLinkEnt;// the entity that blocks this connection (doors, etc)
// m_szLinkEntModelname is not necessarily NULL terminated (so we can store it in a more alignment-friendly 4 bytes) // m_szLinkEntModelname is not necessarily NULL terminated (so we can store it in a more alignment-friendly 4 bytes)
char m_szLinkEntModelname[ 4 ];// the unique name of the brush model that blocks the connection (this is kept for save/restore) char m_szLinkEntModelname[ 4 ];// the unique name of the brush model that blocks the connection (this is kept for save/restore)
int m_afLinkInfo;// information about this link int m_afLinkInfo;// information about this link
float m_flWeight;// length of the link line segment float m_flWeight;// length of the link line segment
}; };
typedef struct typedef struct
{ {
int m_SortedBy[3]; int m_SortedBy[3];
int m_CheckedEvent; int m_CheckedEvent;
} DIST_INFO; } DIST_INFO;
typedef struct typedef struct
{ {
Vector v; Vector v;
short n; // Nearest node or -1 if no node found. short n; // Nearest node or -1 if no node found.
} CACHE_ENTRY; } CACHE_ENTRY;
//========================================================= //=========================================================
// CGraph // CGraph
//========================================================= //=========================================================
#define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files.
class CGraph class CGraph
{ {
public: public:
// the graph has two flags, and should not be accessed unless both flags are TRUE! // the graph has two flags, and should not be accessed unless both flags are TRUE!
BOOL m_fGraphPresent;// is the graph in memory? BOOL m_fGraphPresent;// is the graph in memory?
BOOL m_fGraphPointersSet;// are the entity pointers for the graph all set? BOOL m_fGraphPointersSet;// are the entity pointers for the graph all set?
BOOL m_fRoutingComplete; // are the optimal routes computed, yet? BOOL m_fRoutingComplete; // are the optimal routes computed, yet?
CNode *m_pNodes;// pointer to the memory block that contains all node info CNode *m_pNodes;// pointer to the memory block that contains all node info
CLink *m_pLinkPool;// big list of all node connections CLink *m_pLinkPool;// big list of all node connections
char *m_pRouteInfo; // compressed routing information the nodes use. char *m_pRouteInfo; // compressed routing information the nodes use.
int m_cNodes;// total number of nodes int m_cNodes;// total number of nodes
int m_cLinks;// total number of links int m_cLinks;// total number of links
int m_nRouteInfo; // size of m_pRouteInfo in bytes. int m_nRouteInfo; // size of m_pRouteInfo in bytes.
// Tables for making nearest node lookup faster. SortedBy provided nodes in a // Tables for making nearest node lookup faster. SortedBy provided nodes in a
// order of a particular coordinate. Instead of doing a binary search, RangeStart // order of a particular coordinate. Instead of doing a binary search, RangeStart
// and RangeEnd let you get to the part of SortedBy that you are interested in. // and RangeEnd let you get to the part of SortedBy that you are interested in.
// //
// Once you have a point of interest, the only way you'll find a closer point is // Once you have a point of interest, the only way you'll find a closer point is
// if at least one of the coordinates is closer than the ones you have now. So we // if at least one of the coordinates is closer than the ones you have now. So we
// search each range. After the search is exhausted, we know we have the closest // search each range. After the search is exhausted, we know we have the closest
// node. // node.
// //
#define CACHE_SIZE 128 #define CACHE_SIZE 128
#define NUM_RANGES 256 #define NUM_RANGES 256
DIST_INFO *m_di; // This is m_cNodes long, but the entries don't correspond to CNode entries. DIST_INFO *m_di; // This is m_cNodes long, but the entries don't correspond to CNode entries.
int m_RangeStart[3][NUM_RANGES]; int m_RangeStart[3][NUM_RANGES];
int m_RangeEnd[3][NUM_RANGES]; int m_RangeEnd[3][NUM_RANGES];
float m_flShortest; float m_flShortest;
int m_iNearest; int m_iNearest;
int m_minX, m_minY, m_minZ, m_maxX, m_maxY, m_maxZ; int m_minX, m_minY, m_minZ, m_maxX, m_maxY, m_maxZ;
int m_minBoxX, m_minBoxY, m_minBoxZ, m_maxBoxX, m_maxBoxY, m_maxBoxZ; int m_minBoxX, m_minBoxY, m_minBoxZ, m_maxBoxX, m_maxBoxY, m_maxBoxZ;
int m_CheckedCounter; int m_CheckedCounter;
float m_RegionMin[3], m_RegionMax[3]; // The range of nodes. float m_RegionMin[3], m_RegionMax[3]; // The range of nodes.
CACHE_ENTRY m_Cache[CACHE_SIZE]; CACHE_ENTRY m_Cache[CACHE_SIZE];
int m_HashPrimes[16]; int m_HashPrimes[16];
short *m_pHashLinks; short *m_pHashLinks;
int m_nHashLinks; int m_nHashLinks;
// kinda sleazy. In order to allow variety in active idles for monster groups in a room with more than one node, // kinda sleazy. In order to allow variety in active idles for monster groups in a room with more than one node,
// we keep track of the last node we searched from and store it here. Subsequent searches by other monsters will pick // we keep track of the last node we searched from and store it here. Subsequent searches by other monsters will pick
// up where the last search stopped. // up where the last search stopped.
int m_iLastActiveIdleSearch; int m_iLastActiveIdleSearch;
// another such system used to track the search for cover nodes, helps greatly with two monsters trying to get to the same node. // another such system used to track the search for cover nodes, helps greatly with two monsters trying to get to the same node.
int m_iLastCoverSearch; int m_iLastCoverSearch;
// functions to create the graph // functions to create the graph
int LinkVisibleNodes ( CLink *pLinkPool, FILE *file, int *piBadNode ); int LinkVisibleNodes ( CLink *pLinkPool, FILE *file, int *piBadNode );
int RejectInlineLinks ( CLink *pLinkPool, FILE *file ); int RejectInlineLinks ( CLink *pLinkPool, FILE *file );
int FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, int afCapMask); int FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, int afCapMask);
int FindNearestNode ( const Vector &vecOrigin, CMBaseEntity *pEntity ); int FindNearestNode ( const Vector &vecOrigin, CMBaseEntity *pEntity );
int FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ); int FindNearestNode ( const Vector &vecOrigin, int afNodeTypes );
//int FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, BOOL *pfAlongLine ); //int FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, BOOL *pfAlongLine );
float PathLength( int iStart, int iDest, int iHull, int afCapMask ); float PathLength( int iStart, int iDest, int iHull, int afCapMask );
int NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ); int NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap );
enum NODEQUERY { NODEGRAPH_DYNAMIC, NODEGRAPH_STATIC }; enum NODEQUERY { NODEGRAPH_DYNAMIC, NODEGRAPH_STATIC };
// A static query means we're asking about the possiblity of handling this entity at ANY time // A static query means we're asking about the possiblity of handling this entity at ANY time
// A dynamic query means we're asking about it RIGHT NOW. So we should query the current state // A dynamic query means we're asking about it RIGHT NOW. So we should query the current state
int HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ); int HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType );
entvars_t* LinkEntForLink ( CLink *pLink, CNode *pNode ); entvars_t* LinkEntForLink ( CLink *pLink, CNode *pNode );
void ShowNodeConnections ( int iNode ); void ShowNodeConnections ( int iNode );
void InitGraph( void ); void InitGraph( void );
int AllocNodes ( void ); int AllocNodes ( void );
int CheckNODFile(char *szMapName); int CheckNODFile(char *szMapName);
int FLoadGraph(char *szMapName); int FLoadGraph(char *szMapName);
int FSaveGraph(char *szMapName); int FSaveGraph(char *szMapName);
int FSetGraphPointers(void); int FSetGraphPointers(void);
void CheckNode(Vector vecOrigin, int iNode); void CheckNode(Vector vecOrigin, int iNode);
void BuildRegionTables(void); void BuildRegionTables(void);
void ComputeStaticRoutingTables(void); void ComputeStaticRoutingTables(void);
void TestRoutingTables(void); void TestRoutingTables(void);
void HashInsert(int iSrcNode, int iDestNode, int iKey); void HashInsert(int iSrcNode, int iDestNode, int iKey);
void HashSearch(int iSrcNode, int iDestNode, int &iKey); void HashSearch(int iSrcNode, int iDestNode, int &iKey);
void HashChoosePrimes(int TableSize); void HashChoosePrimes(int TableSize);
void BuildLinkLookups(void); void BuildLinkLookups(void);
void SortNodes(void); void SortNodes(void);
int HullIndex( const CMBaseEntity *pEntity ); // what hull the monster uses int HullIndex( const CMBaseEntity *pEntity ); // what hull the monster uses
int NodeType( const CMBaseEntity *pEntity ); // what node type the monster uses int NodeType( const CMBaseEntity *pEntity ); // what node type the monster uses
inline int CapIndex( int afCapMask ) inline int CapIndex( int afCapMask )
{ {
if (afCapMask & (bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE)) if (afCapMask & (bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE))
return 1; return 1;
return 0; return 0;
} }
inline CNode &Node( int i ) inline CNode &Node( int i )
{ {
#ifdef _DEBUG #ifdef _DEBUG
if ( !m_pNodes || i < 0 || i > m_cNodes ) if ( !m_pNodes || i < 0 || i > m_cNodes )
ALERT( at_error, "Bad Node!\n" ); ALERT( at_error, "Bad Node!\n" );
#endif #endif
return m_pNodes[i]; return m_pNodes[i];
} }
inline CLink &Link( int i ) inline CLink &Link( int i )
{ {
#ifdef _DEBUG #ifdef _DEBUG
if ( !m_pLinkPool || i < 0 || i > m_cLinks ) if ( !m_pLinkPool || i < 0 || i > m_cLinks )
ALERT( at_error, "Bad link!\n" ); ALERT( at_error, "Bad link!\n" );
#endif #endif
return m_pLinkPool[i]; return m_pLinkPool[i];
} }
inline CLink &NodeLink( int iNode, int iLink ) inline CLink &NodeLink( int iNode, int iLink )
{ {
return Link( Node( iNode ).m_iFirstLink + iLink ); return Link( Node( iNode ).m_iFirstLink + iLink );
} }
inline CLink &NodeLink( const CNode &node, int iLink ) inline CLink &NodeLink( const CNode &node, int iLink )
{ {
return Link( node.m_iFirstLink + iLink ); return Link( node.m_iFirstLink + iLink );
} }
inline int INodeLink ( int iNode, int iLink ) inline int INodeLink ( int iNode, int iLink )
{ {
return NodeLink( iNode, iLink ).m_iDestNode; return NodeLink( iNode, iLink ).m_iDestNode;
} }
#if 0 #if 0
inline CNode &SourceNode( int iNode, int iLink ) inline CNode &SourceNode( int iNode, int iLink )
{ {
return Node( NodeLink( iNode, iLink ).m_iSrcNode ); return Node( NodeLink( iNode, iLink ).m_iSrcNode );
} }
inline CNode &DestNode( int iNode, int iLink ) inline CNode &DestNode( int iNode, int iLink )
{ {
return Node( NodeLink( iNode, iLink ).m_iDestNode ); return Node( NodeLink( iNode, iLink ).m_iDestNode );
} }
inline CNode *PNodeLink ( int iNode, int iLink ) inline CNode *PNodeLink ( int iNode, int iLink )
{ {
return &DestNode( iNode, iLink ); return &DestNode( iNode, iLink );
} }
#endif #endif
}; };
//========================================================= //=========================================================
// Nodes start out as ents in the level. The node graph // Nodes start out as ents in the level. The node graph
// is built, then these ents are discarded. // is built, then these ents are discarded.
//========================================================= //=========================================================
class CNodeEnt : public CMBaseEntity class CNodeEnt : public CMBaseEntity
{ {
void Spawn( void ); void Spawn( void );
void KeyValue( KeyValueData *pkvd ); void KeyValue( KeyValueData *pkvd );
virtual int ObjectCaps( void ) { return CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual int ObjectCaps( void ) { return CMBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
short m_sHintType; short m_sHintType;
short m_sHintActivity; short m_sHintActivity;
}; };
//========================================================= //=========================================================
// Node viewer // Node viewer
//========================================================= //=========================================================
class CNodeViewer : public CMBaseEntity class CNodeViewer : public CMBaseEntity
{ {
public: public:
void Spawn( void ); void Spawn( void );
int m_iBaseNode; int m_iBaseNode;
int m_iDraw; int m_iDraw;
int m_nVisited; int m_nVisited;
int m_aFrom[128]; int m_aFrom[128];
int m_aTo[128]; int m_aTo[128];
int m_iHull; int m_iHull;
int m_afNodeType; int m_afNodeType;
Vector m_vecColor; Vector m_vecColor;
void FindNodeConnections( int iNode ); void FindNodeConnections( int iNode );
void AddNode( int iFrom, int iTo ); void AddNode( int iFrom, int iTo );
void EXPORT DrawThink( void ); void EXPORT DrawThink( void );
}; };
//========================================================= //=========================================================
// CStack - last in, first out. // CStack - last in, first out.
//========================================================= //=========================================================
class CStack class CStack
{ {
public: public:
CStack( void ); CStack( void );
void Push( int value ); void Push( int value );
int Pop( void ); int Pop( void );
int Top( void ); int Top( void );
int Empty( void ) { return m_level==0; } int Empty( void ) { return m_level==0; }
int Size( void ) { return m_level; } int Size( void ) { return m_level; }
void CopyToArray ( int *piArray ); void CopyToArray ( int *piArray );
private: private:
int m_stack[ MAX_STACK_NODES ]; int m_stack[ MAX_STACK_NODES ];
int m_level; int m_level;
}; };
//========================================================= //=========================================================
// CQueue - first in, first out. // CQueue - first in, first out.
//========================================================= //=========================================================
class CQueue class CQueue
{ {
public: public:
CQueue( void );// constructor CQueue( void );// constructor
inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); } inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); }
inline int Empty ( void ) { return ( m_cSize == 0 ); } inline int Empty ( void ) { return ( m_cSize == 0 ); }
//inline int Tail ( void ) { return ( m_queue[ m_tail ] ); } //inline int Tail ( void ) { return ( m_queue[ m_tail ] ); }
inline int Size ( void ) { return ( m_cSize ); } inline int Size ( void ) { return ( m_cSize ); }
void Insert( int, float ); void Insert( int, float );
int Remove( float & ); int Remove( float & );
private: private:
int m_cSize; int m_cSize;
struct tag_QUEUE_NODE struct tag_QUEUE_NODE
{ {
int Id; int Id;
float Priority; float Priority;
} m_queue[ MAX_STACK_NODES ]; } m_queue[ MAX_STACK_NODES ];
int m_head; int m_head;
int m_tail; int m_tail;
}; };
//========================================================= //=========================================================
// CQueuePriority - Priority queue (smallest item out first). // CQueuePriority - Priority queue (smallest item out first).
// //
//========================================================= //=========================================================
class CQueuePriority class CQueuePriority
{ {
public: public:
CQueuePriority( void );// constructor CQueuePriority( void );// constructor
inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); } inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); }
inline int Empty ( void ) { return ( m_cSize == 0 ); } inline int Empty ( void ) { return ( m_cSize == 0 ); }
//inline int Tail ( float & ) { return ( m_queue[ m_tail ].Id ); } //inline int Tail ( float & ) { return ( m_queue[ m_tail ].Id ); }
inline int Size ( void ) { return ( m_cSize ); } inline int Size ( void ) { return ( m_cSize ); }
void Insert( int, float ); void Insert( int, float );
int Remove( float &); int Remove( float &);
private: private:
int m_cSize; int m_cSize;
struct tag_HEAP_NODE struct tag_HEAP_NODE
{ {
int Id; int Id;
float Priority; float Priority;
} m_heap[ MAX_STACK_NODES ]; } m_heap[ MAX_STACK_NODES ];
void Heap_SiftDown(int); void Heap_SiftDown(int);
void Heap_SiftUp(void); void Heap_SiftUp(void);
}; };
//========================================================= //=========================================================
// hints - these MUST coincide with the HINTS listed under // hints - these MUST coincide with the HINTS listed under
// info_node in the FGD file! // info_node in the FGD file!
//========================================================= //=========================================================
enum enum
{ {
HINT_NONE = 0, HINT_NONE = 0,
HINT_WORLD_DOOR, HINT_WORLD_DOOR,
HINT_WORLD_WINDOW, HINT_WORLD_WINDOW,
HINT_WORLD_BUTTON, HINT_WORLD_BUTTON,
HINT_WORLD_MACHINERY, HINT_WORLD_MACHINERY,
HINT_WORLD_LEDGE, HINT_WORLD_LEDGE,
HINT_WORLD_LIGHT_SOURCE, HINT_WORLD_LIGHT_SOURCE,
HINT_WORLD_HEAT_SOURCE, HINT_WORLD_HEAT_SOURCE,
HINT_WORLD_BLINKING_LIGHT, HINT_WORLD_BLINKING_LIGHT,
HINT_WORLD_BRIGHT_COLORS, HINT_WORLD_BRIGHT_COLORS,
HINT_WORLD_HUMAN_BLOOD, HINT_WORLD_HUMAN_BLOOD,
HINT_WORLD_ALIEN_BLOOD, HINT_WORLD_ALIEN_BLOOD,
HINT_TACTICAL_EXIT = 100, HINT_TACTICAL_EXIT = 100,
HINT_TACTICAL_VANTAGE, HINT_TACTICAL_VANTAGE,
HINT_TACTICAL_AMBUSH, HINT_TACTICAL_AMBUSH,
HINT_STUKA_PERCH = 300, HINT_STUKA_PERCH = 300,
HINT_STUKA_LANDING, HINT_STUKA_LANDING,
}; };
extern CGraph WorldGraph; extern CGraph WorldGraph;

View File

@@ -1,329 +1,329 @@
// HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository! // HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository!
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// monster template // monster template
//========================================================= //=========================================================
// UNDONE: Holster weapon? // UNDONE: Holster weapon?
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "schedule.h" #include "schedule.h"
#include "defaultai.h" #include "defaultai.h"
#include "weapons.h" #include "weapons.h"
#define NUM_OTIS_HEADS 2 // heads available for otis model #define NUM_OTIS_HEADS 2 // heads available for otis model
#define GUN_GROUP 1 #define GUN_GROUP 1
#define HEAD_GROUP 2 #define HEAD_GROUP 2
#define HEAD_HAIR 0 #define HEAD_HAIR 0
#define HEAD_BALD 1 #define HEAD_BALD 1
#define GUN_NONE 0 #define GUN_NONE 0
#define GUN_EAGLE 1 #define GUN_EAGLE 1
#define GUN_DONUT 2 #define GUN_DONUT 2
//========================================================= //=========================================================
// Monster's Anim Events Go Here // Monster's Anim Events Go Here
//========================================================= //=========================================================
// first flag is Otis dying for scripted sequences? // first flag is Otis dying for scripted sequences?
#define OTIS_AE_DRAW ( 2 ) #define OTIS_AE_DRAW ( 2 )
#define OTIS_AE_SHOOT ( 3 ) #define OTIS_AE_SHOOT ( 3 )
#define OTIS_AE_HOLSTER ( 4 ) #define OTIS_AE_HOLSTER ( 4 )
#define OTIS_BODY_GUNHOLSTERED 0 #define OTIS_BODY_GUNHOLSTERED 0
#define OTIS_BODY_GUNDRAWN 1 #define OTIS_BODY_GUNDRAWN 1
#define OTIS_BODY_DONUT 2 #define OTIS_BODY_DONUT 2
//========================================================= //=========================================================
// ALertSound - otis says "Freeze!" // ALertSound - otis says "Freeze!"
//========================================================= //=========================================================
void CMOtis::AlertSound(void) void CMOtis::AlertSound(void)
{ {
if (m_hEnemy != 0) if (m_hEnemy != 0)
{ {
if (FOkToSpeak()) if (FOkToSpeak())
{ {
PlaySentence("OT_ATTACK", RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE); PlaySentence("OT_ATTACK", RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE);
} }
} }
} }
//========================================================= //=========================================================
// BarneyFirePistol - shoots one round from the pistol at // BarneyFirePistol - shoots one round from the pistol at
// the enemy otis is facing. // the enemy otis is facing.
//========================================================= //=========================================================
void CMOtis::BarneyFirePistol(void) void CMOtis::BarneyFirePistol(void)
{ {
Vector vecShootOrigin; Vector vecShootOrigin;
UTIL_MakeVectors(pev->angles); UTIL_MakeVectors(pev->angles);
vecShootOrigin = pev->origin + Vector(0, 0, 55); vecShootOrigin = pev->origin + Vector(0, 0, 55);
Vector vecShootDir = ShootAtEnemy(vecShootOrigin); Vector vecShootDir = ShootAtEnemy(vecShootOrigin);
Vector angDir = UTIL_VecToAngles(vecShootDir); Vector angDir = UTIL_VecToAngles(vecShootDir);
SetBlending(0, angDir.x); SetBlending(0, angDir.x);
pev->effects = EF_MUZZLEFLASH; pev->effects = EF_MUZZLEFLASH;
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_357); FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_357);
int pitchShift = RANDOM_LONG(0, 20); int pitchShift = RANDOM_LONG(0, 20);
// Only shift about half the time // Only shift about half the time
if (pitchShift > 10) if (pitchShift > 10)
pitchShift = 0; pitchShift = 0;
else else
pitchShift -= 5; pitchShift -= 5;
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "weapons/desert_eagle_fire.wav", 1, ATTN_NORM, 0, 100 + pitchShift); EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "weapons/desert_eagle_fire.wav", 1, ATTN_NORM, 0, 100 + pitchShift);
// UNDONE: Reload? // UNDONE: Reload?
m_cAmmoLoaded--;// take away a bullet! m_cAmmoLoaded--;// take away a bullet!
} }
//========================================================= //=========================================================
// HandleAnimEvent - catches the monster-specific messages // HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played. // that occur when tagged animation frames are played.
// //
// Returns number of events handled, 0 if none. // Returns number of events handled, 0 if none.
//========================================================= //=========================================================
void CMOtis::HandleAnimEvent(MonsterEvent_t *pEvent) void CMOtis::HandleAnimEvent(MonsterEvent_t *pEvent)
{ {
switch (pEvent->event) switch (pEvent->event)
{ {
case OTIS_AE_SHOOT: case OTIS_AE_SHOOT:
BarneyFirePistol(); BarneyFirePistol();
break; break;
case OTIS_AE_DRAW: case OTIS_AE_DRAW:
// otis' bodygroup switches here so he can pull gun from holster // otis' bodygroup switches here so he can pull gun from holster
// pev->body = OTIS_BODY_GUNDRAWN; // pev->body = OTIS_BODY_GUNDRAWN;
SetBodygroup( GUN_GROUP, GUN_EAGLE ); SetBodygroup( GUN_GROUP, GUN_EAGLE );
m_fGunDrawn = TRUE; m_fGunDrawn = TRUE;
break; break;
case OTIS_AE_HOLSTER: case OTIS_AE_HOLSTER:
// change bodygroup to replace gun in holster // change bodygroup to replace gun in holster
// pev->body = OTIS_BODY_GUNHOLSTERED; // pev->body = OTIS_BODY_GUNHOLSTERED;
SetBodygroup( GUN_GROUP, GUN_NONE ); SetBodygroup( GUN_GROUP, GUN_NONE );
m_fGunDrawn = FALSE; m_fGunDrawn = FALSE;
break; break;
default: default:
CMBarney::HandleAnimEvent(pEvent); CMBarney::HandleAnimEvent(pEvent);
} }
} }
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CMOtis::Spawn() void CMOtis::Spawn()
{ {
Precache(); Precache();
SET_MODEL(ENT(pev), "models/otis.mdl"); SET_MODEL(ENT(pev), "models/otis.mdl");
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_RED; m_bloodColor = BLOOD_COLOR_RED;
pev->health = gSkillData.otisHealth; pev->health = gSkillData.otisHealth;
pev->view_ofs = Vector(0, 0, 50);// position of the eyes relative to monster's origin. pev->view_ofs = Vector(0, 0, 50);// position of the eyes relative to monster's origin.
m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello
m_MonsterState = MONSTERSTATE_NONE; m_MonsterState = MONSTERSTATE_NONE;
pev->body = 0; // gun in holster pev->body = 0; // gun in holster
m_fGunDrawn = FALSE; m_fGunDrawn = FALSE;
m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP;
// Make sure hands are white. // Make sure hands are white.
pev->skin = 0; pev->skin = 0;
// Select a random head. // Select a random head.
if (head == -1) if (head == -1)
{ {
SetBodygroup(HEAD_GROUP, RANDOM_LONG(0, NUM_OTIS_HEADS - 1)); SetBodygroup(HEAD_GROUP, RANDOM_LONG(0, NUM_OTIS_HEADS - 1));
} }
else else
{ {
SetBodygroup(HEAD_GROUP, head); SetBodygroup(HEAD_GROUP, head);
} }
if (bodystate == -1) if (bodystate == -1)
{ {
SetBodygroup(GUN_GROUP, RANDOM_LONG(OTIS_BODY_GUNHOLSTERED, OTIS_BODY_GUNDRAWN)); // don't random donut SetBodygroup(GUN_GROUP, RANDOM_LONG(OTIS_BODY_GUNHOLSTERED, OTIS_BODY_GUNDRAWN)); // don't random donut
} }
else else
{ {
SetBodygroup(GUN_GROUP, bodystate); SetBodygroup(GUN_GROUP, bodystate);
} }
MonsterInit(); MonsterInit();
pev->classname = MAKE_STRING( "monster_otis" ); pev->classname = MAKE_STRING( "monster_otis" );
if ( strlen( STRING( m_szMonsterName ) ) == 0 ) if ( strlen( STRING( m_szMonsterName ) ) == 0 )
{ {
// default name // default name
m_szMonsterName = MAKE_STRING( "Otis" ); m_szMonsterName = MAKE_STRING( "Otis" );
} }
} }
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CMOtis::Precache() void CMOtis::Precache()
{ {
PRECACHE_MODEL("models/otis.mdl"); PRECACHE_MODEL("models/otis.mdl");
PRECACHE_SOUND("weapons/desert_eagle_fire.wav"); PRECACHE_SOUND("weapons/desert_eagle_fire.wav");
PRECACHE_SOUND("barney/ba_pain1.wav"); PRECACHE_SOUND("barney/ba_pain1.wav");
PRECACHE_SOUND("barney/ba_pain2.wav"); PRECACHE_SOUND("barney/ba_pain2.wav");
PRECACHE_SOUND("barney/ba_pain3.wav"); PRECACHE_SOUND("barney/ba_pain3.wav");
PRECACHE_SOUND("barney/ba_die1.wav"); PRECACHE_SOUND("barney/ba_die1.wav");
PRECACHE_SOUND("barney/ba_die2.wav"); PRECACHE_SOUND("barney/ba_die2.wav");
PRECACHE_SOUND("barney/ba_die3.wav"); PRECACHE_SOUND("barney/ba_die3.wav");
// every new otis must call this, otherwise // every new otis must call this, otherwise
// when a level is loaded, nobody will talk (time is reset to 0) // when a level is loaded, nobody will talk (time is reset to 0)
TalkInit(); TalkInit();
CMTalkMonster::Precache(); CMTalkMonster::Precache();
} }
// Init talk data // Init talk data
void CMOtis::TalkInit() void CMOtis::TalkInit()
{ {
CMTalkMonster::TalkInit(); CMTalkMonster::TalkInit();
// scientists speach group names (group names are in sentences.txt) // scientists speach group names (group names are in sentences.txt)
m_szGrp[TLK_ANSWER] = "OT_ANSWER"; m_szGrp[TLK_ANSWER] = "OT_ANSWER";
m_szGrp[TLK_QUESTION] = "OT_QUESTION"; m_szGrp[TLK_QUESTION] = "OT_QUESTION";
m_szGrp[TLK_IDLE] = "OT_IDLE"; m_szGrp[TLK_IDLE] = "OT_IDLE";
m_szGrp[TLK_STARE] = "OT_STARE"; m_szGrp[TLK_STARE] = "OT_STARE";
m_szGrp[TLK_USE] = "OT_OK"; m_szGrp[TLK_USE] = "OT_OK";
m_szGrp[TLK_UNUSE] = "OT_WAIT"; m_szGrp[TLK_UNUSE] = "OT_WAIT";
m_szGrp[TLK_STOP] = "OT_STOP"; m_szGrp[TLK_STOP] = "OT_STOP";
m_szGrp[TLK_NOSHOOT] = "OT_SCARED"; m_szGrp[TLK_NOSHOOT] = "OT_SCARED";
m_szGrp[TLK_HELLO] = "OT_HELLO"; m_szGrp[TLK_HELLO] = "OT_HELLO";
m_szGrp[TLK_PLHURT1] = "!OT_CUREA"; m_szGrp[TLK_PLHURT1] = "!OT_CUREA";
m_szGrp[TLK_PLHURT2] = "!OT_CUREB"; m_szGrp[TLK_PLHURT2] = "!OT_CUREB";
m_szGrp[TLK_PLHURT3] = "!OT_CUREC"; m_szGrp[TLK_PLHURT3] = "!OT_CUREC";
m_szGrp[TLK_PHELLO] = NULL; m_szGrp[TLK_PHELLO] = NULL;
m_szGrp[TLK_PIDLE] = NULL; m_szGrp[TLK_PIDLE] = NULL;
m_szGrp[TLK_PQUESTION] = NULL; m_szGrp[TLK_PQUESTION] = NULL;
m_szGrp[TLK_SMELL] = "OT_SMELL"; m_szGrp[TLK_SMELL] = "OT_SMELL";
m_szGrp[TLK_WOUND] = "OT_WOUND"; m_szGrp[TLK_WOUND] = "OT_WOUND";
m_szGrp[TLK_MORTAL] = "OT_MORTAL"; m_szGrp[TLK_MORTAL] = "OT_MORTAL";
// get voice for head - just one otis voice for now // get voice for head - just one otis voice for now
m_voicePitch = 100; m_voicePitch = 100;
} }
int CMOtis::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) int CMOtis::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType)
{ {
// make sure friends talk about it if player hurts talkmonsters... // make sure friends talk about it if player hurts talkmonsters...
int ret = CMTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); int ret = CMTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);
if (!IsAlive() || pev->deadflag == DEAD_DYING) if (!IsAlive() || pev->deadflag == DEAD_DYING)
return ret; return ret;
if (m_MonsterState != MONSTERSTATE_PRONE && (pevAttacker->flags & FL_CLIENT)) if (m_MonsterState != MONSTERSTATE_PRONE && (pevAttacker->flags & FL_CLIENT))
{ {
// This is a heurstic to determine if the player intended to harm me // This is a heurstic to determine if the player intended to harm me
// If I have an enemy, we can't establish intent (may just be crossfire) // If I have an enemy, we can't establish intent (may just be crossfire)
if ( ( m_hEnemy != NULL ) && UTIL_IsPlayer(m_hEnemy) ) if ( ( m_hEnemy != NULL ) && UTIL_IsPlayer(m_hEnemy) )
{ {
Remember( bits_MEMORY_PROVOKED ); Remember( bits_MEMORY_PROVOKED );
} }
} }
return ret; return ret;
} }
void CMOtis::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) void CMOtis::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType)
{ {
switch (ptr->iHitgroup) switch (ptr->iHitgroup)
{ {
case HITGROUP_CHEST: case HITGROUP_CHEST:
case HITGROUP_STOMACH: case HITGROUP_STOMACH:
if (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST)) if (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST))
{ {
flDamage = flDamage / 2; flDamage = flDamage / 2;
} }
break; break;
case 10: // Otis wears no helmet, so do not prevent taking headshot damage. case 10: // Otis wears no helmet, so do not prevent taking headshot damage.
// always a head shot // always a head shot
ptr->iHitgroup = HITGROUP_HEAD; ptr->iHitgroup = HITGROUP_HEAD;
break; break;
default: default:
break; break;
} }
CMTalkMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType); CMTalkMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType);
} }
void CMOtis::Killed(entvars_t *pevAttacker, int iGib) void CMOtis::Killed(entvars_t *pevAttacker, int iGib)
{ {
if (GetBodygroup(GUN_GROUP) != OTIS_BODY_GUNHOLSTERED) if (GetBodygroup(GUN_GROUP) != OTIS_BODY_GUNHOLSTERED)
{ {
// drop the gun! // drop the gun!
SetBodygroup(GUN_GROUP, OTIS_BODY_GUNHOLSTERED); SetBodygroup(GUN_GROUP, OTIS_BODY_GUNHOLSTERED);
} }
CMTalkMonster::Killed(pevAttacker, iGib); CMTalkMonster::Killed(pevAttacker, iGib);
} }
//========================================================= //=========================================================
// AI Schedules Specific to this monster // AI Schedules Specific to this monster
//========================================================= //=========================================================
//========================================================= //=========================================================
// GetSchedule - Decides which type of schedule best suits // GetSchedule - Decides which type of schedule best suits
// the monster's current state and conditions. Then calls // the monster's current state and conditions. Then calls
// monster's member function to get a pointer to a schedule // monster's member function to get a pointer to a schedule
// of the proper type. // of the proper type.
//========================================================= //=========================================================
Schedule_t *CMOtis::GetSchedule(void) Schedule_t *CMOtis::GetSchedule(void)
{ {
if (HasConditions(bits_COND_ENEMY_DEAD) && FOkToSpeak()) if (HasConditions(bits_COND_ENEMY_DEAD) && FOkToSpeak())
{ {
PlaySentence("OT_KILL", 4, VOL_NORM, ATTN_NORM); PlaySentence("OT_KILL", 4, VOL_NORM, ATTN_NORM);
} }
return CMBarney::GetSchedule(); return CMBarney::GetSchedule();
} }
void CMOtis::KeyValue(KeyValueData *pkvd) void CMOtis::KeyValue(KeyValueData *pkvd)
{ {
if (FStrEq(pkvd->szKeyName, "head")) if (FStrEq(pkvd->szKeyName, "head"))
{ {
head = atoi(pkvd->szValue); head = atoi(pkvd->szValue);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
CMBarney::KeyValue(pkvd); CMBarney::KeyValue(pkvd);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,43 +1,43 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef PLANE_H #ifndef PLANE_H
#define PLANE_H #define PLANE_H
//========================================================= //=========================================================
// Plane // Plane
//========================================================= //=========================================================
class CPlane class CPlane
{ {
public: public:
CPlane ( void ); CPlane ( void );
//========================================================= //=========================================================
// InitializePlane - Takes a normal for the plane and a // InitializePlane - Takes a normal for the plane and a
// point on the plane and // point on the plane and
//========================================================= //=========================================================
void InitializePlane ( const Vector &vecNormal, const Vector &vecPoint ); void InitializePlane ( const Vector &vecNormal, const Vector &vecPoint );
//========================================================= //=========================================================
// PointInFront - determines whether the given vector is // PointInFront - determines whether the given vector is
// in front of the plane. // in front of the plane.
//========================================================= //=========================================================
BOOL PointInFront ( const Vector &vecPoint ); BOOL PointInFront ( const Vector &vecPoint );
Vector m_vecNormal; Vector m_vecNormal;
float m_flDist; float m_flDist;
BOOL m_fInitialized; BOOL m_fInitialized;
}; };
#endif // PLANE_H #endif // PLANE_H

View File

@@ -1,290 +1,290 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// Scheduling // Scheduling
//========================================================= //=========================================================
#ifndef SCHEDULE_H #ifndef SCHEDULE_H
#define SCHEDULE_H #define SCHEDULE_H
#define TASKSTATUS_NEW 0 // Just started #define TASKSTATUS_NEW 0 // Just started
#define TASKSTATUS_RUNNING 1 // Running task & movement #define TASKSTATUS_RUNNING 1 // Running task & movement
#define TASKSTATUS_RUNNING_MOVEMENT 2 // Just running movement #define TASKSTATUS_RUNNING_MOVEMENT 2 // Just running movement
#define TASKSTATUS_RUNNING_TASK 3 // Just running task #define TASKSTATUS_RUNNING_TASK 3 // Just running task
#define TASKSTATUS_COMPLETE 4 // Completed, get next task #define TASKSTATUS_COMPLETE 4 // Completed, get next task
//========================================================= //=========================================================
// These are the schedule types // These are the schedule types
//========================================================= //=========================================================
typedef enum typedef enum
{ {
SCHED_NONE = 0, SCHED_NONE = 0,
SCHED_IDLE_STAND, SCHED_IDLE_STAND,
SCHED_IDLE_WALK, SCHED_IDLE_WALK,
SCHED_WAKE_ANGRY, SCHED_WAKE_ANGRY,
SCHED_WAKE_CALLED, SCHED_WAKE_CALLED,
SCHED_ALERT_FACE, SCHED_ALERT_FACE,
SCHED_ALERT_SMALL_FLINCH, SCHED_ALERT_SMALL_FLINCH,
SCHED_ALERT_BIG_FLINCH, SCHED_ALERT_BIG_FLINCH,
SCHED_ALERT_STAND, SCHED_ALERT_STAND,
SCHED_INVESTIGATE_SOUND, SCHED_INVESTIGATE_SOUND,
SCHED_COMBAT_FACE, SCHED_COMBAT_FACE,
SCHED_COMBAT_STAND, SCHED_COMBAT_STAND,
SCHED_CHASE_ENEMY, SCHED_CHASE_ENEMY,
SCHED_CHASE_ENEMY_FAILED, SCHED_CHASE_ENEMY_FAILED,
SCHED_VICTORY_DANCE, SCHED_VICTORY_DANCE,
SCHED_TARGET_FACE, SCHED_TARGET_FACE,
SCHED_TARGET_CHASE, SCHED_TARGET_CHASE,
SCHED_SMALL_FLINCH, SCHED_SMALL_FLINCH,
SCHED_TAKE_COVER_FROM_ENEMY, SCHED_TAKE_COVER_FROM_ENEMY,
SCHED_TAKE_COVER_FROM_BEST_SOUND, SCHED_TAKE_COVER_FROM_BEST_SOUND,
SCHED_TAKE_COVER_FROM_ORIGIN, SCHED_TAKE_COVER_FROM_ORIGIN,
SCHED_COWER, // usually a last resort! SCHED_COWER, // usually a last resort!
SCHED_MELEE_ATTACK1, SCHED_MELEE_ATTACK1,
SCHED_MELEE_ATTACK2, SCHED_MELEE_ATTACK2,
SCHED_RANGE_ATTACK1, SCHED_RANGE_ATTACK1,
SCHED_RANGE_ATTACK2, SCHED_RANGE_ATTACK2,
SCHED_SPECIAL_ATTACK1, SCHED_SPECIAL_ATTACK1,
SCHED_SPECIAL_ATTACK2, SCHED_SPECIAL_ATTACK2,
SCHED_STANDOFF, SCHED_STANDOFF,
SCHED_ARM_WEAPON, SCHED_ARM_WEAPON,
SCHED_RELOAD, SCHED_RELOAD,
SCHED_GUARD, SCHED_GUARD,
SCHED_AMBUSH, SCHED_AMBUSH,
SCHED_DIE, SCHED_DIE,
SCHED_WAIT_TRIGGER, SCHED_WAIT_TRIGGER,
SCHED_FOLLOW, SCHED_FOLLOW,
SCHED_SLEEP, SCHED_SLEEP,
SCHED_WAKE, SCHED_WAKE,
SCHED_BARNACLE_VICTIM_GRAB, SCHED_BARNACLE_VICTIM_GRAB,
SCHED_BARNACLE_VICTIM_CHOMP, SCHED_BARNACLE_VICTIM_CHOMP,
SCHED_AISCRIPT, SCHED_AISCRIPT,
SCHED_FAIL, SCHED_FAIL,
LAST_COMMON_SCHEDULE // Leave this at the bottom LAST_COMMON_SCHEDULE // Leave this at the bottom
} SCHEDULE_TYPE; } SCHEDULE_TYPE;
//========================================================= //=========================================================
// These are the shared tasks // These are the shared tasks
//========================================================= //=========================================================
typedef enum typedef enum
{ {
TASK_INVALID = 0, TASK_INVALID = 0,
TASK_WAIT, TASK_WAIT,
TASK_WAIT_FACE_ENEMY, TASK_WAIT_FACE_ENEMY,
TASK_WAIT_PVS, TASK_WAIT_PVS,
TASK_SUGGEST_STATE, TASK_SUGGEST_STATE,
TASK_WALK_TO_TARGET, TASK_WALK_TO_TARGET,
TASK_RUN_TO_TARGET, TASK_RUN_TO_TARGET,
TASK_MOVE_TO_TARGET_RANGE, TASK_MOVE_TO_TARGET_RANGE,
TASK_GET_PATH_TO_ENEMY, TASK_GET_PATH_TO_ENEMY,
TASK_GET_PATH_TO_ENEMY_LKP, TASK_GET_PATH_TO_ENEMY_LKP,
TASK_GET_PATH_TO_ENEMY_CORPSE, TASK_GET_PATH_TO_ENEMY_CORPSE,
TASK_GET_PATH_TO_LEADER, TASK_GET_PATH_TO_LEADER,
TASK_GET_PATH_TO_SPOT, TASK_GET_PATH_TO_SPOT,
TASK_GET_PATH_TO_TARGET, TASK_GET_PATH_TO_TARGET,
TASK_GET_PATH_TO_HINTNODE, TASK_GET_PATH_TO_HINTNODE,
TASK_GET_PATH_TO_LASTPOSITION, TASK_GET_PATH_TO_LASTPOSITION,
TASK_GET_PATH_TO_BESTSOUND, TASK_GET_PATH_TO_BESTSOUND,
TASK_GET_PATH_TO_BESTSCENT, TASK_GET_PATH_TO_BESTSCENT,
TASK_RUN_PATH, TASK_RUN_PATH,
TASK_WALK_PATH, TASK_WALK_PATH,
TASK_STRAFE_PATH, TASK_STRAFE_PATH,
TASK_CLEAR_MOVE_WAIT, TASK_CLEAR_MOVE_WAIT,
TASK_STORE_LASTPOSITION, TASK_STORE_LASTPOSITION,
TASK_CLEAR_LASTPOSITION, TASK_CLEAR_LASTPOSITION,
TASK_PLAY_ACTIVE_IDLE, TASK_PLAY_ACTIVE_IDLE,
TASK_FIND_HINTNODE, TASK_FIND_HINTNODE,
TASK_CLEAR_HINTNODE, TASK_CLEAR_HINTNODE,
TASK_SMALL_FLINCH, TASK_SMALL_FLINCH,
TASK_FACE_IDEAL, TASK_FACE_IDEAL,
TASK_FACE_ROUTE, TASK_FACE_ROUTE,
TASK_FACE_ENEMY, TASK_FACE_ENEMY,
TASK_FACE_HINTNODE, TASK_FACE_HINTNODE,
TASK_FACE_TARGET, TASK_FACE_TARGET,
TASK_FACE_LASTPOSITION, TASK_FACE_LASTPOSITION,
TASK_RANGE_ATTACK1, TASK_RANGE_ATTACK1,
TASK_RANGE_ATTACK2, TASK_RANGE_ATTACK2,
TASK_MELEE_ATTACK1, TASK_MELEE_ATTACK1,
TASK_MELEE_ATTACK2, TASK_MELEE_ATTACK2,
TASK_RELOAD, TASK_RELOAD,
TASK_RANGE_ATTACK1_NOTURN, TASK_RANGE_ATTACK1_NOTURN,
TASK_RANGE_ATTACK2_NOTURN, TASK_RANGE_ATTACK2_NOTURN,
TASK_MELEE_ATTACK1_NOTURN, TASK_MELEE_ATTACK1_NOTURN,
TASK_MELEE_ATTACK2_NOTURN, TASK_MELEE_ATTACK2_NOTURN,
TASK_RELOAD_NOTURN, TASK_RELOAD_NOTURN,
TASK_SPECIAL_ATTACK1, TASK_SPECIAL_ATTACK1,
TASK_SPECIAL_ATTACK2, TASK_SPECIAL_ATTACK2,
TASK_CROUCH, TASK_CROUCH,
TASK_STAND, TASK_STAND,
TASK_GUARD, TASK_GUARD,
TASK_STEP_LEFT, TASK_STEP_LEFT,
TASK_STEP_RIGHT, TASK_STEP_RIGHT,
TASK_STEP_FORWARD, TASK_STEP_FORWARD,
TASK_STEP_BACK, TASK_STEP_BACK,
TASK_DODGE_LEFT, TASK_DODGE_LEFT,
TASK_DODGE_RIGHT, TASK_DODGE_RIGHT,
TASK_SOUND_ANGRY, TASK_SOUND_ANGRY,
TASK_SOUND_DEATH, TASK_SOUND_DEATH,
TASK_SET_ACTIVITY, TASK_SET_ACTIVITY,
TASK_SET_SCHEDULE, TASK_SET_SCHEDULE,
TASK_SET_FAIL_SCHEDULE, TASK_SET_FAIL_SCHEDULE,
TASK_CLEAR_FAIL_SCHEDULE, TASK_CLEAR_FAIL_SCHEDULE,
TASK_PLAY_SEQUENCE, TASK_PLAY_SEQUENCE,
TASK_PLAY_SEQUENCE_FACE_ENEMY, TASK_PLAY_SEQUENCE_FACE_ENEMY,
TASK_PLAY_SEQUENCE_FACE_TARGET, TASK_PLAY_SEQUENCE_FACE_TARGET,
TASK_SOUND_IDLE, TASK_SOUND_IDLE,
TASK_SOUND_WAKE, TASK_SOUND_WAKE,
TASK_SOUND_PAIN, TASK_SOUND_PAIN,
TASK_SOUND_DIE, TASK_SOUND_DIE,
TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover
TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover
TASK_FIND_LATERAL_COVER_FROM_ENEMY, TASK_FIND_LATERAL_COVER_FROM_ENEMY,
TASK_FIND_NODE_COVER_FROM_ENEMY, TASK_FIND_NODE_COVER_FROM_ENEMY,
TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover. TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover.
TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover. TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover.
TASK_FIND_COVER_FROM_ORIGIN, TASK_FIND_COVER_FROM_ORIGIN,
TASK_EAT, TASK_EAT,
TASK_DIE, TASK_DIE,
TASK_WAIT_FOR_SCRIPT, TASK_WAIT_FOR_SCRIPT,
TASK_PLAY_SCRIPT, TASK_PLAY_SCRIPT,
TASK_ENABLE_SCRIPT, TASK_ENABLE_SCRIPT,
TASK_PLANT_ON_SCRIPT, TASK_PLANT_ON_SCRIPT,
TASK_FACE_SCRIPT, TASK_FACE_SCRIPT,
TASK_WAIT_RANDOM, TASK_WAIT_RANDOM,
TASK_WAIT_INDEFINITE, TASK_WAIT_INDEFINITE,
TASK_STOP_MOVING, TASK_STOP_MOVING,
TASK_TURN_LEFT, TASK_TURN_LEFT,
TASK_TURN_RIGHT, TASK_TURN_RIGHT,
TASK_REMEMBER, TASK_REMEMBER,
TASK_FORGET, TASK_FORGET,
TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete() TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete()
LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM!! (sjb) LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM!! (sjb)
} SHARED_TASKS; } SHARED_TASKS;
// These go in the flData member of the TASK_WALK_TO_TARGET, TASK_RUN_TO_TARGET // These go in the flData member of the TASK_WALK_TO_TARGET, TASK_RUN_TO_TARGET
enum enum
{ {
TARGET_MOVE_NORMAL = 0, TARGET_MOVE_NORMAL = 0,
TARGET_MOVE_SCRIPTED = 1, TARGET_MOVE_SCRIPTED = 1,
}; };
// A goal should be used for a task that requires several schedules to complete. // A goal should be used for a task that requires several schedules to complete.
// The goal index should indicate which schedule (ordinally) the monster is running. // The goal index should indicate which schedule (ordinally) the monster is running.
// That way, when tasks fail, the AI can make decisions based on the context of the // That way, when tasks fail, the AI can make decisions based on the context of the
// current goal and sequence rather than just the current schedule. // current goal and sequence rather than just the current schedule.
enum enum
{ {
GOAL_ATTACK_ENEMY, GOAL_ATTACK_ENEMY,
GOAL_MOVE, GOAL_MOVE,
GOAL_TAKE_COVER, GOAL_TAKE_COVER,
GOAL_MOVE_TARGET, GOAL_MOVE_TARGET,
GOAL_EAT, GOAL_EAT,
}; };
// an array of tasks is a task list // an array of tasks is a task list
// an array of schedules is a schedule list // an array of schedules is a schedule list
struct Task_t struct Task_t
{ {
int iTask; int iTask;
float flData; float flData;
}; };
struct Schedule_t struct Schedule_t
{ {
Task_t *pTasklist; Task_t *pTasklist;
int cTasks; int cTasks;
int iInterruptMask;// a bit mask of conditions that can interrupt this schedule int iInterruptMask;// a bit mask of conditions that can interrupt this schedule
// a more specific mask that indicates which TYPES of sounds will interrupt the schedule in the // a more specific mask that indicates which TYPES of sounds will interrupt the schedule in the
// event that the schedule is broken by COND_HEAR_SOUND // event that the schedule is broken by COND_HEAR_SOUND
int iSoundMask; int iSoundMask;
const char *pName; const char *pName;
}; };
// an array of waypoints makes up the monster's route. // an array of waypoints makes up the monster's route.
// !!!LATER- this declaration doesn't belong in this file. // !!!LATER- this declaration doesn't belong in this file.
struct WayPoint_t struct WayPoint_t
{ {
Vector vecLocation; Vector vecLocation;
int iType; int iType;
}; };
// these MoveFlag values are assigned to a WayPoint's TYPE in order to demonstrate the // these MoveFlag values are assigned to a WayPoint's TYPE in order to demonstrate the
// type of movement the monster should use to get there. // type of movement the monster should use to get there.
#define bits_MF_TO_TARGETENT ( 1 << 0 ) // local move to targetent. #define bits_MF_TO_TARGETENT ( 1 << 0 ) // local move to targetent.
#define bits_MF_TO_ENEMY ( 1 << 1 ) // local move to enemy #define bits_MF_TO_ENEMY ( 1 << 1 ) // local move to enemy
#define bits_MF_TO_COVER ( 1 << 2 ) // local move to a hiding place #define bits_MF_TO_COVER ( 1 << 2 ) // local move to a hiding place
#define bits_MF_TO_DETOUR ( 1 << 3 ) // local move to detour point. #define bits_MF_TO_DETOUR ( 1 << 3 ) // local move to detour point.
#define bits_MF_TO_PATHCORNER ( 1 << 4 ) // local move to a path corner #define bits_MF_TO_PATHCORNER ( 1 << 4 ) // local move to a path corner
#define bits_MF_TO_NODE ( 1 << 5 ) // local move to a node #define bits_MF_TO_NODE ( 1 << 5 ) // local move to a node
#define bits_MF_TO_LOCATION ( 1 << 6 ) // local move to an arbitrary point #define bits_MF_TO_LOCATION ( 1 << 6 ) // local move to an arbitrary point
#define bits_MF_IS_GOAL ( 1 << 7 ) // this waypoint is the goal of the whole move. #define bits_MF_IS_GOAL ( 1 << 7 ) // this waypoint is the goal of the whole move.
#define bits_MF_DONT_SIMPLIFY ( 1 << 8 ) // Don't let the route code simplify this waypoint #define bits_MF_DONT_SIMPLIFY ( 1 << 8 ) // Don't let the route code simplify this waypoint
// If you define any flags that aren't _TO_ flags, add them here so we can mask // If you define any flags that aren't _TO_ flags, add them here so we can mask
// them off when doing compares. // them off when doing compares.
#define bits_MF_NOT_TO_MASK (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY) #define bits_MF_NOT_TO_MASK (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY)
#define MOVEGOAL_NONE (0) #define MOVEGOAL_NONE (0)
#define MOVEGOAL_TARGETENT (bits_MF_TO_TARGETENT) #define MOVEGOAL_TARGETENT (bits_MF_TO_TARGETENT)
#define MOVEGOAL_ENEMY (bits_MF_TO_ENEMY) #define MOVEGOAL_ENEMY (bits_MF_TO_ENEMY)
#define MOVEGOAL_PATHCORNER (bits_MF_TO_PATHCORNER) #define MOVEGOAL_PATHCORNER (bits_MF_TO_PATHCORNER)
#define MOVEGOAL_LOCATION (bits_MF_TO_LOCATION) #define MOVEGOAL_LOCATION (bits_MF_TO_LOCATION)
#define MOVEGOAL_NODE (bits_MF_TO_NODE) #define MOVEGOAL_NODE (bits_MF_TO_NODE)
// these bits represent conditions that may befall the monster, of which some are allowed // these bits represent conditions that may befall the monster, of which some are allowed
// to interrupt certain schedules. // to interrupt certain schedules.
#define bits_COND_NO_AMMO_LOADED ( 1 << 0 ) // weapon needs to be reloaded! #define bits_COND_NO_AMMO_LOADED ( 1 << 0 ) // weapon needs to be reloaded!
#define bits_COND_SEE_HATE ( 1 << 1 ) // see something that you hate #define bits_COND_SEE_HATE ( 1 << 1 ) // see something that you hate
#define bits_COND_SEE_FEAR ( 1 << 2 ) // see something that you are afraid of #define bits_COND_SEE_FEAR ( 1 << 2 ) // see something that you are afraid of
#define bits_COND_SEE_DISLIKE ( 1 << 3 ) // see something that you dislike #define bits_COND_SEE_DISLIKE ( 1 << 3 ) // see something that you dislike
#define bits_COND_SEE_ENEMY ( 1 << 4 ) // target entity is in full view. #define bits_COND_SEE_ENEMY ( 1 << 4 ) // target entity is in full view.
#define bits_COND_ENEMY_OCCLUDED ( 1 << 5 ) // target entity occluded by the world #define bits_COND_ENEMY_OCCLUDED ( 1 << 5 ) // target entity occluded by the world
#define bits_COND_SMELL_FOOD ( 1 << 6 ) #define bits_COND_SMELL_FOOD ( 1 << 6 )
#define bits_COND_ENEMY_TOOFAR ( 1 << 7 ) #define bits_COND_ENEMY_TOOFAR ( 1 << 7 )
#define bits_COND_LIGHT_DAMAGE ( 1 << 8 ) // hurt a little #define bits_COND_LIGHT_DAMAGE ( 1 << 8 ) // hurt a little
#define bits_COND_HEAVY_DAMAGE ( 1 << 9 ) // hurt a lot #define bits_COND_HEAVY_DAMAGE ( 1 << 9 ) // hurt a lot
#define bits_COND_CAN_RANGE_ATTACK1 ( 1 << 10) #define bits_COND_CAN_RANGE_ATTACK1 ( 1 << 10)
#define bits_COND_CAN_MELEE_ATTACK1 ( 1 << 11) #define bits_COND_CAN_MELEE_ATTACK1 ( 1 << 11)
#define bits_COND_CAN_RANGE_ATTACK2 ( 1 << 12) #define bits_COND_CAN_RANGE_ATTACK2 ( 1 << 12)
#define bits_COND_CAN_MELEE_ATTACK2 ( 1 << 13) #define bits_COND_CAN_MELEE_ATTACK2 ( 1 << 13)
// #define bits_COND_CAN_RANGE_ATTACK3 ( 1 << 14) // #define bits_COND_CAN_RANGE_ATTACK3 ( 1 << 14)
#define bits_COND_PROVOKED ( 1 << 15) #define bits_COND_PROVOKED ( 1 << 15)
#define bits_COND_NEW_ENEMY ( 1 << 16) #define bits_COND_NEW_ENEMY ( 1 << 16)
#define bits_COND_HEAR_SOUND ( 1 << 17) // there is an interesting sound #define bits_COND_HEAR_SOUND ( 1 << 17) // there is an interesting sound
#define bits_COND_SMELL ( 1 << 18) // there is an interesting scent #define bits_COND_SMELL ( 1 << 18) // there is an interesting scent
#define bits_COND_ENEMY_FACING_ME ( 1 << 19) // enemy is facing me #define bits_COND_ENEMY_FACING_ME ( 1 << 19) // enemy is facing me
#define bits_COND_ENEMY_DEAD ( 1 << 20) // enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance. #define bits_COND_ENEMY_DEAD ( 1 << 20) // enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance.
#define bits_COND_SEE_CLIENT ( 1 << 21) // see a client #define bits_COND_SEE_CLIENT ( 1 << 21) // see a client
#define bits_COND_SEE_NEMESIS ( 1 << 22) // see my nemesis #define bits_COND_SEE_NEMESIS ( 1 << 22) // see my nemesis
#define bits_COND_SPECIAL1 ( 1 << 28) // Defined by individual monster #define bits_COND_SPECIAL1 ( 1 << 28) // Defined by individual monster
#define bits_COND_SPECIAL2 ( 1 << 29) // Defined by individual monster #define bits_COND_SPECIAL2 ( 1 << 29) // Defined by individual monster
#define bits_COND_TASK_FAILED ( 1 << 30) #define bits_COND_TASK_FAILED ( 1 << 30)
#define bits_COND_SCHEDULE_DONE ( 1 << 31) #define bits_COND_SCHEDULE_DONE ( 1 << 31)
#define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2) #define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2)
#define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) #define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2)
#endif // SCHEDULE_H #endif // SCHEDULE_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,233 +1,233 @@
// HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository! // HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository!
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// shock - projectile shot from shockrifles. // shock - projectile shot from shockrifles.
//========================================================= //=========================================================
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "schedule.h" #include "schedule.h"
#include "effects.h" #include "effects.h"
#include "decals.h" #include "decals.h"
#include "weapons.h" #include "weapons.h"
#include "customentity.h" #include "customentity.h"
#include "shock.h" #include "shock.h"
void CMShock::Spawn() void CMShock::Spawn()
{ {
Precache(); Precache();
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
pev->classname = MAKE_STRING("shock_beam"); pev->classname = MAKE_STRING("shock_beam");
SET_MODEL(ENT(pev), "models/shock_effect.mdl"); SET_MODEL(ENT(pev), "models/shock_effect.mdl");
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
pev->dmg = gSkillData.monDmgShockroach; pev->dmg = gSkillData.monDmgShockroach;
UTIL_SetSize(pev, Vector(-4, -4, -4), Vector(4, 4, 4)); UTIL_SetSize(pev, Vector(-4, -4, -4), Vector(4, 4, 4));
CreateEffects(); CreateEffects();
SetThink( &CMShock::FlyThink ); SetThink( &CMShock::FlyThink );
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
void CMShock::Precache() void CMShock::Precache()
{ {
PRECACHE_MODEL("sprites/flare3.spr"); PRECACHE_MODEL("sprites/flare3.spr");
PRECACHE_MODEL("sprites/lgtning.spr"); PRECACHE_MODEL("sprites/lgtning.spr");
PRECACHE_MODEL("models/shock_effect.mdl"); PRECACHE_MODEL("models/shock_effect.mdl");
PRECACHE_SOUND("weapons/shock_impact.wav"); PRECACHE_SOUND("weapons/shock_impact.wav");
} }
void CMShock::FlyThink() void CMShock::FlyThink()
{ {
if (pev->waterlevel == 3) if (pev->waterlevel == 3)
{ {
entvars_t *pevOwner = VARS(pev->owner); entvars_t *pevOwner = VARS(pev->owner);
EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/shock_impact.wav", VOL_NORM, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/shock_impact.wav", VOL_NORM, ATTN_NORM);
RadiusDamage(pev->origin, pev, pevOwner ? pevOwner : pev, pev->dmg * 3, 144, CLASS_NONE, DMG_SHOCK | DMG_ALWAYSGIB ); RadiusDamage(pev->origin, pev, pevOwner ? pevOwner : pev, pev->dmg * 3, 144, CLASS_NONE, DMG_SHOCK | DMG_ALWAYSGIB );
ClearEffects(); ClearEffects();
SetThink( &CMBaseEntity::SUB_Remove ); SetThink( &CMBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
else else
{ {
pev->nextthink = gpGlobals->time + 0.05; pev->nextthink = gpGlobals->time + 0.05;
} }
} }
edict_t *CMShock::Shoot(entvars_t *pevOwner, const Vector angles, const Vector vecStart, const Vector vecVelocity) edict_t *CMShock::Shoot(entvars_t *pevOwner, const Vector angles, const Vector vecStart, const Vector vecVelocity)
{ {
CMShock *pShock = CreateClassPtr((CMShock *)NULL); CMShock *pShock = CreateClassPtr((CMShock *)NULL);
if (pShock == NULL) if (pShock == NULL)
return NULL; return NULL;
UTIL_SetOrigin(pShock->pev, vecStart); UTIL_SetOrigin(pShock->pev, vecStart);
pShock->Spawn(); pShock->Spawn();
pShock->pev->velocity = vecVelocity; pShock->pev->velocity = vecVelocity;
pShock->pev->owner = ENT(pevOwner); pShock->pev->owner = ENT(pevOwner);
pShock->pev->angles = angles; pShock->pev->angles = angles;
pShock->pev->nextthink = gpGlobals->time; pShock->pev->nextthink = gpGlobals->time;
return pShock->edict(); return pShock->edict();
} }
void CMShock::Touch(edict_t *pOther) void CMShock::Touch(edict_t *pOther)
{ {
// Do not collide with the owner. // Do not collide with the owner.
if (pOther == pev->owner) if (pOther == pev->owner)
return; return;
TraceResult tr = UTIL_GetGlobalTrace( ); TraceResult tr = UTIL_GetGlobalTrace( );
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE(TE_DLIGHT); WRITE_BYTE(TE_DLIGHT);
WRITE_COORD(pev->origin.x); // X WRITE_COORD(pev->origin.x); // X
WRITE_COORD(pev->origin.y); // Y WRITE_COORD(pev->origin.y); // Y
WRITE_COORD(pev->origin.z); // Z WRITE_COORD(pev->origin.z); // Z
WRITE_BYTE( 8 ); // radius * 0.1 WRITE_BYTE( 8 ); // radius * 0.1
WRITE_BYTE( 0 ); // r WRITE_BYTE( 0 ); // r
WRITE_BYTE( 255 ); // g WRITE_BYTE( 255 ); // g
WRITE_BYTE( 255 ); // b WRITE_BYTE( 255 ); // b
WRITE_BYTE( 10 ); // time * 10 WRITE_BYTE( 10 ); // time * 10
WRITE_BYTE( 10 ); // decay * 0.1 WRITE_BYTE( 10 ); // decay * 0.1
MESSAGE_END( ); MESSAGE_END( );
ClearEffects(); ClearEffects();
if (!pOther->v.takedamage) if (!pOther->v.takedamage)
{ {
// make a splat on the wall // make a splat on the wall
const int baseDecal = DECAL_SCORCH1; const int baseDecal = DECAL_SCORCH1;
UTIL_DecalTrace(&tr, baseDecal + RANDOM_LONG(0, 1)); UTIL_DecalTrace(&tr, baseDecal + RANDOM_LONG(0, 1));
int iContents = UTIL_PointContents(pev->origin); int iContents = UTIL_PointContents(pev->origin);
// Create sparks // Create sparks
if (iContents != CONTENTS_WATER) if (iContents != CONTENTS_WATER)
{ {
UTIL_Sparks(tr.vecEndPos); UTIL_Sparks(tr.vecEndPos);
} }
} }
else else
{ {
int damageType = DMG_SHOCK; int damageType = DMG_SHOCK;
ClearMultiDamage(); ClearMultiDamage();
entvars_t *pevOwner = VARS(pev->owner); entvars_t *pevOwner = VARS(pev->owner);
entvars_t *pevAttacker = pevOwner ? pevOwner : pev; entvars_t *pevAttacker = pevOwner ? pevOwner : pev;
if ( UTIL_IsPlayer( pOther ) ) if ( UTIL_IsPlayer( pOther ) )
UTIL_TraceAttack( pOther, pevAttacker, pev->dmg, pev->velocity.Normalize(), &tr, damageType ); UTIL_TraceAttack( pOther, pevAttacker, pev->dmg, pev->velocity.Normalize(), &tr, damageType );
else if ( pOther->v.euser4 != NULL ) else if ( pOther->v.euser4 != NULL )
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
pMonster->TraceAttack( pevAttacker, pev->dmg, pev->velocity.Normalize(), &tr, damageType ); pMonster->TraceAttack( pevAttacker, pev->dmg, pev->velocity.Normalize(), &tr, damageType );
} }
ApplyMultiDamage(pev, pevAttacker); ApplyMultiDamage(pev, pevAttacker);
} }
// splat sound // splat sound
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/shock_impact.wav", VOL_NORM, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/shock_impact.wav", VOL_NORM, ATTN_NORM);
pev->modelindex = 0; pev->modelindex = 0;
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
SetThink( &CMBaseEntity::SUB_Remove ); SetThink( &CMBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time + 0.01; // let the sound play pev->nextthink = gpGlobals->time + 0.01; // let the sound play
} }
void CMShock::CreateEffects() void CMShock::CreateEffects()
{ {
m_pSprite = CMSprite::SpriteCreate( "sprites/flare3.spr", pev->origin, FALSE ); m_pSprite = CMSprite::SpriteCreate( "sprites/flare3.spr", pev->origin, FALSE );
m_pSprite->SetAttachment( edict(), 0 ); m_pSprite->SetAttachment( edict(), 0 );
m_pSprite->pev->scale = 0.35; m_pSprite->pev->scale = 0.35;
m_pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 170, kRenderFxNoDissipation ); m_pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 170, kRenderFxNoDissipation );
//m_pSprite->pev->spawnflags |= SF_SPRITE_TEMPORARY; //m_pSprite->pev->spawnflags |= SF_SPRITE_TEMPORARY;
//m_pSprite->pev->flags |= FL_SKIPLOCALHOST; //m_pSprite->pev->flags |= FL_SKIPLOCALHOST;
m_pBeam = CMBeam::BeamCreate( "sprites/lgtning.spr", 30 ); m_pBeam = CMBeam::BeamCreate( "sprites/lgtning.spr", 30 );
if (m_pBeam) if (m_pBeam)
{ {
m_pBeam->EntsInit( entindex(), entindex() ); m_pBeam->EntsInit( entindex(), entindex() );
m_pBeam->SetStartAttachment( 1 ); m_pBeam->SetStartAttachment( 1 );
m_pBeam->SetEndAttachment( 2 ); m_pBeam->SetEndAttachment( 2 );
m_pBeam->SetBrightness( 180 ); m_pBeam->SetBrightness( 180 );
m_pBeam->SetScrollRate( 10 ); m_pBeam->SetScrollRate( 10 );
m_pBeam->SetNoise( 0 ); m_pBeam->SetNoise( 0 );
m_pBeam->SetFlags( BEAM_FSHADEOUT ); m_pBeam->SetFlags( BEAM_FSHADEOUT );
m_pBeam->SetColor( 0, 255, 255 ); m_pBeam->SetColor( 0, 255, 255 );
//m_pBeam->pev->spawnflags = SF_BEAM_TEMPORARY; //m_pBeam->pev->spawnflags = SF_BEAM_TEMPORARY;
m_pBeam->RelinkBeam(); m_pBeam->RelinkBeam();
} }
else else
{ {
ALERT(at_console, "Could not create shockbeam beam!\n"); ALERT(at_console, "Could not create shockbeam beam!\n");
} }
m_pNoise = CMBeam::BeamCreate( "sprites/lgtning.spr", 30 ); m_pNoise = CMBeam::BeamCreate( "sprites/lgtning.spr", 30 );
if (m_pNoise) if (m_pNoise)
{ {
m_pNoise->EntsInit( entindex(), entindex() ); m_pNoise->EntsInit( entindex(), entindex() );
m_pNoise->SetStartAttachment( 1 ); m_pNoise->SetStartAttachment( 1 );
m_pNoise->SetEndAttachment( 2 ); m_pNoise->SetEndAttachment( 2 );
m_pNoise->SetBrightness( 180 ); m_pNoise->SetBrightness( 180 );
m_pNoise->SetScrollRate( 30 ); m_pNoise->SetScrollRate( 30 );
m_pNoise->SetNoise( 30 ); m_pNoise->SetNoise( 30 );
m_pNoise->SetFlags( BEAM_FSHADEOUT ); m_pNoise->SetFlags( BEAM_FSHADEOUT );
m_pNoise->SetColor( 255, 255, 173 ); m_pNoise->SetColor( 255, 255, 173 );
//m_pNoise->pev->spawnflags = SF_BEAM_TEMPORARY; //m_pNoise->pev->spawnflags = SF_BEAM_TEMPORARY;
m_pNoise->RelinkBeam(); m_pNoise->RelinkBeam();
} }
else else
{ {
ALERT(at_console, "Could not create shockbeam noise!\n"); ALERT(at_console, "Could not create shockbeam noise!\n");
} }
} }
void CMShock::ClearEffects() void CMShock::ClearEffects()
{ {
if (m_pBeam) if (m_pBeam)
{ {
UTIL_Remove( m_pBeam->edict() ); UTIL_Remove( m_pBeam->edict() );
m_pBeam = NULL; m_pBeam = NULL;
} }
if (m_pNoise) if (m_pNoise)
{ {
UTIL_Remove( m_pNoise->edict() ); UTIL_Remove( m_pNoise->edict() );
m_pNoise = NULL; m_pNoise = NULL;
} }
if (m_pSprite) if (m_pSprite)
{ {
UTIL_Remove( m_pSprite->edict() ); UTIL_Remove( m_pSprite->edict() );
m_pSprite = NULL; m_pSprite = NULL;
} }
} }
void CMShock::UpdateOnRemove() void CMShock::UpdateOnRemove()
{ {
CMBaseAnimating::UpdateOnRemove(); CMBaseAnimating::UpdateOnRemove();
ClearEffects(); ClearEffects();
} }

View File

@@ -1,25 +1,25 @@
#ifndef SHOCKBEAM_H #ifndef SHOCKBEAM_H
#define SHOCKBEAM_H #define SHOCKBEAM_H
//========================================================= //=========================================================
// Shockrifle projectile // Shockrifle projectile
//========================================================= //=========================================================
class CMShock : public CMBaseAnimating class CMShock : public CMBaseAnimating
{ {
public: public:
void Spawn(void); void Spawn(void);
void Precache(void); void Precache(void);
static edict_t *Shoot(entvars_t *pevOwner, const Vector angles, const Vector vecStart, const Vector vecVelocity); static edict_t *Shoot(entvars_t *pevOwner, const Vector angles, const Vector vecStart, const Vector vecVelocity);
void Touch(edict_t *pOther); void Touch(edict_t *pOther);
void EXPORT FlyThink(); void EXPORT FlyThink();
void CreateEffects(); void CreateEffects();
void ClearEffects(); void ClearEffects();
void UpdateOnRemove(); void UpdateOnRemove();
CMBeam *m_pBeam; CMBeam *m_pBeam;
CMBeam *m_pNoise; CMBeam *m_pNoise;
CMSprite *m_pSprite; CMSprite *m_pSprite;
}; };
#endif #endif

View File

@@ -1,223 +1,223 @@
// HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository! // HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository!
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// shockroach.cpp // shockroach.cpp
//========================================================= //=========================================================
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "schedule.h" #include "schedule.h"
#include "weapons.h" #include "weapons.h"
const char *CMShockRoach::pIdleSounds[] = const char *CMShockRoach::pIdleSounds[] =
{ {
"shockroach/shock_idle1.wav", "shockroach/shock_idle1.wav",
"shockroach/shock_idle2.wav", "shockroach/shock_idle2.wav",
"shockroach/shock_idle3.wav", "shockroach/shock_idle3.wav",
}; };
const char *CMShockRoach::pAlertSounds[] = const char *CMShockRoach::pAlertSounds[] =
{ {
"shockroach/shock_angry.wav", "shockroach/shock_angry.wav",
}; };
const char *CMShockRoach::pPainSounds[] = const char *CMShockRoach::pPainSounds[] =
{ {
"shockroach/shock_flinch.wav", "shockroach/shock_flinch.wav",
}; };
const char *CMShockRoach::pAttackSounds[] = const char *CMShockRoach::pAttackSounds[] =
{ {
"shockroach/shock_jump1.wav", "shockroach/shock_jump1.wav",
"shockroach/shock_jump2.wav", "shockroach/shock_jump2.wav",
}; };
const char *CMShockRoach::pDeathSounds[] = const char *CMShockRoach::pDeathSounds[] =
{ {
"shockroach/shock_die.wav", "shockroach/shock_die.wav",
}; };
const char *CMShockRoach::pBiteSounds[] = const char *CMShockRoach::pBiteSounds[] =
{ {
"shockroach/shock_bite.wav", "shockroach/shock_bite.wav",
}; };
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CMShockRoach::Spawn() void CMShockRoach::Spawn()
{ {
Precache(); Precache();
SET_MODEL(ENT(pev), "models/w_shock_rifle.mdl"); SET_MODEL(ENT(pev), "models/w_shock_rifle.mdl");
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
m_bloodColor = BLOOD_COLOR_GREEN; m_bloodColor = BLOOD_COLOR_GREEN;
pev->effects = 0; pev->effects = 0;
pev->health = gSkillData.roachHealth; pev->health = gSkillData.roachHealth;
pev->view_ofs = Vector(0, 0, 20);// position of the eyes relative to monster's origin. pev->view_ofs = Vector(0, 0, 20);// position of the eyes relative to monster's origin.
pev->yaw_speed = 5;//!!! should we put this in the monster's changeanim function since turn rates may vary with state/anim? pev->yaw_speed = 5;//!!! should we put this in the monster's changeanim function since turn rates may vary with state/anim?
m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE; m_MonsterState = MONSTERSTATE_NONE;
m_fRoachSolid = 0; m_fRoachSolid = 0;
m_flBirthTime = gpGlobals->time; m_flBirthTime = gpGlobals->time;
MonsterInit(); MonsterInit();
pev->classname = MAKE_STRING( "monster_shockroach" ); pev->classname = MAKE_STRING( "monster_shockroach" );
if ( strlen( STRING( m_szMonsterName ) ) == 0 ) if ( strlen( STRING( m_szMonsterName ) ) == 0 )
{ {
// default name // default name
m_szMonsterName = MAKE_STRING( "Shock Roach" ); m_szMonsterName = MAKE_STRING( "Shock Roach" );
} }
} }
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CMShockRoach::Precache() void CMShockRoach::Precache()
{ {
PRECACHE_SOUND_ARRAY(pIdleSounds); PRECACHE_SOUND_ARRAY(pIdleSounds);
PRECACHE_SOUND_ARRAY(pAlertSounds); PRECACHE_SOUND_ARRAY(pAlertSounds);
PRECACHE_SOUND_ARRAY(pPainSounds); PRECACHE_SOUND_ARRAY(pPainSounds);
PRECACHE_SOUND_ARRAY(pAttackSounds); PRECACHE_SOUND_ARRAY(pAttackSounds);
PRECACHE_SOUND_ARRAY(pDeathSounds); PRECACHE_SOUND_ARRAY(pDeathSounds);
PRECACHE_SOUND_ARRAY(pBiteSounds); PRECACHE_SOUND_ARRAY(pBiteSounds);
PRECACHE_SOUND("shockroach/shock_walk.wav"); PRECACHE_SOUND("shockroach/shock_walk.wav");
PRECACHE_MODEL("models/w_shock_rifle.mdl"); PRECACHE_MODEL("models/w_shock_rifle.mdl");
} }
//========================================================= //=========================================================
// LeapTouch - this is the headcrab's touch function when it // LeapTouch - this is the headcrab's touch function when it
// is in the air // is in the air
//========================================================= //=========================================================
void CMShockRoach::LeapTouch(edict_t *pOther) void CMShockRoach::LeapTouch(edict_t *pOther)
{ {
if (!pOther->v.takedamage) if (!pOther->v.takedamage)
{ {
return; return;
} }
// Don't hit if back on ground // Don't hit if back on ground
if (!FBitSet(pev->flags, FL_ONGROUND)) if (!FBitSet(pev->flags, FL_ONGROUND))
{ {
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pBiteSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pBiteSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch());
if (UTIL_IsPlayer(pOther)) if (UTIL_IsPlayer(pOther))
UTIL_TakeDamage( pOther, pev, pev, GetDamageAmount(), DMG_SLASH ); UTIL_TakeDamage( pOther, pev, pev, GetDamageAmount(), DMG_SLASH );
else if (pOther->v.euser4 != NULL) else if (pOther->v.euser4 != NULL)
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
pMonster->TakeDamage( pev, pev, GetDamageAmount(), DMG_SLASH ); pMonster->TakeDamage( pev, pev, GetDamageAmount(), DMG_SLASH );
} }
} }
SetTouch(NULL); SetTouch(NULL);
} }
//========================================================= //=========================================================
// PrescheduleThink // PrescheduleThink
//========================================================= //=========================================================
void CMShockRoach::MonsterThink(void) void CMShockRoach::MonsterThink(void)
{ {
float lifeTime = (gpGlobals->time - m_flBirthTime); float lifeTime = (gpGlobals->time - m_flBirthTime);
if (lifeTime >= 0.2) if (lifeTime >= 0.2)
{ {
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_STEP;
} }
if (!m_fRoachSolid && lifeTime >= 2.0 ) { if (!m_fRoachSolid && lifeTime >= 2.0 ) {
m_fRoachSolid = TRUE; m_fRoachSolid = TRUE;
UTIL_SetSize(pev, Vector(-12, -12, 0), Vector(12, 12, 4)); UTIL_SetSize(pev, Vector(-12, -12, 0), Vector(12, 12, 4));
} }
if (lifeTime >= gSkillData.roachLifespan) if (lifeTime >= gSkillData.roachLifespan)
{ {
pev->health = -1; pev->health = -1;
Killed(pev, 0); Killed(pev, 0);
return; return;
} }
CMHeadCrab::MonsterThink(); CMHeadCrab::MonsterThink();
} }
//========================================================= //=========================================================
// IdleSound // IdleSound
//========================================================= //=========================================================
void CMShockRoach::IdleSound(void) void CMShockRoach::IdleSound(void)
{ {
EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pIdleSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pIdleSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch());
} }
//========================================================= //=========================================================
// AlertSound // AlertSound
//========================================================= //=========================================================
void CMShockRoach::AlertSound(void) void CMShockRoach::AlertSound(void)
{ {
EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pAlertSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pAlertSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch());
} }
//========================================================= //=========================================================
// AlertSound // AlertSound
//========================================================= //=========================================================
void CMShockRoach::PainSound(void) void CMShockRoach::PainSound(void)
{ {
EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pPainSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pPainSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch());
} }
//========================================================= //=========================================================
// DeathSound // DeathSound
//========================================================= //=========================================================
void CMShockRoach::DeathSound(void) void CMShockRoach::DeathSound(void)
{ {
EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pDeathSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pDeathSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch());
} }
void CMShockRoach::StartTask(Task_t *pTask) void CMShockRoach::StartTask(Task_t *pTask)
{ {
m_iTaskStatus = TASKSTATUS_RUNNING; m_iTaskStatus = TASKSTATUS_RUNNING;
switch (pTask->iTask) switch (pTask->iTask)
{ {
case TASK_RANGE_ATTACK1: case TASK_RANGE_ATTACK1:
{ {
m_IdealActivity = ACT_RANGE_ATTACK1; m_IdealActivity = ACT_RANGE_ATTACK1;
SetTouch(&CMShockRoach::LeapTouch); SetTouch(&CMShockRoach::LeapTouch);
break; break;
} }
default: default:
CMHeadCrab::StartTask(pTask); CMHeadCrab::StartTask(pTask);
} }
} }
int CMShockRoach::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) int CMShockRoach::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{ {
if ( gpGlobals->time - m_flBirthTime < 2.0 ) if ( gpGlobals->time - m_flBirthTime < 2.0 )
flDamage = 0.0; flDamage = 0.0;
// Skip headcrab's TakeDamage to avoid unwanted immunity to acid. // Skip headcrab's TakeDamage to avoid unwanted immunity to acid.
return CMBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); return CMBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
} }
void CMShockRoach::AttackSound() void CMShockRoach::AttackSound()
{ {
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch());
} }

View File

@@ -1,337 +1,337 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#ifndef __linux__ #ifndef __linux__
#include <io.h> #include <io.h>
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "extdll.h" #include "extdll.h"
#include "dllapi.h" #include "dllapi.h"
#include "meta_api.h" #include "meta_api.h"
#include "skill.h" #include "skill.h"
extern cvar_t *dllapi_log; extern cvar_t *dllapi_log;
skilldata_t gSkillData; skilldata_t gSkillData;
struct skill_cfg_t struct skill_cfg_t
{ {
char *name; char *name;
float *value; float *value;
}; };
skill_cfg_t skill_cfg[] = { skill_cfg_t skill_cfg[] = {
{"sk_agrunt_health", &gSkillData.agruntHealth}, {"sk_agrunt_health", &gSkillData.agruntHealth},
{"sk_agrunt_dmg_punch", &gSkillData.agruntDmgPunch}, {"sk_agrunt_dmg_punch", &gSkillData.agruntDmgPunch},
{"sk_apache_health", &gSkillData.apacheHealth}, {"sk_apache_health", &gSkillData.apacheHealth},
{"sk_barney_health", &gSkillData.barneyHealth}, {"sk_barney_health", &gSkillData.barneyHealth},
{"sk_bigmomma_health_factor", &gSkillData.bigmommaHealthFactor}, {"sk_bigmomma_health_factor", &gSkillData.bigmommaHealthFactor},
{"sk_bigmomma_dmg_slash", &gSkillData.bigmommaDmgSlash}, {"sk_bigmomma_dmg_slash", &gSkillData.bigmommaDmgSlash},
{"sk_bigmomma_dmg_blast", &gSkillData.bigmommaDmgBlast}, {"sk_bigmomma_dmg_blast", &gSkillData.bigmommaDmgBlast},
{"sk_bigmomma_radius_blast", &gSkillData.bigmommaRadiusBlast}, {"sk_bigmomma_radius_blast", &gSkillData.bigmommaRadiusBlast},
{"sk_bullsquid_health", &gSkillData.bullsquidHealth}, {"sk_bullsquid_health", &gSkillData.bullsquidHealth},
{"sk_bullsquid_dmg_bite", &gSkillData.bullsquidDmgBite}, {"sk_bullsquid_dmg_bite", &gSkillData.bullsquidDmgBite},
{"sk_bullsquid_dmg_whip", &gSkillData.bullsquidDmgWhip}, {"sk_bullsquid_dmg_whip", &gSkillData.bullsquidDmgWhip},
{"sk_bullsquid_dmg_spit", &gSkillData.bullsquidDmgSpit}, {"sk_bullsquid_dmg_spit", &gSkillData.bullsquidDmgSpit},
{"sk_gargantua_health", &gSkillData.gargantuaHealth}, {"sk_gargantua_health", &gSkillData.gargantuaHealth},
{"sk_gargantua_armor", &gSkillData.gargantuaArmor}, {"sk_gargantua_armor", &gSkillData.gargantuaArmor},
{"sk_gargantua_dmg_slash", &gSkillData.gargantuaDmgSlash}, {"sk_gargantua_dmg_slash", &gSkillData.gargantuaDmgSlash},
{"sk_gargantua_dmg_fire", &gSkillData.gargantuaDmgFire}, {"sk_gargantua_dmg_fire", &gSkillData.gargantuaDmgFire},
{"sk_gargantua_dmg_stomp", &gSkillData.gargantuaDmgStomp}, {"sk_gargantua_dmg_stomp", &gSkillData.gargantuaDmgStomp},
{"sk_hassassin_health", &gSkillData.hassassinHealth}, {"sk_hassassin_health", &gSkillData.hassassinHealth},
{"sk_headcrab_health", &gSkillData.headcrabHealth}, {"sk_headcrab_health", &gSkillData.headcrabHealth},
{"sk_headcrab_dmg_bite", &gSkillData.headcrabDmgBite}, {"sk_headcrab_dmg_bite", &gSkillData.headcrabDmgBite},
{"sk_hgrunt_health", &gSkillData.hgruntHealth}, {"sk_hgrunt_health", &gSkillData.hgruntHealth},
{"sk_hgrunt_kick", &gSkillData.hgruntDmgKick}, {"sk_hgrunt_kick", &gSkillData.hgruntDmgKick},
{"sk_hgrunt_pellets", &gSkillData.hgruntShotgunPellets}, {"sk_hgrunt_pellets", &gSkillData.hgruntShotgunPellets},
{"sk_hgrunt_gspeed", &gSkillData.hgruntGrenadeSpeed}, {"sk_hgrunt_gspeed", &gSkillData.hgruntGrenadeSpeed},
{"sk_houndeye_health", &gSkillData.houndeyeHealth}, {"sk_houndeye_health", &gSkillData.houndeyeHealth},
{"sk_houndeye_dmg_blast", &gSkillData.houndeyeDmgBlast}, {"sk_houndeye_dmg_blast", &gSkillData.houndeyeDmgBlast},
{"sk_islave_health", &gSkillData.slaveHealth}, {"sk_islave_health", &gSkillData.slaveHealth},
{"sk_islave_dmg_claw", &gSkillData.slaveDmgClaw}, {"sk_islave_dmg_claw", &gSkillData.slaveDmgClaw},
{"sk_islave_dmg_clawrake", &gSkillData.slaveDmgClawrake}, {"sk_islave_dmg_clawrake", &gSkillData.slaveDmgClawrake},
{"sk_islave_dmg_zap", &gSkillData.slaveDmgZap}, {"sk_islave_dmg_zap", &gSkillData.slaveDmgZap},
{"sk_ichthyosaur_health", &gSkillData.ichthyosaurHealth}, {"sk_ichthyosaur_health", &gSkillData.ichthyosaurHealth},
{"sk_ichthyosaur_shake", &gSkillData.ichthyosaurDmgShake}, {"sk_ichthyosaur_shake", &gSkillData.ichthyosaurDmgShake},
{"sk_controller_health", &gSkillData.controllerHealth}, {"sk_controller_health", &gSkillData.controllerHealth},
{"sk_controller_dmgzap", &gSkillData.controllerDmgZap}, {"sk_controller_dmgzap", &gSkillData.controllerDmgZap},
{"sk_controller_speedball", &gSkillData.controllerSpeedBall}, {"sk_controller_speedball", &gSkillData.controllerSpeedBall},
{"sk_controller_dmgball", &gSkillData.controllerDmgBall}, {"sk_controller_dmgball", &gSkillData.controllerDmgBall},
{"sk_scientist_health", &gSkillData.scientistHealth}, {"sk_scientist_health", &gSkillData.scientistHealth},
{"sk_scientist_heal", &gSkillData.scientistHeal}, {"sk_scientist_heal", &gSkillData.scientistHeal},
{"sk_snark_health", &gSkillData.snarkHealth}, {"sk_snark_health", &gSkillData.snarkHealth},
{"sk_snark_dmg_bite", &gSkillData.snarkDmgBite}, {"sk_snark_dmg_bite", &gSkillData.snarkDmgBite},
{"sk_snark_dmg_pop", &gSkillData.snarkDmgPop}, {"sk_snark_dmg_pop", &gSkillData.snarkDmgPop},
{"sk_zombie_health", &gSkillData.zombieHealth}, {"sk_zombie_health", &gSkillData.zombieHealth},
{"sk_zombie_dmg_one_slash", &gSkillData.zombieDmgOneSlash}, {"sk_zombie_dmg_one_slash", &gSkillData.zombieDmgOneSlash},
{"sk_zombie_dmg_both_slash", &gSkillData.zombieDmgBothSlash}, {"sk_zombie_dmg_both_slash", &gSkillData.zombieDmgBothSlash},
{"sk_turret_health", &gSkillData.turretHealth}, {"sk_turret_health", &gSkillData.turretHealth},
{"sk_miniturret_health", &gSkillData.miniturretHealth}, {"sk_miniturret_health", &gSkillData.miniturretHealth},
{"sk_sentry_health", &gSkillData.sentryHealth}, {"sk_sentry_health", &gSkillData.sentryHealth},
{"sk_gonome_health", &gSkillData.gonomeHealth}, {"sk_gonome_health", &gSkillData.gonomeHealth},
{"sk_gonome_dmg_guts", &gSkillData.gonomeDmgGuts}, {"sk_gonome_dmg_guts", &gSkillData.gonomeDmgGuts},
{"sk_gonome_dmg_one_slash", &gSkillData.gonomeDmgOneSlash}, {"sk_gonome_dmg_one_slash", &gSkillData.gonomeDmgOneSlash},
{"sk_gonome_dmg_one_bite", &gSkillData.gonomeDmgOneBite}, {"sk_gonome_dmg_one_bite", &gSkillData.gonomeDmgOneBite},
{"sk_massassin_health", &gSkillData.massnHealth}, {"sk_massassin_health", &gSkillData.massnHealth},
{"sk_massassin_kick", &gSkillData.massnDmgKick}, {"sk_massassin_kick", &gSkillData.massnDmgKick},
{"sk_otis_health", &gSkillData.otisHealth}, {"sk_otis_health", &gSkillData.otisHealth},
{"sk_pitdrone_health", &gSkillData.pitdroneHealth}, {"sk_pitdrone_health", &gSkillData.pitdroneHealth},
{"sk_pitdrone_dmg_spit", &gSkillData.pitdroneDmgSpit}, {"sk_pitdrone_dmg_spit", &gSkillData.pitdroneDmgSpit},
{"sk_pitdrone_dmg_whip", &gSkillData.pitdroneDmgWhip}, {"sk_pitdrone_dmg_whip", &gSkillData.pitdroneDmgWhip},
{"sk_pitdrone_dmg_bite", &gSkillData.pitdroneDmgBite}, {"sk_pitdrone_dmg_bite", &gSkillData.pitdroneDmgBite},
{"sk_shockroach_health", &gSkillData.roachHealth}, {"sk_shockroach_health", &gSkillData.roachHealth},
{"sk_shockroach_lifespan", &gSkillData.roachLifespan}, {"sk_shockroach_lifespan", &gSkillData.roachLifespan},
{"sk_shocktrooper_health", &gSkillData.strooperHealth}, {"sk_shocktrooper_health", &gSkillData.strooperHealth},
{"sk_shocktrooper_kick", &gSkillData.strooperDmgKick}, {"sk_shocktrooper_kick", &gSkillData.strooperDmgKick},
{"sk_shocktrooper_maxcharge", &gSkillData.strooperMaxCharge}, {"sk_shocktrooper_maxcharge", &gSkillData.strooperMaxCharge},
{"sk_shocktrooper_rchgspeed", &gSkillData.strooperRchgSpeed}, {"sk_shocktrooper_rchgspeed", &gSkillData.strooperRchgSpeed},
{"sk_voltigore_health", &gSkillData.voltigoreHealth}, {"sk_voltigore_health", &gSkillData.voltigoreHealth},
{"sk_voltigore_dmg_beam", &gSkillData.voltigoreDmgBeam}, {"sk_voltigore_dmg_beam", &gSkillData.voltigoreDmgBeam},
{"sk_voltigore_dmg_punch", &gSkillData.voltigoreDmgPunch}, {"sk_voltigore_dmg_punch", &gSkillData.voltigoreDmgPunch},
{"sk_babyvoltigore_health", &gSkillData.babyVoltigoreHealth}, {"sk_babyvoltigore_health", &gSkillData.babyVoltigoreHealth},
{"sk_babyvoltigore_dmg_punch", &gSkillData.babyVoltigoreDmgPunch}, {"sk_babyvoltigore_dmg_punch", &gSkillData.babyVoltigoreDmgPunch},
{"sk_babygarg_health", &gSkillData.babygargHealth}, {"sk_babygarg_health", &gSkillData.babygargHealth},
{"sk_babygarg_dmg_slash", &gSkillData.babygargDmgSlash}, {"sk_babygarg_dmg_slash", &gSkillData.babygargDmgSlash},
{"sk_babygarg_dmg_fire", &gSkillData.babygargDmgFire}, {"sk_babygarg_dmg_fire", &gSkillData.babygargDmgFire},
{"sk_babygarg_dmg_stomp", &gSkillData.babygargDmgStomp}, {"sk_babygarg_dmg_stomp", &gSkillData.babygargDmgStomp},
{"sk_12mm_bullet", &gSkillData.monDmg9MM}, {"sk_12mm_bullet", &gSkillData.monDmg9MM},
{"sk_9mmAR_bullet", &gSkillData.monDmgMP5}, {"sk_9mmAR_bullet", &gSkillData.monDmgMP5},
{"sk_9mm_bullet", &gSkillData.monDmg12MM}, {"sk_9mm_bullet", &gSkillData.monDmg12MM},
{"sk_9mmAR_grenade", &gSkillData.monDmgM203Grenade}, {"sk_9mmAR_grenade", &gSkillData.monDmgM203Grenade},
{"sk_762_bullet", &gSkillData.monDmg762}, {"sk_762_bullet", &gSkillData.monDmg762},
{"sk_357_bullet", &gSkillData.monDmg357}, {"sk_357_bullet", &gSkillData.monDmg357},
{"sk_hornet_dmg", &gSkillData.monDmgHornet}, {"sk_hornet_dmg", &gSkillData.monDmgHornet},
{"sk_shock_dmg", &gSkillData.monDmgShockroach}, {"sk_shock_dmg", &gSkillData.monDmgShockroach},
{"sk_spore_dmg", &gSkillData.monDmgSpore}, {"sk_spore_dmg", &gSkillData.monDmgSpore},
{"", NULL} {"", NULL}
}; };
bool get_input(FILE *fp, char *input); bool get_input(FILE *fp, char *input);
void scan_monster_skill(FILE *fp) void scan_monster_skill(FILE *fp)
{ {
char input[1024]; char input[1024];
int index, len, pos; int index, len, pos;
bool found; bool found;
while (get_input(fp, input)) while (get_input(fp, input))
{ {
index = 0; index = 0;
found = FALSE; found = FALSE;
while (skill_cfg[index].name[0]) while (skill_cfg[index].name[0])
{ {
len = strlen(skill_cfg[index].name); len = strlen(skill_cfg[index].name);
if (strncmp(input, skill_cfg[index].name, len) == 0) if (strncmp(input, skill_cfg[index].name, len) == 0)
{ {
found = TRUE; found = TRUE;
pos = len; pos = len;
sscanf(&input[pos], "%f", skill_cfg[index].value); sscanf(&input[pos], "%f", skill_cfg[index].value);
if (dllapi_log->value) if (dllapi_log->value)
LOG_MESSAGE(PLID, "skill setting %s set to %f", LOG_MESSAGE(PLID, "skill setting %s set to %f",
skill_cfg[index].name, *skill_cfg[index].value); skill_cfg[index].name, *skill_cfg[index].value);
break; break;
} }
index++; index++;
} }
if (!found) if (!found)
{ {
//META_CONS("[MONSTER] ERROR: unknown monster_skill.cfg item: %s", input); //META_CONS("[MONSTER] ERROR: unknown monster_skill.cfg item: %s", input);
LOG_MESSAGE(PLID, "ERROR: unknown monster_skill.cfg item: %s", input); LOG_MESSAGE(PLID, "ERROR: unknown monster_skill.cfg item: %s", input);
} }
} }
} }
void monster_skill_init(void) void monster_skill_init(void)
{ {
char game_dir[256]; char game_dir[256];
char filename[256]; char filename[256];
FILE *fp = NULL; FILE *fp = NULL;
// Alien Grunt // Alien Grunt
gSkillData.agruntHealth = 90.0f; gSkillData.agruntHealth = 90.0f;
gSkillData.agruntDmgPunch = 20.0f; gSkillData.agruntDmgPunch = 20.0f;
// Apache // Apache
gSkillData.apacheHealth = 250.0f; gSkillData.apacheHealth = 250.0f;
// Barney // Barney
gSkillData.barneyHealth = 35.0f; gSkillData.barneyHealth = 35.0f;
// Big momma // Big momma
gSkillData.bigmommaHealthFactor = 1.5f; gSkillData.bigmommaHealthFactor = 1.5f;
gSkillData.bigmommaDmgSlash = 60.0f; gSkillData.bigmommaDmgSlash = 60.0f;
gSkillData.bigmommaDmgBlast = 120.0f; gSkillData.bigmommaDmgBlast = 120.0f;
gSkillData.bigmommaRadiusBlast = 250.0f; gSkillData.bigmommaRadiusBlast = 250.0f;
// Bullsquid // Bullsquid
gSkillData.bullsquidHealth = 40.0f; gSkillData.bullsquidHealth = 40.0f;
gSkillData.bullsquidDmgBite = 25.0f; gSkillData.bullsquidDmgBite = 25.0f;
gSkillData.bullsquidDmgWhip = 35.0f; gSkillData.bullsquidDmgWhip = 35.0f;
gSkillData.bullsquidDmgSpit = 10.0f; gSkillData.bullsquidDmgSpit = 10.0f;
// Gargantua // Gargantua
gSkillData.gargantuaHealth = 800.0f; gSkillData.gargantuaHealth = 800.0f;
gSkillData.gargantuaArmor = 0.85f; gSkillData.gargantuaArmor = 0.85f;
gSkillData.gargantuaDmgSlash = 30.0f; gSkillData.gargantuaDmgSlash = 30.0f;
gSkillData.gargantuaDmgFire = 5.0f; gSkillData.gargantuaDmgFire = 5.0f;
gSkillData.gargantuaDmgStomp = 100.0f; gSkillData.gargantuaDmgStomp = 100.0f;
// Hassassin (Female Assassin) // Hassassin (Female Assassin)
gSkillData.hassassinHealth = 50.0f; gSkillData.hassassinHealth = 50.0f;
// Headcrab // Headcrab
gSkillData.headcrabHealth = 10.0f; gSkillData.headcrabHealth = 10.0f;
gSkillData.headcrabDmgBite = 10.0f; gSkillData.headcrabDmgBite = 10.0f;
// Hgrunt (Human Grunt) // Hgrunt (Human Grunt)
gSkillData.hgruntHealth = 50.0f; gSkillData.hgruntHealth = 50.0f;
gSkillData.hgruntDmgKick = 10.0f; gSkillData.hgruntDmgKick = 10.0f;
gSkillData.hgruntShotgunPellets = 5.0f; gSkillData.hgruntShotgunPellets = 5.0f;
gSkillData.hgruntGrenadeSpeed = 600.0f; gSkillData.hgruntGrenadeSpeed = 600.0f;
// Houndeye // Houndeye
gSkillData.houndeyeHealth = 20.0f; gSkillData.houndeyeHealth = 20.0f;
gSkillData.houndeyeDmgBlast = 15.0f; gSkillData.houndeyeDmgBlast = 15.0f;
// Alien Slave // Alien Slave
gSkillData.slaveHealth = 30.0f; gSkillData.slaveHealth = 30.0f;
gSkillData.slaveDmgClaw = 10.0f; gSkillData.slaveDmgClaw = 10.0f;
gSkillData.slaveDmgClawrake = 25.0f; gSkillData.slaveDmgClawrake = 25.0f;
gSkillData.slaveDmgZap = 10.0f; gSkillData.slaveDmgZap = 10.0f;
// Icthyosaur // Icthyosaur
gSkillData.ichthyosaurHealth = 200.0f; gSkillData.ichthyosaurHealth = 200.0f;
gSkillData.ichthyosaurDmgShake = 35.0f; gSkillData.ichthyosaurDmgShake = 35.0f;
// Controller // Controller
gSkillData.controllerHealth = 60.0f; gSkillData.controllerHealth = 60.0f;
gSkillData.controllerDmgZap = 25.0f; gSkillData.controllerDmgZap = 25.0f;
gSkillData.controllerSpeedBall = 800.0f; gSkillData.controllerSpeedBall = 800.0f;
gSkillData.controllerDmgBall = 4.0f; gSkillData.controllerDmgBall = 4.0f;
// Scientist // Scientist
gSkillData.scientistHealth = 20.0f; gSkillData.scientistHealth = 20.0f;
gSkillData.scientistHeal = 25.0f; gSkillData.scientistHeal = 25.0f;
// Snark // Snark
gSkillData.snarkHealth = 2.0f; gSkillData.snarkHealth = 2.0f;
gSkillData.snarkDmgBite = 10.0f; gSkillData.snarkDmgBite = 10.0f;
gSkillData.snarkDmgPop = 5.0f; gSkillData.snarkDmgPop = 5.0f;
// Zombie // Zombie
gSkillData.zombieHealth = 50.0f; gSkillData.zombieHealth = 50.0f;
gSkillData.zombieDmgOneSlash = 20.0f; gSkillData.zombieDmgOneSlash = 20.0f;
gSkillData.zombieDmgBothSlash = 40.0f; gSkillData.zombieDmgBothSlash = 40.0f;
// Turret // Turret
gSkillData.turretHealth = 50.0f; gSkillData.turretHealth = 50.0f;
// Mini-Turret // Mini-Turret
gSkillData.miniturretHealth = 40.0f; gSkillData.miniturretHealth = 40.0f;
// Sentry // Sentry
gSkillData.sentryHealth = 40.0f; gSkillData.sentryHealth = 40.0f;
// Gonome // Gonome
gSkillData.gonomeHealth = 85.0f; gSkillData.gonomeHealth = 85.0f;
gSkillData.gonomeDmgGuts = 10.0f; gSkillData.gonomeDmgGuts = 10.0f;
gSkillData.gonomeDmgOneSlash = 20.0f; gSkillData.gonomeDmgOneSlash = 20.0f;
gSkillData.gonomeDmgOneBite = 14.0f; gSkillData.gonomeDmgOneBite = 14.0f;
// Male Assassin // Male Assassin
gSkillData.massnHealth = 50.0f; gSkillData.massnHealth = 50.0f;
gSkillData.massnDmgKick = 25.0f; gSkillData.massnDmgKick = 25.0f;
// Otis // Otis
gSkillData.otisHealth = 35.0f; gSkillData.otisHealth = 35.0f;
// Pit Drone // Pit Drone
gSkillData.pitdroneHealth = 40.0f; gSkillData.pitdroneHealth = 40.0f;
gSkillData.pitdroneDmgSpit = 10.0f; gSkillData.pitdroneDmgSpit = 10.0f;
gSkillData.pitdroneDmgWhip = 35.0f; gSkillData.pitdroneDmgWhip = 35.0f;
gSkillData.pitdroneDmgBite = 25.0f; gSkillData.pitdroneDmgBite = 25.0f;
// Shock Roach // Shock Roach
gSkillData.roachHealth = 10.0f; gSkillData.roachHealth = 10.0f;
gSkillData.roachLifespan = 10.0f; gSkillData.roachLifespan = 10.0f;
// Shock Trooper // Shock Trooper
gSkillData.strooperHealth = 50.0f; gSkillData.strooperHealth = 50.0f;
gSkillData.strooperDmgKick = 10.0f; gSkillData.strooperDmgKick = 10.0f;
gSkillData.strooperMaxCharge = 8.0f; gSkillData.strooperMaxCharge = 8.0f;
gSkillData.strooperRchgSpeed = 1.0f; gSkillData.strooperRchgSpeed = 1.0f;
// Voltigore // Voltigore
gSkillData.voltigoreHealth = 320.0f; gSkillData.voltigoreHealth = 320.0f;
gSkillData.voltigoreDmgBeam = 50.0f; gSkillData.voltigoreDmgBeam = 50.0f;
gSkillData.voltigoreDmgPunch = 40.0f; gSkillData.voltigoreDmgPunch = 40.0f;
// Baby Voltigore // Baby Voltigore
gSkillData.babyVoltigoreHealth = 60.0f; gSkillData.babyVoltigoreHealth = 60.0f;
gSkillData.babyVoltigoreDmgPunch = 15.0f; gSkillData.babyVoltigoreDmgPunch = 15.0f;
// Baby Gargantua // Baby Gargantua
gSkillData.babygargHealth = 640.0f; gSkillData.babygargHealth = 640.0f;
gSkillData.babygargDmgSlash = 24.0f; gSkillData.babygargDmgSlash = 24.0f;
gSkillData.babygargDmgFire = 4.0f; gSkillData.babygargDmgFire = 4.0f;
gSkillData.babygargDmgStomp = 80.0f; gSkillData.babygargDmgStomp = 80.0f;
// MONSTER WEAPONS // MONSTER WEAPONS
gSkillData.monDmg9MM = 5.0f; gSkillData.monDmg9MM = 5.0f;
gSkillData.monDmgMP5 = 4.0f; gSkillData.monDmgMP5 = 4.0f;
gSkillData.monDmg12MM = 10.0f; gSkillData.monDmg12MM = 10.0f;
gSkillData.monDmgM203Grenade = 100.0f; gSkillData.monDmgM203Grenade = 100.0f;
gSkillData.monDmg762 = 100.0f; gSkillData.monDmg762 = 100.0f;
gSkillData.monDmg357 = 40.0f; gSkillData.monDmg357 = 40.0f;
// HORNET // HORNET
gSkillData.monDmgHornet = 5.0f; gSkillData.monDmgHornet = 5.0f;
// SHOCK ROACH // SHOCK ROACH
gSkillData.monDmgShockroach = 15.0f; gSkillData.monDmgShockroach = 15.0f;
// SPORE GRENADE // SPORE GRENADE
gSkillData.monDmgSpore = 50.0f; gSkillData.monDmgSpore = 50.0f;
// find the directory name of the currently running MOD... // find the directory name of the currently running MOD...
(*g_engfuncs.pfnGetGameDir)(game_dir); (*g_engfuncs.pfnGetGameDir)(game_dir);
strcpy(filename, game_dir); strcpy(filename, game_dir);
strcat(filename, "/monster_skill.cfg"); strcat(filename, "/monster_skill.cfg");
// check if the map specific filename exists... // check if the map specific filename exists...
if (access(filename, 0) == 0) if (access(filename, 0) == 0)
{ {
if (dllapi_log->value) if (dllapi_log->value)
{ {
//META_CONS("[MONSTER] Processing monster skill file=%s", filename); //META_CONS("[MONSTER] Processing monster skill file=%s", filename);
LOG_MESSAGE(PLID, "Processing monster skill file=%s", filename); LOG_MESSAGE(PLID, "Processing monster skill file=%s", filename);
} }
if ((fp = fopen(filename, "r")) == NULL) if ((fp = fopen(filename, "r")) == NULL)
{ {
//META_CONS("[MONSTER] ERROR: Could not open \"%s\"!", filename); //META_CONS("[MONSTER] ERROR: Could not open \"%s\"!", filename);
LOG_MESSAGE(PLID, "ERROR: Could not open \"%s\"!", filename); LOG_MESSAGE(PLID, "ERROR: Could not open \"%s\"!", filename);
} }
scan_monster_skill(fp); scan_monster_skill(fp);
fclose(fp); fclose(fp);
} }
else else
{ {
//META_CONS("[MONSTER] ERROR: Could not find \"%s\" (default skill used)", filename); //META_CONS("[MONSTER] ERROR: Could not find \"%s\" (default skill used)", filename);
LOG_MESSAGE(PLID, "ERROR: Could not find \"%s\" (default skill used)", filename); LOG_MESSAGE(PLID, "ERROR: Could not find \"%s\" (default skill used)", filename);
} }
} }

View File

@@ -1,144 +1,144 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
//========================================================= //=========================================================
// skill.h - skill level concerns // skill.h - skill level concerns
//========================================================= //=========================================================
#ifndef SKILL_H #ifndef SKILL_H
#define SKILL_H #define SKILL_H
struct skilldata_t struct skilldata_t
{ {
// Monster Health & Damage // Monster Health & Damage
float agruntHealth; float agruntHealth;
float agruntDmgPunch; float agruntDmgPunch;
float apacheHealth; float apacheHealth;
float barneyHealth; float barneyHealth;
float bigmommaHealthFactor; // Multiply each node's health by this float bigmommaHealthFactor; // Multiply each node's health by this
float bigmommaDmgSlash; // melee attack damage float bigmommaDmgSlash; // melee attack damage
float bigmommaDmgBlast; // mortar attack damage float bigmommaDmgBlast; // mortar attack damage
float bigmommaRadiusBlast; // mortar attack radius float bigmommaRadiusBlast; // mortar attack radius
float bullsquidHealth; float bullsquidHealth;
float bullsquidDmgBite; float bullsquidDmgBite;
float bullsquidDmgWhip; float bullsquidDmgWhip;
float bullsquidDmgSpit; float bullsquidDmgSpit;
float gargantuaHealth; float gargantuaHealth;
float gargantuaArmor; // Non-explosives will deal this much damage float gargantuaArmor; // Non-explosives will deal this much damage
float gargantuaDmgSlash; float gargantuaDmgSlash;
float gargantuaDmgFire; float gargantuaDmgFire;
float gargantuaDmgStomp; float gargantuaDmgStomp;
float hassassinHealth; float hassassinHealth;
float headcrabHealth; float headcrabHealth;
float headcrabDmgBite; float headcrabDmgBite;
float hgruntHealth; float hgruntHealth;
float hgruntDmgKick; float hgruntDmgKick;
float hgruntShotgunPellets; float hgruntShotgunPellets;
float hgruntGrenadeSpeed; float hgruntGrenadeSpeed;
float houndeyeHealth; float houndeyeHealth;
float houndeyeDmgBlast; float houndeyeDmgBlast;
float slaveHealth; float slaveHealth;
float slaveDmgClaw; float slaveDmgClaw;
float slaveDmgClawrake; float slaveDmgClawrake;
float slaveDmgZap; float slaveDmgZap;
float ichthyosaurHealth; float ichthyosaurHealth;
float ichthyosaurDmgShake; float ichthyosaurDmgShake;
float controllerHealth; float controllerHealth;
float controllerDmgZap; float controllerDmgZap;
float controllerSpeedBall; float controllerSpeedBall;
float controllerDmgBall; float controllerDmgBall;
float scientistHealth; float scientistHealth;
float scientistHeal; float scientistHeal;
float snarkHealth; float snarkHealth;
float snarkDmgBite; float snarkDmgBite;
float snarkDmgPop; float snarkDmgPop;
float zombieHealth; float zombieHealth;
float zombieDmgOneSlash; float zombieDmgOneSlash;
float zombieDmgBothSlash; float zombieDmgBothSlash;
float turretHealth; float turretHealth;
float miniturretHealth; float miniturretHealth;
float sentryHealth; float sentryHealth;
//OP4 monsters //OP4 monsters
float gonomeHealth; float gonomeHealth;
float gonomeDmgGuts; float gonomeDmgGuts;
float gonomeDmgOneSlash; float gonomeDmgOneSlash;
float gonomeDmgOneBite; float gonomeDmgOneBite;
float massnHealth; float massnHealth;
float massnDmgKick; float massnDmgKick;
float otisHealth; float otisHealth;
float pitdroneHealth; float pitdroneHealth;
float pitdroneDmgSpit; float pitdroneDmgSpit;
float pitdroneDmgWhip; float pitdroneDmgWhip;
float pitdroneDmgBite; float pitdroneDmgBite;
float roachHealth; float roachHealth;
float roachLifespan; float roachLifespan;
float strooperHealth; float strooperHealth;
float strooperDmgKick; float strooperDmgKick;
float strooperMaxCharge; float strooperMaxCharge;
float strooperRchgSpeed; float strooperRchgSpeed;
float voltigoreHealth; float voltigoreHealth;
float voltigoreDmgBeam; float voltigoreDmgBeam;
float voltigoreDmgPunch; float voltigoreDmgPunch;
float babyVoltigoreHealth; float babyVoltigoreHealth;
float babyVoltigoreDmgPunch; float babyVoltigoreDmgPunch;
//SC monsters //SC monsters
float babygargHealth; float babygargHealth;
float babygargDmgSlash; float babygargDmgSlash;
float babygargDmgFire; float babygargDmgFire;
float babygargDmgStomp; float babygargDmgStomp;
// weapons shared by monsters // weapons shared by monsters
float monDmg9MM; float monDmg9MM;
float monDmgMP5; float monDmgMP5;
float monDmg12MM; float monDmg12MM;
float monDmgM203Grenade; float monDmgM203Grenade;
float monDmg762; float monDmg762;
float monDmg357; float monDmg357;
float monDmgHornet; float monDmgHornet;
float monDmgShockroach; float monDmgShockroach;
float monDmgSpore; float monDmgSpore;
}; };
extern DLL_GLOBAL skilldata_t gSkillData; extern DLL_GLOBAL skilldata_t gSkillData;
void monster_skill_init(void); void monster_skill_init(void);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,345 +1,345 @@
// HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository! // HUGE thanks to DrBeef for his hlsdk-xash3d-opfor repository!
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "weapons.h" #include "weapons.h"
#include "decals.h" #include "decals.h"
#include "explode.h" #include "explode.h"
int gSporeExplode, gSporeExplodeC; int gSporeExplode, gSporeExplodeC;
void CMSporeGrenade::Precache() void CMSporeGrenade::Precache()
{ {
PRECACHE_MODEL("models/spore.mdl"); PRECACHE_MODEL("models/spore.mdl");
PRECACHE_MODEL("sprites/glow02.spr"); PRECACHE_MODEL("sprites/glow02.spr");
g_sModelIndexTinySpit = PRECACHE_MODEL("sprites/tinyspit.spr"); g_sModelIndexTinySpit = PRECACHE_MODEL("sprites/tinyspit.spr");
gSporeExplode = PRECACHE_MODEL("sprites/spore_exp_01.spr"); gSporeExplode = PRECACHE_MODEL("sprites/spore_exp_01.spr");
gSporeExplodeC = PRECACHE_MODEL("sprites/spore_exp_c_01.spr"); gSporeExplodeC = PRECACHE_MODEL("sprites/spore_exp_c_01.spr");
PRECACHE_SOUND("weapons/splauncher_bounce.wav"); PRECACHE_SOUND("weapons/splauncher_bounce.wav");
PRECACHE_SOUND("weapons/splauncher_impact.wav"); PRECACHE_SOUND("weapons/splauncher_impact.wav");
} }
void CMSporeGrenade::Explode(TraceResult *pTrace) void CMSporeGrenade::Explode(TraceResult *pTrace)
{ {
pev->solid = SOLID_NOT;// intangible pev->solid = SOLID_NOT;// intangible
pev->takedamage = DAMAGE_NO; pev->takedamage = DAMAGE_NO;
// Pull out of the wall a bit // Pull out of the wall a bit
if (pTrace->flFraction != 1.0) if (pTrace->flFraction != 1.0)
{ {
pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6); pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6);
} }
Vector vecSpraySpot = pTrace->vecEndPos; Vector vecSpraySpot = pTrace->vecEndPos;
float flSpraySpeed = RANDOM_LONG(10, 15); float flSpraySpeed = RANDOM_LONG(10, 15);
// If the trace is pointing up, then place // If the trace is pointing up, then place
// spawn position a few units higher. // spawn position a few units higher.
if (pTrace->vecPlaneNormal.z > 0) if (pTrace->vecPlaneNormal.z > 0)
{ {
vecSpraySpot = vecSpraySpot + (pTrace->vecPlaneNormal * 8); vecSpraySpot = vecSpraySpot + (pTrace->vecPlaneNormal * 8);
flSpraySpeed *= 2; // Double the speed to make them fly higher flSpraySpeed *= 2; // Double the speed to make them fly higher
// in the air. // in the air.
} }
// Spawn small particles at the explosion origin. // Spawn small particles at the explosion origin.
SpawnExplosionParticles( SpawnExplosionParticles(
vecSpraySpot, // position vecSpraySpot, // position
pTrace->vecPlaneNormal, // direction pTrace->vecPlaneNormal, // direction
g_sModelIndexTinySpit, // modelindex g_sModelIndexTinySpit, // modelindex
RANDOM_LONG(40, 50), // count RANDOM_LONG(40, 50), // count
flSpraySpeed, // speed flSpraySpeed, // speed
RANDOM_FLOAT(600, 640)); // noise RANDOM_FLOAT(600, 640)); // noise
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_SPRITE ); WRITE_BYTE( TE_SPRITE );
WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->origin.z );
WRITE_SHORT( RANDOM_LONG( 0, 1 ) ? gSporeExplode : gSporeExplodeC ); WRITE_SHORT( RANDOM_LONG( 0, 1 ) ? gSporeExplode : gSporeExplodeC );
WRITE_BYTE( 25 ); // scale * 10 WRITE_BYTE( 25 ); // scale * 10
WRITE_BYTE( 155 ); // framerate WRITE_BYTE( 155 ); // framerate
MESSAGE_END(); MESSAGE_END();
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE(TE_DLIGHT); WRITE_BYTE(TE_DLIGHT);
WRITE_COORD( pev->origin.x ); // X WRITE_COORD( pev->origin.x ); // X
WRITE_COORD( pev->origin.y ); // Y WRITE_COORD( pev->origin.y ); // Y
WRITE_COORD( pev->origin.z ); // Z WRITE_COORD( pev->origin.z ); // Z
WRITE_BYTE( 12 ); // radius * 0.1 WRITE_BYTE( 12 ); // radius * 0.1
WRITE_BYTE( 0 ); // r WRITE_BYTE( 0 ); // r
WRITE_BYTE( 180 ); // g WRITE_BYTE( 180 ); // g
WRITE_BYTE( 0 ); // b WRITE_BYTE( 0 ); // b
WRITE_BYTE( 20 ); // time * 10 WRITE_BYTE( 20 ); // time * 10
WRITE_BYTE( 20 ); // decay * 0.1 WRITE_BYTE( 20 ); // decay * 0.1
MESSAGE_END( ); MESSAGE_END( );
// Play explode sound. // Play explode sound.
EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/splauncher_impact.wav", 1, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/splauncher_impact.wav", 1, ATTN_NORM);
entvars_t *pevOwner; entvars_t *pevOwner;
if (pev->owner) if (pev->owner)
pevOwner = VARS(pev->owner); pevOwner = VARS(pev->owner);
else else
pevOwner = NULL; pevOwner = NULL;
pev->owner = NULL; // can't traceline attack owner if this is set pev->owner = NULL; // can't traceline attack owner if this is set
RadiusDamage(pev, pevOwner, pev->dmg, CLASS_NONE, DMG_BLAST); RadiusDamage(pev, pevOwner, pev->dmg, CLASS_NONE, DMG_BLAST);
// Place a decal on the surface that was hit. // Place a decal on the surface that was hit.
UTIL_DecalTrace(pTrace, DECAL_SPIT1 + RANDOM_LONG(0, 1)); UTIL_DecalTrace(pTrace, DECAL_SPIT1 + RANDOM_LONG(0, 1));
UpdateOnRemove(); UpdateOnRemove();
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
} }
void CMSporeGrenade::Detonate() void CMSporeGrenade::Detonate()
{ {
TraceResult tr; TraceResult tr;
Vector vecSpot = pev->origin + Vector(0, 0, 8); Vector vecSpot = pev->origin + Vector(0, 0, 8);
UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -40), ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -40), ignore_monsters, ENT(pev), &tr);
Explode(&tr); Explode(&tr);
} }
void CMSporeGrenade::BounceSound() void CMSporeGrenade::BounceSound()
{ {
EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/splauncher_bounce.wav", 0.25, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/splauncher_bounce.wav", 0.25, ATTN_NORM);
} }
void CMSporeGrenade::TumbleThink() void CMSporeGrenade::TumbleThink()
{ {
if (!IsInWorld()) if (!IsInWorld())
{ {
UpdateOnRemove(); UpdateOnRemove();
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
return; return;
} }
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
if (pev->dmgtime <= gpGlobals->time) if (pev->dmgtime <= gpGlobals->time)
{ {
SetThink(&CMSporeGrenade::Detonate); SetThink(&CMSporeGrenade::Detonate);
} }
// Spawn particles. // Spawn particles.
SpawnTrailParticles( SpawnTrailParticles(
pev->origin, // position pev->origin, // position
-pev->velocity.Normalize(), // dir -pev->velocity.Normalize(), // dir
g_sModelIndexTinySpit, // modelindex g_sModelIndexTinySpit, // modelindex
RANDOM_LONG( 2, 4 ), // count RANDOM_LONG( 2, 4 ), // count
RANDOM_FLOAT(10, 15), // speed RANDOM_FLOAT(10, 15), // speed
RANDOM_FLOAT(2, 3) * 100); // noise ( client will divide by 100 ) RANDOM_FLOAT(2, 3) * 100); // noise ( client will divide by 100 )
} }
// //
// Contact grenade, explode when it touches something // Contact grenade, explode when it touches something
// //
void CMSporeGrenade::ExplodeTouch(edict_t *pOther) void CMSporeGrenade::ExplodeTouch(edict_t *pOther)
{ {
TraceResult tr; TraceResult tr;
Vector vecSpot;// trace starts here! Vector vecSpot;// trace starts here!
pev->enemy = pOther; pev->enemy = pOther;
vecSpot = pev->origin - pev->velocity.Normalize() * 32; vecSpot = pev->origin - pev->velocity.Normalize() * 32;
UTIL_TraceLine(vecSpot, vecSpot + pev->velocity.Normalize() * 64, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot, vecSpot + pev->velocity.Normalize() * 64, ignore_monsters, ENT(pev), &tr);
Explode(&tr); Explode(&tr);
} }
void CMSporeGrenade::DangerSoundThink() void CMSporeGrenade::DangerSoundThink()
{ {
if (!IsInWorld()) if (!IsInWorld())
{ {
UpdateOnRemove(); UpdateOnRemove();
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
return; return;
} }
pev->nextthink = gpGlobals->time + 0.2; pev->nextthink = gpGlobals->time + 0.2;
// Spawn particles. // Spawn particles.
SpawnTrailParticles( SpawnTrailParticles(
pev->origin, // position pev->origin, // position
-pev->velocity.Normalize(), // dir -pev->velocity.Normalize(), // dir
g_sModelIndexTinySpit, // modelindex g_sModelIndexTinySpit, // modelindex
RANDOM_LONG( 5, 10), // count RANDOM_LONG( 5, 10), // count
RANDOM_FLOAT(10, 15), // speed RANDOM_FLOAT(10, 15), // speed
RANDOM_FLOAT(2, 3) * 100); // noise ( client will divide by 100 ) RANDOM_FLOAT(2, 3) * 100); // noise ( client will divide by 100 )
} }
void CMSporeGrenade::BounceTouch(edict_t *pOther) void CMSporeGrenade::BounceTouch(edict_t *pOther)
{ {
if ( !pOther->v.takedamage ) if ( !pOther->v.takedamage )
{ {
if (!(pev->flags & FL_ONGROUND)) { if (!(pev->flags & FL_ONGROUND)) {
if (pev->dmg_save < gpGlobals->time) { if (pev->dmg_save < gpGlobals->time) {
BounceSound(); BounceSound();
pev->dmg_save = gpGlobals->time + 0.1; pev->dmg_save = gpGlobals->time + 0.1;
} }
} else { } else {
pev->velocity = pev->velocity * 0.9; pev->velocity = pev->velocity * 0.9;
} }
if (pev->flags & FL_SWIM) if (pev->flags & FL_SWIM)
{ {
pev->velocity = pev->velocity * 0.5; pev->velocity = pev->velocity * 0.5;
} }
} }
else else
{ {
TraceResult tr = UTIL_GetGlobalTrace(); TraceResult tr = UTIL_GetGlobalTrace();
Explode(&tr); Explode(&tr);
} }
} }
void CMSporeGrenade::Spawn() void CMSporeGrenade::Spawn()
{ {
Precache(); Precache();
pev->classname = MAKE_STRING("spore"); pev->classname = MAKE_STRING("spore");
pev->movetype = MOVETYPE_BOUNCE; pev->movetype = MOVETYPE_BOUNCE;
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pev), "models/spore.mdl"); SET_MODEL(ENT(pev), "models/spore.mdl");
UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0));
//pev->gravity = 0.5; //pev->gravity = 0.5;
pev->dmg = gSkillData.monDmgSpore; pev->dmg = gSkillData.monDmgSpore;
m_pSporeGlow = CMSprite::SpriteCreate("sprites/glow02.spr", pev->origin, FALSE); m_pSporeGlow = CMSprite::SpriteCreate("sprites/glow02.spr", pev->origin, FALSE);
if (m_pSporeGlow) if (m_pSporeGlow)
{ {
m_pSporeGlow->SetTransparency(kRenderGlow, 150, 158, 19, 155, kRenderFxNoDissipation); m_pSporeGlow->SetTransparency(kRenderGlow, 150, 158, 19, 155, kRenderFxNoDissipation);
m_pSporeGlow->SetAttachment(edict(), 0); m_pSporeGlow->SetAttachment(edict(), 0);
m_pSporeGlow->SetScale(.75f); m_pSporeGlow->SetScale(.75f);
} }
} }
CMSporeGrenade* CMSporeGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, bool ai) CMSporeGrenade* CMSporeGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, bool ai)
{ {
CMSporeGrenade *pGrenade = CreateClassPtr((CMSporeGrenade *)NULL); CMSporeGrenade *pGrenade = CreateClassPtr((CMSporeGrenade *)NULL);
if (pGrenade == NULL) if (pGrenade == NULL)
return NULL; return NULL;
UTIL_SetOrigin(pGrenade->pev, vecStart); UTIL_SetOrigin(pGrenade->pev, vecStart);
pGrenade->Spawn(); pGrenade->Spawn();
pGrenade->pev->velocity = vecVelocity; pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner); pGrenade->pev->owner = ENT(pevOwner);
pGrenade->SetTouch(&CMSporeGrenade::BounceTouch); // Bounce if touched pGrenade->SetTouch(&CMSporeGrenade::BounceTouch); // Bounce if touched
float lifetime = 2.0; float lifetime = 2.0;
if (ai) { if (ai) {
lifetime = 4.0; lifetime = 4.0;
pGrenade->pev->gravity = 0.5; pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.9; pGrenade->pev->friction = 0.9;
} }
pGrenade->pev->dmgtime = gpGlobals->time + lifetime; pGrenade->pev->dmgtime = gpGlobals->time + lifetime;
pGrenade->SetThink(&CMSporeGrenade::TumbleThink); pGrenade->SetThink(&CMSporeGrenade::TumbleThink);
pGrenade->pev->nextthink = gpGlobals->time + 0.1; pGrenade->pev->nextthink = gpGlobals->time + 0.1;
if (lifetime < 0.1) if (lifetime < 0.1)
{ {
pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->nextthink = gpGlobals->time;
pGrenade->pev->velocity = Vector(0, 0, 0); pGrenade->pev->velocity = Vector(0, 0, 0);
} }
return pGrenade; return pGrenade;
} }
CMSporeGrenade *CMSporeGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) CMSporeGrenade *CMSporeGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity)
{ {
CMSporeGrenade *pGrenade = CreateClassPtr((CMSporeGrenade *)NULL); CMSporeGrenade *pGrenade = CreateClassPtr((CMSporeGrenade *)NULL);
if (pGrenade == NULL) if (pGrenade == NULL)
return NULL; return NULL;
UTIL_SetOrigin(pGrenade->pev, vecStart); UTIL_SetOrigin(pGrenade->pev, vecStart);
pGrenade->Spawn(); pGrenade->Spawn();
pGrenade->pev->movetype = MOVETYPE_FLY; pGrenade->pev->movetype = MOVETYPE_FLY;
pGrenade->pev->velocity = vecVelocity; pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner); pGrenade->pev->owner = ENT(pevOwner);
// make monsters afraid of it while in the air // make monsters afraid of it while in the air
pGrenade->SetThink(&CMSporeGrenade::DangerSoundThink); pGrenade->SetThink(&CMSporeGrenade::DangerSoundThink);
pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->nextthink = gpGlobals->time;
// Explode on contact // Explode on contact
pGrenade->SetTouch(&CMSporeGrenade::ExplodeTouch); pGrenade->SetTouch(&CMSporeGrenade::ExplodeTouch);
pGrenade->pev->gravity = 0.5; pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.7; pGrenade->pev->friction = 0.7;
return pGrenade; return pGrenade;
} }
void CMSporeGrenade::SpawnTrailParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise) void CMSporeGrenade::SpawnTrailParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise)
{ {
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, origin); MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, origin);
WRITE_BYTE(TE_SPRITE_SPRAY); WRITE_BYTE(TE_SPRITE_SPRAY);
WRITE_COORD(origin.x); // pos WRITE_COORD(origin.x); // pos
WRITE_COORD(origin.y); WRITE_COORD(origin.y);
WRITE_COORD(origin.z); WRITE_COORD(origin.z);
WRITE_COORD(direction.x); // dir WRITE_COORD(direction.x); // dir
WRITE_COORD(direction.y); WRITE_COORD(direction.y);
WRITE_COORD(direction.z); WRITE_COORD(direction.z);
WRITE_SHORT(modelindex); // model WRITE_SHORT(modelindex); // model
WRITE_BYTE(count); // count WRITE_BYTE(count); // count
WRITE_BYTE(speed); // speed WRITE_BYTE(speed); // speed
WRITE_BYTE(noise); // noise ( client will divide by 100 ) WRITE_BYTE(noise); // noise ( client will divide by 100 )
MESSAGE_END(); MESSAGE_END();
} }
void CMSporeGrenade::SpawnExplosionParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise) void CMSporeGrenade::SpawnExplosionParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise)
{ {
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, origin); MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, origin);
WRITE_BYTE(TE_SPRITE_SPRAY); WRITE_BYTE(TE_SPRITE_SPRAY);
WRITE_COORD(origin.x); // pos WRITE_COORD(origin.x); // pos
WRITE_COORD(origin.y); WRITE_COORD(origin.y);
WRITE_COORD(origin.z); WRITE_COORD(origin.z);
WRITE_COORD(direction.x); // dir WRITE_COORD(direction.x); // dir
WRITE_COORD(direction.y); WRITE_COORD(direction.y);
WRITE_COORD(direction.z); WRITE_COORD(direction.z);
WRITE_SHORT(modelindex); // model WRITE_SHORT(modelindex); // model
WRITE_BYTE(count); // count WRITE_BYTE(count); // count
WRITE_BYTE(speed); // speed WRITE_BYTE(speed); // speed
WRITE_BYTE(noise); // noise ( client will divide by 100 ) WRITE_BYTE(noise); // noise ( client will divide by 100 )
MESSAGE_END(); MESSAGE_END();
} }
void CMSporeGrenade::UpdateOnRemove() void CMSporeGrenade::UpdateOnRemove()
{ {
CMBaseMonster::UpdateOnRemove(); CMBaseMonster::UpdateOnRemove();
if (m_pSporeGlow) if (m_pSporeGlow)
{ {
UTIL_Remove(m_pSporeGlow->edict()); UTIL_Remove(m_pSporeGlow->edict());
m_pSporeGlow = NULL; m_pSporeGlow = NULL;
} }
} }

View File

@@ -1,350 +1,350 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "weapons.h" #include "weapons.h"
#include "nodes.h" #include "nodes.h"
enum w_squeak_e { enum w_squeak_e {
WSQUEAK_IDLE1 = 0, WSQUEAK_IDLE1 = 0,
WSQUEAK_FIDGET, WSQUEAK_FIDGET,
WSQUEAK_JUMP, WSQUEAK_JUMP,
WSQUEAK_RUN, WSQUEAK_RUN,
}; };
enum squeak_e { enum squeak_e {
SQUEAK_IDLE1 = 0, SQUEAK_IDLE1 = 0,
SQUEAK_FIDGETFIT, SQUEAK_FIDGETFIT,
SQUEAK_FIDGETNIP, SQUEAK_FIDGETNIP,
SQUEAK_DOWN, SQUEAK_DOWN,
SQUEAK_UP, SQUEAK_UP,
SQUEAK_THROW SQUEAK_THROW
}; };
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
float CMSqueakGrenade::m_flNextBounceSoundTime = 0; float CMSqueakGrenade::m_flNextBounceSoundTime = 0;
#define SQUEEK_DETONATE_DELAY 15.0 #define SQUEEK_DETONATE_DELAY 15.0
int CMSqueakGrenade :: Classify ( void ) int CMSqueakGrenade :: Classify ( void )
{ {
// E // E
if ( m_iClassifyOverride == -1 ) // helper if ( m_iClassifyOverride == -1 ) // helper
return CLASS_NONE; return CLASS_NONE;
else if ( m_iClassifyOverride > 0 ) else if ( m_iClassifyOverride > 0 )
return m_iClassifyOverride; // override return m_iClassifyOverride; // override
return CLASS_ALIEN_MONSTER; return CLASS_ALIEN_MONSTER;
} }
void CMSqueakGrenade :: Spawn( void ) void CMSqueakGrenade :: Spawn( void )
{ {
Precache( ); Precache( );
// motor // motor
pev->movetype = MOVETYPE_BOUNCE; pev->movetype = MOVETYPE_BOUNCE;
pev->solid = SOLID_BBOX; pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pev), "models/w_squeak.mdl"); SET_MODEL(ENT(pev), "models/w_squeak.mdl");
UTIL_SetSize(pev, Vector( -4, -4, 0), Vector(4, 4, 8)); UTIL_SetSize(pev, Vector( -4, -4, 0), Vector(4, 4, 8));
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
SetTouch( &CMSqueakGrenade::SuperBounceTouch ); SetTouch( &CMSqueakGrenade::SuperBounceTouch );
SetThink( &CMSqueakGrenade::HuntThink ); SetThink( &CMSqueakGrenade::HuntThink );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
m_flNextHunt = gpGlobals->time + 1E6; m_flNextHunt = gpGlobals->time + 1E6;
pev->flags |= FL_MONSTER; pev->flags |= FL_MONSTER;
pev->takedamage = DAMAGE_AIM; pev->takedamage = DAMAGE_AIM;
pev->health = gSkillData.snarkHealth; pev->health = gSkillData.snarkHealth;
pev->gravity = 0.5; pev->gravity = 0.5;
pev->friction = 0.5; pev->friction = 0.5;
pev->dmg = gSkillData.snarkDmgPop; pev->dmg = gSkillData.snarkDmgPop;
m_flDie = gpGlobals->time + SQUEEK_DETONATE_DELAY; m_flDie = gpGlobals->time + SQUEEK_DETONATE_DELAY;
m_flFieldOfView = 0; // 180 degrees m_flFieldOfView = 0; // 180 degrees
m_flNextBounceSoundTime = gpGlobals->time;// reset each time a snark is spawned. m_flNextBounceSoundTime = gpGlobals->time;// reset each time a snark is spawned.
pev->sequence = WSQUEAK_RUN; pev->sequence = WSQUEAK_RUN;
ResetSequenceInfo( ); ResetSequenceInfo( );
m_hEnemy = NULL; m_hEnemy = NULL;
pev->classname = MAKE_STRING( "monster_snark" ); pev->classname = MAKE_STRING( "monster_snark" );
if ( strlen( STRING( m_szMonsterName ) ) == 0 ) if ( strlen( STRING( m_szMonsterName ) ) == 0 )
{ {
// hi :3 // hi :3
m_szMonsterName = MAKE_STRING( "Snark" ); m_szMonsterName = MAKE_STRING( "Snark" );
} }
} }
void CMSqueakGrenade::Precache( void ) void CMSqueakGrenade::Precache( void )
{ {
PRECACHE_MODEL("models/w_squeak.mdl"); PRECACHE_MODEL("models/w_squeak.mdl");
PRECACHE_SOUND("squeek/sqk_blast1.wav"); PRECACHE_SOUND("squeek/sqk_blast1.wav");
PRECACHE_SOUND("common/bodysplat.wav"); PRECACHE_SOUND("common/bodysplat.wav");
PRECACHE_SOUND("squeek/sqk_die1.wav"); PRECACHE_SOUND("squeek/sqk_die1.wav");
PRECACHE_SOUND("squeek/sqk_hunt1.wav"); PRECACHE_SOUND("squeek/sqk_hunt1.wav");
PRECACHE_SOUND("squeek/sqk_hunt2.wav"); PRECACHE_SOUND("squeek/sqk_hunt2.wav");
PRECACHE_SOUND("squeek/sqk_hunt3.wav"); PRECACHE_SOUND("squeek/sqk_hunt3.wav");
PRECACHE_SOUND("squeek/sqk_deploy1.wav"); PRECACHE_SOUND("squeek/sqk_deploy1.wav");
} }
void CMSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib ) void CMSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib )
{ {
pev->model = iStringNull;// make invisible pev->model = iStringNull;// make invisible
SetThink( &CMSqueakGrenade::SUB_Remove ); SetThink( &CMSqueakGrenade::SUB_Remove );
SetTouch( NULL ); SetTouch( NULL );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
// since squeak grenades never leave a body behind, clear out their takedamage now. // since squeak grenades never leave a body behind, clear out their takedamage now.
// Squeaks do a bit of radius damage when they pop, and that radius damage will // Squeaks do a bit of radius damage when they pop, and that radius damage will
// continue to call this function unless we acknowledge the Squeak's death now. (sjb) // continue to call this function unless we acknowledge the Squeak's death now. (sjb)
pev->takedamage = DAMAGE_NO; pev->takedamage = DAMAGE_NO;
// play squeek blast // play squeek blast
EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM); EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM);
UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 );
RadiusDamage ( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); RadiusDamage ( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST );
CMBaseMonster :: Killed( pevAttacker, GIB_ALWAYS ); CMBaseMonster :: Killed( pevAttacker, GIB_ALWAYS );
} }
void CMSqueakGrenade :: GibMonster( void ) void CMSqueakGrenade :: GibMonster( void )
{ {
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200); EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200);
} }
void CMSqueakGrenade::HuntThink( void ) void CMSqueakGrenade::HuntThink( void )
{ {
// ALERT( at_console, "think\n" ); // ALERT( at_console, "think\n" );
if (!IsInWorld()) if (!IsInWorld())
{ {
SetTouch( NULL ); SetTouch( NULL );
UTIL_Remove( this->edict() ); UTIL_Remove( this->edict() );
return; return;
} }
StudioFrameAdvance( ); StudioFrameAdvance( );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
// explode when ready // explode when ready
if (gpGlobals->time >= m_flDie) if (gpGlobals->time >= m_flDie)
{ {
g_vecAttackDir = pev->velocity.Normalize( ); g_vecAttackDir = pev->velocity.Normalize( );
pev->health = -1; pev->health = -1;
Killed( pev, 0 ); Killed( pev, 0 );
return; return;
} }
// float // float
if (pev->waterlevel != 0) if (pev->waterlevel != 0)
{ {
if (pev->movetype == MOVETYPE_BOUNCE) if (pev->movetype == MOVETYPE_BOUNCE)
{ {
pev->movetype = MOVETYPE_FLY; pev->movetype = MOVETYPE_FLY;
} }
pev->velocity = pev->velocity * 0.9; pev->velocity = pev->velocity * 0.9;
pev->velocity.z += 8.0; pev->velocity.z += 8.0;
} }
else if (pev->movetype = MOVETYPE_FLY) else if (pev->movetype = MOVETYPE_FLY)
{ {
pev->movetype = MOVETYPE_BOUNCE; pev->movetype = MOVETYPE_BOUNCE;
} }
// return if not time to hunt // return if not time to hunt
if (m_flNextHunt > gpGlobals->time) if (m_flNextHunt > gpGlobals->time)
return; return;
m_flNextHunt = gpGlobals->time + 2.0; m_flNextHunt = gpGlobals->time + 2.0;
Vector vecDir; Vector vecDir;
TraceResult tr; TraceResult tr;
Vector vecFlat = pev->velocity; Vector vecFlat = pev->velocity;
vecFlat.z = 0; vecFlat.z = 0;
vecFlat = vecFlat.Normalize( ); vecFlat = vecFlat.Normalize( );
UTIL_MakeVectors( pev->angles ); UTIL_MakeVectors( pev->angles );
if (m_hEnemy == NULL || !UTIL_IsAlive(m_hEnemy)) if (m_hEnemy == NULL || !UTIL_IsAlive(m_hEnemy))
{ {
// find target, bounce a bit towards it. // find target, bounce a bit towards it.
Look( 512 ); Look( 512 );
m_hEnemy = BestVisibleEnemy( ); m_hEnemy = BestVisibleEnemy( );
} }
// squeek if it's about time blow up // squeek if it's about time blow up
if ((m_flDie - gpGlobals->time <= 0.5) && (m_flDie - gpGlobals->time >= 0.3)) if ((m_flDie - gpGlobals->time <= 0.5) && (m_flDie - gpGlobals->time >= 0.3))
{ {
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + RANDOM_LONG(0,0x3F)); EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + RANDOM_LONG(0,0x3F));
} }
// higher pitch as squeeker gets closer to detonation time // higher pitch as squeeker gets closer to detonation time
float flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY); float flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY);
if (flpitch < 80) if (flpitch < 80)
flpitch = 80; flpitch = 80;
if (m_hEnemy != NULL) if (m_hEnemy != NULL)
{ {
if (UTIL_FVisible( m_hEnemy, ENT(pev) )) if (UTIL_FVisible( m_hEnemy, ENT(pev) ))
{ {
vecDir = (m_hEnemy->v.origin + m_hEnemy->v.view_ofs) - pev->origin; vecDir = (m_hEnemy->v.origin + m_hEnemy->v.view_ofs) - pev->origin;
m_vecTarget = vecDir.Normalize( ); m_vecTarget = vecDir.Normalize( );
} }
float flVel = pev->velocity.Length(); float flVel = pev->velocity.Length();
float flAdj = 50.0 / (flVel + 10.0); float flAdj = 50.0 / (flVel + 10.0);
if (flAdj > 1.2) if (flAdj > 1.2)
flAdj = 1.2; flAdj = 1.2;
// ALERT( at_console, "think : enemy\n"); // ALERT( at_console, "think : enemy\n");
// ALERT( at_console, "%.0f %.2f %.2f %.2f\n", flVel, m_vecTarget.x, m_vecTarget.y, m_vecTarget.z ); // ALERT( at_console, "%.0f %.2f %.2f %.2f\n", flVel, m_vecTarget.x, m_vecTarget.y, m_vecTarget.z );
pev->velocity = pev->velocity * flAdj + m_vecTarget * 300; pev->velocity = pev->velocity * flAdj + m_vecTarget * 300;
} }
if (pev->flags & FL_ONGROUND) if (pev->flags & FL_ONGROUND)
{ {
pev->avelocity = Vector( 0, 0, 0 ); pev->avelocity = Vector( 0, 0, 0 );
} }
else else
{ {
if (pev->avelocity == Vector( 0, 0, 0)) if (pev->avelocity == Vector( 0, 0, 0))
{ {
pev->avelocity.x = RANDOM_FLOAT( -100, 100 ); pev->avelocity.x = RANDOM_FLOAT( -100, 100 );
pev->avelocity.z = RANDOM_FLOAT( -100, 100 ); pev->avelocity.z = RANDOM_FLOAT( -100, 100 );
} }
} }
if ((pev->origin - m_posPrev).Length() < 1.0) if ((pev->origin - m_posPrev).Length() < 1.0)
{ {
pev->velocity.x = RANDOM_FLOAT( -100, 100 ); pev->velocity.x = RANDOM_FLOAT( -100, 100 );
pev->velocity.y = RANDOM_FLOAT( -100, 100 ); pev->velocity.y = RANDOM_FLOAT( -100, 100 );
} }
m_posPrev = pev->origin; m_posPrev = pev->origin;
pev->angles = UTIL_VecToAngles( pev->velocity ); pev->angles = UTIL_VecToAngles( pev->velocity );
pev->angles.z = 0; pev->angles.z = 0;
pev->angles.x = 0; pev->angles.x = 0;
} }
void CMSqueakGrenade::SuperBounceTouch( edict_t *pOther ) void CMSqueakGrenade::SuperBounceTouch( edict_t *pOther )
{ {
float flpitch; float flpitch;
TraceResult tr = UTIL_GetGlobalTrace( ); TraceResult tr = UTIL_GetGlobalTrace( );
// don't hit the guy that launched this grenade // don't hit the guy that launched this grenade
if ( pev->owner && (pOther == pev->owner) ) if ( pev->owner && (pOther == pev->owner) )
return; return;
// at least until we've bounced once // at least until we've bounced once
pev->owner = NULL; pev->owner = NULL;
pev->angles.x = 0; pev->angles.x = 0;
pev->angles.z = 0; pev->angles.z = 0;
// avoid bouncing too much // avoid bouncing too much
if (m_flNextHit > gpGlobals->time) if (m_flNextHit > gpGlobals->time)
return; return;
// higher pitch as squeeker gets closer to detonation time // higher pitch as squeeker gets closer to detonation time
flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY); flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY);
if ( pOther->v.takedamage && m_flNextAttack < gpGlobals->time ) if ( pOther->v.takedamage && m_flNextAttack < gpGlobals->time )
{ {
// attack! // attack!
// make sure it's me who has touched them // make sure it's me who has touched them
if (tr.pHit == pOther) if (tr.pHit == pOther)
{ {
// and it's not another squeakgrenade // and it's not another squeakgrenade
if (tr.pHit->v.modelindex != pev->modelindex) if (tr.pHit->v.modelindex != pev->modelindex)
{ {
// ALERT( at_console, "hit enemy\n"); // ALERT( at_console, "hit enemy\n");
ClearMultiDamage( ); ClearMultiDamage( );
if (UTIL_IsPlayer(pOther)) if (UTIL_IsPlayer(pOther))
UTIL_TraceAttack(pOther, pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); UTIL_TraceAttack(pOther, pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH );
else if (pOther->v.euser4 != NULL) else if (pOther->v.euser4 != NULL)
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
pMonster->TraceAttack(pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); pMonster->TraceAttack(pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH );
} }
ApplyMultiDamage( pev, pev ); ApplyMultiDamage( pev, pev );
pev->dmg += gSkillData.snarkDmgPop; // add more explosion damage pev->dmg += gSkillData.snarkDmgPop; // add more explosion damage
// m_flDie += 2.0; // add more life // m_flDie += 2.0; // add more life
// make bite sound // make bite sound
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0, ATTN_NORM, 0, (int)flpitch); EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0, ATTN_NORM, 0, (int)flpitch);
m_flNextAttack = gpGlobals->time + 0.5; m_flNextAttack = gpGlobals->time + 0.5;
} }
} }
else else
{ {
// ALERT( at_console, "been hit\n"); // ALERT( at_console, "been hit\n");
} }
} }
m_flNextHit = gpGlobals->time + 0.1; m_flNextHit = gpGlobals->time + 0.1;
m_flNextHunt = gpGlobals->time; m_flNextHunt = gpGlobals->time;
// in multiplayer, we limit how often snarks can make their bounce sounds to prevent overflows. // in multiplayer, we limit how often snarks can make their bounce sounds to prevent overflows.
if ( gpGlobals->time < m_flNextBounceSoundTime ) if ( gpGlobals->time < m_flNextBounceSoundTime )
{ {
// too soon! // too soon!
return; return;
} }
if (!(pev->flags & FL_ONGROUND)) if (!(pev->flags & FL_ONGROUND))
{ {
// play bounce sound // play bounce sound
float flRndSound = RANDOM_FLOAT ( 0 , 1 ); float flRndSound = RANDOM_FLOAT ( 0 , 1 );
if ( flRndSound <= 0.33 ) if ( flRndSound <= 0.33 )
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch); EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch);
else if (flRndSound <= 0.66) else if (flRndSound <= 0.66)
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch); EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch);
else else
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch); EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch);
} }
m_flNextBounceSoundTime = gpGlobals->time + 0.5;// half second. m_flNextBounceSoundTime = gpGlobals->time + 0.5;// half second.
} }
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,470 +1,470 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
===== subs.cpp ======================================================== ===== subs.cpp ========================================================
frequently used global functions frequently used global functions
*/ */
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "nodes.h" #include "nodes.h"
#include "doors.h" #include "doors.h"
extern CGraph WorldGraph; extern CGraph WorldGraph;
extern BOOL FEntIsVisible(entvars_t* pev, entvars_t* pevTarget); extern BOOL FEntIsVisible(entvars_t* pev, entvars_t* pevTarget);
void Remove_Entity(edict_t *pEdict); void Remove_Entity(edict_t *pEdict);
// Landmark class // Landmark class
void CMPointEntity :: Spawn( void ) void CMPointEntity :: Spawn( void )
{ {
pev->solid = SOLID_NOT; pev->solid = SOLID_NOT;
// UTIL_SetSize(pev, g_vecZero, g_vecZero); // UTIL_SetSize(pev, g_vecZero, g_vecZero);
} }
// This updates global tables that need to know about entities being removed // This updates global tables that need to know about entities being removed
void CMBaseEntity::UpdateOnRemove( void ) void CMBaseEntity::UpdateOnRemove( void )
{ {
int i; int i;
if ( FBitSet( pev->flags, FL_GRAPHED ) ) if ( FBitSet( pev->flags, FL_GRAPHED ) )
{ {
// this entity was a LinkEnt in the world node graph, so we must remove it from // this entity was a LinkEnt in the world node graph, so we must remove it from
// the graph since we are removing it from the world. // the graph since we are removing it from the world.
for ( i = 0 ; i < WorldGraph.m_cLinks ; i++ ) for ( i = 0 ; i < WorldGraph.m_cLinks ; i++ )
{ {
if ( WorldGraph.m_pLinkPool [ i ].m_pLinkEnt == pev ) if ( WorldGraph.m_pLinkPool [ i ].m_pLinkEnt == pev )
{ {
// if this link has a link ent which is the same ent that is removing itself, remove it! // if this link has a link ent which is the same ent that is removing itself, remove it!
WorldGraph.m_pLinkPool [ i ].m_pLinkEnt = NULL; WorldGraph.m_pLinkPool [ i ].m_pLinkEnt = NULL;
} }
} }
} }
//jlb if ( pev->globalname ) //jlb if ( pev->globalname )
//jlb gGlobalState.EntitySetState( pev->globalname, GLOBAL_DEAD ); //jlb gGlobalState.EntitySetState( pev->globalname, GLOBAL_DEAD );
} }
// Convenient way to delay removing oneself // Convenient way to delay removing oneself
void CMBaseEntity :: SUB_Remove( void ) void CMBaseEntity :: SUB_Remove( void )
{ {
UpdateOnRemove(); UpdateOnRemove();
if (pev->health > 0) if (pev->health > 0)
{ {
// this situation can screw up monsters who can't tell their entity pointers are invalid. // this situation can screw up monsters who can't tell their entity pointers are invalid.
pev->health = 0; pev->health = 0;
ALERT( at_aiconsole, "SUB_Remove called on entity with health > 0\n"); ALERT( at_aiconsole, "SUB_Remove called on entity with health > 0\n");
} }
// REMOVE_ENTITY(ENT(pev)); // REMOVE_ENTITY(ENT(pev));
Remove_Entity(ENT(pev)); Remove_Entity(ENT(pev));
} }
// Convenient way to explicitly do nothing (passed to functions that require a method) // Convenient way to explicitly do nothing (passed to functions that require a method)
void CMBaseEntity :: SUB_DoNothing( void ) void CMBaseEntity :: SUB_DoNothing( void )
{ {
} }
void CMBaseDelay :: KeyValue( KeyValueData *pkvd ) void CMBaseDelay :: KeyValue( KeyValueData *pkvd )
{ {
if (FStrEq(pkvd->szKeyName, "delay")) if (FStrEq(pkvd->szKeyName, "delay"))
{ {
m_flDelay = atof( pkvd->szValue ); m_flDelay = atof( pkvd->szValue );
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "killtarget")) else if (FStrEq(pkvd->szKeyName, "killtarget"))
{ {
m_iszKillTarget = ALLOC_STRING(pkvd->szValue); m_iszKillTarget = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
{ {
CMBaseEntity::KeyValue( pkvd ); CMBaseEntity::KeyValue( pkvd );
} }
} }
/* /*
============================== ==============================
SUB_UseTargets SUB_UseTargets
If self.delay is set, a DelayedUse entity will be created that will actually If self.delay is set, a DelayedUse entity will be created that will actually
do the SUB_UseTargets after that many seconds have passed. do the SUB_UseTargets after that many seconds have passed.
Removes all entities with a targetname that match self.killtarget, Removes all entities with a targetname that match self.killtarget,
and removes them, so some events can remove other triggers. and removes them, so some events can remove other triggers.
Search for (string)targetname in all entities that Search for (string)targetname in all entities that
match (string)self.target and call their .use function (if they have one) match (string)self.target and call their .use function (if they have one)
============================== ==============================
*/ */
void CMBaseEntity :: SUB_UseTargets( edict_t *pActivator, USE_TYPE useType, float value ) void CMBaseEntity :: SUB_UseTargets( edict_t *pActivator, USE_TYPE useType, float value )
{ {
// //
// fire targets // fire targets
// //
if (!FStringNull(pev->target)) if (!FStringNull(pev->target))
{ {
FireTargets( STRING(pev->target), pActivator, this->edict(), useType, value ); FireTargets( STRING(pev->target), pActivator, this->edict(), useType, value );
} }
} }
void FireTargets( const char *targetName, edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value ) void FireTargets( const char *targetName, edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value )
{ {
edict_t *pentTarget = NULL; edict_t *pentTarget = NULL;
if ( !targetName ) if ( !targetName )
return; return;
ALERT( at_aiconsole, "Firing: (%s)\n", targetName ); ALERT( at_aiconsole, "Firing: (%s)\n", targetName );
for (;;) for (;;)
{ {
pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, targetName); pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, targetName);
if (FNullEnt(pentTarget)) if (FNullEnt(pentTarget))
break; break;
CMBaseEntity *pTarget = CMBaseEntity::Instance( pentTarget ); CMBaseEntity *pTarget = CMBaseEntity::Instance( pentTarget );
if ( pTarget && !(pTarget->pev->flags & FL_KILLME) ) // Don't use dying ents if ( pTarget && !(pTarget->pev->flags & FL_KILLME) ) // Don't use dying ents
{ {
ALERT( at_aiconsole, "Found: %s, firing (%s)\n", STRING(pTarget->pev->classname), targetName ); ALERT( at_aiconsole, "Found: %s, firing (%s)\n", STRING(pTarget->pev->classname), targetName );
pTarget->Use( pActivator, pCaller, useType, value ); pTarget->Use( pActivator, pCaller, useType, value );
} }
} }
} }
void CMBaseDelay :: SUB_UseTargets( edict_t *pActivator, USE_TYPE useType, float value ) void CMBaseDelay :: SUB_UseTargets( edict_t *pActivator, USE_TYPE useType, float value )
{ {
// //
// exit immediatly if we don't have a target or kill target // exit immediatly if we don't have a target or kill target
// //
if (FStringNull(pev->target) && !m_iszKillTarget) if (FStringNull(pev->target) && !m_iszKillTarget)
return; return;
// //
// check for a delay // check for a delay
// //
if (m_flDelay != 0) if (m_flDelay != 0)
{ {
// create a temp object to fire at a later time // create a temp object to fire at a later time
CMBaseDelay *pTemp = CreateClassPtr( (CMBaseDelay *)NULL); CMBaseDelay *pTemp = CreateClassPtr( (CMBaseDelay *)NULL);
if (pTemp == NULL) if (pTemp == NULL)
return; return;
pTemp->pev->classname = MAKE_STRING("DelayedUse"); pTemp->pev->classname = MAKE_STRING("DelayedUse");
pTemp->pev->nextthink = gpGlobals->time + m_flDelay; pTemp->pev->nextthink = gpGlobals->time + m_flDelay;
pTemp->SetThink( &CMBaseDelay::DelayThink ); pTemp->SetThink( &CMBaseDelay::DelayThink );
// Save the useType // Save the useType
pTemp->pev->button = (int)useType; pTemp->pev->button = (int)useType;
pTemp->m_iszKillTarget = m_iszKillTarget; pTemp->m_iszKillTarget = m_iszKillTarget;
pTemp->m_flDelay = 0; // prevent "recursion" pTemp->m_flDelay = 0; // prevent "recursion"
pTemp->pev->target = pev->target; pTemp->pev->target = pev->target;
// HACKHACK // HACKHACK
// This wasn't in the release build of Half-Life. We should have moved m_hActivator into this class // This wasn't in the release build of Half-Life. We should have moved m_hActivator into this class
// but changing member variable hierarchy would break save/restore without some ugly code. // but changing member variable hierarchy would break save/restore without some ugly code.
// This code is not as ugly as that code // This code is not as ugly as that code
if ( pActivator && UTIL_IsPlayer(pActivator) ) // If a player activates, then save it if ( pActivator && UTIL_IsPlayer(pActivator) ) // If a player activates, then save it
{ {
pTemp->pev->owner = pActivator; pTemp->pev->owner = pActivator;
} }
else else
{ {
pTemp->pev->owner = NULL; pTemp->pev->owner = NULL;
} }
return; return;
} }
// //
// kill the killtargets // kill the killtargets
// //
if ( m_iszKillTarget ) if ( m_iszKillTarget )
{ {
edict_t *pentKillTarget = NULL; edict_t *pentKillTarget = NULL;
ALERT( at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget) ); ALERT( at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget) );
pentKillTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_iszKillTarget) ); pentKillTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_iszKillTarget) );
while ( !FNullEnt(pentKillTarget) ) while ( !FNullEnt(pentKillTarget) )
{ {
UTIL_Remove( CMBaseEntity::Instance(pentKillTarget)->edict() ); UTIL_Remove( CMBaseEntity::Instance(pentKillTarget)->edict() );
ALERT( at_aiconsole, "killing %s\n", STRING( pentKillTarget->v.classname ) ); ALERT( at_aiconsole, "killing %s\n", STRING( pentKillTarget->v.classname ) );
pentKillTarget = FIND_ENTITY_BY_TARGETNAME( pentKillTarget, STRING(m_iszKillTarget) ); pentKillTarget = FIND_ENTITY_BY_TARGETNAME( pentKillTarget, STRING(m_iszKillTarget) );
} }
} }
// //
// fire targets // fire targets
// //
if (!FStringNull(pev->target)) if (!FStringNull(pev->target))
{ {
FireTargets( STRING(pev->target), pActivator, this->edict(), useType, value ); FireTargets( STRING(pev->target), pActivator, this->edict(), useType, value );
} }
} }
/* /*
QuakeEd only writes a single float for angles (bad idea), so up and down are QuakeEd only writes a single float for angles (bad idea), so up and down are
just constant angles. just constant angles.
*/ */
void SetMovedir( entvars_t *pev ) void SetMovedir( entvars_t *pev )
{ {
if (pev->angles == Vector(0, -1, 0)) if (pev->angles == Vector(0, -1, 0))
{ {
pev->movedir = Vector(0, 0, 1); pev->movedir = Vector(0, 0, 1);
} }
else if (pev->angles == Vector(0, -2, 0)) else if (pev->angles == Vector(0, -2, 0))
{ {
pev->movedir = Vector(0, 0, -1); pev->movedir = Vector(0, 0, -1);
} }
else else
{ {
UTIL_MakeVectors(pev->angles); UTIL_MakeVectors(pev->angles);
pev->movedir = gpGlobals->v_forward; pev->movedir = gpGlobals->v_forward;
} }
pev->angles = g_vecZero; pev->angles = g_vecZero;
} }
void CMBaseDelay::DelayThink( void ) void CMBaseDelay::DelayThink( void )
{ {
edict_t *pActivator = NULL; edict_t *pActivator = NULL;
if ( pev->owner != NULL ) // A player activated this on delay if ( pev->owner != NULL ) // A player activated this on delay
{ {
pActivator = ENT(pev->owner); pActivator = ENT(pev->owner);
} }
// The use type is cached (and stashed) in pev->button // The use type is cached (and stashed) in pev->button
SUB_UseTargets( pActivator, (USE_TYPE)pev->button, 0 ); SUB_UseTargets( pActivator, (USE_TYPE)pev->button, 0 );
// REMOVE_ENTITY(ENT(pev)); // REMOVE_ENTITY(ENT(pev));
Remove_Entity(ENT(pev)); Remove_Entity(ENT(pev));
} }
void CMBaseToggle::KeyValue( KeyValueData *pkvd ) void CMBaseToggle::KeyValue( KeyValueData *pkvd )
{ {
if (FStrEq(pkvd->szKeyName, "lip")) if (FStrEq(pkvd->szKeyName, "lip"))
{ {
m_flLip = atof(pkvd->szValue); m_flLip = atof(pkvd->szValue);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "wait")) else if (FStrEq(pkvd->szKeyName, "wait"))
{ {
m_flWait = atof(pkvd->szValue); m_flWait = atof(pkvd->szValue);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "master")) else if (FStrEq(pkvd->szKeyName, "master"))
{ {
m_sMaster = ALLOC_STRING(pkvd->szValue); m_sMaster = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else if (FStrEq(pkvd->szKeyName, "distance")) else if (FStrEq(pkvd->szKeyName, "distance"))
{ {
m_flMoveDistance = atof(pkvd->szValue); m_flMoveDistance = atof(pkvd->szValue);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
} }
else else
CMBaseDelay::KeyValue( pkvd ); CMBaseDelay::KeyValue( pkvd );
} }
/* /*
============= =============
LinearMove LinearMove
calculate pev->velocity and pev->nextthink to reach vecDest from calculate pev->velocity and pev->nextthink to reach vecDest from
pev->origin traveling at flSpeed pev->origin traveling at flSpeed
=============== ===============
*/ */
void CMBaseToggle :: LinearMove( Vector vecDest, float flSpeed ) void CMBaseToggle :: LinearMove( Vector vecDest, float flSpeed )
{ {
ASSERTSZ(flSpeed != 0, "LinearMove: no speed is defined!"); ASSERTSZ(flSpeed != 0, "LinearMove: no speed is defined!");
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined"); // ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined");
m_vecFinalDest = vecDest; m_vecFinalDest = vecDest;
// Already there? // Already there?
if (vecDest == pev->origin) if (vecDest == pev->origin)
{ {
LinearMoveDone(); LinearMoveDone();
return; return;
} }
// set destdelta to the vector needed to move // set destdelta to the vector needed to move
Vector vecDestDelta = vecDest - pev->origin; Vector vecDestDelta = vecDest - pev->origin;
// divide vector length by speed to get time to reach dest // divide vector length by speed to get time to reach dest
float flTravelTime = vecDestDelta.Length() / flSpeed; float flTravelTime = vecDestDelta.Length() / flSpeed;
// set nextthink to trigger a call to LinearMoveDone when dest is reached // set nextthink to trigger a call to LinearMoveDone when dest is reached
pev->nextthink = pev->ltime + flTravelTime; pev->nextthink = pev->ltime + flTravelTime;
SetThink( &CMBaseToggle::LinearMoveDone ); SetThink( &CMBaseToggle::LinearMoveDone );
// scale the destdelta vector by the time spent traveling to get velocity // scale the destdelta vector by the time spent traveling to get velocity
pev->velocity = vecDestDelta / flTravelTime; pev->velocity = vecDestDelta / flTravelTime;
} }
/* /*
============ ============
After moving, set origin to exact final destination, call "move done" function After moving, set origin to exact final destination, call "move done" function
============ ============
*/ */
void CMBaseToggle :: LinearMoveDone( void ) void CMBaseToggle :: LinearMoveDone( void )
{ {
UTIL_SetOrigin(pev, m_vecFinalDest); UTIL_SetOrigin(pev, m_vecFinalDest);
pev->velocity = g_vecZero; pev->velocity = g_vecZero;
pev->nextthink = -1; pev->nextthink = -1;
if ( m_pfnCallWhenMoveDone ) if ( m_pfnCallWhenMoveDone )
(this->*m_pfnCallWhenMoveDone)(); (this->*m_pfnCallWhenMoveDone)();
} }
BOOL CMBaseToggle :: IsLockedByMaster( void ) BOOL CMBaseToggle :: IsLockedByMaster( void )
{ {
return FALSE; return FALSE;
} }
/* /*
============= =============
AngularMove AngularMove
calculate pev->velocity and pev->nextthink to reach vecDest from calculate pev->velocity and pev->nextthink to reach vecDest from
pev->origin traveling at flSpeed pev->origin traveling at flSpeed
Just like LinearMove, but rotational. Just like LinearMove, but rotational.
=============== ===============
*/ */
void CMBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed ) void CMBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed )
{ {
ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!"); ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!");
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined"); // ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined");
m_vecFinalAngle = vecDestAngle; m_vecFinalAngle = vecDestAngle;
// Already there? // Already there?
if (vecDestAngle == pev->angles) if (vecDestAngle == pev->angles)
{ {
AngularMoveDone(); AngularMoveDone();
return; return;
} }
// set destdelta to the vector needed to move // set destdelta to the vector needed to move
Vector vecDestDelta = vecDestAngle - pev->angles; Vector vecDestDelta = vecDestAngle - pev->angles;
// divide by speed to get time to reach dest // divide by speed to get time to reach dest
float flTravelTime = vecDestDelta.Length() / flSpeed; float flTravelTime = vecDestDelta.Length() / flSpeed;
// set nextthink to trigger a call to AngularMoveDone when dest is reached // set nextthink to trigger a call to AngularMoveDone when dest is reached
pev->nextthink = pev->ltime + flTravelTime; pev->nextthink = pev->ltime + flTravelTime;
SetThink( &CMBaseToggle::AngularMoveDone ); SetThink( &CMBaseToggle::AngularMoveDone );
// scale the destdelta vector by the time spent traveling to get velocity // scale the destdelta vector by the time spent traveling to get velocity
pev->avelocity = vecDestDelta / flTravelTime; pev->avelocity = vecDestDelta / flTravelTime;
} }
/* /*
============ ============
After rotating, set angle to exact final angle, call "move done" function After rotating, set angle to exact final angle, call "move done" function
============ ============
*/ */
void CMBaseToggle :: AngularMoveDone( void ) void CMBaseToggle :: AngularMoveDone( void )
{ {
pev->angles = m_vecFinalAngle; pev->angles = m_vecFinalAngle;
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
pev->nextthink = -1; pev->nextthink = -1;
if ( m_pfnCallWhenMoveDone ) if ( m_pfnCallWhenMoveDone )
(this->*m_pfnCallWhenMoveDone)(); (this->*m_pfnCallWhenMoveDone)();
} }
float CMBaseToggle :: AxisValue( int flags, const Vector &angles ) float CMBaseToggle :: AxisValue( int flags, const Vector &angles )
{ {
if ( FBitSet(flags, SF_DOOR_ROTATE_Z) ) if ( FBitSet(flags, SF_DOOR_ROTATE_Z) )
return angles.z; return angles.z;
if ( FBitSet(flags, SF_DOOR_ROTATE_X) ) if ( FBitSet(flags, SF_DOOR_ROTATE_X) )
return angles.x; return angles.x;
return angles.y; return angles.y;
} }
void CMBaseToggle :: AxisDir( entvars_t *pev ) void CMBaseToggle :: AxisDir( entvars_t *pev )
{ {
if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_Z) ) if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_Z) )
pev->movedir = Vector ( 0, 0, 1 ); // around z-axis pev->movedir = Vector ( 0, 0, 1 ); // around z-axis
else if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_X) ) else if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_X) )
pev->movedir = Vector ( 1, 0, 0 ); // around x-axis pev->movedir = Vector ( 1, 0, 0 ); // around x-axis
else else
pev->movedir = Vector ( 0, 1, 0 ); // around y-axis pev->movedir = Vector ( 0, 1, 0 ); // around y-axis
} }
float CMBaseToggle :: AxisDelta( int flags, const Vector &angle1, const Vector &angle2 ) float CMBaseToggle :: AxisDelta( int flags, const Vector &angle1, const Vector &angle2 )
{ {
if ( FBitSet (flags, SF_DOOR_ROTATE_Z) ) if ( FBitSet (flags, SF_DOOR_ROTATE_Z) )
return angle1.z - angle2.z; return angle1.z - angle2.z;
if ( FBitSet (flags, SF_DOOR_ROTATE_X) ) if ( FBitSet (flags, SF_DOOR_ROTATE_X) )
return angle1.x - angle2.x; return angle1.x - angle2.x;
return angle1.y - angle2.y; return angle1.y - angle2.y;
} }
/* /*
============= =============
FEntIsVisible FEntIsVisible
returns TRUE if the passed entity is visible to caller, even if not infront () returns TRUE if the passed entity is visible to caller, even if not infront ()
============= =============
*/ */
BOOL BOOL
FEntIsVisible( FEntIsVisible(
entvars_t* pev, entvars_t* pev,
entvars_t* pevTarget) entvars_t* pevTarget)
{ {
Vector vecSpot1 = pev->origin + pev->view_ofs; Vector vecSpot1 = pev->origin + pev->view_ofs;
Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs; Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs;
TraceResult tr; TraceResult tr;
UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr);
if (tr.fInOpen && tr.fInWater) if (tr.fInOpen && tr.fInWater)
return FALSE; // sight line crossed contents return FALSE; // sight line crossed contents
if (tr.flFraction == 1) if (tr.flFraction == 1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

File diff suppressed because it is too large Load Diff

2324
src/dlls/turret.cpp Executable file → Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,112 +1,112 @@
/*** /***
* *
* Copyright (c) 1999, Valve LLC. All rights reserved. * Copyright (c) 1999, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef VECTOR_H #ifndef VECTOR_H
#define VECTOR_H #define VECTOR_H
//========================================================= //=========================================================
// 2DVector - used for many pathfinding and many other // 2DVector - used for many pathfinding and many other
// operations that are treated as planar rather than 3d. // operations that are treated as planar rather than 3d.
//========================================================= //=========================================================
class Vector2D class Vector2D
{ {
public: public:
inline Vector2D(void) { } inline Vector2D(void) { }
inline Vector2D(float X, float Y) { x = X; y = Y; } inline Vector2D(float X, float Y) { x = X; y = Y; }
inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); }
inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); }
inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); }
inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); }
inline float Length(void) const { return sqrt(x*x + y*y ); } inline float Length(void) const { return sqrt(x*x + y*y ); }
inline Vector2D Normalize ( void ) const inline Vector2D Normalize ( void ) const
{ {
Vector2D vec2; Vector2D vec2;
float flLen = Length(); float flLen = Length();
if ( flLen == 0 ) if ( flLen == 0 )
{ {
return Vector2D( 0, 0 ); return Vector2D( 0, 0 );
} }
else else
{ {
flLen = 1 / flLen; flLen = 1 / flLen;
return Vector2D( x * flLen, y * flLen ); return Vector2D( x * flLen, y * flLen );
} }
} }
vec_t x, y; vec_t x, y;
}; };
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); }
inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; }
//========================================================= //=========================================================
// 3D Vector // 3D Vector
//========================================================= //=========================================================
class Vector // same data-layout as engine's vec3_t, class Vector // same data-layout as engine's vec3_t,
{ // which is a vec_t[3] { // which is a vec_t[3]
public: public:
// Construction/destruction // Construction/destruction
inline Vector(void) { } inline Vector(void) { }
inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; } inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; }
//inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } //inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; }
//inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } //inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; }
inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; } inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; }
inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
// Operators // Operators
inline Vector operator-(void) const { return Vector(-x,-y,-z); } inline Vector operator-(void) const { return Vector(-x,-y,-z); }
inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; }
inline int operator!=(const Vector& v) const { return !(*this==v); } inline int operator!=(const Vector& v) const { return !(*this==v); }
inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); }
inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); }
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); }
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); }
// Methods // Methods
inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; }
inline float Length(void) const { return sqrt(x*x + y*y + z*z); } inline float Length(void) const { return sqrt(x*x + y*y + z*z); }
operator float *() { return &x; } // Vectors will now automatically convert to float * when needed operator float *() { return &x; } // Vectors will now automatically convert to float * when needed
operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed
inline Vector Normalize(void) const inline Vector Normalize(void) const
{ {
float flLen = Length(); float flLen = Length();
if (flLen == 0) return Vector(0,0,1); // ???? if (flLen == 0) return Vector(0,0,1); // ????
flLen = 1 / flLen; flLen = 1 / flLen;
return Vector(x * flLen, y * flLen, z * flLen); return Vector(x * flLen, y * flLen, z * flLen);
} }
inline Vector2D Make2D ( void ) const inline Vector2D Make2D ( void ) const
{ {
Vector2D Vec2; Vector2D Vec2;
Vec2.x = x; Vec2.x = x;
Vec2.y = y; Vec2.y = y;
return Vec2; return Vec2;
} }
inline float Length2D(void) const { return sqrt(x*x + y*y); } inline float Length2D(void) const { return sqrt(x*x + y*y); }
// Members // Members
vec_t x, y, z; vec_t x, y, z;
}; };
inline Vector operator*(float fl, const Vector& v) { return v * fl; } inline Vector operator*(float fl, const Vector& v) { return v * fl; }
inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); }
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,232 +1,232 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
===== weapons.cpp ======================================================== ===== weapons.cpp ========================================================
functions governing the selection/use of weapons for players functions governing the selection/use of weapons for players
*/ */
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "weapons.h" #include "weapons.h"
#include "nodes.h" #include "nodes.h"
#include "decals.h" #include "decals.h"
extern CGraph WorldGraph; extern CGraph WorldGraph;
MULTIDAMAGE gMultiDamage; MULTIDAMAGE gMultiDamage;
#define TRACER_FREQ 4 // Tracers fire every fourth bullet #define TRACER_FREQ 4 // Tracers fire every fourth bullet
/* /*
============================================================================== ==============================================================================
MULTI-DAMAGE MULTI-DAMAGE
Collects multiple small damages into a single damage Collects multiple small damages into a single damage
============================================================================== ==============================================================================
*/ */
// //
// ClearMultiDamage - resets the global multi damage accumulator // ClearMultiDamage - resets the global multi damage accumulator
// //
void ClearMultiDamage(void) void ClearMultiDamage(void)
{ {
gMultiDamage.pEntity = NULL; gMultiDamage.pEntity = NULL;
gMultiDamage.amount = 0; gMultiDamage.amount = 0;
gMultiDamage.type = 0; gMultiDamage.type = 0;
} }
// //
// ApplyMultiDamage - inflicts contents of global multi damage register on gMultiDamage.pEntity // ApplyMultiDamage - inflicts contents of global multi damage register on gMultiDamage.pEntity
// //
// GLOBALS USED: // GLOBALS USED:
// gMultiDamage // gMultiDamage
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker )
{ {
Vector vecSpot1;//where blood comes from Vector vecSpot1;//where blood comes from
Vector vecDir;//direction blood should go Vector vecDir;//direction blood should go
TraceResult tr; TraceResult tr;
if ( !gMultiDamage.pEntity ) if ( !gMultiDamage.pEntity )
return; return;
if (UTIL_IsPlayer(gMultiDamage.pEntity)) if (UTIL_IsPlayer(gMultiDamage.pEntity))
UTIL_TakeDamage(gMultiDamage.pEntity, pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type ); UTIL_TakeDamage(gMultiDamage.pEntity, pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
else if (gMultiDamage.pEntity->v.euser4 != NULL) else if (gMultiDamage.pEntity->v.euser4 != NULL)
{ {
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(gMultiDamage.pEntity)); CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(gMultiDamage.pEntity));
pMonster->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type ); pMonster->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
} }
} }
// GLOBALS USED: // GLOBALS USED:
// gMultiDamage // gMultiDamage
void AddMultiDamage( entvars_t *pevInflictor, edict_t *pEntity, float flDamage, int bitsDamageType) void AddMultiDamage( entvars_t *pevInflictor, edict_t *pEntity, float flDamage, int bitsDamageType)
{ {
if ( !pEntity ) if ( !pEntity )
return; return;
gMultiDamage.type |= bitsDamageType; gMultiDamage.type |= bitsDamageType;
if ( pEntity != gMultiDamage.pEntity ) if ( pEntity != gMultiDamage.pEntity )
{ {
ApplyMultiDamage(pevInflictor,pevInflictor); // UNDONE: wrong attacker! ApplyMultiDamage(pevInflictor,pevInflictor); // UNDONE: wrong attacker!
gMultiDamage.pEntity = pEntity; gMultiDamage.pEntity = pEntity;
gMultiDamage.amount = 0; gMultiDamage.amount = 0;
} }
gMultiDamage.amount += flDamage; gMultiDamage.amount += flDamage;
} }
/* /*
================ ================
SpawnBlood SpawnBlood
================ ================
*/ */
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage)
{ {
UTIL_BloodDrips( vecSpot, g_vecAttackDir, bloodColor, (int)flDamage ); UTIL_BloodDrips( vecSpot, g_vecAttackDir, bloodColor, (int)flDamage );
} }
int DamageDecal( CMBaseEntity *pEntity, int bitsDamageType ) int DamageDecal( CMBaseEntity *pEntity, int bitsDamageType )
{ {
if ( !pEntity ) if ( !pEntity )
return (DECAL_GUNSHOT1 + RANDOM_LONG(0,4)); return (DECAL_GUNSHOT1 + RANDOM_LONG(0,4));
return pEntity->DamageDecal( bitsDamageType ); return pEntity->DamageDecal( bitsDamageType );
} }
void DecalGunshot( TraceResult *pTrace, int iBulletType ) void DecalGunshot( TraceResult *pTrace, int iBulletType )
{ {
// Is the entity valid // Is the entity valid
if ( !UTIL_IsValidEntity( pTrace->pHit ) ) if ( !UTIL_IsValidEntity( pTrace->pHit ) )
return; return;
if ( VARS(pTrace->pHit)->solid == SOLID_BSP || VARS(pTrace->pHit)->movetype == MOVETYPE_PUSHSTEP ) if ( VARS(pTrace->pHit)->solid == SOLID_BSP || VARS(pTrace->pHit)->movetype == MOVETYPE_PUSHSTEP )
{ {
CMBaseEntity *pEntity = NULL; CMBaseEntity *pEntity = NULL;
// Decal the wall with a gunshot // Decal the wall with a gunshot
if ( !FNullEnt(pTrace->pHit) ) if ( !FNullEnt(pTrace->pHit) )
pEntity = CMBaseEntity::Instance(pTrace->pHit); pEntity = CMBaseEntity::Instance(pTrace->pHit);
switch( iBulletType ) switch( iBulletType )
{ {
case BULLET_PLAYER_CROWBAR: case BULLET_PLAYER_CROWBAR:
{ {
// wall decal // wall decal
UTIL_DecalTrace( pTrace, DamageDecal( pEntity, DMG_CLUB ) ); UTIL_DecalTrace( pTrace, DamageDecal( pEntity, DMG_CLUB ) );
break; break;
} }
default: default:
{ {
// smoke and decal // smoke and decal
UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) ); UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
break; break;
} }
/* why the duplicate case? /* why the duplicate case?
case BULLET_PLAYER_9MM: case BULLET_PLAYER_9MM:
case BULLET_MONSTER_9MM: case BULLET_MONSTER_9MM:
case BULLET_PLAYER_MP5: case BULLET_PLAYER_MP5:
case BULLET_MONSTER_MP5: case BULLET_MONSTER_MP5:
case BULLET_PLAYER_BUCKSHOT: case BULLET_PLAYER_BUCKSHOT:
case BULLET_PLAYER_357: case BULLET_PLAYER_357:
default: default:
// smoke and decal // smoke and decal
UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) ); UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
break; break;
case BULLET_MONSTER_12MM: case BULLET_MONSTER_12MM:
// smoke and decal // smoke and decal
UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) ); UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
break; break;
case BULLET_PLAYER_CROWBAR: case BULLET_PLAYER_CROWBAR:
// wall decal // wall decal
UTIL_DecalTrace( pTrace, DamageDecal( pEntity, DMG_CLUB ) ); UTIL_DecalTrace( pTrace, DamageDecal( pEntity, DMG_CLUB ) );
break; break;
*/ */
} }
} }
} }
// //
// EjectBrass - tosses a brass shell from passed origin at passed velocity // EjectBrass - tosses a brass shell from passed origin at passed velocity
// //
void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype )
{ {
// FIX: when the player shoots, their gun isn't in the same position as it is on the model other players see. // FIX: when the player shoots, their gun isn't in the same position as it is on the model other players see.
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin );
WRITE_BYTE( TE_MODEL); WRITE_BYTE( TE_MODEL);
WRITE_COORD( vecOrigin.x); WRITE_COORD( vecOrigin.x);
WRITE_COORD( vecOrigin.y); WRITE_COORD( vecOrigin.y);
WRITE_COORD( vecOrigin.z); WRITE_COORD( vecOrigin.z);
WRITE_COORD( vecVelocity.x); WRITE_COORD( vecVelocity.x);
WRITE_COORD( vecVelocity.y); WRITE_COORD( vecVelocity.y);
WRITE_COORD( vecVelocity.z); WRITE_COORD( vecVelocity.z);
WRITE_ANGLE( rotation ); WRITE_ANGLE( rotation );
WRITE_SHORT( model ); WRITE_SHORT( model );
WRITE_BYTE ( soundtype); WRITE_BYTE ( soundtype);
WRITE_BYTE ( 25 );// 2.5 seconds WRITE_BYTE ( 25 );// 2.5 seconds
MESSAGE_END(); MESSAGE_END();
} }
#if 0 #if 0
// UNDONE: This is no longer used? // UNDONE: This is no longer used?
void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ) void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count )
{ {
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin );
WRITE_BYTE ( TE_EXPLODEMODEL ); WRITE_BYTE ( TE_EXPLODEMODEL );
WRITE_COORD( vecOrigin.x ); WRITE_COORD( vecOrigin.x );
WRITE_COORD( vecOrigin.y ); WRITE_COORD( vecOrigin.y );
WRITE_COORD( vecOrigin.z ); WRITE_COORD( vecOrigin.z );
WRITE_COORD( speed ); WRITE_COORD( speed );
WRITE_SHORT( model ); WRITE_SHORT( model );
WRITE_SHORT( count ); WRITE_SHORT( count );
WRITE_BYTE ( 15 );// 1.5 seconds WRITE_BYTE ( 15 );// 1.5 seconds
MESSAGE_END(); MESSAGE_END();
} }
#endif #endif
BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted )
{ {
#if defined( CLIENT_WEAPONS ) #if defined( CLIENT_WEAPONS )
if ( !isPredicted ) if ( !isPredicted )
#else #else
if ( 1 ) if ( 1 )
#endif #endif
{ {
return ( attack_time <= curtime ) ? TRUE : FALSE; return ( attack_time <= curtime ) ? TRUE : FALSE;
} }
else else
{ {
return ( attack_time <= 0.0 ) ? TRUE : FALSE; return ( attack_time <= 0.0 ) ? TRUE : FALSE;
} }
} }

View File

@@ -1,287 +1,287 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef WEAPONS_H #ifndef WEAPONS_H
#define WEAPONS_H #define WEAPONS_H
#include "effects.h" #include "effects.h"
// Contact Grenade / Timed grenade / Satchel Charge // Contact Grenade / Timed grenade / Satchel Charge
class CMGrenade : public CMBaseMonster class CMGrenade : public CMBaseMonster
{ {
public: public:
void Spawn( void ); void Spawn( void );
typedef enum { SATCHEL_DETONATE = 0, SATCHEL_RELEASE } SATCHELCODE; typedef enum { SATCHEL_DETONATE = 0, SATCHEL_RELEASE } SATCHELCODE;
static CMGrenade *ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ); static CMGrenade *ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time );
static CMGrenade *ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ); static CMGrenade *ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity );
static CMGrenade *ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ); static CMGrenade *ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity );
void Explode( Vector vecSrc, Vector vecAim ); void Explode( Vector vecSrc, Vector vecAim );
void Explode( TraceResult *pTrace, int bitsDamageType ); void Explode( TraceResult *pTrace, int bitsDamageType );
void EXPORT Smoke( void ); void EXPORT Smoke( void );
void EXPORT BounceTouch( edict_t *pOther ); void EXPORT BounceTouch( edict_t *pOther );
void EXPORT SlideTouch( edict_t *pOther ); void EXPORT SlideTouch( edict_t *pOther );
void EXPORT ExplodeTouch( edict_t *pOther ); void EXPORT ExplodeTouch( edict_t *pOther );
void EXPORT DangerSoundThink( void ); void EXPORT DangerSoundThink( void );
void EXPORT PreDetonate( void ); void EXPORT PreDetonate( void );
void EXPORT Detonate( void ); void EXPORT Detonate( void );
void EXPORT DetonateUse( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value ); void EXPORT DetonateUse( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value );
void EXPORT TumbleThink( void ); void EXPORT TumbleThink( void );
virtual void BounceSound( void ); virtual void BounceSound( void );
virtual int BloodColor( void ) { return DONT_BLEED; } virtual int BloodColor( void ) { return DONT_BLEED; }
virtual void Killed( entvars_t *pevAttacker, int iGib ); virtual void Killed( entvars_t *pevAttacker, int iGib );
BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet. BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet.
}; };
// Contact/Timed spore grenade // Contact/Timed spore grenade
class CMSporeGrenade : public CMBaseMonster class CMSporeGrenade : public CMBaseMonster
{ {
public: public:
void Precache(void); void Precache(void);
void Spawn(void); void Spawn(void);
static CMSporeGrenade *ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, bool ai); static CMSporeGrenade *ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, bool ai);
static CMSporeGrenade *ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity); static CMSporeGrenade *ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity);
void Explode(TraceResult *pTrace); void Explode(TraceResult *pTrace);
void EXPORT BounceTouch(edict_t *pOther); void EXPORT BounceTouch(edict_t *pOther);
void EXPORT ExplodeTouch(edict_t *pOther); void EXPORT ExplodeTouch(edict_t *pOther);
void EXPORT DangerSoundThink(void); void EXPORT DangerSoundThink(void);
void EXPORT Detonate(void); void EXPORT Detonate(void);
void EXPORT TumbleThink(void); void EXPORT TumbleThink(void);
void BounceSound(void); void BounceSound(void);
void DangerSound(); void DangerSound();
static void SpawnTrailParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise); static void SpawnTrailParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise);
static void SpawnExplosionParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise); static void SpawnExplosionParticles(const Vector& origin, const Vector& direction, int modelindex, int count, float speed, float noise);
void UpdateOnRemove(); void UpdateOnRemove();
CMSprite* m_pSporeGlow; CMSprite* m_pSporeGlow;
}; };
// constant items // constant items
#define ITEM_HEALTHKIT 1 #define ITEM_HEALTHKIT 1
#define ITEM_ANTIDOTE 2 #define ITEM_ANTIDOTE 2
#define ITEM_SECURITY 3 #define ITEM_SECURITY 3
#define ITEM_BATTERY 4 #define ITEM_BATTERY 4
#define WEAPON_NONE 0 #define WEAPON_NONE 0
#define WEAPON_CROWBAR 1 #define WEAPON_CROWBAR 1
#define WEAPON_GLOCK 2 #define WEAPON_GLOCK 2
#define WEAPON_PYTHON 3 #define WEAPON_PYTHON 3
#define WEAPON_MP5 4 #define WEAPON_MP5 4
#define WEAPON_CHAINGUN 5 #define WEAPON_CHAINGUN 5
#define WEAPON_CROSSBOW 6 #define WEAPON_CROSSBOW 6
#define WEAPON_SHOTGUN 7 #define WEAPON_SHOTGUN 7
#define WEAPON_RPG 8 #define WEAPON_RPG 8
#define WEAPON_GAUSS 9 #define WEAPON_GAUSS 9
#define WEAPON_EGON 10 #define WEAPON_EGON 10
#define WEAPON_HORNETGUN 11 #define WEAPON_HORNETGUN 11
#define WEAPON_HANDGRENADE 12 #define WEAPON_HANDGRENADE 12
#define WEAPON_TRIPMINE 13 #define WEAPON_TRIPMINE 13
#define WEAPON_SATCHEL 14 #define WEAPON_SATCHEL 14
#define WEAPON_SNARK 15 #define WEAPON_SNARK 15
#define WEAPON_ALLWEAPONS (~(1<<WEAPON_SUIT)) #define WEAPON_ALLWEAPONS (~(1<<WEAPON_SUIT))
#define WEAPON_SUIT 31 // ????? #define WEAPON_SUIT 31 // ?????
#define MAX_WEAPONS 32 #define MAX_WEAPONS 32
#define MAX_NORMAL_BATTERY 100 #define MAX_NORMAL_BATTERY 100
// weapon weight factors (for auto-switching) (-1 = noswitch) // weapon weight factors (for auto-switching) (-1 = noswitch)
#define CROWBAR_WEIGHT 0 #define CROWBAR_WEIGHT 0
#define GLOCK_WEIGHT 10 #define GLOCK_WEIGHT 10
#define PYTHON_WEIGHT 15 #define PYTHON_WEIGHT 15
#define MP5_WEIGHT 15 #define MP5_WEIGHT 15
#define SHOTGUN_WEIGHT 15 #define SHOTGUN_WEIGHT 15
#define CROSSBOW_WEIGHT 10 #define CROSSBOW_WEIGHT 10
#define RPG_WEIGHT 20 #define RPG_WEIGHT 20
#define GAUSS_WEIGHT 20 #define GAUSS_WEIGHT 20
#define EGON_WEIGHT 20 #define EGON_WEIGHT 20
#define HORNETGUN_WEIGHT 10 #define HORNETGUN_WEIGHT 10
#define HANDGRENADE_WEIGHT 5 #define HANDGRENADE_WEIGHT 5
#define SNARK_WEIGHT 5 #define SNARK_WEIGHT 5
#define SATCHEL_WEIGHT -10 #define SATCHEL_WEIGHT -10
#define TRIPMINE_WEIGHT -10 #define TRIPMINE_WEIGHT -10
// weapon clip/carry ammo capacities // weapon clip/carry ammo capacities
#define URANIUM_MAX_CARRY 100 #define URANIUM_MAX_CARRY 100
#define _9MM_MAX_CARRY 250 #define _9MM_MAX_CARRY 250
#define _357_MAX_CARRY 36 #define _357_MAX_CARRY 36
#define BUCKSHOT_MAX_CARRY 125 #define BUCKSHOT_MAX_CARRY 125
#define BOLT_MAX_CARRY 50 #define BOLT_MAX_CARRY 50
#define ROCKET_MAX_CARRY 5 #define ROCKET_MAX_CARRY 5
#define HANDGRENADE_MAX_CARRY 10 #define HANDGRENADE_MAX_CARRY 10
#define SATCHEL_MAX_CARRY 5 #define SATCHEL_MAX_CARRY 5
#define TRIPMINE_MAX_CARRY 5 #define TRIPMINE_MAX_CARRY 5
#define SNARK_MAX_CARRY 15 #define SNARK_MAX_CARRY 15
#define HORNET_MAX_CARRY 8 #define HORNET_MAX_CARRY 8
#define M203_GRENADE_MAX_CARRY 10 #define M203_GRENADE_MAX_CARRY 10
// the maximum amount of ammo each weapon's clip can hold // the maximum amount of ammo each weapon's clip can hold
#define WEAPON_NOCLIP -1 #define WEAPON_NOCLIP -1
//#define CROWBAR_MAX_CLIP WEAPON_NOCLIP //#define CROWBAR_MAX_CLIP WEAPON_NOCLIP
#define GLOCK_MAX_CLIP 17 #define GLOCK_MAX_CLIP 17
#define PYTHON_MAX_CLIP 6 #define PYTHON_MAX_CLIP 6
#define MP5_MAX_CLIP 50 #define MP5_MAX_CLIP 50
#define MP5_DEFAULT_AMMO 25 #define MP5_DEFAULT_AMMO 25
#define SHOTGUN_MAX_CLIP 8 #define SHOTGUN_MAX_CLIP 8
#define CROSSBOW_MAX_CLIP 5 #define CROSSBOW_MAX_CLIP 5
#define RPG_MAX_CLIP 1 #define RPG_MAX_CLIP 1
#define GAUSS_MAX_CLIP WEAPON_NOCLIP #define GAUSS_MAX_CLIP WEAPON_NOCLIP
#define EGON_MAX_CLIP WEAPON_NOCLIP #define EGON_MAX_CLIP WEAPON_NOCLIP
#define HORNETGUN_MAX_CLIP WEAPON_NOCLIP #define HORNETGUN_MAX_CLIP WEAPON_NOCLIP
#define HANDGRENADE_MAX_CLIP WEAPON_NOCLIP #define HANDGRENADE_MAX_CLIP WEAPON_NOCLIP
#define SATCHEL_MAX_CLIP WEAPON_NOCLIP #define SATCHEL_MAX_CLIP WEAPON_NOCLIP
#define TRIPMINE_MAX_CLIP WEAPON_NOCLIP #define TRIPMINE_MAX_CLIP WEAPON_NOCLIP
#define SNARK_MAX_CLIP WEAPON_NOCLIP #define SNARK_MAX_CLIP WEAPON_NOCLIP
// the default amount of ammo that comes with each gun when it spawns // the default amount of ammo that comes with each gun when it spawns
#define GLOCK_DEFAULT_GIVE 17 #define GLOCK_DEFAULT_GIVE 17
#define PYTHON_DEFAULT_GIVE 6 #define PYTHON_DEFAULT_GIVE 6
#define MP5_DEFAULT_GIVE 25 #define MP5_DEFAULT_GIVE 25
#define MP5_DEFAULT_AMMO 25 #define MP5_DEFAULT_AMMO 25
#define MP5_M203_DEFAULT_GIVE 0 #define MP5_M203_DEFAULT_GIVE 0
#define SHOTGUN_DEFAULT_GIVE 12 #define SHOTGUN_DEFAULT_GIVE 12
#define CROSSBOW_DEFAULT_GIVE 5 #define CROSSBOW_DEFAULT_GIVE 5
#define RPG_DEFAULT_GIVE 1 #define RPG_DEFAULT_GIVE 1
#define GAUSS_DEFAULT_GIVE 20 #define GAUSS_DEFAULT_GIVE 20
#define EGON_DEFAULT_GIVE 20 #define EGON_DEFAULT_GIVE 20
#define HANDGRENADE_DEFAULT_GIVE 5 #define HANDGRENADE_DEFAULT_GIVE 5
#define SATCHEL_DEFAULT_GIVE 1 #define SATCHEL_DEFAULT_GIVE 1
#define TRIPMINE_DEFAULT_GIVE 1 #define TRIPMINE_DEFAULT_GIVE 1
#define SNARK_DEFAULT_GIVE 5 #define SNARK_DEFAULT_GIVE 5
#define HIVEHAND_DEFAULT_GIVE 8 #define HIVEHAND_DEFAULT_GIVE 8
// The amount of ammo given to a player by an ammo item. // The amount of ammo given to a player by an ammo item.
#define AMMO_URANIUMBOX_GIVE 20 #define AMMO_URANIUMBOX_GIVE 20
#define AMMO_GLOCKCLIP_GIVE GLOCK_MAX_CLIP #define AMMO_GLOCKCLIP_GIVE GLOCK_MAX_CLIP
#define AMMO_357BOX_GIVE PYTHON_MAX_CLIP #define AMMO_357BOX_GIVE PYTHON_MAX_CLIP
#define AMMO_MP5CLIP_GIVE MP5_MAX_CLIP #define AMMO_MP5CLIP_GIVE MP5_MAX_CLIP
#define AMMO_CHAINBOX_GIVE 200 #define AMMO_CHAINBOX_GIVE 200
#define AMMO_M203BOX_GIVE 2 #define AMMO_M203BOX_GIVE 2
#define AMMO_BUCKSHOTBOX_GIVE 12 #define AMMO_BUCKSHOTBOX_GIVE 12
#define AMMO_CROSSBOWCLIP_GIVE CROSSBOW_MAX_CLIP #define AMMO_CROSSBOWCLIP_GIVE CROSSBOW_MAX_CLIP
#define AMMO_RPGCLIP_GIVE RPG_MAX_CLIP #define AMMO_RPGCLIP_GIVE RPG_MAX_CLIP
#define AMMO_URANIUMBOX_GIVE 20 #define AMMO_URANIUMBOX_GIVE 20
#define AMMO_SNARKBOX_GIVE 5 #define AMMO_SNARKBOX_GIVE 5
// bullet types // bullet types
typedef enum typedef enum
{ {
BULLET_NONE = 0, BULLET_NONE = 0,
BULLET_PLAYER_9MM, // glock BULLET_PLAYER_9MM, // glock
BULLET_PLAYER_MP5, // mp5 BULLET_PLAYER_MP5, // mp5
BULLET_PLAYER_357, // python BULLET_PLAYER_357, // python
BULLET_PLAYER_BUCKSHOT, // shotgun BULLET_PLAYER_BUCKSHOT, // shotgun
BULLET_PLAYER_CROWBAR, // crowbar swipe BULLET_PLAYER_CROWBAR, // crowbar swipe
BULLET_MONSTER_9MM, BULLET_MONSTER_9MM,
BULLET_MONSTER_MP5, BULLET_MONSTER_MP5,
BULLET_MONSTER_12MM, BULLET_MONSTER_12MM,
BULLET_MONSTER_762, BULLET_MONSTER_762,
BULLET_MONSTER_357, BULLET_MONSTER_357,
} Bullet; } Bullet;
#define ITEM_FLAG_SELECTONEMPTY 1 #define ITEM_FLAG_SELECTONEMPTY 1
#define ITEM_FLAG_NOAUTORELOAD 2 #define ITEM_FLAG_NOAUTORELOAD 2
#define ITEM_FLAG_NOAUTOSWITCHEMPTY 4 #define ITEM_FLAG_NOAUTOSWITCHEMPTY 4
#define ITEM_FLAG_LIMITINWORLD 8 #define ITEM_FLAG_LIMITINWORLD 8
#define ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon #define ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon
#define WEAPON_IS_ONTARGET 0x40 #define WEAPON_IS_ONTARGET 0x40
typedef struct typedef struct
{ {
int iSlot; int iSlot;
int iPosition; int iPosition;
const char *pszAmmo1; // ammo 1 type const char *pszAmmo1; // ammo 1 type
int iMaxAmmo1; // max ammo 1 int iMaxAmmo1; // max ammo 1
const char *pszAmmo2; // ammo 2 type const char *pszAmmo2; // ammo 2 type
int iMaxAmmo2; // max ammo 2 int iMaxAmmo2; // max ammo 2
const char *pszName; const char *pszName;
int iMaxClip; int iMaxClip;
int iId; int iId;
int iFlags; int iFlags;
int iWeight;// this value used to determine this weapon's importance in autoselection. int iWeight;// this value used to determine this weapon's importance in autoselection.
} ItemInfo; } ItemInfo;
typedef struct typedef struct
{ {
const char *pszName; const char *pszName;
int iId; int iId;
} AmmoInfo; } AmmoInfo;
extern void ClearMultiDamage(void); extern void ClearMultiDamage(void);
extern void ApplyMultiDamage(entvars_t* pevInflictor, entvars_t* pevAttacker ); extern void ApplyMultiDamage(entvars_t* pevInflictor, entvars_t* pevAttacker );
extern void AddMultiDamage( entvars_t *pevInflictor, edict_t *pEntity, float flDamage, int bitsDamageType); extern void AddMultiDamage( entvars_t *pevInflictor, edict_t *pEntity, float flDamage, int bitsDamageType);
extern void DecalGunshot( TraceResult *pTrace, int iBulletType ); extern void DecalGunshot( TraceResult *pTrace, int iBulletType );
extern void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage); extern void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage);
extern int DamageDecal( CMBaseEntity *pEntity, int bitsDamageType ); extern int DamageDecal( CMBaseEntity *pEntity, int bitsDamageType );
extern void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ); extern void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType );
typedef struct typedef struct
{ {
edict_t *pEntity; edict_t *pEntity;
float amount; float amount;
int type; int type;
} MULTIDAMAGE; } MULTIDAMAGE;
extern MULTIDAMAGE gMultiDamage; extern MULTIDAMAGE gMultiDamage;
#define LOUD_GUN_VOLUME 1000 #define LOUD_GUN_VOLUME 1000
#define NORMAL_GUN_VOLUME 600 #define NORMAL_GUN_VOLUME 600
#define QUIET_GUN_VOLUME 200 #define QUIET_GUN_VOLUME 200
#define BRIGHT_GUN_FLASH 512 #define BRIGHT_GUN_FLASH 512
#define NORMAL_GUN_FLASH 256 #define NORMAL_GUN_FLASH 256
#define DIM_GUN_FLASH 128 #define DIM_GUN_FLASH 128
#define BIG_EXPLOSION_VOLUME 2048 #define BIG_EXPLOSION_VOLUME 2048
#define NORMAL_EXPLOSION_VOLUME 1024 #define NORMAL_EXPLOSION_VOLUME 1024
#define SMALL_EXPLOSION_VOLUME 512 #define SMALL_EXPLOSION_VOLUME 512
#define WEAPON_ACTIVITY_VOLUME 64 #define WEAPON_ACTIVITY_VOLUME 64
#define VECTOR_CONE_1DEGREES Vector( 0.00873, 0.00873, 0.00873 ) #define VECTOR_CONE_1DEGREES Vector( 0.00873, 0.00873, 0.00873 )
#define VECTOR_CONE_2DEGREES Vector( 0.01745, 0.01745, 0.01745 ) #define VECTOR_CONE_2DEGREES Vector( 0.01745, 0.01745, 0.01745 )
#define VECTOR_CONE_3DEGREES Vector( 0.02618, 0.02618, 0.02618 ) #define VECTOR_CONE_3DEGREES Vector( 0.02618, 0.02618, 0.02618 )
#define VECTOR_CONE_4DEGREES Vector( 0.03490, 0.03490, 0.03490 ) #define VECTOR_CONE_4DEGREES Vector( 0.03490, 0.03490, 0.03490 )
#define VECTOR_CONE_5DEGREES Vector( 0.04362, 0.04362, 0.04362 ) #define VECTOR_CONE_5DEGREES Vector( 0.04362, 0.04362, 0.04362 )
#define VECTOR_CONE_6DEGREES Vector( 0.05234, 0.05234, 0.05234 ) #define VECTOR_CONE_6DEGREES Vector( 0.05234, 0.05234, 0.05234 )
#define VECTOR_CONE_7DEGREES Vector( 0.06105, 0.06105, 0.06105 ) #define VECTOR_CONE_7DEGREES Vector( 0.06105, 0.06105, 0.06105 )
#define VECTOR_CONE_8DEGREES Vector( 0.06976, 0.06976, 0.06976 ) #define VECTOR_CONE_8DEGREES Vector( 0.06976, 0.06976, 0.06976 )
#define VECTOR_CONE_9DEGREES Vector( 0.07846, 0.07846, 0.07846 ) #define VECTOR_CONE_9DEGREES Vector( 0.07846, 0.07846, 0.07846 )
#define VECTOR_CONE_10DEGREES Vector( 0.08716, 0.08716, 0.08716 ) #define VECTOR_CONE_10DEGREES Vector( 0.08716, 0.08716, 0.08716 )
#define VECTOR_CONE_15DEGREES Vector( 0.13053, 0.13053, 0.13053 ) #define VECTOR_CONE_15DEGREES Vector( 0.13053, 0.13053, 0.13053 )
#define VECTOR_CONE_20DEGREES Vector( 0.17365, 0.17365, 0.17365 ) #define VECTOR_CONE_20DEGREES Vector( 0.17365, 0.17365, 0.17365 )
#endif // WEAPONS_H #endif // WEAPONS_H

View File

@@ -1,328 +1,328 @@
/*** /***
* *
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. * Copyright (c) 1996-2001, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* This source code contains proprietary and confidential information of * This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to * Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access, * persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal. * use or distribution of this code by or to any unlicensed person is illegal.
* *
****/ ****/
//========================================================= //=========================================================
// Zombie // Zombie
//========================================================= //=========================================================
// UNDONE: Don't flinch every time you get hit // UNDONE: Don't flinch every time you get hit
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cmbase.h" #include "cmbase.h"
#include "cmbasemonster.h" #include "cmbasemonster.h"
#include "monsters.h" #include "monsters.h"
#include "schedule.h" #include "schedule.h"
//========================================================= //=========================================================
// Monster's Anim Events Go Here // Monster's Anim Events Go Here
//========================================================= //=========================================================
#define ZOMBIE_AE_ATTACK_RIGHT 0x01 #define ZOMBIE_AE_ATTACK_RIGHT 0x01
#define ZOMBIE_AE_ATTACK_LEFT 0x02 #define ZOMBIE_AE_ATTACK_LEFT 0x02
#define ZOMBIE_AE_ATTACK_BOTH 0x03 #define ZOMBIE_AE_ATTACK_BOTH 0x03
#define ZOMBIE_FLINCH_DELAY 2 // at most one flinch every n secs #define ZOMBIE_FLINCH_DELAY 2 // at most one flinch every n secs
const char *CMZombie::pAttackHitSounds[] = const char *CMZombie::pAttackHitSounds[] =
{ {
"zombie/claw_strike1.wav", "zombie/claw_strike1.wav",
"zombie/claw_strike2.wav", "zombie/claw_strike2.wav",
"zombie/claw_strike3.wav", "zombie/claw_strike3.wav",
}; };
const char *CMZombie::pAttackMissSounds[] = const char *CMZombie::pAttackMissSounds[] =
{ {
"zombie/claw_miss1.wav", "zombie/claw_miss1.wav",
"zombie/claw_miss2.wav", "zombie/claw_miss2.wav",
}; };
const char *CMZombie::pAttackSounds[] = const char *CMZombie::pAttackSounds[] =
{ {
"zombie/zo_attack1.wav", "zombie/zo_attack1.wav",
"zombie/zo_attack2.wav", "zombie/zo_attack2.wav",
}; };
const char *CMZombie::pIdleSounds[] = const char *CMZombie::pIdleSounds[] =
{ {
"zombie/zo_idle1.wav", "zombie/zo_idle1.wav",
"zombie/zo_idle2.wav", "zombie/zo_idle2.wav",
"zombie/zo_idle3.wav", "zombie/zo_idle3.wav",
"zombie/zo_idle4.wav", "zombie/zo_idle4.wav",
}; };
const char *CMZombie::pAlertSounds[] = const char *CMZombie::pAlertSounds[] =
{ {
"zombie/zo_alert10.wav", "zombie/zo_alert10.wav",
"zombie/zo_alert20.wav", "zombie/zo_alert20.wav",
"zombie/zo_alert30.wav", "zombie/zo_alert30.wav",
}; };
const char *CMZombie::pPainSounds[] = const char *CMZombie::pPainSounds[] =
{ {
"zombie/zo_pain1.wav", "zombie/zo_pain1.wav",
"zombie/zo_pain2.wav", "zombie/zo_pain2.wav",
}; };
//========================================================= //=========================================================
// Classify - indicates this monster's place in the // Classify - indicates this monster's place in the
// relationship table. // relationship table.
//========================================================= //=========================================================
int CMZombie :: Classify ( void ) int CMZombie :: Classify ( void )
{ {
if ( m_iClassifyOverride == -1 ) // helper if ( m_iClassifyOverride == -1 ) // helper
return CLASS_NONE; return CLASS_NONE;
else if ( m_iClassifyOverride > 0 ) else if ( m_iClassifyOverride > 0 )
return m_iClassifyOverride; // override return m_iClassifyOverride; // override
return CLASS_ALIEN_MONSTER; return CLASS_ALIEN_MONSTER;
} }
//========================================================= //=========================================================
// SetYawSpeed - allows each sequence to have a different // SetYawSpeed - allows each sequence to have a different
// turn rate associated with it. // turn rate associated with it.
//========================================================= //=========================================================
void CMZombie :: SetYawSpeed ( void ) void CMZombie :: SetYawSpeed ( void )
{ {
int ys; int ys;
ys = 120; ys = 120;
#if 0 #if 0
switch ( m_Activity ) switch ( m_Activity )
{ {
} }
#endif #endif
pev->yaw_speed = ys; pev->yaw_speed = ys;
} }
int CMZombie :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) int CMZombie :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{ {
// Take 30% damage from bullets // Take 30% damage from bullets
if ( bitsDamageType == DMG_BULLET ) if ( bitsDamageType == DMG_BULLET )
{ {
Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5;
vecDir = vecDir.Normalize(); vecDir = vecDir.Normalize();
float flForce = DamageForce( flDamage ); float flForce = DamageForce( flDamage );
pev->velocity = pev->velocity + vecDir * flForce; pev->velocity = pev->velocity + vecDir * flForce;
flDamage *= 0.3; flDamage *= 0.3;
} }
// HACK HACK -- until we fix this. // HACK HACK -- until we fix this.
if ( IsAlive() ) if ( IsAlive() )
PainSound(); PainSound();
return CMBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); return CMBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
} }
void CMZombie :: PainSound( void ) void CMZombie :: PainSound( void )
{ {
int pitch = 95 + RANDOM_LONG(0,9); int pitch = 95 + RANDOM_LONG(0,9);
if (RANDOM_LONG(0,5) < 2) if (RANDOM_LONG(0,5) < 2)
EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pPainSounds[ RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pPainSounds[ RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1) ], 1.0, ATTN_NORM, 0, pitch );
} }
void CMZombie :: AlertSound( void ) void CMZombie :: AlertSound( void )
{ {
int pitch = 95 + RANDOM_LONG(0,9); int pitch = 95 + RANDOM_LONG(0,9);
EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAlertSounds[ RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1) ], 1.0, ATTN_NORM, 0, pitch ); EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAlertSounds[ RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1) ], 1.0, ATTN_NORM, 0, pitch );
} }
void CMZombie :: IdleSound( void ) void CMZombie :: IdleSound( void )
{ {
int pitch = 95 + RANDOM_LONG(0,9); int pitch = 95 + RANDOM_LONG(0,9);
// Play a random idle sound // Play a random idle sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pIdleSounds[ RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pIdleSounds[ RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
} }
void CMZombie :: AttackSound( void ) void CMZombie :: AttackSound( void )
{ {
// Play a random attack sound // Play a random attack sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAttackSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAttackSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
} }
//========================================================= //=========================================================
// HandleAnimEvent - catches the monster-specific messages // HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played. // that occur when tagged animation frames are played.
//========================================================= //=========================================================
void CMZombie :: HandleAnimEvent( MonsterEvent_t *pEvent ) void CMZombie :: HandleAnimEvent( MonsterEvent_t *pEvent )
{ {
switch( pEvent->event ) switch( pEvent->event )
{ {
case ZOMBIE_AE_ATTACK_RIGHT: case ZOMBIE_AE_ATTACK_RIGHT:
{ {
// do stuff for this event. // do stuff for this event.
// ALERT( at_console, "Slash right!\n" ); // ALERT( at_console, "Slash right!\n" );
edict_t *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); edict_t *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH );
if ( pHurt ) if ( pHurt )
{ {
if ( pHurt->v.flags & (FL_MONSTER|FL_CLIENT) ) if ( pHurt->v.flags & (FL_MONSTER|FL_CLIENT) )
{ {
pHurt->v.punchangle.z = -18; pHurt->v.punchangle.z = -18;
pHurt->v.punchangle.x = 5; pHurt->v.punchangle.x = 5;
pHurt->v.velocity = pHurt->v.velocity - gpGlobals->v_right * 100; pHurt->v.velocity = pHurt->v.velocity - gpGlobals->v_right * 100;
} }
// Play a random attack hit sound // Play a random attack hit sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
} }
else // Play a random attack miss sound else // Play a random attack miss sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
if (RANDOM_LONG(0,1)) if (RANDOM_LONG(0,1))
AttackSound(); AttackSound();
} }
break; break;
case ZOMBIE_AE_ATTACK_LEFT: case ZOMBIE_AE_ATTACK_LEFT:
{ {
// do stuff for this event. // do stuff for this event.
// ALERT( at_console, "Slash left!\n" ); // ALERT( at_console, "Slash left!\n" );
edict_t *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH ); edict_t *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgOneSlash, DMG_SLASH );
if ( pHurt ) if ( pHurt )
{ {
if ( pHurt->v.flags & (FL_MONSTER|FL_CLIENT) ) if ( pHurt->v.flags & (FL_MONSTER|FL_CLIENT) )
{ {
pHurt->v.punchangle.z = 18; pHurt->v.punchangle.z = 18;
pHurt->v.punchangle.x = 5; pHurt->v.punchangle.x = 5;
pHurt->v.velocity = pHurt->v.velocity + gpGlobals->v_right * 100; pHurt->v.velocity = pHurt->v.velocity + gpGlobals->v_right * 100;
} }
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
} }
else else
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
if (RANDOM_LONG(0,1)) if (RANDOM_LONG(0,1))
AttackSound(); AttackSound();
} }
break; break;
case ZOMBIE_AE_ATTACK_BOTH: case ZOMBIE_AE_ATTACK_BOTH:
{ {
// do stuff for this event. // do stuff for this event.
edict_t *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgBothSlash, DMG_SLASH ); edict_t *pHurt = CheckTraceHullAttack( 70, gSkillData.zombieDmgBothSlash, DMG_SLASH );
if ( pHurt ) if ( pHurt )
{ {
if ( pHurt->v.flags & (FL_MONSTER|FL_CLIENT) ) if ( pHurt->v.flags & (FL_MONSTER|FL_CLIENT) )
{ {
pHurt->v.punchangle.x = 5; pHurt->v.punchangle.x = 5;
pHurt->v.velocity = pHurt->v.velocity + gpGlobals->v_forward * -100; pHurt->v.velocity = pHurt->v.velocity + gpGlobals->v_forward * -100;
} }
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
} }
else else
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
if (RANDOM_LONG(0,1)) if (RANDOM_LONG(0,1))
AttackSound(); AttackSound();
} }
break; break;
default: default:
CMBaseMonster::HandleAnimEvent( pEvent ); CMBaseMonster::HandleAnimEvent( pEvent );
break; break;
} }
} }
//========================================================= //=========================================================
// Spawn // Spawn
//========================================================= //=========================================================
void CMZombie :: Spawn() void CMZombie :: Spawn()
{ {
Precache( ); Precache( );
SET_MODEL(ENT(pev), "models/zombie.mdl"); SET_MODEL(ENT(pev), "models/zombie.mdl");
UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_GREEN; m_bloodColor = BLOOD_COLOR_GREEN;
pev->health = gSkillData.zombieHealth; pev->health = gSkillData.zombieHealth;
pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin. pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin.
m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE; m_MonsterState = MONSTERSTATE_NONE;
m_afCapability = bits_CAP_DOORS_GROUP; m_afCapability = bits_CAP_DOORS_GROUP;
MonsterInit(); MonsterInit();
pev->classname = MAKE_STRING( "monster_zombie" ); pev->classname = MAKE_STRING( "monster_zombie" );
if ( strlen( STRING( m_szMonsterName ) ) == 0 ) if ( strlen( STRING( m_szMonsterName ) ) == 0 )
{ {
// default name // default name
m_szMonsterName = MAKE_STRING( "Zombie" ); m_szMonsterName = MAKE_STRING( "Zombie" );
} }
} }
//========================================================= //=========================================================
// Precache - precaches all resources this monster needs // Precache - precaches all resources this monster needs
//========================================================= //=========================================================
void CMZombie :: Precache() void CMZombie :: Precache()
{ {
int i; int i;
PRECACHE_MODEL("models/zombie.mdl"); PRECACHE_MODEL("models/zombie.mdl");
for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ )
PRECACHE_SOUND((char *)pAttackHitSounds[i]); PRECACHE_SOUND((char *)pAttackHitSounds[i]);
for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ )
PRECACHE_SOUND((char *)pAttackMissSounds[i]); PRECACHE_SOUND((char *)pAttackMissSounds[i]);
for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ )
PRECACHE_SOUND((char *)pAttackSounds[i]); PRECACHE_SOUND((char *)pAttackSounds[i]);
for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ )
PRECACHE_SOUND((char *)pIdleSounds[i]); PRECACHE_SOUND((char *)pIdleSounds[i]);
for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ )
PRECACHE_SOUND((char *)pAlertSounds[i]); PRECACHE_SOUND((char *)pAlertSounds[i]);
for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ )
PRECACHE_SOUND((char *)pPainSounds[i]); PRECACHE_SOUND((char *)pPainSounds[i]);
} }
//========================================================= //=========================================================
// AI Schedules Specific to this monster // AI Schedules Specific to this monster
//========================================================= //=========================================================
int CMZombie::IgnoreConditions ( void ) int CMZombie::IgnoreConditions ( void )
{ {
int iIgnore = CMBaseMonster::IgnoreConditions(); int iIgnore = CMBaseMonster::IgnoreConditions();
if ((m_Activity == ACT_MELEE_ATTACK1) || (m_Activity == ACT_MELEE_ATTACK1)) if ((m_Activity == ACT_MELEE_ATTACK1) || (m_Activity == ACT_MELEE_ATTACK1))
{ {
#if 0 #if 0
if (pev->health < 20) if (pev->health < 20)
iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE);
else else
#endif #endif
if (m_flNextFlinch >= gpGlobals->time) if (m_flNextFlinch >= gpGlobals->time)
iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE);
} }
if ((m_Activity == ACT_SMALL_FLINCH) || (m_Activity == ACT_BIG_FLINCH)) if ((m_Activity == ACT_SMALL_FLINCH) || (m_Activity == ACT_BIG_FLINCH))
{ {
if (m_flNextFlinch < gpGlobals->time) if (m_flNextFlinch < gpGlobals->time)
m_flNextFlinch = gpGlobals->time + ZOMBIE_FLINCH_DELAY; m_flNextFlinch = gpGlobals->time + ZOMBIE_FLINCH_DELAY;
} }
return iIgnore; return iIgnore;
} }

View File

@@ -1,201 +1,201 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// S c r i p t e d S e q u e n c e s // S c r i p t e d S e q u e n c e s
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#ifndef _INCLUDE_SEQUENCE_H_ #ifndef _INCLUDE_SEQUENCE_H_
#define _INCLUDE_SEQUENCE_H_ #define _INCLUDE_SEQUENCE_H_
#ifndef _DEF_BYTE_ #ifndef _DEF_BYTE_
typedef unsigned char byte; typedef unsigned char byte;
#endif #endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// client_textmessage_t // client_textmessage_t
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
typedef struct client_textmessage_s typedef struct client_textmessage_s
{ {
int effect; int effect;
byte r1, g1, b1, a1; // 2 colors for effects byte r1, g1, b1, a1; // 2 colors for effects
byte r2, g2, b2, a2; byte r2, g2, b2, a2;
float x; float x;
float y; float y;
float fadein; float fadein;
float fadeout; float fadeout;
float holdtime; float holdtime;
float fxtime; float fxtime;
const char *pName; const char *pName;
const char *pMessage; const char *pMessage;
} client_textmessage_t; } client_textmessage_t;
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// sequenceDefaultBits_e // sequenceDefaultBits_e
// //
// Enumerated list of possible modifiers for a command. This enumeration // Enumerated list of possible modifiers for a command. This enumeration
// is used in a bitarray controlling what modifiers are specified for a command. // is used in a bitarray controlling what modifiers are specified for a command.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
enum sequenceModifierBits enum sequenceModifierBits
{ {
SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1),
SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2),
SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3),
SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4),
SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5),
SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6),
SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7),
SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8),
SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9),
SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10),
SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11),
}; };
typedef enum sequenceModifierBits sequenceModifierBits_e ; typedef enum sequenceModifierBits sequenceModifierBits_e ;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// sequenceCommandEnum_e // sequenceCommandEnum_e
// //
// Enumerated sequence command types. // Enumerated sequence command types.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
enum sequenceCommandEnum_ enum sequenceCommandEnum_
{ {
SEQUENCE_COMMAND_ERROR = -1, SEQUENCE_COMMAND_ERROR = -1,
SEQUENCE_COMMAND_PAUSE = 0, SEQUENCE_COMMAND_PAUSE = 0,
SEQUENCE_COMMAND_FIRETARGETS, SEQUENCE_COMMAND_FIRETARGETS,
SEQUENCE_COMMAND_KILLTARGETS, SEQUENCE_COMMAND_KILLTARGETS,
SEQUENCE_COMMAND_TEXT, SEQUENCE_COMMAND_TEXT,
SEQUENCE_COMMAND_SOUND, SEQUENCE_COMMAND_SOUND,
SEQUENCE_COMMAND_GOSUB, SEQUENCE_COMMAND_GOSUB,
SEQUENCE_COMMAND_SENTENCE, SEQUENCE_COMMAND_SENTENCE,
SEQUENCE_COMMAND_REPEAT, SEQUENCE_COMMAND_REPEAT,
SEQUENCE_COMMAND_SETDEFAULTS, SEQUENCE_COMMAND_SETDEFAULTS,
SEQUENCE_COMMAND_MODIFIER, SEQUENCE_COMMAND_MODIFIER,
SEQUENCE_COMMAND_POSTMODIFIER, SEQUENCE_COMMAND_POSTMODIFIER,
SEQUENCE_COMMAND_NOOP, SEQUENCE_COMMAND_NOOP,
SEQUENCE_MODIFIER_EFFECT, SEQUENCE_MODIFIER_EFFECT,
SEQUENCE_MODIFIER_POSITION, SEQUENCE_MODIFIER_POSITION,
SEQUENCE_MODIFIER_COLOR, SEQUENCE_MODIFIER_COLOR,
SEQUENCE_MODIFIER_COLOR2, SEQUENCE_MODIFIER_COLOR2,
SEQUENCE_MODIFIER_FADEIN, SEQUENCE_MODIFIER_FADEIN,
SEQUENCE_MODIFIER_FADEOUT, SEQUENCE_MODIFIER_FADEOUT,
SEQUENCE_MODIFIER_HOLDTIME, SEQUENCE_MODIFIER_HOLDTIME,
SEQUENCE_MODIFIER_FXTIME, SEQUENCE_MODIFIER_FXTIME,
SEQUENCE_MODIFIER_SPEAKER, SEQUENCE_MODIFIER_SPEAKER,
SEQUENCE_MODIFIER_LISTENER, SEQUENCE_MODIFIER_LISTENER,
SEQUENCE_MODIFIER_TEXTCHANNEL, SEQUENCE_MODIFIER_TEXTCHANNEL,
}; };
typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; typedef enum sequenceCommandEnum_ sequenceCommandEnum_e;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// sequenceCommandType_e // sequenceCommandType_e
// //
// Typeerated sequence command types. // Typeerated sequence command types.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
enum sequenceCommandType_ enum sequenceCommandType_
{ {
SEQUENCE_TYPE_COMMAND, SEQUENCE_TYPE_COMMAND,
SEQUENCE_TYPE_MODIFIER, SEQUENCE_TYPE_MODIFIER,
}; };
typedef enum sequenceCommandType_ sequenceCommandType_e; typedef enum sequenceCommandType_ sequenceCommandType_e;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// sequenceCommandMapping_s // sequenceCommandMapping_s
// //
// A mapping of a command enumerated-value to its name. // A mapping of a command enumerated-value to its name.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; typedef struct sequenceCommandMapping_ sequenceCommandMapping_s;
struct sequenceCommandMapping_ struct sequenceCommandMapping_
{ {
sequenceCommandEnum_e commandEnum; sequenceCommandEnum_e commandEnum;
const char* commandName; const char* commandName;
sequenceCommandType_e commandType; sequenceCommandType_e commandType;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// sequenceCommandLine_s // sequenceCommandLine_s
// //
// Structure representing a single command (usually 1 line) from a // Structure representing a single command (usually 1 line) from a
// .SEQ file entry. // .SEQ file entry.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
typedef struct sequenceCommandLine_ sequenceCommandLine_s; typedef struct sequenceCommandLine_ sequenceCommandLine_s;
struct sequenceCommandLine_ struct sequenceCommandLine_
{ {
int commandType; // Specifies the type of command int commandType; // Specifies the type of command
client_textmessage_t clientMessage; // Text HUD message struct client_textmessage_t clientMessage; // Text HUD message struct
char* speakerName; // Targetname of speaking entity char* speakerName; // Targetname of speaking entity
char* listenerName; // Targetname of entity being spoken to char* listenerName; // Targetname of entity being spoken to
char* soundFileName; // Name of sound file to play char* soundFileName; // Name of sound file to play
char* sentenceName; // Name of sentences.txt to play char* sentenceName; // Name of sentences.txt to play
char* fireTargetNames; // List of targetnames to fire char* fireTargetNames; // List of targetnames to fire
char* killTargetNames; // List of targetnames to remove char* killTargetNames; // List of targetnames to remove
float delay; // Seconds 'till next command float delay; // Seconds 'till next command
int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite)
int textChannel; // Display channel on which text message is sent int textChannel; // Display channel on which text message is sent
int modifierBitField; // Bit field to specify what clientmessage fields are valid int modifierBitField; // Bit field to specify what clientmessage fields are valid
sequenceCommandLine_s* nextCommandLine; // Next command (linked list) sequenceCommandLine_s* nextCommandLine; // Next command (linked list)
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// sequenceEntry_s // sequenceEntry_s
// //
// Structure representing a single command (usually 1 line) from a // Structure representing a single command (usually 1 line) from a
// .SEQ file entry. // .SEQ file entry.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
typedef struct sequenceEntry_ sequenceEntry_s; typedef struct sequenceEntry_ sequenceEntry_s;
struct sequenceEntry_ struct sequenceEntry_
{ {
char* fileName; // Name of sequence file without .SEQ extension char* fileName; // Name of sequence file without .SEQ extension
char* entryName; // Name of entry label in file char* entryName; // Name of entry label in file
sequenceCommandLine_s* firstCommand; // Linked list of commands in entry sequenceCommandLine_s* firstCommand; // Linked list of commands in entry
sequenceEntry_s* nextEntry; // Next loaded entry sequenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions? qboolean isGlobal; // Is entry retained over level transitions?
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// sentenceEntry_s // sentenceEntry_s
// Structure representing a single sentence of a group from a .SEQ // Structure representing a single sentence of a group from a .SEQ
// file entry. Sentences are identical to entries in sentences.txt, but // file entry. Sentences are identical to entries in sentences.txt, but
// can be unique per level and are loaded/unloaded with the level. // can be unique per level and are loaded/unloaded with the level.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
typedef struct sentenceEntry_ sentenceEntry_s; typedef struct sentenceEntry_ sentenceEntry_s;
struct sentenceEntry_ struct sentenceEntry_
{ {
char* data; // sentence data (ie "We have hostiles" ) char* data; // sentence data (ie "We have hostiles" )
sentenceEntry_s* nextEntry; // Next loaded entry sentenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions? qboolean isGlobal; // Is entry retained over level transitions?
unsigned int index; // this entry's position in the file. unsigned int index; // this entry's position in the file.
}; };
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// sentenceGroupEntry_s // sentenceGroupEntry_s
// Structure representing a group of sentences found in a .SEQ file. // Structure representing a group of sentences found in a .SEQ file.
// A sentence group is defined by all sentences with the same name, ignoring // A sentence group is defined by all sentences with the same name, ignoring
// the number at the end of the sentence name. Groups enable a sentence // the number at the end of the sentence name. Groups enable a sentence
// to be picked at random across a group. // to be picked at random across a group.
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; typedef struct sentenceGroupEntry_ sentenceGroupEntry_s;
struct sentenceGroupEntry_ struct sentenceGroupEntry_
{ {
char* groupName; // name of the group (ie CT_ALERT ) char* groupName; // name of the group (ie CT_ALERT )
unsigned int numSentences; // number of sentences in group unsigned int numSentences; // number of sentences in group
sentenceEntry_s* firstSentence; // head of linked list of sentences in group sentenceEntry_s* firstSentence; // head of linked list of sentences in group
sentenceGroupEntry_s* nextEntry; // next loaded group sentenceGroupEntry_s* nextEntry; // next loaded group
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Function declarations // Function declarations
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName );
void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); void Sequence_ParseFile( const char* fileName, qboolean isGlobal );
void Sequence_OnLevelLoad( const char* mapName ); void Sequence_OnLevelLoad( const char* mapName );
sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked );
#endif /* _INCLUDE_SEQUENCE_H_ */ #endif /* _INCLUDE_SEQUENCE_H_ */

View File

@@ -1,177 +1,177 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
{-0.525731, 0.000000, 0.850651}, {-0.525731, 0.000000, 0.850651},
{-0.442863, 0.238856, 0.864188}, {-0.442863, 0.238856, 0.864188},
{-0.295242, 0.000000, 0.955423}, {-0.295242, 0.000000, 0.955423},
{-0.309017, 0.500000, 0.809017}, {-0.309017, 0.500000, 0.809017},
{-0.162460, 0.262866, 0.951056}, {-0.162460, 0.262866, 0.951056},
{0.000000, 0.000000, 1.000000}, {0.000000, 0.000000, 1.000000},
{0.000000, 0.850651, 0.525731}, {0.000000, 0.850651, 0.525731},
{-0.147621, 0.716567, 0.681718}, {-0.147621, 0.716567, 0.681718},
{0.147621, 0.716567, 0.681718}, {0.147621, 0.716567, 0.681718},
{0.000000, 0.525731, 0.850651}, {0.000000, 0.525731, 0.850651},
{0.309017, 0.500000, 0.809017}, {0.309017, 0.500000, 0.809017},
{0.525731, 0.000000, 0.850651}, {0.525731, 0.000000, 0.850651},
{0.295242, 0.000000, 0.955423}, {0.295242, 0.000000, 0.955423},
{0.442863, 0.238856, 0.864188}, {0.442863, 0.238856, 0.864188},
{0.162460, 0.262866, 0.951056}, {0.162460, 0.262866, 0.951056},
{-0.681718, 0.147621, 0.716567}, {-0.681718, 0.147621, 0.716567},
{-0.809017, 0.309017, 0.500000}, {-0.809017, 0.309017, 0.500000},
{-0.587785, 0.425325, 0.688191}, {-0.587785, 0.425325, 0.688191},
{-0.850651, 0.525731, 0.000000}, {-0.850651, 0.525731, 0.000000},
{-0.864188, 0.442863, 0.238856}, {-0.864188, 0.442863, 0.238856},
{-0.716567, 0.681718, 0.147621}, {-0.716567, 0.681718, 0.147621},
{-0.688191, 0.587785, 0.425325}, {-0.688191, 0.587785, 0.425325},
{-0.500000, 0.809017, 0.309017}, {-0.500000, 0.809017, 0.309017},
{-0.238856, 0.864188, 0.442863}, {-0.238856, 0.864188, 0.442863},
{-0.425325, 0.688191, 0.587785}, {-0.425325, 0.688191, 0.587785},
{-0.716567, 0.681718, -0.147621}, {-0.716567, 0.681718, -0.147621},
{-0.500000, 0.809017, -0.309017}, {-0.500000, 0.809017, -0.309017},
{-0.525731, 0.850651, 0.000000}, {-0.525731, 0.850651, 0.000000},
{0.000000, 0.850651, -0.525731}, {0.000000, 0.850651, -0.525731},
{-0.238856, 0.864188, -0.442863}, {-0.238856, 0.864188, -0.442863},
{0.000000, 0.955423, -0.295242}, {0.000000, 0.955423, -0.295242},
{-0.262866, 0.951056, -0.162460}, {-0.262866, 0.951056, -0.162460},
{0.000000, 1.000000, 0.000000}, {0.000000, 1.000000, 0.000000},
{0.000000, 0.955423, 0.295242}, {0.000000, 0.955423, 0.295242},
{-0.262866, 0.951056, 0.162460}, {-0.262866, 0.951056, 0.162460},
{0.238856, 0.864188, 0.442863}, {0.238856, 0.864188, 0.442863},
{0.262866, 0.951056, 0.162460}, {0.262866, 0.951056, 0.162460},
{0.500000, 0.809017, 0.309017}, {0.500000, 0.809017, 0.309017},
{0.238856, 0.864188, -0.442863}, {0.238856, 0.864188, -0.442863},
{0.262866, 0.951056, -0.162460}, {0.262866, 0.951056, -0.162460},
{0.500000, 0.809017, -0.309017}, {0.500000, 0.809017, -0.309017},
{0.850651, 0.525731, 0.000000}, {0.850651, 0.525731, 0.000000},
{0.716567, 0.681718, 0.147621}, {0.716567, 0.681718, 0.147621},
{0.716567, 0.681718, -0.147621}, {0.716567, 0.681718, -0.147621},
{0.525731, 0.850651, 0.000000}, {0.525731, 0.850651, 0.000000},
{0.425325, 0.688191, 0.587785}, {0.425325, 0.688191, 0.587785},
{0.864188, 0.442863, 0.238856}, {0.864188, 0.442863, 0.238856},
{0.688191, 0.587785, 0.425325}, {0.688191, 0.587785, 0.425325},
{0.809017, 0.309017, 0.500000}, {0.809017, 0.309017, 0.500000},
{0.681718, 0.147621, 0.716567}, {0.681718, 0.147621, 0.716567},
{0.587785, 0.425325, 0.688191}, {0.587785, 0.425325, 0.688191},
{0.955423, 0.295242, 0.000000}, {0.955423, 0.295242, 0.000000},
{1.000000, 0.000000, 0.000000}, {1.000000, 0.000000, 0.000000},
{0.951056, 0.162460, 0.262866}, {0.951056, 0.162460, 0.262866},
{0.850651, -0.525731, 0.000000}, {0.850651, -0.525731, 0.000000},
{0.955423, -0.295242, 0.000000}, {0.955423, -0.295242, 0.000000},
{0.864188, -0.442863, 0.238856}, {0.864188, -0.442863, 0.238856},
{0.951056, -0.162460, 0.262866}, {0.951056, -0.162460, 0.262866},
{0.809017, -0.309017, 0.500000}, {0.809017, -0.309017, 0.500000},
{0.681718, -0.147621, 0.716567}, {0.681718, -0.147621, 0.716567},
{0.850651, 0.000000, 0.525731}, {0.850651, 0.000000, 0.525731},
{0.864188, 0.442863, -0.238856}, {0.864188, 0.442863, -0.238856},
{0.809017, 0.309017, -0.500000}, {0.809017, 0.309017, -0.500000},
{0.951056, 0.162460, -0.262866}, {0.951056, 0.162460, -0.262866},
{0.525731, 0.000000, -0.850651}, {0.525731, 0.000000, -0.850651},
{0.681718, 0.147621, -0.716567}, {0.681718, 0.147621, -0.716567},
{0.681718, -0.147621, -0.716567}, {0.681718, -0.147621, -0.716567},
{0.850651, 0.000000, -0.525731}, {0.850651, 0.000000, -0.525731},
{0.809017, -0.309017, -0.500000}, {0.809017, -0.309017, -0.500000},
{0.864188, -0.442863, -0.238856}, {0.864188, -0.442863, -0.238856},
{0.951056, -0.162460, -0.262866}, {0.951056, -0.162460, -0.262866},
{0.147621, 0.716567, -0.681718}, {0.147621, 0.716567, -0.681718},
{0.309017, 0.500000, -0.809017}, {0.309017, 0.500000, -0.809017},
{0.425325, 0.688191, -0.587785}, {0.425325, 0.688191, -0.587785},
{0.442863, 0.238856, -0.864188}, {0.442863, 0.238856, -0.864188},
{0.587785, 0.425325, -0.688191}, {0.587785, 0.425325, -0.688191},
{0.688191, 0.587785, -0.425325}, {0.688191, 0.587785, -0.425325},
{-0.147621, 0.716567, -0.681718}, {-0.147621, 0.716567, -0.681718},
{-0.309017, 0.500000, -0.809017}, {-0.309017, 0.500000, -0.809017},
{0.000000, 0.525731, -0.850651}, {0.000000, 0.525731, -0.850651},
{-0.525731, 0.000000, -0.850651}, {-0.525731, 0.000000, -0.850651},
{-0.442863, 0.238856, -0.864188}, {-0.442863, 0.238856, -0.864188},
{-0.295242, 0.000000, -0.955423}, {-0.295242, 0.000000, -0.955423},
{-0.162460, 0.262866, -0.951056}, {-0.162460, 0.262866, -0.951056},
{0.000000, 0.000000, -1.000000}, {0.000000, 0.000000, -1.000000},
{0.295242, 0.000000, -0.955423}, {0.295242, 0.000000, -0.955423},
{0.162460, 0.262866, -0.951056}, {0.162460, 0.262866, -0.951056},
{-0.442863, -0.238856, -0.864188}, {-0.442863, -0.238856, -0.864188},
{-0.309017, -0.500000, -0.809017}, {-0.309017, -0.500000, -0.809017},
{-0.162460, -0.262866, -0.951056}, {-0.162460, -0.262866, -0.951056},
{0.000000, -0.850651, -0.525731}, {0.000000, -0.850651, -0.525731},
{-0.147621, -0.716567, -0.681718}, {-0.147621, -0.716567, -0.681718},
{0.147621, -0.716567, -0.681718}, {0.147621, -0.716567, -0.681718},
{0.000000, -0.525731, -0.850651}, {0.000000, -0.525731, -0.850651},
{0.309017, -0.500000, -0.809017}, {0.309017, -0.500000, -0.809017},
{0.442863, -0.238856, -0.864188}, {0.442863, -0.238856, -0.864188},
{0.162460, -0.262866, -0.951056}, {0.162460, -0.262866, -0.951056},
{0.238856, -0.864188, -0.442863}, {0.238856, -0.864188, -0.442863},
{0.500000, -0.809017, -0.309017}, {0.500000, -0.809017, -0.309017},
{0.425325, -0.688191, -0.587785}, {0.425325, -0.688191, -0.587785},
{0.716567, -0.681718, -0.147621}, {0.716567, -0.681718, -0.147621},
{0.688191, -0.587785, -0.425325}, {0.688191, -0.587785, -0.425325},
{0.587785, -0.425325, -0.688191}, {0.587785, -0.425325, -0.688191},
{0.000000, -0.955423, -0.295242}, {0.000000, -0.955423, -0.295242},
{0.000000, -1.000000, 0.000000}, {0.000000, -1.000000, 0.000000},
{0.262866, -0.951056, -0.162460}, {0.262866, -0.951056, -0.162460},
{0.000000, -0.850651, 0.525731}, {0.000000, -0.850651, 0.525731},
{0.000000, -0.955423, 0.295242}, {0.000000, -0.955423, 0.295242},
{0.238856, -0.864188, 0.442863}, {0.238856, -0.864188, 0.442863},
{0.262866, -0.951056, 0.162460}, {0.262866, -0.951056, 0.162460},
{0.500000, -0.809017, 0.309017}, {0.500000, -0.809017, 0.309017},
{0.716567, -0.681718, 0.147621}, {0.716567, -0.681718, 0.147621},
{0.525731, -0.850651, 0.000000}, {0.525731, -0.850651, 0.000000},
{-0.238856, -0.864188, -0.442863}, {-0.238856, -0.864188, -0.442863},
{-0.500000, -0.809017, -0.309017}, {-0.500000, -0.809017, -0.309017},
{-0.262866, -0.951056, -0.162460}, {-0.262866, -0.951056, -0.162460},
{-0.850651, -0.525731, 0.000000}, {-0.850651, -0.525731, 0.000000},
{-0.716567, -0.681718, -0.147621}, {-0.716567, -0.681718, -0.147621},
{-0.716567, -0.681718, 0.147621}, {-0.716567, -0.681718, 0.147621},
{-0.525731, -0.850651, 0.000000}, {-0.525731, -0.850651, 0.000000},
{-0.500000, -0.809017, 0.309017}, {-0.500000, -0.809017, 0.309017},
{-0.238856, -0.864188, 0.442863}, {-0.238856, -0.864188, 0.442863},
{-0.262866, -0.951056, 0.162460}, {-0.262866, -0.951056, 0.162460},
{-0.864188, -0.442863, 0.238856}, {-0.864188, -0.442863, 0.238856},
{-0.809017, -0.309017, 0.500000}, {-0.809017, -0.309017, 0.500000},
{-0.688191, -0.587785, 0.425325}, {-0.688191, -0.587785, 0.425325},
{-0.681718, -0.147621, 0.716567}, {-0.681718, -0.147621, 0.716567},
{-0.442863, -0.238856, 0.864188}, {-0.442863, -0.238856, 0.864188},
{-0.587785, -0.425325, 0.688191}, {-0.587785, -0.425325, 0.688191},
{-0.309017, -0.500000, 0.809017}, {-0.309017, -0.500000, 0.809017},
{-0.147621, -0.716567, 0.681718}, {-0.147621, -0.716567, 0.681718},
{-0.425325, -0.688191, 0.587785}, {-0.425325, -0.688191, 0.587785},
{-0.162460, -0.262866, 0.951056}, {-0.162460, -0.262866, 0.951056},
{0.442863, -0.238856, 0.864188}, {0.442863, -0.238856, 0.864188},
{0.162460, -0.262866, 0.951056}, {0.162460, -0.262866, 0.951056},
{0.309017, -0.500000, 0.809017}, {0.309017, -0.500000, 0.809017},
{0.147621, -0.716567, 0.681718}, {0.147621, -0.716567, 0.681718},
{0.000000, -0.525731, 0.850651}, {0.000000, -0.525731, 0.850651},
{0.425325, -0.688191, 0.587785}, {0.425325, -0.688191, 0.587785},
{0.587785, -0.425325, 0.688191}, {0.587785, -0.425325, 0.688191},
{0.688191, -0.587785, 0.425325}, {0.688191, -0.587785, 0.425325},
{-0.955423, 0.295242, 0.000000}, {-0.955423, 0.295242, 0.000000},
{-0.951056, 0.162460, 0.262866}, {-0.951056, 0.162460, 0.262866},
{-1.000000, 0.000000, 0.000000}, {-1.000000, 0.000000, 0.000000},
{-0.850651, 0.000000, 0.525731}, {-0.850651, 0.000000, 0.525731},
{-0.955423, -0.295242, 0.000000}, {-0.955423, -0.295242, 0.000000},
{-0.951056, -0.162460, 0.262866}, {-0.951056, -0.162460, 0.262866},
{-0.864188, 0.442863, -0.238856}, {-0.864188, 0.442863, -0.238856},
{-0.951056, 0.162460, -0.262866}, {-0.951056, 0.162460, -0.262866},
{-0.809017, 0.309017, -0.500000}, {-0.809017, 0.309017, -0.500000},
{-0.864188, -0.442863, -0.238856}, {-0.864188, -0.442863, -0.238856},
{-0.951056, -0.162460, -0.262866}, {-0.951056, -0.162460, -0.262866},
{-0.809017, -0.309017, -0.500000}, {-0.809017, -0.309017, -0.500000},
{-0.681718, 0.147621, -0.716567}, {-0.681718, 0.147621, -0.716567},
{-0.681718, -0.147621, -0.716567}, {-0.681718, -0.147621, -0.716567},
{-0.850651, 0.000000, -0.525731}, {-0.850651, 0.000000, -0.525731},
{-0.688191, 0.587785, -0.425325}, {-0.688191, 0.587785, -0.425325},
{-0.587785, 0.425325, -0.688191}, {-0.587785, 0.425325, -0.688191},
{-0.425325, 0.688191, -0.587785}, {-0.425325, 0.688191, -0.587785},
{-0.425325, -0.688191, -0.587785}, {-0.425325, -0.688191, -0.587785},
{-0.587785, -0.425325, -0.688191}, {-0.587785, -0.425325, -0.688191},
{-0.688191, -0.587785, -0.425325}, {-0.688191, -0.587785, -0.425325},

View File

@@ -1,41 +1,41 @@
// //
// Word size dependent definitions // Word size dependent definitions
// DAL 1/03 // DAL 1/03
// //
#ifndef ARCHTYPES_H #ifndef ARCHTYPES_H
#define ARCHTYPES_H #define ARCHTYPES_H
#ifdef __x86_64__ #ifdef __x86_64__
#define X64BITS #define X64BITS
#endif #endif
#if defined( _WIN32 ) && (! defined( __MINGW32__ )) #if defined( _WIN32 ) && (! defined( __MINGW32__ ))
typedef __int16 int16; typedef __int16 int16;
typedef unsigned __int16 uint16; typedef unsigned __int16 uint16;
typedef __int32 int32; typedef __int32 int32;
typedef unsigned __int32 uint32; typedef unsigned __int32 uint32;
typedef __int64 int64; typedef __int64 int64;
typedef unsigned __int64 uint64; typedef unsigned __int64 uint64;
typedef __int32 intp; // intp is an integer that can accomodate a pointer typedef __int32 intp; // intp is an integer that can accomodate a pointer
typedef unsigned __int32 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) typedef unsigned __int32 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *)
#else /* _WIN32 */ #else /* _WIN32 */
typedef short int16; typedef short int16;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef int int32; typedef int int32;
typedef unsigned int uint32; typedef unsigned int uint32;
typedef long long int64; typedef long long int64;
typedef unsigned long long uint64; typedef unsigned long long uint64;
#ifdef X64BITS #ifdef X64BITS
typedef long long intp; typedef long long intp;
typedef unsigned long long uintp; typedef unsigned long long uintp;
#else #else
typedef int intp; typedef int intp;
typedef unsigned int uintp; typedef unsigned int uintp;
#endif #endif
#endif /* else _WIN32 */ #endif /* else _WIN32 */
#endif /* ARCHTYPES_H */ #endif /* ARCHTYPES_H */

View File

@@ -1,311 +1,311 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cdll_int.h // cdll_int.h
// //
// 4-23-98 // 4-23-98
// JOHN: client dll interface declarations // JOHN: client dll interface declarations
// //
#ifndef CDLL_INT_H #ifndef CDLL_INT_H
#define CDLL_INT_H #define CDLL_INT_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "const.h" #include "const.h"
// this file is included by both the engine and the client-dll, // this file is included by both the engine and the client-dll,
// so make sure engine declarations aren't done twice // so make sure engine declarations aren't done twice
typedef int HSPRITE; // handle to a graphic typedef int HSPRITE; // handle to a graphic
#define SCRINFO_SCREENFLASH 1 #define SCRINFO_SCREENFLASH 1
#define SCRINFO_STRETCHED 2 #define SCRINFO_STRETCHED 2
typedef struct SCREENINFO_s typedef struct SCREENINFO_s
{ {
int iSize; int iSize;
int iWidth; int iWidth;
int iHeight; int iHeight;
int iFlags; int iFlags;
int iCharHeight; int iCharHeight;
short charWidths[256]; short charWidths[256];
} SCREENINFO; } SCREENINFO;
typedef struct client_data_s typedef struct client_data_s
{ {
// fields that cannot be modified (ie. have no effect if changed) // fields that cannot be modified (ie. have no effect if changed)
vec3_t origin; vec3_t origin;
// fields that can be changed by the cldll // fields that can be changed by the cldll
vec3_t viewangles; vec3_t viewangles;
int iWeaponBits; int iWeaponBits;
float fov; // field of view float fov; // field of view
} client_data_t; } client_data_t;
typedef struct client_sprite_s typedef struct client_sprite_s
{ {
char szName[64]; char szName[64];
char szSprite[64]; char szSprite[64];
int hspr; int hspr;
int iRes; int iRes;
wrect_t rc; wrect_t rc;
} client_sprite_t; } client_sprite_t;
typedef struct client_textmessage_s typedef struct client_textmessage_s
{ {
int effect; int effect;
byte r1, g1, b1, a1; // 2 colors for effects byte r1, g1, b1, a1; // 2 colors for effects
byte r2, g2, b2, a2; byte r2, g2, b2, a2;
float x; float x;
float y; float y;
float fadein; float fadein;
float fadeout; float fadeout;
float holdtime; float holdtime;
float fxtime; float fxtime;
const char *pName; const char *pName;
const char *pMessage; const char *pMessage;
} client_textmessage_t; } client_textmessage_t;
typedef struct hud_player_info_s typedef struct hud_player_info_s
{ {
char *name; char *name;
short ping; short ping;
byte thisplayer; // TRUE if this is the calling player byte thisplayer; // TRUE if this is the calling player
// stuff that's unused at the moment, but should be done // stuff that's unused at the moment, but should be done
byte spectator; byte spectator;
byte packetloss; byte packetloss;
char *model; char *model;
short topcolor; short topcolor;
short bottomcolor; short bottomcolor;
} hud_player_info_t; } hud_player_info_t;
typedef struct cl_enginefuncs_s typedef struct cl_enginefuncs_s
{ {
// sprite handlers // sprite handlers
HSPRITE ( *pfnSPR_Load ) ( const char *szPicName ); HSPRITE ( *pfnSPR_Load ) ( const char *szPicName );
int ( *pfnSPR_Frames ) ( HSPRITE hPic ); int ( *pfnSPR_Frames ) ( HSPRITE hPic );
int ( *pfnSPR_Height ) ( HSPRITE hPic, int frame ); int ( *pfnSPR_Height ) ( HSPRITE hPic, int frame );
int ( *pfnSPR_Width ) ( HSPRITE hPic, int frame ); int ( *pfnSPR_Width ) ( HSPRITE hPic, int frame );
void ( *pfnSPR_Set ) ( HSPRITE hPic, int r, int g, int b ); void ( *pfnSPR_Set ) ( HSPRITE hPic, int r, int g, int b );
void ( *pfnSPR_Draw ) ( int frame, int x, int y, const wrect_t *prc ); void ( *pfnSPR_Draw ) ( int frame, int x, int y, const wrect_t *prc );
void ( *pfnSPR_DrawHoles ) ( int frame, int x, int y, const wrect_t *prc ); void ( *pfnSPR_DrawHoles ) ( int frame, int x, int y, const wrect_t *prc );
void ( *pfnSPR_DrawAdditive ) ( int frame, int x, int y, const wrect_t *prc ); void ( *pfnSPR_DrawAdditive ) ( int frame, int x, int y, const wrect_t *prc );
void ( *pfnSPR_EnableScissor ) ( int x, int y, int width, int height ); void ( *pfnSPR_EnableScissor ) ( int x, int y, int width, int height );
void ( *pfnSPR_DisableScissor ) ( void ); void ( *pfnSPR_DisableScissor ) ( void );
client_sprite_t *( *pfnSPR_GetList ) ( char *psz, int *piCount ); client_sprite_t *( *pfnSPR_GetList ) ( char *psz, int *piCount );
// screen handlers // screen handlers
void ( *pfnFillRGBA ) ( int x, int y, int width, int height, int r, int g, int b, int a ); void ( *pfnFillRGBA ) ( int x, int y, int width, int height, int r, int g, int b, int a );
int ( *pfnGetScreenInfo ) ( SCREENINFO *pscrinfo ); int ( *pfnGetScreenInfo ) ( SCREENINFO *pscrinfo );
void ( *pfnSetCrosshair ) ( HSPRITE hspr, wrect_t rc, int r, int g, int b ); void ( *pfnSetCrosshair ) ( HSPRITE hspr, wrect_t rc, int r, int g, int b );
// cvar handlers // cvar handlers
struct cvar_s *( *pfnRegisterVariable ) ( char *szName, char *szValue, int flags ); struct cvar_s *( *pfnRegisterVariable ) ( char *szName, char *szValue, int flags );
float ( *pfnGetCvarFloat ) ( char *szName ); float ( *pfnGetCvarFloat ) ( char *szName );
char* ( *pfnGetCvarString ) ( char *szName ); char* ( *pfnGetCvarString ) ( char *szName );
// command handlers // command handlers
int ( *pfnAddCommand ) ( char *cmd_name, void (*function)(void) ); int ( *pfnAddCommand ) ( char *cmd_name, void (*function)(void) );
int ( *pfnHookUserMsg ) ( char *szMsgName, pfnUserMsgHook pfn ); int ( *pfnHookUserMsg ) ( char *szMsgName, pfnUserMsgHook pfn );
int ( *pfnServerCmd ) ( char *szCmdString ); int ( *pfnServerCmd ) ( char *szCmdString );
int ( *pfnClientCmd ) ( char *szCmdString ); int ( *pfnClientCmd ) ( char *szCmdString );
void ( *pfnGetPlayerInfo ) ( int ent_num, hud_player_info_t *pinfo ); void ( *pfnGetPlayerInfo ) ( int ent_num, hud_player_info_t *pinfo );
// sound handlers // sound handlers
void ( *pfnPlaySoundByName ) ( char *szSound, float volume ); void ( *pfnPlaySoundByName ) ( char *szSound, float volume );
void ( *pfnPlaySoundByIndex ) ( int iSound, float volume ); void ( *pfnPlaySoundByIndex ) ( int iSound, float volume );
// vector helpers // vector helpers
void ( *pfnAngleVectors ) ( const float * vecAngles, float * forward, float * right, float * up ); void ( *pfnAngleVectors ) ( const float * vecAngles, float * forward, float * right, float * up );
// text message system // text message system
client_textmessage_t *( *pfnTextMessageGet ) ( const char *pName ); client_textmessage_t *( *pfnTextMessageGet ) ( const char *pName );
int ( *pfnDrawCharacter ) ( int x, int y, int number, int r, int g, int b ); int ( *pfnDrawCharacter ) ( int x, int y, int number, int r, int g, int b );
int ( *pfnDrawConsoleString ) ( int x, int y, char *string ); int ( *pfnDrawConsoleString ) ( int x, int y, char *string );
void ( *pfnDrawSetTextColor ) ( float r, float g, float b ); void ( *pfnDrawSetTextColor ) ( float r, float g, float b );
void ( *pfnDrawConsoleStringLen )( const char *string, int *length, int *height ); void ( *pfnDrawConsoleStringLen )( const char *string, int *length, int *height );
void ( *pfnConsolePrint ) ( const char *string ); void ( *pfnConsolePrint ) ( const char *string );
void ( *pfnCenterPrint ) ( const char *string ); void ( *pfnCenterPrint ) ( const char *string );
// Added for user input processing // Added for user input processing
int ( *GetWindowCenterX ) ( void ); int ( *GetWindowCenterX ) ( void );
int ( *GetWindowCenterY ) ( void ); int ( *GetWindowCenterY ) ( void );
void ( *GetViewAngles ) ( float * ); void ( *GetViewAngles ) ( float * );
void ( *SetViewAngles ) ( float * ); void ( *SetViewAngles ) ( float * );
int ( *GetMaxClients ) ( void ); int ( *GetMaxClients ) ( void );
void ( *Cvar_SetValue ) ( char *cvar, float value ); void ( *Cvar_SetValue ) ( char *cvar, float value );
int (*Cmd_Argc) (void); int (*Cmd_Argc) (void);
char *( *Cmd_Argv ) ( int arg ); char *( *Cmd_Argv ) ( int arg );
void ( *Con_Printf ) ( char *fmt, ... ); void ( *Con_Printf ) ( char *fmt, ... );
void ( *Con_DPrintf ) ( char *fmt, ... ); void ( *Con_DPrintf ) ( char *fmt, ... );
void ( *Con_NPrintf ) ( int pos, char *fmt, ... ); void ( *Con_NPrintf ) ( int pos, char *fmt, ... );
void ( *Con_NXPrintf ) ( struct con_nprint_s *info, char *fmt, ... ); void ( *Con_NXPrintf ) ( struct con_nprint_s *info, char *fmt, ... );
const char *( *PhysInfo_ValueForKey ) ( const char *key ); const char *( *PhysInfo_ValueForKey ) ( const char *key );
const char *( *ServerInfo_ValueForKey )( const char *key ); const char *( *ServerInfo_ValueForKey )( const char *key );
float ( *GetClientMaxspeed ) ( void ); float ( *GetClientMaxspeed ) ( void );
int ( *CheckParm ) ( char *parm, char **ppnext ); int ( *CheckParm ) ( char *parm, char **ppnext );
void ( *Key_Event ) ( int key, int down ); void ( *Key_Event ) ( int key, int down );
void ( *GetMousePosition ) ( int *mx, int *my ); void ( *GetMousePosition ) ( int *mx, int *my );
int ( *IsNoClipping ) ( void ); int ( *IsNoClipping ) ( void );
struct cl_entity_s *( *GetLocalPlayer ) ( void ); struct cl_entity_s *( *GetLocalPlayer ) ( void );
struct cl_entity_s *( *GetViewModel ) ( void ); struct cl_entity_s *( *GetViewModel ) ( void );
struct cl_entity_s *( *GetEntityByIndex ) ( int idx ); struct cl_entity_s *( *GetEntityByIndex ) ( int idx );
float ( *GetClientTime ) ( void ); float ( *GetClientTime ) ( void );
void ( *V_CalcShake ) ( void ); void ( *V_CalcShake ) ( void );
void ( *V_ApplyShake ) ( float *origin, float *angles, float factor ); void ( *V_ApplyShake ) ( float *origin, float *angles, float factor );
int ( *PM_PointContents ) ( float *point, int *truecontents ); int ( *PM_PointContents ) ( float *point, int *truecontents );
int ( *PM_WaterEntity ) ( float *p ); int ( *PM_WaterEntity ) ( float *p );
struct pmtrace_s *( *PM_TraceLine ) ( float *start, float *end, int flags, int usehull, int ignore_pe ); struct pmtrace_s *( *PM_TraceLine ) ( float *start, float *end, int flags, int usehull, int ignore_pe );
struct model_s *( *CL_LoadModel ) ( const char *modelname, int *index ); struct model_s *( *CL_LoadModel ) ( const char *modelname, int *index );
int ( *CL_CreateVisibleEntity ) ( int type, struct cl_entity_s *ent ); int ( *CL_CreateVisibleEntity ) ( int type, struct cl_entity_s *ent );
const struct model_s * ( *GetSpritePointer ) ( HSPRITE hSprite ); const struct model_s * ( *GetSpritePointer ) ( HSPRITE hSprite );
void ( *pfnPlaySoundByNameAtLocation ) ( char *szSound, float volume, float *origin ); void ( *pfnPlaySoundByNameAtLocation ) ( char *szSound, float volume, float *origin );
unsigned short ( *pfnPrecacheEvent ) ( int type, const char* psz ); unsigned short ( *pfnPrecacheEvent ) ( int type, const char* psz );
void ( *pfnPlaybackEvent ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); void ( *pfnPlaybackEvent ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
void ( *pfnWeaponAnim ) ( int iAnim, int body ); void ( *pfnWeaponAnim ) ( int iAnim, int body );
float ( *pfnRandomFloat ) ( float flLow, float flHigh ); float ( *pfnRandomFloat ) ( float flLow, float flHigh );
long ( *pfnRandomLong ) ( long lLow, long lHigh ); long ( *pfnRandomLong ) ( long lLow, long lHigh );
void ( *pfnHookEvent ) ( char *name, void ( *pfnEvent )( struct event_args_s *args ) ); void ( *pfnHookEvent ) ( char *name, void ( *pfnEvent )( struct event_args_s *args ) );
int (*Con_IsVisible) (); int (*Con_IsVisible) ();
const char *( *pfnGetGameDirectory ) ( void ); const char *( *pfnGetGameDirectory ) ( void );
struct cvar_s *( *pfnGetCvarPointer ) ( const char *szName ); struct cvar_s *( *pfnGetCvarPointer ) ( const char *szName );
const char *( *Key_LookupBinding ) ( const char *pBinding ); const char *( *Key_LookupBinding ) ( const char *pBinding );
const char *( *pfnGetLevelName ) ( void ); const char *( *pfnGetLevelName ) ( void );
void ( *pfnGetScreenFade ) ( struct screenfade_s *fade ); void ( *pfnGetScreenFade ) ( struct screenfade_s *fade );
void ( *pfnSetScreenFade ) ( struct screenfade_s *fade ); void ( *pfnSetScreenFade ) ( struct screenfade_s *fade );
void *( *VGui_GetPanel ) ( ); void *( *VGui_GetPanel ) ( );
void ( *VGui_ViewportPaintBackground ) (int extents[4]); void ( *VGui_ViewportPaintBackground ) (int extents[4]);
byte* (*COM_LoadFile) ( char *path, int usehunk, int *pLength ); byte* (*COM_LoadFile) ( char *path, int usehunk, int *pLength );
char* (*COM_ParseFile) ( char *data, char *token ); char* (*COM_ParseFile) ( char *data, char *token );
void (*COM_FreeFile) ( void *buffer ); void (*COM_FreeFile) ( void *buffer );
struct triangleapi_s *pTriAPI; struct triangleapi_s *pTriAPI;
struct efx_api_s *pEfxAPI; struct efx_api_s *pEfxAPI;
struct event_api_s *pEventAPI; struct event_api_s *pEventAPI;
struct demo_api_s *pDemoAPI; struct demo_api_s *pDemoAPI;
struct net_api_s *pNetAPI; struct net_api_s *pNetAPI;
struct IVoiceTweak_s *pVoiceTweak; struct IVoiceTweak_s *pVoiceTweak;
// returns 1 if the client is a spectator only (connected to a proxy), 0 otherwise or 2 if in dev_overview mode // returns 1 if the client is a spectator only (connected to a proxy), 0 otherwise or 2 if in dev_overview mode
int ( *IsSpectateOnly ) ( void ); int ( *IsSpectateOnly ) ( void );
struct model_s *( *LoadMapSprite ) ( const char *filename ); struct model_s *( *LoadMapSprite ) ( const char *filename );
// file search functions // file search functions
void ( *COM_AddAppDirectoryToSearchPath ) ( const char *pszBaseDir, const char *appName ); void ( *COM_AddAppDirectoryToSearchPath ) ( const char *pszBaseDir, const char *appName );
int ( *COM_ExpandFilename) ( const char *fileName, char *nameOutBuffer, int nameOutBufferSize ); int ( *COM_ExpandFilename) ( const char *fileName, char *nameOutBuffer, int nameOutBufferSize );
// User info // User info
// playerNum is in the range (1, MaxClients) // playerNum is in the range (1, MaxClients)
// returns NULL if player doesn't exit // returns NULL if player doesn't exit
// returns "" if no value is set // returns "" if no value is set
const char *( *PlayerInfo_ValueForKey )( int playerNum, const char *key ); const char *( *PlayerInfo_ValueForKey )( int playerNum, const char *key );
void ( *PlayerInfo_SetValueForKey )( const char *key, const char *value ); void ( *PlayerInfo_SetValueForKey )( const char *key, const char *value );
// Gets a unique ID for the specified player. This is the same even if you see the player on a different server. // Gets a unique ID for the specified player. This is the same even if you see the player on a different server.
// iPlayer is an entity index, so client 0 would use iPlayer=1. // iPlayer is an entity index, so client 0 would use iPlayer=1.
// Returns false if there is no player on the server in the specified slot. // Returns false if there is no player on the server in the specified slot.
qboolean (*GetPlayerUniqueID)(int iPlayer, char playerID[16]); qboolean (*GetPlayerUniqueID)(int iPlayer, char playerID[16]);
// TrackerID access // TrackerID access
int (*GetTrackerIDForPlayer)(int playerSlot); int (*GetTrackerIDForPlayer)(int playerSlot);
int (*GetPlayerForTrackerID)(int trackerID); int (*GetPlayerForTrackerID)(int trackerID);
// Same as pfnServerCmd, but the message goes in the unreliable stream so it can't clog the net stream // Same as pfnServerCmd, but the message goes in the unreliable stream so it can't clog the net stream
// (but it might not get there). // (but it might not get there).
int ( *pfnServerCmdUnreliable )( char *szCmdString ); int ( *pfnServerCmdUnreliable )( char *szCmdString );
void ( *pfnGetMousePos )( struct tagPOINT *ppt ); void ( *pfnGetMousePos )( struct tagPOINT *ppt );
void ( *pfnSetMousePos )( int x, int y ); void ( *pfnSetMousePos )( int x, int y );
void ( *pfnSetMouseEnable )( qboolean fEnable ); void ( *pfnSetMouseEnable )( qboolean fEnable );
} cl_enginefunc_t; } cl_enginefunc_t;
#ifndef IN_BUTTONS_H #ifndef IN_BUTTONS_H
#include "in_buttons.h" #include "in_buttons.h"
#endif #endif
#define CLDLL_INTERFACE_VERSION 7 #define CLDLL_INTERFACE_VERSION 7
extern void ClientDLL_Init( void ); // from cdll_int.c extern void ClientDLL_Init( void ); // from cdll_int.c
extern void ClientDLL_Shutdown( void ); extern void ClientDLL_Shutdown( void );
extern void ClientDLL_HudInit( void ); extern void ClientDLL_HudInit( void );
extern void ClientDLL_HudVidInit( void ); extern void ClientDLL_HudVidInit( void );
extern void ClientDLL_UpdateClientData( void ); extern void ClientDLL_UpdateClientData( void );
extern void ClientDLL_Frame( double time ); extern void ClientDLL_Frame( double time );
extern void ClientDLL_HudRedraw( int intermission ); extern void ClientDLL_HudRedraw( int intermission );
extern void ClientDLL_MoveClient( struct playermove_s *ppmove ); extern void ClientDLL_MoveClient( struct playermove_s *ppmove );
extern void ClientDLL_ClientMoveInit( struct playermove_s *ppmove ); extern void ClientDLL_ClientMoveInit( struct playermove_s *ppmove );
extern char ClientDLL_ClientTextureType( char *name ); extern char ClientDLL_ClientTextureType( char *name );
extern void ClientDLL_CreateMove( float frametime, struct usercmd_s *cmd, int active ); extern void ClientDLL_CreateMove( float frametime, struct usercmd_s *cmd, int active );
extern void ClientDLL_ActivateMouse( void ); extern void ClientDLL_ActivateMouse( void );
extern void ClientDLL_DeactivateMouse( void ); extern void ClientDLL_DeactivateMouse( void );
extern void ClientDLL_MouseEvent( int mstate ); extern void ClientDLL_MouseEvent( int mstate );
extern void ClientDLL_ClearStates( void ); extern void ClientDLL_ClearStates( void );
extern int ClientDLL_IsThirdPerson( void ); extern int ClientDLL_IsThirdPerson( void );
extern void ClientDLL_GetCameraOffsets( float *ofs ); extern void ClientDLL_GetCameraOffsets( float *ofs );
extern int ClientDLL_GraphKeyDown( void ); extern int ClientDLL_GraphKeyDown( void );
extern struct kbutton_s *ClientDLL_FindKey( const char *name ); extern struct kbutton_s *ClientDLL_FindKey( const char *name );
extern void ClientDLL_CAM_Think( void ); extern void ClientDLL_CAM_Think( void );
extern void ClientDLL_IN_Accumulate( void ); extern void ClientDLL_IN_Accumulate( void );
extern void ClientDLL_CalcRefdef( struct ref_params_s *pparams ); extern void ClientDLL_CalcRefdef( struct ref_params_s *pparams );
extern int ClientDLL_AddEntity( int type, struct cl_entity_s *ent ); extern int ClientDLL_AddEntity( int type, struct cl_entity_s *ent );
extern void ClientDLL_CreateEntities( void ); extern void ClientDLL_CreateEntities( void );
extern void ClientDLL_DrawNormalTriangles( void ); extern void ClientDLL_DrawNormalTriangles( void );
extern void ClientDLL_DrawTransparentTriangles( void ); extern void ClientDLL_DrawTransparentTriangles( void );
extern void ClientDLL_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity ); extern void ClientDLL_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
extern void ClientDLL_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); extern void ClientDLL_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );
extern void ClientDLL_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client ); extern void ClientDLL_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client );
extern void ClientDLL_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src ); extern void ClientDLL_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src );
extern void ClientDLL_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd ); extern void ClientDLL_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd );
extern void ClientDLL_ReadDemoBuffer( int size, unsigned char *buffer ); extern void ClientDLL_ReadDemoBuffer( int size, unsigned char *buffer );
extern int ClientDLL_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); extern int ClientDLL_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
extern int ClientDLL_GetHullBounds( int hullnumber, float *mins, float *maxs ); extern int ClientDLL_GetHullBounds( int hullnumber, float *mins, float *maxs );
extern void ClientDLL_VGui_ConsolePrint(const char* text); extern void ClientDLL_VGui_ConsolePrint(const char* text);
extern int ClientDLL_Key_Event( int down, int keynum, const char *pszCurrentBinding ); extern int ClientDLL_Key_Event( int down, int keynum, const char *pszCurrentBinding );
extern void ClientDLL_TempEntUpdate( double ft, double ct, double grav, struct tempent_s **ppFreeTE, struct tempent_s **ppActiveTE, int ( *addTEntity )( struct cl_entity_s *pEntity ), void ( *playTESound )( struct tempent_s *pTemp, float damp ) ); extern void ClientDLL_TempEntUpdate( double ft, double ct, double grav, struct tempent_s **ppFreeTE, struct tempent_s **ppActiveTE, int ( *addTEntity )( struct cl_entity_s *pEntity ), void ( *playTESound )( struct tempent_s *pTemp, float damp ) );
extern struct cl_entity_s *ClientDLL_GetUserEntity( int index ); extern struct cl_entity_s *ClientDLL_GetUserEntity( int index );
extern void ClientDLL_VoiceStatus(int entindex, qboolean bTalking); extern void ClientDLL_VoiceStatus(int entindex, qboolean bTalking);
extern void ClientDLL_DirectorMessage( int iSize, void *pbuf ); extern void ClientDLL_DirectorMessage( int iSize, void *pbuf );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // CDLL_INT_H #endif // CDLL_INT_H

View File

@@ -1,104 +1,104 @@
/*** /***
* *
* Copyright (c) 1999, Valve LLC. All rights reserved. * Copyright (c) 1999, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// Customization.h // Customization.h
#ifndef CUSTOM_H #ifndef CUSTOM_H
#define CUSTOM_H #define CUSTOM_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
#include "const.h" #include "const.h"
#define MAX_QPATH 64 // Must match value in quakedefs.h #define MAX_QPATH 64 // Must match value in quakedefs.h
///////////////// /////////////////
// Customization // Customization
// passed to pfnPlayerCustomization // passed to pfnPlayerCustomization
// For automatic downloading. // For automatic downloading.
typedef enum typedef enum
{ {
t_sound = 0, t_sound = 0,
t_skin, t_skin,
t_model, t_model,
t_decal, t_decal,
t_generic, t_generic,
t_eventscript t_eventscript
} resourcetype_t; } resourcetype_t;
// Fake type for world // Fake type for world
#define t_world 6 #define t_world 6
typedef struct typedef struct
{ {
int size; int size;
} _resourceinfo_t; } _resourceinfo_t;
typedef struct resourceinfo_s typedef struct resourceinfo_s
{ {
_resourceinfo_t info[ 7 ]; _resourceinfo_t info[ 7 ];
} resourceinfo_t; } resourceinfo_t;
#define RES_FATALIFMISSING (1<<0) // Disconnect if we can't get this file. #define RES_FATALIFMISSING (1<<0) // Disconnect if we can't get this file.
#define RES_WASMISSING (1<<1) // Do we have the file locally, did we get it ok? #define RES_WASMISSING (1<<1) // Do we have the file locally, did we get it ok?
#define RES_CUSTOM (1<<2) // Is this resource one that corresponds to another player's customization #define RES_CUSTOM (1<<2) // Is this resource one that corresponds to another player's customization
// or is it a server startup resource. // or is it a server startup resource.
#define RES_REQUESTED (1<<3) // Already requested a download of this one #define RES_REQUESTED (1<<3) // Already requested a download of this one
#define RES_PRECACHED (1<<4) // Already precached #define RES_PRECACHED (1<<4) // Already precached
#include "crc.h" #include "crc.h"
typedef struct resource_s typedef struct resource_s
{ {
char szFileName[MAX_QPATH]; // File name to download/precache. char szFileName[MAX_QPATH]; // File name to download/precache.
resourcetype_t type; // t_sound, t_skin, t_model, t_decal. resourcetype_t type; // t_sound, t_skin, t_model, t_decal.
int nIndex; // For t_decals int nIndex; // For t_decals
int nDownloadSize; // Size in Bytes if this must be downloaded. int nDownloadSize; // Size in Bytes if this must be downloaded.
unsigned char ucFlags; unsigned char ucFlags;
// For handling client to client resource propagation // For handling client to client resource propagation
unsigned char rgucMD5_hash[16]; // To determine if we already have it. unsigned char rgucMD5_hash[16]; // To determine if we already have it.
unsigned char playernum; // Which player index this resource is associated with, if it's a custom resource. unsigned char playernum; // Which player index this resource is associated with, if it's a custom resource.
unsigned char rguc_reserved[ 32 ]; // For future expansion unsigned char rguc_reserved[ 32 ]; // For future expansion
struct resource_s *pNext; // Next in chain. struct resource_s *pNext; // Next in chain.
struct resource_s *pPrev; struct resource_s *pPrev;
} resource_t; } resource_t;
typedef struct customization_s typedef struct customization_s
{ {
qboolean bInUse; // Is this customization in use; qboolean bInUse; // Is this customization in use;
resource_t resource; // The resource_t for this customization resource_t resource; // The resource_t for this customization
qboolean bTranslated; // Has the raw data been translated into a useable format? qboolean bTranslated; // Has the raw data been translated into a useable format?
// (e.g., raw decal .wad make into texture_t *) // (e.g., raw decal .wad make into texture_t *)
int nUserData1; // Customization specific data int nUserData1; // Customization specific data
int nUserData2; // Customization specific data int nUserData2; // Customization specific data
void *pInfo; // Buffer that holds the data structure that references the data (e.g., the cachewad_t) void *pInfo; // Buffer that holds the data structure that references the data (e.g., the cachewad_t)
void *pBuffer; // Buffer that holds the data for the customization (the raw .wad data) void *pBuffer; // Buffer that holds the data for the customization (the raw .wad data)
struct customization_s *pNext; // Next in chain struct customization_s *pNext; // Next in chain
} customization_t; } customization_t;
#define FCUST_FROMHPAK ( 1<<0 ) #define FCUST_FROMHPAK ( 1<<0 )
#define FCUST_WIPEDATA ( 1<<1 ) #define FCUST_WIPEDATA ( 1<<1 )
#define FCUST_IGNOREINIT ( 1<<2 ) #define FCUST_IGNOREINIT ( 1<<2 )
void COM_ClearCustomizationList( struct customization_s *pHead, qboolean bCleanDecals); void COM_ClearCustomizationList( struct customization_s *pHead, qboolean bCleanDecals);
qboolean COM_CreateCustomization( struct customization_s *pListHead, struct resource_s *pResource, int playernumber, int flags, qboolean COM_CreateCustomization( struct customization_s *pListHead, struct resource_s *pResource, int playernumber, int flags,
struct customization_s **pCustomization, int *nLumps ); struct customization_s **pCustomization, int *nLumps );
int COM_SizeofResourceList ( struct resource_s *pList, struct resourceinfo_s *ri ); int COM_SizeofResourceList ( struct resource_s *pList, struct resourceinfo_s *ri );
#endif // CUSTOM_H #endif // CUSTOM_H

View File

@@ -1,38 +1,38 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef CUSTOMENTITY_H #ifndef CUSTOMENTITY_H
#define CUSTOMENTITY_H #define CUSTOMENTITY_H
// Custom Entities // Custom Entities
// Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12) // Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12)
#define BEAMENT_ENTITY(x) ((x)&0xFFF) #define BEAMENT_ENTITY(x) ((x)&0xFFF)
#define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF) #define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF)
// Beam types, encoded as a byte // Beam types, encoded as a byte
enum enum
{ {
BEAM_POINTS = 0, BEAM_POINTS = 0,
BEAM_ENTPOINT, BEAM_ENTPOINT,
BEAM_ENTS, BEAM_ENTS,
BEAM_HOSE, BEAM_HOSE,
}; };
#define BEAM_FSINE 0x10 #define BEAM_FSINE 0x10
#define BEAM_FSOLID 0x20 #define BEAM_FSOLID 0x20
#define BEAM_FSHADEIN 0x40 #define BEAM_FSHADEIN 0x40
#define BEAM_FSHADEOUT 0x80 #define BEAM_FSHADEOUT 0x80
#endif //CUSTOMENTITY_H #endif //CUSTOMENTITY_H

View File

@@ -1,31 +1,31 @@
#if !defined EDICT_H #if !defined EDICT_H
#define EDICT_H #define EDICT_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
#define MAX_ENT_LEAFS 48 #define MAX_ENT_LEAFS 48
#include "progdefs.h" #include "progdefs.h"
struct edict_s struct edict_s
{ {
qboolean free; qboolean free;
int serialnumber; int serialnumber;
link_t area; // linked to a division node or leaf link_t area; // linked to a division node or leaf
int headnode; // -1 to use normal leaf check int headnode; // -1 to use normal leaf check
int num_leafs; int num_leafs;
short leafnums[MAX_ENT_LEAFS]; short leafnums[MAX_ENT_LEAFS];
float freetime; // sv.time when the object was freed float freetime; // sv.time when the object was freed
void* pvPrivateData; // Alloced and freed by engine, used by DLLs void* pvPrivateData; // Alloced and freed by engine, used by DLLs
entvars_t v; // C exported fields from progs entvars_t v; // C exported fields from progs
// other fields from progs come immediately after // other fields from progs come immediately after
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,131 +1,131 @@
//========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
// keydefs.h // keydefs.h
#ifndef KEYDEFS_H #ifndef KEYDEFS_H
#define KEYDEFS_H #define KEYDEFS_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
// //
// these are the key numbers that should be passed to Key_Event // these are the key numbers that should be passed to Key_Event
// //
#define K_TAB 9 #define K_TAB 9
#define K_ENTER 13 #define K_ENTER 13
#define K_ESCAPE 27 #define K_ESCAPE 27
#define K_SPACE 32 #define K_SPACE 32
// normal keys should be passed as lowercased ascii // normal keys should be passed as lowercased ascii
#define K_BACKSPACE 127 #define K_BACKSPACE 127
#define K_UPARROW 128 #define K_UPARROW 128
#define K_DOWNARROW 129 #define K_DOWNARROW 129
#define K_LEFTARROW 130 #define K_LEFTARROW 130
#define K_RIGHTARROW 131 #define K_RIGHTARROW 131
#define K_ALT 132 #define K_ALT 132
#define K_CTRL 133 #define K_CTRL 133
#define K_SHIFT 134 #define K_SHIFT 134
#define K_F1 135 #define K_F1 135
#define K_F2 136 #define K_F2 136
#define K_F3 137 #define K_F3 137
#define K_F4 138 #define K_F4 138
#define K_F5 139 #define K_F5 139
#define K_F6 140 #define K_F6 140
#define K_F7 141 #define K_F7 141
#define K_F8 142 #define K_F8 142
#define K_F9 143 #define K_F9 143
#define K_F10 144 #define K_F10 144
#define K_F11 145 #define K_F11 145
#define K_F12 146 #define K_F12 146
#define K_INS 147 #define K_INS 147
#define K_DEL 148 #define K_DEL 148
#define K_PGDN 149 #define K_PGDN 149
#define K_PGUP 150 #define K_PGUP 150
#define K_HOME 151 #define K_HOME 151
#define K_END 152 #define K_END 152
#define K_KP_HOME 160 #define K_KP_HOME 160
#define K_KP_UPARROW 161 #define K_KP_UPARROW 161
#define K_KP_PGUP 162 #define K_KP_PGUP 162
#define K_KP_LEFTARROW 163 #define K_KP_LEFTARROW 163
#define K_KP_5 164 #define K_KP_5 164
#define K_KP_RIGHTARROW 165 #define K_KP_RIGHTARROW 165
#define K_KP_END 166 #define K_KP_END 166
#define K_KP_DOWNARROW 167 #define K_KP_DOWNARROW 167
#define K_KP_PGDN 168 #define K_KP_PGDN 168
#define K_KP_ENTER 169 #define K_KP_ENTER 169
#define K_KP_INS 170 #define K_KP_INS 170
#define K_KP_DEL 171 #define K_KP_DEL 171
#define K_KP_SLASH 172 #define K_KP_SLASH 172
#define K_KP_MINUS 173 #define K_KP_MINUS 173
#define K_KP_PLUS 174 #define K_KP_PLUS 174
#define K_CAPSLOCK 175 #define K_CAPSLOCK 175
// //
// joystick buttons // joystick buttons
// //
#define K_JOY1 203 #define K_JOY1 203
#define K_JOY2 204 #define K_JOY2 204
#define K_JOY3 205 #define K_JOY3 205
#define K_JOY4 206 #define K_JOY4 206
// //
// aux keys are for multi-buttoned joysticks to generate so they can use // aux keys are for multi-buttoned joysticks to generate so they can use
// the normal binding process // the normal binding process
// //
#define K_AUX1 207 #define K_AUX1 207
#define K_AUX2 208 #define K_AUX2 208
#define K_AUX3 209 #define K_AUX3 209
#define K_AUX4 210 #define K_AUX4 210
#define K_AUX5 211 #define K_AUX5 211
#define K_AUX6 212 #define K_AUX6 212
#define K_AUX7 213 #define K_AUX7 213
#define K_AUX8 214 #define K_AUX8 214
#define K_AUX9 215 #define K_AUX9 215
#define K_AUX10 216 #define K_AUX10 216
#define K_AUX11 217 #define K_AUX11 217
#define K_AUX12 218 #define K_AUX12 218
#define K_AUX13 219 #define K_AUX13 219
#define K_AUX14 220 #define K_AUX14 220
#define K_AUX15 221 #define K_AUX15 221
#define K_AUX16 222 #define K_AUX16 222
#define K_AUX17 223 #define K_AUX17 223
#define K_AUX18 224 #define K_AUX18 224
#define K_AUX19 225 #define K_AUX19 225
#define K_AUX20 226 #define K_AUX20 226
#define K_AUX21 227 #define K_AUX21 227
#define K_AUX22 228 #define K_AUX22 228
#define K_AUX23 229 #define K_AUX23 229
#define K_AUX24 230 #define K_AUX24 230
#define K_AUX25 231 #define K_AUX25 231
#define K_AUX26 232 #define K_AUX26 232
#define K_AUX27 233 #define K_AUX27 233
#define K_AUX28 234 #define K_AUX28 234
#define K_AUX29 235 #define K_AUX29 235
#define K_AUX30 236 #define K_AUX30 236
#define K_AUX31 237 #define K_AUX31 237
#define K_AUX32 238 #define K_AUX32 238
#define K_MWHEELDOWN 239 #define K_MWHEELDOWN 239
#define K_MWHEELUP 240 #define K_MWHEELUP 240
#define K_PAUSE 255 #define K_PAUSE 255
// //
// mouse buttons generate virtual keys // mouse buttons generate virtual keys
// //
#define K_MOUSE1 241 #define K_MOUSE1 241
#define K_MOUSE2 242 #define K_MOUSE2 242
#define K_MOUSE3 243 #define K_MOUSE3 243
#define K_MOUSE4 244 #define K_MOUSE4 244
#define K_MOUSE5 245 #define K_MOUSE5 245
#endif // KEYDEFS_H #endif // KEYDEFS_H

View File

@@ -1,226 +1,226 @@
/*** /***
* *
* Copyright (c) 1999, Valve LLC. All rights reserved. * Copyright (c) 1999, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef PROGDEFS_H #ifndef PROGDEFS_H
#define PROGDEFS_H #define PROGDEFS_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef struct typedef struct
{ {
float time; float time;
float frametime; float frametime;
float force_retouch; float force_retouch;
string_t mapname; string_t mapname;
string_t startspot; string_t startspot;
float deathmatch; float deathmatch;
float coop; float coop;
float teamplay; float teamplay;
float serverflags; float serverflags;
float found_secrets; float found_secrets;
vec3_t v_forward; vec3_t v_forward;
vec3_t v_up; vec3_t v_up;
vec3_t v_right; vec3_t v_right;
float trace_allsolid; float trace_allsolid;
float trace_startsolid; float trace_startsolid;
float trace_fraction; float trace_fraction;
vec3_t trace_endpos; vec3_t trace_endpos;
vec3_t trace_plane_normal; vec3_t trace_plane_normal;
float trace_plane_dist; float trace_plane_dist;
edict_t *trace_ent; edict_t *trace_ent;
float trace_inopen; float trace_inopen;
float trace_inwater; float trace_inwater;
int trace_hitgroup; int trace_hitgroup;
int trace_flags; int trace_flags;
int msg_entity; int msg_entity;
int cdAudioTrack; int cdAudioTrack;
int maxClients; int maxClients;
int maxEntities; int maxEntities;
const char *pStringBase; const char *pStringBase;
void *pSaveData; void *pSaveData;
vec3_t vecLandmarkOffset; vec3_t vecLandmarkOffset;
} globalvars_t; } globalvars_t;
typedef struct entvars_s typedef struct entvars_s
{ {
string_t classname; string_t classname;
string_t globalname; string_t globalname;
vec3_t origin; vec3_t origin;
vec3_t oldorigin; vec3_t oldorigin;
vec3_t velocity; vec3_t velocity;
vec3_t basevelocity; vec3_t basevelocity;
vec3_t clbasevelocity; // Base velocity that was passed in to server physics so vec3_t clbasevelocity; // Base velocity that was passed in to server physics so
// client can predict conveyors correctly. Server zeroes it, so we need to store here, too. // client can predict conveyors correctly. Server zeroes it, so we need to store here, too.
vec3_t movedir; vec3_t movedir;
vec3_t angles; // Model angles vec3_t angles; // Model angles
vec3_t avelocity; // angle velocity (degrees per second) vec3_t avelocity; // angle velocity (degrees per second)
vec3_t punchangle; // auto-decaying view angle adjustment vec3_t punchangle; // auto-decaying view angle adjustment
vec3_t v_angle; // Viewing angle (player only) vec3_t v_angle; // Viewing angle (player only)
// For parametric entities // For parametric entities
vec3_t endpos; vec3_t endpos;
vec3_t startpos; vec3_t startpos;
float impacttime; float impacttime;
float starttime; float starttime;
int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity
float idealpitch; float idealpitch;
float pitch_speed; float pitch_speed;
float ideal_yaw; float ideal_yaw;
float yaw_speed; float yaw_speed;
int modelindex; int modelindex;
string_t model; string_t model;
int viewmodel; // player's viewmodel int viewmodel; // player's viewmodel
int weaponmodel; // what other players see int weaponmodel; // what other players see
vec3_t absmin; // BB max translated to world coord vec3_t absmin; // BB max translated to world coord
vec3_t absmax; // BB max translated to world coord vec3_t absmax; // BB max translated to world coord
vec3_t mins; // local BB min vec3_t mins; // local BB min
vec3_t maxs; // local BB max vec3_t maxs; // local BB max
vec3_t size; // maxs - mins vec3_t size; // maxs - mins
float ltime; float ltime;
float nextthink; float nextthink;
int movetype; int movetype;
int solid; int solid;
int skin; int skin;
int body; // sub-model selection for studiomodels int body; // sub-model selection for studiomodels
int effects; int effects;
float gravity; // % of "normal" gravity float gravity; // % of "normal" gravity
float friction; // inverse elasticity of MOVETYPE_BOUNCE float friction; // inverse elasticity of MOVETYPE_BOUNCE
int light_level; int light_level;
int sequence; // animation sequence int sequence; // animation sequence
int gaitsequence; // movement animation sequence for player (0 for none) int gaitsequence; // movement animation sequence for player (0 for none)
float frame; // % playback position in animation sequences (0..255) float frame; // % playback position in animation sequences (0..255)
float animtime; // world time when frame was set float animtime; // world time when frame was set
float framerate; // animation playback rate (-8x to 8x) float framerate; // animation playback rate (-8x to 8x)
byte controller[4]; // bone controller setting (0..255) byte controller[4]; // bone controller setting (0..255)
byte blending[2]; // blending amount between sub-sequences (0..255) byte blending[2]; // blending amount between sub-sequences (0..255)
float scale; // sprite rendering scale (0..255) float scale; // sprite rendering scale (0..255)
int rendermode; int rendermode;
float renderamt; float renderamt;
vec3_t rendercolor; vec3_t rendercolor;
int renderfx; int renderfx;
float health; float health;
float frags; float frags;
int weapons; // bit mask for available weapons int weapons; // bit mask for available weapons
float takedamage; float takedamage;
int deadflag; int deadflag;
vec3_t view_ofs; // eye position vec3_t view_ofs; // eye position
int button; int button;
int impulse; int impulse;
edict_t *chain; // Entity pointer when linked into a linked list edict_t *chain; // Entity pointer when linked into a linked list
edict_t *dmg_inflictor; edict_t *dmg_inflictor;
edict_t *enemy; edict_t *enemy;
edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW
edict_t *owner; edict_t *owner;
edict_t *groundentity; edict_t *groundentity;
int spawnflags; int spawnflags;
int flags; int flags;
int colormap; // lowbyte topcolor, highbyte bottomcolor int colormap; // lowbyte topcolor, highbyte bottomcolor
int team; int team;
float max_health; float max_health;
float teleport_time; float teleport_time;
float armortype; float armortype;
float armorvalue; float armorvalue;
int waterlevel; int waterlevel;
int watertype; int watertype;
string_t target; string_t target;
string_t targetname; string_t targetname;
string_t netname; string_t netname;
string_t message; string_t message;
float dmg_take; float dmg_take;
float dmg_save; float dmg_save;
float dmg; float dmg;
float dmgtime; float dmgtime;
string_t noise; string_t noise;
string_t noise1; string_t noise1;
string_t noise2; string_t noise2;
string_t noise3; string_t noise3;
float speed; float speed;
float air_finished; float air_finished;
float pain_finished; float pain_finished;
float radsuit_finished; float radsuit_finished;
edict_t *pContainingEntity; edict_t *pContainingEntity;
int playerclass; int playerclass;
float maxspeed; float maxspeed;
float fov; float fov;
int weaponanim; int weaponanim;
int pushmsec; int pushmsec;
int bInDuck; int bInDuck;
int flTimeStepSound; int flTimeStepSound;
int flSwimTime; int flSwimTime;
int flDuckTime; int flDuckTime;
int iStepLeft; int iStepLeft;
float flFallVelocity; float flFallVelocity;
int gamestate; int gamestate;
int oldbuttons; int oldbuttons;
int groupinfo; int groupinfo;
// For mods // For mods
int iuser1; int iuser1;
int iuser2; int iuser2;
int iuser3; int iuser3;
int iuser4; int iuser4;
float fuser1; float fuser1;
float fuser2; float fuser2;
float fuser3; float fuser3;
float fuser4; float fuser4;
vec3_t vuser1; vec3_t vuser1;
vec3_t vuser2; vec3_t vuser2;
vec3_t vuser3; vec3_t vuser3;
vec3_t vuser4; vec3_t vuser4;
edict_t *euser1; edict_t *euser1;
edict_t *euser2; edict_t *euser2;
edict_t *euser3; edict_t *euser3;
edict_t *euser4; edict_t *euser4;
} entvars_t; } entvars_t;
#endif // PROGDEFS_H #endif // PROGDEFS_H

View File

@@ -1,82 +1,82 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef PROGS_H #ifndef PROGS_H
#define PROGS_H #define PROGS_H
#include "progdefs.h" #include "progdefs.h"
// 16 simultaneous events, max // 16 simultaneous events, max
#define MAX_EVENT_QUEUE 64 #define MAX_EVENT_QUEUE 64
#define DEFAULT_EVENT_RESENDS 1 #define DEFAULT_EVENT_RESENDS 1
#include "event_flags.h" #include "event_flags.h"
typedef struct event_info_s event_info_t; typedef struct event_info_s event_info_t;
#include "event_args.h" #include "event_args.h"
struct event_info_s struct event_info_s
{ {
unsigned short index; // 0 implies not in use unsigned short index; // 0 implies not in use
short packet_index; // Use data from state info for entity in delta_packet . -1 implies separate info based on event short packet_index; // Use data from state info for entity in delta_packet . -1 implies separate info based on event
// parameter signature // parameter signature
short entity_index; // The edict this event is associated with short entity_index; // The edict this event is associated with
float fire_time; // if non-zero, the time when the event should be fired ( fixed up on the client ) float fire_time; // if non-zero, the time when the event should be fired ( fixed up on the client )
event_args_t args; event_args_t args;
// CLIENT ONLY // CLIENT ONLY
int flags; // Reliable or not, etc. int flags; // Reliable or not, etc.
}; };
typedef struct event_state_s event_state_t; typedef struct event_state_s event_state_t;
struct event_state_s struct event_state_s
{ {
struct event_info_s ei[ MAX_EVENT_QUEUE ]; struct event_info_s ei[ MAX_EVENT_QUEUE ];
}; };
#if !defined( ENTITY_STATEH ) #if !defined( ENTITY_STATEH )
#include "entity_state.h" #include "entity_state.h"
#endif #endif
#if !defined( EDICT_H ) #if !defined( EDICT_H )
#include "edict.h" #include "edict.h"
#endif #endif
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m))) #define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) #define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
//============================================================================ //============================================================================
extern char *pr_strings; extern char *pr_strings;
extern globalvars_t gGlobalVariables; extern globalvars_t gGlobalVariables;
//============================================================================ //============================================================================
edict_t *ED_Alloc (void); edict_t *ED_Alloc (void);
void ED_Free (edict_t *ed); void ED_Free (edict_t *ed);
void ED_LoadFromFile (char *data); void ED_LoadFromFile (char *data);
edict_t *EDICT_NUM(int n); edict_t *EDICT_NUM(int n);
int NUM_FOR_EDICT(const edict_t *e); int NUM_FOR_EDICT(const edict_t *e);
#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) #define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e))
#endif // PROGS_H #endif // PROGS_H

Some files were not shown because too many files have changed in this diff Show More