From 625ef14d46343f0102b697390b0cc7edccc66d70 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 17 Sep 2015 02:19:21 +0600 Subject: [PATCH] WIP: full of reversed basic part --- regamedll/build.gradle | 8 +- regamedll/common/mathlib.h | 22 +- regamedll/common/r_studioint.h | 197 +- regamedll/dlls/activitymap.h | 16 +- regamedll/dlls/airtank.cpp | 2 +- regamedll/dlls/animating.cpp | 3 +- regamedll/dlls/animation.cpp | 1678 ++++---- regamedll/dlls/basemonster.h | 34 +- regamedll/dlls/bmodels.cpp | 1013 +++-- regamedll/dlls/bmodels.h | 121 +- regamedll/dlls/bot/cs_bot.cpp | 922 ++-- regamedll/dlls/bot/cs_bot.h | 171 +- regamedll/dlls/bot/cs_bot_chatter.cpp | 120 +- regamedll/dlls/bot/cs_bot_chatter.h | 934 ++-- regamedll/dlls/bot/cs_bot_event.cpp | 2 +- regamedll/dlls/bot/cs_bot_init.cpp | 104 +- regamedll/dlls/bot/cs_bot_learn.cpp | 446 +- regamedll/dlls/bot/cs_bot_listen.cpp | 2 +- regamedll/dlls/bot/cs_bot_manager.cpp | 597 +-- regamedll/dlls/bot/cs_bot_vision.cpp | 968 ++--- regamedll/dlls/bot/cs_bot_weapon.cpp | 4 +- regamedll/dlls/bot/cs_gamestate.h | 236 +- regamedll/dlls/buttons.cpp | 1356 ++++-- regamedll/dlls/buttons.h | 115 +- regamedll/dlls/career_tasks.cpp | 1218 +++--- regamedll/dlls/career_tasks.h | 4 +- regamedll/dlls/cbase.cpp | 1899 ++++----- regamedll/dlls/cbase.h | 244 +- regamedll/dlls/client.cpp | 1925 +++++---- regamedll/dlls/combat.cpp | 2169 ++++++---- regamedll/dlls/doors.cpp | 1169 ++++- regamedll/dlls/doors.h | 87 +- regamedll/dlls/effects.cpp | 2228 +++++----- regamedll/dlls/effects.h | 64 +- regamedll/dlls/enginecallback.h | 1 + regamedll/dlls/explode.cpp | 4 +- regamedll/dlls/explode.h | 2 +- regamedll/dlls/extdll.h | 16 +- regamedll/dlls/func_break.cpp | 1096 +++-- regamedll/dlls/func_break.h | 82 +- regamedll/dlls/func_tank.cpp | 1259 ++++-- regamedll/dlls/func_tank.h | 183 +- regamedll/dlls/gamerules.cpp | 94 +- regamedll/dlls/gamerules.h | 421 +- regamedll/dlls/ggrenade.cpp | 13 +- regamedll/dlls/h_ai.cpp | 235 +- regamedll/dlls/h_ai.h | 6 +- regamedll/dlls/h_battery.cpp | 5 +- regamedll/dlls/h_cycler.cpp | 346 +- regamedll/dlls/h_cycler.h | 243 +- regamedll/dlls/h_export.cpp | 5 +- regamedll/dlls/healthkit.cpp | 298 +- regamedll/dlls/healthkit.h | 7 +- regamedll/dlls/hostage/hostage.cpp | 1418 +++---- regamedll/dlls/hostage/hostage.h | 456 +- regamedll/dlls/hostage/hostage_improv.cpp | 348 +- regamedll/dlls/hostage/hostage_localnav.cpp | 2 +- regamedll/dlls/hostage/hostage_states.h | 22 +- regamedll/dlls/items.cpp | 10 +- regamedll/dlls/items.h | 48 +- regamedll/dlls/lights.cpp | 188 +- regamedll/dlls/lights.h | 7 +- regamedll/dlls/maprules.cpp | 815 ++-- regamedll/dlls/maprules.h | 157 +- regamedll/dlls/monsterevent.h | 1 + regamedll/dlls/monsters.h | 2 +- regamedll/dlls/mortar.cpp | 2 +- regamedll/dlls/mpstubb.cpp | 193 +- regamedll/dlls/multiplay_gamerules.cpp | 44 +- regamedll/dlls/observer.cpp | 8 +- regamedll/dlls/pathcorner.cpp | 440 +- regamedll/dlls/pathcorner.h | 14 +- regamedll/dlls/plats.cpp | 2399 ++++++++--- regamedll/dlls/plats.h | 214 +- regamedll/dlls/player.cpp | 2090 ++++----- regamedll/dlls/player.h | 11 +- regamedll/dlls/saverestore.h | 4 +- regamedll/dlls/skill.cpp | 2 +- regamedll/dlls/skill.h | 2 +- regamedll/dlls/sound.cpp | 1396 +++++- regamedll/dlls/sound.h | 214 +- regamedll/dlls/soundent.cpp | 316 +- regamedll/dlls/soundent.h | 21 +- regamedll/dlls/subs.cpp | 345 +- regamedll/dlls/subs.h | 20 +- regamedll/dlls/talkmonster.h | 2 +- regamedll/dlls/training_gamerules.cpp | 6 +- regamedll/dlls/training_gamerules.h | 2 +- regamedll/dlls/trains.h | 181 +- regamedll/dlls/triggers.cpp | 2191 ++++++++-- regamedll/dlls/triggers.h | 408 +- regamedll/dlls/tutor.cpp | 20 +- regamedll/dlls/tutor_base_states.h | 20 +- regamedll/dlls/tutor_cs_states.cpp | 96 +- regamedll/dlls/tutor_cs_states.h | 20 +- regamedll/dlls/tutor_cs_tutor.cpp | 11 +- regamedll/dlls/tutor_cs_tutor.h | 1 - regamedll/dlls/util.cpp | 48 +- regamedll/dlls/util.h | 35 +- regamedll/dlls/vector.h | 26 +- regamedll/dlls/vehicle.cpp | 1361 ++++-- regamedll/dlls/vehicle.h | 14 +- regamedll/dlls/weapons.cpp | 1681 ++++++-- regamedll/dlls/weapons.h | 293 +- regamedll/dlls/weapontype.cpp | 14 +- regamedll/dlls/weapontype.h | 68 + regamedll/dlls/world.cpp | 720 ++-- regamedll/dlls/wpn_shared/wpn_ak47.cpp | 60 +- regamedll/dlls/wpn_shared/wpn_awp.cpp | 320 +- regamedll/dlls/wpn_shared/wpn_p90.cpp | 280 +- regamedll/dlls/wpn_shared/wpn_usp.cpp | 238 +- regamedll/engine/anorms.h | 330 +- regamedll/engine/bspfile.h | 152 +- regamedll/engine/cdll_int.h | 12 +- regamedll/engine/custom.h | 12 +- regamedll/engine/customentity.h | 2 +- regamedll/engine/eiface.h | 36 +- regamedll/engine/keydefs.h | 2 +- regamedll/engine/maintypes.h | 2 +- regamedll/engine/model.h | 2 +- regamedll/engine/progdefs.h | 368 +- regamedll/engine/progs.h | 10 +- regamedll/engine/shake.h | 2 + regamedll/engine/studio.h | 24 +- regamedll/engine/unicode_strtools.cpp | 14 +- regamedll/game_shared/bitvec.h | 8 +- regamedll/game_shared/bot/bot.cpp | 8 +- regamedll/game_shared/bot/bot.h | 10 +- regamedll/game_shared/bot/bot_constants.h | 16 +- regamedll/game_shared/bot/bot_manager.cpp | 17 +- regamedll/game_shared/bot/bot_manager.h | 23 +- regamedll/game_shared/bot/bot_profile.h | 3 +- regamedll/game_shared/bot/bot_util.cpp | 4 +- regamedll/game_shared/bot/improv.h | 8 +- regamedll/game_shared/bot/nav.h | 804 ++-- regamedll/game_shared/bot/nav_area.cpp | 44 +- regamedll/game_shared/bot/nav_area.h | 3 +- regamedll/game_shared/bot/nav_file.cpp | 51 +- regamedll/game_shared/bot/nav_file.h | 51 +- regamedll/game_shared/bot/nav_node.h | 34 +- regamedll/game_shared/bot/nav_path.h | 14 +- .../game_shared/bot/simple_state_machine.h | 8 +- regamedll/game_shared/shared_util.cpp | 22 +- regamedll/game_shared/voice_gamemgr.cpp | 6 +- regamedll/hookers/6153_hooker.cpp | 1953 +++++---- regamedll/hookers/hooker.cpp | 22 +- regamedll/hookers/hooker.h | 8 + regamedll/hookers/memory.cpp | 2 +- regamedll/hookers/osconfig.h | 2 +- regamedll/hookers/regamedll_debug.cpp | 105 +- regamedll/hookers/regamedll_debug.h | 8 +- regamedll/msvc/ReGameDLL.vcxproj | 4 +- regamedll/pm_shared/pm_defs.h | 2 + regamedll/pm_shared/pm_math.cpp | 164 +- regamedll/pm_shared/pm_movevars.h | 17 +- regamedll/pm_shared/pm_shared.cpp | 3780 ++++++++--------- regamedll/public/MemPool.cpp | 2 +- regamedll/public/basetypes.h | 12 +- regamedll/public/utlvector.h | 274 +- regamedll/regamedll/dlls.h | 10 +- regamedll/regamedll/precompiled.h | 1 - 161 files changed, 31662 insertions(+), 20525 deletions(-) diff --git a/regamedll/build.gradle b/regamedll/build.gradle index b5fd245d..568904da 100644 --- a/regamedll/build.gradle +++ b/regamedll/build.gradle @@ -209,8 +209,8 @@ class RegamedllSrc { srcDirs "hookers" include "**/*.cpp" exclude "6153_hooker.cpp", "hooker.cpp", "main.cpp", "main_mp.cpp" - if (!GradleCppUtils.windows) - exclude "regamedll_debug.cpp" + // if (!GradleCppUtils.windows) + // exclude "regamedll_debug.cpp" } } } @@ -289,7 +289,7 @@ model { components { regamedll_hooker_gamedll(NativeLibrarySpec) { targetPlatform 'x86' - baseName 'FileSystem_Stdio' + baseName 'filesystem_stdio' sources { RegamedllSrc.regamedll_pch(it) @@ -337,7 +337,7 @@ model { task buildRelease { dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> - blib.buildable && (blib.buildType.name == 'release'/* || blib.buildType.name == 'debug'*/) && !blib.name.contains('RegamedllFixes') + blib.buildable && (/*blib.buildType.name == 'release' || */blib.buildType.name == 'debug') && !blib.name.contains('RegamedllFixes') } } diff --git a/regamedll/common/mathlib.h b/regamedll/common/mathlib.h index fd5d3242..afb234ce 100644 --- a/regamedll/common/mathlib.h +++ b/regamedll/common/mathlib.h @@ -67,23 +67,15 @@ typedef union DLONG_u #define M_PI 3.14159265358979323846 -//#ifndef max -//#define max(a,b) (((a) > (b)) ? (a) : (b)) -//#endif -// -//#ifndef min -//#define min(a,b) (((a) < (b)) ? (a) : (b)) -//#endif +#define clamp(val, x, y) (((val) > (y)) ? (y) : (((val) < (x)) ? (x) : (val))) -#ifndef _max -#define _max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#ifndef Q_max +#define Q_max(a,b) ((a) > (b) ? (a) : (b)) // std::max(a, b) +#endif // Q_max -#ifndef _min -#define _min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) +#ifndef Q_min +#define Q_min(a,b) ((a) < (b) ? (a) : (b)) // std::min(a, b) +#endif // Q_min #define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} #define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} diff --git a/regamedll/common/r_studioint.h b/regamedll/common/r_studioint.h index bbe105b4..06e271af 100644 --- a/regamedll/common/r_studioint.h +++ b/regamedll/common/r_studioint.h @@ -1,13 +1,34 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* 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 +* 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 +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ -#if !defined( R_STUDIOINT_H ) +#ifndef R_STUDIOINT_H #define R_STUDIOINT_H -#if defined( _WIN32 ) +#ifdef _WIN32 #pragma once #endif @@ -16,116 +37,148 @@ typedef struct engine_studio_api_s { // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); + void *(*Mem_Calloc)(int number, size_t size); + // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); + void *(*Cache_Check)(struct cache_user_s *c); + + // Load file into cache (can be swapped out on demand) + void (*LoadCacheFile)(char *path, struct cache_user_s *cu); + // Retrieve model pointer for the named model - struct model_s *( *Mod_ForName ) ( const char *name, int crash_if_missing ); + struct model_s *(*Mod_ForName)(const char *name, int crash_if_missing); + // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); + void *(*Mod_Extradata)(struct model_s *mod); + // Retrieve indexed model from client side model precache list - struct model_s *( *GetModelByIndex ) ( int index ); + struct model_s *(*GetModelByIndex)(int index); + // Get entity that is set for rendering - struct cl_entity_s * ( *GetCurrentEntity ) ( void ); + struct cl_entity_s * (*GetCurrentEntity)(void); + // Get referenced player_info_t - struct player_info_s *( *PlayerInfo ) ( int index ); + struct player_info_s *(*PlayerInfo)(int index); + // Get most recently received player state data from network system - struct entity_state_s *( *GetPlayerState ) ( int index ); + struct entity_state_s *(*GetPlayerState)(int index); + // Get viewentity - struct cl_entity_s * ( *GetViewEntity ) ( void ); + struct cl_entity_s * (*GetViewEntity)(void); + // Get current frame count, and last two timestampes on client - void ( *GetTimes ) ( int *framecount, double *current, double *old ); + void (*GetTimes)(int *framecount, double *current, double *old); + // Get a pointer to a cvar by name - struct cvar_s *( *GetCvar ) ( const char *name ); - // Get current render origin and view vectors ( up, right and vpn ) - void ( *GetViewInfo ) ( float *origin, float *upv, float *rightv, float *vpnv ); + struct cvar_s *(*GetCvar)(const char *name); + + // Get current render origin and view vectors (up, right and vpn) + void (*GetViewInfo)(float *origin, float *upv, float *rightv, float *vpnv); + // Get sprite model used for applying chrome effect - struct model_s *( *GetChromeSprite ) ( void ); + struct model_s *(*GetChromeSprite)(void); + // Get model counters so we can incement instrumentation - void ( *GetModelCounters ) ( int **s, int **a ); + void (*GetModelCounters)(int **s, int **a); + // Get software scaling coefficients - void ( *GetAliasScale ) ( float *x, float *y ); + void (*GetAliasScale)(float *x, float *y); // Get bone, light, alias, and rotation matrices - float ****( *StudioGetBoneTransform ) ( void ); - float ****( *StudioGetLightTransform )( void ); - float ***( *StudioGetAliasTransform ) ( void ); - float ***( *StudioGetRotationMatrix ) ( void ); + float ****(*StudioGetBoneTransform) (void); + float ****(*StudioGetLightTransform)(void); + float ***(*StudioGetAliasTransform) (void); + float ***(*StudioGetRotationMatrix) (void); // Set up body part, and get submodel pointers - void ( *StudioSetupModel ) ( int bodypart, void **ppbodypart, void **ppsubmodel ); + void (*StudioSetupModel)(int bodypart, void **ppbodypart, void **ppsubmodel); + // Check if entity's bbox is in the view frustum - int ( *StudioCheckBBox ) ( void ); + int (*StudioCheckBBox)(void); + // Apply lighting effects to model - void ( *StudioDynamicLight ) ( struct cl_entity_s *ent, struct alight_s *plight ); - void ( *StudioEntityLight ) ( struct alight_s *plight ); - void ( *StudioSetupLighting ) ( struct alight_s *plighting ); + void (*StudioDynamicLight)(struct cl_entity_s *ent, struct alight_s *plight); + void (*StudioEntityLight)(struct alight_s *plight); + void (*StudioSetupLighting)(struct alight_s *plighting); // Draw mesh vertices - void ( *StudioDrawPoints ) ( void ); + void (*StudioDrawPoints)(void); // Draw hulls around bones - void ( *StudioDrawHulls ) ( void ); + void (*StudioDrawHulls)(void); + // Draw bbox around studio models - void ( *StudioDrawAbsBBox ) ( void ); + void (*StudioDrawAbsBBox)(void); + // Draws bones - void ( *StudioDrawBones ) ( void ); + void (*StudioDrawBones)(void); // Loads in appropriate texture for model - void ( *StudioSetupSkin ) ( void *ptexturehdr, int index ); + + void (*StudioSetupSkin)(void *ptexturehdr, int index); + // Sets up for remapped colors - void ( *StudioSetRemapColors ) ( int top, int bottom ); + void (*StudioSetRemapColors)(int top, int bottom); + // Set's player model and returns model pointer - struct model_s *( *SetupPlayerModel ) ( int index ); + struct model_s *(*SetupPlayerModel)(int index); + // Fires any events embedded in animation - void ( *StudioClientEvents ) ( void ); + void (*StudioClientEvents)(void); + // Retrieve/set forced render effects flags - int ( *GetForceFaceFlags ) ( void ); - void ( *SetForceFaceFlags ) ( int flags ); + int (*GetForceFaceFlags)(void); + void (*SetForceFaceFlags)(int flags); + // Tell engine the value of the studio model header - void ( *StudioSetHeader ) ( void *header ); + void (*StudioSetHeader)(void *header); + // Tell engine which model_t * is being renderered - void ( *SetRenderModel ) ( struct model_s *model ); + void (*SetRenderModel)(struct model_s *model); // Final state setup and restore for rendering - void ( *SetupRenderer ) ( int rendermode ); - void ( *RestoreRenderer ) ( void ); + void (*SetupRenderer)(int rendermode); + void (*RestoreRenderer)(void); // Set render origin for applying chrome effect - void ( *SetChromeOrigin ) ( void ); + void (*SetChromeOrigin)(void); // True if using D3D/OpenGL - int ( *IsHardware ) ( void ); - - // Only called by hardware interface - void ( *GL_StudioDrawShadow ) ( void ); - void ( *GL_SetRenderMode ) ( int mode ); + int (*IsHardware)(void); + + // Only called by hardware interface + void (*GL_StudioDrawShadow)(void); + void (*GL_SetRenderMode)(int mode); + + void (*StudioSetRenderamt)(int iRenderamt); //!!!CZERO added for rendering glass on viewmodels + void (*StudioSetCullState)(int iCull); + void (*StudioRenderShadow)(int iSprite, float *p1, float *p2, float *p3, float *p4); - void ( *StudioSetRenderamt ) (int iRenderamt); //!!!CZERO added for rendering glass on viewmodels - void ( *StudioSetCullState ) ( int iCull ); - void ( *StudioRenderShadow ) ( int iSprite, float *p1, float *p2, float *p3, float *p4 ); } engine_studio_api_t; typedef struct server_studio_api_s { // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); + void *(*Mem_Calloc)(int number, size_t size); + // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); + void *(*Cache_Check)(struct cache_user_s *c); + + // Load file into cache (can be swapped out on demand) + void (*LoadCacheFile)(char *path, struct cache_user_s *cu); + // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); + void *(*Mod_Extradata)(struct model_s *mod); + } server_studio_api_t; // client blending typedef struct r_studio_interface_s { - int version; - int ( *StudioDrawModel ) ( int flags ); - int ( *StudioDrawPlayer ) ( int flags, struct entity_state_s *pplayer ); + int version; + int (*StudioDrawModel)(int flags); + int (*StudioDrawPlayer)(int flags, struct entity_state_s *pplayer); + } r_studio_interface_t; extern r_studio_interface_t *pStudioAPI; @@ -135,17 +188,17 @@ extern r_studio_interface_t *pStudioAPI; typedef struct sv_blending_interface_s { - int version; - - void ( *SV_StudioSetupBones )( struct model_s *pModel, + int version; + void (*SV_StudioSetupBones)(struct model_s *pModel, float frame, int sequence, - const vec3_t angles, - const vec3_t origin, + const vec_t *angles, + const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, - const edict_t *pEdict ); + const edict_t *pEdict); + } sv_blending_interface_t; #endif // R_STUDIOINT_H diff --git a/regamedll/dlls/activitymap.h b/regamedll/dlls/activitymap.h index da130c68..cc14c396 100644 --- a/regamedll/dlls/activitymap.h +++ b/regamedll/dlls/activitymap.h @@ -90,16 +90,16 @@ activity_map_t activity_map[] = _A(ACT_THREAT_DISPLAY), _A(ACT_FEAR_DISPLAY), _A(ACT_EXCITED), - _A( ACT_SPECIAL_ATTACK1), - _A( ACT_SPECIAL_ATTACK2), - _A( ACT_COMBAT_IDLE), + _A(ACT_SPECIAL_ATTACK1), + _A(ACT_SPECIAL_ATTACK2), + _A(ACT_COMBAT_IDLE), _A(ACT_WALK_SCARED), _A(ACT_RUN_SCARED), - _A( ACT_VICTORY_DANCE), - _A( ACT_DIE_HEADSHOT), - _A( ACT_DIE_CHESTSHOT), - _A( ACT_DIE_GUTSHOT), - _A( ACT_DIE_BACKSHOT), + _A(ACT_VICTORY_DANCE), + _A(ACT_DIE_HEADSHOT), + _A(ACT_DIE_CHESTSHOT), + _A(ACT_DIE_GUTSHOT), + _A(ACT_DIE_BACKSHOT), _A(ACT_FLINCH_HEAD), _A(ACT_FLINCH_CHEST), _A(ACT_FLINCH_STOMACH), diff --git a/regamedll/dlls/airtank.cpp b/regamedll/dlls/airtank.cpp index 14f60d25..eea4ae00 100644 --- a/regamedll/dlls/airtank.cpp +++ b/regamedll/dlls/airtank.cpp @@ -12,7 +12,7 @@ TYPEDESCRIPTION CAirtank::m_SaveData[] = #else -TYPEDESCRIPTION (*CAirtank::pm_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CAirtank, m_SaveData)[1]; #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/animating.cpp b/regamedll/dlls/animating.cpp index 338ce9b7..1500c2e2 100644 --- a/regamedll/dlls/animating.cpp +++ b/regamedll/dlls/animating.cpp @@ -16,7 +16,7 @@ TYPEDESCRIPTION CBaseAnimating::m_SaveData[] = #else -TYPEDESCRIPTION (*CBaseAnimating::pm_SaveData)[5]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBaseAnimating, m_SaveData)[5]; #endif // HOOK_GAMEDLL @@ -187,7 +187,6 @@ NOXREF int CBaseAnimating::FindTransition(int iEndingSequence, int iGoalSequence } return ::FindTransition(pmodel, iEndingSequence, iGoalSequence, piDir); - } /* <10a5d> ../cstrike/dlls/animating.cpp:234 */ diff --git a/regamedll/dlls/animation.cpp b/regamedll/dlls/animation.cpp index c2078572..099d6eb7 100644 --- a/regamedll/dlls/animation.cpp +++ b/regamedll/dlls/animation.cpp @@ -55,70 +55,70 @@ int ExtractBbox(void *pmodel, int sequence, float *mins, float *maxs) /* <152c6> ../cstrike/dlls/animation.cpp:81 */ int LookupActivity(void *pmodel, entvars_t *pev, int activity) { - studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; - - if (!pstudiohdr) - { - return 0; - } - - mstudioseqdesc_t *pseqdesc; - - int i; - int weightTotal = 0; - int activitySequenceCount = 0; - int weight = 0; - int select; - - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); - - for (i = 0; i < pstudiohdr->numseq; i++) - { - if (pseqdesc[i].activity == activity) - { - weightTotal += pseqdesc[i].actweight; - ++activitySequenceCount; - } - } - - if (activitySequenceCount > 0) - { - if (weightTotal) - { - int which = RANDOM_LONG(0, weightTotal - 1); - - for (i = 0; i < pstudiohdr->numseq; i++) - { - if (pseqdesc[i].activity == activity) - { - weight += pseqdesc[i].actweight; - - if (weight > which) - { - return i; - } - } - } - } - else - { - select = RANDOM_LONG(0, activitySequenceCount - 1); - - for (i = 0; i < pstudiohdr->numseq; i++) - { - if (pseqdesc[i].activity == activity) - { - if (select == 0) - { - return i; - } - - --select; - } - } - } - } - + studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; + + if (!pstudiohdr) + { + return 0; + } + + mstudioseqdesc_t *pseqdesc; + + int i; + int weightTotal = 0; + int activitySequenceCount = 0; + int weight = 0; + int select; + + pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); + + for (i = 0; i < pstudiohdr->numseq; i++) + { + if (pseqdesc[i].activity == activity) + { + weightTotal += pseqdesc[i].actweight; + ++activitySequenceCount; + } + } + + if (activitySequenceCount > 0) + { + if (weightTotal) + { + int which = RANDOM_LONG(0, weightTotal - 1); + + for (i = 0; i < pstudiohdr->numseq; i++) + { + if (pseqdesc[i].activity == activity) + { + weight += pseqdesc[i].actweight; + + if (weight > which) + { + return i; + } + } + } + } + else + { + select = RANDOM_LONG(0, activitySequenceCount - 1); + + for (i = 0; i < pstudiohdr->numseq; i++) + { + if (pseqdesc[i].activity == activity) + { + if (select == 0) + { + return i; + } + + --select; + } + } + } + } + return ACTIVITY_NOT_AVAILABLE; } @@ -154,18 +154,18 @@ int LookupActivityHeaviest(void *pmodel, entvars_t *pev, int activity) /* <15439> ../cstrike/dlls/animation.cpp:178 */ NOXREF void GetEyePosition(void *pmodel, float *vecEyePosition) { - studiohdr_t *pstudiohdr; - - pstudiohdr = (studiohdr_t *)pmodel; - - if (!pstudiohdr) - { - ALERT(at_console, "GetEyePosition() Can't get pstudiohdr ptr!\n"); - return; - } - - vecEyePosition[0] = pstudiohdr->eyeposition[0]; - vecEyePosition[1] = pstudiohdr->eyeposition[1]; + studiohdr_t *pstudiohdr; + + pstudiohdr = (studiohdr_t *)pmodel; + + if (!pstudiohdr) + { + ALERT(at_console, "GetEyePosition() Can't get pstudiohdr ptr!\n"); + return; + } + + vecEyePosition[0] = pstudiohdr->eyeposition[0]; + vecEyePosition[1] = pstudiohdr->eyeposition[1]; vecEyePosition[2] = pstudiohdr->eyeposition[2]; } @@ -191,48 +191,48 @@ int LookupSequence(void *pmodel, const char *label) /* <1518c> ../cstrike/dlls/animation.cpp:215 */ int IsSoundEvent(int eventNumber) { - if (eventNumber == SCRIPT_EVENT_SOUND || eventNumber == SCRIPT_EVENT_SOUND_VOICE) - { - return 1; - } - + if (eventNumber == SCRIPT_EVENT_SOUND || eventNumber == SCRIPT_EVENT_SOUND_VOICE) + { + return 1; + } + return 0; } /* <15539> ../cstrike/dlls/animation.cpp:223 */ NOXREF void SequencePrecache(void *pmodel, const char *pSequenceName) { - int index = LookupSequence(pmodel, pSequenceName); - - if (index >= 0) - { - studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; - if (!pstudiohdr || index >= pstudiohdr->numseq) - { - return; - } - - mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + index; - mstudioevent_t *pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); - - for (int i = 0; i < pseqdesc->numevents; i++) - { - // Don't send client-side events to the server AI - if (pevent[i].event >= EVENT_CLIENT) - continue; - - // UNDONE: Add a callback to check to see if a sound is precached yet and don't allocate a copy - // of it's name if it is. - if (IsSoundEvent(pevent[i].event)) - { - if (!Q_strlen(pevent[i].options)) - { - ALERT(at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options); - } - - PRECACHE_SOUND((char *)(gpGlobals->pStringBase + ALLOC_STRING(pevent[i].options))); - } - } + int index = LookupSequence(pmodel, pSequenceName); + + if (index >= 0) + { + studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; + if (!pstudiohdr || index >= pstudiohdr->numseq) + { + return; + } + + mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + index; + mstudioevent_t *pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); + + for (int i = 0; i < pseqdesc->numevents; i++) + { + // Don't send client-side events to the server AI + if (pevent[i].event >= EVENT_CLIENT) + continue; + + // UNDONE: Add a callback to check to see if a sound is precached yet and don't allocate a copy + // of it's name if it is. + if (IsSoundEvent(pevent[i].event)) + { + if (!Q_strlen(pevent[i].options)) + { + ALERT(at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options); + } + + PRECACHE_SOUND((char *)(gpGlobals->pStringBase + ALLOC_STRING(pevent[i].options))); + } + } } } @@ -283,52 +283,52 @@ int GetSequenceFlags(void *pmodel, entvars_t *pev) /* <15717> ../cstrike/dlls/animation.cpp:312 */ int GetAnimationEvent(void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index) { - studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; - - if (!pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent) - { - return 0; - } - - // int events = 0; - - mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; - mstudioevent_t *pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); - - if (pseqdesc->numevents == 0 || index > pseqdesc->numevents) - { - return 0; - } - - if (pseqdesc->numframes > 1) - { - flStart *= (pseqdesc->numframes - 1) / 256.0; - flEnd *= (pseqdesc->numframes - 1) / 256.0; - } - else - { - flStart = 0; - flEnd = 1.0; - } - - for (; index < pseqdesc->numevents; index++) - { - // Don't send client-side events to the server AI - if (pevent[index].event >= EVENT_CLIENT) - continue; - - if ((pevent[index].frame >= flStart && pevent[index].frame < flEnd) || - ((pseqdesc->flags & STUDIO_LOOPING) - && flEnd >= pseqdesc->numframes - 1 - && pevent[index].frame < flEnd - pseqdesc->numframes + 1)) - { - pMonsterEvent->event = pevent[index].event; - pMonsterEvent->options = pevent[index].options; - - return index + 1; - } - } - + studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; + + if (!pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent) + { + return 0; + } + + // int events = 0; + + mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; + mstudioevent_t *pevent = (mstudioevent_t *)((byte *)pstudiohdr + pseqdesc->eventindex); + + if (pseqdesc->numevents == 0 || index > pseqdesc->numevents) + { + return 0; + } + + if (pseqdesc->numframes > 1) + { + flStart *= (pseqdesc->numframes - 1) / 256.0; + flEnd *= (pseqdesc->numframes - 1) / 256.0; + } + else + { + flStart = 0; + flEnd = 1.0; + } + + for (; index < pseqdesc->numevents; index++) + { + // Don't send client-side events to the server AI + if (pevent[index].event >= EVENT_CLIENT) + continue; + + if ((pevent[index].frame >= flStart && pevent[index].frame < flEnd) || + ((pseqdesc->flags & STUDIO_LOOPING) + && flEnd >= pseqdesc->numframes - 1 + && pevent[index].frame < flEnd - pseqdesc->numframes + 1)) + { + pMonsterEvent->event = pevent[index].event; + pMonsterEvent->options = pevent[index].options; + + return index + 1; + } + } + return 0; } @@ -391,141 +391,141 @@ float SetController(void *pmodel, entvars_t *pev, int iController, float flValue /* <15883> ../cstrike/dlls/animation.cpp:414 */ float SetBlending(void *pmodel, entvars_t *pev, int iBlender, float flValue) -{ - studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; - if (!pstudiohdr) - { - return flValue; - } - - mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; - - if (pseqdesc->blendtype[iBlender] == 0) - { - return flValue; - } - - if (pseqdesc->blendtype[iBlender] & (STUDIO_XR | STUDIO_YR | STUDIO_ZR)) - { - // ugly hack, invert value if end < start - if (pseqdesc->blendend[iBlender] < pseqdesc->blendstart[iBlender]) - flValue = -flValue; - - // does the controller not wrap? - if (pseqdesc->blendstart[iBlender] + 359.0 >= pseqdesc->blendend[iBlender]) - { - if (flValue > ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) + 180) - { - flValue = flValue - 360; - } - - if (flValue < ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) - 180) - { - flValue = flValue + 360; - } - } - } - - int setting = (int64_t)(255.0f * (flValue - pseqdesc->blendstart[iBlender]) / (pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender])); - - if (setting < 0) - setting = 0; - - if (setting > 255) - setting = 255; - - pev->blending[iBlender] = setting; - +{ + studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; + if (!pstudiohdr) + { + return flValue; + } + + mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence; + + if (pseqdesc->blendtype[iBlender] == 0) + { + return flValue; + } + + if (pseqdesc->blendtype[iBlender] & (STUDIO_XR | STUDIO_YR | STUDIO_ZR)) + { + // ugly hack, invert value if end < start + if (pseqdesc->blendend[iBlender] < pseqdesc->blendstart[iBlender]) + flValue = -flValue; + + // does the controller not wrap? + if (pseqdesc->blendstart[iBlender] + 359.0 >= pseqdesc->blendend[iBlender]) + { + if (flValue > ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) + 180) + { + flValue = flValue - 360; + } + + if (flValue < ((pseqdesc->blendstart[iBlender] + pseqdesc->blendend[iBlender]) / 2.0) - 180) + { + flValue = flValue + 360; + } + } + } + + int setting = (int64_t)(255.0f * (flValue - pseqdesc->blendstart[iBlender]) / (pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender])); + + if (setting < 0) + setting = 0; + + if (setting > 255) + setting = 255; + + pev->blending[iBlender] = setting; + return setting * (1.0 / 255.0) * (pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender]) + pseqdesc->blendstart[iBlender]; } /* <15917> ../cstrike/dlls/animation.cpp:458 */ int FindTransition(void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir) { - studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; - if (!pstudiohdr) - { - return iGoalAnim; - } - - mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); - - // bail if we're going to or from a node 0 - if (pseqdesc[iEndingAnim].entrynode == 0 || pseqdesc[iGoalAnim].entrynode == 0) - { - return iGoalAnim; - } - - int iEndNode; - - if (*piDir > 0) - { - iEndNode = pseqdesc[iEndingAnim].exitnode; - } - else - { - iEndNode = pseqdesc[iEndingAnim].entrynode; - } - - if (iEndNode == pseqdesc[iGoalAnim].entrynode) - { - *piDir = 1; - return iGoalAnim; - } - - byte *pTransition = ((byte *)pstudiohdr + pstudiohdr->transitionindex); - - int iInternNode = pTransition[(iEndNode - 1)*pstudiohdr->numtransitions + (pseqdesc[iGoalAnim].entrynode - 1)]; - - if (iInternNode == 0) - { - return iGoalAnim; - } - - // look for someone going - for (int i = 0; i < pstudiohdr->numseq; i++) - { - if (pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode) - { - *piDir = 1; - return i; - } - if (pseqdesc[i].nodeflags) - { - if (pseqdesc[i].exitnode == iEndNode && pseqdesc[i].entrynode == iInternNode) - { - *piDir = -1; - return i; - } - } - } - - ALERT(at_console, "error in transition graph"); + studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; + if (!pstudiohdr) + { + return iGoalAnim; + } + + mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex); + + // bail if we're going to or from a node 0 + if (pseqdesc[iEndingAnim].entrynode == 0 || pseqdesc[iGoalAnim].entrynode == 0) + { + return iGoalAnim; + } + + int iEndNode; + + if (*piDir > 0) + { + iEndNode = pseqdesc[iEndingAnim].exitnode; + } + else + { + iEndNode = pseqdesc[iEndingAnim].entrynode; + } + + if (iEndNode == pseqdesc[iGoalAnim].entrynode) + { + *piDir = 1; + return iGoalAnim; + } + + byte *pTransition = ((byte *)pstudiohdr + pstudiohdr->transitionindex); + + int iInternNode = pTransition[(iEndNode - 1)*pstudiohdr->numtransitions + (pseqdesc[iGoalAnim].entrynode - 1)]; + + if (iInternNode == 0) + { + return iGoalAnim; + } + + // look for someone going + for (int i = 0; i < pstudiohdr->numseq; i++) + { + if (pseqdesc[i].entrynode == iEndNode && pseqdesc[i].exitnode == iInternNode) + { + *piDir = 1; + return i; + } + if (pseqdesc[i].nodeflags) + { + if (pseqdesc[i].exitnode == iEndNode && pseqdesc[i].entrynode == iInternNode) + { + *piDir = -1; + return i; + } + } + } + + ALERT(at_console, "error in transition graph"); return iGoalAnim; } /* <159d8> ../cstrike/dlls/animation.cpp:523 */ void SetBodygroup(void *pmodel, entvars_t *pev, int iGroup, int iValue) { - studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; - if (!pstudiohdr) - { - return; - } - - if (iGroup > pstudiohdr->numbodyparts) - { - return; - } - - mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex) + iGroup; - - if (iValue >= pbodypart->nummodels) - { - return; - } - - int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels; + studiohdr_t *pstudiohdr = (studiohdr_t *)pmodel; + if (!pstudiohdr) + { + return; + } + + if (iGroup > pstudiohdr->numbodyparts) + { + return; + } + + mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex) + iGroup; + + if (iValue >= pbodypart->nummodels) + { + return; + } + + int iCurrent = (pev->body / pbodypart->base) % pbodypart->nummodels; pev->body += (iValue - iCurrent) * pbodypart->base; } @@ -641,54 +641,54 @@ void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt) int i; float_precision a = 0; float_precision b = 0; - - for (i = 0; i < 4; i++) - { - a += (p[i] - q[i]) * (p[i] - q[i]); - b += (p[i] + q[i]) * (p[i] + q[i]); - } - - if (a > b) - { - for (i = 0; i < 4; i++) - q[i] = -q[i]; - } - - cosom = (p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3]); - - if ((1.0 + cosom) > 0.00000001) - { - if ((1.0 - cosom) > 0.00000001) - { - float_precision cosomega = acos((float_precision)cosom); - - omega = cosomega; - sinom = sin(cosomega); - - sclp = sin((1.0 - t) * omega) / sinom; - sclq = sin((float_precision)(omega * t)) / sinom; - } - else - { - sclq = t; - sclp = 1.0 - t; - } - - for (i = 0; i < 4; i++) - qt[i] = sclp * p[i] + sclq * q[i]; - } - else - { - qt[0] = -q[1]; - qt[1] = q[0]; - qt[2] = -q[3]; - qt[3] = q[2]; - - sclp = sin((1.0 - t) * 0.5 * M_PI); - sclq = sin(t * 0.5 * M_PI); - - for (i = 0; i < 3; i++) - qt[i] = sclp * p[i] + sclq * qt[i]; + + for (i = 0; i < 4; i++) + { + a += (p[i] - q[i]) * (p[i] - q[i]); + b += (p[i] + q[i]) * (p[i] + q[i]); + } + + if (a > b) + { + for (i = 0; i < 4; i++) + q[i] = -q[i]; + } + + cosom = (p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3]); + + if ((1.0 + cosom) > 0.00000001) + { + if ((1.0 - cosom) > 0.00000001) + { + float_precision cosomega = acos((float_precision)cosom); + + omega = cosomega; + sinom = sin(cosomega); + + sclp = sin((1.0 - t) * omega) / sinom; + sclq = sin((float_precision)(omega * t)) / sinom; + } + else + { + sclq = t; + sclp = 1.0 - t; + } + + for (i = 0; i < 4; i++) + qt[i] = sclp * p[i] + sclq * q[i]; + } + else + { + qt[0] = -q[1]; + qt[1] = q[0]; + qt[2] = -q[3]; + qt[3] = q[2]; + + sclp = sin((1.0 - t) * 0.5 * M_PI); + sclq = sin(t * 0.5 * M_PI); + + for (i = 0; i < 3; i++) + qt[i] = sclp * p[i] + sclq * qt[i]; } } @@ -696,20 +696,20 @@ void (*pQuaternionMatrix)(vec_t *quaternion, float matrix[3][4]); /* <15cd0> ../cstrike/dlls/animation.cpp:700 */ NOBODY void __declspec(naked) QuaternionMatrix(vec_t *quaternion, float matrix[3][4]) -{ - UNTESTED - __asm - { - jmp pQuaternionMatrix - } - - //matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2]; - //matrix[1][1] = 2.0 * quaternion[2] * quaternion[3] + quaternion[0] * quaternion[1]; - //matrix[2][2] = 2.0 * quaternion[2] * quaternion[0] - 2.0 * quaternion[3] * quaternion[1]; - //matrix[0][1] = 2.0 * quaternion[0] * quaternion[1] - 2.0 * quaternion[2] * quaternion[3]; - //matrix[1][2] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[2] * quaternion[2]; - //matrix[3][0] = 2.0 * quaternion[2] * quaternion[1] + quaternion[0] * quaternion[3]; - //matrix[0][2] = 2.0 * quaternion[2] * quaternion[0] + quaternion[3] * quaternion[1]; +{ + UNTESTED + __asm + { + jmp pQuaternionMatrix + } + + //matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2]; + //matrix[1][1] = 2.0 * quaternion[2] * quaternion[3] + quaternion[0] * quaternion[1]; + //matrix[2][2] = 2.0 * quaternion[2] * quaternion[0] - 2.0 * quaternion[3] * quaternion[1]; + //matrix[0][1] = 2.0 * quaternion[0] * quaternion[1] - 2.0 * quaternion[2] * quaternion[3]; + //matrix[1][2] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[2] * quaternion[2]; + //matrix[3][0] = 2.0 * quaternion[2] * quaternion[1] + quaternion[0] * quaternion[3]; + //matrix[0][2] = 2.0 * quaternion[2] * quaternion[0] + quaternion[3] * quaternion[1]; //matrix[2][0] = 2.0 * quaternion[2] * quaternion[1] - 2.0 * quaternion[0] * quaternion[3]; } @@ -725,20 +725,20 @@ mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc) { return (mstudioanim_t *)((byte *)g_pstudiohdr + pseqdesc->animindex); } - + paSequences = (cache_user_t *)m_pSubModel->submodels; if (paSequences == NULL) { - paSequences = (cache_user_t *)IEngineStudio.Mem_Calloc(16, sizeof(cache_user_t)); // UNDONE: leak! + paSequences = (cache_user_t *)IEngineStudio.Mem_Calloc(16, sizeof(cache_user_t)); // UNDONE: leak! m_pSubModel->submodels = (dmodel_t *)paSequences; } - if (!IEngineStudio.Cache_Check((struct cache_user_s *)&(paSequences[ pseqdesc->seqgroup ]))) - { - IEngineStudio.LoadCacheFile(pseqgroup->name, (struct cache_user_s *)&paSequences[ pseqdesc->seqgroup ]); - } - + if (!IEngineStudio.Cache_Check((struct cache_user_s *)&(paSequences[ pseqdesc->seqgroup ]))) + { + IEngineStudio.LoadCacheFile(pseqgroup->name, (struct cache_user_s *)&paSequences[ pseqdesc->seqgroup ]); + } + return (mstudioanim_t *)((byte *)paSequences[ pseqdesc->seqgroup ].data + pseqdesc->animindex); } @@ -755,233 +755,233 @@ NOXREF mstudioanim_t *LookupAnimation(studiohdr_t *pstudiohdr, model_s *model, m /* <151a9> ../cstrike/dlls/animation.cpp:770 */ void StudioCalcBoneAdj(float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen) { - int i, j; - float value; - mstudiobonecontroller_t *pbonecontroller; - - pbonecontroller = (mstudiobonecontroller_t *)((byte *)g_pstudiohdr + g_pstudiohdr->bonecontrollerindex); - - for (j = 0; j < g_pstudiohdr->numbonecontrollers; j++) - { - i = pbonecontroller[j].index; - if (i <= 3) - { - // check for 360% wrapping - if (pbonecontroller[j].type & STUDIO_RLOOP) - { - if (abs(pcontroller1[i] - pcontroller2[i]) > 128) - { - int a, b; - a = (pcontroller1[j] + 128) % 256; - b = (pcontroller2[j] + 128) % 256; - value = ((a * dadt) + (b * (1 - dadt)) - 128) * (360.0/256.0) + pbonecontroller[j].start; - } - else - { - value = ((pcontroller1[i] * dadt + (pcontroller2[i]) * (1.0 - dadt))) * (360.0/256.0) + pbonecontroller[j].start; - } - } - else - { - value = (pcontroller1[i] * dadt + pcontroller2[i] * (1.0 - dadt)) / 255.0; - - if (value < 0) - value = 0; - - if (value > 1.0) - value = 1.0; - - value = (1.0 - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; - } - } - else - { - value = mouthopen / 64.0; - - if (value > 1.0) - value = 1.0; - - value = (1.0 - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; - } - switch(pbonecontroller[j].type & STUDIO_TYPES) - { - case STUDIO_XR: - case STUDIO_YR: - case STUDIO_ZR: - adj[j] = value * (M_PI / 180.0); - break; - case STUDIO_X: - case STUDIO_Y: - case STUDIO_Z: - adj[j] = value; - break; - } + int i, j; + float value; + mstudiobonecontroller_t *pbonecontroller; + + pbonecontroller = (mstudiobonecontroller_t *)((byte *)g_pstudiohdr + g_pstudiohdr->bonecontrollerindex); + + for (j = 0; j < g_pstudiohdr->numbonecontrollers; j++) + { + i = pbonecontroller[j].index; + if (i <= 3) + { + // check for 360% wrapping + if (pbonecontroller[j].type & STUDIO_RLOOP) + { + if (abs(pcontroller1[i] - pcontroller2[i]) > 128) + { + int a, b; + a = (pcontroller1[j] + 128) % 256; + b = (pcontroller2[j] + 128) % 256; + value = ((a * dadt) + (b * (1 - dadt)) - 128) * (360.0/256.0) + pbonecontroller[j].start; + } + else + { + value = ((pcontroller1[i] * dadt + (pcontroller2[i]) * (1.0 - dadt))) * (360.0/256.0) + pbonecontroller[j].start; + } + } + else + { + value = (pcontroller1[i] * dadt + pcontroller2[i] * (1.0 - dadt)) / 255.0; + + if (value < 0) + value = 0; + + if (value > 1.0) + value = 1.0; + + value = (1.0 - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; + } + } + else + { + value = mouthopen / 64.0; + + if (value > 1.0) + value = 1.0; + + value = (1.0 - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; + } + switch (pbonecontroller[j].type & STUDIO_TYPES) + { + case STUDIO_XR: + case STUDIO_YR: + case STUDIO_ZR: + adj[j] = value * (M_PI / 180.0); + break; + case STUDIO_X: + case STUDIO_Y: + case STUDIO_Z: + adj[j] = value; + break; + } } } /* <15ea6> ../cstrike/dlls/animation.cpp:828 */ void StudioCalcBoneQuaterion(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q) { - int j, k; - vec4_t q1, q2; - vec3_t angle1, angle2; - mstudioanimvalue_t *panimvalue; - - for (j = 0; j < 3; j++) - { - if (panim->offset[j + 3] == 0) - { - // default; - angle2[j] = angle1[j] = pbone->value[j + 3]; - } - else - { - panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j + 3]); - k = frame; - - if (panimvalue->num.total < panimvalue->num.valid) - k = 0; - - while (panimvalue->num.total <= k) - { - k -= panimvalue->num.total; - panimvalue += panimvalue->num.valid + 1; - - if (panimvalue->num.total < panimvalue->num.valid) - k = 0; - } - - // Bah, missing blend! - if (panimvalue->num.valid > k) - { - angle1[j] = panimvalue[k + 1].value; - - if (panimvalue->num.valid > k + 1) - { - angle2[j] = panimvalue[k + 2].value; - } - else - { - if (panimvalue->num.total > k + 1) - angle2[j] = angle1[j]; - else - angle2[j] = panimvalue[panimvalue->num.valid + 2].value; - } - } - else - { - angle1[j] = panimvalue[panimvalue->num.valid].value; - if (panimvalue->num.total > k + 1) - { - angle2[j] = angle1[j]; - } - else - { - angle2[j] = panimvalue[panimvalue->num.valid + 2].value; - } - } - angle1[j] = pbone->value[j + 3] + angle1[j] * pbone->scale[j + 3]; - angle2[j] = pbone->value[j + 3] + angle2[j] * pbone->scale[j + 3]; - } - - if (pbone->bonecontroller[j + 3] != -1) - { - angle1[j] += adj[pbone->bonecontroller[j + 3]]; - angle2[j] += adj[pbone->bonecontroller[j + 3]]; - } - } - - if (!VectorCompare(angle1, angle2)) - { - AngleQuaternion(angle1, q1); - AngleQuaternion(angle2, q2); - QuaternionSlerp(q1, q2, s, q); - } - else + int j, k; + vec4_t q1, q2; + vec3_t angle1, angle2; + mstudioanimvalue_t *panimvalue; + + for (j = 0; j < 3; j++) + { + if (panim->offset[j + 3] == 0) + { + // default; + angle2[j] = angle1[j] = pbone->value[j + 3]; + } + else + { + panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j + 3]); + k = frame; + + if (panimvalue->num.total < panimvalue->num.valid) + k = 0; + + while (panimvalue->num.total <= k) + { + k -= panimvalue->num.total; + panimvalue += panimvalue->num.valid + 1; + + if (panimvalue->num.total < panimvalue->num.valid) + k = 0; + } + + // Bah, missing blend! + if (panimvalue->num.valid > k) + { + angle1[j] = panimvalue[k + 1].value; + + if (panimvalue->num.valid > k + 1) + { + angle2[j] = panimvalue[k + 2].value; + } + else + { + if (panimvalue->num.total > k + 1) + angle2[j] = angle1[j]; + else + angle2[j] = panimvalue[panimvalue->num.valid + 2].value; + } + } + else + { + angle1[j] = panimvalue[panimvalue->num.valid].value; + if (panimvalue->num.total > k + 1) + { + angle2[j] = angle1[j]; + } + else + { + angle2[j] = panimvalue[panimvalue->num.valid + 2].value; + } + } + angle1[j] = pbone->value[j + 3] + angle1[j] * pbone->scale[j + 3]; + angle2[j] = pbone->value[j + 3] + angle2[j] * pbone->scale[j + 3]; + } + + if (pbone->bonecontroller[j + 3] != -1) + { + angle1[j] += adj[pbone->bonecontroller[j + 3]]; + angle2[j] += adj[pbone->bonecontroller[j + 3]]; + } + } + + if (!VectorCompare(angle1, angle2)) + { + AngleQuaternion(angle1, q1); + AngleQuaternion(angle2, q2); + QuaternionSlerp(q1, q2, s, q); + } + else AngleQuaternion(angle1, q); } /* <15f94> ../cstrike/dlls/animation.cpp:908 */ void StudioCalcBonePosition(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos) { - int j, k; - mstudioanimvalue_t *panimvalue; - - for (j = 0; j < 3; j++) - { - // default; - pos[j] = pbone->value[j]; - if (panim->offset[j] != 0) - { - panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j]); - - k = frame; - - if (panimvalue->num.total < panimvalue->num.valid) - k = 0; - - // find span of values that includes the frame we want - while (panimvalue->num.total <= k) - { - k -= panimvalue->num.total; - panimvalue += panimvalue->num.valid + 1; - - if (panimvalue->num.total < panimvalue->num.valid) - k = 0; - } - // if we're inside the span - if (panimvalue->num.valid > k) - { - // and there's more data in the span - if (panimvalue->num.valid > k + 1) - pos[j] += (panimvalue[k + 1].value * (1.0 - s) + s * panimvalue[k + 2].value) * pbone->scale[j]; - else - pos[j] += panimvalue[k + 1].value * pbone->scale[j]; - } - else - { - // are we at the end of the repeating values section and there's another section with data? - if (panimvalue->num.total <= k + 1) - pos[j] += (panimvalue[panimvalue->num.valid].value * (1.0 - s) + s * panimvalue[panimvalue->num.valid + 2].value) * pbone->scale[j]; - - else - pos[j] += panimvalue[panimvalue->num.valid].value * pbone->scale[j]; - } - } - if (pbone->bonecontroller[j] != -1 && adj) - { - pos[j] += adj[pbone->bonecontroller[j]]; - } + int j, k; + mstudioanimvalue_t *panimvalue; + + for (j = 0; j < 3; j++) + { + // default; + pos[j] = pbone->value[j]; + if (panim->offset[j] != 0) + { + panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j]); + + k = frame; + + if (panimvalue->num.total < panimvalue->num.valid) + k = 0; + + // find span of values that includes the frame we want + while (panimvalue->num.total <= k) + { + k -= panimvalue->num.total; + panimvalue += panimvalue->num.valid + 1; + + if (panimvalue->num.total < panimvalue->num.valid) + k = 0; + } + // if we're inside the span + if (panimvalue->num.valid > k) + { + // and there's more data in the span + if (panimvalue->num.valid > k + 1) + pos[j] += (panimvalue[k + 1].value * (1.0 - s) + s * panimvalue[k + 2].value) * pbone->scale[j]; + else + pos[j] += panimvalue[k + 1].value * pbone->scale[j]; + } + else + { + // are we at the end of the repeating values section and there's another section with data? + if (panimvalue->num.total <= k + 1) + pos[j] += (panimvalue[panimvalue->num.valid].value * (1.0 - s) + s * panimvalue[panimvalue->num.valid + 2].value) * pbone->scale[j]; + + else + pos[j] += panimvalue[panimvalue->num.valid].value * pbone->scale[j]; + } + } + if (pbone->bonecontroller[j] != -1 && adj) + { + pos[j] += adj[pbone->bonecontroller[j]]; + } } } /* <1603c> ../cstrike/dlls/animation.cpp:970 */ void StudioSlerpBones(vec4_t *q1, float pos1[][3], vec4_t *q2, float pos2[][3], float s) { - int i; - vec4_t q3; - float s1; - - if (s < 0) - s = 0; - - else if (s > 1.0) - s = 1.0; - - s1 = 1.0 - s; - - for (i = 0; i < g_pstudiohdr->numbones; i++) - { - QuaternionSlerp(q1[i], q2[i], s, q3); - - q1[i][0] = q3[0]; - q1[i][1] = q3[1]; - q1[i][2] = q3[2]; - q1[i][3] = q3[3]; - - pos1[i][0] = pos1[i][0] * s1 + pos2[i][0] * s; - pos1[i][1] = pos1[i][1] * s1 + pos2[i][1] * s; - pos1[i][2] = pos1[i][2] * s1 + pos2[i][2] * s; + int i; + vec4_t q3; + float s1; + + if (s < 0) + s = 0; + + else if (s > 1.0) + s = 1.0; + + s1 = 1.0 - s; + + for (i = 0; i < g_pstudiohdr->numbones; i++) + { + QuaternionSlerp(q1[i], q2[i], s, q3); + + q1[i][0] = q3[0]; + q1[i][1] = q3[1]; + q1[i][2] = q3[2]; + q1[i][3] = q3[3]; + + pos1[i][0] = pos1[i][0] * s1 + pos2[i][0] * s; + pos1[i][1] = pos1[i][1] * s1 + pos2[i][1] * s; + pos1[i][2] = pos1[i][2] * s1 + pos2[i][2] * s; } } @@ -1003,291 +1003,291 @@ NOXREF void StudioCalcRotations(mstudiobone_t *pbones, int *chain, int chainleng /* <161fd> ../cstrike/dlls/animation.cpp:1006 */ void ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]) { - out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + in1[0][2] * in2[2][0]; - out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + in1[0][2] * in2[2][1]; - out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + in1[0][2] * in2[2][2]; - out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + in1[0][2] * in2[2][3] + in1[0][3]; - - out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + in1[1][2] * in2[2][0]; - out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + in1[1][2] * in2[2][1]; - out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + in1[1][2] * in2[2][2]; - out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + in1[1][2] * in2[2][3] + in1[1][3]; - - out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + in1[2][2] * in2[2][0]; - out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + in1[2][2] * in2[2][1]; - out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + in1[2][2] * in2[2][2]; + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + in1[0][2] * in2[2][0]; + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + in1[0][2] * in2[2][1]; + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + in1[0][2] * in2[2][2]; + out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + in1[0][2] * in2[2][3] + in1[0][3]; + + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + in1[1][2] * in2[2][0]; + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + in1[1][2] * in2[2][1]; + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + in1[1][2] * in2[2][2]; + out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + in1[1][2] * in2[2][3] + in1[1][3]; + + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + in1[2][2] * in2[2][0]; + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + in1[2][2] * in2[2][1]; + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + in1[2][2] * in2[2][2]; out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3]; } /* <16247> ../cstrike/dlls/animation.cpp:1115 */ NOBODY void SV_StudioSetupBones(struct model_s *pModel, float frame, int sequence, const vec_t *angles, const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, const edict_t *pEdict) { -// { -// int i; // 1117 -// int j; // 1117 -// float f; // 1118 -// float subframe; // 1118 -// float adj; // 1119 -// mstudiobone_t *pbones; // 1120 -// mstudioseqdesc_t *pseqdesc; // 1121 -// mstudioanim_t *panim; // 1122 -// float pos; // 1124 -// float bonematrix; // 1125 -// float q; // 1126 -// float pos3; // 1127 -// float q2; // 1128 -// int chain; // 1130 -// int chainlength; // 1131 -// vec3_t temp_angles; // 1354 -// StudioCalcBoneAdj(float dadt, -// float *adj, -// const byte *pcontroller1, -// const byte *pcontroller2, -// byte mouthopen); // 1175 -// { -// float b; // 1295 -// } -// { -// float pos3; // 1186 -// float q3; // 1187 -// float pos4; // 1188 -// float q4; // 1189 -// float s; // 1191 -// float t; // 1192 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1236 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1237 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1238 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1239 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1240 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1241 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1242 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1243 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1257 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1258 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1259 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1260 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1261 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1262 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1263 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1264 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1272 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1273 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1274 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1275 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1276 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1277 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1278 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1279 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1222 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1223 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1224 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1225 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1226 -// LookupAnimation(studiohdr_t *pstudiohdr, -// model_s *model, -// mstudioseqdesc_t *pseqdesc, -// int index); // 1227 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1228 -// } -// { -// int copy; // 1323 -// int gaitsequence; // 1324 -// StudioCalcRotations(mstudiobone_t *pbones, -// int *chain, -// int chainlength, -// float *adj, -// float *pos, -// vec4_t *q, -// mstudioseqdesc_t *pseqdesc, -// mstudioanim_t *panim, -// float f, -// float s); // 1333 -// } +// { +// int i; // 1117 +// int j; // 1117 +// float f; // 1118 +// float subframe; // 1118 +// float adj; // 1119 +// mstudiobone_t *pbones; // 1120 +// mstudioseqdesc_t *pseqdesc; // 1121 +// mstudioanim_t *panim; // 1122 +// float pos; // 1124 +// float bonematrix; // 1125 +// float q; // 1126 +// float pos3; // 1127 +// float q2; // 1128 +// int chain; // 1130 +// int chainlength; // 1131 +// vec3_t temp_angles; // 1354 +// StudioCalcBoneAdj(float dadt, +// float *adj, +// const byte *pcontroller1, +// const byte *pcontroller2, +// byte mouthopen); // 1175 +// { +// float b; // 1295 +// } +// { +// float pos3; // 1186 +// float q3; // 1187 +// float pos4; // 1188 +// float q4; // 1189 +// float s; // 1191 +// float t; // 1192 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1236 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1237 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1238 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1239 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1240 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1241 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1242 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1243 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1257 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1258 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1259 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1260 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1261 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1262 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1263 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1264 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1272 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1273 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1274 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1275 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1276 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1277 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1278 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1279 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1222 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1223 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1224 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1225 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1226 +// LookupAnimation(studiohdr_t *pstudiohdr, +// model_s *model, +// mstudioseqdesc_t *pseqdesc, +// int index); // 1227 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1228 +// } +// { +// int copy; // 1323 +// int gaitsequence; // 1324 +// StudioCalcRotations(mstudiobone_t *pbones, +// int *chain, +// int chainlength, +// float *adj, +// float *pos, +// vec4_t *q, +// mstudioseqdesc_t *pseqdesc, +// mstudioanim_t *panim, +// float f, +// float s); // 1333 +// } // } } diff --git a/regamedll/dlls/basemonster.h b/regamedll/dlls/basemonster.h index fecc1673..2e4f2d38 100644 --- a/regamedll/dlls/basemonster.h +++ b/regamedll/dlls/basemonster.h @@ -42,10 +42,10 @@ NOXREF char *vstr(float *v); class CBaseMonster: public CBaseToggle { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); + virtual void KeyValue(KeyValueData *pkvd); virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY virtual int TakeHealth(float flHealth, int bitsDamageType); + virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + virtual int TakeHealth(float flHealth, int bitsDamageType); virtual void Killed(entvars_t *pevAttacker, int iGib); virtual int BloodColor(void) { @@ -58,20 +58,20 @@ public: virtual float ChangeYaw(int speed); virtual BOOL HasHumanGibs(void); virtual BOOL HasAlienGibs(void); - NOBODY virtual void FadeMonster(void); + virtual void FadeMonster(void); virtual void GibMonster(void); - NOBODY virtual Activity GetDeathActivity(void); + NOXREF virtual Activity GetDeathActivity(void); virtual void BecomeDead(void); virtual BOOL ShouldFadeOnDeath(void); - NOBODY virtual int IRelationship(CBaseEntity *pTarget); + virtual int IRelationship(CBaseEntity *pTarget); virtual void PainSound(void) {} - NOBODY virtual void ResetMaxSpeed(void) {} - NOBODY virtual void ReportAIState(void) {} + virtual void ResetMaxSpeed(void) {} + virtual void ReportAIState(void) {} virtual void MonsterInitDead(void); - NOBODY virtual void Look(int iDistance); - NOBODY virtual CBaseEntity *BestVisibleEnemy(void); - NOBODY virtual BOOL FInViewCone(CBaseEntity *pEntity); - NOBODY virtual BOOL FInViewCone(Vector *pOrigin); + virtual void Look(int iDistance); + virtual CBaseEntity *BestVisibleEnemy(void); + virtual BOOL FInViewCone(CBaseEntity *pEntity); + virtual BOOL FInViewCone(const Vector *pOrigin); #ifdef HOOK_GAMEDLL @@ -101,13 +101,13 @@ public: void Look_(int iDistance); CBaseEntity *BestVisibleEnemy_(void); BOOL FInViewCone_(CBaseEntity *pEntity); - BOOL FInViewCone_(Vector *pOrigin); + BOOL FInViewCone_(const Vector *pOrigin); #endif // HOOK_GAMEDLL public: void MakeIdealYaw(Vector vecTarget); - NOBODY Activity GetSmallFlinchActivity(void); + NOXREF Activity GetSmallFlinchActivity(void); BOOL ShouldGibMonster(int iGib); void CallGibMonster(void); BOOL FCheckAITrigger(void); @@ -171,8 +171,8 @@ public: { pev->framerate = 0.0; } - NOBODY void CorpseFallThink(void); - NOBODY CBaseEntity *CheckTraceHullAttack(float flDist, int iDamage, int iDmgType); + NOXREF void CorpseFallThink(void); + NOXREF CBaseEntity *CheckTraceHullAttack(float flDist, int iDamage, int iDmgType); NOXREF void MakeDamageBloodDecal(int cCount, float flNoise, TraceResult *ptr, Vector &vecDir); void MonsterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { @@ -206,7 +206,7 @@ typedef void (CBaseMonster::*RADIUSDAMAGE_ENTVARS)(entvars_t *, entvars_t *, flo typedef void (CBaseMonster::*RADIUSDAMAGE_VECTOR)(Vector, entvars_t *, entvars_t *, float, int, int); typedef BOOL (CBaseMonster::*FINVIEWCONE_ENTITY)(CBaseEntity *); -typedef BOOL (CBaseMonster::*FINVIEWCONE_VECTOR)(Vector *); +typedef BOOL (CBaseMonster::*FINVIEWCONE_VECTOR)(const Vector *); #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/bmodels.cpp b/regamedll/dlls/bmodels.cpp index d1f11add..428ea165 100644 --- a/regamedll/dlls/bmodels.cpp +++ b/regamedll/dlls/bmodels.cpp @@ -28,333 +28,836 @@ TYPEDESCRIPTION CPendulum::m_SaveData[] = #else -TYPEDESCRIPTION (*CFuncRotating::pm_SaveData)[5]; -TYPEDESCRIPTION (*CPendulum::pm_SaveData)[8]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncRotating, m_SaveData)[5]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CPendulum, m_SaveData)[8]; #endif // HOOK_GAMEDLL -/* <1c36f> ../cstrike/dlls/bmodels.cpp:43 */ -Vector VecBModelOrigin(entvars_t *pevBModel) +// BModelOrigin - calculates origin of a bmodel from absmin/size because all bmodel origins are 0 0 0 + +/* <1c36f> ../cstrike/dlls/bmodels.cpp:43 */ +Vector VecBModelOrigin(entvars_t *pevBModel) { - return pevBModel->absmin + (pevBModel->size * 0.5); + return pevBModel->absmin + (pevBModel->size * 0.5); } -/* <1e384> ../cstrike/dlls/bmodels.cpp:63 */ +/* <1e384> ../cstrike/dlls/bmodels.cpp:63 */ LINK_ENTITY_TO_CLASS(func_wall, CFuncWall); -/* <1d193> ../cstrike/dlls/bmodels.cpp:65 */ -NOBODY void CFuncWall::__MAKE_VHOOK(Spawn)(void) -{ +/* <1d193> ../cstrike/dlls/bmodels.cpp:65 */ +void CFuncWall::__MAKE_VHOOK(Spawn)(void) +{ + pev->angles = g_vecZero; + + // so it doesn't get pushed by anything + pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + + SET_MODEL(ENT(pev), STRING(pev->model)); + + // If it can't move/go away, it's really part of the world + pev->flags |= FL_WORLDBRUSH; } -/* <1d873> ../cstrike/dlls/bmodels.cpp:77 */ -NOBODY void CFuncWall::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// Use(CFuncWall *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 77 +/* <1d873> ../cstrike/dlls/bmodels.cpp:77 */ +void CFuncWall::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (ShouldToggle(useType, (int)(pev->frame))) + { + pev->frame = 1.0 - pev->frame; + } } -/* <1e44e> ../cstrike/dlls/bmodels.cpp:96 */ -LINK_ENTITY_TO_CLASS(func_wall_toggle, CFuncWallToggle); - -/* <1e28f> ../cstrike/dlls/bmodels.cpp:98 */ -NOBODY void CFuncWallToggle::__MAKE_VHOOK(Spawn)(void) -{ -// Spawn(CFuncWall *const this); // 100 -// TurnOff(CFuncWallToggle *const this); // 102 +/* <1e44e> ../cstrike/dlls/bmodels.cpp:96 */ +LINK_ENTITY_TO_CLASS(func_wall_toggle, CFuncWallToggle); + +/* <1e28f> ../cstrike/dlls/bmodels.cpp:98 */ +void CFuncWallToggle::__MAKE_VHOOK(Spawn)(void) +{ + CFuncWall::Spawn(); + + if (pev->spawnflags & SF_WALL_START_OFF) + { + TurnOff(); + } } -/* <1e518> ../cstrike/dlls/bmodels.cpp:106 */ -NOBODY void CFuncWallToggle::TurnOff(void) -{ +/* <1e518> ../cstrike/dlls/bmodels.cpp:106 */ +void CFuncWallToggle::TurnOff(void) +{ + pev->solid = SOLID_NOT; + pev->effects |= EF_NODRAW; + UTIL_SetOrigin(pev, pev->origin); } -/* <1e53a> ../cstrike/dlls/bmodels.cpp:114 */ -NOBODY void CFuncWallToggle::TurnOn(void) -{ +/* <1e53a> ../cstrike/dlls/bmodels.cpp:114 */ +void CFuncWallToggle::TurnOn(void) +{ + pev->solid = SOLID_BSP; + pev->effects &= ~EF_NODRAW; + UTIL_SetOrigin(pev, pev->origin); } -/* <1e55c> ../cstrike/dlls/bmodels.cpp:122 */ -NOBODY BOOL CFuncWallToggle::IsOn(void) -{ +/* <1e55c> ../cstrike/dlls/bmodels.cpp:122 */ +BOOL CFuncWallToggle::IsOn(void) +{ + if (pev->solid == SOLID_NOT) + { + return FALSE; + } + + return TRUE; } -/* <1e101> ../cstrike/dlls/bmodels.cpp:130 */ -NOBODY void CFuncWallToggle::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// { -// int status; // 132 -// IsOn(CFuncWallToggle *const this); // 132 -// TurnOff(CFuncWallToggle *const this); // 137 -// TurnOn(CFuncWallToggle *const this); // 139 -// } +/* <1e101> ../cstrike/dlls/bmodels.cpp:130 */ +void CFuncWallToggle::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + int status = IsOn(); + + if (ShouldToggle(useType, status)) + { + if (status) + TurnOff(); + else + TurnOn(); + } } -/* <1e57d> ../cstrike/dlls/bmodels.cpp:155 */ +/* <1e57d> ../cstrike/dlls/bmodels.cpp:155 */ LINK_ENTITY_TO_CLASS(func_conveyor, CFuncConveyor); -/* <1e1c3> ../cstrike/dlls/bmodels.cpp:156 */ -NOBODY void CFuncConveyor::__MAKE_VHOOK(Spawn)(void) -{ -// Spawn(CFuncWall *const this); // 159 -// UpdateSpeed(CFuncConveyor *const this, -// float speed); // 174 +/* <1e1c3> ../cstrike/dlls/bmodels.cpp:156 */ +void CFuncConveyor::__MAKE_VHOOK(Spawn)(void) +{ + SetMovedir(pev); + CFuncWall::Spawn(); + + if (!(pev->spawnflags & SF_CONVEYOR_VISUAL)) + { + pev->flags |= FL_CONVEYOR; + } + + // HACKHACK - This is to allow for some special effects + if (pev->spawnflags & SF_CONVEYOR_NOTSOLID) + { + // Don't want the engine thinking we've got special contents on this brush + pev->solid = SOLID_NOT; + pev->skin = 0; + } + + if (pev->speed == 0) + pev->speed = 100; + + UpdateSpeed(pev->speed); } -/* <1e647> ../cstrike/dlls/bmodels.cpp:179 */ -NOBODY void CFuncConveyor::UpdateSpeed(float speed) -{ -// { -// int speedCode; // 182 -// fabs(double __x); // 182 -// } +// HACKHACK -- This is ugly, but encode the speed in the rendercolor to avoid adding more data to the network stream + +/* <1e647> ../cstrike/dlls/bmodels.cpp:179 */ +void CFuncConveyor::UpdateSpeed(float speed) +{ + // Encode it as an integer with 4 fractional bits + int speedCode = (int)(fabs((float_precision)speed) * 16.0); + + if (speed < 0) + pev->rendercolor.x = 1; + else + pev->rendercolor.x = 0; + + pev->rendercolor.y = (speedCode >> 8); + pev->rendercolor.z = (speedCode & 0xFF); } -/* <1e021> ../cstrike/dlls/bmodels.cpp:194 */ -NOBODY void CFuncConveyor::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// UpdateSpeed(CFuncConveyor *const this, -// float speed); // 197 +/* <1e021> ../cstrike/dlls/bmodels.cpp:194 */ +void CFuncConveyor::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + pev->speed = -pev->speed; + UpdateSpeed(pev->speed); } -/* <1e695> ../cstrike/dlls/bmodels.cpp:217 */ -LINK_ENTITY_TO_CLASS(func_illusionary, CFuncIllusionary); +/* <1e695> ../cstrike/dlls/bmodels.cpp:217 */ +LINK_ENTITY_TO_CLASS(func_illusionary, CFuncIllusionary); -/* <1ddc9> ../cstrike/dlls/bmodels.cpp:219 */ -NOBODY void CFuncIllusionary::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 221 -// KeyValue(CFuncIllusionary *const this, -// KeyValueData *pkvd); // 219 +/* <1ddc9> ../cstrike/dlls/bmodels.cpp:219 */ +void CFuncIllusionary::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + //skin is used for content type + if (FStrEq(pkvd->szKeyName, "skin")) + { + pev->skin = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseToggle::KeyValue(pkvd); } -/* <1d1db> ../cstrike/dlls/bmodels.cpp:230 */ -NOBODY void CFuncIllusionary::__MAKE_VHOOK(Spawn)(void) -{ +/* <1d1db> ../cstrike/dlls/bmodels.cpp:230 */ +void CFuncIllusionary::__MAKE_VHOOK(Spawn)(void) +{ + pev->angles = g_vecZero; + pev->movetype = MOVETYPE_NONE; + + // always solid_not + pev->solid = SOLID_NOT; + + SET_MODEL(ENT(pev), STRING(pev->model)); + + // I'd rather eat the network bandwidth of this than figure out how to save/restore + // these entities after they have been moved to the client, or respawn them ala Quake + // Perhaps we can do this in deathmatch only. + // MAKE_STATIC(ENT(pev)); } -/* <1e75f> ../cstrike/dlls/bmodels.cpp:262 */ -LINK_ENTITY_TO_CLASS(func_monsterclip, CFuncMonsterClip); +/* <1e75f> ../cstrike/dlls/bmodels.cpp:262 */ +LINK_ENTITY_TO_CLASS(func_monsterclip, CFuncMonsterClip); -/* <1e24f> ../cstrike/dlls/bmodels.cpp:264 */ -NOBODY void CFuncMonsterClip::__MAKE_VHOOK(Spawn)(void) -{ -// Spawn(CFuncWall *const this); // 266 +/* <1e24f> ../cstrike/dlls/bmodels.cpp:264 */ +void CFuncMonsterClip::__MAKE_VHOOK(Spawn)(void) +{ + CFuncWall::Spawn(); + + if (CVAR_GET_FLOAT("showtriggers") == 0) + { + pev->effects = EF_NODRAW; + } + + pev->flags |= FL_MONSTERCLIP; } -/* <1e82c> ../cstrike/dlls/bmodels.cpp:313 */ -LINK_ENTITY_TO_CLASS(func_rotating, CFuncRotating); +/* <1e82c> ../cstrike/dlls/bmodels.cpp:313 */ +LINK_ENTITY_TO_CLASS(func_rotating, CFuncRotating); -/* <1d826> ../cstrike/dlls/bmodels.cpp:310 */ -IMPLEMENT_SAVERESTORE(CFuncRotating, CBaseEntity); +/* <1d826> ../cstrike/dlls/bmodels.cpp:310 */ +IMPLEMENT_SAVERESTORE(CFuncRotating, CBaseEntity); -/* <1dc21> ../cstrike/dlls/bmodels.cpp:315 */ -NOBODY void CFuncRotating::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 317 -// FStrEq(const char *sz1, -// const char *sz2); // 322 -// FStrEq(const char *sz1, -// const char *sz2); // 332 -// FStrEq(const char *sz1, -// const char *sz2); // 339 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 345 -// { -// Vector tmp; // 334 -// operator!=(const Vector *const this, -// const Vector &v); // 336 -// } -// atoi(const char *__nptr); // 341 -// atof(const char *__nptr); // 324 -// atof(const char *__nptr); // 319 +/* <1dc21> ../cstrike/dlls/bmodels.cpp:315 */ +void CFuncRotating::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "fanfriction")) + { + m_flFanFriction = Q_atof(pkvd->szValue) / 100; + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "Volume")) + { + m_flVolume = Q_atof(pkvd->szValue) / 10.0; + + if (m_flVolume > 1.0) + m_flVolume = 1.0; + + if (m_flVolume < 0.0) + m_flVolume = 0.0; + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "spawnorigin")) + { + Vector tmp; + UTIL_StringToVector((float *)tmp, pkvd->szValue); + + if (tmp != g_vecZero) + { + pev->origin = tmp; + } + } + else if (FStrEq(pkvd->szKeyName, "sounds")) + { + m_sounds = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } -/* <1d5c4> ../cstrike/dlls/bmodels.cpp:362 */ -NOBODY void CFuncRotating::__MAKE_VHOOK(Spawn)(void) -{ -// operator*(const Vector ::Spawn(// float fl); // 404 +// QUAKED func_rotating (0 .5 .8) ? START_ON REVERSE X_AXIS Y_AXIS +// You need to have an origin brush as part of this entity. The +// center of that brush will be +// the point around which it is rotated. It will rotate around the Z +// axis by default. You can +// check either the X_AXIS or Y_AXIS box to change that. + +// "speed" determines how fast it moves; default value is 100. +// "dmg" damage to inflict when blocked (2 default) + +// REVERSE will cause the it to rotate in the opposite direction. + +/* <1d5c4> ../cstrike/dlls/bmodels.cpp:362 */ +void CFuncRotating::__MAKE_VHOOK(Spawn)(void) +{ + // set final pitch. Must not be PITCH_NORM, since we + // plan on pitch shifting later. + m_pitch = PITCH_NORM - 1; + + // maintain compatibility with previous maps + if (m_flVolume == 0.0) + m_flVolume = 1.0; + + // if the designer didn't set a sound attenuation, default to one. + m_flAttenuation = ATTN_NORM; + + if (pev->spawnflags & SF_BRUSH_ROTATE_SMALLRADIUS) + { + m_flAttenuation = ATTN_IDLE; + } + else if (pev->spawnflags & SF_BRUSH_ROTATE_MEDIUMRADIUS) + { + m_flAttenuation = ATTN_STATIC; + } + else if (pev->spawnflags & SF_BRUSH_ROTATE_LARGERADIUS) + { + m_flAttenuation = ATTN_NORM; + } + + // prevent divide by zero if level designer forgets friction! + if (m_flFanFriction == 0) + { + m_flFanFriction = 1; + } + + if (pev->spawnflags & SF_BRUSH_ROTATE_Z_AXIS) + { + pev->movedir = Vector(0, 0, 1); + } + else if (pev->spawnflags & SF_BRUSH_ROTATE_X_AXIS) + { + pev->movedir = Vector(1, 0, 0); + } + else + { + // y-axis + pev->movedir = Vector(0, 1, 0); + } + + // check for reverse rotation + if (pev->spawnflags & SF_BRUSH_ROTATE_BACKWARDS) + { + pev->movedir = pev->movedir * -1; + } + + // some rotating objects like fake volumetric lights will not be solid. + if (pev->spawnflags & SF_ROTATING_NOT_SOLID) + { + pev->solid = SOLID_NOT; + pev->skin = CONTENTS_EMPTY; + pev->movetype = MOVETYPE_PUSH; + } + else + { + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + } + + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + SetUse(&CFuncRotating::RotatingUse); + + // did level designer forget to assign speed? + if (pev->speed <= 0) + { + pev->speed = 0; + } + + // Removed this per level designers request. -- JAY + // if (pev->dmg == 0) + // pev->dmg = 2; + + // instant-use brush? + if (pev->spawnflags & SF_BRUSH_ROTATE_INSTANT) + { + SetThink(&CFuncRotating::SUB_CallUseToggle); + + // leave a magic delay for client to start up + pev->nextthink = pev->ltime + 1.5; + } + + // can this brush inflict pain? + if (pev->spawnflags & SF_BRUSH_HURT) + { + SetTouch(&CFuncRotating::HurtTouch); + } + + Precache(); } -/* <1d28a> ../cstrike/dlls/bmodels.cpp:447 */ -NOBODY void CFuncRotating::__MAKE_VHOOK(Precache)(void) -{ -// { -// char *szSoundFile; // 449 -// operator!=(const Vector *const this, -// const Vector &v); // 502 -// } +/* <1d28a> ../cstrike/dlls/bmodels.cpp:447 */ +void CFuncRotating::__MAKE_VHOOK(Precache)(void) +{ + char *szSoundFile = (char *)STRING(pev->message); + + // set up fan sounds + if (!FStringNull(pev->message) && Q_strlen(szSoundFile) > 0) + { + // if a path is set for a wave, use it + PRECACHE_SOUND(szSoundFile); + pev->noiseRunning = ALLOC_STRING(szSoundFile); + } + else + { + // otherwise use preset sound + switch (m_sounds) + { + case 1: + PRECACHE_SOUND("fans/fan1.wav"); + pev->noiseRunning = ALLOC_STRING("fans/fan1.wav"); + break; + case 2: + PRECACHE_SOUND("fans/fan2.wav"); + pev->noiseRunning = ALLOC_STRING("fans/fan2.wav"); + break; + case 3: + PRECACHE_SOUND("fans/fan3.wav"); + pev->noiseRunning = ALLOC_STRING("fans/fan3.wav"); + break; + case 4: + PRECACHE_SOUND("fans/fan4.wav"); + pev->noiseRunning = ALLOC_STRING("fans/fan4.wav"); + break; + case 5: + PRECACHE_SOUND("fans/fan5.wav"); + pev->noiseRunning = ALLOC_STRING("fans/fan5.wav"); + break; + + case 0: + default: + if (!FStringNull(pev->message) && Q_strlen(szSoundFile) > 0) + { + PRECACHE_SOUND(szSoundFile); + pev->noiseRunning = ALLOC_STRING(szSoundFile); + break; + } + else + { + pev->noiseRunning = ALLOC_STRING("common/null.wav"); + break; + } + } + } + + if (pev->avelocity != g_vecZero) + { + // if fan was spinning, and we went through transition or save/restore, + // make sure we restart the sound. 1.5 sec delay is magic number. KDB + SetThink(&CFuncRotating::SpinUp); + pev->nextthink = pev->ltime + 1.5; + } } -/* <1dea4> ../cstrike/dlls/bmodels.cpp:517 */ -NOBODY void CFuncRotating::HurtTouch(CBaseEntity *pOther) -{ -// { -// entvars_t *pevOther; // 519 -// Length(const Vector *const this); // 526 -// VecBModelOrigin(entvars_t *pevBModel); // 530 -// operator-(const Vector *const this, -// const Vector &v); // 530 -// Normalize(const Vector *const this); // 530 -// operator*(const Vector *const this, -// float fl); // 530 -// } +// Touch - will hurt others based on how fast the brush is spinning + +/* <1dea4> ../cstrike/dlls/bmodels.cpp:517 */ +void CFuncRotating::HurtTouch(CBaseEntity *pOther) +{ + entvars_t *pevOther = pOther->pev; + + // we can't hurt this thing, so we're not concerned with it + if (pevOther->takedamage == DAMAGE_NO) + { + return; + } + + // calculate damage based on rotation speed + pev->dmg = pev->avelocity.Length() / 10; + pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); + pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev)).Normalize() * pev->dmg; } -/* <1e8f9> ../cstrike/dlls/bmodels.cpp:540 */ -NOBODY void CFuncRotating::RampPitchVol(int fUp) -{ -// { -// Vector vecAVel; // 543 -// vec_t vecCur; // 544 -// vec_t vecFinal; // 545 -// float fpct; // 546 -// float fvol; // 547 -// float fpitch; // 548 -// int pitch; // 549 -// Vector(Vector *const this, -// const Vector &v); // 543 -// } +// RampPitchVol - ramp pitch and volume up to final values, based on difference +// between how fast we're going vs how fast we plan to go + +/* <1e8f9> ../cstrike/dlls/bmodels.cpp:540 */ +void CFuncRotating::RampPitchVol(int fUp) +{ + Vector vecAVel = pev->avelocity; + float_precision vecCur; + float_precision vecFinal; + float_precision fpct; + float fvol; + float fpitch; + int pitch; + + // get current angular velocity + vecCur = abs((int)(vecAVel.x != 0 ? vecAVel.x : (vecAVel.y != 0 ? vecAVel.y : vecAVel.z))); + + // get target angular velocity + vecFinal = (pev->movedir.x != 0 ? pev->movedir.x : (pev->movedir.y != 0 ? pev->movedir.y : pev->movedir.z)); + vecFinal *= pev->speed; + vecFinal = abs((int)vecFinal); + + // calc volume and pitch as % of final vol and pitch + fpct = vecCur / vecFinal; + + //if (fUp) + //{ + // // spinup volume ramps up from 50% max vol + // fvol = m_flVolume * (0.5 + fpct/2.0); + //} + //else + { + // slowdown volume ramps down to 0 + fvol = m_flVolume * fpct; + } + + fpitch = FANPITCHMIN + (FANPITCHMAX - FANPITCHMIN) * fpct; + + pitch = (int)fpitch; + if (pitch == PITCH_NORM) + { + pitch = PITCH_NORM - 1; + } + + // change the fan's vol and pitch + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), fvol, m_flAttenuation, (SND_CHANGE_PITCH | SND_CHANGE_VOL), pitch); } -/* <1ea74> ../cstrike/dlls/bmodels.cpp:585 */ -NOBODY void CFuncRotating::SpinUp(void) -{ -// { -// Vector vecAVel; // 587 -// operator*(const Vector *const this, -// float fl); // 590 -// operator+(const Vector *const this, -// const Vector &v); // 590 -// Rotate(CFuncRotating *const this); // 604 -// } -} +// SpinUp - accelerates a non-moving func_rotating up to it's speed -/* <1e9c3> ../cstrike/dlls/bmodels.cpp:615 */ -NOBODY void CFuncRotating::SpinDown(void) -{ -// { -// Vector vecAVel; // 617 -// vec_t vecdir; // 618 -// operator*(const Vector *const this, -// float fl); // 622 -// operator-(const Vector *const this, -// const Vector &v); // 622 -// Rotate(CFuncRotating *const this); // 645 -// } -} - -/* <1d304> ../cstrike/dlls/bmodels.cpp:653 */ -NOBODY void CFuncRotating::Rotate(void) -{ +/* <1ea74> ../cstrike/dlls/bmodels.cpp:585 */ +void CFuncRotating::SpinUp(void) +{ + //rotational velocity + Vector vecAVel; + + pev->nextthink = pev->ltime + 0.1; + pev->avelocity = pev->avelocity + (pev->movedir * (pev->speed * m_flFanFriction)); + + // cache entity's rotational velocity + vecAVel = pev->avelocity; + + // if we've met or exceeded target speed, set target speed and stop thinking + if (abs((int)vecAVel.x) >= abs((int)(pev->movedir.x * pev->speed)) + && abs((int)vecAVel.y) >= abs((int)(pev->movedir.y * pev->speed)) + && abs((int)vecAVel.z) >= abs((int)(pev->movedir.z * pev->speed))) + { + // set speed in case we overshot + pev->avelocity = pev->movedir * pev->speed; + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), m_flVolume, m_flAttenuation, (SND_CHANGE_PITCH | SND_CHANGE_VOL), FANPITCHMAX); + + SetThink(&CFuncRotating::Rotate); + Rotate(); + } + else + { + RampPitchVol(TRUE); + } } -/* <1d60e> ../cstrike/dlls/bmodels.cpp:661 */ -NOBODY void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// operator!=(const Vector *const this, -// const Vector &v); // 667 -// operator!=(const Vector *const this, -// const Vector &v); // 683 -// operator*(const Vector *const this, -// float fl); // 694 -// Rotate(CFuncRotating *const this); // 697 +/* <1e9c3> ../cstrike/dlls/bmodels.cpp:615 */ +void CFuncRotating::SpinDown(void) +{ + //rotational velocity + Vector vecAVel; + vec_t vecdir; + + pev->nextthink = pev->ltime + 0.1; + + //spin down slower than spinup + pev->avelocity = pev->avelocity - (pev->movedir * (pev->speed * m_flFanFriction)); + + // cache entity's rotational velocity + vecAVel = pev->avelocity; + + if (pev->movedir.x != 0) + vecdir = pev->movedir.x; + else if (pev->movedir.y != 0) + vecdir = pev->movedir.y; + else + vecdir = pev->movedir.z; + + // if we've met or exceeded target speed, set target speed and stop thinking + // (note: must check for movedir > 0 or < 0) + if (((vecdir > 0) && (vecAVel.x <= 0 && vecAVel.y <= 0 && vecAVel.z <= 0)) + || ((vecdir < 0) && (vecAVel.x >= 0 && vecAVel.y >= 0 && vecAVel.z >= 0))) + { + // set speed in case we overshot + pev->avelocity = g_vecZero; + + // stop sound, we're done + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 0, ATTN_NONE, SND_STOP, m_pitch); + + SetThink(&CFuncRotating::Rotate); + Rotate(); + } + else + { + RampPitchVol(FALSE); + } } -/* <1d325> ../cstrike/dlls/bmodels.cpp:706 */ -NOBODY void CFuncRotating::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) -{ +/* <1d304> ../cstrike/dlls/bmodels.cpp:653 */ +void CFuncRotating::Rotate(void) +{ + pev->nextthink = pev->ltime + 10; } -/* <1eb14> ../cstrike/dlls/bmodels.cpp:747 */ -LINK_ENTITY_TO_CLASS(func_pendulum, CPendulum); - -/* <1d7d9> ../cstrike/dlls/bmodels.cpp:761 */ -IMPLEMENT_SAVERESTORE(CPendulum, CBaseEntity); +// Rotating Use - when a rotating brush is triggered -/* <1db2a> ../cstrike/dlls/bmodels.cpp:765 */ -NOBODY void CPendulum::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 767 -// FStrEq(const char *sz1, -// const char *sz2); // 772 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 778 -// atof(const char *__nptr); // 769 -// KeyValue(CPendulum *const this, -// KeyValueData *pkvd); // 765 +/* <1d60e> ../cstrike/dlls/bmodels.cpp:661 */ +void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + // is this a brush that should accelerate and decelerate when turned on/off (fan)? + if (pev->spawnflags & SF_BRUSH_ACCDCC) + { + // fan is spinning, so stop it. + if (pev->avelocity != g_vecZero) + { + SetThink(&CFuncRotating::SpinDown); + + //EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), m_flVolume, m_flAttenuation, 0, m_pitch); + pev->nextthink = pev->ltime + 0.1; + } + else // fan is not moving, so start it + { + SetThink(&CFuncRotating::SpinUp); + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 0.01, m_flAttenuation, 0, FANPITCHMIN); + + pev->nextthink = pev->ltime + 0.1; + } + } + else if (!(pev->spawnflags & SF_BRUSH_ACCDCC)) // this is a normal start/stop brush. + { + if (pev->avelocity != g_vecZero) + { + // play stopping sound here + SetThink(&CFuncRotating::SpinDown); + + // EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), m_flVolume, m_flAttenuation, 0, m_pitch); + + pev->nextthink = pev->ltime + 0.1; + // pev->avelocity = g_vecZero; + } + else + { + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), m_flVolume, m_flAttenuation, 0, FANPITCHMAX); + pev->avelocity = pev->movedir * pev->speed; + + SetThink(&CFuncRotating::Rotate); + Rotate(); + } + } } -/* <1d9c7> ../cstrike/dlls/bmodels.cpp:782 */ -NOBODY void CPendulum::__MAKE_VHOOK(Spawn)(void) -{ -// Spawn(CPendulum *const this); // 782 +// RotatingBlocked - An entity has blocked the brush + +/* <1d325> ../cstrike/dlls/bmodels.cpp:706 */ +void CFuncRotating::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) +{ + pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); } -/* <1d8ec> ../cstrike/dlls/bmodels.cpp:821 */ -NOBODY void CPendulum::PendulumUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// { -// float delta; // 827 -// } -// PendulumUse(CPendulum *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 821 +/* <1eb14> ../cstrike/dlls/bmodels.cpp:747 */ +LINK_ENTITY_TO_CLASS(func_pendulum, CPendulum); + +/* <1d7d9> ../cstrike/dlls/bmodels.cpp:761 */ +IMPLEMENT_SAVERESTORE(CPendulum, CBaseEntity); + +/* <1db2a> ../cstrike/dlls/bmodels.cpp:765 */ +void CPendulum::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "distance")) + { + m_distance = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "damp")) + { + m_damp = Q_atof(pkvd->szValue) * 0.001; + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } -/* <1d381> ../cstrike/dlls/bmodels.cpp:852 */ -NOBODY void CPendulum::Stop(void) -{ +/* <1d9c7> ../cstrike/dlls/bmodels.cpp:782 */ +void CPendulum::__MAKE_VHOOK(Spawn)(void) +{ + // set the axis of rotation + CBaseToggle::AxisDir(pev); + + if (pev->spawnflags & SF_DOOR_PASSABLE) + pev->solid = SOLID_NOT; + else + pev->solid = SOLID_BSP; + + pev->movetype = MOVETYPE_PUSH; + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (m_distance == 0) + return; + + if (pev->speed == 0) + pev->speed = 100; + + // Calculate constant acceleration from speed and distance + m_accel = (pev->speed * pev->speed) / (2 * fabs((float_precision)m_distance)); + m_maxSpeed = pev->speed; + m_start = pev->angles; + m_center = pev->angles + (m_distance * 0.5) * pev->movedir; + + if (pev->spawnflags & SF_BRUSH_ROTATE_INSTANT) + { + SetThink(&CPendulum::SUB_CallUseToggle); + pev->nextthink = gpGlobals->time + 0.1f; + } + + pev->speed = 0; + SetUse(&CPendulum::PendulumUse); + + if (pev->spawnflags & SF_PENDULUM_SWING) + { + SetTouch (&CPendulum::RopeTouch); + } } -/* <1d3a7> ../cstrike/dlls/bmodels.cpp:861 */ -NOBODY void CPendulum::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) -{ +/* <1d8ec> ../cstrike/dlls/bmodels.cpp:821 */ +void CPendulum::PendulumUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + // Pendulum is moving, stop it and auto-return if necessary + if (pev->speed) + { + if (pev->spawnflags & SF_PENDULUM_AUTO_RETURN) + { + float_precision delta; + + delta = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_start); + + pev->avelocity = m_maxSpeed * pev->movedir; + pev->nextthink = pev->ltime + (delta / m_maxSpeed); + SetThink(&CPendulum::Stop); + } + else + { + // Dead stop + pev->speed = 0; + SetThink(NULL); + pev->avelocity = g_vecZero; + } + } + else + { + // Start the pendulum moving + pev->nextthink = pev->ltime + 0.1f; + + // Save time to calculate dt + m_time = gpGlobals->time; + SetThink(&CPendulum::Swing); + m_dampSpeed = m_maxSpeed; + } } -/* <1d533> ../cstrike/dlls/bmodels.cpp:867 */ -NOBODY void CPendulum::Swing(void) -{ -// { -// float delta; // 869 -// float dt; // 869 -// operator*(float fl, -// const Vector &v); // 885 -// } +/* <1d381> ../cstrike/dlls/bmodels.cpp:852 */ +void CPendulum::Stop(void) +{ + pev->angles = m_start; + pev->speed = 0; + SetThink(NULL); + pev->avelocity = g_vecZero; } -/* <1d3f5> ../cstrike/dlls/bmodels.cpp:909 */ -NOBODY void CPendulum::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) -{ -// { -// entvars_t *pevOther; // 911 -// float damage; // 921 -// VecBModelOrigin(entvars_t *pevBModel); // 928 -// operator-(const Vector *const this, -// const Vector &v); // 928 -// Normalize(const Vector *const this); // 928 -// operator*(const Vector *const this, -// float fl); // 928 -// } +/* <1d3a7> ../cstrike/dlls/bmodels.cpp:861 */ +void CPendulum::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) +{ + m_time = gpGlobals->time; } -/* <1da85> ../cstrike/dlls/bmodels.cpp:931 */ -NOBODY void CPendulum::RopeTouch(CBaseEntity *pOther) -{ -// { -// entvars_t *pevOther; // 933 -// edict(CBaseEntity *const this); // 946 -// } -// RopeTouch(CPendulum *const this, -// class CBaseEntity *pOther); // 931 +/* <1d533> ../cstrike/dlls/bmodels.cpp:867 */ +void CPendulum::Swing(void) +{ + float delta, dt; + + delta = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_center); + + // How much time has passed? + dt = gpGlobals->time - m_time; + + // Remember the last time called + m_time = gpGlobals->time; + + if (delta > 0 && m_accel > 0) + { + // Integrate velocity + pev->speed -= m_accel * dt; + } + else + pev->speed += m_accel * dt; + + if (pev->speed > m_maxSpeed) + pev->speed = m_maxSpeed; + + else if (pev->speed < -m_maxSpeed) + pev->speed = -m_maxSpeed; + + // scale the destdelta vector by the time spent traveling to get velocity + pev->avelocity = pev->speed * pev->movedir; + + // Call this again + pev->nextthink = pev->ltime + 0.1; + + if (m_damp) + { + m_dampSpeed -= m_damp * m_dampSpeed * dt; + + if (m_dampSpeed < 30.0) + { + pev->angles = m_center; + pev->speed = 0; + SetThink(NULL); + pev->avelocity = g_vecZero; + } + else if (pev->speed > m_dampSpeed) + pev->speed = m_dampSpeed; + + else if (pev->speed < -m_dampSpeed) + pev->speed = -m_dampSpeed; + } +} + +/* <1d3f5> ../cstrike/dlls/bmodels.cpp:909 */ +void CPendulum::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +{ + entvars_t *pevOther = pOther->pev; + + if (pev->dmg <= 0) + return; + + // we can't hurt this thing, so we're not concerned with it + if (pevOther->takedamage == DAMAGE_NO) + return; + + // calculate damage based on rotation speed + float damage = pev->dmg * pev->speed * 0.01; + + if (damage < 0) + { + damage = -damage; + } + + pOther->TakeDamage(pev, pev, damage, DMG_CRUSH); + pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev)).Normalize() * damage; +} + +/* <1da85> ../cstrike/dlls/bmodels.cpp:931 */ +void CPendulum::RopeTouch(CBaseEntity *pOther) +{ + entvars_t *pevOther = pOther->pev; + + // not a player! + if (!pOther->IsPlayer()) + { + ALERT(at_console, "Not a client\n"); + return; + } + + // this player already on the rope. + if (ENT(pevOther) == pev->enemy) + { + return; + } + + pev->enemy = pOther->edict(); + pevOther->velocity = g_vecZero; + pevOther->movetype = MOVETYPE_NONE; } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/bmodels.h b/regamedll/dlls/bmodels.h index 1e73f212..7b88099e 100644 --- a/regamedll/dlls/bmodels.h +++ b/regamedll/dlls/bmodels.h @@ -32,10 +32,11 @@ #pragma once #endif -#define SF_PENDULUM_SWING 2 -#define SF_BRUSH_ACCDCC 16 -#define SF_BRUSH_HURT 32 -#define SF_ROTATING_NOT_SOLID 64 +#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. + +#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled +#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed +#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. #define SF_WALL_START_OFF 0x0001 @@ -45,20 +46,25 @@ #define FANPITCHMIN 30 #define FANPITCHMAX 100 +// covering cheesy noise1, noise2, & noise3 fields so they make more sense (for rotating fans) #define noiseStart noise1 #define noiseStop noise2 #define noiseRunning noise3 +// This is just a solid wall if not inhibited + /* <1c494> ../cstrike/dlls/bmodels.cpp:53 */ class CFuncWall: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + + // Bmodels don't go across transitions + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -77,8 +83,8 @@ public: class CFuncWallToggle: public CFuncWall { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -88,9 +94,9 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void TurnOff(void); - NOBODY void TurnOn(void); - NOBODY BOOL IsOn(void); + void TurnOff(void); + void TurnOn(void); + BOOL IsOn(void); };/* size: 152, cachelines: 3, members: 1 */ @@ -98,8 +104,8 @@ public: class CFuncConveyor: public CFuncWall { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -109,17 +115,19 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void UpdateSpeed(float speed); + void UpdateSpeed(float speed); };/* size: 152, cachelines: 3, members: 1 */ +// A simple entity that looks solid but lets you walk through it. + /* <1c65b> ../cstrike/dlls/bmodels.cpp:208 */ class CFuncIllusionary: public CBaseToggle { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int ObjectCaps(void) { return ObjectCaps_(); } @@ -136,15 +144,25 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT SloshTouch(CBaseEntity *pOther); + void EXPORT SloshTouch(CBaseEntity *pOther); };/* size: 312, cachelines: 5, members: 1 */ +// Monster only clip brush +// +// This brush will be solid for any entity who has the FL_MONSTERCLIP flag set +// in pev->flags +// +// otherwise it will be invisible and not solid. This can be used to keep +// specific monsters out of certain areas + /* <1c6a8> ../cstrike/dlls/bmodels.cpp:255 */ class CFuncMonsterClip: public CFuncWall { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); + + // Clear out func_wall's use function virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { ; @@ -163,16 +181,17 @@ public: class CFuncRotating: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + // basic functions + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Blocked(CBaseEntity *pOther); + virtual void Blocked(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -190,12 +209,12 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT SpinUp(void); - NOBODY void EXPORT SpinDown(void); - NOBODY void EXPORT HurtTouch(CBaseEntity *pOther); - NOBODY void EXPORT RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void EXPORT Rotate(void); - NOBODY void RampPitchVol(int fUp); + void EXPORT SpinUp(void); + void EXPORT SpinDown(void); + void EXPORT HurtTouch(CBaseEntity *pOther); + void EXPORT RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT Rotate(void); + void RampPitchVol(int fUp); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[5]; @@ -213,16 +232,16 @@ public: class CPendulum: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Touch(CBaseEntity *pOther); - NOBODY virtual void Blocked(CBaseEntity *pOther); + virtual void Touch(CBaseEntity *pOther); + virtual void Blocked(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -240,20 +259,23 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT Swing(void); - NOBODY void EXPORT PendulumUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void EXPORT Stop(void); - NOBODY void EXPORT RopeTouch(CBaseEntity *pOther); + void EXPORT Swing(void); + void EXPORT PendulumUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT Stop(void); + + // this touch func makes the pendulum a rope + void EXPORT RopeTouch(CBaseEntity *pOther); static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[8]; public: - float m_accel; + float m_accel; // Acceleration float m_distance; float m_time; float m_damp; float m_maxSpeed; float m_dampSpeed; + Vector m_center; Vector m_start; @@ -261,4 +283,13 @@ public: Vector VecBModelOrigin(entvars_t *pevBModel); +// linked objects +C_DLLEXPORT void func_wall(entvars_t *pev); +C_DLLEXPORT void func_wall_toggle(entvars_t *pev); +C_DLLEXPORT void func_conveyor(entvars_t *pev); +C_DLLEXPORT void func_illusionary(entvars_t *pev); +C_DLLEXPORT void func_monsterclip(entvars_t *pev); +C_DLLEXPORT void func_rotating(entvars_t *pev); +C_DLLEXPORT void func_pendulum(entvars_t *pev); + #endif // BMODELS_H diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp index b7bd3397..30e8c4de 100644 --- a/regamedll/dlls/bot/cs_bot.cpp +++ b/regamedll/dlls/bot/cs_bot.cpp @@ -1,482 +1,482 @@ #include "precompiled.h" -/* <2e85c8> ../cstrike/dlls/bot/cs_bot.cpp:24 */ -NOBODY int GetBotFollowCount(CBasePlayer *leader) -{ -// { -// int count; // 26 -// { -// int i; // 28 -// { -// class CBaseEntity *entity; // 30 -// class CBasePlayer *player; // 41 -// class CCSBot *bot; // 49 -// FNullEnt(entvars_t *pev); // 35 -// GetFollowLeader(CCSBot *const this); // 50 -// } -// } -// } +/* <2e85c8> ../cstrike/dlls/bot/cs_bot.cpp:24 */ +NOBODY int GetBotFollowCount(CBasePlayer *leader) +{ +// { +// int count; // 26 +// { +// int i; // 28 +// { +// class CBaseEntity *entity; // 30 +// class CBasePlayer *player; // 41 +// class CCSBot *bot; // 49 +// FNullEnt(entvars_t *pev); // 35 +// GetFollowLeader(CCSBot *const this); // 50 +// } +// } +// } } -/* <2e86df> ../cstrike/dlls/bot/cs_bot.cpp:62 */ -NOBODY void CCSBot::__MAKE_VHOOK(Walk)(void) -{ -// IsElapsed(const class CountdownTimer *const this); // 64 -// Walk(CBot *const this); // 66 -} - -/* <2e8732> ../cstrike/dlls/bot/cs_bot.cpp:80 */ -NOBODY bool CCSBot::__MAKE_VHOOK(Jump)(bool mustJump) -{ +/* <2e86df> ../cstrike/dlls/bot/cs_bot.cpp:62 */ +NOBODY void CCSBot::__MAKE_VHOOK(Walk)(void) +{ +// IsElapsed(const class CountdownTimer *const this); // 64 +// Walk(CBot *const this); // 66 } -/* <2e8e39> ../cstrike/dlls/bot/cs_bot.cpp:97 */ -NOBODY int CCSBot::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ -// { -// class CBaseEntity *attacker; // 99 -// GetClassPtr(CBaseEntity *a); // 99 -// { -// class CBasePlayer *player; // 104 -// } -// { -// class CBasePlayer *lastAttacker; // 113 -// float lastAttackedTimestamp; // 114 -// AdjustSafeTime(CCSBot *const this); // 121 -// IsSurprised(const class CCSBot *const this); // 124 -// { -// class CBasePlayer *enemy; // 126 -// bool panic; // 127 -// { -// float invSkill; // 148 -// float panicChance; // 149 -// } -// } -// } -// } +/* <2e8732> ../cstrike/dlls/bot/cs_bot.cpp:80 */ +NOBODY bool CCSBot::__MAKE_VHOOK(Jump)(bool mustJump) +{ } -/* <2e8769> ../cstrike/dlls/bot/cs_bot.cpp:171 */ -NOBODY void CCSBot::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) -{ -// { -// float const deathDanger; // 178 -// float const deathDangerRadius; // 179 -// } +/* <2e8e39> ../cstrike/dlls/bot/cs_bot.cpp:97 */ +NOBODY int CCSBot::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ +// { +// class CBaseEntity *attacker; // 99 +// GetClassPtr(CBaseEntity *a); // 99 +// { +// class CBasePlayer *player; // 104 +// } +// { +// class CBasePlayer *lastAttacker; // 113 +// float lastAttackedTimestamp; // 114 +// AdjustSafeTime(CCSBot *const this); // 121 +// IsSurprised(const class CCSBot *const this); // 124 +// { +// class CBasePlayer *enemy; // 126 +// bool panic; // 127 +// { +// float invSkill; // 148 +// float panicChance; // 149 +// } +// } +// } +// } } -/* <2e7c11> ../cstrike/dlls/bot/cs_bot.cpp:200 */ -NOBODY inline bool IsIntersectingBox(const Vector *start, const Vector *end, const Vector *boxMin, const Vector *boxMax) -{ -// { -// unsigned char startFlags; // 202 -// unsigned char endFlags; // 203 -// } +/* <2e8769> ../cstrike/dlls/bot/cs_bot.cpp:171 */ +NOBODY void CCSBot::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) +{ +// { +// float const deathDanger; // 178 +// float const deathDangerRadius; // 179 +// } } -/* <2e87d9> ../cstrike/dlls/bot/cs_bot.cpp:253 */ -NOBODY void CCSBot::BotTouch(CBaseEntity *other) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 297 -// { -// Vector center; // 299 -// class Extent extent; // 301 -// bool breakIt; // 307 -// operator+(const Vector *const this, -// const Vector &v); // 299 -// { -// Vector goal; // 312 -// Vector(Vector *const this, -// const Vector &v); // 312 -// IsIntersectingBox(const Vector *start, -// const Vector *end, -// const Vector *boxMin, -// const Vector *boxMax); // 314 -// } -// operator/(const Vector *const this, -// float fl); // 299 -// } -// { -// class CBasePlayer *player; // 269 -// unsigned int otherPri; // 272 -// unsigned int myPri; // 275 -// { -// unsigned int avoidPri; // 284 -// } -// } -} - -/* <2e89e3> ../cstrike/dlls/bot/cs_bot.cpp:335 */ -NOBODY bool CCSBot::IsBusy(void) const -{ -} - -/* <2e8a0c> ../cstrike/dlls/bot/cs_bot.cpp:351 */ -NOBODY void CCSBot::BotDeathThink(void) -{ -} - -/* <2e8a34> ../cstrike/dlls/bot/cs_bot.cpp:358 */ -NOBODY CBasePlayer *CCSBot::FindNearbyPlayer(void) -{ -// { -// class CBaseEntity *pEntity; // 360 -// Vector vecSrc; // 361 -// float flRadius; // 362 -// Vector(Vector *const this, -// const Vector &v); // 361 -// } -} - -/* <2e8abd> ../cstrike/dlls/bot/cs_bot.cpp:385 */ -void CCSBot::SetEnemy(CBasePlayer *enemy) -{ - if (m_enemy != enemy) - { - m_enemy = enemy; - m_currentEnemyAcquireTimestamp = gpGlobals->time; - } -} - -/* <2e8af6> ../cstrike/dlls/bot/cs_bot.cpp:400 */ -NOBODY bool CCSBot::StayOnNavMesh(void) -{ -// { -// class CNavArea *goalArea; // 408 -// { -// Vector pos; // 422 -// Vector to; // 426 -// float const stepInDist; // 429 -// operator-(const Vector *const this, -// const Vector &v); // 426 -// NormalizeInPlace(Vector *const this); // 427 -// operator*(float fl, -// const Vector &v); // 430 -// operator+(const Vector *const this, -// const Vector &v); // 430 -// } -// } -} - -/* <2e8c56> ../cstrike/dlls/bot/cs_bot.cpp:450 */ -NOBODY void CCSBot::Panic(CBasePlayer *enemy) -{ -// { -// class Vector2D dir; // 456 -// class Vector2D perp; // 457 -// Vector spot; // 459 -// IsSurprised(const class CCSBot *const this); // 453 -// { -// class Vector2D toEnemy; // 473 -// float along; // 476 -// float c45; // 477 -// float size; // 478 -// float shift; // 479 -// NormalizeInPlace(Vector2D *const this); // 474 -// DotProduct(const class Vector2D &a, -// const class Vector2D &b); // 476 -// { -// float side; // 495 -// DotProduct(const class Vector2D &a, -// const class Vector2D &b); // 495 -// } -// } -// { -// float const offset; // 464 -// float side; // 465 -// } -// } -} - -/* <2e9047> ../cstrike/dlls/bot/cs_bot.cpp:527 */ -NOBODY bool CCSBot::IsDoingScenario(void) -{ -} - -/* <2e9070> ../cstrike/dlls/bot/cs_bot.cpp:544 */ -NOBODY bool CCSBot::NoticeLooseBomb(void) const -{ -// { -// class CCSBotManager *ctrl; // 546 -// class CBaseEntity *bomb; // 551 -// GetLooseBomb(CCSBotManager *const this); // 551 -// } -} - -/* <2e90d4> ../cstrike/dlls/bot/cs_bot.cpp:566 */ -NOBODY bool CCSBot::CanSeeLooseBomb(void) const -{ -// { -// class CCSBotManager *ctrl; // 568 -// class CBaseEntity *bomb; // 573 -// GetLooseBomb(CCSBotManager *const this); // 573 -// } -} - -/* <2e9140> ../cstrike/dlls/bot/cs_bot.cpp:588 */ -NOBODY bool CCSBot::CanSeePlantedBomb(void) const -{ -// { -// class CCSBotManager *ctrl; // 590 -// const Vector *bombPos; // 598 -// } -} - -/* <2e918e> ../cstrike/dlls/bot/cs_bot.cpp:610 */ -NOBODY CBasePlayer *CCSBot::GetAttacker(void) -{ -} - -/* <2e91b7> ../cstrike/dlls/bot/cs_bot.cpp:622 */ -NOBODY void CCSBot::GetOffLadder(void) -{ -// DestroyPath(CCSBot *const this); // 627 -} - -/* <2e91f1> ../cstrike/dlls/bot/cs_bot.cpp:637 */ -NOBODY float CCSBot::GetHidingSpotCheckTimestamp(HidingSpot *spot) -{ -// { -// int i; // 639 -// } -} - -/* <2e9240> ../cstrike/dlls/bot/cs_bot.cpp:651 */ -NOBODY void CCSBot::SetHidingSpotCheckTimestamp(HidingSpot *spot) -{ -// { -// int leastRecent; // 653 -// float leastRecentTime; // 654 -// { -// int i; // 656 -// } -// } -} - -/* <2e92b8> ../cstrike/dlls/bot/cs_bot.cpp:693 */ -NOBODY void CCSBot::UpdateHostageEscortCount(void) -{ -// { -// float const updateInterval; // 695 -// { -// class CHostage *hostage; // 704 -// IsValid(CHostage *const this); // 709 -// IsFollowing(CHostage *const this, -// const class CBaseEntity *entity); // 713 -// edict(CBaseEntity *const this); // 705 -// FNullEnt(const edict_t *pent); // 705 -// } -// } -} - -/* <2e940d> ../cstrike/dlls/bot/cs_bot.cpp:722 */ -NOBODY bool CCSBot::IsOutnumbered(void) -{ -// GetNearbyFriendCount(const class CCSBot *const this); // 724 -// GetNearbyEnemyCount(const class CCSBot *const this); // 724 -} - -/* <2e94a0> ../cstrike/dlls/bot/cs_bot.cpp:731 */ -NOBODY int CCSBot::OutnumberedCount(void) -{ -// IsOutnumbered(const class CCSBot *const this); // 733 -// GetNearbyEnemyCount(const class CCSBot *const this); // 734 -// GetNearbyFriendCount(const class CCSBot *const this); // 734 -} - -/* <2e95cb> ../cstrike/dlls/bot/cs_bot.cpp:744 */ -NOBODY CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) -{ -// { -// class CCSBotManager *ctrl; // 746 -// class CBasePlayer *nearEnemy; // 747 -// float nearDist; // 748 -// { -// int i; // 750 -// { -// class CBaseEntity *entity; // 752 -// class CBasePlayer *player; // 767 -// Vector d; // 782 -// float distSq; // 783 -// FNullEnt(entvars_t *pev); // 757 -// operator-(const Vector *const this, -// const Vector &v); // 782 -// } -// } -// } -} - -/* <2e9719> ../cstrike/dlls/bot/cs_bot.cpp:801 */ -NOBODY void CCSBot::SetDisposition(DispositionType disposition) -{ -// Invalidate(CountdownTimer *const this); // 806 -} - -/* <2e9762> ../cstrike/dlls/bot/cs_bot.cpp:814 */ -CCSBot::DispositionType CCSBot::GetDisposition(void) const -{ - if (!m_ignoreEnemiesTimer.IsElapsed()) - return IGNORE_ENEMIES; - - return m_disposition; -} - -/* <2e979b> ../cstrike/dlls/bot/cs_bot.cpp:826 */ -NOBODY void CCSBot::IgnoreEnemies(float duration) -{ -// Start(CountdownTimer *const this, -// float duration); // 828 -} - -/* <2e97fc> ../cstrike/dlls/bot/cs_bot.cpp:835 */ -NOBODY void CCSBot::IncreaseMorale(void) -{ -} - -/* <2e9824> ../cstrike/dlls/bot/cs_bot.cpp:845 */ -void CCSBot::DecreaseMorale(void) -{ - if (m_morale > TERRIBLE) - { - m_morale = static_cast(m_morale - 1); - } -} - -/* <2e984c> ../cstrike/dlls/bot/cs_bot.cpp:857 */ -NOBODY bool CCSBot::IsRogue(void) const -{ -// { -// class CCSBotManager *ctrl; // 859 -// AllowRogues(const class CCSBotManager *const this); // 860 -// IsElapsed(const class CountdownTimer *const this); // 864 -// { -// float const rogueChance; // 869 -// Start(CountdownTimer *const this, -// float duration); // 866 -// } -// } -} - -/* <2e98f1> ../cstrike/dlls/bot/cs_bot.cpp:882 */ -NOBODY bool CCSBot::IsHurrying(void) const -{ -// { -// class CCSBotManager *ctrl; // 887 -// IsElapsed(const class CountdownTimer *const this); // 884 -// } -} - -/* <2e9942> ../cstrike/dlls/bot/cs_bot.cpp:906 */ -NOBODY bool CCSBot::IsSafe(void) const -{ -// { -// class CCSBotManager *ctrl; // 908 -// GetElapsedRoundTime(const class CCSBotManager *const this); // 910 -// } -} - -/* <2e9987> ../cstrike/dlls/bot/cs_bot.cpp:920 */ -NOBODY bool CCSBot::IsWellPastSafe(void) const -{ -// { -// class CCSBotManager *ctrl; // 922 -// GetElapsedRoundTime(const class CCSBotManager *const this); // 924 -// } -} - -/* <2e99d8> ../cstrike/dlls/bot/cs_bot.cpp:934 */ -NOBODY bool CCSBot::IsEndOfSafeTime(void) const -{ -// IsSafe(const class CCSBot *const this); // 936 -} - -/* <2e9a3e> ../cstrike/dlls/bot/cs_bot.cpp:943 */ -NOBODY float CCSBot::GetSafeTimeRemaining(void) const -{ -// { -// class CCSBotManager *ctrl; // 945 -// GetElapsedRoundTime(const class CCSBotManager *const this); // 947 -// } -} - -/* <2e9a8f> ../cstrike/dlls/bot/cs_bot.cpp:954 */ -void CCSBot::AdjustSafeTime(void) -{ - CCSBotManager *ctrl = TheCSBots(); - - // if we spotted an enemy sooner than we thought possible, adjust our notion of "safe" time +/* <2e7c11> ../cstrike/dlls/bot/cs_bot.cpp:200 */ +NOBODY inline bool IsIntersectingBox(const Vector *start, const Vector *end, const Vector *boxMin, const Vector *boxMax) +{ +// { +// unsigned char startFlags; // 202 +// unsigned char endFlags; // 203 +// } +} + +/* <2e87d9> ../cstrike/dlls/bot/cs_bot.cpp:253 */ +NOBODY void CCSBot::BotTouch(CBaseEntity *other) +{ +// FStrEq(const char *sz1, +// const char *sz2); // 297 +// { +// Vector center; // 299 +// class Extent extent; // 301 +// bool breakIt; // 307 +// operator+(const Vector *const this, +// const Vector &v); // 299 +// { +// Vector goal; // 312 +// Vector(Vector *const this, +// const Vector &v); // 312 +// IsIntersectingBox(const Vector *start, +// const Vector *end, +// const Vector *boxMin, +// const Vector *boxMax); // 314 +// } +// operator/(const Vector *const this, +// float fl); // 299 +// } +// { +// class CBasePlayer *player; // 269 +// unsigned int otherPri; // 272 +// unsigned int myPri; // 275 +// { +// unsigned int avoidPri; // 284 +// } +// } +} + +/* <2e89e3> ../cstrike/dlls/bot/cs_bot.cpp:335 */ +NOBODY bool CCSBot::IsBusy(void) const +{ +} + +/* <2e8a0c> ../cstrike/dlls/bot/cs_bot.cpp:351 */ +NOBODY void CCSBot::BotDeathThink(void) +{ +} + +/* <2e8a34> ../cstrike/dlls/bot/cs_bot.cpp:358 */ +NOBODY CBasePlayer *CCSBot::FindNearbyPlayer(void) +{ +// { +// class CBaseEntity *pEntity; // 360 +// Vector vecSrc; // 361 +// float flRadius; // 362 +// Vector(Vector *const this, +// const Vector &v); // 361 +// } +} + +/* <2e8abd> ../cstrike/dlls/bot/cs_bot.cpp:385 */ +void CCSBot::SetEnemy(CBasePlayer *enemy) +{ + if (m_enemy != enemy) + { + m_enemy = enemy; + m_currentEnemyAcquireTimestamp = gpGlobals->time; + } +} + +/* <2e8af6> ../cstrike/dlls/bot/cs_bot.cpp:400 */ +NOBODY bool CCSBot::StayOnNavMesh(void) +{ +// { +// class CNavArea *goalArea; // 408 +// { +// Vector pos; // 422 +// Vector to; // 426 +// float const stepInDist; // 429 +// operator-(const Vector *const this, +// const Vector &v); // 426 +// NormalizeInPlace(Vector *const this); // 427 +// operator*(float fl, +// const Vector &v); // 430 +// operator+(const Vector *const this, +// const Vector &v); // 430 +// } +// } +} + +/* <2e8c56> ../cstrike/dlls/bot/cs_bot.cpp:450 */ +NOBODY void CCSBot::Panic(CBasePlayer *enemy) +{ +// { +// class Vector2D dir; // 456 +// class Vector2D perp; // 457 +// Vector spot; // 459 +// IsSurprised(const class CCSBot *const this); // 453 +// { +// class Vector2D toEnemy; // 473 +// float along; // 476 +// float c45; // 477 +// float size; // 478 +// float shift; // 479 +// NormalizeInPlace(Vector2D *const this); // 474 +// DotProduct(const class Vector2D &a, +// const class Vector2D &b); // 476 +// { +// float side; // 495 +// DotProduct(const class Vector2D &a, +// const class Vector2D &b); // 495 +// } +// } +// { +// float const offset; // 464 +// float side; // 465 +// } +// } +} + +/* <2e9047> ../cstrike/dlls/bot/cs_bot.cpp:527 */ +NOBODY bool CCSBot::IsDoingScenario(void) +{ +} + +/* <2e9070> ../cstrike/dlls/bot/cs_bot.cpp:544 */ +NOBODY bool CCSBot::NoticeLooseBomb(void) const +{ +// { +// class CCSBotManager *ctrl; // 546 +// class CBaseEntity *bomb; // 551 +// GetLooseBomb(CCSBotManager *const this); // 551 +// } +} + +/* <2e90d4> ../cstrike/dlls/bot/cs_bot.cpp:566 */ +NOBODY bool CCSBot::CanSeeLooseBomb(void) const +{ +// { +// class CCSBotManager *ctrl; // 568 +// class CBaseEntity *bomb; // 573 +// GetLooseBomb(CCSBotManager *const this); // 573 +// } +} + +/* <2e9140> ../cstrike/dlls/bot/cs_bot.cpp:588 */ +NOBODY bool CCSBot::CanSeePlantedBomb(void) const +{ +// { +// class CCSBotManager *ctrl; // 590 +// const Vector *bombPos; // 598 +// } +} + +/* <2e918e> ../cstrike/dlls/bot/cs_bot.cpp:610 */ +NOBODY CBasePlayer *CCSBot::GetAttacker(void) +{ +} + +/* <2e91b7> ../cstrike/dlls/bot/cs_bot.cpp:622 */ +NOBODY void CCSBot::GetOffLadder(void) +{ +// DestroyPath(CCSBot *const this); // 627 +} + +/* <2e91f1> ../cstrike/dlls/bot/cs_bot.cpp:637 */ +NOBODY float CCSBot::GetHidingSpotCheckTimestamp(HidingSpot *spot) +{ +// { +// int i; // 639 +// } +} + +/* <2e9240> ../cstrike/dlls/bot/cs_bot.cpp:651 */ +NOBODY void CCSBot::SetHidingSpotCheckTimestamp(HidingSpot *spot) +{ +// { +// int leastRecent; // 653 +// float leastRecentTime; // 654 +// { +// int i; // 656 +// } +// } +} + +/* <2e92b8> ../cstrike/dlls/bot/cs_bot.cpp:693 */ +NOBODY void CCSBot::UpdateHostageEscortCount(void) +{ +// { +// float const updateInterval; // 695 +// { +// class CHostage *hostage; // 704 +// IsValid(CHostage *const this); // 709 +// IsFollowing(CHostage *const this, +// const class CBaseEntity *entity); // 713 +// edict(CBaseEntity *const this); // 705 +// FNullEnt(const edict_t *pent); // 705 +// } +// } +} + +/* <2e940d> ../cstrike/dlls/bot/cs_bot.cpp:722 */ +NOBODY bool CCSBot::IsOutnumbered(void) +{ +// GetNearbyFriendCount(const class CCSBot *const this); // 724 +// GetNearbyEnemyCount(const class CCSBot *const this); // 724 +} + +/* <2e94a0> ../cstrike/dlls/bot/cs_bot.cpp:731 */ +NOBODY int CCSBot::OutnumberedCount(void) +{ +// IsOutnumbered(const class CCSBot *const this); // 733 +// GetNearbyEnemyCount(const class CCSBot *const this); // 734 +// GetNearbyFriendCount(const class CCSBot *const this); // 734 +} + +/* <2e95cb> ../cstrike/dlls/bot/cs_bot.cpp:744 */ +NOBODY CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) +{ +// { +// class CCSBotManager *ctrl; // 746 +// class CBasePlayer *nearEnemy; // 747 +// float nearDist; // 748 +// { +// int i; // 750 +// { +// class CBaseEntity *entity; // 752 +// class CBasePlayer *player; // 767 +// Vector d; // 782 +// float distSq; // 783 +// FNullEnt(entvars_t *pev); // 757 +// operator-(const Vector *const this, +// const Vector &v); // 782 +// } +// } +// } +} + +/* <2e9719> ../cstrike/dlls/bot/cs_bot.cpp:801 */ +NOBODY void CCSBot::SetDisposition(DispositionType disposition) +{ +// Invalidate(CountdownTimer *const this); // 806 +} + +/* <2e9762> ../cstrike/dlls/bot/cs_bot.cpp:814 */ +CCSBot::DispositionType CCSBot::GetDisposition(void) const +{ + if (!m_ignoreEnemiesTimer.IsElapsed()) + return IGNORE_ENEMIES; + + return m_disposition; +} + +/* <2e979b> ../cstrike/dlls/bot/cs_bot.cpp:826 */ +NOBODY void CCSBot::IgnoreEnemies(float duration) +{ +// Start(CountdownTimer *const this, +// float duration); // 828 +} + +/* <2e97fc> ../cstrike/dlls/bot/cs_bot.cpp:835 */ +NOBODY void CCSBot::IncreaseMorale(void) +{ +} + +/* <2e9824> ../cstrike/dlls/bot/cs_bot.cpp:845 */ +void CCSBot::DecreaseMorale(void) +{ + if (m_morale > TERRIBLE) + { + m_morale = static_cast(m_morale - 1); + } +} + +/* <2e984c> ../cstrike/dlls/bot/cs_bot.cpp:857 */ +NOBODY bool CCSBot::IsRogue(void) const +{ +// { +// class CCSBotManager *ctrl; // 859 +// AllowRogues(const class CCSBotManager *const this); // 860 +// IsElapsed(const class CountdownTimer *const this); // 864 +// { +// float const rogueChance; // 869 +// Start(CountdownTimer *const this, +// float duration); // 866 +// } +// } +} + +/* <2e98f1> ../cstrike/dlls/bot/cs_bot.cpp:882 */ +NOBODY bool CCSBot::IsHurrying(void) const +{ +// { +// class CCSBotManager *ctrl; // 887 +// IsElapsed(const class CountdownTimer *const this); // 884 +// } +} + +/* <2e9942> ../cstrike/dlls/bot/cs_bot.cpp:906 */ +NOBODY bool CCSBot::IsSafe(void) const +{ +// { +// class CCSBotManager *ctrl; // 908 +// GetElapsedRoundTime(const class CCSBotManager *const this); // 910 +// } +} + +/* <2e9987> ../cstrike/dlls/bot/cs_bot.cpp:920 */ +NOBODY bool CCSBot::IsWellPastSafe(void) const +{ +// { +// class CCSBotManager *ctrl; // 922 +// GetElapsedRoundTime(const class CCSBotManager *const this); // 924 +// } +} + +/* <2e99d8> ../cstrike/dlls/bot/cs_bot.cpp:934 */ +NOBODY bool CCSBot::IsEndOfSafeTime(void) const +{ +// IsSafe(const class CCSBot *const this); // 936 +} + +/* <2e9a3e> ../cstrike/dlls/bot/cs_bot.cpp:943 */ +NOBODY float CCSBot::GetSafeTimeRemaining(void) const +{ +// { +// class CCSBotManager *ctrl; // 945 +// GetElapsedRoundTime(const class CCSBotManager *const this); // 947 +// } +} + +/* <2e9a8f> ../cstrike/dlls/bot/cs_bot.cpp:954 */ +void CCSBot::AdjustSafeTime(void) +{ + CCSBotManager *ctrl = TheCSBots(); + + // if we spotted an enemy sooner than we thought possible, adjust our notion of "safe" time if (m_safeTime > ctrl->GetElapsedRoundTime()) - { + { // since right now is not safe, adjust safe time to be a few seconds ago m_safeTime = ctrl->GetElapsedRoundTime() - 2.0f; - } -} - -/* <2e9ad0> ../cstrike/dlls/bot/cs_bot.cpp:970 */ -NOBODY bool CCSBot::HasNotSeenEnemyForLongTime(void) const -{ -// { -// float const longTime; // 972 -// GetTimeSinceLastSawEnemy(const class CCSBot *const this); // 973 -// } -} - -/* <2e9b26> ../cstrike/dlls/bot/cs_bot.cpp:980 */ -NOBODY bool CCSBot::GuardRandomZone(float range) -{ -// { -// class CCSBotManager *ctrl; // 982 -// const class Zone *zone; // 984 -// GetRandomZone(const class CCSBotManager *const this); // 984 -// { -// class CNavArea *rescueArea; // 987 -// } -// } -} - -/* <2e9c1f> ../cstrike/dlls/bot/cs_bot.cpp:1066 */ -NOBODY const Vector *FindNearbyRetreatSpot(CCSBot *me, float maxRange) -{ -// { -// class CNavArea *area; // 1068 -// class CollectRetreatSpotsFunctor collector; // 1073 -// int which; // 1080 -// SearchSurroundingAreas(CNavArea *startArea, -// const Vector *startPos, -// class CollectRetreatSpotsFunctor &func, -// float maxRange); // 1074 -// } -} - -/* <2eaa1d> ../cstrike/dlls/bot/cs_bot.cpp:1116 */ -NOBODY float CCSBot::GetRangeToFarthestEscortedHostage(void) -{ -// { -// class FarthestHostage away; // 1118 -// ForEachHostage(const class CHostageManager *const this, -// class FarthestHostage &func); // 1120 -// } -} - + } +} + +/* <2e9ad0> ../cstrike/dlls/bot/cs_bot.cpp:970 */ +NOBODY bool CCSBot::HasNotSeenEnemyForLongTime(void) const +{ +// { +// float const longTime; // 972 +// GetTimeSinceLastSawEnemy(const class CCSBot *const this); // 973 +// } +} + +/* <2e9b26> ../cstrike/dlls/bot/cs_bot.cpp:980 */ +NOBODY bool CCSBot::GuardRandomZone(float range) +{ +// { +// class CCSBotManager *ctrl; // 982 +// const class Zone *zone; // 984 +// GetRandomZone(const class CCSBotManager *const this); // 984 +// { +// class CNavArea *rescueArea; // 987 +// } +// } +} + +/* <2e9c1f> ../cstrike/dlls/bot/cs_bot.cpp:1066 */ +NOBODY const Vector *FindNearbyRetreatSpot(CCSBot *me, float maxRange) +{ +// { +// class CNavArea *area; // 1068 +// class CollectRetreatSpotsFunctor collector; // 1073 +// int which; // 1080 +// SearchSurroundingAreas(CNavArea *startArea, +// const Vector *startPos, +// class CollectRetreatSpotsFunctor &func, +// float maxRange); // 1074 +// } +} + +/* <2eaa1d> ../cstrike/dlls/bot/cs_bot.cpp:1116 */ +NOBODY float CCSBot::GetRangeToFarthestEscortedHostage(void) +{ +// { +// class FarthestHostage away; // 1118 +// ForEachHostage(const class CHostageManager *const this, +// class FarthestHostage &func); // 1120 +// } +} + #ifdef HOOK_GAMEDLL -void CCSBot::Walk(void) -{ - Walk_(); -} -bool CCSBot::Jump(bool mustJump) -{ - return Jump_(mustJump); +void CCSBot::Walk(void) +{ + Walk_(); } - -int CCSBot::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ - return TakeDamage_(pevInflictor, pevAttacker, flDamage, bitsDamageType); -} -void CCSBot::Killed(entvars_t *pevAttacker, int iGib) -{ - Killed_(pevAttacker, iGib); +bool CCSBot::Jump(bool mustJump) +{ + return Jump_(mustJump); +} + +int CCSBot::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + return TakeDamage_(pevInflictor, pevAttacker, flDamage, bitsDamageType); +} +void CCSBot::Killed(entvars_t *pevAttacker, int iGib) +{ + Killed_(pevAttacker, iGib); } #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/bot/cs_bot.h b/regamedll/dlls/bot/cs_bot.h index 46ead337..3b7245a3 100644 --- a/regamedll/dlls/bot/cs_bot.h +++ b/regamedll/dlls/bot/cs_bot.h @@ -36,11 +36,11 @@ #include "bot/cs_bot_manager.h" #include "bot/cs_bot_chatter.h" -#define CSBOT_VERSION_MAJOR 1 +#define CSBOT_VERSION_MAJOR 1 #define CSBOT_VERSION_MINOR 50 -#define FLAG_PROGRESS_DRAW 0x0 // draw status bar progress -#define FLAG_PROGRESS_START 0x1 // init status bar progress +#define FLAG_PROGRESS_DRAW 0x0 // draw status bar progress +#define FLAG_PROGRESS_START 0x1 // init status bar progress #define FLAG_PROGRESS_HIDE 0x2 // hide status bar progress #ifdef HOOK_GAMEDLL @@ -53,6 +53,9 @@ extern int _navAreaCount; extern int _currentIndex; +class CCSBot; +class BotChatterInterface; + /* <3327a8> ../cstrike/dlls/bot/cs_bot.h:44 */ class BotState { @@ -444,17 +447,17 @@ public: void Disconnect(void); float GetCombatRange(void) const { - return m_combatRange; + return m_combatRange; } NOBODY bool IsRogue(void)const; void SetRogue(bool rogue) - { + { m_isRogue = rogue; } NOBODY bool IsHurrying(void) const; void Hurry(float duration) { - m_hurryTimer.Start(duration); + m_hurryTimer.Start(duration); } NOBODY bool IsSafe(void) const; NOBODY bool IsWellPastSafe(void) const; @@ -685,7 +688,7 @@ public: } int GetNearbyEnemyCount(void) const { - return _min(GetEnemiesRemaining(), m_nearbyEnemyCount); + return Q_min(GetEnemiesRemaining(), m_nearbyEnemyCount); } unsigned int GetEnemyPlace(void) const { @@ -698,7 +701,7 @@ public: } int GetNearbyFriendCount(void) const { - return _min(GetFriendsRemaining(), m_nearbyFriendCount); + return Q_min(GetFriendsRemaining(), m_nearbyFriendCount); } CBasePlayer *GetClosestVisibleFriend(void) const { @@ -1061,9 +1064,7 @@ private: float m_pathLadderDismountTimestamp; float m_pathLadderEnd; float m_pathLadderTimestamp; - - CountdownTimer m_mustRunTimer; - + class CountdownTimer m_mustRunTimer; CSGameState m_gameState; byte m_hostageEscortCount; float m_hostageEscortCountTimestamp; @@ -1403,80 +1404,80 @@ private: };/* size: 8, cachelines: 1, members: 2 */ -/* <568fae> ../cstrike/dlls/bot/states/cs_bot_follow.cpp:95 */ -class FollowTargetCollector -{ -public: - FollowTargetCollector(CBasePlayer *player) - { - m_player = player; - - Vector playerVel = player->pev->velocity; - - m_forward.x = playerVel.x; - m_forward.y = playerVel.y; - - float speed = m_forward.NormalizeInPlace(); - - Vector playerOrigin = player->pev->origin; - - const float walkSpeed = 100.0f; - if (speed < walkSpeed) - { - m_cutoff.x = playerOrigin.x; - m_cutoff.y = playerOrigin.y; - - m_forward.x = 0.0f; - m_forward.y = 0.0f; - } - else - { - const float k = 1.5f; // 2.0f; - float trimSpeed = (speed < 200.0f) ? speed : 200.0f; - - m_cutoff.x = playerOrigin.x + k * trimSpeed * m_forward.x; - m_cutoff.y = playerOrigin.y + k * trimSpeed * m_forward.y; - } - - m_targetAreaCount = 0; - } - - enum { MAX_TARGET_AREAS = 128 }; - - /* <568dc3> ../cstrike/dlls/bot/states/cs_bot_follow.cpp:124 */ - bool operator()(CNavArea *area) - { - if (m_targetAreaCount >= MAX_TARGET_AREAS) - return false; - - // only use two-way connections - if (!area->GetParent() || area->IsConnected(area->GetParent(), NUM_DIRECTIONS)) - { - if (m_forward.IsZero()) - { - m_targetArea[ m_targetAreaCount++ ] = area; - } - else - { - // collect areas in the direction of the player's forward motion - Vector2D to(((*area->GetCenter()).x - m_cutoff.x), (*area->GetCenter()).y - m_cutoff.y); - to.NormalizeInPlace(); - - //if (DotProduct( to, m_forward ) > 0.7071f) - if ((to.x * m_forward.x + to.y * m_forward.y) > 0.7071f) - m_targetArea[ m_targetAreaCount++ ] = area; - } - } - - return (m_targetAreaCount < MAX_TARGET_AREAS); - } - - CBasePlayer *m_player; - Vector2D m_forward; - Vector2D m_cutoff; - CNavArea *m_targetArea[ MAX_TARGET_AREAS ]; - int m_targetAreaCount; - +/* <568fae> ../cstrike/dlls/bot/states/cs_bot_follow.cpp:95 */ +class FollowTargetCollector +{ +public: + FollowTargetCollector(CBasePlayer *player) + { + m_player = player; + + Vector playerVel = player->pev->velocity; + + m_forward.x = playerVel.x; + m_forward.y = playerVel.y; + + float speed = m_forward.NormalizeInPlace(); + + Vector playerOrigin = player->pev->origin; + + const float walkSpeed = 100.0f; + if (speed < walkSpeed) + { + m_cutoff.x = playerOrigin.x; + m_cutoff.y = playerOrigin.y; + + m_forward.x = 0.0f; + m_forward.y = 0.0f; + } + else + { + const float k = 1.5f; // 2.0f; + float trimSpeed = (speed < 200.0f) ? speed : 200.0f; + + m_cutoff.x = playerOrigin.x + k * trimSpeed * m_forward.x; + m_cutoff.y = playerOrigin.y + k * trimSpeed * m_forward.y; + } + + m_targetAreaCount = 0; + } + + enum { MAX_TARGET_AREAS = 128 }; + + /* <568dc3> ../cstrike/dlls/bot/states/cs_bot_follow.cpp:124 */ + bool operator()(CNavArea *area) + { + if (m_targetAreaCount >= MAX_TARGET_AREAS) + return false; + + // only use two-way connections + if (!area->GetParent() || area->IsConnected(area->GetParent(), NUM_DIRECTIONS)) + { + if (m_forward.IsZero()) + { + m_targetArea[ m_targetAreaCount++ ] = area; + } + else + { + // collect areas in the direction of the player's forward motion + Vector2D to(((*area->GetCenter()).x - m_cutoff.x), (*area->GetCenter()).y - m_cutoff.y); + to.NormalizeInPlace(); + + //if (DotProduct(to, m_forward) > 0.7071f) + if ((to.x * m_forward.x + to.y * m_forward.y) > 0.7071f) + m_targetArea[ m_targetAreaCount++ ] = area; + } + } + + return (m_targetAreaCount < MAX_TARGET_AREAS); + } + + CBasePlayer *m_player; + Vector2D m_forward; + Vector2D m_cutoff; + CNavArea *m_targetArea[ MAX_TARGET_AREAS ]; + int m_targetAreaCount; + };/* size: 536, cachelines: 9, members: 5 */ #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/bot/cs_bot_chatter.cpp b/regamedll/dlls/bot/cs_bot_chatter.cpp index 90c8a32a..cb435223 100644 --- a/regamedll/dlls/bot/cs_bot_chatter.cpp +++ b/regamedll/dlls/bot/cs_bot_chatter.cpp @@ -225,7 +225,7 @@ char *BotPhrase::GetSpeakable(int bankIndex, float *duration) const // check count criteria // if this speakable has a count criteria, it must match to be used // if this speakable does not have a count criteria, we dont care what the count is set to - if (speak->m_count == UNDEFINED_COUNT || speak->m_count == _min(m_countCriteria, COUNT_MANY)) + if (speak->m_count == UNDEFINED_COUNT || speak->m_count == Q_min(m_countCriteria, (CountCriteria)COUNT_MANY)) { if (duration) *duration = speak->m_duration; @@ -270,7 +270,7 @@ NOBODY void __declspec(naked) BotPhrase::Randomize(void) // // BotSpeakable *firstElem = speakables->front(); // int nSize = speakables->size(); -// +// // for (unsigned int index = 1; index < nSize; index++) // { // // TODO: check it, need hook std rand @@ -398,58 +398,58 @@ NOBODY BotPhraseManager::~BotPhraseManager(void) /* <3043ec> ../cstrike/dlls/bot/cs_bot_chatter.cpp:708 */ Place BotPhraseManager::NameToID(const char *name) const -{ - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) - { - const BotPhrase *phrase = *iter; - - if (!Q_stricmp(phrase->m_name, name)) - return phrase->m_id; - } - - for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) - { - const BotPhrase *phrase = *iter; - - if (!Q_stricmp(phrase->m_name, name)) - return phrase->m_id; - } - +{ + for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + { + const BotPhrase *phrase = *iter; + + if (!Q_stricmp(phrase->m_name, name)) + return phrase->m_id; + } + + for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) + { + const BotPhrase *phrase = *iter; + + if (!Q_stricmp(phrase->m_name, name)) + return phrase->m_id; + } + return 0; } /* <3044b4> ../cstrike/dlls/bot/cs_bot_chatter.cpp:732 */ const char *BotPhraseManager::IDToName(Place id) const -{ - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) - { - const BotPhrase *phrase = *iter; - - if (phrase->m_id == id) - return phrase->m_name; - } - - for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) - { - const BotPhrase *phrase = *iter; - - if (phrase->m_id == id) - return phrase->m_name; - } - +{ + for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + { + const BotPhrase *phrase = *iter; + + if (phrase->m_id == id) + return phrase->m_name; + } + + for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) + { + const BotPhrase *phrase = *iter; + + if (phrase->m_id == id) + return phrase->m_name; + } + return NULL; } /* <304597> ../cstrike/dlls/bot/cs_bot_chatter.cpp:758 */ NOBODY const BotPhrase *BotPhraseManager::GetPhrase(const char *name) const -{ - for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) - { - const BotPhrase *phrase = *iter; - - if (!Q_stricmp(phrase->m_name, name)) - return phrase; - } +{ + for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) + { + const BotPhrase *phrase = *iter; + + if (!Q_stricmp(phrase->m_name, name)) + return phrase; + } return NULL; } @@ -459,14 +459,14 @@ NOBODY const BotPhrase *BotPhraseManager::GetPlace(const char *name) const if (name == NULL) return NULL; - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) - { - const BotPhrase *phrase = *iter; - - if (!Q_stricmp(phrase->m_name, name)) - return phrase; - } - + for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + { + const BotPhrase *phrase = *iter; + + if (!Q_stricmp(phrase->m_name, name)) + return phrase; + } + return NULL; } @@ -476,14 +476,14 @@ NOBODY const BotPhrase *BotPhraseManager::GetPlace(PlaceCriteria place) const if (place == UNDEFINED_PLACE) return NULL; - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) - { - const BotPhrase *phrase = *iter; - - if (phrase->m_id == place) - return phrase; - } - + for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + { + const BotPhrase *phrase = *iter; + + if (phrase->m_id == place) + return phrase; + } + return NULL; } diff --git a/regamedll/dlls/bot/cs_bot_chatter.h b/regamedll/dlls/bot/cs_bot_chatter.h index 8ad08a42..58ff6158 100644 --- a/regamedll/dlls/bot/cs_bot_chatter.h +++ b/regamedll/dlls/bot/cs_bot_chatter.h @@ -31,43 +31,43 @@ #ifdef _WIN32 #pragma once #endif - -#define UNDEFINED_COUNT 0xFFFF -#define MAX_PLACES_PER_MAP 64 -#define UNDEFINED_SUBJECT (-1) -#define COUNT_MANY 4 - + +#define UNDEFINED_COUNT 0xFFFF +#define MAX_PLACES_PER_MAP 64 +#define UNDEFINED_SUBJECT (-1) +#define COUNT_MANY 4 + class CCSBot; -class BotChatterInterface; - -typedef unsigned int PlaceCriteria; -typedef unsigned int CountCriteria; - - -/* <2fe97b> ../cstrike/dlls/bot/cs_bot_chatter.h:42 */ +class BotChatterInterface; + +typedef unsigned int PlaceCriteria; +typedef unsigned int CountCriteria; + + +/* <2fe97b> ../cstrike/dlls/bot/cs_bot_chatter.h:42 */ class BotMeme { public: NOBODY void Transmit(CCSBot *sender) const; NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const = 0; -};/* size: 4, cachelines: 1, members: 1 */ - +};/* size: 4, cachelines: 1, members: 1 */ + class BotAllHostagesGoneMeme: public BotMeme { public: NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; };/* size: 4, cachelines: 1, members: 1 */ - + class BotHostageBeingTakenMeme: public BotMeme { public: NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; };/* size: 4, cachelines: 1, members: 1 */ - -/* <2ff7ef> ../cstrike/dlls/bot/cs_bot_chatter.h:53 */ + +/* <2ff7ef> ../cstrike/dlls/bot/cs_bot_chatter.h:53 */ class BotHelpMeme: public BotMeme { public: @@ -79,9 +79,9 @@ public: private: Place m_place; -};/* size: 8, cachelines: 1, members: 2 */ - -/* <2ff65e> ../cstrike/dlls/bot/cs_bot_chatter.h:70 */ +};/* size: 8, cachelines: 1, members: 2 */ + +/* <2ff65e> ../cstrike/dlls/bot/cs_bot_chatter.h:70 */ class BotBombsiteStatusMeme: public BotMeme { public: @@ -100,10 +100,10 @@ private: int m_zoneIndex; StatusType m_status; -};/* size: 12, cachelines: 1, members: 3 */ - - -/* <2ff6de> ../cstrike/dlls/bot/cs_bot_chatter.h:87 */ +};/* size: 12, cachelines: 1, members: 3 */ + + +/* <2ff6de> ../cstrike/dlls/bot/cs_bot_chatter.h:87 */ class BotBombStatusMeme: public BotMeme { public: @@ -118,66 +118,66 @@ private: CSGameState::BombState m_state; Vector m_pos; -};/* size: 20, cachelines: 1, members: 3 */ - -/* <2ff75d> ../cstrike/dlls/bot/cs_bot_chatter.h:101 */ +};/* size: 20, cachelines: 1, members: 3 */ + +/* <2ff75d> ../cstrike/dlls/bot/cs_bot_chatter.h:101 */ class BotFollowMeme: public BotMeme { public: NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; -};/* size: 4, cachelines: 1, members: 1 */ - -/* <2ff731> ../cstrike/dlls/bot/cs_bot_chatter.h:111 */ -class BotDefendHereMeme: public BotMeme -{ -public: - BotDefendHereMeme(const Vector &pos) - { - m_pos = pos; - } - NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; -private: - Vector m_pos; - -};/* size: 16, cachelines: 1, members: 2 */ - -/* <2ff696> ../cstrike/dlls/bot/cs_bot_chatter.h:123 */ -class BotWhereBombMeme: public BotMeme -{ -public: - NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; - -};/* size: 4, cachelines: 1, members: 1 */ - -/* <2ff81b> ../cstrike/dlls/bot/cs_bot_chatter.h:130 */ -class BotRequestReportMeme: public BotMeme -{ -public: - NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; - -};/* size: 4, cachelines: 1, members: 1 */ - -enum BotStatementType -{ - REPORT_VISIBLE_ENEMIES = 0, - REPORT_ENEMY_ACTION, - REPORT_MY_CURRENT_TASK, - REPORT_MY_INTENTION, - REPORT_CRITICAL_EVENT, - REPORT_REQUEST_HELP, - REPORT_REQUEST_INFORMATION, - REPORT_ROUND_END, - REPORT_MY_PLAN, - REPORT_INFORMATION, - REPORT_EMOTE, - REPORT_ACKNOWLEDGE, - REPORT_ENEMIES_REMAINING, - REPORT_FRIENDLY_FIRE, - REPORT_KILLED_FRIEND, - NUM_BOT_STATEMENT_TYPES, -}; - +};/* size: 4, cachelines: 1, members: 1 */ + +/* <2ff731> ../cstrike/dlls/bot/cs_bot_chatter.h:111 */ +class BotDefendHereMeme: public BotMeme +{ +public: + BotDefendHereMeme(const Vector &pos) + { + m_pos = pos; + } + NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; +private: + Vector m_pos; + +};/* size: 16, cachelines: 1, members: 2 */ + +/* <2ff696> ../cstrike/dlls/bot/cs_bot_chatter.h:123 */ +class BotWhereBombMeme: public BotMeme +{ +public: + NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; + +};/* size: 4, cachelines: 1, members: 1 */ + +/* <2ff81b> ../cstrike/dlls/bot/cs_bot_chatter.h:130 */ +class BotRequestReportMeme: public BotMeme +{ +public: + NOBODY virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; + +};/* size: 4, cachelines: 1, members: 1 */ + +enum BotStatementType +{ + REPORT_VISIBLE_ENEMIES = 0, + REPORT_ENEMY_ACTION, + REPORT_MY_CURRENT_TASK, + REPORT_MY_INTENTION, + REPORT_CRITICAL_EVENT, + REPORT_REQUEST_HELP, + REPORT_REQUEST_INFORMATION, + REPORT_ROUND_END, + REPORT_MY_PLAN, + REPORT_INFORMATION, + REPORT_EMOTE, + REPORT_ACKNOWLEDGE, + REPORT_ENEMIES_REMAINING, + REPORT_FRIENDLY_FIRE, + REPORT_KILLED_FRIEND, + NUM_BOT_STATEMENT_TYPES, +}; + class BotSpeakable { public: @@ -193,175 +193,175 @@ public: typedef std::vector BotSpeakableVector; typedef std::vector BotVoiceBankVector; - -class BotPhrase -{ + +class BotPhrase +{ public: NOBODY BotPhrase(unsigned int id, bool isPlace); NOBODY ~BotPhrase(void); - NOBODY void InitVoiceBank(int bankIndex); - char *GetSpeakable(int bankIndex, float *duration = NULL) const; - - void ClearCriteria(void) const; - void SetPlaceCriteria(PlaceCriteria place) const; - void SetCountCriteria(CountCriteria count) const; - - const char *GetName(void) const - { - return m_name; - } - Place GetID(void) const - { - return m_id; - } - GameEventType GetRadioEquivalent(void) const - { - return m_radioEvent; - } - bool IsImportant(void) const - { - return m_isImportant; - } - bool IsPlace(void) const - { - return m_isPlace; - } - NOBODY void Randomize(void); -//private: -public: - friend class BotPhraseManager; - - char *m_name; - Place m_id; - bool m_isPlace; - GameEventType m_radioEvent; - bool m_isImportant; - -#if defined(_WIN32) && defined(HOOK_GAMEDLL) - int unknown_padding; -#endif // HOOK_GAMEDLL - - mutable BotVoiceBankVector m_voiceBank; - -#if defined(_WIN32) && defined(HOOK_GAMEDLL) - int unknown_padding2; -#endif // HOOK_GAMEDLL - - std::vector< int > m_count; - -#if defined(_WIN32) && defined(HOOK_GAMEDLL) - int unknown_padding3; -#endif // HOOK_GAMEDLL - - mutable std::vector< int > m_index; - - int m_numVoiceBanks; - mutable PlaceCriteria m_placeCriteria; - mutable CountCriteria m_countCriteria; - -};/* size: 68, cachelines: 2, members: 11 */ - -typedef std::list BotPhraseList; - -/* <2fea0e> ../cstrike/dlls/bot/cs_bot_chatter.h:239 */ -inline void BotPhrase::ClearCriteria(void) const -{ + NOBODY void InitVoiceBank(int bankIndex); + char *GetSpeakable(int bankIndex, float *duration = NULL) const; + + void ClearCriteria(void) const; + void SetPlaceCriteria(PlaceCriteria place) const; + void SetCountCriteria(CountCriteria count) const; + + const char *GetName(void) const + { + return m_name; + } + Place GetID(void) const + { + return m_id; + } + GameEventType GetRadioEquivalent(void) const + { + return m_radioEvent; + } + bool IsImportant(void) const + { + return m_isImportant; + } + bool IsPlace(void) const + { + return m_isPlace; + } + NOBODY void Randomize(void); +//private: +public: + friend class BotPhraseManager; + + char *m_name; + Place m_id; + bool m_isPlace; + GameEventType m_radioEvent; + bool m_isImportant; + +#if defined(_WIN32) && defined(HOOK_GAMEDLL) + int unknown_padding; +#endif // HOOK_GAMEDLL + + mutable BotVoiceBankVector m_voiceBank; + +#if defined(_WIN32) && defined(HOOK_GAMEDLL) + int unknown_padding2; +#endif // HOOK_GAMEDLL + + std::vector< int > m_count; + +#if defined(_WIN32) && defined(HOOK_GAMEDLL) + int unknown_padding3; +#endif // HOOK_GAMEDLL + + mutable std::vector< int > m_index; + + int m_numVoiceBanks; + mutable PlaceCriteria m_placeCriteria; + mutable CountCriteria m_countCriteria; + +};/* size: 68, cachelines: 2, members: 11 */ + +typedef std::list BotPhraseList; + +/* <2fea0e> ../cstrike/dlls/bot/cs_bot_chatter.h:239 */ +inline void BotPhrase::ClearCriteria(void) const +{ m_placeCriteria = ANY_PLACE; - m_countCriteria = UNDEFINED_COUNT; -} - -/* <2fea2a> ../cstrike/dlls/bot/cs_bot_chatter.h:245 */ + m_countCriteria = UNDEFINED_COUNT; +} + +/* <2fea2a> ../cstrike/dlls/bot/cs_bot_chatter.h:245 */ inline void BotPhrase::SetPlaceCriteria(PlaceCriteria place) const { m_placeCriteria = place; } /* <2fea52> ../cstrike/dlls/bot/cs_bot_chatter.h:250 */ -inline void BotPhrase::SetCountCriteria( CountCriteria count ) const +inline void BotPhrase::SetCountCriteria(CountCriteria count) const { m_countCriteria = count; -} - -// The BotPhraseManager is a singleton that provides an interface to all BotPhrase collections +} + +// The BotPhraseManager is a singleton that provides an interface to all BotPhrase collections class BotPhraseManager -{ -public: +{ +public: NOBODY BotPhraseManager(void); - NOBODY ~BotPhraseManager(void); - - // initialize phrase system from database file for a specific voice bank (0 is the default voice bank) - NOBODY bool Initialize(const char *filename, int bankIndex); - - // invoked when round resets - void OnRoundRestart(void); - - // invoked when map changes - NOBODY void OnMapChange(void); - Place NameToID(const char *name) const; - const char *IDToName(Place id) const; - - // given a name, return the associated phrase collection - NOBODY const BotPhrase *GetPhrase(const char *name) const; - - // given a name, return the associated Place phrase collection - NOBODY const BotPhrase *GetPlace(const char *name) const; - - // given an id, return the associated Place phrase collection - NOBODY const BotPhrase *GetPlace(PlaceCriteria place) const; - - const BotPhraseList *GetPlaceList(void) const - { - return &m_placeList; - } - - // return time last statement of given type was emitted by a teammate for the given place - float GetPlaceStatementInterval(Place place) const; - - // set time of last statement of given type was emitted by a teammate for the given place - void ResetPlaceStatementInterval(Place place) const; - + NOBODY ~BotPhraseManager(void); + + // initialize phrase system from database file for a specific voice bank (0 is the default voice bank) + NOBODY bool Initialize(const char *filename, int bankIndex); + + // invoked when round resets + void OnRoundRestart(void); + + // invoked when map changes + NOBODY void OnMapChange(void); + Place NameToID(const char *name) const; + const char *IDToName(Place id) const; + + // given a name, return the associated phrase collection + NOBODY const BotPhrase *GetPhrase(const char *name) const; + + // given a name, return the associated Place phrase collection + NOBODY const BotPhrase *GetPlace(const char *name) const; + + // given an id, return the associated Place phrase collection + NOBODY const BotPhrase *GetPlace(PlaceCriteria place) const; + + const BotPhraseList *GetPlaceList(void) const + { + return &m_placeList; + } + + // return time last statement of given type was emitted by a teammate for the given place + float GetPlaceStatementInterval(Place place) const; + + // set time of last statement of given type was emitted by a teammate for the given place + void ResetPlaceStatementInterval(Place place) const; + #ifndef HOOK_GAMEDLL private: #else public: #endif // HOOK_GAMEDLL - int FindPlaceIndex(Place where) const; - -#if defined(_WIN32) && defined(HOOK_GAMEDLL) - // The member m_placeList on Windows must be with offset +4 - // on Linux : +0 - int unknown_padding1; - -#endif // HOOK_GAMEDLL - - // master list of all phrase collections - BotPhraseList m_list; - -#if defined(_WIN32) && defined(HOOK_GAMEDLL) - // The member m_placeList on Windows must be with offset +16 - // on Linux : +8 - int unknown_padding2; - -#endif // HOOK_GAMEDLL - - // master list of all Place phrases - BotPhraseList m_placeList; - - struct PlaceTimeInfo - { - Place placeID; - IntervalTimer timer; - }; - mutable PlaceTimeInfo m_placeStatementHistory[ MAX_PLACES_PER_MAP ]; - mutable int m_placeCount; - -};/* size: 532, cachelines: 9, members: 4 */ - -/* <2fea95> ../cstrike/dlls/bot/cs_bot_chatter.h:298 */ -inline int BotPhraseManager::FindPlaceIndex(Place where) const -{ + int FindPlaceIndex(Place where) const; + +#if defined(_WIN32) && defined(HOOK_GAMEDLL) + // The member m_placeList on Windows must be with offset +4 + // on Linux : +0 + int unknown_padding1; + +#endif // HOOK_GAMEDLL + + // master list of all phrase collections + BotPhraseList m_list; + +#if defined(_WIN32) && defined(HOOK_GAMEDLL) + // The member m_placeList on Windows must be with offset +16 + // on Linux : +8 + int unknown_padding2; + +#endif // HOOK_GAMEDLL + + // master list of all Place phrases + BotPhraseList m_placeList; + + struct PlaceTimeInfo + { + Place placeID; + IntervalTimer timer; + }; + mutable PlaceTimeInfo m_placeStatementHistory[ MAX_PLACES_PER_MAP ]; + mutable int m_placeCount; + +};/* size: 532, cachelines: 9, members: 4 */ + +/* <2fea95> ../cstrike/dlls/bot/cs_bot_chatter.h:298 */ +inline int BotPhraseManager::FindPlaceIndex(Place where) const +{ for (int i = 0; i < m_placeCount; i++) { if (m_placeStatementHistory[i].placeID == where) @@ -373,10 +373,10 @@ inline int BotPhraseManager::FindPlaceIndex(Place where) const m_placeStatementHistory[++m_placeCount].timer.Invalidate(); return m_placeCount-1; } - return -1; -} - -/* <2ff83d> ../cstrike/dlls/bot/cs_bot_chatter.h:319 */ + return -1; +} + +/* <2ff83d> ../cstrike/dlls/bot/cs_bot_chatter.h:319 */ inline float BotPhraseManager::GetPlaceStatementInterval(Place place) const { int index = FindPlaceIndex(place); @@ -388,9 +388,9 @@ inline float BotPhraseManager::GetPlaceStatementInterval(Place place) const return 999999.9f; return m_placeStatementHistory[ index ].timer.GetElapsedTime(); -} - -/* <2ff876> ../cstrike/dlls/bot/cs_bot_chatter.h:335 */ +} + +/* <2ff876> ../cstrike/dlls/bot/cs_bot_chatter.h:335 */ inline void BotPhraseManager::ResetPlaceStatementInterval(Place place) const { int index = FindPlaceIndex(place); @@ -401,235 +401,235 @@ inline void BotPhraseManager::ResetPlaceStatementInterval(Place place) const return; m_placeStatementHistory[index].timer.Reset(); -} - -class BotStatement -{ -public: - NOBODY BotStatement(BotChatterInterface *chatter, BotStatementType type, float expireDuration); - NOBODY ~BotStatement(void); -public: - BotChatterInterface *GetChatter(void) const - { - return m_chatter; - } - NOBODY CCSBot *GetOwner(void) const; - BotStatementType GetType(void) const - { - return m_type; - } - NOBODY bool IsImportant(void) const; - bool HasSubject(void) const - { - return (m_subject != UNDEFINED_SUBJECT); - } - void SetSubject(int playerID) - { - m_subject = playerID; - } - int GetSubject(void) const - { - return m_subject; - } - bool HasPlace(void) const - { - return (GetPlace()) ? true : false; - } - NOBODY Place GetPlace(void) const; - void SetPlace(Place where) - { - m_place = where; - } - NOBODY bool HasCount(void) const; - NOBODY bool IsRedundant(const BotStatement *say) const; - NOBODY bool IsObsolete(void) const; - NOBODY void Convert(const BotStatement *say); - NOBODY void AppendPhrase(const BotPhrase *phrase); - void SetStartTime(float timestamp) - { - m_startTime = timestamp; - } - float GetStartTime(void) const - { - return m_startTime; - } - - enum ConditionType - { - IS_IN_COMBAT, - RADIO_SILENCE, - ENEMIES_REMAINING, - NUM_CONDITIONS, - }; - - NOBODY void AddCondition(ConditionType condition); - NOBODY bool IsValid(void) const; - - enum ContextType - { - CURRENT_ENEMY_COUNT, - REMAINING_ENEMY_COUNT, - SHORT_DELAY, - LONG_DELAY, - ACCUMULATE_ENEMIES_DELAY, - }; - NOBODY void AppendPhrase(ContextType contextPhrase); - - NOBODY bool Update(void); - NOBODY bool IsSpeaking(void) const - { - return m_isSpeaking; - } - NOBODY float GetTimestamp(void) const - { - return m_timestamp; - } - NOBODY void AttachMeme(BotMeme *meme); -public: - friend class BotChatterInterface; - - BotChatterInterface *m_chatter; - BotStatement *m_next; - BotStatement *m_prev; - BotStatementType m_type; - int m_subject; - Place m_place; - BotMeme *m_meme; - float m_timestamp; - float m_startTime; - float m_expireTime; - float m_speakTimestamp; - bool m_isSpeaking; - float m_nextTime; - - enum { MAX_BOT_PHRASES = 4 }; - struct - { - bool isPhrase; - union - { - const BotPhrase *phrase; - ContextType context; - }; - } m_statement[ MAX_BOT_PHRASES ]; - - enum { MAX_BOT_CONDITIONS = 4 }; - - ConditionType m_condition[ MAX_BOT_CONDITIONS ]; - int m_conditionCount; - int m_index; - int m_count; -};/* size: 112, cachelines: 2, members: 18 */ - -class BotChatterInterface -{ -public: - BotChatterInterface(void) { }; - - NOBODY BotChatterInterface(CCSBot *me); - NOBODY ~BotChatterInterface(); - - NOBODY void Reset(void); - NOBODY void Update(void); - - NOBODY void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - NOBODY void OnDeath(void); - - enum VerbosityType - { - NORMAL, - MINIMAL, - RADIO, - OFF, - }; - - VerbosityType GetVerbosity(void) const; - NOBODY CCSBot *GetOwner(void) const - { - return m_me; - } - bool IsTalking(void) const; - NOBODY float GetRadioSilenceDuration(void); - NOBODY void ResetRadioSilenceDuration(void); - - enum { MUST_ADD = 1 }; - - NOBODY void AddStatement(BotStatement *statement, bool mustAdd = false); - NOBODY void RemoveStatement(BotStatement *statement); - - NOBODY BotStatement *GetActiveStatement(void); - BotStatement *GetStatement(void) const; - - int GetPitch(void) const - { - return m_pitch; - } - - void Say(const char *phraseName, float lifetime = 3.0f, float delay = 0.0f); - - NOBODY void AnnouncePlan(const char *phraseName, Place place); - NOBODY void Affirmative(void); - NOBODY void Negative(void); - - NOBODY void EnemySpotted(void); - NOBODY void KilledMyEnemy(int victimID); - NOBODY void EnemiesRemaining(void); - - NOBODY void Clear(Place place); - NOBODY void ReportIn(void); - NOBODY void ReportingIn(void); - NOBODY bool NeedBackup(void); - NOBODY void PinnedDown(void); - NOBODY void Scared(void); - NOBODY void HeardNoise(const Vector *pos); - NOBODY void TheyPickedUpTheBomb(void); - NOBODY void GoingToPlantTheBomb(Place place); - NOBODY void BombsiteClear(int zoneIndex); - NOBODY void FoundPlantedBomb(int zoneIndex); - NOBODY void PlantingTheBomb(Place place); - NOBODY void SpottedBomber(CBasePlayer *bomber); - NOBODY void SpottedLooseBomb(CBaseEntity *bomb); - NOBODY void GuardingLooseBomb(CBaseEntity *bomb); - NOBODY void RequestBombLocation(void); - NOBODY void GuardingHostages(Place place, bool isPlan); - NOBODY void GuardingHostageEscapeZone(bool isPlan); - NOBODY void HostagesBeingTaken(void); - NOBODY void HostagesTaken(void); - NOBODY void TalkingToHostages(void); - NOBODY void EscortingHostages(void); - NOBODY void HostageDown(void); - NOBODY void CelebrateWin(void); - - NOBODY void Encourage(const char *phraseName, float repeatInterval = 10.0f, float lifetime = 3.0f); - NOBODY void KilledFriend(void); - NOBODY void FriendlyFire(void); -public: - static CountdownTimer m_encourageTimer; - static IntervalTimer m_radioSilenceInterval[2]; -private: - - NOBODY void ReportEnemies(void); - NOBODY bool ShouldSpeak(void) const; - - BotStatement *m_statementList; - CCSBot *m_me; - - bool m_seeAtLeastOneEnemy; - float m_timeWhenSawFirstEnemy; - bool m_reportedEnemies; - bool m_requestedBombLocation; - int m_pitch; - - IntervalTimer m_needBackupInterval; - IntervalTimer m_spottedBomberInterval; - IntervalTimer m_scaredInterval; - IntervalTimer m_planInterval; - CountdownTimer m_spottedLooseBombTimer; - CountdownTimer m_heardNoiseTimer; - CountdownTimer m_escortingHostageTimer; -};/* size: 64, cachelines: 1, members: 16 */ +} -/* <2fec2d> ../cstrike/dlls/bot/cs_bot_chatter.h:572 */ +class BotStatement +{ +public: + NOBODY BotStatement(BotChatterInterface *chatter, BotStatementType type, float expireDuration); + NOBODY ~BotStatement(void); +public: + BotChatterInterface *GetChatter(void) const + { + return m_chatter; + } + NOBODY CCSBot *GetOwner(void) const; + BotStatementType GetType(void) const + { + return m_type; + } + NOBODY bool IsImportant(void) const; + bool HasSubject(void) const + { + return (m_subject != UNDEFINED_SUBJECT); + } + void SetSubject(int playerID) + { + m_subject = playerID; + } + int GetSubject(void) const + { + return m_subject; + } + bool HasPlace(void) const + { + return (GetPlace()) ? true : false; + } + NOBODY Place GetPlace(void) const; + void SetPlace(Place where) + { + m_place = where; + } + NOBODY bool HasCount(void) const; + NOBODY bool IsRedundant(const BotStatement *say) const; + NOBODY bool IsObsolete(void) const; + NOBODY void Convert(const BotStatement *say); + NOBODY void AppendPhrase(const BotPhrase *phrase); + void SetStartTime(float timestamp) + { + m_startTime = timestamp; + } + float GetStartTime(void) const + { + return m_startTime; + } + + enum ConditionType + { + IS_IN_COMBAT, + RADIO_SILENCE, + ENEMIES_REMAINING, + NUM_CONDITIONS, + }; + + NOBODY void AddCondition(ConditionType condition); + NOBODY bool IsValid(void) const; + + enum ContextType + { + CURRENT_ENEMY_COUNT, + REMAINING_ENEMY_COUNT, + SHORT_DELAY, + LONG_DELAY, + ACCUMULATE_ENEMIES_DELAY, + }; + NOBODY void AppendPhrase(ContextType contextPhrase); + + NOBODY bool Update(void); + NOBODY bool IsSpeaking(void) const + { + return m_isSpeaking; + } + NOBODY float GetTimestamp(void) const + { + return m_timestamp; + } + NOBODY void AttachMeme(BotMeme *meme); +public: + friend class BotChatterInterface; + + BotChatterInterface *m_chatter; + BotStatement *m_next; + BotStatement *m_prev; + BotStatementType m_type; + int m_subject; + Place m_place; + BotMeme *m_meme; + float m_timestamp; + float m_startTime; + float m_expireTime; + float m_speakTimestamp; + bool m_isSpeaking; + float m_nextTime; + + enum { MAX_BOT_PHRASES = 4 }; + struct + { + bool isPhrase; + union + { + const BotPhrase *phrase; + ContextType context; + }; + } m_statement[ MAX_BOT_PHRASES ]; + + enum { MAX_BOT_CONDITIONS = 4 }; + + ConditionType m_condition[ MAX_BOT_CONDITIONS ]; + int m_conditionCount; + int m_index; + int m_count; +};/* size: 112, cachelines: 2, members: 18 */ + +class BotChatterInterface +{ +public: + BotChatterInterface(void) {}; + + NOBODY BotChatterInterface(CCSBot *me); + NOBODY ~BotChatterInterface(); + + NOBODY void Reset(void); + NOBODY void Update(void); + + NOBODY void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); + NOBODY void OnDeath(void); + + enum VerbosityType + { + NORMAL, + MINIMAL, + RADIO, + OFF, + }; + + VerbosityType GetVerbosity(void) const; + NOBODY CCSBot *GetOwner(void) const + { + return m_me; + } + bool IsTalking(void) const; + NOBODY float GetRadioSilenceDuration(void); + NOBODY void ResetRadioSilenceDuration(void); + + enum { MUST_ADD = 1 }; + + NOBODY void AddStatement(BotStatement *statement, bool mustAdd = false); + NOBODY void RemoveStatement(BotStatement *statement); + + NOBODY BotStatement *GetActiveStatement(void); + BotStatement *GetStatement(void) const; + + int GetPitch(void) const + { + return m_pitch; + } + + void Say(const char *phraseName, float lifetime = 3.0f, float delay = 0.0f); + + NOBODY void AnnouncePlan(const char *phraseName, Place place); + NOBODY void Affirmative(void); + NOBODY void Negative(void); + + NOBODY void EnemySpotted(void); + NOBODY void KilledMyEnemy(int victimID); + NOBODY void EnemiesRemaining(void); + + NOBODY void Clear(Place place); + NOBODY void ReportIn(void); + NOBODY void ReportingIn(void); + NOBODY bool NeedBackup(void); + NOBODY void PinnedDown(void); + NOBODY void Scared(void); + NOBODY void HeardNoise(const Vector *pos); + NOBODY void TheyPickedUpTheBomb(void); + NOBODY void GoingToPlantTheBomb(Place place); + NOBODY void BombsiteClear(int zoneIndex); + NOBODY void FoundPlantedBomb(int zoneIndex); + NOBODY void PlantingTheBomb(Place place); + NOBODY void SpottedBomber(CBasePlayer *bomber); + NOBODY void SpottedLooseBomb(CBaseEntity *bomb); + NOBODY void GuardingLooseBomb(CBaseEntity *bomb); + NOBODY void RequestBombLocation(void); + NOBODY void GuardingHostages(Place place, bool isPlan); + NOBODY void GuardingHostageEscapeZone(bool isPlan); + NOBODY void HostagesBeingTaken(void); + NOBODY void HostagesTaken(void); + NOBODY void TalkingToHostages(void); + NOBODY void EscortingHostages(void); + NOBODY void HostageDown(void); + NOBODY void CelebrateWin(void); + + NOBODY void Encourage(const char *phraseName, float repeatInterval = 10.0f, float lifetime = 3.0f); + NOBODY void KilledFriend(void); + NOBODY void FriendlyFire(void); +public: + static CountdownTimer m_encourageTimer; + static IntervalTimer m_radioSilenceInterval[2]; +private: + + NOBODY void ReportEnemies(void); + NOBODY bool ShouldSpeak(void) const; + + BotStatement *m_statementList; + CCSBot *m_me; + + bool m_seeAtLeastOneEnemy; + float m_timeWhenSawFirstEnemy; + bool m_reportedEnemies; + bool m_requestedBombLocation; + int m_pitch; + + IntervalTimer m_needBackupInterval; + IntervalTimer m_spottedBomberInterval; + IntervalTimer m_scaredInterval; + IntervalTimer m_planInterval; + CountdownTimer m_spottedLooseBombTimer; + CountdownTimer m_heardNoiseTimer; + CountdownTimer m_escortingHostageTimer; +};/* size: 64, cachelines: 1, members: 16 */ + +/* <2fec2d> ../cstrike/dlls/bot/cs_bot_chatter.h:572 */ inline BotChatterInterface::VerbosityType BotChatterInterface::GetVerbosity(void) const { const char *string = cv_bot_chatter.string; @@ -647,11 +647,11 @@ inline BotChatterInterface::VerbosityType BotChatterInterface::GetVerbosity(void return OFF; return NORMAL; -} - +} + /* <2fec4a> ../cstrike/dlls/bot/cs_bot_chatter.h:590 */ -inline bool BotChatterInterface::IsTalking(void) const -{ +inline bool BotChatterInterface::IsTalking(void) const +{ if (m_statementList) return m_statementList->IsSpeaking(); return false; diff --git a/regamedll/dlls/bot/cs_bot_event.cpp b/regamedll/dlls/bot/cs_bot_event.cpp index e2cf1f5a..96cf0375 100644 --- a/regamedll/dlls/bot/cs_bot_event.cpp +++ b/regamedll/dlls/bot/cs_bot_event.cpp @@ -114,4 +114,4 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe OnEvent_(event, entity, other); } -#endif // HOOK_GAMEDLL \ No newline at end of file +#endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/bot/cs_bot_init.cpp b/regamedll/dlls/bot/cs_bot_init.cpp index 0c1894bb..80d19e2d 100644 --- a/regamedll/dlls/bot/cs_bot_init.cpp +++ b/regamedll/dlls/bot/cs_bot_init.cpp @@ -20,37 +20,37 @@ void Bot_ServerCommand(void) /* <333cec> ../cstrike/dlls/bot/cs_bot_init.cpp:81 */ void Bot_RegisterCvars(void) { - if (UTIL_IsGame("czero")) - { - CVAR_REGISTER(&cv_bot_traceview); - CVAR_REGISTER(&cv_bot_stop); - CVAR_REGISTER(&cv_bot_show_nav); - CVAR_REGISTER(&cv_bot_show_danger); - CVAR_REGISTER(&cv_bot_nav_edit); - CVAR_REGISTER(&cv_bot_nav_zdraw); - CVAR_REGISTER(&cv_bot_walk); - CVAR_REGISTER(&cv_bot_difficulty); - CVAR_REGISTER(&cv_bot_debug); - CVAR_REGISTER(&cv_bot_quicksave); - CVAR_REGISTER(&cv_bot_quota); - CVAR_REGISTER(&cv_bot_quota_match); - CVAR_REGISTER(&cv_bot_prefix); - CVAR_REGISTER(&cv_bot_allow_rogues); - CVAR_REGISTER(&cv_bot_allow_pistols); - CVAR_REGISTER(&cv_bot_allow_shotguns); - CVAR_REGISTER(&cv_bot_allow_sub_machine_guns); - CVAR_REGISTER(&cv_bot_allow_rifles); - CVAR_REGISTER(&cv_bot_allow_machine_guns); - CVAR_REGISTER(&cv_bot_allow_grenades); - CVAR_REGISTER(&cv_bot_allow_snipers); - CVAR_REGISTER(&cv_bot_allow_shield); - CVAR_REGISTER(&cv_bot_join_team); - CVAR_REGISTER(&cv_bot_join_after_player); - CVAR_REGISTER(&cv_bot_auto_vacate); - CVAR_REGISTER(&cv_bot_zombie); - CVAR_REGISTER(&cv_bot_defer_to_human); - CVAR_REGISTER(&cv_bot_chatter); - CVAR_REGISTER(&cv_bot_profile_db); + if (UTIL_IsGame("czero")) + { + CVAR_REGISTER(&cv_bot_traceview); + CVAR_REGISTER(&cv_bot_stop); + CVAR_REGISTER(&cv_bot_show_nav); + CVAR_REGISTER(&cv_bot_show_danger); + CVAR_REGISTER(&cv_bot_nav_edit); + CVAR_REGISTER(&cv_bot_nav_zdraw); + CVAR_REGISTER(&cv_bot_walk); + CVAR_REGISTER(&cv_bot_difficulty); + CVAR_REGISTER(&cv_bot_debug); + CVAR_REGISTER(&cv_bot_quicksave); + CVAR_REGISTER(&cv_bot_quota); + CVAR_REGISTER(&cv_bot_quota_match); + CVAR_REGISTER(&cv_bot_prefix); + CVAR_REGISTER(&cv_bot_allow_rogues); + CVAR_REGISTER(&cv_bot_allow_pistols); + CVAR_REGISTER(&cv_bot_allow_shotguns); + CVAR_REGISTER(&cv_bot_allow_sub_machine_guns); + CVAR_REGISTER(&cv_bot_allow_rifles); + CVAR_REGISTER(&cv_bot_allow_machine_guns); + CVAR_REGISTER(&cv_bot_allow_grenades); + CVAR_REGISTER(&cv_bot_allow_snipers); + CVAR_REGISTER(&cv_bot_allow_shield); + CVAR_REGISTER(&cv_bot_join_team); + CVAR_REGISTER(&cv_bot_join_after_player); + CVAR_REGISTER(&cv_bot_auto_vacate); + CVAR_REGISTER(&cv_bot_zombie); + CVAR_REGISTER(&cv_bot_defer_to_human); + CVAR_REGISTER(&cv_bot_chatter); + CVAR_REGISTER(&cv_bot_profile_db); } } @@ -129,7 +129,7 @@ NOBODY void CCSBot::ResetValues(void) m_areaEnteredTimestamp = 0.0f; m_currentArea = NULL; m_lastKnownArea = NULL; - + m_avoidFriendTimer.Invalidate(); m_isFriendInTheWay = false; @@ -146,10 +146,10 @@ NOBODY void CCSBot::ResetValues(void) m_closestVisibleFriend = NULL; m_closestVisibleHumanFriend = NULL; - for (int w = 0; w < ARRAYSIZE(m_watchInfo); w++) - { - m_watchInfo[w].timestamp = 0.0f; - m_watchInfo[w].isEnemy = false; + for (int w = 0; w < ARRAYSIZE(m_watchInfo); w++) + { + m_watchInfo[w].timestamp = 0.0f; + m_watchInfo[w].isEnemy = false; } m_isEnemyVisible = false; @@ -227,8 +227,8 @@ NOBODY void CCSBot::ResetValues(void) m_taskEntity = NULL; m_approachPointCount = 0; - m_approachPointViewPosition = Vector(0, 0, 0); - + m_approachPointViewPosition = Vector(0, 0, 0); + m_checkedHidingSpotCount = 0; m_isJumpCrouching = false; @@ -241,7 +241,7 @@ NOBODY void CCSBot::ResetValues(void) m_huntState.ClearHuntArea(); - // adjust morale - if we died, our morale decreased, + // adjust morale - if we died, our morale decreased, // but if we live, no adjustement (round win/loss also adjusts morale if (m_diedLastRound) { @@ -284,27 +284,27 @@ void CCSBot::Disconnect(void) if (m_processMode) { - MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); - WRITE_BYTE(FLAG_PROGRESS_HIDE); + MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); + WRITE_BYTE(FLAG_PROGRESS_HIDE); MESSAGE_END(); } } #ifdef HOOK_GAMEDLL -bool CCSBot::Initialize(const BotProfile *profile) -{ - return Initialize_(profile); -} - -void CCSBot::SpawnBot(void) -{ - SpawnBot_(); +bool CCSBot::Initialize(const BotProfile *profile) +{ + return Initialize_(profile); } -void CCSBot::RoundRespawn(void) -{ - RoundRespawn_(); +void CCSBot::SpawnBot(void) +{ + SpawnBot_(); +} + +void CCSBot::RoundRespawn(void) +{ + RoundRespawn_(); } #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/bot/cs_bot_learn.cpp b/regamedll/dlls/bot/cs_bot_learn.cpp index 8f12816f..58ba9bd1 100644 --- a/regamedll/dlls/bot/cs_bot_learn.cpp +++ b/regamedll/dlls/bot/cs_bot_learn.cpp @@ -4,193 +4,193 @@ * Globals initialization */ #ifndef HOOK_GAMEDLL - + const float updateTimesliceDuration; -#else - +#else + const float updateTimesliceDuration = 0.0;//TODO: what value?? check it. #endif // HOOK_GAMEDLL -int _navAreaCount; +int _navAreaCount; int _currentIndex; -/* <343cbe> ../cstrike/dlls/bot/cs_bot_learn.cpp:95 */ -NOBODY inline class CNavNode *LadderEndSearch(CBaseEntity *entity, const Vector *pos, NavDirType mountDir) -{ -// { -// Vector center; // 97 -// { -// int d; // 103 -// { -// Vector tryPos; // 105 -// Vector tryNormal; // 118 -// float const fudge; // 123 -// TraceResult result; // 124 -// } -// } -// } +/* <343cbe> ../cstrike/dlls/bot/cs_bot_learn.cpp:95 */ +NOBODY inline class CNavNode *LadderEndSearch(CBaseEntity *entity, const Vector *pos, NavDirType mountDir) +{ +// { +// Vector center; // 97 +// { +// int d; // 103 +// { +// Vector tryPos; // 105 +// Vector tryNormal; // 118 +// float const fudge; // 123 +// TraceResult result; // 124 +// } +// } +// } } -/* <343a56> ../cstrike/dlls/bot/cs_bot_learn.cpp:30 */ -NOBODY CNavNode *CCSBot::AddNode(const Vector *destPos, const Vector *normal, NavDirType dir, CNavNode *source) -{ -// { -// class CNavNode *node; // 34 -// bool useNew; // 37 -// float const zTolerance; // 48 -// TraceResult result; // 63 -// Vector floor; // 64 -// Vector ceiling; // 64 -// bool crouch; // 65 -// MarkAsVisited(CNavNode *const this, -// enum NavDirType dir); // 52 -// { -// float y; // 66 -// { -// float x; // 68 -// } -// } -// SetAttributes(CNavNode *const this, -// unsigned char bits); // 89 -// } +/* <343a56> ../cstrike/dlls/bot/cs_bot_learn.cpp:30 */ +NOBODY CNavNode *CCSBot::AddNode(const Vector *destPos, const Vector *normal, NavDirType dir, CNavNode *source) +{ +// { +// class CNavNode *node; // 34 +// bool useNew; // 37 +// float const zTolerance; // 48 +// TraceResult result; // 63 +// Vector floor; // 64 +// Vector ceiling; // 64 +// bool crouch; // 65 +// MarkAsVisited(CNavNode *const this, +// enum NavDirType dir); // 52 +// { +// float y; // 66 +// { +// float x; // 68 +// } +// } +// SetAttributes(CNavNode *const this, +// unsigned char bits); // 89 +// } } -/* <343b40> ../cstrike/dlls/bot/cs_bot_learn.cpp:150 */ -NOXREF void drawProgressMeter(float progress, char *title) -{ +/* <343b40> ../cstrike/dlls/bot/cs_bot_learn.cpp:150 */ +NOXREF void drawProgressMeter(float progress, char *title) +{ MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); WRITE_BYTE(FLAG_PROGRESS_DRAW); - WRITE_BYTE((int)progress); + WRITE_BYTE((int)progress); WRITE_STRING(title); - MESSAGE_END(); -} + MESSAGE_END(); +} -/* <3435ce> ../cstrike/dlls/bot/cs_bot_learn.cpp:159 */ -NOXREF void startProgressMeter(const char *title) -{ +/* <3435ce> ../cstrike/dlls/bot/cs_bot_learn.cpp:159 */ +NOXREF void startProgressMeter(const char *title) +{ MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); WRITE_BYTE(FLAG_PROGRESS_START); WRITE_STRING(title); - MESSAGE_END(); -} - -/* <3435a8> ../cstrike/dlls/bot/cs_bot_learn.cpp:167 */ -NOXREF void hideProgressMeter(void) -{ + MESSAGE_END(); +} + +/* <3435a8> ../cstrike/dlls/bot/cs_bot_learn.cpp:167 */ +NOXREF void hideProgressMeter(void) +{ MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); WRITE_BYTE(FLAG_PROGRESS_HIDE); - MESSAGE_END(); -} - -/* <343b63> ../cstrike/dlls/bot/cs_bot_learn.cpp:182 */ -NOBODY void CCSBot::StartLearnProcess(void) -{ -// { -// Vector pos; // 192 -// Vector normal; // 195 -// startProgressMeter(const char *title); // 184 -// drawProgressMeter(float progress, -// char *title); // 185 -// Vector(Vector *const this, -// const Vector &v); // 192 -// SnapToGrid(Vector *pos); // 193 -// StartNormalProcess(CCSBot *const this); // 199 -// } + MESSAGE_END(); } -/* <343d37> ../cstrike/dlls/bot/cs_bot_learn.cpp:217 */ -NOBODY bool CCSBot::LearnStep(void) -{ -// { -// int dir; // 249 -// { -// float feetOffset; // 256 -// Vector pos; // 259 -// int cx; // 262 -// int cy; // 263 -// TraceResult result; // 283 -// Vector from; // 284 -// Vector to; // 284 -// Vector toNormal; // 289 -// Vector fromOrigin; // 298 -// Vector toOrigin; // 299 -// bool walkable; // 303 -// IsEntityWalkable(entvars_t *entity, -// unsigned int flags); // 362 -// { -// float toGround; // 309 -// float fromGround; // 310 -// float epsilon; // 312 -// { -// Vector delta; // 322 -// float const inc; // 323 -// float along; // 324 -// bool done; // 325 -// float ground; // 326 -// Vector normal; // 327 -// operator-(const Vector *const this, -// const Vector &v); // 322 -// { -// Vector p; // 333 -// operator*(const Vector *const this, -// float fl); // 343 -// operator+(const Vector *const this, -// const Vector &v); // 343 -// } -// } -// } -// VARS(edict_t *pent); // 362 -// GetFeetZ(const class CCSBot *const this); // 256 -// Vector(Vector *const this, -// const Vector &v); // 259 -// MarkAsVisited(CNavNode *const this, -// enum NavDirType dir); // 280 -// operator+(const Vector *const this, -// const Vector &v); // 294 -// operator+(const Vector *const this, -// const Vector &v); // 298 -// operator+(const Vector *const this, -// const Vector &v); // 299 -// { -// class CNavNode *newNode; // 376 -// AddNode(CCSBot *const this, -// const Vector *destPos, -// const Vector *normal, -// enum NavDirType dir, -// class CNavNode *source); // 376 -// } -// } -// HasVisited(CNavNode *const this, -// enum NavDirType dir); // 251 -// } -// { -// iterator iter; // 225 -// { -// class CNavLadder *ladder; // 227 -// LadderEndSearch(CBaseEntity *entity, -// const Vector *pos, -// enum NavDirType mountDir); // 230 -// LadderEndSearch(CBaseEntity *entity, -// const Vector *pos, -// enum NavDirType mountDir); // 234 -// } -// operator++(_List_iterator *const this); // 225 -// } +/* <343b63> ../cstrike/dlls/bot/cs_bot_learn.cpp:182 */ +NOBODY void CCSBot::StartLearnProcess(void) +{ +// { +// Vector pos; // 192 +// Vector normal; // 195 +// startProgressMeter(const char *title); // 184 +// drawProgressMeter(float progress, +// char *title); // 185 +// Vector(Vector *const this, +// const Vector &v); // 192 +// SnapToGrid(Vector *pos); // 193 +// StartNormalProcess(CCSBot *const this); // 199 +// } } -/* <34489e> ../cstrike/dlls/bot/cs_bot_learn.cpp:392 */ -NOBODY void CCSBot::UpdateLearnProcess(void) -{ -// { -// float startTime; // 394 -// } +/* <343d37> ../cstrike/dlls/bot/cs_bot_learn.cpp:217 */ +NOBODY bool CCSBot::LearnStep(void) +{ +// { +// int dir; // 249 +// { +// float feetOffset; // 256 +// Vector pos; // 259 +// int cx; // 262 +// int cy; // 263 +// TraceResult result; // 283 +// Vector from; // 284 +// Vector to; // 284 +// Vector toNormal; // 289 +// Vector fromOrigin; // 298 +// Vector toOrigin; // 299 +// bool walkable; // 303 +// IsEntityWalkable(entvars_t *entity, +// unsigned int flags); // 362 +// { +// float toGround; // 309 +// float fromGround; // 310 +// float epsilon; // 312 +// { +// Vector delta; // 322 +// float const inc; // 323 +// float along; // 324 +// bool done; // 325 +// float ground; // 326 +// Vector normal; // 327 +// operator-(const Vector *const this, +// const Vector &v); // 322 +// { +// Vector p; // 333 +// operator*(const Vector *const this, +// float fl); // 343 +// operator+(const Vector *const this, +// const Vector &v); // 343 +// } +// } +// } +// VARS(edict_t *pent); // 362 +// GetFeetZ(const class CCSBot *const this); // 256 +// Vector(Vector *const this, +// const Vector &v); // 259 +// MarkAsVisited(CNavNode *const this, +// enum NavDirType dir); // 280 +// operator+(const Vector *const this, +// const Vector &v); // 294 +// operator+(const Vector *const this, +// const Vector &v); // 298 +// operator+(const Vector *const this, +// const Vector &v); // 299 +// { +// class CNavNode *newNode; // 376 +// AddNode(CCSBot *const this, +// const Vector *destPos, +// const Vector *normal, +// enum NavDirType dir, +// class CNavNode *source); // 376 +// } +// } +// HasVisited(CNavNode *const this, +// enum NavDirType dir); // 251 +// } +// { +// iterator iter; // 225 +// { +// class CNavLadder *ladder; // 227 +// LadderEndSearch(CBaseEntity *entity, +// const Vector *pos, +// enum NavDirType mountDir); // 230 +// LadderEndSearch(CBaseEntity *entity, +// const Vector *pos, +// enum NavDirType mountDir); // 234 +// } +// operator++(_List_iterator *const this); // 225 +// } } -/* <344750> ../cstrike/dlls/bot/cs_bot_learn.cpp:409 */ -void CCSBot::StartAnalyzeAlphaProcess(void) -{ +/* <34489e> ../cstrike/dlls/bot/cs_bot_learn.cpp:392 */ +NOBODY void CCSBot::UpdateLearnProcess(void) +{ +// { +// float startTime; // 394 +// } +} + +/* <344750> ../cstrike/dlls/bot/cs_bot_learn.cpp:409 */ +void CCSBot::StartAnalyzeAlphaProcess(void) +{ m_processMode = PROCESS_ANALYZE_ALPHA; m_analyzeIter = TheNavAreaList.begin(); @@ -201,80 +201,80 @@ void CCSBot::StartAnalyzeAlphaProcess(void) DestroyHidingSpots(); startProgressMeter("#CZero_AnalyzingHidingSpots"); - drawProgressMeter(0, "#CZero_AnalyzingHidingSpots"); + drawProgressMeter(0, "#CZero_AnalyzingHidingSpots"); } -/* <34396c> ../cstrike/dlls/bot/cs_bot_learn.cpp:427 */ -NOBODY inline bool CCSBot::AnalyzeAlphaStep(void) -{ -// { -// class CNavArea *area; // 432 -// } +/* <34396c> ../cstrike/dlls/bot/cs_bot_learn.cpp:427 */ +NOBODY inline bool CCSBot::AnalyzeAlphaStep(void) +{ +// { +// class CNavArea *area; // 432 +// } } -/* <3448de> ../cstrike/dlls/bot/cs_bot_learn.cpp:443 */ -NOBODY void CCSBot::UpdateAnalyzeAlphaProcess(void) -{ -// { -// float startTime; // 445 -// float progress; // 462 -// AnalyzeAlphaStep(CCSBot *const this); // 451 -// drawProgressMeter(float progress, -// char *title); // 454 -// StartAnalyzeBetaProcess(CCSBot *const this); // 456 -// drawProgressMeter(float progress, -// char *title); // 463 -// } +/* <3448de> ../cstrike/dlls/bot/cs_bot_learn.cpp:443 */ +NOBODY void CCSBot::UpdateAnalyzeAlphaProcess(void) +{ +// { +// float startTime; // 445 +// float progress; // 462 +// AnalyzeAlphaStep(CCSBot *const this); // 451 +// drawProgressMeter(float progress, +// char *title); // 454 +// StartAnalyzeBetaProcess(CCSBot *const this); // 456 +// drawProgressMeter(float progress, +// char *title); // 463 +// } } -/* <344aed> ../cstrike/dlls/bot/cs_bot_learn.cpp:467 */ -NOBODY void CCSBot::StartAnalyzeBetaProcess(void) -{ -// size(const class list> *const this); // 471 +/* <344aed> ../cstrike/dlls/bot/cs_bot_learn.cpp:467 */ +NOBODY void CCSBot::StartAnalyzeBetaProcess(void) +{ +// size(const class list> *const this); // 471 } -/* <3437c8> ../cstrike/dlls/bot/cs_bot_learn.cpp:479 */ -NOBODY inline bool CCSBot::AnalyzeBetaStep(void) -{ -// { -// class CNavArea *area; // 484 -// } +/* <3437c8> ../cstrike/dlls/bot/cs_bot_learn.cpp:479 */ +NOBODY inline bool CCSBot::AnalyzeBetaStep(void) +{ +// { +// class CNavArea *area; // 484 +// } } -/* <344b8d> ../cstrike/dlls/bot/cs_bot_learn.cpp:495 */ -NOBODY void CCSBot::UpdateAnalyzeBetaProcess(void) -{ -// { -// float startTime; // 497 -// float progress; // 512 -// AnalyzeBetaStep(CCSBot *const this); // 503 -// drawProgressMeter(float progress, -// char *title); // 506 -// StartSaveProcess(CCSBot *const this); // 507 -// drawProgressMeter(float progress, -// char *title); // 513 -// } +/* <344b8d> ../cstrike/dlls/bot/cs_bot_learn.cpp:495 */ +NOBODY void CCSBot::UpdateAnalyzeBetaProcess(void) +{ +// { +// float startTime; // 497 +// float progress; // 512 +// AnalyzeBetaStep(CCSBot *const this); // 503 +// drawProgressMeter(float progress, +// char *title); // 506 +// StartSaveProcess(CCSBot *const this); // 507 +// drawProgressMeter(float progress, +// char *title); // 513 +// } } -/* <344d1f> ../cstrike/dlls/bot/cs_bot_learn.cpp:517 */ -NOBODY void CCSBot::StartSaveProcess(void) -{ -} - -/* <344d41> ../cstrike/dlls/bot/cs_bot_learn.cpp:527 */ -NOBODY void CCSBot::UpdateSaveProcess(void) -{ -// { -// char filename; // 530 -// char msg; // 538 -// char cmd; // 548 -// hideProgressMeter(void); // 542 -// StartNormalProcess(CCSBot *const this); // 545 -// } +/* <344d1f> ../cstrike/dlls/bot/cs_bot_learn.cpp:517 */ +NOBODY void CCSBot::StartSaveProcess(void) +{ } -/* <344e24> ../cstrike/dlls/bot/cs_bot_learn.cpp:554 */ -void CCSBot::StartNormalProcess(void) -{ - m_processMode = PROCESS_NORMAL; -} +/* <344d41> ../cstrike/dlls/bot/cs_bot_learn.cpp:527 */ +NOBODY void CCSBot::UpdateSaveProcess(void) +{ +// { +// char filename; // 530 +// char msg; // 538 +// char cmd; // 548 +// hideProgressMeter(void); // 542 +// StartNormalProcess(CCSBot *const this); // 545 +// } +} + +/* <344e24> ../cstrike/dlls/bot/cs_bot_learn.cpp:554 */ +void CCSBot::StartNormalProcess(void) +{ + m_processMode = PROCESS_NORMAL; +} diff --git a/regamedll/dlls/bot/cs_bot_listen.cpp b/regamedll/dlls/bot/cs_bot_listen.cpp index d7a37cb4..c40aae4f 100644 --- a/regamedll/dlls/bot/cs_bot_listen.cpp +++ b/regamedll/dlls/bot/cs_bot_listen.cpp @@ -29,7 +29,7 @@ NOBODY bool CCSBot::ShouldInvestigateNoise(float *retNoiseDist) } /* <354c8d> ../cstrike/dlls/bot/cs_bot_listen.cpp:104 */ -NOBODY bool CCSBot::CanHearNearbyEnemyGunfire( float range) +NOBODY bool CCSBot::CanHearNearbyEnemyGunfire(float range) { // { // float gunfireDistSq; // 125 diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index 4addd04a..19666788 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -7,39 +7,39 @@ CBotManager *TheBots = NULL; -cvar_t cv_bot_traceview = { "bot_traceview", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_stop = { "bot_stop", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_show_nav = { "bot_show_nav", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_show_danger = { "bot_show_danger", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_nav_edit = { "bot_nav_edit", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_nav_zdraw = { "bot_nav_zdraw", "4", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_walk = { "bot_walk", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_difficulty = { "bot_difficulty", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_debug = { "bot_debug", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_quicksave = { "bot_quicksave", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_quota = { "bot_quota", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_prefix = { "bot_prefix", "", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_rogues = { "bot_allow_rogues", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_pistols = { "bot_allow_pistols", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_shotguns = { "bot_allow_shotguns", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_sub_machine_guns = { "bot_allow_sub_machine_guns", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_rifles = { "bot_allow_rifles", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_machine_guns = { "bot_allow_machine_guns", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_grenades = { "bot_allow_grenades", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_snipers = { "bot_allow_snipers", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_shield = { "bot_allow_shield", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_join_team = { "bot_join_team", "any", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_join_after_player = { &unk_1EF09A, "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_auto_vacate = { "bot_auto_vacate", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_zombie = { "bot_zombie", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_defer_to_human = { "bot_defer_to_human", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_chatter = { "bot_chatter", "normal", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_traceview = { "bot_traceview", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_stop = { "bot_stop", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_show_nav = { "bot_show_nav", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_show_danger = { "bot_show_danger", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_nav_edit = { "bot_nav_edit", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_nav_zdraw = { "bot_nav_zdraw", "4", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_walk = { "bot_walk", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_difficulty = { "bot_difficulty", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_debug = { "bot_debug", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_quicksave = { "bot_quicksave", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_quota = { "bot_quota", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_prefix = { "bot_prefix", "", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_rogues = { "bot_allow_rogues", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_pistols = { "bot_allow_pistols", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_shotguns = { "bot_allow_shotguns", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_sub_machine_guns = { "bot_allow_sub_machine_guns", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_rifles = { "bot_allow_rifles", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_machine_guns = { "bot_allow_machine_guns", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_grenades = { "bot_allow_grenades", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_snipers = { "bot_allow_snipers", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_allow_shield = { "bot_allow_shield", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_join_team = { "bot_join_team", "any", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_join_after_player = { &unk_1EF09A, "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_auto_vacate = { "bot_auto_vacate", "1", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_zombie = { "bot_zombie", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_defer_to_human = { "bot_defer_to_human", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_chatter = { "bot_chatter", "normal", FCVAR_SERVER, 0.0f, NULL }; cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVAR_SERVER, 0.0f, NULL }; -float CCSBotManager::m_flNextCVarCheck; -bool CCSBotManager::m_isMapDataLoaded; -bool CCSBotManager::m_isLearningMap; +float CCSBotManager::m_flNextCVarCheck; +bool CCSBotManager::m_isMapDataLoaded; +bool CCSBotManager::m_isLearningMap; bool CCSBotManager::m_isAnalysisRequested; NavEditCmdType CCSBotManager::m_editCmd; @@ -47,39 +47,39 @@ NavEditCmdType CCSBotManager::m_editCmd; CBotManager *TheBots; -cvar_t cv_bot_traceview; -cvar_t cv_bot_stop; -cvar_t cv_bot_show_nav; -cvar_t cv_bot_show_danger; -cvar_t cv_bot_nav_edit; -cvar_t cv_bot_nav_zdraw; -cvar_t cv_bot_walk; -cvar_t cv_bot_difficulty; -cvar_t cv_bot_debug; -cvar_t cv_bot_quicksave; -cvar_t cv_bot_quota; -cvar_t cv_bot_quota_match; -cvar_t cv_bot_prefix; -cvar_t cv_bot_allow_rogues; -cvar_t cv_bot_allow_pistols; -cvar_t cv_bot_allow_shotguns; -cvar_t cv_bot_allow_sub_machine_guns; -cvar_t cv_bot_allow_rifles; -cvar_t cv_bot_allow_machine_guns; -cvar_t cv_bot_allow_grenades; -cvar_t cv_bot_allow_snipers; -cvar_t cv_bot_allow_shield; -cvar_t cv_bot_join_team; -cvar_t cv_bot_join_after_player; -cvar_t cv_bot_auto_vacate; -cvar_t cv_bot_zombie; -cvar_t cv_bot_defer_to_human; -cvar_t cv_bot_chatter; +cvar_t cv_bot_traceview; +cvar_t cv_bot_stop; +cvar_t cv_bot_show_nav; +cvar_t cv_bot_show_danger; +cvar_t cv_bot_nav_edit; +cvar_t cv_bot_nav_zdraw; +cvar_t cv_bot_walk; +cvar_t cv_bot_difficulty; +cvar_t cv_bot_debug; +cvar_t cv_bot_quicksave; +cvar_t cv_bot_quota; +cvar_t cv_bot_quota_match; +cvar_t cv_bot_prefix; +cvar_t cv_bot_allow_rogues; +cvar_t cv_bot_allow_pistols; +cvar_t cv_bot_allow_shotguns; +cvar_t cv_bot_allow_sub_machine_guns; +cvar_t cv_bot_allow_rifles; +cvar_t cv_bot_allow_machine_guns; +cvar_t cv_bot_allow_grenades; +cvar_t cv_bot_allow_snipers; +cvar_t cv_bot_allow_shield; +cvar_t cv_bot_join_team; +cvar_t cv_bot_join_after_player; +cvar_t cv_bot_auto_vacate; +cvar_t cv_bot_zombie; +cvar_t cv_bot_defer_to_human; +cvar_t cv_bot_chatter; cvar_t cv_bot_profile_db; -float (*CCSBotManager::pm_flNextCVarCheck); -bool (*CCSBotManager::pm_isMapDataLoaded); -bool (*CCSBotManager::pm_isLearningMap); +float (*CCSBotManager::pm_flNextCVarCheck); +bool (*CCSBotManager::pm_isMapDataLoaded); +bool (*CCSBotManager::pm_isLearningMap); bool (*CCSBotManager::pm_isAnalysisRequested); NavEditCmdType (*CCSBotManager::pm_editCmd); @@ -114,27 +114,27 @@ NOBODY CCSBotManager::CCSBotManager(void) /* <36b22a> ../cstrike/dlls/bot/cs_bot_manager.cpp:111 */ void CCSBotManager::__MAKE_VHOOK(RestartRound)(void) { - // extend - CBotManager::RestartRound(); - - SetLooseBomb(NULL); - m_isBombPlanted = false; - - m_bombDefuser = NULL; - m_earliestBombPlantTimestamp = gpGlobals->time + RANDOM_FLOAT(10, 30); - - IMPLEMENT_ARRAY(m_editCmd) = EDIT_NONE; - - ResetRadioMessageTimestamps(); - m_lastSeenEnemyTimestamp = -9999.9f; - m_roundStartTimestamp = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime"); - - // randomly decide if defensive team wants to "rush" as a whole - const float defenseRushChance = 33.3f; // 25.0f; - m_isDefenseRushing = (RANDOM_FLOAT(0, 100) <= defenseRushChance) ? true : false; - - TheBotPhrases->OnRoundRestart(); - + // extend + CBotManager::RestartRound(); + + SetLooseBomb(NULL); + m_isBombPlanted = false; + + m_bombDefuser = NULL; + m_earliestBombPlantTimestamp = gpGlobals->time + RANDOM_FLOAT(10, 30); + + IMPLEMENT_ARRAY(m_editCmd) = EDIT_NONE; + + ResetRadioMessageTimestamps(); + m_lastSeenEnemyTimestamp = -9999.9f; + m_roundStartTimestamp = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime"); + + // randomly decide if defensive team wants to "rush" as a whole + const float defenseRushChance = 33.3f; // 25.0f; + m_isDefenseRushing = (RANDOM_FLOAT(0, 100) <= defenseRushChance) ? true : false; + + TheBotPhrases->OnRoundRestart(); + m_isRoundOver = false; m_isRespawnStarted = false; m_canRespawn = true; @@ -176,17 +176,17 @@ bool CCSBotManager::IsWeaponUseable(CBasePlayerItem *item) const { int weaponClass = WeaponIDToWeaponClass(item->m_iId); - if ((!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) - || (!AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN) - || (!AllowRifles() && weaponClass == WEAPONCLASS_RIFLE) - //|| (!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) // TODO: already is checked shotguns! - || (!AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE) - || (!AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN) - || (!AllowTacticalShield() && item->m_iId == WEAPON_SHIELDGUN) - || (!AllowPistols() && weaponClass == WEAPONCLASS_PISTOL) - || (!AllowGrenades() && weaponClass == WEAPONCLASS_GRENADE)) - { - return false; + if ((!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) + || (!AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN) + || (!AllowRifles() && weaponClass == WEAPONCLASS_RIFLE) + //|| (!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) // TODO: already is checked shotguns! + || (!AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE) + || (!AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN) + || (!AllowTacticalShield() && item->m_iId == WEAPON_SHIELDGUN) + || (!AllowPistols() && weaponClass == WEAPONCLASS_PISTOL) + || (!AllowGrenades() && weaponClass == WEAPONCLASS_GRENADE)) + { + return false; } } @@ -248,46 +248,46 @@ void CCSBotManager::__MAKE_VHOOK(AddServerCommands)(void) if (UTIL_IsGame("czero")) { - AddServerCommand("bot_about"); - AddServerCommand("bot_add"); - AddServerCommand("bot_add_t"); - AddServerCommand("bot_add_ct"); - AddServerCommand("bot_kill"); - AddServerCommand("bot_kick"); - AddServerCommand("bot_knives_only"); - AddServerCommand("bot_pistols_only"); - AddServerCommand("bot_snipers_only"); - AddServerCommand("bot_all_weapons"); - AddServerCommand("entity_dump"); - AddServerCommand("bot_nav_delete"); - AddServerCommand("bot_nav_split"); - AddServerCommand("bot_nav_merge"); - AddServerCommand("bot_nav_mark"); - AddServerCommand("bot_nav_begin_area"); - AddServerCommand("bot_nav_end_area"); - AddServerCommand("bot_nav_connect"); - AddServerCommand("bot_nav_disconnect"); - AddServerCommand("bot_nav_splice"); - AddServerCommand("bot_nav_crouch"); - AddServerCommand("bot_nav_jump"); - AddServerCommand("bot_nav_precise"); - AddServerCommand("bot_nav_no_jump"); - AddServerCommand("bot_nav_analyze"); - AddServerCommand("bot_nav_strip"); - AddServerCommand("bot_nav_save"); - AddServerCommand("bot_nav_load"); - AddServerCommand("bot_nav_use_place"); - AddServerCommand("bot_nav_place_floodfill"); - AddServerCommand("bot_nav_place_pick"); - AddServerCommand("bot_nav_toggle_place_mode"); - AddServerCommand("bot_nav_toggle_place_painting"); - AddServerCommand("bot_goto_mark"); - AddServerCommand("bot_memory_usage"); - AddServerCommand("bot_nav_mark_unnamed"); - AddServerCommand("bot_nav_warp"); - AddServerCommand("bot_nav_corner_select"); - AddServerCommand("bot_nav_corner_raise"); - AddServerCommand("bot_nav_corner_lower"); + AddServerCommand("bot_about"); + AddServerCommand("bot_add"); + AddServerCommand("bot_add_t"); + AddServerCommand("bot_add_ct"); + AddServerCommand("bot_kill"); + AddServerCommand("bot_kick"); + AddServerCommand("bot_knives_only"); + AddServerCommand("bot_pistols_only"); + AddServerCommand("bot_snipers_only"); + AddServerCommand("bot_all_weapons"); + AddServerCommand("entity_dump"); + AddServerCommand("bot_nav_delete"); + AddServerCommand("bot_nav_split"); + AddServerCommand("bot_nav_merge"); + AddServerCommand("bot_nav_mark"); + AddServerCommand("bot_nav_begin_area"); + AddServerCommand("bot_nav_end_area"); + AddServerCommand("bot_nav_connect"); + AddServerCommand("bot_nav_disconnect"); + AddServerCommand("bot_nav_splice"); + AddServerCommand("bot_nav_crouch"); + AddServerCommand("bot_nav_jump"); + AddServerCommand("bot_nav_precise"); + AddServerCommand("bot_nav_no_jump"); + AddServerCommand("bot_nav_analyze"); + AddServerCommand("bot_nav_strip"); + AddServerCommand("bot_nav_save"); + AddServerCommand("bot_nav_load"); + AddServerCommand("bot_nav_use_place"); + AddServerCommand("bot_nav_place_floodfill"); + AddServerCommand("bot_nav_place_pick"); + AddServerCommand("bot_nav_toggle_place_mode"); + AddServerCommand("bot_nav_toggle_place_painting"); + AddServerCommand("bot_goto_mark"); + AddServerCommand("bot_memory_usage"); + AddServerCommand("bot_nav_mark_unnamed"); + AddServerCommand("bot_nav_warp"); + AddServerCommand("bot_nav_corner_select"); + AddServerCommand("bot_nav_corner_raise"); + AddServerCommand("bot_nav_corner_lower"); AddServerCommand("bot_nav_check_consistency"); } } @@ -300,22 +300,22 @@ void CCSBotManager::__MAKE_VHOOK(ServerDeactivate)(void) /* <36b5fa> ../cstrike/dlls/bot/cs_bot_manager.cpp:415 */ void CCSBotManager::__MAKE_VHOOK(ClientDisconnect)(CBasePlayer *pPlayer) -{ +{ if (!pPlayer || !pPlayer->IsBot()) - return; - + return; + CCSBot *pBot = static_cast(pPlayer); entvars_t *temp = VARS(pPlayer->edict()); - pBot->Disconnect(); - - if (pPlayer->pev->classname) - RemoveEntityHashValue(pPlayer->pev, STRING(pPlayer->pev->classname), CLASSNAME); - - FREE_PRIVATE(pPlayer->edict()); - - CBasePlayer *player = GetClassPtr((CBasePlayer *)temp); - AddEntityHashValue(player->pev, STRING(player->pev->classname), CLASSNAME); + pBot->Disconnect(); + + if (pPlayer->pev->classname) + RemoveEntityHashValue(pPlayer->pev, STRING(pPlayer->pev->classname), CLASSNAME); + + FREE_PRIVATE(pPlayer->edict()); + + CBasePlayer *player = GetClassPtr((CBasePlayer *)temp); + AddEntityHashValue(player->pev, STRING(player->pev->classname), CLASSNAME); player->pev->flags = FL_DORMANT; } @@ -328,7 +328,7 @@ void PrintAllEntities(void) if (!edict || FStringNull(edict->v.classname)) continue; - + CONSOLE_ECHO(" %s\n", STRING(edict->v.classname)); } } @@ -478,61 +478,61 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd) { PrintAllEntities(); } - else if (FStrEq(pcmd, "bot_nav_delete")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_DELETE; - } - else if (FStrEq(pcmd, "bot_nav_split")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SPLIT; - } - else if (FStrEq(pcmd, "bot_nav_merge")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MERGE; - } - else if (FStrEq(pcmd, "bot_nav_mark")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MARK; - } - else if (FStrEq(pcmd, "bot_nav_begin_area")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_BEGIN_AREA; - } - else if (FStrEq(pcmd, "bot_nav_end_area")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_END_AREA; - } - else if (FStrEq(pcmd, "bot_nav_connect")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_CONNECT; - } - else if (FStrEq(pcmd, "bot_nav_disconnect")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_DISCONNECT; - } - else if (FStrEq(pcmd, "bot_nav_splice")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SPLICE; - } - else if (FStrEq(pcmd, "bot_nav_crouch")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_CROUCH; - } - else if (FStrEq(pcmd, "bot_nav_jump")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_JUMP; - } - else if (FStrEq(pcmd, "bot_nav_precise")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_PRECISE; - } - else if (FStrEq(pcmd, "bot_nav_no_jump")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_NO_JUMP; - } - else if (FStrEq(pcmd, "bot_nav_analyze")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_isAnalysisRequested) = true; + else if (FStrEq(pcmd, "bot_nav_delete")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_DELETE; + } + else if (FStrEq(pcmd, "bot_nav_split")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SPLIT; + } + else if (FStrEq(pcmd, "bot_nav_merge")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MERGE; + } + else if (FStrEq(pcmd, "bot_nav_mark")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MARK; + } + else if (FStrEq(pcmd, "bot_nav_begin_area")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_BEGIN_AREA; + } + else if (FStrEq(pcmd, "bot_nav_end_area")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_END_AREA; + } + else if (FStrEq(pcmd, "bot_nav_connect")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_CONNECT; + } + else if (FStrEq(pcmd, "bot_nav_disconnect")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_DISCONNECT; + } + else if (FStrEq(pcmd, "bot_nav_splice")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SPLICE; + } + else if (FStrEq(pcmd, "bot_nav_crouch")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_CROUCH; + } + else if (FStrEq(pcmd, "bot_nav_jump")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_JUMP; + } + else if (FStrEq(pcmd, "bot_nav_precise")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_PRECISE; + } + else if (FStrEq(pcmd, "bot_nav_no_jump")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_NO_JUMP; + } + else if (FStrEq(pcmd, "bot_nav_analyze")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_isAnalysisRequested) = true; } else if (FStrEq(pcmd, "bot_nav_strip")) { @@ -609,23 +609,23 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd) } } } - else if (FStrEq(pcmd, "bot_nav_toggle_place_mode")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_TOGGLE_PLACE_MODE; - } - else if (FStrEq(pcmd, "bot_nav_place_floodfill")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_PLACE_FLOODFILL; - } - else if (FStrEq(pcmd, "bot_nav_place_pick")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_PLACE_PICK; - } - else if (FStrEq(pcmd, "bot_nav_toggle_place_painting")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_TOGGLE_PLACE_PAINTING; + else if (FStrEq(pcmd, "bot_nav_toggle_place_mode")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_TOGGLE_PLACE_MODE; } - else if (FStrEq(pcmd, "bot_goto_mark")) + else if (FStrEq(pcmd, "bot_nav_place_floodfill")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_PLACE_FLOODFILL; + } + else if (FStrEq(pcmd, "bot_nav_place_pick")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_PLACE_PICK; + } + else if (FStrEq(pcmd, "bot_nav_toggle_place_painting")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_TOGGLE_PLACE_PAINTING; + } + else if (FStrEq(pcmd, "bot_goto_mark")) { // tell the first bot we find to go to our marked area CNavArea *area = GetMarkedArea();// TODO: reverse me @@ -651,7 +651,7 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd) } } } - else if (FStrEq(pcmd, "bot_memory_usage")) + else if (FStrEq(pcmd, "bot_memory_usage")) { CONSOLE_ECHO("Memory usage:\n"); CONSOLE_ECHO(" %d bytes per bot\b", sizeof(CCSBot)); @@ -681,27 +681,27 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd) CONSOLE_ECHO(" Encounter Spot data = %d bytes\n", encounterMem); } - else if (FStrEq(pcmd, "bot_nav_mark_unnamed")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MARK_UNNAMED; - } - else if (FStrEq(pcmd, "bot_nav_warp")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_WARP_TO_MARK; - } - else if (FStrEq(pcmd, "bot_nav_corner_select")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SELECT_CORNER; - } - else if (FStrEq(pcmd, "bot_nav_corner_raise")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_RAISE_CORNER; - } - else if (FStrEq(pcmd, "bot_nav_corner_lower")) - { - IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_LOWER_CORNER; + else if (FStrEq(pcmd, "bot_nav_mark_unnamed")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MARK_UNNAMED; } - else if (FStrEq(pcmd, "bot_nav_check_consistency")) + else if (FStrEq(pcmd, "bot_nav_warp")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_WARP_TO_MARK; + } + else if (FStrEq(pcmd, "bot_nav_corner_select")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SELECT_CORNER; + } + else if (FStrEq(pcmd, "bot_nav_corner_raise")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_RAISE_CORNER; + } + else if (FStrEq(pcmd, "bot_nav_corner_lower")) + { + IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_LOWER_CORNER; + } + else if (FStrEq(pcmd, "bot_nav_check_consistency")) { if (CMD_ARGC() != 2) { @@ -721,17 +721,17 @@ NOBODY bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromCon const BotProfile *profile = NULL; - if (!isFromConsole || CMD_ARGC() < 2) + if (!isFromConsole || CMD_ARGC() < 2) { if (team == BOT_TEAM_ANY) { // if team not specified, check cv_bot_join_team cvar for preference - if (!Q_stricmp(cv_bot_join_team.string, "T")) - team = BOT_TEAM_T; - - else if (!Q_stricmp(cv_bot_join_team.string, "CT")) - team = BOT_TEAM_CT; - else + if (!Q_stricmp(cv_bot_join_team.string, "T")) + team = BOT_TEAM_T; + + else if (!Q_stricmp(cv_bot_join_team.string, "CT")) + team = BOT_TEAM_CT; + else { TeamName defaultTeam = SelectDefaultTeam(); @@ -761,17 +761,17 @@ NOBODY bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromCon if (mp && mp->IsCareer()) ignoreHumans = true; - if (UTIL_IsNameTaken(CMD_ARGV(1), ignoreHumans)) + if (UTIL_IsNameTaken(CMD_ARGV(1), ignoreHumans)) { CONSOLE_ECHO("Error - %s is already in the game.\n", CMD_ARGV(1)); return true; } - profile = TheBotProfiles->GetProfile(CMD_ARGV(1), team); - if (profile == NULL) - { - CONSOLE_ECHO("Error - no profile for '%s' exists.\n", CMD_ARGV(1)); - return true; + profile = TheBotProfiles->GetProfile(CMD_ARGV(1), team); + if (profile == NULL) + { + CONSOLE_ECHO("Error - no profile for '%s' exists.\n", CMD_ARGV(1)); + return true; } } @@ -834,7 +834,7 @@ void CCSBotManager::ValidateMapData(void) m_zoneCount = 0; m_gameScenario = SCENARIO_DEATHMATCH; - // Search all entities in the map and set the game type and + // Search all entities in the map and set the game type and // store all zones (bomb target, etc). CBaseEntity *entity = NULL; @@ -852,48 +852,48 @@ void CCSBotManager::ValidateMapData(void) if (FClassnameIs(entity->pev, "func_bomb_target")) { - found = true; + found = true; isLegacy = false; m_gameScenario = SCENARIO_DEFUSE_BOMB; } else if (FClassnameIs(entity->pev, "info_bomb_target")) { - found = true; + found = true; isLegacy = true; m_gameScenario = SCENARIO_DEFUSE_BOMB; } else if (FClassnameIs(entity->pev, "func_hostage_rescue")) { - found = true; + found = true; isLegacy = false; m_gameScenario = SCENARIO_RESCUE_HOSTAGES; } else if (FClassnameIs(entity->pev, "info_hostage_rescue")) { - found = true; + found = true; isLegacy = true; m_gameScenario = SCENARIO_RESCUE_HOSTAGES; } else if (FClassnameIs(entity->pev, "hostage_entity")) { - // some very old maps (ie: cs_assault) use info_player_start - // as rescue zones, so set the scenario if there are hostages + // some very old maps (ie: cs_assault) use info_player_start + // as rescue zones, so set the scenario if there are hostages // in the map m_gameScenario = SCENARIO_RESCUE_HOSTAGES; } else if (FClassnameIs(entity->pev, "func_vip_safetyzone")) { - found = true; + found = true; isLegacy = false; m_gameScenario = SCENARIO_ESCORT_VIP; } - if (found) + if (found) { if (m_zoneCount < MAX_ZONES) { @@ -913,7 +913,7 @@ void CCSBotManager::ValidateMapData(void) } } - // If there are no zones and the scenario is hostage rescue, + // If there are no zones and the scenario is hostage rescue, // use the info_player_start entities as rescue zones. if (m_zoneCount == 0 && m_gameScenario == SCENARIO_RESCUE_HOSTAGES) { @@ -939,20 +939,20 @@ void CCSBotManager::ValidateMapData(void) } // Collect nav areas that overlap each zone - for (i = 0; i < m_zoneCount; i++) + for (i = 0; i < m_zoneCount; i++) { Zone *zone = &m_zone[i]; - if (zone->m_isLegacy) + if (zone->m_isLegacy) { - const float legacyRange = 256.0f; - - zone->m_extent.lo.x = zone->m_center.x - legacyRange; - zone->m_extent.lo.y = zone->m_center.y - legacyRange; - zone->m_extent.lo.z = zone->m_center.z - legacyRange; - - zone->m_extent.hi.x = zone->m_center.x + legacyRange; - zone->m_extent.hi.y = zone->m_center.y + legacyRange; + const float legacyRange = 256.0f; + + zone->m_extent.lo.x = zone->m_center.x - legacyRange; + zone->m_extent.lo.y = zone->m_center.y - legacyRange; + zone->m_extent.lo.z = zone->m_center.z - legacyRange; + + zone->m_extent.hi.x = zone->m_center.x + legacyRange; + zone->m_extent.hi.y = zone->m_center.y + legacyRange; zone->m_extent.hi.z = zone->m_center.z + legacyRange; } else @@ -961,11 +961,11 @@ void CCSBotManager::ValidateMapData(void) zone->m_extent.hi = zone->m_entity->pev->absmax; } - // ensure Z overlap - const float zFudge = 50.0f; - - zone->m_areaCount = 0; - zone->m_extent.lo.z -= zFudge; + // ensure Z overlap + const float zFudge = 50.0f; + + zone->m_areaCount = 0; + zone->m_extent.lo.z -= zFudge; zone->m_extent.hi.z += zFudge; // build a list of nav areas that overlap this zone @@ -974,17 +974,17 @@ void CCSBotManager::ValidateMapData(void) CNavArea *area = (*iter); const Extent *areaExtent = area->GetExtent(); - if (areaExtent->hi.x >= zone->m_extent.lo.x && areaExtent->lo.x <= zone->m_extent.hi.x - && areaExtent->hi.y >= zone->m_extent.lo.y && areaExtent->lo.y <= zone->m_extent.hi.y - && areaExtent->hi.z >= zone->m_extent.lo.z && areaExtent->lo.z <= zone->m_extent.hi.z) - { - // area overlaps zone - zone->m_area[ zone->m_areaCount++ ] = area; - - if (zone->m_areaCount == MAX_ZONE_NAV_AREAS) - { - break; - } + if (areaExtent->hi.x >= zone->m_extent.lo.x && areaExtent->lo.x <= zone->m_extent.hi.x + && areaExtent->hi.y >= zone->m_extent.lo.y && areaExtent->lo.y <= zone->m_extent.hi.y + && areaExtent->hi.z >= zone->m_extent.lo.z && areaExtent->lo.z <= zone->m_extent.hi.z) + { + // area overlaps zone + zone->m_area[ zone->m_areaCount++ ] = area; + + if (zone->m_areaCount == MAX_ZONE_NAV_AREAS) + { + break; + } } } } @@ -1010,10 +1010,10 @@ NOBODY bool __declspec(naked) CCSBotManager::AddBot(const BotProfile *profile, B //if (team == BOT_TEAM_ANY) //{ // // if team not specified, check cv_bot_join_team cvar for preference - // if (!Q_stricmp(cv_bot_join_team.string, "T")) - // nTeamSlot = TERRORIST; - - // else if (!Q_stricmp(cv_bot_join_team.string, "CT")) + // if (!Q_stricmp(cv_bot_join_team.string, "T")) + // nTeamSlot = TERRORIST; + + // else if (!Q_stricmp(cv_bot_join_team.string, "CT")) // nTeamSlot = CT; //} //else if (team == BOT_TEAM_CT) @@ -1043,7 +1043,7 @@ NOBODY bool __declspec(naked) CCSBotManager::AddBot(const BotProfile *profile, B //if (pBot == NULL) //{ // return false; - //} + //} ////int nJoinedTeam; //ClientPutInServer(pBot->edict()); @@ -1162,6 +1162,7 @@ void CCSBotManager::__MAKE_VHOOK(OnEvent)(GameEventType event, CBaseEntity *enti default: break; } + CBotManager::OnEvent(event, entity, other); } @@ -1186,11 +1187,11 @@ NOBODY float CCSBotManager::GetBombTimeLeft(void) const /* <36bddb> ../cstrike/dlls/bot/cs_bot_manager.cpp:1547 */ void CCSBotManager::SetLooseBomb(CBaseEntity *bomb) { - m_looseBomb = bomb; - - if (bomb) - m_looseBombArea = TheNavAreaGrid.GetNearestNavArea(&bomb->pev->origin); - else + m_looseBomb = bomb; + + if (bomb) + m_looseBombArea = TheNavAreaGrid.GetNearestNavArea(&bomb->pev->origin); + else m_looseBombArea = NULL; } diff --git a/regamedll/dlls/bot/cs_bot_vision.cpp b/regamedll/dlls/bot/cs_bot_vision.cpp index dae694dd..452557df 100644 --- a/regamedll/dlls/bot/cs_bot_vision.cpp +++ b/regamedll/dlls/bot/cs_bot_vision.cpp @@ -2,16 +2,16 @@ // Used to update view angles to stay on a ladder -/* <3d8352> ../cstrike/dlls/bot/cs_bot_vision.cpp:16 */ -float StayOnLadderLine(CCSBot *me, const CNavLadder *ladder) -{ - // determine our facing - NavDirType faceDir = AngleToDirection( me->pev->v_angle.y ); - const float stiffness = 1.0f; - - // move toward ladder mount point - switch (faceDir) - { +/* <3d8352> ../cstrike/dlls/bot/cs_bot_vision.cpp:16 */ +float StayOnLadderLine(CCSBot *me, const CNavLadder *ladder) +{ + // determine our facing + NavDirType faceDir = AngleToDirection(me->pev->v_angle.y); + const float stiffness = 1.0f; + + // move toward ladder mount point + switch (faceDir) + { case NORTH: return stiffness * (ladder->m_top.x - me->pev->origin.x); case EAST: @@ -19,523 +19,523 @@ float StayOnLadderLine(CCSBot *me, const CNavLadder *ladder) case SOUTH: return -stiffness * (ladder->m_top.x - me->pev->origin.x); case WEST: - return -stiffness * (ladder->m_top.y - me->pev->origin.y); - } - - return 0.0f; + return -stiffness * (ladder->m_top.y - me->pev->origin.y); + } + + return 0.0f; } - -void (*pCCSBot__UpdateLookAngles)(void); - -/* <3d882c> ../cstrike/dlls/bot/cs_bot_vision.cpp:48 */ -void __declspec(naked) CCSBot::UpdateLookAngles(void) -{ - __asm - { - jmp pCCSBot__UpdateLookAngles - } - - //float stiffness; - //float damping; - - //if (IsAttacking()) - //{ - // damping = 30.0f; - // stiffness = 300.0f; - //} - //else + +void (*pCCSBot__UpdateLookAngles)(void); + +/* <3d882c> ../cstrike/dlls/bot/cs_bot_vision.cpp:48 */ +void __declspec(naked) CCSBot::UpdateLookAngles(void) +{ + __asm + { + jmp pCCSBot__UpdateLookAngles + } + + //float stiffness; + //float damping; + + //if (IsAttacking()) + //{ + // damping = 30.0f; + // stiffness = 300.0f; + //} + //else //{ // damping = 25.0f; - // stiffness = 200.0f; - //} - - //float useYaw = m_lookYaw; - //float usePitch = m_lookPitch; - - //const float deltaT = (long double)g_flBotCommandInterval; - //const float maxAccel = 3000.0f; - //const float lookAlongLadderRange = 100.0f; - //const float ladderPitch = 60.0f; - - //if (IsUsingLadder()) - //{ - // NavDirType faceDir = m_pathLadder->m_dir; - // Vector to = m_pathLadder->m_top - pev->origin; - // float idealYaw = UTIL_VecToYaw( to ); - - // if (m_pathLadderFaceIn) - // { - // faceDir = OppositeDirection( faceDir ); - // } - - // switch (m_pathLadderState) - // { - // case APPROACH_ASCENDING_LADDER: - // { - // Vector to = m_goalPosition - pev->origin; - // if (to.IsLengthLessThan( lookAlongLadderRange )) - // usePitch = -ladderPitch; - // useYaw = idealYaw; - // break; - // } - // case APPROACH_DESCENDING_LADDER: - // { - // Vector to = m_goalPosition - pev->origin; - // if (to.IsLengthLessThan( lookAlongLadderRange )) - // usePitch = ladderPitch; - // useYaw = idealYaw; - // break; - // } - // case FACE_ASCENDING_LADDER: - // { - // useYaw = idealYaw; - // usePitch = -ladderPitch; - // break; - // } - // case FACE_DESCENDING_LADDER: - // { - // useYaw = idealYaw; - // usePitch = ladderPitch; - // break; - // } - // case MOUNT_ASCENDING_LADDER: - // case ASCEND_LADDER: - // { - // useYaw = DirectionToAngle( faceDir ) + StayOnLadderLine(this, m_pathLadder); - // usePitch = -ladderPitch; - // break; - // } - // case MOUNT_DESCENDING_LADDER: - // case DESCEND_LADDER: - // { - // useYaw = DirectionToAngle( faceDir ) + StayOnLadderLine(this, m_pathLadder); - // usePitch = ladderPitch; - // break; - // } - // case DISMOUNT_ASCENDING_LADDER: - // case DISMOUNT_DESCENDING_LADDER: - // { - // useYaw = DirectionToAngle( faceDir ); - // break; - // } - // } - //} - - //// if almost at target angle, snap to it - //const float onTargetTolerance = 1.0f; - //float angleDiff = NormalizeAngle( useYaw - pev->v_angle.y ); - - //if (angleDiff < onTargetTolerance && angleDiff > -onTargetTolerance) - //{ - // m_lookYawVel = 0; - // pev->v_angle.y = useYaw; - //} - //else - //{ - // // simple angular spring/damper - // long double accel = (long double)(angleDiff * stiffness - m_lookYawVel * damping); - // //float_precision accel = (float_precision)(angleDiff * stiffness - m_lookYawVel * damping); - - // // limit rate - // if (accel > maxAccel) - // accel = maxAccel; - - // else if (accel < -maxAccel) - // accel = -maxAccel; - - // m_lookYawVel = m_lookYawVel + (deltaT * accel); - // pev->v_angle.y += (deltaT * m_lookYawVel); - //} - - //angleDiff = NormalizeAngle( usePitch - pev->v_angle.x ); - + // stiffness = 200.0f; + //} + + //float useYaw = m_lookYaw; + //float usePitch = m_lookPitch; + + //const float deltaT = (long double)g_flBotCommandInterval; + //const float maxAccel = 3000.0f; + //const float lookAlongLadderRange = 100.0f; + //const float ladderPitch = 60.0f; + + //if (IsUsingLadder()) + //{ + // NavDirType faceDir = m_pathLadder->m_dir; + // Vector to = m_pathLadder->m_top - pev->origin; + // float idealYaw = UTIL_VecToYaw(to); + + // if (m_pathLadderFaceIn) + // { + // faceDir = OppositeDirection(faceDir); + // } + + // switch (m_pathLadderState) + // { + // case APPROACH_ASCENDING_LADDER: + // { + // Vector to = m_goalPosition - pev->origin; + // if (to.IsLengthLessThan(lookAlongLadderRange)) + // usePitch = -ladderPitch; + // useYaw = idealYaw; + // break; + // } + // case APPROACH_DESCENDING_LADDER: + // { + // Vector to = m_goalPosition - pev->origin; + // if (to.IsLengthLessThan(lookAlongLadderRange)) + // usePitch = ladderPitch; + // useYaw = idealYaw; + // break; + // } + // case FACE_ASCENDING_LADDER: + // { + // useYaw = idealYaw; + // usePitch = -ladderPitch; + // break; + // } + // case FACE_DESCENDING_LADDER: + // { + // useYaw = idealYaw; + // usePitch = ladderPitch; + // break; + // } + // case MOUNT_ASCENDING_LADDER: + // case ASCEND_LADDER: + // { + // useYaw = DirectionToAngle(faceDir) + StayOnLadderLine(this, m_pathLadder); + // usePitch = -ladderPitch; + // break; + // } + // case MOUNT_DESCENDING_LADDER: + // case DESCEND_LADDER: + // { + // useYaw = DirectionToAngle(faceDir) + StayOnLadderLine(this, m_pathLadder); + // usePitch = ladderPitch; + // break; + // } + // case DISMOUNT_ASCENDING_LADDER: + // case DISMOUNT_DESCENDING_LADDER: + // { + // useYaw = DirectionToAngle(faceDir); + // break; + // } + // } + //} + + //// if almost at target angle, snap to it + //const float onTargetTolerance = 1.0f; + //float angleDiff = NormalizeAngle(useYaw - pev->v_angle.y); + + //if (angleDiff < onTargetTolerance && angleDiff > -onTargetTolerance) + //{ + // m_lookYawVel = 0; + // pev->v_angle.y = useYaw; + //} + //else + //{ + // // simple angular spring/damper + // long double accel = (long double)(angleDiff * stiffness - m_lookYawVel * damping); + // //float_precision accel = (float_precision)(angleDiff * stiffness - m_lookYawVel * damping); + + // // limit rate + // if (accel > maxAccel) + // accel = maxAccel; + + // else if (accel < -maxAccel) + // accel = -maxAccel; + + // m_lookYawVel = m_lookYawVel + (deltaT * accel); + // pev->v_angle.y += (deltaT * m_lookYawVel); + //} + + //angleDiff = NormalizeAngle(usePitch - pev->v_angle.x); + //// simple angular spring/damper - //// double the stiffness since pitch is only +/- 90 and yaw is +/- 180 - //float accel = 2.0f * stiffness * angleDiff - damping * m_lookPitchVel; - - //if (accel > maxAccel) - // accel = maxAccel; - - //else if (accel < -maxAccel) - // accel = -maxAccel; - - //m_lookPitchVel += (deltaT * accel); - //pev->v_angle.x += (deltaT * m_lookPitchVel); - - //// limit range - avoid gimbal lock - //if (pev->v_angle.x < -89.0f) - // pev->v_angle.x = -89.0f; - //else if (pev->v_angle.x > 89.0f) - // pev->v_angle.x = 89.0f; - - //pev->v_angle.z = 0.0f; + //// double the stiffness since pitch is only +/- 90 and yaw is +/- 180 + //float accel = 2.0f * stiffness * angleDiff - damping * m_lookPitchVel; + + //if (accel > maxAccel) + // accel = maxAccel; + + //else if (accel < -maxAccel) + // accel = -maxAccel; + + //m_lookPitchVel += (deltaT * accel); + //pev->v_angle.x += (deltaT * m_lookPitchVel); + + //// limit range - avoid gimbal lock + //if (pev->v_angle.x < -89.0f) + // pev->v_angle.x = -89.0f; + //else if (pev->v_angle.x > 89.0f) + // pev->v_angle.x = 89.0f; + + //pev->v_angle.z = 0.0f; } -/* <3d8c91> ../cstrike/dlls/bot/cs_bot_vision.cpp:238 */ -NOBODY bool CCSBot::__MAKE_VHOOK(IsVisible)(const Vector *pos, bool testFOV) const -{ -// { -// const Vector *eye; // 248 -// class CCSBotManager *ctrl; // 251 -// TraceResult result; // 256 -// GetEyePosition(const class CCSBot *const this); // 248 -// GetEyePosition(const class CCSBot *const this); // 252 -// } +/* <3d8c91> ../cstrike/dlls/bot/cs_bot_vision.cpp:238 */ +NOBODY bool CCSBot::__MAKE_VHOOK(IsVisible)(const Vector *pos, bool testFOV) const +{ +// { +// const Vector *eye; // 248 +// class CCSBotManager *ctrl; // 251 +// TraceResult result; // 256 +// GetEyePosition(const class CCSBot *const this); // 248 +// GetEyePosition(const class CCSBot *const this); // 252 +// } } -/* <3d8d9b> ../cstrike/dlls/bot/cs_bot_vision.cpp:269 */ -NOBODY bool CCSBot::__MAKE_VHOOK(IsVisible)(CBasePlayer *player, bool testFOV, unsigned char *visParts) const -{ -// { -// float const topOfHead; // 271 -// float const standFeet; // 272 -// float const crouchFeet; // 273 -// unsigned char testVisParts; // 274 -// Vector spot; // 283 -// class Vector2D dir; // 297 -// class Vector2D perp; // 299 -// float const edgeOffset; // 300 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 283 -// NormalizeInPlace(Vector2D *const this); // 298 -// } +/* <3d8d9b> ../cstrike/dlls/bot/cs_bot_vision.cpp:269 */ +NOBODY bool CCSBot::__MAKE_VHOOK(IsVisible)(CBasePlayer *player, bool testFOV, unsigned char *visParts) const +{ +// { +// float const topOfHead; // 271 +// float const standFeet; // 272 +// float const crouchFeet; // 273 +// unsigned char testVisParts; // 274 +// Vector spot; // 283 +// class Vector2D dir; // 297 +// class Vector2D perp; // 299 +// float const edgeOffset; // 300 +// Vector(Vector *const this, +// float X, +// float Y, +// float Z); // 283 +// NormalizeInPlace(Vector2D *const this); // 298 +// } } /* <3d8f9f> ../cstrike/dlls/bot/cs_bot_vision.cpp:302 */ -bool CCSBot::__MAKE_VHOOK(IsEnemyPartVisible)(VisiblePartType part) const -{ - if (!IsEnemyVisible()) - return false; - - return (m_visibleEnemyParts & part) != 0; +bool CCSBot::__MAKE_VHOOK(IsEnemyPartVisible)(VisiblePartType part) const +{ + if (!IsEnemyVisible()) + return false; + + return (m_visibleEnemyParts & part) != 0; } -/* <3d8f0d> ../cstrike/dlls/bot/cs_bot_vision.cpp:331 */ -void CCSBot::UpdateLookAt(void) +/* <3d8f0d> ../cstrike/dlls/bot/cs_bot_vision.cpp:331 */ +void CCSBot::UpdateLookAt(void) { Vector to = m_lookAtSpot - EyePosition(); - Vector idealAngle = UTIL_VecToAngles( to ); + Vector idealAngle = UTIL_VecToAngles(to); idealAngle.x = 360.0f - idealAngle.x; - SetLookAngles(idealAngle.y, idealAngle.x); -} - -/* <3d900c> ../cstrike/dlls/bot/cs_bot_vision.cpp:345 */ -void CCSBot::SetLookAt(const char *desc, const Vector *pos, PriorityType pri, float duration, bool clearIfClose, float angleTolerance) -{ - if (pos == NULL) - return; - - // if currently looking at a point in space with higher priority, ignore this request - if (m_lookAtSpotState != NOT_LOOKING_AT_SPOT && m_lookAtSpotPriority > pri) - return; - - // if already looking at this spot, just extend the time - const float tolerance = 10.0f; - if (m_lookAtSpotState != NOT_LOOKING_AT_SPOT && VectorsAreEqual( pos, &m_lookAtSpot, tolerance )) - { - m_lookAtSpotDuration = duration; - - if (m_lookAtSpotPriority < pri) - m_lookAtSpotPriority = pri; - } - else - { - // look at new spot - m_lookAtSpot = *pos; - m_lookAtSpotState = LOOK_TOWARDS_SPOT; - m_lookAtSpotDuration = duration; - m_lookAtSpotPriority = pri; - } - - m_lookAtSpotAngleTolerance = angleTolerance; - m_lookAtSpotClearIfClose = clearIfClose; - m_lookAtDesc = desc; + SetLookAngles(idealAngle.y, idealAngle.x); } -/* <3d90a7> ../cstrike/dlls/bot/cs_bot_vision.cpp:383 */ -NOBODY void CCSBot::InhibitLookAround(float duration) -{ -} +/* <3d900c> ../cstrike/dlls/bot/cs_bot_vision.cpp:345 */ +void CCSBot::SetLookAt(const char *desc, const Vector *pos, PriorityType pri, float duration, bool clearIfClose, float angleTolerance) +{ + if (pos == NULL) + return; -/* <3d90d3> ../cstrike/dlls/bot/cs_bot_vision.cpp:392 */ -NOBODY void CCSBot::UpdatePeripheralVision(void) -{ -// { -// float const peripheralUpdateInterval; // 394 -// { -// const class SpotOrder *spotOrder; // 403 -// Vector pos; // 404 -// { -// const_iterator iter; // 406 -// end(list> *const this); // 406 -// operator++(_List_const_iterator *const this); // 406 -// { -// const Vector *spotPos;// 410 -// } -// } -// } -// } + // if currently looking at a point in space with higher priority, ignore this request + if (m_lookAtSpotState != NOT_LOOKING_AT_SPOT && m_lookAtSpotPriority > pri) + return; + + // if already looking at this spot, just extend the time + const float tolerance = 10.0f; + if (m_lookAtSpotState != NOT_LOOKING_AT_SPOT && VectorsAreEqual(pos, &m_lookAtSpot, tolerance)) + { + m_lookAtSpotDuration = duration; + + if (m_lookAtSpotPriority < pri) + m_lookAtSpotPriority = pri; + } + else + { + // look at new spot + m_lookAtSpot = *pos; + m_lookAtSpotState = LOOK_TOWARDS_SPOT; + m_lookAtSpotDuration = duration; + m_lookAtSpotPriority = pri; + } + + m_lookAtSpotAngleTolerance = angleTolerance; + m_lookAtSpotClearIfClose = clearIfClose; + m_lookAtDesc = desc; } -/* <3d91af> ../cstrike/dlls/bot/cs_bot_vision.cpp:429 */ -NOBODY void CCSBot::UpdateLookAround(bool updateNow) -{ -// { -// float const noiseStartleRange; // 439 -// float const recentThreatTime; // 456 -// { -// Vector spot; // 442 -// Vector(Vector *const this, -// const Vector &v); // 442 -// InhibitLookAround(CCSBot *const this, -// float duration); // 448 -// } -// IsLookingAtSpot(const class CCSBot *const this, -// enum PriorityType pri); // 457 -// { -// Vector spot; // 461 -// Vector(Vector *const this, -// const Vector &v); // 461 -// ClearLookAt(CCSBot *const this); // 459 -// } -// IsNotMoving(const class CCSBot *const this); // 481 -// { -// int which; // 521 -// Vector spot; // 522 -// IsViewMoving(const class CCSBot *const this, -// float angleVelThreshold); // 489 -// { -// float range; // 491 -// } -// GetZoomLevel(const class CCSBot *const this); // 497 -// ClearLookAt(CCSBot *const this); // 517 -// Vector(Vector *const this, -// const Vector &v); // 522 -// } -// IsLookingAtSpot(const class CCSBot *const this, -// enum PriorityType pri); // 541 -// { -// float asleep; // 550 -// Vector delta; // 558 -// float length; // 559 -// float adx; // 560 -// float ady; // 561 -// float t; // 562 -// float const leadCheckRange; // 570 -// class HidingSpot *dangerSpot; // 580 -// int dangerSpotCount; // 581 -// int dangerIndex; // 582 -// float const checkTime; // 584 -// const class SpotOrder *spotOrder; // 585 -// operator-(const Vector *const this, -// const Vector &v); // 558 -// Length(const Vector *const this); // 559 -// { -// iterator iter; // 586 -// end(list> *const this); // 586 -// operator++(_List_iterator *const this); // 586 -// } -// { -// int which; // 607 -// const Vector *checkSpot; // 608 -// Vector pos; // 610 -// operator+(const Vector *const this, -// const Vector &v); // 610 -// } -// } -// } +/* <3d90a7> ../cstrike/dlls/bot/cs_bot_vision.cpp:383 */ +NOBODY void CCSBot::InhibitLookAround(float duration) +{ } -/* <3d9618> ../cstrike/dlls/bot/cs_bot_vision.cpp:628 */ -NOBODY bool CCSBot::BendLineOfSight(Vector *eye, const Vector *point, Vector *bend) -{ -// { -// TraceResult result; // 631 -// Vector v; // 641 -// float startAngle; // 642 -// float length; // 643 -// float const angleInc; // 645 -// operator+(const Vector *const this, -// const Vector &v); // 632 -// Length2D(const Vector *const this); // 643 -// operator-(const Vector *const this, -// const Vector &v); // 641 -// { -// float angle; // 646 -// { -// int side; // 649 -// { -// float actualAngle; // 651 -// float dx; // 653 -// float dy; // 654 -// Vector rotPoint; // 657 -// TraceResult result; // 660 -// Vector ray; // 667 -// float rayLength; // 668 -// float visibleLength; // 669 -// float const bendStepSize; // 672 -// operator+(const Vector *const this, -// const Vector &v); // 661 -// operator-(const Vector *const this, -// const Vector &v); // 667 -// NormalizeInPlace(Vector *const this); // 668 -// { -// float bendLength; // 673 -// { -// Vector rayPoint; // 676 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 676 -// operator+(const Vector *const this, -// const Vector &v); // 679 -// } -// } -// } -// } -// } -// } +/* <3d90d3> ../cstrike/dlls/bot/cs_bot_vision.cpp:392 */ +NOBODY void CCSBot::UpdatePeripheralVision(void) +{ +// { +// float const peripheralUpdateInterval; // 394 +// { +// const class SpotOrder *spotOrder; // 403 +// Vector pos; // 404 +// { +// const_iterator iter; // 406 +// end(list> *const this); // 406 +// operator++(_List_const_iterator *const this); // 406 +// { +// const Vector *spotPos;// 410 +// } +// } +// } +// } } -/* <3d99e8> ../cstrike/dlls/bot/cs_bot_vision.cpp:707 */ -NOBODY CBasePlayer *CCSBot::FindMostDangerousThreat(void) -{ -// { -// class CloseInfo threat; // 715 -// int threatCount; // 716 -// float closeFriendRange; // 721 -// float closeHumanFriendRange; // 724 -// int i; // 726 -// int prevEnemies; // 835 -// int prevFriends; // 836 -// class PlaceRank placeRank; // 869 -// int locCount; // 870 -// class PlaceRank common; // 872 -// { -// class CBaseEntity *entity; // 729 -// class CBasePlayer *player; // 744 -// int idx; // 792 -// Vector d; // 801 -// float distSq; // 802 -// FNullEnt(entvars_t *pev); // 734 -// { -// int j; // 814 -// { -// int k; // 822 -// } -// } -// entindex(CBaseEntity *const this); // 747 -// entindex(CBaseEntity *const this); // 747 -// { -// TraceResult result; // 758 -// GetEyePosition(const class CCSBot *const this); // 759 -// { -// int idx; // 763 -// Vector to; // 768 -// float rangeSq; // 769 -// entindex(CBaseEntity *const this); // 763 -// operator-(const Vector *const this, -// const Vector &v); // 768 -// LengthSquared(const Vector *const this); // 769 -// } -// } -// entindex(CBaseEntity *const this); // 792 -// operator-(const Vector *const this, -// const Vector &v); // 801 -// LengthSquared(const Vector *const this); // 802 -// } -// { -// float const recentTime; // 844 -// } -// { -// class CNavArea *area; // 879 -// unsigned int threatLoc; // 888 -// int j; // 893 -// } -// { -// int t; // 948 -// IsProtectedByShield(CBasePlayer *const this); // 949 -// } -// } +/* <3d91af> ../cstrike/dlls/bot/cs_bot_vision.cpp:429 */ +NOBODY void CCSBot::UpdateLookAround(bool updateNow) +{ +// { +// float const noiseStartleRange; // 439 +// float const recentThreatTime; // 456 +// { +// Vector spot; // 442 +// Vector(Vector *const this, +// const Vector &v); // 442 +// InhibitLookAround(CCSBot *const this, +// float duration); // 448 +// } +// IsLookingAtSpot(const class CCSBot *const this, +// enum PriorityType pri); // 457 +// { +// Vector spot; // 461 +// Vector(Vector *const this, +// const Vector &v); // 461 +// ClearLookAt(CCSBot *const this); // 459 +// } +// IsNotMoving(const class CCSBot *const this); // 481 +// { +// int which; // 521 +// Vector spot; // 522 +// IsViewMoving(const class CCSBot *const this, +// float angleVelThreshold); // 489 +// { +// float range; // 491 +// } +// GetZoomLevel(const class CCSBot *const this); // 497 +// ClearLookAt(CCSBot *const this); // 517 +// Vector(Vector *const this, +// const Vector &v); // 522 +// } +// IsLookingAtSpot(const class CCSBot *const this, +// enum PriorityType pri); // 541 +// { +// float asleep; // 550 +// Vector delta; // 558 +// float length; // 559 +// float adx; // 560 +// float ady; // 561 +// float t; // 562 +// float const leadCheckRange; // 570 +// class HidingSpot *dangerSpot; // 580 +// int dangerSpotCount; // 581 +// int dangerIndex; // 582 +// float const checkTime; // 584 +// const class SpotOrder *spotOrder; // 585 +// operator-(const Vector *const this, +// const Vector &v); // 558 +// Length(const Vector *const this); // 559 +// { +// iterator iter; // 586 +// end(list> *const this); // 586 +// operator++(_List_iterator *const this); // 586 +// } +// { +// int which; // 607 +// const Vector *checkSpot; // 608 +// Vector pos; // 610 +// operator+(const Vector *const this, +// const Vector &v); // 610 +// } +// } +// } } -/* <3d9f7d> ../cstrike/dlls/bot/cs_bot_vision.cpp:960 */ -NOBODY void CCSBot::UpdateReactionQueue(void) -{ -// { -// class CBasePlayer *threat; // 967 -// int now; // 969 -// float reactionTime; // 994 -// float maxReactionTime; // 995 -// int reactionTimeSteps; // 1000 -// int i; // 1002 -// IsReloading(CBasePlayer *const this); // 975 -// IsProtectedByShield(CBasePlayer *const this); // 976 -// } +/* <3d9618> ../cstrike/dlls/bot/cs_bot_vision.cpp:628 */ +NOBODY bool CCSBot::BendLineOfSight(Vector *eye, const Vector *point, Vector *bend) +{ +// { +// TraceResult result; // 631 +// Vector v; // 641 +// float startAngle; // 642 +// float length; // 643 +// float const angleInc; // 645 +// operator+(const Vector *const this, +// const Vector &v); // 632 +// Length2D(const Vector *const this); // 643 +// operator-(const Vector *const this, +// const Vector &v); // 641 +// { +// float angle; // 646 +// { +// int side; // 649 +// { +// float actualAngle; // 651 +// float dx; // 653 +// float dy; // 654 +// Vector rotPoint; // 657 +// TraceResult result; // 660 +// Vector ray; // 667 +// float rayLength; // 668 +// float visibleLength; // 669 +// float const bendStepSize; // 672 +// operator+(const Vector *const this, +// const Vector &v); // 661 +// operator-(const Vector *const this, +// const Vector &v); // 667 +// NormalizeInPlace(Vector *const this); // 668 +// { +// float bendLength; // 673 +// { +// Vector rayPoint; // 676 +// Vector(Vector *const this, +// float X, +// float Y, +// float Z); // 676 +// operator+(const Vector *const this, +// const Vector &v); // 679 +// } +// } +// } +// } +// } +// } } -/* <3da052> ../cstrike/dlls/bot/cs_bot_vision.cpp:1013 */ -CBasePlayer *CCSBot::GetRecognizedEnemy(void) -{ - if (m_enemyQueueAttendIndex >= m_enemyQueueCount) - return NULL; - - return (CBasePlayer *)((CBaseEntity *)m_enemyQueue[ m_enemyQueueAttendIndex ].player); +/* <3d99e8> ../cstrike/dlls/bot/cs_bot_vision.cpp:707 */ +NOBODY CBasePlayer *CCSBot::FindMostDangerousThreat(void) +{ +// { +// class CloseInfo threat; // 715 +// int threatCount; // 716 +// float closeFriendRange; // 721 +// float closeHumanFriendRange; // 724 +// int i; // 726 +// int prevEnemies; // 835 +// int prevFriends; // 836 +// class PlaceRank placeRank; // 869 +// int locCount; // 870 +// class PlaceRank common; // 872 +// { +// class CBaseEntity *entity; // 729 +// class CBasePlayer *player; // 744 +// int idx; // 792 +// Vector d; // 801 +// float distSq; // 802 +// FNullEnt(entvars_t *pev); // 734 +// { +// int j; // 814 +// { +// int k; // 822 +// } +// } +// entindex(CBaseEntity *const this); // 747 +// entindex(CBaseEntity *const this); // 747 +// { +// TraceResult result; // 758 +// GetEyePosition(const class CCSBot *const this); // 759 +// { +// int idx; // 763 +// Vector to; // 768 +// float rangeSq; // 769 +// entindex(CBaseEntity *const this); // 763 +// operator-(const Vector *const this, +// const Vector &v); // 768 +// LengthSquared(const Vector *const this); // 769 +// } +// } +// entindex(CBaseEntity *const this); // 792 +// operator-(const Vector *const this, +// const Vector &v); // 801 +// LengthSquared(const Vector *const this); // 802 +// } +// { +// float const recentTime; // 844 +// } +// { +// class CNavArea *area; // 879 +// unsigned int threatLoc; // 888 +// int j; // 893 +// } +// { +// int t; // 948 +// IsProtectedByShield(CBasePlayer *const this); // 949 +// } +// } } -/* <3da075> ../cstrike/dlls/bot/cs_bot_vision.cpp:1025 */ -NOBODY bool CCSBot::IsRecognizedEnemyReloading(void) -{ -} - -/* <3da09d> ../cstrike/dlls/bot/cs_bot_vision.cpp:1037 */ -NOBODY bool CCSBot::IsRecognizedEnemyProtectedByShield(void) -{ +/* <3d9f7d> ../cstrike/dlls/bot/cs_bot_vision.cpp:960 */ +NOBODY void CCSBot::UpdateReactionQueue(void) +{ +// { +// class CBasePlayer *threat; // 967 +// int now; // 969 +// float reactionTime; // 994 +// float maxReactionTime; // 995 +// int reactionTimeSteps; // 1000 +// int i; // 1002 +// IsReloading(CBasePlayer *const this); // 975 +// IsProtectedByShield(CBasePlayer *const this); // 976 +// } } -/* <3da0c5> ../cstrike/dlls/bot/cs_bot_vision.cpp:1049 */ -NOBODY float CCSBot::GetRangeToNearestRecognizedEnemy(void) -{ -// { -// const class CBasePlayer *enemy; // 1051 -// GetRecognizedEnemy(CCSBot *const this); // 1051 -// operator-(const Vector *const this, -// const Vector &v); // 1054 -// Length(const Vector *const this); // 1054 -// } +/* <3da052> ../cstrike/dlls/bot/cs_bot_vision.cpp:1013 */ +CBasePlayer *CCSBot::GetRecognizedEnemy(void) +{ + if (m_enemyQueueAttendIndex >= m_enemyQueueCount) + return NULL; + + return (CBasePlayer *)((CBaseEntity *)m_enemyQueue[ m_enemyQueueAttendIndex ].player); } - -/* <3da170> ../cstrike/dlls/bot/cs_bot_vision.cpp:1063 */ -NOBODY void CCSBot::__MAKE_VHOOK(Blind)(float duration, float holdTime, float fadeTime, int alpha) -{ -// Say(BotChatterInterface *const this, -// const char *phraseName, -// float lifetime, -// float delay); // 1091 + +/* <3da075> ../cstrike/dlls/bot/cs_bot_vision.cpp:1025 */ +NOBODY bool CCSBot::IsRecognizedEnemyReloading(void) +{ +} + +/* <3da09d> ../cstrike/dlls/bot/cs_bot_vision.cpp:1037 */ +NOBODY bool CCSBot::IsRecognizedEnemyProtectedByShield(void) +{ +} + +/* <3da0c5> ../cstrike/dlls/bot/cs_bot_vision.cpp:1049 */ +NOBODY float CCSBot::GetRangeToNearestRecognizedEnemy(void) +{ +// { +// const class CBasePlayer *enemy; // 1051 +// GetRecognizedEnemy(CCSBot *const this); // 1051 +// operator-(const Vector *const this, +// const Vector &v); // 1054 +// Length(const Vector *const this); // 1054 +// } +} + +/* <3da170> ../cstrike/dlls/bot/cs_bot_vision.cpp:1063 */ +NOBODY void CCSBot::__MAKE_VHOOK(Blind)(float duration, float holdTime, float fadeTime, int alpha) +{ +// Say(BotChatterInterface *const this, +// const char *phraseName, +// float lifetime, +// float delay); // 1091 } #ifdef HOOK_GAMEDLL -void CCSBot::Blind(float duration, float holdTime, float fadeTime, int alpha) -{ - Blind_(duration, holdTime, fadeTime, alpha); +void CCSBot::Blind(float duration, float holdTime, float fadeTime, int alpha) +{ + Blind_(duration, holdTime, fadeTime, alpha); } -bool CCSBot::IsVisible(const Vector *pos, bool testFOV) const -{ - return IsVisible_(pos, testFOV); -} -bool CCSBot::IsVisible(CBasePlayer *player, bool testFOV, unsigned char *visParts) const -{ - return IsVisible_(player, testFOV, visParts); +bool CCSBot::IsVisible(const Vector *pos, bool testFOV) const +{ + return IsVisible_(pos, testFOV); +} +bool CCSBot::IsVisible(CBasePlayer *player, bool testFOV, unsigned char *visParts) const +{ + return IsVisible_(player, testFOV, visParts); } -bool CCSBot::IsEnemyPartVisible(VisiblePartType part) const -{ - return IsEnemyPartVisible_(part); +bool CCSBot::IsEnemyPartVisible(VisiblePartType part) const +{ + return IsEnemyPartVisible_(part); } #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/bot/cs_bot_weapon.cpp b/regamedll/dlls/bot/cs_bot_weapon.cpp index 9c8769bc..9b194670 100644 --- a/regamedll/dlls/bot/cs_bot_weapon.cpp +++ b/regamedll/dlls/bot/cs_bot_weapon.cpp @@ -68,7 +68,7 @@ void CCSBot::SetAimOffset(float accuracy) } // focusTime is the time it takes for a bot to "focus in" for very good aim, from 2 to 5 seconds - const float focusTime = _max(5.0f * (1.0f - accuracy), 2.0f); + const float focusTime = Q_max(5.0f * (1.0f - accuracy), 2.0f); float focusInterval = gpGlobals->time - m_aimSpreadTimestamp; float focusAccuracy = focusInterval / focusTime; @@ -79,7 +79,7 @@ void CCSBot::SetAimOffset(float accuracy) if (focusAccuracy > maxFocusAccuracy) focusAccuracy = maxFocusAccuracy; - accuracy = _max(accuracy, focusAccuracy); + accuracy = Q_max(accuracy, focusAccuracy); } PrintIfWatched("Accuracy = %4.3f\n", accuracy); diff --git a/regamedll/dlls/bot/cs_gamestate.h b/regamedll/dlls/bot/cs_gamestate.h index 3c48b95c..5f79f940 100644 --- a/regamedll/dlls/bot/cs_gamestate.h +++ b/regamedll/dlls/bot/cs_gamestate.h @@ -41,130 +41,130 @@ public: CSGameState(void); CSGameState(CCSBot *owner); - struct HostageInfo - { - CHostage *hostage; - Vector knownPos; - bool isValid; - bool isAlive; - bool isFree; + struct HostageInfo + { + CHostage *hostage; + Vector knownPos; + bool isValid; + bool isAlive; + bool isFree; };/* size: 20, cachelines: 1, members: 5 */ - NOBODY void Reset(void); - // Event handling - NOBODY void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - // true if round has been won or lost (but not yet reset) - NOBODY bool IsRoundOver(void) const; + NOBODY void Reset(void); + // Event handling + NOBODY void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); + // true if round has been won or lost (but not yet reset) + NOBODY bool IsRoundOver(void) const; - enum BombState - { - MOVING, // being carried by a Terrorist - LOOSE, // loose on the ground somewhere - PLANTED, // planted and ticking - DEFUSED, // the bomb has been defused - EXPLODED, // the bomb has exploded - }; - bool IsBombMoving(void) const - { - return (m_bombState == MOVING); - } - bool IsBombLoose(void) const - { - return (m_bombState == LOOSE); - } - bool IsBombPlanted(void) const - { - return (m_bombState == PLANTED); - } - bool IsBombDefused(void) const - { - return (m_bombState == DEFUSED); - } - bool IsBombExploded(void) const - { - return (m_bombState == EXPLODED); - } - // we see the loose bomb - NOBODY void UpdateLooseBomb(const Vector *pos); - // how long has is been since we saw the loose bomb - NOBODY float TimeSinceLastSawLooseBomb(void) const; - // do we know where the loose bomb is - NOBODY bool IsLooseBombLocationKnown(void) const; - // we see the bomber - NOBODY void UpdateBomber(const Vector *pos); - // how long has is been since we saw the bomber - NOBODY float TimeSinceLastSawBomber(void) const; - // we see the planted bomb - NOBODY void UpdatePlantedBomb(const Vector *pos); - // do we know where the bomb was planted - NOBODY bool IsPlantedBombLocationKnown(void) const; - // mark bombsite as the location of the planted bomb - NOBODY void MarkBombsiteAsPlanted(int zoneIndex); - - enum { UNKNOWN = -1 }; - // return the zone index of the planted bombsite, or UNKNOWN - NOBODY int GetPlantedBombsite(void) const; - // return true if we are currently in the bombsite where the bomb is planted - NOBODY bool IsAtPlantedBombsite(void) const; - // return the zone index of the next bombsite to search - NOBODY int GetNextBombsiteToSearch(void); - // return true if given bombsite has been cleared - NOBODY bool IsBombsiteClear(int zoneIndex) const; - // mark bombsite as clear - NOBODY void ClearBombsite(int zoneIndex); - // return where we think the bomb is, or NULL if we don't know - NOBODY const Vector *GetBombPosition(void) const; - - NOBODY CHostage *GetNearestFreeHostage(Vector *knowPos); - NOBODY const Vector *GetRandomFreeHostagePosition(void); - NOBODY bool AreAllHostagesBeingRescued(void); - NOBODY bool AreAllHostagesGone(void); - NOBODY void AllHostagesGone(void); - bool HaveSomeHostagesBeenTaken(void) - { - return m_haveSomeHostagesBeenTaken; - } - void HostageWasTaken(void) - { - m_haveSomeHostagesBeenTaken = true; - } - NOBODY CHostage *GetNearestVisibleFreeHostage(void); - NOBODY unsigned char ValidateHostagePositions(void); - NOBODY void SetBombState(BombState state); - BombState GetBombState(void) - { - return m_bombState; - } - CBaseEntity *GetNearestHostage(void) - { - UNTESTED - // TODO: Not implemented - - //CHostage *pHostage = g_pHostages->GetClosestHostage(m_owner->pev->origin); - //return GetClassPtr((CHostage *)pHostage->pev); - } + enum BombState + { + MOVING, // being carried by a Terrorist + LOOSE, // loose on the ground somewhere + PLANTED, // planted and ticking + DEFUSED, // the bomb has been defused + EXPLODED, // the bomb has exploded + }; + bool IsBombMoving(void) const + { + return (m_bombState == MOVING); + } + bool IsBombLoose(void) const + { + return (m_bombState == LOOSE); + } + bool IsBombPlanted(void) const + { + return (m_bombState == PLANTED); + } + bool IsBombDefused(void) const + { + return (m_bombState == DEFUSED); + } + bool IsBombExploded(void) const + { + return (m_bombState == EXPLODED); + } + // we see the loose bomb + NOBODY void UpdateLooseBomb(const Vector *pos); + // how long has is been since we saw the loose bomb + NOBODY float TimeSinceLastSawLooseBomb(void) const; + // do we know where the loose bomb is + NOBODY bool IsLooseBombLocationKnown(void) const; + // we see the bomber + NOBODY void UpdateBomber(const Vector *pos); + // how long has is been since we saw the bomber + NOBODY float TimeSinceLastSawBomber(void) const; + // we see the planted bomb + NOBODY void UpdatePlantedBomb(const Vector *pos); + // do we know where the bomb was planted + NOBODY bool IsPlantedBombLocationKnown(void) const; + // mark bombsite as the location of the planted bomb + NOBODY void MarkBombsiteAsPlanted(int zoneIndex); + + enum { UNKNOWN = -1 }; + // return the zone index of the planted bombsite, or UNKNOWN + NOBODY int GetPlantedBombsite(void) const; + // return true if we are currently in the bombsite where the bomb is planted + NOBODY bool IsAtPlantedBombsite(void) const; + // return the zone index of the next bombsite to search + NOBODY int GetNextBombsiteToSearch(void); + // return true if given bombsite has been cleared + NOBODY bool IsBombsiteClear(int zoneIndex) const; + // mark bombsite as clear + NOBODY void ClearBombsite(int zoneIndex); + // return where we think the bomb is, or NULL if we don't know + NOBODY const Vector *GetBombPosition(void) const; + + NOBODY CHostage *GetNearestFreeHostage(Vector *knowPos); + NOBODY const Vector *GetRandomFreeHostagePosition(void); + NOBODY bool AreAllHostagesBeingRescued(void); + NOBODY bool AreAllHostagesGone(void); + NOBODY void AllHostagesGone(void); + bool HaveSomeHostagesBeenTaken(void) + { + return m_haveSomeHostagesBeenTaken; + } + void HostageWasTaken(void) + { + m_haveSomeHostagesBeenTaken = true; + } + NOBODY CHostage *GetNearestVisibleFreeHostage(void); + NOBODY unsigned char ValidateHostagePositions(void); + NOBODY void SetBombState(BombState state); + BombState GetBombState(void) + { + return m_bombState; + } + CBaseEntity *GetNearestHostage(void) + { + UNTESTED + // TODO: Not implemented + + //CHostage *pHostage = g_pHostages->GetClosestHostage(m_owner->pev->origin); + //return GetClassPtr((CHostage *)pHostage->pev); + } NOBODY void InitializeHostageInfo(void); private: - CCSBot *m_owner; - bool m_isRoundOver; - BombState m_bombState; - IntervalTimer m_lastSawBomber; - Vector m_bomberPos; - IntervalTimer m_lastSawLooseBomb; - Vector m_looseBombPos; - bool m_isBombsiteClear[4]; - int m_bombsiteSearchOrder[4]; - int m_bombsiteCount; - int m_bombsiteSearchIndex; - int m_plantedBombsite; - bool m_isPlantedBombPosKnown; - Vector m_plantedBombPos; - struct HostageInfo m_hostage[12]; - int m_hostageCount; - CountdownTimer m_validateInterval; - bool m_allHostagesRescued; + CCSBot *m_owner; + bool m_isRoundOver; + BombState m_bombState; + IntervalTimer m_lastSawBomber; + Vector m_bomberPos; + IntervalTimer m_lastSawLooseBomb; + Vector m_looseBombPos; + bool m_isBombsiteClear[4]; + int m_bombsiteSearchOrder[4]; + int m_bombsiteCount; + int m_bombsiteSearchIndex; + int m_plantedBombsite; + bool m_isPlantedBombPosKnown; + Vector m_plantedBombPos; + struct HostageInfo m_hostage[12]; + int m_hostageCount; + CountdownTimer m_validateInterval; + bool m_allHostagesRescued; bool m_haveSomeHostagesBeenTaken; - + };/* size: 348, cachelines: 6, members: 19 */ #endif // CS_GAMESTATE_H diff --git a/regamedll/dlls/buttons.cpp b/regamedll/dlls/buttons.cpp index 777ef609..3f0d8ba1 100644 --- a/regamedll/dlls/buttons.cpp +++ b/regamedll/dlls/buttons.cpp @@ -14,12 +14,14 @@ TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = TYPEDESCRIPTION CMultiSource::m_SaveData[] = { + //!!!BUGBUG FIX DEFINE_ARRAY(CMultiSource, m_rgEntities, FIELD_EHANDLE, MS_MAX_TARGETS), DEFINE_ARRAY(CMultiSource, m_rgTriggered, FIELD_INTEGER, MS_MAX_TARGETS), DEFINE_FIELD(CMultiSource, m_iTotal, FIELD_INTEGER), DEFINE_FIELD(CMultiSource, m_globalstate, FIELD_STRING), }; +// CBaseButton TYPEDESCRIPTION CBaseButton::m_SaveData[] = { DEFINE_FIELD(CBaseButton, m_fStayPushed, FIELD_BOOLEAN), @@ -30,6 +32,7 @@ TYPEDESCRIPTION CBaseButton::m_SaveData[] = DEFINE_FIELD(CBaseButton, m_bUnlockedSound, FIELD_CHARACTER), DEFINE_FIELD(CBaseButton, m_bUnlockedSentence, FIELD_CHARACTER), DEFINE_FIELD(CBaseButton, m_strChangeTarget, FIELD_STRING), +// DEFINE_FIELD(CBaseButton, m_ls, FIELD_???), // This is restored in Precache() }; TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] = @@ -49,11 +52,11 @@ TYPEDESCRIPTION CEnvSpark::m_SaveData[] = #else -TYPEDESCRIPTION (*CEnvGlobal::pm_SaveData)[3]; -TYPEDESCRIPTION (*CMultiSource::pm_SaveData)[4]; -TYPEDESCRIPTION (*CBaseButton::pm_SaveData)[8]; -TYPEDESCRIPTION (*CMomentaryRotButton::pm_SaveData)[6]; -TYPEDESCRIPTION (*CEnvSpark::pm_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CEnvGlobal, m_SaveData)[3]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CMultiSource, m_SaveData)[4]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBaseButton, m_SaveData)[8]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CMomentaryRotButton, m_SaveData)[6]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CEnvSpark, m_SaveData)[1]; #endif // HOOK_GAMEDLL @@ -64,33 +67,85 @@ IMPLEMENT_SAVERESTORE(CEnvGlobal, CBaseEntity); LINK_ENTITY_TO_CLASS(env_global, CEnvGlobal); /* <26863> ../cstrike/dlls/buttons.cpp:66 */ -NOBODY void CEnvGlobal::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CEnvGlobal::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 70 -// FStrEq(const char *sz1, -// const char *sz2); // 72 -// KeyValue(CEnvGlobal *const this, -// KeyValueData *pkvd); // 66 -// atoi(const char *__nptr); // 73 + pkvd->fHandled = TRUE; + + // State name + if (FStrEq(pkvd->szKeyName, "globalstate")) + { + m_globalstate = ALLOC_STRING(pkvd->szValue); + } + else if (FStrEq(pkvd->szKeyName, "triggermode")) + { + m_triggermode = Q_atoi(pkvd->szValue); + } + else if (FStrEq(pkvd->szKeyName, "initialstate")) + { + m_initialstate = Q_atoi(pkvd->szValue); + } + else + CPointEntity::KeyValue(pkvd); } /* <26486> ../cstrike/dlls/buttons.cpp:80 */ -NOBODY void CEnvGlobal::__MAKE_VHOOK(Spawn)(void) +void CEnvGlobal::__MAKE_VHOOK(Spawn)(void) { -// EntityInTable(CGlobalState::Spawn(// string_t globalname); // 89 -// Spawn(CEnvGlobal *const this); // 80 + if (!m_globalstate) + { + REMOVE_ENTITY(ENT(pev)); + return; + } + + if (pev->spawnflags & SF_GLOBAL_SET) + { + if (!gGlobalState.EntityInTable(m_globalstate)) + { + gGlobalState.EntityAdd(m_globalstate, gpGlobals->mapname, (GLOBALESTATE)m_initialstate); + } + } } /* <25ee7> ../cstrike/dlls/buttons.cpp:95 */ -NOBODY void CEnvGlobal::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CEnvGlobal::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// GLOBALESTATE oldState; // 97 -// GLOBALESTATE newState; // 98 -// EntityInTable(CGlobalState *const this, -// string_t globalname); // 124 -// } + GLOBALESTATE oldState = gGlobalState.EntityGetState(m_globalstate); + GLOBALESTATE newState; + + switch (m_triggermode) + { + case 0: + newState = GLOBAL_OFF; + break; + + case 1: + newState = GLOBAL_ON; + break; + + case 2: + newState = GLOBAL_DEAD; + break; + + default: + case 3: + if (oldState == GLOBAL_ON) + { + newState = GLOBAL_OFF; + } + else if (oldState == GLOBAL_OFF) + { + newState = GLOBAL_ON; + } + else + newState = oldState; + } + + if (gGlobalState.EntityInTable(m_globalstate)) + { + gGlobalState.EntitySetState(m_globalstate, newState); + } + else + gGlobalState.EntityAdd(m_globalstate, gpGlobals->mapname, newState); } /* <2616f> ../cstrike/dlls/buttons.cpp:141 */ @@ -99,293 +154,756 @@ IMPLEMENT_SAVERESTORE(CMultiSource, CBaseEntity); /* <27379> ../cstrike/dlls/buttons.cpp:143 */ LINK_ENTITY_TO_CLASS(multisource, CMultiSource); +// Cache user-entity-field values until spawn is called. + /* <26d1e> ../cstrike/dlls/buttons.cpp:148 */ -NOBODY void CMultiSource::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CMultiSource::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 150 -// FStrEq(const char *sz1, -// const char *sz2); // 151 -// FStrEq(const char *sz1, -// const char *sz2); // 152 -// FStrEq(const char *sz1, -// const char *sz2); // 153 -// FStrEq(const char *sz1, -// const char *sz2); // 154 -// FStrEq(const char *sz1, -// const char *sz2); // 155 -// FStrEq(const char *sz1, -// const char *sz2); // 157 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 163 + if (FStrEq(pkvd->szKeyName, "style") + || FStrEq(pkvd->szKeyName, "height") + || FStrEq(pkvd->szKeyName, "killtarget") + || FStrEq(pkvd->szKeyName, "value1") + || FStrEq(pkvd->szKeyName, "value2") + || FStrEq(pkvd->szKeyName, "value3")) + pkvd->fHandled = TRUE; + + else if (FStrEq(pkvd->szKeyName, "globalstate")) + { + m_globalstate = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CPointEntity::KeyValue(pkvd); } /* <256e2> ../cstrike/dlls/buttons.cpp:168 */ -NOBODY void CMultiSource::__MAKE_VHOOK(Spawn)(void) +void CMultiSource::__MAKE_VHOOK(Spawn)(void) { + // set up think for later registration + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->nextthink = gpGlobals->time + 0.1; + + // Until it's initialized + pev->spawnflags |= SF_MULTI_INIT; + + SetThink(&CMultiSource::Register); } /* <2633b> ../cstrike/dlls/buttons.cpp:179 */ -NOBODY void CMultiSource::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CMultiSource::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// int i; // 181 -// { -// USE_TYPE useType; // 203 -// } -// } -// Use(CMultiSource *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 179 + int i = 0; + + // Find the entity in our list + while (i < m_iTotal) + { + if (m_rgEntities[i++] == pCaller) + break; + } + + // if we didn't find it, report error and leave + if (i > m_iTotal) + { + ALERT(at_console, "MultiSrc:Used by non member %s.\n", STRING(pCaller->pev->classname)); + return; + } + + // CONSIDER: a Use input to the multisource always toggles. + // Could check useType for ON/OFF/TOGGLE + m_rgTriggered[i - 1] ^= 1; + + if (IsTriggered(pActivator)) + { + ALERT(at_aiconsole, "Multisource %s enabled (%d inputs)\n", STRING(pev->targetname), m_iTotal); + USE_TYPE useType = USE_TOGGLE; + + if (!FStringNull(m_globalstate)) + { + useType = USE_ON; + } + + SUB_UseTargets(NULL, useType, 0); + } } /* <26419> ../cstrike/dlls/buttons.cpp:211 */ -NOBODY BOOL CMultiSource::__MAKE_VHOOK(IsTriggered)(CBaseEntity *) +BOOL CMultiSource::__MAKE_VHOOK(IsTriggered)(CBaseEntity *) { -// { -// int i; // 214 -// } -// IsTriggered(CMultiSource *const this, -// class CBaseEntity *); // 211 + // Is everything triggered? + int i = 0; + + // Still initializing? + if (pev->spawnflags & SF_MULTI_INIT) + return 0; + + while (i < m_iTotal) + { + if (m_rgTriggered[i] == 0) + break; + i++; + } + + if (i == m_iTotal) + { + if (FStringNull(m_globalstate) || gGlobalState.EntityGetState(m_globalstate) == GLOBAL_ON) + { + return 1; + } + } + + return 0; } /* <25d5a> ../cstrike/dlls/buttons.cpp:236 */ -NOBODY void CMultiSource::Register(void) +void CMultiSource::Register(void) { -// { -// edict_t *pentTarget; // 238 -// FNullEnt(const edict_t *pent); // 249 -// FNullEnt(const edict_t *pent); // 259 -// { -// class CBaseEntity *pTarget; // 261 -// Instance(edict_t *pent); // 261 -// } -// { -// class CBaseEntity *pTarget; // 251 -// Instance(edict_t *pent); // 251 -// } -// } + edict_t *pentTarget = NULL; + + m_iTotal = 0; + Q_memset(m_rgEntities, 0, MS_MAX_TARGETS * sizeof(EHANDLE)); + + SetThink(&CMultiSource::SUB_DoNothing); + + // search for all entities which target this multisource (pev->targetname) + pentTarget = FIND_ENTITY_BY_STRING(NULL, "target", STRING(pev->targetname)); + + while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS) + { + CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); + + if (pTarget != NULL) + { + m_rgEntities[m_iTotal++] = pTarget; + } + + pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "target", STRING(pev->targetname)); + } + + pentTarget = FIND_ENTITY_BY_STRING(NULL, "classname", "multi_manager"); + + while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS) + { + CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); + if (pTarget != NULL && pTarget->HasTarget(pev->targetname)) + { + m_rgEntities[m_iTotal++] = pTarget; + } + + pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "classname", "multi_manager"); + } + + pev->spawnflags &= ~SF_MULTI_INIT; } /* <262ee> ../cstrike/dlls/buttons.cpp:287 */ IMPLEMENT_SAVERESTORE(CBaseButton, CBaseToggle); /* <25709> ../cstrike/dlls/buttons.cpp:289 */ -NOBODY void CBaseButton::__MAKE_VHOOK(Precache)(void) +void CBaseButton::__MAKE_VHOOK(Precache)(void) { -// { -// char *pszSound; // 291 -// ButtonSound(int sound); // 307 -// ButtonSound(int sound); // 314 -// } + char *pszSound; + + // this button should spark in OFF state + if (pev->spawnflags & SF_BUTTON_SPARK_IF_OFF) + { + PRECACHE_SOUND("buttons/spark1.wav"); + PRECACHE_SOUND("buttons/spark2.wav"); + PRECACHE_SOUND("buttons/spark3.wav"); + PRECACHE_SOUND("buttons/spark4.wav"); + PRECACHE_SOUND("buttons/spark5.wav"); + PRECACHE_SOUND("buttons/spark6.wav"); + } + + // get door button sounds, for doors which require buttons to open + if (m_bLockedSound) + { + pszSound = ButtonSound((int)m_bLockedSound); + PRECACHE_SOUND(pszSound); + m_ls.sLockedSound = ALLOC_STRING(pszSound); + } + + if (m_bUnlockedSound) + { + pszSound = ButtonSound((int)m_bUnlockedSound); + PRECACHE_SOUND(pszSound); + m_ls.sUnlockedSound = ALLOC_STRING(pszSound); + } + + // get sentence group names, for doors which are directly 'touched' to open + switch (m_bLockedSentence) + { + case 1: m_ls.sLockedSentence = MAKE_STRING("NA"); break; // access denied + case 2: m_ls.sLockedSentence = MAKE_STRING("ND"); break; // security lockout + case 3: m_ls.sLockedSentence = MAKE_STRING("NF"); break; // blast door + case 4: m_ls.sLockedSentence = MAKE_STRING("NFIRE"); break; // fire door + case 5: m_ls.sLockedSentence = MAKE_STRING("NCHEM"); break; // chemical door + case 6: m_ls.sLockedSentence = MAKE_STRING("NRAD"); break; // radiation door + case 7: m_ls.sLockedSentence = MAKE_STRING("NCON"); break; // gen containment + case 8: m_ls.sLockedSentence = MAKE_STRING("NH"); break; // maintenance door + case 9: m_ls.sLockedSentence = MAKE_STRING("NG"); break; // broken door + default: m_ls.sLockedSentence = 0; break; + } + + switch (m_bUnlockedSentence) + { + case 1: m_ls.sUnlockedSentence = MAKE_STRING("EA"); break; // access granted + case 2: m_ls.sUnlockedSentence = MAKE_STRING("ED"); break; // security door + case 3: m_ls.sUnlockedSentence = MAKE_STRING("EF"); break; // blast door + case 4: m_ls.sUnlockedSentence = MAKE_STRING("EFIRE"); break; // fire door + case 5: m_ls.sUnlockedSentence = MAKE_STRING("ECHEM"); break; // chemical door + case 6: m_ls.sUnlockedSentence = MAKE_STRING("ERAD"); break; // radiation door + case 7: m_ls.sUnlockedSentence = MAKE_STRING("ECON"); break; // gen containment + case 8: m_ls.sUnlockedSentence = MAKE_STRING("EH"); break; // maintenance door + default: m_ls.sUnlockedSentence = 0; break; + } } + +// Cache user-entity-field values until spawn is called. /* <269cb> ../cstrike/dlls/buttons.cpp:355 */ -NOBODY void CBaseButton::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CBaseButton::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 357 -// FStrEq(const char *sz1, -// const char *sz2); // 362 -// KeyValue(CBaseButton *const this, -// KeyValueData *pkvd); // 355 -// atof(const char *__nptr); // 364 + if (FStrEq(pkvd->szKeyName, "changetarget")) + { + m_strChangeTarget = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "locked_sound")) + { + m_bLockedSound = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "locked_sentence")) + { + m_bLockedSentence = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "unlocked_sound")) + { + m_bUnlockedSound = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "unlocked_sentence")) + { + m_bUnlockedSentence = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "sounds")) + { + m_sounds = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseToggle::KeyValue(pkvd); } +// ButtonShot + /* <26e90> ../cstrike/dlls/buttons.cpp:394 */ -NOBODY int CBaseButton::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +int CBaseButton::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { -// { -// enum BUTTON_CODE code; // 396 -// -// ButtonResponseToTouch(CBaseButton *const this); // 396 -// Instance(entvars_t *pev); // 403 -// ButtonActivate(CBaseButton *const this); // 417 -// } -// TakeDamage(CBaseButton *const this, -// entvars_t *pevInflictor, -// entvars_t *pevAttacker, -// float flDamage, -// int bitsDamageType); // 394 + BUTTON_CODE code = ButtonResponseToTouch(); + + if (code == BUTTON_NOTHING) + { + return 0; + } + + // Temporarily disable the touch function, until movement is finished. + SetTouch(NULL); + + m_hActivator = CBaseEntity::Instance(pevAttacker); + if (m_hActivator == NULL) + return 0; + + if (code == BUTTON_RETURN) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char*)STRING(pev->noise), 1, ATTN_NORM); + + // Toggle buttons fire when they get back to their "home" position + if (!(pev->spawnflags & SF_BUTTON_TOGGLE)) + { + SUB_UseTargets(m_hActivator, USE_TOGGLE, 0); + } + + ButtonReturn(); + } + else + { + // code == BUTTON_ACTIVATE + ButtonActivate(); + } + + return 0; } +// QUAKED func_button (0 .5 .8) ? +// When a button is touched, it moves some distance in the direction of it's angle, +// triggers all of it's targets, waits some time, then returns to it's original position +// where it can be triggered again. +// +// "angle" determines the opening direction +// "target" all entities with a matching targetname will be used +// "speed" override the default 40 speed +// "wait" override the default 1 second wait (-1 = never return) +// "lip" override the default 4 pixel lip remaining at end of move +// "health" if set, the button must be killed instead of touched +// "sounds" +// 0) steam metal +// 1) wooden clunk +// 2) metallic click +// 3) in-out + /* <27443> ../cstrike/dlls/buttons.cpp:439 */ LINK_ENTITY_TO_CLASS(func_button, CBaseButton); /* <25c2c> ../cstrike/dlls/buttons.cpp:442 */ -NOBODY void CBaseButton::__MAKE_VHOOK(Spawn)(void) +void CBaseButton::__MAKE_VHOOK(Spawn)(void) { -// { -// char *pszSound; // 444 -// ButtonSound(int sound); // 450 -// fabs(double __x); // 484 -// fabs(double __x); // 484 -// fabs(double __x); // 484 -// operator+(const Vector *const this, -// const Vector &v); // 484 -// operator*(const Vector *const this, -// float fl); // 484 -// operator-(const Vector *const this, -// const Vector &v); // 488 -// Length(const Vector *const this); // 488 -// } + char *pszSound; + + //---------------------------------------------------- + //determine sounds for buttons + //a sound of 0 should not make a sound + //---------------------------------------------------- + pszSound = ButtonSound(m_sounds); + PRECACHE_SOUND(pszSound); + pev->noise = ALLOC_STRING(pszSound); + + Precache(); + + // this button should spark in OFF state + if (pev->spawnflags & SF_BUTTON_SPARK_IF_OFF) + { + SetThink(&CBaseButton::ButtonSpark); + + // no hurry, make sure everything else spawns + pev->nextthink = gpGlobals->time + 0.5; + } + + SetMovedir(pev); + + pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (pev->speed == 0) + pev->speed = 40; + + if (pev->health > 0) + { + pev->takedamage = DAMAGE_YES; + } + + if (m_flWait == 0) + { + m_flWait = 1; + } + + if (m_flLip == 0) + { + m_flLip = 4; + } + + m_toggle_state = TS_AT_BOTTOM; + m_vecPosition1 = pev->origin; + + // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big + m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs((float_precision)(pev->movedir.x * (pev->size.x - 2))) + fabs((float_precision)(pev->movedir.y * (pev->size.y - 2))) + fabs((float_precision)(pev->movedir.z * (pev->size.z - 2))) - m_flLip)); + + // Is this a non-moving button? + if (((m_vecPosition2 - m_vecPosition1).Length() < 1) || (pev->spawnflags & SF_BUTTON_DONTMOVE)) + { + m_vecPosition2 = m_vecPosition1; + } + + m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE); + m_fRotating = FALSE; + + // if the button is flagged for USE button activation only, take away it's touch function and add a use function + // touchable button + if (pev->spawnflags & SF_BUTTON_TOUCH_ONLY) + { + SetTouch(&CBaseButton::ButtonTouch); + } + else + { + SetTouch(NULL); + SetUse(&CBaseButton::ButtonUse); + } } +// Button sound table. +// Also used by CBaseDoor to get 'touched' door lock/unlock sounds + /* <24738> ../cstrike/dlls/buttons.cpp:511 */ -NOBODY char *ButtonSound(int sound) +char *ButtonSound(int sound) { -// { -// char *pszSound; // 513 -// } + char *pszSound; + + switch (sound) + { + case 0: pszSound = "common/null.wav"; break; + case 1: pszSound = "buttons/button1.wav"; break; + case 2: pszSound = "buttons/button2.wav"; break; + case 3: pszSound = "buttons/button3.wav"; break; + case 4: pszSound = "buttons/button4.wav"; break; + case 5: pszSound = "buttons/button5.wav"; break; + case 6: pszSound = "buttons/button6.wav"; break; + case 7: pszSound = "buttons/button7.wav"; break; + case 8: pszSound = "buttons/button8.wav"; break; + case 9: pszSound = "buttons/button9.wav"; break; + case 10: pszSound = "buttons/button10.wav"; break; + case 11: pszSound = "buttons/button11.wav"; break; + case 12: pszSound = "buttons/latchlocked1.wav"; break; + case 13: pszSound = "buttons/latchunlocked1.wav"; break; + case 14: pszSound = "buttons/lightswitch2.wav"; break; + + // next 6 slots reserved for any additional sliding button sounds we may add + case 21: pszSound = "buttons/lever1.wav"; break; + case 22: pszSound = "buttons/lever2.wav"; break; + case 23: pszSound = "buttons/lever3.wav"; break; + case 24: pszSound = "buttons/lever4.wav"; break; + case 25: pszSound = "buttons/lever5.wav"; break; + default: pszSound = "buttons/button9.wav"; break; + } + + return pszSound; } +// Makes flagged buttons spark when turned off + /* <2752e> ../cstrike/dlls/buttons.cpp:551 */ -NOBODY void DoSpark(entvars_t *pev, const Vector &location) +void DoSpark(entvars_t *pev, const Vector &location) { -// { -// Vector tmp; // 553 -// float flVolume; // 556 -// operator*(const Vector *const this, -// float fl); // 553 -// operator+(const Vector *const this, -// const Vector &v); // 553 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 564 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 563 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 559 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 560 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 561 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 562 -// } + Vector tmp = location + (pev->size * 0.5); + UTIL_Sparks(tmp); + + //random volume range + float flVolume = RANDOM_FLOAT(0.25 , 0.75) * 0.4; + + switch ((int)(RANDOM_FLOAT(0, 1) * 6)) + { + case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark1.wav", flVolume, ATTN_NORM); break; + case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark2.wav", flVolume, ATTN_NORM); break; + case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark3.wav", flVolume, ATTN_NORM); break; + case 3: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark4.wav", flVolume, ATTN_NORM); break; + case 4: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM); break; + case 5: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM); break; + } } /* <277fa> ../cstrike/dlls/buttons.cpp:568 */ -NOBODY void CBaseButton::ButtonSpark(void) +void CBaseButton::ButtonSpark(void) { + SetThink(&CBaseButton::ButtonSpark); + + // spark again at random interval + pev->nextthink = gpGlobals->time + (0.1 + RANDOM_FLOAT(0, 1.5)); + + DoSpark(pev, pev->mins); } +// Button's Use function + /* <2719b> ../cstrike/dlls/buttons.cpp:580 */ -NOBODY void CBaseButton::ButtonUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CBaseButton::ButtonUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// ButtonActivate(CBaseButton *const this); // 599 -// ButtonUse(CBaseButton *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 580 + // Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. + // UNDONE: Should this use ButtonResponseToTouch() too? + if (m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN) + return; + + m_hActivator = pActivator; + if (m_toggle_state == TS_AT_TOP) + { + if (!m_fStayPushed && (pev->spawnflags & SF_BUTTON_TOGGLE)) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), VOL_NORM, ATTN_NORM); + //SUB_UseTargets(m_eoActivator); + ButtonReturn(); + } + } + else + ButtonActivate(); } /* <27821> ../cstrike/dlls/buttons.cpp:603 */ -NOBODY CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch(void) +CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch(void) { + // Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. + if (m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN || (m_toggle_state == TS_AT_TOP && !m_fStayPushed && !(pev->spawnflags & SF_BUTTON_TOGGLE))) + { + return BUTTON_NOTHING; + } + + if (m_toggle_state == TS_AT_TOP) + { + if ((pev->spawnflags & SF_BUTTON_TOGGLE) && !m_fStayPushed) + { + return BUTTON_RETURN; + } + } + else + return BUTTON_ACTIVATE; + + return BUTTON_NOTHING; } +// Touching a button simply "activates" it. + /* <27047> ../cstrike/dlls/buttons.cpp:628 */ -NOBODY void CBaseButton::ButtonTouch(CBaseEntity *pOther) +void CBaseButton::ButtonTouch(CBaseEntity *pOther) { -// { -// enum BUTTON_CODE code; // 636 -// -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 631 -// } -// ButtonTouch(CBaseButton *const this, -// class CBaseEntity *pOther); // 628 + // Ignore touches by anything but players + if (!FClassnameIs(pOther->pev, "player")) + return; + + m_hActivator = pOther; + + BUTTON_CODE code = ButtonResponseToTouch(); + + if (code == BUTTON_NOTHING) + return; + + if (!UTIL_IsMasterTriggered(m_sMaster, pOther)) + { + // play button locked sound + PlayLockSounds(pev, &m_ls, TRUE, TRUE); + return; + } + + // Temporarily disable the touch function, until movement is finished. + SetTouch(NULL); + + if (code == BUTTON_RETURN) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), VOL_NORM, ATTN_NORM); + SUB_UseTargets(m_hActivator, USE_TOGGLE, 0); + ButtonReturn(); + } + else // code == BUTTON_ACTIVATE + { + ButtonActivate(); + } } +// Starts the button moving "in/up". + /* <27843> ../cstrike/dlls/buttons.cpp:664 */ -NOBODY void CBaseButton::ButtonActivate(void) +void CBaseButton::ButtonActivate(void) { -// Vector(Vector *const this, const Vector &const v); -// Vector(Vector *const this, const Vector &const v); -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 666 + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), VOL_NORM, ATTN_NORM); + + if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + { + // button is locked, play locked sound + PlayLockSounds(pev, &m_ls, TRUE, TRUE); + return; + } + else + { + // button is unlocked, play unlocked sound + PlayLockSounds(pev, &m_ls, FALSE, TRUE); + } + + assert(m_toggle_state == TS_AT_BOTTOM); + m_toggle_state = TS_GOING_UP; + + SetMoveDone(&CBaseButton::TriggerAndWait); + if (!m_fRotating) + { + LinearMove(m_vecPosition2, pev->speed); + } + else + { + AngularMove(m_vecAngle2, pev->speed); + } } +// Button has reached the "in/up" position. Activate its "targets", and pause before "popping out". + /* <263dd> ../cstrike/dlls/buttons.cpp:693 */ -NOBODY void CBaseButton::TriggerAndWait(void) +void CBaseButton::TriggerAndWait(void) { -// TriggerAndWait(CBaseButton *const this); // 693 + assert(m_toggle_state == TS_GOING_UP); + + if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + return; + + m_toggle_state = TS_AT_TOP; + + // If button automatically comes back out, start it moving out. + // Else re-instate touch method + if (m_fStayPushed || (pev->spawnflags & SF_BUTTON_TOGGLE)) + { + // this button only works if USED, not touched! + if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY)) + { + // ALL buttons are now use only + SetTouch(NULL); + } + else + SetTouch(&CBaseButton::ButtonTouch); + } + else + { + pev->nextthink = pev->ltime + m_flWait; + SetThink(&CBaseButton::ButtonReturn); + } + + // use alternate textures + pev->frame = 1; + SUB_UseTargets(m_hActivator, USE_TOGGLE, 0); } +// Starts the button moving "out/down". + /* <25bb7> ../cstrike/dlls/buttons.cpp:730 */ -NOBODY void CBaseButton::ButtonReturn(void) +void CBaseButton::ButtonReturn(void) { -// Vector(Vector *const this, -// const Vector &v); // 739 -// Vector(Vector *const this, -// const Vector &v); // 737 + assert(m_toggle_state == TS_AT_TOP); + m_toggle_state = TS_GOING_DOWN; + + SetMoveDone(&CBaseButton::ButtonBackHome); + if (!m_fRotating) + { + LinearMove(m_vecPosition1, pev->speed); + } + else + { + AngularMove(m_vecAngle1, pev->speed); + } + + // use normal textures + pev->frame = 0; } +// Button has returned to start state. Quiesce it. + /* <26658> ../cstrike/dlls/buttons.cpp:748 */ -NOBODY void CBaseButton::ButtonBackHome(void) +void CBaseButton::ButtonBackHome(void) { -// { -// edict_t *pentTarget; // 761 -// { -// class CBaseEntity *pTarget; // 771 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 764 -// FNullEnt(const edict_t *pent); // 766 -// FClassnameIs(edict_t *pent, -// const char *szClassname); // 769 -// Instance(edict_t *pent); // 771 -// } -// } + assert(m_toggle_state == TS_GOING_DOWN); + m_toggle_state = TS_AT_BOTTOM; + + if (pev->spawnflags & SF_BUTTON_TOGGLE) + { + //EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), 1, ATTN_NORM); + SUB_UseTargets(m_hActivator, USE_TOGGLE, 0); + } + + if (!FStringNull(pev->target)) + { + edict_t *pentTarget = NULL; + + while (true) + { + pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); + + if (FNullEnt(pentTarget)) + break; + + if (!FClassnameIs(pentTarget, "multisource")) + continue; + + CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); + + if (pTarget != NULL) + { + pTarget->Use(m_hActivator, this, USE_TOGGLE, 0); + } + } + } + + // Re-instate touch method, movement cycle is complete. + // this button only works if USED, not touched! + if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY)) + { + // All buttons are now use only + SetTouch(NULL); + } + else + SetTouch(&CBaseButton::ButtonTouch); + + // reset think for a sparking button + if (pev->spawnflags & SF_BUTTON_SPARK_IF_OFF) + { + SetThink(&CBaseButton::ButtonSpark); + + // no hurry. + pev->nextthink = gpGlobals->time + 0.5; + } } /* <278a4> ../cstrike/dlls/buttons.cpp:806 */ LINK_ENTITY_TO_CLASS(func_rot_button, CRotButton); /* <25a06> ../cstrike/dlls/buttons.cpp:808 */ -NOBODY void CRotButton::__MAKE_VHOOK(Spawn)(void) +void CRotButton::__MAKE_VHOOK(Spawn)(void) { -// { -// char *pszSound; // 810 -// ButtonSound(int sound); // 815 -// operator*(const Vector *const this, -// float fl); // 824 -// operator*(const Vector *const this, -// float fl); // 848 -// operator+(const Vector *const this, -// const Vector &v); // 848 -// } -} - -/* <2577a> ../cstrike/dlls/buttons.cpp:878 */ -NOBODY int CMomentaryRotButton::__MAKE_VHOOK(ObjectCaps)(void) -{ -// { -// int flags; // 880 -// } + char *pszSound; + + //---------------------------------------------------- + //determine sounds for buttons + //a sound of 0 should not make a sound + //---------------------------------------------------- + pszSound = ButtonSound(m_sounds); + PRECACHE_SOUND(pszSound); + pev->noise = ALLOC_STRING(pszSound); + + // set the axis of rotation + CBaseToggle::AxisDir(pev); + + // check for clockwise rotation + if (pev->spawnflags & SF_DOOR_ROTATE_BACKWARDS) + { + pev->movedir = pev->movedir * -1; + } + + pev->movetype = MOVETYPE_PUSH; + + if (pev->spawnflags & SF_ROTBUTTON_NOTSOLID) + pev->solid = SOLID_NOT; + else + pev->solid = SOLID_BSP; + + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (pev->speed == 0) + pev->speed = 40; + + if (m_flWait == 0) + { + m_flWait = 1; + } + + if (pev->health > 0) + { + pev->takedamage = DAMAGE_YES; + } + + m_toggle_state = TS_AT_BOTTOM; + m_vecAngle1 = pev->angles; + m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; + + assert(("rotating button start/end positions are equal", m_vecAngle1 != m_vecAngle2)); + + m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE); + m_fRotating = TRUE; + + // if the button is flagged for USE button activation only, take away it's touch function and add a use function + if (!(pev->spawnflags & SF_BUTTON_TOUCH_ONLY)) + { + SetTouch(NULL); + SetUse(&CRotButton::ButtonUse); + } + else // touchable button + SetTouch(&CRotButton::ButtonTouch); + + //SetTouch(ButtonTouch); } /* <262a1> ../cstrike/dlls/buttons.cpp:918 */ @@ -395,113 +913,228 @@ IMPLEMENT_SAVERESTORE(CMomentaryRotButton, CBaseToggle); LINK_ENTITY_TO_CLASS(momentary_rot_button, CMomentaryRotButton); /* <25acc> ../cstrike/dlls/buttons.cpp:922 */ -NOBODY void CMomentaryRotButton::__MAKE_VHOOK(Spawn)(void) +void CMomentaryRotButton::__MAKE_VHOOK(Spawn)(void) { -// { -// char *pszSound; // 952 -// operator*(const Vector *const this, -// float fl); // 931 -// operator+(const Vector *const this, -// const Vector &v); // 931 -// ButtonSound(int sound); // 952 -// operator*(const Vector *const this, -// float fl); // 939 -// operator+(const Vector *const this, -// const Vector &v); // 939 -// } + CBaseToggle::AxisDir(pev); + + if (pev->speed == 0) + pev->speed = 100; + + if (m_flMoveDistance < 0) + { + m_start = pev->angles + pev->movedir * m_flMoveDistance; + m_end = pev->angles; + + // This will toggle to -1 on the first use() + m_direction = 1; + m_flMoveDistance = -m_flMoveDistance; + } + else + { + m_start = pev->angles; + m_end = pev->angles + pev->movedir * m_flMoveDistance; + + // This will toggle to +1 on the first use() + m_direction = -1; + } + + if (pev->spawnflags & SF_MOMENTARY_DOOR) + pev->solid = SOLID_BSP; + else + pev->solid = SOLID_NOT; + + pev->movetype = MOVETYPE_PUSH; + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + char *pszSound = ButtonSound(m_sounds); + PRECACHE_SOUND(pszSound); + pev->noise = ALLOC_STRING(pszSound); + m_lastUsed = 0; } /* <2678f> ../cstrike/dlls/buttons.cpp:958 */ -NOBODY void CMomentaryRotButton::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CMomentaryRotButton::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 960 -// FStrEq(const char *sz1, -// const char *sz2); // 965 -// atoi(const char *__nptr); // 967 -// KeyValue(CMomentaryRotButton *const this, -// KeyValueData *pkvd); // 958 + if (FStrEq(pkvd->szKeyName, "returnspeed")) + { + m_returnSpeed = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "sounds")) + { + m_sounds = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseToggle::KeyValue(pkvd); } /* <27a57> ../cstrike/dlls/buttons.cpp:974 */ -NOBODY void CMomentaryRotButton::PlaySound(void) +void CMomentaryRotButton::PlaySound(void) { -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 976 + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), VOL_NORM, ATTN_NORM); } + +// BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse +// will send the target in the wrong direction because the parameter is calculated based on the +// current, not future position. /* <27dc0> ../cstrike/dlls/buttons.cpp:982 */ -NOBODY void CMomentaryRotButton::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CMomentaryRotButton::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// UpdateTarget(CMomentaryRotButton *const this, -// float value); // 987 + pev->ideal_yaw = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_start) / m_flMoveDistance; + + UpdateAllButtons(pev->ideal_yaw, 1); + UpdateTarget(pev->ideal_yaw); + +#if 0 + // Calculate destination angle and use it to predict value, this prevents sending target in wrong direction on retriggering + Vector dest = pev->angles + pev->avelocity * (pev->nextthink - pev->ltime); + float value1 = CBaseToggle::AxisDelta(pev->spawnflags, dest, m_start) / m_flMoveDistance; + UpdateTarget(value1); +#endif } /* <27c49> ../cstrike/dlls/buttons.cpp:990 */ -NOBODY void CMomentaryRotButton::UpdateAllButtons(float value, int start) +void CMomentaryRotButton::UpdateAllButtons(float value, int start) { -// { -// edict_t *pentTarget; // 993 -// FNullEnt(const edict_t *pent); // 998 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 1001 -// { -// class CMomentaryRotButton *pEntity; // 1003 -// Instance(edict_t *pent); // 1003 -// } -// } + // Update all rot buttons attached to the same target + edict_t *pentTarget = NULL; + while (true) + { + + pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "target", STRING(pev->target)); + + if (FNullEnt(pentTarget)) + break; + + if (FClassnameIs(VARS(pentTarget), "momentary_rot_button")) + { + CMomentaryRotButton *pEntity = CMomentaryRotButton::Instance(pentTarget); + + if (pEntity != NULL) + { + if (start) + pEntity->UpdateSelf(value); + else + pEntity->UpdateSelfReturn(value); + } + } + } } /* <27ab8> ../cstrike/dlls/buttons.cpp:1015 */ -NOBODY void CMomentaryRotButton::UpdateSelf(float value) +void CMomentaryRotButton::UpdateSelf(float value) { -// { -// BOOL fplaysound; // 1017 -// operator*(float fl, -// const Vector &v); // 1049 -// PlaySound(CMomentaryRotButton *const this); // 1041 -// } + BOOL fplaysound = FALSE; + + if (!m_lastUsed) + { + fplaysound = TRUE; + m_direction = -m_direction; + } + + m_lastUsed = 1; + pev->nextthink = pev->ltime + 0.1f; + + if (m_direction > 0 && value >= 1.0f) + { + pev->avelocity = g_vecZero; + pev->angles = m_end; + return; + } + else if (m_direction < 0 && value <= 0.0f) + { + pev->avelocity = g_vecZero; + pev->angles = m_start; + return; + } + + if (fplaysound) + { + PlaySound(); + } + + // HACKHACK -- If we're going slow, we'll get multiple player packets per frame, bump nexthink on each one to avoid stalling + if (pev->nextthink < pev->ltime) + pev->nextthink = pev->ltime + 0.1; + else + pev->nextthink += 0.1; + + pev->avelocity = (m_direction * pev->speed) * pev->movedir; + SetThink(&CMomentaryRotButton::Off); } /* <26550> ../cstrike/dlls/buttons.cpp:1053 */ -NOBODY void CMomentaryRotButton::UpdateTarget(float value) +void CMomentaryRotButton::UpdateTarget(float value) { -// { -// edict_t *pentTarget; // 1057 -// { -// class CBaseEntity *pEntity; // 1063 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1060 -// FNullEnt(const edict_t *pent); // 1061 -// Instance(edict_t *pent); // 1063 -// } -// } + if (!FStringNull(pev->target)) + { + edict_t *pentTarget = NULL; + + while (true) + { + pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); + + if (FNullEnt(pentTarget)) + break; + + CBaseEntity *pEntity = CBaseEntity::Instance(pentTarget); + + if (pEntity != NULL) + { + pEntity->Use(this, this, USE_SET, value); + } + } + } } /* <25f88> ../cstrike/dlls/buttons.cpp:1072 */ -NOBODY void CMomentaryRotButton::Off(void) +void CMomentaryRotButton::Off(void) { -// Off(CMomentaryRotButton *const this); // 1072 + pev->avelocity = g_vecZero; + m_lastUsed = 0; + + if ((pev->spawnflags & SF_PENDULUM_AUTO_RETURN) && m_returnSpeed > 0) + { + SetThink(&CMomentaryRotButton::Return); + pev->nextthink = pev->ltime + 0.1f; + m_direction = -1; + } + else + SetThink(NULL); } /* <27d60> ../cstrike/dlls/buttons.cpp:1086 */ -NOBODY void CMomentaryRotButton::Return(void) +void CMomentaryRotButton::Return(void) { -// { -// float value; // 1088 -// UpdateTarget(CMomentaryRotButton *const this, -// float value); // 1092 -// } + float value = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_start) / m_flMoveDistance; + + // This will end up calling UpdateSelfReturn() n times, but it still works right + UpdateAllButtons(value, 0); + + if (value > 0) + { + UpdateTarget(value); + } } /* <27bce> ../cstrike/dlls/buttons.cpp:1096 */ -NOBODY void CMomentaryRotButton::UpdateSelfReturn(float value) +void CMomentaryRotButton::UpdateSelfReturn(float value) { -// operator*(float fl, -// const Vector &v); // 1107 + if (value <= 0) + { + pev->avelocity = g_vecZero; + pev->angles = m_start; + pev->nextthink = -1; + SetThink(NULL); + } + else + { + pev->avelocity = -m_returnSpeed * pev->movedir; + pev->nextthink = pev->ltime + 0.1; + } } /* <26122> ../cstrike/dlls/buttons.cpp:1141 */ @@ -514,82 +1147,142 @@ LINK_ENTITY_TO_CLASS(env_spark, CEnvSpark); LINK_ENTITY_TO_CLASS(env_debris, CEnvSpark); /* <257b7> ../cstrike/dlls/buttons.cpp:1146 */ -NOBODY void CEnvSpark::__MAKE_VHOOK(Spawn)(void) +void CEnvSpark::__MAKE_VHOOK(Spawn)(void) { + SetThink(NULL); + SetUse(NULL); + + // Use for on/off + if (pev->spawnflags & SF_SPARK_TOOGLE) + { + // Start on + if (pev->spawnflags & SF_SPARK_IF_OFF) + { + // start sparking + SetThink(&CEnvSpark::SparkThink); + + // set up +USE to stop sparking + SetUse(&CEnvSpark::SparkStop); + } + else + SetUse(&CEnvSpark::SparkStart); + } + else + SetThink(&CEnvSpark::SparkThink); + + pev->nextthink = gpGlobals->time + (0.1 + RANDOM_FLOAT(0, 1.5)); + + if (m_flDelay <= 0) + { + m_flDelay = 1.5; + } + + Precache(); } /* <257de> ../cstrike/dlls/buttons.cpp:1173 */ -NOBODY void CEnvSpark::__MAKE_VHOOK(Precache)(void) +void CEnvSpark::__MAKE_VHOOK(Precache)(void) { + PRECACHE_SOUND("buttons/spark1.wav"); + PRECACHE_SOUND("buttons/spark2.wav"); + PRECACHE_SOUND("buttons/spark3.wav"); + PRECACHE_SOUND("buttons/spark4.wav"); + PRECACHE_SOUND("buttons/spark5.wav"); + PRECACHE_SOUND("buttons/spark6.wav"); } /* <26b97> ../cstrike/dlls/buttons.cpp:1183 */ -NOBODY void CEnvSpark::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CEnvSpark::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 1185 -// FStrEq(const char *sz1, -// const char *sz2); // 1190 -// FStrEq(const char *sz1, -// const char *sz2); // 1191 -// FStrEq(const char *sz1, -// const char *sz2); // 1192 -// FStrEq(const char *sz1, -// const char *sz2); // 1193 -// FStrEq(const char *sz1, -// const char *sz2); // 1194 -// FStrEq(const char *sz1, -// const char *sz2); // 1195 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 1198 -// atof(const char *__nptr); // 1187 + if (FStrEq(pkvd->szKeyName, "MaxDelay")) + { + m_flDelay = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "style") + || FStrEq(pkvd->szKeyName, "height") + || FStrEq(pkvd->szKeyName, "killtarget") + || FStrEq(pkvd->szKeyName, "value1") + || FStrEq(pkvd->szKeyName, "value2") + || FStrEq(pkvd->szKeyName, "value3")) + pkvd->fHandled = TRUE; + else + CBaseEntity::KeyValue(pkvd); } /* <277d3> ../cstrike/dlls/buttons.cpp:1201 */ -NOBODY void CEnvSpark::SparkThink(void) +void CEnvSpark::SparkThink(void) { + pev->nextthink = gpGlobals->time + 0.1 + RANDOM_FLOAT(0, m_flDelay); + DoSpark(pev, pev->origin); } /* <25805> ../cstrike/dlls/buttons.cpp:1207 */ -NOBODY void CEnvSpark::SparkStart(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CEnvSpark::SparkStart(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { + SetUse(&CEnvSpark::SparkStop); + SetThink(&CEnvSpark::SparkThink); + pev->nextthink = gpGlobals->time + (0.1 + RANDOM_FLOAT(0, m_flDelay)); } /* <25868> ../cstrike/dlls/buttons.cpp:1214 */ -NOBODY void CEnvSpark::SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CEnvSpark::SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { + SetUse(&CEnvSpark::SparkStart); + SetThink(NULL); } /* <28011> ../cstrike/dlls/buttons.cpp:1233 */ LINK_ENTITY_TO_CLASS(button_target, CButtonTarget); /* <258ca> ../cstrike/dlls/buttons.cpp:1235 */ -NOBODY void CButtonTarget::__MAKE_VHOOK(Spawn)(void) +void CButtonTarget::__MAKE_VHOOK(Spawn)(void) { + pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + + SET_MODEL(ENT(pev), STRING(pev->model)); + pev->takedamage = DAMAGE_YES; + + if (pev->spawnflags & SF_BTARGET_ON) + { + pev->frame = 1; + } } /* <25fc3> ../cstrike/dlls/buttons.cpp:1246 */ -NOBODY void CButtonTarget::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CButtonTarget::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// Use(CButtonTarget *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 1246 + if (!ShouldToggle(useType, (int)pev->frame)) + return; + + pev->frame = 1 - pev->frame; + + if (pev->frame) + { + SUB_UseTargets(pActivator, USE_ON, 0); + } + else + SUB_UseTargets(pActivator, USE_OFF, 0); } /* <258f1> ../cstrike/dlls/buttons.cpp:1258 */ -NOBODY int CButtonTarget::__MAKE_VHOOK(ObjectCaps)(void) +int CButtonTarget::__MAKE_VHOOK(ObjectCaps)(void) { -// { -// int caps; // 1260 -// } + int caps = CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; + + if (pev->spawnflags & SF_BTARGET_USE) + return caps | FCAP_IMPULSE_USE; + else + return caps; } /* <2592e> ../cstrike/dlls/buttons.cpp:1269 */ -NOBODY int CButtonTarget::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +int CButtonTarget::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { -// Instance(entvars_t *pev); // 1271 + Use(Instance(pevAttacker), this, USE_TOGGLE, 0); + + return 1; } #ifdef HOOK_GAMEDLL @@ -704,11 +1397,6 @@ int CMomentaryRotButton::Restore(CRestore &restore) return Restore_(restore); } -int CMomentaryRotButton::ObjectCaps(void) -{ - return ObjectCaps_(); -} - void CMomentaryRotButton::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { Use_(pActivator, pCaller, useType, value); diff --git a/regamedll/dlls/buttons.h b/regamedll/dlls/buttons.h index 59d2bb9b..8811f9b0 100644 --- a/regamedll/dlls/buttons.h +++ b/regamedll/dlls/buttons.h @@ -32,15 +32,37 @@ #pragma once #endif +#define SF_BUTTON_DONTMOVE 1 +#define SF_ROTBUTTON_NOTSOLID 1 +#define SF_BUTTON_TOGGLE 32 // button stays pushed until reactivated +#define SF_BUTTON_SPARK_IF_OFF 64 // button sparks in OFF state +#define SF_BUTTON_TOUCH_ONLY 256 // button only fires as a result of USE key. + +#define SF_GLOBAL_SET 1 // Set global state to initial state on spawn + +#define SF_MULTI_INIT 1 + +// Make this button behave like a door (HACKHACK) +// This will disable use and make the button solid +// rotating buttons were made SOLID_NOT by default since their were some +// collision problems with them... +#define SF_MOMENTARY_DOOR 0x0001 + +#define SF_SPARK_TOOGLE 32 +#define SF_SPARK_IF_OFF 64 + +#define SF_BTARGET_USE 0x0001 +#define SF_BTARGET_ON 0x0002 + /* <249a3> ../cstrike/dlls/buttons.cpp:38 */ class CEnvGlobal: public CPointEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -66,10 +88,12 @@ public: class CRotButton: public CBaseButton { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL + void Spawn_(void); + #endif // HOOK_GAMEDLL };/* size: 368, cachelines: 6, members: 1 */ @@ -78,12 +102,15 @@ public: class CMomentaryRotButton: public CBaseToggle { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) + { + return ObjectCaps_(); + } + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -91,19 +118,29 @@ public: void KeyValue_(KeyValueData *pkvd); int Save_(CSave &save); int Restore_(CRestore &restore); - int ObjectCaps_(void); + int ObjectCaps_(void) + { + int flags = CBaseToggle::ObjectCaps() & (~FCAP_ACROSS_TRANSITION); + + if (pev->spawnflags & SF_MOMENTARY_DOOR) + { + return flags; + } + + return (flags | FCAP_CONTINUOUS_USE); + } void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT Off(void); - NOBODY void EXPORT Return(void); - NOBODY void UpdateSelf(float value); - NOBODY void UpdateSelfReturn(float value); - NOBODY void UpdateAllButtons(float value, int start); - NOBODY void PlaySound(void); - NOBODY void UpdateTarget(float value); + void EXPORT Off(void); + void EXPORT Return(void); + void UpdateSelf(float value); + void UpdateSelfReturn(float value); + void UpdateAllButtons(float value, int start); + void PlaySound(void); + void UpdateTarget(float value); public: static CMomentaryRotButton *Instance(edict_t *pent) { @@ -127,11 +164,11 @@ public: class CEnvSpark: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); #ifdef HOOK_GAMEDLL @@ -144,9 +181,9 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT SparkThink(void); - NOBODY void EXPORT SparkStart(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void EXPORT SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT SparkThink(void); + void EXPORT SparkStart(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; @@ -160,10 +197,10 @@ public: class CButtonTarget: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int ObjectCaps(void); - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual int ObjectCaps(void); + virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -176,7 +213,17 @@ public: };/* size: 152, cachelines: 3, members: 1 */ -NOBODY char *ButtonSound(int sound); -NOBODY void DoSpark(entvars_t *pev, const Vector &location); +char *ButtonSound(int sound); +void DoSpark(entvars_t *pev, const Vector &location); + +// linked objects +C_DLLEXPORT void env_global(entvars_t *pev); +C_DLLEXPORT void multisource(entvars_t *pev); +C_DLLEXPORT void func_button(entvars_t *pev); +C_DLLEXPORT void func_rot_button(entvars_t *pev); +C_DLLEXPORT void momentary_rot_button(entvars_t *pev); +C_DLLEXPORT void env_spark(entvars_t *pev); +C_DLLEXPORT void env_debris(entvars_t *pev); +C_DLLEXPORT void button_target(entvars_t *pev); #endif // BUTTON_H diff --git a/regamedll/dlls/career_tasks.cpp b/regamedll/dlls/career_tasks.cpp index aad86220..d9592a66 100644 --- a/regamedll/dlls/career_tasks.cpp +++ b/regamedll/dlls/career_tasks.cpp @@ -4,7 +4,7 @@ * Globals initialization */ #ifndef HOOK_GAMEDLL - + CCareerTaskManager *TheCareerTasks = NULL; const TaskInfo taskInfo[] = @@ -39,635 +39,635 @@ const TaskInfo taskInfo[21]; #endif // HOOK_GAMEDLL -/* <1ef647> ../cstrike/dlls/career_tasks.cpp:133 */ -CCareerTask *CPreventDefuseTask::NewTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) -{ - CPreventDefuseTask *pNewTask = new CPreventDefuseTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete); - - pNewTask->m_bombPlantedThisRound = false; - pNewTask->m_defuseStartedThisRound = false; - - return (CCareerTask *)pNewTask; -} - -/* <1ef5db> ../cstrike/dlls/career_tasks.cpp:139 */ -CPreventDefuseTask::CPreventDefuseTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) -{ - CCareerTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete); - - m_bombPlantedThisRound = false; - m_defuseStartedThisRound = false; -} - -/* <1ef296> ../cstrike/dlls/career_tasks.cpp:147 */ -void CPreventDefuseTask::__MAKE_VHOOK(Reset)(void) -{ - m_bombPlantedThisRound = false; - m_defuseStartedThisRound = false; - - CCareerTask::Reset(); -} - -/* <1efbf8> ../cstrike/dlls/career_tasks.cpp:156 */ -void CPreventDefuseTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim) -{ - if (IsComplete()) - return; - - if (event == EVENT_BOMB_PLANTED) - { - m_bombPlantedThisRound = true; - } - else if (event == EVENT_BOMB_DEFUSING) - { - m_defuseStartedThisRound = true; - } - - CCareerTask::OnEvent(event, pAttacker, pVictim); - - if (event >= EVENT_ROUND_DRAW && event <= EVENT_ROUND_LOSS) - { - m_bombPlantedThisRound = false; - m_defuseStartedThisRound = false; - } +/* <1ef647> ../cstrike/dlls/career_tasks.cpp:133 */ +CCareerTask *CPreventDefuseTask::NewTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) +{ + CPreventDefuseTask *pNewTask = new CPreventDefuseTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete); + + pNewTask->m_bombPlantedThisRound = false; + pNewTask->m_defuseStartedThisRound = false; + + return (CCareerTask *)pNewTask; } -/* <1ef4e1> ../cstrike/dlls/career_tasks.cpp:186 */ -CCareerTask *CCareerTask::NewTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) -{ - CCareerTask *pTask = new CCareerTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete); - return pTask; +/* <1ef5db> ../cstrike/dlls/career_tasks.cpp:139 */ +CPreventDefuseTask::CPreventDefuseTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) +{ + CCareerTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete); + + m_bombPlantedThisRound = false; + m_defuseStartedThisRound = false; } -/* <1ef43f> ../cstrike/dlls/career_tasks.cpp:192 */ -CCareerTask::CCareerTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) -{ - m_isComplete = isComplete; - m_event = event; - m_eventsNeeded = n; - - m_name = taskName; - m_eventsSeen = 0; - m_mustLive = mustLive; - m_crossRounds = crossRounds; - m_diedThisRound = false; - m_id = id; - m_weaponId = AliasToWeaponID(weaponName); - m_weaponClassId = AliasToWeaponClass(weaponName); - - m_rescuer = (Q_stricmp(taskName, "stoprescue") == 0); - m_defuser = (Q_stricmp(taskName, "killdefuser") == 0); - m_vip = (Q_stricmp(taskName, "killvip") == 0); - - if (event == EVENT_ALL_HOSTAGES_RESCUED) - { - m_mustLive = true; - m_crossRounds = false; - } - - if (m_isComplete) - { - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("TASKDONE"); - WRITE_BYTE(m_id); - MESSAGE_END(); - } +/* <1ef296> ../cstrike/dlls/career_tasks.cpp:147 */ +void CPreventDefuseTask::__MAKE_VHOOK(Reset)(void) +{ + m_bombPlantedThisRound = false; + m_defuseStartedThisRound = false; + + CCareerTask::Reset(); } -/* <1ef211> ../cstrike/dlls/career_tasks.cpp:240 */ -void CCareerTask::__MAKE_VHOOK(Reset)(void) -{ - m_eventsSeen = 0; - m_isComplete = false; - - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("TASKUNDONE"); - WRITE_BYTE(m_id); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("TASKPART"); - WRITE_BYTE(m_id); - WRITE_SHORT(m_eventsSeen); - MESSAGE_END(); -} +/* <1efbf8> ../cstrike/dlls/career_tasks.cpp:156 */ +void CPreventDefuseTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim) +{ + if (IsComplete()) + return; -/* <1ef74c> ../cstrike/dlls/career_tasks.cpp:256 */ -void CCareerTask::SendPartialNotification(void) -{ - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("TASKPART"); - WRITE_BYTE(m_id); - WRITE_SHORT(m_eventsSeen); - MESSAGE_END(); - - UTIL_LogPrintf("Career Task Partial %d %d\n", m_id, m_eventsSeen); -} + if (event == EVENT_BOMB_PLANTED) + { + m_bombPlantedThisRound = true; + } + else if (event == EVENT_BOMB_DEFUSING) + { + m_defuseStartedThisRound = true; + } -/* <1efc6c> ../cstrike/dlls/career_tasks.cpp:268 */ -void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim) -{ - if (m_isComplete || m_event != EVENT_KILL && (m_event != EVENT_HEADSHOT || !headshot)) - { - return; - } - - if (!pVictim || (m_defuser && !pVictim->m_bIsDefusing) || (m_vip && !pVictim->m_bIsVIP)) - { - return; - } - - if (m_rescuer) - { - int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; - - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) - { - CHostage *hostage = (CHostage *)hostageEntity; - - if (!hostage || hostage->pev->takedamage != DAMAGE_YES) - continue; - - if (hostage->m_improv) - { - if (!hostage->IsFollowingSomeone()) - continue; - } - else if (!hostage->m_hTargetEnt || hostage->m_State != CHostage::FOLLOW) - continue; - - if (hostage->IsValid() && hostage->m_target == pAttacker) - ++hostages_; - } - - if (!hostages_) - return; - } - - if (m_weaponId == WEAPON_SHIELDGUN) - { - if (!killerHasShield) - return; - } - else if (m_weaponId) - { - if (m_weaponId != weaponId) - return; - } - else if (m_weaponClassId) - { - if (m_weaponClassId != weaponClassId) - return; - } - - ++m_eventsSeen; - SendPartialNotification(); -} + CCareerTask::OnEvent(event, pAttacker, pVictim); -/* <1efe16> ../cstrike/dlls/career_tasks.cpp:348 */ -void CCareerTask::OnWeaponInjury(int weaponId, int weaponClassId, bool attackerHasShield, CBasePlayer *pAttacker) -{ - if (m_isComplete || m_event != EVENT_PLAYER_TOOK_DAMAGE) - { - return; - } - - if (m_weaponId == WEAPON_SHIELDGUN) - { - if (!attackerHasShield) - return; - } - else if (m_weaponId) - { - if (m_weaponId != weaponId) - return; - } - else if (m_weaponClassId) - { - if (m_weaponClassId != weaponClassId) - return; - } - - ++m_eventsSeen; - SendPartialNotification(); -} - -/* <1ef79d> ../cstrike/dlls/career_tasks.cpp:385 */ -void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVictim, CBasePlayer *pAttacker) -{ - if (m_isComplete) - return; - - if (event == m_event) - { - if ((m_defuser && !pAttacker->m_bIsDefusing) || (m_vip && !pAttacker->m_bIsVIP)) - return; - - if (m_rescuer) - { - int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; - - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) - { - if (hostageEntity->pev->takedamage != DAMAGE_YES) - continue; - - CHostage *hostage = reinterpret_cast(hostageEntity); - - if (hostage->m_improv) - { - if (!hostage->IsFollowingSomeone()) - { - continue; - } - } - else if (hostage->m_hTargetEnt == NULL || hostage->m_State != CHostage::FOLLOW) - { - continue; - } - - if (hostage->IsValid() && hostage->m_target == pAttacker) - ++hostages_; - } - - if (!hostages_) - { - return; - } - } - - if (m_event != EVENT_KILL || (!m_weaponId && !m_weaponClassId) - && m_event != EVENT_HEADSHOT || (!m_weaponId && !m_weaponClassId) - && m_event != EVENT_PLAYER_TOOK_DAMAGE || (!m_weaponId && !m_weaponClassId)) - { - if (m_event == EVENT_ROUND_WIN) - { - if (!Q_strcmp(m_name, "defendhostages")) - { - int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; - - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) - { - if (hostageEntity->pev->takedamage != 1.0f && hostageEntity->pev->deadflag != DEAD_DEAD) - ++hostages_; - } - - if (!hostages_) - { - ++m_eventsSeen; - SendPartialNotification(); - } - } - else if (!Q_strcmp(m_name, "hostagessurvive")) - { - int hostages_ = 0; - CBaseEntity *hostageEntity = NULL; - - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) - { - CHostage *hostage = (CHostage *)hostageEntity; - - if (hostage && hostage->IsDead()) - ++hostages_; - } - - if (!hostages_) - { - ++m_eventsSeen; - SendPartialNotification(); - } - } - else if (!Q_strcmp(m_name, "winfast")) - { - if (m_eventsNeeded >= TheCareerTasks->GetRoundElapsedTime()) - { - m_eventsSeen = m_eventsNeeded; - SendPartialNotification(); - } - } - else if (IsTaskCompletableThisRound()) - { - ++m_eventsSeen; - SendPartialNotification(); - } - } - else - { - ++m_eventsSeen; - SendPartialNotification(); - } - } - } - - if (event == m_event && !m_mustLive && m_eventsSeen >= m_eventsNeeded && IsTaskCompletableThisRound()) - { - CBasePlayer *player = UTIL_GetLocalPlayer(); - EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM); - - m_isComplete = true; - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("TASKDONE"); - WRITE_BYTE(m_id); - MESSAGE_END(); - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_CAREER_TASK_DONE); - } - - UTIL_LogPrintf("Career Task Done %d\n", m_id); - - if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast")) - { - TheCareerTasks->SetFinishedTaskTime((int)TheCareerTasks->GetRoundElapsedTime()); - UTIL_GetLocalPlayer()->SyncRoundTimer(); - } - } - else if (event >= EVENT_ROUND_DRAW) - { - if (event > EVENT_ROUND_LOSS) - { - if (event == EVENT_DIE && (m_mustLive || m_crossRounds)) - { - m_eventsSeen = 0; - SendPartialNotification(); - m_diedThisRound = true; - } - } - else if (m_mustLive) - { - if (m_eventsSeen >= m_eventsNeeded && !m_diedThisRound && IsTaskCompletableThisRound()) - { - CBasePlayer *player = UTIL_GetLocalPlayer(); - EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM); - - m_isComplete = true; - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("TASKDONE"); - WRITE_BYTE(m_id); - MESSAGE_END(); - - UTIL_LogPrintf("Career Task Done %d\n", m_id); - - if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast")) - { - TheCareerTasks->SetFinishedTaskTime((signed __int64)(TheCareerTasks->GetRoundElapsedTime())); - UTIL_GetLocalPlayer()->SyncRoundTimer(); - } - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_CAREER_TASK_DONE); - } - } - - m_diedThisRound = false; - - if (m_mustLive) - { - m_eventsSeen = 0; - SendPartialNotification(); - } - } - } -} - -/* <1efeed> ../cstrike/dlls/career_tasks.cpp:623 */ -void CCareerTaskManager::Create(void) -{ - if (TheCareerTasks != NULL) - { - TheCareerTasks->Reset(); - return; - } - - TheCareerTasks = new CCareerTaskManager; -} - -/* <1eff77> ../cstrike/dlls/career_tasks.cpp:636 */ -CCareerTaskManager::CCareerTaskManager(void) -{ - m_taskTime = 0; - Reset(); -} - -/* <1effeb> ../cstrike/dlls/career_tasks.cpp:643 */ -void CCareerTaskManager::Reset(bool deleteTasks) -{ - if (deleteTasks) - { - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - delete (*it); - } - - m_tasks.clear(); - m_nextId = 0; - } - else - { - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - CCareerTask *pTask = (*it); - pTask->Reset(); - } - } - - m_finishedTaskTime = 0; - m_finishedTaskRound = 0; - m_shouldLatchRoundEndMessage = false; - - m_roundStartTime = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime"); -} - -/* <1f014e> ../cstrike/dlls/career_tasks.cpp:671 */ -void CCareerTaskManager::SetFinishedTaskTime(int val) -{ - CHalfLifeMultiplay *mp = g_pGameRules; - - m_finishedTaskTime = val; - m_finishedTaskRound = mp->m_iTotalRoundsPlayed; -} - -/* <1f018b> ../cstrike/dlls/career_tasks.cpp:679 */ -void CCareerTaskManager::AddTask(const char *taskName, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, bool isComplete) -{ - ++m_nextId; - - for (int i = 0; i < ARRAYSIZE(taskInfo); i++) - { - const TaskInfo *pTaskInfo = &taskInfo[ i ]; - - if (pTaskInfo->taskName != NULL) - { - if (!Q_stricmp(pTaskInfo->taskName, taskName)) - { - CCareerTask *newTask = pTaskInfo->factory - ( - pTaskInfo->taskName, - pTaskInfo->event, - weaponName, - eventCount, - mustLive, - crossRounds, - m_nextId, - isComplete - ); - - m_tasks.push_back(newTask); - - if (pTaskInfo->event == EVENT_ROUND_WIN && !Q_strcmp(taskName, "winfast")) - { - m_taskTime = eventCount; - - if (isComplete) - { - m_finishedTaskTime = eventCount; - } - } - - return; - } - } - } - - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("TASKDONE"); - WRITE_BYTE(m_nextId); - MESSAGE_END(); -} - -/* <1f0381> ../cstrike/dlls/career_tasks.cpp:721 */ -void CCareerTaskManager::HandleEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim) -{ - if (event == EVENT_ROUND_START) - { - m_roundStartTime = gpGlobals->time; - return; - } - - if ((event <= EVENT_ROUND_LOSS && event >= EVENT_ROUND_DRAW) && m_shouldLatchRoundEndMessage) - { - m_roundEndMessage = event; - return; - } - - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - (*it)->OnEvent(event, pAttacker, pVictim); - } -} - -/* <1f0462> ../cstrike/dlls/career_tasks.cpp:748 */ -void CCareerTaskManager::HandleWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim) -{ - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - (*it)->OnWeaponKill(weaponId, weaponClassId, headshot, killerHasShield, pAttacker, pVictim); - } -} - -/* <1f04ed> ../cstrike/dlls/career_tasks.cpp:757 */ -void CCareerTaskManager::HandleEnemyKill(bool wasBlind, const char *weaponName, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim) -{ - HandleWeaponKill(AliasToWeaponID(weaponName), AliasToWeaponClass(weaponName), headshot, killerHasShield, pAttacker, pVictim); - - HandleEvent(EVENT_KILL, pAttacker, pVictim); - - if (headshot) - { - HandleEvent(EVENT_HEADSHOT, pAttacker, pVictim); - } - if (wasBlind) - { - HandleEvent(EVENT_KILL_FLASHBANGED, pAttacker, pVictim); - } -} - -/* <1f079c> ../cstrike/dlls/career_tasks.cpp:768 */ -void CCareerTaskManager::HandleWeaponInjury(int weaponId, int weaponClassId, bool attackerHasShield, CBasePlayer *pAttacker) -{ - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - (*it)->OnWeaponInjury(weaponId, weaponClassId, attackerHasShield, pAttacker); - } -} - -/* <1f0815> ../cstrike/dlls/career_tasks.cpp:777 */ -void CCareerTaskManager::HandleEnemyInjury(const char *weaponName, bool attackerHasShield, CBasePlayer *pAttacker) -{ - HandleWeaponInjury(AliasToWeaponID(weaponName), AliasToWeaponClass(weaponName), attackerHasShield, pAttacker); - HandleEvent(EVENT_PLAYER_TOOK_DAMAGE); -} - -/* <1f094e> ../cstrike/dlls/career_tasks.cpp:784 */ -void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker) -{ - int enemyTeam = (Q_strcmp(humans_join_team.string, "CT") != 0) ? CT : TERRORIST; - int numEnemies = 0; - - if (enemyTeam != team) - return; - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); - - if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive()) - ++numEnemies; - } - - if (!numEnemies) - { - HandleEvent(EVENT_KILL_ALL); + if (event >= EVENT_ROUND_DRAW && event <= EVENT_ROUND_LOSS) + { + m_bombPlantedThisRound = false; + m_defuseStartedThisRound = false; } } -/* <1f0a5d> ../cstrike/dlls/career_tasks.cpp:805 */ -bool CCareerTaskManager::AreAllTasksComplete(void) -{ - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - if (!(*it)->IsComplete()) - return false; - } - - return true; +/* <1ef4e1> ../cstrike/dlls/career_tasks.cpp:186 */ +CCareerTask *CCareerTask::NewTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) +{ + CCareerTask *pTask = new CCareerTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete); + return pTask; } -/* <1f0abc> ../cstrike/dlls/career_tasks.cpp:818 */ -int CCareerTaskManager::GetNumRemainingTasks(void) -{ - int ret = 0; - for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) - { - if (!(*it)->IsComplete()) - ret++; - } - - return ret; +/* <1ef43f> ../cstrike/dlls/career_tasks.cpp:192 */ +CCareerTask::CCareerTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) +{ + m_isComplete = isComplete; + m_event = event; + m_eventsNeeded = n; + + m_name = taskName; + m_eventsSeen = 0; + m_mustLive = mustLive; + m_crossRounds = crossRounds; + m_diedThisRound = false; + m_id = id; + m_weaponId = AliasToWeaponID(weaponName); + m_weaponClassId = AliasToWeaponClass(weaponName); + + m_rescuer = (Q_stricmp(taskName, "stoprescue") == 0); + m_defuser = (Q_stricmp(taskName, "killdefuser") == 0); + m_vip = (Q_stricmp(taskName, "killvip") == 0); + + if (event == EVENT_ALL_HOSTAGES_RESCUED) + { + m_mustLive = true; + m_crossRounds = false; + } + + if (m_isComplete) + { + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("TASKDONE"); + WRITE_BYTE(m_id); + MESSAGE_END(); + } } -/* <1f0b33> ../cstrike/dlls/career_tasks.cpp:832 */ -float CCareerTaskManager::GetRoundElapsedTime(void) -{ - return (gpGlobals->time - m_roundStartTime); +/* <1ef211> ../cstrike/dlls/career_tasks.cpp:240 */ +void CCareerTask::__MAKE_VHOOK(Reset)(void) +{ + m_eventsSeen = 0; + m_isComplete = false; + + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("TASKUNDONE"); + WRITE_BYTE(m_id); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("TASKPART"); + WRITE_BYTE(m_id); + WRITE_SHORT(m_eventsSeen); + MESSAGE_END(); } -/* <1f0b56> ../cstrike/dlls/career_tasks.cpp:838 */ -void CCareerTaskManager::LatchRoundEndMessage(void) -{ - m_shouldLatchRoundEndMessage = true; +/* <1ef74c> ../cstrike/dlls/career_tasks.cpp:256 */ +void CCareerTask::SendPartialNotification(void) +{ + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("TASKPART"); + WRITE_BYTE(m_id); + WRITE_SHORT(m_eventsSeen); + MESSAGE_END(); + + UTIL_LogPrintf("Career Task Partial %d %d\n", m_id, m_eventsSeen); } -/* <1f0b81> ../cstrike/dlls/career_tasks.cpp:844 */ -void CCareerTaskManager::UnlatchRoundEndMessage(void) -{ +/* <1efc6c> ../cstrike/dlls/career_tasks.cpp:268 */ +void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim) +{ + if (m_isComplete || m_event != EVENT_KILL && (m_event != EVENT_HEADSHOT || !headshot)) + { + return; + } + + if (!pVictim || (m_defuser && !pVictim->m_bIsDefusing) || (m_vip && !pVictim->m_bIsVIP)) + { + return; + } + + if (m_rescuer) + { + int hostages_ = 0; + CBaseEntity *hostageEntity = NULL; + + while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + { + CHostage *hostage = (CHostage *)hostageEntity; + + if (!hostage || hostage->pev->takedamage != DAMAGE_YES) + continue; + + if (hostage->m_improv) + { + if (!hostage->IsFollowingSomeone()) + continue; + } + else if (!hostage->m_hTargetEnt || hostage->m_State != CHostage::FOLLOW) + continue; + + if (hostage->IsValid() && hostage->m_target == pAttacker) + ++hostages_; + } + + if (!hostages_) + return; + } + + if (m_weaponId == WEAPON_SHIELDGUN) + { + if (!killerHasShield) + return; + } + else if (m_weaponId) + { + if (m_weaponId != weaponId) + return; + } + else if (m_weaponClassId) + { + if (m_weaponClassId != weaponClassId) + return; + } + + ++m_eventsSeen; + SendPartialNotification(); +} + +/* <1efe16> ../cstrike/dlls/career_tasks.cpp:348 */ +void CCareerTask::OnWeaponInjury(int weaponId, int weaponClassId, bool attackerHasShield, CBasePlayer *pAttacker) +{ + if (m_isComplete || m_event != EVENT_PLAYER_TOOK_DAMAGE) + { + return; + } + + if (m_weaponId == WEAPON_SHIELDGUN) + { + if (!attackerHasShield) + return; + } + else if (m_weaponId) + { + if (m_weaponId != weaponId) + return; + } + else if (m_weaponClassId) + { + if (m_weaponClassId != weaponClassId) + return; + } + + ++m_eventsSeen; + SendPartialNotification(); +} + +/* <1ef79d> ../cstrike/dlls/career_tasks.cpp:385 */ +void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVictim, CBasePlayer *pAttacker) +{ + if (m_isComplete) + return; + + if (event == m_event) + { + if ((m_defuser && !pAttacker->m_bIsDefusing) || (m_vip && !pAttacker->m_bIsVIP)) + return; + + if (m_rescuer) + { + int hostages_ = 0; + CBaseEntity *hostageEntity = NULL; + + while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + { + if (hostageEntity->pev->takedamage != DAMAGE_YES) + continue; + + CHostage *hostage = reinterpret_cast(hostageEntity); + + if (hostage->m_improv) + { + if (!hostage->IsFollowingSomeone()) + { + continue; + } + } + else if (hostage->m_hTargetEnt == NULL || hostage->m_State != CHostage::FOLLOW) + { + continue; + } + + if (hostage->IsValid() && hostage->m_target == pAttacker) + ++hostages_; + } + + if (!hostages_) + { + return; + } + } + + if (m_event != EVENT_KILL || (!m_weaponId && !m_weaponClassId) + && m_event != EVENT_HEADSHOT || (!m_weaponId && !m_weaponClassId) + && m_event != EVENT_PLAYER_TOOK_DAMAGE || (!m_weaponId && !m_weaponClassId)) + { + if (m_event == EVENT_ROUND_WIN) + { + if (!Q_strcmp(m_name, "defendhostages")) + { + int hostages_ = 0; + CBaseEntity *hostageEntity = NULL; + + while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + { + if (hostageEntity->pev->takedamage != 1.0f && hostageEntity->pev->deadflag != DEAD_DEAD) + ++hostages_; + } + + if (!hostages_) + { + ++m_eventsSeen; + SendPartialNotification(); + } + } + else if (!Q_strcmp(m_name, "hostagessurvive")) + { + int hostages_ = 0; + CBaseEntity *hostageEntity = NULL; + + while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity")) != NULL) + { + CHostage *hostage = (CHostage *)hostageEntity; + + if (hostage && hostage->IsDead()) + ++hostages_; + } + + if (!hostages_) + { + ++m_eventsSeen; + SendPartialNotification(); + } + } + else if (!Q_strcmp(m_name, "winfast")) + { + if (m_eventsNeeded >= TheCareerTasks->GetRoundElapsedTime()) + { + m_eventsSeen = m_eventsNeeded; + SendPartialNotification(); + } + } + else if (IsTaskCompletableThisRound()) + { + ++m_eventsSeen; + SendPartialNotification(); + } + } + else + { + ++m_eventsSeen; + SendPartialNotification(); + } + } + } + + if (event == m_event && !m_mustLive && m_eventsSeen >= m_eventsNeeded && IsTaskCompletableThisRound()) + { + CBasePlayer *player = UTIL_GetLocalPlayer(); + EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM); + + m_isComplete = true; + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("TASKDONE"); + WRITE_BYTE(m_id); + MESSAGE_END(); + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_CAREER_TASK_DONE); + } + + UTIL_LogPrintf("Career Task Done %d\n", m_id); + + if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast")) + { + TheCareerTasks->SetFinishedTaskTime((int)TheCareerTasks->GetRoundElapsedTime()); + UTIL_GetLocalPlayer()->SyncRoundTimer(); + } + } + else if (event >= EVENT_ROUND_DRAW) + { + if (event > EVENT_ROUND_LOSS) + { + if (event == EVENT_DIE && (m_mustLive || m_crossRounds)) + { + m_eventsSeen = 0; + SendPartialNotification(); + m_diedThisRound = true; + } + } + else if (m_mustLive) + { + if (m_eventsSeen >= m_eventsNeeded && !m_diedThisRound && IsTaskCompletableThisRound()) + { + CBasePlayer *player = UTIL_GetLocalPlayer(); + EMIT_SOUND(ENT(player->pev), CHAN_VOICE, "events/task_complete.wav", VOL_NORM, ATTN_NORM); + + m_isComplete = true; + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("TASKDONE"); + WRITE_BYTE(m_id); + MESSAGE_END(); + + UTIL_LogPrintf("Career Task Done %d\n", m_id); + + if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast")) + { + TheCareerTasks->SetFinishedTaskTime((signed __int64)(TheCareerTasks->GetRoundElapsedTime())); + UTIL_GetLocalPlayer()->SyncRoundTimer(); + } + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_CAREER_TASK_DONE); + } + } + + m_diedThisRound = false; + + if (m_mustLive) + { + m_eventsSeen = 0; + SendPartialNotification(); + } + } + } +} + +/* <1efeed> ../cstrike/dlls/career_tasks.cpp:623 */ +void CCareerTaskManager::Create(void) +{ + if (TheCareerTasks != NULL) + { + TheCareerTasks->Reset(); + return; + } + + TheCareerTasks = new CCareerTaskManager; +} + +/* <1eff77> ../cstrike/dlls/career_tasks.cpp:636 */ +CCareerTaskManager::CCareerTaskManager(void) +{ + m_taskTime = 0; + Reset(); +} + +/* <1effeb> ../cstrike/dlls/career_tasks.cpp:643 */ +void CCareerTaskManager::Reset(bool deleteTasks) +{ + if (deleteTasks) + { + for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) + { + delete (*it); + } + + m_tasks.clear(); + m_nextId = 0; + } + else + { + for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) + { + CCareerTask *pTask = (*it); + pTask->Reset(); + } + } + + m_finishedTaskTime = 0; + m_finishedTaskRound = 0; m_shouldLatchRoundEndMessage = false; - HandleEvent(m_roundEndMessage); + + m_roundStartTime = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime"); +} + +/* <1f014e> ../cstrike/dlls/career_tasks.cpp:671 */ +void CCareerTaskManager::SetFinishedTaskTime(int val) +{ + CHalfLifeMultiplay *mp = g_pGameRules; + + m_finishedTaskTime = val; + m_finishedTaskRound = mp->m_iTotalRoundsPlayed; +} + +/* <1f018b> ../cstrike/dlls/career_tasks.cpp:679 */ +void CCareerTaskManager::AddTask(const char *taskName, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, bool isComplete) +{ + ++m_nextId; + + for (int i = 0; i < ARRAYSIZE(taskInfo); i++) + { + const TaskInfo *pTaskInfo = &taskInfo[ i ]; + + if (pTaskInfo->taskName != NULL) + { + if (!Q_stricmp(pTaskInfo->taskName, taskName)) + { + CCareerTask *newTask = pTaskInfo->factory + ( + pTaskInfo->taskName, + pTaskInfo->event, + weaponName, + eventCount, + mustLive, + crossRounds, + m_nextId, + isComplete + ); + + m_tasks.push_back(newTask); + + if (pTaskInfo->event == EVENT_ROUND_WIN && !Q_strcmp(taskName, "winfast")) + { + m_taskTime = eventCount; + + if (isComplete) + { + m_finishedTaskTime = eventCount; + } + } + + return; + } + } + } + + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("TASKDONE"); + WRITE_BYTE(m_nextId); + MESSAGE_END(); +} + +/* <1f0381> ../cstrike/dlls/career_tasks.cpp:721 */ +void CCareerTaskManager::HandleEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim) +{ + if (event == EVENT_ROUND_START) + { + m_roundStartTime = gpGlobals->time; + return; + } + + if ((event <= EVENT_ROUND_LOSS && event >= EVENT_ROUND_DRAW) && m_shouldLatchRoundEndMessage) + { + m_roundEndMessage = event; + return; + } + + for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) + { + (*it)->OnEvent(event, pAttacker, pVictim); + } +} + +/* <1f0462> ../cstrike/dlls/career_tasks.cpp:748 */ +void CCareerTaskManager::HandleWeaponKill(int weaponId, int weaponClassId, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim) +{ + for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) + { + (*it)->OnWeaponKill(weaponId, weaponClassId, headshot, killerHasShield, pAttacker, pVictim); + } +} + +/* <1f04ed> ../cstrike/dlls/career_tasks.cpp:757 */ +void CCareerTaskManager::HandleEnemyKill(bool wasBlind, const char *weaponName, bool headshot, bool killerHasShield, CBasePlayer *pAttacker, CBasePlayer *pVictim) +{ + HandleWeaponKill(AliasToWeaponID(weaponName), AliasToWeaponClass(weaponName), headshot, killerHasShield, pAttacker, pVictim); + + HandleEvent(EVENT_KILL, pAttacker, pVictim); + + if (headshot) + { + HandleEvent(EVENT_HEADSHOT, pAttacker, pVictim); + } + if (wasBlind) + { + HandleEvent(EVENT_KILL_FLASHBANGED, pAttacker, pVictim); + } +} + +/* <1f079c> ../cstrike/dlls/career_tasks.cpp:768 */ +void CCareerTaskManager::HandleWeaponInjury(int weaponId, int weaponClassId, bool attackerHasShield, CBasePlayer *pAttacker) +{ + for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) + { + (*it)->OnWeaponInjury(weaponId, weaponClassId, attackerHasShield, pAttacker); + } +} + +/* <1f0815> ../cstrike/dlls/career_tasks.cpp:777 */ +void CCareerTaskManager::HandleEnemyInjury(const char *weaponName, bool attackerHasShield, CBasePlayer *pAttacker) +{ + HandleWeaponInjury(AliasToWeaponID(weaponName), AliasToWeaponClass(weaponName), attackerHasShield, pAttacker); + HandleEvent(EVENT_PLAYER_TOOK_DAMAGE); +} + +/* <1f094e> ../cstrike/dlls/career_tasks.cpp:784 */ +void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker) +{ + int enemyTeam = (Q_strcmp(humans_join_team.string, "CT") != 0) ? CT : TERRORIST; + int numEnemies = 0; + + if (enemyTeam != team) + return; + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive()) + ++numEnemies; + } + + if (!numEnemies) + { + HandleEvent(EVENT_KILL_ALL); + } +} + +/* <1f0a5d> ../cstrike/dlls/career_tasks.cpp:805 */ +bool CCareerTaskManager::AreAllTasksComplete(void) +{ + for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) + { + if (!(*it)->IsComplete()) + return false; + } + + return true; +} + +/* <1f0abc> ../cstrike/dlls/career_tasks.cpp:818 */ +int CCareerTaskManager::GetNumRemainingTasks(void) +{ + int ret = 0; + for (CareerTaskListIt it = m_tasks.begin(); it != m_tasks.end(); ++it) + { + if (!(*it)->IsComplete()) + ret++; + } + + return ret; +} + +/* <1f0b33> ../cstrike/dlls/career_tasks.cpp:832 */ +float CCareerTaskManager::GetRoundElapsedTime(void) +{ + return (gpGlobals->time - m_roundStartTime); +} + +/* <1f0b56> ../cstrike/dlls/career_tasks.cpp:838 */ +void CCareerTaskManager::LatchRoundEndMessage(void) +{ + m_shouldLatchRoundEndMessage = true; +} + +/* <1f0b81> ../cstrike/dlls/career_tasks.cpp:844 */ +void CCareerTaskManager::UnlatchRoundEndMessage(void) +{ + m_shouldLatchRoundEndMessage = false; + HandleEvent(m_roundEndMessage); } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/career_tasks.h b/regamedll/dlls/career_tasks.h index 7f2126ce..9f620800 100644 --- a/regamedll/dlls/career_tasks.h +++ b/regamedll/dlls/career_tasks.h @@ -38,7 +38,7 @@ class CCareerTask { public: - CCareerTask(void) { }; + CCareerTask(void) {}; CCareerTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete); public: virtual void OnEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim); @@ -82,7 +82,7 @@ public: { return m_weaponClassId; } - bool IsValidFor(CBasePlayer *pPlayer)//! + bool IsValidFor(CBasePlayer *pPlayer) { return true; } diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 7de87ad2..7e69cced 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -67,14 +67,14 @@ static NEW_DLL_FUNCTIONS gNewDLLFunctions NULL }; -// Global Savedata for Delay -TYPEDESCRIPTION CBaseEntity::m_SaveData[] = -{ - DEFINE_FIELD(CBaseEntity, m_pGoalEnt, FIELD_CLASSPTR), - DEFINE_FIELD(CBaseEntity, m_pfnThink, FIELD_FUNCTION), // UNDONE: Build table of these!!! - DEFINE_FIELD(CBaseEntity, m_pfnTouch, FIELD_FUNCTION), - DEFINE_FIELD(CBaseEntity, m_pfnUse, FIELD_FUNCTION), - DEFINE_FIELD(CBaseEntity, m_pfnBlocked, FIELD_FUNCTION), +// Global Savedata for Delay +TYPEDESCRIPTION CBaseEntity::m_SaveData[] = +{ + DEFINE_FIELD(CBaseEntity, m_pGoalEnt, FIELD_CLASSPTR), + DEFINE_FIELD(CBaseEntity, m_pfnThink, FIELD_FUNCTION), // UNDONE: Build table of these!!! + DEFINE_FIELD(CBaseEntity, m_pfnTouch, FIELD_FUNCTION), + DEFINE_FIELD(CBaseEntity, m_pfnUse, FIELD_FUNCTION), + DEFINE_FIELD(CBaseEntity, m_pfnBlocked, FIELD_FUNCTION), }; CMemoryPool hashItemMemPool(sizeof(hash_item_t), 64); @@ -91,202 +91,202 @@ BOOL gTouchDisabled; #endif // HOOK_GAMEDLL -/* <30850> ../cstrike/dlls/cbase.cpp:117 */ -int CaseInsensitiveHash(const char *string, int iBounds) -{ - unsigned int hash = 0; - - if (!string[0]) - { - return 0; - } - - while (*string) - { - if (*string < 'A' || *string > 'Z') - hash = *string + 2 * hash; - else - hash = *string + 2 * hash + ' '; - string++; - } - return (hash % iBounds); -} - -/* <30d81> ../cstrike/dlls/cbase.cpp:136 */ -void EmptyEntityHashTable(void) -{ - int i; - hash_item_t *item; - hash_item_t *temp; - hash_item_t *free; - - for (i = 0; i < stringsHashTable.Count(); i++) - { - item = &stringsHashTable[i]; - temp = item->next; - - item->pev = NULL; - item->pevIndex = 0; - item->lastHash = 0; - item->next = NULL; - - while (temp) - { +/* <30850> ../cstrike/dlls/cbase.cpp:117 */ +int CaseInsensitiveHash(const char *string, int iBounds) +{ + unsigned int hash = 0; + + if (!string[0]) + { + return 0; + } + + while (*string) + { + if (*string < 'A' || *string > 'Z') + hash = *string + 2 * hash; + else + hash = *string + 2 * hash + ' '; + string++; + } + return (hash % iBounds); +} + +/* <30d81> ../cstrike/dlls/cbase.cpp:136 */ +void EmptyEntityHashTable(void) +{ + int i; + hash_item_t *item; + hash_item_t *temp; + hash_item_t *free; + + for (i = 0; i < stringsHashTable.Count(); i++) + { + item = &stringsHashTable[i]; + temp = item->next; + + item->pev = NULL; + item->pevIndex = 0; + item->lastHash = 0; + item->next = NULL; + + while (temp) + { free = temp; - temp = temp->next; - hashItemMemPool.Free(free); - } - } -} - -/* <2f053> ../cstrike/dlls/cbase.cpp:156 */ -void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) -{ - int count; - hash_item_t *item; - hash_item_t *next; - hash_item_t *temp; - hash_item_t *newp; - int hash; - int pevIndex; - entvars_t *pevtemp; - - if (fieldType != CLASSNAME) - return; - - if (FStringNull(pev->classname)) - return; - - count = stringsHashTable.Count(); - hash = CaseInsensitiveHash(value, count); - pevIndex = ENTINDEX(ENT(pev)); - item = &stringsHashTable[hash]; - - while (item->pev) - { - if (!strcmp(STRING(item->pev->classname), STRING(pev->classname))) - break; - - hash = (hash + 1) % count; - item = &stringsHashTable[hash]; - } - if (item->pev) - { - next = item->next; - while (next) - { - if (item->pev == pev || item->pevIndex >= pevIndex) - break; - - item = next; - next = next->next; - } - if (pevIndex < item->pevIndex) - { - pevtemp = item->pev; - item->pev = pev; - item->lastHash = NULL; - item->pevIndex = pevIndex; - - pevIndex = ENTINDEX(ENT(pevtemp)); - } - else - pevtemp = pev; - - if (item->pev != pevtemp) - { - temp = item->next; - newp = (hash_item_t *)hashItemMemPool.Alloc(sizeof(hash_item_t)); - - item->next = newp; - newp->pev = pevtemp; - newp->lastHash = NULL; - newp->pevIndex = pevIndex; - - if (next) - newp->next = temp; - else - newp->next = NULL; - } - } - else - { - item->pev = pev; - item->lastHash = NULL; - item->pevIndex = ENTINDEX(ENT(pev)); - } -} - -/* <2f0c8> ../cstrike/dlls/cbase.cpp:255 */ -void RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) -{ - int hash; - hash_item_t *item; - hash_item_t *last; - int pevIndex; - int count; - - count = stringsHashTable.Count(); - hash = CaseInsensitiveHash(value, count); - pevIndex = ENTINDEX(ENT(pev)); - - if (fieldType != CLASSNAME) - return; - - hash = hash % count; - item = &stringsHashTable[hash]; - - while (item->pev) - { - if (!strcmp(STRING(item->pev->classname), STRING(pev->classname))) - break; - - hash = (hash + 1) % count; - item = &stringsHashTable[hash]; - } - if (item->pev) - { - last = item; - while (item->next) - { - if (item->pev == pev) - break; - - last = item; - item = item->next; - } - if (item->pev == pev) - { - if (last == item) - { - if (item->next) - { - item->pev = item->next->pev; - item->pevIndex = item->next->pevIndex; - item->lastHash = NULL; - item->next = item->next->next; - } - else - { - item->pev = NULL; - item->lastHash = NULL; - item->pevIndex = 0; - } - } - else - { - if (stringsHashTable[hash].lastHash == item) - stringsHashTable[hash].lastHash = NULL; - - last->next = item->next; - hashItemMemPool.Free(item); - } - } - } -} - -/* <31125> ../cstrike/dlls/cbase.cpp:337 */ -void printEntities(void) + temp = temp->next; + hashItemMemPool.Free(free); + } + } +} + +/* <2f053> ../cstrike/dlls/cbase.cpp:156 */ +void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) +{ + int count; + hash_item_t *item; + hash_item_t *next; + hash_item_t *temp; + hash_item_t *newp; + int hash; + int pevIndex; + entvars_t *pevtemp; + + if (fieldType != CLASSNAME) + return; + + if (FStringNull(pev->classname)) + return; + + count = stringsHashTable.Count(); + hash = CaseInsensitiveHash(value, count); + pevIndex = ENTINDEX(ENT(pev)); + item = &stringsHashTable[hash]; + + while (item->pev) + { + if (!strcmp(STRING(item->pev->classname), STRING(pev->classname))) + break; + + hash = (hash + 1) % count; + item = &stringsHashTable[hash]; + } + if (item->pev) + { + next = item->next; + while (next) + { + if (item->pev == pev || item->pevIndex >= pevIndex) + break; + + item = next; + next = next->next; + } + if (pevIndex < item->pevIndex) + { + pevtemp = item->pev; + item->pev = pev; + item->lastHash = NULL; + item->pevIndex = pevIndex; + + pevIndex = ENTINDEX(ENT(pevtemp)); + } + else + pevtemp = pev; + + if (item->pev != pevtemp) + { + temp = item->next; + newp = (hash_item_t *)hashItemMemPool.Alloc(sizeof(hash_item_t)); + + item->next = newp; + newp->pev = pevtemp; + newp->lastHash = NULL; + newp->pevIndex = pevIndex; + + if (next) + newp->next = temp; + else + newp->next = NULL; + } + } + else + { + item->pev = pev; + item->lastHash = NULL; + item->pevIndex = ENTINDEX(ENT(pev)); + } +} + +/* <2f0c8> ../cstrike/dlls/cbase.cpp:255 */ +void RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) +{ + int hash; + hash_item_t *item; + hash_item_t *last; + int pevIndex; + int count; + + count = stringsHashTable.Count(); + hash = CaseInsensitiveHash(value, count); + pevIndex = ENTINDEX(ENT(pev)); + + if (fieldType != CLASSNAME) + return; + + hash = hash % count; + item = &stringsHashTable[hash]; + + while (item->pev) + { + if (!strcmp(STRING(item->pev->classname), STRING(pev->classname))) + break; + + hash = (hash + 1) % count; + item = &stringsHashTable[hash]; + } + if (item->pev) + { + last = item; + while (item->next) + { + if (item->pev == pev) + break; + + last = item; + item = item->next; + } + if (item->pev == pev) + { + if (last == item) + { + if (item->next) + { + item->pev = item->next->pev; + item->pevIndex = item->next->pevIndex; + item->lastHash = NULL; + item->next = item->next->next; + } + else + { + item->pev = NULL; + item->lastHash = NULL; + item->pevIndex = 0; + } + } + else + { + if (stringsHashTable[hash].lastHash == item) + stringsHashTable[hash].lastHash = NULL; + + last->next = item->next; + hashItemMemPool.Free(item); + } + } + } +} + +/* <31125> ../cstrike/dlls/cbase.cpp:337 */ +void printEntities(void) { for (int i = 0; i < stringsHashTable.Count(); i++) { @@ -300,29 +300,29 @@ void printEntities(void) for (item = stringsHashTable[i].next; item; item = item->next) { UTIL_LogPrintf("Print: %s %i %p\n", STRING(item->pev->classname), ENTINDEX(ENT(item->pev)), item->pev); - } - } -} - -/* <311e9> ../cstrike/dlls/cbase.cpp:354 */ -edict_t *CREATE_NAMED_ENTITY(string_t iClass) -{ - edict_t *named = g_engfuncs.pfnCreateNamedEntity(iClass); - if (named) - AddEntityHashValue(&named->v, STRING(iClass), CLASSNAME); - return named; -} - -/* <31249> ../cstrike/dlls/cbase.cpp:366 */ -void REMOVE_ENTITY(edict_t *e) -{ + } + } +} + +/* <311e9> ../cstrike/dlls/cbase.cpp:354 */ +edict_t *CREATE_NAMED_ENTITY(string_t iClass) +{ + edict_t *named = g_engfuncs.pfnCreateNamedEntity(iClass); + if (named) + AddEntityHashValue(&named->v, STRING(iClass), CLASSNAME); + return named; +} + +/* <31249> ../cstrike/dlls/cbase.cpp:366 */ +void REMOVE_ENTITY(edict_t *e) +{ if (e) - (*g_engfuncs.pfnRemoveEntity)(e); -} - -/* <30158> ../cstrike/dlls/cbase.cpp:375 */ -void CONSOLE_ECHO_(char *pszMsg, ...) -{ + (*g_engfuncs.pfnRemoveEntity)(e); +} + +/* <30158> ../cstrike/dlls/cbase.cpp:375 */ +void CONSOLE_ECHO_(char *pszMsg, ...) +{ va_list argptr; static char szStr[1024]; @@ -330,12 +330,12 @@ void CONSOLE_ECHO_(char *pszMsg, ...) vsprintf(szStr, pszMsg, argptr); va_end(argptr); - SERVER_PRINT(szStr); -} - -/* <31273> ../cstrike/dlls/cbase.cpp:386 */ -void loopPerformance(void) -{ + SERVER_PRINT(szStr); +} + +/* <31273> ../cstrike/dlls/cbase.cpp:386 */ +void loopPerformance(void) +{ CPerformanceCounter loopCounter; loopCounter.InitializePerformanceCounter(); @@ -383,122 +383,122 @@ void loopPerformance(void) } end = loopCounter.GetCurTime(); - CONSOLE_ECHO(" Time in new search loop %.4f\n", (end - start) * 1000.0); -} - -/* <313df> ../cstrike/dlls/cbase.cpp:451 */ -C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion) -{ + CONSOLE_ECHO(" Time in new search loop %.4f\n", (end - start) * 1000.0); +} + +/* <313df> ../cstrike/dlls/cbase.cpp:451 */ +C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion) +{ if (!pFunctionTable || interfaceVersion != INTERFACE_VERSION) - return 0; - - Q_memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); - stringsHashTable.AddMultipleToTail(2048); - + return 0; + + Q_memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); + stringsHashTable.AddMultipleToTail(2048); + for (int i = 0; i < stringsHashTable.Count(); i++) - { - stringsHashTable[i].next = NULL; - } - - EmptyEntityHashTable(); - return 1; -} - -/* <3161a> ../cstrike/dlls/cbase.cpp:471 */ -NOXREF extern "C" C_EXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) -{ - if (!pFunctionTable || *interfaceVersion != INTERFACE_VERSION) - { - *interfaceVersion = INTERFACE_VERSION; - return 0; - } - - Q_memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); - return 1; -} - -/* <3165b> ../cstrike/dlls/cbase.cpp:485 */ -extern "C" C_EXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) -{ - if (!pFunctionTable || *interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) - { - *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION; - return 0; - } - Q_memcpy(pFunctionTable, &gNewDLLFunctions, sizeof(NEW_DLL_FUNCTIONS)); - return 1; -} - -/* <30ab0> ../cstrike/dlls/cbase.cpp:498 */ -int DispatchSpawn(edict_t *pent) -{ - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - if (pEntity != NULL) - { - // Initialize these or entities who don't link to the world won't have anything in here - pEntity->pev->absmin = pEntity->pev->origin - Vector(1, 1, 1); - pEntity->pev->absmax = pEntity->pev->origin + Vector(1, 1, 1); - pEntity->Spawn(); - - // Try to get the pointer again, in case the spawn function deleted the entity. - // UNDONE: Spawn() should really return a code to ask that the entity be deleted, but - // that would touch too much code for me to do that right now. - pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - if (pEntity) - { - if (g_pGameRules && !g_pGameRules->IsAllowedToSpawn(pEntity)) - { - // return that this entity should be deleted - return -1; - } - - if (pEntity->pev->flags & FL_KILLME) - { - return -1; - } - } - - // Handle global stuff here - if (pEntity && pEntity->pev->globalname) - { - const globalentity_t *pGlobal = gGlobalState.EntityFromTable(pEntity->pev->globalname); - - if (pGlobal) - { - // Already dead? delete - if (pGlobal->state == GLOBAL_DEAD) - return -1; - - else if (!FStrEq(STRING(gpGlobals->mapname), pGlobal->levelName)) - { - // Hasn't been moved to this level yet, wait but stay alive - // In this level & not dead, continue on as normal - pEntity->MakeDormant(); - } - } - else - { - // Spawned entities default to 'On' - gGlobalState.EntityAdd(pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON); - } - } - - } - - return 0; -} - -/* <2e8a0> ../cstrike/dlls/cbase.cpp:549 */ -void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) -{ + { + stringsHashTable[i].next = NULL; + } + + EmptyEntityHashTable(); + return 1; +} + +/* <3161a> ../cstrike/dlls/cbase.cpp:471 */ +NOXREF extern "C" C_EXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) +{ + if (!pFunctionTable || *interfaceVersion != INTERFACE_VERSION) + { + *interfaceVersion = INTERFACE_VERSION; + return 0; + } + + Q_memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); + return 1; +} + +/* <3165b> ../cstrike/dlls/cbase.cpp:485 */ +extern "C" C_EXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) +{ + if (!pFunctionTable || *interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) + { + *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION; + return 0; + } + Q_memcpy(pFunctionTable, &gNewDLLFunctions, sizeof(NEW_DLL_FUNCTIONS)); + return 1; +} + +/* <30ab0> ../cstrike/dlls/cbase.cpp:498 */ +int DispatchSpawn(edict_t *pent) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + + if (pEntity != NULL) + { + // Initialize these or entities who don't link to the world won't have anything in here + pEntity->pev->absmin = pEntity->pev->origin - Vector(1, 1, 1); + pEntity->pev->absmax = pEntity->pev->origin + Vector(1, 1, 1); + pEntity->Spawn(); + + // Try to get the pointer again, in case the spawn function deleted the entity. + // UNDONE: Spawn() should really return a code to ask that the entity be deleted, but + // that would touch too much code for me to do that right now. + pEntity = (CBaseEntity *)GET_PRIVATE(pent); + + if (pEntity) + { + if (g_pGameRules && !g_pGameRules->IsAllowedToSpawn(pEntity)) + { + // return that this entity should be deleted + return -1; + } + + if (pEntity->pev->flags & FL_KILLME) + { + return -1; + } + } + + // Handle global stuff here + if (pEntity && pEntity->pev->globalname) + { + const globalentity_t *pGlobal = gGlobalState.EntityFromTable(pEntity->pev->globalname); + + if (pGlobal) + { + // Already dead? delete + if (pGlobal->state == GLOBAL_DEAD) + return -1; + + else if (!FStrEq(STRING(gpGlobals->mapname), pGlobal->levelName)) + { + // Hasn't been moved to this level yet, wait but stay alive + // In this level & not dead, continue on as normal + pEntity->MakeDormant(); + } + } + else + { + // Spawned entities default to 'On' + gGlobalState.EntityAdd(pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON); + } + } + + } + + return 0; +} + +/* <2e8a0> ../cstrike/dlls/cbase.cpp:549 */ +void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) +{ if (!pkvd || !pentKeyvalue) return; EntvarsKeyvalue(VARS(pentKeyvalue), pkvd); - // If the key was an entity variable, or there's no class set yet, don't look for the object, it may + // If the key was an entity variable, or there's no class set yet, don't look for the object, it may // not exist yet. if (pkvd->fHandled || !pkvd->szClassName) return; @@ -506,281 +506,281 @@ void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) // Get the actualy entity object CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentKeyvalue); - if (!pEntity) - return; - - pEntity->KeyValue(pkvd); -} - -// HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers) -// while it builds the graph - -/* <2e7db> ../cstrike/dlls/cbase.cpp:574 */ -void DispatchTouch(edict_t *pentTouched, edict_t *pentOther) -{ - if (gTouchDisabled) - return; - - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched); - CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); - - if (pEntity && pOther && !((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME)) - pEntity->Touch(pOther); -} - -/* <2fa9b> ../cstrike/dlls/cbase.cpp:587 */ -void DispatchUse(edict_t *pentUsed, edict_t *pentOther) -{ - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed); - CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); - - if (pEntity && !(pEntity->pev->flags & FL_KILLME)) - { - pEntity->Use(pOther, pOther, USE_TOGGLE, 0); - } -} - -/* <2fb2f> ../cstrike/dlls/cbase.cpp:596 */ -void DispatchThink(edict_t *pent) -{ - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - if (pEntity != NULL) - { - if ((pEntity->pev->flags & FL_DORMANT)) - { - ALERT(at_error, "Dormant entity %s is thinking!!\n", STRING(pEntity->pev->classname)); - } - pEntity->Think(); - } -} - -/* <2fb89> ../cstrike/dlls/cbase.cpp:612 */ -void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther) -{ - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentBlocked); - CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); - - if (pEntity != NULL) - { - pEntity->Blocked(pOther); - } -} - -/* <2ff56> ../cstrike/dlls/cbase.cpp:621 */ -void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData) -{ - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - if (pEntity != NULL && pSaveData != NULL) - { - ENTITYTABLE *pTable = &pSaveData->pTable[ pSaveData->currentIndex ]; - - if (pTable->pent != pent) - { - ALERT(at_error, "ENTITY TABLE OR INDEX IS WRONG!!!!\n"); - } - - if (pEntity->ObjectCaps() & FCAP_DONT_SAVE) - return; - - // These don't use ltime & nextthink as times really, but we'll fudge around it. - if (pEntity->pev->movetype == MOVETYPE_PUSH) - { - float_precision delta = pEntity->pev->nextthink - pEntity->pev->ltime; - pEntity->pev->ltime = gpGlobals->time; - pEntity->pev->nextthink = pEntity->pev->ltime + delta; - } - - // Remember entity position for file I/O - pTable->location = pSaveData->size; - - // Remember entity class for respawn - pTable->classname = pEntity->pev->classname; - - CSave saveHelper(pSaveData); - pEntity->Save(saveHelper); - - // Size of entity block is data size written to block - pTable->size = pSaveData->size - pTable->location; - } -} - -// Find the matching global entity. Spit out an error if the designer made entities of -// different classes with the same global name - -/* <31697> ../cstrike/dlls/cbase.cpp:656 */ -CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname) -{ - edict_t *pent = FIND_ENTITY_BY_STRING(NULL, "globalname", STRING(globalname)); - CBaseEntity *pReturn = CBaseEntity::Instance(pent); - - if (pReturn != NULL) - { - if (!FClassnameIs(pReturn->pev, STRING(classname))) - { - ALERT(at_console, "Global entity found %s, wrong class %s\n", STRING(globalname), STRING(pReturn->pev->classname)); - pReturn = NULL; - } - } - - return pReturn; -} - -/* <3179c> ../cstrike/dlls/cbase.cpp:673 */ -int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity) -{ - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - if (pEntity && pSaveData) - { - entvars_t tmpVars; - Vector oldOffset; - CRestore restoreHelper(pSaveData); - - if (globalEntity) - { - CRestore tmpRestore(pSaveData); - tmpRestore.PrecacheMode(0); - tmpRestore.ReadEntVars("ENTVARS", &tmpVars); - - // HACKHACK - reset the save pointers, we're going to restore for real this time - pSaveData->size = pSaveData->pTable[pSaveData->currentIndex].location; - pSaveData->pCurrentData = pSaveData->pBaseData + pSaveData->size; - - const globalentity_t *pGlobal = gGlobalState.EntityFromTable(tmpVars.globalname); - - // Don't overlay any instance of the global that isn't the latest - // pSaveData->szCurrentMapName is the level this entity is coming from - // pGlobla->levelName is the last level the global entity was active in. - // If they aren't the same, then this global update is out of date. - if (!FStrEq(pSaveData->szCurrentMapName, pGlobal->levelName)) - { - return 0; - } - - // Compute the new global offset - oldOffset = pSaveData->vecLandmarkOffset; - CBaseEntity *pNewEntity = FindGlobalEntity(tmpVars.classname, tmpVars.globalname); - - if (pNewEntity != NULL) - { - // Tell the restore code we're overlaying a global entity from another level - // Don't overwrite global fields - restoreHelper.SetGlobalMode(1); - - pSaveData->vecLandmarkOffset = (pSaveData->vecLandmarkOffset - pNewEntity->pev->mins) + tmpVars.mins; - - // we're going to restore this data OVER the old entity - pEntity = pNewEntity; - pent = ENT(pEntity->pev); - - // Update the global table to say that the global definition of this entity should come from this level - gGlobalState.EntityUpdate(pEntity->pev->globalname, gpGlobals->mapname); - } - else - { - // This entity will be freed automatically by the engine. If we don't do a restore on a matching entity (below) - // or call EntityUpdate() to move it to this level, we haven't changed global state at all. - - return 0; - } - - } - - if (pEntity->ObjectCaps() & FCAP_MUST_SPAWN) - { - pEntity->Restore(restoreHelper); - pEntity->Spawn(); - } - else - { - pEntity->Restore(restoreHelper); - pEntity->Precache(); - } - - // Again, could be deleted, get the pointer again. - pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - // Is this an overriding global entity (coming over the transition), or one restoring in a level - if (globalEntity) - { - pSaveData->vecLandmarkOffset = oldOffset; - - if (pEntity != NULL) - { - UTIL_SetOrigin(pEntity->pev, pEntity->pev->origin); - pEntity->OverrideReset(); - } - } - else if (pEntity != NULL && pEntity->pev->globalname) - { - const globalentity_t *pGlobal = gGlobalState.EntityFromTable(pEntity->pev->globalname); - - if (pGlobal != NULL) - { - // Already dead? delete - if (pGlobal->state == GLOBAL_DEAD) - return -1; - - else if (!FStrEq(STRING(gpGlobals->mapname), pGlobal->levelName)) - { - // Hasn't been moved to this level yet, wait but stay alive - pEntity->MakeDormant(); - } - // In this level & not dead, continue on as normal - } - else - { - ALERT(at_error, "Global Entity %s (%s) not in table!!!\n", STRING(pEntity->pev->globalname), STRING(pEntity->pev->classname)); - - // Spawned entities default to 'On' - gGlobalState.EntityAdd(pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON); - } - } - } - - return 0; -} - -/* <2fdcd> ../cstrike/dlls/cbase.cpp:776 */ -void DispatchObjectCollsionBox(edict_t *pent) -{ - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - - if (pEntity != NULL) - { - pEntity->SetObjectCollisionBox(); - } - else - SetObjectCollisionBox(&pent->v); - -} - -/* <2fe94> ../cstrike/dlls/cbase.cpp:788 */ -void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) -{ - CSave saveHelper(pSaveData); - saveHelper.WriteFields(pname, pBaseData, pFields, fieldCount); -} - -/* <30047> ../cstrike/dlls/cbase.cpp:795 */ -void SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) -{ - CRestore restoreHelper(pSaveData); - restoreHelper.ReadFields(pname, pBaseData, pFields, fieldCount); -} - -/* <31a74> ../cstrike/dlls/cbase.cpp:802 */ + if (!pEntity) + return; + + pEntity->KeyValue(pkvd); +} + +// HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers) +// while it builds the graph + +/* <2e7db> ../cstrike/dlls/cbase.cpp:574 */ +void DispatchTouch(edict_t *pentTouched, edict_t *pentOther) +{ + if (gTouchDisabled) + return; + + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched); + CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); + + if (pEntity && pOther && !((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME)) + pEntity->Touch(pOther); +} + +/* <2fa9b> ../cstrike/dlls/cbase.cpp:587 */ +void DispatchUse(edict_t *pentUsed, edict_t *pentOther) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed); + CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); + + if (pEntity && !(pEntity->pev->flags & FL_KILLME)) + { + pEntity->Use(pOther, pOther, USE_TOGGLE, 0); + } +} + +/* <2fb2f> ../cstrike/dlls/cbase.cpp:596 */ +void DispatchThink(edict_t *pent) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + + if (pEntity != NULL) + { + if ((pEntity->pev->flags & FL_DORMANT)) + { + ALERT(at_error, "Dormant entity %s is thinking!!\n", STRING(pEntity->pev->classname)); + } + pEntity->Think(); + } +} + +/* <2fb89> ../cstrike/dlls/cbase.cpp:612 */ +void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentBlocked); + CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); + + if (pEntity != NULL) + { + pEntity->Blocked(pOther); + } +} + +/* <2ff56> ../cstrike/dlls/cbase.cpp:621 */ +void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + + if (pEntity != NULL && pSaveData != NULL) + { + ENTITYTABLE *pTable = &pSaveData->pTable[ pSaveData->currentIndex ]; + + if (pTable->pent != pent) + { + ALERT(at_error, "ENTITY TABLE OR INDEX IS WRONG!!!!\n"); + } + + if (pEntity->ObjectCaps() & FCAP_DONT_SAVE) + return; + + // These don't use ltime & nextthink as times really, but we'll fudge around it. + if (pEntity->pev->movetype == MOVETYPE_PUSH) + { + float_precision delta = pEntity->pev->nextthink - pEntity->pev->ltime; + pEntity->pev->ltime = gpGlobals->time; + pEntity->pev->nextthink = pEntity->pev->ltime + delta; + } + + // Remember entity position for file I/O + pTable->location = pSaveData->size; + + // Remember entity class for respawn + pTable->classname = pEntity->pev->classname; + + CSave saveHelper(pSaveData); + pEntity->Save(saveHelper); + + // Size of entity block is data size written to block + pTable->size = pSaveData->size - pTable->location; + } +} + +// Find the matching global entity. Spit out an error if the designer made entities of +// different classes with the same global name + +/* <31697> ../cstrike/dlls/cbase.cpp:656 */ +CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname) +{ + edict_t *pent = FIND_ENTITY_BY_STRING(NULL, "globalname", STRING(globalname)); + CBaseEntity *pReturn = CBaseEntity::Instance(pent); + + if (pReturn != NULL) + { + if (!FClassnameIs(pReturn->pev, STRING(classname))) + { + ALERT(at_console, "Global entity found %s, wrong class %s\n", STRING(globalname), STRING(pReturn->pev->classname)); + pReturn = NULL; + } + } + + return pReturn; +} + +/* <3179c> ../cstrike/dlls/cbase.cpp:673 */ +int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + + if (pEntity && pSaveData) + { + entvars_t tmpVars; + Vector oldOffset; + CRestore restoreHelper(pSaveData); + + if (globalEntity) + { + CRestore tmpRestore(pSaveData); + tmpRestore.PrecacheMode(0); + tmpRestore.ReadEntVars("ENTVARS", &tmpVars); + + // HACKHACK - reset the save pointers, we're going to restore for real this time + pSaveData->size = pSaveData->pTable[pSaveData->currentIndex].location; + pSaveData->pCurrentData = pSaveData->pBaseData + pSaveData->size; + + const globalentity_t *pGlobal = gGlobalState.EntityFromTable(tmpVars.globalname); + + // Don't overlay any instance of the global that isn't the latest + // pSaveData->szCurrentMapName is the level this entity is coming from + // pGlobla->levelName is the last level the global entity was active in. + // If they aren't the same, then this global update is out of date. + if (!FStrEq(pSaveData->szCurrentMapName, pGlobal->levelName)) + { + return 0; + } + + // Compute the new global offset + oldOffset = pSaveData->vecLandmarkOffset; + CBaseEntity *pNewEntity = FindGlobalEntity(tmpVars.classname, tmpVars.globalname); + + if (pNewEntity != NULL) + { + // Tell the restore code we're overlaying a global entity from another level + // Don't overwrite global fields + restoreHelper.SetGlobalMode(1); + + pSaveData->vecLandmarkOffset = (pSaveData->vecLandmarkOffset - pNewEntity->pev->mins) + tmpVars.mins; + + // we're going to restore this data OVER the old entity + pEntity = pNewEntity; + pent = ENT(pEntity->pev); + + // Update the global table to say that the global definition of this entity should come from this level + gGlobalState.EntityUpdate(pEntity->pev->globalname, gpGlobals->mapname); + } + else + { + // This entity will be freed automatically by the engine. If we don't do a restore on a matching entity (below) + // or call EntityUpdate() to move it to this level, we haven't changed global state at all. + + return 0; + } + + } + + if (pEntity->ObjectCaps() & FCAP_MUST_SPAWN) + { + pEntity->Restore(restoreHelper); + pEntity->Spawn(); + } + else + { + pEntity->Restore(restoreHelper); + pEntity->Precache(); + } + + // Again, could be deleted, get the pointer again. + pEntity = (CBaseEntity *)GET_PRIVATE(pent); + + // Is this an overriding global entity (coming over the transition), or one restoring in a level + if (globalEntity) + { + pSaveData->vecLandmarkOffset = oldOffset; + + if (pEntity != NULL) + { + UTIL_SetOrigin(pEntity->pev, pEntity->pev->origin); + pEntity->OverrideReset(); + } + } + else if (pEntity != NULL && pEntity->pev->globalname) + { + const globalentity_t *pGlobal = gGlobalState.EntityFromTable(pEntity->pev->globalname); + + if (pGlobal != NULL) + { + // Already dead? delete + if (pGlobal->state == GLOBAL_DEAD) + return -1; + + else if (!FStrEq(STRING(gpGlobals->mapname), pGlobal->levelName)) + { + // Hasn't been moved to this level yet, wait but stay alive + pEntity->MakeDormant(); + } + // In this level & not dead, continue on as normal + } + else + { + ALERT(at_error, "Global Entity %s (%s) not in table!!!\n", STRING(pEntity->pev->globalname), STRING(pEntity->pev->classname)); + + // Spawned entities default to 'On' + gGlobalState.EntityAdd(pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON); + } + } + } + + return 0; +} + +/* <2fdcd> ../cstrike/dlls/cbase.cpp:776 */ +void DispatchObjectCollsionBox(edict_t *pent) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + + if (pEntity != NULL) + { + pEntity->SetObjectCollisionBox(); + } + else + SetObjectCollisionBox(&pent->v); + +} + +/* <2fe94> ../cstrike/dlls/cbase.cpp:788 */ +void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) +{ + CSave saveHelper(pSaveData); + saveHelper.WriteFields(pname, pBaseData, pFields, fieldCount); +} + +/* <30047> ../cstrike/dlls/cbase.cpp:795 */ +void SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) +{ + CRestore restoreHelper(pSaveData); + restoreHelper.ReadFields(pname, pBaseData, pFields, fieldCount); +} + +/* <31a74> ../cstrike/dlls/cbase.cpp:802 */ edict_t *EHANDLE::Get(void) { if (!m_pent || m_pent->serialnumber != m_serialnumber) return NULL; return m_pent; -} - -/* <31a95> ../cstrike/dlls/cbase.cpp:814 */ +} + +/* <31a95> ../cstrike/dlls/cbase.cpp:814 */ edict_t *EHANDLE::Set(edict_t *pent) { m_pent = pent; @@ -788,15 +788,15 @@ edict_t *EHANDLE::Set(edict_t *pent) m_serialnumber = pent->serialnumber; return pent; -} - -/* <31ace> ../cstrike/dlls/cbase.cpp:823 */ +} + +/* <31ace> ../cstrike/dlls/cbase.cpp:823 */ EHANDLE::operator CBaseEntity *(void) { return (CBaseEntity *)GET_PRIVATE(Get()); -} - -/* <31b30> ../cstrike/dlls/cbase.cpp:829 */ +} + +/* <31b30> ../cstrike/dlls/cbase.cpp:829 */ CBaseEntity *EHANDLE::operator=(CBaseEntity *pEntity) { if (pEntity) @@ -811,23 +811,23 @@ CBaseEntity *EHANDLE::operator=(CBaseEntity *pEntity) m_serialnumber = 0; } return pEntity; -} - -/* <31b69> ../cstrike/dlls/cbase.cpp:845 */ +} + +/* <31b69> ../cstrike/dlls/cbase.cpp:845 */ EHANDLE::operator int(void) { return Get() != NULL; -} - -/* <31bac> ../cstrike/dlls/cbase.cpp:850 */ +} + +/* <31bac> ../cstrike/dlls/cbase.cpp:850 */ CBaseEntity *EHANDLE::operator->(void) { return (CBaseEntity *)GET_PRIVATE(Get()); -} - -/* <301be> ../cstrike/dlls/cbase.cpp:857 */ -int CBaseEntity::__MAKE_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) -{ +} + +/* <301be> ../cstrike/dlls/cbase.cpp:857 */ +int CBaseEntity::__MAKE_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) +{ if (pev->takedamage == DAMAGE_NO) return 0; @@ -839,191 +839,191 @@ int CBaseEntity::__MAKE_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) if (pev->health > pev->max_health) pev->health = pev->max_health; - return 1; -} - -/* <305af> ../cstrike/dlls/cbase.cpp:876 */ -int CBaseEntity::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ - Vector vecTemp; - - if (pev->takedamage == DAMAGE_NO) - return 0; - - // 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. - // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). - if (pevAttacker == pevInflictor) - { - vecTemp = pevInflictor->origin - (VecBModelOrigin(pev)); - } - else - { - // an actual missile was involved. - vecTemp = pevInflictor->origin - (VecBModelOrigin(pev)); - } - - // this global is still used for glass and other non-monster killables, along with decals. - g_vecAttackDir = vecTemp.Normalize(); - - // save damage based on the target's armor level - // 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)) - { - Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; - vecDir = vecDir.Normalize(); - - float_precision flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; - - if (flForce > 1000.0) - flForce = 1000.0; - - pev->velocity = pev->velocity + vecDir * flForce; - } - - // do the damage - pev->health -= flDamage; - if (pev->health <= 0) - { - Killed(pevAttacker, GIB_NORMAL); - return 0; - } - - return 1; -} - -/* <2fe50> ../cstrike/dlls/cbase.cpp:927 */ -void CBaseEntity::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) -{ - pev->takedamage = DAMAGE_NO; - pev->deadflag = DEAD_DEAD; - UTIL_Remove(this); -} - -/* <2fc1c> ../cstrike/dlls/cbase.cpp:935 */ -CBaseEntity *CBaseEntity::__MAKE_VHOOK(GetNextTarget)(void) -{ - if (FStringNull(pev->target)) - return NULL; - - edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); - - if (FNullEnt(pTarget)) - { - return NULL; - } - - return Instance(pTarget); -} - -/* <302a6> ../cstrike/dlls/cbase.cpp:958 */ -int CBaseEntity::__MAKE_VHOOK(Save)(CSave &save) -{ - if (save.WriteEntVars("ENTVARS", pev)) - { - return save.WriteFields("BASE", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData))); - } - - return 0; -} - -/* <30440> ../cstrike/dlls/cbase.cpp:966 */ -int CBaseEntity::__MAKE_VHOOK(Restore)(CRestore &restore) -{ - int status; - - status = restore.ReadEntVars("ENTVARS", pev); - - if (status) - { - status = restore.ReadFields("BASE", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData))); - } - - if (pev->modelindex != 0 && !FStringNull(pev->model)) - { - Vector mins, maxs; - - // Set model is about to destroy these - mins = pev->mins; - maxs = pev->maxs; - - PRECACHE_MODEL((char *)STRING(pev->model)); - SET_MODEL(ENT(pev), STRING(pev->model)); - - // Reset them - UTIL_SetSize(pev, mins, maxs); - } - - return status; -} - -/* <2fcf6> ../cstrike/dlls/cbase.cpp:991 */ -void SetObjectCollisionBox(entvars_t *pev) -{ - if ((pev->solid == SOLID_BSP) && (pev->angles.x || pev->angles.y || pev->angles.z)) - { - // expand for rotation - float_precision max, v; - int i; - - max = 0; - for (i = 0 ; i < 3 ; i++) - { - v = fabs((float_precision)((float *)pev->mins)[i]); - if (v > max) - { - max = v; - } - - v = fabs((float_precision)((float *)pev->maxs)[i]); - if (v > max) - { - max = v; - } - } - for (i = 0; i < 3; i++) - { - ((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max; - ((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max; - } - } - else - { - pev->absmin = pev->origin + pev->mins; - pev->absmax = pev->origin + pev->maxs; - } - - pev->absmin.x -= 1; - pev->absmin.y -= 1; - pev->absmin.z -= 1; - - pev->absmax.x += 1; - pev->absmax.y += 1; - pev->absmax.z += 1; -} - -/* <2fe2a> ../cstrike/dlls/cbase.cpp:1030 */ -void CBaseEntity::__MAKE_VHOOK(SetObjectCollisionBox)(void) -{ - ::SetObjectCollisionBox(pev); -} - -/* <31c0e> ../cstrike/dlls/cbase.cpp:1036 */ -int CBaseEntity::Intersects(CBaseEntity *pOther) -{ - if (pOther->pev->absmin.x > pev->absmax.x - || pOther->pev->absmin.y > pev->absmax.y - || pOther->pev->absmin.z > pev->absmax.z - || pOther->pev->absmax.x < pev->absmin.x - || pOther->pev->absmax.y < pev->absmin.y - || pOther->pev->absmax.z < pev->absmin.z) - return 0; - return 1; -} - -/* <31c43> ../cstrike/dlls/cbase.cpp:1048 */ -void CBaseEntity::MakeDormant(void) -{ + return 1; +} + +/* <305af> ../cstrike/dlls/cbase.cpp:876 */ +int CBaseEntity::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + Vector vecTemp; + + if (pev->takedamage == DAMAGE_NO) + return 0; + + // 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. + // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). + if (pevAttacker == pevInflictor) + { + vecTemp = pevInflictor->origin - (VecBModelOrigin(pev)); + } + else + { + // an actual missile was involved. + vecTemp = pevInflictor->origin - (VecBModelOrigin(pev)); + } + + // this global is still used for glass and other non-monster killables, along with decals. + g_vecAttackDir = vecTemp.Normalize(); + + // save damage based on the target's armor level + // 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)) + { + Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5; + vecDir = vecDir.Normalize(); + + float_precision flForce = flDamage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; + + if (flForce > 1000.0) + flForce = 1000.0; + + pev->velocity = pev->velocity + vecDir * flForce; + } + + // do the damage + pev->health -= flDamage; + if (pev->health <= 0) + { + Killed(pevAttacker, GIB_NORMAL); + return 0; + } + + return 1; +} + +/* <2fe50> ../cstrike/dlls/cbase.cpp:927 */ +void CBaseEntity::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) +{ + pev->takedamage = DAMAGE_NO; + pev->deadflag = DEAD_DEAD; + UTIL_Remove(this); +} + +/* <2fc1c> ../cstrike/dlls/cbase.cpp:935 */ +CBaseEntity *CBaseEntity::__MAKE_VHOOK(GetNextTarget)(void) +{ + if (FStringNull(pev->target)) + return NULL; + + edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); + + if (FNullEnt(pTarget)) + { + return NULL; + } + + return Instance(pTarget); +} + +/* <302a6> ../cstrike/dlls/cbase.cpp:958 */ +int CBaseEntity::__MAKE_VHOOK(Save)(CSave &save) +{ + if (save.WriteEntVars("ENTVARS", pev)) + { + return save.WriteFields("BASE", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData))); + } + + return 0; +} + +/* <30440> ../cstrike/dlls/cbase.cpp:966 */ +int CBaseEntity::__MAKE_VHOOK(Restore)(CRestore &restore) +{ + int status; + + status = restore.ReadEntVars("ENTVARS", pev); + + if (status) + { + status = restore.ReadFields("BASE", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData))); + } + + if (pev->modelindex != 0 && !FStringNull(pev->model)) + { + Vector mins, maxs; + + // Set model is about to destroy these + mins = pev->mins; + maxs = pev->maxs; + + PRECACHE_MODEL((char *)STRING(pev->model)); + SET_MODEL(ENT(pev), STRING(pev->model)); + + // Reset them + UTIL_SetSize(pev, mins, maxs); + } + + return status; +} + +/* <2fcf6> ../cstrike/dlls/cbase.cpp:991 */ +void SetObjectCollisionBox(entvars_t *pev) +{ + if ((pev->solid == SOLID_BSP) && (pev->angles.x || pev->angles.y || pev->angles.z)) + { + // expand for rotation + float_precision max, v; + int i; + + max = 0; + for (i = 0; i < 3; i++) + { + v = fabs((float_precision)((float *)pev->mins)[i]); + if (v > max) + { + max = v; + } + + v = fabs((float_precision)((float *)pev->maxs)[i]); + if (v > max) + { + max = v; + } + } + for (i = 0; i < 3; i++) + { + ((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max; + ((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max; + } + } + else + { + pev->absmin = pev->origin + pev->mins; + pev->absmax = pev->origin + pev->maxs; + } + + pev->absmin.x -= 1; + pev->absmin.y -= 1; + pev->absmin.z -= 1; + + pev->absmax.x += 1; + pev->absmax.y += 1; + pev->absmax.z += 1; +} + +/* <2fe2a> ../cstrike/dlls/cbase.cpp:1030 */ +void CBaseEntity::__MAKE_VHOOK(SetObjectCollisionBox)(void) +{ + ::SetObjectCollisionBox(pev); +} + +/* <31c0e> ../cstrike/dlls/cbase.cpp:1036 */ +int CBaseEntity::Intersects(CBaseEntity *pOther) +{ + if (pOther->pev->absmin.x > pev->absmax.x + || pOther->pev->absmin.y > pev->absmax.y + || pOther->pev->absmin.z > pev->absmax.z + || pOther->pev->absmax.x < pev->absmin.x + || pOther->pev->absmax.y < pev->absmin.y + || pOther->pev->absmax.z < pev->absmin.z) + return 0; + return 1; +} + +/* <31c43> ../cstrike/dlls/cbase.cpp:1048 */ +void CBaseEntity::MakeDormant(void) +{ pev->flags |= FL_DORMANT; // Don't touch @@ -1039,102 +1039,103 @@ void CBaseEntity::MakeDormant(void) pev->nextthink = 0; // Relink - UTIL_SetOrigin(pev, pev->origin); -} - -/* <31c66> ../cstrike/dlls/cbase.cpp:1064 */ -int CBaseEntity::IsDormant(void) -{ - return (pev->flags & FL_DORMANT) == FL_DORMANT; -} - -/* <30221> ../cstrike/dlls/cbase.cpp:1069 */ -BOOL CBaseEntity::__MAKE_VHOOK(IsInWorld)(void) -{ - // position - if (pev->origin.x >= 4096.0 || pev->origin.y >= 4096.0 || pev->origin.z >= 4096.0) - { - return FALSE; - } - if (pev->origin.x <= -4096.0 || pev->origin.y <= -4096.0 || pev->origin.z <= -4096.0) - { - return FALSE; - } - - // speed - if (pev->velocity.x >= 2000.0 || pev->velocity.y >= 2000.0 || pev->velocity.z >= 2000.0) - { - return FALSE; - } - if (pev->velocity.x <= -2000.0 || pev->velocity.y <= -2000.0 || pev->velocity.z <= -2000.0) - { - return FALSE; - } - - return TRUE; -} - -/* <31c8c> ../cstrike/dlls/cbase.cpp:1089 */ -int CBaseEntity::ShouldToggle(USE_TYPE useType, BOOL currentState) -{ - if (useType != USE_TOGGLE && useType != USE_SET) - { - if ((currentState && useType == USE_ON) || (!currentState && useType == USE_OFF)) - return 0; - } - return 1; -} - -/* <30258> ../cstrike/dlls/cbase.cpp:1100 */ -int CBaseEntity::__MAKE_VHOOK(DamageDecal)(int bitsDamageType) -{ - if (pev->rendermode == kRenderTransAlpha) - return -1; - - if (pev->rendermode != kRenderNormal) - return DECAL_BPROOF1; - - return DECAL_GUNSHOT1 + RANDOM_LONG(0, 4); -} - -// NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity -// will keep a pointer to it after this call. - -/* <31cd1> ../cstrike/dlls/cbase.cpp:1115 */ -CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner) -{ - edict_t *pent; - CBaseEntity *pEntity; - - pent = CREATE_NAMED_ENTITY(MAKE_STRING(szName)); - if (FNullEnt(pent)) - { - ALERT(at_console, "NULL Ent in Create!\n"); - return NULL; - } - - pEntity = Instance(pent); - - pEntity->pev->owner = pentOwner; - pEntity->pev->origin = vecOrigin; - pEntity->pev->angles = vecAngles; - - DispatchSpawn(pEntity->edict()); - - return pEntity; -} - -/* <30885> ../cstrike/dlls/cbase.cpp:1134 */ -void OnFreeEntPrivateData(edict_t *pEnt) + UTIL_SetOrigin(pev, pev->origin); +} + +/* <31c66> ../cstrike/dlls/cbase.cpp:1064 */ +int CBaseEntity::IsDormant(void) { - CBaseEntity *pEntity = CBaseEntity::Instance(pEnt); + return (pev->flags & FL_DORMANT) == FL_DORMANT; +} + +/* <30221> ../cstrike/dlls/cbase.cpp:1069 */ +BOOL CBaseEntity::__MAKE_VHOOK(IsInWorld)(void) +{ + // position + if (pev->origin.x >= 4096.0 || pev->origin.y >= 4096.0 || pev->origin.z >= 4096.0) + { + return FALSE; + } + if (pev->origin.x <= -4096.0 || pev->origin.y <= -4096.0 || pev->origin.z <= -4096.0) + { + return FALSE; + } + + // speed + if (pev->velocity.x >= 2000.0 || pev->velocity.y >= 2000.0 || pev->velocity.z >= 2000.0) + { + return FALSE; + } + if (pev->velocity.x <= -2000.0 || pev->velocity.y <= -2000.0 || pev->velocity.z <= -2000.0) + { + return FALSE; + } + + return TRUE; +} + +/* <31c8c> ../cstrike/dlls/cbase.cpp:1089 */ +int CBaseEntity::ShouldToggle(USE_TYPE useType, BOOL currentState) +{ + if (useType != USE_TOGGLE && useType != USE_SET) + { + if ((currentState && useType == USE_ON) || (!currentState && useType == USE_OFF)) + return 0; + } + + return 1; +} + +/* <30258> ../cstrike/dlls/cbase.cpp:1100 */ +int CBaseEntity::__MAKE_VHOOK(DamageDecal)(int bitsDamageType) +{ + if (pev->rendermode == kRenderTransAlpha) + return -1; + + if (pev->rendermode != kRenderNormal) + return DECAL_BPROOF1; + + return DECAL_GUNSHOT1 + RANDOM_LONG(0, 4); +} + +// NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity +// will keep a pointer to it after this call. + +/* <31cd1> ../cstrike/dlls/cbase.cpp:1115 */ +CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner) +{ + edict_t *pent; + CBaseEntity *pEntity; + + pent = CREATE_NAMED_ENTITY(MAKE_STRING(szName)); + if (FNullEnt(pent)) + { + ALERT(at_console, "NULL Ent in Create!\n"); + return NULL; + } + + pEntity = Instance(pent); + + pEntity->pev->owner = pentOwner; + pEntity->pev->origin = vecOrigin; + pEntity->pev->angles = vecAngles; + + DispatchSpawn(pEntity->edict()); + + return pEntity; +} + +/* <30885> ../cstrike/dlls/cbase.cpp:1134 */ +void OnFreeEntPrivateData(edict_t *pEnt) +{ + CBaseEntity *pEntity = CBaseEntity::Instance(pEnt); if (!pEntity) - return; - - pEntity->UpdateOnRemove(); - RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME); -} - + return; + + pEntity->UpdateOnRemove(); + RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME); +} + #ifdef HOOK_GAMEDLL int CBaseEntity::Save(CSave &save) @@ -1147,59 +1148,59 @@ int CBaseEntity::Restore(CRestore &restore) return Restore_(restore); } -void CBaseEntity::SetObjectCollisionBox(void) -{ - SetObjectCollisionBox_(); +void CBaseEntity::SetObjectCollisionBox(void) +{ + SetObjectCollisionBox_(); } - -void CBaseEntity::TraceAttack(entvars_t *pevAttacker,float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) -{ - TraceAttack_(pevAttacker,flDamage,vecDir,ptr,bitsDamageType); + +void CBaseEntity::TraceAttack(entvars_t *pevAttacker,float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) +{ + TraceAttack_(pevAttacker,flDamage,vecDir,ptr,bitsDamageType); } - -int CBaseEntity::TakeDamage(entvars_t *pevInflictor,entvars_t *pevAttacker,float flDamage,int bitsDamageType) -{ - return TakeDamage_(pevInflictor,pevAttacker,flDamage,bitsDamageType); + +int CBaseEntity::TakeDamage(entvars_t *pevInflictor,entvars_t *pevAttacker,float flDamage,int bitsDamageType) +{ + return TakeDamage_(pevInflictor,pevAttacker,flDamage,bitsDamageType); } - -int CBaseEntity::TakeHealth(float flHealth,int bitsDamageType) -{ - return TakeHealth_(flHealth, bitsDamageType); + +int CBaseEntity::TakeHealth(float flHealth,int bitsDamageType) +{ + return TakeHealth_(flHealth, bitsDamageType); } - -void CBaseEntity::Killed(entvars_t *pevAttacker,int iGib) -{ - Killed_(pevAttacker,iGib); + +void CBaseEntity::Killed(entvars_t *pevAttacker,int iGib) +{ + Killed_(pevAttacker,iGib); } - -void CBaseEntity::TraceBleed(float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) -{ - TraceBleed_(flDamage,vecDir,ptr,bitsDamageType); + +void CBaseEntity::TraceBleed(float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) +{ + TraceBleed_(flDamage,vecDir,ptr,bitsDamageType); } - -int CBaseEntity::DamageDecal(int bitsDamageType) -{ - return DamageDecal_(bitsDamageType); + +int CBaseEntity::DamageDecal(int bitsDamageType) +{ + return DamageDecal_(bitsDamageType); } - -BOOL CBaseEntity::IsInWorld(void) -{ - return IsInWorld_(); + +BOOL CBaseEntity::IsInWorld(void) +{ + return IsInWorld_(); } - -CBaseEntity *CBaseEntity::GetNextTarget(void) -{ - return GetNextTarget(); + +CBaseEntity *CBaseEntity::GetNextTarget(void) +{ + return GetNextTarget_(); } - -BOOL CBaseEntity::FVisible(CBaseEntity *pEntity) -{ - return FVisible_(pEntity); + +BOOL CBaseEntity::FVisible(CBaseEntity *pEntity) +{ + return FVisible_(pEntity); } - -BOOL CBaseEntity::FVisible(Vector &vecOrigin) -{ - return FVisible_(vecOrigin); + +BOOL CBaseEntity::FVisible(const Vector &vecOrigin) +{ + return FVisible_(vecOrigin); } - + #endif // HOOK_GAMEDLL \ No newline at end of file diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index 7a9a28ff..54f69ba1 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -39,9 +39,6 @@ #undef CREATE_NAMED_ENTITY #undef REMOVE_ENTITY -//#define CAREER_MODE_DELETED_SCENE 1 // ?? -#define CAREER_MODE_CAMPAIGN 2 - #define FCAP_CUSTOMSAVE 0x00000001 #define FCAP_ACROSS_TRANSITION 0x00000002 #define FCAP_MUST_SPAWN 0x00000004 @@ -222,6 +219,7 @@ typedef enum USE_ON, USE_SET, USE_TOGGLE, + } USE_TYPE; typedef enum @@ -298,37 +296,6 @@ private: };/* size: 8, cachelines: 1, members: 2 */ -typedef struct dynpitchvol -{ - int preset; - int pitchrun; - int pitchstart; - int spinup; - int spindown; - int volrun; - int volstart; - int fadein; - int fadeout; - int lfotype; - int lforate; - int lfomodpitch; - int lfomodvol; - int cspinup; - int cspincount; - int pitch; - int spinupsav; - int spindownsav; - int pitchfrac; - int vol; - int fadeinsav; - int fadeoutsav; - int volfrac; - int lfofrac; - int lfomult; - -} dynpitchvol_t; -/* size: 100, cachelines: 2, members: 25 */ - /* <48e9c1> ../cstrike/dlls/cbase.h:166 */ class CBaseEntity { @@ -340,8 +307,8 @@ public: { pkvd->fHandled = FALSE; } - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); virtual int ObjectCaps(void) { return FCAP_ACROSS_TRANSITION; @@ -381,17 +348,17 @@ public: { return GetToggleState_(); } - virtual void AddPoints(int score, BOOL bAllowNegativeScore) {} // __stdcall - virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) {} // __stdcall + virtual void AddPoints(int score, BOOL bAllowNegativeScore) {} + virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) {} virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) { return FALSE; } - virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) // __stdcall + virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) { return FALSE; } - virtual int GiveAmmo(int iAmount, char *szName, int iMax) // __stdcall + virtual int GiveAmmo(int iAmount, char *szName, int iMax) { return -1; } @@ -449,22 +416,30 @@ public: virtual void Think(void) { if (m_pfnThink) + { (this->*m_pfnThink)(); + } } virtual void Touch(CBaseEntity *pOther) { if (m_pfnTouch) + { (this->*m_pfnTouch)(pOther); + } } virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType = USE_OFF, float value = 0.0f) { if (m_pfnUse) + { (this->*m_pfnUse)(pActivator, pCaller, useType, value); + } } virtual void Blocked(CBaseEntity *pOther) { if (m_pfnBlocked) + { (this->*m_pfnBlocked)(pOther); + } } virtual CBaseEntity *Respawn(void) { @@ -496,15 +471,15 @@ public: return GETENTITYILLUM(ENT(pev)); } - NOBODY virtual BOOL FVisible(CBaseEntity *pEntity); - NOBODY virtual BOOL FVisible(Vector &vecOrigin); + virtual BOOL FVisible(CBaseEntity *pEntity); + virtual BOOL FVisible(const Vector &vecOrigin); #ifdef HOOK_GAMEDLL int Save_(CSave &save); int Restore_(CRestore &restore); void SetObjectCollisionBox_(void); - void DeathNotice_(entvars_t *pevChild) { } + void DeathNotice_(entvars_t *pevChild) {} void TraceAttack_(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); int TakeDamage_(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); int TakeHealth_(float flHealth, int bitsDamageType); @@ -526,7 +501,7 @@ public: return Center(); } BOOL FVisible_(CBaseEntity *pEntity); - BOOL FVisible_(Vector &vecOrigin); + BOOL FVisible_(const Vector &vecOrigin); #endif // HOOK_GAMEDLL @@ -548,8 +523,8 @@ public: { Use(this, this, USE_TOGGLE, 0); } - NOBODY int ShouldToggle(USE_TYPE useType, BOOL currentState); - NOBODY void FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL); + int ShouldToggle(USE_TYPE useType, BOOL currentState); + void FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL); Vector FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand = 0); void SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value); int Intersects(CBaseEntity *pOther); @@ -665,8 +640,8 @@ inline int FNullEnt(EHANDLE hent) class CPointEntity: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual int ObjectCaps(void) { return ObjectCaps_(); } @@ -687,16 +662,16 @@ public: class CMultiSource: public CPointEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual BOOL IsTriggered(CBaseEntity *pActivator); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual BOOL IsTriggered(CBaseEntity *pActivator); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); #ifdef HOOK_GAMEDLL @@ -714,7 +689,7 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT Register(void); + void EXPORT Register(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[4]; @@ -731,8 +706,8 @@ class CBaseDelay: public CBaseEntity { public: virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); #ifdef HOOK_GAMEDLL @@ -757,8 +732,8 @@ public: class CBaseAnimating: public CBaseDelay { public: - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); virtual void HandleAnimEvent(MonsterEvent_t *pEvent) {} #ifdef HOOK_GAMEDLL @@ -823,16 +798,16 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void LinearMove(Vector vecDest, float flSpeed); - NOBODY void EXPORT LinearMoveDone(void); - NOBODY void AngularMove(Vector vecDestAngle, float flSpeed); - NOBODY void EXPORT AngularMoveDone(void); - NOBODY BOOL IsLockedByMaster(void); + void LinearMove(Vector vecDest, float flSpeed); + void EXPORT LinearMoveDone(void); + void AngularMove(Vector vecDestAngle, float flSpeed); + void EXPORT AngularMoveDone(void); + NOXREF BOOL IsLockedByMaster(void); public: - NOBODY static float AxisValue(int flags, Vector &angles); - NOBODY static void AxisDir(entvars_t *pev); - NOBODY static float AxisDelta(int flags, Vector &angle1, Vector &angle2); + static float AxisValue(int flags, const Vector &angles); + static void AxisDir(entvars_t *pev); + static float AxisDelta(int flags, const Vector &angle1, const Vector &angle2); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[19]; @@ -856,10 +831,13 @@ public: Vector m_vecFinalAngle; int m_bitsDamageInflict; string_t m_sMaster; + };/* size: 312, cachelines: 5, members: 21 */ #include "basemonster.h" +// Generic Button + /* <24b19> ../cstrike/dlls/cbase.h:745 */ class CBaseButton: public CBaseToggle { @@ -871,12 +849,12 @@ class CBaseButton: public CBaseToggle }; public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); virtual int ObjectCaps(void) { return ObjectCaps_(); @@ -893,7 +871,9 @@ public: int ObjectCaps_(void) { if (pev->takedamage == DAMAGE_NO) + { return FCAP_IMPULSE_USE; + } return (CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } @@ -901,19 +881,19 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void RotSpawn(void); - NOBODY void ButtonActivate(void); - NOBODY void SparkSoundCache(void); + NOXREF void RotSpawn(void); + void ButtonActivate(void); + NOXREF void SparkSoundCache(void); - NOBODY void EXPORT ButtonShot(void); - NOBODY void EXPORT ButtonTouch(CBaseEntity *pOther); - NOBODY void EXPORT ButtonSpark(void); - NOBODY void EXPORT TriggerAndWait(void); - NOBODY void EXPORT ButtonReturn(void); - NOBODY void EXPORT ButtonBackHome(void); - NOBODY void EXPORT ButtonUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + NOXREF void EXPORT ButtonShot(void); + void EXPORT ButtonTouch(CBaseEntity *pOther); + void EXPORT ButtonSpark(void); + void EXPORT TriggerAndWait(void); + void EXPORT ButtonReturn(void); + void EXPORT ButtonBackHome(void); + void EXPORT ButtonUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY BUTTON_CODE ButtonResponseToTouch(void); + BUTTON_CODE ButtonResponseToTouch(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[8]; @@ -927,6 +907,7 @@ public: BYTE m_bUnlockedSound; BYTE m_bUnlockedSentence; int m_sounds; + };/* size: 368, cachelines: 6, members: 11 */ /* <1da023> ../cstrike/dlls/cbase.h:861 */ @@ -990,97 +971,9 @@ public: };/* size: 152, cachelines: 3, members: 1 */ -/* <170b59> ../cstrike/dlls/sound.cpp:117 */ -class CAmbientGeneric: public CBaseEntity -{ -public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - virtual int ObjectCaps(void) - { - return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); - } -#ifdef HOOK_GAMEDLL - int Save_(CSave &save); - int Restore_(CRestore &restore); -#endif // HOOK_GAMEDLL - -public: - NOBODY void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void EXPORT RampThink(void); - NOBODY void InitModulationParms(void); - -public: - static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[4]; - - float m_flAttenuation; - dynpitchvol_t m_dpv; - BOOL m_fActive; - BOOL m_fLooping; - -};/* size: 264, cachelines: 5, members: 6 */ - -/* <170bc2> ../cstrike/dlls/sound.cpp:875 */ -class CEnvSound: public CPointEntity -{ -public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Think(void); - -#ifdef HOOK_GAMEDLL - - int Save_(CSave &save); - int Restore_(CRestore &restore); - -#endif // HOOK_GAMEDLL - -public: - static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[2]; - - float m_flRadius; - float m_flRoomtype; -};/* size: 160, cachelines: 3, members: 4 */ - -/* <170ced> ../cstrike/dlls/sound.cpp:1867 */ -class CSpeaker: public CBaseEntity -{ -public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - virtual int ObjectCaps(void) - { - return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); - } - -#ifdef HOOK_GAMEDLL - - int Save_(CSave &save); - int Restore_(CRestore &restore); - -#endif // HOOK_GAMEDLL - -public: - NOBODY void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void EXPORT SpeakerThink(void); -public: - static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; - - int m_preset; - -};/* size: 156, cachelines: 3, members: 3 */ template T *GetClassPtr(T *a) @@ -1134,7 +1027,7 @@ void OnFreeEntPrivateData(edict_t *pEnt); #ifdef HOOK_GAMEDLL typedef BOOL (CBaseEntity::*FVISIBLE_ENTITY)(CBaseEntity *); -typedef BOOL (CBaseEntity::*FVISIBLE_VECTOR)(Vector &); +typedef BOOL (CBaseEntity::*FVISIBLE_VECTOR)(const Vector &); typedef void (CGrenade::*EXPLODE_VECTOR)(Vector, Vector); typedef void (CGrenade::*EXPLODE_TRACERESULT)(TraceResult *, int); @@ -1145,7 +1038,4 @@ typedef CBaseEntity *(CBaseEntity::*CBASE_ISTANCE_INT)(int); #endif // HOOK_GAMEDLL -//Refs -extern void (*pCGib__SpawnHeadGib)(void); - #endif // CBASE_H diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index bd3cc4e3..c53af5c1 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -6,12 +6,12 @@ */ #ifndef HOOK_GAMEDLL -float g_flTimeLimit = 0; +float g_flTimeLimit = 0; float g_flResetTime = 0; bool g_bClientPrintEnable = true; -char *sPlayerModelFiles[] = -{ +char *sPlayerModelFiles[] = +{ "models/player.mdl", "models/player/leet/leet.mdl", "models/player/gign/gign.mdl", @@ -23,38 +23,38 @@ char *sPlayerModelFiles[] = "models/player/terror/terror.mdl", "models/player/urban/urban.mdl", "models/player/spetsnaz/spetsnaz.mdl", // CZ - "models/player/militia/militia.mdl" // CZ -}; - + "models/player/militia/militia.mdl" // CZ +}; + bool g_skipCareerInitialSpawn; -static entity_field_alias_t entity_field_alias[] = -{ - { "origin[0]", 0 }, - { "origin[1]", 0 }, - { "origin[2]", 0 }, - { "angles[0]", 0 }, - { "angles[1]", 0 }, - { "angles[2]", 0 }, +static entity_field_alias_t entity_field_alias[] = +{ + { "origin[0]", 0 }, + { "origin[1]", 0 }, + { "origin[2]", 0 }, + { "angles[0]", 0 }, + { "angles[1]", 0 }, + { "angles[2]", 0 }, }; static entity_field_alias_t player_field_alias[] = { - { "origin[0]", 0 }, - { "origin[1]", 0 }, + { "origin[0]", 0 }, + { "origin[1]", 0 }, { "origin[2]", 0 }, } static entity_field_alias_t custom_entity_field_alias[] = { - { "origin[0]", 0 }, - { "origin[1]", 0 }, - { "origin[2]", 0 }, - { "angles[0]", 0 }, - { "angles[1]", 0 }, - { "angles[2]", 0 }, - { "skin", 0 }, - { "sequence", 0 }, + { "origin[0]", 0 }, + { "origin[1]", 0 }, + { "origin[2]", 0 }, + { "angles[0]", 0 }, + { "angles[1]", 0 }, + { "angles[2]", 0 }, + { "skin", 0 }, + { "sequence", 0 }, { "animtime", 0 }, } @@ -62,12 +62,12 @@ static int g_serveractive = 0; #else -float g_flTimeLimit; +float g_flTimeLimit; float g_flResetTime; bool g_bClientPrintEnable; -char *sPlayerModelFiles[12]; -bool g_skipCareerInitialSpawn; +char *sPlayerModelFiles[12]; +bool g_skipCareerInitialSpawn; entity_field_alias_t entity_field_alias[6]; entity_field_alias_t player_field_alias[3]; @@ -76,9 +76,9 @@ int g_serveractive; #endif // HOOK_GAMEDLL -PLAYERPVSSTATUS g_PVSStatus[32]; -unsigned short m_usResetDecals; -unsigned short g_iShadowSprite; +PLAYERPVSSTATUS g_PVSStatus[32]; +unsigned short m_usResetDecals; +unsigned short g_iShadowSprite; /* <47b45> ../cstrike/dlls/client.cpp:76 */ int CMD_ARGC_(void) @@ -562,7 +562,7 @@ void ClientPutInServer(edict_t *pEntity) TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, (CBaseEntity *)pPlayer); pPlayer->m_iJoiningState = SHOWLTEXT; - + static char sName[128]; Q_strcpy(sName, STRING(pPlayer->pev->netname)); @@ -589,17 +589,17 @@ int Q_strlen_(const char *str) /* <4bbff> ../cstrike/dlls/client.cpp:814 */ void Host_Say(edict_t *pEntity, int teamonly) { - CBasePlayer *client; - int j; - char *p; - char text[128]; - char szTemp[256]; - const char *cpSay = "say"; - const char *cpSayTeam = "say_team"; + CBasePlayer *client; + int j; + char *p; + char text[128]; + char szTemp[256]; + const char *cpSay = "say"; + const char *cpSayTeam = "say_team"; const char *pcmd = CMD_ARGV_(0); bool bSenderDead = false; - - entvars_t *pev = &pEntity->v; + + entvars_t *pev = &pEntity->v; CBasePlayer *player = GetClassPtr((CBasePlayer *)pev); if (player->m_flLastTalk != 0.0f && gpGlobals->time - player->m_flLastTalk < 0.66f) @@ -616,40 +616,40 @@ void Host_Say(edict_t *pEntity, int teamonly) if (!Q_stricmp(pcmd, cpSay) || !Q_stricmp(pcmd, cpSayTeam)) { - if (CMD_ARGC_() >= 2) - { - p = (char *)CMD_ARGS(); - } - else - { - // say with a blank message, nothing to do - return; + if (CMD_ARGC_() >= 2) + { + p = (char *)CMD_ARGS(); + } + else + { + // say with a blank message, nothing to do + return; } } else // Raw text, need to prepend argv[0] { - if (CMD_ARGC_() >= 2) - { - Q_sprintf(szTemp, "%s %s", (char *)pcmd, (char *)CMD_ARGS()); - } - else - { - // Just a one word command, use the first word...sigh - Q_sprintf(szTemp, "%s", (char *)pcmd); - } - + if (CMD_ARGC_() >= 2) + { + Q_sprintf(szTemp, "%s %s", (char *)pcmd, (char *)CMD_ARGS()); + } + else + { + // Just a one word command, use the first word...sigh + Q_sprintf(szTemp, "%s", (char *)pcmd); + } + p = szTemp; } - // remove quotes if present - if (*p == '"') - { - p++; - p[Q_strlen(p) - 1] = '\0'; + // remove quotes if present + if (*p == '"') + { + p++; + p[Q_strlen(p) - 1] = '\0'; } - // make sure the text has content - if (!p || !p[0] || !Q_UnicodeValidate(p)) + // make sure the text has content + if (!p || !p[0] || !Q_UnicodeValidate(p)) { // no character found, so say nothing return; @@ -776,9 +776,9 @@ void Host_Say(edict_t *pEntity, int teamonly) Q_strcat(text, p); Q_strcat(text, "\n"); - // loop through all players - // Start with the first player. - // This may return the world in single player if the client types something between levels or during spawn + // loop through all players + // Start with the first player. + // This may return the world in single player if the client types something between levels or during spawn // so check it, or it will infinite loop client = NULL; @@ -857,20 +857,11 @@ void Host_Say(edict_t *pEntity, int teamonly) if (CVAR_GET_FLOAT("mp_logmessages") != 0) { - char *temp; + const char *temp = teamonly ? "say_team" : "say"; + const char *deadText = (player->m_iTeam != SPECTATOR && bSenderDead) ? " (dead)" : ""; + char *szTeam = GetTeam(player->m_iTeam); - char *deadText = ""; - if (teamonly) - temp = "say_team"; - else - temp = "say"; - - if (player->m_iTeam != SPECTATOR && bSenderDead) - { - deadText = " (dead)"; - } - UTIL_LogPrintf ( "\"%s<%i><%s><%s>\" %s \"%s\"%s\n", @@ -891,7 +882,9 @@ void DropSecondary(CBasePlayer *pPlayer) if (pPlayer->HasShield()) { if (pPlayer->HasShield() && pPlayer->m_bShieldDrawn && pPlayer->m_pActiveItem != NULL) + { ((CBasePlayerWeapon *)pPlayer->m_pActiveItem)->SecondaryAttack(); + } pPlayer->m_bShieldDrawn = false; } @@ -1175,7 +1168,7 @@ void BuySubMachineGun(CBasePlayer *pPlayer, int iSlot) { iWeapon = WEAPON_UMP45; iWeaponPrice = UMP45_PRICE; - pszWeapon = "weapon_mp5navy"; + pszWeapon = "weapon_ump45"; break; } case 4: @@ -1521,62 +1514,62 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot) } case MENU_SLOT_ITEM_VESTHELM: { - if (fullArmor) - { - if (helmet) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Helmet"); - } - - return; - } - - if (pPlayer->m_iAccount >= HELMET_PRICE) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Bought_Helmet"); - } - - pszItem = "item_assaultsuit"; - iItemPrice = HELMET_PRICE; - } - else - enoughMoney = 0; - - break; - } - else - { - if (helmet) - { - if (pPlayer->m_iAccount >= KEVLAR_PRICE) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Helmet_Bought_Kevlar"); - } - - pszItem = "item_assaultsuit"; - iItemPrice = KEVLAR_PRICE; - } - else - enoughMoney = 0; - } - else - { - if (pPlayer->m_iAccount >= ASSAULTSUIT_PRICE) - { - pszItem = "item_assaultsuit"; - iItemPrice = ASSAULTSUIT_PRICE; - } - else - enoughMoney = 0; - } - } - + if (fullArmor) + { + if (helmet) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Helmet"); + } + + return; + } + + if (pPlayer->m_iAccount >= HELMET_PRICE) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Bought_Helmet"); + } + + pszItem = "item_assaultsuit"; + iItemPrice = HELMET_PRICE; + } + else + enoughMoney = 0; + + break; + } + else + { + if (helmet) + { + if (pPlayer->m_iAccount >= KEVLAR_PRICE) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Helmet_Bought_Kevlar"); + } + + pszItem = "item_assaultsuit"; + iItemPrice = KEVLAR_PRICE; + } + else + enoughMoney = 0; + } + else + { + if (pPlayer->m_iAccount >= ASSAULTSUIT_PRICE) + { + pszItem = "item_assaultsuit"; + iItemPrice = ASSAULTSUIT_PRICE; + } + else + enoughMoney = 0; + } + } + break; } case MENU_SLOT_ITEM_FLASHGREN: @@ -1675,7 +1668,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot) } else enoughMoney = 0; - + break; } case MENU_SLOT_ITEM_DEFUSEKIT: @@ -1770,12 +1763,12 @@ void HandleMenu_ChooseAppearance(CBasePlayer *player, int slot) CHalfLifeMultiplay *mp = g_pGameRules; int numSkins = UTIL_IsGame("czero") ? CZ_NUM_SKIN : CS_NUM_SKIN; - struct - { - ModelName model_id; - char *model_name; - int model_name_index; - + struct + { + ModelName model_id; + char *model_name; + int model_name_index; + } appearance; Q_memset(&appearance, 0, sizeof(appearance)); @@ -1969,40 +1962,40 @@ BOOL HandleMenu_ChooseTeam(CBasePlayer *player, int slot) CLIENT_COMMAND(ENT(player->pev), "slot10\n"); return TRUE; } - case MENU_SLOT_TEAM_RANDOM: - { - team = SelectDefaultTeam(); - - if (team == UNASSIGNED) - { - bool madeRoom = false; - if (cv_bot_auto_vacate.value > 0.0f && !player->IsBot()) - { - team = (RANDOM_LONG(0, 1) == 0) ? TERRORIST : CT; - - if (UTIL_KickBotFromTeam(team)) - madeRoom = true; - else - { - if (team == CT) - team = TERRORIST; - else - team = CT; - - if (UTIL_KickBotFromTeam(team)) - { - madeRoom = true; - } - } - } - - if (!madeRoom) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#All_Teams_Full"); - return FALSE; - } - } - break; + case MENU_SLOT_TEAM_RANDOM: + { + team = SelectDefaultTeam(); + + if (team == UNASSIGNED) + { + bool madeRoom = false; + if (cv_bot_auto_vacate.value > 0.0f && !player->IsBot()) + { + team = (RANDOM_LONG(0, 1) == 0) ? TERRORIST : CT; + + if (UTIL_KickBotFromTeam(team)) + madeRoom = true; + else + { + if (team == CT) + team = TERRORIST; + else + team = CT; + + if (UTIL_KickBotFromTeam(team)) + { + madeRoom = true; + } + } + } + + if (!madeRoom) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#All_Teams_Full"); + return FALSE; + } + } + break; } case MENU_SLOT_TEAM_SPECT: { @@ -2615,15 +2608,15 @@ BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) else if (FStrEq(pszCommand, "secammo")) { bRetVal = TRUE; - if (BuyAmmo(pPlayer, PISTOL_SLOT, true)) - { - while (BuyAmmo(pPlayer, PISTOL_SLOT, false)) - ; - + if (BuyAmmo(pPlayer, PISTOL_SLOT, true)) + { + while (BuyAmmo(pPlayer, PISTOL_SLOT, false)) + ; + if (TheTutor) { TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } + } } } else if (FStrEq(pszCommand, "vest")) @@ -2807,7 +2800,7 @@ BOOL HandleRadioAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) /* <4c6c1> ../cstrike/dlls/client.cpp:3234 */ void ClientCommand(edict_t *pEntity) { - const char *pcmd = CMD_ARGV_(0); + const char *pcmd = CMD_ARGV_(0); const char *pstr = NULL; CHalfLifeMultiplay *mp = g_pGameRules; @@ -2974,7 +2967,7 @@ void ClientCommand(edict_t *pEntity) ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_votemap_usage"); return; } - + if (CountTeamPlayers(player->m_iTeam) < 2) { ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Need_More_People"); @@ -3602,9 +3595,9 @@ void ClientCommand(edict_t *pEntity) else if (FStrEq(pcmd, "fov")) { #if 0 - if (g_flWeaponCheat && CMD_ARGC() > 1) - GetClassPtr((CBasePlayer *)pev)->m_iFOV = Q_atoi(CMD_ARGV(1)); - else + if (g_flWeaponCheat && CMD_ARGC() > 1) + GetClassPtr((CBasePlayer *)pev)->m_iFOV = Q_atoi(CMD_ARGV(1)); + else CLIENT_PRINTF(pEntity, print_console, UTIL_VarArgs("\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV)); #endif } @@ -3742,7 +3735,7 @@ void ClientCommand(edict_t *pEntity) // tell the user they entered an unknown command char command[128]; - // check the length of the command (prevents crash) + // check the length of the command (prevents crash) // max total length is 192 ...and we're adding a string below ("Unknown command: %s\n") Q_strncpy(command, pcmd, sizeof(command) - 1); command[sizeof(command) - 1] = '\0'; @@ -3823,30 +3816,30 @@ void ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) /* <4a378> ../cstrike/dlls/client.cpp:4362 */ void ServerDeactivate(void) { - // It's possible that the engine will call this function more times than is necessary - // Therefore, only run it one time for each call to ServerActivate - if (g_serveractive != 1) - { - return; + // It's possible that the engine will call this function more times than is necessary + // Therefore, only run it one time for each call to ServerActivate + if (g_serveractive != 1) + { + return; } - g_serveractive = 0; - - // Peform any shutdown operations here... - g_pGameRules->ServerDeactivate(); - CLocalNav::Reset(); - TheBots->ServerDeactivate(); - - if (g_pHostages) - { - g_pHostages->ServerDeactivate(); + g_serveractive = 0; + + // Peform any shutdown operations here... + g_pGameRules->ServerDeactivate(); + CLocalNav::Reset(); + TheBots->ServerDeactivate(); + + if (g_pHostages) + { + g_pHostages->ServerDeactivate(); } } /* <4a392> ../cstrike/dlls/client.cpp:4400 */ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) { - int i; + int i; CBaseEntity *pClass; // Every call to ServerActivate should be matched by a call to ServerDeactivate @@ -3909,10 +3902,10 @@ void PlayerPreThink(edict_t *pEntity) /* <4a47c> ../cstrike/dlls/client.cpp:4475 */ void PlayerPostThink(edict_t *pEntity) { - entvars_t *pev = &pEntity->v; - CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); - - if (pPlayer) + entvars_t *pev = &pEntity->v; + CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); + + if (pPlayer) { pPlayer->PostThink(); } @@ -3976,407 +3969,407 @@ void StartFrame(void) /* <4a581> ../cstrike/dlls/client.cpp:4534 */ void ClientPrecache(void) { - int i; - bool isCZero = UTIL_IsGame("czero"); - - PRECACHE_SOUND("weapons/dryfire_pistol.wav"); - PRECACHE_SOUND("weapons/dryfire_rifle.wav"); - PRECACHE_SOUND("player/pl_shot1.wav"); - PRECACHE_SOUND("player/pl_die1.wav"); - PRECACHE_SOUND("player/headshot1.wav"); - PRECACHE_SOUND("player/headshot2.wav"); - PRECACHE_SOUND("player/headshot3.wav"); - PRECACHE_SOUND("player/bhit_flesh-1.wav"); - PRECACHE_SOUND("player/bhit_flesh-2.wav"); - PRECACHE_SOUND("player/bhit_flesh-3.wav"); - PRECACHE_SOUND("player/bhit_kevlar-1.wav"); - PRECACHE_SOUND("player/bhit_helmet-1.wav"); - PRECACHE_SOUND("player/die1.wav"); - PRECACHE_SOUND("player/die2.wav"); - PRECACHE_SOUND("player/die3.wav"); - PRECACHE_SOUND("player/death6.wav"); - PRECACHE_SOUND("radio/locknload.wav"); - PRECACHE_SOUND("radio/letsgo.wav"); - PRECACHE_SOUND("radio/moveout.wav"); - PRECACHE_SOUND("radio/com_go.wav"); - PRECACHE_SOUND("radio/rescued.wav"); - PRECACHE_SOUND("radio/rounddraw.wav"); - PRECACHE_SOUND("items/kevlar.wav"); - PRECACHE_SOUND("items/ammopickup2.wav"); - PRECACHE_SOUND("items/nvg_on.wav"); - PRECACHE_SOUND("items/nvg_off.wav"); - PRECACHE_SOUND("items/equip_nvg.wav"); - PRECACHE_SOUND("weapons/c4_beep1.wav"); - PRECACHE_SOUND("weapons/c4_beep2.wav"); - PRECACHE_SOUND("weapons/c4_beep3.wav"); - PRECACHE_SOUND("weapons/c4_beep4.wav"); - PRECACHE_SOUND("weapons/c4_beep5.wav"); - PRECACHE_SOUND("weapons/c4_explode1.wav"); - PRECACHE_SOUND("weapons/c4_plant.wav"); - PRECACHE_SOUND("weapons/c4_disarm.wav"); - PRECACHE_SOUND("weapons/c4_disarmed.wav"); - PRECACHE_SOUND("weapons/explode3.wav"); - PRECACHE_SOUND("weapons/explode4.wav"); - PRECACHE_SOUND("weapons/explode5.wav"); - PRECACHE_SOUND("player/sprayer.wav"); - PRECACHE_SOUND("player/pl_fallpain2.wav"); - PRECACHE_SOUND("player/pl_fallpain3.wav"); - PRECACHE_SOUND("player/pl_snow1.wav"); - PRECACHE_SOUND("player/pl_snow2.wav"); - PRECACHE_SOUND("player/pl_snow3.wav"); - PRECACHE_SOUND("player/pl_snow4.wav"); - PRECACHE_SOUND("player/pl_snow5.wav"); - PRECACHE_SOUND("player/pl_snow6.wav"); - PRECACHE_SOUND("player/pl_step1.wav"); - PRECACHE_SOUND("player/pl_step2.wav"); - PRECACHE_SOUND("player/pl_step3.wav"); - PRECACHE_SOUND("player/pl_step4.wav"); - PRECACHE_SOUND("common/npc_step1.wav"); - PRECACHE_SOUND("common/npc_step2.wav"); - PRECACHE_SOUND("common/npc_step3.wav"); - PRECACHE_SOUND("common/npc_step4.wav"); - PRECACHE_SOUND("player/pl_metal1.wav"); - PRECACHE_SOUND("player/pl_metal2.wav"); - PRECACHE_SOUND("player/pl_metal3.wav"); - PRECACHE_SOUND("player/pl_metal4.wav"); - PRECACHE_SOUND("player/pl_dirt1.wav"); - PRECACHE_SOUND("player/pl_dirt2.wav"); - PRECACHE_SOUND("player/pl_dirt3.wav"); - PRECACHE_SOUND("player/pl_dirt4.wav"); - PRECACHE_SOUND("player/pl_duct1.wav"); - PRECACHE_SOUND("player/pl_duct2.wav"); - PRECACHE_SOUND("player/pl_duct3.wav"); - PRECACHE_SOUND("player/pl_duct4.wav"); - PRECACHE_SOUND("player/pl_grate1.wav"); - PRECACHE_SOUND("player/pl_grate2.wav"); - PRECACHE_SOUND("player/pl_grate3.wav"); - PRECACHE_SOUND("player/pl_grate4.wav"); - PRECACHE_SOUND("player/pl_slosh1.wav"); - PRECACHE_SOUND("player/pl_slosh2.wav"); - PRECACHE_SOUND("player/pl_slosh3.wav"); - PRECACHE_SOUND("player/pl_slosh4.wav"); - PRECACHE_SOUND("player/pl_tile1.wav"); - PRECACHE_SOUND("player/pl_tile2.wav"); - PRECACHE_SOUND("player/pl_tile3.wav"); - PRECACHE_SOUND("player/pl_tile4.wav"); - PRECACHE_SOUND("player/pl_tile5.wav"); - PRECACHE_SOUND("player/pl_swim1.wav"); - PRECACHE_SOUND("player/pl_swim2.wav"); - PRECACHE_SOUND("player/pl_swim3.wav"); - PRECACHE_SOUND("player/pl_swim4.wav"); - PRECACHE_SOUND("player/pl_ladder1.wav"); - PRECACHE_SOUND("player/pl_ladder2.wav"); - PRECACHE_SOUND("player/pl_ladder3.wav"); - PRECACHE_SOUND("player/pl_ladder4.wav"); - PRECACHE_SOUND("player/pl_wade1.wav"); - PRECACHE_SOUND("player/pl_wade2.wav"); - PRECACHE_SOUND("player/pl_wade3.wav"); - PRECACHE_SOUND("player/pl_wade4.wav"); - PRECACHE_SOUND("debris/wood1.wav"); - PRECACHE_SOUND("debris/wood2.wav"); - PRECACHE_SOUND("debris/wood3.wav"); - PRECACHE_SOUND("plats/train_use1.wav"); - PRECACHE_SOUND("plats/vehicle_ignition.wav"); - PRECACHE_SOUND("buttons/spark5.wav"); - PRECACHE_SOUND("buttons/spark6.wav"); - PRECACHE_SOUND("debris/glass1.wav"); - PRECACHE_SOUND("debris/glass2.wav"); - PRECACHE_SOUND("debris/glass3.wav"); - PRECACHE_SOUND("items/flashlight1.wav"); - PRECACHE_SOUND("items/flashlight1.wav"); - PRECACHE_SOUND("common/bodysplat.wav"); - PRECACHE_SOUND("player/pl_pain2.wav"); - PRECACHE_SOUND("player/pl_pain4.wav"); - PRECACHE_SOUND("player/pl_pain5.wav"); - PRECACHE_SOUND("player/pl_pain6.wav"); - PRECACHE_SOUND("player/pl_pain7.wav"); - - int numPlayerModels; - if (isCZero) - numPlayerModels = ARRAYSIZE(sPlayerModelFiles); - else - numPlayerModels = ARRAYSIZE(sPlayerModelFiles) - 2; - - for (i = 0; i < numPlayerModels; i++) - PRECACHE_MODEL(sPlayerModelFiles[i]); - - for (i = FirstCustomSkin; i <= LastCustomSkin; i++) - { - const char *fname = TheBotProfiles->GetCustomSkinFname( i ); - - if (!fname) - break; - - PRECACHE_MODEL((char *)fname); - } - - PRECACHE_MODEL("models/p_ak47.mdl"); - PRECACHE_MODEL("models/p_aug.mdl"); - PRECACHE_MODEL("models/p_awp.mdl"); - PRECACHE_MODEL("models/p_c4.mdl"); - PRECACHE_MODEL("models/w_c4.mdl"); - PRECACHE_MODEL("models/p_deagle.mdl"); - PRECACHE_MODEL("models/shield/p_shield_deagle.mdl"); - PRECACHE_MODEL("models/p_flashbang.mdl"); - PRECACHE_MODEL("models/shield/p_shield_flashbang.mdl"); - PRECACHE_MODEL("models/p_hegrenade.mdl"); - PRECACHE_MODEL("models/shield/p_shield_hegrenade.mdl"); - PRECACHE_MODEL("models/p_glock18.mdl"); - PRECACHE_MODEL("models/shield/p_shield_glock18.mdl"); - PRECACHE_MODEL("models/p_p228.mdl"); - PRECACHE_MODEL("models/shield/p_shield_p228.mdl"); - PRECACHE_MODEL("models/p_smokegrenade.mdl"); - PRECACHE_MODEL("models/shield/p_shield_smokegrenade.mdl"); - PRECACHE_MODEL("models/p_usp.mdl"); - PRECACHE_MODEL("models/shield/p_shield_usp.mdl"); - PRECACHE_MODEL("models/p_fiveseven.mdl"); - PRECACHE_MODEL("models/shield/p_shield_fiveseven.mdl"); - PRECACHE_MODEL("models/p_knife.mdl"); - PRECACHE_MODEL("models/shield/p_shield_knife.mdl"); - PRECACHE_MODEL("models/w_flashbang.mdl"); - PRECACHE_MODEL("models/w_hegrenade.mdl"); - PRECACHE_MODEL("models/p_sg550.mdl"); - PRECACHE_MODEL("models/p_g3sg1.mdl"); - PRECACHE_MODEL("models/p_m249.mdl"); - PRECACHE_MODEL("models/p_m3.mdl"); - PRECACHE_MODEL("models/p_m4a1.mdl"); - PRECACHE_MODEL("models/p_mac10.mdl"); - PRECACHE_MODEL("models/p_mp5.mdl"); - PRECACHE_MODEL("models/p_ump45.mdl"); - PRECACHE_MODEL("models/p_p90.mdl"); - PRECACHE_MODEL("models/p_scout.mdl"); - PRECACHE_MODEL("models/p_sg552.mdl"); - PRECACHE_MODEL("models/w_smokegrenade.mdl"); - PRECACHE_MODEL("models/p_tmp.mdl"); - PRECACHE_MODEL("models/p_elite.mdl"); - PRECACHE_MODEL("models/p_xm1014.mdl"); - PRECACHE_MODEL("models/p_galil.mdl"); - PRECACHE_MODEL("models/p_famas.mdl"); - PRECACHE_MODEL("models/p_shield.mdl"); - PRECACHE_MODEL("models/w_shield.mdl"); - - Vector temp = g_vecZero; - Vector vMin = Vector(-38, -24, -41); - Vector vMax = Vector(38, 24, 41); - - for (i = 0; i < numPlayerModels; i++) - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, sPlayerModelFiles[i]); - - for (i = FirstCustomSkin; i <= LastCustomSkin; i++) - { - const char *fname = TheBotProfiles->GetCustomSkinFname( i ); - - if (!fname) - break; - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds_if_avail, (float *)&vMin, (float *)&vMax, fname); - } - - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke1.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke2.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke3.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke4.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/fast_wallpuff1.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/smokepuff.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/gas_puff_01.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc.tga"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_nw.tga"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_ne.tga"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_sw.tga"); - - if (isCZero) - { - vMin = Vector(-13, -6, -22); - vMax = Vector(13, 6, 22); - } - else - { - vMin = Vector(-12, -6, -22); - vMax = Vector(12, 6, 22); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_deagle.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p228.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_elite.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_usp.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_fiveseven.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_glock18.mdl"); - - if (isCZero) - { - vMin = Vector(-26, -19, -21); - vMax = Vector(26, 23, 21); - } - else - { - vMin = Vector(-25, -19, -21); - vMax = Vector(25, 23, 21); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_xm1014.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m3.mdl"); - - if (isCZero) - { - vMin = Vector(-23, -9, -20); - vMax = Vector(23, 17, 20); - } - else - { - vMin = Vector(-23, -8, -20); - vMax = Vector(23, 8, 20); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mac10.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mp5.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ump45.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_tmp.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p90.mdl"); - - if (isCZero) - { - vMin = Vector(-38, -33, -22); - vMax = Vector(38, 15, 35); - } - else - { - vMin = Vector(-31, -8, -21); - vMax = Vector(31, 12, 31); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ak47.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_aug.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_awp.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_g3sg1.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg550.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m4a1.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_scout.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg552.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_famas.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_galil.mdl"); - - if (isCZero) - { - vMin = Vector(-30, -10, -20); - vMax = Vector(30, 11, 20); - } - else - { - vMin = Vector(-24, -10, -20); - vMax = Vector(25, 10, 20); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m249.mdl"); - - vMin = Vector(-7, -7, -15); - vMax = Vector(7, 7, 15); - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_c4.mdl"); - - vMin = Vector(-4, -8, -3); - vMax = Vector(3, 7, 3); - - if (isCZero) - { - vMin = Vector(-17, -8, -3); - vMax = Vector(17, 7, 3); - } - else - { - vMin = Vector(-4, -8, -3); - vMax = Vector(3, 7, 3); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_c4.mdl"); - - if (isCZero) - { - vMin = Vector(-7, -3, -18); - vMax = Vector(7, 2, 18); - } - else - { - vMin = Vector(-7, -2, -18); - vMax = Vector(7, 2, 18); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_flashbang.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_hegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_smokegrenade.mdl"); - - if (isCZero) - vMin = Vector(-5, -5, -7); - else - vMin = Vector(-5, -5, -5); - - vMax = Vector(5, 5, 14); - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_flashbang.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_hegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_smokegrenade.mdl"); - - vMin = Vector(-7, -11, -18); - vMax = Vector(7, 6, 18); - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_knife.mdl"); - - if (isCZero) - { - vMin = Vector(-21, -25, -54); - vMax = Vector(21, 23, 24); - } - else - { - vMin = Vector(-16, -8, -54); - vMax = Vector(16, 6, 24); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_deagle.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_fiveseven.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_flashbang.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_glock18.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_hegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_knife.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_p228.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_smokegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_usp.mdl"); - - PRECACHE_SOUND("common/wpn_hudoff.wav"); - PRECACHE_SOUND("common/wpn_hudon.wav"); - PRECACHE_SOUND("common/wpn_moveselect.wav"); - PRECACHE_SOUND("common/wpn_select.wav"); - PRECACHE_SOUND("common/wpn_denyselect.wav"); - PRECACHE_SOUND("player/geiger6.wav"); - PRECACHE_SOUND("player/geiger5.wav"); - PRECACHE_SOUND("player/geiger4.wav"); - PRECACHE_SOUND("player/geiger3.wav"); - PRECACHE_SOUND("player/geiger2.wav"); - PRECACHE_SOUND("player/geiger1.wav"); - - if (giPrecacheGrunt) - UTIL_PrecacheOther("enemy_terrorist"); - - g_iShadowSprite = PRECACHE_MODEL("sprites/shadow_circle.spr"); - - PRECACHE_MODEL("sprites/wall_puff1.spr"); - PRECACHE_MODEL("sprites/wall_puff2.spr"); - PRECACHE_MODEL("sprites/wall_puff3.spr"); - PRECACHE_MODEL("sprites/wall_puff4.spr"); - PRECACHE_MODEL("sprites/black_smoke1.spr"); - PRECACHE_MODEL("sprites/black_smoke2.spr"); - PRECACHE_MODEL("sprites/black_smoke3.spr"); - PRECACHE_MODEL("sprites/black_smoke4.spr"); - PRECACHE_MODEL("sprites/fast_wallpuff1.spr"); - PRECACHE_MODEL("sprites/pistol_smoke1.spr"); - PRECACHE_MODEL("sprites/pistol_smoke2.spr"); - PRECACHE_MODEL("sprites/rifle_smoke1.spr"); - PRECACHE_MODEL("sprites/rifle_smoke2.spr"); - PRECACHE_MODEL("sprites/rifle_smoke3.spr"); - PRECACHE_GENERIC("sprites/scope_arc.tga"); - PRECACHE_GENERIC("sprites/scope_arc_nw.tga"); - PRECACHE_GENERIC("sprites/scope_arc_ne.tga"); - PRECACHE_GENERIC("sprites/scope_arc_sw.tga"); - + int i; + bool isCZero = UTIL_IsGame("czero"); + + PRECACHE_SOUND("weapons/dryfire_pistol.wav"); + PRECACHE_SOUND("weapons/dryfire_rifle.wav"); + PRECACHE_SOUND("player/pl_shot1.wav"); + PRECACHE_SOUND("player/pl_die1.wav"); + PRECACHE_SOUND("player/headshot1.wav"); + PRECACHE_SOUND("player/headshot2.wav"); + PRECACHE_SOUND("player/headshot3.wav"); + PRECACHE_SOUND("player/bhit_flesh-1.wav"); + PRECACHE_SOUND("player/bhit_flesh-2.wav"); + PRECACHE_SOUND("player/bhit_flesh-3.wav"); + PRECACHE_SOUND("player/bhit_kevlar-1.wav"); + PRECACHE_SOUND("player/bhit_helmet-1.wav"); + PRECACHE_SOUND("player/die1.wav"); + PRECACHE_SOUND("player/die2.wav"); + PRECACHE_SOUND("player/die3.wav"); + PRECACHE_SOUND("player/death6.wav"); + PRECACHE_SOUND("radio/locknload.wav"); + PRECACHE_SOUND("radio/letsgo.wav"); + PRECACHE_SOUND("radio/moveout.wav"); + PRECACHE_SOUND("radio/com_go.wav"); + PRECACHE_SOUND("radio/rescued.wav"); + PRECACHE_SOUND("radio/rounddraw.wav"); + PRECACHE_SOUND("items/kevlar.wav"); + PRECACHE_SOUND("items/ammopickup2.wav"); + PRECACHE_SOUND("items/nvg_on.wav"); + PRECACHE_SOUND("items/nvg_off.wav"); + PRECACHE_SOUND("items/equip_nvg.wav"); + PRECACHE_SOUND("weapons/c4_beep1.wav"); + PRECACHE_SOUND("weapons/c4_beep2.wav"); + PRECACHE_SOUND("weapons/c4_beep3.wav"); + PRECACHE_SOUND("weapons/c4_beep4.wav"); + PRECACHE_SOUND("weapons/c4_beep5.wav"); + PRECACHE_SOUND("weapons/c4_explode1.wav"); + PRECACHE_SOUND("weapons/c4_plant.wav"); + PRECACHE_SOUND("weapons/c4_disarm.wav"); + PRECACHE_SOUND("weapons/c4_disarmed.wav"); + PRECACHE_SOUND("weapons/explode3.wav"); + PRECACHE_SOUND("weapons/explode4.wav"); + PRECACHE_SOUND("weapons/explode5.wav"); + PRECACHE_SOUND("player/sprayer.wav"); + PRECACHE_SOUND("player/pl_fallpain2.wav"); + PRECACHE_SOUND("player/pl_fallpain3.wav"); + PRECACHE_SOUND("player/pl_snow1.wav"); + PRECACHE_SOUND("player/pl_snow2.wav"); + PRECACHE_SOUND("player/pl_snow3.wav"); + PRECACHE_SOUND("player/pl_snow4.wav"); + PRECACHE_SOUND("player/pl_snow5.wav"); + PRECACHE_SOUND("player/pl_snow6.wav"); + PRECACHE_SOUND("player/pl_step1.wav"); + PRECACHE_SOUND("player/pl_step2.wav"); + PRECACHE_SOUND("player/pl_step3.wav"); + PRECACHE_SOUND("player/pl_step4.wav"); + PRECACHE_SOUND("common/npc_step1.wav"); + PRECACHE_SOUND("common/npc_step2.wav"); + PRECACHE_SOUND("common/npc_step3.wav"); + PRECACHE_SOUND("common/npc_step4.wav"); + PRECACHE_SOUND("player/pl_metal1.wav"); + PRECACHE_SOUND("player/pl_metal2.wav"); + PRECACHE_SOUND("player/pl_metal3.wav"); + PRECACHE_SOUND("player/pl_metal4.wav"); + PRECACHE_SOUND("player/pl_dirt1.wav"); + PRECACHE_SOUND("player/pl_dirt2.wav"); + PRECACHE_SOUND("player/pl_dirt3.wav"); + PRECACHE_SOUND("player/pl_dirt4.wav"); + PRECACHE_SOUND("player/pl_duct1.wav"); + PRECACHE_SOUND("player/pl_duct2.wav"); + PRECACHE_SOUND("player/pl_duct3.wav"); + PRECACHE_SOUND("player/pl_duct4.wav"); + PRECACHE_SOUND("player/pl_grate1.wav"); + PRECACHE_SOUND("player/pl_grate2.wav"); + PRECACHE_SOUND("player/pl_grate3.wav"); + PRECACHE_SOUND("player/pl_grate4.wav"); + PRECACHE_SOUND("player/pl_slosh1.wav"); + PRECACHE_SOUND("player/pl_slosh2.wav"); + PRECACHE_SOUND("player/pl_slosh3.wav"); + PRECACHE_SOUND("player/pl_slosh4.wav"); + PRECACHE_SOUND("player/pl_tile1.wav"); + PRECACHE_SOUND("player/pl_tile2.wav"); + PRECACHE_SOUND("player/pl_tile3.wav"); + PRECACHE_SOUND("player/pl_tile4.wav"); + PRECACHE_SOUND("player/pl_tile5.wav"); + PRECACHE_SOUND("player/pl_swim1.wav"); + PRECACHE_SOUND("player/pl_swim2.wav"); + PRECACHE_SOUND("player/pl_swim3.wav"); + PRECACHE_SOUND("player/pl_swim4.wav"); + PRECACHE_SOUND("player/pl_ladder1.wav"); + PRECACHE_SOUND("player/pl_ladder2.wav"); + PRECACHE_SOUND("player/pl_ladder3.wav"); + PRECACHE_SOUND("player/pl_ladder4.wav"); + PRECACHE_SOUND("player/pl_wade1.wav"); + PRECACHE_SOUND("player/pl_wade2.wav"); + PRECACHE_SOUND("player/pl_wade3.wav"); + PRECACHE_SOUND("player/pl_wade4.wav"); + PRECACHE_SOUND("debris/wood1.wav"); + PRECACHE_SOUND("debris/wood2.wav"); + PRECACHE_SOUND("debris/wood3.wav"); + PRECACHE_SOUND("plats/train_use1.wav"); + PRECACHE_SOUND("plats/vehicle_ignition.wav"); + PRECACHE_SOUND("buttons/spark5.wav"); + PRECACHE_SOUND("buttons/spark6.wav"); + PRECACHE_SOUND("debris/glass1.wav"); + PRECACHE_SOUND("debris/glass2.wav"); + PRECACHE_SOUND("debris/glass3.wav"); + PRECACHE_SOUND("items/flashlight1.wav"); + PRECACHE_SOUND("items/flashlight1.wav"); + PRECACHE_SOUND("common/bodysplat.wav"); + PRECACHE_SOUND("player/pl_pain2.wav"); + PRECACHE_SOUND("player/pl_pain4.wav"); + PRECACHE_SOUND("player/pl_pain5.wav"); + PRECACHE_SOUND("player/pl_pain6.wav"); + PRECACHE_SOUND("player/pl_pain7.wav"); + + int numPlayerModels; + if (isCZero) + numPlayerModels = ARRAYSIZE(sPlayerModelFiles); + else + numPlayerModels = ARRAYSIZE(sPlayerModelFiles) - 2; + + for (i = 0; i < numPlayerModels; i++) + PRECACHE_MODEL(sPlayerModelFiles[i]); + + for (i = FirstCustomSkin; i <= LastCustomSkin; i++) + { + const char *fname = TheBotProfiles->GetCustomSkinFname(i); + + if (!fname) + break; + + PRECACHE_MODEL((char *)fname); + } + + PRECACHE_MODEL("models/p_ak47.mdl"); + PRECACHE_MODEL("models/p_aug.mdl"); + PRECACHE_MODEL("models/p_awp.mdl"); + PRECACHE_MODEL("models/p_c4.mdl"); + PRECACHE_MODEL("models/w_c4.mdl"); + PRECACHE_MODEL("models/p_deagle.mdl"); + PRECACHE_MODEL("models/shield/p_shield_deagle.mdl"); + PRECACHE_MODEL("models/p_flashbang.mdl"); + PRECACHE_MODEL("models/shield/p_shield_flashbang.mdl"); + PRECACHE_MODEL("models/p_hegrenade.mdl"); + PRECACHE_MODEL("models/shield/p_shield_hegrenade.mdl"); + PRECACHE_MODEL("models/p_glock18.mdl"); + PRECACHE_MODEL("models/shield/p_shield_glock18.mdl"); + PRECACHE_MODEL("models/p_p228.mdl"); + PRECACHE_MODEL("models/shield/p_shield_p228.mdl"); + PRECACHE_MODEL("models/p_smokegrenade.mdl"); + PRECACHE_MODEL("models/shield/p_shield_smokegrenade.mdl"); + PRECACHE_MODEL("models/p_usp.mdl"); + PRECACHE_MODEL("models/shield/p_shield_usp.mdl"); + PRECACHE_MODEL("models/p_fiveseven.mdl"); + PRECACHE_MODEL("models/shield/p_shield_fiveseven.mdl"); + PRECACHE_MODEL("models/p_knife.mdl"); + PRECACHE_MODEL("models/shield/p_shield_knife.mdl"); + PRECACHE_MODEL("models/w_flashbang.mdl"); + PRECACHE_MODEL("models/w_hegrenade.mdl"); + PRECACHE_MODEL("models/p_sg550.mdl"); + PRECACHE_MODEL("models/p_g3sg1.mdl"); + PRECACHE_MODEL("models/p_m249.mdl"); + PRECACHE_MODEL("models/p_m3.mdl"); + PRECACHE_MODEL("models/p_m4a1.mdl"); + PRECACHE_MODEL("models/p_mac10.mdl"); + PRECACHE_MODEL("models/p_mp5.mdl"); + PRECACHE_MODEL("models/p_ump45.mdl"); + PRECACHE_MODEL("models/p_p90.mdl"); + PRECACHE_MODEL("models/p_scout.mdl"); + PRECACHE_MODEL("models/p_sg552.mdl"); + PRECACHE_MODEL("models/w_smokegrenade.mdl"); + PRECACHE_MODEL("models/p_tmp.mdl"); + PRECACHE_MODEL("models/p_elite.mdl"); + PRECACHE_MODEL("models/p_xm1014.mdl"); + PRECACHE_MODEL("models/p_galil.mdl"); + PRECACHE_MODEL("models/p_famas.mdl"); + PRECACHE_MODEL("models/p_shield.mdl"); + PRECACHE_MODEL("models/w_shield.mdl"); + + Vector temp = g_vecZero; + Vector vMin = Vector(-38, -24, -41); + Vector vMax = Vector(38, 24, 41); + + for (i = 0; i < numPlayerModels; i++) + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, sPlayerModelFiles[i]); + + for (i = FirstCustomSkin; i <= LastCustomSkin; i++) + { + const char *fname = TheBotProfiles->GetCustomSkinFname(i); + + if (!fname) + break; + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds_if_avail, (float *)&vMin, (float *)&vMax, fname); + } + + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke1.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke2.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke3.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke4.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/fast_wallpuff1.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/smokepuff.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/gas_puff_01.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc.tga"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_nw.tga"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_ne.tga"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_sw.tga"); + + if (isCZero) + { + vMin = Vector(-13, -6, -22); + vMax = Vector(13, 6, 22); + } + else + { + vMin = Vector(-12, -6, -22); + vMax = Vector(12, 6, 22); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_deagle.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p228.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_elite.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_usp.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_fiveseven.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_glock18.mdl"); + + if (isCZero) + { + vMin = Vector(-26, -19, -21); + vMax = Vector(26, 23, 21); + } + else + { + vMin = Vector(-25, -19, -21); + vMax = Vector(25, 23, 21); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_xm1014.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m3.mdl"); + + if (isCZero) + { + vMin = Vector(-23, -9, -20); + vMax = Vector(23, 17, 20); + } + else + { + vMin = Vector(-23, -8, -20); + vMax = Vector(23, 8, 20); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mac10.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mp5.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ump45.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_tmp.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p90.mdl"); + + if (isCZero) + { + vMin = Vector(-38, -33, -22); + vMax = Vector(38, 15, 35); + } + else + { + vMin = Vector(-31, -8, -21); + vMax = Vector(31, 12, 31); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ak47.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_aug.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_awp.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_g3sg1.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg550.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m4a1.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_scout.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg552.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_famas.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_galil.mdl"); + + if (isCZero) + { + vMin = Vector(-30, -10, -20); + vMax = Vector(30, 11, 20); + } + else + { + vMin = Vector(-24, -10, -20); + vMax = Vector(25, 10, 20); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m249.mdl"); + + vMin = Vector(-7, -7, -15); + vMax = Vector(7, 7, 15); + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_c4.mdl"); + + vMin = Vector(-4, -8, -3); + vMax = Vector(3, 7, 3); + + if (isCZero) + { + vMin = Vector(-17, -8, -3); + vMax = Vector(17, 7, 3); + } + else + { + vMin = Vector(-4, -8, -3); + vMax = Vector(3, 7, 3); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_c4.mdl"); + + if (isCZero) + { + vMin = Vector(-7, -3, -18); + vMax = Vector(7, 2, 18); + } + else + { + vMin = Vector(-7, -2, -18); + vMax = Vector(7, 2, 18); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_flashbang.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_hegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_smokegrenade.mdl"); + + if (isCZero) + vMin = Vector(-5, -5, -7); + else + vMin = Vector(-5, -5, -5); + + vMax = Vector(5, 5, 14); + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_flashbang.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_hegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_smokegrenade.mdl"); + + vMin = Vector(-7, -11, -18); + vMax = Vector(7, 6, 18); + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_knife.mdl"); + + if (isCZero) + { + vMin = Vector(-21, -25, -54); + vMax = Vector(21, 23, 24); + } + else + { + vMin = Vector(-16, -8, -54); + vMax = Vector(16, 6, 24); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_deagle.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_fiveseven.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_flashbang.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_glock18.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_hegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_knife.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_p228.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_smokegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_usp.mdl"); + + PRECACHE_SOUND("common/wpn_hudoff.wav"); + PRECACHE_SOUND("common/wpn_hudon.wav"); + PRECACHE_SOUND("common/wpn_moveselect.wav"); + PRECACHE_SOUND("common/wpn_select.wav"); + PRECACHE_SOUND("common/wpn_denyselect.wav"); + PRECACHE_SOUND("player/geiger6.wav"); + PRECACHE_SOUND("player/geiger5.wav"); + PRECACHE_SOUND("player/geiger4.wav"); + PRECACHE_SOUND("player/geiger3.wav"); + PRECACHE_SOUND("player/geiger2.wav"); + PRECACHE_SOUND("player/geiger1.wav"); + + if (giPrecacheGrunt) + UTIL_PrecacheOther("enemy_terrorist"); + + g_iShadowSprite = PRECACHE_MODEL("sprites/shadow_circle.spr"); + + PRECACHE_MODEL("sprites/wall_puff1.spr"); + PRECACHE_MODEL("sprites/wall_puff2.spr"); + PRECACHE_MODEL("sprites/wall_puff3.spr"); + PRECACHE_MODEL("sprites/wall_puff4.spr"); + PRECACHE_MODEL("sprites/black_smoke1.spr"); + PRECACHE_MODEL("sprites/black_smoke2.spr"); + PRECACHE_MODEL("sprites/black_smoke3.spr"); + PRECACHE_MODEL("sprites/black_smoke4.spr"); + PRECACHE_MODEL("sprites/fast_wallpuff1.spr"); + PRECACHE_MODEL("sprites/pistol_smoke1.spr"); + PRECACHE_MODEL("sprites/pistol_smoke2.spr"); + PRECACHE_MODEL("sprites/rifle_smoke1.spr"); + PRECACHE_MODEL("sprites/rifle_smoke2.spr"); + PRECACHE_MODEL("sprites/rifle_smoke3.spr"); + PRECACHE_GENERIC("sprites/scope_arc.tga"); + PRECACHE_GENERIC("sprites/scope_arc_nw.tga"); + PRECACHE_GENERIC("sprites/scope_arc_ne.tga"); + PRECACHE_GENERIC("sprites/scope_arc_sw.tga"); + m_usResetDecals = g_engfuncs.pfnPrecacheEvent(1, "events/decal_reset.sc"); } @@ -4433,7 +4426,9 @@ void SpectatorConnect(edict_t *pEntity) CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); if (pPlayer) + { pPlayer->SpectatorConnect(); + } } /* <4a83d> ../cstrike/dlls/client.cpp:5095 */ @@ -4442,7 +4437,9 @@ void SpectatorDisconnect(edict_t *pEntity) CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); if (pPlayer) + { pPlayer->SpectatorDisconnect(); + } } /* <4a8b5> ../cstrike/dlls/client.cpp:5111 */ @@ -4451,46 +4448,48 @@ void SpectatorThink(edict_t *pEntity) CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); if (pPlayer) + { pPlayer->SpectatorThink(); + } } /* <4a92d> ../cstrike/dlls/client.cpp:5160 */ void SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas) -{ - edict_t *pView = pClient; - - // Find the client's PVS - if (pViewEntity) - { - pView = pViewEntity; - } - - if (pClient->v.flags & FL_PROXY) - { - *pvs = NULL; // the spectator proxy sees - *pas = NULL; // and hears everything - return; - } - - CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pClient)); - - if (pPlayer->pev->iuser2 && pPlayer->m_hObserverTarget) - { - if (pPlayer->m_afPhysicsFlags & PFLAG_OBSERVER) - { +{ + edict_t *pView = pClient; + + // Find the client's PVS + if (pViewEntity) + { + pView = pViewEntity; + } + + if (pClient->v.flags & FL_PROXY) + { + *pvs = NULL; // the spectator proxy sees + *pas = NULL; // and hears everything + return; + } + + CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pClient)); + + if (pPlayer->pev->iuser2 && pPlayer->m_hObserverTarget) + { + if (pPlayer->m_afPhysicsFlags & PFLAG_OBSERVER) + { pView = pPlayer->m_hObserverTarget->edict(); - UTIL_SetOrigin(pPlayer->pev, pPlayer->m_hObserverTarget->pev->origin); - } - } - - Vector org = pView->v.origin + pView->v.view_ofs; - - if (pView->v.flags & FL_DUCKING) - { - org = org + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); - } - - *pvs = ENGINE_SET_PVS((float *)&org); + UTIL_SetOrigin(pPlayer->pev, pPlayer->m_hObserverTarget->pev->origin); + } + } + + Vector org = pView->v.origin + pView->v.view_ofs; + + if (pView->v.flags & FL_DUCKING) + { + org = org + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); + } + + *pvs = ENGINE_SET_PVS((float *)&org); *pas = ENGINE_SET_PAS((float *)&org); } @@ -4665,7 +4664,7 @@ int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *ho if (ent->v.owner) { int owner = ENTINDEX(ent->v.owner); - + if (owner >= 1 && owner <= gpGlobals->maxClients) state->owner = owner; } @@ -4674,7 +4673,7 @@ int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *ho { Q_memcpy(state->basevelocity, ent->v.basevelocity, sizeof(float) * 3); - state->weaponmodel = MODEL_INDEX( STRING(ent->v.weaponmodel) ); + state->weaponmodel = MODEL_INDEX(STRING(ent->v.weaponmodel)); state->gaitsequence = ent->v.gaitsequence; state->spectator = (ent->v.flags & FL_SPECTATOR) ? TRUE : FALSE; @@ -4695,59 +4694,59 @@ int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *ho /* <4aef3> ../cstrike/dlls/client.cpp:5516 */ void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, Vector player_mins, Vector player_maxs) { - baseline->origin = entity->v.origin; - baseline->angles = entity->v.angles; - - baseline->frame = entity->v.frame; + baseline->origin = entity->v.origin; + baseline->angles = entity->v.angles; + + baseline->frame = entity->v.frame; baseline->skin = (short)entity->v.skin; - // render information - baseline->rendermode = (byte)entity->v.rendermode; - baseline->renderamt = (byte)entity->v.renderamt; - baseline->rendercolor.r = (byte)entity->v.rendercolor.x; - baseline->rendercolor.g = (byte)entity->v.rendercolor.y; - baseline->rendercolor.b = (byte)entity->v.rendercolor.z; + // render information + baseline->rendermode = (byte)entity->v.rendermode; + baseline->renderamt = (byte)entity->v.renderamt; + baseline->rendercolor.r = (byte)entity->v.rendercolor.x; + baseline->rendercolor.g = (byte)entity->v.rendercolor.y; + baseline->rendercolor.b = (byte)entity->v.rendercolor.z; baseline->renderfx = (byte)entity->v.renderfx; - if (player) - { - baseline->mins = player_mins; - baseline->maxs = player_maxs; - - baseline->colormap = eindex; - baseline->modelindex = playermodelindex; - baseline->friction = 1.0; - baseline->movetype = MOVETYPE_WALK; - - baseline->solid = SOLID_SLIDEBOX; - baseline->scale = entity->v.scale; - baseline->framerate = 1.0; - baseline->gravity = 1.0; - } - else - { - baseline->mins = entity->v.mins; - baseline->maxs = entity->v.maxs; - - baseline->colormap = 0; - baseline->modelindex = entity->v.modelindex; - baseline->movetype = entity->v.movetype; - - baseline->scale = entity->v.scale; - baseline->solid = entity->v.solid; - baseline->framerate = entity->v.framerate; - baseline->gravity = entity->v.gravity; + if (player) + { + baseline->mins = player_mins; + baseline->maxs = player_maxs; + + baseline->colormap = eindex; + baseline->modelindex = playermodelindex; + baseline->friction = 1.0; + baseline->movetype = MOVETYPE_WALK; + + baseline->solid = SOLID_SLIDEBOX; + baseline->scale = entity->v.scale; + baseline->framerate = 1.0; + baseline->gravity = 1.0; + } + else + { + baseline->mins = entity->v.mins; + baseline->maxs = entity->v.maxs; + + baseline->colormap = 0; + baseline->modelindex = entity->v.modelindex; + baseline->movetype = entity->v.movetype; + + baseline->scale = entity->v.scale; + baseline->solid = entity->v.solid; + baseline->framerate = entity->v.framerate; + baseline->gravity = entity->v.gravity; } } /* <47d8a> ../cstrike/dlls/client.cpp:5586 */ void Entity_FieldInit(struct delta_s *pFields) { - entity_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN0 ].name); - entity_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN1 ].name); - entity_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN2 ].name); - entity_field_alias[ FIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES0 ].name); - entity_field_alias[ FIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES1 ].name); + entity_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN0 ].name); + entity_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN1 ].name); + entity_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN2 ].name); + entity_field_alias[ FIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES0 ].name); + entity_field_alias[ FIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES1 ].name); entity_field_alias[ FIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES2 ].name); } @@ -4756,112 +4755,112 @@ void Entity_FieldInit(struct delta_s *pFields) /* <47da7> ../cstrike/dlls/client.cpp:5604 */ void Entity_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) { - entity_state_t *f, *t; - int localplayer = 0; + entity_state_t *f, *t; + int localplayer = 0; static int initialized = 0; - if (!initialized) - { - Entity_FieldInit(pFields); - initialized = 1; + if (!initialized) + { + Entity_FieldInit(pFields); + initialized = 1; } - f = (entity_state_t *)from; + f = (entity_state_t *)from; t = (entity_state_t *)to; - // Never send origin to local player, it's sent with more resolution in clientdata_t structure - localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); - - if (localplayer) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - if (t->impacttime != 0 && t->starttime != 0) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES2 ].field); - } - if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - else if (t->aiment != f->aiment) - { - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + // Never send origin to local player, it's sent with more resolution in clientdata_t structure + localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); + + if (localplayer) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + if (t->impacttime != 0 && t->starttime != 0) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES2 ].field); + } + if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + else if (t->aiment != f->aiment) + { + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); } } /* <47cb4> ../cstrike/dlls/client.cpp:5662 */ void Player_FieldInit(struct delta_s *pFields) { - player_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN0 ].name); - player_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN1 ].name); + player_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN0 ].name); + player_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN1 ].name); player_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN2 ].name); } -// Callback for sending entity_state_t for players info over network. +// Callback for sending entity_state_t for players info over network. /* <47cd1> ../cstrike/dlls/client.cpp:5676 */ void Player_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) { - entity_state_t *f, *t; - int localplayer = 0; - - static int initialized = 0; - if (!initialized) - { - Player_FieldInit(pFields); - initialized = 1; - } - - f = (entity_state_t *)from; - t = (entity_state_t *)to; - - // Never send origin to local player, it's sent with more resolution in clientdata_t structure - localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); - - if (localplayer) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - else if (t->aiment != f->aiment) - { - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + entity_state_t *f, *t; + int localplayer = 0; + + static int initialized = 0; + if (!initialized) + { + Player_FieldInit(pFields); + initialized = 1; + } + + f = (entity_state_t *)from; + t = (entity_state_t *)to; + + // Never send origin to local player, it's sent with more resolution in clientdata_t structure + localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); + + if (localplayer) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + else if (t->aiment != f->aiment) + { + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); } } /* <4afc4> ../cstrike/dlls/client.cpp:5738 */ void Custom_Entity_FieldInit(delta_s *pFields) { - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].name); - custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].name); - custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].name); + custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].name); + custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].name); + custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].name); custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].name); } @@ -4870,55 +4869,55 @@ void Custom_Entity_FieldInit(delta_s *pFields) /* <4aff3> ../cstrike/dlls/client.cpp:5759 */ void Custom_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) { - entity_state_t *f, *t; - int beamType; - static int initialized = 0; - - if (!initialized) - { - Custom_Entity_FieldInit(pFields); - initialized = 1; - } - - f = (entity_state_t *)from; - t = (entity_state_t *)to; - - beamType = t->rendermode & 0x0F; - - if (beamType != BEAM_POINTS) - { - if (beamType != BEAM_ENTPOINT) - { - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field); - } - - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field); - } - - if (beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT) - { - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field); - } - - // animtime is compared by rounding first - // see if we really shouldn't actually send it - - if ((int)f->animtime == (int)t->animtime) - { - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field); + entity_state_t *f, *t; + int beamType; + static int initialized = 0; + + if (!initialized) + { + Custom_Entity_FieldInit(pFields); + initialized = 1; + } + + f = (entity_state_t *)from; + t = (entity_state_t *)to; + + beamType = t->rendermode & 0x0F; + + if (beamType != BEAM_POINTS) + { + if (beamType != BEAM_ENTPOINT) + { + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field); + } + + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field); + } + + if (beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT) + { + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field); + } + + // animtime is compared by rounding first + // see if we really shouldn't actually send it + + if ((int)f->animtime == (int)t->animtime) + { + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field); } } /* <4b08a> ../cstrike/dlls/client.cpp:5811 */ void RegisterEncoders(void) { - DELTA_ADDENCODER("Entity_Encode", Entity_Encode); - DELTA_ADDENCODER("Custom_Encode", Custom_Encode); + DELTA_ADDENCODER("Entity_Encode", Entity_Encode); + DELTA_ADDENCODER("Custom_Encode", Custom_Encode); DELTA_ADDENCODER("Player_Encode", Player_Encode); } @@ -4942,7 +4941,7 @@ int GetWeaponData(edict_s *player, struct weapon_data_s *info) while (pPlayerItem != NULL) { CBasePlayerWeapon *gun = reinterpret_cast(pPlayerItem->GetWeaponPtr()); - + if (gun && gun->UseDecrement()) { ItemInfo II; @@ -4955,10 +4954,10 @@ int GetWeaponData(edict_s *player, struct weapon_data_s *info) item->m_iId = II.iId; item->m_iClip = gun->m_iClip; - item->m_flTimeWeaponIdle = _max(gun->m_flTimeWeaponIdle, -0.001); - item->m_flNextPrimaryAttack = _max(gun->m_flNextPrimaryAttack, -0.001); - item->m_flNextSecondaryAttack = _max(gun->m_flNextSecondaryAttack, -0.001); - item->m_flNextReload = _max(gun->m_flNextReload, -0.001); + item->m_flTimeWeaponIdle = Q_max(gun->m_flTimeWeaponIdle, -0.001f); + item->m_flNextPrimaryAttack = Q_max(gun->m_flNextPrimaryAttack, -0.001f); + item->m_flNextSecondaryAttack = Q_max(gun->m_flNextSecondaryAttack, -0.001f); + item->m_flNextReload = Q_max(gun->m_flNextReload, -0.001f); item->m_fInReload = gun->m_fInReload; item->m_fInSpecialReload = gun->m_fInSpecialReload; item->m_fInZoom = gun->m_iShotsFired; @@ -4979,122 +4978,122 @@ int GetWeaponData(edict_s *player, struct weapon_data_s *info) /* <4b1fd> ../cstrike/dlls/client.cpp:5889 */ void UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd) -{ - if (!ent || !ent->pvPrivateData) +{ + if (!ent || !ent->pvPrivateData) { - return; + return; } - - entvars_t *pevOrg = NULL; - entvars_t *pev = (entvars_t *)&ent->v; - CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); - - if (pl->pev->iuser1 == OBS_IN_EYE && pl->m_hObserverTarget) - { - pevOrg = pev; - pev = pl->m_hObserverTarget->pev; - pl = reinterpret_cast(CBasePlayer::Instance(pev)); - } - - cd->flags = pev->flags; - cd->health = pev->health; - cd->viewmodel = MODEL_INDEX( STRING(pev->viewmodel) ); - cd->waterlevel = pev->waterlevel; - cd->watertype = pev->watertype; - cd->weapons = pev->weapons; - cd->origin = pev->origin; - cd->velocity = pev->velocity; - cd->view_ofs = pev->view_ofs; - cd->punchangle = pev->punchangle; - cd->bInDuck = pev->bInDuck; - cd->flTimeStepSound = pev->flTimeStepSound; - cd->flDuckTime = pev->flDuckTime; - cd->flSwimTime = pev->flSwimTime; - cd->waterjumptime = (int)pev->teleport_time; - - Q_strcpy(cd->physinfo, ENGINE_GETPHYSINFO(ent)); - - cd->maxspeed = pev->maxspeed; - cd->fov = pev->fov; - cd->weaponanim = pev->weaponanim; - cd->pushmsec = pev->pushmsec; - - if (pevOrg) - { - cd->iuser1 = pevOrg->iuser1; - cd->iuser2 = pevOrg->iuser2; - cd->iuser3 = pevOrg->iuser3; - } - else - { - cd->iuser1 = pev->iuser1; - cd->iuser2 = pev->iuser2; - cd->iuser3 = pev->iuser3; - } - - cd->fuser1 = pev->fuser1; - cd->fuser3 = pev->fuser3; - cd->fuser2 = pev->fuser2; - - if (sendweapons && pl != NULL) - { - cd->ammo_shells = pl->ammo_buckshot; - cd->ammo_nails = pl->ammo_9mm; - cd->ammo_cells = pl->ammo_556nato; - cd->ammo_rockets = pl->ammo_556natobox; - cd->vuser2.x = pl->ammo_762nato; - cd->vuser2.y = pl->ammo_45acp; - cd->vuser2.z = pl->ammo_50ae; - cd->vuser3.x = pl->ammo_338mag; - cd->vuser3.y = pl->ammo_57mm; - cd->vuser3.z = pl->ammo_357sig; - cd->m_flNextAttack = pl->m_flNextAttack; - - int iUser3 = 0; - if (pl->m_bCanShoot && !pl->m_bIsDefusing) - iUser3 |= DATA_IUSER3_CANSHOOT; - - if (g_pGameRules->IsFreezePeriod()) - iUser3 |= DATA_IUSER3_FREEZETIMEOVER; - else - iUser3 &= ~DATA_IUSER3_FREEZETIMEOVER; - - if (pl->m_signals.GetState() & SIGNAL_BOMB) - iUser3 |= DATA_IUSER3_INBOMBZONE; - else - iUser3 &= ~DATA_IUSER3_INBOMBZONE; - - if (pl->HasShield()) - iUser3 |= DATA_IUSER3_HOLDINGSHIELD; - else - iUser3 &= ~DATA_IUSER3_HOLDINGSHIELD; - - if (!pl->pev->iuser1 && !pevOrg) - cd->iuser3 = iUser3; - - if (pl->m_pActiveItem != NULL) - { - ItemInfo II; - Q_memset(&II, 0, sizeof(II)); - - CBasePlayerWeapon *gun = reinterpret_cast(pl->m_pActiveItem->GetWeaponPtr()); - - if (gun != NULL && gun->UseDecrement() && gun->GetItemInfo(&II)) - { - cd->m_iId = II.iId; - - if ((unsigned int)gun->m_iPrimaryAmmoType < MAX_AMMO_TYPES) - { - cd->vuser4.x = gun->m_iPrimaryAmmoType; - cd->vuser4.y = pl->m_rgAmmo[ gun->m_iPrimaryAmmoType ]; - } - else - { - cd->vuser4.x = -1.0; - cd->vuser4.y = 0; - } - } - } + + entvars_t *pevOrg = NULL; + entvars_t *pev = (entvars_t *)&ent->v; + CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); + + if (pl->pev->iuser1 == OBS_IN_EYE && pl->m_hObserverTarget) + { + pevOrg = pev; + pev = pl->m_hObserverTarget->pev; + pl = reinterpret_cast(CBasePlayer::Instance(pev)); + } + + cd->flags = pev->flags; + cd->health = pev->health; + cd->viewmodel = MODEL_INDEX(STRING(pev->viewmodel)); + cd->waterlevel = pev->waterlevel; + cd->watertype = pev->watertype; + cd->weapons = pev->weapons; + cd->origin = pev->origin; + cd->velocity = pev->velocity; + cd->view_ofs = pev->view_ofs; + cd->punchangle = pev->punchangle; + cd->bInDuck = pev->bInDuck; + cd->flTimeStepSound = pev->flTimeStepSound; + cd->flDuckTime = pev->flDuckTime; + cd->flSwimTime = pev->flSwimTime; + cd->waterjumptime = (int)pev->teleport_time; + + Q_strcpy(cd->physinfo, ENGINE_GETPHYSINFO(ent)); + + cd->maxspeed = pev->maxspeed; + cd->fov = pev->fov; + cd->weaponanim = pev->weaponanim; + cd->pushmsec = pev->pushmsec; + + if (pevOrg) + { + cd->iuser1 = pevOrg->iuser1; + cd->iuser2 = pevOrg->iuser2; + cd->iuser3 = pevOrg->iuser3; + } + else + { + cd->iuser1 = pev->iuser1; + cd->iuser2 = pev->iuser2; + cd->iuser3 = pev->iuser3; + } + + cd->fuser1 = pev->fuser1; + cd->fuser3 = pev->fuser3; + cd->fuser2 = pev->fuser2; + + if (sendweapons && pl != NULL) + { + cd->ammo_shells = pl->ammo_buckshot; + cd->ammo_nails = pl->ammo_9mm; + cd->ammo_cells = pl->ammo_556nato; + cd->ammo_rockets = pl->ammo_556natobox; + cd->vuser2.x = pl->ammo_762nato; + cd->vuser2.y = pl->ammo_45acp; + cd->vuser2.z = pl->ammo_50ae; + cd->vuser3.x = pl->ammo_338mag; + cd->vuser3.y = pl->ammo_57mm; + cd->vuser3.z = pl->ammo_357sig; + cd->m_flNextAttack = pl->m_flNextAttack; + + int iUser3 = 0; + if (pl->m_bCanShoot && !pl->m_bIsDefusing) + iUser3 |= DATA_IUSER3_CANSHOOT; + + if (g_pGameRules->IsFreezePeriod()) + iUser3 |= DATA_IUSER3_FREEZETIMEOVER; + else + iUser3 &= ~DATA_IUSER3_FREEZETIMEOVER; + + if (pl->m_signals.GetState() & SIGNAL_BOMB) + iUser3 |= DATA_IUSER3_INBOMBZONE; + else + iUser3 &= ~DATA_IUSER3_INBOMBZONE; + + if (pl->HasShield()) + iUser3 |= DATA_IUSER3_HOLDINGSHIELD; + else + iUser3 &= ~DATA_IUSER3_HOLDINGSHIELD; + + if (!pl->pev->iuser1 && !pevOrg) + cd->iuser3 = iUser3; + + if (pl->m_pActiveItem != NULL) + { + ItemInfo II; + Q_memset(&II, 0, sizeof(II)); + + CBasePlayerWeapon *gun = reinterpret_cast(pl->m_pActiveItem->GetWeaponPtr()); + + if (gun != NULL && gun->UseDecrement() && gun->GetItemInfo(&II)) + { + cd->m_iId = II.iId; + + if ((unsigned int)gun->m_iPrimaryAmmoType < MAX_AMMO_TYPES) + { + cd->vuser4.x = gun->m_iPrimaryAmmoType; + cd->vuser4.y = pl->m_rgAmmo[ gun->m_iPrimaryAmmoType ]; + } + else + { + cd->vuser4.x = -1.0; + cd->vuser4.y = 0; + } + } + } } } @@ -5136,15 +5135,15 @@ void CmdEnd(const edict_t *player) /* <4b644> ../cstrike/dlls/client.cpp:6101 */ int ConnectionlessPacket(const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size) { - // Parse stuff from args - int max_buffer_size = *response_buffer_size; - - // Zero it out since we aren't going to respond. - // If we wanted to response, we'd write data into response_buffer - *response_buffer_size = 0; - - // Since we don't listen for anything here, just respond that it's a bogus message - // If we didn't reject the message, we'd return 1 for success instead. + // Parse stuff from args + int max_buffer_size = *response_buffer_size; + + // Zero it out since we aren't going to respond. + // If we wanted to response, we'd write data into response_buffer + *response_buffer_size = 0; + + // Since we don't listen for anything here, just respond that it's a bogus message + // If we didn't reject the message, we'd return 1 for success instead. return 0; } @@ -5153,43 +5152,43 @@ int GetHullBounds(int hullnumber, float *mins, float *maxs) { return hullnumber < 3; } - -// Create pseudo-baselines for items that aren't placed in the map at spawn time, but which are likely + +// Create pseudo-baselines for items that aren't placed in the map at spawn time, but which are likely // to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, etc. ) /* <4b733> ../cstrike/dlls/client.cpp:6156 */ void CreateInstancedBaselines(void) { - int iret = 0; - entity_state_t state; - + int iret = 0; + entity_state_t state; + Q_memset(&state, 0, sizeof(state)); - // Create any additional baselines here for things like grendates, etc. - // iret = ENGINE_INSTANCE_BASELINE(pc->pev->classname, &state); - - // Destroy objects. + // Create any additional baselines here for things like grendates, etc. + // iret = ENGINE_INSTANCE_BASELINE(pc->pev->classname, &state); + + // Destroy objects. // UTIL_Remove(pc); } /* <4b77c> ../cstrike/dlls/client.cpp:6179 */ int InconsistentFile(const edict_t *player, const char *filename, char *disconnect_message) { - // Server doesn't care? - if (CVAR_GET_FLOAT("mp_consistency") != 1) - return 0; - - // Default behavior is to kick the player - Q_sprintf(disconnect_message, "Server is enforcing file consistency for %s\n", filename); - - // Kick now with specified disconnect message. + // Server doesn't care? + if (CVAR_GET_FLOAT("mp_consistency") != 1) + return 0; + + // Default behavior is to kick the player + Q_sprintf(disconnect_message, "Server is enforcing file consistency for %s\n", filename); + + // Kick now with specified disconnect message. return 1; } -// The game .dll should return 1 if lag compensation should be allowed ( could also just set -// the sv_unlag cvar. -// Most games right now should return 0, until client-side weapon prediction code is written -// and tested for them ( note you can predict weapons, but not do lag compensation, too, +// The game .dll should return 1 if lag compensation should be allowed ( could also just set +// the sv_unlag cvar. +// Most games right now should return 0, until client-side weapon prediction code is written +// and tested for them ( note you can predict weapons, but not do lag compensation, too, // if you want. /* <4b7cf> ../cstrike/dlls/client.cpp:6204 */ diff --git a/regamedll/dlls/combat.cpp b/regamedll/dlls/combat.cpp index ecb59f52..ef749363 100644 --- a/regamedll/dlls/combat.cpp +++ b/regamedll/dlls/combat.cpp @@ -1,17 +1,17 @@ #include "precompiled.h" -#define GERMAN_GIB_COUNT 4 -#define HUMAN_GIB_COUNT 6 +#define GERMAN_GIB_COUNT 4 +#define HUMAN_GIB_COUNT 6 #define ALIEN_GIB_COUNT 4 /* <5f4cb> ../cstrike/dlls/combat.cpp:52 */ void CGib::LimitVelocity(void) { - float length = pev->velocity.Length(); - - // ceiling at 1500. The gib velocity equation is not bounded properly. Rather than tune it - // in 3 separate places again, I'll just limit it here. - if (length > 1500.0) + float length = pev->velocity.Length(); + + // ceiling at 1500. The gib velocity equation is not bounded properly. Rather than tune it + // in 3 separate places again, I'll just limit it here. + if (length > 1500.0) { // This should really be sv_maxvelocity * 0.75 or something pev->velocity = pev->velocity.Normalize() * 1500; @@ -19,239 +19,455 @@ void CGib::LimitVelocity(void) } /* <60320> ../cstrike/dlls/combat.cpp:63 */ -NOBODY void CGib::SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs) +NOXREF void CGib::SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs) { -// { -// int i; // 65 -// { -// class CGib *pGib; // 75 -// GetClassPtr(CGib *a); // 75 -// operator*(const Vector *const this, -// float fl); // 93 -// operator*(const Vector *const this, -// float fl); // 100 -// Instance(entvars_t *pev); // 106 -// operator*(const Vector *const this, -// float fl); // 110 -// operator*(const Vector *const this, -// float fl); // 118 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 124 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 124 -// LimitVelocity(CGib *const this); // 128 -// operator*(const Vector *const this, -// float fl); // 114 -// } -// } + int i; + + if (g_Language == LANGUAGE_GERMAN) + { + // no sticky gibs in germany right now! + return; + } + + for (i = 0; i < cGibs; i++) + { + CGib *pGib = GetClassPtr((CGib *)NULL); + + pGib->Spawn("models/stickygib.mdl"); + pGib->pev->body = RANDOM_LONG(0, 2); + + if (pevVictim) + { + pGib->pev->origin.x = vecOrigin.x + RANDOM_FLOAT(-3, 3); + pGib->pev->origin.y = vecOrigin.y + RANDOM_FLOAT(-3, 3); + pGib->pev->origin.z = vecOrigin.z + RANDOM_FLOAT(-3, 3); + + // make the gib fly away from the attack vector + pGib->pev->velocity = g_vecAttackDir * -1; + + // mix in some noise + pGib->pev->velocity.x += RANDOM_FLOAT(-0.15, 0.15); + pGib->pev->velocity.y += RANDOM_FLOAT(-0.15, 0.15); + pGib->pev->velocity.z += RANDOM_FLOAT(-0.15, 0.15); + + pGib->pev->velocity = pGib->pev->velocity * 900; + + pGib->pev->avelocity.x = RANDOM_FLOAT(250, 400); + pGib->pev->avelocity.y = RANDOM_FLOAT(250, 400); + + // copy owner's blood color + pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); + + if (pevVictim->health > -50) + { + pGib->pev->velocity = pGib->pev->velocity * 0.7; + } + else if (pevVictim->health > -200) + { + pGib->pev->velocity = pGib->pev->velocity * 2; + } + else + { + pGib->pev->velocity = pGib->pev->velocity * 4; + } + + pGib->pev->movetype = MOVETYPE_TOSS; + pGib->pev->solid = SOLID_BBOX; + UTIL_SetSize(pGib->pev, Vector (0, 0,0), Vector (0, 0, 0)); + pGib->SetTouch(&CGib::StickyGibTouch); + pGib->SetThink(NULL); + } + + pGib->LimitVelocity(); + } } -void (*pCGib__SpawnHeadGib)(void); - /* <5ff7f> ../cstrike/dlls/combat.cpp:132 */ -void __declspec(naked) CGib::SpawnHeadGib(entvars_t *pevVictim) +void CGib::SpawnHeadGib(entvars_t *pevVictim) { - __asm + CGib *pGib = GetClassPtr((CGib *)NULL); + + if (g_Language == LANGUAGE_GERMAN) { - jmp pCGib__SpawnHeadGib + // throw one head + pGib->Spawn("models/germangibs.mdl"); + pGib->pev->body = 0; } + else + { + // throw one head + pGib->Spawn("models/hgibs.mdl"); + pGib->pev->body = 0; + } + + if (pevVictim) + { + pGib->pev->origin = pevVictim->origin + pevVictim->view_ofs; + + edict_t *pentPlayer = FIND_CLIENT_IN_PVS(pGib->edict()); + + if (RANDOM_LONG(0, 100) <= 5 && pentPlayer != NULL) + { + // 5% chance head will be thrown at player's face. + entvars_t *pevPlayer = VARS(pentPlayer); + + pGib->pev->velocity = ((pevPlayer->origin + pevPlayer->view_ofs) - pGib->pev->origin).Normalize() * 300; + pGib->pev->velocity.z += 100; + } + else + { + pGib->pev->velocity.z = RANDOM_FLOAT(200, 300); + pGib->pev->velocity.y = RANDOM_FLOAT(-100, 100); + pGib->pev->velocity.x = RANDOM_FLOAT(-100, 100); + } + + pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); + pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); + + // copy owner's blood color + pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); + + if (pevVictim->health > -50) + { + pGib->pev->velocity = pGib->pev->velocity * 0.7; + } + else if (pevVictim->health > -200) + { + pGib->pev->velocity = pGib->pev->velocity * 2; + } + else + pGib->pev->velocity = pGib->pev->velocity * 4; + } + + pGib->LimitVelocity(); } /* <606c8> ../cstrike/dlls/combat.cpp:190 */ void CGib::SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human) { - int cSplat; - for (cSplat = 0; cSplat < cGibs; cSplat++) - { - CGib *pGib = GetClassPtr((CGib *)NULL); - - if (g_Language == LANGUAGE_GERMAN) - { - pGib->Spawn("models/germangibs.mdl"); - pGib->pev->body = RANDOM_LONG(0, GERMAN_GIB_COUNT - 1); - } - else - { - if (human) - { - // human pieces - pGib->Spawn("models/hgibs.mdl"); - // start at one to avoid throwing random amounts of skulls (0th gib) - pGib->pev->body = RANDOM_LONG(1, HUMAN_GIB_COUNT - 1); - } - else - { - // aliens - pGib->Spawn("models/agibs.mdl"); - pGib->pev->body = RANDOM_LONG(0, ALIEN_GIB_COUNT - 1); - } - } - - if (pevVictim) - { - // spawn the gib somewhere in the monster's bounding volume - pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT(0, 1)); - pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * (RANDOM_FLOAT(0, 1)); - // absmin.z is in the floor because the engine subtracts 1 to enlarge the box - pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * (RANDOM_FLOAT(0, 1)) + 1; - - // make the gib fly away from the attack vector - pGib->pev->velocity = g_vecAttackDir * -1; - - // mix in some noise - pGib->pev->velocity.x += RANDOM_FLOAT(-0.25, 0.25); - pGib->pev->velocity.y += RANDOM_FLOAT(-0.25, 0.25); - pGib->pev->velocity.z += RANDOM_FLOAT(-0.25, 0.25); - - pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT(300, 400); - - pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); - pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); - - // copy owner's blood color - pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); - - if (pevVictim->health > -50) - pGib->pev->velocity = pGib->pev->velocity * 0.7; - - else if (pevVictim->health > -200) - pGib->pev->velocity = pGib->pev->velocity * 2; - else - pGib->pev->velocity = pGib->pev->velocity * 4; - - pGib->pev->solid = SOLID_BBOX; - UTIL_SetSize(pGib->pev, Vector(0, 0, 0), Vector(0, 0, 0)); - } - pGib->LimitVelocity(); + int cSplat; + for (cSplat = 0; cSplat < cGibs; cSplat++) + { + CGib *pGib = GetClassPtr((CGib *)NULL); + + if (g_Language == LANGUAGE_GERMAN) + { + pGib->Spawn("models/germangibs.mdl"); + pGib->pev->body = RANDOM_LONG(0, GERMAN_GIB_COUNT - 1); + } + else + { + if (human) + { + // human pieces + pGib->Spawn("models/hgibs.mdl"); + // start at one to avoid throwing random amounts of skulls (0th gib) + pGib->pev->body = RANDOM_LONG(1, HUMAN_GIB_COUNT - 1); + } + else + { + // aliens + pGib->Spawn("models/agibs.mdl"); + pGib->pev->body = RANDOM_LONG(0, ALIEN_GIB_COUNT - 1); + } + } + + if (pevVictim) + { + // spawn the gib somewhere in the monster's bounding volume + pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT(0, 1)); + pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * (RANDOM_FLOAT(0, 1)); + // absmin.z is in the floor because the engine subtracts 1 to enlarge the box + pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * (RANDOM_FLOAT(0, 1)) + 1; + + // make the gib fly away from the attack vector + pGib->pev->velocity = g_vecAttackDir * -1; + + // mix in some noise + pGib->pev->velocity.x += RANDOM_FLOAT(-0.25, 0.25); + pGib->pev->velocity.y += RANDOM_FLOAT(-0.25, 0.25); + pGib->pev->velocity.z += RANDOM_FLOAT(-0.25, 0.25); + + pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT(300, 400); + + pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); + pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); + + // copy owner's blood color + pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); + + if (pevVictim->health > -50) + pGib->pev->velocity = pGib->pev->velocity * 0.7; + + else if (pevVictim->health > -200) + pGib->pev->velocity = pGib->pev->velocity * 2; + else + pGib->pev->velocity = pGib->pev->velocity * 4; + + pGib->pev->solid = SOLID_BBOX; + UTIL_SetSize(pGib->pev, Vector(0, 0, 0), Vector(0, 0, 0)); + } + pGib->LimitVelocity(); } } /* <5f58a> ../cstrike/dlls/combat.cpp:263 */ BOOL CBaseMonster::__MAKE_VHOOK(HasHumanGibs)(void) { - int myClass = Classify(); - - if (myClass == CLASS_HUMAN_MILITARY - || myClass == CLASS_PLAYER_ALLY - || myClass == CLASS_HUMAN_PASSIVE - || myClass == CLASS_PLAYER) - return TRUE; - + int myClass = Classify(); + + if (myClass == CLASS_HUMAN_MILITARY + || myClass == CLASS_PLAYER_ALLY + || myClass == CLASS_HUMAN_PASSIVE + || myClass == CLASS_PLAYER) + return TRUE; + return FALSE; } /* <5f5ca> ../cstrike/dlls/combat.cpp:278 */ BOOL CBaseMonster::__MAKE_VHOOK(HasAlienGibs)(void) { - int myClass = Classify(); - if (myClass == CLASS_ALIEN_MILITARY - || myClass == CLASS_ALIEN_MONSTER - || myClass == CLASS_ALIEN_PASSIVE - || myClass == CLASS_INSECT - || myClass == CLASS_ALIEN_PREDATOR - || myClass == CLASS_ALIEN_PREY) - return TRUE; - + int myClass = Classify(); + if (myClass == CLASS_ALIEN_MILITARY + || myClass == CLASS_ALIEN_MONSTER + || myClass == CLASS_ALIEN_PASSIVE + || myClass == CLASS_INSECT + || myClass == CLASS_ALIEN_PREDATOR + || myClass == CLASS_ALIEN_PREY) + return TRUE; + return FALSE; } /* <5f60a> ../cstrike/dlls/combat.cpp:295 */ void CBaseMonster::__MAKE_VHOOK(FadeMonster)(void) { - StopAnimation(); - - pev->velocity = g_vecZero; - pev->movetype = MOVETYPE_NONE; - pev->avelocity = g_vecZero; - pev->animtime = gpGlobals->time; - pev->effects |= EF_NOINTERP; - + StopAnimation(); + + pev->velocity = g_vecZero; + pev->movetype = MOVETYPE_NONE; + pev->avelocity = g_vecZero; + pev->animtime = gpGlobals->time; + pev->effects |= EF_NOINTERP; + SUB_StartFadeOut(); } /* <60a59> ../cstrike/dlls/combat.cpp:310 */ void CBaseMonster::__MAKE_VHOOK(GibMonster)(void) { - TraceResult tr; - BOOL gibbed = FALSE; - - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); - - // only humans throw skulls !!!UNDONE - eventually monsters will have their own sets of gibs - if (HasHumanGibs()) - { - // Only the player will ever get here - if (CVAR_GET_FLOAT("violence_hgibs") != 0) - { - CGib::SpawnHeadGib(pev); - - // throw some human gibs. - CGib::SpawnRandomGibs(pev, 4, 1); - } - gibbed = TRUE; - } - else if (HasAlienGibs()) - { - // Should never get here, but someone might call it directly - if (CVAR_GET_FLOAT("violence_agibs") != 0) - { - // Throw alien gibs - CGib::SpawnRandomGibs(pev, 4, 0); - } - gibbed = TRUE; - } - - if (!IsPlayer()) - { - if (gibbed) - { - // don't remove players! - SetThink(&CBaseMonster::SUB_Remove); - pev->nextthink = gpGlobals->time; - } - else - FadeMonster(); + TraceResult tr; + BOOL gibbed = FALSE; + + EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); + + // only humans throw skulls !!!UNDONE - eventually monsters will have their own sets of gibs + if (HasHumanGibs()) + { + // Only the player will ever get here + if (CVAR_GET_FLOAT("violence_hgibs") != 0) + { + CGib::SpawnHeadGib(pev); + + // throw some human gibs. + CGib::SpawnRandomGibs(pev, 4, 1); + } + gibbed = TRUE; + } + else if (HasAlienGibs()) + { + // Should never get here, but someone might call it directly + if (CVAR_GET_FLOAT("violence_agibs") != 0) + { + // Throw alien gibs + CGib::SpawnRandomGibs(pev, 4, 0); + } + gibbed = TRUE; + } + + if (!IsPlayer()) + { + if (gibbed) + { + // don't remove players! + SetThink(&CBaseMonster::SUB_Remove); + pev->nextthink = gpGlobals->time; + } + else + FadeMonster(); } } +// GetDeathActivity - determines the best type of death +// anim to play. + /* <5f65e> ../cstrike/dlls/combat.cpp:355 */ -NOBODY Activity CBaseMonster::__MAKE_VHOOK(GetDeathActivity)(void) +NOXREF Activity CBaseMonster::__MAKE_VHOOK(GetDeathActivity)(void) { -// { -// Activity deathActivity; // 357 -// BOOL fTriedDirection; // 358 -// float flDot; // 359 -// TraceResult tr; // 360 -// class Vector vecSrc; // 361 -// operator*(const Vector *const this, -// float fl); // 375 -// DotProduct(const Vector &a, -// const Vector &b); // 375 -// edict(CBaseEntity *const this); // 461 -// operator*(const Vector *const this, -// float fl); // 461 -// operator-(const Vector *const this, -// const Vector &v); // 461 -// edict(CBaseEntity *const this); // 450 -// operator*(const Vector *const this, -// float fl); // 450 -// operator+(const Vector *const this, -// const Vector &v); // 450 -// } + Activity deathActivity; + BOOL fTriedDirection; + float flDot; + TraceResult tr; + Vector vecSrc; + + if (pev->deadflag != DEAD_NO) + { + // don't run this while dying. + return m_IdealActivity; + } + + vecSrc = Center(); + + fTriedDirection = FALSE; + + // in case we can't find any special deaths to do. + deathActivity = ACT_DIESIMPLE; + + UTIL_MakeVectors(pev->angles); + flDot = DotProduct(gpGlobals->v_forward, g_vecAttackDir * -1); + + switch (m_LastHitGroup) + { + case HITGROUP_HEAD: + // try to pick a region-specific death. + deathActivity = ACT_DIE_HEADSHOT; + break; + case HITGROUP_STOMACH: + deathActivity = ACT_DIE_GUTSHOT; + break; + case HITGROUP_GENERIC: + // try to pick a death based on attack direction + fTriedDirection = TRUE; + + if (flDot > 0.3) + { + deathActivity = ACT_DIEFORWARD; + } + else if (flDot <= -0.3) + { + deathActivity = ACT_DIEBACKWARD; + } + break; + + default: + // try to pick a death based on attack direction + fTriedDirection = TRUE; + + if (flDot > 0.3) + { + deathActivity = ACT_DIEFORWARD; + } + else if (flDot <= -0.3) + { + deathActivity = ACT_DIEBACKWARD; + } + break; + } + + // can we perform the prescribed death? + if (LookupActivity(deathActivity) == ACTIVITY_NOT_AVAILABLE) + { + // no! did we fail to perform a directional death? + if (fTriedDirection) + { + // if yes, we're out of options. Go simple. + deathActivity = ACT_DIESIMPLE; + } + else + { + // cannot perform the ideal region-specific death, so try a direction. + if (flDot > 0.3) + { + deathActivity = ACT_DIEFORWARD; + } + else if (flDot <= -0.3) + { + deathActivity = ACT_DIEBACKWARD; + } + } + } + + if (LookupActivity(deathActivity) == ACTIVITY_NOT_AVAILABLE) + { + // if we're still invalid, simple is our only option. + deathActivity = ACT_DIESIMPLE; + } + + if (deathActivity == ACT_DIEFORWARD) + { + // make sure there's room to fall forward + UTIL_TraceHull(vecSrc, vecSrc + gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr); + + if (tr.flFraction != 1.0f) + { + deathActivity = ACT_DIESIMPLE; + } + } + + if (deathActivity == ACT_DIEBACKWARD) + { + // make sure there's room to fall backward + UTIL_TraceHull(vecSrc, vecSrc - gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr); + + if (tr.flFraction != 1.0f) + { + deathActivity = ACT_DIESIMPLE; + } + } + + return deathActivity; } +// GetSmallFlinchActivity - determines the best type of flinch +// anim to play. + /* <5f848> ../cstrike/dlls/combat.cpp:476 */ -NOBODY Activity CBaseMonster::GetSmallFlinchActivity(void) +NOXREF Activity CBaseMonster::GetSmallFlinchActivity(void) { -// { -// Activity flinchActivity; // 478 -// BOOL fTriedDirection; // 479 -// float flDot; // 480 -// } + Activity flinchActivity; + BOOL fTriedDirection; + float flDot; + + fTriedDirection = FALSE; + UTIL_MakeVectors(pev->angles); + flDot = DotProduct(gpGlobals->v_forward, g_vecAttackDir * -1); // TODO: noxref + + switch (m_LastHitGroup) + { + case HITGROUP_HEAD: + // pick a region-specific flinch + flinchActivity = ACT_FLINCH_HEAD; + break; + case HITGROUP_STOMACH: + flinchActivity = ACT_FLINCH_STOMACH; + break; + case HITGROUP_LEFTARM: + flinchActivity = ACT_FLINCH_LEFTARM; + break; + case HITGROUP_RIGHTARM: + flinchActivity = ACT_FLINCH_RIGHTARM; + break; + case HITGROUP_LEFTLEG: + flinchActivity = ACT_FLINCH_LEFTLEG; + break; + case HITGROUP_RIGHTLEG: + flinchActivity = ACT_FLINCH_RIGHTLEG; + break; + case HITGROUP_GENERIC: + default: + // just get a generic flinch. + flinchActivity = ACT_SMALL_FLINCH; + break; + } + + // do we have a sequence for the ideal activity? + if (LookupActivity(flinchActivity) == ACTIVITY_NOT_AVAILABLE) + { + flinchActivity = ACT_SMALL_FLINCH; + } + + return flinchActivity; } /* <5f8a6> ../cstrike/dlls/combat.cpp:525 */ @@ -260,7 +476,7 @@ void CBaseMonster::__MAKE_VHOOK(BecomeDead)(void) // don't let autoaim aim at corpses. pev->takedamage = DAMAGE_YES; - // give the corpse half of the monster's original maximum health. + // give the corpse half of the monster's original maximum health. pev->health = pev->max_health / 2; // max_health now becomes a counter for how many blood decals the corpse can place. @@ -273,102 +489,104 @@ void CBaseMonster::__MAKE_VHOOK(BecomeDead)(void) /* <5f8cc> ../cstrike/dlls/combat.cpp:542 */ BOOL CBaseMonster::ShouldGibMonster(int iGib) { - if ((iGib == GIB_NORMAL && pev->health < GIB_HEALTH_VALUE) || (iGib == GIB_ALWAYS)) - return TRUE; - + if ((iGib == GIB_NORMAL && pev->health < GIB_HEALTH_VALUE) || (iGib == GIB_ALWAYS)) + { + return TRUE; + } + return FALSE; } /* <5f8f8> ../cstrike/dlls/combat.cpp:551 */ void CBaseMonster::CallGibMonster(void) { - BOOL fade = FALSE; - - if (HasHumanGibs()) - { - if (CVAR_GET_FLOAT("violence_hgibs") == 0) - fade = TRUE; - } - else if (HasAlienGibs()) - { - if (CVAR_GET_FLOAT("violence_agibs") == 0) - fade = TRUE; - } - - // do something with the body. while monster blows up - pev->solid = SOLID_NOT; - pev->takedamage = DAMAGE_NO; - - if (fade) - { - FadeMonster(); - } - else - { - // make the model invisible. - pev->effects = EF_NODRAW; - GibMonster(); - } - - pev->deadflag = DEAD_DEAD; - FCheckAITrigger(); - - // don't let the status bar glitch for players.with <0 health. - if (pev->health < -99.0f) - { - pev->health = 0; - } - - if (ShouldFadeOnDeath() && !fade) + BOOL fade = FALSE; + + if (HasHumanGibs()) + { + if (CVAR_GET_FLOAT("violence_hgibs") == 0) + fade = TRUE; + } + else if (HasAlienGibs()) + { + if (CVAR_GET_FLOAT("violence_agibs") == 0) + fade = TRUE; + } + + // do something with the body. while monster blows up + pev->solid = SOLID_NOT; + pev->takedamage = DAMAGE_NO; + + if (fade) + { + FadeMonster(); + } + else + { + // make the model invisible. + pev->effects = EF_NODRAW; + GibMonster(); + } + + pev->deadflag = DEAD_DEAD; + FCheckAITrigger(); + + // don't let the status bar glitch for players.with <0 health. + if (pev->health < -99.0f) + { + pev->health = 0; + } + + if (ShouldFadeOnDeath() && !fade) UTIL_Remove(this); } /* <5f938> ../cstrike/dlls/combat.cpp:598 */ void CBaseMonster::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) { - // unsigned int cCount = 0; - // BOOL fDone = FALSE; - - if (HasMemory(bits_MEMORY_KILLED)) - { - if (ShouldGibMonster(iGib)) - CallGibMonster(); - return; - } - - Remember(bits_MEMORY_KILLED); - - // clear the deceased's sound channels.(may have been firing or reloading when killed) - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/null.wav", VOL_NORM, ATTN_NORM); - m_IdealMonsterState = MONSTERSTATE_DEAD; - // Make sure this condition is fired too (TakeDamage breaks out before this happens on death) - SetConditions(bits_COND_LIGHT_DAMAGE); - - // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. - CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); - if (pOwner) - { - pOwner->DeathNotice(pev); - } - - if (ShouldGibMonster(iGib)) - { - CallGibMonster(); - return; - } - else if (pev->flags & FL_MONSTER) - { - SetTouch(NULL); - BecomeDead(); - } - - // don't let the status bar glitch for players.with <0 health. - if (pev->health < -99) - { - pev->health = 0; - } - - //pev->enemy = ENT( pevAttacker );//why? (sjb) + // unsigned int cCount = 0; + // BOOL fDone = FALSE; + + if (HasMemory(bits_MEMORY_KILLED)) + { + if (ShouldGibMonster(iGib)) + CallGibMonster(); + return; + } + + Remember(bits_MEMORY_KILLED); + + // clear the deceased's sound channels.(may have been firing or reloading when killed) + EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/null.wav", VOL_NORM, ATTN_NORM); + m_IdealMonsterState = MONSTERSTATE_DEAD; + // Make sure this condition is fired too (TakeDamage breaks out before this happens on death) + SetConditions(bits_COND_LIGHT_DAMAGE); + + // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. + CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); + if (pOwner) + { + pOwner->DeathNotice(pev); + } + + if (ShouldGibMonster(iGib)) + { + CallGibMonster(); + return; + } + else if (pev->flags & FL_MONSTER) + { + SetTouch(NULL); + BecomeDead(); + } + + // don't let the status bar glitch for players.with <0 health. + if (pev->health < -99) + { + pev->health = 0; + } + + //pev->enemy = ENT(pevAttacker);//why? (sjb) m_IdealMonsterState = MONSTERSTATE_DEAD; } @@ -450,7 +668,7 @@ void CGib::BounceGibTouch(CBaseEntity *pOther) if (m_material != matNone && !RANDOM_LONG(0, 2)) { float zvel = fabs(pev->velocity.z); - float volume = 0.8 * _min(1, zvel / 450); + float volume = 0.8 * Q_min(1.0f, zvel / 450); CBreakable::MaterialSoundRandom(edict(), (Materials)m_material, volume); } @@ -462,7 +680,7 @@ void CGib::BounceGibTouch(CBaseEntity *pOther) /* <5ed6d> ../cstrike/dlls/combat.cpp:761 */ void CGib::StickyGibTouch(CBaseEntity *pOther) { - Vector vecSpot; + Vector vecSpot; TraceResult tr; SetThink(&CBaseEntity::SUB_Remove); @@ -489,38 +707,38 @@ void CGib::StickyGibTouch(CBaseEntity *pOther) /* <5fb0b> ../cstrike/dlls/combat.cpp:789 */ void CGib::Spawn(const char *szGibModel) { - pev->movetype = MOVETYPE_BOUNCE; - - // deading the bounce a bit - pev->friction = 0.55; - - // sometimes an entity inherits the edict from a former piece of glass, - // and will spawn using the same render FX or rendermode! bad! - pev->renderamt = 255.0; - pev->rendermode = kRenderNormal; - pev->renderfx = kRenderFxNone; - - /// hopefully this will fix the VELOCITY TOO LOW crap - pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_BOUNCE; + + // deading the bounce a bit + pev->friction = 0.55; + + // sometimes an entity inherits the edict from a former piece of glass, + // and will spawn using the same render FX or rendermode! bad! + pev->renderamt = 255.0; + pev->rendermode = kRenderNormal; + pev->renderfx = kRenderFxNone; + + /// hopefully this will fix the VELOCITY TOO LOW crap + pev->solid = SOLID_SLIDEBOX; if (pev->classname) - RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); - - MAKE_STRING_CLASS("gib", pev); - AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); - - SET_MODEL(ENT(pev), szGibModel); - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); - - pev->nextthink = gpGlobals->time + 4.0f; - m_lifeTime = 25.0f; - - SetThink(&CGib::WaitTillLand); - SetTouch(&CGib::BounceGibTouch); - - m_material = matNone; - - // how many blood decals this gib can place (1 per bounce until none remain). + RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + + MAKE_STRING_CLASS("gib", pev); + AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + + SET_MODEL(ENT(pev), szGibModel); + UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + + pev->nextthink = gpGlobals->time + 4.0f; + m_lifeTime = 25.0f; + + SetThink(&CGib::WaitTillLand); + SetTouch(&CGib::BounceGibTouch); + + m_material = matNone; + + // how many blood decals this gib can place (1 per bounce until none remain). m_cBloodDecals = 5; } @@ -530,19 +748,19 @@ int CBaseMonster::__MAKE_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) if (pev->takedamage == DAMAGE_NO) return 0; - // clear out any damage types we healed. - // UNDONE: generic health should not heal any + // clear out any damage types we healed. + // UNDONE: generic health should not heal any // UNDONE: time-based damage m_bitsDamageType &= ~(bitsDamageType & ~DMG_TIMEBASED); return CBaseEntity::TakeHealth(flHealth, bitsDamageType); } -// The damage is coming from inflictor, but get mad at attacker -// This should be the only function that ever reduces health. -// bitsDamageType indicates the type of damage sustained, ie: DMG_SHOCK -// -// Time-based damage: only occurs while the monster is within the trigger_hurt. +// The damage is coming from inflictor, but get mad at attacker +// This should be the only function that ever reduces health. +// bitsDamageType indicates the type of damage sustained, ie: DMG_SHOCK +// +// Time-based damage: only occurs while the monster is within the trigger_hurt. // When a monster is poisoned via an arrow etc it takes all the poison damage at once. /* <60d7a> ../cstrike/dlls/combat.cpp:845 */ @@ -580,18 +798,27 @@ int CBaseMonster::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *p if (pInflictor) { +#if 0 vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); +#else + // TODO: fix test demo + vecDir = NormalizeSubtract< + float_precision, float, float_precision, float_precision + >(Center(), pInflictor->Center() - Vector(0, 0, 10)); +#endif vecDir = g_vecAttackDir = vecDir.Normalize(); } } - // add to the damage total for clients, which will be sent as a single - // message at the end of the frame + // add to the damage total for clients, which will be sent as a single + // message at the end of the frame // TODO: remove after combining shotgun blasts? if (IsPlayer()) { if (pevInflictor) + { pev->dmg_inflictor = ENT(pevInflictor); + } pev->dmg_take += flTake; } @@ -629,15 +856,34 @@ int CBaseMonster::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *p m_vecEnemyLKP = pevInflictor->origin; } else - m_vecEnemyLKP = pev->origin + (g_vecAttackDir * 64); + { + //m_vecEnemyLKP = pev->origin + (g_vecAttackDir * 64); + + Vector v38; + float v37 = g_vecAttackDir[2] * 64.0; + v38[0] = g_vecAttackDir[0] * 64.0 + pev->origin[0]; + v38[1] = g_vecAttackDir[1] * 64.0 + pev->origin[1]; + double dbl_v29 = v37 + pev->origin[2]; + float v30 = v38[1]; + + m_vecEnemyLKP[0] = v38[0]; + v38[2] = dbl_v29; + float v32 = v38[2]; + m_vecEnemyLKP[1] = v30; + m_vecEnemyLKP[2] = v32; + } MakeIdealYaw(m_vecEnemyLKP); if (flDamage > 20.0f) + { SetConditions(bits_COND_LIGHT_DAMAGE); + } if (flDamage >= 20.0f) + { SetConditions(bits_COND_HEAVY_DAMAGE); + } } } @@ -649,181 +895,183 @@ int CBaseMonster::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *p /* <60b32> ../cstrike/dlls/combat.cpp:981 */ int CBaseMonster::DeadTakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { - // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). - Vector vecDir = Vector(0, 0, 0); - - if (!FNullEnt(pevInflictor)) - { - CBaseEntity *pInflictor = CBaseEntity::Instance(pevInflictor); - if (pInflictor) - { - vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); - vecDir = g_vecAttackDir = vecDir.Normalize(); - } - } - -// turn this back on when the bounding box issues are resolved. -#if 0 - - pev->flags &= ~FL_ONGROUND; - pev->origin.z += 1; - - // let the damage scoot the corpse around a bit. - if (!FNullEnt(pevInflictor) && (pevAttacker->solid != SOLID_TRIGGER)) - { - pev->velocity = pev->velocity + vecDir * -DamageForce(flDamage); - } - -#endif - - // kill the corpse if enough damage was done to destroy the corpse and the damage is of a type that is allowed to destroy the corpse. - if (bitsDamageType & DMG_GIB_CORPSE) - { - if (pev->health <= flDamage) - { - pev->health = -50; - Killed(pevAttacker, GIB_ALWAYS); - return 0; - } - - // Accumulate corpse gibbing damage, so you can gib with multiple hits - pev->health -= flDamage * 0.1; - } - + // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). + Vector vecDir = Vector(0, 0, 0); + + if (!FNullEnt(pevInflictor)) + { + CBaseEntity *pInflictor = CBaseEntity::Instance(pevInflictor); + if (pInflictor) + { + vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); + vecDir = g_vecAttackDir = vecDir.Normalize(); + } + } + +// turn this back on when the bounding box issues are resolved. +#if 0 + + pev->flags &= ~FL_ONGROUND; + pev->origin.z += 1; + + // let the damage scoot the corpse around a bit. + if (!FNullEnt(pevInflictor) && (pevAttacker->solid != SOLID_TRIGGER)) + { + pev->velocity = pev->velocity + vecDir * -DamageForce(flDamage); + } + +#endif + + // kill the corpse if enough damage was done to destroy the corpse and the damage is of a type that is allowed to destroy the corpse. + if (bitsDamageType & DMG_GIB_CORPSE) + { + if (pev->health <= flDamage) + { + pev->health = -50; + Killed(pevAttacker, GIB_ALWAYS); + return 0; + } + + // Accumulate corpse gibbing damage, so you can gib with multiple hits + pev->health -= flDamage * 0.1; + } + return 1; } /* <61120> ../cstrike/dlls/combat.cpp:1027 */ float CBaseMonster::DamageForce(float damage) { - float_precision force = damage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; - - if (force > 1000.0) - { - force = 1000.0; - } + float_precision force = damage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; + + if (force > 1000.0) + { + force = 1000.0; + } return force; } /* <61174> ../cstrike/dlls/combat.cpp:1044 */ -void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) -{ - CBaseEntity *pEntity = NULL; - TraceResult tr; - float flAdjustedDamage, falloff; - Vector vecSpot; - float flRadius = 1500; - - if (flRadius) - falloff = flDamage / flRadius; - else - falloff = 1; - - int bInWater = (UTIL_PointContents(vecSrc) == CONTENTS_WATER); - - vecSrc.z += 1; - - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, 1500.0)) != NULL) - { - TraceResult tr2; - Vector vecLOS; - float flDot; - float fadeTime; - float fadeHold; - int alpha; - CBasePlayer *pPlayer; - float currentHoldTime; - - if (!pEntity->IsPlayer()) - continue; - - pPlayer = (CBasePlayer *)pEntity; - - if (pPlayer->pev->takedamage == DAMAGE_NO || pPlayer->pev->deadflag != DEAD_NO) - continue; - - if (bInWater && pPlayer->pev->waterlevel == 0) - continue; - - if (!bInWater && pPlayer->pev->waterlevel == 3) - continue; - - vecSpot = pPlayer->BodyTarget(vecSrc); - UTIL_TraceLine(vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), &tr); - - if (tr.flFraction != 1.0f && tr.pHit != pPlayer->pev->pContainingEntity) - continue; - - UTIL_TraceLine(vecSpot, vecSrc, dont_ignore_monsters, tr.pHit, &tr2); - - if (tr2.flFraction >= 1.0) - { - if (tr.fStartSolid) - { - tr.vecEndPos = vecSrc; - tr.flFraction = 0; - } - - flAdjustedDamage = flDamage - (vecSrc - tr.vecEndPos).Length() * falloff; - - if (flAdjustedDamage < 0) - flAdjustedDamage = 0; - - UTIL_MakeVectors(pPlayer->pev->v_angle); - vecLOS = vecSrc - pPlayer->EarPosition(); - flDot = DotProduct(vecLOS, gpGlobals->v_forward); - - if (flDot < 0) - { - alpha = 200; - fadeTime = flAdjustedDamage * 1.75; - fadeHold = flAdjustedDamage / 3.5; - } - else - { - alpha = 255; - fadeTime = flAdjustedDamage * 3; - fadeHold = flAdjustedDamage / 1.5; - } - - currentHoldTime = pPlayer->m_blindStartTime + pPlayer->m_blindHoldTime - gpGlobals->time; - - if (currentHoldTime > 0.0 && alpha == 255) - fadeHold += currentHoldTime; - - if (pPlayer->m_blindStartTime != 0.0f && pPlayer->m_blindFadeTime != 0.0f) - { - if ((pPlayer->m_blindStartTime + pPlayer->m_blindFadeTime + pPlayer->m_blindHoldTime) > gpGlobals->time) - { - if (pPlayer->m_blindFadeTime > fadeTime) - fadeTime = pPlayer->m_blindFadeTime; - - if (pPlayer->m_blindAlpha >= alpha) - alpha = pPlayer->m_blindAlpha; - } - } - - UTIL_ScreenFade(pPlayer, Vector(255, 255, 255), fadeTime, fadeHold, alpha, 0); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pObserver || !pObserver->IsObservingPlayer(pPlayer)) - continue; - - if (!fadetoblack.value) - UTIL_ScreenFade(pPlayer, Vector(255, 255, 255), fadeTime, fadeHold, alpha, 0); - } - - pPlayer->Blind(fadeTime * 0.33, fadeHold, fadeTime, alpha); - - if (TheBots) - { - TheBots->OnEvent(EVENT_PLAYER_BLINDED_BY_FLASHBANG, pPlayer); - } - } - } +void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) +{ + CBaseEntity *pEntity = NULL; + TraceResult tr; + float flAdjustedDamage, falloff; + Vector vecSpot; + float flRadius = 1500; + + if (flRadius) + falloff = flDamage / flRadius; + else + falloff = 1; + + int bInWater = (UTIL_PointContents(vecSrc) == CONTENTS_WATER); + + vecSrc.z += 1; + + while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, 1500.0)) != NULL) + { + TraceResult tr2; + Vector vecLOS; + float flDot; + float fadeTime; + float fadeHold; + int alpha; + CBasePlayer *pPlayer; + float currentHoldTime; + + if (!pEntity->IsPlayer()) + continue; + + pPlayer = (CBasePlayer *)pEntity; + + if (pPlayer->pev->takedamage == DAMAGE_NO || pPlayer->pev->deadflag != DEAD_NO) + continue; + + if (bInWater && pPlayer->pev->waterlevel == 0) + continue; + + if (!bInWater && pPlayer->pev->waterlevel == 3) + continue; + + vecSpot = pPlayer->BodyTarget(vecSrc); + UTIL_TraceLine(vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), &tr); + + if (tr.flFraction != 1.0f && tr.pHit != pPlayer->pev->pContainingEntity) + continue; + + UTIL_TraceLine(vecSpot, vecSrc, dont_ignore_monsters, tr.pHit, &tr2); + + if (tr2.flFraction >= 1.0) + { + if (tr.fStartSolid) + { + tr.vecEndPos = vecSrc; + tr.flFraction = 0; + } + + flAdjustedDamage = flDamage - (vecSrc - tr.vecEndPos).Length() * falloff; + + if (flAdjustedDamage < 0) + flAdjustedDamage = 0; + + UTIL_MakeVectors(pPlayer->pev->v_angle); + vecLOS = vecSrc - pPlayer->EarPosition(); + flDot = DotProduct(vecLOS, gpGlobals->v_forward); + + if (flDot < 0) + { + alpha = 200; + fadeTime = flAdjustedDamage * 1.75; + fadeHold = flAdjustedDamage / 3.5; + } + else + { + alpha = 255; + fadeTime = flAdjustedDamage * 3; + fadeHold = flAdjustedDamage / 1.5; + } + + currentHoldTime = pPlayer->m_blindStartTime + pPlayer->m_blindHoldTime - gpGlobals->time; + + if (currentHoldTime > 0.0 && alpha == 255) + fadeHold += currentHoldTime; + + if (pPlayer->m_blindStartTime != 0.0f && pPlayer->m_blindFadeTime != 0.0f) + { + if ((pPlayer->m_blindStartTime + pPlayer->m_blindFadeTime + pPlayer->m_blindHoldTime) > gpGlobals->time) + { + if (pPlayer->m_blindFadeTime > fadeTime) + fadeTime = pPlayer->m_blindFadeTime; + + if (pPlayer->m_blindAlpha >= alpha) + alpha = pPlayer->m_blindAlpha; + } + } + + UTIL_ScreenFade(pPlayer, Vector(255, 255, 255), fadeTime, fadeHold, alpha, 0); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pObserver || !pObserver->IsObservingPlayer(pPlayer)) + continue; + + if (!fadetoblack.value) + { + UTIL_ScreenFade(pObserver, Vector(255, 255, 255), fadeTime, fadeHold, alpha, 0); + } + } + + pPlayer->Blind(fadeTime * 0.33, fadeHold, fadeTime, alpha); + + if (TheBots) + { + TheBots->OnEvent(EVENT_PLAYER_BLINDED_BY_FLASHBANG, pPlayer); + } + } + } } /* <5f042> ../cstrike/dlls/combat.cpp:1185 */ @@ -1048,78 +1296,157 @@ NOXREF void CBaseMonster::RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, e RadiusDamage2(vecSrc, pevInflictor, pevAttacker, flDamage, iClassIgnore, bitsDamageType); } +// CheckTraceHullAttack - expects a length to trace, amount +// of damage to do, and damage type. Returns a pointer to +// the damaged entity in case the monster wishes to do +// other stuff to the victim (punchangle, etc) +// +// Used for many contact-range melee attacks. Bites, claws, etc. + /* <61949> ../cstrike/dlls/combat.cpp:1454 */ -NOBODY CBaseEntity *CBaseMonster::CheckTraceHullAttack(float flDist, int iDamage, int iDmgType) +NOXREF CBaseEntity *CBaseMonster::CheckTraceHullAttack(float flDist, int iDamage, int iDmgType) { -// { -// TraceResult tr; // 1456 -// class Vector vecStart; // 1463 -// class Vector vecEnd; // 1465 -// Vector(Vector *const this, -// const Vector &v); // 1463 -// operator*(const Vector *const this, -// float fl); // 1465 -// operator+(const Vector *const this, -// const Vector &v); // 1465 -// { -// class CBaseEntity *pEntity; // 1471 -// Instance(edict_t *pent); // 1471 -// } -// } + TraceResult tr; + + if (IsPlayer()) + UTIL_MakeVectors(pev->angles); + else + UTIL_MakeAimVectors(pev->angles); + + Vector vecStart = pev->origin; + vecStart.z += pev->size.z * 0.5; + Vector vecEnd = vecStart + (gpGlobals->v_forward * flDist); + + UTIL_TraceHull(vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr); + + if (tr.pHit) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + + if (iDamage > 0) + { + pEntity->TakeDamage(pev, pev, iDamage, iDmgType); + } + + return pEntity; + } + return NULL; } +// FInViewCone - returns true is the passed ent is in +// the caller's forward view cone. The dot product is performed +// in 2d, making the view cone infinitely tall. + /* <61ae6> ../cstrike/dlls/combat.cpp:1490 */ -NOBODY BOOL CBaseMonster::__MAKE_VHOOK(FInViewCone)(CBaseEntity *pEntity) +BOOL CBaseMonster::__MAKE_VHOOK(FInViewCone)(CBaseEntity *pEntity) { -// { -// class Vector2D vec2LOS; // 1492 -// float flDot; // 1493 -// operator-(const Vector *const this, -// const Vector &v); // 1497 -// Normalize(const class Vector2D *const this); // 1498 -// DotProduct(const class Vector2D &a, -// const class Vector2D &b); // 1500 -// } - return FALSE; + Vector2D vec2LOS; + float flDot; + + UTIL_MakeVectors(pev->angles); + + vec2LOS = (pEntity->pev->origin - pev->origin).Make2D(); + vec2LOS = vec2LOS.Normalize(); + + flDot = DotProduct(vec2LOS, gpGlobals->v_forward.Make2D()); + + if (flDot > m_flFieldOfView) + { + return TRUE; + } + else + { + return FALSE; + } } +// FInViewCone - returns true is the passed vector is in +// the caller's forward view cone. The dot product is performed +// in 2d, making the view cone infinitely tall. + /* <61be6> ../cstrike/dlls/combat.cpp:1517 */ -NOBODY BOOL CBaseMonster::__MAKE_VHOOK(FInViewCone)(Vector *pOrigin) +BOOL CBaseMonster::__MAKE_VHOOK(FInViewCone)(const Vector *pOrigin) { -// { -// class Vector2D vec2LOS; // 1519 -// float flDot; // 1520 -// operator-(const Vector *const this, -// const Vector &v); // 1524 -// Normalize(const class Vector2D *const this); // 1525 -// DotProduct(const class Vector2D &a, -// const class Vector2D &b); // 1527 -// } - return FALSE; + Vector2D vec2LOS; + float flDot; + + UTIL_MakeVectors(pev->angles); + + vec2LOS = (*pOrigin - pev->origin).Make2D(); + vec2LOS = vec2LOS.Normalize(); + + flDot = DotProduct(vec2LOS, gpGlobals->v_forward.Make2D()); + + if (flDot > m_flFieldOfView) + { + return TRUE; + } + else + { + return FALSE; + } } +// FVisible - returns true if a line can be traced from +// the caller's eyes to the target + /* <5ecb4> ../cstrike/dlls/combat.cpp:1543 */ -NOBODY BOOL CBaseEntity::__MAKE_VHOOK(FVisible)(CBaseEntity *pEntity) +BOOL CBaseEntity::__MAKE_VHOOK(FVisible)(CBaseEntity *pEntity) { -// { -// TraceResult tr; // 1545 -// class Vector vecLookerOrigin; // 1546 -// class Vector vecTargetOrigin; // 1547 -// } -// FVisible(CBaseEntity *const this, -// class CBaseEntity *pEntity); // 1543 - return FALSE; + TraceResult tr; + Vector vecLookerOrigin; + Vector vecTargetOrigin; + + if (pEntity->pev->flags & FL_NOTARGET) + return FALSE; + + // don't look through water + if ((pev->waterlevel != 3 && pEntity->pev->waterlevel == 3) || (pev->waterlevel == 3 && pEntity->pev->waterlevel == 0)) + return FALSE; + + //look through the caller's 'eyes' + vecLookerOrigin = pev->origin + pev->view_ofs; + vecTargetOrigin = pEntity->EyePosition(); + + UTIL_TraceLine(vecLookerOrigin, vecTargetOrigin, ignore_monsters, ignore_glass, ENT(pev), &tr); + + if (tr.flFraction != 1.0f) + { + // Line of sight is not established + return FALSE; + } + else + { + // line of sight is valid. + return TRUE; + } } +// FVisible - returns true if a line can be traced from +// the caller's eyes to the target vector + /* <5e9bb> ../cstrike/dlls/combat.cpp:1576 */ -NOBODY BOOL CBaseEntity::__MAKE_VHOOK(FVisible)(Vector &vecOrigin) +BOOL CBaseEntity::__MAKE_VHOOK(FVisible)(const Vector &vecOrigin) { -// { -// TraceResult tr; // 1578 -// class Vector vecLookerOrigin; // 1579 -// } - return FALSE; + TraceResult tr; + Vector vecLookerOrigin; + + //look through the caller's 'eyes' + vecLookerOrigin = EyePosition(); + + UTIL_TraceLine(vecLookerOrigin, vecOrigin, ignore_monsters, ignore_glass, ENT(pev), &tr); + + if (tr.flFraction != 1.0f) + { + // Line of sight is not established + return FALSE; + } + else + { + // line of sight is valid. + return TRUE; + } } /* <5e872> ../cstrike/dlls/combat.cpp:1600 */ @@ -1188,111 +1515,148 @@ void CBaseMonster::__MAKE_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDam } /* <61df9> ../cstrike/dlls/combat.cpp:1704 */ -NOBODY void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) +void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) { -// { -// int tracerCount; // 1706 -// int tracer; // 1707 -// TraceResult tr; // 1708 -// class Vector vecRight; // 1709 -// class Vector vecUp; // 1710 -// bool m_bCreatedShotgunSpark; // 1711 -// Vector(Vector *const this, -// const Vector &v); // 1709 -// Vector(Vector *const this, -// const Vector &v); // 1710 -// { -// ULONG iShot; // 1722 -// { -// int spark; // 1724 -// float x; // 1727 -// float y; // 1727 -// float z; // 1727 -// class Vector vecDir; // 1734 -// class Vector vecEnd; // 1737 -// operator*(float fl, -// const Vector &v); // 1736 -// operator*(float fl, -// const Vector &v); // 1736 -// operator+(const Vector *const this, -// const Vector &v); // 1736 -// operator+(const Vector *const this, -// const Vector &v); // 1736 -// operator*(const Vector *const this, -// float fl); // 1739 -// operator+(const Vector *const this, -// const Vector &v); // 1739 -// { -// class Vector vecTracerSrc; // 1745 -// operator*(const Vector *const this, -// float fl); // 1749 -// operator*(const Vector *const this, -// float fl); // 1749 -// operator+(const Vector *const this, -// const Vector &v); // 1749 -// operator+(const Vector *const this, -// const Vector &v); // 1749 -// operator+(const Vector *const this, -// const Vector &v); // 1749 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 1765 -// } -// { -// class CBaseEntity *pEntity; // 1780 -// Instance(edict_t *pent); // 1780 -// Vector(Vector *const this, -// const Vector &v); // 1784 -// Vector(Vector *const this, -// const Vector &v); // 1786 -// Vector(Vector *const this, -// const Vector &v); // 1786 -// { -// float flDamage; // 1802 -// Vector(Vector *const this, -// const Vector &v); // 1793 -// Vector(Vector *const this, -// const Vector &v); // 1830 -// Vector(Vector *const this, -// const Vector &v); // 1822 -// Vector(Vector *const this, -// const Vector &v); // 1824 -// Vector(Vector *const this, -// const Vector &v); // 1824 -// Vector(Vector *const this, -// const Vector &v); // 1814 -// Vector(Vector *const this, -// const Vector &v); // 1816 -// Vector(Vector *const this, -// const Vector &v); // 1816 -// Vector(Vector *const this, -// const Vector &v); // 1806 -// Vector(Vector *const this, -// const Vector &v); // 1810 -// Vector(Vector *const this, -// const Vector &v); // 1797 -// Vector(Vector *const this, -// const Vector &v); // 1839 -// Vector(Vector *const this, -// const Vector &v); // 1840 -// Vector(Vector *const this, -// const Vector &v); // 1840 -// FNullEnt(const edict_t *pent); // 1842 -// VARS(edict_t *pent); // 1842 -// Vector(Vector *const this, -// const Vector &v); // 1833 -// Vector(Vector *const this, -// const Vector &v); // 1833 -// } -// } -// Vector(Vector *const this, -// const Vector &v); // 1851 -// Vector(Vector *const this, -// const Vector &v); // 1851 -// } -// } -// } + static int tracerCount; + int tracer; + + TraceResult tr; + Vector vecRight, vecUp; + bool m_bCreatedShotgunSpark = true; + + vecRight = gpGlobals->v_right; + vecUp = gpGlobals->v_up; + + if (!pevAttacker) + { + // the default attacker is ourselves + pevAttacker = pev; + } + + ClearMultiDamage(); + gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); + + for (ULONG iShot = 1; iShot <= cShots; iShot++) + { + int spark = 0; + + // get circular gaussian spread + float x, y, z; + + do + { + x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + z = x * x + y * y; + } + while (z > 1); + + Vector vecDir, vecEnd; + + vecDir = vecDirShooting + x * vecSpread.x * vecRight + y * vecSpread.y * vecUp; + vecEnd = vecSrc + vecDir * flDistance; + + UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); + tracer = 0; + + if (iTracerFreq != 0 && !(tracerCount++ % iTracerFreq)) + { + Vector vecTracerSrc; + + if (IsPlayer()) + { + // adjust tracer position for player + vecTracerSrc = vecSrc + Vector(0, 0, -4) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16; + } + else + { + vecTracerSrc = vecSrc; + } + + // guns that always trace also always decal + if (iTracerFreq != 1) + tracer = 1; + + MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecTracerSrc); + WRITE_BYTE(TE_TRACER); + WRITE_COORD(vecTracerSrc.x); + WRITE_COORD(vecTracerSrc.y); + WRITE_COORD(vecTracerSrc.z); + WRITE_COORD(tr.vecEndPos.x); + WRITE_COORD(tr.vecEndPos.y); + WRITE_COORD(tr.vecEndPos.z); + MESSAGE_END(); + } + + // do damage, paint decals + if (tr.flFraction != 1.0f) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + + if (iDamage) + { + pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB)); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + } + else + { + float flDamage; + + switch (iBulletType) + { + case BULLET_PLAYER_MP5: + pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET); + break; + case BULLET_PLAYER_BUCKSHOT: + flDamage = ((1 - tr.flFraction) * 20); + pEntity->TraceAttack(pevAttacker, (int)flDamage, vecDir, &tr, DMG_BULLET); + break; + case BULLET_PLAYER_357: + pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg357, vecDir, &tr, DMG_BULLET); + break; + case BULLET_MONSTER_9MM: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + break; + case BULLET_MONSTER_MP5: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmgMP5, vecDir, &tr, DMG_BULLET); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + break; + case BULLET_MONSTER_12MM: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmg12MM, vecDir, &tr, DMG_BULLET); + + if (!tracer) + { + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + } + break; + case BULLET_NONE: + flDamage = 50; + pEntity->TraceAttack(pevAttacker, flDamage, vecDir, &tr, DMG_CLUB); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + + // only decal glass + if (!FNullEnt(tr.pHit) && VARS(tr.pHit)->rendermode != kRenderNormal) + { + UTIL_DecalTrace(&tr, DECAL_GLASSBREAK1 + RANDOM_LONG(0, 2)); + } + break; + default: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET); + break; + } + } + } + + // make bullet trails + UTIL_BubbleTrail(vecSrc, tr.vecEndPos, (int)((flDistance * tr.flFraction) / 64)); + } + + ApplyMultiDamage(pev, pevAttacker); } /* <62693> ../cstrike/dlls/combat.cpp:1856 */ @@ -1301,105 +1665,78 @@ NOXREF char *vstr(float *v) static int idx = 0; static char string[ 16 ][ 1024 ]; - idx = (idx + 1) % 0xF; - Q_sprintf(string[ idx ], "%.4f %.4f %.4f", v[0], v[1], v[2]); - + idx = (idx + 1) % 0xF; + Q_sprintf(string[ idx ], "%.4f %.4f %.4f", v[0], v[1], v[2]); + return string[ idx ]; } -Vector (*pFireBullets3)(Vector, Vector, float, float, int, int, int, float, entvars_t *, bool, int); +// Go to the trouble of combining multiple pellets into a single damage call. +// This version is used by Players, uses the random seed generator to sync client and server side shots. /* <62709> ../cstrike/dlls/combat.cpp:1869 */ -Vector __declspec(naked) CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) +Vector CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) { - UNTESTED - //TODO: crash a test to czero - - __asm - { - jmp pFireBullets3 - } -/* int iOriginalPenetration = iPenetration; + int iOriginalPenetration = iPenetration; int iPenetrationPower; - - //int iSparksAmount; - int iCurrentDamage = iDamage; - float flPenetrationDistance; + int iCurrentDamage = iDamage; float flCurrentDistance; - TraceResult tr; - TraceResult tr2; - - CBaseEntity *pEntity; - Vector vecDir; - Vector vecEnd; + TraceResult tr, tr2; + Vector vecRight, vecUp; bool bHitMetal = false; + int iSparksAmount = 1; - Vector vecRight = gpGlobals->v_right; - Vector vecUp = gpGlobals->v_up; + vecRight = gpGlobals->v_right; + vecUp = gpGlobals->v_up; switch (iBulletType) { - case BULLET_PLAYER_9MM: - { - iPenetrationPower = 21; - flPenetrationDistance = 800; - break; - } - case BULLET_PLAYER_45ACP: - { - iPenetrationPower = 15; - flPenetrationDistance = 500; - break; - } - case BULLET_PLAYER_50AE: - { - iPenetrationPower = 30; - flPenetrationDistance = 1000; - break; - } - case BULLET_PLAYER_762MM: - { - iPenetrationPower = 39; - flPenetrationDistance = 5000.0f; - break; - } - case BULLET_PLAYER_556MM: - { - iPenetrationPower = 35; - flPenetrationDistance = 4000; - break; - } - case BULLET_PLAYER_338MAG: - { - iPenetrationPower = 45; - flPenetrationDistance = 8000; - break; - } - case BULLET_PLAYER_57MM: - { - iPenetrationPower = 30; - flPenetrationDistance = 2000; - break; - } - case BULLET_PLAYER_357SIG: - { - iPenetrationPower = 25; - flPenetrationDistance = 800; - break; - } - default: - { - iPenetrationPower = 0; - flPenetrationDistance = 0; - break; - } + case BULLET_PLAYER_9MM: + iPenetrationPower = 21; + flPenetrationDistance = 800; + break; + case BULLET_PLAYER_45ACP: + iPenetrationPower = 15; + flPenetrationDistance = 500; + break; + case BULLET_PLAYER_50AE: + iPenetrationPower = 30; + flPenetrationDistance = 1000; + break; + case BULLET_PLAYER_762MM: + iPenetrationPower = 39; + flPenetrationDistance = 5000; + break; + case BULLET_PLAYER_556MM: + iPenetrationPower = 35; + flPenetrationDistance = 4000; + break; + case BULLET_PLAYER_338MAG: + iPenetrationPower = 45; + flPenetrationDistance = 8000; + break; + case BULLET_PLAYER_57MM: + iPenetrationPower = 30; + flPenetrationDistance = 2000; + break; + case BULLET_PLAYER_357SIG: + iPenetrationPower = 25; + flPenetrationDistance = 800; + break; + default: + iPenetrationPower = 0; + flPenetrationDistance = 0; + break; } if (!pevAttacker) - pevAttacker = pev; // the default attacker is ourselves + { + // the default attacker is ourselves + pevAttacker = pev; + } gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); @@ -1407,7 +1744,7 @@ Vector __declspec(naked) CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirS if (IsPlayer()) { - // Use player's random seed. + // Use player's random seed. // get circular gaussian spread x = UTIL_SharedRandomFloat(shared_rand, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 1, -0.5, 0.5); y = UTIL_SharedRandomFloat(shared_rand + 2, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 3, -0.5, 0.5); @@ -1423,6 +1760,9 @@ Vector __declspec(naked) CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirS while (z > 1); } + Vector vecDir, vecEnd; + Vector vecOldSrc, vecNewSrc; + vecDir = vecDirShooting + x * vecSpread * vecRight + y * vecSpread * vecUp; vecEnd = vecSrc + vecDir * flDistance; @@ -1433,96 +1773,97 @@ Vector __declspec(naked) CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirS ClearMultiDamage(); UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1) - TheBots->OnEvent(EVENT_BULLET_IMPACT, this, NULL); - - switch (UTIL_TextureHit(&tr, vecSrc, vecEnd)) + if (tr.flFraction != 1.0f) { - case CHAR_TEX_METAL: - { - bHitMetal = true; - iPenetrationPower *= 0.15; - flDamageModifier = 0.2; - break; - } - case CHAR_TEX_CONCRETE: - { - iPenetrationPower *= 0.25; - break; - } - case CHAR_TEX_GRATE: - { - bHitMetal = true; - iPenetrationPower *= 0.5; - flDamageModifier = 0.4; - break; - } - case CHAR_TEX_VENT: - { - bHitMetal = true; - iPenetrationPower *= 0.5; - flDamageModifier = 0.45; - break; - } - case CHAR_TEX_TILE: - { - iPenetrationPower *= 0.65; - flDamageModifier = 0.3; - break; - } - case CHAR_TEX_COMPUTER: - { - bHitMetal = true; - iPenetrationPower *= 0.4; - flDamageModifier = 0.45; - break; - } - case CHAR_TEX_WOOD: - { - flDamageModifier = 0.6; - break; - } - default: - break; + TheBots->OnEvent(EVENT_BULLET_IMPACT, this, (CBaseEntity *)&tr.vecEndPos); } - if (tr.flFraction != 1.0) + + char cTextureType = UTIL_TextureHit(&tr, vecSrc, vecEnd); + bool bSparks = false; + + switch (cTextureType) { - pEntity = CBaseEntity::Instance(tr.pHit); + case CHAR_TEX_METAL: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.15; + flDamageModifier = 0.2; + break; + case CHAR_TEX_CONCRETE: + iPenetrationPower *= 0.25; + break; + case CHAR_TEX_GRATE: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.5; + flDamageModifier = 0.4; + break; + case CHAR_TEX_VENT: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.5; + flDamageModifier = 0.45; + break; + case CHAR_TEX_TILE: + iPenetrationPower *= 0.65; + flDamageModifier = 0.3; + break; + case CHAR_TEX_COMPUTER: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.4; + flDamageModifier = 0.45; + break; + case CHAR_TEX_WOOD: + flDamageModifier = 0.6; + break; + default: + break; + } + if (tr.flFraction != 1.0f) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); iPenetration--; flCurrentDistance = tr.flFraction * flDistance; iCurrentDamage *= pow(flRangeModifier, flCurrentDistance / 500); if (flCurrentDistance > flPenetrationDistance) + { iPenetration = 0; + } if (tr.iHitgroup == HITGROUP_SHIELD) { - if (RANDOM_LONG(0, 1)) - EMIT_SOUND(pEntity->edict(), CHAN_VOICE, "weapons/ric_metal-1.wav", VOL_NORM, ATTN_NORM); - else - EMIT_SOUND(pEntity->edict(), CHAN_VOICE, "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); - + EMIT_SOUND(pEntity->edict(), CHAN_VOICE, (RANDOM_LONG(0, 1) == 1) ? "weapons/ric_metal-1.wav" : "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); UTIL_Sparks(tr.vecEndPos); pEntity->pev->punchangle.x = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); pEntity->pev->punchangle.z = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); if (pEntity->pev->punchangle.x < 4) - pEntity->pev->punchangle.x = -4;//TODO:?? 4 ? + { + pEntity->pev->punchangle.x = -4; + } if (pEntity->pev->punchangle.z < -5) + { pEntity->pev->punchangle.z = -5; - + } else if (pEntity->pev->punchangle.z > 5) + { pEntity->pev->punchangle.z = 5; + } break; } float flDistanceModifier; - //if (VARS(tr.pHit)->solid != SOLID_BSP || !iPenetration) - if (pEntity->pev->solid != SOLID_BSP || !iPenetration) + if (VARS(tr.pHit)->solid != SOLID_BSP || !iPenetration) { iPenetrationPower = 42; flDamageModifier = 0.75; @@ -1532,12 +1873,12 @@ Vector __declspec(naked) CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirS flDistanceModifier = 0.5; DecalGunshot(&tr, iBulletType, (!bPistol && RANDOM_LONG(0, 3)), pev, bHitMetal); - + vecSrc = tr.vecEndPos + (vecDir * iPenetrationPower); flDistance = (flDistance - flCurrentDistance) * flDistanceModifier; vecEnd = vecSrc + (vecDir * flDistance); - pEntity->TraceAttack(pevAttacker, iCurrentDamage, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB); + pEntity->TraceAttack(pevAttacker, iCurrentDamage, vecDir, &tr, (DMG_BULLET | DMG_NEVERGIB)); iCurrentDamage *= flDamageModifier; } else @@ -1546,7 +1887,7 @@ Vector __declspec(naked) CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirS ApplyMultiDamage(pev, pevAttacker); } - return Vector(x * vecSpread, y * vecSpread, 0);*/ + return Vector(x * vecSpread, y * vecSpread, 0); } /* <5eb17> ../cstrike/dlls/combat.cpp:2075 */ @@ -1561,7 +1902,7 @@ void CBaseEntity::__MAKE_VHOOK(TraceBleed)(float flDamage, Vector vecDir, TraceR if (!(bitsDamageType & (DMG_CRUSH | DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB | DMG_MORTAR))) return; - // make blood decal on the wall! + // make blood decal on the wall! TraceResult Bloodtr; Vector vecTraceDir; float flNoise; @@ -1597,7 +1938,9 @@ void CBaseEntity::__MAKE_VHOOK(TraceBleed)(float flDamage, Vector vecDir, TraceR if (Bloodtr.flFraction != 1.0f) { if (!RANDOM_LONG(0, 2)) + { UTIL_BloodDecalTrace(&Bloodtr, BloodColor()); + } } } } @@ -1605,37 +1948,37 @@ void CBaseEntity::__MAKE_VHOOK(TraceBleed)(float flDamage, Vector vecDir, TraceR /* <62e0e> ../cstrike/dlls/combat.cpp:2145 */ NOXREF void CBaseMonster::MakeDamageBloodDecal(int cCount, float flNoise, TraceResult *ptr, Vector &vecDir) { - // make blood decal on the wall! - TraceResult Bloodtr; - Vector vecTraceDir; + // make blood decal on the wall! + TraceResult Bloodtr; + Vector vecTraceDir; int i; - if (!IsAlive()) - { - // dealing with a dead monster. - if (pev->max_health <= 0) - { - // no blood decal for a monster that has already decalled its limit. - return; - } - else - pev->max_health--; - } - - for (i = 0 ; i < cCount ; i++) - { - vecTraceDir = vecDir; - - vecTraceDir.x += RANDOM_FLOAT(-flNoise, flNoise); - vecTraceDir.y += RANDOM_FLOAT(-flNoise, flNoise); - vecTraceDir.z += RANDOM_FLOAT(-flNoise, flNoise); - - UTIL_TraceLine(ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT(pev), &Bloodtr); - - if (Bloodtr.flFraction != 1.0) - { - UTIL_BloodDecalTrace(&Bloodtr, BloodColor()); - } + if (!IsAlive()) + { + // dealing with a dead monster. + if (pev->max_health <= 0) + { + // no blood decal for a monster that has already decalled its limit. + return; + } + else + pev->max_health--; + } + + for (i = 0; i < cCount; i++) + { + vecTraceDir = vecDir; + + vecTraceDir.x += RANDOM_FLOAT(-flNoise, flNoise); + vecTraceDir.y += RANDOM_FLOAT(-flNoise, flNoise); + vecTraceDir.z += RANDOM_FLOAT(-flNoise, flNoise); + + UTIL_TraceLine(ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT(pev), &Bloodtr); + + if (Bloodtr.flFraction != 1.0) + { + UTIL_BloodDecalTrace(&Bloodtr, BloodColor()); + } } } @@ -1660,99 +2003,99 @@ void CBaseMonster::BloodSplat(const Vector &vecSrc, const Vector &vecDir, int Hi #ifdef HOOK_GAMEDLL -void CBaseMonster::KeyValue(KeyValueData *pkvd) -{ - KeyValue_(pkvd); -} - -void CBaseMonster::TraceAttack(entvars_t *pevAttacker,float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) -{ - TraceAttack_(pevAttacker, flDamage, vecDir, ptr, bitsDamageType); -} - -int CBaseMonster::TakeDamage(entvars_t *pevInflictor,entvars_t *pevAttacker,float flDamage,int bitsDamageType) -{ - return TakeDamage_(pevInflictor, pevAttacker, flDamage, bitsDamageType); -} - -int CBaseMonster::TakeHealth(float flHealth,int bitsDamageType) -{ - return TakeHealth_(flHealth, bitsDamageType); -} - -void CBaseMonster::Killed(entvars_t *pevAttacker,int iGib) -{ - Killed_(pevAttacker, iGib); -} - -float CBaseMonster::ChangeYaw(int speed) -{ - return ChangeYaw_(speed); -} - -BOOL CBaseMonster::HasHumanGibs(void) -{ - return HasHumanGibs_(); -} - -BOOL CBaseMonster::HasAlienGibs(void) -{ - return HasHumanGibs_(); -} - -void CBaseMonster::FadeMonster(void) -{ - FadeMonster_(); -} - -void CBaseMonster::GibMonster(void) -{ - GibMonster_(); -} - -Activity CBaseMonster::GetDeathActivity(void) -{ - return GetDeathActivity_(); -} - -void CBaseMonster::BecomeDead(void) -{ - BecomeDead_(); -} - -BOOL CBaseMonster::ShouldFadeOnDeath(void) -{ - return ShouldFadeOnDeath_(); -} - -int CBaseMonster::IRelationship(CBaseEntity *pTarget) -{ - return IRelationship_(pTarget); -} - -void CBaseMonster::MonsterInitDead(void) -{ - MonsterInitDead_(); -} - -void CBaseMonster::Look(int iDistance) -{ - Look_(iDistance); -} - -CBaseEntity *CBaseMonster::BestVisibleEnemy(void) -{ - return BestVisibleEnemy_(); -} - -BOOL CBaseMonster::FInViewCone(CBaseEntity *pEntity) -{ - return FInViewCone_(pEntity); -} - -BOOL CBaseMonster::FInViewCone(Vector *pOrigin) -{ - return FInViewCone_(pOrigin); -} +void CBaseMonster::KeyValue(KeyValueData *pkvd) +{ + KeyValue_(pkvd); +} + +void CBaseMonster::TraceAttack(entvars_t *pevAttacker,float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) +{ + TraceAttack_(pevAttacker, flDamage, vecDir, ptr, bitsDamageType); +} + +int CBaseMonster::TakeDamage(entvars_t *pevInflictor,entvars_t *pevAttacker,float flDamage,int bitsDamageType) +{ + return TakeDamage_(pevInflictor, pevAttacker, flDamage, bitsDamageType); +} + +int CBaseMonster::TakeHealth(float flHealth,int bitsDamageType) +{ + return TakeHealth_(flHealth, bitsDamageType); +} + +void CBaseMonster::Killed(entvars_t *pevAttacker,int iGib) +{ + Killed_(pevAttacker, iGib); +} + +float CBaseMonster::ChangeYaw(int speed) +{ + return ChangeYaw_(speed); +} + +BOOL CBaseMonster::HasHumanGibs(void) +{ + return HasHumanGibs_(); +} + +BOOL CBaseMonster::HasAlienGibs(void) +{ + return HasHumanGibs_(); +} + +void CBaseMonster::FadeMonster(void) +{ + FadeMonster_(); +} + +void CBaseMonster::GibMonster(void) +{ + GibMonster_(); +} + +Activity CBaseMonster::GetDeathActivity(void) +{ + return GetDeathActivity_(); +} + +void CBaseMonster::BecomeDead(void) +{ + BecomeDead_(); +} + +BOOL CBaseMonster::ShouldFadeOnDeath(void) +{ + return ShouldFadeOnDeath_(); +} + +int CBaseMonster::IRelationship(CBaseEntity *pTarget) +{ + return IRelationship_(pTarget); +} + +void CBaseMonster::MonsterInitDead(void) +{ + MonsterInitDead_(); +} + +void CBaseMonster::Look(int iDistance) +{ + Look_(iDistance); +} + +CBaseEntity *CBaseMonster::BestVisibleEnemy(void) +{ + return BestVisibleEnemy_(); +} + +BOOL CBaseMonster::FInViewCone(CBaseEntity *pEntity) +{ + return FInViewCone_(pEntity); +} + +BOOL CBaseMonster::FInViewCone(const Vector *pOrigin) +{ + return FInViewCone_(pOrigin); +} #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/doors.cpp b/regamedll/dlls/doors.cpp index 131aab12..7188d4e8 100644 --- a/regamedll/dlls/doors.cpp +++ b/regamedll/dlls/doors.cpp @@ -23,235 +23,952 @@ TYPEDESCRIPTION CMomentaryDoor::m_SaveData[] = #else -TYPEDESCRIPTION (*CBaseDoor::pm_SaveData)[7]; -TYPEDESCRIPTION (*CMomentaryDoor::pm_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBaseDoor, m_SaveData)[7]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CMomentaryDoor, m_SaveData)[1]; #endif // HOOK_GAMEDLL /* <693c0> ../cstrike/dlls/doors.cpp:98 */ IMPLEMENT_SAVERESTORE(CBaseDoor, CBaseToggle); +// play door or button locked or unlocked sounds. +// pass in pointer to valid locksound struct. +// if flocked is true, play 'door is locked' sound, +// otherwise play 'door is unlocked' sound +// NOTE: this routine is shared by doors and buttons + /* <68561> ../cstrike/dlls/doors.cpp:112 */ -NOBODY void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton) +void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton) { -// { -// float flsoundwait; // 118 -// { -// int fplaysound; // 127 -// int fplaysentence; // 128 -// float fvol; // 129 -// { -// int iprev; // 148 -// } -// } -// { -// int fplaysound; // 164 -// int fplaysentence; // 165 -// float fvol; // 166 -// { -// int iprev; // 184 -// } -// } -// } + // LOCKED SOUND + + // CONSIDER: consolidate the locksound_t struct (all entries are duplicates for lock/unlock) + // CONSIDER: and condense this code. + float flsoundwait; + + if (fbutton) + flsoundwait = BUTTON_SOUNDWAIT; + else + flsoundwait = DOOR_SOUNDWAIT; + + if (flocked) + { + int fplaysound = (pls->sLockedSound && gpGlobals->time > pls->flwaitSound); + int fplaysentence = (pls->sLockedSentence && !pls->bEOFLocked && gpGlobals->time > pls->flwaitSentence); + float fvol; + + if (fplaysound && fplaysentence) + fvol = 0.25; + else + fvol = 1.0; + + // if there is a locked sound, and we've debounced, play sound + if (fplaysound) + { + // play 'door locked' sound + EMIT_SOUND(ENT(pev), CHAN_ITEM, (char *)STRING(pls->sLockedSound), fvol, ATTN_NORM); + pls->flwaitSound = gpGlobals->time + flsoundwait; + } + + // if there is a sentence, we've not played all in list, and we've debounced, play sound + if (fplaysentence) + { + // play next 'door locked' sentence in group + int iprev = pls->iLockedSentence; + + pls->iLockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sLockedSentence), 0.85, ATTN_NORM, 0, 100, pls->iLockedSentence, FALSE); + pls->iUnlockedSentence = 0; + + // make sure we don't keep calling last sentence in list + pls->bEOFLocked = (iprev == pls->iLockedSentence); + pls->flwaitSentence = gpGlobals->time + DOOR_SENTENCEWAIT; + } + } + else + { + // UNLOCKED SOUND + + int fplaysound = (pls->sUnlockedSound && gpGlobals->time > pls->flwaitSound); + int fplaysentence = (pls->sUnlockedSentence && !pls->bEOFUnlocked && gpGlobals->time > pls->flwaitSentence); + float fvol; + + // if playing both sentence and sound, lower sound volume so we hear sentence + if (fplaysound && fplaysentence) + fvol = 0.25; + else + fvol = 1.0; + + // play 'door unlocked' sound if set + if (fplaysound) + { + EMIT_SOUND(ENT(pev), CHAN_ITEM, (char *)STRING(pls->sUnlockedSound), fvol, ATTN_NORM); + pls->flwaitSound = gpGlobals->time + flsoundwait; + } + + // play next 'door unlocked' sentence in group + if (fplaysentence) + { + int iprev = pls->iUnlockedSentence; + + pls->iUnlockedSentence = SENTENCEG_PlaySequentialSz(ENT(pev), STRING(pls->sUnlockedSentence), 0.85, ATTN_NORM, 0, 100, pls->iUnlockedSentence, FALSE); + pls->iLockedSentence = 0; + + // make sure we don't keep calling last sentence in list + pls->bEOFUnlocked = (iprev == pls->iUnlockedSentence); + pls->flwaitSentence = gpGlobals->time + DOOR_SENTENCEWAIT; + } + } } +// Cache user-entity-field values until spawn is called. + /* <69a4f> ../cstrike/dlls/doors.cpp:201 */ -NOBODY void CBaseDoor::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CBaseDoor::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 204 -// FStrEq(const char *sz1, -// const char *sz2); // 209 -// KeyValue(CBaseDoor *const this, -// KeyValueData *pkvd); // 201 -// atof(const char *__nptr); // 206 -// atof(const char *__nptr); // 211 + //skin is used for content type + if (FStrEq(pkvd->szKeyName, "skin")) + { + pev->skin = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "movesnd")) + { + m_bMoveSnd = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "stopsnd")) + { + m_bStopSnd = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "healthvalue")) + { + m_bHealthValue = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "locked_sound")) + { + m_bLockedSound = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "locked_sentence")) + { + m_bLockedSentence = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "unlocked_sound")) + { + m_bUnlockedSound = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "unlocked_sentence")) + { + m_bUnlockedSentence = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "WaveHeight")) + { + pev->scale = Q_atof(pkvd->szValue) * (1.0 / 8.0); + pkvd->fHandled = TRUE; + } + else + CBaseToggle::KeyValue(pkvd); } +// QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK TOGGLE +// if two doors touch, they are assumed to be connected and operate as a unit. + +// TOGGLE causes the door to wait in both the start and end states for a trigger event. + +// START_OPEN causes the door to move to its destination when spawned, and operate in reverse. +// It is used to temporarily or permanently close off an area when triggered (not usefull for +// touch or takedamage doors). + +// "angle" determines the opening direction +// "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door. +// "health" if set, door must be shot open +// "speed" movement speed (100 default) +// "wait" wait before returning (3 default, -1 = never return) +// "lip" lip remaining at end of move (8 default) +// "dmg" damage to inflict when blocked (2 default) +// "sounds" +// 0) no sound +// 1) stone +// 2) base +// 3) stone chain +// 4) screechy metal + /* <69f8b> ../cstrike/dlls/doors.cpp:278 */ LINK_ENTITY_TO_CLASS(func_door, CBaseDoor); +// func_water - same as a door. + /* <6a058> ../cstrike/dlls/doors.cpp:282 */ LINK_ENTITY_TO_CLASS(func_water, CBaseDoor); /* <690bc> ../cstrike/dlls/doors.cpp:285 */ -NOBODY void CBaseDoor::__MAKE_VHOOK(Spawn)(void) +void CBaseDoor::__MAKE_VHOOK(Spawn)(void) { -// fabs(double __x); // 312 -// fabs(double __x); // 312 -// fabs(double __x); // 312 -// operator*(const Vector *const this, -// float fl); // 312 -// operator+(const Vector *const this, -// const Vector &v); // 312 + Precache(); + SetMovedir(pev); + + //normal door + if (pev->skin == 0) + { + if (pev->spawnflags & SF_DOOR_PASSABLE) + pev->solid = SOLID_NOT; + else + pev->solid = SOLID_BSP; + } + else // special contents + { + pev->solid = SOLID_NOT; + + // water is silent for now + pev->spawnflags |= SF_DOOR_SILENT; + } + + pev->movetype = MOVETYPE_PUSH; + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (pev->speed == 0) + pev->speed = 100; + + m_vecPosition1 = pev->origin; + + // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big + m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs((float_precision)(pev->movedir.x * (pev->size.x - 2))) + fabs((float_precision)(pev->movedir.y * (pev->size.y - 2))) + fabs((float_precision)(pev->movedir.z * (pev->size.z - 2))) - m_flLip)); + + assert(("door start/end positions are equal", m_vecPosition1 != m_vecPosition2)); + + if (pev->spawnflags & SF_DOOR_START_OPEN) + { + // swap pos1 and pos2, put door at pos2 + UTIL_SetOrigin(pev, m_vecPosition2); + m_vecPosition2 = m_vecPosition1; + m_vecPosition1 = pev->origin; + } + + m_toggle_state = TS_AT_BOTTOM; + + // if the door is flagged for USE button activation only, use NULL touch function + if (pev->spawnflags & SF_DOOR_USE_ONLY) + { + SetTouch(NULL); + } + else + { + // touchable button + SetTouch(&CBaseDoor::DoorTouch); + } + + m_lastBlockedTimestamp = 0; } /* <69949> ../cstrike/dlls/doors.cpp:334 */ -NOBODY void CBaseDoor::__MAKE_VHOOK(Restart)(void) +void CBaseDoor::__MAKE_VHOOK(Restart)(void) { + SetMovedir(pev); + m_toggle_state = TS_AT_BOTTOM; + DoorGoDown(); + + if (pev->spawnflags & SF_DOOR_USE_ONLY) + SetTouch(NULL); + else + SetTouch(&CBaseDoor::DoorTouch); } /* <69289> ../cstrike/dlls/doors.cpp:350 */ -NOBODY void CBaseDoor::__MAKE_VHOOK(SetToggleState)(int state) +void CBaseDoor::__MAKE_VHOOK(SetToggleState)(int state) { -// SetToggleState(CBaseDoor *const this, -// int state); // 350 + if (state == TS_AT_TOP) + UTIL_SetOrigin(pev, m_vecPosition2); + else + UTIL_SetOrigin(pev, m_vecPosition1); } #define noiseMoving noise1 #define noiseArrived noise2 /* <6924c> ../cstrike/dlls/doors.cpp:359 */ -NOBODY void CBaseDoor::__MAKE_VHOOK(Precache)(void) +void CBaseDoor::__MAKE_VHOOK(Precache)(void) { -// { -// char *pszSound; // 361 -// } + char *pszSound; + + // set the door's "in-motion" sound + switch (m_bMoveSnd) + { + case 0: + pev->noiseMoving = ALLOC_STRING("common/null.wav"); + break; + case 1: + PRECACHE_SOUND("doors/doormove1.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove1.wav"); + break; + case 2: + PRECACHE_SOUND("doors/doormove2.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove2.wav"); + break; + case 3: + PRECACHE_SOUND("doors/doormove3.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove3.wav"); + break; + case 4: + PRECACHE_SOUND("doors/doormove4.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove4.wav"); + break; + case 5: + PRECACHE_SOUND("doors/doormove5.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove5.wav"); + break; + case 6: + PRECACHE_SOUND("doors/doormove6.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove6.wav"); + break; + case 7: + PRECACHE_SOUND("doors/doormove7.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove7.wav"); + break; + case 8: + PRECACHE_SOUND("doors/doormove8.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove8.wav"); + break; + case 9: + PRECACHE_SOUND("doors/doormove9.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove9.wav"); + break; + case 10: + PRECACHE_SOUND("doors/doormove10.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove10.wav"); + break; + default: + pev->noiseMoving = ALLOC_STRING("common/null.wav"); + break; + } + + // set the door's 'reached destination' stop sound + switch (m_bStopSnd) + { + case 0: + pev->noiseArrived = ALLOC_STRING("common/null.wav"); + break; + case 1: + PRECACHE_SOUND("doors/doorstop1.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop1.wav"); + break; + case 2: + PRECACHE_SOUND("doors/doorstop2.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop2.wav"); + break; + case 3: + PRECACHE_SOUND("doors/doorstop3.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop3.wav"); + break; + case 4: + PRECACHE_SOUND("doors/doorstop4.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop4.wav"); + break; + case 5: + PRECACHE_SOUND("doors/doorstop5.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop5.wav"); + break; + case 6: + PRECACHE_SOUND("doors/doorstop6.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop6.wav"); + break; + case 7: + PRECACHE_SOUND("doors/doorstop7.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop7.wav"); + break; + case 8: + PRECACHE_SOUND("doors/doorstop8.wav"); + pev->noiseArrived = ALLOC_STRING("doors/doorstop8.wav"); + break; + default: + pev->noiseArrived = ALLOC_STRING("common/null.wav"); + break; + } + + // get door button sounds, for doors which are directly 'touched' to open + if (m_bLockedSound) + { + pszSound = ButtonSound((int)m_bLockedSound); + PRECACHE_SOUND(pszSound); + m_ls.sLockedSound = ALLOC_STRING(pszSound); + } + + if (m_bUnlockedSound) + { + pszSound = ButtonSound((int)m_bUnlockedSound); + PRECACHE_SOUND(pszSound); + m_ls.sUnlockedSound = ALLOC_STRING(pszSound); + } + + // get sentence group names, for doors which are directly 'touched' to open + switch (m_bLockedSentence) + { + case 1: m_ls.sLockedSentence = ALLOC_STRING("NA"); break; // access denied + case 2: m_ls.sLockedSentence = ALLOC_STRING("ND"); break; // security lockout + case 3: m_ls.sLockedSentence = ALLOC_STRING("NF"); break; // blast door + case 4: m_ls.sLockedSentence = ALLOC_STRING("NFIRE"); break; // fire door + case 5: m_ls.sLockedSentence = ALLOC_STRING("NCHEM"); break; // chemical door + case 6: m_ls.sLockedSentence = ALLOC_STRING("NRAD"); break; // radiation door + case 7: m_ls.sLockedSentence = ALLOC_STRING("NCON"); break; // gen containment + case 8: m_ls.sLockedSentence = ALLOC_STRING("NH"); break; // maintenance door + case 9: m_ls.sLockedSentence = ALLOC_STRING("NG"); break; // broken door + default: m_ls.sLockedSentence = 0; break; + } + + switch (m_bUnlockedSentence) + { + case 1: m_ls.sUnlockedSentence = ALLOC_STRING("EA"); break; // access granted + case 2: m_ls.sUnlockedSentence = ALLOC_STRING("ED"); break; // security door + case 3: m_ls.sUnlockedSentence = ALLOC_STRING("EF"); break; // blast door + case 4: m_ls.sUnlockedSentence = ALLOC_STRING("EFIRE"); break; // fire door + case 5: m_ls.sUnlockedSentence = ALLOC_STRING("ECHEM"); break; // chemical door + case 6: m_ls.sUnlockedSentence = ALLOC_STRING("ERAD"); break; // radiation door + case 7: m_ls.sUnlockedSentence = ALLOC_STRING("ECON"); break; // gen containment + case 8: m_ls.sUnlockedSentence = ALLOC_STRING("EH"); break; // maintenance door + default: m_ls.sUnlockedSentence = 0; break; + } } +// Doors not tied to anything (e.g. button, another door) can be touched, to make them activate. + /* <6a3b8> ../cstrike/dlls/doors.cpp:508 */ -NOBODY void CBaseDoor::DoorTouch(CBaseEntity *pOther) +void CBaseDoor::DoorTouch(CBaseEntity *pOther) { -// { -// entvars_t *pevToucher; // 510 -// } -// DoorTouch(CBaseDoor *const this, -// class CBaseEntity *pOther); // 508 + entvars_t *pevToucher = pOther->pev; + + // Ignore touches by dead players + if (pevToucher->deadflag != DEAD_NO) + return; + + // If door has master, and it's not ready to trigger, + // play 'locked' sound + if (!FStringNull(m_sMaster) && !UTIL_IsMasterTriggered(m_sMaster, pOther)) + { + PlayLockSounds(pev, &m_ls, TRUE, FALSE); + } + + // If door is somebody's target, then touching does nothing. + // You have to activate the owner (e.g. button). + if (!FStringNull(pev->targetname)) + { + // play locked sound + PlayLockSounds(pev, &m_ls, TRUE, FALSE); + return; + } + + // remember who activated the door + m_hActivator = pOther; + + if (DoorActivate()) + { + // Temporarily disable the touch function, until movement is finished. + SetTouch(NULL); + } } +// Used by SUB_UseTargets, when a door is the target of a button. + /* <6a33b> ../cstrike/dlls/doors.cpp:543 */ -NOBODY void CBaseDoor::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CBaseDoor::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// DoorActivate(CBaseDoor *const this); // 548 + m_hActivator = pActivator; + + // if not ready to be used, ignore "use" command. + if (m_toggle_state == TS_AT_BOTTOM || ((pev->spawnflags & SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP)) + { + DoorActivate(); + } } +// Causes the door to "do its thing", i.e. start moving, and cascade activation. + /* <6a319> ../cstrike/dlls/doors.cpp:554 */ -NOBODY int CBaseDoor::DoorActivate(void) +int CBaseDoor::DoorActivate(void) { + if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + return 0; + + // door should close + if ((pev->spawnflags & SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP) + { + DoorGoDown(); + } + else // door should open + { + // give health if player opened the door (medikit) + if (m_hActivator != NULL && m_hActivator->IsPlayer()) + { + // VARS(m_eoActivator)->health += m_bHealthValue; + m_hActivator->TakeHealth(m_bHealthValue, DMG_GENERIC); + + } + + // play door unlock sounds + PlayLockSounds(pev, &m_ls, FALSE, FALSE); + DoorGoUp(); + } + + return 1; } +// Starts the door going to its "up" position (simply ToggleData->vecPosition2). + /* <6a125> ../cstrike/dlls/doors.cpp:588 */ -NOBODY void CBaseDoor::DoorGoUp(void) +void CBaseDoor::DoorGoUp(void) { -// { -// entvars_t *pevActivator; // 590 -// bool isReversing; // 596 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 604 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 613 -// { -// float sign; // 615 -// { -// class Vector2D toActivator; // 626 -// float loX; // 628 -// float loY; // 629 -// float hiX; // 630 -// float hiY; // 631 -// float momentArmX; // 633 -// float momentArmY; // 634 -// } -// operator*(const Vector *const this, -// float fl); // 712 -// } -// Vector(Vector *const this, -// const Vector &v); // 715 -// } + entvars_t *pevActivator; + bool isReversing = (m_toggle_state == TS_GOING_DOWN); + + // It could be going-down, if blocked. + assert(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN); + + // emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't + // filter them out and leave a client stuck with looping door sounds! + if (!isReversing) + { + if (!(pev->spawnflags & SF_DOOR_SILENT)) + { + if (m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN) + { + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving), VOL_NORM, ATTN_NORM); + } + + TheBots->OnEvent(EVENT_DOOR, m_hActivator); + } + } + + m_toggle_state = TS_GOING_UP; + + SetMoveDone(&CBaseDoor::DoorHitTop); + + // !!! BUGBUG Triggered doors don't work with this yet + if (FClassnameIs(pev, "func_door_rotating")) + { + float sign = 1.0; + + if (m_hActivator != NULL) + { + pevActivator = m_hActivator->pev; + + // Y axis rotation, move away from the player + if (!(pev->spawnflags & SF_DOOR_ONEWAY) && pev->movedir.y) + { + Vector2D toActivator = pevActivator->origin.Make2D(); + + float loX = pev->mins.x + pev->origin.x; + float loY = pev->mins.y + pev->origin.y; + + float hiX = pev->maxs.x + pev->origin.x; + float hiY = pev->maxs.y + pev->origin.y; + + float momentArmX = toActivator.x - pev->origin.x; + float momentArmY = toActivator.y - pev->origin.y; + + if (loX > toActivator.x) + { + if (toActivator.y < loY) + { + if (abs((int)momentArmY) > abs((int)momentArmX)) + sign = (momentArmY < 0) ? 1 : -1; + else + sign = (momentArmX > 0) ? 1 : -1; + } + else if (toActivator.y > hiY) + { + if (abs((int)momentArmY) > abs((int)momentArmX)) + sign = (momentArmY < 0) ? 1 : -1; + else + sign = (momentArmX < 0) ? 1 : -1; + } + else + sign = (momentArmY < 0) ? 1 : -1; + } + else + { + if (toActivator.x <= hiX) + { + if (toActivator.y > loY) + sign = (momentArmX > 0) ? 1 : -1; + else if (toActivator.y > hiY) + sign = (momentArmX < 0) ? 1 : -1; + } + else if (toActivator.y < loY) + { + if (abs((int)momentArmY) > abs((int)momentArmX)) + sign = (momentArmY > 0) ? 1 : -1; + else + sign = (momentArmX > 0) ? 1 : -1; + } + else if (toActivator.y > hiY) + { + if (abs((int)momentArmY) > abs((int)momentArmX)) + sign = (momentArmY > 0) ? 1 : -1; + else + sign = (momentArmX < 0) ? 1 : -1; + } + else + sign = (momentArmY > 0) ? 1 : -1; + } + + if (isReversing) + { + sign = -sign; + } + } + } + + AngularMove(m_vecAngle2 * sign, pev->speed); + } + else + LinearMove(m_vecPosition2, pev->speed); } +// The door has reached the "up" position. Either go back down, or wait for another activation. + /* <6940c> ../cstrike/dlls/doors.cpp:721 */ -NOBODY void CBaseDoor::DoorHitTop(void) +void CBaseDoor::DoorHitTop(void) { -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 725 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 726 + if (!(pev->spawnflags & SF_DOOR_SILENT)) + { + STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving)); + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseArrived), VOL_NORM, ATTN_NORM); + } + + assert(m_toggle_state == TS_GOING_UP); + m_toggle_state = TS_AT_TOP; + + // toggle-doors don't come down automatically, they wait for refire. + if (pev->spawnflags & SF_DOOR_NO_AUTO_RETURN) + { + // Re-instate touch method, movement is complete + if (!(pev->spawnflags & SF_DOOR_USE_ONLY)) + { + SetTouch(&CBaseDoor::DoorTouch); + } + } + else + { + // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open + pev->nextthink = pev->ltime + m_flWait; + SetThink(&CBaseDoor::DoorGoDown); + + if (m_flWait == -1) + { + pev->nextthink = -1; + } + } + + // Fire the close target (if startopen is set, then "top" is closed) - netname is the close target + if (!FStringNull(pev->netname) && (pev->spawnflags & SF_DOOR_START_OPEN)) + { + FireTargets(STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0); + } + + // this isn't finished + SUB_UseTargets(m_hActivator, USE_TOGGLE, 0); } +// Starts the door going to its "down" position (simply ToggleData->vecPosition1). + /* <697ad> ../cstrike/dlls/doors.cpp:762 */ -NOBODY void CBaseDoor::DoorGoDown(void) +void CBaseDoor::DoorGoDown(void) { -// { -// bool isReversing; // 765 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 770 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 782 -// Vector(Vector *const this, -// const Vector &v); // 785 -// Vector(Vector *const this, -// const Vector &v); // 783 -// } + bool isReversing = (m_toggle_state == TS_GOING_UP); + + if (!isReversing) + { + if (!(pev->spawnflags & SF_DOOR_SILENT)) + { + if (m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN) + { + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving), VOL_NORM, ATTN_NORM); + } + + TheBots->OnEvent(EVENT_DOOR, m_hActivator); + } + } + +#ifdef DOOR_ASSERT + assert(m_toggle_state == TS_AT_TOP); +#endif // DOOR_ASSERT + + m_toggle_state = TS_GOING_DOWN; + + SetMoveDone(&CBaseDoor::DoorHitBottom); + + //rotating door + if (FClassnameIs(pev, "func_door_rotating")) + { + AngularMove(m_vecAngle1, pev->speed); + } + else + LinearMove(m_vecPosition1, pev->speed); } +// The door has reached the "down" position. Back to quiescence. + /* <694a5> ../cstrike/dlls/doors.cpp:791 */ -NOBODY void CBaseDoor::DoorHitBottom(void) +void CBaseDoor::DoorHitBottom(void) { -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 795 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 796 + if (!(pev->spawnflags & SF_DOOR_SILENT)) + { + STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving)); + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseArrived), VOL_NORM, ATTN_NORM); + } + + assert(m_toggle_state == TS_GOING_DOWN); + m_toggle_state = TS_AT_BOTTOM; + + // Re-instate touch method, cycle is complete + if (pev->spawnflags & SF_DOOR_USE_ONLY) + { + // use only door + SetTouch(NULL); + } + else + { + // touchable door + SetTouch(&CBaseDoor::DoorTouch); + } + + // this isn't finished + SUB_UseTargets(m_hActivator, USE_TOGGLE, 0); + + // Fire the close target (if startopen is set, then "top" is closed) - netname is the close target + if (!FStringNull(pev->netname) && !(pev->spawnflags & SF_DOOR_START_OPEN)) + { + FireTargets(STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0); + } } /* <6a465> ../cstrike/dlls/doors.cpp:817 */ -NOBODY void CBaseDoor::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) +void CBaseDoor::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) { -// { -// edict_t *pentTarget; // 819 -// class CBaseDoor *pDoor; // 820 -// float const checkBlockedInterval; // 827 -// } -// Blocked(CBaseDoor *const this, -// class CBaseEntity *pOther); // 817 + edict_t *pentTarget = NULL; + CBaseDoor *pDoor = NULL; + const float checkBlockedInterval = 0.25f; + + // Hurt the blocker a little. + if (pev->dmg != 0.0f) + { + pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); + } + + if (gpGlobals->time - m_lastBlockedTimestamp < checkBlockedInterval) + { + return; + } + + m_lastBlockedTimestamp = gpGlobals->time; + + // if a door has a negative wait, it would never come back if blocked, + // so let it just squash the object to death real fast + if (m_flWait >= 0) + { + if (m_toggle_state == TS_GOING_DOWN) + { + DoorGoUp(); + } + else + { + DoorGoDown(); + } + } + + // Block all door pieces with the same targetname here. + if (!FStringNull(pev->targetname)) + { + while (true) + { + pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->targetname)); + + if (VARS(pentTarget) != pev) + { + if (FNullEnt(pentTarget)) + break; + + if (FClassnameIs(pentTarget, "func_door") || FClassnameIs(pentTarget, "func_door_rotating")) + { + pDoor = GetClassPtr((CBaseDoor *)VARS(pentTarget)); + + if (pDoor->m_flWait >= 0) + { + if (pDoor->pev->velocity == pev->velocity && pDoor->pev->avelocity == pev->velocity) + { + // this is the most hacked, evil, bastardized thing I've ever seen. kjb + if (FClassnameIs(pentTarget, "func_door")) + { + // set origin to realign normal doors + pDoor->pev->origin = pev->origin; + + // stop! + pDoor->pev->velocity = g_vecZero; + } + else + { + // set angles to realign rotating doors + pDoor->pev->angles = pev->angles; + pDoor->pev->avelocity = g_vecZero; + } + } + + if (!(pev->spawnflags & SF_DOOR_SILENT)) + { + STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving)); + } + + if (pDoor->m_toggle_state == TS_GOING_DOWN) + pDoor->DoorGoUp(); + else + pDoor->DoorGoDown(); + } + } + } + } + } } +// QUAKED FuncRotDoorSpawn (0 .5 .8) ? START_OPEN REVERSE +// DOOR_DONT_LINK TOGGLE X_AXIS Y_AXIS +// if two doors touch, they are assumed to be connected and operate as a unit. + +// TOGGLE causes the door to wait in both the start and end states for a trigger event. + +// START_OPEN causes the door to move to its destination when spawned, +// and operate in reverse. It is used to temporarily or permanently +// close off an area when triggered (not usefull for touch or +// takedamage doors). + +// You need to have an origin brush as part of this entity. The +// center of that brush will be +// the point around which it is rotated. It will rotate around the Z +// axis by default. You can +// check either the X_AXIS or Y_AXIS box to change that. + +// "distance" is how many degrees the door will be rotated. +// "speed" determines how fast the door moves; default value is 100. + +// REVERSE will cause the door to rotate in the opposite direction. + +// "angle" determines the opening direction +// "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door. +// "health" if set, door must be shot open +// "speed" movement speed (100 default) +// "wait" wait before returning (3 default, -1 = never return) +// "dmg" damage to inflict when blocked (2 default) +// "sounds" +// 0) no sound +// 1) stone +// 2) base +// 3) stone chain +// 4) screechy metal + + /* <6a767> ../cstrike/dlls/doors.cpp:943 */ LINK_ENTITY_TO_CLASS(func_door_rotating, CRotDoor); /* <698be> ../cstrike/dlls/doors.cpp:946 */ -NOBODY void CRotDoor::__MAKE_VHOOK(Restart)(void) +void CRotDoor::__MAKE_VHOOK(Restart)(void) { -// operator*(const Vector ::Restart(// float fl); // 953 -// { -// Vector vecSav; // 967 -// operator*(const Vector *const this, -// float fl); // 970 -// } + CBaseToggle::AxisDir(pev); + + if (pev->spawnflags & SF_DOOR_ROTATE_BACKWARDS) + { + pev->movedir = pev->movedir * -1; + } + + if (pev->speed == 0) + pev->speed = 100; + + if (pev->spawnflags & SF_DOOR_START_OPEN) + { + pev->angles = m_vecAngle2; + + Vector vecSav = m_vecAngle1; + m_vecAngle2 = m_vecAngle1; + m_vecAngle1 = vecSav; + + pev->movedir = pev->movedir * -1; + } + + m_toggle_state = TS_AT_BOTTOM; + DoorGoDown(); } /* <69177> ../cstrike/dlls/doors.cpp:978 */ -NOBODY void CRotDoor::__MAKE_VHOOK(Spawn)(void) +void CRotDoor::__MAKE_VHOOK(Spawn)(void) { -// operator*(const class Vector *const this, -// float fl); // 986 -// operator*(const Vector *const this, -// float fl); // 990 -// operator+(const Vector *const this, -// const Vector &v); // 990 -// { -// Vector vecSav; // 1011 -// operator*(const Vector *const this, -// float fl); // 1014 -// } + Precache(); + + // set the axis of rotation + CBaseToggle::AxisDir(pev); + + // check for clockwise rotation + if (pev->spawnflags & SF_DOOR_ROTATE_BACKWARDS) + { + pev->movedir = pev->movedir * -1; + } + + //m_flWait = 2; who the hell did this? (sjb) + m_vecAngle1 = pev->angles; + m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; + + assert(("rotating door start/end positions are equal", m_vecAngle1 != m_vecAngle2)); + + if (pev->spawnflags & SF_DOOR_PASSABLE) + pev->solid = SOLID_NOT; + else + pev->solid = SOLID_BSP; + + pev->movetype = MOVETYPE_PUSH; + + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (pev->speed == 0) + pev->speed = 100; + + // DOOR_START_OPEN is to allow an entity to be lighted in the closed position + // but spawn in the open position + if (pev->spawnflags & SF_DOOR_START_OPEN) + { + // swap pos1 and pos2, put door at pos2, invert movement direction + pev->angles = m_vecAngle2; + + Vector vecSav = m_vecAngle1; + m_vecAngle2 = m_vecAngle1; + m_vecAngle1 = vecSav; + + pev->movedir = pev->movedir * -1; + } + + m_toggle_state = TS_AT_BOTTOM; + + if (pev->spawnflags & SF_DOOR_USE_ONLY) + { + SetTouch(NULL); + } + else + { + // touchable button + SetTouch(&CRotDoor::DoorTouch); + } } /* <68fcc> ../cstrike/dlls/doors.cpp:1028 */ -NOBODY void CRotDoor::__MAKE_VHOOK(SetToggleState)(int state) +void CRotDoor::__MAKE_VHOOK(SetToggleState)(int state) { + if (state == TS_AT_TOP) + pev->angles = m_vecAngle2; + else + pev->angles = m_vecAngle1; + + UTIL_SetOrigin(pev, pev->origin); } /* <6a834> ../cstrike/dlls/doors.cpp:1056 */ @@ -261,48 +978,150 @@ LINK_ENTITY_TO_CLASS(momentary_door, CMomentaryDoor); IMPLEMENT_SAVERESTORE(CMomentaryDoor, CBaseToggle); /* <69001> ../cstrike/dlls/doors.cpp:1065 */ -NOBODY void CMomentaryDoor::__MAKE_VHOOK(Spawn)(void) +void CMomentaryDoor::__MAKE_VHOOK(Spawn)(void) { -// fabs(double __x); // 1082 -// fabs(double __x); // 1082 -// fabs(double __x); // 1082 -// operator*(const Vector *const this, -// float fl); // 1082 -// operator+(const Vector *const this, -// const Vector &v); // 1082 + SetMovedir(pev); + + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (pev->speed == 0) + pev->speed = 100; + + if (pev->dmg == 0) + pev->dmg = 2; + + m_vecPosition1 = pev->origin; + + // Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big + m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs((float_precision)(pev->movedir.x * (pev->size.x - 2))) + fabs((float_precision)(pev->movedir.y * (pev->size.y - 2))) + fabs((float_precision)(pev->movedir.z * (pev->size.z - 2))) - m_flLip)); + assert(("door start/end positions are equal", m_vecPosition1 != m_vecPosition2)); + + if (pev->spawnflags & SF_DOOR_START_OPEN) + { + // swap pos1 and pos2, put door at pos2 + UTIL_SetOrigin(pev, m_vecPosition2); + + m_vecPosition2 = m_vecPosition1; + m_vecPosition1 = pev->origin; + } + + SetTouch(NULL); + Precache(); } /* <68fa5> ../cstrike/dlls/doors.cpp:1096 */ -NOBODY void CMomentaryDoor::__MAKE_VHOOK(Precache)(void) +void CMomentaryDoor::__MAKE_VHOOK(Precache)(void) { + // set the door's "in-motion" sound + switch (m_bMoveSnd) + { + case 0: + pev->noiseMoving = ALLOC_STRING("common/null.wav"); + break; + case 1: + PRECACHE_SOUND("doors/doormove1.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove1.wav"); + break; + case 2: + PRECACHE_SOUND("doors/doormove2.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove2.wav"); + break; + case 3: + PRECACHE_SOUND("doors/doormove3.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove3.wav"); + break; + case 4: + PRECACHE_SOUND("doors/doormove4.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove4.wav"); + break; + case 5: + PRECACHE_SOUND("doors/doormove5.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove5.wav"); + break; + case 6: + PRECACHE_SOUND("doors/doormove6.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove6.wav"); + break; + case 7: + PRECACHE_SOUND("doors/doormove7.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove7.wav"); + break; + case 8: + PRECACHE_SOUND("doors/doormove8.wav"); + pev->noiseMoving = ALLOC_STRING("doors/doormove8.wav"); + break; + default: + pev->noiseMoving = ALLOC_STRING("common/null.wav"); + break; + } } /* <69970> ../cstrike/dlls/doors.cpp:1143 */ -NOBODY void CMomentaryDoor::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CMomentaryDoor::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 1146 -// FStrEq(const char *sz1, -// const char *sz2); // 1151 -// FStrEq(const char *sz1, -// const char *sz2); // 1156 -// KeyValue(CMomentaryDoor *const this, -// KeyValueData *pkvd); // 1143 + if (FStrEq(pkvd->szKeyName, "movesnd")) + { + m_bMoveSnd = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "stopsnd")) + { + //m_bStopSnd =(int) Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "healthvalue")) + { + //m_bHealthValue = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseToggle::KeyValue(pkvd); } /* <6953e> ../cstrike/dlls/doors.cpp:1165 */ -NOBODY void CMomentaryDoor::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CMomentaryDoor::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// Vector move; // 1172 -// Vector delta; // 1174 -// float speed; // 1175 -// } -// Use(CMomentaryDoor *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 1165 + // Momentary buttons will pass down a float in here + if (useType != USE_SET) + { + return; + } + + if (value > 1.0) + value = 1.0; + + Vector move = m_vecPosition1 + (value * (m_vecPosition2 - m_vecPosition1)); + Vector delta = move - pev->origin; + + //float speed = delta.Length() * 10; + + // move there in 0.1 sec + float speed = delta.Length() / 0.1; + + if (speed == 0) + return; + + // This entity only thinks when it moves, so if it's thinking, it's in the process of moving + // play the sound when it starts moving (not yet thinking) + if (pev->nextthink < pev->ltime || pev->nextthink == 0) + { + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving), VOL_NORM, ATTN_NORM); + } +#if 0 + // If we already moving to designated point, return + else if (move == m_vecFinalDest) + { + return; + } + + SetMoveDone(&CMomentaryDoor::DoorMoveDone); +#endif + + LinearMove(move, speed); } #ifdef HOOK_GAMEDLL @@ -321,7 +1140,7 @@ void CBaseDoor::Restart(void) { Restart_(); } - + void CBaseDoor::KeyValue(KeyValueData *pkvd) { KeyValue_(pkvd); diff --git a/regamedll/dlls/doors.h b/regamedll/dlls/doors.h index eed1d0d1..62cbbb5c 100644 --- a/regamedll/dlls/doors.h +++ b/regamedll/dlls/doors.h @@ -48,23 +48,23 @@ #define SF_DOOR_NOMONSTERS 512 // Monster can't open #define SF_DOOR_SILENT 0x80000000 -/* <6840f> ../cstrike/dlls/doors.cpp:34 */ +/* <6840f> ../cstrike/dlls/doors.cpp:34 */ class CBaseDoor: public CBaseToggle { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual void Restart(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void SetToggleState(int state); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual void Blocked(CBaseEntity *pOther); + virtual void SetToggleState(int state); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Blocked(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -86,37 +86,43 @@ public: void Blocked_(CBaseEntity *pOther); #endif // HOOK_GAMEDLL - + public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[7]; public: - NOBODY void EXPORT DoorTouch(CBaseEntity *pOther); - NOBODY int DoorActivate(void); - NOBODY void EXPORT DoorGoUp(void); - NOBODY void EXPORT DoorGoDown(void); - NOBODY void EXPORT DoorHitTop(void); - NOBODY void EXPORT DoorHitBottom(void); + // used to selectivly override defaults + void EXPORT DoorTouch(CBaseEntity *pOther); + int DoorActivate(void); + void EXPORT DoorGoUp(void); + void EXPORT DoorGoDown(void); + void EXPORT DoorHitTop(void); + void EXPORT DoorHitBottom(void); + public: - BYTE m_bHealthValue; - BYTE m_bMoveSnd; - BYTE m_bStopSnd; - locksound_t m_ls; - BYTE m_bLockedSound; + BYTE m_bHealthValue; // some doors are medi-kit doors, they give players health + + BYTE m_bMoveSnd; // sound a door makes while moving + BYTE m_bStopSnd; // sound a door makes when it stops + + locksound_t m_ls; // door lock sounds + + BYTE m_bLockedSound; // ordinals from entity selection BYTE m_bLockedSentence; BYTE m_bUnlockedSound; BYTE m_bUnlockedSentence; + float m_lastBlockedTimestamp; -};/* size: 360, cachelines: 6, members: 11 */ +};/* size: 360, cachelines: 6, members: 11 */ -/* <684c0> ../cstrike/dlls/doors.cpp:935 */ +/* <684c0> ../cstrike/dlls/doors.cpp:935 */ class CRotDoor: public CBaseDoor { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Restart(void); - NOBODY virtual void SetToggleState(int state); + virtual void Spawn(void); + virtual void Restart(void); + virtual void SetToggleState(int state); #ifdef HOOK_GAMEDLL @@ -128,20 +134,20 @@ public: };/* size: 360, cachelines: 6, members: 1 */ -/* <68513> ../cstrike/dlls/doors.cpp:1039 */ +/* <68513> ../cstrike/dlls/doors.cpp:1039 */ class CMomentaryDoor: public CBaseToggle { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -162,11 +168,16 @@ public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; public: - BYTE m_bMoveSnd; + BYTE m_bMoveSnd; // sound a door makes while moving };/* size: 316, cachelines: 5, members: 3 */ +void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); -NOBODY void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); +// linked objects +C_DLLEXPORT void func_door(entvars_t *pev); +C_DLLEXPORT void func_water(entvars_t *pev); +C_DLLEXPORT void func_door_rotating(entvars_t *pev); +C_DLLEXPORT void momentary_door(entvars_t *pev); #endif // DOORS_H diff --git a/regamedll/dlls/effects.cpp b/regamedll/dlls/effects.cpp index 04fa58f3..b9952d3c 100644 --- a/regamedll/dlls/effects.cpp +++ b/regamedll/dlls/effects.cpp @@ -82,31 +82,31 @@ IMPLEMENT_SAVERESTORE(CBubbling, CBaseEntity); /* <7344d> ../cstrike/dlls/effects.cpp:73 */ void CBubbling::__MAKE_VHOOK(Spawn)(void) { - Precache(); - SET_MODEL(ENT(pev), STRING(pev->model)); // Set size - - // Remove model & collisions - pev->solid = SOLID_NOT; - - // The engine won't draw this model if this is set to 0 and blending is on - pev->renderamt = 0; - pev->rendermode = kRenderTransTexture; - - int speed = (pev->speed > 0) ? pev->speed : -pev->speed; - - // HACKHACK!!! - Speed in rendercolor - pev->rendercolor.x = (speed >> 8); - pev->rendercolor.y = (speed & 255); - pev->rendercolor.z = (pev->speed < 0) ? 1 : 0; - - if (!(pev->spawnflags & SF_BUBBLES_STARTOFF)) - { - SetThink(&CBubbling::FizzThink); - - pev->nextthink = gpGlobals->time + 2.0; - m_state = 1; - } - else + Precache(); + SET_MODEL(ENT(pev), STRING(pev->model)); // Set size + + // Remove model & collisions + pev->solid = SOLID_NOT; + + // The engine won't draw this model if this is set to 0 and blending is on + pev->renderamt = 0; + pev->rendermode = kRenderTransTexture; + + int speed = (pev->speed > 0) ? pev->speed : -pev->speed; + + // HACKHACK!!! - Speed in rendercolor + pev->rendercolor.x = (speed >> 8); + pev->rendercolor.y = (speed & 255); + pev->rendercolor.z = (pev->speed < 0) ? 1 : 0; + + if (!(pev->spawnflags & SF_BUBBLES_STARTOFF)) + { + SetThink(&CBubbling::FizzThink); + + pev->nextthink = gpGlobals->time + 2.0; + m_state = 1; + } + else m_state = 0; } @@ -120,56 +120,56 @@ void CBubbling::__MAKE_VHOOK(Precache)(void) /* <742a4> ../cstrike/dlls/effects.cpp:105 */ void CBubbling::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (ShouldToggle(useType, m_state)) - m_state = !m_state; - - if (m_state) - { - SetThink(&CBubbling::FizzThink); - pev->nextthink = gpGlobals->time + 0.1; - } - else - { - SetThink(NULL); - pev->nextthink = 0; + if (ShouldToggle(useType, m_state)) + m_state = !m_state; + + if (m_state) + { + SetThink(&CBubbling::FizzThink); + pev->nextthink = gpGlobals->time + 0.1; + } + else + { + SetThink(NULL); + pev->nextthink = 0; } } /* <74aae> ../cstrike/dlls/effects.cpp:123 */ void CBubbling::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "density")) - { - m_density = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "frequency")) - { - m_frequency = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "current")) - { - pev->speed = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else + if (FStrEq(pkvd->szKeyName, "density")) + { + m_density = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "frequency")) + { + m_frequency = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "current")) + { + pev->speed = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else CBaseEntity::KeyValue(pkvd); } /* <73d03> ../cstrike/dlls/effects.cpp:145 */ void CBubbling::FizzThink(void) { - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, VecBModelOrigin(pev)); - WRITE_BYTE(TE_FIZZ); - WRITE_SHORT(ENTINDEX(edict())); - WRITE_SHORT(m_bubbleModel); - WRITE_BYTE(m_density); - MESSAGE_END(); - - if (m_frequency > 19) - pev->nextthink = gpGlobals->time + 0.5; - else + MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, VecBModelOrigin(pev)); + WRITE_BYTE(TE_FIZZ); + WRITE_SHORT(ENTINDEX(edict())); + WRITE_SHORT(m_bubbleModel); + WRITE_BYTE(m_density); + MESSAGE_END(); + + if (m_frequency > 19) + pev->nextthink = gpGlobals->time + 0.5; + else pev->nextthink = gpGlobals->time + 2.5 - (0.1 * m_frequency); } @@ -180,19 +180,19 @@ LINK_ENTITY_TO_CLASS(beam, CBeam); void CBeam::__MAKE_VHOOK(Spawn)(void) { // Remove model & collisions - pev->solid = SOLID_NOT; + pev->solid = SOLID_NOT; Precache(); } /* <734d6> ../cstrike/dlls/effects.cpp:174 */ void CBeam::__MAKE_VHOOK(Precache)(void) { - if (pev->owner) - { - SetStartEntity(ENTINDEX(pev->owner)); - } - if (pev->aiment) - { + if (pev->owner) + { + SetStartEntity(ENTINDEX(pev->owner)); + } + if (pev->aiment) + { SetEndEntity(ENTINDEX(pev->aiment)); } } @@ -200,14 +200,14 @@ void CBeam::__MAKE_VHOOK(Precache)(void) /* <762d8> ../cstrike/dlls/effects.cpp:182 */ void CBeam::SetStartEntity(int entityIndex) { - pev->sequence = (entityIndex & 0x0FFF) | ((pev->sequence & 0xF000) << 12); + pev->sequence = (entityIndex & 0x0FFF) | ((pev->sequence & 0xF000) << 12); pev->owner = INDEXENT(entityIndex); } /* <76303> ../cstrike/dlls/effects.cpp:188 */ void CBeam::SetEndEntity(int entityIndex) { - pev->skin = (entityIndex & 0x0FFF) | ((pev->skin & 0xF000) << 12); + pev->skin = (entityIndex & 0x0FFF) | ((pev->skin & 0xF000) << 12); pev->aiment = INDEXENT(entityIndex); } @@ -226,35 +226,35 @@ const Vector &CBeam::GetStartPos(void) /* <7639a> ../cstrike/dlls/effects.cpp:207 */ const Vector &CBeam::GetEndPos(void) { - int type = GetType(); - if (type == BEAM_POINTS || type == BEAM_HOSE) - { - return pev->angles; - } - - edict_t *pent = INDEXENT(GetEndEntity()); - if (pent) - { - return pent->v.origin; - } - + int type = GetType(); + if (type == BEAM_POINTS || type == BEAM_HOSE) + { + return pev->angles; + } + + edict_t *pent = INDEXENT(GetEndEntity()); + if (pent) + { + return pent->v.origin; + } + return pev->angles; } /* <76540> ../cstrike/dlls/effects.cpp:222 */ CBeam *CBeam::BeamCreate(const char *pSpriteName, int width) { - // Create a new entity with CBeam private data - CBeam *pBeam = GetClassPtr((CBeam *)NULL); - + // Create a new entity with CBeam private data + CBeam *pBeam = GetClassPtr((CBeam *)NULL); + if (pBeam->pev->classname) - RemoveEntityHashValue(pBeam->pev, STRING(pBeam->pev->classname), CLASSNAME); - - MAKE_STRING_CLASS("beam", pBeam->pev); - AddEntityHashValue(pBeam->pev, STRING(pBeam->pev->classname), CLASSNAME); - - pBeam->BeamInit(pSpriteName, width); - + RemoveEntityHashValue(pBeam->pev, STRING(pBeam->pev->classname), CLASSNAME); + + MAKE_STRING_CLASS("beam", pBeam->pev); + AddEntityHashValue(pBeam->pev, STRING(pBeam->pev->classname), CLASSNAME); + + pBeam->BeamInit(pSpriteName, width); + return pBeam; } @@ -280,114 +280,114 @@ void CBeam::BeamInit(const char *pSpriteName, int width) /* <76a56> ../cstrike/dlls/effects.cpp:251 */ void CBeam::PointsInit(const Vector &start, const Vector &end) { - SetType(BEAM_POINTS); - SetStartPos(start); - SetEndPos(end); - SetStartAttachment(0); - SetEndAttachment(0); + SetType(BEAM_POINTS); + SetStartPos(start); + SetEndPos(end); + SetStartAttachment(0); + SetEndAttachment(0); RelinkBeam(); } /* <7695b> ../cstrike/dlls/effects.cpp:262 */ void CBeam::HoseInit(const Vector &start, const Vector &direction) { - SetType(BEAM_HOSE); - SetStartPos(start); - SetEndPos(direction); - SetStartAttachment(0); - SetEndAttachment(0); + SetType(BEAM_HOSE); + SetStartPos(start); + SetEndPos(direction); + SetStartAttachment(0); + SetEndAttachment(0); RelinkBeam(); } /* <76887> ../cstrike/dlls/effects.cpp:273 */ void CBeam::PointEntInit(const Vector &start, int endIndex) { - SetType(BEAM_ENTPOINT); - SetStartPos(start); - SetEndEntity(endIndex); - SetStartAttachment(0); - SetEndAttachment(0); + SetType(BEAM_ENTPOINT); + SetStartPos(start); + SetEndEntity(endIndex); + SetStartAttachment(0); + SetEndAttachment(0); RelinkBeam(); } /* <767ab> ../cstrike/dlls/effects.cpp:283 */ void CBeam::EntsInit(int startIndex, int endIndex) { - SetType(BEAM_ENTS); - SetStartEntity(startIndex); - SetEndEntity(endIndex); - SetStartAttachment(0); - SetEndAttachment(0); + SetType(BEAM_ENTS); + SetStartEntity(startIndex); + SetEndEntity(endIndex); + SetStartAttachment(0); + SetEndAttachment(0); RelinkBeam(); } /* <7663a> ../cstrike/dlls/effects.cpp:294 */ void CBeam::RelinkBeam(void) { - const Vector &startPos = GetStartPos(); - const Vector &endPos = GetEndPos(); - - pev->mins.x = _min(startPos.x, endPos.x); - pev->mins.y = _min(startPos.y, endPos.y); - pev->mins.z = _min(startPos.z, endPos.z); - - pev->maxs.x = _max(startPos.x, endPos.x); - pev->maxs.y = _max(startPos.y, endPos.y); - pev->maxs.z = _max(startPos.z, endPos.z); - - pev->mins = pev->mins - pev->origin; - pev->maxs = pev->maxs - pev->origin; - - UTIL_SetSize(pev, pev->mins, pev->maxs); + const Vector &startPos = GetStartPos(); + const Vector &endPos = GetEndPos(); + + pev->mins.x = Q_min(startPos.x, endPos.x); + pev->mins.y = Q_min(startPos.y, endPos.y); + pev->mins.z = Q_min(startPos.z, endPos.z); + + pev->maxs.x = Q_max(startPos.x, endPos.x); + pev->maxs.y = Q_max(startPos.y, endPos.y); + pev->maxs.z = Q_max(startPos.z, endPos.z); + + pev->mins = pev->mins - pev->origin; + pev->maxs = pev->maxs - pev->origin; + + UTIL_SetSize(pev, pev->mins, pev->maxs); UTIL_SetOrigin(pev, pev->origin); } /* <77305> ../cstrike/dlls/effects.cpp:311 */ void CBeam::TriggerTouch(CBaseEntity *pOther) { - if (pOther->pev->flags & (FL_CLIENT | FL_MONSTER)) - { - if (pev->owner) - { - CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); - pOwner->Use(pOther, this, USE_TOGGLE, 0); - } - ALERT(at_console, "Firing targets!!!\n"); + if (pOther->pev->flags & (FL_CLIENT | FL_MONSTER)) + { + if (pev->owner) + { + CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); + pOwner->Use(pOther, this, USE_TOGGLE, 0); + } + ALERT(at_console, "Firing targets!!!\n"); } } /* <773e2> ../cstrike/dlls/effects.cpp:325 */ CBaseEntity *CBeam::RandomTargetname(const char *szName) { - int total = 0; - - CBaseEntity *pEntity = NULL; - CBaseEntity *pNewEntity = NULL; - - while ((pNewEntity = UTIL_FindEntityByTargetname(pNewEntity, szName)) != NULL) - { - total++; - - if (RANDOM_LONG(0, total - 1) < 1) - pEntity = pNewEntity; - } - + int total = 0; + + CBaseEntity *pEntity = NULL; + CBaseEntity *pNewEntity = NULL; + + while ((pNewEntity = UTIL_FindEntityByTargetname(pNewEntity, szName)) != NULL) + { + total++; + + if (RANDOM_LONG(0, total - 1) < 1) + pEntity = pNewEntity; + } + return pEntity; } /* <77431> ../cstrike/dlls/effects.cpp:341 */ void CBeam::DoSparks(const Vector &start, const Vector &end) { - if (pev->spawnflags & (SF_BEAM_SPARKSTART | SF_BEAM_SPARKEND)) - { - if (pev->spawnflags & SF_BEAM_SPARKSTART) - { - UTIL_Sparks(start); - } - if (pev->spawnflags & SF_BEAM_SPARKEND) - { - UTIL_Sparks(end); - } + if (pev->spawnflags & (SF_BEAM_SPARKSTART | SF_BEAM_SPARKEND)) + { + if (pev->spawnflags & SF_BEAM_SPARKSTART) + { + UTIL_Sparks(start); + } + if (pev->spawnflags & SF_BEAM_SPARKEND) + { + UTIL_Sparks(end); + } } } @@ -403,363 +403,363 @@ IMPLEMENT_SAVERESTORE(CLightning, CBeam); /* <744b2> ../cstrike/dlls/effects.cpp:444 */ void CLightning::__MAKE_VHOOK(Spawn)(void) { - if (FStringNull(m_iszSpriteName)) - { - SetThink(&CLightning::SUB_Remove); - return; - } - - // Remove model & collisions - pev->solid = SOLID_NOT; - Precache(); - - pev->dmgtime = gpGlobals->time; - - if (ServerSide()) - { - SetThink(NULL); - if (pev->dmg > 0) - { - SetThink(&CLightning::DamageThink); - pev->nextthink = gpGlobals->time + 0.1f; - } - if (pev->targetname) - { - if (!(pev->spawnflags & SF_BEAM_STARTON)) - { - pev->effects = EF_NODRAW; - m_active = 0; - pev->nextthink = 0; - } - else - m_active = 1; - - SetUse(&CLightning::ToggleUse); - } - } - else - { - m_active = 0; - if (!FStringNull(pev->targetname)) - { - SetUse(&CLightning::StrikeUse); - } - if (FStringNull(pev->targetname) || (pev->spawnflags & SF_BEAM_STARTON)) - { - SetThink(&CLightning::StrikeThink); - pev->nextthink = gpGlobals->time + 1.0f; - } + if (FStringNull(m_iszSpriteName)) + { + SetThink(&CLightning::SUB_Remove); + return; + } + + // Remove model & collisions + pev->solid = SOLID_NOT; + Precache(); + + pev->dmgtime = gpGlobals->time; + + if (ServerSide()) + { + SetThink(NULL); + if (pev->dmg > 0) + { + SetThink(&CLightning::DamageThink); + pev->nextthink = gpGlobals->time + 0.1f; + } + if (pev->targetname) + { + if (!(pev->spawnflags & SF_BEAM_STARTON)) + { + pev->effects = EF_NODRAW; + m_active = 0; + pev->nextthink = 0; + } + else + m_active = 1; + + SetUse(&CLightning::ToggleUse); + } + } + else + { + m_active = 0; + if (!FStringNull(pev->targetname)) + { + SetUse(&CLightning::StrikeUse); + } + if (FStringNull(pev->targetname) || (pev->spawnflags & SF_BEAM_STARTON)) + { + SetThink(&CLightning::StrikeThink); + pev->nextthink = gpGlobals->time + 1.0f; + } } } /* <7357f> ../cstrike/dlls/effects.cpp:493 */ void CLightning::__MAKE_VHOOK(Precache)(void) { - m_spriteTexture = PRECACHE_MODEL((char *)STRING(m_iszSpriteName)); + m_spriteTexture = PRECACHE_MODEL((char *)STRING(m_iszSpriteName)); CBeam::Precache(); } /* <786a1> ../cstrike/dlls/effects.cpp:500 */ void CLightning::__MAKE_VHOOK(Activate)(void) { - if (ServerSide()) + if (ServerSide()) BeamUpdateVars(); } /* <7536c> ../cstrike/dlls/effects.cpp:507 */ void CLightning::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "LightningStart")) - { - m_iszStartEntity = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "LightningEnd")) - { - m_iszEndEntity = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "life")) - { - m_life = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "BoltWidth")) - { - m_boltWidth = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude")) - { - m_noiseAmplitude = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "TextureScroll")) - { - m_speed = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "StrikeTime")) - { - m_restrike = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "texture")) - { - m_iszSpriteName = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "framestart")) - { - m_frameStart = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "Radius")) - { - m_radius = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "damage")) - { - pev->dmg = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else + if (FStrEq(pkvd->szKeyName, "LightningStart")) + { + m_iszStartEntity = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "LightningEnd")) + { + m_iszEndEntity = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "life")) + { + m_life = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "BoltWidth")) + { + m_boltWidth = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "NoiseAmplitude")) + { + m_noiseAmplitude = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "TextureScroll")) + { + m_speed = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "StrikeTime")) + { + m_restrike = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "texture")) + { + m_iszSpriteName = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "framestart")) + { + m_frameStart = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "Radius")) + { + m_radius = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "damage")) + { + pev->dmg = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else CBeam::KeyValue(pkvd); } /* <75ad3> ../cstrike/dlls/effects.cpp:569 */ void CLightning::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (!ShouldToggle(useType, m_active)) - return; - - if (m_active) - { - m_active = 0; - pev->effects |= EF_NODRAW; - pev->nextthink = 0; - } - else - { - m_active = 1; - pev->effects &= ~EF_NODRAW; - DoSparks(GetStartPos(), GetEndPos()); - - if (pev->dmg > 0) - { - pev->nextthink = gpGlobals->time; - pev->dmgtime = gpGlobals->time; - } + if (!ShouldToggle(useType, m_active)) + return; + + if (m_active) + { + m_active = 0; + pev->effects |= EF_NODRAW; + pev->nextthink = 0; + } + else + { + m_active = 1; + pev->effects &= ~EF_NODRAW; + DoSparks(GetStartPos(), GetEndPos()); + + if (pev->dmg > 0) + { + pev->nextthink = gpGlobals->time; + pev->dmgtime = gpGlobals->time; + } } } /* <7422d> ../cstrike/dlls/effects.cpp:593 */ void CLightning::StrikeUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (!ShouldToggle(useType, m_active)) - return; - - if (m_active) - { - m_active = 0; - SetThink(NULL); - } - else - { - SetThink(&CLightning::StrikeThink); - pev->nextthink = gpGlobals->time + 0.1f; - } - - if (!(pev->spawnflags & SF_BEAM_TOGGLE)) + if (!ShouldToggle(useType, m_active)) + return; + + if (m_active) + { + m_active = 0; + SetThink(NULL); + } + else + { + SetThink(&CLightning::StrikeThink); + pev->nextthink = gpGlobals->time + 0.1f; + } + + if (!(pev->spawnflags & SF_BEAM_TOGGLE)) SetUse(NULL); } /* <71e66> ../cstrike/dlls/effects.cpp:614 */ int IsPointEntity(CBaseEntity *pEnt) { - if (!pEnt->pev->modelindex) - return 1; - - if (FClassnameIs(pEnt->pev, "info_target") || FClassnameIs(pEnt->pev, "info_landmark") || FClassnameIs(pEnt->pev, "path_corner")) - { - return 1; - } + if (!pEnt->pev->modelindex) + return 1; + + if (FClassnameIs(pEnt->pev, "info_target") || FClassnameIs(pEnt->pev, "info_landmark") || FClassnameIs(pEnt->pev, "path_corner")) + { + return 1; + } return 0; } /* <77f64> ../cstrike/dlls/effects.cpp:625 */ void CLightning::StrikeThink(void) { - if (m_life != 0.0f) - { - if (pev->spawnflags & SF_BEAM_RANDOM) - pev->nextthink = gpGlobals->time + m_life + RANDOM_FLOAT(0, m_restrike); - else - pev->nextthink = gpGlobals->time + m_life + m_restrike; - } - m_active = 1; - - if (FStringNull(m_iszEndEntity)) - { - if (FStringNull(m_iszStartEntity)) - { - RandomArea(); - } - else - { - CBaseEntity *pStart = RandomTargetname(STRING(m_iszStartEntity)); - if (pStart != NULL) - RandomPoint(pStart->pev->origin); - else - ALERT(at_console, "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity)); - } - return; - } - - CBaseEntity *pStart = RandomTargetname(STRING(m_iszStartEntity)); - CBaseEntity *pEnd = RandomTargetname(STRING(m_iszEndEntity)); - - if (pStart != NULL && pEnd != NULL) - { - if (IsPointEntity(pStart) || IsPointEntity(pEnd)) - { - if (pev->spawnflags & SF_BEAM_RING) - { - // don't work - return; - } - } - - MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); - - if (IsPointEntity(pStart) || IsPointEntity(pEnd)) - { - // One point entity must be in pEnd - if (!IsPointEntity(pEnd)) - { - CBaseEntity *pTemp; - pTemp = pStart; - pStart = pEnd; - pEnd = pTemp; - } - - // One sided - if (!IsPointEntity(pStart)) - { - WRITE_BYTE(TE_BEAMENTPOINT); - WRITE_SHORT(pStart->entindex()); - WRITE_COORD(pEnd->pev->origin.x); - WRITE_COORD(pEnd->pev->origin.y); - WRITE_COORD(pEnd->pev->origin.z); - } - else - { - WRITE_BYTE(TE_BEAMPOINTS); - WRITE_COORD(pStart->pev->origin.x); - WRITE_COORD(pStart->pev->origin.y); - WRITE_COORD(pStart->pev->origin.z); - WRITE_COORD(pEnd->pev->origin.x); - WRITE_COORD(pEnd->pev->origin.y); - WRITE_COORD(pEnd->pev->origin.z); - } - - - } - else - { - if (pev->spawnflags & SF_BEAM_RING) - WRITE_BYTE(TE_BEAMRING); - else - WRITE_BYTE(TE_BEAMENTS); - WRITE_SHORT(pStart->entindex()); - WRITE_SHORT(pEnd->entindex()); - } - - WRITE_SHORT(m_spriteTexture); - WRITE_BYTE(m_frameStart); // framestart - WRITE_BYTE((int)pev->framerate); // framerate - WRITE_BYTE((int)(m_life*10.0)); // life - WRITE_BYTE(m_boltWidth); // width - WRITE_BYTE(m_noiseAmplitude); // noise - WRITE_BYTE((int)pev->rendercolor.x); // r, g, b - WRITE_BYTE((int)pev->rendercolor.y); // r, g, b - WRITE_BYTE((int)pev->rendercolor.z); // r, g, b - WRITE_BYTE(pev->renderamt); // brightness - WRITE_BYTE(m_speed); // speed - MESSAGE_END(); - - DoSparks(pStart->pev->origin, pEnd->pev->origin); - - if (pev->dmg > 0) - { - TraceResult tr; - UTIL_TraceLine(pStart->pev->origin, pEnd->pev->origin, dont_ignore_monsters, NULL, &tr); - BeamDamageInstant(&tr, pev->dmg); - } + if (m_life != 0.0f) + { + if (pev->spawnflags & SF_BEAM_RANDOM) + pev->nextthink = gpGlobals->time + m_life + RANDOM_FLOAT(0, m_restrike); + else + pev->nextthink = gpGlobals->time + m_life + m_restrike; + } + m_active = 1; + + if (FStringNull(m_iszEndEntity)) + { + if (FStringNull(m_iszStartEntity)) + { + RandomArea(); + } + else + { + CBaseEntity *pStart = RandomTargetname(STRING(m_iszStartEntity)); + if (pStart != NULL) + RandomPoint(pStart->pev->origin); + else + ALERT(at_console, "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity)); + } + return; + } + + CBaseEntity *pStart = RandomTargetname(STRING(m_iszStartEntity)); + CBaseEntity *pEnd = RandomTargetname(STRING(m_iszEndEntity)); + + if (pStart != NULL && pEnd != NULL) + { + if (IsPointEntity(pStart) || IsPointEntity(pEnd)) + { + if (pev->spawnflags & SF_BEAM_RING) + { + // don't work + return; + } + } + + MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); + + if (IsPointEntity(pStart) || IsPointEntity(pEnd)) + { + // One point entity must be in pEnd + if (!IsPointEntity(pEnd)) + { + CBaseEntity *pTemp; + pTemp = pStart; + pStart = pEnd; + pEnd = pTemp; + } + + // One sided + if (!IsPointEntity(pStart)) + { + WRITE_BYTE(TE_BEAMENTPOINT); + WRITE_SHORT(pStart->entindex()); + WRITE_COORD(pEnd->pev->origin.x); + WRITE_COORD(pEnd->pev->origin.y); + WRITE_COORD(pEnd->pev->origin.z); + } + else + { + WRITE_BYTE(TE_BEAMPOINTS); + WRITE_COORD(pStart->pev->origin.x); + WRITE_COORD(pStart->pev->origin.y); + WRITE_COORD(pStart->pev->origin.z); + WRITE_COORD(pEnd->pev->origin.x); + WRITE_COORD(pEnd->pev->origin.y); + WRITE_COORD(pEnd->pev->origin.z); + } + + + } + else + { + if (pev->spawnflags & SF_BEAM_RING) + WRITE_BYTE(TE_BEAMRING); + else + WRITE_BYTE(TE_BEAMENTS); + WRITE_SHORT(pStart->entindex()); + WRITE_SHORT(pEnd->entindex()); + } + + WRITE_SHORT(m_spriteTexture); + WRITE_BYTE(m_frameStart); // framestart + WRITE_BYTE((int)pev->framerate); // framerate + WRITE_BYTE((int)(m_life*10.0)); // life + WRITE_BYTE(m_boltWidth); // width + WRITE_BYTE(m_noiseAmplitude); // noise + WRITE_BYTE((int)pev->rendercolor.x); // r, g, b + WRITE_BYTE((int)pev->rendercolor.y); // r, g, b + WRITE_BYTE((int)pev->rendercolor.z); // r, g, b + WRITE_BYTE(pev->renderamt); // brightness + WRITE_BYTE(m_speed); // speed + MESSAGE_END(); + + DoSparks(pStart->pev->origin, pEnd->pev->origin); + + if (pev->dmg > 0) + { + TraceResult tr; + UTIL_TraceLine(pStart->pev->origin, pEnd->pev->origin, dont_ignore_monsters, NULL, &tr); + BeamDamageInstant(&tr, pev->dmg); + } } } /* <77680> ../cstrike/dlls/effects.cpp:731 */ void CBeam::BeamDamage(TraceResult *ptr) { - RelinkBeam(); - - if (ptr->flFraction != 1.0f && ptr->pHit != NULL) - { - CBaseEntity *pHit = CBaseEntity::Instance(ptr->pHit); - - if (pHit != NULL) - { - ClearMultiDamage(); - pHit->TraceAttack(pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM); - ApplyMultiDamage(pev, pev); - - if (pev->spawnflags & SF_BEAM_DECALS) - { - if (pHit->IsBSPModel()) - { - UTIL_DecalTrace(ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0, 4)); - } - } - } - } - + RelinkBeam(); + + if (ptr->flFraction != 1.0f && ptr->pHit != NULL) + { + CBaseEntity *pHit = CBaseEntity::Instance(ptr->pHit); + + if (pHit != NULL) + { + ClearMultiDamage(); + pHit->TraceAttack(pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM); + ApplyMultiDamage(pev, pev); + + if (pev->spawnflags & SF_BEAM_DECALS) + { + if (pHit->IsBSPModel()) + { + UTIL_DecalTrace(ptr, DECAL_BIGSHOT1 + RANDOM_LONG(0, 4)); + } + } + } + } + pev->dmgtime = gpGlobals->time; } /* <777dd> ../cstrike/dlls/effects.cpp:753 */ void CLightning::DamageThink(void) { - pev->nextthink = gpGlobals->time + 0.1; - - TraceResult tr; - UTIL_TraceLine(GetStartPos(), GetEndPos(), dont_ignore_monsters, NULL, &tr); + pev->nextthink = gpGlobals->time + 0.1; + + TraceResult tr; + UTIL_TraceLine(GetStartPos(), GetEndPos(), dont_ignore_monsters, NULL, &tr); BeamDamage(&tr); } /* <77a90> ../cstrike/dlls/effects.cpp:763 */ void CLightning::Zap(const Vector &vecSrc, const Vector &vecDest) { - MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); - WRITE_BYTE(TE_BEAMPOINTS); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z); - WRITE_COORD(vecDest.x); - WRITE_COORD(vecDest.y); - WRITE_COORD(vecDest.z); - WRITE_SHORT(m_spriteTexture); - WRITE_BYTE(m_frameStart); // framestart - WRITE_BYTE((int)pev->framerate); // framerate - WRITE_BYTE((int)(m_life * 10.0)); // life - WRITE_BYTE(m_boltWidth); // width - WRITE_BYTE(m_noiseAmplitude); // noise - WRITE_BYTE((int)pev->rendercolor.x); // r, g, b - WRITE_BYTE((int)pev->rendercolor.y); // r, g, b - WRITE_BYTE((int)pev->rendercolor.z); // r, g, b - WRITE_BYTE((int)pev->renderamt); // brightness - WRITE_BYTE(m_speed); // speed + MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); + WRITE_BYTE(TE_BEAMPOINTS); + WRITE_COORD(vecSrc.x); + WRITE_COORD(vecSrc.y); + WRITE_COORD(vecSrc.z); + WRITE_COORD(vecDest.x); + WRITE_COORD(vecDest.y); + WRITE_COORD(vecDest.z); + WRITE_SHORT(m_spriteTexture); + WRITE_BYTE(m_frameStart); // framestart + WRITE_BYTE((int)pev->framerate); // framerate + WRITE_BYTE((int)(m_life * 10.0)); // life + WRITE_BYTE(m_boltWidth); // width + WRITE_BYTE(m_noiseAmplitude); // noise + WRITE_BYTE((int)pev->rendercolor.x); // r, g, b + WRITE_BYTE((int)pev->rendercolor.y); // r, g, b + WRITE_BYTE((int)pev->rendercolor.z); // r, g, b + WRITE_BYTE((int)pev->renderamt); // brightness + WRITE_BYTE(m_speed); // speed MESSAGE_END(); DoSparks(vecSrc, vecDest); @@ -767,140 +767,140 @@ void CLightning::Zap(const Vector &vecSrc, const Vector &vecDest) /* <77b45> ../cstrike/dlls/effects.cpp:789 */ void CLightning::RandomArea(void) -{ - for (int iLoops = 0; iLoops < 10; iLoops++) - { - Vector vecSrc = pev->origin; - Vector vecDir1 = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1)); - vecDir1 = vecDir1.Normalize(); - - TraceResult tr1; - UTIL_TraceLine(vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1); - - if (tr1.flFraction == 1.0f) - continue; - - Vector vecDir2; - do - { - vecDir2 = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1)); - } - while (DotProduct(vecDir1, vecDir2) > 0); - - vecDir2 = vecDir2.Normalize(); - - TraceResult tr2; - UTIL_TraceLine(vecSrc, vecSrc + vecDir2 * m_radius, ignore_monsters, ENT(pev), &tr2); - - if (tr2.flFraction == 1.0f) - continue; - - if ((tr1.vecEndPos - tr2.vecEndPos).Length() < m_radius * 0.1f) - continue; - - UTIL_TraceLine(tr1.vecEndPos, tr2.vecEndPos, ignore_monsters, ENT(pev), &tr2); - - if (tr2.flFraction != 1.0f) - continue; - - Zap(tr1.vecEndPos, tr2.vecEndPos); - break; +{ + for (int iLoops = 0; iLoops < 10; iLoops++) + { + Vector vecSrc = pev->origin; + Vector vecDir1 = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1)); + vecDir1 = vecDir1.Normalize(); + + TraceResult tr1; + UTIL_TraceLine(vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1); + + if (tr1.flFraction == 1.0f) + continue; + + Vector vecDir2; + do + { + vecDir2 = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1)); + } + while (DotProduct(vecDir1, vecDir2) > 0); + + vecDir2 = vecDir2.Normalize(); + + TraceResult tr2; + UTIL_TraceLine(vecSrc, vecSrc + vecDir2 * m_radius, ignore_monsters, ENT(pev), &tr2); + + if (tr2.flFraction == 1.0f) + continue; + + if ((tr1.vecEndPos - tr2.vecEndPos).Length() < m_radius * 0.1f) + continue; + + UTIL_TraceLine(tr1.vecEndPos, tr2.vecEndPos, ignore_monsters, ENT(pev), &tr2); + + if (tr2.flFraction != 1.0f) + continue; + + Zap(tr1.vecEndPos, tr2.vecEndPos); + break; } } /* <77de8> ../cstrike/dlls/effects.cpp:831 */ void CLightning::RandomPoint(Vector &vecSrc) { - int iLoops = 0; - - for (iLoops = 0; iLoops < 10; iLoops++) - { - Vector vecDir1 = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1)); - vecDir1 = vecDir1.Normalize(); - - TraceResult tr1; - UTIL_TraceLine(vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1); - - if ((tr1.vecEndPos - vecSrc).Length() < m_radius * 0.1f) - continue; - - if (tr1.flFraction == 1.0f) - continue; - - Zap(vecSrc, tr1.vecEndPos); - break; + int iLoops = 0; + + for (iLoops = 0; iLoops < 10; iLoops++) + { + Vector vecDir1 = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1)); + vecDir1 = vecDir1.Normalize(); + + TraceResult tr1; + UTIL_TraceLine(vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1); + + if ((tr1.vecEndPos - vecSrc).Length() < m_radius * 0.1f) + continue; + + if (tr1.flFraction == 1.0f) + continue; + + Zap(vecSrc, tr1.vecEndPos); + break; } } /* <78313> ../cstrike/dlls/effects.cpp:855 */ void CLightning::BeamUpdateVars(void) { - int beamType; - int pointStart, pointEnd; - - edict_t *pStart = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszStartEntity)); - edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEndEntity)); - - pointStart = IsPointEntity(CBaseEntity::Instance(pStart)); - pointEnd = IsPointEntity(CBaseEntity::Instance(pEnd)); - - pev->skin = 0; - pev->sequence = 0; - pev->rendermode = 0; - pev->flags |= FL_CUSTOMENTITY; - pev->model = m_iszSpriteName; - SetTexture(m_spriteTexture); - - beamType = BEAM_ENTS; - if (pointStart || pointEnd) - { - // One point entity must be in pStart - if (!pointStart) - { - edict_t *pTemp; - // Swap start & end - pTemp = pStart; - pStart = pEnd; - pEnd = pTemp; - - int swap = pointStart; - pointStart = pointEnd; - pointEnd = swap; - } - if (!pointEnd) - beamType = BEAM_ENTPOINT; - else - beamType = BEAM_POINTS; - } - - SetType(beamType); - if (beamType == BEAM_POINTS || beamType == BEAM_ENTPOINT || beamType == BEAM_HOSE) - { - SetStartPos(pStart->v.origin); - - if (beamType == BEAM_POINTS || beamType == BEAM_HOSE) - SetEndPos(pEnd->v.origin); - else - SetEndEntity(ENTINDEX(pEnd)); - } - else - { - SetStartEntity(ENTINDEX(pStart)); - SetEndEntity(ENTINDEX(pEnd)); - } - - RelinkBeam(); - - SetWidth(m_boltWidth); - SetNoise(m_noiseAmplitude); - SetFrame(m_frameStart); - SetScrollRate(m_speed); - - if (pev->spawnflags & SF_BEAM_SHADEIN) - { - SetFlags(BEAM_FSHADEIN); - } - else if (pev->spawnflags & SF_BEAM_SHADEOUT) + int beamType; + int pointStart, pointEnd; + + edict_t *pStart = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszStartEntity)); + edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEndEntity)); + + pointStart = IsPointEntity(CBaseEntity::Instance(pStart)); + pointEnd = IsPointEntity(CBaseEntity::Instance(pEnd)); + + pev->skin = 0; + pev->sequence = 0; + pev->rendermode = 0; + pev->flags |= FL_CUSTOMENTITY; + pev->model = m_iszSpriteName; + SetTexture(m_spriteTexture); + + beamType = BEAM_ENTS; + if (pointStart || pointEnd) + { + // One point entity must be in pStart + if (!pointStart) + { + edict_t *pTemp; + // Swap start & end + pTemp = pStart; + pStart = pEnd; + pEnd = pTemp; + + int swap = pointStart; + pointStart = pointEnd; + pointEnd = swap; + } + if (!pointEnd) + beamType = BEAM_ENTPOINT; + else + beamType = BEAM_POINTS; + } + + SetType(beamType); + if (beamType == BEAM_POINTS || beamType == BEAM_ENTPOINT || beamType == BEAM_HOSE) + { + SetStartPos(pStart->v.origin); + + if (beamType == BEAM_POINTS || beamType == BEAM_HOSE) + SetEndPos(pEnd->v.origin); + else + SetEndEntity(ENTINDEX(pEnd)); + } + else + { + SetStartEntity(ENTINDEX(pStart)); + SetEndEntity(ENTINDEX(pEnd)); + } + + RelinkBeam(); + + SetWidth(m_boltWidth); + SetNoise(m_noiseAmplitude); + SetFrame(m_frameStart); + SetScrollRate(m_speed); + + if (pev->spawnflags & SF_BEAM_SHADEIN) + { + SetFlags(BEAM_FSHADEIN); + } + else if (pev->spawnflags & SF_BEAM_SHADEOUT) { SetFlags(BEAM_FSHADEOUT); } @@ -915,41 +915,41 @@ IMPLEMENT_SAVERESTORE(CLaser, CBeam); /* <76b3f> ../cstrike/dlls/effects.cpp:931 */ void CLaser::__MAKE_VHOOK(Spawn)(void) { - if (FStringNull(pev->model)) - { - SetThink(&CLaser::SUB_Remove); - return; - } - - // Remove model & collisions - pev->solid = SOLID_NOT; - Precache(); - - SetThink(&CLaser::StrikeThink); - pev->flags |= FL_CUSTOMENTITY; - - PointsInit(pev->origin, pev->origin); - - if (!m_pSprite && m_iszSpriteName) - m_pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteName), pev->origin, TRUE); - else - m_pSprite = NULL; - - if (m_pSprite) - m_pSprite->SetTransparency(kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx); - - if (pev->targetname && !(pev->spawnflags & SF_BEAM_STARTON)) - TurnOff(); - else + if (FStringNull(pev->model)) + { + SetThink(&CLaser::SUB_Remove); + return; + } + + // Remove model & collisions + pev->solid = SOLID_NOT; + Precache(); + + SetThink(&CLaser::StrikeThink); + pev->flags |= FL_CUSTOMENTITY; + + PointsInit(pev->origin, pev->origin); + + if (!m_pSprite && m_iszSpriteName) + m_pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteName), pev->origin, TRUE); + else + m_pSprite = NULL; + + if (m_pSprite) + m_pSprite->SetTransparency(kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx); + + if (pev->targetname && !(pev->spawnflags & SF_BEAM_STARTON)) + TurnOff(); + else TurnOn(); } /* <73d82> ../cstrike/dlls/effects.cpp:960 */ void CLaser::__MAKE_VHOOK(Precache)(void) { - pev->modelindex = PRECACHE_MODEL((char *)STRING(pev->model)); - - if (m_iszSpriteName) + pev->modelindex = PRECACHE_MODEL((char *)STRING(pev->model)); + + if (m_iszSpriteName) { PRECACHE_MODEL((char *)STRING(m_iszSpriteName)); } @@ -1018,7 +1018,9 @@ void CLaser::TurnOff(void) pev->nextthink = 0; if (m_pSprite) + { m_pSprite->TurnOff(); + } } /* <78804> ../cstrike/dlls/effects.cpp:1032 */ @@ -1027,7 +1029,9 @@ void CLaser::TurnOn(void) pev->effects &= ~EF_NODRAW; if (m_pSprite) + { m_pSprite->TurnOn(); + } pev->dmgtime = gpGlobals->time; pev->nextthink = gpGlobals->time; @@ -1082,37 +1086,37 @@ IMPLEMENT_SAVERESTORE(CGlow, CPointEntity); /* <735a6> ../cstrike/dlls/effects.cpp:1109 */ void CGlow::__MAKE_VHOOK(Spawn)(void) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; - - PRECACHE_MODEL((char *)STRING(pev->model)); - SET_MODEL(ENT(pev), STRING(pev->model)); - - m_maxFrame = (float)MODEL_FRAMES(pev->modelindex) - 1; - - if (m_maxFrame > 1.0f && pev->framerate != 0.0f) - { - pev->nextthink = gpGlobals->time + 0.1f; - } - + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; + + PRECACHE_MODEL((char *)STRING(pev->model)); + SET_MODEL(ENT(pev), STRING(pev->model)); + + m_maxFrame = (float)MODEL_FRAMES(pev->modelindex) - 1; + + if (m_maxFrame > 1.0f && pev->framerate != 0.0f) + { + pev->nextthink = gpGlobals->time + 0.1f; + } + m_lastTime = gpGlobals->time; } /* <74606> ../cstrike/dlls/effects.cpp:1127 */ void CGlow::__MAKE_VHOOK(Think)(void) { - Animate(pev->framerate * (gpGlobals->time - m_lastTime)); - - pev->nextthink = gpGlobals->time + 0.1f; + Animate(pev->framerate * (gpGlobals->time - m_lastTime)); + + pev->nextthink = gpGlobals->time + 0.1f; m_lastTime = gpGlobals->time; } /* <78a1f> ../cstrike/dlls/effects.cpp:1136 */ void CGlow::Animate(float frames) { - if (m_maxFrame > 0) + if (m_maxFrame > 0) pev->frame = fmod((float_precision)(pev->frame + frames), (float_precision)m_maxFrame); } @@ -1180,25 +1184,25 @@ IMPLEMENT_SAVERESTORE(CSprite, CPointEntity); /* <75dc8> ../cstrike/dlls/effects.cpp:1236 */ void CSprite::__MAKE_VHOOK(Spawn)(void) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; - - Precache(); - SET_MODEL(ENT(pev), STRING(pev->model)); - m_maxFrame = (float)MODEL_FRAMES(pev->modelindex) - 1; - - if (pev->targetname && !(pev->spawnflags & SF_SPRITE_STARTON)) - TurnOff(); - else - TurnOn(); - - // Worldcraft only sets y rotation, copy to Z - if (pev->angles.y != 0.0f && pev->angles.z == 0.0f) - { - pev->angles.z = pev->angles.y; - pev->angles.y = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; + + Precache(); + SET_MODEL(ENT(pev), STRING(pev->model)); + m_maxFrame = (float)MODEL_FRAMES(pev->modelindex) - 1; + + if (pev->targetname && !(pev->spawnflags & SF_SPRITE_STARTON)) + TurnOff(); + else + TurnOn(); + + // Worldcraft only sets y rotation, copy to Z + if (pev->angles.y != 0.0f && pev->angles.z == 0.0f) + { + pev->angles.z = pev->angles.y; + pev->angles.y = 0; } } @@ -1235,8 +1239,8 @@ void CSprite::__MAKE_VHOOK(Precache)(void) /* <78bea> ../cstrike/dlls/effects.cpp:1289 */ void CSprite::SpriteInit(const char *pSpriteName, const Vector &origin) { - pev->model = MAKE_STRING(pSpriteName); - pev->origin = origin; + pev->model = MAKE_STRING(pSpriteName); + pev->origin = origin; Spawn(); } @@ -1376,156 +1380,156 @@ LINK_ENTITY_TO_CLASS(gibshooter, CGibShooter); /* <73dbb> ../cstrike/dlls/effects.cpp:1452 */ void CGibShooter::__MAKE_VHOOK(Precache)(void) { - if (g_Language == LANGUAGE_GERMAN) - { - m_iGibModelIndex = PRECACHE_MODEL("models/germanygibs.mdl"); - } - else - { - m_iGibModelIndex = PRECACHE_MODEL("models/hgibs.mdl"); + if (g_Language == LANGUAGE_GERMAN) + { + m_iGibModelIndex = PRECACHE_MODEL("models/germanygibs.mdl"); + } + else + { + m_iGibModelIndex = PRECACHE_MODEL("models/hgibs.mdl"); } } /* <74886> ../cstrike/dlls/effects.cpp:1465 */ void CGibShooter::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "m_iGibs")) - { - m_iGibs = m_iGibCapacity = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "m_flVelocity")) - { - m_flGibVelocity = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "m_flVariance")) - { - m_flVariance = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "m_flGibLife")) - { - m_flGibLife = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else + if (FStrEq(pkvd->szKeyName, "m_iGibs")) + { + m_iGibs = m_iGibCapacity = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "m_flVelocity")) + { + m_flGibVelocity = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "m_flVariance")) + { + m_flVariance = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "m_flGibLife")) + { + m_flGibLife = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else CBaseDelay::KeyValue(pkvd); } /* <735f4> ../cstrike/dlls/effects.cpp:1493 */ void CGibShooter::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - SetThink(&CGibShooter::ShootThink); + SetThink(&CGibShooter::ShootThink); pev->nextthink = gpGlobals->time; } /* <73cb5> ../cstrike/dlls/effects.cpp:1499 */ void CGibShooter::__MAKE_VHOOK(Spawn)(void) { - Precache(); - - pev->solid = SOLID_NOT; - pev->effects = EF_NODRAW; - - if (m_flDelay == 0.0f) - { - m_flDelay = 0.1f; - } - - if (m_flGibLife == 0.0f) - { - m_flGibLife = 25; - } - - SetMovedir(pev); + Precache(); + + pev->solid = SOLID_NOT; + pev->effects = EF_NODRAW; + + if (m_flDelay == 0.0f) + { + m_flDelay = 0.1f; + } + + if (m_flGibLife == 0.0f) + { + m_flGibLife = 25; + } + + SetMovedir(pev); pev->body = MODEL_FRAMES(m_iGibModelIndex); } /* <744ff> ../cstrike/dlls/effects.cpp:1521 */ CGib *CGibShooter::__MAKE_VHOOK(CreateGib)(void) { - if (CVAR_GET_FLOAT("violence_hgibs") == 0) - return NULL; - - CGib *pGib = GetClassPtr((CGib *)NULL); - - pGib->Spawn("models/hgibs.mdl"); - pGib->m_bloodColor = BLOOD_COLOR_RED; - - if (pev->body <= 1) - { - ALERT(at_aiconsole, "GibShooter Body is <= 1!\n"); - } - - // avoid throwing random amounts of the 0th gib. (skull). - pGib->pev->body = RANDOM_LONG(1, pev->body - 1); - + if (CVAR_GET_FLOAT("violence_hgibs") == 0) + return NULL; + + CGib *pGib = GetClassPtr((CGib *)NULL); + + pGib->Spawn("models/hgibs.mdl"); + pGib->m_bloodColor = BLOOD_COLOR_RED; + + if (pev->body <= 1) + { + ALERT(at_aiconsole, "GibShooter Body is <= 1!\n"); + } + + // avoid throwing random amounts of the 0th gib. (skull). + pGib->pev->body = RANDOM_LONG(1, pev->body - 1); + return pGib; } /* <75751> ../cstrike/dlls/effects.cpp:1541 */ void CGibShooter::ShootThink(void) -{ - pev->nextthink = m_flDelay + gpGlobals->time; - - Vector vecShootDir; - vecShootDir = pev->movedir; - - float rnd_right = RANDOM_FLOAT(-1, 1); - float rnd_forward = RANDOM_FLOAT(-1, 1); - float rnd_up = RANDOM_FLOAT(-1, 1); - - // right - vecShootDir[0] = (vecShootDir[0] + (rnd_right * gpGlobals->v_right[0]) * m_flVariance); - vecShootDir[1] = (vecShootDir[1] + (rnd_right * gpGlobals->v_right[1]) * m_flVariance); - vecShootDir[2] = (vecShootDir[2] + (rnd_right * gpGlobals->v_right[2]) * m_flVariance); - - // forward - vecShootDir[0] = (vecShootDir[0] + (rnd_forward * gpGlobals->v_forward[0]) * m_flVariance); - vecShootDir[1] = (vecShootDir[1] + (rnd_forward * gpGlobals->v_forward[1]) * m_flVariance); - vecShootDir[2] = (vecShootDir[2] + (rnd_forward * gpGlobals->v_forward[2]) * m_flVariance); - - // up - vecShootDir[0] = (vecShootDir[0] + (rnd_up * gpGlobals->v_up[0]) * m_flVariance); - vecShootDir[1] = (vecShootDir[1] + (rnd_up * gpGlobals->v_up[1]) * m_flVariance); - vecShootDir[2] = (vecShootDir[2] + (rnd_up * gpGlobals->v_up[2]) * m_flVariance); - - vecShootDir = vecShootDir.Normalize(); - CGib *pGib = CreateGib(); - - if (pGib) - { - pGib->pev->origin = pev->origin; - pGib->pev->velocity = vecShootDir * m_flGibVelocity; - - pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); - pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); - - float thinkTime = pGib->pev->nextthink - gpGlobals->time; - - pGib->m_lifeTime = (m_flGibLife * RANDOM_FLOAT(0.95, 1.05)); // +/- 5% - if (pGib->m_lifeTime < thinkTime) - { - pGib->pev->nextthink = gpGlobals->time + pGib->m_lifeTime; - pGib->m_lifeTime = 0; - } - - } - - if (--m_iGibs <= 0) - { - if (pev->spawnflags & SF_GIBSHOOTER_REPEATABLE) - { - m_iGibs = m_iGibCapacity; - SetThink(NULL); - pev->nextthink = gpGlobals->time; - } - else - { - SetThink(&CGibShooter::SUB_Remove); - pev->nextthink = gpGlobals->time; - } +{ + pev->nextthink = m_flDelay + gpGlobals->time; + + Vector vecShootDir; + vecShootDir = pev->movedir; + + float rnd_right = RANDOM_FLOAT(-1, 1); + float rnd_forward = RANDOM_FLOAT(-1, 1); + float rnd_up = RANDOM_FLOAT(-1, 1); + + // right + vecShootDir[0] = (vecShootDir[0] + (rnd_right * gpGlobals->v_right[0]) * m_flVariance); + vecShootDir[1] = (vecShootDir[1] + (rnd_right * gpGlobals->v_right[1]) * m_flVariance); + vecShootDir[2] = (vecShootDir[2] + (rnd_right * gpGlobals->v_right[2]) * m_flVariance); + + // forward + vecShootDir[0] = (vecShootDir[0] + (rnd_forward * gpGlobals->v_forward[0]) * m_flVariance); + vecShootDir[1] = (vecShootDir[1] + (rnd_forward * gpGlobals->v_forward[1]) * m_flVariance); + vecShootDir[2] = (vecShootDir[2] + (rnd_forward * gpGlobals->v_forward[2]) * m_flVariance); + + // up + vecShootDir[0] = (vecShootDir[0] + (rnd_up * gpGlobals->v_up[0]) * m_flVariance); + vecShootDir[1] = (vecShootDir[1] + (rnd_up * gpGlobals->v_up[1]) * m_flVariance); + vecShootDir[2] = (vecShootDir[2] + (rnd_up * gpGlobals->v_up[2]) * m_flVariance); + + vecShootDir = vecShootDir.Normalize(); + CGib *pGib = CreateGib(); + + if (pGib) + { + pGib->pev->origin = pev->origin; + pGib->pev->velocity = vecShootDir * m_flGibVelocity; + + pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); + pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); + + float thinkTime = pGib->pev->nextthink - gpGlobals->time; + + pGib->m_lifeTime = (m_flGibLife * RANDOM_FLOAT(0.95, 1.05)); // +/- 5% + if (pGib->m_lifeTime < thinkTime) + { + pGib->pev->nextthink = gpGlobals->time + pGib->m_lifeTime; + pGib->m_lifeTime = 0; + } + + } + + if (--m_iGibs <= 0) + { + if (pev->spawnflags & SF_GIBSHOOTER_REPEATABLE) + { + m_iGibs = m_iGibCapacity; + SetThink(NULL); + pev->nextthink = gpGlobals->time; + } + else + { + SetThink(&CGibShooter::SUB_Remove); + pev->nextthink = gpGlobals->time; + } } } @@ -1533,76 +1537,76 @@ void CGibShooter::ShootThink(void) LINK_ENTITY_TO_CLASS(env_shooter, CEnvShooter); /* <749e7> ../cstrike/dlls/effects.cpp:1602 */ -NOBODY void CEnvShooter::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CEnvShooter::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "shootmodel")) - { - pev->model = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "shootsounds")) - { - int iNoise = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - - switch(iNoise) - { - case 0: - m_iGibMaterial = matGlass; - break; - case 1: - m_iGibMaterial = matWood; - break; - case 2: - m_iGibMaterial = matMetal; - break; - case 3: - m_iGibMaterial = matFlesh; - break; - case 4: - m_iGibMaterial = matRocks; - break; - - default: - case -1: - m_iGibMaterial = matNone; - break; - } - } - else + if (FStrEq(pkvd->szKeyName, "shootmodel")) + { + pev->model = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "shootsounds")) + { + int iNoise = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + + switch (iNoise) + { + case 0: + m_iGibMaterial = matGlass; + break; + case 1: + m_iGibMaterial = matWood; + break; + case 2: + m_iGibMaterial = matMetal; + break; + case 3: + m_iGibMaterial = matFlesh; + break; + case 4: + m_iGibMaterial = matRocks; + break; + + default: + case -1: + m_iGibMaterial = matNone; + break; + } + } + else CGibShooter::KeyValue(pkvd); } /* <73cdc> ../cstrike/dlls/effects.cpp:1644 */ void CEnvShooter::__MAKE_VHOOK(Precache)(void) { - m_iGibModelIndex = PRECACHE_MODEL((char *)STRING(pev->model)); + m_iGibModelIndex = PRECACHE_MODEL((char *)STRING(pev->model)); CBreakable::MaterialSoundPrecache((Materials)m_iGibMaterial); } /* <7464b> ../cstrike/dlls/effects.cpp:1651 */ CGib *CEnvShooter::__MAKE_VHOOK(CreateGib)(void) { - CGib *pGib = GetClassPtr((CGib *)NULL); - - pGib->Spawn(STRING(pev->model)); - - int bodyPart = 0; - - if (pev->body > 1) - bodyPart = RANDOM_LONG(0, pev->body - 1); - - pGib->pev->body = bodyPart; - pGib->m_bloodColor = DONT_BLEED; - pGib->m_material = m_iGibMaterial; - - pGib->pev->rendermode = pev->rendermode; - pGib->pev->renderamt = pev->renderamt; - pGib->pev->rendercolor = pev->rendercolor; - pGib->pev->renderfx = pev->renderfx; - pGib->pev->scale = pev->scale; - pGib->pev->skin = pev->skin; - + CGib *pGib = GetClassPtr((CGib *)NULL); + + pGib->Spawn(STRING(pev->model)); + + int bodyPart = 0; + + if (pev->body > 1) + bodyPart = RANDOM_LONG(0, pev->body - 1); + + pGib->pev->body = bodyPart; + pGib->m_bloodColor = DONT_BLEED; + pGib->m_material = m_iGibMaterial; + + pGib->pev->rendermode = pev->rendermode; + pGib->pev->renderamt = pev->renderamt; + pGib->pev->rendercolor = pev->rendercolor; + pGib->pev->renderfx = pev->renderfx; + pGib->pev->scale = pev->scale; + pGib->pev->skin = pev->skin; + return pGib; } @@ -1624,59 +1628,59 @@ void CTestEffect::__MAKE_VHOOK(Precache)(void) /* <76e39> ../cstrike/dlls/effects.cpp:1708 */ void CTestEffect::TestThink(void) { - int i; - float t = (gpGlobals->time - m_flStartTime); - - if (m_iBeam < 24) - { - CBeam *pbeam = CBeam::BeamCreate("sprites/lgtning.spr", 100); - - TraceResult tr; - Vector vecSrc = pev->origin; - Vector vecDir = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1),RANDOM_FLOAT(-1, 1)); - vecDir = vecDir.Normalize(); - - UTIL_TraceLine(vecSrc, vecSrc + vecDir * 128, ignore_monsters, ENT(pev), &tr); - - pbeam->PointsInit(vecSrc, tr.vecEndPos); - pbeam->SetColor(255, 180, 100); - pbeam->SetWidth(100); - pbeam->SetScrollRate(12); - - m_flBeamTime[m_iBeam] = gpGlobals->time; - m_pBeam[m_iBeam] = pbeam; - m_iBeam++; - - } - - if (t < 3.0) - { - for (i = 0; i < m_iBeam; i++) - { - t = (gpGlobals->time - m_flBeamTime[i]) / (3 + m_flStartTime - m_flBeamTime[i]); - m_pBeam[i]->SetBrightness(255 * t); - } - pev->nextthink = gpGlobals->time + 0.1f; - } - else - { - for (i = 0; i < m_iBeam; i++) - { - UTIL_Remove(m_pBeam[i]); - } - - m_flStartTime = gpGlobals->time; - m_iBeam = 0; - SetThink(NULL); + int i; + float t = (gpGlobals->time - m_flStartTime); + + if (m_iBeam < 24) + { + CBeam *pbeam = CBeam::BeamCreate("sprites/lgtning.spr", 100); + + TraceResult tr; + Vector vecSrc = pev->origin; + Vector vecDir = Vector(RANDOM_FLOAT(-1, 1), RANDOM_FLOAT(-1, 1),RANDOM_FLOAT(-1, 1)); + vecDir = vecDir.Normalize(); + + UTIL_TraceLine(vecSrc, vecSrc + vecDir * 128, ignore_monsters, ENT(pev), &tr); + + pbeam->PointsInit(vecSrc, tr.vecEndPos); + pbeam->SetColor(255, 180, 100); + pbeam->SetWidth(100); + pbeam->SetScrollRate(12); + + m_flBeamTime[m_iBeam] = gpGlobals->time; + m_pBeam[m_iBeam] = pbeam; + m_iBeam++; + + } + + if (t < 3.0) + { + for (i = 0; i < m_iBeam; i++) + { + t = (gpGlobals->time - m_flBeamTime[i]) / (3 + m_flStartTime - m_flBeamTime[i]); + m_pBeam[i]->SetBrightness(255 * t); + } + pev->nextthink = gpGlobals->time + 0.1f; + } + else + { + for (i = 0; i < m_iBeam; i++) + { + UTIL_Remove(m_pBeam[i]); + } + + m_flStartTime = gpGlobals->time; + m_iBeam = 0; + SetThink(NULL); } } /* <736a2> ../cstrike/dlls/effects.cpp:1759 */ void CTestEffect::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - SetThink(&CTestEffect::TestThink); - - pev->nextthink = gpGlobals->time + 0.1f; + SetThink(&CTestEffect::TestThink); + + pev->nextthink = gpGlobals->time + 0.1f; m_flStartTime = gpGlobals->time; } @@ -1686,47 +1690,47 @@ LINK_ENTITY_TO_CLASS(env_blood, CBlood); /* <73c8f> ../cstrike/dlls/effects.cpp:1797 */ void CBlood::__MAKE_VHOOK(Spawn)(void) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; - + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; + SetMovedir(pev); } /* <74c34> ../cstrike/dlls/effects.cpp:1807 */ void CBlood::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "color")) - { - int color = Q_atoi(pkvd->szValue); - switch (color) - { - case 1: - SetColor(BLOOD_COLOR_YELLOW); - break; - default: - SetColor(BLOOD_COLOR_RED); - break; - } - - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "amount")) - { - SetBloodAmount(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else + if (FStrEq(pkvd->szKeyName, "color")) + { + int color = Q_atoi(pkvd->szValue); + switch (color) + { + case 1: + SetColor(BLOOD_COLOR_YELLOW); + break; + default: + SetColor(BLOOD_COLOR_RED); + break; + } + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "amount")) + { + SetBloodAmount(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else CPointEntity::KeyValue(pkvd); } /* <791f7> ../cstrike/dlls/effects.cpp:1834 */ Vector CBlood::Direction(void) { - if (pev->spawnflags & SF_BLOOD_RANDOM) - return UTIL_RandomBloodVector(); - + if (pev->spawnflags & SF_BLOOD_RANDOM) + return UTIL_RandomBloodVector(); + return pev->movedir; } @@ -1754,22 +1758,22 @@ Vector CBlood::BloodPosition(CBaseEntity *pActivator) /* <79351> ../cstrike/dlls/effects.cpp:1863 */ void CBlood::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (pev->spawnflags & SF_BLOOD_STREAM) - UTIL_BloodStream(BloodPosition(pActivator), Direction(), (Color() == BLOOD_COLOR_RED) ? 70 : Color(), (int)BloodAmount()); - else - UTIL_BloodDrips(BloodPosition(pActivator), Direction(), Color(), (int)BloodAmount()); - - if (pev->spawnflags & SF_BLOOD_DECAL) - { - Vector forward = Direction(); - Vector start = BloodPosition(pActivator); - - TraceResult tr; - UTIL_TraceLine(start, start + forward * BloodAmount() * 2, ignore_monsters, NULL, &tr); - - if (tr.flFraction != 1.0f) - { - UTIL_BloodDecalTrace(&tr, Color()); + if (pev->spawnflags & SF_BLOOD_STREAM) + UTIL_BloodStream(BloodPosition(pActivator), Direction(), (Color() == BLOOD_COLOR_RED) ? 70 : Color(), (int)BloodAmount()); + else + UTIL_BloodDrips(BloodPosition(pActivator), Direction(), Color(), (int)BloodAmount()); + + if (pev->spawnflags & SF_BLOOD_DECAL) + { + Vector forward = Direction(); + Vector start = BloodPosition(pActivator); + + TraceResult tr; + UTIL_TraceLine(start, start + forward * BloodAmount() * 2, ignore_monsters, NULL, &tr); + + if (tr.flFraction != 1.0f) + { + UTIL_BloodDecalTrace(&tr, Color()); } } } @@ -1780,39 +1784,39 @@ LINK_ENTITY_TO_CLASS(env_shake, CShake); /* <73705> ../cstrike/dlls/effects.cpp:1919 */ void CShake::__MAKE_VHOOK(Spawn)(void) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; - pev->frame = 0; - - if (pev->spawnflags & SF_SHAKE_EVERYONE) + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; + pev->frame = 0; + + if (pev->spawnflags & SF_SHAKE_EVERYONE) pev->dmg = 0; } /* <74d76> ../cstrike/dlls/effects.cpp:1931 */ void CShake::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "amplitude")) - { - SetAmplitude(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "frequency")) - { - SetFrequency(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "duration")) - { - SetDuration(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "radius")) - { - SetRadius(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else + if (FStrEq(pkvd->szKeyName, "amplitude")) + { + SetAmplitude(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "frequency")) + { + SetFrequency(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "duration")) + { + SetDuration(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "radius")) + { + SetRadius(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else CPointEntity::KeyValue(pkvd); } @@ -1828,50 +1832,50 @@ LINK_ENTITY_TO_CLASS(env_fade, CFade); /* <7372b> ../cstrike/dlls/effects.cpp:1987 */ void CFade::__MAKE_VHOOK(Spawn)(void) { - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - pev->effects = 0; + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = 0; pev->frame = 0; } /* <74efa> ../cstrike/dlls/effects.cpp:1996 */ void CFade::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "duration")) - { - SetDuration(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "holdtime")) - { - SetHoldTime(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else + if (FStrEq(pkvd->szKeyName, "duration")) + { + SetDuration(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "holdtime")) + { + SetHoldTime(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else CPointEntity::KeyValue(pkvd); } /* <73bb4> ../cstrike/dlls/effects.cpp:2013 */ void CFade::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - int fadeFlags = 0; - - if (!(pev->spawnflags & SF_FADE_IN)) - fadeFlags |= FFADE_OUT; - - if (pev->spawnflags & SF_FADE_MODULATE) - fadeFlags |= FFADE_MODULATE; - - if (pev->spawnflags & SF_FADE_ONLYONE) - { - if (pActivator->IsNetClient()) - { - UTIL_ScreenFade(pActivator, pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags); - } - } - else - UTIL_ScreenFadeAll(pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags); - + int fadeFlags = 0; + + if (!(pev->spawnflags & SF_FADE_IN)) + fadeFlags |= FFADE_OUT; + + if (pev->spawnflags & SF_FADE_MODULATE) + fadeFlags |= FFADE_MODULATE; + + if (pev->spawnflags & SF_FADE_ONLYONE) + { + if (pActivator->IsNetClient()) + { + UTIL_ScreenFade(pActivator, pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags); + } + } + else + UTIL_ScreenFadeAll(pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags); + SUB_UseTargets(this, USE_TOGGLE, 0); } @@ -1881,41 +1885,41 @@ LINK_ENTITY_TO_CLASS(env_message, CMessage); /* <73751> ../cstrike/dlls/effects.cpp:2051 */ void CMessage::__MAKE_VHOOK(Spawn)(void) { - Precache(); - - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_NONE; - - switch (pev->impulse) - { - case 1: // Medium radius - pev->speed = ATTN_STATIC; - break; - - case 2: // Large radius - pev->speed = ATTN_NORM; - break; - - case 3: //EVERYWHERE - pev->speed = ATTN_NONE; - break; - - default: - case 0: // Small radius - pev->speed = ATTN_IDLE; - break; - } - pev->impulse = 0; - - // No volume, use normal - if (pev->scale <= 0.0f) + Precache(); + + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + + switch (pev->impulse) + { + case 1: // Medium radius + pev->speed = ATTN_STATIC; + break; + + case 2: // Large radius + pev->speed = ATTN_NORM; + break; + + case 3: //EVERYWHERE + pev->speed = ATTN_NONE; + break; + + default: + case 0: // Small radius + pev->speed = ATTN_IDLE; + break; + } + pev->impulse = 0; + + // No volume, use normal + if (pev->scale <= 0.0f) pev->scale = 1.0; } /* <73df7> ../cstrike/dlls/effects.cpp:2085 */ void CMessage::__MAKE_VHOOK(Precache)(void) { - if (pev->noise) + if (pev->noise) { PRECACHE_SOUND((char *)STRING(pev->noise)); } @@ -1924,51 +1928,51 @@ void CMessage::__MAKE_VHOOK(Precache)(void) /* <74765> ../cstrike/dlls/effects.cpp:2091 */ void CMessage::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "messagesound")) - { - pev->noise = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "messagevolume")) - { - pev->scale = Q_atof(pkvd->szValue) * 0.1; - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "messageattenuation")) - { - pev->impulse = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else + if (FStrEq(pkvd->szKeyName, "messagesound")) + { + pev->noise = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "messagevolume")) + { + pev->scale = Q_atof(pkvd->szValue) * 0.1; + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "messageattenuation")) + { + pev->impulse = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else CPointEntity::KeyValue(pkvd); } /* <73aa5> ../cstrike/dlls/effects.cpp:2113 */ void CMessage::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - CBaseEntity *pPlayer = NULL; - - if (pev->spawnflags & SF_MESSAGE_ALL) - UTIL_ShowMessageAll(STRING(pev->message)); - else - { - if (pActivator && pActivator->IsPlayer()) - pPlayer = pActivator; - else - { - pPlayer = CBaseEntity::Instance(INDEXENT(1)); - } - - if (pPlayer) - UTIL_ShowMessage(STRING(pev->message), pPlayer); - } - if (pev->noise) - { - EMIT_SOUND(edict(), CHAN_BODY, STRING(pev->noise), pev->scale, pev->speed); - } - if (pev->spawnflags & SF_MESSAGE_ONCE) - UTIL_Remove(this); - + CBaseEntity *pPlayer = NULL; + + if (pev->spawnflags & SF_MESSAGE_ALL) + UTIL_ShowMessageAll(STRING(pev->message)); + else + { + if (pActivator && pActivator->IsPlayer()) + pPlayer = pActivator; + else + { + pPlayer = CBaseEntity::Instance(INDEXENT(1)); + } + + if (pPlayer) + UTIL_ShowMessage(STRING(pev->message), pPlayer); + } + if (pev->noise) + { + EMIT_SOUND(edict(), CHAN_BODY, STRING(pev->noise), pev->scale, pev->speed); + } + if (pev->spawnflags & SF_MESSAGE_ONCE) + UTIL_Remove(this); + SUB_UseTargets(this, USE_TOGGLE, 0); } @@ -1984,35 +1988,35 @@ void CEnvFunnel::__MAKE_VHOOK(Precache)(void) /* <7379f> ../cstrike/dlls/effects.cpp:2162 */ void CEnvFunnel::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); - WRITE_BYTE(TE_LARGEFUNNEL); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z); - WRITE_SHORT(m_iSprite); - - // funnel flows in reverse? - if (pev->spawnflags & SF_FUNNEL_REVERSE) - { - WRITE_SHORT(1); - } - else - { - WRITE_SHORT(0); - } - - - MESSAGE_END(); - - SetThink(&CEnvFunnel::SUB_Remove); + MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); + WRITE_BYTE(TE_LARGEFUNNEL); + WRITE_COORD(pev->origin.x); + WRITE_COORD(pev->origin.y); + WRITE_COORD(pev->origin.z); + WRITE_SHORT(m_iSprite); + + // funnel flows in reverse? + if (pev->spawnflags & SF_FUNNEL_REVERSE) + { + WRITE_SHORT(1); + } + else + { + WRITE_SHORT(0); + } + + + MESSAGE_END(); + + SetThink(&CEnvFunnel::SUB_Remove); pev->nextthink = gpGlobals->time; } /* <7382b> ../cstrike/dlls/effects.cpp:2187 */ void CEnvFunnel::__MAKE_VHOOK(Spawn)(void) { - Precache(); - pev->solid = SOLID_NOT; + Precache(); + pev->solid = SOLID_NOT; pev->effects = EF_NODRAW; } @@ -2029,37 +2033,37 @@ LINK_ENTITY_TO_CLASS(env_beverage, CEnvBeverage); /* <7439c> ../cstrike/dlls/effects.cpp:2215 */ void CEnvBeverage::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (pev->frags != 0.0f || pev->health <= 0.0f) - { - // no more cans while one is waiting in the dispenser, or if I'm out of cans. - return; - } - - CBaseEntity *pCan = CBaseEntity::Create("item_sodacan", pev->origin, pev->angles, edict()); - - if (pev->skin == 6) - { - // random - pCan->pev->skin = RANDOM_LONG(0, 5); - } - else - pCan->pev->skin = pev->skin; - - pev->frags = 1; + if (pev->frags != 0.0f || pev->health <= 0.0f) + { + // no more cans while one is waiting in the dispenser, or if I'm out of cans. + return; + } + + CBaseEntity *pCan = CBaseEntity::Create("item_sodacan", pev->origin, pev->angles, edict()); + + if (pev->skin == 6) + { + // random + pCan->pev->skin = RANDOM_LONG(0, 5); + } + else + pCan->pev->skin = pev->skin; + + pev->frags = 1; pev->health--; } /* <73879> ../cstrike/dlls/effects.cpp:2242 */ void CEnvBeverage::__MAKE_VHOOK(Spawn)(void) { - Precache(); - pev->solid = SOLID_NOT; - pev->effects = EF_NODRAW; - pev->frags = 0; - - if (pev->health == 0.0f) - { - pev->health = 10; + Precache(); + pev->solid = SOLID_NOT; + pev->effects = EF_NODRAW; + pev->frags = 0; + + if (pev->health == 0.0f) + { + pev->health = 10; } } @@ -2075,26 +2079,26 @@ LINK_ENTITY_TO_CLASS(item_sodacan, CItemSoda); /* <738c6> ../cstrike/dlls/effects.cpp:2273 */ void CItemSoda::__MAKE_VHOOK(Spawn)(void) { - Precache(); - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_TOSS; - - SET_MODEL(ENT(pev), "models/can.mdl"); - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); - - SetThink(&CItemSoda::CanThink); + Precache(); + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_TOSS; + + SET_MODEL(ENT(pev), "models/can.mdl"); + UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + + SetThink(&CItemSoda::CanThink); pev->nextthink = gpGlobals->time + 0.5f; } /* <73961> ../cstrike/dlls/effects.cpp:2286 */ void CItemSoda::CanThink(void) { - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/g_bounce3.wav", VOL_NORM, ATTN_NORM); - - pev->solid = SOLID_TRIGGER; - UTIL_SetSize(pev, Vector(-8, -8, 0), Vector(8, 8, 8)); - - SetThink(NULL); + EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/g_bounce3.wav", VOL_NORM, ATTN_NORM); + + pev->solid = SOLID_TRIGGER; + UTIL_SetSize(pev, Vector(-8, -8, 0), Vector(8, 8, 8)); + + SetThink(NULL); SetTouch(&CItemSoda::CanTouch); } @@ -2102,17 +2106,17 @@ void CItemSoda::CanThink(void) void CItemSoda::CanTouch(CBaseEntity *pOther) { if (!pOther->IsPlayer()) - { - return; + { + return; } // spoit sound here pOther->TakeHealth(1, DMG_GENERIC);// a bit of health. if (!FNullEnt(pev->owner)) - { - // tell the machine the can was taken - pev->owner->v.frags = 0; + { + // tell the machine the can was taken + pev->owner->v.frags = 0; } pev->solid = SOLID_NOT; diff --git a/regamedll/dlls/effects.h b/regamedll/dlls/effects.h index c5606825..890998db 100644 --- a/regamedll/dlls/effects.h +++ b/regamedll/dlls/effects.h @@ -153,7 +153,7 @@ public: { pev->renderamt = brightness; } - void AnimateAndDie(float framerate) + void AnimateAndDie(float_precision framerate) { SetThink(&CSprite::AnimateUntilDead); pev->framerate = framerate; @@ -455,9 +455,9 @@ public: /* <71e17> ../cstrike/dlls/effects.cpp:373 */ inline BOOL ServerSide(void) { - if (!m_life && !(pev->spawnflags & SF_BEAM_RING)) - return TRUE; - + if (!m_life && !(pev->spawnflags & SF_BEAM_RING)) + return TRUE; + return FALSE; } void BeamUpdateVars(void); @@ -482,7 +482,7 @@ public: }; /* size: 204, cachelines: 4, members: 15 */ -/* <7244f> ../cstrike/dlls/effects.cpp:1085 */ +/* <7244f> ../cstrike/dlls/effects.cpp:1085 */ class CGlow: public CPointEntity { public: @@ -531,10 +531,10 @@ public: };/* size: 172, cachelines: 3, members: 4 */ -/* <72581> ../cstrike/dlls/effects.cpp:1413 */ -class CGibShooter: public CBaseDelay -{ -public: +/* <72581> ../cstrike/dlls/effects.cpp:1413 */ +class CGibShooter: public CBaseDelay +{ +public: virtual void Spawn(void); virtual void Precache(void); virtual void KeyValue(KeyValueData *pkvd); @@ -568,8 +568,8 @@ public: float m_flGibVelocity; float m_flVariance; - float m_flGibLife; - + float m_flGibLife; + };/* size: 188, cachelines: 3, members: 9 */ /* <725ef> ../cstrike/dlls/effects.cpp:1592 */ @@ -616,13 +616,13 @@ public: int m_iBeam; CBeam *m_pBeam[ MAX_BEAM ]; - + float m_flBeamTime[ MAX_BEAM ]; float m_flStartTime; };/* size: 364, cachelines: 6, members: 6 */ -/* <72690> ../cstrike/dlls/effects.cpp:1769 */ +/* <72690> ../cstrike/dlls/effects.cpp:1769 */ class CBlood: public CPointEntity { public: @@ -666,7 +666,7 @@ public: };/* size: 152, cachelines: 3, members: 1 */ -/* <726de> ../cstrike/dlls/effects.cpp:1886 */ +/* <726de> ../cstrike/dlls/effects.cpp:1886 */ class CShake: public CPointEntity { public: @@ -726,7 +726,7 @@ public: };/* size: 152, cachelines: 3, members: 1 */ -/* <7272c> ../cstrike/dlls/effects.cpp:1964 */ +/* <7272c> ../cstrike/dlls/effects.cpp:1964 */ class CFade: public CPointEntity { public: @@ -825,7 +825,7 @@ public: };/* size: 160, cachelines: 3, members: 1 */ -/* <72869> ../cstrike/dlls/effects.cpp:2258 */ +/* <72869> ../cstrike/dlls/effects.cpp:2258 */ class CItemSoda: public CBaseEntity { public: @@ -850,22 +850,22 @@ int IsPointEntity(CBaseEntity *pEnt); // linked objects C_DLLEXPORT void info_target(entvars_t *pev); C_DLLEXPORT void env_bubbles(entvars_t *pev); -C_DLLEXPORT void beam(entvars_t *pev); -C_DLLEXPORT void env_lightning(entvars_t *pev); -C_DLLEXPORT void env_beam(entvars_t *pev); -C_DLLEXPORT void env_laser(entvars_t *pev); -C_DLLEXPORT void env_glow(entvars_t *pev); -C_DLLEXPORT void env_bombglow(entvars_t *pev); -C_DLLEXPORT void env_sprite(entvars_t *pev); -C_DLLEXPORT void gibshooter(entvars_t *pev); -C_DLLEXPORT void env_shooter(entvars_t *pev); -C_DLLEXPORT void test_effect(entvars_t *pev); -C_DLLEXPORT void env_blood(entvars_t *pev); -C_DLLEXPORT void env_shake(entvars_t *pev); -C_DLLEXPORT void env_fade(entvars_t *pev); -C_DLLEXPORT void env_message(entvars_t *pev); -C_DLLEXPORT void env_funnel(entvars_t *pev); -C_DLLEXPORT void env_beverage(entvars_t *pev); +C_DLLEXPORT void beam(entvars_t *pev); +C_DLLEXPORT void env_lightning(entvars_t *pev); +C_DLLEXPORT void env_beam(entvars_t *pev); +C_DLLEXPORT void env_laser(entvars_t *pev); +C_DLLEXPORT void env_glow(entvars_t *pev); +C_DLLEXPORT void env_bombglow(entvars_t *pev); +C_DLLEXPORT void env_sprite(entvars_t *pev); +C_DLLEXPORT void gibshooter(entvars_t *pev); +C_DLLEXPORT void env_shooter(entvars_t *pev); +C_DLLEXPORT void test_effect(entvars_t *pev); +C_DLLEXPORT void env_blood(entvars_t *pev); +C_DLLEXPORT void env_shake(entvars_t *pev); +C_DLLEXPORT void env_fade(entvars_t *pev); +C_DLLEXPORT void env_message(entvars_t *pev); +C_DLLEXPORT void env_funnel(entvars_t *pev); +C_DLLEXPORT void env_beverage(entvars_t *pev); C_DLLEXPORT void item_sodacan(entvars_t *pev); #endif // EFFECTS_H diff --git a/regamedll/dlls/enginecallback.h b/regamedll/dlls/enginecallback.h index b701538c..8b99e226 100644 --- a/regamedll/dlls/enginecallback.h +++ b/regamedll/dlls/enginecallback.h @@ -150,6 +150,7 @@ inline void *GET_PRIVATE(edict_t *pent) #define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle) #define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe) #define FREE_FILE (*g_engfuncs.pfnFreeFile) +#define END_SECTION (*g_engfuncs.pfnEndSection) #define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime) #define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) #define SET_CLIENT_MAXSPEED (*g_engfuncs.pfnSetClientMaxspeed) diff --git a/regamedll/dlls/explode.cpp b/regamedll/dlls/explode.cpp index f75a3c09..891d6243 100644 --- a/regamedll/dlls/explode.cpp +++ b/regamedll/dlls/explode.cpp @@ -13,7 +13,7 @@ TYPEDESCRIPTION CEnvExplosion::m_SaveData[] = #else // HOOK_GAMEDLL -TYPEDESCRIPTION (*CEnvExplosion::pm_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CEnvExplosion, m_SaveData)[2]; #endif // HOOK_GAMEDLL @@ -221,7 +221,7 @@ void CEnvExplosion::Smoke(void) // HACKHACK -- create one of these and fake a keyvalue to get the right explosion setup /* <7f7f4> ../cstrike/dlls/explode.cpp:258 */ -void ExplosionCreate(Vector ¢er, Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage) +void ExplosionCreate(const Vector ¢er, Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage) { KeyValueData kvd; char buf[128]; diff --git a/regamedll/dlls/explode.h b/regamedll/dlls/explode.h index 64d38ccd..762e9982 100644 --- a/regamedll/dlls/explode.h +++ b/regamedll/dlls/explode.h @@ -97,7 +97,7 @@ public: };/* size: 412, cachelines: 7, members: 4 */ -void ExplosionCreate(Vector ¢er, Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage); +void ExplosionCreate(const Vector ¢er, Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage); // linked objects C_DLLEXPORT void spark_shower(entvars_t *pev); diff --git a/regamedll/dlls/extdll.h b/regamedll/dlls/extdll.h index a3698070..c593db24 100644 --- a/regamedll/dlls/extdll.h +++ b/regamedll/dlls/extdll.h @@ -41,6 +41,7 @@ #include "archtypes.h" #ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN #define NOWINRES #define NOSERVICE @@ -51,26 +52,11 @@ #include "winsani_out.h" #undef PlaySound #else - //#define FALSE 0 - //#define TRUE 1 - //typedef unsigned long ULONG; - //typedef unsigned char BYTE; - //typedef int BOOL; - - //#define MAX_PATH PATH_MAX #include #include #include - #ifndef min - #define min(a,b) (((a) < (b)) ? (a) : (b)) - #endif // min - #ifndef max - #define max(a,b) (((a) > (b)) ? (a) : (b)) - #define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) - #endif // max - #endif // _WIN32 // Misc C-runtime library headers diff --git a/regamedll/dlls/func_break.cpp b/regamedll/dlls/func_break.cpp index 81195cf0..d799210c 100644 --- a/regamedll/dlls/func_break.cpp +++ b/regamedll/dlls/func_break.cpp @@ -5,8 +5,8 @@ */ #ifndef HOOK_GAMEDLL -// Just add more items to the bottom of this array and they will automagically be supported -// This is done instead of just a classname in the FGD so we can control which entities can +// Just add more items to the bottom of this array and they will automagically be supported +// This is done instead of just a classname in the FGD so we can control which entities can // be spawned, and still remain fairly flexible const char *CBreakable::pSpawnObjects[] = { @@ -116,60 +116,157 @@ const char *(*CBreakable::ppSoundsGlass)[3]; char *(*CPushable::pm_soundNames)[3]; -TYPEDESCRIPTION (*CBreakable::pm_SaveData)[5]; -TYPEDESCRIPTION (*CPushable::pm_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBreakable, m_SaveData)[5]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CPushable, m_SaveData)[2]; #endif // HOOK_GAMEDLL -/* <85bf3> ../cstrike/dlls/func_break.cpp:76 */ -NOBODY void CBreakable::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 90 -// FStrEq(const char *sz1, -// const char *sz2); // 103 -// FStrEq(const char *sz1, -// const char *sz2); // 107 -// FStrEq(const char *sz1, -// const char *sz2); // 112 -// FStrEq(const char *sz1, -// const char *sz2); // 117 -// FStrEq(const char *sz1, -// const char *sz2); // 124 -// FStrEq(const char *sz1, -// const char *sz2); // 129 -// { -// int object; // 119 -// atoi(const char *__nptr); // 119 -// } -// atoi(const char *__nptr); // 126 -// ExplosionSetMagnitude(CBreakable *const this, -// int magnitude); // 126 -// { -// int i; // 92 -// atoi(const char *__nptr); // 92 -// } +/* <85bf3> ../cstrike/dlls/func_break.cpp:76 */ +void CBreakable::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + // UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file! + if (FStrEq(pkvd->szKeyName, "explosion")) + { + if (!Q_stricmp(pkvd->szValue, "directed")) + m_Explosion = expDirected; + + else if (!Q_stricmp(pkvd->szValue, "random")) + m_Explosion = expRandom; + else + m_Explosion = expRandom; + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "material")) + { + int i = Q_atoi(pkvd->szValue); + + // 0:glass, 1:metal, 2:flesh, 3:wood + + if (i < 0 || i >= matLastMaterial) + m_Material = matWood; + else + m_Material = (Materials)i; + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "deadmodel")) + { + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "shards")) + { + //m_iShards = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "gibmodel")) + { + m_iszGibModel = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "spawnobject")) + { + int object = Q_atoi(pkvd->szValue); + if (object > 0 && object < ARRAYSIZE(pSpawnObjects)) + { + m_iszSpawnObject = MAKE_STRING(pSpawnObjects[object]); + } + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "explodemagnitude")) + { + ExplosionSetMagnitude(Q_atoi(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "lip")) + pkvd->fHandled = TRUE; + else + CBaseDelay::KeyValue(pkvd); } -/* <86426> ../cstrike/dlls/func_break.cpp:139 */ -LINK_ENTITY_TO_CLASS(func_breakable, CBreakable); +/* <86426> ../cstrike/dlls/func_break.cpp:139 */ +LINK_ENTITY_TO_CLASS(func_breakable, CBreakable); /* <85b30> ../cstrike/dlls/func_break.cpp:155 */ IMPLEMENT_SAVERESTORE(CBreakable, CBaseEntity); -/* <85663> ../cstrike/dlls/func_break.cpp:157 */ -NOBODY void CBreakable::__MAKE_VHOOK(Spawn)(void) -{ +/* <85663> ../cstrike/dlls/func_break.cpp:157 */ +void CBreakable::__MAKE_VHOOK(Spawn)(void) +{ + Precache(); + + if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY) + pev->takedamage = DAMAGE_NO; + else + pev->takedamage = DAMAGE_YES; + + m_flHealth = pev->health; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + m_angle = pev->angles.y; + pev->angles.y = 0; + + // HACK: matGlass can receive decals, we need the client to know about this + // so use class to store the material flag + if (m_Material == matGlass) + { + pev->playerclass = 1; + } + + //set size and link into world. + SET_MODEL(ENT(pev), STRING(pev->model)); + + SetTouch(&CBreakable::BreakTouch); + + // Only break on trigger + if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY) + { + SetTouch(NULL); + } + + // Flag unbreakable glass as "worldbrush" so it will block ALL tracelines + if (!IsBreakable() && pev->rendermode != kRenderNormal) + { + pev->flags |= FL_WORLDBRUSH; + } } -/* <8568a> ../cstrike/dlls/func_break.cpp:191 */ -NOBODY void CBreakable::__MAKE_VHOOK(Restart)(void) -{ +/* <8568a> ../cstrike/dlls/func_break.cpp:191 */ +void CBreakable::__MAKE_VHOOK(Restart)(void) +{ + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + pev->deadflag = DEAD_NO; + + if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY) + pev->takedamage = DAMAGE_NO; + else + pev->takedamage = DAMAGE_YES; + + pev->deadflag = DEAD_NO; + pev->health = m_flHealth; + pev->effects &= ~EF_NODRAW; + m_angle = pev->angles.y; + pev->angles.y = 0; + + SET_MODEL(ENT(pev), STRING(pev->model)); + SetTouch(&CBreakable::BreakTouch); + + if (pev->spawnflags & SF_BREAK_TRIGGER_ONLY) + { + SetTouch(NULL); + } + + if (!IsBreakable() && pev->rendermode != kRenderNormal) + { + pev->flags |= FL_WORLDBRUSH; + } } -/* <864f1> ../cstrike/dlls/func_break.cpp:260 */ -const char **CBreakable::MaterialSoundList(Materials precacheMaterial, int &soundCount) -{ +/* <864f1> ../cstrike/dlls/func_break.cpp:260 */ +const char **CBreakable::MaterialSoundList(Materials precacheMaterial, int &soundCount) +{ const char **pSoundList = NULL; switch (precacheMaterial) @@ -186,9 +283,9 @@ const char **CBreakable::MaterialSoundList(Materials precacheMaterial, int &soun soundCount = ARRAYSIZE(pSoundsFlesh); break; } + case matGlass: case matComputer: case matUnbreakableGlass: - case matGlass: { pSoundList = pSoundsGlass; soundCount = ARRAYSIZE(pSoundsGlass); @@ -213,252 +310,763 @@ const char **CBreakable::MaterialSoundList(Materials precacheMaterial, int &soun soundCount = 0; break; } - return pSoundList; + + return pSoundList; } -/* <86526> ../cstrike/dlls/func_break.cpp:303 */ -void CBreakable::MaterialSoundPrecache(Materials precacheMaterial) +/* <86526> ../cstrike/dlls/func_break.cpp:303 */ +void CBreakable::MaterialSoundPrecache(Materials precacheMaterial) { - const char **pSoundList; - int i, soundCount = 0; - - pSoundList = MaterialSoundList(precacheMaterial, soundCount); - - for (i = 0; i < soundCount; i++) - { - PRECACHE_SOUND((char *)pSoundList[i]); + const char **pSoundList; + int i, soundCount = 0; + + pSoundList = MaterialSoundList(precacheMaterial, soundCount); + + for (i = 0; i < soundCount; i++) + { + PRECACHE_SOUND((char *)pSoundList[i]); } } -/* <86598> ../cstrike/dlls/func_break.cpp:316 */ -void CBreakable::MaterialSoundRandom(edict_t *pEdict, Materials soundMaterial, float volume) -{ +/* <86598> ../cstrike/dlls/func_break.cpp:316 */ +void CBreakable::MaterialSoundRandom(edict_t *pEdict, Materials soundMaterial, float volume) +{ int soundCount = 0; const char **pSoundList = MaterialSoundList(soundMaterial, soundCount); if (soundCount) - { - EMIT_SOUND(pEdict, CHAN_BODY, pSoundList[ RANDOM_LONG(0, soundCount - 1) ], volume, 1.0); + { + EMIT_SOUND(pEdict, CHAN_BODY, pSoundList[ RANDOM_LONG(0, soundCount - 1) ], volume, 1.0); } } -/* <8634b> ../cstrike/dlls/func_break.cpp:328 */ -NOBODY void CBreakable::__MAKE_VHOOK(Precache)(void) -{ -// { -// const char *pGibName; // 330 -// MaterialSoundPrecache(Materials precacheMaterial); // 386 -// } +/* <8634b> ../cstrike/dlls/func_break.cpp:328 */ +void CBreakable::__MAKE_VHOOK(Precache)(void) +{ + const char *pGibName = NULL; + + switch (m_Material) + { + case matWood: + pGibName = "models/woodgibs.mdl"; + + PRECACHE_SOUND("debris/bustcrate1.wav"); + PRECACHE_SOUND("debris/bustcrate2.wav"); + break; + case matFlesh: + pGibName = "models/fleshgibs.mdl"; + + PRECACHE_SOUND("debris/bustflesh1.wav"); + PRECACHE_SOUND("debris/bustflesh2.wav"); + break; + case matComputer: + PRECACHE_SOUND("buttons/spark5.wav"); + PRECACHE_SOUND("buttons/spark6.wav"); + pGibName = "models/computergibs.mdl"; + + PRECACHE_SOUND("debris/bustmetal1.wav"); + PRECACHE_SOUND("debris/bustmetal2.wav"); + break; + case matGlass: + case matUnbreakableGlass: + pGibName = "models/glassgibs.mdl"; + + PRECACHE_SOUND("debris/bustglass1.wav"); + PRECACHE_SOUND("debris/bustglass2.wav"); + break; + case matMetal: + pGibName = "models/metalplategibs.mdl"; + + PRECACHE_SOUND("debris/bustmetal1.wav"); + PRECACHE_SOUND("debris/bustmetal2.wav"); + break; + case matCinderBlock: + pGibName = "models/cindergibs.mdl"; + + PRECACHE_SOUND("debris/bustconcrete1.wav"); + PRECACHE_SOUND("debris/bustconcrete2.wav"); + break; + case matRocks: + pGibName = "models/rockgibs.mdl"; + + PRECACHE_SOUND("debris/bustconcrete1.wav"); + PRECACHE_SOUND("debris/bustconcrete2.wav"); + break; + case matCeilingTile: + pGibName = "models/ceilinggibs.mdl"; + + PRECACHE_SOUND("debris/bustceiling.wav"); + break; + } + + MaterialSoundPrecache(m_Material); + + if (m_iszGibModel) + { + pGibName = STRING(m_iszGibModel); + } + + if (pGibName != NULL) + { + m_idShard = PRECACHE_MODEL((char *)pGibName); + } + + // Precache the spawn item's data + if (m_iszSpawnObject) + { + UTIL_PrecacheOther((char *)STRING(m_iszSpawnObject)); + } } -/* <86676> ../cstrike/dlls/func_break.cpp:401 */ -NOBODY void CBreakable::DamageSound(void) -{ -// { -// int pitch; // 403 -// float fvol; // 404 -// char *rgpsz; // 405 -// int i; // 406 -// int material; // 407 -// } +/* <86676> ../cstrike/dlls/func_break.cpp:401 */ +void CBreakable::DamageSound(void) +{ + int pitch; + float fvol; + char *rgpsz[6]; + int i; + int material = m_Material; + + if (RANDOM_LONG(0, 2)) + pitch = PITCH_NORM; + else + pitch = 95 + RANDOM_LONG(0, 34); + + fvol = RANDOM_FLOAT(0.75, 1.0); + + if (material == matComputer && RANDOM_LONG(0, 1)) + material = matMetal; + + switch (material) + { + case matGlass: + case matComputer: + case matUnbreakableGlass: + rgpsz[0] = "debris/glass1.wav"; + rgpsz[1] = "debris/glass2.wav"; + rgpsz[2] = "debris/glass3.wav"; + i = 3; + break; + + case matWood: + rgpsz[0] = "debris/wood1.wav"; + rgpsz[1] = "debris/wood2.wav"; + rgpsz[2] = "debris/wood3.wav"; + i = 3; + break; + + case matMetal: + rgpsz[0] = "debris/metal1.wav"; + rgpsz[1] = "debris/metal3.wav"; + rgpsz[2] = "debris/metal2.wav"; + i = 2; + break; + + case matFlesh: + rgpsz[0] = "debris/flesh1.wav"; + rgpsz[1] = "debris/flesh2.wav"; + rgpsz[2] = "debris/flesh3.wav"; + rgpsz[3] = "debris/flesh5.wav"; + rgpsz[4] = "debris/flesh6.wav"; + rgpsz[5] = "debris/flesh7.wav"; + i = 6; + break; + + case matRocks: + case matCinderBlock: + rgpsz[0] = "debris/concrete1.wav"; + rgpsz[1] = "debris/concrete2.wav"; + rgpsz[2] = "debris/concrete3.wav"; + i = 3; + break; + + case matCeilingTile: + // UNDONE: no ceiling tile shard sound yet + i = 0; + break; + } + + if (i) + { + EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, rgpsz[RANDOM_LONG(0, i - 1)], fvol, ATTN_NORM, 0, pitch); + } } -/* <8691c> ../cstrike/dlls/func_break.cpp:475 */ -NOBODY void CBreakable::BreakTouch(CBaseEntity *pOther) -{ -// { -// float flDamage; // 477 -// entvars_t *pevToucher; // 478 -// Length(const Vector *const this); // 500 -// } +/* <8691c> ../cstrike/dlls/func_break.cpp:475 */ +void CBreakable::BreakTouch(CBaseEntity *pOther) +{ + float flDamage; + entvars_t *pevToucher = pOther->pev; + + // only players can break these right now + if (!pOther->IsPlayer() || !IsBreakable()) + { + if (pev->rendermode == kRenderNormal || !FClassnameIs(pOther->pev, "grenade")) + return; + + pev->angles.y = m_angle; + UTIL_MakeVectors(pev->angles); + + g_vecAttackDir = gpGlobals->v_forward; + + pev->takedamage = DAMAGE_NO; + pev->deadflag = DEAD_DEAD; + pev->effects = EF_NODRAW; + + Die(); + } + + // can be broken when run into + if (pev->spawnflags & SF_BREAK_TOUCH) + { + flDamage = pevToucher->velocity.Length() * 0.01; + + if (flDamage >= pev->health) + { + SetTouch(NULL); + TakeDamage(pevToucher, pevToucher, flDamage, DMG_CRUSH); + + // do a little damage to player if we broke glass or computer + pOther->TakeDamage(pev, pev, flDamage / 4, DMG_SLASH); + } + } + + // can be broken when stood upon + if ((pev->spawnflags & SF_BREAK_PRESSURE) && pevToucher->absmin.z >= pev->maxs.z - 2) + { + // play creaking sound here. + DamageSound(); + + SetThink(&CBreakable::Die); + SetTouch(NULL); + + // !!!BUGBUG - why doesn't zero delay work? + if (m_flDelay == 0) + { + m_flDelay = 0.1; + } + + pev->nextthink = pev->ltime + m_flDelay; + } } -/* <85f2d> ../cstrike/dlls/func_break.cpp:538 */ -NOBODY void CBreakable::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// Use(CBreakable *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 538 +// Smash the our breakable object +// Break when triggered + +/* <85f2d> ../cstrike/dlls/func_break.cpp:538 */ +void CBreakable::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (IsBreakable()) + { + pev->angles.y = m_angle; + UTIL_MakeVectors(pev->angles); + g_vecAttackDir = gpGlobals->v_forward; + + pev->takedamage = DAMAGE_NO; + pev->deadflag = DEAD_DEAD; + pev->effects = EF_NODRAW; + + Die(); + } } -/* <85964> ../cstrike/dlls/func_break.cpp:554 */ -NOBODY void CBreakable::__MAKE_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) -{ -// { -// float flVolume; // 565 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 568 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 569 -// } -// Vector(Vector *const this, -// const Vector &v); // 580 +/* <85964> ../cstrike/dlls/func_break.cpp:554 */ +void CBreakable::__MAKE_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +{ + // random spark if this is a 'computer' object + if (RANDOM_LONG(0, 1)) + { + switch (m_Material) + { + case matComputer: + { + UTIL_Sparks(ptr->vecEndPos); + + //random volume range + float flVolume = RANDOM_FLOAT(0.7 , 1.0); + switch (RANDOM_LONG(0, 1)) + { + case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM); break; + case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM); break; + } + + break; + } + + case matUnbreakableGlass: + { + UTIL_Ricochet(ptr->vecEndPos, RANDOM_FLOAT(0.5, 1.5)); + break; + } + } + } + + CBaseDelay::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType); } -/* <86719> ../cstrike/dlls/func_break.cpp:588 */ -NOBODY int CBreakable::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ -// { -// Vector vecTemp; // 590 -// operator*(const Vector *const this, -// float fl); // 606 -// operator+(const Vector *const this, -// const Vector &v); // 606 -// operator-(const Vector *const this, -// const Vector &v); // 606 -// Normalize(const Vector *const this); // 621 -// operator*(const Vector *const this, -// float fl); // 596 -// operator+(const Vector *const this, -// const Vector &v); // 596 -// operator-(const Vector *const this, -// const Vector &v); // 596 -// } +// Special takedamage for func_breakable. Allows us to make +// exceptions that are breakable-specific +// bitsDamageType indicates the type of damage sustained ie: DMG_CRUSH + +/* <86719> ../cstrike/dlls/func_break.cpp:588 */ +int CBreakable::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + Vector vecTemp; + + // 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). + if (pevAttacker == pevInflictor) + { + vecTemp = pevInflictor->origin - (pev->absmin + (pev->size * 0.5)); + + // if a client hit the breakable with a crowbar, and breakable is crowbar-sensitive, break it now. + if ((pevAttacker->flags & FL_CLIENT) && (pev->spawnflags & SF_BREAK_CROWBAR) && (bitsDamageType & DMG_CLUB)) + { + flDamage = pev->health; + } + } + else + { + // an actual missile was involved. + vecTemp = pevInflictor->origin - (pev->absmin + (pev->size * 0.5)); + } + + if (!IsBreakable()) + return 0; + + // Breakables take double damage from the crowbar + if (bitsDamageType & DMG_CLUB) + { + flDamage *= 2; + } + + // Boxes / glass / etc. don't take much poison damage, just the impact of the dart - consider that 10% + if (bitsDamageType & DMG_POISON) + { + flDamage *= 0.1; + } + + // this global is still used for glass and other non-monster killables, along with decals. + g_vecAttackDir = vecTemp.Normalize(); + + // do the damage + pev->health -= flDamage; + + if (pev->health <= 0) + { + pev->takedamage = 0; + pev->deadflag = DEAD_DEAD; + pev->effects = EF_NODRAW; + Die(); + + if (m_flDelay == 0) + { + m_flDelay = 0.1; + } + + pev->nextthink = pev->ltime + m_flDelay; + return 0; + } + + // Make a shard noise each time func breakable is hit. + // Don't play shard noise if cbreakable actually died. + DamageSound(); + + return 1; } -/* <856fe> ../cstrike/dlls/func_break.cpp:653 */ -NOBODY void CBreakable::Die(void) -{ -// { -// Vector vecSpot; // 655 -// Vector vecVelocity; // 656 -// class CBaseEntity *pEntity; // 657 -// char cFlag; // 658 -// int pitch; // 659 -// float fvol; // 660 -// float size; // 790 -// Vector mins; // 798 -// Vector maxs; // 799 -// class CBaseEntity *pList; // 804 -// int count; // 805 -// operator+(const Vector *const this, -// const Vector &v); // 755 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 756 -// operator*(const Vector *const this, -// float fl); // 755 -// operator+(const Vector *const this, -// const Vector &v); // 755 -// Vector(Vector *const this, -// const Vector &v); // 798 -// Vector(Vector *const this, -// const Vector &v); // 799 -// { -// int i; // 808 -// } -// Explodable(CBreakable *const this); // 825 -// edict(CBaseEntity *const this); // 827 -// operator*(const Vector *const this, -// float fl); // 747 -// edict(CBaseEntity *const this); // 822 -// } +/* <856fe> ../cstrike/dlls/func_break.cpp:653 */ +void CBreakable::Die(void) +{ + Vector vecSpot; // shard origin + Vector vecVelocity; // shard velocity + CBaseEntity *pEntity = NULL; + char cFlag = 0; + int pitch; + float fvol; + + pitch = 95 + RANDOM_LONG(0, 29); + + if (pitch > 97 && pitch < 103) + pitch = 100; + + // The more negative pev->health, the louder + // the sound should be. + fvol = RANDOM_FLOAT(0.85, 1.0) + (abs((int)pev->health) / 100.0); + + if (fvol > 1.0) + fvol = 1.0; + + switch (m_Material) + { + case matGlass: + switch (RANDOM_LONG(0, 1)) + { + case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustglass1.wav", fvol, ATTN_NORM, 0, pitch); + break; + case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustglass2.wav", fvol, ATTN_NORM, 0, pitch); + break; + } + cFlag = BREAK_GLASS; + TheBots->OnEvent(EVENT_BREAK_GLASS, this); + break; + + case matWood: + switch (RANDOM_LONG(0, 1)) + { + case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustcrate1.wav", fvol, ATTN_NORM, 0, pitch); + break; + case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustcrate2.wav", fvol, ATTN_NORM, 0, pitch); + break; + } + cFlag = BREAK_WOOD; + TheBots->OnEvent(EVENT_BREAK_WOOD, this); + break; + + case matMetal: + case matComputer: + switch (RANDOM_LONG(0, 1)) + { + case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustmetal1.wav", fvol, ATTN_NORM, 0, pitch); + break; + case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustmetal2.wav", fvol, ATTN_NORM, 0, pitch); + break; + } + cFlag = BREAK_METAL; + TheBots->OnEvent(EVENT_BREAK_METAL, this); + break; + + case matFlesh: + switch (RANDOM_LONG(0, 1)) + { + case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustflesh1.wav", fvol, ATTN_NORM, 0, pitch); + break; + case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustflesh2.wav", fvol, ATTN_NORM, 0, pitch); + break; + } + cFlag = BREAK_FLESH; + TheBots->OnEvent(EVENT_BREAK_FLESH, this); + break; + + case matCinderBlock: + case matRocks: + switch (RANDOM_LONG(0, 1)) + { + case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustconcrete1.wav", fvol, ATTN_NORM, 0, pitch); + break; + case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustconcrete2.wav", fvol, ATTN_NORM, 0, pitch); + break; + } + cFlag = BREAK_CONCRETE; + TheBots->OnEvent(EVENT_BREAK_CONCRETE, this); + break; + + case matCeilingTile: + EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch); + break; + } + + if (m_Explosion == expDirected) + { + vecVelocity = g_vecAttackDir * 200; + } + else + { + vecVelocity.x = 0; + vecVelocity.y = 0; + vecVelocity.z = 0; + } + + vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; + + MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, vecSpot); + WRITE_BYTE(TE_BREAKMODEL); + WRITE_COORD(vecSpot.x); // position + WRITE_COORD(vecSpot.y); + WRITE_COORD(vecSpot.z); + WRITE_COORD(pev->size.x); // size + WRITE_COORD(pev->size.y); + WRITE_COORD(pev->size.z); + WRITE_COORD(vecVelocity.x); // velocity + WRITE_COORD(vecVelocity.y); + WRITE_COORD(vecVelocity.z); + WRITE_BYTE(10); // randomization + WRITE_SHORT(m_idShard); // model id# + WRITE_BYTE(0); // # of shards, let client decide + WRITE_BYTE(25); // duration, 2.5 seconds + WRITE_BYTE(cFlag); // flags + MESSAGE_END(); + + float size = pev->size.x; + + if (size < pev->size.y) + size = pev->size.y; + + if (size < pev->size.z) + size = pev->size.z; + + Vector mins = pev->absmin; + Vector maxs = pev->absmax; + mins.z = pev->absmax.z; + maxs.z += 8; + + CBaseEntity *pList[256]; + int count = UTIL_EntitiesInBox(pList, ARRAYSIZE(pList), mins, maxs, FL_ONGROUND); + + if (count) + { + for (int i = 0; i < count; i++) + { + pList[i]->pev->flags &= ~FL_ONGROUND; + pList[i]->pev->groundentity = NULL; + } + } + + pev->solid = SOLID_NOT; + SUB_UseTargets(NULL, USE_TOGGLE, 0); + SetThink(NULL); + + pev->nextthink = pev->ltime + 0.1; + + if (m_iszSpawnObject) + { + CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict()); + } + + if (Explodable()) + { + ExplosionCreate(Center(), pev->angles, edict(), ExplosionMagnitude(), TRUE); + } } -/* <86992> ../cstrike/dlls/func_break.cpp:833 */ -NOBODY BOOL CBreakable::IsBreakable(void) -{ +/* <86992> ../cstrike/dlls/func_break.cpp:833 */ +BOOL CBreakable::IsBreakable(void) +{ + return m_Material != matUnbreakableGlass; } -/* <85a99> ../cstrike/dlls/func_break.cpp:839 */ -NOBODY int CBreakable::__MAKE_VHOOK(DamageDecal)(int bitsDamageType) -{ -// DamageDecal(CBreakable *const this, -// int bitsDamageType); // 839 +/* <85a99> ../cstrike/dlls/func_break.cpp:839 */ +int CBreakable::__MAKE_VHOOK(DamageDecal)(int bitsDamageType) +{ + if (m_Material == matGlass) + return DECAL_GLASSBREAK1 + RANDOM_LONG(0, 2); + + if (m_Material == matUnbreakableGlass) + return DECAL_BPROOF1; + + return CBaseEntity::DamageDecal(bitsDamageType); } -/* <869b4> ../cstrike/dlls/func_break.cpp:888 */ -LINK_ENTITY_TO_CLASS(func_pushable, CPushable); - +/* <869b4> ../cstrike/dlls/func_break.cpp:888 */ +LINK_ENTITY_TO_CLASS(func_pushable, CPushable); + /* <85e0b> ../cstrike/dlls/func_break.cpp:886 */ IMPLEMENT_SAVERESTORE(CPushable, CBreakable); -/* <856d7> ../cstrike/dlls/func_break.cpp:893 */ -NOBODY void CPushable::__MAKE_VHOOK(Spawn)(void) -{ +/* <856d7> ../cstrike/dlls/func_break.cpp:893 */ +void CPushable::__MAKE_VHOOK(Spawn)(void) +{ + if (pev->spawnflags & SF_PUSH_BREAKABLE) + CBreakable::Spawn(); + else + Precache(); + + pev->movetype = MOVETYPE_PUSHSTEP; + pev->solid = SOLID_BBOX; + + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (pev->friction > 399) + { + pev->friction = 399; + } + + m_maxSpeed = 400 - pev->friction; + + pev->flags |= FL_FLOAT; + pev->friction = 0; + + // Pick up off of the floor + pev->origin.z += 1; + UTIL_SetOrigin(pev, pev->origin); + + // Multiply by area of the box's cross-section (assume 1000 units^3 standard volume) + pev->skin = (int)((pev->skin * (pev->maxs.x - pev->mins.x) * (pev->maxs.y - pev->mins.y)) * 0.0005); + m_soundTime = 0; } -/* <863eb> ../cstrike/dlls/func_break.cpp:920 */ -NOBODY void CPushable::__MAKE_VHOOK(Precache)(void) -{ -// { -// int i; // 922 -// } +/* <863eb> ../cstrike/dlls/func_break.cpp:920 */ +void CPushable::__MAKE_VHOOK(Precache)(void) +{ + for (int i = 0; i < 3; i++) + { + PRECACHE_SOUND(m_soundNames[i]); + } + + if (pev->spawnflags & SF_PUSH_BREAKABLE) + { + CBreakable::Precache(); + } } -/* <85fa3> ../cstrike/dlls/func_break.cpp:930 */ -NOBODY void CPushable::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// { -// int bbox; // 934 -// } -// FStrEq(const char *sz1, -// const char *sz2); // 932 -// FStrEq(const char *sz1, -// const char *sz2); // 958 -// KeyValue(CBreakable *const this, -// KeyValueData *pkvd); // 964 -// atof(const char *__nptr); // 960 -// KeyValue(CPushable *const this, -// KeyValueData *pkvd); // 930 +/* <85fa3> ../cstrike/dlls/func_break.cpp:930 */ +void CPushable::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "size")) + { + int bbox = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + + switch (bbox) + { + case 0: // Point + UTIL_SetSize(pev, Vector(-8, -8, -8), Vector(8, 8, 8)); + break; + + case 2: // Big Hull!?!? !!!BUGBUG Figure out what this hull really is + UTIL_SetSize(pev, VEC_DUCK_HULL_MIN * 2, VEC_DUCK_HULL_MAX * 2); + break; + + case 3: // Player duck + UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); + break; + + default: + case 1: // Player + UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + break; + } + + } + else if (FStrEq(pkvd->szKeyName, "buoyancy")) + { + pev->skin = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBreakable::KeyValue(pkvd); } -/* <86c0d> ../cstrike/dlls/func_break.cpp:969 */ -NOBODY void CPushable::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// Use(CPushable *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 969 -// operator!=(const Vector *const this, -// const Vector &v); // 978 +// Pull the func_pushable + +/* <86c0d> ../cstrike/dlls/func_break.cpp:969 */ +void CPushable::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!pActivator || !pActivator->IsPlayer()) + { + if (pev->spawnflags & SF_PUSH_BREAKABLE) + { + this->CBreakable::Use(pActivator, pCaller, useType, value); + } + + return; + } + + if (pActivator->pev->velocity != g_vecZero) + { + Move(pActivator, 0); + } } -/* <86b99> ../cstrike/dlls/func_break.cpp:983 */ -NOBODY void CPushable::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) -{ -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 985 +/* <86b99> ../cstrike/dlls/func_break.cpp:983 */ +void CPushable::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +{ + if (FClassnameIs(pOther->pev, "worldspawn")) + return; + + Move(pOther, 1); } -/* <86a82> ../cstrike/dlls/func_break.cpp:992 */ -NOBODY void CPushable::Move(CBaseEntity *pOther, int push) -{ -// { -// entvars_t *pevToucher; // 994 -// int playerTouch; // 995 -// float factor; // 1015 -// float length; // 1035 -// VARS(edict_t *pent); // 998 -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 1056 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 1051 -// } +/* <86a82> ../cstrike/dlls/func_break.cpp:992 */ +void CPushable::Move(CBaseEntity *pOther, int push) +{ + entvars_t *pevToucher = pOther->pev; + int playerTouch = 0; + + // Is entity standing on this pushable ? + if ((pevToucher->flags & FL_ONGROUND) && pevToucher->groundentity && VARS(pevToucher->groundentity) == pev) + { + // Only push if floating + if (pev->waterlevel > 0) + { + pev->velocity.z += pevToucher->velocity.z * 0.1; + } + + return; + } + + if (pOther->IsPlayer()) + { + // Don't push unless the player is pushing forward and NOT use (pull) + if (push && !(pevToucher->button & (IN_FORWARD | IN_USE))) + { + return; + } + + playerTouch = 1; + } + + float_precision factor; + + if (playerTouch) + { + // Don't push away from jumping/falling players unless in water + if (!(pevToucher->flags & FL_ONGROUND)) + { + if (pev->waterlevel < 1) + return; + else + factor = 0.1; + } + else + factor = 1; + } + else + factor = 0.25; + + pev->velocity.x += pevToucher->velocity.x * factor; + pev->velocity.y += pevToucher->velocity.y * factor; + + float_precision length = sqrt(pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y); + + if (push && (length > MaxSpeed())) + { + pev->velocity.x = (pev->velocity.x * MaxSpeed() / length); + pev->velocity.y = (pev->velocity.y * MaxSpeed() / length); + } + + if (playerTouch) + { + pevToucher->velocity.x = pev->velocity.x; + pevToucher->velocity.y = pev->velocity.y; + + if ((gpGlobals->time - m_soundTime) > 0.7) + { + m_soundTime = gpGlobals->time; + + if (length > 0 && (pev->flags & FL_ONGROUND)) + { + m_lastSound = RANDOM_LONG(0, 2); + EMIT_SOUND(ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound], 0.5, ATTN_NORM); + + //SetThink(StopSound); + //pev->nextthink = pev->ltime + 0.1; + } + else + STOP_SOUND(ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound]); + } + } } -/* <868b0> ../cstrike/dlls/func_break.cpp:1061 */ -NOBODY int CPushable::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ -// TakeDamage(CPushable *const this, -// entvars_t *pevInflictor, -// entvars_t *pevAttacker, -// float flDamage, -// int bitsDamageType); // 1061 +/* <868b0> ../cstrike/dlls/func_break.cpp:1061 */ +int CPushable::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + if (pev->spawnflags & SF_PUSH_BREAKABLE) + { + return CBreakable::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); + } + + return 1; } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/func_break.h b/regamedll/dlls/func_break.h index df642cb3..b359b89c 100644 --- a/regamedll/dlls/func_break.h +++ b/regamedll/dlls/func_break.h @@ -35,6 +35,15 @@ // this many shards spawned when breakable objects break; #define NUM_SHARDS 6 +// func breakable +#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger +#define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass) +#define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it +#define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar + +// func_pushable (it's also func_breakable, so don't collide with those flags) +#define SF_PUSH_BREAKABLE 128 + typedef enum { expRandom = 0, @@ -75,25 +84,25 @@ class CBreakable: public CBaseDelay { public: // basic functions - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual void Restart(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } // To spark when hit - NOBODY virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); // breakables use an overridden takedamage - NOBODY 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); - NOBODY virtual int DamageDecal(int bitsDamageType); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual int DamageDecal(int bitsDamageType); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -115,14 +124,14 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT BreakTouch(CBaseEntity *pOther); - NOBODY void DamageSound(void); + void EXPORT BreakTouch(CBaseEntity *pOther); + void DamageSound(void); - NOBODY BOOL IsBreakable(void); - NOBODY BOOL SparkWhenHit(void); + BOOL IsBreakable(void); + NOXREF BOOL SparkWhenHit(void); + + void EXPORT Die(void); - NOBODY void EXPORT Die(void); - inline BOOL Explodable(void) { return ExplosionMagnitude() > 0; @@ -160,23 +169,23 @@ public: };/* size: 188, cachelines: 3, members: 15 */ -/* <84da0> ../cstrike/dlls/func_break.cpp:851 */ +/* <84da0> ../cstrike/dlls/func_break.cpp:851 */ class CPushable: public CBreakable { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY virtual void Touch(CBaseEntity *pOther); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - + virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + virtual void Touch(CBaseEntity *pOther); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + #ifdef HOOK_GAMEDLL void Spawn_(void); @@ -195,8 +204,17 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void Move(CBaseEntity *pMover, int push); - NOBODY void EXPORT StopSound(void); + void Move(CBaseEntity *pMover, int push); + void EXPORT StopSound(void) + { +#if 0 + Vector dist = pev->oldorigin - pev->origin; + if (dist.Length() <= 0) + { + STOP_SOUND(ENT(pev), CHAN_WEAPON, m_soundNames[m_lastSound]); + } +#endif + } inline float MaxSpeed(void) { return m_maxSpeed; @@ -214,4 +232,8 @@ public: };/* size: 200, cachelines: 4, members: 6 */ +// linked objects +C_DLLEXPORT void func_breakable(entvars_t *pev); +C_DLLEXPORT void func_pushable(entvars_t *pev); + #endif // FUNC_BREAK_H diff --git a/regamedll/dlls/func_tank.cpp b/regamedll/dlls/func_tank.cpp index a645d708..cda8ced8 100644 --- a/regamedll/dlls/func_tank.cpp +++ b/regamedll/dlls/func_tank.cpp @@ -4,7 +4,7 @@ * Globals initialization */ #ifndef HOOK_GAMEDLL - + TYPEDESCRIPTION CFuncTank::m_SaveData[] = { DEFINE_FIELD(CFuncTank, m_yawCenter, FIELD_FLOAT), @@ -33,479 +33,930 @@ TYPEDESCRIPTION CFuncTank::m_SaveData[] = DEFINE_FIELD(CFuncTank, m_flNextAttack, FIELD_TIME), DEFINE_FIELD(CFuncTank, m_iBulletDamage, FIELD_INTEGER), DEFINE_FIELD(CFuncTank, m_iszMaster, FIELD_STRING), -}; - +}; + TYPEDESCRIPTION CFuncTankLaser::m_SaveData[] = { DEFINE_FIELD(CFuncTankLaser, m_pLaser, FIELD_CLASSPTR), DEFINE_FIELD(CFuncTankLaser, m_laserTime, FIELD_TIME), -}; - +}; + TYPEDESCRIPTION CFuncTankControls::m_SaveData[] = { DEFINE_FIELD(CFuncTankControls, m_pTank, FIELD_CLASSPTR), -}; - -#else - -TYPEDESCRIPTION (*CFuncTank::pm_SaveData)[26]; -TYPEDESCRIPTION (*CFuncTankLaser::pm_SaveData)[2]; -TYPEDESCRIPTION (*CFuncTankControls::pm_SaveData)[1]; - +}; + +static Vector gTankSpread[] = +{ + Vector(0, 0, 0), // perfect + Vector(0.025, 0.025, 0.025), // small cone + Vector(0.05, 0.05, 0.05), // medium cone + Vector(0.1, 0.1, 0.1), // large cone + Vector(0.25, 0.25, 0.25), // extra-large cone +}; + +#else + +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncTank, m_SaveData)[26]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncTankLaser, m_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncTankControls, m_SaveData)[1]; +Vector gTankSpread[5]; + #endif // HOOK_GAMEDLL -/* <8ea25> ../cstrike/dlls/func_tank.cpp:177 */ -NOBODY void CFuncTank::__MAKE_VHOOK(Spawn)(void) -{ -// IsActive(CFuncTank *const this); // 188 -// BarrelPosition(CFuncTank *const this); // 191 +#define MAX_FIRING_SPREADS ARRAYSIZE(gTankSpread) + +/* <8d76a> ../cstrike/dlls/func_tank.cpp:164 */ +IMPLEMENT_SAVERESTORE(CFuncTank, CBaseEntity); + +/* <8ea25> ../cstrike/dlls/func_tank.cpp:177 */ +void CFuncTank::__MAKE_VHOOK(Spawn)(void) +{ + Precache(); + + // so it doesn't get pushed by anything + pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + SET_MODEL(ENT(pev), STRING(pev->model)); + + m_yawCenter = pev->angles.y; + m_pitchCenter = pev->angles.x; + + if (IsActive()) + { + pev->nextthink = pev->ltime + 1.0; + } + + // Point at the end of the barrel + m_sightOrigin = BarrelPosition(); + + if (m_fireRate <= 0) + m_fireRate = 1; + + if (m_spread > MAX_FIRING_SPREADS) + m_spread = 0; + + pev->oldorigin = pev->origin; } -/* <8d76a> ../cstrike/dlls/func_tank.cpp:164 */ -IMPLEMENT_SAVERESTORE(CFuncTank, CBaseEntity); - -/* <8d64d> ../cstrike/dlls/func_tank.cpp:202 */ -NOBODY void CFuncTank::__MAKE_VHOOK(Precache)(void) -{ -// Precache(CFuncTank *const this); // 202 -} +/* <8d64d> ../cstrike/dlls/func_tank.cpp:202 */ +void CFuncTank::__MAKE_VHOOK(Precache)(void) +{ + if (m_iszSpriteSmoke) + { + PRECACHE_MODEL((char *)STRING(m_iszSpriteSmoke)); + } -/* <8e19e> ../cstrike/dlls/func_tank.cpp:214 */ -NOBODY void CFuncTank::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 226 -// FStrEq(const char *sz1, -// const char *sz2); // 231 -// FStrEq(const char *sz1, -// const char *sz2); // 236 -// FStrEq(const char *sz1, -// const char *sz2); // 241 -// FStrEq(const char *sz1, -// const char *sz2); // 246 -// FStrEq(const char *sz1, -// const char *sz2); // 251 -// FStrEq(const char *sz1, -// const char *sz2); // 256 -// FStrEq(const char *sz1, -// const char *sz2); // 261 -// FStrEq(const char *sz1, -// const char *sz2); // 266 -// FStrEq(const char *sz1, -// const char *sz2); // 271 -// FStrEq(const char *sz1, -// const char *sz2); // 276 -// FStrEq(const char *sz1, -// const char *sz2); // 281 -// FStrEq(const char *sz1, -// const char *sz2); // 286 -// FStrEq(const char *sz1, -// const char *sz2); // 291 -// FStrEq(const char *sz1, -// const char *sz2); // 296 -// FStrEq(const char *sz1, -// const char *sz2); // 301 -// FStrEq(const char *sz1, -// const char *sz2); // 306 -// FStrEq(const char *sz1, -// const char *sz2); // 311 -// FStrEq(const char *sz1, -// const char *sz2); // 316 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 322 -// atof(const char *__nptr); // 228 -// atof(const char *__nptr); // 238 -// atof(const char *__nptr); // 258 -// atof(const char *__nptr); // 233 -// atof(const char *__nptr); // 243 -// atof(const char *__nptr); // 248 -// atof(const char *__nptr); // 253 -// atof(const char *__nptr); // 288 -// atof(const char *__nptr); // 263 -// atof(const char *__nptr); // 268 -// atoi(const char *__nptr); // 293 -// atoi(const char *__nptr); // 298 -// atoi(const char *__nptr); // 303 -// atof(const char *__nptr); // 308 -// atof(const char *__nptr); // 313 + if (m_iszSpriteFlash) + { + PRECACHE_MODEL((char *)STRING(m_iszSpriteFlash)); + } + + if (pev->noise) + { + PRECACHE_SOUND((char *)STRING(pev->noise)); + } } -/* <8dca8> ../cstrike/dlls/func_tank.cpp:329 */ -NOBODY BOOL CFuncTank::__MAKE_VHOOK(OnControls)(entvars_t *pevTest) -{ -// { -// Vector offset; // 334 -// } -// OnControls(CFuncTank *const this, -// entvars_t *pevTest); // 329 +/* <8e19e> ../cstrike/dlls/func_tank.cpp:214 */ +void CFuncTank::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "yawrate")) + { + m_yawRate = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "yawrange")) + { + m_yawRange = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "yawtolerance")) + { + m_yawTolerance = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "pitchrange")) + { + m_pitchRange = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "pitchrate")) + { + m_pitchRate = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "pitchtolerance")) + { + m_pitchTolerance = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "firerate")) + { + m_fireRate = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "barrel")) + { + m_barrelPos.x = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "barrely")) + { + m_barrelPos.y = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "barrelz")) + { + m_barrelPos.z = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "spritescale")) + { + m_spriteScale = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "spritesmoke")) + { + m_iszSpriteSmoke = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "spriteflash")) + { + m_iszSpriteFlash = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "rotatesound")) + { + pev->noise = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "persistence")) + { + m_persist = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "bullet")) + { + m_bulletType = (TANKBULLET)Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "bullet_damage")) + { + m_iBulletDamage = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "firespread")) + { + m_spread = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "minRange")) + { + m_minRange = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "maxRange")) + { + m_maxRange = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "master")) + { + m_iszMaster = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } -/* <8eba8> ../cstrike/dlls/func_tank.cpp:342 */ -NOBODY BOOL CFuncTank::StartControl(CBasePlayer *pController) -{ +/* <8dca8> ../cstrike/dlls/func_tank.cpp:329 */ +BOOL CFuncTank::__MAKE_VHOOK(OnControls)(entvars_t *pevTest) +{ + if (!(pev->spawnflags & SF_TANK_CANCONTROL)) + return FALSE; + + Vector offset = pevTest->origin - pev->origin; + + if ((m_vecControllerUsePos - pevTest->origin).Length() < 30) + { + return TRUE; + } + + return FALSE; } -/* <8ebde> ../cstrike/dlls/func_tank.cpp:372 */ -NOBODY void CFuncTank::StopControl(void) -{ -// IsActive(CFuncTank *const this); // 393 +/* <8eba8> ../cstrike/dlls/func_tank.cpp:342 */ +BOOL CFuncTank::StartControl(CBasePlayer *pController) +{ + if (m_pController != NULL) + return FALSE; + + // Team only or disabled? + if (m_iszMaster) + { + if (!UTIL_IsMasterTriggered(m_iszMaster, pController)) + { + return FALSE; + } + } + + ALERT(at_console, "using TANK!\n"); + + m_pController = pController; + + if (m_pController->m_pActiveItem != NULL) + { + m_pController->m_pActiveItem->Holster(); + m_pController->pev->weaponmodel = 0; + //m_pController->pev->viewmodel = 0; + } + + m_pController->m_iHideHUD |= HIDEHUD_WEAPONS; + m_vecControllerUsePos = m_pController->pev->origin; + + pev->nextthink = pev->ltime + 0.1; + + return TRUE; } -/* <8ec15> ../cstrike/dlls/func_tank.cpp:398 */ -NOBODY void CFuncTank::ControllerPostFrame(void) -{ -// { -// Vector vecForward; // 407 -// UTIL_MakeVectorsPrivate(Vector &vecAngles, -// float *p_vForward, -// float *p_vRight, -// float *p_vUp); // 408 -// BarrelPosition(CFuncTank *const this); // 412 -// } +/* <8ebde> ../cstrike/dlls/func_tank.cpp:372 */ +void CFuncTank::StopControl(void) +{ + // TODO: bring back the controllers current weapon + if (!m_pController) + return; + + if (m_pController->m_pActiveItem != NULL) + { + m_pController->m_pActiveItem->Deploy(); + + if (m_pController->IsPlayer()) + { + m_pController->ResetMaxSpeed(); + } + } + + ALERT(at_console, "stopped using TANK\n"); + + m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS; + + pev->nextthink = 0; + m_pController = NULL; + + if (IsActive()) + { + pev->nextthink = pev->ltime + 1.0; + } } -/* <8ee12> ../cstrike/dlls/func_tank.cpp:424 */ -NOBODY void CFuncTank::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// IsActive(CFuncTank *const this); // 448 -// IsActive(CFuncTank *const this); // 451 -// TankDeactivate(CFuncTank *const this); // 452 -// TankActivate(CFuncTank *const this); // 454 +/* <8ec15> ../cstrike/dlls/func_tank.cpp:398 */ +void CFuncTank::ControllerPostFrame(void) +{ + assert(m_pController != NULL); + + if (gpGlobals->time < m_flNextAttack) + return; + + if (m_pController->pev->button & IN_ATTACK) + { + Vector vecForward; + UTIL_MakeVectorsPrivate(pev->angles, vecForward, NULL, NULL); + + m_fireLast = gpGlobals->time - (1 / m_fireRate) - 0.01; + Fire(BarrelPosition(), vecForward, m_pController->pev); + + if (m_pController && m_pController->IsPlayer()) + { + m_pController->m_iWeaponVolume = LOUD_GUN_VOLUME; + } + + m_flNextAttack = gpGlobals->time + (1 / m_fireRate); + } } -/* <8ef04> ../cstrike/dlls/func_tank.cpp:459 */ -NOBODY edict_t *CFuncTank::FindTarget(edict_t *pPlayer) -{ +/* <8ee12> ../cstrike/dlls/func_tank.cpp:424 */ +void CFuncTank::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + // player controlled turret + if (pev->spawnflags & SF_TANK_CANCONTROL) + { + if (pActivator->Classify() != CLASS_PLAYER) + return; + + if (value == 2 && useType == USE_SET) + { + ControllerPostFrame(); + } + else if (!m_pController && useType != USE_OFF) + { + ((CBasePlayer*)pActivator)->m_pTank = this; + StartControl((CBasePlayer*)pActivator); + } + else + { + StopControl(); + } + } + else + { + if (!ShouldToggle(useType, IsActive())) + return; + + if (IsActive()) + TankDeactivate(); + else + TankActivate(); + } } -/* <8ef2d> ../cstrike/dlls/func_tank.cpp:466 */ -NOBODY BOOL CFuncTank::InRange(float range) -{ -// InRange(CFuncTank *const this, -// float range); // 466 +/* <8ef04> ../cstrike/dlls/func_tank.cpp:459 */ +edict_t *CFuncTank::FindTarget(edict_t *pPlayer) +{ + return pPlayer; } -/* <8f717> ../cstrike/dlls/func_tank.cpp:477 */ -NOBODY void CFuncTank::__MAKE_VHOOK(Think)(void) -{ -// fabs(double __x); // 482 -// fabs(double __x); // 482 -// StartRotSound(CFuncTank *const this); // 483 -// StopRotSound(CFuncTank *const this); // 485 +/* <8ef2d> ../cstrike/dlls/func_tank.cpp:466 */ +BOOL CFuncTank::InRange(float range) +{ + if (range < m_minRange) + return FALSE; + + if (m_maxRange > 0 && range > m_maxRange) + return FALSE; + + return TRUE; } -/* <8efe4> ../cstrike/dlls/func_tank.cpp:488 */ -NOBODY void CFuncTank::TrackTarget(void) -{ -// { -// TraceResult tr; // 490 -// edict_t *pPlayer; // 491 -// BOOL updateTime; // 492 -// BOOL lineOfSight; // 492 -// Vector angles; // 493 -// Vector direction; // 493 -// Vector targetPosition; // 493 -// Vector barrelEnd; // 493 -// edict_t *pTarget; // 494 -// float distY; // 578 -// float distX; // 592 -// edict(CBaseEntity *const this); // 491 -// { -// float range; // 524 -// IsActive(CFuncTank *const this); // 506 -// FNullEnt(const edict_t *pent); // 511 -// BarrelPosition(CFuncTank *const this); // 522 -// operator+(const Vector *const this, -// const Vector &v); // 523 -// operator-(const Vector *const this, -// const Vector &v); // 524 -// Length(const Vector *const this); // 524 -// InRange(CFuncTank *const this, -// float range); // 526 -// edict(CBaseEntity *const this); // 529 -// { -// class CBaseEntity *pInstance; // 537 -// InRange(CFuncTank *const this, -// float range); // 538 -// Instance(edict_t *pent); // 537 -// } -// operator-(const Vector *const this, -// const Vector &v); // 548 -// Length(const Vector *const this); // 553 -// IsActive(CFuncTank *const this); // 513 -// } -// CanFire(CFuncTank *const this); // 603 -// fabs(double __x); // 603 -// fabs(double __x); // 603 -// { -// BOOL fire; // 605 -// Vector forward; // 606 -// UTIL_MakeVectorsPrivate(Vector &vecAngles, -// float *p_vForward, -// float *p_vRight, -// float *p_vUp); // 607 -// { -// float length; // 611 -// Length(const Vector *const this); // 611 -// operator*(const Vector *const this, -// float fl); // 612 -// edict(CBaseEntity *const this); // 612 -// operator+(const Vector *const this, -// const Vector &v); // 612 -// } -// BarrelPosition(CFuncTank *const this); // 621 -// } -// } +/* <8f717> ../cstrike/dlls/func_tank.cpp:477 */ +void CFuncTank::__MAKE_VHOOK(Think)(void) +{ + pev->avelocity = g_vecZero; + TrackTarget(); + + if (fabs((float_precision)pev->avelocity.x) > 1 || fabs((float_precision)pev->avelocity.y) > 1) + StartRotSound(); + else + StopRotSound(); } -/* <8ef79> ../cstrike/dlls/func_tank.cpp:632 */ -NOBODY void CFuncTank::AdjustAnglesForBarrel(Vector &angles, float distance) -{ -// { -// float r2; // 634 -// float d2; // 634 -// } +/* <8efe4> ../cstrike/dlls/func_tank.cpp:488 */ +void CFuncTank::TrackTarget(void) +{ + TraceResult tr; + edict_t *pPlayer = FIND_CLIENT_IN_PVS(edict()); + BOOL updateTime = FALSE, lineOfSight; + Vector angles, direction, targetPosition, barrelEnd; + edict_t *pTarget = NULL; + + // Get a position to aim for + if (m_pController != NULL) + { + // Tanks attempt to mirror the player's angles + angles = m_pController->pev->v_angle; + angles.x = 0 - angles.x; + pev->nextthink = pev->ltime + 0.05; + } + else + { + if (IsActive()) + pev->nextthink = pev->ltime + 0.1; + else + return; + + if (FNullEnt(pPlayer)) + { + if (IsActive()) + { + // Wait 2 secs + pev->nextthink = pev->ltime + 2; + } + + return; + } + + pTarget = FindTarget(pPlayer); + if (!pTarget) + { + return; + } + + // Calculate angle needed to aim at target + barrelEnd = BarrelPosition(); + targetPosition = pTarget->v.origin + pTarget->v.view_ofs; + float range = (targetPosition - barrelEnd).Length(); + + if (!InRange(range)) + return; + + UTIL_TraceLine(barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr); + lineOfSight = FALSE; + + // No line of sight, don't track + if (tr.flFraction == 1.0f || tr.pHit == pTarget) + { + lineOfSight = TRUE; + + CBaseEntity *pInstance = CBaseEntity::Instance(pTarget); + if (InRange(range) && pInstance && pInstance->IsAlive()) + { + updateTime = TRUE; + m_sightOrigin = UpdateTargetPosition(pInstance); + } + } + + // Track sight origin + // !!! I'm not sure what i changed + direction = m_sightOrigin - pev->origin; + //direction = m_sightOrigin - barrelEnd; + angles = UTIL_VecToAngles(direction); + + // Calculate the additional rotation to point the end of the barrel at the target (not the gun's center) + AdjustAnglesForBarrel(angles, direction.Length()); + } + + angles.x = -angles.x; + + // Force the angles to be relative to the center position + angles.y = m_yawCenter + UTIL_AngleDistance(angles.y, m_yawCenter); + angles.x = m_pitchCenter + UTIL_AngleDistance(angles.x, m_pitchCenter); + + // Limit against range in y + if (angles.y > m_yawCenter + m_yawRange) + { + angles.y = m_yawCenter + m_yawRange; + + // Don't update if you saw the player, but out of range + updateTime = FALSE; + } + else if (angles.y < (m_yawCenter - m_yawRange)) + { + angles.y = (m_yawCenter - m_yawRange); + + // Don't update if you saw the player, but out of range + updateTime = FALSE; + } + + if (updateTime) + { + m_lastSightTime = gpGlobals->time; + } + + // Move toward target at rate or less + float_precision distY = UTIL_AngleDistance(angles.y, pev->angles.y); + pev->avelocity.y = distY * 10; + + if (pev->avelocity.y > m_yawRate) + { + pev->avelocity.y = m_yawRate; + } + else if (pev->avelocity.y < -m_yawRate) + { + pev->avelocity.y = -m_yawRate; + } + + // Limit against range in x + if (angles.x > m_pitchCenter + m_pitchRange) + { + angles.x = m_pitchCenter + m_pitchRange; + } + else if (angles.x < m_pitchCenter - m_pitchRange) + { + angles.x = m_pitchCenter - m_pitchRange; + } + + // Move toward target at rate or less + float_precision distX = UTIL_AngleDistance(angles.x, pev->angles.x); + pev->avelocity.x = distX * 10; + + if (pev->avelocity.x > m_pitchRate) + { + pev->avelocity.x = m_pitchRate; + } + else if (pev->avelocity.x < -m_pitchRate) + { + pev->avelocity.x = -m_pitchRate; + } + + if (m_pController != NULL) + { + return; + } + + if (CanFire() && ((fabs(distX) < m_pitchTolerance && fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT))) + { + BOOL fire = FALSE; + Vector forward; + UTIL_MakeVectorsPrivate(pev->angles, forward, NULL, NULL); + + if (pev->spawnflags & SF_TANK_LINEOFSIGHT) + { + float length = direction.Length(); + UTIL_TraceLine(barrelEnd, barrelEnd + forward * length, dont_ignore_monsters, edict(), &tr); + + if (tr.pHit == pTarget) + { + fire = TRUE; + } + } + else + fire = TRUE; + + if (fire) + { + Fire(BarrelPosition(), forward, pev); + } + else + m_fireLast = 0; + } + else + m_fireLast = 0; } -/* <8d4ad> ../cstrike/dlls/func_tank.cpp:656 */ -NOBODY void CFuncTank::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) -{ -// { -// class CSprite *pSprite; // 662 -// AnimateAndDie(CSprite *const this, -// float framerate); // 663 -// SetTransparency(CSprite *const this, -// int rendermode, -// int r, -// int g, -// int b, -// int a, -// int fx); // 664 -// SetScale(CSprite *const this, -// float scale); // 666 -// } -// { -// class CSprite *pSprite; // 670 -// SetTransparency(CSprite *const this, -// int rendermode, -// int r, -// int g, -// int b, -// int a, -// int fx); // 672 -// AnimateAndDie(CSprite *const this, -// float framerate); // 671 -// SetScale(CSprite *const this, -// float scale); // 673 -// } +// If barrel is offset, add in additional rotation + +/* <8ef79> ../cstrike/dlls/func_tank.cpp:632 */ +void CFuncTank::AdjustAnglesForBarrel(Vector &angles, float distance) +{ + float_precision r2, d2; + + if (m_barrelPos.y != 0 || m_barrelPos.z != 0) + { + distance -= m_barrelPos.z; + d2 = distance * distance; + + if (m_barrelPos.y) + { + r2 = m_barrelPos.y * m_barrelPos.y; + angles.y += (180.0 / M_PI) * atan2(m_barrelPos.y, sqrt(d2 - r2)); + } + + if (m_barrelPos.z) + { + r2 = m_barrelPos.z * m_barrelPos.z; + angles.x += (180.0 / M_PI) * atan2(-m_barrelPos.z, sqrt(d2 - r2)); + } + } } -/* <8f830> ../cstrike/dlls/func_tank.cpp:684 */ -NOBODY void CFuncTank::TankTrace(const Vector &vecStart, const Vector &vecForward, const Vector &vecSpread, TraceResult &tr) -{ -// { -// float x; // 687 -// float y; // 687 -// float z; // 687 -// Vector vecDir; // 693 -// Vector vecEnd; // 696 -// operator*(float fl, -// const Vector &v); // 695 -// operator*(float fl, -// const Vector &v); // 695 -// operator+(const Vector *const this, -// const Vector &v); // 695 -// operator+(const Vector *const this, -// const Vector &v); // 695 -// operator*(const Vector *const this, -// float fl); // 698 -// operator+(const Vector *const this, -// const Vector &v); // 698 -// edict(CBaseEntity *const this); // 699 -// } -} - -/* <8f9c0> ../cstrike/dlls/func_tank.cpp:703 */ -NOBODY void CFuncTank::StartRotSound(void) -{ -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 708 -} - -/* <8fa1b> ../cstrike/dlls/func_tank.cpp:712 */ -NOBODY void CFuncTank::StopRotSound(void) -{ -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 715 +// Fire targets and spawn sprites + +/* <8d4ad> ../cstrike/dlls/func_tank.cpp:656 */ +void CFuncTank::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) +{ + if (m_fireLast != 0) + { + if (m_iszSpriteSmoke) + { + CSprite *pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteSmoke), barrelEnd, TRUE); + + pSprite->AnimateAndDie(RANDOM_FLOAT(15, 20)); + pSprite->SetTransparency(kRenderTransAlpha, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, 255, kRenderFxNone); + pSprite->pev->velocity.z = RANDOM_FLOAT(40, 80); + pSprite->SetScale(m_spriteScale); + } + + if (m_iszSpriteFlash) + { + CSprite *pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteFlash), barrelEnd, TRUE); + + pSprite->AnimateAndDie(60); + pSprite->SetTransparency(kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation); + pSprite->SetScale(m_spriteScale); + + // Hack Hack, make it stick around for at least 100 ms. + pSprite->pev->nextthink += 0.1; + } + + SUB_UseTargets(this, USE_TOGGLE, 0); + } + + m_fireLast = gpGlobals->time; } -/* <8fa65> ../cstrike/dlls/func_tank.cpp:724 */ +/* <8f830> ../cstrike/dlls/func_tank.cpp:684 */ +void CFuncTank::TankTrace(const Vector &vecStart, const Vector &vecForward, const Vector &vecSpread, TraceResult &tr) +{ + // get circular gaussian spread + float x, z; + float_precision y; + + do + { + x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + z = x * x + y * y; + } + while (z > 1); + + Vector vecDir = vecForward + x * vecSpread.x * gpGlobals->v_right + y * vecSpread.y * gpGlobals->v_up; + Vector vecEnd; + + vecEnd = vecStart + vecDir * 4096; + UTIL_TraceLine(vecStart, vecEnd, dont_ignore_monsters, edict(), &tr); +} + +/* <8f9c0> ../cstrike/dlls/func_tank.cpp:703 */ +void CFuncTank::StartRotSound(void) +{ + if (!pev->noise || (pev->spawnflags & SF_TANK_SOUNDON)) + { + return; + } + + pev->spawnflags |= SF_TANK_SOUNDON; + EMIT_SOUND(edict(), CHAN_STATIC, (char *)STRING(pev->noise), 0.85, ATTN_NORM); +} + +/* <8fa1b> ../cstrike/dlls/func_tank.cpp:712 */ +void CFuncTank::StopRotSound(void) +{ + if (pev->spawnflags & SF_TANK_SOUNDON) + { + STOP_SOUND(edict(), CHAN_STATIC, (char *)STRING(pev->noise)); + } + + pev->spawnflags &= ~SF_TANK_SOUNDON; +} + +/* <8fa65> ../cstrike/dlls/func_tank.cpp:724 */ LINK_ENTITY_TO_CLASS(func_tank, CFuncTankGun); -/* <8c3d5> ../cstrike/dlls/func_tank.cpp:726 */ -NOBODY void CFuncTankGun::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) -{ -// { -// int i; // 728 -// { -// int bulletCount; // 735 -// } -// } -// Fire(CFuncTankGun *const this, -// const Vector &barrelEnd, -// const Vector &forward, -// entvars_t *pevAttacker); // 726 +/* <8c3d5> ../cstrike/dlls/func_tank.cpp:726 */ +void CFuncTankGun::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) +{ + int i; + + if (m_fireLast != 0) + { + // FireBullets needs gpGlobals->v_up, etc. + UTIL_MakeAimVectors(pev->angles); + + int bulletCount = (int)((gpGlobals->time - m_fireLast) * m_fireRate); + + if (bulletCount > 0) + { + for (i = 0; i < bulletCount; i++) + { + switch(m_bulletType) + { + case TANK_BULLET_9MM: + FireBullets(1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_9MM, 1, m_iBulletDamage, pevAttacker); + break; + case TANK_BULLET_MP5: + FireBullets(1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_MP5, 1, m_iBulletDamage, pevAttacker); + break; + case TANK_BULLET_12MM: + FireBullets(1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_12MM, 1, m_iBulletDamage, pevAttacker); + break; + default: + case TANK_BULLET_NONE: + break; + } + } + + CFuncTank::Fire(barrelEnd, forward, pevAttacker); + } + } + else + CFuncTank::Fire(barrelEnd, forward, pevAttacker); } -/* <8fb34> ../cstrike/dlls/func_tank.cpp:785 */ -LINK_ENTITY_TO_CLASS(func_tanklaser, CFuncTankLaser); +/* <8fb34> ../cstrike/dlls/func_tank.cpp:785 */ +LINK_ENTITY_TO_CLASS(func_tanklaser, CFuncTankLaser); -/* <8e07c> ../cstrike/dlls/func_tank.cpp:793 */ -IMPLEMENT_SAVERESTORE(CFuncTankLaser, CFuncTank); +/* <8e07c> ../cstrike/dlls/func_tank.cpp:793 */ +IMPLEMENT_SAVERESTORE(CFuncTankLaser, CFuncTank); -/* <8deed> ../cstrike/dlls/func_tank.cpp:795 */ -NOBODY void CFuncTankLaser::__MAKE_VHOOK(Activate)(void) -{ -// GetLaser(CFuncTankLaser *const this); // 797 -// Activate(CFuncTankLaser *const this); // 795 +/* <8deed> ../cstrike/dlls/func_tank.cpp:795 */ +void CFuncTankLaser::__MAKE_VHOOK(Activate)(void) +{ + if (!GetLaser()) + { + UTIL_Remove(this); + ALERT(at_error, "Laser tank with no env_laser!\n"); + } + else + { + m_pLaser->TurnOff(); + } } -/* <8e8ca> ../cstrike/dlls/func_tank.cpp:809 */ -NOBODY void CFuncTankLaser::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 811 -// KeyValue(CFuncTank *const this, -// KeyValueData *pkvd); // 817 -// KeyValue(CFuncTankLaser *const this, -// KeyValueData *pkvd); // 809 +/* <8e8ca> ../cstrike/dlls/func_tank.cpp:809 */ +void CFuncTankLaser::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "laserentity")) + { + pev->message = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CFuncTank::KeyValue(pkvd); } -/* <8dd79> ../cstrike/dlls/func_tank.cpp:821 */ -NOBODY CLaser *CFuncTankLaser::GetLaser(void) -{ -// { -// edict_t *pentLaser; // 826 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 828 -// FNullEnt(const edict_t *pent); // 829 -// FClassnameIs(edict_t *pent, -// const char *szClassname); // 832 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 838 -// Instance(edict_t *pent); // 834 -// } +/* <8dd79> ../cstrike/dlls/func_tank.cpp:821 */ +CLaser *CFuncTankLaser::GetLaser(void) +{ + if (m_pLaser != NULL) + { + return m_pLaser; + } + + edict_t *pentLaser; + + pentLaser = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->message)); + + while (!FNullEnt(pentLaser)) + { + // Found the landmark + if (FClassnameIs(pentLaser, "env_laser")) + { + m_pLaser = (CLaser *)CBaseEntity::Instance(pentLaser); + break; + } + else + pentLaser = FIND_ENTITY_BY_TARGETNAME(pentLaser, STRING(pev->message)); + } + + return m_pLaser; } -/* <8f809> ../cstrike/dlls/func_tank.cpp:845 */ -NOBODY void CFuncTankLaser::__MAKE_VHOOK(Think)(void) -{ +/* <8f809> ../cstrike/dlls/func_tank.cpp:845 */ +void CFuncTankLaser::__MAKE_VHOOK(Think)(void) +{ + if (m_pLaser != NULL && gpGlobals->time > m_laserTime) + { + m_pLaser->TurnOff(); + } + + CFuncTank::Think(); } -/* <8df51> ../cstrike/dlls/func_tank.cpp:854 */ -NOBODY void CFuncTankLaser::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) -{ -// { -// int i; // 856 -// TraceResult tr; // 857 -// GetLaser(CFuncTankLaser *const this); // 859 -// { -// int bulletCount; // 864 -// } -// } -// Fire(CFuncTankLaser *const this, -// const Vector &barrelEnd, -// const Vector &forward, -// entvars_t *pevAttacker); // 854 +/* <8df51> ../cstrike/dlls/func_tank.cpp:854 */ +void CFuncTankLaser::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) +{ + int i; + TraceResult tr; + + if (m_fireLast != 0 && GetLaser()) + { + // TankTrace needs gpGlobals->v_up, etc. + UTIL_MakeAimVectors(pev->angles); + + int bulletCount = (int)((gpGlobals->time - m_fireLast) * m_fireRate); + + if (bulletCount) + { + for (i = 0; i < bulletCount; i++) + { + m_pLaser->pev->origin = barrelEnd; + TankTrace(barrelEnd, forward, gTankSpread[m_spread], tr); + + m_laserTime = gpGlobals->time; + m_pLaser->TurnOn(); + m_pLaser->pev->dmgtime = gpGlobals->time - 1.0; + m_pLaser->FireAtPoint(tr); + m_pLaser->pev->nextthink = 0; + } + + CFuncTank::Fire(barrelEnd, forward, pev); + } + } + else + { + CFuncTank::Fire(barrelEnd, forward, pev); + } } -/* <8fc2f> ../cstrike/dlls/func_tank.cpp:893 */ -LINK_ENTITY_TO_CLASS(func_tankrocket, CFuncTankRocket); +/* <8fc2f> ../cstrike/dlls/func_tank.cpp:893 */ +LINK_ENTITY_TO_CLASS(func_tankrocket, CFuncTankRocket); -/* <8e736> ../cstrike/dlls/func_tank.cpp:895 */ -NOBODY void CFuncTankRocket::__MAKE_VHOOK(Precache)(void) -{ -// Precache(CFuncTank *const this); // 898 -} - -/* <8d7b6> ../cstrike/dlls/func_tank.cpp:903 */ -NOBODY void CFuncTankRocket::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) -{ -// { -// int i; // 905 -// { -// int bulletCount; // 909 -// { -// class CBaseEntity *pRocket; // 914 -// } -// } -// } -// Fire(CFuncTankRocket *const this, -// const Vector &barrelEnd, -// const Vector &forward, -// entvars_t *pevAttacker); // 903 +/* <8e736> ../cstrike/dlls/func_tank.cpp:895 */ +void CFuncTankRocket::__MAKE_VHOOK(Precache)(void) +{ + UTIL_PrecacheOther("rpg_rocket"); + CFuncTank::Precache(); } -/* <8fcfe> ../cstrike/dlls/func_tank.cpp:930 */ -LINK_ENTITY_TO_CLASS(func_tankmortar, CFuncTankMortar); +/* <8d7b6> ../cstrike/dlls/func_tank.cpp:903 */ +void CFuncTankRocket::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) +{ + int i; -/* <8e790> ../cstrike/dlls/func_tank.cpp:933 */ -NOBODY void CFuncTankMortar::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 935 -// KeyValue(CFuncTank *const this, -// KeyValueData *pkvd); // 941 -// KeyValue(CFuncTankMortar *const this, -// KeyValueData *pkvd); // 933 + if (m_fireLast != 0) + { + int bulletCount = (int)((gpGlobals->time - m_fireLast) * m_fireRate); + + if (bulletCount > 0) + { + for (i = 0; i < bulletCount; i++) + { + CBaseEntity *pRocket = CBaseEntity::Create("rpg_rocket", barrelEnd, pev->angles, edict()); + } + + CFuncTank::Fire(barrelEnd, forward, pev); + } + } + else + CFuncTank::Fire(barrelEnd, forward, pev); } -/* <8dbfa> ../cstrike/dlls/func_tank.cpp:945 */ -NOBODY void CFuncTankMortar::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) -{ -// { -// int bulletCount; // 949 -// { -// TraceResult tr; // 953 -// } -// } -// Fire(CFuncTankMortar *const this, -// const Vector &barrelEnd, -// const Vector &forward, -// entvars_t *pevAttacker); // 945 +/* <8fcfe> ../cstrike/dlls/func_tank.cpp:930 */ +LINK_ENTITY_TO_CLASS(func_tankmortar, CFuncTankMortar); + +/* <8e790> ../cstrike/dlls/func_tank.cpp:933 */ +void CFuncTankMortar::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "iMagnitude")) + { + pev->impulse = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CFuncTank::KeyValue(pkvd); } -/* <8fdcd> ../cstrike/dlls/func_tank.cpp:988 */ +/* <8dbfa> ../cstrike/dlls/func_tank.cpp:945 */ +void CFuncTankMortar::__MAKE_VHOOK(Fire)(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) +{ + if (m_fireLast != 0) + { + int bulletCount = (int)((gpGlobals->time - m_fireLast) * m_fireRate); + + // Only create 1 explosion + if (bulletCount > 0) + { + TraceResult tr; + + // TankTrace needs gpGlobals->v_up, etc. + UTIL_MakeAimVectors(pev->angles); + + TankTrace(barrelEnd, forward, gTankSpread[m_spread], tr); + + ExplosionCreate(tr.vecEndPos, pev->angles, edict(), pev->impulse, TRUE); + + CFuncTank::Fire(barrelEnd, forward, pev); + } + } + else + CFuncTank::Fire(barrelEnd, forward, pev); +} + +/* <8fdcd> ../cstrike/dlls/func_tank.cpp:988 */ LINK_ENTITY_TO_CLASS(func_tankcontrols, CFuncTankControls); -/* <8d71d> ../cstrike/dlls/func_tank.cpp:995 */ +/* <8d71d> ../cstrike/dlls/func_tank.cpp:995 */ IMPLEMENT_SAVERESTORE(CFuncTankControls, CBaseEntity); -/* <8d310> ../cstrike/dlls/func_tank.cpp:1003 */ -NOBODY void CFuncTankControls::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ +/* <8d310> ../cstrike/dlls/func_tank.cpp:1003 */ +void CFuncTankControls::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + // pass the Use command onto the controls + if (m_pTank) + { + m_pTank->Use(pActivator, pCaller, useType, value); + } + + // if this fails, most likely means save/restore hasn't worked properly + assert(m_pTank != NULL); } -/* <8d39a> ../cstrike/dlls/func_tank.cpp:1012 */ -NOBODY void CFuncTankControls::__MAKE_VHOOK(Think)(void) -{ -// { -// edict_t *pTarget; // 1014 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1018 -// FNullEnt(const edict_t *pent); // 1019 -// FNullEnt(const edict_t *pent); // 1021 -// Instance(edict_t *pent); // 1027 -// } +/* <8d39a> ../cstrike/dlls/func_tank.cpp:1012 */ +void CFuncTankControls::__MAKE_VHOOK(Think)(void) +{ + edict_t *pTarget = NULL; + + do + { + pTarget = FIND_ENTITY_BY_TARGETNAME(pTarget, STRING(pev->target)); + } + while (!FNullEnt(pTarget) && Q_strncmp(STRING(pTarget->v.classname), "func_tank", 9)); + + if (FNullEnt(pTarget)) + { + ALERT(at_console, "No tank %s\n", STRING(pev->target)); + return; + } + + m_pTank = reinterpret_cast(Instance(pTarget)); } -/* <8d373> ../cstrike/dlls/func_tank.cpp:1030 */ -NOBODY void CFuncTankControls::__MAKE_VHOOK(Spawn)(void) -{ +/* <8d373> ../cstrike/dlls/func_tank.cpp:1030 */ +void CFuncTankControls::__MAKE_VHOOK(Spawn)(void) +{ + pev->solid = SOLID_TRIGGER; + pev->movetype = MOVETYPE_NONE; + pev->effects |= EF_NODRAW; + + SET_MODEL(ENT(pev), STRING(pev->model)); + + UTIL_SetSize(pev, pev->mins, pev->maxs); + UTIL_SetOrigin(pev, pev->origin); + + // After all the func_tank's have spawned + pev->nextthink = gpGlobals->time + 0.3; + + CBaseEntity::Spawn(); } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/func_tank.h b/regamedll/dlls/func_tank.h index 325fc509..7008cff3 100644 --- a/regamedll/dlls/func_tank.h +++ b/regamedll/dlls/func_tank.h @@ -40,36 +40,38 @@ #define SF_TANK_CANCONTROL 0x0020 #define SF_TANK_SOUNDON 0x8000 -enum TANKBULLET -{ - TANK_BULLET_NONE = 0, - TANK_BULLET_9MM, - TANK_BULLET_MP5, - TANK_BULLET_12MM, +enum TANKBULLET +{ + TANK_BULLET_NONE = 0, // Custom damage + TANK_BULLET_9MM, // env_laser (duration is 0.5 rate of fire) + TANK_BULLET_MP5, // rockets + TANK_BULLET_12MM, // explosion? }; -/* <8c75e> ../cstrike/dlls/func_tank.cpp:46 */ +/* <8c75e> ../cstrike/dlls/func_tank.cpp:46 */ class CFuncTank: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + + // Bmodels don't go across transitions + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual BOOL OnControls(entvars_t *pevTest); - NOBODY virtual void Think(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); - NOBODY virtual Vector UpdateTargetPosition(CBaseEntity *pTarget) + virtual BOOL OnControls(entvars_t *pevTest); + virtual void Think(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); + virtual Vector UpdateTargetPosition(CBaseEntity *pTarget) { - return UpdateTargetPosition_(pTarget); + return pTarget->BodyTarget(pev->origin); } - + #ifdef HOOK_GAMEDLL void Spawn_(void); @@ -85,17 +87,13 @@ public: void Think_(void); void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void Fire_(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); - Vector UpdateTargetPosition_(CBaseEntity *pTarget) - { - return pTarget->BodyTarget(pev->origin); - } #endif // HOOK_GAMEDLL public: - NOBODY void TrackTarget(void); - NOBODY void StartRotSound(void); - NOBODY void StopRotSound(void); + void TrackTarget(void); + void StartRotSound(void); + void StopRotSound(void); inline BOOL IsActive(void) { @@ -118,9 +116,11 @@ public: return (gpGlobals->time - m_lastSightTime) < m_persist; } - NOBODY BOOL InRange(float range); - NOBODY edict_t *FindTarget(edict_t *pPlayer); - NOBODY void TankTrace(const Vector &vecStart, const Vector &vecForward, const Vector &vecSpread, TraceResult &tr); + BOOL InRange(float range); + + // Acquire a target. pPlayer is a player in the PVS + edict_t *FindTarget(edict_t *pPlayer); + void TankTrace(const Vector &vecStart, const Vector &vecForward, const Vector &vecSpread, TraceResult &tr); Vector BarrelPosition(void) { @@ -129,10 +129,10 @@ public: return pev->origin + (forward * m_barrelPos.x) + (right * m_barrelPos.y) + (up * m_barrelPos.z); } - NOBODY void AdjustAnglesForBarrel(Vector &angles, float distance); - NOBODY BOOL StartControl(CBasePlayer *pController); - NOBODY void StopControl(void); - NOBODY void ControllerPostFrame(void); + void AdjustAnglesForBarrel(Vector &angles, float distance); + BOOL StartControl(CBasePlayer *pController); + void StopControl(void); + void ControllerPostFrame(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[26]; @@ -141,55 +141,64 @@ protected: CBasePlayer *m_pController; float m_flNextAttack; Vector m_vecControllerUsePos; - float m_yawCenter; - float m_yawRate; - float m_yawRange; - float m_yawTolerance; - float m_pitchCenter; - float m_pitchRate; - float m_pitchRange; - float m_pitchTolerance; - float m_fireLast; - float m_fireRate; - float m_lastSightTime; - float m_persist; - float m_minRange; - float m_maxRange; - Vector m_barrelPos; - float m_spriteScale; + + float m_yawCenter; // "Center" yaw + float m_yawRate; // Max turn rate to track targets + float m_yawRange; // Range of turning motion (one-sided: 30 is +/- 30 degress from center) + // Zero is full rotation + + float m_yawTolerance; // Tolerance angle + + float m_pitchCenter; // "Center" pitch + float m_pitchRate; // Max turn rate on pitch + float m_pitchRange; // Range of pitch motion as above + float m_pitchTolerance; // Tolerance angle + + float m_fireLast; // Last time I fired + float m_fireRate; // How many rounds/second + float m_lastSightTime; // Last time I saw target + float m_persist; // Persistence of firing (how long do I shoot when I can't see) + float m_minRange; // Minimum range to aim/track + float m_maxRange; // Max range to aim/track + + Vector m_barrelPos; // Length of the freakin barrel + float m_spriteScale; // Scale of any sprites we shoot int m_iszSpriteSmoke; int m_iszSpriteFlash; - TANKBULLET m_bulletType; - int m_iBulletDamage; - Vector m_sightOrigin; - int m_spread; - int m_iszMaster; + TANKBULLET m_bulletType; // Bullet type + int m_iBulletDamage; // 0 means use Bullet type's default damage + + Vector m_sightOrigin; // Last sight of target + int m_spread; // firing spread + int m_iszMaster; // Master entity (game_team_master or multisource) };/* size: 280, cachelines: 5, members: 28 */ -/* <8c79a> ../cstrike/dlls/func_tank.cpp:719 */ +/* <8c79a> ../cstrike/dlls/func_tank.cpp:719 */ class CFuncTankGun: public CFuncTank { public: - NOBODY virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); + virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); #ifdef HOOK_GAMEDLL + void Fire_(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); + #endif // HOOK_GAMEDLL };/* size: 280, cachelines: 5, members: 1 */ -/* <8c7e8> ../cstrike/dlls/func_tank.cpp:768 */ +/* <8c7e8> ../cstrike/dlls/func_tank.cpp:768 */ class CFuncTankLaser: public CFuncTank { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Activate(void); - NOBODY virtual void Think(void); - NOBODY virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); - + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Activate(void); + virtual void Think(void); + virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); + #ifdef HOOK_GAMEDLL void KeyValue_(KeyValueData *pkvd); @@ -201,7 +210,7 @@ public: #endif // HOOK_GAMEDLL - NOBODY CLaser *GetLaser(void); + CLaser *GetLaser(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[2]; @@ -212,12 +221,12 @@ private: };/* size: 288, cachelines: 5, members: 4 */ -/* <8c836> ../cstrike/dlls/func_tank.cpp:887 */ +/* <8c836> ../cstrike/dlls/func_tank.cpp:887 */ class CFuncTankRocket: public CFuncTank { public: - NOBODY virtual void Precache(void); - NOBODY virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); + virtual void Precache(void); + virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); #ifdef HOOK_GAMEDLL @@ -228,12 +237,12 @@ public: };/* size: 280, cachelines: 5, members: 1 */ -/* <8c884> ../cstrike/dlls/func_tank.cpp:924 */ +/* <8c884> ../cstrike/dlls/func_tank.cpp:924 */ class CFuncTankMortar: public CFuncTank { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); + virtual void KeyValue(KeyValueData *pkvd); + virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker); #ifdef HOOK_GAMEDLL @@ -244,20 +253,20 @@ public: };/* size: 280, cachelines: 5, members: 1 */ -/* <8c8d2> ../cstrike/dlls/func_tank.cpp:974 */ +/* <8c8d2> ../cstrike/dlls/func_tank.cpp:974 */ class CFuncTankControls: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Think(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - + virtual void Think(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + #ifdef HOOK_GAMEDLL void Spawn_(void); @@ -280,4 +289,18 @@ public: };/* size: 156, cachelines: 3, members: 3 */ +#ifdef HOOK_GAMEDLL + +#define gTankSpread (*pgTankSpread) +extern Vector gTankSpread[5]; + +#endif // HOOK_GAMEDLL + +// linked objects +C_DLLEXPORT void func_tank(entvars_t *pev); +C_DLLEXPORT void func_tanklaser(entvars_t *pev); +C_DLLEXPORT void func_tankrocket(entvars_t *pev); +C_DLLEXPORT void func_tankmortar(entvars_t *pev); +C_DLLEXPORT void func_tankcontrols(entvars_t *pev); + #endif // FUNC_TANK_H diff --git a/regamedll/dlls/gamerules.cpp b/regamedll/dlls/gamerules.cpp index ae645415..6fce36e0 100644 --- a/regamedll/dlls/gamerules.cpp +++ b/regamedll/dlls/gamerules.cpp @@ -38,17 +38,17 @@ BOOL CGameRules::__MAKE_VHOOK(CanHaveAmmo)(CBasePlayer *pPlayer, const char *psz /* ../cstrike/dlls/gamerules.cpp:59 */ edict_t *CGameRules::__MAKE_VHOOK(GetPlayerSpawnSpot)(CBasePlayer *pPlayer) { - edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer); - - pPlayer->pev->origin = VARS(pentSpawnSpot)->origin;// + Vector(0, 0, 1); - pPlayer->pev->origin.z += 1; - - pPlayer->pev->v_angle = g_vecZero; - pPlayer->pev->velocity = g_vecZero; - pPlayer->pev->angles = VARS(pentSpawnSpot)->angles; - pPlayer->pev->punchangle = g_vecZero; - pPlayer->pev->fixangle = 1; - + edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer); + + pPlayer->pev->origin = VARS(pentSpawnSpot)->origin;// + Vector(0, 0, 1); + pPlayer->pev->origin.z += 1; + + pPlayer->pev->v_angle = g_vecZero; + pPlayer->pev->velocity = g_vecZero; + pPlayer->pev->angles = VARS(pentSpawnSpot)->angles; + pPlayer->pev->punchangle = g_vecZero; + pPlayer->pev->fixangle = 1; + return pentSpawnSpot; } @@ -68,28 +68,28 @@ BOOL CGameRules::__MAKE_VHOOK(CanHavePlayerItem)(CBasePlayer *pPlayer, CBasePlay return FALSE; } - if (pWeapon->pszAmmo1()) - { - if (!CanHaveAmmo(pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1())) - { - // we can't carry anymore ammo for this gun. We can only - // have the gun if we aren't already carrying one of this type - if (pPlayer->HasPlayerItem(pWeapon)) - { - return FALSE; - } - } - } - else - { - // weapon doesn't use ammo, don't take another if you already have it. - if (pPlayer->HasPlayerItem(pWeapon)) - { - return FALSE; - } + if (pWeapon->pszAmmo1()) + { + if (!CanHaveAmmo(pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1())) + { + // we can't carry anymore ammo for this gun. We can only + // have the gun if we aren't already carrying one of this type + if (pPlayer->HasPlayerItem(pWeapon)) + { + return FALSE; + } + } + } + else + { + // weapon doesn't use ammo, don't take another if you already have it. + if (pPlayer->HasPlayerItem(pWeapon)) + { + return FALSE; + } } - // note: will fall through to here if GetItemInfo doesn't fill the struct! + // note: will fall through to here if GetItemInfo doesn't fill the struct! return TRUE; } @@ -143,21 +143,21 @@ NOBODY __declspec(naked) CGameRules *InstallGameRules(void) void CGameRules::RefreshSkillData(void) { RefreshSkillData_(); -} - -edict_t *CGameRules::GetPlayerSpawnSpot(CBasePlayer *pPlayer) -{ - return GetPlayerSpawnSpot_(pPlayer); -} - -BOOL CGameRules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) -{ - return CanHavePlayerItem_(pPlayer, pWeapon); -} - -BOOL CGameRules::CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry) -{ - return CanHaveAmmo_(pPlayer, pszAmmoName, iMaxCarry); -} +} + +edict_t *CGameRules::GetPlayerSpawnSpot(CBasePlayer *pPlayer) +{ + return GetPlayerSpawnSpot_(pPlayer); +} + +BOOL CGameRules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) +{ + return CanHavePlayerItem_(pPlayer, pWeapon); +} + +BOOL CGameRules::CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry) +{ + return CanHaveAmmo_(pPlayer, pszAmmoName, iMaxCarry); +} #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index cf243e67..89d6f1e8 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -53,14 +53,14 @@ #define WEAPON_RESPAWN_TIME 20 #define AMMO_RESPAWN_TIME 20 -// longest the intermission can last, in seconds +// longest the intermission can last, in seconds #define MAX_INTERMISSION_TIME 120 -// when we are within this close to running out of entities, items -// marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn +// when we are within this close to running out of entities, items +// marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn #define ENTITY_INTOLERANCE 100 -#define MAX_MOTD_CHUNK 60 +#define MAX_MOTD_CHUNK 60 #define MAX_MOTD_LENGTH 1536 // (MAX_MOTD_CHUNK * 4) // custom enum @@ -122,6 +122,7 @@ enum RewardAccount REWARD_RESCUED_HOSTAGE = 750, REWARD_KILLED_ENEMY = 300, REWARD_KILLED_VIP = 2500, + REWARD_VIP_HAVE_SELF_RESCUED = 2500, }; @@ -137,33 +138,33 @@ enum InfoMapBuyParam BUYING_EVERYONE = 0, BUYING_ONLY_CTS, BUYING_ONLY_TERRORISTS, - BUYING_NO_ONE, + BUYING_NO_ONE, }; -enum -{ - GR_NONE = 0, - GR_WEAPON_RESPAWN_YES, - GR_WEAPON_RESPAWN_NO, - GR_AMMO_RESPAWN_YES, - GR_AMMO_RESPAWN_NO, - GR_ITEM_RESPAWN_YES, - GR_ITEM_RESPAWN_NO, - GR_PLR_DROP_GUN_ALL, - GR_PLR_DROP_GUN_ACTIVE, - GR_PLR_DROP_GUN_NO, - GR_PLR_DROP_AMMO_ALL, - GR_PLR_DROP_AMMO_ACTIVE, - GR_PLR_DROP_AMMO_NO, +enum +{ + GR_NONE = 0, + GR_WEAPON_RESPAWN_YES, + GR_WEAPON_RESPAWN_NO, + GR_AMMO_RESPAWN_YES, + GR_AMMO_RESPAWN_NO, + GR_ITEM_RESPAWN_YES, + GR_ITEM_RESPAWN_NO, + GR_PLR_DROP_GUN_ALL, + GR_PLR_DROP_GUN_ACTIVE, + GR_PLR_DROP_GUN_NO, + GR_PLR_DROP_AMMO_ALL, + GR_PLR_DROP_AMMO_ACTIVE, + GR_PLR_DROP_AMMO_NO, }; -enum -{ - GR_NOTTEAMMATE = 0, - GR_TEAMMATE, - GR_ENEMY, - GR_ALLY, - GR_NEUTRAL, +enum +{ + GR_NOTTEAMMATE = 0, + GR_TEAMMATE, + GR_ENEMY, + GR_ALLY, + GR_NEUTRAL, }; class CItem; @@ -192,7 +193,7 @@ public: virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char *szRejectReason) = 0; virtual void InitHUD(CBasePlayer *pl) = 0; virtual void ClientDisconnected(edict_t *pClient) = 0; - virtual void UpdateGameMode(CBasePlayer *pPlayer) {} + virtual void UpdateGameMode(CBasePlayer *pPlayer) {}; virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) { @@ -219,7 +220,7 @@ public: { return ClientCommand_(pPlayer, pcmd); } - virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) {} + virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) {}; virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor) = 0; @@ -260,7 +261,7 @@ public: { return IsValidTeam_(pTeamName); } - virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) {} + virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) {}; virtual const char *SetDefaultPlayerTeam(CBasePlayer *pPlayer) { return SetDefaultPlayerTeam_(pPlayer); @@ -270,76 +271,76 @@ public: return PlayTextureSounds_(); } virtual BOOL FAllowMonsters(void) = 0; - virtual void EndMultiplayerGame(void) {} + virtual void EndMultiplayerGame(void) {}; virtual BOOL IsFreezePeriod(void) { return IsFreezePeriod_(); } - virtual void ServerDeactivate(void) {} - virtual void CheckMapConditions(void) {} + virtual void ServerDeactivate(void) {}; + virtual void CheckMapConditions(void) {}; #ifdef HOOK_GAMEDLL - void RefreshSkillData_(void); - BOOL IsTeamplay_(void) - { - return FALSE; - } + void RefreshSkillData_(void); + BOOL IsTeamplay_(void) + { + return FALSE; + } const char *GetGameDescription_(void) { return "Counter-Strike"; - } - BOOL FPlayerCanTakeDamage_(CBasePlayer *pPlayer, CBaseEntity *pAttacker) - { - return TRUE; - } - BOOL ShouldAutoAim_(CBasePlayer *pPlayer, edict_t *target) - { - return TRUE; - } - edict_t *GetPlayerSpawnSpot_(CBasePlayer *pPlayer); - BOOL AllowAutoTargetCrosshair_(void) - { - return TRUE; - } - BOOL ClientCommand_DeadOrAlive_(CBasePlayer *pPlayer, const char *pcmd) - { - return FALSE; - } - BOOL ClientCommand_(CBasePlayer *pPlayer, const char *pcmd) - { - return FALSE; - } - BOOL CanHavePlayerItem_(CBasePlayer *pPlayer, CBasePlayerItem *pItem); - BOOL CanHaveAmmo_(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry); + } + BOOL FPlayerCanTakeDamage_(CBasePlayer *pPlayer, CBaseEntity *pAttacker) + { + return TRUE; + } + BOOL ShouldAutoAim_(CBasePlayer *pPlayer, edict_t *target) + { + return TRUE; + } + edict_t *GetPlayerSpawnSpot_(CBasePlayer *pPlayer); + BOOL AllowAutoTargetCrosshair_(void) + { + return TRUE; + } + BOOL ClientCommand_DeadOrAlive_(CBasePlayer *pPlayer, const char *pcmd) + { + return FALSE; + } + BOOL ClientCommand_(CBasePlayer *pPlayer, const char *pcmd) + { + return FALSE; + } + BOOL CanHavePlayerItem_(CBasePlayer *pPlayer, CBasePlayerItem *pItem); + BOOL CanHaveAmmo_(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry); float FlHEVChargerRechargeTime_(void) { return 0.0f; - } + } int GetTeamIndex_(const char *pTeamName) { return -1; - } + } const char *GetIndexedTeamName_(int teamIndex) { return ""; - } + } BOOL IsValidTeam_(const char *pTeamName) { return TRUE; - } + } const char *SetDefaultPlayerTeam_(CBasePlayer *pPlayer) { return ""; - } + } BOOL PlayTextureSounds_(void) { return TRUE; - } + } BOOL IsFreezePeriod_(void) { return m_bFreezePeriod; - } + } #endif // HOOK_GAMEDLL @@ -405,52 +406,52 @@ public: #ifdef HOOK_GAMEDLL - void Think_(void); - BOOL IsAllowedToSpawn_(CBaseEntity *pEntity); - BOOL FAllowFlashlight_(void) - { - return TRUE; - }; - BOOL FShouldSwitchWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); - BOOL GetNextBestWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon); - BOOL IsMultiplayer_(void); - BOOL IsDeathmatch_(void); - BOOL IsCoOp_(void); - BOOL ClientConnected_(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]); - void InitHUD_(CBasePlayer *pl); - void ClientDisconnected_(edict_t *pClient); - float FlPlayerFallDamage_(CBasePlayer *pPlayer); - void PlayerSpawn_(CBasePlayer *pPlayer); - void PlayerThink_(CBasePlayer *pPlayer); - BOOL FPlayerCanRespawn_(CBasePlayer *pPlayer); - float FlPlayerSpawnTime_(CBasePlayer *pPlayer); - edict_t *GetPlayerSpawnSpot_(CBasePlayer *pPlayer); - BOOL AllowAutoTargetCrosshair_(void); - int IPointsForKill_(CBasePlayer *pAttacker, CBasePlayer *pKilled); - void PlayerKilled_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); - void DeathNotice_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); - void PlayerGotWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); - int WeaponShouldRespawn_(CBasePlayerItem *pWeapon); - float FlWeaponRespawnTime_(CBasePlayerItem *pWeapon); - float FlWeaponTryRespawn_(CBasePlayerItem *pWeapon); - Vector VecWeaponRespawnSpot_(CBasePlayerItem *pWeapon); - BOOL CanHaveItem_(CBasePlayer *pPlayer, CItem *pItem); - void PlayerGotItem_(CBasePlayer *pPlayer, CItem *pItem); - int ItemShouldRespawn_(CItem *pItem); - float FlItemRespawnTime_(CItem *pItem); - Vector VecItemRespawnSpot_(CItem *pItem); - void PlayerGotAmmo_(CBasePlayer *pPlayer, char *szName, int iCount); - int AmmoShouldRespawn_(CBasePlayerAmmo *pAmmo); - float FlAmmoRespawnTime_(CBasePlayerAmmo *pAmmo); - Vector VecAmmoRespawnSpot_(CBasePlayerAmmo *pAmmo); - float FlHealthChargerRechargeTime_(void); - int DeadPlayerWeapons_(CBasePlayer *pPlayer); - int DeadPlayerAmmo_(CBasePlayer *pPlayer); - const char *GetTeamID_(CBaseEntity *pEntity) - { - return ""; - }; - int PlayerRelationship_(CBasePlayer *pPlayer, CBaseEntity *pTarget); + void Think_(void); + BOOL IsAllowedToSpawn_(CBaseEntity *pEntity); + BOOL FAllowFlashlight_(void) + { + return TRUE; + }; + BOOL FShouldSwitchWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); + BOOL GetNextBestWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon); + BOOL IsMultiplayer_(void); + BOOL IsDeathmatch_(void); + BOOL IsCoOp_(void); + BOOL ClientConnected_(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]); + void InitHUD_(CBasePlayer *pl); + void ClientDisconnected_(edict_t *pClient); + float FlPlayerFallDamage_(CBasePlayer *pPlayer); + void PlayerSpawn_(CBasePlayer *pPlayer); + void PlayerThink_(CBasePlayer *pPlayer); + BOOL FPlayerCanRespawn_(CBasePlayer *pPlayer); + float FlPlayerSpawnTime_(CBasePlayer *pPlayer); + edict_t *GetPlayerSpawnSpot_(CBasePlayer *pPlayer); + BOOL AllowAutoTargetCrosshair_(void); + int IPointsForKill_(CBasePlayer *pAttacker, CBasePlayer *pKilled); + void PlayerKilled_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); + void DeathNotice_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); + void PlayerGotWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); + int WeaponShouldRespawn_(CBasePlayerItem *pWeapon); + float FlWeaponRespawnTime_(CBasePlayerItem *pWeapon); + float FlWeaponTryRespawn_(CBasePlayerItem *pWeapon); + Vector VecWeaponRespawnSpot_(CBasePlayerItem *pWeapon); + BOOL CanHaveItem_(CBasePlayer *pPlayer, CItem *pItem); + void PlayerGotItem_(CBasePlayer *pPlayer, CItem *pItem); + int ItemShouldRespawn_(CItem *pItem); + float FlItemRespawnTime_(CItem *pItem); + Vector VecItemRespawnSpot_(CItem *pItem); + void PlayerGotAmmo_(CBasePlayer *pPlayer, char *szName, int iCount); + int AmmoShouldRespawn_(CBasePlayerAmmo *pAmmo); + float FlAmmoRespawnTime_(CBasePlayerAmmo *pAmmo); + Vector VecAmmoRespawnSpot_(CBasePlayerAmmo *pAmmo); + float FlHealthChargerRechargeTime_(void); + int DeadPlayerWeapons_(CBasePlayer *pPlayer); + int DeadPlayerAmmo_(CBasePlayer *pPlayer); + const char *GetTeamID_(CBaseEntity *pEntity) + { + return ""; + }; + int PlayerRelationship_(CBasePlayer *pPlayer, CBaseEntity *pTarget); BOOL FAllowMonsters_(void); #endif // HOOK_GAMEDLL @@ -532,78 +533,78 @@ public: virtual void ChangeLevel(void); virtual void GoToIntermission(void); -#ifdef HOOK_GAMEDLL - - void RefreshSkillData_(void); - void Think_(void); - BOOL IsAllowedToSpawn_(CBaseEntity *pEntity); - BOOL FAllowFlashlight_(void); - BOOL FShouldSwitchWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); - BOOL GetNextBestWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon); - BOOL IsMultiplayer_(void); - BOOL IsDeathmatch_(void); - BOOL IsCoOp_(void); - BOOL ClientConnected_(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]); - void InitHUD_(CBasePlayer *pl); - void ClientDisconnected_(edict_t *pClient); - void UpdateGameMode_(CBasePlayer *pPlayer); - float FlPlayerFallDamage_(CBasePlayer *pPlayer); - BOOL FPlayerCanTakeDamage_(CBasePlayer *pPlayer, CBaseEntity *pAttacker); - void PlayerSpawn_(CBasePlayer *pPlayer); - void PlayerThink_(CBasePlayer *pPlayer); - BOOL FPlayerCanRespawn_(CBasePlayer *pPlayer); - float FlPlayerSpawnTime_(CBasePlayer *pPlayer); - edict_t *GetPlayerSpawnSpot_(CBasePlayer *pPlayer); - BOOL AllowAutoTargetCrosshair_(void); - BOOL ClientCommand_DeadOrAlive_(CBasePlayer *pPlayer, const char *pcmd); - BOOL ClientCommand_(CBasePlayer *pPlayer, const char *pcmd); - void ClientUserInfoChanged_(CBasePlayer *pPlayer, char *infobuffer); - int IPointsForKill_(CBasePlayer *pAttacker, CBasePlayer *pKilled); - void PlayerKilled_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); - void DeathNotice_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); - BOOL CanHavePlayerItem_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); - void PlayerGotWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); - int WeaponShouldRespawn_(CBasePlayerItem *pWeapon); - float FlWeaponRespawnTime_(CBasePlayerItem *pWeapon); - float FlWeaponTryRespawn_(CBasePlayerItem *pWeapon); - Vector VecWeaponRespawnSpot_(CBasePlayerItem *pWeapon); - BOOL CanHaveItem_(CBasePlayer *pPlayer, CItem *pItem); - void PlayerGotItem_(CBasePlayer *pPlayer, CItem *pItem); - int ItemShouldRespawn_(CItem *pItem); - float FlItemRespawnTime_(CItem *pItem); - Vector VecItemRespawnSpot_(CItem *pItem); - void PlayerGotAmmo_(CBasePlayer *pPlayer, char *szName, int iCount); - int AmmoShouldRespawn_(CBasePlayerAmmo *pAmmo); - float FlAmmoRespawnTime_(CBasePlayerAmmo *pAmmo); - Vector VecAmmoRespawnSpot_(CBasePlayerAmmo *pAmmo); - float FlHealthChargerRechargeTime_(void); - float FlHEVChargerRechargeTime_(void); - int DeadPlayerWeapons_(CBasePlayer *pPlayer); - int DeadPlayerAmmo_(CBasePlayer *pPlayer); +#ifdef HOOK_GAMEDLL + + void RefreshSkillData_(void); + void Think_(void); + BOOL IsAllowedToSpawn_(CBaseEntity *pEntity); + BOOL FAllowFlashlight_(void); + BOOL FShouldSwitchWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); + BOOL GetNextBestWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon); + BOOL IsMultiplayer_(void); + BOOL IsDeathmatch_(void); + BOOL IsCoOp_(void); + BOOL ClientConnected_(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]); + void InitHUD_(CBasePlayer *pl); + void ClientDisconnected_(edict_t *pClient); + void UpdateGameMode_(CBasePlayer *pPlayer); + float FlPlayerFallDamage_(CBasePlayer *pPlayer); + BOOL FPlayerCanTakeDamage_(CBasePlayer *pPlayer, CBaseEntity *pAttacker); + void PlayerSpawn_(CBasePlayer *pPlayer); + void PlayerThink_(CBasePlayer *pPlayer); + BOOL FPlayerCanRespawn_(CBasePlayer *pPlayer); + float FlPlayerSpawnTime_(CBasePlayer *pPlayer); + edict_t *GetPlayerSpawnSpot_(CBasePlayer *pPlayer); + BOOL AllowAutoTargetCrosshair_(void); + BOOL ClientCommand_DeadOrAlive_(CBasePlayer *pPlayer, const char *pcmd); + BOOL ClientCommand_(CBasePlayer *pPlayer, const char *pcmd); + void ClientUserInfoChanged_(CBasePlayer *pPlayer, char *infobuffer); + int IPointsForKill_(CBasePlayer *pAttacker, CBasePlayer *pKilled); + void PlayerKilled_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); + void DeathNotice_(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); + BOOL CanHavePlayerItem_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); + void PlayerGotWeapon_(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); + int WeaponShouldRespawn_(CBasePlayerItem *pWeapon); + float FlWeaponRespawnTime_(CBasePlayerItem *pWeapon); + float FlWeaponTryRespawn_(CBasePlayerItem *pWeapon); + Vector VecWeaponRespawnSpot_(CBasePlayerItem *pWeapon); + BOOL CanHaveItem_(CBasePlayer *pPlayer, CItem *pItem); + void PlayerGotItem_(CBasePlayer *pPlayer, CItem *pItem); + int ItemShouldRespawn_(CItem *pItem); + float FlItemRespawnTime_(CItem *pItem); + Vector VecItemRespawnSpot_(CItem *pItem); + void PlayerGotAmmo_(CBasePlayer *pPlayer, char *szName, int iCount); + int AmmoShouldRespawn_(CBasePlayerAmmo *pAmmo); + float FlAmmoRespawnTime_(CBasePlayerAmmo *pAmmo); + Vector VecAmmoRespawnSpot_(CBasePlayerAmmo *pAmmo); + float FlHealthChargerRechargeTime_(void); + float FlHEVChargerRechargeTime_(void); + int DeadPlayerWeapons_(CBasePlayer *pPlayer); + int DeadPlayerAmmo_(CBasePlayer *pPlayer); const char *GetTeamID_(CBaseEntity *pEntity) { return ""; - } - int PlayerRelationship_(CBasePlayer *pPlayer, CBaseEntity *pTarget); + } + int PlayerRelationship_(CBasePlayer *pPlayer, CBaseEntity *pTarget); BOOL PlayTextureSounds_(void) { return FALSE; - } - BOOL FAllowMonsters_(void); + } + BOOL FAllowMonsters_(void); void EndMultiplayerGame_(void) { GoToIntermission(); - } - void ServerDeactivate_(void); - void CheckMapConditions_(void); - void CleanUpMap_(void); - void RestartRound_(void); - void CheckWinConditions_(void); - void RemoveGuns_(void); - void GiveC4_(void); - void ChangeLevel_(void); - void GoToIntermission_(void); - + } + void ServerDeactivate_(void); + void CheckMapConditions_(void); + void CleanUpMap_(void); + void RestartRound_(void); + void CheckWinConditions_(void); + void RemoveGuns_(void); + void GiveC4_(void); + void ChangeLevel_(void); + void GoToIntermission_(void); + #endif // HOOK_GAMEDLL public: @@ -773,18 +774,18 @@ public: };/* size: 160, cachelines: 3, members: 3 */ -/* <111732> ../cstrike/dlls/multiplay_gamerules.cpp:292 */ -class CCStrikeGameMgrHelper: public IVoiceGameMgrHelper -{ -public: - virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pSender); - -#ifdef HOOK_GAMEDLL - - bool CanPlayerHearPlayer_(CBasePlayer *pListener, CBasePlayer *pSender); - -#endif // HOOK_GAMEDLL - +/* <111732> ../cstrike/dlls/multiplay_gamerules.cpp:292 */ +class CCStrikeGameMgrHelper: public IVoiceGameMgrHelper +{ +public: + virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pSender); + +#ifdef HOOK_GAMEDLL + + bool CanPlayerHearPlayer_(CBasePlayer *pListener, CBasePlayer *pSender); + +#endif // HOOK_GAMEDLL + };/* size: 4, cachelines: 1, members: 1 */ #ifdef HOOK_GAMEDLL @@ -809,26 +810,26 @@ CGameRules *InstallGameRules(void); * Multiplay gamerules */ -bool IsBotSpeaking(void); -void SV_Continue_f(void); -void SV_Tutor_Toggle_f(void); -void SV_Career_Restart_f(void); -void SV_Career_EndRound_f(void); -void SV_CareerAddTask_f(void); -void SV_CareerMatchLimit_f(void); -void Broadcast(const char *sentence); -char *GetTeam(int teamNo); -void EndRoundMessage(const char *sentence, int event); -void ReadMultiplayCvars(CHalfLifeMultiplay *mp); -void DestroyMapCycle(mapcycle_t *cycle); - -char *MP_COM_GetToken(void); -char *MP_COM_Parse(char *data); -int MP_COM_TokenWaiting(char *buffer); - -int ReloadMapCycleFile(char *filename, mapcycle_t *cycle); -int CountPlayers(void); -void ExtractCommandString(char *s, char *szCommand); +bool IsBotSpeaking(void); +void SV_Continue_f(void); +void SV_Tutor_Toggle_f(void); +void SV_Career_Restart_f(void); +void SV_Career_EndRound_f(void); +void SV_CareerAddTask_f(void); +void SV_CareerMatchLimit_f(void); +void Broadcast(const char *sentence); +char *GetTeam(int teamNo); +void EndRoundMessage(const char *sentence, int event); +void ReadMultiplayCvars(CHalfLifeMultiplay *mp); +void DestroyMapCycle(mapcycle_t *cycle); + +char *MP_COM_GetToken(void); +char *MP_COM_Parse(char *data); +int MP_COM_TokenWaiting(char *buffer); + +int ReloadMapCycleFile(char *filename, mapcycle_t *cycle); +int CountPlayers(void); +void ExtractCommandString(char *s, char *szCommand); int GetMapCount(void); // refs diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index 5f8b43e6..89a38c21 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -26,7 +26,7 @@ TYPEDESCRIPTION CGrenade::m_SaveData[] = #else // HOOK_GAMEDLL -TYPEDESCRIPTION (*CGrenade::pm_SaveData)[15]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CGrenade, m_SaveData)[15]; #endif // HOOK_GAMEDLL @@ -855,7 +855,9 @@ void CGrenade::__MAKE_VHOOK(Spawn)(void) pev->movetype = MOVETYPE_BOUNCE; if (pev->classname) + { RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + } MAKE_STRING_CLASS("grenade", pev); AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); @@ -864,7 +866,7 @@ void CGrenade::__MAKE_VHOOK(Spawn)(void) pev->solid = SOLID_BBOX; 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 = 30; m_fRegisteredSound = FALSE; @@ -1005,10 +1007,13 @@ void CGrenade::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, if (player->m_bHasDefuser) { - UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Begin_Bomb_Defuse_With_Kit\"\n", + UTIL_LogPrintf + ( + "\"%s<%i><%s>\" triggered \"Begin_Bomb_Defuse_With_Kit\"\n", STRING(player->pev->netname), GETPLAYERUSERID(player->edict()), - GETPLAYERAUTHID(player->edict())); + GETPLAYERAUTHID(player->edict()) + ); ClientPrint(player->pev, HUD_PRINTCENTER, "#Defusing_Bomb_With_Defuse_Kit"); EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); diff --git a/regamedll/dlls/h_ai.cpp b/regamedll/dlls/h_ai.cpp index fb5b25ac..b611dd78 100644 --- a/regamedll/dlls/h_ai.cpp +++ b/regamedll/dlls/h_ai.cpp @@ -1,5 +1,8 @@ #include "precompiled.h" +#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 + /* * Globals initialization */ @@ -14,93 +17,165 @@ BOOL g_fDrawLines; #endif // HOOK_GAMEDLL /* ../cstrike/dlls/h_ai.cpp:47 */ -NOBODY BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize) +NOXREF BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize) { -// { -// TraceResult tr; // 54 -// Vector vecLookerOrigin; // 55 -// operator+(const Vector *const this, -// const Vector &v); // 55 -// { -// int i; // 56 -// { -// Vector vecTarget; // 58 -// Vector(Vector *const this, -// const Vector &v); // 58 -// } -// } -// } + // don't look through water + if ((pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3) || (pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0)) + { + return FALSE; + } + + TraceResult tr; + + //look through the monster's 'eyes' + Vector vecLookerOrigin = pevLooker->origin + pevLooker->view_ofs; + + for (int i = 0; i < 5; i++) + { + Vector vecTarget = pevTarget->origin; + + 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.z += RANDOM_FLOAT(pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize); + + UTIL_TraceLine(vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT(pevLooker), &tr); + + if (tr.flFraction == 1.0f) + { + vecTargetOrigin = vecTarget; + + // line of sight is valid. + return TRUE; + } + } + + // Line of sight is not established + return FALSE; } +// 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. + /* ../cstrike/dlls/h_ai.cpp:78 */ -NOBODY Vector VecCheckToss(entvars_t *pev, Vector &vecSpot1, Vector vecSpot2, float flGravityAdj) +NOXREF Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj) { -// { -// TraceResult tr; // 80 -// Vector vecMidPoint; // 81 -// Vector vecApex; // 82 -// Vector vecScale; // 83 -// Vector vecGrenadeVel; // 84 -// Vector vecTemp; // 85 -// float flGravity; // 86 -// float distance1; // 119 -// float distance2; // 120 -// float time1; // 123 -// float time2; // 124 -// Vector(Vector *const this, -// const Vector &v); // 153 -// operator*(const Vector *const this, -// float fl); // 97 -// operator+(const Vector *const this, -// const Vector &v); // 97 -// operator*(const Vector *const this, -// float fl); // 98 -// operator+(const Vector *const this, -// const Vector &v); // 98 -// operator-(const Vector *const this, -// const Vector &v); // 106 -// operator+(const Vector *const this, -// const Vector &v); // 106 -// operator*(const Vector *const this, -// float fl); // 106 -// operator+(const Vector *const this, -// const Vector &v); // 107 -// operator-(const Vector *const this, -// const Vector &v); // 133 -// operator/(const Vector *const this, -// float fl); // 133 -// operator*(const Vector *const this, -// float fl); // 138 -// operator+(const Vector *const this, -// const Vector &v); // 138 -// Vector(Vector *const this, -// const Vector &v); // 156 -// } + TraceResult tr; + Vector vecMidPoint; // halfway point between Spot1 and Spot2 + Vector vecApex; // highest point + Vector vecScale; + Vector vecGrenadeVel; + Vector vecTemp; + float flGravity = g_psv_gravity->value * flGravityAdj; + + if (vecSpot2.z - vecSpot1.z > 500) + { + // to high, fail + return g_vecZero; + } + + UTIL_MakeVectors(pev->angles); + + // 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_forward * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16)); + + // calculate the midpoint and apex of the 'triangle' + // 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? + + // get a rough idea of how high it can be thrown + vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; + UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0,0,500), ignore_monsters, ENT(pev), &tr); + vecMidPoint = tr.vecEndPos; + + // (subtract 15 so the grenade doesn't hit the ceiling) + vecMidPoint.z -= 15; + + if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z) + { + // to not enough space, fail + return g_vecZero; + } + + // How high should the grenade travel to reach the apex + float distance1 = (vecMidPoint.z - vecSpot1.z); + float distance2 = (vecMidPoint.z - vecSpot2.z); + + // How long will it take for the grenade to travel this distance + float time1 = sqrt(distance1 / (0.5 * flGravity)); + float time2 = sqrt(distance2 / (0.5 * flGravity)); + + if (time1 < 0.1) + { + // too close + return g_vecZero; + } + + // how hard to throw sideways to get there in time. + vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2); + + // how hard upwards to reach the apex at the right time. + vecGrenadeVel.z = flGravity * time1; + + // find the apex + vecApex = vecSpot1 + vecGrenadeVel * time1; + vecApex.z = vecMidPoint.z; + + UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); + if (tr.flFraction != 1.0f) + { + // fail! + return g_vecZero; + } + + // UNDONE: either ignore monsters or change it to not care if we hit our enemy + UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); + if (tr.flFraction != 1.0) + { + // fail! + return g_vecZero; + } + + return vecGrenadeVel; } +// 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. + /* ../cstrike/dlls/h_ai.cpp:164 */ -NOBODY Vector VecCheckThrow(entvars_t *pev, Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj) +NOXREF Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj) { -// { -// float flGravity; // 166 -// Vector vecGrenadeVel; // 168 -// float time; // 171 -// Vector vecApex; // 177 -// TraceResult tr; // 180 -// operator-(const Vector *const this, -// const Vector &v); // 168 -// Length(const Vector *const this); // 171 -// operator-(const Vector *const this, -// const Vector &v); // 177 -// operator*(const Vector *const this, -// float fl); // 177 -// operator+(const Vector *const this, -// const Vector &v); // 177 -// Vector(Vector *const this, -// const Vector &v); // 192 -// operator*(const Vector *const this, -// float fl); // 172 -// Vector(Vector *const this, -// const Vector &v); // 195 -// } + float flGravity = g_psv_gravity->value * flGravityAdj; + + Vector vecGrenadeVel = (vecSpot2 - vecSpot1); + + // throw at a constant time + float time = vecGrenadeVel.Length() / flSpeed; + vecGrenadeVel = vecGrenadeVel * (1.0 / time); + + // adjust upward toss to compensate for gravity loss + vecGrenadeVel.z += flGravity * time * 0.5; + + Vector vecApex = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5; + vecApex.z += 0.5 * flGravity * (time * 0.5) * (time * 0.5); + + TraceResult tr; + UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); + + if (tr.flFraction != 1.0f) + { + // fail! + return g_vecZero; + } + + UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); + + if (tr.flFraction != 1.0f) + { + // fail! + return g_vecZero; + } + + return vecGrenadeVel; } diff --git a/regamedll/dlls/h_ai.h b/regamedll/dlls/h_ai.h index f55ecd9c..80c270e7 100644 --- a/regamedll/dlls/h_ai.h +++ b/regamedll/dlls/h_ai.h @@ -32,8 +32,8 @@ #pragma once #endif -NOBODY BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize); -NOBODY Vector VecCheckToss(entvars_t *pev, Vector &vecSpot1, Vector vecSpot2, float flGravityAdj); -NOBODY Vector VecCheckThrow(entvars_t *pev, Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj); +NOXREF BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize); +NOXREF Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj); +NOXREF Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj); #endif // H_AI_H diff --git a/regamedll/dlls/h_battery.cpp b/regamedll/dlls/h_battery.cpp index 54eb4835..74ad7bf9 100644 --- a/regamedll/dlls/h_battery.cpp +++ b/regamedll/dlls/h_battery.cpp @@ -16,7 +16,7 @@ TYPEDESCRIPTION CRecharge::m_SaveData[] = #else -TYPEDESCRIPTION (*CRecharge::pm_SaveData)[5]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CRecharge, m_SaveData)[5]; #endif // HOOK_GAMEDLL @@ -54,7 +54,8 @@ void CRecharge::__MAKE_VHOOK(Spawn)(void) pev->solid = SOLID_BSP; pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); // set size and link into world + // set size and link into world + UTIL_SetOrigin(pev, pev->origin); UTIL_SetSize(pev, pev->mins, pev->maxs); SET_MODEL(ENT(pev), STRING(pev->model)); diff --git a/regamedll/dlls/h_cycler.cpp b/regamedll/dlls/h_cycler.cpp index f75cf6c8..a15f5e8b 100644 --- a/regamedll/dlls/h_cycler.cpp +++ b/regamedll/dlls/h_cycler.cpp @@ -24,9 +24,9 @@ TYPEDESCRIPTION CWreckage::m_SaveData[] = #else -TYPEDESCRIPTION (*CCycler::pm_SaveData)[1]; -TYPEDESCRIPTION (*CCyclerSprite::pm_SaveData)[3]; -TYPEDESCRIPTION (*CWreckage::pm_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CCycler, m_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CCyclerSprite, m_SaveData)[3]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CWreckage, m_SaveData)[1]; #endif // HOOK_GAMEDLL @@ -36,17 +36,7 @@ IMPLEMENT_SAVERESTORE(CCycler, CBaseToggle); /* ../cstrike/dlls/h_cycler.cpp:70 */ void CGenericCycler::__MAKE_VHOOK(Spawn)(void) { -// Vector(Vector::Spawn(// float X, -// float Y, -// float Z); // 70 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 70 -// GenericCyclerSpawn(CCycler *const this, -// char *szModel, -// Vector vecMin, -// Vector vecMax); // 70 + GenericCyclerSpawn((char *)STRING(pev->model), Vector(-16, -16, 0), Vector(16, 16, 72)); } /* ../cstrike/dlls/h_cycler.cpp:72 */ @@ -58,52 +48,144 @@ LINK_ENTITY_TO_CLASS(cycler_prdroid, CCyclerProbe); /* ../cstrike/dlls/h_cycler.cpp:86 */ void CCyclerProbe::__MAKE_VHOOK(Spawn)(void) { -// Vector(Vector::Spawn(// float X, -// float Y, -// float Z); // 89 -// operator+(const Vector *const this, -// const Vector &v); // 88 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 89 + pev->origin = pev->origin + Vector(0, 0, 16); + GenericCyclerSpawn("models/prdroid.mdl", Vector(-16, -16, -16), Vector(16, 16, 16)); } +// Cycler member functions + /* ../cstrike/dlls/h_cycler.cpp:96 */ void CCycler::GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax) { -// GenericCyclerSpawn(CCycler *const this, -// char *szModel, -// Vector vecMin, -// Vector vecMax); // 96 -// MAKE_STRING_CLASS(const char *str, -// entvars_t *pev); // 105 + if (!szModel || !*szModel) + { + ALERT(at_error, "cycler at %.0f %.0f %0.f missing modelname", pev->origin.x, pev->origin.y, pev->origin.z); + REMOVE_ENTITY(ENT(pev)); + return; + } + + if (pev->classname) + { + RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + } + + MAKE_STRING_CLASS("cycler", pev); + AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + + PRECACHE_MODEL(szModel); + SET_MODEL(ENT(pev), szModel); + + CCycler::Spawn(); + + UTIL_SetSize(pev, vecMin, vecMax); } /* ../cstrike/dlls/h_cycler.cpp:115 */ void CCycler::__MAKE_VHOOK(Spawn)(void) { + InitBoneControllers(); + + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_NONE; + pev->takedamage = DAMAGE_YES; + pev->effects = 0; + + // no cycler should die + pev->health = 80000; + + pev->yaw_speed = 5; + pev->ideal_yaw = pev->angles.y; + ChangeYaw(360); + + m_flFrameRate = 75; + m_flGroundSpeed = 0; + + pev->nextthink += 1.0; + + ResetSequenceInfo(); + + if (pev->sequence != 0 || pev->frame != 0) + { + m_animate = 0; + pev->framerate = 0; + } + else + { + m_animate = 1; + } } +// cycler think + /* ../cstrike/dlls/h_cycler.cpp:151 */ void CCycler::__MAKE_VHOOK(Think)(void) { -// Think(CCycler *const this); // 151 + pev->nextthink = gpGlobals->time + 0.1f; + + if (m_animate) + { + StudioFrameAdvance(); + } + + if (m_fSequenceFinished && !m_fSequenceLoops) + { + // ResetSequenceInfo(); + // hack to avoid reloading model every frame + pev->animtime = gpGlobals->time; + pev->framerate = 1.0; + m_fSequenceFinished = FALSE; + m_flLastEventCheck = gpGlobals->time; + pev->frame = 0; + + if (!m_animate) + { + // FIX: don't reset framerate + pev->framerate = 0.0; + } + } } +// CyclerUse - starts a rotation trend + /* ../cstrike/dlls/h_cycler.cpp:176 */ void CCycler::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { + m_animate = !m_animate; + + if (m_animate) + pev->framerate = 1.0; + else + pev->framerate = 0.0; } +// CyclerPain , changes sequences when shot + /* ../cstrike/dlls/h_cycler.cpp:189 */ int CCycler::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { -// TakeDamage(CCycler *const this, -// entvars_t *pevInflictor, -// entvars_t *pevAttacker, -// float flDamage, -// int bitsDamageType); // 189 + if (m_animate) + { + pev->sequence++; + ResetSequenceInfo(); + + if (m_flFrameRate == 0.0) + { + pev->sequence = 0; + ResetSequenceInfo(); + } + + pev->frame = 0; + } + else + { + pev->framerate = 1.0; + StudioFrameAdvance(0.1); + pev->framerate = 0; + + ALERT(at_console, "sequence: %d, frame %.0f\n", pev->sequence, pev->frame); + } + + return 0; } /* ../cstrike/dlls/h_cycler.cpp:246 */ @@ -112,47 +194,96 @@ LINK_ENTITY_TO_CLASS(cycler_sprite, CCyclerSprite); /* ../cstrike/dlls/h_cycler.cpp:255 */ IMPLEMENT_SAVERESTORE(CCyclerSprite, CBaseEntity); -/* ../cstrike/dlls/h_cycler.cpp:284 */ -void CCyclerSprite::__MAKE_VHOOK(Restart)(void) -{ -// { -// int i; // 300 -// } -} - /* ../cstrike/dlls/h_cycler.cpp:258 */ void CCyclerSprite::__MAKE_VHOOK(Spawn)(void) { -// { -// int i; // 279 -// } + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_NONE; + pev->takedamage = DAMAGE_YES; + pev->effects = 0; + + pev->frame = 0; + pev->nextthink = gpGlobals->time + 0.1f; + m_animate = 1; + m_lastTime = gpGlobals->time; + + PRECACHE_MODEL((char *)STRING(pev->model)); + SET_MODEL(ENT(pev), STRING(pev->model)); + + m_maxFrame = (float)MODEL_FRAMES(pev->modelindex) - 1; + + m_renderfx = pev->renderfx; + m_rendermode = pev->rendermode; + m_renderamt = pev->renderamt; + + for (int i = 0; i < ARRAYSIZE(pev->rendercolor); i++) + { + pev->rendercolor[i] = m_rendercolor[i]; + } +} + +/* ../cstrike/dlls/h_cycler.cpp:284 */ +void CCyclerSprite::__MAKE_VHOOK(Restart)(void) +{ + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_NONE; + pev->takedamage = DAMAGE_YES; + pev->effects = 0; + + pev->frame = 0; + pev->nextthink = gpGlobals->time + 0.1f; + m_animate = 1; + m_lastTime = gpGlobals->time; + + pev->renderfx = m_renderfx; + pev->rendermode = m_rendermode; + pev->renderamt = m_renderamt; + + for (int i = 0; i < ARRAYSIZE(pev->rendercolor); i++) + { + pev->rendercolor[i] = m_rendercolor[i]; + } } /* ../cstrike/dlls/h_cycler.cpp:305 */ void CCyclerSprite::__MAKE_VHOOK(Think)(void) { -// ShouldAnimate(CCyclerSprite *const this); // 307 -// Animate(CCyclerSprite *const this, -// float frames); // 308 + if (ShouldAnimate()) + { + Animate(pev->framerate * (gpGlobals->time - m_lastTime)); + } + + pev->nextthink = gpGlobals->time + 0.1f; + m_lastTime = gpGlobals->time; } /* ../cstrike/dlls/h_cycler.cpp:315 */ void CCyclerSprite::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { + m_animate = !m_animate; + ALERT(at_console, "Sprite: %s\n", STRING(pev->model)); } /* ../cstrike/dlls/h_cycler.cpp:322 */ int CCyclerSprite::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { -// Animate(CCyclerSprite *const this, -// float frames); // 326 + if (m_maxFrame > 1.0) + { + Animate(1.0); + } + + return 1; } /* ../cstrike/dlls/h_cycler.cpp:331 */ void CCyclerSprite::Animate(float frames) { -// Animate(CCyclerSprite *const this, -// float frames); // 331 + pev->frame += frames; + + if (m_maxFrame > 0) + { + pev->frame = fmod((float_precision)pev->frame, (float_precision)m_maxFrame); + } } /* ../cstrike/dlls/h_cycler.cpp:358 */ @@ -161,38 +292,64 @@ LINK_ENTITY_TO_CLASS(cycler_weapon, CWeaponCycler); /* ../cstrike/dlls/h_cycler.cpp:361 */ void CWeaponCycler::__MAKE_VHOOK(Spawn)(void) { -// Vector(Vector::Spawn(// float X, -// float Y, -// float Z); // 372 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 372 + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_NONE; + + PRECACHE_MODEL((char *)STRING(pev->model)); + SET_MODEL(ENT(pev), STRING(pev->model)); + + m_iszModel = pev->model; + m_iModel = pev->modelindex; + + UTIL_SetOrigin(pev, pev->origin); + UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); + SetTouch(&CWeaponCycler::DefaultTouch); } /* ../cstrike/dlls/h_cycler.cpp:378 */ BOOL CWeaponCycler::__MAKE_VHOOK(Deploy)(void) { + m_pPlayer->pev->viewmodel = m_iszModel; + m_pPlayer->m_flNextAttack = WEAPON_TIMEBASED + 1.0; + + SendWeaponAnim(0); + m_iClip = 0; + + return TRUE; } /* ../cstrike/dlls/h_cycler.cpp:388 */ void CWeaponCycler::__MAKE_VHOOK(Holster)(int skiplocal) { + m_pPlayer->m_flNextAttack = WEAPON_TIMEBASED + 0.5; } /* ../cstrike/dlls/h_cycler.cpp:394 */ void CWeaponCycler::__MAKE_VHOOK(PrimaryAttack)(void) { + SendWeaponAnim(pev->sequence); + m_flNextPrimaryAttack = gpGlobals->time + 0.3; } /* ../cstrike/dlls/h_cycler.cpp:403 */ void CWeaponCycler::__MAKE_VHOOK(SecondaryAttack)(void) { -// { -// float flFrameRate; // 405 -// float flGroundSpeed; // 405 -// void *pmodel; // 410 -// } + float flFrameRate, flGroundSpeed; + + pev->sequence = (pev->sequence + 1) % 8; + + pev->modelindex = m_iModel; + void *pmodel = GET_MODEL_PTR(ENT(pev)); + GetSequenceInfo(pmodel, pev, &flFrameRate, &flGroundSpeed); + pev->modelindex = 0; + + if (flFrameRate == 0.0) + { + pev->sequence = 0; + } + + SendWeaponAnim(pev->sequence); + m_flNextSecondaryAttack = gpGlobals->time + 0.3; } /* ../cstrike/dlls/h_cycler.cpp:443 */ @@ -204,24 +361,67 @@ LINK_ENTITY_TO_CLASS(cycler_wreckage, CWreckage); /* ../cstrike/dlls/h_cycler.cpp:448 */ void CWreckage::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->takedamage = DAMAGE_NO; + pev->effects = 0; + + pev->frame = 0; + pev->nextthink = gpGlobals->time + 0.1f; + + if (!FStringNull(pev->model)) + { + PRECACHE_MODEL((char *)STRING(pev->model)); + SET_MODEL(ENT(pev), STRING(pev->model)); + } + + // pev->scale = 5.0; + m_flStartTime = (int)gpGlobals->time; } /* ../cstrike/dlls/h_cycler.cpp:468 */ void CWreckage::__MAKE_VHOOK(Precache)(void) { -// Precache(CWreckage *const this); // 468 + if (!FStringNull(pev->model)) + { + PRECACHE_MODEL((char *)STRING(pev->model)); + } } /* ../cstrike/dlls/h_cycler.cpp:474 */ void CWreckage::__MAKE_VHOOK(Think)(void) { -// { -// Vector VecSrc; // 492 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 498 -// } + StudioFrameAdvance(); + pev->nextthink = gpGlobals->time + 0.2; + + if (pev->dmgtime) + { + if (pev->dmgtime < gpGlobals->time) + { + UTIL_Remove(this); + return; + } + else if (RANDOM_FLOAT(0, pev->dmgtime - m_flStartTime) > pev->dmgtime - gpGlobals->time) + { + return; + } + } + + Vector VecSrc; + + VecSrc.x = RANDOM_FLOAT(pev->absmin.x, pev->absmax.x); + VecSrc.y = RANDOM_FLOAT(pev->absmin.y, pev->absmax.y); + VecSrc.z = RANDOM_FLOAT(pev->absmin.z, pev->absmax.z); + + MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, VecSrc); + WRITE_BYTE(TE_SMOKE); + WRITE_COORD(VecSrc.x); + WRITE_COORD(VecSrc.y); + WRITE_COORD(VecSrc.z); + WRITE_SHORT(g_sModelIndexSmoke); + WRITE_BYTE(RANDOM_LONG(0, 49) + 50); // scale * 10 + WRITE_BYTE(RANDOM_LONG(0, 3) + 8); // framerate + MESSAGE_END(); } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/h_cycler.h b/regamedll/dlls/h_cycler.h index 7654e5b4..5a32ee8f 100644 --- a/regamedll/dlls/h_cycler.h +++ b/regamedll/dlls/h_cycler.h @@ -31,39 +31,122 @@ #ifdef _WIN32 #pragma once #endif - -class CCyclerSprite: public CBaseEntity + +/* ../cstrike/dlls/h_cycler.cpp:35 */ +class CCycler: public CBaseMonster { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Restart(void); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual void Spawn(void); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); virtual int ObjectCaps(void) { - return ((CBaseEntity::ObjectCaps()|FCAP_DONT_SAVE|FCAP_IMPULSE_USE)); + return ObjectCaps_(); } - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY virtual void Think(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + + // Don't treat as a live target + virtual BOOL IsAlive(void) + { + return FALSE; + } + virtual void Think(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL - NOBODY void Spawn_(void); - NOBODY void Restart_(void); - NOBODY int Save_(CSave &save); - NOBODY int Restore_(CRestore &restore); - NOBODY int TakeDamage_(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY void Think_(void); - NOBODY void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void Spawn_(void); + int Save_(CSave &save); + int Restore_(CRestore &restore); + int ObjectCaps_(void) + { + return (CBaseEntity::ObjectCaps() | FCAP_IMPULSE_USE); + } + int TakeDamage_(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + void Think_(void); + void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #endif // HOOK_GAMEDLL public: - NOBODY void Animate(float frames); + void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax); + +public: + static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; + + int m_animate; + +};/* size: 408, cachelines: 7, members: 3 */ + +// we should get rid of all the other cyclers and replace them with this. + +/* ../cstrike/dlls/h_cycler.cpp:67 */ +class CGenericCycler: public CCycler +{ +public: + virtual void Spawn(void); + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + +#endif // HOOK_GAMEDLL + +};/* size: 408, cachelines: 7, members: 1 */ + +// Probe droid imported for tech demo compatibility + +/* ../cstrike/dlls/h_cycler.cpp:80 */ +class CCyclerProbe: public CCycler +{ +public: + virtual void Spawn(void); + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + +#endif // HOOK_GAMEDLL + +};/* size: 408, cachelines: 7, members: 1 */ + +/* ../cstrike/dlls/h_cycler.cpp:218 */ +class CCyclerSprite: public CBaseEntity +{ +public: + virtual void Spawn(void); + virtual void Restart(void); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) + { + return ObjectCaps_(); + } + virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + virtual void Think(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Restart_(void); + int Save_(CSave &save); + int Restore_(CRestore &restore); + int ObjectCaps_(void) + { + return (CBaseEntity::ObjectCaps() | FCAP_DONT_SAVE | FCAP_IMPULSE_USE); + } + int TakeDamage_(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + void Think_(void); + void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + +#endif // HOOK_GAMEDLL + +public: + void Animate(float frames); inline int ShouldAnimate(void) { - return m_animate && m_maxFrame > 1.0; + return (m_animate && m_maxFrame > 1.0); } public: @@ -79,97 +162,32 @@ public: };/* size: 188, cachelines: 3, members: 9 */ -class CCycler: public CBaseMonster -{ -public: - NOBODY virtual void Spawn(void); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - virtual int ObjectCaps(void) - { - return ((CBaseEntity::ObjectCaps()|FCAP_IMPULSE_USE)); - } - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - virtual BOOL IsAlive(void) - { - return FALSE; - } - NOBODY virtual void Think(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - -#ifdef HOOK_GAMEDLL - - NOBODY void Spawn_(void); - NOBODY int Save_(CSave &save); - NOBODY int Restore_(CRestore &restore); - NOBODY int TakeDamage_(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY void Think_(void); - NOBODY void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - -#endif // HOOK_GAMEDLL - -public: - void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax); - -public: - static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; - - int m_animate; - -};/* size: 408, cachelines: 7, members: 3 */ - -class CGenericCycler: public CCycler -{ -public: - NOBODY virtual void Spawn(void); - -#ifdef HOOK_GAMEDLL - - NOBODY void Spawn_(void); - -#endif // HOOK_GAMEDLL - -};/* size: 408, cachelines: 7, members: 1 */ - -class CCyclerProbe: public CCycler -{ -public: - NOBODY virtual void Spawn(void); - -#ifdef HOOK_GAMEDLL - - NOBODY void Spawn_(void); - -#endif // HOOK_GAMEDLL - -};/* size: 408, cachelines: 7, members: 1 */ - -//#include "weapons.h" - + +/* ../cstrike/dlls/h_cycler.cpp:344 */ class CWeaponCycler: public CBasePlayerWeapon { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); virtual int GetItemInfo(ItemInfo *p) { return 0; } - NOBODY virtual BOOL Deploy(void); - NOBODY virtual void Holster(int skiplocal = 0); + virtual BOOL Deploy(void); + virtual void Holster(int skiplocal = 0); virtual int iItemSlot(void) { return 1; } - NOBODY virtual void PrimaryAttack(void); - NOBODY virtual void SecondaryAttack(void); + virtual void PrimaryAttack(void); + virtual void SecondaryAttack(void); #ifdef HOOK_GAMEDLL - NOBODY void Spawn_(void); - NOBODY BOOL Deploy_(void); - NOBODY void Holster_(int skiplocal = 0); - NOBODY void PrimaryAttack_(void); - NOBODY void SecondaryAttack_(void); + void Spawn_(void); + BOOL Deploy_(void); + void Holster_(int skiplocal = 0); + void PrimaryAttack_(void); + void SecondaryAttack_(void); #endif // HOOK_GAMEDLL @@ -178,22 +196,26 @@ public: int m_iModel; };/* size: 344, cachelines: 6, members: 3 */ - + +// Flaming Wreakage + +/* ../cstrike/dlls/h_cycler.cpp:427 */ class CWreckage: public CBaseMonster { - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Think(void); +public: + virtual void Spawn(void); + virtual void Precache(void); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Think(void); #ifdef HOOK_GAMEDLL - NOBODY void Spawn_(void); - NOBODY void Precache_(void); - NOBODY int Save_(CSave &save); - NOBODY int Restore_(CRestore &restore); - NOBODY void Think_(void); + void Spawn_(void); + void Precache_(void); + int Save_(CSave &save); + int Restore_(CRestore &restore); + void Think_(void); #endif // HOOK_GAMEDLL @@ -204,4 +226,11 @@ public: };/* size: 408, cachelines: 7, members: 3 */ +// linked objects +C_DLLEXPORT void cycler(entvars_t *pev); +C_DLLEXPORT void cycler_prdroid(entvars_t *pev); +C_DLLEXPORT void cycler_sprite(entvars_t *pev); +C_DLLEXPORT void cycler_weapon(entvars_t *pev); +C_DLLEXPORT void cycler_wreckage(entvars_t *pev); + #endif // H_CYCLER_H diff --git a/regamedll/dlls/h_export.cpp b/regamedll/dlls/h_export.cpp index 66ac7c2d..80ef6a42 100644 --- a/regamedll/dlls/h_export.cpp +++ b/regamedll/dlls/h_export.cpp @@ -9,7 +9,8 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable,globalv Q_memcpy(&g_engfuncs, pEnginefuncsTable, sizeof(enginefuncs_t)); gpGlobals = pGlobals; -#if defined(_WIN32) && !defined(REGAMEDLL_UNIT_TESTS) +#if defined(HOOK_GAMEDLL) && !defined(REGAMEDLL_UNIT_TESTS) Regamedll_Game_Init(); -#endif // _WIN32 && REGAMEDLL_UNIT_TESTS +#endif // HOOK_GAMEDLL + } diff --git a/regamedll/dlls/healthkit.cpp b/regamedll/dlls/healthkit.cpp index 2abdb9db..68153ff5 100644 --- a/regamedll/dlls/healthkit.cpp +++ b/regamedll/dlls/healthkit.cpp @@ -16,60 +16,60 @@ TYPEDESCRIPTION CWallHealth::m_SaveData[] = #else -TYPEDESCRIPTION (*CWallHealth::pm_SaveData)[5]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CWallHealth, m_SaveData)[5]; #endif // HOOK_GAMEDLL -/* ../cstrike/dlls/healthkit.cpp:43 */ +/* ../cstrike/dlls/healthkit.cpp:43 */ LINK_ENTITY_TO_CLASS(item_healthkit, CHealthKit); - -/* ../cstrike/dlls/healthkit.cpp:55 */ -void CHealthKit::__MAKE_VHOOK(Spawn)(void) -{ - Precache(); - SET_MODEL(ENT(pev), "models/w_medkit.mdl"); - - CItem::Spawn(); + +/* ../cstrike/dlls/healthkit.cpp:55 */ +void CHealthKit::__MAKE_VHOOK(Spawn)(void) +{ + Precache(); + SET_MODEL(ENT(pev), "models/w_medkit.mdl"); + + CItem::Spawn(); } -/* ../cstrike/dlls/healthkit.cpp:63 */ -void CHealthKit::__MAKE_VHOOK(Precache)(void) -{ - PRECACHE_MODEL("models/w_medkit.mdl"); - PRECACHE_SOUND("items/smallmedkit1.wav"); +/* ../cstrike/dlls/healthkit.cpp:63 */ +void CHealthKit::__MAKE_VHOOK(Precache)(void) +{ + PRECACHE_MODEL("models/w_medkit.mdl"); + PRECACHE_SOUND("items/smallmedkit1.wav"); } -/* ../cstrike/dlls/healthkit.cpp:69 */ -BOOL CHealthKit::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) -{ - if (pPlayer->TakeHealth(gSkillData.healthkitCapacity, DMG_GENERIC)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); - WRITE_STRING( STRING(pev->classname)); - MESSAGE_END(); - - EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", VOL_NORM, ATTN_NORM); - - if (g_pGameRules->ItemShouldRespawn(this)) - Respawn(); - else - UTIL_Remove(this); - - return TRUE; - } - - return FALSE; +/* ../cstrike/dlls/healthkit.cpp:69 */ +BOOL CHealthKit::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) +{ + if (pPlayer->TakeHealth(gSkillData.healthkitCapacity, DMG_GENERIC)) + { + MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); + WRITE_STRING(STRING(pev->classname)); + MESSAGE_END(); + + EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", VOL_NORM, ATTN_NORM); + + if (g_pGameRules->ItemShouldRespawn(this)) + Respawn(); + else + UTIL_Remove(this); + + return TRUE; + } + + return FALSE; } -/* ../cstrike/dlls/healthkit.cpp:130 */ +/* ../cstrike/dlls/healthkit.cpp:130 */ IMPLEMENT_SAVERESTORE(CWallHealth, CBaseEntity); -/* ../cstrike/dlls/healthkit.cpp:132 */ +/* ../cstrike/dlls/healthkit.cpp:132 */ LINK_ENTITY_TO_CLASS(func_healthcharger, CWallHealth); - -/* ../cstrike/dlls/healthkit.cpp:135 */ -void CWallHealth::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ + +/* ../cstrike/dlls/healthkit.cpp:135 */ +void CWallHealth::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ if (FStrEq(pkvd->szKeyName, "style") || FStrEq(pkvd->szKeyName, "height") || FStrEq(pkvd->szKeyName, "value1") || FStrEq(pkvd->szKeyName, "value2") || FStrEq(pkvd->szKeyName, "value3")) { pkvd->fHandled = TRUE; @@ -80,121 +80,121 @@ void CWallHealth::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else - CBaseToggle::KeyValue(pkvd); + CBaseToggle::KeyValue(pkvd); } -/* ../cstrike/dlls/healthkit.cpp:154 */ -void CWallHealth::__MAKE_VHOOK(Spawn)(void) -{ - Precache(); - - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; - - // set size and link into world - UTIL_SetOrigin(pev, pev->origin); - UTIL_SetSize(pev, pev->mins, pev->maxs); - - SET_MODEL(ENT(pev), STRING(pev->model)); - - m_iJuice = (int)gSkillData.healthchargerCapacity; - pev->frame = 0.0f; -} - -/* ../cstrike/dlls/healthkit.cpp:169 */ -void CWallHealth::__MAKE_VHOOK(Precache)(void) -{ - PRECACHE_SOUND("items/medshot4.wav"); - PRECACHE_SOUND("items/medshotno1.wav"); - PRECACHE_SOUND("items/medcharge4.wav"); +/* ../cstrike/dlls/healthkit.cpp:154 */ +void CWallHealth::__MAKE_VHOOK(Spawn)(void) +{ + Precache(); + + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + + // set size and link into world + UTIL_SetOrigin(pev, pev->origin); + UTIL_SetSize(pev, pev->mins, pev->maxs); + + SET_MODEL(ENT(pev), STRING(pev->model)); + + m_iJuice = (int)gSkillData.healthchargerCapacity; + pev->frame = 0.0f; } -/* ../cstrike/dlls/healthkit.cpp:177 */ -void CWallHealth::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ - // Make sure that we have a caller - if (!pActivator) - return; - - // if it's not a player, ignore - if (!pActivator->IsPlayer()) - return; - - // if there is no juice left, turn it off - if (m_iJuice <= 0) - { - pev->frame = 1.0f; - Off(); - } - - // if the player doesn't have the suit, or there is no juice left, make the deny noise - if (m_iJuice <= 0 || !(pActivator->pev->weapons & (1 << WEAPON_SUIT))) - { - if (gpGlobals->time >= m_flSoundTime) - { - m_flSoundTime = gpGlobals->time + 0.62f; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshotno1.wav", VOL_NORM, ATTN_NORM); - } - return; - } - - pev->nextthink = pev->ltime + 0.25f; - SetThink(&CWallHealth::Off); - - // Time to recharge yet? - - if (m_flNextCharge >= gpGlobals->time) - return; - - // Play the on sound or the looping charging sound - if (!m_iOn) - { - m_iOn++; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM); - m_flSoundTime = gpGlobals->time + 0.56f; - } - if (m_iOn == 1 && gpGlobals->time >= m_flSoundTime) - { - m_iOn++; - EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav", VOL_NORM, ATTN_NORM); - } - - // charge the player - if (pActivator->TakeHealth(1, DMG_GENERIC)) - m_iJuice--; - - // govern the rate of charge - m_flNextCharge = gpGlobals->time + 0.1f; +/* ../cstrike/dlls/healthkit.cpp:169 */ +void CWallHealth::__MAKE_VHOOK(Precache)(void) +{ + PRECACHE_SOUND("items/medshot4.wav"); + PRECACHE_SOUND("items/medshotno1.wav"); + PRECACHE_SOUND("items/medcharge4.wav"); } -/* ../cstrike/dlls/healthkit.cpp:236 */ -void CWallHealth::Recharge(void) -{ - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM); - m_iJuice = gSkillData.healthchargerCapacity; - pev->frame = 0.0f; - SetThink(&CWallHealth::SUB_DoNothing); +/* ../cstrike/dlls/healthkit.cpp:177 */ +void CWallHealth::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + // Make sure that we have a caller + if (!pActivator) + return; + + // if it's not a player, ignore + if (!pActivator->IsPlayer()) + return; + + // if there is no juice left, turn it off + if (m_iJuice <= 0) + { + pev->frame = 1.0f; + Off(); + } + + // if the player doesn't have the suit, or there is no juice left, make the deny noise + if (m_iJuice <= 0 || !(pActivator->pev->weapons & (1 << WEAPON_SUIT))) + { + if (gpGlobals->time >= m_flSoundTime) + { + m_flSoundTime = gpGlobals->time + 0.62f; + EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshotno1.wav", VOL_NORM, ATTN_NORM); + } + return; + } + + pev->nextthink = pev->ltime + 0.25f; + SetThink(&CWallHealth::Off); + + // Time to recharge yet? + + if (m_flNextCharge >= gpGlobals->time) + return; + + // Play the on sound or the looping charging sound + if (!m_iOn) + { + m_iOn++; + EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM); + m_flSoundTime = gpGlobals->time + 0.56f; + } + if (m_iOn == 1 && gpGlobals->time >= m_flSoundTime) + { + m_iOn++; + EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav", VOL_NORM, ATTN_NORM); + } + + // charge the player + if (pActivator->TakeHealth(1, DMG_GENERIC)) + m_iJuice--; + + // govern the rate of charge + m_flNextCharge = gpGlobals->time + 0.1f; } -/* ../cstrike/dlls/healthkit.cpp:244 */ -void CWallHealth::Off(void) -{ - // Stop looping sound. - if (m_iOn > 1) - STOP_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav"); - - m_iOn = 0; - - if (!m_iJuice && ((m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime()) > 0)) - { - pev->nextthink = pev->ltime + m_iReactivate; - SetThink(&CWallHealth::Recharge); - } - else - SetThink(&CWallHealth::SUB_DoNothing); +/* ../cstrike/dlls/healthkit.cpp:236 */ +void CWallHealth::Recharge(void) +{ + EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM); + m_iJuice = gSkillData.healthchargerCapacity; + pev->frame = 0.0f; + SetThink(&CWallHealth::SUB_DoNothing); } - -#ifdef HOOK_GAMEDLL + +/* ../cstrike/dlls/healthkit.cpp:244 */ +void CWallHealth::Off(void) +{ + // Stop looping sound. + if (m_iOn > 1) + STOP_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav"); + + m_iOn = 0; + + if (!m_iJuice && ((m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime()) > 0)) + { + pev->nextthink = pev->ltime + m_iReactivate; + SetThink(&CWallHealth::Recharge); + } + else + SetThink(&CWallHealth::SUB_DoNothing); +} + +#ifdef HOOK_GAMEDLL void CHealthKit::Spawn(void) { @@ -240,5 +240,5 @@ void CWallHealth::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us { Use_(pActivator, pCaller, useType, value); } - -#endif // HOOK_GAMEDLL + +#endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/healthkit.h b/regamedll/dlls/healthkit.h index ef119923..24cb5abd 100644 --- a/regamedll/dlls/healthkit.h +++ b/regamedll/dlls/healthkit.h @@ -63,7 +63,7 @@ public: { return ObjectCaps_(); } - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -95,9 +95,4 @@ public: };/* size: 332, cachelines: 6, members: 7 */ - - - - - #endif // HEALTKIT_H diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp index 3db8cfd8..e40b73c2 100644 --- a/regamedll/dlls/hostage/hostage.cpp +++ b/regamedll/dlls/hostage/hostage.cpp @@ -18,41 +18,41 @@ cvar_t cv_hostage_stop; CHostageManager *g_pHostages; int g_iHostageNumber; -/* <45c3fa> ../cstrike/dlls/hostage/hostage.cpp:47 */ -LINK_ENTITY_TO_CLASS(hostage_entity, CHostage); +/* <45c3fa> ../cstrike/dlls/hostage/hostage.cpp:47 */ +LINK_ENTITY_TO_CLASS(hostage_entity, CHostage); -/* <45c4d3> ../cstrike/dlls/hostage/hostage.cpp:48 */ +/* <45c4d3> ../cstrike/dlls/hostage/hostage.cpp:48 */ LINK_ENTITY_TO_CLASS(monster_scientist, CHostage); -/* <45c228> ../cstrike/dlls/hostage/hostage.cpp:54 */ -NOBODY void CHostage::__MAKE_VHOOK(Spawn)(void) -{ -// MAKE_STRING_CLASS(const char *str, -// entvars_t *pev); // 61 -// SetActivity(CHostage *const this, -// int act); // 83 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 93 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 93 -// edict(CBaseEntity *const this); // 102 -// CHostageManager(CHostageManager *const this); // 57 +/* <45c228> ../cstrike/dlls/hostage/hostage.cpp:54 */ +NOBODY void CHostage::__MAKE_VHOOK(Spawn)(void) +{ +// MAKE_STRING_CLASS(const char *str, +// entvars_t *pev); // 61 +// SetActivity(CHostage *const this, +// int act); // 83 +// Vector(Vector *const this, +// float X, +// float Y, +// float Z); // 93 +// Vector(Vector *const this, +// float X, +// float Y, +// float Z); // 93 +// edict(CBaseEntity *const this); // 102 +// CHostageManager(CHostageManager *const this); // 57 } -/* <45bf91> ../cstrike/dlls/hostage/hostage.cpp:137 */ -NOBODY void CHostage::__MAKE_VHOOK(Precache)(void) -{ -// { -// int which; // 141 -// } +/* <45bf91> ../cstrike/dlls/hostage/hostage.cpp:137 */ +NOBODY void CHostage::__MAKE_VHOOK(Precache)(void) +{ +// { +// int which; // 141 +// } } -/* <45c5ac> ../cstrike/dlls/hostage/hostage.cpp:179 */ -void CHostage::SetActivity(int act) +/* <45c5ac> ../cstrike/dlls/hostage/hostage.cpp:179 */ +void CHostage::SetActivity(int act) { if (m_Activity != act) { @@ -78,85 +78,85 @@ void CHostage::SetActivity(int act) void (*pCHostage__IdleThink)(void); -/* <45f194> ../cstrike/dlls/hostage/hostage.cpp:204 */ -NOBODY void __declspec(naked) CHostage::IdleThink(void) -{ - __asm - { - jmp pCHostage__IdleThink - } -// { -// float const upkeepRate; // 220 -// float flInterval; // 224 -// float const updateRate; // 236 -// { -// float const giveUpTime; // 249 -// } -// { -// class CBasePlayer *player; // 263 -// GetFollowLeader(const class CHostageImprov *const this); // 263 -// { -// class CBaseEntity *pSpot; // 271 -// BOOL bContinue; // 272 -// BOOL bResHostagePt; // 272 -// operator-(const Vector *const this, -// const Vector &v); // 284 -// Length(const Vector *const this); // 284 -// operator-(const Vector *const this, -// const Vector &v); // 298 -// Length(const Vector *const this); // 298 -// } -// edict(CBaseEntity *const this); // 332 -// edict(CBaseEntity *const this); // 332 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 337 -// edict(CBaseEntity *const this); // 340 -// ENTINDEX(edict_t *pEdict); // 340 -// edict(CBaseEntity *const this); // 341 -// ENTINDEX(edict_t *pEdict); // 341 -// Remove(CHostage *const this); // 346 -// } -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 242 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 242 -// { -// Vector vDistance; // 395 -// operator-(const Vector *const this, -// const Vector &v); // 395 -// Length(const Vector *const this); // 397 -// } -// Length(const Vector *const this); // 378 -// SetActivity(CHostage *const this, -// int act); // 379 -// Length(const Vector *const this); // 380 -// SetActivity(CHostage *const this, -// int act); // 381 -// SetActivity(CHostage *const this, -// int act); // 383 -// } +/* <45f194> ../cstrike/dlls/hostage/hostage.cpp:204 */ +NOBODY void __declspec(naked) CHostage::IdleThink(void) +{ + __asm + { + jmp pCHostage__IdleThink + } +// { +// float const upkeepRate; // 220 +// float flInterval; // 224 +// float const updateRate; // 236 +// { +// float const giveUpTime; // 249 +// } +// { +// class CBasePlayer *player; // 263 +// GetFollowLeader(const class CHostageImprov *const this); // 263 +// { +// class CBaseEntity *pSpot; // 271 +// BOOL bContinue; // 272 +// BOOL bResHostagePt; // 272 +// operator-(const Vector *const this, +// const Vector &v); // 284 +// Length(const Vector *const this); // 284 +// operator-(const Vector *const this, +// const Vector &v); // 298 +// Length(const Vector *const this); // 298 +// } +// edict(CBaseEntity *const this); // 332 +// edict(CBaseEntity *const this); // 332 +// MESSAGE_BEGIN(int msg_dest, +// int msg_type, +// const float *pOrigin, +// edict_t *ed); // 337 +// edict(CBaseEntity *const this); // 340 +// ENTINDEX(edict_t *pEdict); // 340 +// edict(CBaseEntity *const this); // 341 +// ENTINDEX(edict_t *pEdict); // 341 +// Remove(CHostage *const this); // 346 +// } +// Vector(Vector *const this, +// float X, +// float Y, +// float Z); // 242 +// Vector(Vector *const this, +// float X, +// float Y, +// float Z); // 242 +// { +// Vector vDistance; // 395 +// operator-(const Vector *const this, +// const Vector &v); // 395 +// Length(const Vector *const this); // 397 +// } +// Length(const Vector *const this); // 378 +// SetActivity(CHostage *const this, +// int act); // 379 +// Length(const Vector *const this); // 380 +// SetActivity(CHostage *const this, +// int act); // 381 +// SetActivity(CHostage *const this, +// int act); // 383 +// } } -/* <45c041> ../cstrike/dlls/hostage/hostage.cpp:413 */ -NOBODY void CHostage::Remove(void) -{ -// Vector(Vector::Remove(// float X, -// float Y, -// float Z); // 419 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 419 -} +/* <45c041> ../cstrike/dlls/hostage/hostage.cpp:413 */ +NOBODY void CHostage::Remove(void) +{ +// Vector(Vector::Remove(// float X, +// float Y, +// float Z); // 419 +// Vector(Vector *const this, +// float X, +// float Y, +// float Z); // 419 +} -/* <45c624> ../cstrike/dlls/hostage/hostage.cpp:426 */ -void CHostage::RePosition(void) +/* <45c624> ../cstrike/dlls/hostage/hostage.cpp:426 */ +void CHostage::RePosition(void) { pev->health = pev->max_health; pev->movetype = MOVETYPE_STEP; @@ -194,254 +194,254 @@ void CHostage::RePosition(void) m_flNextFullThink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2); } -/* <45ee7f> ../cstrike/dlls/hostage/hostage.cpp:469 */ -NOBODY int CHostage::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ -// { -// float flActualDamage; // 471 -// class CBasePlayer *pAttacker; // 472 -// GetModifiedDamage(CHostage *const this, -// float flDamage, -// int nHitGroup); // 475 -// PlayPainSound(CHostage *const this); // 485 -// { -// class CBaseEntity *pAttackingEnt; // 489 -// GetClassPtr(CBaseEntity *a); // 492 -// } -// ApplyHostagePenalty(CHostage *const this, -// class CBasePlayer *pAttacker); // 518 -// SetFlinchActivity(CHostage *const this); // 552 -// } +/* <45ee7f> ../cstrike/dlls/hostage/hostage.cpp:469 */ +NOBODY int CHostage::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ +// { +// float flActualDamage; // 471 +// class CBasePlayer *pAttacker; // 472 +// GetModifiedDamage(CHostage *const this, +// float flDamage, +// int nHitGroup); // 475 +// PlayPainSound(CHostage *const this); // 485 +// { +// class CBaseEntity *pAttackingEnt; // 489 +// GetClassPtr(CBaseEntity *a); // 492 +// } +// ApplyHostagePenalty(CHostage *const this, +// class CBasePlayer *pAttacker); // 518 +// SetFlinchActivity(CHostage *const this); // 552 +// } } -/* <45c783> ../cstrike/dlls/hostage/hostage.cpp:578 */ -NOBODY float CHostage::GetModifiedDamage(float flDamage, int nHitGroup) -{ -} - -/* <45c7d3> ../cstrike/dlls/hostage/hostage.cpp:597 */ -NOBODY void CHostage::PlayPainSound(void) -{ -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 603 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 605 -} - -/* <45c8c4> ../cstrike/dlls/hostage/hostage.cpp:612 */ -NOBODY void CHostage::SetFlinchActivity(void) -{ -// { -// Activity activity; // 616 -// SetActivity(CHostage *const this, -// int act); // 637 -// } -} - -/* <45c960> ../cstrike/dlls/hostage/hostage.cpp:642 */ -NOBODY void CHostage::SetDeathActivity(void) -{ -// SetActivity(CHostage::SetDeathActivity(// int act); // 675 -// SetActivity(CHostage *const this, -// int act); // 678 -// SetActivity(CHostage *const this, -// int act); // 676 -// SetActivity(CHostage *const this, -// int act); // 677 -// SetActivity(CHostage *const this, -// int act); // 658 -// SetActivity(CHostage *const this, -// int act); // 656 +/* <45c783> ../cstrike/dlls/hostage/hostage.cpp:578 */ +NOBODY float CHostage::GetModifiedDamage(float flDamage, int nHitGroup) +{ } -/* <45cc41> ../cstrike/dlls/hostage/hostage.cpp:684 */ -NOBODY void CHostage::AnnounceDeath(CBasePlayer *pAttacker) -{ -// edict(CBaseEntity *const this); // 704 -// edict(CBaseEntity *const this); // 704 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 707 -// edict(CBaseEntity *const this); // 710 -// ENTINDEX(edict_t *pEdict); // 710 -// edict(CBaseEntity *const this); // 711 -// ENTINDEX(edict_t *pEdict); // 711 +/* <45c7d3> ../cstrike/dlls/hostage/hostage.cpp:597 */ +NOBODY void CHostage::PlayPainSound(void) +{ +// EMIT_SOUND(edict_t *entity, +// int channel, +// const char *sample, +// float volume, +// float attenuation); // 603 +// EMIT_SOUND(edict_t *entity, +// int channel, +// const char *sample, +// float volume, +// float attenuation); // 605 } -/* <45cd6b> ../cstrike/dlls/hostage/hostage.cpp:717 */ -NOBODY void CHostage::ApplyHostagePenalty(CBasePlayer *pAttacker) -{ -// { -// int iHostagePenalty; // 719 -// edict(CBaseEntity *const this); // 735 -// } +/* <45c8c4> ../cstrike/dlls/hostage/hostage.cpp:612 */ +NOBODY void CHostage::SetFlinchActivity(void) +{ +// { +// Activity activity; // 616 +// SetActivity(CHostage *const this, +// int act); // 637 +// } } -/* <45cfd6> ../cstrike/dlls/hostage/hostage.cpp:740 */ -NOBODY void CHostage::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// { -// class CBasePlayer *pPlayer; // 742 -// } -// Use(CHostage *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 740 +/* <45c960> ../cstrike/dlls/hostage/hostage.cpp:642 */ +NOBODY void CHostage::SetDeathActivity(void) +{ +// SetActivity(CHostage::SetDeathActivity(// int act); // 675 +// SetActivity(CHostage *const this, +// int act); // 678 +// SetActivity(CHostage *const this, +// int act); // 676 +// SetActivity(CHostage *const this, +// int act); // 677 +// SetActivity(CHostage *const this, +// int act); // 658 +// SetActivity(CHostage *const this, +// int act); // 656 } -/* <45cdba> ../cstrike/dlls/hostage/hostage.cpp:833 */ -NOBODY void CHostage::PlayFollowRescueSound(void) -{ -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 845 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 843 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 837 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 839 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 841 +/* <45cc41> ../cstrike/dlls/hostage/hostage.cpp:684 */ +NOBODY void CHostage::AnnounceDeath(CBasePlayer *pAttacker) +{ +// edict(CBaseEntity *const this); // 704 +// edict(CBaseEntity *const this); // 704 +// MESSAGE_BEGIN(int msg_dest, +// int msg_type, +// const float *pOrigin, +// edict_t *ed); // 707 +// edict(CBaseEntity *const this); // 710 +// ENTINDEX(edict_t *pEdict); // 710 +// edict(CBaseEntity *const this); // 711 +// ENTINDEX(edict_t *pEdict); // 711 } -/* <45d1ff> ../cstrike/dlls/hostage/hostage.cpp:851 */ -NOBODY void CHostage::GiveCTTouchBonus(CBasePlayer *pPlayer) -{ -// edict(CBaseEntity *const this); // 865 -// edict(CBaseEntity *const this); // 865 -} - -/* <45bf69> ../cstrike/dlls/hostage/hostage.cpp:869 */ -NOBODY int CHostage::__MAKE_VHOOK(ObjectCaps)(void) -{ -} - -/* <45c0e3> ../cstrike/dlls/hostage/hostage.cpp:876 */ -NOBODY void CHostage::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) -{ -// { -// class Vector2D vPush; // 901 -// float const pushForce; // 904 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 895 -// { -// class CBasePlayer *pPlayer; // 888 -// } -// } -// Touch(CHostage *const this, -// class CBaseEntity *pOther); // 876 +/* <45cd6b> ../cstrike/dlls/hostage/hostage.cpp:717 */ +NOBODY void CHostage::ApplyHostagePenalty(CBasePlayer *pAttacker) +{ +// { +// int iHostagePenalty; // 719 +// edict(CBaseEntity *const this); // 735 +// } } -/* <45dd66> ../cstrike/dlls/hostage/hostage.cpp:910 */ -NOBODY void CHostage::DoFollow(void) -{ -// { -// class CBaseEntity *pFollowing; // 912 -// Vector vecDest; // 913 -// float flRadius; // 914 -// float flDistToDest; // 915 -// GetClassPtr(CBaseEntity *a); // 930 -// SetTargetEnt(CLocalNav *const this, -// class CBaseEntity *pTarget); // 931 -// operator-(const Vector *const this, -// const Vector &v); // 937 -// Length(const Vector *const this); // 937 -// Length2D(const Vector *const this); // 1009 -// operator-(const Vector *const this, -// const Vector &v); // 964 -// Length2D(const Vector *const this); // 964 -// Length2D(const Vector *const this); // 952 -// IsFollowingSomeone(CHostage *const this); // 994 -// PointAt(CHostage *const this, -// const Vector &vecLoc); // 985 -// } +/* <45cfd6> ../cstrike/dlls/hostage/hostage.cpp:740 */ +NOBODY void CHostage::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ +// { +// class CBasePlayer *pPlayer; // 742 +// } +// Use(CHostage *const this, +// class CBaseEntity *pActivator, +// class CBaseEntity *pCaller, +// USE_TYPE useType, +// float value); // 740 } -/* <45d278> ../cstrike/dlls/hostage/hostage.cpp:1018 */ -NOBODY void CHostage::PointAt(const Vector &vecLoc) -{ -// operator-(const Vector *const this, -// const Vector &v); // 1022 +/* <45cdba> ../cstrike/dlls/hostage/hostage.cpp:833 */ +NOBODY void CHostage::PlayFollowRescueSound(void) +{ +// EMIT_SOUND(edict_t *entity, +// int channel, +// const char *sample, +// float volume, +// float attenuation); // 845 +// EMIT_SOUND(edict_t *entity, +// int channel, +// const char *sample, +// float volume, +// float attenuation); // 843 +// EMIT_SOUND(edict_t *entity, +// int channel, +// const char *sample, +// float volume, +// float attenuation); // 837 +// EMIT_SOUND(edict_t *entity, +// int channel, +// const char *sample, +// float volume, +// float attenuation); // 839 +// EMIT_SOUND(edict_t *entity, +// int channel, +// const char *sample, +// float volume, +// float attenuation); // 841 } -/* <45d34c> ../cstrike/dlls/hostage/hostage.cpp:1025 */ -NOBODY void CHostage::MoveToward(const Vector &vecLoc) -{ -// { -// int nFwdMove; // 1027 -// Vector vecFwd; // 1028 -// Vector vecbigDest; // 1029 -// Vector vecMove; // 1030 -// class CBaseEntity *pFollowing; // 1032 -// Vector vecAng; // 1034 -// float flDist; // 1040 -// GetClassPtr(CBaseEntity *a); // 1032 -// UTIL_MakeVectorsPrivate(Vector &vecAngles, -// float *p_vForward, -// float *p_vRight, -// float *p_vUp); // 1038 -// operator-(const Vector *const this, -// const Vector &v); // 1036 -// operator-(const Vector *const this, -// const Vector &v); // 1040 -// Length2D(const Vector *const this); // 1040 -// operator*(const Vector *const this, -// float fl); // 1040 -// Length2D(const Vector *const this); // 1040 -// operator-(const Vector *const this, -// const Vector &v); // 1040 -// Length2D(const Vector *const this); // 1040 -// operator*(const Vector *const this, -// float fl); // 1041 -// operator+(const Vector *const this, -// const Vector &v); // 1043 -// { -// float flSpeed; // 1049 -// Vector vecDest; // 1051 -// { -// float flDist; // 1061 -// operator-(const Vector *const this, -// const Vector &v); // 1063 -// Length(const Vector *const this); // 1063 -// } -// } -// operator*(const Vector *const this, -// float fl); // 1040 -// Length2D(const Vector *const this); // 1040 -// } +/* <45d1ff> ../cstrike/dlls/hostage/hostage.cpp:851 */ +NOBODY void CHostage::GiveCTTouchBonus(CBasePlayer *pPlayer) +{ +// edict(CBaseEntity *const this); // 865 +// edict(CBaseEntity *const this); // 865 } -/* <45d704> ../cstrike/dlls/hostage/hostage.cpp:1102 */ -NOBODY BOOL CHostage::IsOnLadder(void) -{ +/* <45bf69> ../cstrike/dlls/hostage/hostage.cpp:869 */ +NOBODY int CHostage::__MAKE_VHOOK(ObjectCaps)(void) +{ } -/* <45d727> ../cstrike/dlls/hostage/hostage.cpp:1106 */ -void CHostage::NavReady(void) -{ +/* <45c0e3> ../cstrike/dlls/hostage/hostage.cpp:876 */ +NOBODY void CHostage::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +{ +// { +// class Vector2D vPush; // 901 +// float const pushForce; // 904 +// FClassnameIs(entvars_t *pev, +// const char *szClassname); // 895 +// { +// class CBasePlayer *pPlayer; // 888 +// } +// } +// Touch(CHostage *const this, +// class CBaseEntity *pOther); // 876 +} + +/* <45dd66> ../cstrike/dlls/hostage/hostage.cpp:910 */ +NOBODY void CHostage::DoFollow(void) +{ +// { +// class CBaseEntity *pFollowing; // 912 +// Vector vecDest; // 913 +// float flRadius; // 914 +// float flDistToDest; // 915 +// GetClassPtr(CBaseEntity *a); // 930 +// SetTargetEnt(CLocalNav *const this, +// class CBaseEntity *pTarget); // 931 +// operator-(const Vector *const this, +// const Vector &v); // 937 +// Length(const Vector *const this); // 937 +// Length2D(const Vector *const this); // 1009 +// operator-(const Vector *const this, +// const Vector &v); // 964 +// Length2D(const Vector *const this); // 964 +// Length2D(const Vector *const this); // 952 +// IsFollowingSomeone(CHostage *const this); // 994 +// PointAt(CHostage *const this, +// const Vector &vecLoc); // 985 +// } +} + +/* <45d278> ../cstrike/dlls/hostage/hostage.cpp:1018 */ +NOBODY void CHostage::PointAt(const Vector &vecLoc) +{ +// operator-(const Vector *const this, +// const Vector &v); // 1022 +} + +/* <45d34c> ../cstrike/dlls/hostage/hostage.cpp:1025 */ +NOBODY void CHostage::MoveToward(const Vector &vecLoc) +{ +// { +// int nFwdMove; // 1027 +// Vector vecFwd; // 1028 +// Vector vecbigDest; // 1029 +// Vector vecMove; // 1030 +// class CBaseEntity *pFollowing; // 1032 +// Vector vecAng; // 1034 +// float flDist; // 1040 +// GetClassPtr(CBaseEntity *a); // 1032 +// UTIL_MakeVectorsPrivate(Vector &vecAngles, +// float *p_vForward, +// float *p_vRight, +// float *p_vUp); // 1038 +// operator-(const Vector *const this, +// const Vector &v); // 1036 +// operator-(const Vector *const this, +// const Vector &v); // 1040 +// Length2D(const Vector *const this); // 1040 +// operator*(const Vector *const this, +// float fl); // 1040 +// Length2D(const Vector *const this); // 1040 +// operator-(const Vector *const this, +// const Vector &v); // 1040 +// Length2D(const Vector *const this); // 1040 +// operator*(const Vector *const this, +// float fl); // 1041 +// operator+(const Vector *const this, +// const Vector &v); // 1043 +// { +// float flSpeed; // 1049 +// Vector vecDest; // 1051 +// { +// float flDist; // 1061 +// operator-(const Vector *const this, +// const Vector &v); // 1063 +// Length(const Vector *const this); // 1063 +// } +// } +// operator*(const Vector *const this, +// float fl); // 1040 +// Length2D(const Vector *const this); // 1040 +// } +} + +/* <45d704> ../cstrike/dlls/hostage/hostage.cpp:1102 */ +NOBODY BOOL CHostage::IsOnLadder(void) +{ +} + +/* <45d727> ../cstrike/dlls/hostage/hostage.cpp:1106 */ +void CHostage::NavReady(void) +{ CBaseEntity *pFollowing; Vector vecDest; float flRadius = 40.0; @@ -453,7 +453,7 @@ void CHostage::NavReady(void) pFollowing = GetClassPtr((CBaseEntity *)m_hTargetEnt->pev); vecDest = pFollowing->pev->origin; - + if (!(pFollowing->pev->flags & FL_ONGROUND)) { TraceResult tr; @@ -492,87 +492,87 @@ void CHostage::NavReady(void) m_flPathCheckInterval = 0.5; m_nPathNodes = m_LocalNav->SetupPathNodes(nindexPath, vecNodes, 1); - } + } } -/* <45edaa> ../cstrike/dlls/hostage/hostage.cpp:1159 */ -NOBODY void CHostage::SendHostagePositionMsg(void) -{ -// { -// class CBaseEntity *pEntity; // 1161 -// edict(CBaseEntity *const this); // 1165 -// FNullEnt(const edict_t *pent); // 1165 -// { -// class CBasePlayer *pTempPlayer; // 1169 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// entvars_t *ent); // 1173 -// } -// } +/* <45edaa> ../cstrike/dlls/hostage/hostage.cpp:1159 */ +NOBODY void CHostage::SendHostagePositionMsg(void) +{ +// { +// class CBaseEntity *pEntity; // 1161 +// edict(CBaseEntity *const this); // 1165 +// FNullEnt(const edict_t *pent); // 1165 +// { +// class CBasePlayer *pTempPlayer; // 1169 +// MESSAGE_BEGIN(int msg_dest, +// int msg_type, +// const float *pOrigin, +// entvars_t *ent); // 1173 +// } +// } } -/* <45ecd5> ../cstrike/dlls/hostage/hostage.cpp:1189 */ -NOBODY void CHostage::SendHostageEventMsg(void) -{ -// { -// class CBaseEntity *pEntity; // 1191 -// edict(CBaseEntity *const this); // 1195 -// FNullEnt(const edict_t *pent); // 1195 -// { -// class CBasePlayer *pTempPlayer; // 1199 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// entvars_t *ent); // 1203 -// } -// } +/* <45ecd5> ../cstrike/dlls/hostage/hostage.cpp:1189 */ +NOBODY void CHostage::SendHostageEventMsg(void) +{ +// { +// class CBaseEntity *pEntity; // 1191 +// edict(CBaseEntity *const this); // 1195 +// FNullEnt(const edict_t *pent); // 1195 +// { +// class CBasePlayer *pTempPlayer; // 1199 +// MESSAGE_BEGIN(int msg_dest, +// int msg_type, +// const float *pOrigin, +// entvars_t *ent); // 1203 +// } +// } } -/* <45d8a6> ../cstrike/dlls/hostage/hostage.cpp:1292 */ -NOBODY void CHostage::Wiggle(void) -{ -// { -// TraceResult tr; // 1294 -// Vector vec; // 1295 -// Vector wiggle_directions; // 1297 -// operator*(const Vector *const this, -// float fl); // 1307 -// { -// int i; // 1309 -// { -// Vector dest; // 1311 -// operator+(const Vector *const this, -// const Vector &v); // 1311 -// operator-(const Vector *const this, -// const Vector &v); // 1314 -// } -// } -// operator*(const Vector *const this, -// float fl); // 1307 -// operator*(const Vector *const this, -// float fl); // 1307 -// operator*(const Vector *const this, -// float fl); // 1307 -// operator*(const Vector *const this, -// float fl); // 1307 -// operator*(const Vector *const this, -// float fl); // 1307 -// operator*(const Vector *const this, -// float fl); // 1307 -// operator*(const Vector *const this, -// float fl); // 1307 -// operator+(const Vector *const this, -// const Vector &v); // 1338 -// Normalize(const Vector *const this); // 1340 -// operator+(const Vector *const this, -// const Vector &v); // 1340 -// } +/* <45d8a6> ../cstrike/dlls/hostage/hostage.cpp:1292 */ +NOBODY void CHostage::Wiggle(void) +{ +// { +// TraceResult tr; // 1294 +// Vector vec; // 1295 +// Vector wiggle_directions; // 1297 +// operator*(const Vector *const this, +// float fl); // 1307 +// { +// int i; // 1309 +// { +// Vector dest; // 1311 +// operator+(const Vector *const this, +// const Vector &v); // 1311 +// operator-(const Vector *const this, +// const Vector &v); // 1314 +// } +// } +// operator*(const Vector *const this, +// float fl); // 1307 +// operator*(const Vector *const this, +// float fl); // 1307 +// operator*(const Vector *const this, +// float fl); // 1307 +// operator*(const Vector *const this, +// float fl); // 1307 +// operator*(const Vector *const this, +// float fl); // 1307 +// operator*(const Vector *const this, +// float fl); // 1307 +// operator*(const Vector *const this, +// float fl); // 1307 +// operator+(const Vector *const this, +// const Vector &v); // 1338 +// Normalize(const Vector *const this); // 1340 +// operator+(const Vector *const this, +// const Vector &v); // 1340 +// } } -/* <45e00c> ../cstrike/dlls/hostage/hostage.cpp:1346 */ -void CHostage::PreThink(void) -{ +/* <45e00c> ../cstrike/dlls/hostage/hostage.cpp:1346 */ +void CHostage::PreThink(void) +{ Vector vecSrc; Vector vecDest; TraceResult tr; @@ -645,31 +645,31 @@ void CHostage::PreThink(void) vecNewOrigin.z = tr.vecEndPos.z; UTIL_SetOrigin(pev, vecNewOrigin); pev->velocity.z += pev->gravity * g_psv_gravity->value * gpGlobals->frametime; - } + } } - -/* <45e24e> ../cstrike/dlls/hostage/hostage.cpp:1421 */ -void Hostage_RegisterCVars(void) -{ + +/* <45e24e> ../cstrike/dlls/hostage/hostage.cpp:1421 */ +void Hostage_RegisterCVars(void) +{ CVAR_REGISTER(&cv_hostage_debug); - CVAR_REGISTER(&cv_hostage_stop); + CVAR_REGISTER(&cv_hostage_stop); } -/* <45e2a6> ../cstrike/dlls/hostage/hostage.cpp:1430 */ -NOBODY void InstallHostageManager(void) -{ -// ~CHostageManager(CHostageManager *const this, -// int const __in_chrg); // 1433 -// CHostageManager(CHostageManager *const this); // 1435 +/* <45e2a6> ../cstrike/dlls/hostage/hostage.cpp:1430 */ +NOBODY void InstallHostageManager(void) +{ +// ~CHostageManager(CHostageManager *const this, +// int const __in_chrg); // 1433 +// CHostageManager(CHostageManager *const this); // 1435 } -/* <45e375> ../cstrike/dlls/hostage/hostage.cpp:1443 */ -NOBODY CHostageManager::CHostageManager(void) -{ - Q_memset(&m_chatter, 0, sizeof(m_chatter)); - m_hostageCount = 0; - -// SimpleChatter(SimpleChatter *const this); // 1443 +/* <45e375> ../cstrike/dlls/hostage/hostage.cpp:1443 */ +NOBODY CHostageManager::CHostageManager(void) +{ + Q_memset(&m_chatter, 0, sizeof(m_chatter)); + m_hostageCount = 0; + +// SimpleChatter(SimpleChatter *const this); // 1443 } /* <45e39b> ../cstrike/dlls/hostage/hostage.cpp:1456 */ @@ -685,135 +685,135 @@ void CHostageManager::ServerActivate(void) if (UTIL_IsGame("czero")) { - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/getouttahere.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/illfollow.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letsdoit.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letsgo.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letshurry.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letsmove.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/okletsgo.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/youlead.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/comeback.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/dontleaveme.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/illstayhere.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/notleaveme.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/yeahillstay.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/donthurtme1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/donthurtme2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/dontkill.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/endpeace.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/nevernegotiate.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/nottellanything.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/surrender.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/whatdoyou.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/whyareyou.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/donthurtme1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/donthurtme2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/dontkill.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/dontkill.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/illgoback1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/illgoback2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/okokgoing.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/okokgoing2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/sorry1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/sorry2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/sorry3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain4.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain5.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain6.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/awwcrap1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/awwcrap2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/getdown1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/getdown2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/getdown3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookout1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookout2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookshooting1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookshooting2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookshooting3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/ohgod1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/ohgod2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awwcrap1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awwcrap2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/deargod1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/deargod2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/deargod3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohgod1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohgod2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohno1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohno2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awww2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awww4.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/awwcrap1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/awwcrap2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/lookout1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/lookout2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/areyousave.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/getmeoutta1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/getmeoutta2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/imahostage.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/rescueme1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/rescueme2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/theyregonna.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/areyousave.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/getmeoutta1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/getmeoutta2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/rescueme1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/rescueme2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/almostouttahere.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/almostthere.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/keepgoing.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/notfar.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/alldead.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/goodnews.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/outtahere.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over4.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over5.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/relief.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/doomed.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/godno.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/nowwhat.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/ohman.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/ohno.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/finally.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/finallysafe.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/thankyou.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/wemadeit1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/wemadeit2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/wemadeit3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/becareful1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/becareful2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/stillaround1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/stillaround2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/lookout1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/lookout2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/overthere1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/overthere2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/helpme1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/helpme2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/hey1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/hey2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/overhere1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough3.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough4.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough5.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough6.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_BLINDED, "hostage/hflash/cantsee.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_BLINDED, "hostage/hflash/myeyes.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/grenade1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/grenade2.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/run.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/watchout.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_DEATH_CRY, "hostage/hdie/hdeath1.wav"); - m_chatter.AddSound(HOSTAGE_CHATTER_DEATH_CRY, "hostage/hdie/hdeath2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/getouttahere.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/illfollow.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letsdoit.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letsgo.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letshurry.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/letsmove.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/okletsgo.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_START_FOLLOW, "hostage/huse/youlead.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/comeback.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/dontleaveme.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/illstayhere.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/notleaveme.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_STOP_FOLLOW, "hostage/hunuse/yeahillstay.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/donthurtme1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/donthurtme2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/dontkill.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/endpeace.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/nevernegotiate.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/nottellanything.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/surrender.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/whatdoyou.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_INTIMIDATED, "hostage/hseenbyt/whyareyou.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/donthurtme1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/donthurtme2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/dontkill.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hseenbyt/dontkill.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/illgoback1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/illgoback2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/okokgoing.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/okokgoing2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/sorry1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/sorry2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RETREAT, "hostage/hretreat/sorry3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain4.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain5.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PAIN, "hostage/hpain/hpain6.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/awwcrap1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/awwcrap2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/getdown1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/getdown2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/getdown3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookout1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookout2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookshooting1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookshooting2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/lookshooting3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/ohgod1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, "hostage/hreactions/ohgod2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awwcrap1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awwcrap2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/deargod1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/deargod2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/deargod3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohgod1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohgod2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohno1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/ohno2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awww2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SCARED_OF_MURDER, "hostage/hreactions/awww4.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/awwcrap1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/awwcrap2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/lookout1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_LOOK_OUT, "hostage/hreactions/lookout2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/areyousave.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/getmeoutta1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/getmeoutta2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/imahostage.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/rescueme1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/rescueme2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_PLEASE_RESCUE_ME, "hostage/hseenbyct/theyregonna.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/areyousave.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/getmeoutta1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/getmeoutta2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/rescueme1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, "hostage/hseenbyct/rescueme2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/almostouttahere.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/almostthere.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/keepgoing.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SEE_RESCUE_ZONE, "hostage/hseezone/notfar.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/alldead.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/goodnews.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/outtahere.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over4.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/over5.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CTS_WIN, "hostage/hctwin/relief.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/doomed.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/godno.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/nowwhat.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/ohman.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_TERRORISTS_WIN, "hostage/htwin/ohno.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/finally.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/finallysafe.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/thankyou.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/wemadeit1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/wemadeit2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_RESCUED, "hostage/hrescued/wemadeit3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/becareful1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/becareful2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/stillaround1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_NEARBY, "hostage/hwarn/stillaround2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/lookout1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/lookout2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/overthere1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_WARN_SPOTTED, "hostage/hwarn/overthere2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/helpme1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/helpme2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/hey1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/hey2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_CALL_TO_RESCUER, "hostage/hwavect/overhere1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough3.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough4.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough5.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_COUGH, "hostage/hsmoke/cough6.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_BLINDED, "hostage/hflash/cantsee.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_BLINDED, "hostage/hflash/myeyes.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/grenade1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/grenade2.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/run.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_SAW_HE_GRENADE, "hostage/hgrenade/watchout.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_DEATH_CRY, "hostage/hdie/hdeath1.wav"); + m_chatter.AddSound(HOSTAGE_CHATTER_DEATH_CRY, "hostage/hdie/hdeath2.wav"); m_chatter.AddSound(HOSTAGE_CHATTER_DEATH_CRY, "hostage/hdie/hdeath3.wav"); } } @@ -824,8 +824,8 @@ void CHostageManager::ServerDeactivate(void) ; } -/* <45e3f7> ../cstrike/dlls/hostage/hostage.cpp:1631 */ -void CHostageManager::RestartRound(void) +/* <45e3f7> ../cstrike/dlls/hostage/hostage.cpp:1631 */ +void CHostageManager::RestartRound(void) { for (int i = 0; i < m_hostageCount; i++) { @@ -836,192 +836,192 @@ void CHostageManager::RestartRound(void) } } -/* <45e43d> ../cstrike/dlls/hostage/hostage.cpp:1640 */ -void CHostageManager::AddHostage(CHostage *hostage) -{ - if (m_hostageCount >= MAX_HOSTAGES) - return; - - int i; - for (i = 0; i < m_hostageCount; i++) - { +/* <45e43d> ../cstrike/dlls/hostage/hostage.cpp:1640 */ +void CHostageManager::AddHostage(CHostage *hostage) +{ + if (m_hostageCount >= MAX_HOSTAGES) + return; + + int i; + for (i = 0; i < m_hostageCount; i++) + { if (m_hostage[i] == hostage) { break; - } - } - + } + } + if (i == m_hostageCount) { m_hostage[m_hostageCount] = hostage; m_hostageCount++; - } + } } -/* <45e47f> ../cstrike/dlls/hostage/hostage.cpp:1657 */ -NOBODY bool CHostageManager::IsNearbyHostageTalking(CHostageImprov *improv) -{ -// { -// int i; // 1659 -// { -// const class CHostageImprov *other; // 1663 -// float const closeRange; // 1671 -// operator-(const Vector *const this, -// const Vector &v); // 1672 -// IsLengthGreaterThan(const Vector *const this, -// float length); // 1672 -// IsTalking(const class CHostageImprov *const this); // 1675 -// } -// } +/* <45e47f> ../cstrike/dlls/hostage/hostage.cpp:1657 */ +NOBODY bool CHostageManager::IsNearbyHostageTalking(CHostageImprov *improv) +{ +// { +// int i; // 1659 +// { +// const class CHostageImprov *other; // 1663 +// float const closeRange; // 1671 +// operator-(const Vector *const this, +// const Vector &v); // 1672 +// IsLengthGreaterThan(const Vector *const this, +// float length); // 1672 +// IsTalking(const class CHostageImprov *const this); // 1675 +// } +// } } -/* <45e57b> ../cstrike/dlls/hostage/hostage.cpp:1689 */ -NOBODY bool CHostageManager::IsNearbyHostageJumping(CHostageImprov *improv) -{ -// { -// int i; // 1691 -// { -// const class CHostageImprov *other; // 1695 -// float const closeRange; // 1703 -// operator-(const Vector *const this, -// const Vector &v); // 1704 -// IsLengthGreaterThan(const Vector *const this, -// float length); // 1704 -// } -// } +/* <45e57b> ../cstrike/dlls/hostage/hostage.cpp:1689 */ +NOBODY bool CHostageManager::IsNearbyHostageJumping(CHostageImprov *improv) +{ +// { +// int i; // 1691 +// { +// const class CHostageImprov *other; // 1695 +// float const closeRange; // 1703 +// operator-(const Vector *const this, +// const Vector &v); // 1704 +// IsLengthGreaterThan(const Vector *const this, +// float length); // 1704 +// } +// } } -/* <45e642> ../cstrike/dlls/hostage/hostage.cpp:1716 */ -void CHostageManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) -{ - for (int i = 0; i < m_hostageCount; i++) - { - CHostageImprov *improv = m_hostage[ i ]->m_improv; - - if (improv != NULL) +/* <45e642> ../cstrike/dlls/hostage/hostage.cpp:1716 */ +void CHostageManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +{ + for (int i = 0; i < m_hostageCount; i++) + { + CHostageImprov *improv = m_hostage[ i ]->m_improv; + + if (improv != NULL) { - improv->OnGameEvent(event, entity, other); + improv->OnGameEvent(event, entity, other); } - } + } } -/* <45e6b8> ../cstrike/dlls/hostage/hostage.cpp:1726 */ -SimpleChatter::SimpleChatter(void) -{ - for (int i = 0; i < ARRAYSIZE(m_chatter); i++) - { - m_chatter[i].count = 0; - m_chatter[i].index = 0; - m_chatter[i].needsShuffle = false; - } +/* <45e6b8> ../cstrike/dlls/hostage/hostage.cpp:1726 */ +SimpleChatter::SimpleChatter(void) +{ + for (int i = 0; i < ARRAYSIZE(m_chatter); i++) + { + m_chatter[i].count = 0; + m_chatter[i].index = 0; + m_chatter[i].needsShuffle = false; + } } -/* <45e6f0> ../cstrike/dlls/hostage/hostage.cpp:1737 */ -SimpleChatter::~SimpleChatter(void) -{ - for (int i = 0; i < ARRAYSIZE(m_chatter); i++) - { - for (int f = 0; f < m_chatter[i].count; f++) - { - if (m_chatter[i].file[f].filename) - { - delete[] m_chatter[i].file[f].filename; - } - } - } +/* <45e6f0> ../cstrike/dlls/hostage/hostage.cpp:1737 */ +SimpleChatter::~SimpleChatter(void) +{ + for (int i = 0; i < ARRAYSIZE(m_chatter); i++) + { + for (int f = 0; f < m_chatter[i].count; f++) + { + if (m_chatter[i].file[f].filename) + { + delete[] m_chatter[i].file[f].filename; + } + } + } } -/* <45e736> ../cstrike/dlls/hostage/hostage.cpp:1752 */ -void SimpleChatter::AddSound(HostageChatterType type, char *filename) -{ - ChatterSet *chatter; - char actualFilename[128]; - - chatter = &m_chatter[ type ]; - - Q_snprintf(actualFilename, sizeof(actualFilename), "sound\\%s", filename); - - chatter->file[ chatter->count ].filename = CloneString(filename); - chatter->file[ chatter->count ].duration = (double)GET_APPROX_WAVE_PLAY_LEN(actualFilename) / 1000.0; - - chatter->needsShuffle = true; - chatter->count++; - - PRECACHE_SOUND(filename); +/* <45e736> ../cstrike/dlls/hostage/hostage.cpp:1752 */ +void SimpleChatter::AddSound(HostageChatterType type, char *filename) +{ + ChatterSet *chatter; + char actualFilename[128]; + + chatter = &m_chatter[ type ]; + + Q_snprintf(actualFilename, sizeof(actualFilename), "sound\\%s", filename); + + chatter->file[ chatter->count ].filename = CloneString(filename); + chatter->file[ chatter->count ].duration = (double)GET_APPROX_WAVE_PLAY_LEN(actualFilename) / 1000.0; + + chatter->needsShuffle = true; + chatter->count++; + + PRECACHE_SOUND(filename); } -/* <45e8c7> ../cstrike/dlls/hostage/hostage.cpp:1773 */ -NOBODY void SimpleChatter::Shuffle(ChatterSet *chatter) -{ -// { -// int i; // 1775 -// { -// int j; // 1777 -// { -// class SoundFile tmp; // 1781 -// } -// } -// } +/* <45e8c7> ../cstrike/dlls/hostage/hostage.cpp:1773 */ +NOBODY void SimpleChatter::Shuffle(ChatterSet *chatter) +{ +// { +// int i; // 1775 +// { +// int j; // 1777 +// { +// class SoundFile tmp; // 1781 +// } +// } +// } } -/* <45e979> ../cstrike/dlls/hostage/hostage.cpp:1793 */ -NOBODY char *SimpleChatter::GetSound(HostageChatterType type, float *duration) -{ -// { -// class ChatterSet *chatter; // 1795 -// char *sound; // 1805 -// Shuffle(SimpleChatter *const this, -// class ChatterSet *chatter); // 1800 -// } +/* <45e979> ../cstrike/dlls/hostage/hostage.cpp:1793 */ +NOBODY char *SimpleChatter::GetSound(HostageChatterType type, float *duration) +{ +// { +// class ChatterSet *chatter; // 1795 +// char *sound; // 1805 +// Shuffle(SimpleChatter *const this, +// class ChatterSet *chatter); // 1800 +// } } -/* <45ea1b> ../cstrike/dlls/hostage/hostage.cpp:1818 */ -NOBODY float SimpleChatter::PlaySound(CBaseEntity *entity, HostageChatterType type) -{ -// { -// class CHostage *hostage; // 1821 -// float duration; // 1823 -// char *sound; // 1824 -// GetSound(SimpleChatter *const this, -// enum HostageChatterType type, -// float *duration); // 1824 -// { -// int pitch; // 1828 -// int attenuation; // 1838 -// } -// } +/* <45ea1b> ../cstrike/dlls/hostage/hostage.cpp:1818 */ +NOBODY float SimpleChatter::PlaySound(CBaseEntity *entity, HostageChatterType type) +{ +// { +// class CHostage *hostage; // 1821 +// float duration; // 1823 +// char *sound; // 1824 +// GetSound(SimpleChatter *const this, +// enum HostageChatterType type, +// float *duration); // 1824 +// { +// int pitch; // 1828 +// int attenuation; // 1838 +// } +// } } #ifdef HOOK_GAMEDLL -void CHostage::Spawn(void) -{ - Spawn_(); -} - -void CHostage::Precache(void) -{ - Precache_(); -} - -int CHostage::ObjectCaps(void) -{ - return ObjectCaps_(); -} - -int CHostage::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ - return TakeDamage_(pevInflictor, pevAttacker, flDamage, bitsDamageType); -} - -void CHostage::Touch(CBaseEntity *pOther) -{ - Touch_(pOther); -} - -void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ - Use_(pActivator, pCaller, useType, value); +void CHostage::Spawn(void) +{ + Spawn_(); +} + +void CHostage::Precache(void) +{ + Precache_(); +} + +int CHostage::ObjectCaps(void) +{ + return ObjectCaps_(); +} + +int CHostage::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + return TakeDamage_(pevInflictor, pevAttacker, flDamage, bitsDamageType); +} + +void CHostage::Touch(CBaseEntity *pOther) +{ + Touch_(pOther); +} + +void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + Use_(pActivator, pCaller, useType, value); } #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/hostage/hostage.h b/regamedll/dlls/hostage/hostage.h index 21a4e2b2..9ff94ad8 100644 --- a/regamedll/dlls/hostage/hostage.h +++ b/regamedll/dlls/hostage/hostage.h @@ -31,7 +31,7 @@ #ifdef _WIN32 #pragma once #endif - + #include "hostage/hostage_improv.h" #define MAX_NODES 100 @@ -50,30 +50,30 @@ class CLocalNav; class CHostageImprov; class CHostageManager; -enum HostageChatterType -{ - HOSTAGE_CHATTER_START_FOLLOW = 0, - HOSTAGE_CHATTER_STOP_FOLLOW, - HOSTAGE_CHATTER_INTIMIDATED, - HOSTAGE_CHATTER_PAIN, - HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, - HOSTAGE_CHATTER_SCARED_OF_MURDER, - HOSTAGE_CHATTER_LOOK_OUT, - HOSTAGE_CHATTER_PLEASE_RESCUE_ME, - HOSTAGE_CHATTER_SEE_RESCUE_ZONE, - HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, - HOSTAGE_CHATTER_CTS_WIN , - HOSTAGE_CHATTER_TERRORISTS_WIN, - HOSTAGE_CHATTER_RESCUED, - HOSTAGE_CHATTER_WARN_NEARBY, - HOSTAGE_CHATTER_WARN_SPOTTED, - HOSTAGE_CHATTER_CALL_TO_RESCUER, - HOSTAGE_CHATTER_RETREAT, - HOSTAGE_CHATTER_COUGH, - HOSTAGE_CHATTER_BLINDED, - HOSTAGE_CHATTER_SAW_HE_GRENADE, - HOSTAGE_CHATTER_DEATH_CRY, - NUM_HOSTAGE_CHATTER_TYPES, +enum HostageChatterType +{ + HOSTAGE_CHATTER_START_FOLLOW = 0, + HOSTAGE_CHATTER_STOP_FOLLOW, + HOSTAGE_CHATTER_INTIMIDATED, + HOSTAGE_CHATTER_PAIN, + HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, + HOSTAGE_CHATTER_SCARED_OF_MURDER, + HOSTAGE_CHATTER_LOOK_OUT, + HOSTAGE_CHATTER_PLEASE_RESCUE_ME, + HOSTAGE_CHATTER_SEE_RESCUE_ZONE, + HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, + HOSTAGE_CHATTER_CTS_WIN , + HOSTAGE_CHATTER_TERRORISTS_WIN, + HOSTAGE_CHATTER_RESCUED, + HOSTAGE_CHATTER_WARN_NEARBY, + HOSTAGE_CHATTER_WARN_SPOTTED, + HOSTAGE_CHATTER_CALL_TO_RESCUER, + HOSTAGE_CHATTER_RETREAT, + HOSTAGE_CHATTER_COUGH, + HOSTAGE_CHATTER_BLINDED, + HOSTAGE_CHATTER_SAW_HE_GRENADE, + HOSTAGE_CHATTER_DEATH_CRY, + NUM_HOSTAGE_CHATTER_TYPES, }; #ifdef HOOK_GAMEDLL @@ -96,137 +96,137 @@ extern cvar_t cv_hostage_stop; class CHostage: public CBaseMonster { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual int ObjectCaps(void); - virtual int Classify(void) - { - return CLASS_HUMAN_PASSIVE; - } - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - virtual int BloodColor(void) - { - return BLOOD_COLOR_RED; - } - NOBODY virtual void Touch(CBaseEntity *pOther); + NOBODY virtual void Spawn(void); + NOBODY virtual void Precache(void); + NOBODY virtual int ObjectCaps(void); + virtual int Classify(void) + { + return CLASS_HUMAN_PASSIVE; + } + NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + virtual int BloodColor(void) + { + return BLOOD_COLOR_RED; + } + NOBODY virtual void Touch(CBaseEntity *pOther); NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - NOBODY void EXPORT IdleThink(void); - NOBODY void Remove(void); - void RePosition(void); - void SetActivity(int act); - NOBODY int GetActivity(void); - NOBODY float GetModifiedDamage(float flDamage, int nHitGroup); - NOBODY void SetFlinchActivity(void); - NOBODY void SetDeathActivity(void); - NOBODY void PlayPainSound(void); - NOBODY void PlayFollowRescueSound(void); - NOBODY void AnnounceDeath(CBasePlayer *pAttacker); - NOBODY void ApplyHostagePenalty(CBasePlayer *pAttacker); - NOBODY void GiveCTTouchBonus(CBasePlayer *pPlayer); - NOBODY void SendHostagePositionMsg(void); - NOBODY void SendHostageEventMsg(void); - NOBODY void DoFollow(void); - NOBODY BOOL IsOnLadder(void); - NOBODY void PointAt(const Vector &vecLoc); - NOBODY void MoveToward(const Vector &vecLoc); - void NavReady(void); - NOBODY void Wiggle(void); - void PreThink(void); - - NOBODY bool IsFollowingSomeone(void) - { - UNTESTED - return m_improv->IsFollowing(NULL); - } - NOBODY CBaseEntity *GetLeader(void) - { - UNTESTED - if (m_improv != NULL) - { - return m_improv->GetFollowLeader(); - } - - return NULL; - } - NOBODY bool IsFollowing(const CBaseEntity *entity) - { - return (entity == m_hTargetEnt && m_State == FOLLOW); - } - NOBODY bool IsValid(void) - { - UNTESTED - return (pev->takedamage == DAMAGE_YES); - } - NOBODY bool IsDead(void) - { - UNTESTED - return (pev->deadflag == DEAD_DEAD); - } - NOBODY bool IsAtHome(void);// + NOBODY void EXPORT IdleThink(void); + NOBODY void Remove(void); + void RePosition(void); + void SetActivity(int act); + NOBODY int GetActivity(void); + NOBODY float GetModifiedDamage(float flDamage, int nHitGroup); + NOBODY void SetFlinchActivity(void); + NOBODY void SetDeathActivity(void); + NOBODY void PlayPainSound(void); + NOBODY void PlayFollowRescueSound(void); + NOBODY void AnnounceDeath(CBasePlayer *pAttacker); + NOBODY void ApplyHostagePenalty(CBasePlayer *pAttacker); + NOBODY void GiveCTTouchBonus(CBasePlayer *pPlayer); + NOBODY void SendHostagePositionMsg(void); + NOBODY void SendHostageEventMsg(void); + NOBODY void DoFollow(void); + NOBODY BOOL IsOnLadder(void); + NOBODY void PointAt(const Vector &vecLoc); + NOBODY void MoveToward(const Vector &vecLoc); + void NavReady(void); + NOBODY void Wiggle(void); + void PreThink(void); + + NOBODY bool IsFollowingSomeone(void) + { + UNTESTED + return m_improv->IsFollowing(NULL); + } + NOBODY CBaseEntity *GetLeader(void) + { + UNTESTED + if (m_improv != NULL) + { + return m_improv->GetFollowLeader(); + } + + return NULL; + } + NOBODY bool IsFollowing(const CBaseEntity *entity) + { + return (entity == m_hTargetEnt && m_State == FOLLOW); + } + NOBODY bool IsValid(void) + { + UNTESTED + return (pev->takedamage == DAMAGE_YES); + } + NOBODY bool IsDead(void) + { + UNTESTED + return (pev->deadflag == DEAD_DEAD); + } + NOBODY bool IsAtHome(void);// NOBODY const Vector *GetHomePosition(void);// - + #ifdef HOOK_GAMEDLL - void Spawn_(void); - void Precache_(void); - int ObjectCaps_(void); - int TakeDamage_(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - void Touch_(CBaseEntity *pOther); + void Spawn_(void); + void Precache_(void); + int ObjectCaps_(void); + int TakeDamage_(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + void Touch_(CBaseEntity *pOther); void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #endif // HOOK_GAMEDLL public: - enum state - { - FOLLOW = 0, - STAND, - DUCK, - SCARED, - IDLE, - FOLLOWPATH, + enum state + { + FOLLOW = 0, + STAND, + DUCK, + SCARED, + IDLE, + FOLLOWPATH, }; - enum ModelType - { - REGULAR_GUY = 0, - OLD_GUY, - BLACK_GUY, - GOOFY_GUY, + enum ModelType + { + REGULAR_GUY = 0, + OLD_GUY, + BLACK_GUY, + GOOFY_GUY, }; - int m_Activity; - BOOL m_bTouched; - BOOL m_bRescueMe; - float m_flFlinchTime; - float m_flNextChange; - float m_flMarkPosition; - int m_iModel; - int m_iSkin; - float m_flNextRadarTime; - state m_State; - Vector m_vStart; - Vector m_vStartAngles; - Vector m_vPathToFollow[20]; - int m_iWaypoint; - CBasePlayer *m_target; - CLocalNav *m_LocalNav; - int nTargetNode; - Vector vecNodes[ MAX_NODES ]; - EHANDLE m_hStoppedTargetEnt; - float m_flNextFullThink; - float m_flPathCheckInterval; - float m_flLastPathCheck; - int m_nPathNodes; - BOOL m_fHasPath; - float m_flPathAcquired; - Vector m_vOldPos; - int m_iHostageIndex; - BOOL m_bStuck; - float m_flStuckTime; - CHostageImprov *m_improv; + int m_Activity; + BOOL m_bTouched; + BOOL m_bRescueMe; + float m_flFlinchTime; + float m_flNextChange; + float m_flMarkPosition; + int m_iModel; + int m_iSkin; + float m_flNextRadarTime; + state m_State; + Vector m_vStart; + Vector m_vStartAngles; + Vector m_vPathToFollow[20]; + int m_iWaypoint; + CBasePlayer *m_target; + CLocalNav *m_LocalNav; + int nTargetNode; + Vector vecNodes[ MAX_NODES ]; + EHANDLE m_hStoppedTargetEnt; + float m_flNextFullThink; + float m_flPathCheckInterval; + float m_flLastPathCheck; + int m_nPathNodes; + BOOL m_fHasPath; + float m_flPathAcquired; + Vector m_vOldPos; + int m_iHostageIndex; + BOOL m_bStuck; + float m_flStuckTime; + CHostageImprov *m_improv; ModelType m_whichModel; };/* size: 1988, cachelines: 32, members: 32 */ @@ -247,9 +247,9 @@ public: struct ChatterSet { - struct SoundFile file[32]; - int count; - int index; + struct SoundFile file[32]; + int count; + int index; bool needsShuffle; };/* size: 268, cachelines: 5, members: 4 */ @@ -270,102 +270,102 @@ private: };/* size: 5628, cachelines: 88, members: 1 */ /* <45b018> ../cstrike/dlls/hostage/hostage.h:247 */ -class CHostageManager -{ -public: - CHostageManager(void); - - void ServerActivate(void); - void ServerDeactivate(void); - - void RestartRound(void); - void AddHostage(CHostage *hostage); - SimpleChatter *GetChatter(void) - { - return &m_chatter; - } - NOBODY bool IsNearbyHostageTalking(CHostageImprov *improv); - NOBODY bool IsNearbyHostageJumping(CHostageImprov *improv); - NOBODY void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - UNTESTED inline CHostage *GetClosestHostage(const Vector &pos, float *resultRange = NULL) - { - float closeRange = 100000000.0f; - CHostage *close = NULL; - - for (int i = 0; i < m_hostageCount; i++) - { - float range = (m_hostage[ i ]->pev->origin - pos).Length(); - - if (range < closeRange) - { - closeRange = range; - close = m_hostage[ i ]; - } - } - - if (resultRange) - *resultRange = closeRange; - - return close; - } - - template< - typename T - > - bool ForEachHostage(T &func) - { - UNTESTED - - for (int i = 0; i < m_hostageCount; i++) - { - CHostage *pHostage = m_hostage[ i ]; - - if (pHostage->deadflag != DEAD_NO || pHostage->takedamage != DAMAGE_YES) - continue; - - if (!pHostage->m_improv) - break; - - if (func(pHostage)) - return true; - } - return false; - } - +class CHostageManager +{ +public: + CHostageManager(void); + + void ServerActivate(void); + void ServerDeactivate(void); + + void RestartRound(void); + void AddHostage(CHostage *hostage); + SimpleChatter *GetChatter(void) + { + return &m_chatter; + } + NOBODY bool IsNearbyHostageTalking(CHostageImprov *improv); + NOBODY bool IsNearbyHostageJumping(CHostageImprov *improv); + NOBODY void OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other); + UNTESTED inline CHostage *GetClosestHostage(const Vector &pos, float *resultRange = NULL) + { + float closeRange = 100000000.0f; + CHostage *close = NULL; + + for (int i = 0; i < m_hostageCount; i++) + { + float range = (m_hostage[ i ]->pev->origin - pos).Length(); + + if (range < closeRange) + { + closeRange = range; + close = m_hostage[ i ]; + } + } + + if (resultRange) + *resultRange = closeRange; + + return close; + } + + template< + typename T + > + bool ForEachHostage(T &func) + { + UNTESTED + + for (int i = 0; i < m_hostageCount; i++) + { + CHostage *pHostage = m_hostage[ i ]; + + if (pHostage->deadflag != DEAD_NO || pHostage->takedamage != DAMAGE_YES) + continue; + + if (!pHostage->m_improv) + break; + + if (func(pHostage)) + return true; + } + return false; + } + private: - CHostage *m_hostage[ MAX_HOSTAGES ]; - int m_hostageCount; + CHostage *m_hostage[ MAX_HOSTAGES ]; + int m_hostageCount; SimpleChatter m_chatter; };/* size: 5680, cachelines: 89, members: 3 */ -///* <470134> ../cstrike/dlls/hostage/hostage.h:293 */ -//inline void CHostageManager::ForEachHostage(KeepPersonalSpace &func) -//{ -//// { -//// int i; // 295 -//// } +///* <470134> ../cstrike/dlls/hostage/hostage.h:293 */ +//inline void CHostageManager::ForEachHostage(KeepPersonalSpace &func) +//{ +//// { +//// int i; // 295 +//// } //} // -///* <46fbe8> ../cstrike/dlls/hostage/hostage.h:293 */ -//inline void CHostageManager::ForEachHostage(CheckAhead &func) -//{ -//// { -//// int i; // 295 -//// } +///* <46fbe8> ../cstrike/dlls/hostage/hostage.h:293 */ +//inline void CHostageManager::ForEachHostage(CheckAhead &func) +//{ +//// { +//// int i; // 295 +//// } //} // -///* <46fb04> ../cstrike/dlls/hostage/hostage.h:293 */ -//inline void CHostageManager::ForEachHostage(CheckWayFunctor &func) -//{ -//// { -//// int i; // 295 -//// } +///* <46fb04> ../cstrike/dlls/hostage/hostage.h:293 */ +//inline void CHostageManager::ForEachHostage(CheckWayFunctor &func) +//{ +//// { +//// int i; // 295 +//// } //} -void Hostage_RegisterCVars(void); -NOBODY void InstallHostageManager(void); +void Hostage_RegisterCVars(void); +NOBODY void InstallHostageManager(void); // refs extern void (*pCHostage__IdleThink)(void); diff --git a/regamedll/dlls/hostage/hostage_improv.cpp b/regamedll/dlls/hostage/hostage_improv.cpp index 61e1d9bf..a4c345eb 100644 --- a/regamedll/dlls/hostage/hostage_improv.cpp +++ b/regamedll/dlls/hostage/hostage_improv.cpp @@ -428,7 +428,7 @@ void CHostageImprov::__MAKE_VHOOK(OnReset)(void) m_moveFlags = 0; m_moveType = Stopped; m_moveLimit = Running; - + m_vel.x = 0; m_vel.y = 0; @@ -1156,179 +1156,179 @@ NOBODY void CHostageImprov::UpdateStationaryAnimation(void) #ifdef HOOK_GAMEDLL -void CHostageImprov::OnMoveToFailure(const Vector &goal, MoveToFailureType reason) -{ - OnMoveToFailure_(goal, reason); -} - -bool CHostageImprov::IsAlive(void) const -{ - return IsAlive_(); -} - -void CHostageImprov::MoveTo(const Vector &goal) -{ - MoveTo_(goal); -} - -void CHostageImprov::LookAt(const Vector &target) -{ - LookAt_(target); -} - -void CHostageImprov::ClearLookAt(void) -{ - ClearLookAt_(); -} - -void CHostageImprov::FaceTo(const Vector &goal) -{ - FaceTo_(goal); -} - -void CHostageImprov::ClearFaceTo(void) -{ - ClearFaceTo_(); -} - -bool CHostageImprov::IsAtMoveGoal(float error) const -{ - return IsAtMoveGoal_(error); -} - -bool CHostageImprov::IsAtFaceGoal(void) const -{ - return IsAtFaceGoal_(); -} - -bool CHostageImprov::IsFriendInTheWay(const Vector &goalPos) const -{ - return IsFriendInTheWay_(goalPos); -} - -bool CHostageImprov::IsFriendInTheWay(CBaseEntity *myFriend, const Vector &goalPos) const -{ - return IsFriendInTheWay_(myFriend, goalPos); -} - -bool CHostageImprov::Jump(void) -{ - return Jump_(); -} - -void CHostageImprov::Crouch(void) -{ - Crouch_(); -} - -void CHostageImprov::StandUp(void) -{ - StandUp_(); -} - -void CHostageImprov::TrackPath(const Vector &pathGoal, float deltaT) -{ - TrackPath_(pathGoal, deltaT); -} - -void CHostageImprov::StartLadder(const CNavLadder *ladder, NavTraverseType how, const Vector *approachPos, const Vector *departPos) -{ - StartLadder_(ladder, how, approachPos, departPos); -} - -bool CHostageImprov::TraverseLadder(const CNavLadder *ladder, NavTraverseType how, const Vector *approachPos, const Vector *departPos, float deltaT) -{ - return TraverseLadder_(ladder, how, approachPos, departPos, deltaT); -} - -bool CHostageImprov::GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal) -{ - return GetSimpleGroundHeightWithFloor_(pos, height, normal); -} - -void CHostageImprov::Run(void) -{ - Run_(); -} - -void CHostageImprov::Walk(void) -{ - Walk_(); -} - -void CHostageImprov::Stop(void) -{ - Stop_(); -} - -const Vector &CHostageImprov::GetFeet(void) const -{ - return GetFeet_(); -} - -const Vector &CHostageImprov::GetCentroid(void) -{ - return GetCentroid_(); -} - -const Vector &CHostageImprov::GetEyes(void) const -{ - return GetEyes_(); -} - -bool CHostageImprov::IsOnGround(void) const -{ - return IsOnGround_(); -} - -bool CHostageImprov::IsMoving(void) const -{ - return IsMoving_(); -} - -bool CHostageImprov::IsVisible(const Vector &pos, bool testFOV) const -{ - return IsVisible_(pos, testFOV); -} - -bool CHostageImprov::IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance) const -{ - return IsPlayerLookingAtMe_(other, cosTolerance); -} - -CBasePlayer *CHostageImprov::IsAnyPlayerLookingAtMe(int team, float cosTolerance) const -{ - return IsAnyPlayerLookingAtMe_(team, cosTolerance); -} - -CBasePlayer *CHostageImprov::GetClosestPlayerByTravelDistance(int team, float *range) const -{ - return GetClosestPlayerByTravelDistance_(team, range); -} - -void CHostageImprov::OnUpdate(float deltaT) -{ - OnUpdate_(deltaT); -} - -void CHostageImprov::OnUpkeep(float deltaT) -{ - OnUpkeep_(deltaT); -} - -void CHostageImprov::OnReset(void) -{ - OnReset_(); -} - -void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) -{ - OnGameEvent_(event, entity, other); -} - -void CHostageImprov::OnTouch(CBaseEntity *other) -{ - OnTouch_(other); +void CHostageImprov::OnMoveToFailure(const Vector &goal, MoveToFailureType reason) +{ + OnMoveToFailure_(goal, reason); +} + +bool CHostageImprov::IsAlive(void) const +{ + return IsAlive_(); +} + +void CHostageImprov::MoveTo(const Vector &goal) +{ + MoveTo_(goal); +} + +void CHostageImprov::LookAt(const Vector &target) +{ + LookAt_(target); +} + +void CHostageImprov::ClearLookAt(void) +{ + ClearLookAt_(); +} + +void CHostageImprov::FaceTo(const Vector &goal) +{ + FaceTo_(goal); +} + +void CHostageImprov::ClearFaceTo(void) +{ + ClearFaceTo_(); +} + +bool CHostageImprov::IsAtMoveGoal(float error) const +{ + return IsAtMoveGoal_(error); +} + +bool CHostageImprov::IsAtFaceGoal(void) const +{ + return IsAtFaceGoal_(); +} + +bool CHostageImprov::IsFriendInTheWay(const Vector &goalPos) const +{ + return IsFriendInTheWay_(goalPos); +} + +bool CHostageImprov::IsFriendInTheWay(CBaseEntity *myFriend, const Vector &goalPos) const +{ + return IsFriendInTheWay_(myFriend, goalPos); +} + +bool CHostageImprov::Jump(void) +{ + return Jump_(); +} + +void CHostageImprov::Crouch(void) +{ + Crouch_(); +} + +void CHostageImprov::StandUp(void) +{ + StandUp_(); +} + +void CHostageImprov::TrackPath(const Vector &pathGoal, float deltaT) +{ + TrackPath_(pathGoal, deltaT); +} + +void CHostageImprov::StartLadder(const CNavLadder *ladder, NavTraverseType how, const Vector *approachPos, const Vector *departPos) +{ + StartLadder_(ladder, how, approachPos, departPos); +} + +bool CHostageImprov::TraverseLadder(const CNavLadder *ladder, NavTraverseType how, const Vector *approachPos, const Vector *departPos, float deltaT) +{ + return TraverseLadder_(ladder, how, approachPos, departPos, deltaT); +} + +bool CHostageImprov::GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal) +{ + return GetSimpleGroundHeightWithFloor_(pos, height, normal); +} + +void CHostageImprov::Run(void) +{ + Run_(); +} + +void CHostageImprov::Walk(void) +{ + Walk_(); +} + +void CHostageImprov::Stop(void) +{ + Stop_(); +} + +const Vector &CHostageImprov::GetFeet(void) const +{ + return GetFeet_(); +} + +const Vector &CHostageImprov::GetCentroid(void) +{ + return GetCentroid_(); +} + +const Vector &CHostageImprov::GetEyes(void) const +{ + return GetEyes_(); +} + +bool CHostageImprov::IsOnGround(void) const +{ + return IsOnGround_(); +} + +bool CHostageImprov::IsMoving(void) const +{ + return IsMoving_(); +} + +bool CHostageImprov::IsVisible(const Vector &pos, bool testFOV) const +{ + return IsVisible_(pos, testFOV); +} + +bool CHostageImprov::IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance) const +{ + return IsPlayerLookingAtMe_(other, cosTolerance); +} + +CBasePlayer *CHostageImprov::IsAnyPlayerLookingAtMe(int team, float cosTolerance) const +{ + return IsAnyPlayerLookingAtMe_(team, cosTolerance); +} + +CBasePlayer *CHostageImprov::GetClosestPlayerByTravelDistance(int team, float *range) const +{ + return GetClosestPlayerByTravelDistance_(team, range); +} + +void CHostageImprov::OnUpdate(float deltaT) +{ + OnUpdate_(deltaT); +} + +void CHostageImprov::OnUpkeep(float deltaT) +{ + OnUpkeep_(deltaT); +} + +void CHostageImprov::OnReset(void) +{ + OnReset_(); +} + +void CHostageImprov::OnGameEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +{ + OnGameEvent_(event, entity, other); +} + +void CHostageImprov::OnTouch(CBaseEntity *other) +{ + OnTouch_(other); } #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/hostage/hostage_localnav.cpp b/regamedll/dlls/hostage/hostage_localnav.cpp index be275941..6edf5786 100644 --- a/regamedll/dlls/hostage/hostage_localnav.cpp +++ b/regamedll/dlls/hostage/hostage_localnav.cpp @@ -221,7 +221,7 @@ node_index_t CLocalNav::GetBestNode(Vector &vecOrigin, Vector &vecDest) float flDistToDest; float_precision flZDiff = -1.0; - flDistFromStart = LenghtSubtract + flDistFromStart = LengthSubtract (vecDest, nodeCurrent->vecLoc); diff --git a/regamedll/dlls/hostage/hostage_states.h b/regamedll/dlls/hostage/hostage_states.h index c34ab742..e7c2cfbc 100644 --- a/regamedll/dlls/hostage/hostage_states.h +++ b/regamedll/dlls/hostage/hostage_states.h @@ -38,9 +38,9 @@ class CHostageImprov; class HostageState: public SimpleState, public IImprovEvent { public: - virtual ~HostageState(void) { }; + virtual ~HostageState(void) {}; - virtual void UpdateStationaryAnimation(CHostageImprov *improv) { }; + virtual void UpdateStationaryAnimation(CHostageImprov *improv) {}; };/* size: 12, cachelines: 1, members: 2 */ @@ -64,7 +64,7 @@ public: Update(); } - void UpdateStationaryAnimation(CHostageImprov *improv) { }; + void UpdateStationaryAnimation(CHostageImprov *improv) {}; };/* size: 16, cachelines: 1, members: 2 */ @@ -72,7 +72,7 @@ public: class HostageIdleState: public HostageState { public: - virtual ~HostageIdleState(void) { }; + virtual ~HostageIdleState(void) {}; virtual void OnEnter(CHostageImprov *improv); virtual void OnUpdate(CHostageImprov *improv); @@ -120,7 +120,7 @@ private: class HostageEscapeToCoverState: public HostageState { public: - virtual ~HostageEscapeToCoverState(void) { }; + virtual ~HostageEscapeToCoverState(void) {}; virtual void OnEnter(CHostageImprov *improv); virtual void OnUpdate(CHostageImprov *improv); @@ -143,7 +143,7 @@ private: class HostageEscapeLookAroundState: public HostageState { public: - virtual ~HostageEscapeLookAroundState(void) { }; + virtual ~HostageEscapeLookAroundState(void) {}; virtual void OnEnter(CHostageImprov *improv); virtual void OnUpdate(CHostageImprov *improv); @@ -162,7 +162,7 @@ private: class HostageEscapeState: public HostageState { public: - virtual ~HostageEscapeState(void) { }; + virtual ~HostageEscapeState(void) {}; virtual void OnEnter(CHostageImprov *improv); virtual void OnUpdate(CHostageImprov *improv); @@ -193,7 +193,7 @@ private: class HostageRetreatState: public HostageState { public: - virtual ~HostageRetreatState(void) { }; + virtual ~HostageRetreatState(void) {}; virtual void OnEnter(CHostageImprov *improv); virtual void OnUpdate(CHostageImprov *improv); @@ -209,7 +209,7 @@ public: class HostageFollowState: public HostageState { public: - virtual ~HostageFollowState(void) { }; + virtual ~HostageFollowState(void) {}; virtual void OnEnter(CHostageImprov *improv); virtual void OnUpdate(CHostageImprov *improv); @@ -245,7 +245,7 @@ private: class HostageAnimateState: public HostageState { public: - virtual ~HostageAnimateState(void) { } + virtual ~HostageAnimateState(void) {} virtual void OnEnter(CHostageImprov *improv); virtual void OnUpdate(CHostageImprov *improv); @@ -309,9 +309,7 @@ public: bool IsDoneHolding(void); private: - enum { MAX_SEQUENCES = 8 }; - struct SeqInfo m_sequence[ MAX_SEQUENCES ]; int m_sequenceCount; int m_currentSequence; diff --git a/regamedll/dlls/items.cpp b/regamedll/dlls/items.cpp index abe3684b..055644c3 100644 --- a/regamedll/dlls/items.cpp +++ b/regamedll/dlls/items.cpp @@ -20,7 +20,7 @@ void CWorldItem::__MAKE_VHOOK(Spawn)(void) { CBaseEntity *pEntity = NULL; - switch (m_iType) + switch (m_iType) { case 41: // ITEM_HEALTHKIT break; @@ -54,7 +54,7 @@ void CItem::__MAKE_VHOOK(Spawn)(void) pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; - UTIL_SetOrigin( pev, pev->origin ); + UTIL_SetOrigin(pev, pev->origin); UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); SetTouch(&CItem::ItemTouch); @@ -179,7 +179,7 @@ BOOL CItemBattery::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) char szcharge[64]; pPlayer->pev->armorvalue += gSkillData.batteryCapacity; - pPlayer->pev->armorvalue = _min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY); + pPlayer->pev->armorvalue = Q_min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY); EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); @@ -194,11 +194,11 @@ BOOL CItemBattery::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) if (pct > 0) pct--; - + Q_sprintf(szcharge,"!HEV_%1dP", pct); pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC); - return TRUE; + return TRUE; } return FALSE; } diff --git a/regamedll/dlls/items.h b/regamedll/dlls/items.h index 921b2645..f3ce5dd5 100644 --- a/regamedll/dlls/items.h +++ b/regamedll/dlls/items.h @@ -86,9 +86,9 @@ public: class CItemSuit: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL @@ -104,9 +104,9 @@ public: class CItemBattery: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL @@ -122,9 +122,9 @@ public: class CItemAntidote: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL @@ -140,9 +140,9 @@ public: class CItemSecurity: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL @@ -158,9 +158,9 @@ public: class CItemLongJump: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL @@ -176,9 +176,9 @@ public: class CItemKevlar: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL @@ -194,9 +194,9 @@ public: class CItemAssaultSuit: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL @@ -212,9 +212,9 @@ public: class CItemThighPack: public CItem { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual BOOL MyTouch(CBasePlayer *pPlayer); + virtual void Spawn(void); + virtual void Precache(void); + virtual BOOL MyTouch(CBasePlayer *pPlayer); #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/lights.cpp b/regamedll/dlls/lights.cpp index af9cf6c1..f5b95b5c 100644 --- a/regamedll/dlls/lights.cpp +++ b/regamedll/dlls/lights.cpp @@ -13,67 +13,67 @@ TYPEDESCRIPTION CLight::m_SaveData[] = #else -TYPEDESCRIPTION (*CLight::pm_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CLight, m_SaveData)[2]; #endif // HOOK_GAMEDLL -/* ../cstrike/dlls/lights.cpp:48 */ -LINK_ENTITY_TO_CLASS(light, CLight); +/* ../cstrike/dlls/lights.cpp:48 */ +LINK_ENTITY_TO_CLASS(light, CLight); -/* ../cstrike/dlls/lights.cpp:56 */ -IMPLEMENT_SAVERESTORE(CLight, CPointEntity); - -// Cache user-entity-field values until spawn is called. - -/* ../cstrike/dlls/lights.cpp:62 */ -void CLight::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ - if (FStrEq(pkvd->szKeyName, "style")) - { - m_iStyle = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "pitch")) - { - pev->angles.x = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "pattern")) - { - m_iszPattern = ALLOC_STRING( pkvd->szValue ); - pkvd->fHandled = TRUE; - } - else - CPointEntity::KeyValue( pkvd ); +/* ../cstrike/dlls/lights.cpp:56 */ +IMPLEMENT_SAVERESTORE(CLight, CPointEntity); + +// Cache user-entity-field values until spawn is called. + +/* ../cstrike/dlls/lights.cpp:62 */ +void CLight::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "style")) + { + m_iStyle = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "pitch")) + { + pev->angles.x = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "pattern")) + { + m_iszPattern = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CPointEntity::KeyValue(pkvd); } -/* ../cstrike/dlls/lights.cpp:92 */ -void CLight::__MAKE_VHOOK(Spawn)(void) -{ - // inert light - if (FStringNull(pev->targetname)) - { - REMOVE_ENTITY(ENT(pev)); - return; - } - - m_iStartedOff = (pev->spawnflags & SF_LIGHT_START_OFF) != 0; - - if (m_iStyle >= 32) - { - if (pev->spawnflags & SF_LIGHT_START_OFF) - LIGHT_STYLE(m_iStyle, "a"); - - else if (m_iszPattern) - LIGHT_STYLE(m_iStyle, (char *)STRING( m_iszPattern )); - else - LIGHT_STYLE(m_iStyle, "m"); - } +/* ../cstrike/dlls/lights.cpp:92 */ +void CLight::__MAKE_VHOOK(Spawn)(void) +{ + // inert light + if (FStringNull(pev->targetname)) + { + REMOVE_ENTITY(ENT(pev)); + return; + } + + m_iStartedOff = (pev->spawnflags & SF_LIGHT_START_OFF) != 0; + + if (m_iStyle >= 32) + { + if (pev->spawnflags & SF_LIGHT_START_OFF) + LIGHT_STYLE(m_iStyle, "a"); + + else if (m_iszPattern) + LIGHT_STYLE(m_iStyle, (char *)STRING(m_iszPattern)); + else + LIGHT_STYLE(m_iStyle, "m"); + } } -/* ../cstrike/dlls/lights.cpp:117 */ -void CLight::__MAKE_VHOOK(Restart)(void) -{ +/* ../cstrike/dlls/lights.cpp:117 */ +void CLight::__MAKE_VHOOK(Restart)(void) +{ if (m_iStyle >= 32) { if (m_iStartedOff) @@ -90,12 +90,12 @@ void CLight::__MAKE_VHOOK(Restart)(void) else LIGHT_STYLE(m_iStyle, "m"); } - } + } } -/* ../cstrike/dlls/lights.cpp:139 */ -void CLight::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ +/* ../cstrike/dlls/lights.cpp:139 */ +void CLight::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ if (m_iStyle >= 32) { if (!ShouldToggle(useType, !(pev->spawnflags & SF_LIGHT_START_OFF))) @@ -115,18 +115,18 @@ void CLight::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, US LIGHT_STYLE(m_iStyle, "a"); pev->spawnflags |= SF_LIGHT_START_OFF; } - } + } } -/* ../cstrike/dlls/lights.cpp:165 */ -LINK_ENTITY_TO_CLASS(light_spot, CLight); +/* ../cstrike/dlls/lights.cpp:165 */ +LINK_ENTITY_TO_CLASS(light_spot, CLight); -/* ../cstrike/dlls/lights.cpp:175 */ +/* ../cstrike/dlls/lights.cpp:175 */ LINK_ENTITY_TO_CLASS(light_environment, CEnvLight); -/* ../cstrike/dlls/lights.cpp:177 */ -void CEnvLight::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ +/* ../cstrike/dlls/lights.cpp:177 */ +void CEnvLight::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ if (FStrEq(pkvd->szKeyName, "_light")) { int r, g, b, v, j; @@ -143,9 +143,9 @@ void CEnvLight::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling - r = pow( r / 114.0, 0.6 ) * 264; - g = pow( g / 114.0, 0.6 ) * 264; - b = pow( b / 114.0, 0.6 ) * 264; + r = pow(r / 114.0, 0.6) * 264; + g = pow(g / 114.0, 0.6) * 264; + b = pow(b / 114.0, 0.6) * 264; pkvd->fHandled = TRUE; @@ -158,35 +158,35 @@ void CEnvLight::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) CVAR_SET_STRING("sv_skycolor_b", szColor); } else - CLight::KeyValue(pkvd); + CLight::KeyValue(pkvd); } -/* ../cstrike/dlls/lights.cpp:215 */ -void CEnvLight::__MAKE_VHOOK(Spawn)(void) -{ -#if defined(HOOK_GAMEDLL) -// NOTE: fix negative the values for function sprintf from STD C++: -// expected - sv_skyvec_y "0.000000" -// with using sprintf from STD C++, got - sv_skyvec_y "-0.000000" -// If we not doing it then the test will be failed! -#define SPRINTF_OLD_STD_FIX + 0 -#else -#define SPRINTF_OLD_STD_FIX -#endif // HOOK_GAMEDLL - - char szVector[64]; - UTIL_MakeAimVectors( pev->angles ); - - Q_sprintf(szVector, "%f", gpGlobals->v_forward.x SPRINTF_OLD_STD_FIX); - CVAR_SET_STRING("sv_skyvec_x", szVector); - - Q_sprintf(szVector, "%f", gpGlobals->v_forward.y SPRINTF_OLD_STD_FIX); - CVAR_SET_STRING("sv_skyvec_y", szVector); - - Q_sprintf(szVector, "%f", gpGlobals->v_forward.z SPRINTF_OLD_STD_FIX); - CVAR_SET_STRING("sv_skyvec_z", szVector); - - CLight::Spawn(); +/* ../cstrike/dlls/lights.cpp:215 */ +void CEnvLight::__MAKE_VHOOK(Spawn)(void) +{ +#if defined(HOOK_GAMEDLL) +// NOTE: fix negative the values for function sprintf from STD C++: +// expected - sv_skyvec_y "0.000000" +// with using sprintf from STD C++, got - sv_skyvec_y "-0.000000" +// If we not doing it then the test will be failed! +#define SPRINTF_OLD_STD_FIX + 0 +#else +#define SPRINTF_OLD_STD_FIX +#endif // HOOK_GAMEDLL + + char szVector[64]; + UTIL_MakeAimVectors(pev->angles); + + Q_sprintf(szVector, "%f", gpGlobals->v_forward.x SPRINTF_OLD_STD_FIX); + CVAR_SET_STRING("sv_skyvec_x", szVector); + + Q_sprintf(szVector, "%f", gpGlobals->v_forward.y SPRINTF_OLD_STD_FIX); + CVAR_SET_STRING("sv_skyvec_y", szVector); + + Q_sprintf(szVector, "%f", gpGlobals->v_forward.z SPRINTF_OLD_STD_FIX); + CVAR_SET_STRING("sv_skyvec_z", szVector); + + CLight::Spawn(); } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/lights.h b/regamedll/dlls/lights.h index ce659b11..c6d30090 100644 --- a/regamedll/dlls/lights.h +++ b/regamedll/dlls/lights.h @@ -34,7 +34,7 @@ #define SF_LIGHT_START_OFF 1 -/* ../cstrike/dlls/lights.cpp:29 */ +/* ../cstrike/dlls/lights.cpp:29 */ class CLight: public CPointEntity { public: @@ -66,19 +66,20 @@ private: };/* size: 164, cachelines: 3, members: 5 */ -/* ../cstrike/dlls/lights.cpp:168 */ +/* ../cstrike/dlls/lights.cpp:168 */ class CEnvLight: public CLight { public: virtual void Spawn(void); virtual void KeyValue(KeyValueData *pkvd); - + #ifdef HOOK_GAMEDLL void Spawn_(void); void KeyValue_(KeyValueData *pkvd); #endif // HOOK_GAMEDLL + };/* size: 164, cachelines: 3, members: 1 */ #endif // LIGHT_H diff --git a/regamedll/dlls/maprules.cpp b/regamedll/dlls/maprules.cpp index c84d8662..c9da1ab6 100644 --- a/regamedll/dlls/maprules.cpp +++ b/regamedll/dlls/maprules.cpp @@ -10,6 +10,8 @@ TYPEDESCRIPTION CRuleEntity::m_SaveData[] = DEFINE_FIELD(CRuleEntity, m_iszMaster, FIELD_STRING), }; +// Save parms as a block. Will break save/restore if the structure changes, but this entity didn't ship with Half-Life, so +// it can't impact saved Half-Life games. TYPEDESCRIPTION CGameText::m_SaveData[] = { DEFINE_ARRAY(CGameText, m_textParms, FIELD_CHARACTER, sizeof(hudtextparms_t)), @@ -25,9 +27,9 @@ TYPEDESCRIPTION CGamePlayerZone::m_SaveData[] = #else -TYPEDESCRIPTION (*CRuleEntity::pm_SaveData)[1]; -TYPEDESCRIPTION (*CGameText::pm_SaveData)[1]; -TYPEDESCRIPTION (*CGamePlayerZone::pm_SaveData)[4]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CRuleEntity, m_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CGameText, m_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CGamePlayerZone, m_SaveData)[4]; #endif // HOOK_GAMEDLL @@ -35,370 +37,615 @@ TYPEDESCRIPTION (*CGamePlayerZone::pm_SaveData)[4]; IMPLEMENT_SAVERESTORE(CRuleEntity, CBaseEntity); /* ../cstrike/dlls/maprules.cpp:60 */ -NOBODY void CRuleEntity::__MAKE_VHOOK(Spawn)(void) +void CRuleEntity::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + pev->effects = EF_NODRAW; } /* ../cstrike/dlls/maprules.cpp:68 */ -NOBODY void CRuleEntity::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CRuleEntity::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 70 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 76 -// KeyValue(CRuleEntity *const this, -// KeyValueData *pkvd); // 68 + if (FStrEq(pkvd->szKeyName, "master")) + { + SetMaster(ALLOC_STRING(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } /* ../cstrike/dlls/maprules.cpp:79 */ -NOBODY BOOL CRuleEntity::CanFireForActivator(CBaseEntity *pActivator) +BOOL CRuleEntity::CanFireForActivator(CBaseEntity *pActivator) { -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 79 + if (!FStringNull(m_iszMaster)) + { + if (UTIL_IsMasterTriggered(m_iszMaster, pActivator)) + return TRUE; + else + return FALSE; + } + + return TRUE; } /* ../cstrike/dlls/maprules.cpp:101 */ -NOBODY void CRulePointEntity::__MAKE_VHOOK(Spawn)(void) +void CRulePointEntity::__MAKE_VHOOK(Spawn)(void) { -// Spawn(CRuleEntity *const this); // 103 + CRuleEntity::Spawn(); + pev->frame = 0; + pev->model = 0; } /* ../cstrike/dlls/maprules.cpp:120 */ -NOBODY void CRuleBrushEntity::__MAKE_VHOOK(Spawn)(void) +void CRuleBrushEntity::__MAKE_VHOOK(Spawn)(void) { -// Spawn(CRuleEntity *const this); // 123 + SET_MODEL(edict(), STRING(pev->model)); + CRuleEntity::Spawn(); } /* ../cstrike/dlls/maprules.cpp:151 */ LINK_ENTITY_TO_CLASS(game_score, CGameScore); /* ../cstrike/dlls/maprules.cpp:154 */ -NOBODY void CGameScore::__MAKE_VHOOK(Spawn)(void) +void CGameScore::__MAKE_VHOOK(Spawn)(void) { -// Spawn(CRulePointEntity *const this); // 156 + CRulePointEntity::Spawn(); } /* ../cstrike/dlls/maprules.cpp:160 */ -NOBODY void CGameScore::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CGameScore::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 162 -// KeyValue(CRuleEntity *const this, -// KeyValueData *pkvd); // 168 -// KeyValue(CGameScore *const this, -// KeyValueData *pkvd); // 160 + if (FStrEq(pkvd->szKeyName, "points")) + { + SetPoints(Q_atoi(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else + CRulePointEntity::KeyValue(pkvd); } /* ../cstrike/dlls/maprules.cpp:173 */ -NOBODY void CGameScore::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CGameScore::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 175 -// Use(CGameScore *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 173 -// AwardToTeam(CGameScore *const this); // 181 -// AllowNegativeScore(CGameScore *const this); // 187 -// Points(CGameScore *const this); // 187 + if (!CanFireForActivator(pActivator)) + return; + + // Only players can use this + if (pActivator->IsPlayer()) + { + if (AwardToTeam()) + { + pActivator->AddPointsToTeam(Points(), AllowNegativeScore()); + } + else + { + pActivator->AddPoints(Points(), AllowNegativeScore()); + } + } } /* ../cstrike/dlls/maprules.cpp:202 */ LINK_ENTITY_TO_CLASS(game_end, CGameEnd); +/* ../cstrike/dlls/maprules.cpp:205 */ +void CGameEnd::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; + + g_pGameRules->EndMultiplayerGame(); +} + /* ../cstrike/dlls/maprules.cpp:242 */ LINK_ENTITY_TO_CLASS(game_text, CGameText); -/* ../cstrike/dlls/maprules.cpp:205 */ -NOBODY void CGameEnd::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 207 -// Use(CGameEnd *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 205 -} - /* ../cstrike/dlls/maprules.cpp:251 */ IMPLEMENT_SAVERESTORE(CGameText, CRulePointEntity); /* ../cstrike/dlls/maprules.cpp:254 */ -NOBODY void CGameText::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CGameText::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// { -// int color; // 278 -// } -// { -// int color; // 288 -// } -// FStrEq(const char *sz1, -// const char *sz2); // 256 -// FStrEq(const char *sz1, -// const char *sz2); // 261 -// atof(const char *__nptr); // 263 -// atoi(const char *__nptr); // 258 -// KeyValue(CGameText *const this, -// KeyValueData *pkvd); // 254 + if (FStrEq(pkvd->szKeyName, "channel")) + { + m_textParms.channel = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "x")) + { + m_textParms.x = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "y")) + { + m_textParms.y = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "effect")) + { + m_textParms.effect = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "color")) + { + int color[4]; + UTIL_StringToIntArray(color, ARRAYSIZE(color), pkvd->szValue); + + m_textParms.r1 = color[0]; + m_textParms.g1 = color[1]; + m_textParms.b1 = color[2]; + m_textParms.a1 = color[3]; + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "color2")) + { + int color[4]; + UTIL_StringToIntArray(color, ARRAYSIZE(color), pkvd->szValue); + + m_textParms.r2 = color[0]; + m_textParms.g2 = color[1]; + m_textParms.b2 = color[2]; + m_textParms.a2 = color[3]; + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "fadein")) + { + m_textParms.fadeinTime = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "fadeout")) + { + m_textParms.fadeoutTime = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "holdtime")) + { + m_textParms.holdTime = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "fxtime")) + { + m_textParms.fxTime = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CRulePointEntity::KeyValue(pkvd); } -/* ../cstrike/dlls/maprules.cpp:321 */ -NOBODY void CGameText::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 323 -// MessageGet(CGameText *const this); // 328 -// Use(CGameText *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 321 +/* ../cstrike/dlls/maprules.cpp:321 */ +void CGameText::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; + + if (MessageToAll()) + { + UTIL_HudMessageAll(m_textParms, MessageGet()); + } + else + { + if (pActivator->IsNetClient()) + { + UTIL_HudMessage(pActivator, m_textParms, MessageGet()); + } + } } -/* ../cstrike/dlls/maprules.cpp:371 */ +/* ../cstrike/dlls/maprules.cpp:371 */ LINK_ENTITY_TO_CLASS(game_team_master, CGameTeamMaster); -/* ../cstrike/dlls/maprules.cpp:373 */ -NOBODY void CGameTeamMaster::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 375 -// FStrEq(const char *sz1, -// const char *sz2); // 380 -// KeyValue(CRuleEntity *const this, -// KeyValueData *pkvd); // 398 -// { -// int type; // 382 -// atoi(const char *__nptr); // 382 -// } -// KeyValue(CGameTeamMaster *const this, -// KeyValueData *pkvd); // 373 +/* ../cstrike/dlls/maprules.cpp:373 */ +void CGameTeamMaster::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "teamindex")) + { + m_teamIndex = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "triggerstate")) + { + int type = Q_atoi(pkvd->szValue); + + switch(type) + { + case 0: + triggerType = USE_OFF; + break; + case 2: + triggerType = USE_TOGGLE; + break; + default: + triggerType = USE_ON; + break; + } + + pkvd->fHandled = TRUE; + } + else + CRulePointEntity::KeyValue(pkvd); } -/* ../cstrike/dlls/maprules.cpp:402 */ -void CGameTeamMaster::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 404 -// TeamMatch(CGameTeamMaster *const this, -// class CBaseEntity *pActivator); // 420 -// Use(CGameTeamMaster *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 402 +/* ../cstrike/dlls/maprules.cpp:402 */ +void CGameTeamMaster::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; + + if (useType == USE_SET) + { + if (value < 0) + { + m_teamIndex = -1; + } + else + { + m_teamIndex = g_pGameRules->GetTeamIndex(pActivator->TeamID()); + } + + return; + } + + if (TeamMatch(pActivator)) + { + SUB_UseTargets(pActivator, triggerType, value); + + if (RemoveOnFire()) + { + UTIL_Remove(this); + } + } } -/* ../cstrike/dlls/maprules.cpp:429 */ -BOOL CGameTeamMaster::__MAKE_VHOOK(IsTriggered)(CBaseEntity *pActivator) -{ -// TeamMatch(CGameTeamMaster *const this, -// class CBaseEntity *pActivator); // 431 +/* ../cstrike/dlls/maprules.cpp:429 */ +BOOL CGameTeamMaster::__MAKE_VHOOK(IsTriggered)(CBaseEntity *pActivator) +{ + return TeamMatch(pActivator); } -/* ../cstrike/dlls/maprules.cpp:435 */ -const char *CGameTeamMaster::__MAKE_VHOOK(TeamID)(void) -{ -// TeamID(CGameTeamMaster *const this); // 435 +/* ../cstrike/dlls/maprules.cpp:435 */ +const char *CGameTeamMaster::__MAKE_VHOOK(TeamID)(void) +{ + // Currently set to "no team" + if (m_teamIndex < 0) + { + return ""; + } + + // UNDONE: Fill this in with the team from the "teamlist" + return g_pGameRules->GetIndexedTeamName(m_teamIndex); } -/* ../cstrike/dlls/maprules.cpp:444 */ -BOOL CGameTeamMaster::TeamMatch(CBaseEntity *pActivator) -{ -// TeamMatch(CGameTeamMaster *const this, -// class CBaseEntity *pActivator); // 444 -// AnyTeam(CGameTeamMaster *const this); // 446 +/* ../cstrike/dlls/maprules.cpp:444 */ +BOOL CGameTeamMaster::TeamMatch(CBaseEntity *pActivator) +{ + if (m_teamIndex < 0 && AnyTeam()) + return TRUE; + + if (!pActivator) + return FALSE; + + return UTIL_TeamsMatch(pActivator->TeamID(), TeamID()); } -/* ../cstrike/dlls/maprules.cpp:474 */ +/* ../cstrike/dlls/maprules.cpp:474 */ LINK_ENTITY_TO_CLASS(game_team_set, CGameTeamSet); - -/* ../cstrike/dlls/maprules.cpp:477 */ -void CGameTeamSet::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 479 -// Use(CGameTeamSet *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 477 -} - -/* ../cstrike/dlls/maprules.cpp:519 */ -LINK_ENTITY_TO_CLASS(game_zone_player, CGamePlayerZone); -/* ../cstrike/dlls/maprules.cpp:528 */ +/* ../cstrike/dlls/maprules.cpp:477 */ +void CGameTeamSet::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; + + if (ShouldClearTeam()) + { + SUB_UseTargets(pActivator, USE_SET, -1); + } + else + { + SUB_UseTargets(pActivator, USE_SET, 0); + } + + if (RemoveOnFire()) + { + UTIL_Remove(this); + } +} + +/* ../cstrike/dlls/maprules.cpp:519 */ +LINK_ENTITY_TO_CLASS(game_zone_player, CGamePlayerZone); + +/* ../cstrike/dlls/maprules.cpp:528 */ IMPLEMENT_SAVERESTORE(CGamePlayerZone, CRuleBrushEntity); -/* ../cstrike/dlls/maprules.cpp:530 */ -void CGamePlayerZone::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 532 -// FStrEq(const char *sz1, -// const char *sz2); // 537 -// KeyValue(CGamePlayerZone *const this, -// KeyValueData *pkvd); // 530 +/* ../cstrike/dlls/maprules.cpp:530 */ +void CGamePlayerZone::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "intarget")) + { + m_iszInTarget = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "outtarget")) + { + m_iszOutTarget = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "incount")) + { + m_iszInCount = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "outcount")) + { + m_iszOutCount = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CRuleBrushEntity::KeyValue(pkvd); } -/* ../cstrike/dlls/maprules.cpp:556 */ -void CGamePlayerZone::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// { -// int playersInCount; // 558 -// int playersOutCount; // 559 -// class CBaseEntity *pPlayer; // 564 -// { -// int i; // 566 -// { -// TraceResult trace; // 571 -// int hullNumber; // 572 -// } -// } -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 561 -// } -// Use(CGamePlayerZone *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 556 +/* ../cstrike/dlls/maprules.cpp:556 */ +void CGamePlayerZone::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + int playersInCount = 0; + int playersOutCount = 0; + + if (!CanFireForActivator(pActivator)) + return; + + CBaseEntity *pPlayer = NULL; + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + pPlayer = reinterpret_cast(UTIL_PlayerByIndex(i)); + + if (pPlayer) + { + TraceResult trace; + int hullNumber; + + hullNumber = human_hull; + if (pPlayer->pev->flags & FL_DUCKING) + { + hullNumber = head_hull; + } + + UTIL_TraceModel(pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace); + + if (trace.fStartSolid) + { + playersInCount++; + if (!FStringNull(m_iszInTarget)) + { + FireTargets(STRING(m_iszInTarget), pPlayer, pActivator, useType, value); + } + } + else + { + playersOutCount++; + if (!FStringNull(m_iszOutTarget)) + { + FireTargets(STRING(m_iszOutTarget), pPlayer, pActivator, useType, value); + } + } + } + } + + if (!FStringNull(m_iszInCount)) + { + FireTargets(STRING(m_iszInCount), pActivator, this, USE_SET, playersInCount); + } + + if (!FStringNull(m_iszOutCount)) + { + FireTargets(STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount); + } + } -/* ../cstrike/dlls/maprules.cpp:628 */ +/* ../cstrike/dlls/maprules.cpp:628 */ LINK_ENTITY_TO_CLASS(game_player_hurt, CGamePlayerHurt); -/* ../cstrike/dlls/maprules.cpp:631 */ -void CGamePlayerHurt::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 633 -// Use(CGamePlayerHurt *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 631 +/* ../cstrike/dlls/maprules.cpp:631 */ +void CGamePlayerHurt::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; + + if (pActivator->IsPlayer()) + { + if (pev->dmg < 0) + pActivator->TakeHealth(-pev->dmg, DMG_GENERIC); + else + pActivator->TakeDamage(pev, pev, pev->dmg, DMG_GENERIC); + } + + SUB_UseTargets(pActivator, useType, value); + + if (RemoveOnFire()) + { + UTIL_Remove(this); + } } -/* ../cstrike/dlls/maprules.cpp:684 */ -LINK_ENTITY_TO_CLASS(game_counter, CGameCounter); +/* ../cstrike/dlls/maprules.cpp:684 */ +LINK_ENTITY_TO_CLASS(game_counter, CGameCounter); -/* ../cstrike/dlls/maprules.cpp:686 */ -void CGameCounter::__MAKE_VHOOK(Spawn)(void) -{ -// CountValue(CGameCounter *const this); // 689 -// SetInitialValue(CGameCounter *const this, -// int value); // 689 -// Spawn(CRulePointEntity *const this); // 690 +/* ../cstrike/dlls/maprules.cpp:686 */ +void CGameCounter::__MAKE_VHOOK(Spawn)(void) +{ + // Save off the initial count + SetInitialValue(CountValue()); + CRulePointEntity::Spawn(); } -/* ../cstrike/dlls/maprules.cpp:694 */ -void CGameCounter::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 696 -// Use(CGameCounter *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 694 -} - -/* ../cstrike/dlls/maprules.cpp:747 */ -LINK_ENTITY_TO_CLASS(game_counter_set, CGameCounterSet); +/* ../cstrike/dlls/maprules.cpp:694 */ +void CGameCounter::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; -/* ../cstrike/dlls/maprules.cpp:750 */ -void CGameCounterSet::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 752 -// Use(CGameCounterSet *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 750 -} - -/* ../cstrike/dlls/maprules.cpp:788 */ -LINK_ENTITY_TO_CLASS(game_player_equip, CGamePlayerEquip); - -/* ../cstrike/dlls/maprules.cpp:791 */ -void CGamePlayerEquip::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// { -// int i; // 797 -// { -// char tmp; // 801 -// } -// } -// KeyValue(CRuleEntity *const this, -// KeyValueData *pkvd); // 793 -// KeyValue(CGamePlayerEquip *const this, -// KeyValueData *pkvd); // 791 + switch (useType) + { + case USE_ON: + case USE_TOGGLE: + CountUp(); + break; + + case USE_OFF: + CountDown(); + break; + + case USE_SET: + SetCountValue((int)value); + break; + } + + if (HitLimit()) + { + SUB_UseTargets(pActivator, USE_TOGGLE, 0); + + if (RemoveOnFire()) + { + UTIL_Remove(this); + } + + if (ResetOnFire()) + { + ResetCount(); + } + } } -/* ../cstrike/dlls/maprules.cpp:816 */ -void CGamePlayerEquip::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) -{ -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 818 -// Touch(CGamePlayerEquip *const this, -// class CBaseEntity *pOther); // 816 -} - -/* ../cstrike/dlls/maprules.cpp:827 */ -void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity) -{ -// { -// class CBasePlayer *pPlayer; // 829 -// { -// int i; // 839 -// { -// int j; // 843 -// } -// } -// } +/* ../cstrike/dlls/maprules.cpp:747 */ +LINK_ENTITY_TO_CLASS(game_counter_set, CGameCounterSet); + +/* ../cstrike/dlls/maprules.cpp:750 */ +void CGameCounterSet::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; + + SUB_UseTargets(pActivator, USE_SET, pev->frags); + + if (RemoveOnFire()) + { + UTIL_Remove(this); + } } -/* ../cstrike/dlls/maprules.cpp:851 */ -void CGamePlayerEquip::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// EquipPlayer(CGamePlayerEquip *const this, -// class CBaseEntity *pEntity); // 853 +/* ../cstrike/dlls/maprules.cpp:788 */ +LINK_ENTITY_TO_CLASS(game_player_equip, CGamePlayerEquip); + +/* ../cstrike/dlls/maprules.cpp:791 */ +void CGamePlayerEquip::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + CRulePointEntity::KeyValue(pkvd); + + if (!pkvd->fHandled) + { + for (int i = 0; i < MAX_EQUIP; i++) + { + if (FStringNull(m_weaponNames[i])) + { + char tmp[128]; + UTIL_StripToken(pkvd->szKeyName, tmp); + + m_weaponNames[i] = ALLOC_STRING(tmp); + m_weaponCount[i] = Q_atoi(pkvd->szValue); + m_weaponCount[i] = Q_max(1, m_weaponCount[i]); + + pkvd->fHandled = TRUE; + break; + } + } + } } -/* ../cstrike/dlls/maprules.cpp:881 */ +/* ../cstrike/dlls/maprules.cpp:816 */ +void CGamePlayerEquip::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +{ + if (!CanFireForActivator(pOther)) + return; + + if (UseOnly()) + return; + + EquipPlayer(pOther); +} + +/* ../cstrike/dlls/maprules.cpp:827 */ +void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity) +{ + CBasePlayer *pPlayer = NULL; + + if (pEntity->IsPlayer()) + { + pPlayer = reinterpret_cast(pEntity); + } + + if (!pPlayer) + return; + + for (int i = 0; i < MAX_EQUIP; i++) + { + if (FStringNull(m_weaponNames[i])) + break; + + for (int j = 0; j < m_weaponCount[i]; j++) + { + pPlayer->GiveNamedItem(STRING(m_weaponNames[i])); + } + } +} + +/* ../cstrike/dlls/maprules.cpp:851 */ +void CGamePlayerEquip::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + EquipPlayer(pActivator); +} + +/* ../cstrike/dlls/maprules.cpp:881 */ LINK_ENTITY_TO_CLASS(game_player_team, CGamePlayerTeam); -/* ../cstrike/dlls/maprules.cpp:884 */ -const char *CGamePlayerTeam::TargetTeamName(const char *pszTargetName) -{ -// { -// class CBaseEntity *pTeamEntity; // 886 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 890 -// } +/* ../cstrike/dlls/maprules.cpp:884 */ +const char *CGamePlayerTeam::TargetTeamName(const char *pszTargetName) +{ + CBaseEntity *pTeamEntity = NULL; + + while ((pTeamEntity = UTIL_FindEntityByTargetname(pTeamEntity, pszTargetName)) != NULL) + { + if (FClassnameIs(pTeamEntity->pev, "game_team_master")) + return pTeamEntity->TeamID(); + } + + return NULL; } -/* ../cstrike/dlls/maprules.cpp:898 */ -void CGamePlayerTeam::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// { -// const char *pszTargetTeam; // 905 -// { -// class CBasePlayer *pPlayer; // 908 -// } -// } -// CanFireForActivator(CRuleEntity *const this, -// class CBaseEntity *pActivator); // 900 -// Use(CGamePlayerTeam *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 898 +/* ../cstrike/dlls/maprules.cpp:898 */ +void CGamePlayerTeam::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + if (!CanFireForActivator(pActivator)) + return; + + if (pActivator->IsPlayer()) + { + const char *pszTargetTeam = TargetTeamName(STRING(pev->target)); + + if (pszTargetTeam != NULL) + { + CBasePlayer *pPlayer = reinterpret_cast(pActivator); + g_pGameRules->ChangePlayerTeam(pPlayer, pszTargetTeam, ShouldKillPlayer(), ShouldGibPlayer()); + } + } + + if (RemoveOnFire()) + { + UTIL_Remove(this); + } } #ifdef HOOK_GAMEDLL @@ -492,10 +739,10 @@ void CGameTeamMaster::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP { Use_(pActivator, pCaller, useType, value); } - -void CGameTeamSet::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ - Use_(pActivator, pCaller, useType, value); + +void CGameTeamSet::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + Use_(pActivator, pCaller, useType, value); } void CGamePlayerZone::KeyValue(KeyValueData *pkvd) diff --git a/regamedll/dlls/maprules.h b/regamedll/dlls/maprules.h index f391bbfd..d2dcb8a3 100644 --- a/regamedll/dlls/maprules.h +++ b/regamedll/dlls/maprules.h @@ -61,10 +61,10 @@ class CRuleEntity: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); #ifdef HOOK_GAMEDLL @@ -90,11 +90,13 @@ private: };/* size: 156, cachelines: 3, members: 3 */ +// CRulePointEntity -- base class for all rule "point" entities (not brushes) + /* ../cstrike/dlls/maprules.cpp:95 */ class CRulePointEntity: public CRuleEntity { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -104,11 +106,14 @@ public: };/* size: 156, cachelines: 3, members: 1 */ +// CRuleBrushEntity -- base class for all rule "brush" entities (not brushes) +// Default behavior is to set up like a trigger, invisible, but keep the model for volume testing + /* ../cstrike/dlls/maprules.cpp:112 */ class CRuleBrushEntity: public CRuleEntity { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -118,13 +123,18 @@ public: };/* size: 156, cachelines: 3, members: 1 */ +// CGameScore / game_score -- award points to player / team +// Points +/- total +// Flag: Allow negative scores SF_SCORE_NEGATIVE +// Flag: Award points to team in teamplay SF_SCORE_TEAM + /* ../cstrike/dlls/maprules.cpp:135 */ class CGameScore: public CRulePointEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -135,30 +145,32 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY inline int Points(void) + inline int Points(void) { return (int)(pev->frags); } - NOBODY inline BOOL AllowNegativeScore(void) + inline BOOL AllowNegativeScore(void) { return pev->spawnflags & SF_SCORE_NEGATIVE; } - NOBODY inline BOOL AwardToTeam(void) + inline BOOL AwardToTeam(void) { return pev->spawnflags & SF_SCORE_TEAM; } - NOBODY inline void SetPoints(int points) + inline void SetPoints(int points) { pev->frags = points; } };/* size: 156, cachelines: 3, members: 1 */ +// CGameEnd / game_end -- Ends the game in MP + /* ../cstrike/dlls/maprules.cpp:195 */ class CGameEnd: public CRulePointEntity { public: - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -168,14 +180,17 @@ public: };/* size: 156, cachelines: 3, members: 1 */ +// CGameText / game_text -- NON-Localized HUD Message (use env_message to display a titles.txt message) +// Flag: All players SF_ENVTEXT_ALLPLAYERS + /* ../cstrike/dlls/maprules.cpp:223 */ class CGameText: public CRulePointEntity { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -187,15 +202,15 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY inline BOOL MessageToAll(void) + inline BOOL MessageToAll(void) { return (pev->spawnflags & SF_ENVTEXT_ALLPLAYERS) == SF_ENVTEXT_ALLPLAYERS; } - NOBODY inline void MessageSet(const char *pMessage) + inline void MessageSet(const char *pMessage) { pev->message = ALLOC_STRING(pMessage); } - NOBODY inline const char *MessageGet(void) + inline const char *MessageGet(void) { return STRING(pev->message); } @@ -208,25 +223,32 @@ private: };/* size: 196, cachelines: 4, members: 3 */ -/* ../cstrike/dlls/maprules.cpp:352 */ +// CGameTeamMaster / game_team_master -- "Masters" like multisource, but based on the team of the activator +// Only allows mastered entity to fire if the team matches my team + +// team index (pulled from server team list "mp_teamlist" +// Flag: Remove on Fire +// Flag: Any team until set? -- Any team can use this until the team is set (otherwise no teams can use it) + +/* ../cstrike/dlls/maprules.cpp:352 */ class CGameTeamMaster: public CRulePointEntity { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int ObjectCaps(void) + virtual void KeyValue(KeyValueData *pkvd); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual BOOL IsTriggered(CBaseEntity *pActivator); - NOBODY virtual const char *TeamID(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual BOOL IsTriggered(CBaseEntity *pActivator); + virtual const char *TeamID(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL void KeyValue_(KeyValueData *pkvd); int ObjectCaps_(void) { - return CRulePointEntity::ObjectCaps() | FCAP_MASTER; + return (CRulePointEntity::ObjectCaps() | FCAP_MASTER); } BOOL IsTriggered_(CBaseEntity *pActivator); const char *TeamID_(void); @@ -253,11 +275,15 @@ public: };/* size: 164, cachelines: 3, members: 3 */ -/* ../cstrike/dlls/maprules.cpp:464 */ +// CGameTeamSet / game_team_set -- Changes the team of the entity it targets to the activator's team +// Flag: Fire once +// Flag: Clear team -- Sets the team to "NONE" instead of activator + +/* ../cstrike/dlls/maprules.cpp:464 */ class CGameTeamSet: public CRulePointEntity { public: - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -265,6 +291,7 @@ public: #endif // HOOK_GAMEDLL +public: inline BOOL RemoveOnFire(void) { return (pev->spawnflags & SF_TEAMSET_FIREONCE) == SF_TEAMSET_FIREONCE; @@ -276,14 +303,17 @@ public: };/* size: 156, cachelines: 3, members: 1 */ -/* ../cstrike/dlls/maprules.cpp:502 */ +// CGamePlayerZone / game_player_zone -- players in the zone fire my target when I'm fired +// Needs master? + +/* ../cstrike/dlls/maprules.cpp:502 */ class CGamePlayerZone: public CRuleBrushEntity { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -303,13 +333,16 @@ private: string_t m_iszInCount; string_t m_iszOutCount; -};/* size: 172, cachelines: 3, members: 6 */ +};/* size: 172, cachelines: 3, members: 6 */ -/* ../cstrike/dlls/maprules.cpp:619 */ +// CGamePlayerHurt / game_player_hurt -- Damages the player who fires it +// Flag: Fire once + +/* ../cstrike/dlls/maprules.cpp:619 */ class CGamePlayerHurt: public CRulePointEntity { public: - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -325,12 +358,16 @@ public: };/* size: 156, cachelines: 3, members: 1 */ -/* ../cstrike/dlls/maprules.cpp:662 */ +// CGameCounter / game_counter -- Counts events and fires target +// Flag: Fire once +// Flag: Reset on Fire + +/* ../cstrike/dlls/maprules.cpp:662 */ class CGameCounter: public CRulePointEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -385,11 +422,14 @@ private: };/* size: 156, cachelines: 3, members: 1 */ +// CGameCounterSet / game_counter_set -- Sets the counter's value +// Flag: Fire once + /* ../cstrike/dlls/maprules.cpp:738 */ class CGameCounterSet: public CRulePointEntity { public: - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -405,13 +445,16 @@ public: };/* size: 156, cachelines: 3, members: 1 */ -/* ../cstrike/dlls/maprules.cpp:771 */ +// CGamePlayerEquip / game_playerequip -- Sets the default player equipment +// Flag: USE Only + +/* ../cstrike/dlls/maprules.cpp:771 */ class CGamePlayerEquip: public CRulePointEntity { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual void Touch(CBaseEntity *pOther); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void KeyValue(KeyValueData *pkvd); + virtual void Touch(CBaseEntity *pOther); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -436,11 +479,16 @@ public: };/* size: 412, cachelines: 7, members: 3 */ -/* ../cstrike/dlls/maprules.cpp:867 */ +// CGamePlayerTeam / game_player_team -- Changes the team of the player who fired it +// Flag: Fire once +// Flag: Kill Player +// Flag: Gib Player + +/* ../cstrike/dlls/maprules.cpp:867 */ class CGamePlayerTeam: public CRulePointEntity { public: - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -465,4 +513,17 @@ private: };/* size: 156, cachelines: 3, members: 1 */ +// linked objects +C_DLLEXPORT void game_score(entvars_t *pev); +C_DLLEXPORT void game_end(entvars_t *pev); +C_DLLEXPORT void game_text(entvars_t *pev); +C_DLLEXPORT void game_team_master(entvars_t *pev); +C_DLLEXPORT void game_team_set(entvars_t *pev); +C_DLLEXPORT void game_zone_player(entvars_t *pev); +C_DLLEXPORT void game_player_hurt(entvars_t *pev); +C_DLLEXPORT void game_counter(entvars_t *pev); +C_DLLEXPORT void game_counter_set(entvars_t *pev); +C_DLLEXPORT void game_player_equip(entvars_t *pev); +C_DLLEXPORT void game_player_team(entvars_t *pev); + #endif // MAPRULES_H diff --git a/regamedll/dlls/monsterevent.h b/regamedll/dlls/monsterevent.h index 1db2980c..703ad669 100644 --- a/regamedll/dlls/monsterevent.h +++ b/regamedll/dlls/monsterevent.h @@ -36,6 +36,7 @@ typedef struct { int event; char *options; + } MonsterEvent_t; #define EVENT_SPECIFIC 0 diff --git a/regamedll/dlls/monsters.h b/regamedll/dlls/monsters.h index d7e9dd57..18d36109 100644 --- a/regamedll/dlls/monsters.h +++ b/regamedll/dlls/monsters.h @@ -134,7 +134,7 @@ public: public: static void SpawnHeadGib(entvars_t *pevVictim); static void SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human); - NOBODY static void SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs); + NOXREF static void SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs); public: int m_bloodColor; int m_cBloodDecals; diff --git a/regamedll/dlls/mortar.cpp b/regamedll/dlls/mortar.cpp index 689cceda..d143d9e2 100644 --- a/regamedll/dlls/mortar.cpp +++ b/regamedll/dlls/mortar.cpp @@ -17,7 +17,7 @@ TYPEDESCRIPTION CFuncMortarField::m_SaveData[] = #else -TYPEDESCRIPTION (*CFuncMortarField::pm_SaveData)[6]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncMortarField, m_SaveData)[6]; #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/mpstubb.cpp b/regamedll/dlls/mpstubb.cpp index 9ffe2d4e..476385dc 100644 --- a/regamedll/dlls/mpstubb.cpp +++ b/regamedll/dlls/mpstubb.cpp @@ -63,12 +63,14 @@ void CBaseMonster::MakeIdealYaw(Vector vecTarget) } /* ../cstrike/dlls/mpstubb.cpp:49 */ -NOBODY void CBaseMonster::CorpseFallThink(void) +NOXREF void CBaseMonster::CorpseFallThink(void) { if (pev->flags & FL_ONGROUND) { SetThink(NULL); SetSequenceBox(); + + // link into world. UTIL_SetOrigin(pev, pev->origin); } else @@ -117,50 +119,165 @@ void CBaseMonster::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) } /* ../cstrike/dlls/mpstubb.cpp:104 */ -NOBODY int CBaseMonster::__MAKE_VHOOK(IRelationship)(CBaseEntity *pTarget) +int CBaseMonster::__MAKE_VHOOK(IRelationship)(CBaseEntity *pTarget) { -// { -// int const iEnemy; // 106 -// } + static int const iEnemy[14][14] = + { + // NONE MACH PLYR HPASS HMIL AMIL APASS AMONST APREY APRED INSECT PLRALY PBWPN ABWPN + { R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO }, // NONE + { R_NO, R_NO, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL }, // MACHINE + { R_NO, R_DL, R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL }, // PLAYER + { R_NO, R_NO, R_AL, R_AL, R_HT, R_FR, R_NO, R_HT, R_DL, R_FR, R_NO, R_AL, R_NO, R_NO }, // HUMANPASSIVE + { R_NO, R_NO, R_HT, R_DL, R_NO, R_HT, R_DL, R_DL, R_DL, R_DL, R_NO, R_HT, R_NO, R_NO }, // HUMANMILITAR + { R_NO, R_DL, R_HT, R_DL, R_HT, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO }, // ALIENMILITAR + { R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO }, // ALIENPASSIVE + { R_NO, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO }, // ALIENMONSTER + { R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_FR, R_NO, R_DL, R_NO, R_NO }, // ALIENPREY + { R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_HT, R_DL, R_NO, R_DL, R_NO, R_NO }, // ALIENPREDATO + { R_FR, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_NO, R_NO }, // INSECT + { R_NO, R_DL, R_AL, R_AL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO }, // PLAYERALLY + { R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_NO, R_DL }, // PBIOWEAPON + { R_NO, R_NO, R_DL, R_DL, R_DL, R_AL, R_NO, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL, R_NO } // ABIOWEAPON + }; + + return iEnemy[ Classify() ][ pTarget->Classify() ]; } +// Look - Base class monster function to find enemies or +// food by sight. iDistance is distance (in units) that the +// monster can see. +// +// Sets the sight bits of the m_afConditions mask to indicate +// which types of entities were sighted. +// Function also sets the Looker's m_pLink +// to the head of a link list that contains all visible ents. +// (linked via each ent's m_pLink field) + /* ../cstrike/dlls/mpstubb.cpp:140 */ -NOBODY void CBaseMonster::__MAKE_VHOOK(Look)(int iDistance) +void CBaseMonster::__MAKE_VHOOK(Look)(int iDistance) { -// { -// int iSighted; // 142 -// class CBaseEntity *pSightEnt; // 149 -// class CBaseEntity *pList; // 151 -// Vector delta; // 153 -// int count; // 156 -// ClearConditions(CBaseMonster *const this, -// int iConditions); // 145 -// operator+(const Vector *const this, -// const Vector &v); // 156 -// operator-(const Vector *const this, -// const Vector &v); // 156 -// { -// int i; // 157 -// } -// SetConditions(CBaseMonster *const this, -// int iConditions); // 207 -// } + int iSighted = 0; + + // DON'T let visibility information from last frame sit around! + ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT); + + m_pLink = NULL; + + // the current visible entity that we're dealing with + CBaseEntity *pSightEnt = NULL; + CBaseEntity *pList[100]; + + Vector delta = Vector(iDistance, iDistance, iDistance); + + // Find only monsters/clients in box, NOT limited to PVS + int count = UTIL_EntitiesInBox(pList, ARRAYSIZE(pList), pev->origin - delta, pev->origin + delta, (FL_CLIENT | FL_MONSTER)); + for (int i = 0; i < count; i++) + { + pSightEnt = pList[i]; + if (pSightEnt != this && pSightEnt->pev->health > 0) + { + // the looker will want to consider this entity + // don't check anything else about an entity that can't be seen, or an entity that you don't care about. + if (IRelationship(pSightEnt) != R_NO && FInViewCone(pSightEnt) && !(pSightEnt->pev->flags & FL_NOTARGET) && FVisible(pSightEnt)) + { + if (pSightEnt->IsPlayer()) + { + // if we see a client, remember that (mostly for scripted AI) + iSighted |= bits_COND_SEE_CLIENT; + } + + pSightEnt->m_pLink = m_pLink; + m_pLink = pSightEnt; + + if (pSightEnt == m_hEnemy) + { + // we know this ent is visible, so if it also happens to be our enemy, store that now. + iSighted |= bits_COND_SEE_ENEMY; + } + + // don't add the Enemy's relationship to the conditions. We only want to worry about conditions when + // we see monsters other than the Enemy. + switch (IRelationship (pSightEnt)) + { + case R_NM: + iSighted |= bits_COND_SEE_NEMESIS; + break; + case R_HT: + iSighted |= bits_COND_SEE_HATE; + break; + case R_DL: + iSighted |= bits_COND_SEE_DISLIKE; + break; + case R_FR: + iSighted |= bits_COND_SEE_FEAR; + break; + case R_AL: + break; + default: + ALERT(at_aiconsole, "%s can't assess %s\n", STRING(pev->classname), STRING(pSightEnt->pev->classname)); + break; + } + } + } + } + + SetConditions(iSighted); } +// BestVisibleEnemy - this functions searches the link +// list whose head is the caller's m_pLink field, and returns +// a pointer to the enemy entity in that list that is nearest the +// caller. +// +// !!!UNDONE - currently, this only returns the closest enemy. +// we'll want to consider distance, relationship, attack types, back turned, etc. + /* ../cstrike/dlls/mpstubb.cpp:220 */ -NOBODY CBaseEntity *CBaseMonster::__MAKE_VHOOK(BestVisibleEnemy)(void) +CBaseEntity *CBaseMonster::__MAKE_VHOOK(BestVisibleEnemy)(void) { -// { -// class CBaseEntity *pReturn; // 222 -// class CBaseEntity *pNextEnt; // 223 -// int iNearest; // 224 -// int iDist; // 225 -// int iBestRelationship; // 226 -// operator-(const Vector *const this, -// const Vector &v); // 243 -// Length(const Vector *const this); // 243 -// operator-(const Vector *const this, -// const Vector &v); // 251 -// Length(const Vector *const this); // 251 -// } + CBaseEntity *pReturn; + CBaseEntity *pNextEnt; + int iNearest; + int iDist; + int iBestRelationship; + + // so first visible entity will become the closest. + iNearest = 8192; + pNextEnt = m_pLink; + pReturn = NULL; + iBestRelationship = R_NO; + + while (pNextEnt != NULL) + { + if (pNextEnt->IsAlive()) + { + if (IRelationship(pNextEnt) > iBestRelationship) + { + // this entity is disliked MORE than the entity that we + // currently think is the best visible enemy. No need to do + // a distance check, just get mad at this one for now. + iBestRelationship = IRelationship(pNextEnt); + iNearest = (pNextEnt->pev->origin - pev->origin).Length(); + pReturn = pNextEnt; + } + else if (IRelationship(pNextEnt) == iBestRelationship) + { + // this entity is disliked just as much as the entity that + // we currently think is the best visible enemy, so we only + // get mad at it if it is closer. + iDist = (pNextEnt->pev->origin - pev->origin).Length(); + + if (iDist <= iNearest) + { + iNearest = iDist; + iBestRelationship = IRelationship(pNextEnt); + pReturn = pNextEnt; + } + } + } + + pNextEnt = pNextEnt->m_pLink; + } + + return pReturn; } diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 0b5351f9..28eeeffc 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -759,7 +759,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void) for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i); - + if (!player || FNullEnt(player->edict())) continue; @@ -1582,7 +1582,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) } g_pGameRules->m_bBombDropped = FALSE; - + MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); WRITE_BYTE(0); WRITE_BYTE(100 | DRC_FLAG_FACEPLAYER); @@ -1816,7 +1816,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) if (pPlayer->pev->flags == FL_DORMANT) continue; - + CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); player->m_iNumSpawns = 0; @@ -2293,7 +2293,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) ALERT(at_console, "Changing maps...one team has won the specified number of rounds\n"); GoToIntermission(); - return; + return; } } } @@ -2317,7 +2317,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) UTIL_LogPrintf("World triggered \"Round_Start\"\n"); m_bFreezePeriod = FALSE; - + switch (RANDOM_LONG(0, 3)) { case 0: @@ -2353,7 +2353,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) m_iRoundTimeSecs = m_iRoundTime; m_fRoundCount = gpGlobals->time; - + bCTPlayed = false; bTPlayed = false; @@ -2763,7 +2763,7 @@ void CHalfLifeMultiplay::CareerRestart(void) { m_fTeamCount = gpGlobals->time + 1.0f; } - + // for reset everything m_bCompleteReset = true; m_fCareerRoundMenuTime = 0; @@ -2936,7 +2936,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) { // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = reinterpret_cast(UTIL_PlayerByIndex(i)); - + if (plr != NULL) { MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); @@ -3042,7 +3042,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) if (pClient != NULL) { CBasePlayer *pPlayer = reinterpret_cast(CBaseEntity::Instance(pClient)); - + if (pPlayer != NULL) { pPlayer->has_disconnected = true; @@ -3312,7 +3312,7 @@ int CHalfLifeMultiplay::__MAKE_VHOOK(IPointsForKill)(CBasePlayer *pAttacker, CBa void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) { DeathNotice(pVictim, pKiller, pInflictor); - + pVictim->m_afPhysicsFlags &= ~PFLAG_ONTRAIN; pVictim->m_iDeaths++; pVictim->m_bNotKilled = false; @@ -3383,7 +3383,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvar { // if a player dies in a deathmatch game and the killer is a client, award the killer some points pKiller->frags += IPointsForKill(peKiller, pVictim); - + if (pVictim->m_bIsVIP) { killer->HintMessage("#Hint_reward_for_killing_vip", TRUE); @@ -3439,7 +3439,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvar if (ep && ep->Classify() == CLASS_PLAYER) { CBasePlayer *PK = reinterpret_cast(ep); - + MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); WRITE_BYTE(ENTINDEX(PK->edict())); WRITE_SHORT((int)PK->pev->frags); @@ -3470,14 +3470,14 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars if (pKiller->flags & FL_CLIENT) { killer_index = ENTINDEX(ENT(pKiller)); - + if (pevInflictor) { if (pevInflictor == pKiller) { // If the inflictor is the killer, then it must be their current weapon doing the damage CBasePlayer *pPlayer = reinterpret_cast(CBaseEntity::Instance(pKiller)); - + if (pPlayer && pPlayer->m_pActiveItem) { killer_weapon_name = pPlayer->m_pActiveItem->pszName(); @@ -3523,7 +3523,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars else if (!Q_strcmp(killer_weapon_name, "gauss")) killer_weapon_name = tau; - + if (pVictim->pev == pKiller) { // killed self @@ -3614,7 +3614,7 @@ float CHalfLifeMultiplay::__MAKE_VHOOK(FlWeaponRespawnTime)(CBasePlayerItem *pWe return gpGlobals->time + WEAPON_RESPAWN_TIME; } -// FlWeaponRespawnTime - Returns 0 if the weapon can respawn +// FlWeaponRespawnTime - Returns 0 if the weapon can respawn // now, otherwise it returns the time at which it can try // to spawn again. @@ -3895,7 +3895,7 @@ void DestroyMapCycle(mapcycle_t *cycle) delete p; p = n; } - + delete cycle->items; } @@ -4065,16 +4065,16 @@ int ReloadMapCycleFile(char *filename, mapcycle_t *cycle) if (s && s[0] != '\0') { item->minplayers = Q_atoi(s); - item->minplayers = _max(item->minplayers, 0); - item->minplayers = _min(item->minplayers, gpGlobals->maxClients); + item->minplayers = Q_max(item->minplayers, 0); + item->minplayers = Q_min(item->minplayers, gpGlobals->maxClients); } s = GET_KEY_VALUE(szBuffer, "maxplayers"); if (s && s[0] != '\0') { item->maxplayers = Q_atoi(s); - item->maxplayers = _max(item->maxplayers, 0); - item->maxplayers = _min(item->maxplayers, gpGlobals->maxClients); + item->maxplayers = Q_max(item->maxplayers, 0); + item->maxplayers = Q_min(item->maxplayers, gpGlobals->maxClients); } // Remove keys @@ -4157,7 +4157,7 @@ void ExtractCommandString(char *s, char *szCommand) // work without stomping on each other char *o; - + if (*s == '\\') s++; diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index 372ffbdb..eae43d61 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -25,7 +25,7 @@ CBaseEntity *CBasePlayer::Observer_IsValidTarget(int iPlayerIndex, bool bSameTea return NULL; CBaseEntity *pEnt = UTIL_PlayerByIndex(iPlayerIndex); - + // Don't spec observers or players who haven't picked a class yet if (!pEnt || pEnt == this || pEnt->has_disconnected || ((CBasePlayer *)pEnt)->IsObserver() || (pEnt->pev->effects & EF_NODRAW) || ((CBasePlayer *)pEnt)->m_iTeam == UNASSIGNED || (bSameTeam && ((CBasePlayer *)pEnt)->m_iTeam != m_iTeam)) return NULL; @@ -167,7 +167,7 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name) if (!name) break; - pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( ENTINDEX(m_hObserverTarget->edict()) ); + pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(ENTINDEX(m_hObserverTarget->edict())); if (!Q_strcmp(name, STRING(pPlayer->pev->netname))) break; @@ -186,7 +186,7 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name) MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth2, NULL, pev); WRITE_BYTE((int)m_hObserverTarget->pev->health); - WRITE_BYTE( ENTINDEX(m_hObserverTarget->edict()) ); + WRITE_BYTE(ENTINDEX(m_hObserverTarget->edict())); MESSAGE_END(); // Store the target in pev so the physics DLL can get to it @@ -489,7 +489,7 @@ void CBasePlayer::Observer_SetMode(int iMode) if (pev->iuser1 == OBS_ROAMING) pev->iuser2 = 0; else - pev->iuser2 = ENTINDEX( m_hObserverTarget->edict() ); + pev->iuser2 = ENTINDEX(m_hObserverTarget->edict()); // clear second target from death cam pev->iuser3 = 0; diff --git a/regamedll/dlls/pathcorner.cpp b/regamedll/dlls/pathcorner.cpp index 2510eec9..b637002c 100644 --- a/regamedll/dlls/pathcorner.cpp +++ b/regamedll/dlls/pathcorner.cpp @@ -19,10 +19,10 @@ TYPEDESCRIPTION CPathTrack::m_SaveData[] = DEFINE_FIELD(CPathTrack, m_altName, FIELD_STRING), }; -#else // HOOK_GAMEDLL - -TYPEDESCRIPTION (*CPathCorner::pm_SaveData)[1]; -TYPEDESCRIPTION (*CPathTrack::pm_SaveData)[5]; +#else + +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CPathCorner, m_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CPathTrack, m_SaveData)[5]; #endif // HOOK_GAMEDLL @@ -33,19 +33,21 @@ LINK_ENTITY_TO_CLASS(path_corner, CPathCorner); IMPLEMENT_SAVERESTORE(CPathCorner, CPointEntity); /* <122697> ../cstrike/dlls/pathcorner.cpp:54 */ -NOBODY void CPathCorner::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CPathCorner::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 56 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 62 -// KeyValue(CPathCorner *const this, -// KeyValueData *pkvd); // 54 + if (FStrEq(pkvd->szKeyName, "wait")) + { + m_flWait = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CPointEntity::KeyValue(pkvd); } /* <122325> ../cstrike/dlls/pathcorner.cpp:66 */ -NOBODY void CPathCorner::__MAKE_VHOOK(Spawn)(void) +void CPathCorner::__MAKE_VHOOK(Spawn)(void) { + assert(("path_corner without a targetname", !FStringNull(pev->targetname))); } /* <12256a> ../cstrike/dlls/pathcorner.cpp:80 */ @@ -55,198 +57,326 @@ IMPLEMENT_SAVERESTORE(CPathTrack, CBaseEntity); LINK_ENTITY_TO_CLASS(path_track, CPathTrack); /* <122602> ../cstrike/dlls/pathcorner.cpp:86 */ -NOBODY void CPathTrack::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CPathTrack::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 88 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 94 -// KeyValue(CPathTrack *const this, -// KeyValueData *pkvd); // 86 + if (FStrEq(pkvd->szKeyName, "altpath")) + { + m_altName = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CPointEntity::KeyValue(pkvd); } /* <122433> ../cstrike/dlls/pathcorner.cpp:97 */ -NOBODY void CPathTrack::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CPathTrack::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// int on; // 99 -// } -// Use(CPathTrack *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 97 + int on; + + // Use toggles between two paths + if (m_paltpath) + { + on = !(pev->spawnflags & SF_PATH_ALTERNATE); + + if (ShouldToggle(useType, on)) + { + if (on) + pev->spawnflags |= SF_PATH_ALTERNATE; + else + pev->spawnflags &= ~SF_PATH_ALTERNATE; + } + } + else // Use toggles between enabled/disabled + { + on = !(pev->spawnflags & SF_PATH_DISABLED); + + if (ShouldToggle(useType, on)) + { + if (on) + pev->spawnflags |= SF_PATH_DISABLED; + else + pev->spawnflags &= ~SF_PATH_DISABLED; + } + } } /* <122a12> ../cstrike/dlls/pathcorner.cpp:128 */ -NOBODY void CPathTrack::Link(void) +void CPathTrack::Link(void) { -// { -// edict_t *pentTarget; // 130 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 151 -// FNullEnt(const edict_t *pent); // 152 -// Instance(edict_t *pent); // 154 -// SetPrevious(CPathTrack *const this, -// class CPathTrack *pprev); // 158 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 134 -// FNullEnt(const edict_t *pent); // 135 -// Instance(edict_t *pent); // 137 -// SetPrevious(CPathTrack *const this, -// class CPathTrack *pprev); // 141 -// } + edict_t *pentTarget; + + if (!FStringNull(pev->target)) + { + pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); + if (!FNullEnt(pentTarget)) + { + m_pnext = CPathTrack::Instance(pentTarget); + + // If no next pointer, this is the end of a path + if (m_pnext != NULL) + { + m_pnext->SetPrevious(this); + } + } + else + ALERT(at_console, "Dead end link %s\n", STRING(pev->target)); + } + + // Find "alternate" path + if (!FStringNull(m_altName)) + { + pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_altName)); + if (!FNullEnt(pentTarget)) + { + m_paltpath = CPathTrack::Instance(pentTarget); + + // If no next pointer, this is the end of a path + if (m_paltpath != NULL) + { + m_paltpath->SetPrevious(this); + } + } + } } /* <12239a> ../cstrike/dlls/pathcorner.cpp:165 */ -NOBODY void CPathTrack::__MAKE_VHOOK(Spawn)(void) +void CPathTrack::__MAKE_VHOOK(Spawn)(void) { -// Vector(Vector::Spawn(// float X, -// float Y, -// float Z); // 168 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 168 + pev->solid = SOLID_TRIGGER; + UTIL_SetSize(pev, Vector(-8, -8, -8), Vector(8, 8, 8)); + + m_pnext = NULL; + m_pprevious = NULL; } /* <122c76> ../cstrike/dlls/pathcorner.cpp:180 */ -NOBODY void CPathTrack::__MAKE_VHOOK(Activate)(void) +void CPathTrack::__MAKE_VHOOK(Activate)(void) { + // Link to next, and back-link + if (!FStringNull(pev->targetname)) + { + Link(); + } } /* <122c9c> ../cstrike/dlls/pathcorner.cpp:186 */ -NOBODY CPathTrack *CPathTrack::ValidPath(CPathTrack *ppath, int testFlag) +CPathTrack *CPathTrack::ValidPath(CPathTrack *ppath, int testFlag) { + if (!ppath) + return NULL; + + if (testFlag && (ppath->pev->spawnflags & SF_PATH_DISABLED)) + return NULL; + + return ppath; } /* <122745> ../cstrike/dlls/pathcorner.cpp:198 */ -NOBODY void CPathTrack::Project(CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist) +void CPathTrack::Project(CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist) { -// { -// Vector dir; // 202 -// operator-(const Vector *const this, -// const Vector &v); // 202 -// Normalize(const Vector *const this); // 203 -// operator*(const Vector *const this, -// float fl); // 204 -// operator+(const Vector *const this, -// const Vector &v); // 204 -// } + if (pstart && pend) + { + Vector dir = (pend->pev->origin - pstart->pev->origin); + dir = dir.Normalize(); + + *origin = pend->pev->origin + dir * dist; + } } /* <122d0f> ../cstrike/dlls/pathcorner.cpp:208 */ -NOBODY CPathTrack *CPathTrack::GetNext(void) +CPathTrack *CPathTrack::GetNext(void) { + if (m_paltpath && (pev->spawnflags & SF_PATH_ALTERNATE) && !(pev->spawnflags & SF_PATH_ALTREVERSE)) + { + return m_paltpath; + } + + return m_pnext; } /* <122d30> ../cstrike/dlls/pathcorner.cpp:218 */ -NOBODY CPathTrack *CPathTrack::GetPrevious(void) +CPathTrack *CPathTrack::GetPrevious(void) { + if (m_paltpath && (pev->spawnflags & SF_PATH_ALTERNATE) && (pev->spawnflags & SF_PATH_ALTREVERSE)) + { + return m_paltpath; + } + + return m_pprevious; } /* <122d51> ../cstrike/dlls/pathcorner.cpp:228 */ -NOBODY void CPathTrack::SetPrevious(CPathTrack *pprev) +void CPathTrack::SetPrevious(CPathTrack *pprev) { -// FStrEq(const char *sz1, -// const char *sz2); // 231 + // Only set previous if this isn't my alternate path + if (pprev && !FStrEq(STRING(pprev->pev->targetname), STRING(m_altName))) + { + m_pprevious = pprev; + } } + +// Assumes this is ALWAYS enabled /* <122d95> ../cstrike/dlls/pathcorner.cpp:237 */ -NOBODY CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move) +CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move) { -// { -// class CPathTrack *pcurrent; // 239 -// float originalDist; // 240 -// Vector currentPos; // 243 -// Vector(Vector *const this, -// const Vector &v); // 243 -// { -// Vector dir; // 291 -// float length; // 292 -// GetNext(CPathTrack *const this); // 285 -// ValidPath(CPathTrack *const this, -// class CPathTrack *ppath, -// int testFlag); // 285 -// GetNext(CPathTrack *const this); // 291 -// operator-(const Vector *const this, -// const Vector &v); // 291 -// Length(const Vector *const this); // 292 -// GetNext(CPathTrack *const this); // 293 -// GetNext(CPathTrack *const this); // 293 -// ValidPath(CPathTrack *const this, -// class CPathTrack *ppath, -// int testFlag); // 293 -// Project(CPathTrack *const this, -// class CPathTrack *pstart, -// class CPathTrack *pend, -// Vector *origin, -// float dist); // 288 -// GetNext(CPathTrack *const this); // 307 -// GetNext(CPathTrack *const this); // 308 -// operator*(const Vector *const this, -// float fl); // 301 -// operator+(const Vector *const this, -// const Vector &v); // 301 -// GetPrevious(CPathTrack *const this); // 288 -// } -// { -// Vector dir; // 250 -// float length; // 251 -// operator-(const Vector *const this, -// const Vector &v); // 250 -// Length(const Vector *const this); // 251 -// GetPrevious(CPathTrack *const this); // 254 -// ValidPath(CPathTrack *const this, -// class CPathTrack *ppath, -// int testFlag); // 254 -// GetPrevious(CPathTrack *const this); // 260 -// GetPrevious(CPathTrack *const this); // 275 -// GetPrevious(CPathTrack *const this); // 272 -// ValidPath(CPathTrack *const this, -// class CPathTrack *ppath, -// int testFlag); // 272 -// operator*(const Vector *const this, -// float fl); // 264 -// operator+(const Vector *const this, -// const Vector &v); // 264 -// GetNext(CPathTrack *const this); // 257 -// Project(CPathTrack *const this, -// class CPathTrack *pstart, -// class CPathTrack *pend, -// Vector *origin, -// float dist); // 257 -// } -// } + CPathTrack *pcurrent; + float originalDist = dist; + + pcurrent = this; + Vector currentPos = *origin; + + // Travelling backwards through path + if (dist < 0) + { + dist = -dist; + while (dist > 0) + { + Vector dir = pcurrent->pev->origin - currentPos; + float_precision length = dir.Length(); + + if (!length) + { + // If there is no previous node, or it's disabled, return now. + if (!ValidPath(pcurrent->GetPrevious(), move)) + { + if (!move) + { + Project(pcurrent->GetNext(), pcurrent, origin, dist); + } + + return NULL; + } + + pcurrent = pcurrent->GetPrevious(); + } + // enough left in this path to move + else if (length > dist) + { + *origin = currentPos + (dir * ((float)(dist / length))); + return pcurrent; + } + else + { + dist -= length; + currentPos = pcurrent->pev->origin; + *origin = currentPos; + + // If there is no previous node, or it's disabled, return now. + if (!ValidPath(pcurrent->GetPrevious(), move)) + { + return NULL; + } + + pcurrent = pcurrent->GetPrevious(); + } + } + + *origin = currentPos; + return pcurrent; + } + else + { + // #96 line + while (dist > 0) + { + // If there is no next node, or it's disabled, return now. + if (!ValidPath(pcurrent->GetNext(), move)) + { + if (!move) + { + Project(pcurrent->GetPrevious(), pcurrent, origin, dist); + } + + return NULL; + } + + Vector dir = pcurrent->GetNext()->pev->origin - currentPos; + float_precision length = dir.Length(); + + if (!length && !ValidPath(pcurrent->GetNext()->GetNext(), move)) + { + // HACK -- up against a dead end + if (dist == originalDist) + return NULL; + + return pcurrent; + } + + // enough left in this path to move + if (length > dist) + { + *origin = currentPos + (dir * ((float)(dist / length))); + return pcurrent; + } + else + { + dist -= length; + currentPos = pcurrent->GetNext()->pev->origin; + pcurrent = pcurrent->GetNext(); + + *origin = currentPos; + } + } + + *origin = currentPos; + } + + return pcurrent; } +// Assumes this is ALWAYS enabled + /* <123220> ../cstrike/dlls/pathcorner.cpp:320 */ -NOBODY CPathTrack *CPathTrack::Nearest(Vector origin) +CPathTrack *CPathTrack::Nearest(Vector origin) { -// { -// int deadCount; // 322 -// float minDist; // 323 -// float dist; // 323 -// Vector delta; // 324 -// class CPathTrack *ppath; // 325 -// class CPathTrack *pnearest; // 325 -// operator-(const Vector *const this, -// const Vector &v); // 328 -// Length(const Vector *const this); // 330 -// GetNext(CPathTrack *const this); // 332 -// GetNext(CPathTrack *const this); // 352 -// operator-(const Vector *const this, -// const Vector &v); // 344 -// Length(const Vector *const this); // 346 -// } + int deadCount; + float minDist, dist; + Vector delta; + CPathTrack *ppath, *pnearest; + + delta = origin - pev->origin; + delta.z = 0; + minDist = delta.Length(); + pnearest = this; + ppath = GetNext(); + + // Hey, I could use the old 2 racing pointers solution to this, but I'm lazy :) + deadCount = 0; + while (ppath != NULL && ppath != this) + { + deadCount++; + if (deadCount > 9999) + { + ALERT(at_error, "Bad sequence of path_tracks from %s", STRING(pev->targetname)); + return NULL; + } + + delta = origin - ppath->pev->origin; + delta.z = 0; + dist = delta.Length(); + + if (dist < minDist) + { + minDist = dist; + pnearest = ppath; + } + + ppath = ppath->GetNext(); + } + + return pnearest; } /* <123375> ../cstrike/dlls/pathcorner.cpp:358 */ -NOBODY CPathTrack *CPathTrack::Instance(edict_t *pent) +CPathTrack *CPathTrack::Instance(edict_t *pent) { -// FClassnameIs(edict_t *pent, -// const char *szClassname); // 360 -// GET_PRIVATE(edict_t *pent); // 361 + if (FClassnameIs(pent, "path_track")) + { + return (CPathTrack *)GET_PRIVATE(pent); + } + + return NULL; } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/pathcorner.h b/regamedll/dlls/pathcorner.h index 81a05f12..acf7b8ba 100644 --- a/regamedll/dlls/pathcorner.h +++ b/regamedll/dlls/pathcorner.h @@ -36,14 +36,15 @@ class CPathCorner: public CPointEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY float GetDelay(void) + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + float GetDelay(void) { return GetDelay_(); } + #ifdef HOOK_GAMEDLL void Spawn_(void); @@ -64,4 +65,7 @@ private: };/* size: 156, cachelines: 3, members: 3 */ +// linked objects +C_DLLEXPORT void path_corner(entvars_t *pev); + #endif // PATHCORNER_H diff --git a/regamedll/dlls/plats.cpp b/regamedll/dlls/plats.cpp index 10385972..2f3efa7e 100644 --- a/regamedll/dlls/plats.cpp +++ b/regamedll/dlls/plats.cpp @@ -61,12 +61,12 @@ TYPEDESCRIPTION CGunTarget::m_SaveData[] = #else -TYPEDESCRIPTION (*CBasePlatTrain::pm_SaveData)[3]; -TYPEDESCRIPTION (*CFuncPlatRot::pm_SaveData)[2]; -TYPEDESCRIPTION (*CFuncTrain::pm_SaveData)[3]; -TYPEDESCRIPTION (*CFuncTrackTrain::pm_SaveData)[12]; -TYPEDESCRIPTION (*CFuncTrackChange::pm_SaveData)[9]; -TYPEDESCRIPTION (*CGunTarget::pm_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBasePlatTrain, m_SaveData)[3]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncPlatRot, m_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncTrain, m_SaveData)[3]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncTrackTrain, m_SaveData)[12]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncTrackChange, m_SaveData)[9]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CGunTarget, m_SaveData)[1]; #endif // HOOK_GAMEDLL @@ -74,47 +74,175 @@ TYPEDESCRIPTION (*CGunTarget::pm_SaveData)[1]; IMPLEMENT_SAVERESTORE(CBasePlatTrain, CBaseToggle); /* <12ea9b> ../cstrike/dlls/plats.cpp:61 */ -NOBODY void CBasePlatTrain::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CBasePlatTrain::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 73 -// FStrEq(const char *sz1, -// const char *sz2); // 78 -// FStrEq(const char *sz1, -// const char *sz2); // 83 -// FStrEq(const char *sz1, -// const char *sz2); // 88 -// FStrEq(const char *sz1, -// const char *sz2); // 93 -// atof(const char *__nptr); // 75 -// atof(const char *__nptr); // 85 -// atof(const char *__nptr); // 80 -// atof(const char *__nptr); // 95 -// atof(const char *__nptr); // 90 + if (FStrEq(pkvd->szKeyName, "lip")) + { + m_flLip = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "wait")) + { + m_flWait = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "height")) + { + m_flHeight = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "rotation")) + { + m_vecFinalAngle.x = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "movesnd")) + { + m_bMoveSnd = (BYTE)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "stopsnd")) + { + m_bStopSnd = (BYTE)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "volume")) + { + m_volume = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseToggle::KeyValue(pkvd); } #define noiseMoving noise #define noiseArrived noise1 /* <12d675> ../cstrike/dlls/plats.cpp:105 */ -NOBODY void CBasePlatTrain::__MAKE_VHOOK(Precache)(void) +void CBasePlatTrain::__MAKE_VHOOK(Precache)(void) { + // set the plat's "in-motion" sound + switch (m_bMoveSnd) + { + case 0: + pev->noiseMoving = MAKE_STRING("common/null.wav"); + break; + case 1: + PRECACHE_SOUND("plats/bigmove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/bigmove1.wav"); + break; + case 2: + PRECACHE_SOUND("plats/bigmove2.wav"); + pev->noiseMoving = MAKE_STRING("plats/bigmove2.wav"); + break; + case 3: + PRECACHE_SOUND("plats/elevmove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/elevmove1.wav"); + break; + case 4: + PRECACHE_SOUND("plats/elevmove2.wav"); + pev->noiseMoving = MAKE_STRING("plats/elevmove2.wav"); + break; + case 5: + PRECACHE_SOUND("plats/elevmove3.wav"); + pev->noiseMoving = MAKE_STRING("plats/elevmove3.wav"); + break; + case 6: + PRECACHE_SOUND("plats/freightmove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/freightmove1.wav"); + break; + case 7: + PRECACHE_SOUND("plats/freightmove2.wav"); + pev->noiseMoving = MAKE_STRING("plats/freightmove2.wav"); + break; + case 8: + PRECACHE_SOUND("plats/heavymove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/heavymove1.wav"); + break; + case 9: + PRECACHE_SOUND("plats/rackmove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/rackmove1.wav"); + break; + case 10: + PRECACHE_SOUND("plats/railmove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/railmove1.wav"); + break; + case 11: + PRECACHE_SOUND("plats/squeekmove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/squeekmove1.wav"); + break; + case 12: + PRECACHE_SOUND("plats/talkmove1.wav"); + pev->noiseMoving = MAKE_STRING("plats/talkmove1.wav"); + break; + case 13: + PRECACHE_SOUND("plats/talkmove2.wav"); + pev->noiseMoving = MAKE_STRING("plats/talkmove2.wav"); + break; + default: + pev->noiseMoving = MAKE_STRING("common/null.wav"); + break; + } + + // set the plat's 'reached destination' stop sound + switch (m_bStopSnd) + { + case 0: + pev->noiseArrived = MAKE_STRING("common/null.wav"); + break; + case 1: + PRECACHE_SOUND("plats/bigstop1.wav"); + pev->noiseArrived = MAKE_STRING("plats/bigstop1.wav"); + break; + case 2: + PRECACHE_SOUND("plats/bigstop2.wav"); + pev->noiseArrived = MAKE_STRING("plats/bigstop2.wav"); + break; + case 3: + PRECACHE_SOUND("plats/freightstop1.wav"); + pev->noiseArrived = MAKE_STRING("plats/freightstop1.wav"); + break; + case 4: + PRECACHE_SOUND("plats/heavystop2.wav"); + pev->noiseArrived = MAKE_STRING("plats/heavystop2.wav"); + break; + case 5: + PRECACHE_SOUND("plats/rackstop1.wav"); + pev->noiseArrived = MAKE_STRING("plats/rackstop1.wav"); + break; + case 6: + PRECACHE_SOUND("plats/railstop1.wav"); + pev->noiseArrived = MAKE_STRING("plats/railstop1.wav"); + break; + case 7: + PRECACHE_SOUND("plats/squeekstop1.wav"); + pev->noiseArrived = MAKE_STRING("plats/squeekstop1.wav"); + break; + case 8: + PRECACHE_SOUND("plats/talkstop1.wav"); + pev->noiseArrived = MAKE_STRING("plats/talkstop1.wav"); + break; + + default: + pev->noiseArrived = MAKE_STRING("common/null.wav"); + break; + } } /* <12d69c> ../cstrike/dlls/plats.cpp:235 */ -NOBODY void CFuncPlat::CallGoDown(void) +void CFuncPlat::CallGoDown(void) { GoDown(); } /* <12d6c2> ../cstrike/dlls/plats.cpp:236 */ -NOBODY void CFuncPlat::CallHitTop(void) +void CFuncPlat::CallHitTop(void) { HitTop(); } /* <12d6e8> ../cstrike/dlls/plats.cpp:237 */ -NOBODY void CFuncPlat::CallHitBottom(void) +void CFuncPlat::CallHitBottom(void) { HitBottom(); } @@ -125,122 +253,301 @@ LINK_ENTITY_TO_CLASS(func_plat, CFuncPlat); #define noiseMovement noise #define noiseStopMoving noise1 +// QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER +// speed default 150 + +// Plats are always drawn in the extended position, so they will light correctly. + +// If the plat is the target of another trigger or button, it will start out disabled in +// the extended position until it is trigger, when it will lower and become a normal plat. + +// If the "height" key is set, that will determine the amount the plat moves, instead of +// being implicitly determined by the model's height. + +// Set "sounds" to one of the following: +// 1) base fast +// 2) chain slow + /* <130730> ../cstrike/dlls/plats.cpp:275 */ -NOBODY void CFuncPlat::Setup(void) +void CFuncPlat::Setup(void) { + if (m_flTLength == 0) + m_flTLength = 80; + + if (m_flTWidth == 0) + m_flTWidth = 10; + + pev->angles = g_vecZero; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + + // set size and link into world + UTIL_SetOrigin(pev, pev->origin); + UTIL_SetSize(pev, pev->mins, pev->maxs); + SET_MODEL(ENT(pev), STRING(pev->model)); + + // vecPosition1 is the top position, vecPosition2 is the bottom + m_vecPosition1 = pev->origin; + m_vecPosition2 = pev->origin; + + if (m_flHeight != 0) + { + m_vecPosition2.z = pev->origin.z - m_flHeight; + } + else + { + m_vecPosition2.z = pev->origin.z - pev->size.z + 8; + } + + if (pev->speed == 0) + { + pev->speed = 150; + } + + if (m_volume == 0) + { + m_volume = 0.85; + } } /* <13088e> ../cstrike/dlls/plats.cpp:309 */ -NOBODY void CFuncPlat::__MAKE_VHOOK(Precache)(void) +void CFuncPlat::__MAKE_VHOOK(Precache)(void) { -// PlatSpawnInsideTrigger(entvars_t *pevPlatform); // 315 + CBasePlatTrain::Precache(); + + if (!IsTogglePlat()) + { + // the "start moving" trigger + PlatSpawnInsideTrigger(pev); + } } /* <130757> ../cstrike/dlls/plats.cpp:319 */ -NOBODY void CFuncPlat::__MAKE_VHOOK(Spawn)(void) +void CFuncPlat::__MAKE_VHOOK(Spawn)(void) { -// Spawn(CFuncPlat *const this); // 319 + Setup(); + Precache(); + + // If this platform is the target of some button, it starts at the TOP position, + // and is brought down by that button. Otherwise, it starts at BOTTOM. + if (!FStringNull(pev->targetname)) + { + UTIL_SetOrigin(pev, m_vecPosition1); + m_toggle_state = TS_AT_TOP; + SetUse(&CFuncPlat::PlatUse); + } + else + { + UTIL_SetOrigin(pev, m_vecPosition2); + m_toggle_state = TS_AT_BOTTOM; + } } /* <12c8bb> ../cstrike/dlls/plats.cpp:342 */ -NOBODY void PlatSpawnInsideTrigger(entvars_t *pevPlatform) +void PlatSpawnInsideTrigger(entvars_t *pevPlatform) { + GetClassPtr((CPlatTrigger *)NULL)->SpawnInsideTrigger(GetClassPtr((CFuncPlat *)pevPlatform)); } +// Create a trigger entity for a platform. + /* <130792> ../cstrike/dlls/plats.cpp:351 */ -NOBODY void CPlatTrigger::SpawnInsideTrigger(CFuncPlat *pPlatform) +void CPlatTrigger::SpawnInsideTrigger(CFuncPlat *pPlatform) { -// { -// Vector vecTMin; // 360 -// Vector vecTMax; // 361 -// operator+(const Vector *const this, -// const Vector &v); // 360 -// operator+(const Vector *const this, -// const Vector &v); // 361 -// } + m_pPlatform = pPlatform; + + // Create trigger entity, "point" it at the owning platform, give it a touch method + pev->solid = SOLID_TRIGGER; + pev->movetype = MOVETYPE_NONE; + pev->origin = pPlatform->pev->origin; + + // Establish the trigger field's size + Vector vecTMin = m_pPlatform->pev->mins + Vector(25, 25, 0); + Vector vecTMax = m_pPlatform->pev->maxs + Vector(25, 25, 8); + + vecTMin.z = vecTMax.z - (m_pPlatform->m_vecPosition1.z - m_pPlatform->m_vecPosition2.z + 8); + + if (m_pPlatform->pev->size.x <= 50) + { + vecTMin.x = (m_pPlatform->pev->mins.x + m_pPlatform->pev->maxs.x) / 2; + vecTMax.x = vecTMin.x + 1; + } + + if (m_pPlatform->pev->size.y <= 50) + { + vecTMin.y = (m_pPlatform->pev->mins.y + m_pPlatform->pev->maxs.y) / 2; + vecTMax.y = vecTMin.y + 1; + } + + UTIL_SetSize(pev, vecTMin, vecTMax); } /* <12e7e7> ../cstrike/dlls/plats.cpp:380 */ -NOBODY void CPlatTrigger::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +void CPlatTrigger::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { -// { -// entvars_t *pevToucher; // 383 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 384 -// } -// Touch(CPlatTrigger *const this, -// class CBaseEntity *pOther); // 380 + // Ignore touches by non-players + entvars_t *pevToucher = pOther->pev; + + if (!FClassnameIs(pevToucher, "player")) + { + return; + } + + // Ignore touches by corpses + if (!pOther->IsAlive()) + return; + + // Make linked platform go up/down. + if (m_pPlatform->m_toggle_state == TS_AT_BOTTOM) + { + m_pPlatform->GoUp(); + } + else if (m_pPlatform->m_toggle_state == TS_AT_TOP) + { + // delay going down + m_pPlatform->pev->nextthink = m_pPlatform->pev->ltime + 1; + } } +// Used by SUB_UseTargets, when a platform is the target of a button. +// Start bringing platform down. + /* <12df02> ../cstrike/dlls/plats.cpp:403 */ -NOBODY void CFuncPlat::PlatUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CFuncPlat::PlatUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// BOOL on; // 408 -// } -// PlatUse(CFuncPlat *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 403 + if (IsTogglePlat()) + { + // Top is off, bottom is on + BOOL on = (m_toggle_state == TS_AT_BOTTOM) ? TRUE : FALSE; + + if (!ShouldToggle(useType, on)) + return; + + if (m_toggle_state == TS_AT_TOP) + { + GoDown(); + } + else if (m_toggle_state == TS_AT_BOTTOM) + { + GoUp(); + } + } + else + { + SetUse(NULL); + + if (m_toggle_state == TS_AT_TOP) + { + GoDown(); + } + } } +// Platform is at top, now starts moving down. + /* <12e49b> ../cstrike/dlls/plats.cpp:431 */ -NOBODY void CFuncPlat::__MAKE_VHOOK(GoDown)(void) +void CFuncPlat::__MAKE_VHOOK(GoDown)(void) { -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 434 -// Vector(Vector *const this, -// const Vector &v); // 439 + if (pev->noiseMovement) + { + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement), m_volume, ATTN_NORM); + } + + assert(m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP); + + m_toggle_state = TS_GOING_DOWN; + SetMoveDone(&CFuncPlat::CallHitBottom); + LinearMove(m_vecPosition2, pev->speed); } +// Platform has hit bottom. Stops and waits forever. + /* <12f381> ../cstrike/dlls/plats.cpp:446 */ -NOBODY void CFuncPlat::__MAKE_VHOOK(HitBottom)(void) +void CFuncPlat::__MAKE_VHOOK(HitBottom)(void) { -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 452 -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 449 + if (pev->noiseMovement) + { + STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement)); + } + + if (pev->noiseStopMoving) + { + EMIT_SOUND(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + } + + assert(m_toggle_state == TS_GOING_DOWN); + + m_toggle_state = TS_AT_BOTTOM; } +// Platform is at bottom, now starts moving up + /* <12e52d> ../cstrike/dlls/plats.cpp:462 */ -NOBODY void CFuncPlat::__MAKE_VHOOK(GoUp)(void) +void CFuncPlat::__MAKE_VHOOK(GoUp)(void) { -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 465 -// Vector(Vector *const this, -// const Vector &v); // 470 + if (pev->noiseMovement) + { + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement), m_volume, ATTN_NORM); + } + + assert(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN); + + m_toggle_state = TS_GOING_UP; + SetMoveDone(&CFuncPlat::CallHitTop); + LinearMove(m_vecPosition1, pev->speed); } +// Platform has hit top. Pauses, then starts back down again. + /* <12f452> ../cstrike/dlls/plats.cpp:477 */ -NOBODY void CFuncPlat::__MAKE_VHOOK(HitTop)(void) +void CFuncPlat::__MAKE_VHOOK(HitTop)(void) { -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 480 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 483 + if (pev->noiseMovement) + { + STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement)); + } + + if (pev->noiseStopMoving) + { + EMIT_SOUND(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + } + + assert(m_toggle_state == TS_GOING_UP); + + m_toggle_state = TS_AT_TOP; + + if (!IsTogglePlat()) + { + // After a delay, the platform will automatically start going down again. + SetThink(&CFuncPlat::CallGoDown); + pev->nextthink = pev->ltime + 3; + } } /* <12f524> ../cstrike/dlls/plats.cpp:497 */ -NOBODY void CFuncPlat::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) +void CFuncPlat::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) { -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 504 + ALERT(at_aiconsole, "%s Blocked by %s\n", STRING(pev->classname), STRING(pOther->pev->classname)); + + // Hurt the blocker a little + pOther->TakeDamage(pev, pev, 1, DMG_CRUSH); + + if (pev->noiseMovement) + { + STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement)); + } + + // Send the platform back where it came from + assert(m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN); + + if (m_toggle_state == TS_GOING_UP) + { + GoDown(); + } + else if (m_toggle_state == TS_GOING_DOWN) + { + GoUp(); + } } /* <130a7b> ../cstrike/dlls/plats.cpp:533 */ @@ -250,53 +557,87 @@ LINK_ENTITY_TO_CLASS(func_platrot, CFuncPlatRot); IMPLEMENT_SAVERESTORE(CFuncPlatRot, CFuncPlat); /* <130b48> ../cstrike/dlls/plats.cpp:543 */ -NOBODY void CFuncPlatRot::SetupRotation(void) +void CFuncPlatRot::SetupRotation(void) { -// operator*(const Vector ::SetupRotation(// float fl); // 549 -// operator+(const Vector *const this, -// const Vector &v); // 549 + // This plat rotates too! + if (m_vecFinalAngle.x != 0) + { + CBaseToggle::AxisDir(pev); + m_start = pev->angles; + m_end = pev->angles + pev->movedir * m_vecFinalAngle.x; + } + else + { + m_start = g_vecZero; + m_end = g_vecZero; + } + + // Start at top + if (!FStringNull(pev->targetname)) + { + pev->angles = m_end; + } } /* <130bc4> ../cstrike/dlls/plats.cpp:563 */ -NOBODY void CFuncPlatRot::__MAKE_VHOOK(Spawn)(void) +void CFuncPlatRot::__MAKE_VHOOK(Spawn)(void) { -// Spawn(CFuncPlat *const this); // 565 + CFuncPlat::Spawn(); + SetupRotation(); } /* <12fe63> ../cstrike/dlls/plats.cpp:569 */ -NOBODY void CFuncPlatRot::__MAKE_VHOOK(GoDown)(void) +void CFuncPlatRot::__MAKE_VHOOK(GoDown)(void) { -// RotMove(CFuncPlatRot::GoDown(// Vector &destAngle, -// float time); // 572 + CFuncPlat::GoDown(); + RotMove(m_start, pev->nextthink - pev->ltime); } +// Platform has hit bottom. Stops and waits forever. + /* <12f430> ../cstrike/dlls/plats.cpp:579 */ -NOBODY void CFuncPlatRot::__MAKE_VHOOK(HitBottom)(void) +void CFuncPlatRot::__MAKE_VHOOK(HitBottom)(void) { + CFuncPlat::HitBottom(); + pev->avelocity = g_vecZero; + pev->angles = m_start; } +// Platform is at bottom, now starts moving up + /* <12fdad> ../cstrike/dlls/plats.cpp:590 */ -NOBODY void CFuncPlatRot::__MAKE_VHOOK(GoUp)(void) +void CFuncPlatRot::__MAKE_VHOOK(GoUp)(void) { -// RotMove(CFuncPlatRot::GoUp(// Vector &destAngle, -// float time); // 593 + CFuncPlat::GoUp(); + RotMove(m_end, pev->nextthink - pev->ltime); } +// Platform has hit top. Pauses, then starts back down again. + /* <12f502> ../cstrike/dlls/plats.cpp:600 */ -NOBODY void CFuncPlatRot::__MAKE_VHOOK(HitTop)(void) +void CFuncPlatRot::__MAKE_VHOOK(HitTop)(void) { + CFuncPlat::HitTop(); + pev->avelocity = g_vecZero; + pev->angles = m_end; } /* <130c54> ../cstrike/dlls/plats.cpp:608 */ -NOBODY void CFuncPlatRot::RotMove(Vector &destAngle, float time) +void CFuncPlatRot::RotMove(Vector &destAngle, float time) { -// { -// Vector vecDestDelta; // 611 -// operator-(const Vector *const this, -// const Vector &v); // 611 -// operator/(const Vector *const this, -// float fl); // 615 -// } + // set destdelta to the vector needed to move + Vector vecDestDelta = destAngle - pev->angles; + + // Travel time is so short, we're practically there already; so make it so. + if (time >= 0.1) + { + pev->avelocity = vecDestDelta / time; + } + else + { + pev->avelocity = vecDestDelta; + pev->nextthink = pev->ltime + 1; + } } /* <130ce8> ../cstrike/dlls/plats.cpp:657 */ @@ -306,125 +647,310 @@ LINK_ENTITY_TO_CLASS(func_train, CFuncTrain); IMPLEMENT_SAVERESTORE(CFuncTrain, CBasePlatTrain); /* <130390> ../cstrike/dlls/plats.cpp:668 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CFuncTrain::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 670 -// KeyValue(CBasePlatTrain *const this, -// KeyValueData *pkvd); // 676 -// KeyValue(CFuncTrain *const this, -// KeyValueData *pkvd); // 668 + if (FStrEq(pkvd->szKeyName, "sounds")) + { + m_sounds = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBasePlatTrain::KeyValue(pkvd); } /* <12de63> ../cstrike/dlls/plats.cpp:679 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) +void CFuncTrain::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) { -// Blocked(CFuncTrain *const this, -// class CBaseEntity *pOther); // 679 + if (gpGlobals->time < m_flActivateFinished) + return; + + m_flActivateFinished = gpGlobals->time + 0.5; + + pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); } - /* <12fa23> ../cstrike/dlls/plats.cpp:691 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CFuncTrain::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 708 + if (pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER) + { + // Move toward my target + pev->spawnflags &= ~SF_TRAIN_WAIT_RETRIGGER; + Next(); + } + else + { + pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER; + // Pop back to last target if it's available + if (pev->enemy) + { + pev->target = pev->enemy->v.targetname; + } + + pev->nextthink = 0; + pev->velocity = g_vecZero; + if (pev->noiseStopMoving) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + } + } } /* <12f914> ../cstrike/dlls/plats.cpp:713 */ -NOBODY void CFuncTrain::Wait(void) +void CFuncTrain::Wait(void) { -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 734 -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 732 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 747 -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 745 + if (m_pevCurrentTarget != NULL) + { + // Fire the pass target if there is one + if (m_pevCurrentTarget->message) + { + FireTargets(STRING(m_pevCurrentTarget->message), this, this, USE_TOGGLE, 0); + if (m_pevCurrentTarget->spawnflags & SF_CORNER_FIREONCE) + { + m_pevCurrentTarget->message = 0; + } + } + + // need pointer to LAST target. + if ((m_pevCurrentTarget->spawnflags & SF_TRAIN_WAIT_RETRIGGER) || (pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER)) + { + pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER; + + // clear the sound channel. + if (pev->noiseMovement) + { + STOP_SOUND(edict(), CHAN_STATIC, (char *)STRING(pev->noiseMovement)); + } + if (pev->noiseStopMoving) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + } + + pev->nextthink = 0; + return; + } + } + + if (m_flWait != 0) + { + // -1 wait will wait forever! + pev->nextthink = pev->ltime + m_flWait; + if (pev->noiseMovement) + { + STOP_SOUND(edict(), CHAN_STATIC, (char *)STRING(pev->noiseMovement)); + } + if (pev->noiseStopMoving) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + } + SetThink(&CFuncTrain::Next); + } + else + { + // do it RIGHT now! + Next(); + } } +// Train next - path corner needs to change to next target + /* <12f6a8> ../cstrike/dlls/plats.cpp:760 */ -NOBODY void CFuncTrain::Next(void) +void CFuncTrain::Next(void) { -// { -// class CBaseEntity *pTarg; // 762 -// edict(CBaseEntity *const this); // 791 -// operator+(const Vector *const this, -// const Vector &v); // 813 -// operator*(const Vector *const this, -// float fl); // 813 -// operator-(const Vector *const this, -// const Vector &v); // 813 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 774 -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 808 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 810 -// operator+(const Vector *const this, -// const Vector &v); // 797 -// operator*(const Vector *const this, -// float fl); // 797 -// operator-(const Vector *const this, -// const Vector &v); // 797 -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 771 -// } + CBaseEntity *pTarg; + + // now find our next target + pTarg = GetNextTarget(); + + if (!pTarg) + { + if (pev->noiseMovement) + { + STOP_SOUND(edict(), CHAN_STATIC, (char *)STRING(pev->noiseMovement)); + } + + // Play stop sound + if (pev->noiseStopMoving) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + } + + return; + } + + // Save last target in case we need to find it again + pev->message = pev->target; + + pev->target = pTarg->pev->target; + m_flWait = pTarg->GetDelay(); + + if (m_pevCurrentTarget != NULL && m_pevCurrentTarget->speed != 0) + { + // don't copy speed from target if it is 0 (uninitialized) + pev->speed = m_pevCurrentTarget->speed; + ALERT(at_aiconsole, "Train %s speed to %4.2f\n", STRING(pev->targetname), pev->speed); + } + + // keep track of this since path corners change our target for us. + m_pevCurrentTarget = pTarg->pev; + + //hack + pev->enemy = pTarg->edict(); + + if (m_pevCurrentTarget->spawnflags & SF_CORNER_TELEPORT) + { + // Path corner has indicated a teleport to the next corner. + pev->effects |= EF_NOINTERP; + + UTIL_SetOrigin(pev, pTarg->pev->origin - (pev->mins + pev->maxs) * 0.5); + + // Get on with doing the next path corner. + Wait(); + } + else + { + // Normal linear move. + // CHANGED this from CHAN_VOICE to CHAN_STATIC around OEM beta time because trains should + // use CHAN_STATIC for their movement sounds to prevent sound field problems. + // this is not a hack or temporary fix, this is how things should be. (sjb). + if (pev->noiseMovement) + { + STOP_SOUND(edict(), CHAN_STATIC, (char *)STRING(pev->noiseMovement)); + } + if (pev->noiseMovement) + { + EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMovement), m_volume, ATTN_NORM); + } + + pev->effects &= ~EF_NOINTERP; + SetMoveDone(&CFuncTrain::Wait); + LinearMove(pTarg->pev->origin - (pev->mins + pev->maxs) * 0.5, pev->speed); + } } /* <12e1fd> ../cstrike/dlls/plats.cpp:818 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(Activate)(void) +void CFuncTrain::__MAKE_VHOOK(Activate)(void) { -// { -// entvars_t *pevTarg; // 824 -// } -// Activate(CFuncTrain *const this); // 818 + // Not yet active, so teleport to first target + if (!m_activated) + { + m_activated = TRUE; + entvars_t *pevTarg = VARS(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); + + pev->target = pevTarg->target; + + // keep track of this since path corners change our target for us. + m_pevCurrentTarget = pevTarg; + + UTIL_SetOrigin(pev, pevTarg->origin - (pev->mins + pev->maxs) * 0.5); + + if (FStringNull(pev->targetname)) + { + // not triggered, so start immediately + pev->nextthink = pev->ltime + 0.1; + SetThink(&CFuncTrain::Next); + } + else + pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER; + } } +// QUAKED func_train (0 .5 .8) ? +// Trains are moving platforms that players can ride. +// The targets origin specifies the min point of the train at each corner. +// The train spawns at the first target it is pointing at. +// If the train is the target of a button or trigger, it will not begin moving until activated. +// speed default 100 +// dmg default 2 +// sounds +// 1) ratchet metal + /* <12dcad> ../cstrike/dlls/plats.cpp:852 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(Spawn)(void) +void CFuncTrain::__MAKE_VHOOK(Spawn)(void) { + Precache(); + + if (pev->speed == 0) + pev->speed = 100; + + if (FStringNull(pev->target)) + { + ALERT(at_console, "FuncTrain with no target"); + } + + m_pevFirstTarget = m_pevCurrentTarget; + m_vStartPosition = pev->origin; + + if (pev->dmg == 0) + pev->dmg = 2; + + pev->movetype = MOVETYPE_PUSH; + + if (pev->spawnflags & SF_TRACKTRAIN_PASSABLE) + pev->solid = SOLID_NOT; + else + pev->solid = SOLID_BSP; + + SET_MODEL(ENT(pev), STRING(pev->model)); + UTIL_SetSize(pev, pev->mins, pev->maxs); + UTIL_SetOrigin(pev, pev->origin); + + m_activated = FALSE; + + if (m_volume == 0) + m_volume = 0.85; } /* <12dab7> ../cstrike/dlls/plats.cpp:886 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(Restart)(void) +void CFuncTrain::__MAKE_VHOOK(Restart)(void) { + if (pev->speed == 0) + pev->speed = 100; + + if (pev->dmg == 0) + pev->dmg = 2; + + pev->movetype = MOVETYPE_PUSH; + m_pevCurrentTarget = m_pevFirstTarget; + + UTIL_SetOrigin(pev, m_vStartPosition); + + m_activated = FALSE; + + if (m_volume == 0) + m_volume = 0.85; } /* <12d734> ../cstrike/dlls/plats.cpp:907 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(Precache)(void) +void CFuncTrain::__MAKE_VHOOK(Precache)(void) { + CBasePlatTrain::Precache(); } /* <12e166> ../cstrike/dlls/plats.cpp:913 */ -NOBODY void CFuncTrain::__MAKE_VHOOK(OverrideReset)(void) +void CFuncTrain::__MAKE_VHOOK(OverrideReset)(void) { -// { -// class CBaseEntity *pTarg; // 915 -// operator!=(const Vector *const this, -// const Vector &v); // 918 -// } -// OverrideReset(CFuncTrain *const this); // 913 + CBaseEntity *pTarg; + + // Are we moving? + if (pev->velocity != g_vecZero && pev->nextthink != 0) + { + pev->target = pev->message; + + // now find our next target + pTarg = GetNextTarget(); + + if (!pTarg) + { + pev->nextthink = 0; + pev->velocity = g_vecZero; + } + else // Keep moving for 0.1 secs, then find path_corner again and restart + { + SetThink(&CFuncTrain::Next); + pev->nextthink = pev->ltime + 0.1; + } + } } /* <12e0cd> ../cstrike/dlls/plats.cpp:961 */ @@ -434,54 +960,144 @@ IMPLEMENT_SAVERESTORE(CFuncTrackTrain, CBaseEntity); LINK_ENTITY_TO_CLASS(func_tracktrain, CFuncTrackTrain); /* <12e88e> ../cstrike/dlls/plats.cpp:964 */ -NOBODY void CFuncTrackTrain::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CFuncTrackTrain::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 966 -// FStrEq(const char *sz1, -// const char *sz2); // 971 -// KeyValue(CFuncTrackTrain *const this, -// KeyValueData *pkvd); // 964 -// atof(const char *__nptr); // 968 -// atof(const char *__nptr); // 973 + if (FStrEq(pkvd->szKeyName, "wheels")) + { + m_length = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "height")) + { + m_height = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "startspeed")) + { + m_startSpeed = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "sounds")) + { + m_sounds = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "volume")) + { + m_flVolume = (float)Q_atoi(pkvd->szValue); + m_flVolume *= 0.1; + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "bank")) + { + m_flBank = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } /* <130e82> ../cstrike/dlls/plats.cpp:1002 */ -NOBODY void CFuncTrackTrain::NextThink(float thinkTime, BOOL alwaysThink) +void CFuncTrackTrain::NextThink(float thinkTime, BOOL alwaysThink) { + if (alwaysThink) + pev->flags |= FL_ALWAYSTHINK; + else + pev->flags &= ~FL_ALWAYSTHINK; + + pev->nextthink = thinkTime; } /* <12ee6d> ../cstrike/dlls/plats.cpp:1013 */ -NOBODY void CFuncTrackTrain::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) +void CFuncTrackTrain::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) { -// { -// entvars_t *pevOther; // 1015 -// VARS(edict_t *pent); // 1018 -// operator-(const Vector *const this, -// const Vector &v); // 1028 -// Normalize(const Vector *const this); // 1028 -// operator*(const Vector *const this, -// float fl); // 1028 -// { -// float deltaSpeed; // 1020 -// fabs(double __x); // 1020 -// } -// } + entvars_t *pevOther = pOther->pev; + + // Blocker is on-ground on the train + if ((pevOther->flags & FL_ONGROUND) && VARS(pevOther->groundentity) == pev) + { + float_precision deltaSpeed = fabs((float_precision)pev->speed); + + if (deltaSpeed > 50) + { + deltaSpeed = 50; + } + + if (!pevOther->velocity.z) + { + pevOther->velocity.z += deltaSpeed; + } + + return; + } + else + pevOther->velocity = (pevOther->origin - pev->origin).Normalize() * pev->dmg; + + ALERT(at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING(pev->targetname), STRING(pOther->pev->classname), pev->dmg); + + // TODO: is missing? +#if 0 + if (pev->dmg <= 0) + return; + + // we can't hurt this thing, so we're not concerned with it + pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); + +#endif } /* <1312c7> ../cstrike/dlls/plats.cpp:1038 */ -NOBODY void CFuncTrackTrain::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CFuncTrackTrain::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// float delta; // 1062 -// } + if (useType != USE_SET) + { + if (!ShouldToggle(useType, (pev->speed != 0))) + return; + + if (pev->speed == 0) + { + pev->speed = m_speed * m_dir; + Next(); + } + else + { + pev->speed = 0; + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + StopSound(); + SetThink(NULL); + } + } + else + { + float_precision delta = ((int)(pev->speed * 4) / (int)m_speed) * 0.25 + 0.25 * value; + + if (delta > 1) + delta = 1; + + else if (delta < -1) + delta = -1; + + if (pev->spawnflags & SF_TRACKTRAIN_FORWARDONLY) + { + if (delta < 0) + delta = 0; + } + + pev->speed = m_speed * delta; + Next(); + ALERT(at_aiconsole, "TRAIN(%s), speed to %.2f\n", STRING(pev->targetname), pev->speed); + } } /* <12bc89> ../cstrike/dlls/plats.cpp:1082 */ -NOBODY float Fix(float angle) +float_precision Fix(float_precision v) { + float_precision angle = v; + while (angle < 0) angle += 360; + while (angle > 360) angle -= 360; @@ -489,7 +1105,7 @@ NOBODY float Fix(float angle) } /* <130f04> ../cstrike/dlls/plats.cpp:1093 */ -NOBODY void FixupAngles(Vector &v) +void FixupAngles(Vector &v) { v.x = Fix(v.x); v.y = Fix(v.y); @@ -497,224 +1113,571 @@ NOBODY void FixupAngles(Vector &v) } /* <130eb3> ../cstrike/dlls/plats.cpp:1104 */ -NOBODY void CFuncTrackTrain::StopSound(void) +void CFuncTrackTrain::StopSound(void) { -// { -// short unsigned int us_encode; // 1109 -// short unsigned int us_sound; // 1110 -// } + // if sound playing, stop it + if (m_soundPlaying && pev->noise) + { + unsigned short us_encode; + unsigned short us_sound = ((unsigned short)(m_sounds) & 0x0007) << 12; + + us_encode = us_sound; + + PLAYBACK_EVENT_FULL(FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 1, 0); + EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "plats/ttrain_brake1.wav", m_flVolume, ATTN_NORM, 0, 100); + } + + m_soundPlaying = 0; } /* <12e31d> ../cstrike/dlls/plats.cpp:1130 */ -NOBODY void CFuncTrackTrain::UpdateSound(void) +void CFuncTrackTrain::UpdateSound(void) { -// { -// float flpitch; // 1132 -// { -// short unsigned int us_encode; // 1157 -// short unsigned int us_sound; // 1158 -// short unsigned int us_pitch; // 1159 -// short unsigned int us_volume; // 1160 -// } -// } + float flpitch; + + if (!pev->noise) + return; + + flpitch = TRAIN_STARTPITCH + (abs(pev->speed) * (TRAIN_MAXPITCH - TRAIN_STARTPITCH) / TRAIN_MAXSPEED); + + if (!m_soundPlaying) + { + // play startup sound for train + EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "plats/ttrain_start1.wav", m_flVolume, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noise), m_flVolume, ATTN_NORM, 0, (int)flpitch); + m_soundPlaying = 1; + } + else + { + // update pitch + // EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noise), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch); + + // volume 0.0 - 1.0 - 6 bits + // m_sounds 3 bits + // flpitch = 6 bits + // 15 bits total + + unsigned short us_encode; + unsigned short us_sound = ((unsigned short)(m_sounds) & 0x0007) << 12; + unsigned short us_pitch = ((unsigned short)(flpitch / 10.0) & 0x003f) << 6; + unsigned short us_volume = ((unsigned short)(m_flVolume * 40.0) & 0x003f); + + us_encode = us_sound | us_pitch | us_volume; + + PLAYBACK_EVENT_FULL(FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 0, 0); + } } /* <130f1c> ../cstrike/dlls/plats.cpp:1171 */ -NOBODY void CFuncTrackTrain::Next(void) +void CFuncTrackTrain::Next(void) { -// { -// float time; // 1173 -// Vector nextPos; // 1195 -// class CPathTrack *pnext; // 1198 -// Vector nextFront; // 1202 -// Vector delta; // 1211 -// Vector angles; // 1212 -// float vy; // 1223 -// float vx; // 1223 -// UpdateSound(CFuncTrackTrain *const this); // 1193 -// Vector(Vector *const this, -// const Vector &v); // 1195 -// operator-(const Vector *const this, -// const Vector &v); // 1201 -// operator*(const Vector *const this, -// float fl); // 1201 -// Vector(Vector *const this, -// const Vector &v); // 1202 -// operator-(const Vector *const this, -// const Vector &v); // 1211 -// FixupAngles(Vector &v); // 1217 -// FixupAngles(Vector &v); // 1218 -// { -// class CPathTrack *pFire; // 1247 -// } -// NextThink(CFuncTrackTrain *const this, -// float thinkTime, -// BOOL alwaysThink); // 1276 -// { -// float distance; // 1283 -// operator-(const Vector *const this, -// const Vector &v); // 1281 -// Length(const Vector *const this); // 1283 -// operator*(const Vector *const this, -// float fl); // 1296 -// NextThink(CFuncTrackTrain *const this, -// float thinkTime, -// BOOL alwaysThink); // 1298 -// } -// } + float time = 0.5; + + if (!pev->speed) + { + ALERT(at_aiconsole, "TRAIN(%s): Speed is 0\n", STRING(pev->targetname)); + StopSound(); + return; + } + + if (!m_ppath) + { + ALERT(at_aiconsole, "TRAIN(%s): Lost path\n", STRING(pev->targetname)); + StopSound(); + return; + } + + UpdateSound(); + + Vector nextPos = pev->origin; + + nextPos.z -= m_height; + CPathTrack *pnext = m_ppath->LookAhead(&nextPos, pev->speed * 0.1, 1); + nextPos.z += m_height; + +#if 0 + pev->velocity = (nextPos - pev->origin) * 10; +#else + // TODO: fix test demo + pev->velocity.x = ((float_precision)(nextPos.x - pev->origin.x) * 10.0f); + pev->velocity.y = ((float_precision)(nextPos.y - pev->origin.y) * 10.0f); + pev->velocity.z = ((nextPos.z - pev->origin.z) * 10.0f); +#endif + + Vector nextFront = pev->origin; + nextFront.z -= m_height; + + if (m_length > 0) + m_ppath->LookAhead(&nextFront, m_length, 0); + else + m_ppath->LookAhead(&nextFront, 100, 0); + + nextFront.z += m_height; + + Vector delta = nextFront - pev->origin; + Vector angles = UTIL_VecToAngles(delta); + + float_precision fixAngleY = angles.y + 180.0f; + + // The train actually points west + angles.y += fixAngleY; + + // !!! All of this crap has to be done to make the angles not wrap around, revisit this. +#if 0 + FixupAngles(angles); + FixupAngles(pev->angles); +#else + angles.x = Fix(angles.x); + angles.y = Fix(fixAngleY); // TODO: fix test demo + angles.z = Fix(angles.z); + + FixupAngles(pev->angles); +#endif + if (!pnext || (delta.x == 0 && delta.y == 0)) + angles = pev->angles; + + float vy, vx; + if (!(pev->spawnflags & SF_TRACKTRAIN_NOPITCH)) + vx = UTIL_AngleDistance(angles.x, pev->angles.x); + else + vx = 0; + + vy = UTIL_AngleDistance(angles.y, pev->angles.y); + + pev->avelocity.y = vy * 10; + pev->avelocity.x = vx * 10; + + if (m_flBank != 0) + { + double dbl_v33 = m_flBank; + + if (pev->avelocity.y < -5) + { + pev->avelocity.z = UTIL_AngleDistance(UTIL_ApproachAngle(-m_flBank, pev->angles.z, m_flBank * 2), pev->angles.z); + } + else if (pev->avelocity.y > 5) + { + pev->avelocity.z = UTIL_AngleDistance(UTIL_ApproachAngle(m_flBank, pev->angles.z, m_flBank * 2), pev->angles.z); + } + else + { + pev->avelocity.z = UTIL_AngleDistance(UTIL_ApproachAngle(0, pev->angles.z, m_flBank * 4), pev->angles.z) * 4; + } + } + + if (pnext != NULL) + { + if (pnext != m_ppath) + { + CPathTrack *pFire; + if (pev->speed >= 0) + pFire = pnext; + else + pFire = m_ppath; + + m_ppath = pnext; + + // Fire the pass target if there is one + if (!FStringNull(pFire->pev->message)) + { + FireTargets(STRING(pFire->pev->message), this, this, USE_TOGGLE, 0); + + if (pFire->pev->spawnflags & SF_PATH_FIREONCE) + { + pFire->pev->message = 0; + } + } + + if (pFire->pev->spawnflags & SF_PATH_DISABLE_TRAIN) + { + pev->spawnflags |= SF_TRACKTRAIN_NOCONTROL; + } + + // Don't override speed if under user control + if (pev->spawnflags & SF_TRACKTRAIN_NOCONTROL) + { + if (pFire->pev->speed != 0) + { + // don't copy speed from target if it is 0 (uninitialized) + pev->speed = pFire->pev->speed; + ALERT(at_aiconsole, "TrackTrain %s speed to %4.2f\n", STRING(pev->targetname), pev->speed); + } + } + } + + SetThink(&CFuncTrackTrain::Next); + NextThink(pev->ltime + time, TRUE); + } + else // end of path, stop + { + StopSound(); + pev->velocity = (nextPos - pev->origin); + pev->avelocity = g_vecZero; + + float distance = pev->velocity.Length(); + m_oldSpeed = pev->speed; + pev->speed = 0; + + // Move to the dead end + + // Are we there yet? + if (distance > 0) + { + // no, how long to get there? + time = distance / m_oldSpeed; + pev->velocity = pev->velocity * (m_oldSpeed / distance); + SetThink(&CFuncTrackTrain::DeadEnd); + NextThink(pev->ltime + time, FALSE); + } + else + { + DeadEnd(); + } + } } /* <12de16> ../cstrike/dlls/plats.cpp:1308 */ -NOBODY void CFuncTrackTrain::DeadEnd(void) +void CFuncTrackTrain::DeadEnd(void) { -// { -// class CPathTrack *pTrack; // 1311 -// class CPathTrack *pNext; // 1311 -// } + // Fire the dead-end target if there is one + CPathTrack *pTrack, *pNext; + + pTrack = m_ppath; + + ALERT(at_aiconsole, "TRAIN(%s): Dead end ", STRING(pev->targetname)); + + // Find the dead end path node + // HACKHACK -- This is bugly, but the train can actually stop moving at a different node depending on it's speed + // so we have to traverse the list to it's end. + if (pTrack != NULL) + { + if (m_oldSpeed < 0) + { + do + { + pNext = pTrack->ValidPath(pTrack->GetPrevious(), TRUE); + + if (pNext) + { + pTrack = pNext; + } + } + while (pNext != NULL); + } + else + { + do + { + pNext = pTrack->ValidPath(pTrack->GetNext(), TRUE); + + if (pNext) + { + pTrack = pNext; + } + } + while (pNext != NULL); + } + } + + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + + if (pTrack != NULL) + { + ALERT(at_aiconsole, "at %s\n", STRING(pTrack->pev->targetname)); + + if (!FStringNull(pTrack->pev->netname)) + { + FireTargets(STRING(pTrack->pev->netname), this, this, USE_TOGGLE, 0); + } + } + else + ALERT(at_aiconsole, "\n"); } /* <131370> ../cstrike/dlls/plats.cpp:1354 */ -NOBODY void CFuncTrackTrain::SetControls(entvars_t *pevControls) +void CFuncTrackTrain::SetControls(entvars_t *pevControls) { -// { -// Vector offset; // 1356 -// operator-(const Vector *const this, -// const Vector &v); // 1356 -// operator+(const Vector *const this, -// const Vector &v); // 1358 -// operator+(const Vector *const this, -// const Vector &v); // 1359 -// } + Vector offset = pevControls->origin - pev->oldorigin; + + m_controlMins = pevControls->mins + offset; + m_controlMaxs = pevControls->maxs + offset; } /* <12dd23> ../cstrike/dlls/plats.cpp:1363 */ -NOBODY BOOL CFuncTrackTrain::__MAKE_VHOOK(OnControls)(entvars_t *pevTest) +BOOL CFuncTrackTrain::__MAKE_VHOOK(OnControls)(entvars_t *pevTest) { -// { -// Vector offset; // 1365 -// Vector local; // 1372 -// operator-(const Vector *const this, -// const Vector &v); // 1365 -// DotProduct(Vector &a, -// const Vector &b); // 1373 -// DotProduct(Vector &a, -// const Vector &b); // 1374 -// DotProduct(Vector &a, -// const Vector &b); // 1375 -// } + Vector offset = pevTest->origin - pev->origin; + + if (pev->spawnflags & SF_TRACKTRAIN_NOCONTROL) + return FALSE; + + // Transform offset into local coordinates + UTIL_MakeVectors(pev->angles); + Vector local; + + local.x = DotProduct(offset, gpGlobals->v_forward); + local.y = -DotProduct(offset, gpGlobals->v_right); + local.z = DotProduct(offset, gpGlobals->v_up); + + if (local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z && + local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z) + return TRUE; + + return FALSE; } /* <12e636> ../cstrike/dlls/plats.cpp:1385 */ -NOBODY void CFuncTrackTrain::Find(void) +void CFuncTrackTrain::Find(void) { -// { -// entvars_t *pevTarget; // 1391 -// Vector nextPos; // 1399 -// Vector look; // 1402 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1387 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 1392 -// Vector(Vector *const this, -// const Vector &v); // 1399 -// Vector(Vector *const this, -// const Vector &v); // 1402 -// operator-(const Vector *const this, -// const Vector &v); // 1407 -// NextThink(CFuncTrackTrain *const this, -// float thinkTime, -// BOOL alwaysThink); // 1414 -// UpdateSound(CFuncTrackTrain *const this); // 1418 -// } + m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); + + if (!m_ppath) + { + return; + } + + entvars_t *pevTarget = m_ppath->pev; + if (!FClassnameIs(pevTarget, "path_track")) + { + ALERT(at_error, "func_track_train must be on a path of path_track\n"); + m_ppath = NULL; + return; + } + + Vector nextPos = pevTarget->origin; + nextPos.z += m_height; + + Vector look = nextPos; + look.z -= m_height; + + m_ppath->LookAhead(&look, m_length, 0); + look.z += m_height; + + pev->angles = UTIL_VecToAngles(look - nextPos); + // The train actually points west + pev->angles.y += 180; + + if (pev->spawnflags & SF_TRACKTRAIN_NOPITCH) + { + pev->angles.x = 0; + } + + UTIL_SetOrigin(pev, nextPos); + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncTrackTrain::Next); + pev->speed = m_startSpeed; + + UpdateSound(); } /* <12ecdd> ../cstrike/dlls/plats.cpp:1422 */ -NOBODY void CFuncTrackTrain::NearestPath(void) +void CFuncTrackTrain::NearestPath(void) { -// { -// class CBaseEntity *pTrack; // 1424 -// class CBaseEntity *pNearest; // 1425 -// float dist; // 1426 -// float closest; // 1426 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 1433 -// operator-(const Vector *const this, -// const Vector &v); // 1435 -// Length(const Vector *const this); // 1435 -// operator-(const Vector *const this, -// const Vector &v); // 1456 -// Length(const Vector *const this); // 1456 -// operator-(const Vector *const this, -// const Vector &v); // 1456 -// Length(const Vector *const this); // 1456 -// NextThink(CFuncTrackTrain *const this, -// float thinkTime, -// BOOL alwaysThink); // 1464 -// } + CBaseEntity *pTrack = NULL; + CBaseEntity *pNearest = NULL; + float_precision dist; + float closest; + + closest = 1024; + + while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024)) != NULL) + { + // filter out non-tracks + if (!(pTrack->pev->flags & (FL_CLIENT | FL_MONSTER)) && FClassnameIs(pTrack->pev, "path_track")) + { + dist = (pev->origin - pTrack->pev->origin).Length(); + + if (dist < closest) + { + closest = dist; + pNearest = pTrack; + } + } + } + + if (!pNearest) + { + ALERT(at_console, "Can't find a nearby track !!!\n"); + SetThink(NULL); + return; + } + + ALERT(at_aiconsole, "TRAIN: %s, Nearest track is %s\n", STRING(pev->targetname), STRING(pNearest->pev->targetname)); + + // If I'm closer to the next path_track on this path, then it's my real path + pTrack = ((CPathTrack *)pNearest)->GetNext(); + + if (pTrack != NULL) + { + if ((pev->origin - pTrack->pev->origin).Length() < (pev->origin - pNearest->pev->origin).Length()) + { + pNearest = pTrack; + } + } + + m_ppath = reinterpret_cast(pNearest); + + if (pev->speed != 0) + { + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncTrackTrain::Next); + } } /* <12d75a> ../cstrike/dlls/plats.cpp:1470 */ -NOBODY void CFuncTrackTrain::__MAKE_VHOOK(OverrideReset)(void) +void CFuncTrackTrain::__MAKE_VHOOK(OverrideReset)(void) { -// NextThink(CFuncTrackTrain::OverrideReset(// float thinkTime, -// BOOL alwaysThink); // 1472 + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncTrackTrain::NearestPath); } /* <131434> ../cstrike/dlls/plats.cpp:1477 */ -NOBODY CFuncTrackTrain *CFuncTrackTrain::Instance(edict_t *pent) +CFuncTrackTrain *CFuncTrackTrain::Instance(edict_t *pent) { -// FClassnameIs(edict_t *pent, -// const char *szClassname); // 1479 -// GET_PRIVATE(edict_t *pent); // 1480 + if (FClassnameIs(pent, "func_tracktrain")) + { + return (CFuncTrackTrain *)GET_PRIVATE(pent); + } + + return NULL; } /* <12dcd4> ../cstrike/dlls/plats.cpp:1495 */ -NOBODY void CFuncTrackTrain::__MAKE_VHOOK(Spawn)(void) +void CFuncTrackTrain::__MAKE_VHOOK(Spawn)(void) { -// NextThink(CFuncTrackTrain::Spawn(// float thinkTime, -// BOOL alwaysThink); // 1533 + if (pev->speed == 0) + m_speed = 165; + else + m_speed = pev->speed; + + ALERT(at_console, "M_speed = %f\n", m_speed); + + pev->speed = 0; + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + pev->impulse = (int)m_speed; + + m_dir = 1; + + if (FStringNull(pev->target)) + { + ALERT(at_console, "FuncTrain with no target"); + } + + if (pev->spawnflags & SF_TRACKTRAIN_PASSABLE) + pev->solid = SOLID_NOT; + else + pev->solid = SOLID_BSP; + + pev->movetype = MOVETYPE_PUSH; + SET_MODEL(ENT(pev), STRING(pev->model)); + + UTIL_SetSize(pev, pev->mins, pev->maxs); + UTIL_SetOrigin(pev, pev->origin); + + // Cache off placed origin for train controls + pev->oldorigin = pev->origin; + + m_controlMins = pev->mins; + m_controlMaxs = pev->maxs; + m_controlMaxs.z += 72; + + // start trains on the next frame, to make sure their targets have had + // a chance to spawn/activate + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncTrackTrain::Find); + Precache(); } /* <12dbdf> ../cstrike/dlls/plats.cpp:1539 */ -NOBODY void CFuncTrackTrain::__MAKE_VHOOK(Restart)(void) +void CFuncTrackTrain::__MAKE_VHOOK(Restart)(void) { -// NextThink(CFuncTrackTrain::Restart(// float thinkTime, -// BOOL alwaysThink); // 1557 + ALERT(at_console, "M_speed = %f\n", m_speed); + + pev->speed = 0; + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + pev->impulse = (int)m_speed; + m_dir = 1; + + if (FStringNull(pev->target)) + { + ALERT(at_console, "FuncTrain with no target"); + } + + UTIL_SetOrigin(pev, pev->oldorigin); + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncTrackTrain::Find); } /* <12d7a5> ../cstrike/dlls/plats.cpp:1562 */ -NOBODY void CFuncTrackTrain::__MAKE_VHOOK(Precache)(void) +void CFuncTrackTrain::__MAKE_VHOOK(Precache)(void) { + if (m_flVolume == 0.0) + m_flVolume = 1.0; + + switch (m_sounds) + { + default: + // no sound + pev->noise = 0; + break; + case 1: PRECACHE_SOUND("plats/ttrain1.wav"); pev->noise = MAKE_STRING("plats/ttrain1.wav");break; + case 2: PRECACHE_SOUND("plats/ttrain2.wav"); pev->noise = MAKE_STRING("plats/ttrain2.wav");break; + case 3: PRECACHE_SOUND("plats/ttrain3.wav"); pev->noise = MAKE_STRING("plats/ttrain3.wav");break; + case 4: PRECACHE_SOUND("plats/ttrain4.wav"); pev->noise = MAKE_STRING("plats/ttrain4.wav");break; + case 5: PRECACHE_SOUND("plats/ttrain6.wav"); pev->noise = MAKE_STRING("plats/ttrain6.wav");break; + case 6: PRECACHE_SOUND("plats/ttrain7.wav"); pev->noise = MAKE_STRING("plats/ttrain7.wav");break; + } + + PRECACHE_SOUND("plats/ttrain_brake1.wav"); + PRECACHE_SOUND("plats/ttrain_start1.wav"); + + m_usAdjustPitch = PRECACHE_EVENT(1, "events/train.sc"); } /* <1314d9> ../cstrike/dlls/plats.cpp:1595 */ LINK_ENTITY_TO_CLASS(func_traincontrols, CFuncTrainControls); /* <12fb10> ../cstrike/dlls/plats.cpp:1598 */ -NOBODY void CFuncTrainControls::Find(void) +void CFuncTrainControls::Find(void) { -// { -// edict_t *pTarget; // 1600 -// class CFuncTrackTrain *ptrain; // 1613 -// Instance(edict_t *pent); // 1613 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1604 -// FNullEnt(const edict_t *pent); // 1605 -// FNullEnt(const edict_t *pent); // 1607 -// SetControls(CFuncTrackTrain *const this, -// entvars_t *pevControls); // 1614 -// FClassnameIs(edict_t *pent, -// const char *szClassname); // 1605 -// } + edict_t *pTarget = NULL; + + do + { + pTarget = FIND_ENTITY_BY_TARGETNAME(pTarget, STRING(pev->target)); + } + while (!FNullEnt(pTarget) && !FClassnameIs(pTarget, "func_tracktrain")); + + if (FNullEnt(pTarget)) + { + ALERT(at_console, "No train %s\n", STRING(pev->target)); + return; + } + + CFuncTrackTrain *ptrain = CFuncTrackTrain::Instance(pTarget); + ptrain->SetControls(pev); + UTIL_Remove(this); } /* <12dc86> ../cstrike/dlls/plats.cpp:1619 */ -NOBODY void CFuncTrainControls::__MAKE_VHOOK(Spawn)(void) +void CFuncTrainControls::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + SET_MODEL(ENT(pev), STRING(pev->model)); + + UTIL_SetSize(pev, pev->mins, pev->maxs); + UTIL_SetOrigin(pev, pev->origin); + + SetThink(&CFuncTrainControls::Find); + pev->nextthink = gpGlobals->time; } /* <12d7f2> ../cstrike/dlls/plats.cpp:1673 */ -NOBODY BOOL CFuncTrackChange::__MAKE_VHOOK(IsTogglePlat)(void) +BOOL CFuncTrackChange::__MAKE_VHOOK(IsTogglePlat)(void) { return TRUE; } @@ -726,187 +1689,451 @@ LINK_ENTITY_TO_CLASS(func_trackchange, CFuncTrackChange); IMPLEMENT_SAVERESTORE(CFuncTrackChange, CFuncPlatRot); /* <130c1d> ../cstrike/dlls/plats.cpp:1715 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(Spawn)(void) +void CFuncTrackChange::__MAKE_VHOOK(Spawn)(void) { -// EnableUse(CFuncTrackChange *const this); // 1738 + Setup(); + if (pev->spawnflags & SF_TRACK_DONT_MOVE) + { + m_vecPosition2.z = pev->origin.z; + } + + SetupRotation(); + + if (pev->spawnflags & SF_TRACK_STARTBOTTOM) + { + UTIL_SetOrigin(pev, m_vecPosition2); + m_toggle_state = TS_AT_BOTTOM; + pev->angles = m_start; + m_targetState = TS_AT_TOP; + } + else + { + UTIL_SetOrigin(pev, m_vecPosition1); + m_toggle_state = TS_AT_TOP; + pev->angles = m_end; + m_targetState = TS_AT_BOTTOM; + } + + EnableUse(); + pev->nextthink = pev->ltime + 2.0; + SetThink(&CFuncTrackChange::Find); + Precache(); } /* <130a3b> ../cstrike/dlls/plats.cpp:1744 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(Precache)(void) +void CFuncTrackChange::__MAKE_VHOOK(Precache)(void) { -// Precache(CFuncPlat *const this); // 1749 + // Can't trigger sound + PRECACHE_SOUND("buttons/button11.wav"); + + CFuncPlatRot::Precache(); } +// UNDONE: Filter touches before re-evaluating the train. + /* <12d818> ../cstrike/dlls/plats.cpp:1753 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +void CFuncTrackChange::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { +#if 0 + TRAIN_CODE code; + entvars_t *pevToucher = pOther->pev; +#endif } /* <1304ca> ../cstrike/dlls/plats.cpp:1758 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CFuncTrackChange::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 1760 -// FStrEq(const char *sz1, -// const char *sz2); // 1765 -// KeyValue(CFuncTrackChange *const this, -// KeyValueData *pkvd); // 1758 + if (FStrEq(pkvd->szKeyName, "train")) + { + m_trainName = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "toptrack")) + { + m_trackTopName = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "bottomtrack")) + { + m_trackBottomName = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + { + // Pass up to base class + CFuncPlatRot::KeyValue(pkvd); + } } /* <12d84d> ../cstrike/dlls/plats.cpp:1782 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(OverrideReset)(void) +void CFuncTrackChange::__MAKE_VHOOK(OverrideReset)(void) { + pev->nextthink = pev->ltime + 1.0; + SetThink(&CFuncTrackChange::Find); } /* <12ff19> ../cstrike/dlls/plats.cpp:1788 */ -NOBODY void CFuncTrackChange::Find(void) +void CFuncTrackChange::Find(void) { -// { -// edict_t *target; // 1791 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1793 -// FNullEnt(const edict_t *pent); // 1794 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1797 -// FNullEnt(const edict_t *pent); // 1798 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1801 -// FNullEnt(const edict_t *pent); // 1802 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1820 -// { -// Vector center; // 1810 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1804 -// Instance(edict_t *pent); // 1804 -// operator+(const Vector *const this, -// const Vector &v); // 1810 -// operator*(const Vector *const this, -// float fl); // 1810 -// Vector(Vector *const this, -// const Vector &v); // 1811 -// Vector(Vector *const this, -// const Vector &v); // 1812 -// } -// } + // Find track entities + edict_t *target; + + target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trackTopName)); + if (!FNullEnt(target)) + { + m_trackTop = CPathTrack::Instance(target); + target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trackBottomName)); + + if (!FNullEnt(target)) + { + m_trackBottom = CPathTrack::Instance(target); + target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trainName)); + + if (!FNullEnt(target)) + { + m_train = CFuncTrackTrain::Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trainName))); + + if (!m_train) + { + ALERT(at_error, "Can't find train for track change! %s\n", STRING(m_trainName)); + return; + } + + Vector center = (pev->absmin + pev->absmax) * 0.5; + m_trackBottom = m_trackBottom->Nearest(center); + m_trackTop = m_trackTop->Nearest(center); + UpdateAutoTargets(m_toggle_state); + SetThink(NULL); + return; + } + else + { + ALERT(at_error, "Can't find train for track change! %s\n", STRING(m_trainName)); + target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trainName)); + } + } + else + ALERT(at_error, "Can't find bottom track for track change! %s\n", STRING(m_trackBottomName)); + } + else + ALERT(at_error, "Can't find top track for track change! %s\n", STRING(m_trackTopName)); } /* <131673> ../cstrike/dlls/plats.cpp:1832 */ -NOBODY TRAIN_CODE CFuncTrackChange::EvaluateTrain(CPathTrack *pcurrent) +TRAIN_CODE CFuncTrackChange::EvaluateTrain(CPathTrack *pcurrent) { -// { -// Vector dist; // 1844 -// float length; // 1845 -// } -// EvaluateTrain(CFuncTrackChange *const this, -// class CPathTrack *pcurrent); // 1832 + // Go ahead and work, we don't have anything to switch, so just be an elevator + if (!pcurrent || !m_train) + return TRAIN_SAFE; + + if (m_train->m_ppath == pcurrent || (pcurrent->m_pprevious && m_train->m_ppath == pcurrent->m_pprevious) || + (pcurrent->m_pnext && m_train->m_ppath == pcurrent->m_pnext)) + { + if (m_train->pev->speed != 0) + return TRAIN_BLOCKING; + + Vector dist = pev->origin - m_train->pev->origin; + float_precision length = dist.Length2D(); + + // Empirically determined close distance + if (length < m_train->m_length) + return TRAIN_FOLLOWING; + + else if (length > (150 + m_train->m_length)) + return TRAIN_SAFE; + + return TRAIN_BLOCKING; + } + + return TRAIN_SAFE; + } /* <1317f9> ../cstrike/dlls/plats.cpp:1858 */ -NOBODY void CFuncTrackChange::UpdateTrain(Vector &dest) +void CFuncTrackChange::UpdateTrain(Vector &dest) { -// { -// float time; // 1860 -// Vector offset; // 1870 -// Vector delta; // 1871 -// Vector local; // 1874 -// NextThink(CFuncTrackTrain *const this, -// float thinkTime, -// BOOL alwaysThink); // 1864 -// operator-(const Vector *const this, -// const Vector &v); // 1870 -// operator-(const Vector *const this, -// const Vector &v); // 1871 -// DotProduct(Vector &a, -// const Vector &b); // 1877 -// operator-(const Vector *const this, -// const Vector &v); // 1879 -// operator*(const Vector *const this, -// float fl); // 1880 -// operator+(const Vector *const this, -// const Vector &v); // 1880 -// DotProduct(Vector &a, -// const Vector &b); // 1876 -// DotProduct(Vector &a, -// const Vector &b); // 1875 -// } + float_precision time = (pev->nextthink - pev->ltime); + + m_train->pev->velocity = pev->velocity; + m_train->pev->avelocity = pev->avelocity; + m_train->NextThink(m_train->pev->ltime + time, FALSE); + + // Attempt at getting the train to rotate properly around the origin of the trackchange + if (time <= 0) + return; + + Vector offset = m_train->pev->origin - pev->origin; + Vector delta = dest - pev->angles; + + // Transform offset into local coordinates + UTIL_MakeInvVectors(delta, gpGlobals); + + Vector local; + local.x = DotProduct(offset, gpGlobals->v_forward); + local.y = DotProduct(offset, gpGlobals->v_right); + local.z = DotProduct(offset, gpGlobals->v_up); + + local = local - offset; + m_train->pev->velocity = pev->velocity + (local * (1.0 / time)); } /* <131ade> ../cstrike/dlls/plats.cpp:1883 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(GoDown)(void) +void CFuncTrackChange::__MAKE_VHOOK(GoDown)(void) { -// GoDown(CFuncTrackChange *const this); // 1883 + if (m_code == TRAIN_BLOCKING) + return; + + // HitBottom may get called during CFuncPlat::GoDown(), so set up for that + // before you call GoDown() + UpdateAutoTargets(TS_GOING_DOWN); + + // If ROTMOVE, move & rotate + if (pev->spawnflags & SF_TRACK_DONT_MOVE) + { + SetMoveDone(&CFuncTrackChange::CallHitBottom); + m_toggle_state = TS_GOING_DOWN; + AngularMove(m_start, pev->speed); + } + else + { + CFuncPlat::GoDown(); + SetMoveDone(&CFuncTrackChange::CallHitBottom); + RotMove(m_start, pev->nextthink - pev->ltime); + } + + // Otherwise, rotate first, move second + // If the train is moving with the platform, update it + if (m_code == TRAIN_FOLLOWING) + { + UpdateTrain(m_start); + m_train->m_ppath = NULL; + } } +// Platform is at bottom, now starts moving up + /* <1319f9> ../cstrike/dlls/plats.cpp:1919 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(GoUp)(void) +void CFuncTrackChange::__MAKE_VHOOK(GoUp)(void) { -// GoUp(CFuncTrackChange *const this); // 1919 + if (m_code == TRAIN_BLOCKING) + return; + + // HitTop may get called during CFuncPlat::GoUp(), so set up for that + // before you call GoUp(); + + UpdateAutoTargets(TS_GOING_UP); + if (pev->spawnflags & SF_TRACK_DONT_MOVE) + { + m_toggle_state = TS_GOING_UP; + SetMoveDone(&CFuncTrackChange::CallHitTop); + AngularMove(m_end, pev->speed); + } + else + { + // If ROTMOVE, move & rotate + CFuncPlat::GoUp(); + SetMoveDone(&CFuncTrackChange::CallHitTop); + RotMove(m_end, pev->nextthink - pev->ltime); + } + + // Otherwise, move first, rotate second + + // If the train is moving with the platform, update it + if (m_code == TRAIN_FOLLOWING) + { + UpdateTrain(m_end); + m_train->m_ppath = NULL; + } } +// Normal track change + /* <12deb0> ../cstrike/dlls/plats.cpp:1954 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(UpdateAutoTargets)(int toggleState) +void CFuncTrackChange::__MAKE_VHOOK(UpdateAutoTargets)(int toggleState) { -// UpdateAutoTargets(CFuncTrackChange *const this, -// int toggleState); // 1954 + if (!m_trackTop || !m_trackBottom) + return; + + if (toggleState == TS_AT_TOP) + m_trackTop->pev->spawnflags &= ~SF_PATH_DISABLED; + else + m_trackTop->pev->spawnflags |= SF_PATH_DISABLED; + + if (toggleState == TS_AT_BOTTOM) + m_trackBottom->pev->spawnflags &= ~SF_PATH_DISABLED; + else + m_trackBottom->pev->spawnflags |= SF_PATH_DISABLED; } /* <131725> ../cstrike/dlls/plats.cpp:1971 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CFuncTrackChange::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// Use(CFuncTrackChange *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 1971 -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 1986 + if (m_toggle_state != TS_AT_TOP && m_toggle_state != TS_AT_BOTTOM) + return; + + // If train is in "safe" area, but not on the elevator, play alarm sound + switch (m_toggle_state) + { + case TS_AT_TOP: + m_code = EvaluateTrain(m_trackTop); + break; + case TS_AT_BOTTOM: + m_code = EvaluateTrain(m_trackBottom); + break; + default: + m_code = TRAIN_BLOCKING; + break; + } + + if (m_code == TRAIN_BLOCKING) + { + // Play alarm and return + EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/button11.wav", VOL_NORM, ATTN_NORM); + return; + } + + // Otherwise, it's safe to move + // If at top, go down + // at bottom, go up + + DisableUse(); + if (m_toggle_state == TS_AT_TOP) + GoDown(); + else + GoUp(); } +// Platform has hit bottom. Stops and waits forever. + /* <12f618> ../cstrike/dlls/plats.cpp:2005 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(HitBottom)(void) +void CFuncTrackChange::__MAKE_VHOOK(HitBottom)(void) { -// HitBottom(CFuncPlatRot *const this); // 2007 -// EnableUse(CFuncTrackChange *const this); // 2018 -// SetTrack(CFuncTrackTrain *const this, -// class CPathTrack *track); // 2011 + CFuncPlatRot::HitBottom(); + if (m_code == TRAIN_FOLLOWING) + { + //UpdateTrain(); + m_train->SetTrack(m_trackBottom); + } + SetThink(NULL); + pev->nextthink = -1; + + UpdateAutoTargets(m_toggle_state); + EnableUse(); } +// Platform has hit bottom. Stops and waits forever. + /* <12f588> ../cstrike/dlls/plats.cpp:2025 */ -NOBODY void CFuncTrackChange::__MAKE_VHOOK(HitTop)(void) +void CFuncTrackChange::__MAKE_VHOOK(HitTop)(void) { -// HitTop(CFuncPlatRot *const this); // 2027 -// EnableUse(CFuncTrackChange *const this); // 2038 -// SetTrack(CFuncTrackTrain *const this, -// class CPathTrack *track); // 2031 + CFuncPlatRot::HitTop(); + if (m_code == TRAIN_FOLLOWING) + { + //UpdateTrain(); + m_train->SetTrack(m_trackTop); + } + + // Don't let the plat go back down + SetThink(NULL); + pev->nextthink = -1; + + UpdateAutoTargets(m_toggle_state); + EnableUse(); } /* <131bc3> ../cstrike/dlls/plats.cpp:2050 */ LINK_ENTITY_TO_CLASS(func_trackautochange, CFuncTrackAuto); +// Auto track change + /* <12dc2a> ../cstrike/dlls/plats.cpp:2053 */ -NOBODY void CFuncTrackAuto::__MAKE_VHOOK(UpdateAutoTargets)(int toggleState) +void CFuncTrackAuto::__MAKE_VHOOK(UpdateAutoTargets)(int toggleState) { -// { -// class CPathTrack *pTarget; // 2055 -// class CPathTrack *pNextTarget; // 2055 -// } + CPathTrack *pTarget, *pNextTarget; + + if (!m_trackTop || !m_trackBottom) + return; + + if (m_targetState == TS_AT_TOP) + { + pTarget = m_trackTop->GetNext(); + pNextTarget = m_trackBottom->GetNext(); + } + else + { + pTarget = m_trackBottom->GetNext(); + pNextTarget = m_trackTop->GetNext(); + } + + if (pTarget != NULL) + { + pTarget->pev->spawnflags &= ~SF_PATH_DISABLED; + + if (m_code == TRAIN_FOLLOWING && m_train && m_train->pev->speed == 0) + { + m_train->Use(this, this, USE_ON, 0); + } + } + + if (pNextTarget != NULL) + { + pNextTarget->pev->spawnflags |= SF_PATH_DISABLED; + } } /* <1301f9> ../cstrike/dlls/plats.cpp:2083 */ -NOBODY void CFuncTrackAuto::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CFuncTrackAuto::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// class CPathTrack *pTarget; // 2085 -// } -// Use(CFuncTrackAuto *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 2083 + CPathTrack *pTarget; + + if (!UseEnabled()) + return; + + switch (m_toggle_state) + { + case TS_AT_TOP: + pTarget = m_trackTop; + break; + case TS_AT_BOTTOM: + pTarget = m_trackBottom; + break; + default: + pTarget = NULL; + break; + } + + if (FClassnameIs(pActivator->pev, "func_tracktrain")) + { + m_code = EvaluateTrain(pTarget); + + // Safe to fire? + if (m_code == TRAIN_FOLLOWING && m_toggle_state != m_targetState) + { + DisableUse(); + + if (m_toggle_state == TS_AT_TOP) + GoDown(); + else + GoUp(); + } + } + else + { + if (pTarget != NULL) + { + pTarget = pTarget->GetNext(); + } + + if (pTarget != NULL && m_train->m_ppath != pTarget && ShouldToggle(useType, m_targetState)) + { + if (m_targetState == TS_AT_TOP) + m_targetState = TS_AT_BOTTOM; + else + m_targetState = TS_AT_TOP; + } + + UpdateAutoTargets(m_targetState); + } } /* <131c90> ../cstrike/dlls/plats.cpp:2163 */ @@ -916,78 +2143,160 @@ LINK_ENTITY_TO_CLASS(func_guntarget, CGunTarget); IMPLEMENT_SAVERESTORE(CGunTarget, CBaseMonster); /* <12dbb8> ../cstrike/dlls/plats.cpp:2173 */ -NOBODY void CGunTarget::__MAKE_VHOOK(Spawn)(void) +void CGunTarget::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (pev->speed == 0) + { + pev->speed = 100; + } + + // Don't take damage until "on" + pev->takedamage = DAMAGE_NO; + pev->flags |= FL_MONSTER; + + m_on = FALSE; + pev->max_health = pev->health; + + if (pev->spawnflags & FGUNTARGET_START_ON) + { + SetThink(&CGunTarget::Start); + pev->nextthink = pev->ltime + 0.3; + } } /* <12dade> ../cstrike/dlls/plats.cpp:2199 */ -NOBODY void CGunTarget::__MAKE_VHOOK(Activate)(void) +void CGunTarget::__MAKE_VHOOK(Activate)(void) { -// { -// class CBaseEntity *pTarg; // 2201 -// operator+(const Vector *const this, -// const Vector &v); // 2208 -// operator*(const Vector *const this, -// float fl); // 2208 -// operator-(const Vector *const this, -// const Vector &v); // 2208 -// } + CBaseEntity *pTarg; + + // now find our next target + pTarg = GetNextTarget(); + + if (pTarg != NULL) + { + m_hTargetEnt = pTarg; + UTIL_SetOrigin(pev, pTarg->pev->origin - (pev->mins + pev->maxs) * 0.5); + } } /* <12d947> ../cstrike/dlls/plats.cpp:2213 */ -NOBODY void CGunTarget::Start(void) +void CGunTarget::Start(void) { + Use(this, this, USE_ON, 0); } /* <12d96e> ../cstrike/dlls/plats.cpp:2219 */ -NOBODY void CGunTarget::Next(void) +void CGunTarget::Next(void) { -// { -// class CBaseEntity *pTarget; // 2224 -// operator+(const Vector *const this, -// const Vector &v); // 2232 -// operator*(const Vector *const this, -// float fl); // 2232 -// operator-(const Vector *const this, -// const Vector &v); // 2232 -// Stop(CGunTarget *const this); // 2228 -// } + SetThink(NULL); + + m_hTargetEnt = GetNextTarget(); + CBaseEntity *pTarget = m_hTargetEnt; + + if (!pTarget) + { + Stop(); + return; + } + + SetMoveDone(&CGunTarget::Wait); + LinearMove(pTarget->pev->origin - (pev->mins + pev->maxs) * 0.5, pev->speed); } /* <12da61> ../cstrike/dlls/plats.cpp:2236 */ -NOBODY void CGunTarget::Wait(void) +void CGunTarget::Wait(void) { -// { -// class CBaseEntity *pTarget; // 2238 -// Stop(CGunTarget *const this); // 2242 -// } + CBaseEntity *pTarget = m_hTargetEnt; + + if (!pTarget) + { + Stop(); + return; + } + + // Fire the pass target if there is one + if (pTarget->pev->message) + { + FireTargets(STRING(pTarget->pev->message), this, this, USE_TOGGLE, 0); + + if (pTarget->pev->spawnflags & SF_CORNER_FIREONCE) + { + pTarget->pev->message = 0; + } + } + + m_flWait = pTarget->GetDelay(); + pev->target = pTarget->pev->target; + SetThink(&CGunTarget::Next); + + if (m_flWait != 0) + { + // -1 wait will wait forever! + pev->nextthink = pev->ltime + m_flWait; + } + else + { + // do it RIGHT now! + Next(); + } } /* <131d5d> ../cstrike/dlls/plats.cpp:2269 */ -NOBODY void CGunTarget::Stop(void) +void CGunTarget::Stop(void) { + pev->velocity = g_vecZero; + pev->nextthink = 0; + pev->takedamage = DAMAGE_NO; } /* <12e371> ../cstrike/dlls/plats.cpp:2277 */ -NOBODY int CGunTarget::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +int CGunTarget::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { -// Stop(CGunTarget *const this); // 2285 -// TakeDamage(CGunTarget *const this, -// entvars_t *pevInflictor, -// entvars_t *pevAttacker, -// float flDamage, -// int bitsDamageType); // 2277 + if (pev->health > 0) + { + pev->health -= flDamage; + + if (pev->health <= 0) + { + pev->health = 0; + Stop(); + + if (pev->message) + { + FireTargets(STRING(pev->message), this, this, USE_TOGGLE, 0); + } + } + } + + return 0; } /* <12e408> ../cstrike/dlls/plats.cpp:2294 */ -NOBODY void CGunTarget::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CGunTarget::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// Stop(CGunTarget *const this); // 2301 -// Use(CGunTarget *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 2294 + if (!ShouldToggle(useType, m_on)) + return; + + if (m_on) + { + Stop(); + } + else + { + pev->takedamage = DAMAGE_AIM; + m_hTargetEnt = GetNextTarget(); + if (m_hTargetEnt == NULL) + return; + + pev->health = pev->max_health; + Next(); + } } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/plats.h b/regamedll/dlls/plats.h index 77bee762..b9260b74 100644 --- a/regamedll/dlls/plats.h +++ b/regamedll/dlls/plats.h @@ -46,21 +46,21 @@ #define FGUNTARGET_START_ON 0x0001 -/* <12c817> ../cstrike/dlls/plats.cpp:33 */ +/* <12c817> ../cstrike/dlls/plats.cpp:33 */ class CBasePlatTrain: public CBaseToggle { public: - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } // This is done to fix spawn flag collisions between this class and a derived class - NOBODY virtual BOOL IsTogglePlat(void) + virtual BOOL IsTogglePlat(void) { return IsTogglePlat_(); } @@ -92,17 +92,17 @@ public: };/* size: 320, cachelines: 5, members: 5 */ -/* <12c853> ../cstrike/dlls/plats.cpp:223 */ +/* <12c853> ../cstrike/dlls/plats.cpp:223 */ class CFuncPlat: public CBasePlatTrain { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void Blocked(CBaseEntity *pOther); - NOBODY virtual void GoUp(void); - NOBODY virtual void GoDown(void); - NOBODY virtual void HitTop(void); - NOBODY virtual void HitBottom(void); + virtual void Spawn(void); + virtual void Precache(void); + virtual void Blocked(CBaseEntity *pOther); + virtual void GoUp(void); + virtual void GoDown(void); + virtual void HitTop(void); + virtual void HitBottom(void); #ifdef HOOK_GAMEDLL @@ -117,24 +117,23 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void Setup(void); - - NOBODY void EXPORT PlatUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void EXPORT CallGoDown(void); - NOBODY void EXPORT CallHitTop(void); - NOBODY void EXPORT CallHitBottom(void); + void Setup(void); + void EXPORT PlatUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT CallGoDown(void); + void EXPORT CallHitTop(void); + void EXPORT CallHitBottom(void); };/* size: 320, cachelines: 5, members: 1 */ -/* <12c86e> ../cstrike/dlls/plats.cpp:248 */ +/* <12c86e> ../cstrike/dlls/plats.cpp:248 */ class CPlatTrigger: public CBaseEntity { public: - NOBODY virtual int ObjectCaps(void) + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Touch(CBaseEntity *pOther); + virtual void Touch(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -147,25 +146,25 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void SpawnInsideTrigger(CFuncPlat *pPlatform); + void SpawnInsideTrigger(CFuncPlat *pPlatform); public: CFuncPlat *m_pPlatform; };/* size: 156, cachelines: 3, members: 2 */ -/* <12c8ee> ../cstrike/dlls/plats.cpp:515 */ +/* <12c8ee> ../cstrike/dlls/plats.cpp:515 */ class CFuncPlatRot: public CFuncPlat { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual void Spawn(void); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); - NOBODY virtual void GoUp(void); - NOBODY virtual void GoDown(void); - NOBODY virtual void HitTop(void); - NOBODY virtual void HitBottom(void); + virtual void GoUp(void); + virtual void GoDown(void); + virtual void HitTop(void); + virtual void HitBottom(void); #ifdef HOOK_GAMEDLL @@ -180,9 +179,9 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void SetupRotation(void); - NOBODY void RotMove(Vector &destAngle, float time); - + void SetupRotation(void); + void RotMove(Vector &destAngle, float time); + public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[2]; @@ -196,35 +195,35 @@ public: class CFuncTrain: public CBasePlatTrain { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Activate(void); - NOBODY virtual void OverrideReset(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual void Blocked(CBaseEntity *pOther); + virtual void Spawn(void); + virtual void Precache(void); + virtual void Restart(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Activate(void); + virtual void OverrideReset(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Blocked(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL - void Spawn_(void); - void Precache_(void); - void Restart_(void); - void KeyValue_(KeyValueData *pkvd); - int Save_(CSave &save); - int Restore_(CRestore &restore); - void Activate_(void); - void OverrideReset_(void); - void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void Spawn_(void); + void Precache_(void); + void Restart_(void); + void KeyValue_(KeyValueData *pkvd); + int Save_(CSave &save); + int Restore_(CRestore &restore); + void Activate_(void); + void OverrideReset_(void); + void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void Blocked_(CBaseEntity *pOther); #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT Wait(void); - NOBODY void EXPORT Next(void); + void EXPORT Wait(void); + void EXPORT Next(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[3]; @@ -242,8 +241,8 @@ public: class CFuncTrainControls: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual int ObjectCaps(void) { return ObjectCaps_(); } @@ -251,7 +250,7 @@ public: #ifdef HOOK_GAMEDLL void Spawn_(void); - int ObjectCaps_(void) + int ObjectCaps_(void) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } @@ -259,7 +258,7 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT Find(void); + void EXPORT Find(void); };/* size: 152, cachelines: 3, members: 1 */ @@ -267,22 +266,22 @@ public: class CFuncTrackChange: public CFuncPlatRot { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void OverrideReset(void); - NOBODY virtual void Touch(CBaseEntity *pOther); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual BOOL IsTogglePlat(void); + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void OverrideReset(void); + virtual void Touch(CBaseEntity *pOther); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual BOOL IsTogglePlat(void); - NOBODY virtual void EXPORT GoUp(void); - NOBODY virtual void EXPORT GoDown(void); - - NOBODY virtual void HitBottom(void); - NOBODY virtual void HitTop(void); - NOBODY virtual void UpdateAutoTargets(int toggleState); + virtual void EXPORT GoUp(void); + virtual void EXPORT GoDown(void); + + virtual void HitBottom(void); + virtual void HitTop(void); + virtual void UpdateAutoTargets(int toggleState); #ifdef HOOK_GAMEDLL @@ -302,24 +301,24 @@ public: void UpdateAutoTargets_(int toggleState); #endif // HOOK_GAMEDLL - + public: - NOBODY void EXPORT Find(void); - NOBODY TRAIN_CODE EvaluateTrain(CPathTrack *pcurrent); - NOBODY void UpdateTrain(Vector &dest); + void EXPORT Find(void); + TRAIN_CODE EvaluateTrain(CPathTrack *pcurrent); + void UpdateTrain(Vector &dest); /* <12c515> ../cstrike/dlls/plats.cpp:1675 */ - NOBODY void DisableUse(void) + void DisableUse(void) { m_use = 0; } /* <12c52e> ../cstrike/dlls/plats.cpp:1676 */ - NOBODY void EnableUse(void) + void EnableUse(void) { m_use = 1; } /* <12c547> ../cstrike/dlls/plats.cpp:1677 */ - NOBODY int UseEnabled(void) + int UseEnabled(void) { return m_use; } @@ -346,8 +345,8 @@ public: class CFuncTrackAuto: public CFuncTrackChange { public: - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual void UpdateAutoTargets(int toggleState); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void UpdateAutoTargets(int toggleState); #ifdef HOOK_GAMEDLL @@ -363,25 +362,25 @@ public: class CGunTarget: public CBaseMonster { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Activate(void); - NOBODY virtual int Classify(void) + virtual void Activate(void); + virtual int Classify(void) { return Classify_(); } - NOBODY virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); - NOBODY virtual int BloodColor(void) + virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); + virtual int BloodColor(void) { return BloodColor_(); } - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual Vector BodyTarget(const Vector &posSrc) + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual Vector BodyTarget(const Vector &posSrc) { return BodyTarget_(posSrc); } @@ -414,11 +413,10 @@ public: #endif // HOOK_GAMEDLL public: - - NOBODY void EXPORT Next(void); - NOBODY void EXPORT Start(void); - NOBODY void EXPORT Wait(void); - NOBODY void Stop(void); + void EXPORT Next(void); + void EXPORT Start(void); + void EXPORT Wait(void); + void Stop(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; @@ -428,8 +426,18 @@ private: };/* size: 408, cachelines: 7, members: 3 */ -NOBODY void PlatSpawnInsideTrigger(entvars_t *pevPlatform); -NOBODY float Fix(float angle); -NOBODY void FixupAngles(Vector &v); +void PlatSpawnInsideTrigger(entvars_t *pevPlatform); +//float Fix(float angle); +void FixupAngles(Vector &v); + +// linked objects +C_DLLEXPORT void func_plat(entvars_t *pev); +C_DLLEXPORT void func_platrot(entvars_t *pev); +C_DLLEXPORT void func_train(entvars_t *pev); +C_DLLEXPORT void func_tracktrain(entvars_t *pev); +C_DLLEXPORT void func_traincontrols(entvars_t *pev); +C_DLLEXPORT void func_trackchange(entvars_t *pev); +C_DLLEXPORT void func_trackautochange(entvars_t *pev); +C_DLLEXPORT void func_guntarget(entvars_t *pev); #endif // PLATS_H diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index ccc95383..f659e50c 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -273,8 +273,8 @@ int gmsgShowTimer; BOOL gInitHUD; cvar_t *sv_aim; -TYPEDESCRIPTION (*CRevertSaved::pm_SaveData)[2]; -TYPEDESCRIPTION (*CBasePlayer::pm_playerSaveData)[40]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CRevertSaved, m_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData)[40]; WeaponStruct g_weaponStruct[ MAX_WEAPONS ]; char *(*CDeadHEV::pm_szPoses)[4]; @@ -486,7 +486,7 @@ void CBasePlayer::SetPlayerModel(BOOL HasC4) char *model; if (m_iTeam == CT) - { + { switch (m_iModelName) { case MODEL_URBAN: @@ -632,7 +632,7 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch { if (FNullEnt(pEntity->edict())) break; - + BOOL bSend = FALSE; CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); @@ -669,11 +669,11 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch WRITE_SHORT(pitch); MESSAGE_END(); - if (msg_verbose) + if (msg_verbose) { // search the place name where is located the player const char *placeName = NULL; - Place playerPlace = TheNavAreaGrid.GetPlace( &pev->origin ); + Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) @@ -792,6 +792,7 @@ int TrainSpeed(int iSpeed, int iMax) /* <153c8e> ../cstrike/dlls/player.cpp:902 */ void CBasePlayer::DeathSound(void) { + // temporarily using pain sounds for death sounds switch (RANDOM_LONG(1, 4)) { case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/die1.wav", VOL_NORM, ATTN_NORM); break; @@ -801,6 +802,9 @@ void CBasePlayer::DeathSound(void) } } +// override takehealth +// bitsDamageType indicates type of damage healed. + /* <151213> ../cstrike/dlls/player.cpp:937 */ int CBasePlayer::__MAKE_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) { @@ -951,7 +955,7 @@ void CBasePlayer::__MAKE_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDama if (bShouldBleed) { BloodSplat(ptr->vecEndPos, vecDir, ptr->iHitgroup, flDamage * 5); - SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage); + SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage); // a little surface blood. TraceBleed(flDamage, vecDir, ptr, bitsDamageType); } else if (ptr->iHitgroup == HITGROUP_HEAD && bShouldSpark == true) @@ -1047,414 +1051,414 @@ void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int } } -// Take some damage. -// NOTE: each call to TakeDamage with bitsDamageType set to a time-based damage -// type will cause the damage time countdown to be reset. Thus the ongoing effects of poison, radiation +// Take some damage. +// NOTE: each call to TakeDamage with bitsDamageType set to a time-based damage +// type will cause the damage time countdown to be reset. Thus the ongoing effects of poison, radiation // etc are implemented with subsequent calls to TakeDamage using DMG_GENERIC. /* <15dff9> ../cstrike/dlls/player.cpp:1241 */ -int CBasePlayer::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ - int fTookDamage; - float flRatio = ARMOR_RATIO; - float flBonus = ARMOR_BONUS; - //float flHealthPrev = pev->health; - int iGunType = 0; - float flShieldRatio = 0; - int teamAttack = FALSE; - int armorHit = 0; - CBasePlayer *pAttack = NULL; - CBaseEntity *pAttacker = NULL; - //CBaseEntity *attacker = NULL; // unused - - if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL)) - m_LastHitGroup = HITGROUP_GENERIC; - - else if (m_LastHitGroup == HITGROUP_SHIELD && (bitsDamageType & DMG_BULLET)) - return 0; - - if (HasShield()) - flShieldRatio = 0.2; - - if (m_bIsVIP) - flRatio *= 0.5; - - if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST)) - { - if (!IsAlive()) - { - return 0; - } - - if (bitsDamageType & DMG_EXPLOSION) - { - CBaseEntity *temp = GetClassPtr((CBaseEntity *)pevInflictor); - - if (!Q_strcmp(STRING(temp->pev->classname), "grenade")) - { - CGrenade *pGrenade = GetClassPtr((CGrenade *)pevInflictor); - - if (CVAR_GET_FLOAT("mp_friendlyfire")) - { - if (pGrenade->m_iTeam == m_iTeam) - teamAttack = TRUE; - - pAttack = reinterpret_cast(CBasePlayer::Instance(pevAttacker)); - } - else if (pGrenade->m_iTeam == m_iTeam && (&edict()->v != pevAttacker)) - { - return 0; - } - } - } - - if (!FNullEnt(ENT(pevInflictor))) - m_vBlastVector = pev->origin - pevInflictor->origin; - - if (pev->armorvalue != 0.0f && IsArmored(m_LastHitGroup)) - { - float_precision flNew = flRatio * flDamage; - float_precision flArmor = (flDamage - flNew) * flBonus; - - // Does this use more armor than we have? - if (flArmor > pev->armorvalue) - { - flNew = flDamage - pev->armorvalue; - armorHit = flArmor; - pev->armorvalue = 0; - } - else - { - int oldValue = pev->armorvalue; - - if (flArmor < 0.0) - flArmor = 1.0; - - pev->armorvalue -= flArmor; - armorHit = oldValue - pev->armorvalue; - } - - flDamage = flNew; - - if (pev->armorvalue <= 0.0) - m_iKevlar = ARMOR_TYPE_EMPTY; - - Pain(m_LastHitGroup, true); - } - else - Pain(m_LastHitGroup, false); - - m_lastDamageAmount = flDamage; - - if (pev->health > flDamage) - { - SetAnimation(PLAYER_FLINCH); - Pain(m_LastHitGroup, false); - } - else - { - if (bitsDamageType & DMG_BLAST) - m_bKilledByBomb = true; - - else if (bitsDamageType & DMG_EXPLOSION) - m_bKilledByGrenade = true; - } - - LogAttack(pAttack, this, teamAttack, (int)flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); - fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); - - if (fTookDamage > 0) - { - CHalfLifeMultiplay *mp = g_pGameRules; - - if (TheBots) - TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); - - if (mp->IsCareer()) - { - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); - - if (!pPlayer) - continue; - - bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); - - if (killedByHumanPlayer) - { - TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); - } - } - } - } - - { - // reset damage time countdown for each type of time based damage player just sustained - for (int i = 0; i < CDMG_TIMEBASED; i++) - { - if (bitsDamageType & (DMG_PARALYZE << i)) - m_rgbTimeBasedDamage[i] = 0; - } - } - - // tell director about it - MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); - WRITE_BYTE(9); // command length in bytes - WRITE_BYTE(DRC_CMD_EVENT); // take damage event - WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity - WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity - WRITE_LONG(5); // eventflags (priority and flags) - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_BYTE((int)_max(pev->health, 0) | DRC_FLAG_FACEPLAYER); - MESSAGE_END(); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pPlayer || pPlayer->m_hObserverTarget != this) - continue; - - MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); - WRITE_BYTE((int)_max(pev->health, 0)); - MESSAGE_END(); - } - - return fTookDamage; - } - - pAttacker = CBaseEntity::Instance(pevAttacker); - - if (!g_pGameRules->FPlayerCanTakeDamage(this, pAttacker) && Q_strcmp("grenade", STRING(pevInflictor->classname))) - { - // Refuse the damage - return 0; - } - - if (bitsDamageType & DMG_BLAST && g_pGameRules->IsMultiplayer()) - { - // blasts damage armor more. - flBonus *= 2; - } - - // Already dead - if (!IsAlive()) - return 0; - - pAttacker = GetClassPtr((CBaseEntity *)pevAttacker); - - if (pAttacker->IsPlayer()) - { - pAttack = GetClassPtr((CBasePlayer *)pevAttacker); - - if (pAttack != this && pAttack->m_iTeam == m_iTeam) - { - // TODO: this->m_flDisplayHistory!! - if (!(m_flDisplayHistory & DHF_FRIEND_INJURED)) - { - m_flDisplayHistory |= DHF_FRIEND_INJURED; - pAttack->HintMessage("#Hint_try_not_to_injure_teammates"); - } - - teamAttack = TRUE; - if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6) - { - CBaseEntity *pBasePlayer = NULL; - while ((pBasePlayer = UTIL_FindEntityByClassname(pBasePlayer, "player")) != NULL) - { - if (FNullEnt(pBasePlayer->edict())) - break; - - CBasePlayer *basePlayer = GetClassPtr((CBasePlayer *)pBasePlayer->pev); - - if (basePlayer->m_iTeam == m_iTeam) +int CBasePlayer::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + int fTookDamage; + float flRatio = ARMOR_RATIO; + float flBonus = ARMOR_BONUS; + //float flHealthPrev = pev->health; + int iGunType = 0; + float flShieldRatio = 0; + int teamAttack = FALSE; + int armorHit = 0; + CBasePlayer *pAttack = NULL; + CBaseEntity *pAttacker = NULL; + //CBaseEntity *attacker = NULL; // unused + + if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL)) + m_LastHitGroup = HITGROUP_GENERIC; + + else if (m_LastHitGroup == HITGROUP_SHIELD && (bitsDamageType & DMG_BULLET)) + return 0; + + if (HasShield()) + flShieldRatio = 0.2; + + if (m_bIsVIP) + flRatio *= 0.5; + + if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST)) + { + if (!IsAlive()) + { + return 0; + } + + if (bitsDamageType & DMG_EXPLOSION) + { + CBaseEntity *temp = GetClassPtr((CBaseEntity *)pevInflictor); + + if (!Q_strcmp(STRING(temp->pev->classname), "grenade")) + { + CGrenade *pGrenade = GetClassPtr((CGrenade *)pevInflictor); + + if (CVAR_GET_FLOAT("mp_friendlyfire")) + { + if (pGrenade->m_iTeam == m_iTeam) + teamAttack = TRUE; + + pAttack = reinterpret_cast(CBasePlayer::Instance(pevAttacker)); + } + else if (pGrenade->m_iTeam == m_iTeam && (&edict()->v != pevAttacker)) + { + return 0; + } + } + } + + if (!FNullEnt(ENT(pevInflictor))) + m_vBlastVector = pev->origin - pevInflictor->origin; + + if (pev->armorvalue != 0.0f && IsArmored(m_LastHitGroup)) + { + float_precision flNew = flRatio * flDamage; + float_precision flArmor = (flDamage - flNew) * flBonus; + + // Does this use more armor than we have? + if (flArmor > pev->armorvalue) + { + flNew = flDamage - pev->armorvalue; + armorHit = flArmor; + pev->armorvalue = 0; + } + else + { + int oldValue = pev->armorvalue; + + if (flArmor < 0.0) + flArmor = 1.0; + + pev->armorvalue -= flArmor; + armorHit = oldValue - pev->armorvalue; + } + + flDamage = flNew; + + if (pev->armorvalue <= 0.0) + m_iKevlar = ARMOR_TYPE_EMPTY; + + Pain(m_LastHitGroup, true); + } + else + Pain(m_LastHitGroup, false); + + m_lastDamageAmount = flDamage; + + if (pev->health > flDamage) + { + SetAnimation(PLAYER_FLINCH); + Pain(m_LastHitGroup, false); + } + else + { + if (bitsDamageType & DMG_BLAST) + m_bKilledByBomb = true; + + else if (bitsDamageType & DMG_EXPLOSION) + m_bKilledByGrenade = true; + } + + LogAttack(pAttack, this, teamAttack, (int)flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); + fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); + + if (fTookDamage > 0) + { + CHalfLifeMultiplay *mp = g_pGameRules; + + if (TheBots) + TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); + + if (mp->IsCareer()) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer) + continue; + + bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); + + if (killedByHumanPlayer) { - ClientPrint(basePlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname)); + TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); } - } - - pAttack->m_flLastAttackedTeammate = gpGlobals->time; - } - } - - if (pAttack->m_iTeam == m_iTeam) - flDamage *= 0.35; - - iGunType = pAttack->m_pActiveItem->m_iId; - - if (pAttack->m_pActiveItem) - { - flRatio += flShieldRatio; - switch (iGunType) - { - case WEAPON_AUG: - case WEAPON_M4A1: flRatio *= 1.4; break; - case WEAPON_AWP: flRatio *= 1.95; break; - case WEAPON_G3SG1: flRatio *= 1.65; break; - case WEAPON_SG550: flRatio *= 1.45; break; - case WEAPON_M249: flRatio *= 1.5; break; - case WEAPON_ELITE: flRatio *= 1.05; break; - case WEAPON_DEAGLE: flRatio *= 1.5; break; - case WEAPON_GLOCK18: flRatio *= 1.05; break; - case WEAPON_FIVESEVEN: - case WEAPON_P90: flRatio *= 1.5; break; - case WEAPON_MAC10: flRatio *= 0.95; break; - case WEAPON_P228: flRatio *= 1.25; break; - case WEAPON_SCOUT: - case WEAPON_KNIFE: flRatio *= 1.7; break; - case WEAPON_FAMAS: - case WEAPON_SG552: flRatio *= 1.4; break; - case WEAPON_GALIL: - case WEAPON_AK47: flRatio *= 1.55; break; - } - } - - if (!ShouldDoLargeFlinch(m_LastHitGroup, iGunType)) - { - m_flVelocityModifier = 0.5f; - - if (m_LastHitGroup == HITGROUP_HEAD) - m_bHighDamage = (flDamage > 60); - else - m_bHighDamage = (flDamage > 20); - - SetAnimation(PLAYER_FLINCH); - } - else - { - if (pev->velocity.Length() < 300) - { - Vector attack_velocity = (pev->origin - pAttack->pev->origin).Normalize() * 170; - pev->velocity = pev->velocity + attack_velocity; - - m_flVelocityModifier = 0.65f; - } - SetAnimation(PLAYER_LARGE_FLINCH); - } - } - - // keep track of amount of damage last sustained - m_lastDamageAmount = flDamage; - - // Armor - // armor doesn't protect against fall or drown damage! - if (pev->armorvalue != 0.0f && !(bitsDamageType & (DMG_DROWN | DMG_FALL)) && IsArmored(m_LastHitGroup)) - { - float_precision flNew = flRatio * flDamage; - float_precision flArmor = (flDamage - flNew) * flBonus; - - // Does this use more armor than we have? - if (flArmor > pev->armorvalue) - { - armorHit = flArmor; - flArmor = pev->armorvalue; - flArmor *= (1 / flBonus); - flNew = flDamage - flArmor; - pev->armorvalue = 0; - } - else - { - int oldValue = pev->armorvalue; - - if (flArmor < 0.0) - flArmor = 1.0; - - pev->armorvalue -= flArmor; - armorHit = oldValue - pev->armorvalue; - } - - flDamage = flNew; - - if (pev->armorvalue <= 0.0f) - m_iKevlar = ARMOR_TYPE_EMPTY; - - Pain(m_LastHitGroup, true); - } - else - Pain(m_LastHitGroup, false); - - LogAttack(pAttack, this, teamAttack, flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); - - // this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that - // as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc) - fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); - - if (fTookDamage > 0) - { - CHalfLifeMultiplay *mp = g_pGameRules; - - if (TheBots) - { - TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); - } - - if (mp->IsCareer()) - { - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); - - if (!pPlayer) - continue; - - bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); - - if (killedByHumanPlayer) - { - TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); - } - } - } - } - - { - // reset damage time countdown for each type of time based damage player just sustained - for (int i = 0; i < CDMG_TIMEBASED; i++) - { - if (bitsDamageType & (DMG_PARALYZE << i)) - m_rgbTimeBasedDamage[i] = 0; - } - } - - // tell director about it - MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); - WRITE_BYTE(9); // command length in bytes - WRITE_BYTE(DRC_CMD_EVENT); // take damage event - WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity - WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity - WRITE_LONG(5); // eventflags (priority and flags) - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_BYTE((int)_max(pev->health, 0) | DRC_FLAG_FACEPLAYER); - MESSAGE_END(); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( i ); - - if (!pPlayer) - continue; - - if (pPlayer->m_hObserverTarget == this) - { - MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); - WRITE_BYTE((int)_max(pev->health, 0)); - MESSAGE_END(); - } - } - - // Save this so we can report it to the client - m_bitsHUDDamage = -1; - - // make sure the damage bits get resent - m_bitsDamageType |= bitsDamageType; - + } + } + } + + { + // reset damage time countdown for each type of time based damage player just sustained + for (int i = 0; i < CDMG_TIMEBASED; i++) + { + if (bitsDamageType & (DMG_PARALYZE << i)) + m_rgbTimeBasedDamage[i] = 0; + } + } + + // tell director about it + MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); + WRITE_BYTE(9); // command length in bytes + WRITE_BYTE(DRC_CMD_EVENT); // take damage event + WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity + WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity + WRITE_LONG(5); // eventflags (priority and flags) + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_BYTE((int)Q_max(pev->health, 0.0f) | DRC_FLAG_FACEPLAYER); + MESSAGE_END(); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer || pPlayer->m_hObserverTarget != this) + continue; + + MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); + WRITE_BYTE((int)Q_max(pev->health, 0.0f)); + MESSAGE_END(); + } + + return fTookDamage; + } + + pAttacker = CBaseEntity::Instance(pevAttacker); + + if (!g_pGameRules->FPlayerCanTakeDamage(this, pAttacker) && Q_strcmp("grenade", STRING(pevInflictor->classname))) + { + // Refuse the damage + return 0; + } + + if (bitsDamageType & DMG_BLAST && g_pGameRules->IsMultiplayer()) + { + // blasts damage armor more. + flBonus *= 2; + } + + // Already dead + if (!IsAlive()) + return 0; + + pAttacker = GetClassPtr((CBaseEntity *)pevAttacker); + + if (pAttacker->IsPlayer()) + { + pAttack = GetClassPtr((CBasePlayer *)pevAttacker); + + if (pAttack != this && pAttack->m_iTeam == m_iTeam) + { + // TODO: this->m_flDisplayHistory!! + if (!(m_flDisplayHistory & DHF_FRIEND_INJURED)) + { + m_flDisplayHistory |= DHF_FRIEND_INJURED; + pAttack->HintMessage("#Hint_try_not_to_injure_teammates"); + } + + teamAttack = TRUE; + if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6) + { + CBaseEntity *pBasePlayer = NULL; + while ((pBasePlayer = UTIL_FindEntityByClassname(pBasePlayer, "player")) != NULL) + { + if (FNullEnt(pBasePlayer->edict())) + break; + + CBasePlayer *basePlayer = GetClassPtr((CBasePlayer *)pBasePlayer->pev); + + if (basePlayer->m_iTeam == m_iTeam) + { + ClientPrint(basePlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname)); + } + } + + pAttack->m_flLastAttackedTeammate = gpGlobals->time; + } + } + + if (pAttack->m_iTeam == m_iTeam) + flDamage *= 0.35; + + iGunType = pAttack->m_pActiveItem->m_iId; + + if (pAttack->m_pActiveItem) + { + flRatio += flShieldRatio; + switch (iGunType) + { + case WEAPON_AUG: + case WEAPON_M4A1: flRatio *= 1.4; break; + case WEAPON_AWP: flRatio *= 1.95; break; + case WEAPON_G3SG1: flRatio *= 1.65; break; + case WEAPON_SG550: flRatio *= 1.45; break; + case WEAPON_M249: flRatio *= 1.5; break; + case WEAPON_ELITE: flRatio *= 1.05; break; + case WEAPON_DEAGLE: flRatio *= 1.5; break; + case WEAPON_GLOCK18: flRatio *= 1.05; break; + case WEAPON_FIVESEVEN: + case WEAPON_P90: flRatio *= 1.5; break; + case WEAPON_MAC10: flRatio *= 0.95; break; + case WEAPON_P228: flRatio *= 1.25; break; + case WEAPON_SCOUT: + case WEAPON_KNIFE: flRatio *= 1.7; break; + case WEAPON_FAMAS: + case WEAPON_SG552: flRatio *= 1.4; break; + case WEAPON_GALIL: + case WEAPON_AK47: flRatio *= 1.55; break; + } + } + + if (!ShouldDoLargeFlinch(m_LastHitGroup, iGunType)) + { + m_flVelocityModifier = 0.5f; + + if (m_LastHitGroup == HITGROUP_HEAD) + m_bHighDamage = (flDamage > 60); + else + m_bHighDamage = (flDamage > 20); + + SetAnimation(PLAYER_FLINCH); + } + else + { + if (pev->velocity.Length() < 300) + { + Vector attack_velocity = (pev->origin - pAttack->pev->origin).Normalize() * 170; + pev->velocity = pev->velocity + attack_velocity; + + m_flVelocityModifier = 0.65f; + } + SetAnimation(PLAYER_LARGE_FLINCH); + } + } + + // keep track of amount of damage last sustained + m_lastDamageAmount = flDamage; + + // Armor + // armor doesn't protect against fall or drown damage! + if (pev->armorvalue != 0.0f && !(bitsDamageType & (DMG_DROWN | DMG_FALL)) && IsArmored(m_LastHitGroup)) + { + float_precision flNew = flRatio * flDamage; + float_precision flArmor = (flDamage - flNew) * flBonus; + + // Does this use more armor than we have? + if (flArmor > pev->armorvalue) + { + armorHit = flArmor; + flArmor = pev->armorvalue; + flArmor *= (1 / flBonus); + flNew = flDamage - flArmor; + pev->armorvalue = 0; + } + else + { + int oldValue = pev->armorvalue; + + if (flArmor < 0.0) + flArmor = 1.0; + + pev->armorvalue -= flArmor; + armorHit = oldValue - pev->armorvalue; + } + + flDamage = flNew; + + if (pev->armorvalue <= 0.0f) + m_iKevlar = ARMOR_TYPE_EMPTY; + + Pain(m_LastHitGroup, true); + } + else + Pain(m_LastHitGroup, false); + + LogAttack(pAttack, this, teamAttack, flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); + + // this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that + // as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc) + fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); + + if (fTookDamage > 0) + { + CHalfLifeMultiplay *mp = g_pGameRules; + + if (TheBots) + { + TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); + } + + if (mp->IsCareer()) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer) + continue; + + bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); + + if (killedByHumanPlayer) + { + TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); + } + } + } + } + + { + // reset damage time countdown for each type of time based damage player just sustained + for (int i = 0; i < CDMG_TIMEBASED; i++) + { + if (bitsDamageType & (DMG_PARALYZE << i)) + m_rgbTimeBasedDamage[i] = 0; + } + } + + // tell director about it + MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); + WRITE_BYTE(9); // command length in bytes + WRITE_BYTE(DRC_CMD_EVENT); // take damage event + WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity + WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity + WRITE_LONG(5); // eventflags (priority and flags) + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_BYTE((int)Q_max(pev->health, 0.0f) | DRC_FLAG_FACEPLAYER); + MESSAGE_END(); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer) + continue; + + if (pPlayer->m_hObserverTarget == this) + { + MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); + WRITE_BYTE((int)Q_max(pev->health, 0.0f)); + MESSAGE_END(); + } + } + + // Save this so we can report it to the client + m_bitsHUDDamage = -1; + + // make sure the damage bits get resent + m_bitsDamageType |= bitsDamageType; + return fTookDamage; } @@ -1888,7 +1892,7 @@ void VIP_SafetyZoneIcon_Set(CBasePlayer *player) WRITE_BYTE(160); WRITE_BYTE(0); MESSAGE_END(); - + if (!(player->m_flDisplayHistory & DHF_IN_VIPSAFETY_ZONE)) { if (player->m_iTeam == CT) @@ -1950,15 +1954,15 @@ void CBasePlayer::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) TheBots->OnEvent(EVENT_PLAYER_DIED, this, pAttackerEntity); - if (g_pGameRules->IsCareer()) + if (g_pGameRules->IsCareer()) { bool killerHasShield = false; bool wasBlind = false; - if (!IsBot()) - { - TheCareerTasks->HandleEvent(EVENT_DIE, NULL, this); - } + if (!IsBot()) + { + TheCareerTasks->HandleEvent(EVENT_DIE, NULL, this); + } TheCareerTasks->HandleDeath(m_iTeam, this); if (!m_bKilledByBomb) @@ -1996,48 +2000,48 @@ void CBasePlayer::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) g_pGameRules->PlayerKilled(this, pevAttacker, g_pevLastInflictor); } - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); - WRITE_BYTE(0); + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); + WRITE_BYTE(0); MESSAGE_END(); m_bNightVisionOn = false; - for (int i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pObserver) - continue; - - if (pObserver->IsObservingPlayer(this)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(0); - MESSAGE_END(); - - pObserver->m_bNightVisionOn = false; - } + for (int i = 1; i <= gpGlobals->maxClients; ++i) + { + CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pObserver) + continue; + + if (pObserver->IsObservingPlayer(this)) + { + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + WRITE_BYTE(0); + MESSAGE_END(); + + pObserver->m_bNightVisionOn = false; + } } - if (m_pTank != NULL) - { - m_pTank->Use(this, this, USE_OFF, 0); - m_pTank = NULL; + if (m_pTank != NULL) + { + m_pTank->Use(this, this, USE_OFF, 0); + m_pTank = NULL; } - CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); - - if (pSound) - { - pSound->Reset(); + CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); + + if (pSound) + { + pSound->Reset(); } SetAnimation(PLAYER_DIE); - if (m_pActiveItem && m_pActiveItem->m_pPlayer) + if (m_pActiveItem && m_pActiveItem->m_pPlayer) { - switch (m_pActiveItem->m_iId) - { + switch (m_pActiveItem->m_iId) + { case WEAPON_HEGRENADE: { CHEGrenade *pHEGrenade = (CHEGrenade *)m_pActiveItem; @@ -2065,140 +2069,140 @@ void CBasePlayer::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) break; } default: - break; + break; } } - pev->modelindex = m_modelIndexPlayer; - pev->deadflag = DEAD_DYING; - pev->movetype = MOVETYPE_TOSS; - pev->takedamage = DAMAGE_NO; - - pev->gamestate = 1; - m_bShieldDrawn = false; - + pev->modelindex = m_modelIndexPlayer; + pev->deadflag = DEAD_DYING; + pev->movetype = MOVETYPE_TOSS; + pev->takedamage = DAMAGE_NO; + + pev->gamestate = 1; + m_bShieldDrawn = false; + pev->flags &= ~FL_ONGROUND; - - if (fadetoblack.value == 0.0) - { - pev->iuser1 = OBS_CHASE_FREE; - pev->iuser2 = ENTINDEX(edict()); - pev->iuser3 = ENTINDEX(ENT(pevAttacker)); - - m_hObserverTarget = UTIL_PlayerByIndex(pev->iuser3); - - MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, pev); - MESSAGE_END(); - } - else - UTIL_ScreenFade(this, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); + + if (fadetoblack.value == 0.0) + { + pev->iuser1 = OBS_CHASE_FREE; + pev->iuser2 = ENTINDEX(edict()); + pev->iuser3 = ENTINDEX(ENT(pevAttacker)); + + m_hObserverTarget = UTIL_PlayerByIndex(pev->iuser3); + + MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, pev); + MESSAGE_END(); + } + else + UTIL_ScreenFade(this, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); SetScoreboardAttributes(); - if (m_iThrowDirection) - { - switch (m_iThrowDirection) - { - case THROW_FORWARD: - { - UTIL_MakeVectors(pev->angles); - - pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(100, 200); - pev->velocity.z = RANDOM_FLOAT(50, 100); - - break; - } - case THROW_BACKWARD: - { - UTIL_MakeVectors(pev->angles); - - pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(-100, -200); - pev->velocity.z = RANDOM_FLOAT(50, 100); - - break; - } - case THROW_HITVEL: - { + if (m_iThrowDirection) + { + switch (m_iThrowDirection) + { + case THROW_FORWARD: + { + UTIL_MakeVectors(pev->angles); + + pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(100, 200); + pev->velocity.z = RANDOM_FLOAT(50, 100); + + break; + } + case THROW_BACKWARD: + { + UTIL_MakeVectors(pev->angles); + + pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(-100, -200); + pev->velocity.z = RANDOM_FLOAT(50, 100); + + break; + } + case THROW_HITVEL: + { if (FClassnameIs(pevAttacker, "player")) { UTIL_MakeVectors(pevAttacker->angles); pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(200, 300); pev->velocity.z = RANDOM_FLOAT(200, 300); - } - - break; - } - case THROW_BOMB: - { - pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (2300 - m_vBlastVector.Length()) * 0.25; - pev->velocity.z = (2300 - m_vBlastVector.Length()) / 2.75; - - break; - } - case THROW_GRENADE: - { - pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (500 - m_vBlastVector.Length()); - pev->velocity.z = (350 - m_vBlastVector.Length()) * 1.5; - - break; - } - case THROW_HITVEL_MINUS_AIRVEL: - { - if (FClassnameIs(pevAttacker, "player")) - { - UTIL_MakeVectors(pevAttacker->angles); - pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(200, 300); - } - - break; - } + } + + break; + } + case THROW_BOMB: + { + pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (2300 - m_vBlastVector.Length()) * 0.25; + pev->velocity.z = (2300 - m_vBlastVector.Length()) / 2.75; + + break; + } + case THROW_GRENADE: + { + pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (500 - m_vBlastVector.Length()); + pev->velocity.z = (350 - m_vBlastVector.Length()) * 1.5; + + break; + } + case THROW_HITVEL_MINUS_AIRVEL: + { + if (FClassnameIs(pevAttacker, "player")) + { + UTIL_MakeVectors(pevAttacker->angles); + pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(200, 300); + } + + break; + } default: - break; - } - - pev->angles.y = UTIL_VecToAngles(-pev->velocity).y; - pev->v_angle.y = pev->angles.y; - - m_iThrowDirection = THROW_NONE; + break; + } + + pev->angles.y = UTIL_VecToAngles(-pev->velocity).y; + pev->v_angle.y = pev->angles.y; + + m_iThrowDirection = THROW_NONE; } SetSuitUpdate(NULL, FALSE, 0); - m_iClientHealth = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); - WRITE_BYTE(m_iClientHealth); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); - WRITE_BYTE(0); - WRITE_BYTE(0xFF); - WRITE_BYTE(0xFF); - MESSAGE_END(); - + m_iClientHealth = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); + WRITE_BYTE(m_iClientHealth); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); + WRITE_BYTE(0); + WRITE_BYTE(0xFF); + WRITE_BYTE(0xFF); + MESSAGE_END(); + SendFOV(0); - g_pGameRules->CheckWinConditions(); + g_pGameRules->CheckWinConditions(); m_bNotKilled = false; - if (m_bHasC4) - { - DropPlayerItem("weapon_c4"); - SetProgressBarTime(0); - } - else if (m_bHasDefuser) - { - m_bHasDefuser = false; - pev->body = 0; - - GiveNamedItem("item_thighpack"); - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("defuser"); - MESSAGE_END(); - - SendItemStatus(this); + if (m_bHasC4) + { + DropPlayerItem("weapon_c4"); + SetProgressBarTime(0); + } + else if (m_bHasDefuser) + { + m_bHasDefuser = false; + pev->body = 0; + + GiveNamedItem("item_thighpack"); + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("defuser"); + MESSAGE_END(); + + SendItemStatus(this); } if (m_bIsDefusing) @@ -2206,40 +2210,40 @@ void CBasePlayer::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) SetProgressBarTime(0); } - m_bIsDefusing = false; + m_bIsDefusing = false; BuyZoneIcon_Clear(this); - SetThink(&CBasePlayer::PlayerDeathThink); - pev->nextthink = gpGlobals->time + 0.1; - pev->solid = SOLID_NOT; + SetThink(&CBasePlayer::PlayerDeathThink); + pev->nextthink = gpGlobals->time + 0.1; + pev->solid = SOLID_NOT; - if (m_bPunishedForTK) - { - m_bPunishedForTK = false; - HintMessage("#Hint_cannot_play_because_tk", TRUE, TRUE); + if (m_bPunishedForTK) + { + m_bPunishedForTK = false; + HintMessage("#Hint_cannot_play_because_tk", TRUE, TRUE); } - if ((pev->health < -9000 && iGib != GIB_NEVER) || iGib == GIB_ALWAYS) - { - pev->solid = SOLID_NOT; - GibMonster(); - pev->effects |= EF_NODRAW; - - g_pGameRules->CheckWinConditions(); - - return; + if ((pev->health < -9000 && iGib != GIB_NEVER) || iGib == GIB_ALWAYS) + { + pev->solid = SOLID_NOT; + GibMonster(); + pev->effects |= EF_NODRAW; + + g_pGameRules->CheckWinConditions(); + + return; } - DeathSound(); - - pev->angles.x = 0; - pev->angles.z = 0; - - if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) - { - HintMessage("#Spec_Duck", TRUE, TRUE); - m_flDisplayHistory |= DHF_SPEC_DUCK; + DeathSound(); + + pev->angles.x = 0; + pev->angles.z = 0; + + if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) + { + HintMessage("#Spec_Duck", TRUE, TRUE); + m_flDisplayHistory |= DHF_SPEC_DUCK; } } @@ -2816,15 +2820,15 @@ void CBasePlayer::WaterMove(void) if (pev->health < 0.0f) return; - // waterlevel 0 - not in water - // waterlevel 1 - feet in water - // waterlevel 2 - waist in water + // waterlevel 0 - not in water + // waterlevel 1 - feet in water + // waterlevel 2 - waist in water // waterlevel 3 - head in water if (pev->waterlevel != 3) { - // not underwater - + // not underwater + // play 'up for air' sound if (pev->air_finished < gpGlobals->time) EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade1.wav", VOL_NORM, ATTN_NORM); @@ -2838,11 +2842,11 @@ void CBasePlayer::WaterMove(void) // if we took drowning damage, give it back slowly if (m_idrowndmg > m_idrownrestored) { - // set drowning damage bit. hack - dmg_drownrecover actually - // makes the time based damage code 'give back' health over time. - // make sure counter is cleared so we start count correctly. - - // NOTE: this actually causes the count to continue restarting + // set drowning damage bit. hack - dmg_drownrecover actually + // makes the time based damage code 'give back' health over time. + // make sure counter is cleared so we start count correctly. + + // NOTE: this actually causes the count to continue restarting // until all drowning damage is healed. m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; m_bitsDamageType |= DMG_DROWNRECOVER; @@ -2852,11 +2856,11 @@ void CBasePlayer::WaterMove(void) } else { - // fully under water + // fully under water // stop restoring damage while underwater m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; m_bitsDamageType &= ~DMG_DROWNRECOVER; - + // drown! if (gpGlobals->time > pev->air_finished) { @@ -2871,7 +2875,7 @@ void CBasePlayer::WaterMove(void) TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN); pev->pain_finished = gpGlobals->time + 1; - // track drowning damage, give it back when + // track drowning damage, give it back when // player finally takes a breath m_idrowndmg += pev->dmg; } @@ -3380,7 +3384,7 @@ void CBasePlayer::JoiningThink(void) MAKE_STRING_CLASS("player", pev); AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); - + pev->flags &= (FL_PROXY | FL_FAKECLIENT); pev->flags |= (FL_SPECTATOR | FL_CLIENT); @@ -3420,7 +3424,7 @@ void CBasePlayer::JoiningThink(void) WRITE_SHORT(0); WRITE_SHORT(m_iTeam); MESSAGE_END(); - + if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) { HintMessage("#Spec_Duck", TRUE, TRUE); @@ -3544,7 +3548,7 @@ void CBasePlayer::PlayerDeathThink(void) if (pev->flags & FL_ONGROUND) { float flForward = pev->velocity.Length() - 20; - + if (flForward <= 0) pev->velocity = g_vecZero; else @@ -3553,9 +3557,9 @@ void CBasePlayer::PlayerDeathThink(void) if (HasWeapons()) { - // we drop the guns here because weapons that have an area effect and can kill their user - // will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the - // player class sometimes is freed. It's safer to manipulate the weapons once we know + // we drop the guns here because weapons that have an area effect and can kill their user + // will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the + // player class sometimes is freed. It's safer to manipulate the weapons once we know // we aren't calling into any of their code anymore through the player pointer. PackDeadPlayerItems(); } @@ -3566,7 +3570,7 @@ void CBasePlayer::PlayerDeathThink(void) return; } - // once we're done animating our death and we're on the ground, we want to set movetype to None so our dead body won't do collisions and stuff anymore + // once we're done animating our death and we're on the ground, we want to set movetype to None so our dead body won't do collisions and stuff anymore // this prevents a bug where the dead body would go to a player's head if he walked over it while the dead player was clicking their button to respawn if (pev->movetype != MOVETYPE_NONE && (pev->flags & FL_ONGROUND)) pev->movetype = MOVETYPE_NONE; @@ -3582,8 +3586,8 @@ void CBasePlayer::PlayerDeathThink(void) BOOL fAnyButtonDown = (pev->button & ~IN_SCORE); - // if the player has been dead for one second longer than allowed by forcerespawn, - // forcerespawn isn't on. Send the player off to an intermission camera until they + // if the player has been dead for one second longer than allowed by forcerespawn, + // forcerespawn isn't on. Send the player off to an intermission camera until they // choose to respawn. if (g_pGameRules->IsMultiplayer()) { @@ -3675,7 +3679,7 @@ void CBasePlayer::StartDeathCam(void) /* <155616> ../cstrike/dlls/player.cpp:4190 */ void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) -{ +{ // clear any clientside entities attached to this player MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); WRITE_BYTE(TE_KILLPLAYERATTACHMENTS); @@ -3925,7 +3929,7 @@ void CBasePlayer::PlayerUse(void) if (m_afButtonPressed & IN_USE) EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_select.wav", 0.4, ATTN_NORM); - + if (((pev->button & IN_USE) && (caps & FCAP_CONTINUOUS_USE)) || ((m_afButtonPressed & IN_USE) && (caps & (FCAP_IMPULSE_USE | FCAP_ONOFF_USE)))) { @@ -3971,11 +3975,11 @@ void CBasePlayer::__MAKE_VHOOK(Jump)(void) return; if (pev->waterlevel >= 2) - { - return; + { + return; } - // jump velocity is sqrt( height * gravity * 2) + // jump velocity is sqrt( height * gravity * 2) // If this isn't the first frame pressing the jump button, break out. if (!(m_afButtonPressed & IN_JUMP)) { @@ -4016,24 +4020,24 @@ void CBasePlayer::__MAKE_VHOOK(Jump)(void) } } -// This is a glorious hack to find free space when you've crouched into some solid space -// Our crouching collisions do not work correctly for some reason and this is easier +// This is a glorious hack to find free space when you've crouched into some solid space +// Our crouching collisions do not work correctly for some reason and this is easier // than fixing the problem :( /* <155fe2> ../cstrike/dlls/player.cpp:4565 */ NOXREF void FixPlayerCrouchStuck(edict_t *pPlayer) { - TraceResult trace; - - // Move up as many as 18 pixels if the player is stuck. - for (int i = 0; i < 18; i++) - { - UTIL_TraceHull(pPlayer->v.origin, pPlayer->v.origin, dont_ignore_monsters, head_hull, pPlayer, &trace); - - if (trace.fStartSolid) - pPlayer->v.origin.z ++; - else - break; + TraceResult trace; + + // Move up as many as 18 pixels if the player is stuck. + for (int i = 0; i < 18; i++) + { + UTIL_TraceHull(pPlayer->v.origin, pPlayer->v.origin, dont_ignore_monsters, head_hull, pPlayer, &trace); + + if (trace.fStartSolid) + pPlayer->v.origin.z ++; + else + break; } } @@ -4151,248 +4155,248 @@ bool CBasePlayer::CanPlayerBuy(bool display) /* <15f9ac> ../cstrike/dlls/player.cpp:4717 */ void CBasePlayer::__MAKE_VHOOK(PreThink)(void) -{ - int buttonsChanged = (pev->button ^ m_afButtonLast); - - if (pev->button != m_afButtonLast) - m_fLastMovement = gpGlobals->time; - - m_afButtonPressed = (buttonsChanged & pev->button); // The changed ones still down are "pressed" - m_afButtonReleased = (buttonsChanged & (~pev->button)); // The ones not down are "released" - - m_hintMessageQueue.Update(this); - g_pGameRules->PlayerThink(this); - - if (g_fGameOver) - { - return; - } - - if (m_iJoiningState != JOINED) - { - JoiningThink(); - } - - if (m_bMissionBriefing) - { - if (m_afButtonPressed & (IN_ATTACK | IN_ATTACK2)) - { - m_afButtonPressed &= ~(IN_ATTACK | IN_ATTACK2); - RemoveLevelText(); - m_bMissionBriefing = false; - } - } - - UTIL_MakeVectors(pev->v_angle); - ItemPreFrame(); - WaterMove(); - - if (pev->flags & FL_ONGROUND) - { - if (m_flVelocityModifier < 1.0f) - { - float_precision modvel = m_flVelocityModifier + 0.01; - - m_flVelocityModifier = modvel; - pev->velocity = pev->velocity * modvel; - } - - if (m_flVelocityModifier > 1.0f) - m_flVelocityModifier = 1; - } - - if (m_flIdleCheckTime <= (double)gpGlobals->time || m_flIdleCheckTime == 0.0f) - { - m_flIdleCheckTime = gpGlobals->time + 5.0; - - double v25 = gpGlobals->time - m_fLastMovement; - - if (v25 > g_pGameRules->m_fMaxIdlePeriod) - { - if (!IsBot() && CVAR_GET_FLOAT("mp_autokick") != 0.0f) - { - UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Game_idle_kick\" (auto)\n", - STRING(pev->netname), - GETPLAYERUSERID(edict()), - GETPLAYERAUTHID(edict()), - GetTeam(m_iTeam)); - - UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_idle_kick", STRING(pev->netname)); - SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); - m_fLastMovement = gpGlobals->time; - } - } - } - - if (g_pGameRules && g_pGameRules->FAllowFlashlight()) - m_iHideHUD &= ~HIDEHUD_FLASHLIGHT; - else - m_iHideHUD |= HIDEHUD_FLASHLIGHT; - - // JOHN: checks if new client data (for HUD and view control) needs to be sent to the client - UpdateClientData(); - CheckTimeBasedDamage(); - CheckSuitUpdate(); - - // So the correct flags get sent to client asap. - if (m_afPhysicsFlags & PFLAG_ONTRAIN) - pev->flags |= FL_ONTRAIN; - else - pev->flags &= ~FL_ONTRAIN; - - // Observer Button Handling - if (IsObserver() && (m_afPhysicsFlags & PFLAG_OBSERVER)) - { - Observer_HandleButtons(); - Observer_CheckTarget(); - Observer_CheckProperties(); - return; - } - - if (pev->deadflag >= DEAD_DYING && pev->deadflag != DEAD_RESPAWNABLE) - { - PlayerDeathThink(); - return; - } - - CBaseEntity *pGroundEntity = Instance(pev->groundentity); - - if (pGroundEntity && pGroundEntity->Classify() == CLASS_VEHICLE) - pev->iuser4 = 1; - else - pev->iuser4 = 0; - - // Train speed control - if (m_afPhysicsFlags & PFLAG_ONTRAIN) - { - CBaseEntity *pTrain = Instance(pev->groundentity); - float vel; - - if (!pTrain) - { - TraceResult trainTrace; - // Maybe this is on the other side of a level transition - UTIL_TraceLine(pev->origin, pev->origin + Vector(0, 0, -38), ignore_monsters, ENT(pev), &trainTrace); - - // HACKHACK - Just look for the func_tracktrain classname - if (trainTrace.flFraction != 1.0f && trainTrace.pHit) - pTrain = Instance(trainTrace.pHit); - - if (!pTrain || !(pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) || !pTrain->OnControls(pev)) - { - m_iTrain = (TRAIN_NEW | TRAIN_OFF); - m_afPhysicsFlags &= ~PFLAG_ONTRAIN; - - ((CFuncVehicle *)pTrain)->m_pDriver = NULL; - return; - } - } - else if (!(pev->flags & FL_ONGROUND) || (pTrain->pev->spawnflags & SF_TRACKTRAIN_NOCONTROL)) - { - // Turn off the train if you jump, strafe, or the train controls go dead - m_iTrain = (TRAIN_NEW | TRAIN_OFF); - m_afPhysicsFlags &= ~PFLAG_ONTRAIN; - - ((CFuncVehicle *)pTrain)->m_pDriver = NULL; - return; - } - - pev->velocity = g_vecZero; - vel = 0; - - if (pTrain->Classify() == CLASS_VEHICLE) - { - if (pev->button & IN_FORWARD) - { - vel = 1; - pTrain->Use(this, this, USE_SET, vel); - } - - if (pev->button & IN_BACK) - { - vel = -1; - pTrain->Use(this, this, USE_SET, vel); - } - - if (pev->button & IN_MOVELEFT) - { - vel = 20; - pTrain->Use(this, this, USE_SET, vel); - } - if (pev->button & IN_MOVERIGHT) - { - vel = 30; - pTrain->Use(this, this, USE_SET, vel); - } - } - else - { - if (m_afButtonPressed & IN_FORWARD) - { - vel = 1; - pTrain->Use(this, this, USE_SET, vel); - } - else if (m_afButtonPressed & IN_BACK) - { - vel = -1; - pTrain->Use(this, this, USE_SET, vel); - } - } - - if (vel) - { - m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); - m_iTrain |= (TRAIN_ACTIVE | TRAIN_NEW); - } - } - else if (m_iTrain & TRAIN_ACTIVE) - { - // turn off train - m_iTrain = TRAIN_NEW; - } - - if (pev->button & IN_JUMP) - { - // If on a ladder, jump off the ladder - // else Jump - Jump(); - } - - // If trying to duck, already ducked, or in the process of ducking - if ((pev->button & IN_DUCK) || (pev->flags & FL_DUCKING) || (m_afPhysicsFlags & PFLAG_DUCKING)) - { - Duck(); - } - - if (!(pev->flags & FL_ONGROUND)) - { - m_flFallVelocity = -pev->velocity.z; - } - - // Clear out ladder pointer - m_hEnemy = NULL; - - if (m_afPhysicsFlags & PFLAG_ONBARNACLE) - { - pev->velocity = g_vecZero; - } - - if (!(m_flDisplayHistory & DHF_ROUND_STARTED) && CanPlayerBuy()) - { - HintMessage("#Hint_press_buy_to_purchase"); - m_flDisplayHistory |= DHF_ROUND_STARTED; - } - +{ + int buttonsChanged = (pev->button ^ m_afButtonLast); + + if (pev->button != m_afButtonLast) + m_fLastMovement = gpGlobals->time; + + m_afButtonPressed = (buttonsChanged & pev->button); // The changed ones still down are "pressed" + m_afButtonReleased = (buttonsChanged & (~pev->button)); // The ones not down are "released" + + m_hintMessageQueue.Update(this); + g_pGameRules->PlayerThink(this); + + if (g_fGameOver) + { + return; + } + + if (m_iJoiningState != JOINED) + { + JoiningThink(); + } + + if (m_bMissionBriefing) + { + if (m_afButtonPressed & (IN_ATTACK | IN_ATTACK2)) + { + m_afButtonPressed &= ~(IN_ATTACK | IN_ATTACK2); + RemoveLevelText(); + m_bMissionBriefing = false; + } + } + + UTIL_MakeVectors(pev->v_angle); + ItemPreFrame(); + WaterMove(); + + if (pev->flags & FL_ONGROUND) + { + if (m_flVelocityModifier < 1.0f) + { + float_precision modvel = m_flVelocityModifier + 0.01; + + m_flVelocityModifier = modvel; + pev->velocity = pev->velocity * modvel; + } + + if (m_flVelocityModifier > 1.0f) + m_flVelocityModifier = 1; + } + + if (m_flIdleCheckTime <= (double)gpGlobals->time || m_flIdleCheckTime == 0.0f) + { + m_flIdleCheckTime = gpGlobals->time + 5.0; + + double v25 = gpGlobals->time - m_fLastMovement; + + if (v25 > g_pGameRules->m_fMaxIdlePeriod) + { + if (!IsBot() && CVAR_GET_FLOAT("mp_autokick") != 0.0f) + { + UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Game_idle_kick\" (auto)\n", + STRING(pev->netname), + GETPLAYERUSERID(edict()), + GETPLAYERAUTHID(edict()), + GetTeam(m_iTeam)); + + UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_idle_kick", STRING(pev->netname)); + SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); + m_fLastMovement = gpGlobals->time; + } + } + } + + if (g_pGameRules && g_pGameRules->FAllowFlashlight()) + m_iHideHUD &= ~HIDEHUD_FLASHLIGHT; + else + m_iHideHUD |= HIDEHUD_FLASHLIGHT; + + // JOHN: checks if new client data (for HUD and view control) needs to be sent to the client + UpdateClientData(); + CheckTimeBasedDamage(); + CheckSuitUpdate(); + + // So the correct flags get sent to client asap. + if (m_afPhysicsFlags & PFLAG_ONTRAIN) + pev->flags |= FL_ONTRAIN; + else + pev->flags &= ~FL_ONTRAIN; + + // Observer Button Handling + if (IsObserver() && (m_afPhysicsFlags & PFLAG_OBSERVER)) + { + Observer_HandleButtons(); + Observer_CheckTarget(); + Observer_CheckProperties(); + return; + } + + if (pev->deadflag >= DEAD_DYING && pev->deadflag != DEAD_RESPAWNABLE) + { + PlayerDeathThink(); + return; + } + + CBaseEntity *pGroundEntity = Instance(pev->groundentity); + + if (pGroundEntity && pGroundEntity->Classify() == CLASS_VEHICLE) + pev->iuser4 = 1; + else + pev->iuser4 = 0; + + // Train speed control + if (m_afPhysicsFlags & PFLAG_ONTRAIN) + { + CBaseEntity *pTrain = Instance(pev->groundentity); + float vel; + + if (!pTrain) + { + TraceResult trainTrace; + // Maybe this is on the other side of a level transition + UTIL_TraceLine(pev->origin, pev->origin + Vector(0, 0, -38), ignore_monsters, ENT(pev), &trainTrace); + + // HACKHACK - Just look for the func_tracktrain classname + if (trainTrace.flFraction != 1.0f && trainTrace.pHit) + pTrain = Instance(trainTrace.pHit); + + if (!pTrain || !(pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) || !pTrain->OnControls(pev)) + { + m_iTrain = (TRAIN_NEW | TRAIN_OFF); + m_afPhysicsFlags &= ~PFLAG_ONTRAIN; + + ((CFuncVehicle *)pTrain)->m_pDriver = NULL; + return; + } + } + else if (!(pev->flags & FL_ONGROUND) || (pTrain->pev->spawnflags & SF_TRACKTRAIN_NOCONTROL)) + { + // Turn off the train if you jump, strafe, or the train controls go dead + m_iTrain = (TRAIN_NEW | TRAIN_OFF); + m_afPhysicsFlags &= ~PFLAG_ONTRAIN; + + ((CFuncVehicle *)pTrain)->m_pDriver = NULL; + return; + } + + pev->velocity = g_vecZero; + vel = 0; + + if (pTrain->Classify() == CLASS_VEHICLE) + { + if (pev->button & IN_FORWARD) + { + vel = 1; + pTrain->Use(this, this, USE_SET, vel); + } + + if (pev->button & IN_BACK) + { + vel = -1; + pTrain->Use(this, this, USE_SET, vel); + } + + if (pev->button & IN_MOVELEFT) + { + vel = 20; + pTrain->Use(this, this, USE_SET, vel); + } + if (pev->button & IN_MOVERIGHT) + { + vel = 30; + pTrain->Use(this, this, USE_SET, vel); + } + } + else + { + if (m_afButtonPressed & IN_FORWARD) + { + vel = 1; + pTrain->Use(this, this, USE_SET, vel); + } + else if (m_afButtonPressed & IN_BACK) + { + vel = -1; + pTrain->Use(this, this, USE_SET, vel); + } + } + + if (vel) + { + m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); + m_iTrain |= (TRAIN_ACTIVE | TRAIN_NEW); + } + } + else if (m_iTrain & TRAIN_ACTIVE) + { + // turn off train + m_iTrain = TRAIN_NEW; + } + + if (pev->button & IN_JUMP) + { + // If on a ladder, jump off the ladder + // else Jump + Jump(); + } + + // If trying to duck, already ducked, or in the process of ducking + if ((pev->button & IN_DUCK) || (pev->flags & FL_DUCKING) || (m_afPhysicsFlags & PFLAG_DUCKING)) + { + Duck(); + } + + if (!(pev->flags & FL_ONGROUND)) + { + m_flFallVelocity = -pev->velocity.z; + } + + // Clear out ladder pointer + m_hEnemy = NULL; + + if (m_afPhysicsFlags & PFLAG_ONBARNACLE) + { + pev->velocity = g_vecZero; + } + + if (!(m_flDisplayHistory & DHF_ROUND_STARTED) && CanPlayerBuy()) + { + HintMessage("#Hint_press_buy_to_purchase"); + m_flDisplayHistory |= DHF_ROUND_STARTED; + } + UpdateLocation(); } -// If player is taking time based damage, continue doing damage to player - -// this simulates the effect of being poisoned, gassed, dosed with radiation etc - -// anything that continues to do damage even after the initial contact stops. -// Update all time based damage counters, and shut off any that are done. - -// The m_bitsDamageType bit MUST be set if any damage is to be taken. -// This routine will detect the initial on value of the m_bitsDamageType +// If player is taking time based damage, continue doing damage to player - +// this simulates the effect of being poisoned, gassed, dosed with radiation etc - +// anything that continues to do damage even after the initial contact stops. +// Update all time based damage counters, and shut off any that are done. + +// The m_bitsDamageType bit MUST be set if any damage is to be taken. +// This routine will detect the initial on value of the m_bitsDamageType // and init the appropriate counter. Only processes damage every second. /* <156096> ../cstrike/dlls/player.cpp:5146 */ @@ -4401,7 +4405,7 @@ void CBasePlayer::CheckTimeBasedDamage(void) int i; BYTE bDuration = 0; //static float gtbdPrev = 0.0; - + if (!(m_bitsDamageType & DMG_TIMEBASED)) return; @@ -4409,7 +4413,7 @@ void CBasePlayer::CheckTimeBasedDamage(void) return; m_tbdPrev = gpGlobals->time; - + for (i = 0; i < CDMG_TIMEBASED; i++) { if (m_bitsDamageType & (DMG_PARALYZE << i)) @@ -4433,7 +4437,7 @@ void CBasePlayer::CheckTimeBasedDamage(void) { if (m_idrowndmg > m_idrownrestored) { - int idif = _min(m_idrowndmg - m_idrownrestored, 10); + int idif = Q_min(m_idrowndmg - m_idrownrestored, 10); TakeHealth(idif, DMG_GENERIC); m_idrownrestored += idif; } @@ -4586,7 +4590,7 @@ void CBasePlayer::SetNewPlayerModel(const char *modelName) m_modelIndexPlayer = pev->modelindex; } -// UpdatePlayerSound - updates the position of the player's +// UpdatePlayerSound - updates the position of the player's // reserved sound slot in the sound list. /* <1562a4> ../cstrike/dlls/player.cpp:5543 */ @@ -4606,14 +4610,14 @@ void CBasePlayer::UpdatePlayerSound(void) pSound->m_iType = bits_SOUND_NONE; - // now calculate the best target volume for the sound. If the player's weapon + // now calculate the best target volume for the sound. If the player's weapon // is louder than his body/movement, use the weapon volume, else, use the body volume. if (pev->flags & FL_ONGROUND) { iBodyVolume = pev->velocity.Length(); - // clamp the noise that can be made by the body, in case a push trigger, + // clamp the noise that can be made by the body, in case a push trigger, // weapon recoil, or anything shoves the player abnormally fast. if (iBodyVolume> 512) { @@ -4646,9 +4650,9 @@ void CBasePlayer::UpdatePlayerSound(void) // decay weapon volume over time so bits_SOUND_COMBAT stays set for a while m_iWeaponVolume -= 250 * gpGlobals->frametime; - // if target volume is greater than the player sound's current volume, we paste the new volume in - // immediately. If target is less than the current volume, current volume is not set immediately to the - // lower volume, rather works itself towards target volume over time. This gives monsters a much better chance + // if target volume is greater than the player sound's current volume, we paste the new volume in + // immediately. If target is less than the current volume, current volume is not set immediately to the + // lower volume, rather works itself towards target volume over time. This gives monsters a much better chance // to hear a sound, especially if they don't listen every frame. iVolume = pSound->m_iVolume; @@ -4672,7 +4676,7 @@ void CBasePlayer::UpdatePlayerSound(void) if (gpGlobals->time > m_flStopExtraSoundTime) { - // since the extra sound that a weapon emits only lasts for one client frame, we keep that sound around for a server frame or two + // since the extra sound that a weapon emits only lasts for one client frame, we keep that sound around for a server frame or two // after actual emission to make sure it gets heard. m_iExtraSoundTypes = 0; } @@ -4696,135 +4700,135 @@ void CBasePlayer::UpdatePlayerSound(void) /* <15a182> ../cstrike/dlls/player.cpp:5667 */ void CBasePlayer::__MAKE_VHOOK(PostThink)(void) -{ - // intermission or finale - if (g_fGameOver) - goto pt_end; - - if (!IsAlive()) - goto pt_end; - - // Handle Tank controlling - if (m_pTank != NULL) - { - // if they've moved too far from the gun, or selected a weapon, unuse the gun - if (m_pTank->OnControls(pev) && !pev->weaponmodel) - { - // try fire the gun - m_pTank->Use(this, this, USE_SET, 2); - } - else - { - // they've moved off the platform - m_pTank->Use(this, this, USE_OFF, 0); - m_pTank = NULL; - } - } - - // do weapon stuff - ItemPostFrame(); - - // check to see if player landed hard enough to make a sound - // falling farther than half of the maximum safe distance, but not as far a max safe distance will - // play a bootscrape sound, and no damage will be inflicted. Fallling a distance shorter than half - // of maximum safe distance will make no sound. Falling farther than max safe distance will play a - // fallpain sound, and damage will be inflicted based on how far the player fell - if ((pev->flags & FL_ONGROUND) && pev->health > 0.0f && m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD) - { - if (pev->watertype != CONTENT_WATER) - { - // after this point, we start doing damage - if (m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED) - { - float flFallDamage = g_pGameRules->FlPlayerFallDamage(this); - - //splat - if (flFallDamage > pev->health) - { - // note: play on item channel because we play footstep landing on body channel - EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); - } - if (flFallDamage > 0) - { - m_LastHitGroup = HITGROUP_GENERIC; - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), flFallDamage, DMG_FALL); - pev->punchangle.x = 0; - TheBots->OnEvent(EVENT_PLAYER_LANDED_FROM_HEIGHT, this); - } - } - } - - if (IsAlive()) - { - SetAnimation(PLAYER_WALK); - } - } - - if (pev->flags & FL_ONGROUND) - { - if (m_flFallVelocity > 64.0f && !g_pGameRules->IsMultiplayer()) - { - CSoundEnt::InsertSound(bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2); - } - m_flFallVelocity = 0; - } - - // select the proper animation for the player character - if (IsAlive()) - { - if (pev->velocity.x || pev->velocity.y) - { - if (((pev->velocity.x || pev->velocity.y) && (pev->flags & FL_ONGROUND)) || pev->waterlevel > 1) - SetAnimation(PLAYER_WALK); - } - else if (pev->gaitsequence != ACT_FLY) - SetAnimation(PLAYER_IDLE); - } - - StudioFrameAdvance(); - CheckPowerups(pev); - UpdatePlayerSound(); - -pt_end: -#ifdef CLIENT_WEAPONS - // Decay timers on weapons - // go through all of the weapons and make a list of the ones to pack - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - if (m_rgpPlayerItems[i]) - { - CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - - while (pPlayerItem != NULL) - { - CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); - - if (gun && gun->UseDecrement()) - { - gun->m_flNextPrimaryAttack = _max(gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0); - gun->m_flNextSecondaryAttack = _max(gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001); - - if (gun->m_flTimeWeaponIdle != 1000.0f) - { - gun->m_flTimeWeaponIdle = _max(gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001); - } - } - - pPlayerItem = pPlayerItem->m_pNext; - } - } - } - - m_flNextAttack -= gpGlobals->frametime; - - if (m_flNextAttack < -0.001) - m_flNextAttack = -0.001; -#endif // CLIENT_WEAPONS - - // Track button info so we can detect 'pressed' and 'released' buttons next frame - m_afButtonLast = pev->button; - m_iGaitsequence = pev->gaitsequence; - +{ + // intermission or finale + if (g_fGameOver) + goto pt_end; + + if (!IsAlive()) + goto pt_end; + + // Handle Tank controlling + if (m_pTank != NULL) + { + // if they've moved too far from the gun, or selected a weapon, unuse the gun + if (m_pTank->OnControls(pev) && !pev->weaponmodel) + { + // try fire the gun + m_pTank->Use(this, this, USE_SET, 2); + } + else + { + // they've moved off the platform + m_pTank->Use(this, this, USE_OFF, 0); + m_pTank = NULL; + } + } + + // do weapon stuff + ItemPostFrame(); + + // check to see if player landed hard enough to make a sound + // falling farther than half of the maximum safe distance, but not as far a max safe distance will + // play a bootscrape sound, and no damage will be inflicted. Fallling a distance shorter than half + // of maximum safe distance will make no sound. Falling farther than max safe distance will play a + // fallpain sound, and damage will be inflicted based on how far the player fell + if ((pev->flags & FL_ONGROUND) && pev->health > 0.0f && m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD) + { + if (pev->watertype != CONTENT_WATER) + { + // after this point, we start doing damage + if (m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED) + { + float flFallDamage = g_pGameRules->FlPlayerFallDamage(this); + + //splat + if (flFallDamage > pev->health) + { + // note: play on item channel because we play footstep landing on body channel + EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); + } + if (flFallDamage > 0) + { + m_LastHitGroup = HITGROUP_GENERIC; + TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), flFallDamage, DMG_FALL); + pev->punchangle.x = 0; + TheBots->OnEvent(EVENT_PLAYER_LANDED_FROM_HEIGHT, this); + } + } + } + + if (IsAlive()) + { + SetAnimation(PLAYER_WALK); + } + } + + if (pev->flags & FL_ONGROUND) + { + if (m_flFallVelocity > 64.0f && !g_pGameRules->IsMultiplayer()) + { + CSoundEnt::InsertSound(bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2); + } + m_flFallVelocity = 0; + } + + // select the proper animation for the player character + if (IsAlive()) + { + if (pev->velocity.x || pev->velocity.y) + { + if (((pev->velocity.x || pev->velocity.y) && (pev->flags & FL_ONGROUND)) || pev->waterlevel > 1) + SetAnimation(PLAYER_WALK); + } + else if (pev->gaitsequence != ACT_FLY) + SetAnimation(PLAYER_IDLE); + } + + StudioFrameAdvance(); + CheckPowerups(pev); + UpdatePlayerSound(); + +pt_end: +#ifdef CLIENT_WEAPONS + // Decay timers on weapons + // go through all of the weapons and make a list of the ones to pack + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + if (m_rgpPlayerItems[i]) + { + CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; + + while (pPlayerItem != NULL) + { + CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); + + if (gun && gun->UseDecrement()) + { + gun->m_flNextPrimaryAttack = Q_max(gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0f); + gun->m_flNextSecondaryAttack = Q_max(gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001f); + + if (gun->m_flTimeWeaponIdle != 1000.0f) + { + gun->m_flTimeWeaponIdle = Q_max(gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001f); + } + } + + pPlayerItem = pPlayerItem->m_pNext; + } + } + } + + m_flNextAttack -= gpGlobals->frametime; + + if (m_flNextAttack < -0.001) + m_flNextAttack = -0.001; +#endif // CLIENT_WEAPONS + + // Track button info so we can detect 'pressed' and 'released' buttons next frame + m_afButtonLast = pev->button; + m_iGaitsequence = pev->gaitsequence; + StudioProcessGait(); } @@ -4906,7 +4910,9 @@ CTSpawn: // skip over the null point if (FNullEnt(pSpot)) + { pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"); + } CBaseEntity *pFirstSpot = pSpot; @@ -5083,7 +5089,7 @@ void CBasePlayer::__MAKE_VHOOK(Spawn)(void) pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_WALK; pev->max_health = pev->health; - + pev->flags &= FL_PROXY; pev->flags |= FL_CLIENT; pev->air_finished = gpGlobals->time + 12; @@ -5153,7 +5159,7 @@ void CBasePlayer::__MAKE_VHOOK(Spawn)(void) m_canSwitchObserverModes = true; m_lastLocation[0] = '\0'; - + m_bitsDamageType &= ~(DMG_DROWN | DMG_DROWNRECOVER); m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; m_idrowndmg = 0; @@ -5267,7 +5273,7 @@ void CBasePlayer::__MAKE_VHOOK(Spawn)(void) { ALERT(at_console, "Couldn't alloc player sound slot!\n"); } - + m_iHideHUD &= ~(HIDEHUD_WEAPONS | HIDEHUD_HEALTH | HIDEHUD_TIMER | HIDEHUD_MONEY); m_fNoPlayerSound = FALSE; m_pLastItem = NULL; @@ -5474,7 +5480,7 @@ int CBasePlayer::__MAKE_VHOOK(Restore)(CRestore &restore) { if (!CBaseMonster::Restore(restore)) return 0; - + int status = restore.ReadFields("PLAYER", this, IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData), ARRAYSIZE(IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData))); SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; @@ -5494,12 +5500,12 @@ int CBasePlayer::__MAKE_VHOOK(Restore)(CRestore &restore) m_bloodColor = BLOOD_COLOR_RED; m_modelIndexPlayer = pev->modelindex; - + if (pev->flags & FL_DUCKING) UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); else UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); - + m_flDisplayHistory &= ~DHM_CONNECT_CLEAR; SetScoreboardAttributes(); @@ -5813,7 +5819,7 @@ void CBasePlayer::GiveNamedItem(const char *pszName) { string_t istr = MAKE_STRING(pszName); edict_t *pent = CREATE_NAMED_ENTITY(istr); - + if (FNullEnt(pent)) { ALERT(at_console, "NULL Ent in GiveNamedItem!\n"); @@ -6138,7 +6144,7 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse) dir.NormalizeInPlace(); else dir.z = -1.0f; - + UTIL_TraceLine(EyePosition(), EyePosition() + dir * bloodRange, ignore_monsters, pev->pContainingEntity, &tr); if (tr.flFraction < 1.0f) @@ -6372,12 +6378,12 @@ int CBasePlayer::__MAKE_VHOOK(GiveAmmo)(int iCount, char *szName, int iMax) return -1; } - int i = GetAmmoIndex( szName ); + int i = GetAmmoIndex(szName); if (i < 0 || i >= MAX_AMMO_SLOTS) return -1; - int iAdd = _min(iCount, iMax - m_rgAmmo[i]); + int iAdd = Q_min(iCount, iMax - m_rgAmmo[i]); if (iAdd < 1) return i; @@ -6487,7 +6493,7 @@ void CBasePlayer::SendAmmoUpdate(void) // send "Ammo" update message MESSAGE_BEGIN(MSG_ONE, gmsgAmmoX, NULL, pev); WRITE_BYTE(i); - WRITE_BYTE( _max( _min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte + WRITE_BYTE(Q_max(Q_min(m_rgAmmo[i], 254), 0)); // clamp the value to one byte MESSAGE_END(); } } @@ -6593,6 +6599,8 @@ void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) MESSAGE_BEGIN(MSG_ONE, gmsgResetHUD, NULL, pev); MESSAGE_END(); + CHalfLifeMultiplay *mp = g_pGameRules; + if (!m_fGameHUDInitialized) { MESSAGE_BEGIN(MSG_ONE, gmsgInitHUD, NULL, pev); @@ -6646,10 +6654,10 @@ void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) MESSAGE_END(); } - g_pGameRules->InitHUD(this); + mp->InitHUD(this); m_fGameHUDInitialized = TRUE; - if (g_pGameRules->IsMultiplayer()) + if (mp->IsMultiplayer()) { FireTargets("game_playerjoin", this, this, USE_TOGGLE, 0); } @@ -6683,16 +6691,16 @@ void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) SendHostagePos(); SendWeatherInfo(); - if (g_pGameRules->IsMultiplayer()) + if (mp->IsMultiplayer()) { MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pev); WRITE_STRING(GetTeam(CT)); - WRITE_SHORT(g_pGameRules->m_iNumCTWins); + WRITE_SHORT(mp->m_iNumCTWins); MESSAGE_END(); MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pev); WRITE_STRING(GetTeam(TERRORIST)); - WRITE_SHORT(g_pGameRules->m_iNumTerroristWins); + WRITE_SHORT(mp->m_iNumTerroristWins); MESSAGE_END(); } } @@ -6838,7 +6846,7 @@ void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) MESSAGE_BEGIN(MSG_ONE, gmsgTrain, NULL, pev); WRITE_BYTE(m_iTrain & 0xF); MESSAGE_END(); - + m_iTrain &= ~TRAIN_NEW; } @@ -6864,7 +6872,7 @@ void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) UpdateStatusBar(); m_flNextSBarUpdateTime = gpGlobals->time + 0.2; } - + if (!(m_flDisplayHistory & DHF_AMMO_EXHAUSTED)) { if (m_pActiveItem && m_pActiveItem->IsWeapon()) @@ -6873,7 +6881,7 @@ void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) if (!(w->iFlags() & ITEM_FLAG_EXHAUSTIBLE)) { - if (AmmoInventory( w->m_iPrimaryAmmoType ) < 1 && w->m_iClip == 0) + if (AmmoInventory(w->m_iPrimaryAmmoType) < 1 && w->m_iClip == 0) { m_flDisplayHistory |= DHF_AMMO_EXHAUSTED; HintMessage("#Hint_out_of_ammo"); @@ -7150,7 +7158,7 @@ void CBasePlayer::UpdateStatusBar(void) { CBasePlayer *pTarget = (CBasePlayer *)pEntity; - newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX( pTarget->edict() ); + newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX(pTarget->edict()); newSBarState[ SBAR_ID_TARGETTYPE ] = (pTarget->m_iTeam == m_iTeam) ? SBAR_TARGETTYPE_TEAMMATE : SBAR_TARGETTYPE_ENEMY; if (pTarget->m_iTeam == m_iTeam || IsObserver()) @@ -7388,8 +7396,10 @@ void CBasePlayer::DropPlayerItem(const char *pszItemName) const char *modelname = GetCSModelName(pWeapon->m_iId); - if (modelname) + if (modelname != NULL) + { SET_MODEL(ENT(pWeaponBox->pev), modelname); + } return; } @@ -7416,7 +7426,7 @@ BOOL CBasePlayer::HasNamedPlayerItem(const char *pszItemName) CBasePlayerItem *pItem; int i; - for (i = 0; i < MAX_ITEM_TYPES ; i++) + for (i = 0; i < MAX_ITEM_TYPES; i++) { pItem = m_rgpPlayerItems[ i ]; @@ -7602,15 +7612,15 @@ void CBasePlayer::SwitchTeam(void) { bool kick = false; - if (m_iTeam == CT && !pProfile->IsValidForTeam( BOT_TEAM_CT )) + if (m_iTeam == CT && !pProfile->IsValidForTeam(BOT_TEAM_CT)) kick = true; - else if (m_iTeam == TERRORIST && !pProfile->IsValidForTeam( BOT_TEAM_T )) + else if (m_iTeam == TERRORIST && !pProfile->IsValidForTeam(BOT_TEAM_T)) kick = true; if (kick) { - SERVER_COMMAND( UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname)) ); + SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); } } } @@ -7856,7 +7866,7 @@ void CBasePlayer::StudioEstimateGait(void) m_prevgaitorigin = pev->origin; m_flGaitMovement = est_velocity.Length(); - + if (dt <= 0 || m_flGaitMovement / dt < 5) { m_flGaitMovement = 0; @@ -7920,7 +7930,7 @@ void CBasePlayer::StudioPlayerBlend(int *pBlend, float *pPitch) { // calc up/down pointing float range = (float)(int64_t)(*pPitch * 3.0f); - + *pBlend = range; if (range <= -45.0f) @@ -8053,7 +8063,7 @@ void CBasePlayer::ResetStamina(void) } /* <15a467> ../cstrike/dlls/player.cpp:9829 */ -float GetPlayerPitch(const edict_t *pEdict) +float_precision GetPlayerPitch(const edict_t *pEdict) { entvars_t *pev = VARS((edict_t *)pEdict); CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); @@ -8065,7 +8075,7 @@ float GetPlayerPitch(const edict_t *pEdict) } /* <15a530> ../cstrike/dlls/player.cpp:9846 */ -float GetPlayerYaw(const edict_t *pEdict) +float_precision GetPlayerYaw(const edict_t *pEdict) { entvars_t *pev = VARS((edict_t *)pEdict); CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); @@ -8177,7 +8187,7 @@ BOOL CBasePlayer::ShouldDoLargeFlinch(int nHitGroup, int nGunType) void CBasePlayer::SetPrefsFromUserinfo(char *infobuffer) { const char *pszKeyVal; - + pszKeyVal = GET_KEY_VALUE(infobuffer, "_cl_autowepswitch"); if (Q_strcmp(pszKeyVal, "")) @@ -8204,7 +8214,7 @@ void CBasePlayer::SetPrefsFromUserinfo(char *infobuffer) bool CBasePlayer::IsLookingAtPosition(Vector *pos, float angleTolerance) { Vector to = *pos - EyePosition(); - Vector idealAngle = UTIL_VecToAngles( to ); + Vector idealAngle = UTIL_VecToAngles(to); idealAngle.x = 360.0 - idealAngle.x; @@ -8492,7 +8502,7 @@ void CBasePlayer::AutoBuy(void) } if (TheTutor) - TheTutor->OnEvent( EVENT_PLAYER_LEFT_BUY_ZONE ); + TheTutor->OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE); } /* <14ea4e> ../cstrike/dlls/player.cpp:10556 */ @@ -8505,7 +8515,7 @@ bool IsPrimaryWeaponClass(int classId) bool IsPrimaryWeaponId(int id) { int classId = WEAPONCLASS_NONE; - const char *alias = WeaponIDToAlias( id ); + const char *alias = WeaponIDToAlias(id); if (alias) { @@ -8525,7 +8535,7 @@ bool IsSecondaryWeaponClass(int classId) bool IsSecondaryWeaponId(int id) { int classId = WEAPONCLASS_NONE; - const char *alias = WeaponIDToAlias( id ); + const char *alias = WeaponIDToAlias(id); if (alias) { @@ -8676,7 +8686,7 @@ const char *CBasePlayer::PickFlashKillWeaponString(void) if (foundOne) return "flash flash"; - + return NULL; } @@ -8698,7 +8708,7 @@ const char *CBasePlayer::PickGrenadeKillWeaponString(void) if (foundOne) return "hegren"; - + return NULL; } @@ -9133,7 +9143,7 @@ void CBasePlayer::UpdateLocation(bool forceUpdate) if (pev->deadflag == DEAD_NO && UTIL_IsGame("czero")) { // search the place name where is located the player - Place playerPlace = TheNavAreaGrid.GetPlace( &pev->origin ); + Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) @@ -9156,7 +9166,7 @@ void CBasePlayer::UpdateLocation(bool forceUpdate) for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex( i ); + CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i); if (!player) continue; diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 70b3e3ce..026eb11d 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -123,6 +123,11 @@ #define CHAT_INTERVAL 1.0f #define CSUITNOREPEAT 32 +#define AUTOAIM_2DEGREES 0.0348994967025 +#define AUTOAIM_5DEGREES 0.08715574274766 +#define AUTOAIM_8DEGREES 0.1391731009601 +#define AUTOAIM_10DEGREES 0.1736481776669 + //#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" //#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" @@ -708,7 +713,7 @@ public: void ResetAutoaim(void); Vector AutoaimDeflection(Vector &vecSrc, float flDist, float flDelta); void ForceClientDllUpdate(void); - void DeathMessage(entvars_t *pevAttacker) { }; + void DeathMessage(entvars_t *pevAttacker) {}; void SetCustomDecalFrames(int nFrames); int GetCustomDecalFrames(void); void InitStatusBar(void); @@ -1169,8 +1174,8 @@ NOXREF CBaseEntity *FindZombieSpawn(CBaseEntity *player, bool forceSpawn); edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer); void SetScoreAttrib(CBasePlayer *dest, CBasePlayer *src); CBaseEntity *FindEntityForward(CBaseEntity *pMe); -float GetPlayerPitch(const edict_t *pEdict); -float GetPlayerYaw(const edict_t *pEdict); +float_precision GetPlayerPitch(const edict_t *pEdict); +float_precision GetPlayerYaw(const edict_t *pEdict); int GetPlayerGaitsequence(const edict_t *pEdict); const char *GetBuyStringForWeaponClass(int weaponClass); bool IsPrimaryWeaponClass(int classId); diff --git a/regamedll/dlls/saverestore.h b/regamedll/dlls/saverestore.h index 7eb45f08..4c0d79b3 100644 --- a/regamedll/dlls/saverestore.h +++ b/regamedll/dlls/saverestore.h @@ -220,9 +220,7 @@ public: GLOBALESTATE EntityGetState(string_t globalname); int EntityInTable(string_t globalname) { - if (Find(globalname) != NULL) - return 1; - return 0; + return (Find(globalname) != NULL) ? 1 : 0; } int Save(CSave &save); int Restore(CRestore &restore); diff --git a/regamedll/dlls/skill.cpp b/regamedll/dlls/skill.cpp index b96cc3e0..84e17428 100644 --- a/regamedll/dlls/skill.cpp +++ b/regamedll/dlls/skill.cpp @@ -3,7 +3,7 @@ skilldata_t gSkillData; // take the name of a cvar, tack a digit for the skill level -// on, and return the value.of that Cvar +// on, and return the value.of that Cvar /* <16a558> ../cstrike/dlls/skill.cpp:30 */ NOXREF float GetSkillCvar(char *pName) diff --git a/regamedll/dlls/skill.h b/regamedll/dlls/skill.h index 8970cb0b..7fde7375 100644 --- a/regamedll/dlls/skill.h +++ b/regamedll/dlls/skill.h @@ -66,4 +66,4 @@ extern skilldata_t gSkillData; NOXREF float GetSkillCvar(char *pName); -#endif // SKILL_H \ No newline at end of file +#endif // SKILL_H diff --git a/regamedll/dlls/sound.cpp b/regamedll/dlls/sound.cpp index b1d53d26..a332bf88 100644 --- a/regamedll/dlls/sound.cpp +++ b/regamedll/dlls/sound.cpp @@ -3,35 +3,37 @@ #ifndef HOOK_GAMEDLL -UNTESTED dynpitchvol_t rgdpvpreset[27] = +// presets for runtime pitch and vol modulation of ambient sounds +UNTESTED dynpitchvol_t rgdpvpreset[CDPVPRESETMAX] = { - { 1, 255, 75, 95, 95, 10, 1, 50, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 2, 255, 85, 70, 88, 10, 1, 20, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 3, 255, 100, 50, 75, 10, 1, 10, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 4, 100, 100, 0, 0, 10, 1, 90, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 5, 100, 100, 0, 0, 10, 1, 80, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 6, 100, 100, 0, 0, 10, 1, 50, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 7, 100, 100, 0, 0, 5, 1, 40, 50, 1, 50, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 8, 100, 100, 0, 0, 5, 1, 40, 50, 1, 150, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 9, 100, 100, 0, 0, 5, 1, 40, 50, 1, 750, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 10, 128, 100, 50, 75, 10, 1, 30, 40, 2, 8, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 11, 128, 100, 50, 75, 10, 1, 30, 40, 2, 25, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 12, 128, 100, 50, 75, 10, 1, 30, 40, 2, 70, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 13, 50, 50, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 14, 70, 70, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 15, 90, 90, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 16, 120, 120, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 17, 180, 180, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 18, 255, 255, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 19, 200, 75, 90, 90, 10, 1, 50, 90, 2, 100, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 20, 255, 75, 97, 90, 10, 1, 50, 90, 1, 40, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 21, 100, 100, 0, 0, 10, 1, 30, 50, 3, 15, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 22, 160, 160, 0, 0, 10, 1, 50, 50, 3, 500, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 23, 255, 75, 88, 0, 10, 1, 40, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 24, 200, 20, 95, 70, 10, 1, 70, 70, 3, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 25, 180, 100, 50, 60, 10, 1, 40, 60, 2, 90, 100, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 26, 60, 60, 0, 0, 10, 1, 40, 70, 3, 80, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 27, 128, 90, 10, 10, 10, 1, 20, 40, 1, 5, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + // pitch prun pstart spinup spindwn volrun volstrt fadein fadeout lfotype lforate lfomodp modvol cspnup cspnct pitch spupsv spdwnsv pfrac vol fdinsv fdotsv volfrac lfofrac lfomult + { 1, 255, 75, 95, 95, 10, 1, 50, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 2, 255, 85, 70, 88, 10, 1, 20, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 3, 255, 100, 50, 75, 10, 1, 10, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 4, 100, 100, 0, 0, 10, 1, 90, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 5, 100, 100, 0, 0, 10, 1, 80, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 6, 100, 100, 0, 0, 10, 1, 50, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 7, 100, 100, 0, 0, 5, 1, 40, 50, 1, 50, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 8, 100, 100, 0, 0, 5, 1, 40, 50, 1, 150, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 9, 100, 100, 0, 0, 5, 1, 40, 50, 1, 750, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 10, 128, 100, 50, 75, 10, 1, 30, 40, 2, 8, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 11, 128, 100, 50, 75, 10, 1, 30, 40, 2, 25, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 12, 128, 100, 50, 75, 10, 1, 30, 40, 2, 70, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 13, 50, 50, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 14, 70, 70, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 15, 90, 90, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 16, 120, 120, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 17, 180, 180, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 18, 255, 255, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 19, 200, 75, 90, 90, 10, 1, 50, 90, 2, 100, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 20, 255, 75, 97, 90, 10, 1, 50, 90, 1, 40, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 21, 100, 100, 0, 0, 10, 1, 30, 50, 3, 15, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 22, 160, 160, 0, 0, 10, 1, 50, 50, 3, 500, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 23, 255, 75, 88, 0, 10, 1, 40, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 24, 200, 20, 95, 70, 10, 1, 70, 70, 3, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 25, 180, 100, 50, 60, 10, 1, 40, 60, 2, 90, 100, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 26, 60, 60, 0, 0, 10, 1, 40, 70, 3, 80, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 27, 128, 90, 10, 10, 10, 1, 20, 40, 1, 5, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; int gcallsentences = 0; @@ -42,6 +44,12 @@ TYPEDESCRIPTION CAmbientGeneric::m_SaveData[] = DEFINE_FIELD(CAmbientGeneric, m_flAttenuation, FIELD_FLOAT), DEFINE_FIELD(CAmbientGeneric, m_fActive, FIELD_BOOLEAN), DEFINE_FIELD(CAmbientGeneric, m_fLooping, FIELD_BOOLEAN), + + // HACKHACK - This is not really in the spirit of the save/restore design, but save this + // out as a binary data block. If the dynpitchvol_t is changed, old saved games will NOT + // load these correctly, so bump the save/restore version if you change the size of the struct + // The right way to do this is to split the input parms (read in keyvalue) into members and re-init this + // struct in Precache(), but it's unlikely that the struct will change, so it's not worth the time right now. DEFINE_ARRAY(CAmbientGeneric, m_dpv, FIELD_CHARACTER, sizeof(dynpitchvol_t)), }; @@ -58,16 +66,19 @@ TYPEDESCRIPTION CSpeaker::m_SaveData[] = #else -//dynpitchvol_t rgdpvpreset[27] +dynpitchvol_t rgdpvpreset[CDPVPRESETMAX]; int fSentencesInit; int gcallsentences; -TYPEDESCRIPTION (*CAmbientGeneric::pm_SaveData)[4]; -TYPEDESCRIPTION (*CEnvSound::pm_SaveData)[2]; -TYPEDESCRIPTION (*CSpeaker::pm_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CAmbientGeneric, m_SaveData)[4]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CEnvSound, m_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CSpeaker, m_SaveData)[1]; #endif // HOOK_GAMEDLL +// time delay until it's ok to speak: used so that two NPCs don't talk at once +float CTalkMonster::g_talkWaitTime = 0; + char gszallsentencenames[ CVOXFILESENTENCEMAX ][ CBSENTENCENAME_MAX ]; sentenceg rgsentenceg[ CSENTENCEG_MAX ]; @@ -82,110 +93,787 @@ LINK_ENTITY_TO_CLASS(ambient_generic, CAmbientGeneric); /* <171c1f> ../cstrike/dlls/sound.cpp:155 */ IMPLEMENT_SAVERESTORE(CAmbientGeneric, CBaseEntity); +// -1 : "Default" +// 0 : "Everywhere" +// 200 : "Small Radius" +// 125 : "Medium Radius" +// 80 : "Large Radius" + /* <1718ea> ../cstrike/dlls/sound.cpp:160 */ -NOBODY void CAmbientGeneric::Spawn(void) +void CAmbientGeneric::__MAKE_VHOOK(Spawn)(void) { -// { -// char *szSoundFile; // 191 -// } + if (pev->spawnflags & AMBIENT_SOUND_EVERYWHERE) + { + m_flAttenuation = ATTN_NONE; + } + else if (pev->spawnflags & AMBIENT_SOUND_SMALLRADIUS) + { + m_flAttenuation = ATTN_IDLE; + } + else if (pev->spawnflags & AMBIENT_SOUND_MEDIUMRADIUS) + { + m_flAttenuation = ATTN_STATIC; + } + else if (pev->spawnflags & AMBIENT_SOUND_LARGERADIUS) + { + m_flAttenuation = ATTN_NORM; + } + else + { + // if the designer didn't set a sound attenuation, default to one. + m_flAttenuation = ATTN_STATIC; + } + + char *szSoundFile = (char *)STRING(pev->message); + + if (FStringNull(pev->message) || Q_strlen(szSoundFile) < 1) + { + ALERT(at_error, "EMPTY AMBIENT AT: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z); + pev->nextthink = gpGlobals->time + 0.1f; + SetThink(&CAmbientGeneric::SUB_Remove); + return; + } + + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + + // Set up think function for dynamic modification + // of ambient sound's pitch or volume. Don't + // start thinking yet. + + SetThink(&CAmbientGeneric::RampThink); + pev->nextthink = 0; + + // allow on/off switching via 'use' function. + SetUse(&CAmbientGeneric::ToggleUse); + + m_fActive = FALSE; + + if (pev->spawnflags & AMBIENT_SOUND_NOT_LOOPING) + m_fLooping = FALSE; + else + m_fLooping = TRUE; + + Precache(); } /* <1724f8> ../cstrike/dlls/sound.cpp:223 */ -NOBODY void CAmbientGeneric::Restart(void) +void CAmbientGeneric::__MAKE_VHOOK(Restart)(void) { -// { -// char *szSoundFile; // 247 -// } + if (pev->spawnflags & AMBIENT_SOUND_EVERYWHERE) + { + m_flAttenuation = ATTN_NONE; + } + else if (pev->spawnflags & AMBIENT_SOUND_SMALLRADIUS) + { + m_flAttenuation = ATTN_IDLE; + } + else if (pev->spawnflags & AMBIENT_SOUND_MEDIUMRADIUS) + { + m_flAttenuation = ATTN_STATIC; + } + else if (pev->spawnflags & AMBIENT_SOUND_LARGERADIUS) + { + m_flAttenuation = ATTN_NORM; + } + else + { + // if the designer didn't set a sound attenuation, default to one. + m_flAttenuation = ATTN_STATIC; + } + + char *szSoundFile = (char *)STRING(pev->message); + + if (FStringNull(pev->message) || Q_strlen(szSoundFile) < 1) + { + ALERT(at_error, "EMPTY AMBIENT AT: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z); + pev->nextthink = gpGlobals->time + 0.1f; + SetThink(&CBaseEntity::SUB_Remove); + return; + } + + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + + // Set up think function for dynamic modification + // of ambient sound's pitch or volume. Don't + // start thinking yet. + SetThink(&CAmbientGeneric::RampThink); + pev->nextthink = 0; + + // allow on/off switching via 'use' function. + SetUse(&CAmbientGeneric::ToggleUse); + + m_fActive = FALSE; + + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 0, 0, SND_STOP, 0); + InitModulationParms(); + pev->nextthink = gpGlobals->time + 0.1; + + if (!(pev->spawnflags & AMBIENT_SOUND_NOT_LOOPING)) + { + m_fLooping = TRUE; + m_fActive = TRUE; + } + else + m_fLooping = FALSE; + + if (m_fActive) + { + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, (m_dpv.vol * 0.01), m_flAttenuation, 0, m_dpv.pitch); + } } /* <1724bb> ../cstrike/dlls/sound.cpp:296 */ -NOBODY void CAmbientGeneric::Precache(void) +void CAmbientGeneric::__MAKE_VHOOK(Precache)(void) { -// { -// char *szSoundFile; // 298 -// } + char *szSoundFile = (char *)STRING(pev->message); + + if (!FStringNull(pev->message) && Q_strlen(szSoundFile) > 1) + { + if (*szSoundFile != '!') + { + PRECACHE_SOUND(szSoundFile); + } + } + + // init all dynamic modulation parms + InitModulationParms(); + + if (!(pev->spawnflags & AMBIENT_SOUND_START_SILENT)) + { + // start the sound ASAP + if (m_fLooping) + { + m_fActive = TRUE; + } + } + + if (m_fActive) + { + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, (m_dpv.vol * 0.01), m_flAttenuation, SND_SPAWNING, m_dpv.pitch); + pev->nextthink = gpGlobals->time + 0.1f; + } } +// RampThink - Think at 5hz if we are dynamically modifying +// pitch or volume of the playing sound. This function will +// ramp pitch and/or volume up or down, modify pitch/volume +// with lfo if active. + /* <171973> ../cstrike/dlls/sound.cpp:328 */ -NOBODY void CAmbientGeneric::RampThink(void) +void CAmbientGeneric::RampThink(void) { -// { -// char *szSoundFile; // 330 -// int pitch; // 331 -// int vol; // 332 -// int flags; // 333 -// int fChanged; // 334 -// int prev; // 335 -// { -// int pos; // 429 -// } -// } + char *szSoundFile = (char *)STRING(pev->message); + int pitch = m_dpv.pitch; + int vol = m_dpv.vol; + int flags = 0; + int fChanged = 0; // FALSE if pitch and vol remain unchanged this round + int prev; + + if (!m_dpv.spinup && !m_dpv.spindown && !m_dpv.fadein && !m_dpv.fadeout && !m_dpv.lfotype) + { + // no ramps or lfo, stop thinking + return; + } + + // pitch envelope + if (m_dpv.spinup || m_dpv.spindown) + { + prev = m_dpv.pitchfrac >> 8; + + if (m_dpv.spinup > 0) + { + m_dpv.pitchfrac += m_dpv.spinup; + } + else if (m_dpv.spindown > 0) + { + m_dpv.pitchfrac -= m_dpv.spindown; + } + + pitch = m_dpv.pitchfrac >> 8; + + if (pitch > m_dpv.pitchrun) + { + pitch = m_dpv.pitchrun; + m_dpv.spinup = 0; // done with ramp up + } + + if (pitch < m_dpv.pitchstart) + { + pitch = m_dpv.pitchstart; + m_dpv.spindown = 0; // done with ramp down + + // shut sound off + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 0, 0, SND_STOP, 0); + + // return without setting nextthink + return; + } + + // pitch clamp + if (pitch > 255) + pitch = 255; + if (pitch < 1) + pitch = 1; + + //pitch = Q_max(1, Q_min(255, pitch)); + + m_dpv.pitch = pitch; + + fChanged |= (prev != pitch); + flags |= SND_CHANGE_PITCH; + } + + // amplitude envelope + if (m_dpv.fadein || m_dpv.fadeout) + { + prev = m_dpv.volfrac >> 8; + + if (m_dpv.fadein > 0) + { + m_dpv.volfrac += m_dpv.fadein; + } + else if (m_dpv.fadeout > 0) + { + m_dpv.volfrac -= m_dpv.fadeout; + } + + vol = m_dpv.volfrac >> 8; + + if (vol > m_dpv.volrun) + { + vol = m_dpv.volrun; + m_dpv.fadein = 0; // done with ramp up + } + + if (vol < m_dpv.volstart) + { + vol = m_dpv.volstart; + m_dpv.fadeout = 0; // done with ramp down + + // shut sound off + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 0, 0, SND_STOP, 0); + + // return without setting nextthink + return; + } + + // volume clamp + if (vol > 100) + vol = 100; + if (vol < 1) + vol = 1; + + //vol = Q_max(1, Q_min(100, vol)); + + m_dpv.vol = vol; + + fChanged |= (prev != vol); + flags |= SND_CHANGE_VOL; + } + + // pitch/amplitude LFO + if (m_dpv.lfotype) + { + int pos; + + if (m_dpv.lfofrac > 0x6fffffff) + m_dpv.lfofrac = 0; + + // update lfo, lfofrac/255 makes a triangle wave 0-255 + m_dpv.lfofrac += m_dpv.lforate; + pos = m_dpv.lfofrac >> 8; + + if (m_dpv.lfofrac < 0) + { + m_dpv.lfofrac = 0; + m_dpv.lforate = abs(m_dpv.lforate); + pos = 0; + } + else if (pos > 255) + { + pos = 255; + m_dpv.lfofrac = (255 << 8); + m_dpv.lforate = -abs(m_dpv.lforate); + } + + switch (m_dpv.lfotype) + { + case LFO_SQUARE: + if (pos < 128) + m_dpv.lfomult = 255; + else + m_dpv.lfomult = 0; + + break; + case LFO_RANDOM: + if (pos == 255) + m_dpv.lfomult = RANDOM_LONG(0, 255); + break; + case LFO_TRIANGLE: + default: + m_dpv.lfomult = pos; + break; + } + + if (m_dpv.lfomodpitch) + { + prev = pitch; + + // pitch 0-255 + pitch += ((m_dpv.lfomult - 128) * m_dpv.lfomodpitch) / 100; + + // pitch clamp + if (pitch > 255) + pitch = 255; + if (pitch < 1) + pitch = 1; + + //pitch = Q_max(1, Q_min(255, pitch)); + + fChanged |= (prev != pitch); + flags |= SND_CHANGE_PITCH; + } + + if (m_dpv.lfomodvol) + { + // vol 0-100 + prev = vol; + + vol += ((m_dpv.lfomult - 128) * m_dpv.lfomodvol) / 100; + + // volume clamp + if (vol > 100) + vol = 100; + if (vol < 0) + vol = 0; + + fChanged |= (prev != vol); + flags |= SND_CHANGE_VOL; + } + } + + // Send update to playing sound only if we actually changed + // pitch or volume in this routine. + if (flags && fChanged) + { + if (pitch == PITCH_NORM) + { + // don't send 'no pitch' ! + pitch = PITCH_NORM + 1; + } + + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, (vol * 0.01), m_flAttenuation, flags, pitch); + } + + // update ramps at 5hz + pev->nextthink = gpGlobals->time + 0.2; + return; } +// Init all ramp params in preparation to +// play a new sound + /* <1723db> ../cstrike/dlls/sound.cpp:521 */ -NOBODY void CAmbientGeneric::InitModulationParms(void) +void CAmbientGeneric::InitModulationParms(void) { -// { -// int pitchinc; // 523 -// } + int pitchinc; + + // 0 - 100 + m_dpv.volrun = pev->health * 10; + + if (m_dpv.volrun > 100) + m_dpv.volrun = 100; + if (m_dpv.volrun < 0) + m_dpv.volrun = 0; + + // get presets + if (m_dpv.preset != 0 && m_dpv.preset <= CDPVPRESETMAX) + { + // load preset values + m_dpv = rgdpvpreset[m_dpv.preset - 1]; + + // fixup preset values, just like + // fixups in KeyValue routine. + if (m_dpv.spindown > 0) + { + m_dpv.spindown = (101 - m_dpv.spindown) * 64; + } + if (m_dpv.spinup > 0) + { + m_dpv.spinup = (101 - m_dpv.spinup) * 64; + } + + m_dpv.volstart *= 10; + m_dpv.volrun *= 10; + + if (m_dpv.fadein > 0) + { + m_dpv.fadein = (101 - m_dpv.fadein) * 64; + } + + if (m_dpv.fadeout > 0) + { + m_dpv.fadeout = (101 - m_dpv.fadeout) * 64; + } + + m_dpv.lforate *= 256; + + m_dpv.fadeinsav = m_dpv.fadein; + m_dpv.fadeoutsav = m_dpv.fadeout; + m_dpv.spinupsav = m_dpv.spinup; + m_dpv.spindownsav = m_dpv.spindown; + } + + m_dpv.fadein = m_dpv.fadeinsav; + m_dpv.fadeout = 0; + + if (m_dpv.fadein) + m_dpv.vol = m_dpv.volstart; + else + m_dpv.vol = m_dpv.volrun; + + m_dpv.spinup = m_dpv.spinupsav; + m_dpv.spindown = 0; + + if (m_dpv.spinup) + m_dpv.pitch = m_dpv.pitchstart; + else + m_dpv.pitch = m_dpv.pitchrun; + + if (m_dpv.pitch == 0) + m_dpv.pitch = PITCH_NORM; + + m_dpv.pitchfrac = m_dpv.pitch << 8; + m_dpv.volfrac = m_dpv.vol << 8; + + m_dpv.lfofrac = 0; + m_dpv.lforate = abs(m_dpv.lforate); + + m_dpv.cspincount = 1; + + if (m_dpv.cspinup) + { + pitchinc = (255 - m_dpv.pitchstart) / m_dpv.cspinup; + + m_dpv.pitchrun = m_dpv.pitchstart + pitchinc; + if (m_dpv.pitchrun > 255) + { + m_dpv.pitchrun = 255; + } + } + + if ((m_dpv.spinupsav || m_dpv.spindownsav || (m_dpv.lfotype && m_dpv.lfomodpitch)) && m_dpv.pitch == PITCH_NORM) + { + // must never send 'no pitch' as first pitch + // if we intend to pitch shift later! + m_dpv.pitch = PITCH_NORM + 1; + } } +// ToggleUse - turns an ambient sound on or off. If the +// ambient is a looping sound, mark sound as active (m_fActive) +// if it's playing, innactive if not. If the sound is not +// a looping sound, never mark it as active. + /* <172418> ../cstrike/dlls/sound.cpp:605 */ -NOBODY void CAmbientGeneric::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CAmbientGeneric::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// char *szSoundFile; // 607 -// float fraction; // 608 -// { -// int pitchinc; // 649 -// } -// } + char *szSoundFile = (char *)STRING(pev->message); + float fraction; + + if (useType != USE_TOGGLE) + { + if ((m_fActive && useType == USE_ON) || (!m_fActive && useType == USE_OFF)) + return; + } + + // Directly change pitch if arg passed. Only works if sound is already playing. + // Momentary buttons will pass down a float in here + if (useType == USE_SET && m_fActive) + { + fraction = value; + + if (fraction > 1.0) + fraction = 1.0; + + if (fraction < 0.0) + fraction = 0.01; + + m_dpv.pitch = fraction * 255; + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 0, 0, SND_CHANGE_PITCH, m_dpv.pitch); + return; + } + + // m_fActive is TRUE only if a looping sound is playing. + // turn sound off + if (m_fActive) + { + if (m_dpv.cspinup) + { + // Don't actually shut off. Each toggle causes + // incremental spinup to max pitch + if (m_dpv.cspincount <= m_dpv.cspinup) + { + int pitchinc; + + // start a new spinup + m_dpv.cspincount++; + + pitchinc = (255 - m_dpv.pitchstart) / m_dpv.cspinup; + + m_dpv.spinup = m_dpv.spinupsav; + m_dpv.spindown = 0; + + m_dpv.pitchrun = m_dpv.pitchstart + pitchinc * m_dpv.cspincount; + if (m_dpv.pitchrun > 255) + { + m_dpv.pitchrun = 255; + } + pev->nextthink = gpGlobals->time + 0.1; + } + } + else + { + m_fActive = FALSE; + + // HACKHACK - this makes the code in Precache() work properly after a save/restore + pev->spawnflags |= AMBIENT_SOUND_START_SILENT; + if (m_dpv.spindownsav || m_dpv.fadeoutsav) + { + // spin it down (or fade it) before shutoff if spindown is set + m_dpv.spindown = m_dpv.spindownsav; + m_dpv.spinup = 0; + + m_dpv.fadeout = m_dpv.fadeoutsav; + m_dpv.fadein = 0; + pev->nextthink = gpGlobals->time + 0.1; + } + else + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 0, 0, SND_STOP, 0); + } + } + // turn sound on + else + { + // only toggle if this is a looping sound. If not looping, each + // trigger will cause the sound to play. If the sound is still + // playing from a previous trigger press, it will be shut off + // and then restarted. + if (m_fLooping) + m_fActive = TRUE; + else + { + // shut sound off now - may be interrupting a long non-looping sound + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, 0, 0, SND_STOP, 0); + } + + // init all ramp params for startup + InitModulationParms(); + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, (m_dpv.vol * 0.01), m_flAttenuation, 0, m_dpv.pitch); + pev->nextthink = gpGlobals->time + 0.1f; + } } +// KeyValue - load keyvalue pairs into member data of the +// ambient generic. NOTE: called BEFORE spawn! + /* <171f38> ../cstrike/dlls/sound.cpp:717 */ -NOBODY void CAmbientGeneric::KeyValue(KeyValueData *pkvd) +void CAmbientGeneric::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 723 -// FStrEq(const char *sz1, -// const char *sz2); // 730 -// FStrEq(const char *sz1, -// const char *sz2); // 740 -// FStrEq(const char *sz1, -// const char *sz2); // 750 -// FStrEq(const char *sz1, -// const char *sz2); // 764 -// FStrEq(const char *sz1, -// const char *sz2); // 778 -// FStrEq(const char *sz1, -// const char *sz2); // 791 -// FStrEq(const char *sz1, -// const char *sz2); // 805 -// FStrEq(const char *sz1, -// const char *sz2); // 819 -// FStrEq(const char *sz1, -// const char *sz2); // 827 -// FStrEq(const char *sz1, -// const char *sz2); // 839 -// FStrEq(const char *sz1, -// const char *sz2); // 850 -// FStrEq(const char *sz1, -// const char *sz2); // 860 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 869 -// atoi(const char *__nptr); // 732 -// atoi(const char *__nptr); // 725 -// atoi(const char *__nptr); // 742 -// atoi(const char *__nptr); // 780 -// atoi(const char *__nptr); // 752 -// atoi(const char *__nptr); // 766 -// atoi(const char *__nptr); // 829 -// atoi(const char *__nptr); // 793 -// atoi(const char *__nptr); // 807 -// atoi(const char *__nptr); // 821 -// atoi(const char *__nptr); // 841 -// atoi(const char *__nptr); // 852 -// atoi(const char *__nptr); // 862 + // NOTE: changing any of the modifiers in this code + // NOTE: also requires changing InitModulationParms code. + + // preset + if (FStrEq(pkvd->szKeyName, "preset")) + { + m_dpv.preset = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + + // pitchrun + else if (FStrEq(pkvd->szKeyName, "pitch")) + { + m_dpv.pitchrun = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + + if (m_dpv.pitchrun > 255) + m_dpv.pitchrun = 255; + + if (m_dpv.pitchrun < 0) + m_dpv.pitchrun = 0; + } + + // pitchstart + else if (FStrEq(pkvd->szKeyName, "pitchstart")) + { + m_dpv.pitchstart = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + + if (m_dpv.pitchstart > 255) + m_dpv.pitchstart = 255; + + if (m_dpv.pitchstart < 0) + m_dpv.pitchstart = 0; + } + + // spinup + else if (FStrEq(pkvd->szKeyName, "spinup")) + { + m_dpv.spinup = Q_atoi(pkvd->szValue); + + if (m_dpv.spinup > 100) + m_dpv.spinup = 100; + if (m_dpv.spinup < 0) + m_dpv.spinup = 0; + + if (m_dpv.spinup > 0) + m_dpv.spinup = (101 - m_dpv.spinup) * 64; + + m_dpv.spinupsav = m_dpv.spinup; + pkvd->fHandled = TRUE; + } + + // spindown + else if (FStrEq(pkvd->szKeyName, "spindown")) + { + m_dpv.spindown = Q_atoi(pkvd->szValue); + + if (m_dpv.spindown > 100) + m_dpv.spindown = 100; + + if (m_dpv.spindown < 0) + m_dpv.spindown = 0; + + if (m_dpv.spindown > 0) + m_dpv.spindown = (101 - m_dpv.spindown) * 64; + + m_dpv.spindownsav = m_dpv.spindown; + pkvd->fHandled = TRUE; + } + + // volstart + else if (FStrEq(pkvd->szKeyName, "volstart")) + { + m_dpv.volstart = Q_atoi(pkvd->szValue); + + if (m_dpv.volstart > 10) + m_dpv.volstart = 10; + + if (m_dpv.volstart < 0) + m_dpv.volstart = 0; + + // 0 - 100 + m_dpv.volstart *= 10; + + pkvd->fHandled = TRUE; + } + + // fadein + else if (FStrEq(pkvd->szKeyName, "fadein")) + { + m_dpv.fadein = Q_atoi(pkvd->szValue); + + if (m_dpv.fadein > 100) + m_dpv.fadein = 100; + + if (m_dpv.fadein < 0) + m_dpv.fadein = 0; + + if (m_dpv.fadein > 0) + m_dpv.fadein = (101 - m_dpv.fadein) * 64; + + m_dpv.fadeinsav = m_dpv.fadein; + pkvd->fHandled = TRUE; + } + + // fadeout + else if (FStrEq(pkvd->szKeyName, "fadeout")) + { + m_dpv.fadeout = Q_atoi(pkvd->szValue); + + if (m_dpv.fadeout > 100) + m_dpv.fadeout = 100; + + if (m_dpv.fadeout < 0) + m_dpv.fadeout = 0; + + if (m_dpv.fadeout > 0) + m_dpv.fadeout = (101 - m_dpv.fadeout) * 64; + + m_dpv.fadeoutsav = m_dpv.fadeout; + pkvd->fHandled = TRUE; + } + + // lfotype + else if (FStrEq(pkvd->szKeyName, "lfotype")) + { + m_dpv.lfotype = Q_atoi(pkvd->szValue); + + if (m_dpv.lfotype > 4) + m_dpv.lfotype = LFO_TRIANGLE; + + pkvd->fHandled = TRUE; + } + + // lforate + else if (FStrEq(pkvd->szKeyName, "lforate")) + { + m_dpv.lforate = Q_atoi(pkvd->szValue); + + if (m_dpv.lforate > 1000) + m_dpv.lforate = 1000; + + if (m_dpv.lforate < 0) + m_dpv.lforate = 0; + + m_dpv.lforate *= 256; + pkvd->fHandled = TRUE; + } + // lfomodpitch + else if (FStrEq(pkvd->szKeyName, "lfomodpitch")) + { + m_dpv.lfomodpitch = Q_atoi(pkvd->szValue); + + if (m_dpv.lfomodpitch > 100) + m_dpv.lfomodpitch = 100; + + if (m_dpv.lfomodpitch < 0) + m_dpv.lfomodpitch = 0; + + pkvd->fHandled = TRUE; + } + + // lfomodvol + else if (FStrEq(pkvd->szKeyName, "lfomodvol")) + { + m_dpv.lfomodvol = Q_atoi(pkvd->szValue); + + if (m_dpv.lfomodvol > 100) + m_dpv.lfomodvol = 100; + + if (m_dpv.lfomodvol < 0) + m_dpv.lfomodvol = 0; + + pkvd->fHandled = TRUE; + } + + // cspinup + else if (FStrEq(pkvd->szKeyName, "cspinup")) + { + m_dpv.cspinup = Q_atoi(pkvd->szValue); + + if (m_dpv.cspinup > 100) + m_dpv.cspinup = 100; + + if (m_dpv.cspinup < 0) + m_dpv.cspinup = 0; + + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } /* <172566> ../cstrike/dlls/sound.cpp:891 */ @@ -195,63 +883,166 @@ LINK_ENTITY_TO_CLASS(env_sound, CEnvSound); IMPLEMENT_SAVERESTORE(CEnvSound, CBaseEntity); /* <171d61> ../cstrike/dlls/sound.cpp:901 */ -NOBODY void CEnvSound::KeyValue(KeyValueData *pkvd) +void CEnvSound::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 904 -// FStrEq(const char *sz1, -// const char *sz2); // 909 -// KeyValue(CEnvSound *const this, -// KeyValueData *pkvd); // 901 -// atof(const char *__nptr); // 906 + if (FStrEq(pkvd->szKeyName, "radius")) + { + m_flRadius = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + if (FStrEq(pkvd->szKeyName, "roomtype")) + { + m_flRoomtype = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } } +// returns TRUE if the given sound entity (pev) is in range +// and can see the given player entity (pevTarget) + /* <172633> ../cstrike/dlls/sound.cpp:919 */ -NOBODY BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) +BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange) { -// { -// class CEnvSound *pSound; // 921 -// Vector vecSpot1; // 922 -// Vector vecSpot2; // 923 -// Vector vecRange; // 924 -// float flRange; // 925 -// TraceResult tr; // 926 -// GetClassPtr(CEnvSound *a); // 921 -// operator+(const Vector *const this, -// const Vector &v); // 922 -// operator+(const Vector *const this, -// const Vector &v); // 923 -// operator-(const Vector *const this, -// const Vector &v); // 937 -// Length(const Vector *const this); // 938 -// } + CEnvSound *pSound = GetClassPtr((CEnvSound *)pev); + Vector vecSpot1 = pev->origin + pev->view_ofs; + Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs; + Vector vecRange; + float_precision flRange; + TraceResult tr; + + UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); + + // check if line of sight crosses water boundary, or is blocked + if ((tr.fInOpen && tr.fInWater) || tr.flFraction != 1.0f) + { + return FALSE; + } + + // calc range from sound entity to player + vecRange = tr.vecEndPos - vecSpot1; + flRange = vecRange.Length(); + + if (pSound->m_flRadius < flRange) + return FALSE; + + if (pflRange) + { + *pflRange = flRange; + } + + return TRUE; } +// A client that is visible and in range of a sound entity will +// have its room_type set by that sound entity. If two or more +// sound entities are contending for a client, then the nearest +// sound entity to the client will set the client's room_type. +// A client's room_type will remain set to its prior value until +// a new in-range, visible sound entity resets a new room_type. + +// CONSIDER: if player in water state, autoset roomtype to 14,15 or 16. + /* <17428e> ../cstrike/dlls/sound.cpp:960 */ -NOBODY void CEnvSound::Think(void) +void CEnvSound::__MAKE_VHOOK(Think)(void) { -// -//env_sound_Think_fast: // 1039 -// -//env_sound_Think_slow: // 1043 -// { -// edict_t *pentPlayer; // 965 -// class CBasePlayer *pPlayer; // 966 -// float flRange; // 972 -// edict(CBaseEntity *const this); // 965 -// FNullEnt(const edict_t *pent); // 968 -// VARS(edict_t *pent); // 971 -// FNullEnt(const edict_t *pent); // 977 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 1024 -// } + // get pointer to client if visible; FIND_CLIENT_IN_PVS will + // cycle through visible clients on consecutive calls. + edict_t *pentPlayer = FIND_CLIENT_IN_PVS(edict()); + CBasePlayer *pPlayer = NULL; + + if (FNullEnt(pentPlayer)) + { + // no player in pvs of sound entity, slow it down + goto env_sound_Think_slow; + } + + pPlayer = GetClassPtr((CBasePlayer *)VARS(pentPlayer)); + float flRange; + + // check to see if this is the sound entity that is + // currently affecting this player + + if (!FNullEnt(pPlayer->m_pentSndLast) && pPlayer->m_pentSndLast == ENT(pev)) + { + // this is the entity currently affecting player, check + // for validity + if (pPlayer->m_flSndRoomtype != 0 && pPlayer->m_flSndRange != 0) + { + // we're looking at a valid sound entity affecting + // player, make sure it's still valid, update range + if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange)) + { + pPlayer->m_flSndRange = flRange; + goto env_sound_Think_fast; + } + else + { + // current sound entity affecting player is no longer valid, + // flag this state by clearing room_type and range. + // NOTE: we do not actually change the player's room_type + // NOTE: until we have a new valid room_type to change it to. + + pPlayer->m_flSndRange = 0; + pPlayer->m_flSndRoomtype = 0; + goto env_sound_Think_slow; + } + } + else + { + // entity is affecting player but is out of range, + // wait passively for another entity to usurp it... + goto env_sound_Think_slow; + } + } + + // if we got this far, we're looking at an entity that is contending + // for current player sound. the closest entity to player wins. + if (FEnvSoundInRange(pev, VARS(pentPlayer), &flRange)) + { + if (flRange < pPlayer->m_flSndRange || pPlayer->m_flSndRange == 0) + { + // new entity is closer to player, so it wins. + pPlayer->m_pentSndLast = ENT(pev); + pPlayer->m_flSndRoomtype = m_flRoomtype; + pPlayer->m_flSndRange = flRange; + + // send room_type command to player's server. + // this should be a rare event - once per change of room_type + // only! + + //CLIENT_COMMAND(pentPlayer, "room_type %f", m_flRoomtype); + MESSAGE_BEGIN(MSG_ONE, SVC_ROOMTYPE, NULL, pentPlayer); // use the magic #1 for "one client" + WRITE_SHORT((short)m_flRoomtype); // sequence number + MESSAGE_END(); + + // crank up nextthink rate for new active sound entity + // by falling through to think_fast... + } + // player is not closer to the contending sound entity, + // just fall through to think_fast. this effectively + // cranks up the think_rate of entities near the player. + } + + // player is in pvs of sound entity, but either not visible or + // not in range. do nothing, fall through to think_fast... + +env_sound_Think_fast: + pev->nextthink = gpGlobals->time + 0.25; + return; + +env_sound_Think_slow: + pev->nextthink = gpGlobals->time + 0.75; + return; } +// env_sound - spawn a sound entity that will set player roomtype +// when player moves in range and sight. + /* <171926> ../cstrike/dlls/sound.cpp:1053 */ -NOBODY void CEnvSound::Spawn(void) +void CEnvSound::__MAKE_VHOOK(Spawn)(void) { + // spread think times + pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.0, 0.5); } // randomize list of sentence name indices @@ -261,7 +1052,7 @@ void USENTENCEG_InitLRU(unsigned char *plru, int count) { int i, j, k; unsigned char temp; - + if (!fSentencesInit) return; @@ -283,10 +1074,10 @@ void USENTENCEG_InitLRU(unsigned char *plru, int count) } } -// ignore lru. pick next sentence from sentence group. Go in order until we hit the last sentence, +// ignore lru. pick next sentence from sentence group. Go in order until we hit the last sentence, // then repeat list if freset is true. If freset is false, then repeat last sentence. // ipick is passed in as the requested sentence ordinal. -// ipick 'next' is returned. +// ipick 'next' is returned. // return of -1 indicates an error. /* <17290a> ../cstrike/dlls/sound.cpp:1115 */ @@ -295,7 +1086,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres char *szgroupname; unsigned char count; char sznum[8]; - + if (!fSentencesInit) return -1; @@ -304,7 +1095,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres szgroupname = rgsentenceg[isentenceg].szgroupname; count = rgsentenceg[isentenceg].count; - + if (count == 0) return -1; @@ -315,7 +1106,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres Q_strcat(szfound, szgroupname); Q_sprintf(sznum, "%d", ipick); Q_strcat(szfound, sznum); - + if (ipick >= count) { if (freset) @@ -345,13 +1136,13 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) char sznum[8]; unsigned char ipick = 0xFF; BOOL ffound = FALSE; - + if (!fSentencesInit) return -1; if (isentenceg < 0) return -1; - + szgroupname = rgsentenceg[isentenceg].szgroupname; count = rgsentenceg[isentenceg].count; plru = rgsentenceg[isentenceg].rgblru; @@ -389,7 +1180,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound) // get sentence group index (isentenceg). Returns -1 if no such name. /* <172b0c> ../cstrike/dlls/sound.cpp:1213 */ -NOXREF int SENTENCEG_GetIndex(const char *szgroupname) +int SENTENCEG_GetIndex(const char *szgroupname) { int i; @@ -411,12 +1202,12 @@ NOXREF int SENTENCEG_GetIndex(const char *szgroupname) } // given sentence group index, play random sentence for given entity. -// returns ipick - which sentence was picked to +// returns ipick - which sentence was picked to // play from the group. Ipick is only needed if you plan on stopping // the sound before playback is done (see SENTENCEG_Stop). /* <170eb5> ../cstrike/dlls/sound.cpp:1238 */ -NOXREF int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch) +int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch) { char name[64]; int ipick; @@ -433,8 +1224,10 @@ NOXREF int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, flo return ipick; } +// same as above, but takes sentence group name instead of index + /* <170a36> ../cstrike/dlls/sound.cpp:1257 */ -NOXREF int SENTENCEG_PlayRndSz(edict_t *entity, const char *szgroupname, float volume, float attenuation, int flags, int pitch) +int SENTENCEG_PlayRndSz(edict_t *entity, const char *szgroupname, float volume, float attenuation, int flags, int pitch) { char name[64]; int ipick; @@ -443,19 +1236,21 @@ NOXREF int SENTENCEG_PlayRndSz(edict_t *entity, const char *szgroupname, float v if (!fSentencesInit) return -1; - name[0] = 0; + name[0] = '\0'; isentenceg = SENTENCEG_GetIndex(szgroupname); if (isentenceg < 0) { - ALERT( at_console, "No such sentence group %s\n", szgroupname ); + ALERT(at_console, "No such sentence group %s\n", szgroupname); return -1; } ipick = USENTENCEG_Pick(isentenceg, name); - if (ipick >= 0 && name[0]) + if (ipick >= 0 && name[0] != '\0') + { EMIT_SOUND_DYN(entity, CHAN_VOICE, name, volume, attenuation, flags, pitch); + } return ipick; } @@ -472,15 +1267,17 @@ int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szgroupname, float v if (!fSentencesInit) return -1; - name[0] = 0; + name[0] = '\0'; isentenceg = SENTENCEG_GetIndex(szgroupname); if (isentenceg < 0) return -1; ipicknext = USENTENCEG_PickSequential(isentenceg, name, ipick, freset); - if (ipicknext >= 0 && name[0]) + if (ipicknext >= 0 && name[0] != '\0') + { EMIT_SOUND_DYN(entity, CHAN_VOICE, name, volume, attenuation, flags, pitch); + } return ipicknext; } @@ -531,7 +1328,7 @@ void SENTENCEG_Init(void) Q_memset(szgroup, 0, sizeof(szgroup)); isentencegs = -1; - + int filePos = 0, fileSize; byte *pMemFile = LOAD_FILE_FOR_ME("sound/sentences.txt", &fileSize); if (!pMemFile) @@ -561,7 +1358,7 @@ void SENTENCEG_Init(void) if (gcallsentences > CVOXFILESENTENCEMAX) { - ALERT (at_error, "Too many sentences in sentences.txt!\n"); + ALERT(at_error, "Too many sentences in sentences.txt!\n"); break; } @@ -708,7 +1505,9 @@ void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg) pitch = RANDOM_LONG(0, 6) + 98; if (fvol > 0.05) + { SENTENCEG_PlayRndI(entity, isentenceg, fvol, ATTN_NORM, 0, pitch); + } } // play a sentence, randomly selected from the passed in groupname @@ -720,11 +1519,14 @@ NOXREF void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname) int pitch = PITCH_NORM; fvol = CVAR_GET_FLOAT("suitvolume"); + if (RANDOM_LONG(0, 1)) pitch = RANDOM_LONG(0, 6) + 98; if (fvol > 0.05) + { SENTENCEG_PlayRndSz(entity, groupname, fvol, ATTN_NORM, 0, pitch); + } } /* <171cc9> ../cstrike/dlls/sound.cpp:1561 */ @@ -831,11 +1633,11 @@ void TEXTURETYPE_Init(void) continue; // null-terminate name and save in sentences array - j = _min(j, CBTEXTURENAMEMAX - 1 + i); + j = Q_min(j, CBTEXTURENAMEMAX - 1 + i); buffer[j] = 0; Q_strcpy(&(grgszTextureName[gcTextures++][0]), &(buffer[i])); } - + FREE_FILE(pMemFile); fTextureTypeInit = TRUE; @@ -857,6 +1659,7 @@ char TEXTURETYPE_Find(char *name) if (!Q_strnicmp(name, &(grgszTextureName[ i ][0]), CBTEXTURENAMEMAX - 1)) return (grgchTextureType[ i ]); } + return CHAR_TEX_CONCRETE; } @@ -888,7 +1691,10 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int chTextureType = 0; if (pEntity && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) - chTextureType = CHAR_TEX_FLESH; // hit body + { + // hit body + chTextureType = CHAR_TEX_FLESH; + } else { // hit world @@ -1071,68 +1877,218 @@ LINK_ENTITY_TO_CLASS(speaker, CSpeaker); /* <171b85> ../cstrike/dlls/sound.cpp:1891 */ IMPLEMENT_SAVERESTORE(CSpeaker, CBaseEntity); +// ambient_generic - general-purpose user-defined static sound + /* <171c6b> ../cstrike/dlls/sound.cpp:1896 */ -NOBODY void CSpeaker::Spawn(void) +void CSpeaker::__MAKE_VHOOK(Spawn)(void) { -// { -// char *szSoundFile; // 1898 -// } -// Spawn(CSpeaker *const this); // 1896 + char *szSoundFile = (char *)STRING(pev->message); + + if (!m_preset && (FStringNull(pev->message) || Q_strlen(szSoundFile) < 1)) + { + ALERT(at_error, "SPEAKER with no Level/Sentence! at: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z); + pev->nextthink = gpGlobals->time + 0.1; + SetThink(&CSpeaker::SUB_Remove); + return; + } + + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + + SetThink(&CSpeaker::SpeakerThink); + pev->nextthink = 0.0; + + // allow on/off switching via 'use' function. + SetUse(&CSpeaker::ToggleUse); + + Precache(); } /* <171a16> ../cstrike/dlls/sound.cpp:1924 */ -NOBODY void CSpeaker::Precache(void) +void CSpeaker::__MAKE_VHOOK(Precache)(void) { -// Precache(CSpeaker *const this); // 1924 + if (!(pev->spawnflags & SPEAKER_START_SILENT)) + { + // set first announcement time for random n second + pev->nextthink = gpGlobals->time + RANDOM_FLOAT(5, 15); + } } /* <172b7a> ../cstrike/dlls/sound.cpp:1930 */ -NOBODY void CSpeaker::SpeakerThink(void) +void CSpeaker::SpeakerThink(void) { -// { -// char *szSoundFile; // 1932 -// float flvolume; // 1933 -// float flattenuation; // 1934 -// int flags; // 1935 -// int pitch; // 1936 -// SENTENCEG_PlayRndSz(edict_t *entity, -// const char *szgroupname, -// float volume, -// float attenuation, -// int flags, -// int pitch); // 1980 -// } + char *szSoundFile = NULL; + float flvolume = pev->health * 0.1; + float flattenuation = 0.3; + int flags = 0; + int pitch = 100; + + // Wait for the talkmonster to finish first. + if (gpGlobals->time <= CTalkMonster::g_talkWaitTime) + { + pev->nextthink = CTalkMonster::g_talkWaitTime + RANDOM_FLOAT(5, 10); + return; + } + + if (m_preset) + { + // go lookup preset text, assign szSoundFile + switch (m_preset) + { + case 1: szSoundFile = "C1A0_"; break; + case 2: szSoundFile = "C1A1_"; break; + case 3: szSoundFile = "C1A2_"; break; + case 4: szSoundFile = "C1A3_"; break; + case 5: szSoundFile = "C1A4_"; break; + case 6: szSoundFile = "C2A1_"; break; + case 7: szSoundFile = "C2A2_"; break; + case 8: szSoundFile = "C2A3_"; break; + case 9: szSoundFile = "C2A4_"; break; + case 10: szSoundFile = "C2A5_"; break; + case 11: szSoundFile = "C3A1_"; break; + case 12: szSoundFile = "C3A2_"; break; + } + } + else + szSoundFile = (char *)STRING(pev->message); + +#ifdef REGAMEDLL_FIXES + if (szSoundFile == NULL) + { + // if is null - return; + return; + } +#endif // REGAMEDLL_FIXES + + if (szSoundFile[0] == '!') + { + // play single sentence, one shot + UTIL_EmitAmbientSound(ENT(pev), pev->origin, szSoundFile, flvolume, flattenuation, flags, pitch); + + // shut off and reset + pev->nextthink = 0.0; + } + else + { + // make random announcement from sentence group + + if (SENTENCEG_PlayRndSz(ENT(pev), szSoundFile, flvolume, flattenuation, flags, pitch) < 0) + { + ALERT(at_console, "Level Design Error!\nSPEAKER has bad sentence group name: %s\n", szSoundFile); + } + + // set next announcement time for random 5 to 10 minute delay + pev->nextthink = gpGlobals->time + RANDOM_FLOAT(ANNOUNCE_MINUTES_MIN * 60.0, ANNOUNCE_MINUTES_MAX * 60.0); + + // time delay until it's ok to speak: used so that two NPCs don't talk at once + CTalkMonster::g_talkWaitTime = gpGlobals->time + 5; + } + + return; } +// ToggleUse - if an announcement is pending, cancel it. If no announcement is pending, start one. + /* <171a4e> ../cstrike/dlls/sound.cpp:1997 */ -NOBODY void CSpeaker::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CSpeaker::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// int fActive; // 1999 -// } + int fActive = (pev->nextthink > 0.0); + + // fActive is TRUE only if an announcement is pending + if (useType != USE_TOGGLE) + { + // ignore if we're just turning something on that's already on, or + // turning something off that's already off. + if ((fActive && useType == USE_ON) || (!fActive && useType == USE_OFF)) + { + return; + } + } + + if (useType == USE_ON) + { + // turn on announcements + pev->nextthink = gpGlobals->time + 0.1; + return; + } + + if (useType == USE_OFF) + { + // turn off announcements + pev->nextthink = 0.0; + return; + + } + + // Toggle announcements + if (fActive) + { + // turn off announcements + pev->nextthink = 0.0; + } + else + { + // turn on announcements + pev->nextthink = gpGlobals->time + 0.1; + } } +// KeyValue - load keyvalue pairs into member data +// NOTE: called BEFORE spawn! + /* <171e86> ../cstrike/dlls/sound.cpp:2044 */ -NOBODY void CSpeaker::KeyValue(KeyValueData *pkvd) +void CSpeaker::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 2048 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 2054 -// KeyValue(CSpeaker *const this, -// KeyValueData *pkvd); // 2044 + // preset + if (FStrEq(pkvd->szKeyName, "preset")) + { + m_preset = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } #ifdef HOOK_GAMEDLL +void CAmbientGeneric::Spawn(void) +{ + Spawn_(); +} + +void CAmbientGeneric::Precache(void) +{ + Precache_(); +} + +void CAmbientGeneric::Restart(void) +{ + Restart_(); +} + +void CAmbientGeneric::KeyValue(KeyValueData *pkvd) +{ + KeyValue_(pkvd); +} + int CAmbientGeneric::Save(CSave &save) { - return Save_(save); + Save_(save); } int CAmbientGeneric::Restore(CRestore &restore) { - return Restore_(restore); + Restore_(restore); +} + +void CEnvSound::Spawn(void) +{ + Spawn_(); +} + +void CEnvSound::KeyValue(KeyValueData *pkvd) +{ + KeyValue_(pkvd); } int CEnvSound::Save(CSave &save) @@ -1145,6 +2101,26 @@ int CEnvSound::Restore(CRestore &restore) return Restore_(restore); } +void CEnvSound::Think(void) +{ + Think_(); +} + +void CSpeaker::Spawn(void) +{ + Spawn_(); +} + +void CSpeaker::Precache(void) +{ + Precache_(); +} + +void CSpeaker::KeyValue(KeyValueData *pkvd) +{ + KeyValue_(pkvd); +} + int CSpeaker::Save(CSave &save) { return Save_(save); diff --git a/regamedll/dlls/sound.h b/regamedll/dlls/sound.h index 5cd6587b..b3f3a49a 100644 --- a/regamedll/dlls/sound.h +++ b/regamedll/dlls/sound.h @@ -32,25 +32,200 @@ #pragma once #endif -#define CSENTENCEG_MAX 200 // max number of sentence groups -#define CSENTENCE_LRU_MAX 32 +#define CSENTENCEG_MAX 200 // max number of sentence groups +#define CSENTENCE_LRU_MAX 32 // max number of elements per sentence group +#define CDPVPRESETMAX 27 + +// spawnflags +#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation +#define AMBIENT_SOUND_EVERYWHERE 1 +#define AMBIENT_SOUND_SMALLRADIUS 2 +#define AMBIENT_SOUND_MEDIUMRADIUS 4 +#define AMBIENT_SOUND_LARGERADIUS 8 +#define AMBIENT_SOUND_START_SILENT 16 +#define AMBIENT_SOUND_NOT_LOOPING 32 + +#define ANNOUNCE_MINUTES_MIN 0.25 +#define ANNOUNCE_MINUTES_MAX 2.25 + +#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements + +#define LFO_SQUARE 1 // square +#define LFO_TRIANGLE 2 // triangle +#define LFO_RANDOM 3 // random + +// group of related sentences +typedef struct +{ + char szgroupname[16]; + int count; + unsigned char rgblru[ CSENTENCE_LRU_MAX ]; -typedef struct -{ - char szgroupname[16]; - int count; - unsigned char rgblru[ CSENTENCE_LRU_MAX ]; - } sentenceg; /* size: 52, cachelines: 1, members: 3 */ -NOBODY BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange); +// runtime pitch shift and volume fadein/out structure + +// NOTE: IF YOU CHANGE THIS STRUCT YOU MUST CHANGE THE SAVE/RESTORE VERSION NUMBER +// SEE BELOW (in the typedescription for the class) +typedef struct dynpitchvol +{ + // NOTE: do not change the order of these parameters + // NOTE: unless you also change order of rgdpvpreset array elements! + int preset; + + int pitchrun; // pitch shift % when sound is running 0 - 255 + int pitchstart; // pitch shift % when sound stops or starts 0 - 255 + int spinup; // spinup time 0 - 100 + int spindown; // spindown time 0 - 100 + + int volrun; // volume change % when sound is running 0 - 10 + int volstart; // volume change % when sound stops or starts 0 - 10 + int fadein; // volume fade in time 0 - 100 + int fadeout; // volume fade out time 0 - 100 + + // Low Frequency Oscillator + int lfotype; // 0) off 1) square 2) triangle 3) random + int lforate; // 0 - 1000, how fast lfo osciallates + + int lfomodpitch; // 0-100 mod of current pitch. 0 is off. + int lfomodvol; // 0-100 mod of current volume. 0 is off. + + int cspinup; // each trigger hit increments counter and spinup pitch + + int cspincount; + int pitch; + int spinupsav; + int spindownsav; + int pitchfrac; + int vol; + int fadeinsav; + int fadeoutsav; + int volfrac; + int lfofrac; + int lfomult; + +} dynpitchvol_t; +/* size: 100, cachelines: 2, members: 25 */ + +/* <170b59> ../cstrike/dlls/sound.cpp:117 */ +class CAmbientGeneric: public CBaseEntity +{ +public: + virtual void Spawn(void); + virtual void Precache(void); + virtual void Restart(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) + { + return ObjectCaps_(); + } + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Precache_(void); + void Restart_(void); + void KeyValue_(KeyValueData *pkvd); + int Save_(CSave &save); + int Restore_(CRestore &restore); + int ObjectCaps_(void) + { + return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); + } + +#endif // HOOK_GAMEDLL + +public: + void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT RampThink(void); + void InitModulationParms(void); + +public: + static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[4]; + + float m_flAttenuation; // attenuation value + dynpitchvol_t m_dpv; + BOOL m_fActive; // only TRUE when the entity is playing a looping sound + BOOL m_fLooping; // TRUE when the sound played will loop + +};/* size: 264, cachelines: 5, members: 6 */ + +/* <170bc2> ../cstrike/dlls/sound.cpp:875 */ +class CEnvSound: public CPointEntity +{ +public: + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Think(void); + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void KeyValue_(KeyValueData *pkvd); + int Save_(CSave &save); + int Restore_(CRestore &restore); + void Think_(void); + +#endif // HOOK_GAMEDLL + +public: + static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[2]; + + float m_flRadius; + float m_flRoomtype; + +};/* size: 160, cachelines: 3, members: 4 */ + +/* <170ced> ../cstrike/dlls/sound.cpp:1867 */ +class CSpeaker: public CBaseEntity +{ +public: + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) + { + return ObjectCaps_(); + } + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Precache_(void); + void KeyValue_(KeyValueData *pkvd); + int Save_(CSave &save); + int Restore_(CRestore &restore); + int ObjectCaps_(void) + { + return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); + } + +#endif // HOOK_GAMEDLL + +public: + void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT SpeakerThink(void); +public: + static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; + + int m_preset; // preset number + +};/* size: 156, cachelines: 3, members: 3 */ + +BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange); void USENTENCEG_InitLRU(unsigned char *plru, int count); int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int freset); int USENTENCEG_Pick(int isentenceg, char *szfound); -NOXREF int SENTENCEG_GetIndex(const char *szgroupname); -NOXREF int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch); -NOXREF int SENTENCEG_PlayRndSz(edict_t *entity, const char *szgroupname, float volume, float attenuation, int flags, int pitch); +int SENTENCEG_GetIndex(const char *szgroupname); +int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch); +int SENTENCEG_PlayRndSz(edict_t *entity, const char *szgroupname, float volume, float attenuation, int flags, int pitch); int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szgroupname, float volume, float attenuation, int flags, int pitch, int ipick, int freset); NOXREF void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick); void SENTENCEG_Init(void); @@ -60,9 +235,9 @@ void EMIT_SOUND_SUIT(edict_t *entity, const char *sample); void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); NOXREF void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); char *memfgets(byte *pMemFile, int fileSize, int &filePos, char *pBuffer, int bufferSize); -NOBODY void TEXTURETYPE_Init(void); +void TEXTURETYPE_Init(void); char TEXTURETYPE_Find(char *name); -NOBODY float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType); +float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType); #ifdef HOOK_GAMEDLL @@ -70,6 +245,7 @@ NOBODY float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEn #define rgsentenceg (*prgsentenceg) #define fSentencesInit (*pfSentencesInit) #define gcallsentences (*pgcallsentences) +#define rgdpvpreset (*prgdpvpreset) #endif // HOOK_GAMEDLL @@ -77,5 +253,15 @@ extern char gszallsentencenames[ CVOXFILESENTENCEMAX ][ CBSENTENCENAME_MAX ]; extern sentenceg rgsentenceg[ CSENTENCEG_MAX ]; extern int fSentencesInit; extern int gcallsentences; +extern dynpitchvol_t rgdpvpreset[CDPVPRESETMAX]; + +#ifdef HOOK_GAMEDLL + +// linked objects +C_DLLEXPORT void ambient_generic(entvars_t *pev); +C_DLLEXPORT void env_sound(entvars_t *pev); +C_DLLEXPORT void speaker(entvars_t *pev); + +#endif // HOOK_GAMEDLL #endif // SOUND_H diff --git a/regamedll/dlls/soundent.cpp b/regamedll/dlls/soundent.cpp index 5fe98735..e31a1d8c 100644 --- a/regamedll/dlls/soundent.cpp +++ b/regamedll/dlls/soundent.cpp @@ -5,88 +5,194 @@ CSoundEnt *pSoundEnt; /* <178ca4> ../cstrike/dlls/soundent.cpp:22 */ LINK_ENTITY_TO_CLASS(soundent, CSoundEnt); +// CSound - Clear - zeros all fields for a sound + /* <178d6e> ../cstrike/dlls/soundent.cpp:29 */ -NOBODY void CSound::Clear(void) +void CSound::Clear(void) { + m_vecOrigin = g_vecZero; + m_iType = 0; + m_iVolume = 0; + m_flExpireTime = 0; + m_iNext = SOUNDLIST_EMPTY; + m_iNextAudible = 0; } -// Reset - clears the volume, origin, and type for a sound, -// but doesn't expire or unlink it. +// Reset - clears the volume, origin, and type for a sound, +// but doesn't expire or unlink it. /* <178d8f> ../cstrike/dlls/soundent.cpp:43 */ void CSound::Reset(void) { - m_vecOrigin = g_vecZero; - m_iNext = SOUNDLIST_EMPTY; - m_iType = 0; + m_vecOrigin = g_vecZero; + m_iNext = SOUNDLIST_EMPTY; + m_iType = 0; m_iVolume = 0; } +// FIsSound - returns TRUE if the sound is an Audible sound + /* <178db7> ../cstrike/dlls/soundent.cpp:54 */ -NOBODY BOOL CSound::FIsSound(void) +NOXREF BOOL CSound::FIsSound(void) { + if (m_iType & (bits_SOUND_COMBAT | bits_SOUND_WORLD | bits_SOUND_PLAYER | bits_SOUND_DANGER)) + { + return TRUE; + } + + return FALSE; } +// FIsScent - returns TRUE if the sound is actually a scent + /* <178ddf> ../cstrike/dlls/soundent.cpp:67 */ -NOBODY BOOL CSound::FIsScent(void) +NOXREF BOOL CSound::FIsScent(void) { + if (m_iType & (bits_SOUND_CARCASS | bits_SOUND_MEAT | bits_SOUND_GARBAGE)) + { + return TRUE; + } + + return FALSE; } /* <17900a> ../cstrike/dlls/soundent.cpp:80 */ -NOBODY void CSoundEnt::__MAKE_VHOOK(Spawn)(void) +void CSoundEnt::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_NOT; + Initialize(); + + pev->nextthink = gpGlobals->time + 1; } +// Think - at interval, the entire active sound list is checked +// for sounds that have ExpireTimes less than or equal +// to the current world time, and these sounds are deallocated. + /* <178b0c> ../cstrike/dlls/soundent.cpp:93 */ -NOBODY void CSoundEnt::__MAKE_VHOOK(Think)(void) +void CSoundEnt::__MAKE_VHOOK(Think)(void) { -// { -// int iSound; // 95 -// int iPreviousSound; // 96 -// { -// int iNext; // 107 -// FreeSound(int iSound, -// int iPrevious); // 110 -// } -// } -// Think(CSoundEnt *const this); // 93 + int iSound; + int iPreviousSound; + + // how often to check the sound list. + pev->nextthink = gpGlobals->time + 0.3; + + iPreviousSound = SOUNDLIST_EMPTY; + iSound = m_iActiveSound; + + while (iSound != SOUNDLIST_EMPTY) + { + if (m_SoundPool[ iSound ].m_flExpireTime <= gpGlobals->time && m_SoundPool[ iSound ].m_flExpireTime != SOUND_NEVER_EXPIRE) + { + int iNext = m_SoundPool[ iSound ].m_iNext; + + // move this sound back into the free list + FreeSound(iSound, iPreviousSound); + + iSound = iNext; + } + else + { + iPreviousSound = iSound; + iSound = m_SoundPool[ iSound ].m_iNext; + } + } + + if (m_fShowReport) + { + ALERT(at_aiconsole, "Soundlist: %d / %d (%d)\n", ISoundsInList(SOUNDLISTTYPE_ACTIVE), ISoundsInList(SOUNDLISTTYPE_FREE), ISoundsInList(SOUNDLISTTYPE_ACTIVE) - m_cLastActiveSounds); + m_cLastActiveSounds = ISoundsInList(SOUNDLISTTYPE_ACTIVE); + } } +// Precache - dummy function + /* <178a76> ../cstrike/dlls/soundent.cpp:132 */ -NOBODY void CSoundEnt::__MAKE_VHOOK(Precache)(void) +void CSoundEnt::__MAKE_VHOOK(Precache)(void) { + ; } +// FreeSound - clears the passed active sound and moves it +// to the top of the free list. TAKE CARE to only call this +// function for sounds in the Active list!! + /* <178e07> ../cstrike/dlls/soundent.cpp:141 */ -NOBODY void CSoundEnt::FreeSound(int iSound, int iPrevious) +void CSoundEnt::FreeSound(int iSound, int iPrevious) { + if (!pSoundEnt) + { + // no sound ent! + return; + } + + if (iPrevious != SOUNDLIST_EMPTY) + { + // iSound is not the head of the active list, so + // must fix the index for the Previous sound + // pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = m_SoundPool[ iSound ].m_iNext; + pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = pSoundEnt->m_SoundPool[ iSound ].m_iNext; + } + else + { + // the sound we're freeing IS the head of the active list. + pSoundEnt->m_iActiveSound = pSoundEnt->m_SoundPool[ iSound ].m_iNext; + } + + // make iSound the head of the Free list. + pSoundEnt->m_SoundPool[ iSound ].m_iNext = pSoundEnt->m_iFreeSound; + pSoundEnt->m_iFreeSound = iSound; } +// IAllocSound - moves a sound from the Free list to the +// Active list returns the index of the alloc'd sound + /* <178e2d> ../cstrike/dlls/soundent.cpp:171 */ int CSoundEnt::IAllocSound(void) { + int iNewSound; + if (m_iFreeSound == SOUNDLIST_EMPTY) { + // no free sound! ALERT(at_console, "Free Sound List is full!\n"); return SOUNDLIST_EMPTY; } - int iNewSound = m_iFreeSound; + // there is at least one sound available, so move it to the + // Active sound list, and return its SoundPool index. + // copy the index of the next free sound + iNewSound = m_iFreeSound; + + // move the index down into the free list. m_iFreeSound = m_SoundPool[ iNewSound ].m_iNext; + + // point the new sound at the top of the active list. m_SoundPool[ iNewSound ].m_iNext = m_iActiveSound; + + // now make the new sound the top of the active list. You're done. m_iActiveSound = iNewSound; return iNewSound; } +// InsertSound - Allocates a free sound and fills it with +// sound info. + /* <178e94> ../cstrike/dlls/soundent.cpp:200 */ void CSoundEnt::InsertSound(int iType, const Vector &vecOrigin, int iVolume, float flDuration) { - if (!pSoundEnt) - return; + int iThisSound; - int iThisSound = pSoundEnt->IAllocSound(); + if (!pSoundEnt) + { + // no sound ent! + return; + } + + iThisSound = pSoundEnt->IAllocSound(); if (iThisSound == SOUNDLIST_EMPTY) { @@ -100,65 +206,147 @@ void CSoundEnt::InsertSound(int iType, const Vector &vecOrigin, int iVolume, flo pSoundEnt->m_SoundPool[ iThisSound ].m_flExpireTime = gpGlobals->time + flDuration; } +// Initialize - clears all sounds and moves them into the +// free sound list. + /* <178f4e> ../cstrike/dlls/soundent.cpp:228 */ -NOBODY void CSoundEnt::Initialize(void) +void CSoundEnt::Initialize(void) { -// { -// int i; // 230 -// int iSound; // 231 -// Clear(CSound *const this); // 239 -// IAllocSound(CSoundEnt *const this); // 249 -// } + int i; + int iSound; + + m_cLastActiveSounds = 0; + m_iFreeSound = 0; + m_iActiveSound = SOUNDLIST_EMPTY; + + // clear all sounds, and link them into the free sound list. + for (i = 0; i < MAX_WORLD_SOUNDS; i++) + { + m_SoundPool[ i ].Clear(); + m_SoundPool[ i ].m_iNext = i + 1; + } + + // terminate the list here. + m_SoundPool[ i - 1 ].m_iNext = SOUNDLIST_EMPTY; + + // now reserve enough sounds for each client + for (i = 0; i < gpGlobals->maxClients; i++) + { + iSound = pSoundEnt->IAllocSound(); + + if (iSound == SOUNDLIST_EMPTY) + { + ALERT(at_console, "Could not AllocSound() for Client Reserve! (DLL)\n"); + return; + } + + pSoundEnt->m_SoundPool[ iSound ].m_flExpireTime = SOUND_NEVER_EXPIRE; + } + + if (CVAR_GET_FLOAT("displaysoundlist") == 1) + { + m_fShowReport = TRUE; + } + else + { + m_fShowReport = FALSE; + } } +// ISoundsInList - returns the number of sounds in the desired +// sound list. + /* <179031> ../cstrike/dlls/soundent.cpp:274 */ -NOBODY int CSoundEnt::ISoundsInList(int iListType) +int CSoundEnt::ISoundsInList(int iListType) { -// { -// int i; // 276 -// int iThisSound; // 277 -// } + int i; + int iThisSound; + + if (iListType == SOUNDLISTTYPE_FREE) + { + iThisSound = m_iFreeSound; + } + else if (iListType == SOUNDLISTTYPE_ACTIVE) + { + iThisSound = m_iActiveSound; + } + else + { + ALERT(at_console, "Unknown Sound List Type!\n"); + } + + if (iThisSound == SOUNDLIST_EMPTY) + { + return 0; + } + + i = 0; + + while (iThisSound != SOUNDLIST_EMPTY) + { + i++; + + iThisSound = m_SoundPool[ iThisSound ].m_iNext; + } + + return i; } +// ActiveList - returns the head of the active sound list + /* <179073> ../cstrike/dlls/soundent.cpp:312 */ -NOBODY int CSoundEnt::ActiveList(void) +NOXREF int CSoundEnt::ActiveList(void) { + if (!pSoundEnt) + { + return SOUNDLIST_EMPTY; + } + + return pSoundEnt->m_iActiveSound; } +// FreeList - returns the head of the free sound list + /* <179083> ../cstrike/dlls/soundent.cpp:325 */ -NOBODY int CSoundEnt::FreeList(void) +NOXREF int CSoundEnt::FreeList(void) { + if (!pSoundEnt) + { + return SOUNDLIST_EMPTY; + } + + return pSoundEnt->m_iFreeSound; } -// SoundPointerForIndex - returns a pointer to the instance +// SoundPointerForIndex - returns a pointer to the instance // of CSound at index's position in the sound pool. /* <179093> ../cstrike/dlls/soundent.cpp:339 */ CSound *CSoundEnt::SoundPointerForIndex(int iIndex) { - if (!pSoundEnt) - { - return NULL; - } - - if (iIndex > (MAX_WORLD_SOUNDS - 1)) - { - ALERT(at_console, "SoundPointerForIndex() - Index too large!\n"); - return NULL; - } - - if (iIndex < 0) - { - ALERT(at_console, "SoundPointerForIndex() - Index < 0!\n"); - return NULL; - } - + if (!pSoundEnt) + { + return NULL; + } + + if (iIndex > (MAX_WORLD_SOUNDS - 1)) + { + ALERT(at_console, "SoundPointerForIndex() - Index too large!\n"); + return NULL; + } + + if (iIndex < 0) + { + ALERT(at_console, "SoundPointerForIndex() - Index < 0!\n"); + return NULL; + } + return &pSoundEnt->m_SoundPool[ iIndex ]; } -// Clients are numbered from 1 to MAXCLIENTS, but the client -// reserved sounds in the soundlist are from 0 to MAXCLIENTS - 1, -// so this function ensures that a client gets the proper index +// Clients are numbered from 1 to MAXCLIENTS, but the client +// reserved sounds in the soundlist are from 0 to MAXCLIENTS - 1, +// so this function ensures that a client gets the proper index // to his reserved sound in the soundlist. /* <1790b8> ../cstrike/dlls/soundent.cpp:367 */ @@ -168,9 +356,9 @@ int CSoundEnt::ClientSoundIndex(edict_t *pClient) #if defined(_DEBUG) && !defined(HOOK_GAMEDLL) - if (iReturn < 0 || iReturn > gpGlobals->maxClients) - { - ALERT(at_console, "** ClientSoundIndex returning a bogus value! **\n"); + if (iReturn < 0 || iReturn > gpGlobals->maxClients) + { + ALERT(at_console, "** ClientSoundIndex returning a bogus value! **\n"); } #endif // _DEBUG && !HOOK_GAMEDLL diff --git a/regamedll/dlls/soundent.h b/regamedll/dlls/soundent.h index af10119f..ba2b38b4 100644 --- a/regamedll/dlls/soundent.h +++ b/regamedll/dlls/soundent.h @@ -60,11 +60,11 @@ class CSound { public: - NOBODY void Clear(void); + void Clear(void); void Reset(void); - NOBODY BOOL FIsSound(void); - NOBODY BOOL FIsScent(void); + NOXREF BOOL FIsSound(void); + NOXREF BOOL FIsScent(void); public: Vector m_vecOrigin; // sound's location in space @@ -85,13 +85,13 @@ class CSoundEnt: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Think(void); + virtual void Think(void); #ifdef HOOK_GAMEDLL @@ -113,10 +113,10 @@ public: static void FreeSound(int iSound, int iPrevious); // return the head of the active list - static int ActiveList(void); + NOXREF static int ActiveList(void); // return the head of the free list - static int FreeList(void); + NOXREF static int FreeList(void); // return a pointer for this index in the sound list static CSound *SoundPointerForIndex(int iIndex); @@ -147,4 +147,7 @@ private: extern CSoundEnt *pSoundEnt; +// linked objects +C_DLLEXPORT void soundent(entvars_t *pev); + #endif // SOUNDENT_H diff --git a/regamedll/dlls/subs.cpp b/regamedll/dlls/subs.cpp index 129459c8..0f4434e4 100644 --- a/regamedll/dlls/subs.cpp +++ b/regamedll/dlls/subs.cpp @@ -5,12 +5,14 @@ */ #ifndef HOOK_GAMEDLL +// Global Savedata for Delay TYPEDESCRIPTION CBaseDelay::m_SaveData[] = { DEFINE_FIELD(CBaseDelay, m_flDelay, FIELD_FLOAT), DEFINE_FIELD(CBaseDelay, m_iszKillTarget, FIELD_STRING), }; +// Global Savedata for Toggle TYPEDESCRIPTION CBaseToggle::m_SaveData[] = { DEFINE_FIELD(CBaseToggle, m_toggle_state, FIELD_INTEGER), @@ -22,8 +24,8 @@ TYPEDESCRIPTION CBaseToggle::m_SaveData[] = DEFINE_FIELD(CBaseToggle, m_flTLength, FIELD_FLOAT), DEFINE_FIELD(CBaseToggle, m_vecPosition1, FIELD_POSITION_VECTOR), DEFINE_FIELD(CBaseToggle, m_vecPosition2, FIELD_POSITION_VECTOR), - DEFINE_FIELD(CBaseToggle, m_vecAngle1, FIELD_VECTOR), - DEFINE_FIELD(CBaseToggle, m_vecAngle2, FIELD_VECTOR), + DEFINE_FIELD(CBaseToggle, m_vecAngle1, FIELD_VECTOR), // UNDONE: Position could go through transition, but also angle? + DEFINE_FIELD(CBaseToggle, m_vecAngle2, FIELD_VECTOR), // UNDONE: Position could go through transition, but also angle? DEFINE_FIELD(CBaseToggle, m_cTriggersLeft, FIELD_INTEGER), DEFINE_FIELD(CBaseToggle, m_flHeight, FIELD_FLOAT), DEFINE_FIELD(CBaseToggle, m_hActivator, FIELD_EHANDLE), @@ -31,29 +33,37 @@ TYPEDESCRIPTION CBaseToggle::m_SaveData[] = DEFINE_FIELD(CBaseToggle, m_vecFinalDest, FIELD_POSITION_VECTOR), DEFINE_FIELD(CBaseToggle, m_vecFinalAngle, FIELD_VECTOR), DEFINE_FIELD(CBaseToggle, m_sMaster, FIELD_STRING), - DEFINE_FIELD(CBaseToggle, m_bitsDamageInflict, FIELD_INTEGER), + DEFINE_FIELD(CBaseToggle, m_bitsDamageInflict, FIELD_INTEGER), // damage type inflicted }; #else // HOOK_GAMEDLL -TYPEDESCRIPTION (*CBaseDelay::pm_SaveData)[2]; -TYPEDESCRIPTION (*CBaseToggle::pm_SaveData)[19]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBaseDelay, m_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBaseToggle, m_SaveData)[19]; #endif // HOOK_GAMEDLL +// Landmark class + /* <1832bc> ../cstrike/dlls/subs.cpp:38 */ -NOBODY void CPointEntity::__MAKE_VHOOK(Spawn)(void) +void CPointEntity::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_NOT; } +// Null Entity, remove on startup + /* <183417> ../cstrike/dlls/subs.cpp:53 */ -NOBODY void CNullEntity::__MAKE_VHOOK(Spawn)(void) +void CNullEntity::__MAKE_VHOOK(Spawn)(void) { + REMOVE_ENTITY(ENT(pev)); } /* <1838f5> ../cstrike/dlls/subs.cpp:57 */ LINK_ENTITY_TO_CLASS(info_null, CNullEntity); +// These are the new entry points to entities. + /* <1839f1> ../cstrike/dlls/subs.cpp:69 */ LINK_ENTITY_TO_CLASS(info_player_deathmatch, CBaseDMStart); @@ -73,33 +83,43 @@ LINK_ENTITY_TO_CLASS(info_hostage_rescue, CPointEntity); LINK_ENTITY_TO_CLASS(info_bomb_target, CPointEntity); /* <183647> ../cstrike/dlls/subs.cpp:79 */ -NOBODY void CBaseDMStart::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CBaseDMStart::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 81 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 87 -// KeyValue(CBaseDMStart *const this, -// KeyValueData *pkvd); // 79 + if (FStrEq(pkvd->szKeyName, "master")) + { + pev->netname = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CPointEntity::KeyValue(pkvd); } /* <18331c> ../cstrike/dlls/subs.cpp:90 */ -NOBODY BOOL CBaseDMStart::__MAKE_VHOOK(IsTriggered)(CBaseEntity *pEntity) +BOOL CBaseDMStart::__MAKE_VHOOK(IsTriggered)(CBaseEntity *pEntity) { -// { -// BOOL master; // 92 -// } + BOOL master = UTIL_IsMasterTriggered(pev->netname, pEntity); + + return master; } +// This updates global tables that need to know about entities being removed + /* <183f03> ../cstrike/dlls/subs.cpp:98 */ void CBaseEntity::UpdateOnRemove(void) { + int i; + if (pev->flags & FL_GRAPHED) { - for (int i = 0; i < WorldGraph.m_cLinks; i++) + // 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. + for (i = 0; i < WorldGraph.m_cLinks; i++) { 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! WorldGraph.m_pLinkPool[i].m_pLinkEnt = NULL; + } } } @@ -109,12 +129,15 @@ void CBaseEntity::UpdateOnRemove(void) } } +// Convenient way to delay removing oneself + /* <183f38> ../cstrike/dlls/subs.cpp:120 */ void CBaseEntity::SUB_Remove(void) { UpdateOnRemove(); if (pev->health > 0) { + // this situation can screw up monsters who can't tell their entity pointers are invalid. pev->health = 0; ALERT(at_aiconsole, "SUB_Remove called on entity with health > 0\n"); } @@ -122,6 +145,8 @@ void CBaseEntity::SUB_Remove(void) REMOVE_ENTITY(ENT(pev)); } +// Convenient way to explicitly do nothing (passed to functions that require a method) + /* <183f8a> ../cstrike/dlls/subs.cpp:135 */ void CBaseEntity::SUB_DoNothing(void) { @@ -148,11 +173,23 @@ void CBaseDelay::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) CBaseEntity::KeyValue(pkvd); } +// If self.delay is set, a DelayedUse entity will be created that will actually +// do the SUB_UseTargets after that many seconds have passed. + +// Removes all entities with a targetname that match self.killtarget, +// and removes them, so some events can remove other triggers. + +// Search for (string)targetname in all entities that +// match (string)self.target and call their .use function (if they have one) + /* <1840d5> ../cstrike/dlls/subs.cpp:183 */ void CBaseEntity::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value) { + // fire targets if (!FStringNull(pev->target)) + { FireTargets(STRING(pev->target), pActivator, this, useType, value); + } } /* <183fb0> ../cstrike/dlls/subs.cpp:195 */ @@ -163,13 +200,15 @@ void FireTargets(const char *targetName, CBaseEntity *pActivator, CBaseEntity *p return; ALERT(at_aiconsole, "Firing: (%s)\n", targetName); - while (1) + while (true) { pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, targetName); if (FNullEnt(pentTarget)) break; CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); + + // Don't use dying ents if (pTarget && !(pTarget->pev->flags & FL_KILLME)) { ALERT(at_aiconsole, "Found: %s, firing (%s)\n", STRING(pTarget->pev->classname), targetName); @@ -184,62 +223,96 @@ LINK_ENTITY_TO_CLASS(DelayedUse, CBaseDelay); /* <1844c2> ../cstrike/dlls/subs.cpp:252 */ void CBaseDelay::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value) { - if (!pev->target && !m_iszKillTarget) + // exit immediatly if we don't have a target or kill target + if (FStringNull(pev->target) && !m_iszKillTarget) return; - if (!m_flDelay) - { - if (m_iszKillTarget) - { - ALERT(at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget)); - edict_t *pentKillTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszKillTarget)); - - while (!FNullEnt(pentKillTarget)) - { - UTIL_Remove(CBaseEntity::Instance(pentKillTarget)); - ALERT(at_aiconsole, "killing %s\n", STRING(pentKillTarget->v.classname)); - pentKillTarget = FIND_ENTITY_BY_TARGETNAME(pentKillTarget, STRING(m_iszKillTarget)); - } - } - if (pev->target) - FireTargets(STRING(pev->target), pActivator, this, useType, value); - } - else + // check for a delay + if (m_flDelay != 0) { + // create a temp object to fire at a later time CBaseDelay *pTemp = GetClassPtr((CBaseDelay *)NULL); if (pTemp->pev->classname) + { RemoveEntityHashValue(pTemp->pev, STRING(pTemp->pev->classname), CLASSNAME); + } MAKE_STRING_CLASS("DelayedUse", pTemp->pev); AddEntityHashValue(pTemp->pev, STRING(pTemp->pev->classname), CLASSNAME); pTemp->pev->nextthink = gpGlobals->time + m_flDelay; pTemp->SetThink(&CBaseDelay::DelayThink); + + // Save the useType pTemp->pev->button = (int)useType; pTemp->m_iszKillTarget = m_iszKillTarget; - pTemp->m_flDelay = 0.0f; + + // prevent "recursion" + pTemp->m_flDelay = 0; pTemp->pev->target = pev->target; + // HACKHACK + // 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. + // This code is not as ugly as that code + + // If a player activates, then save it if (pActivator && pActivator->IsPlayer()) + { pTemp->pev->owner = pActivator->edict(); + } else + { pTemp->pev->owner = NULL; + } + + return; + } + + // kill the killtargets + if (m_iszKillTarget) + { + edict_t *pentKillTarget = NULL; + + ALERT(at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget)); + pentKillTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszKillTarget)); + + while (!FNullEnt(pentKillTarget)) + { + UTIL_Remove(CBaseEntity::Instance(pentKillTarget)); + + ALERT(at_aiconsole, "killing %s\n", STRING(pentKillTarget->v.classname)); + pentKillTarget = FIND_ENTITY_BY_TARGETNAME(pentKillTarget, STRING(m_iszKillTarget)); + } + } + + // fire targets + if (!FStringNull(pev->target)) + { + FireTargets(STRING(pev->target), pActivator, this, useType, value); } } +// QuakeEd only writes a single float for angles (bad idea), so up and down are +// just constant angles. + /* <1846d9> ../cstrike/dlls/subs.cpp:335 */ void SetMovedir(entvars_t *pev) { if (pev->angles == Vector(0, -1, 0)) + { pev->movedir = Vector(0, 0, 1); - + } else if (pev->angles == Vector(0, -2, 0)) + { pev->movedir = Vector(0, 0, -1); + } else { UTIL_MakeVectors(pev->angles); pev->movedir = gpGlobals->v_forward; } + pev->angles = g_vecZero; } @@ -247,10 +320,15 @@ void SetMovedir(entvars_t *pev) void CBaseDelay::DelayThink(void) { CBaseEntity *pActivator = NULL; - if (pev->owner) - pActivator = CBaseEntity::Instance(pev->owner); - SUB_UseTargets(pActivator, (USE_TYPE)pev->button, 0.0f); + // A player activated this on delay + if (pev->owner != NULL) + { + pActivator = CBaseEntity::Instance(pev->owner); + } + + // The use type is cached (and stashed) in pev->button + SUB_UseTargets(pActivator, (USE_TYPE)pev->button, 0); REMOVE_ENTITY(ENT(pev)); } @@ -284,82 +362,177 @@ void CBaseToggle::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) CBaseDelay::KeyValue(pkvd); } +// calculate pev->velocity and pev->nextthink to reach vecDest from +// pev->origin traveling at flSpeed + /* <18474d> ../cstrike/dlls/subs.cpp:431 */ -NOBODY void CBaseToggle::LinearMove(Vector vecDest, float flSpeed) +void CBaseToggle::LinearMove(Vector vecDest, float flSpeed) { -// { -// class Vector vecDestDelta; // 446 -// float flTravelTime; // 449 -// operator==(const class Vector *const this, -// const class Vector &v); // 439 -// operator-(const class Vector *const this, -// const class Vector &v); // 446 -// Length(const class Vector *const this); // 449 -// operator/(const class Vector *const this, -// float fl); // 456 -// LinearMoveDone(CBaseToggle *const this); // 441 -// } + assert(("LinearMove: no speed is defined!", flSpeed != 0)); + //assert(("LinearMove: no post-move function defined", m_pfnCallWhenMoveDone != NULL)); + + m_vecFinalDest = vecDest; + + // Already there? + if (vecDest == pev->origin) + { + LinearMoveDone(); + return; + } + + // set destdelta to the vector needed to move + Vector vecDestDelta = vecDest - pev->origin; + + // divide vector length by speed to get time to reach dest + float_precision flTravelTime = vecDestDelta.Length() / flSpeed; + + // set nextthink to trigger a call to LinearMoveDone when dest is reached + pev->nextthink = pev->ltime + flTravelTime; + SetThink(&CBaseToggle::LinearMoveDone); + + // scale the destdelta vector by the time spent traveling to get velocity + pev->velocity = vecDestDelta * (float)(1 / flTravelTime); } +// After moving, set origin to exact final destination, call "move done" function + /* <18337e> ../cstrike/dlls/subs.cpp:465 */ -NOBODY void CBaseToggle::LinearMoveDone(void) +void CBaseToggle::LinearMoveDone(void) { + UTIL_SetOrigin(pev, m_vecFinalDest); + pev->velocity = g_vecZero; + pev->nextthink = -1; + + if (m_pfnCallWhenMoveDone) + { + (this->*m_pfnCallWhenMoveDone)(); + } } /* <184855> ../cstrike/dlls/subs.cpp:474 */ -NOBODY BOOL CBaseToggle::IsLockedByMaster(void) +NOXREF BOOL CBaseToggle::IsLockedByMaster(void) { + if (!FStringNull(m_sMaster) && !UTIL_IsMasterTriggered(m_sMaster, m_hActivator)) + return TRUE; + else + return FALSE; } +// calculate pev->velocity and pev->nextthink to reach vecDest from +// pev->origin traveling at flSpeed +// Just like LinearMove, but rotational. + /* <18487c> ../cstrike/dlls/subs.cpp:491 */ -NOBODY void CBaseToggle::AngularMove(Vector vecDestAngle, float flSpeed) +void CBaseToggle::AngularMove(Vector vecDestAngle, float flSpeed) { -// { -// class Vector vecDestDelta; // 506 -// float flTravelTime; // 509 -// operator==(const class Vector *const this, -// const class Vector &v); // 499 -// operator-(const class Vector *const this, -// const class Vector &v); // 506 -// Length(const class Vector *const this); // 509 -// operator/(const class Vector *const this, -// float fl); // 516 -// AngularMoveDone(CBaseToggle *const this); // 501 -// } + assert(("AngularMove: no speed is defined!", flSpeed != 0)); + //assert(("AngularMove: no post-move function defined", m_pfnCallWhenMoveDone != NULL)); + + m_vecFinalAngle = vecDestAngle; + + // Already there? + if (vecDestAngle == pev->angles) + { + AngularMoveDone(); + return; + } + + // set destdelta to the vector needed to move + Vector vecDestDelta = vecDestAngle - pev->angles; + + // divide by speed to get time to reach dest + float_precision flTravelTime = vecDestDelta.Length() / flSpeed; + + // set nextthink to trigger a call to AngularMoveDone when dest is reached + pev->nextthink = pev->ltime + flTravelTime; + SetThink(&CBaseToggle::AngularMoveDone); + + // scale the destdelta vector by the time spent traveling to get velocity + pev->avelocity = vecDestDelta / flTravelTime; } +// After rotating, set angle to exact final angle, call "move done" function + /* <1832fb> ../cstrike/dlls/subs.cpp:525 */ -NOBODY void CBaseToggle::AngularMoveDone(void) +void CBaseToggle::AngularMoveDone(void) { + pev->angles = m_vecFinalAngle; + pev->avelocity = g_vecZero; + pev->nextthink = -1; + + if (m_pfnCallWhenMoveDone) + { + (this->*m_pfnCallWhenMoveDone)(); + } } /* <184984> ../cstrike/dlls/subs.cpp:535 */ -NOBODY float CBaseToggle::AxisValue(int flags, Vector &angles) +float CBaseToggle::AxisValue(int flags, const Vector &angles) { + if (flags & SF_DOOR_ROTATE_Z) + return angles.z; + + if (flags & SF_DOOR_ROTATE_X) + return angles.x; + + return angles.y; } /* <1849bd> ../cstrike/dlls/subs.cpp:546 */ -NOBODY void CBaseToggle::AxisDir(entvars_t *pev) +void CBaseToggle::AxisDir(entvars_t *pev) { + if (pev->spawnflags & SF_DOOR_ROTATE_Z) + { + // around z-axis + pev->movedir = Vector(0, 0, 1); + } + else if (pev->spawnflags & SF_DOOR_ROTATE_X) + { + // around x-axis + pev->movedir = Vector(1, 0, 0); + } + else + { + // around y-axis + pev->movedir = Vector(0, 1, 0); + } } /* <1849e3> ../cstrike/dlls/subs.cpp:557 */ -NOBODY float CBaseToggle::AxisDelta(int flags, Vector &angle1, Vector &angle2) +float CBaseToggle::AxisDelta(int flags, const Vector &angle1, const Vector &angle2) { + if (flags & SF_DOOR_ROTATE_Z) + return angle1.z - angle2.z; + + if (flags & SF_DOOR_ROTATE_X) + return angle1.x - angle2.x; + + return angle1.y - angle2.y; } +// returns TRUE if the passed entity is visible to caller, even if not infront () + /* <184a30> ../cstrike/dlls/subs.cpp:577 */ -NOBODY BOOL FEntIsVisible(entvars_t *pev, entvars_t *pevTarget) +NOXREF BOOL FEntIsVisible(entvars_t *pev, entvars_t *pevTarget) { -// { -// class Vector vecSpot1; // 581 -// class Vector vecSpot2; // 582 -// TraceResult tr; // 583 -// operator+(const class Vector *const this, -// const class Vector &v); // 581 -// operator+(const class Vector *const this, -// const class Vector &v); // 582 -// } + Vector vecSpot1 = pev->origin + pev->view_ofs; + Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs; + TraceResult tr; + + UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr); + + if (tr.fInOpen && tr.fInWater) + { + // sight line crossed contents + return FALSE; + } + + if (tr.flFraction == 1.0f) + { + return TRUE; + } + + return FALSE; } #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/subs.h b/regamedll/dlls/subs.h index 468fb1ad..958a58e6 100644 --- a/regamedll/dlls/subs.h +++ b/regamedll/dlls/subs.h @@ -36,7 +36,7 @@ class CNullEntity: public CBaseEntity { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -50,8 +50,8 @@ public: class CBaseDMStart: public CPointEntity { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual BOOL IsTriggered(CBaseEntity *pEntity); + virtual void KeyValue(KeyValueData *pkvd); + virtual BOOL IsTriggered(CBaseEntity *pEntity); #ifdef HOOK_GAMEDLL @@ -64,6 +64,16 @@ public: void FireTargets(const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void SetMovedir(entvars_t *pev); -NOBODY BOOL FEntIsVisible(entvars_t *pev, entvars_t *pevTarget); +NOXREF BOOL FEntIsVisible(entvars_t *pev, entvars_t *pevTarget); -#endif // SUBS_H \ No newline at end of file +// linked objects +C_DLLEXPORT void info_null(entvars_t *pev); +C_DLLEXPORT void info_player_deathmatch(entvars_t *pev); +C_DLLEXPORT void info_player_start(entvars_t *pev); +C_DLLEXPORT void info_vip_start(entvars_t *pev); +C_DLLEXPORT void info_landmark(entvars_t *pev); +C_DLLEXPORT void info_hostage_rescue(entvars_t *pev); +C_DLLEXPORT void info_bomb_target(entvars_t *pev); +C_DLLEXPORT void DelayedUse(entvars_t *pev); + +#endif // SUBS_H diff --git a/regamedll/dlls/talkmonster.h b/regamedll/dlls/talkmonster.h index 1195a9c7..47a6fa79 100644 --- a/regamedll/dlls/talkmonster.h +++ b/regamedll/dlls/talkmonster.h @@ -38,4 +38,4 @@ public: static float g_talkWaitTime; }; -#endif // TALKMONSTER_H \ No newline at end of file +#endif // TALKMONSTER_H diff --git a/regamedll/dlls/training_gamerules.cpp b/regamedll/dlls/training_gamerules.cpp index db72893f..9e5f6325 100644 --- a/regamedll/dlls/training_gamerules.cpp +++ b/regamedll/dlls/training_gamerules.cpp @@ -111,7 +111,7 @@ void CHalfLifeTraining::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer) pPlayer->m_iTeam = CT; pPlayer->m_bCanShoot = true; pPlayer->m_fLastMovement = gpGlobals->time; - + if (pPlayer->m_pActiveItem) pPlayer->m_iHideHUD &= ~HIDEHUD_WEAPONS; else @@ -314,7 +314,7 @@ void CHalfLifeTraining::__MAKE_VHOOK(CheckWinConditions)(void) CBaseEntity *pRescueArea; CBaseEntity *pFirstRescueArea; - + pFirstRescueArea = CBaseEntity::Instance(FIND_ENTITY_BY_CLASSNAME(NULL, "func_hostage_rescue")); pRescueArea = pFirstRescueArea; @@ -675,4 +675,4 @@ void CHalfLifeTraining::CheckWinConditions(void) CheckWinConditions_(); } -#endif // HOOK_GAMEDLL \ No newline at end of file +#endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/training_gamerules.h b/regamedll/dlls/training_gamerules.h index 0f49fe67..995d36ef 100644 --- a/regamedll/dlls/training_gamerules.h +++ b/regamedll/dlls/training_gamerules.h @@ -50,7 +50,7 @@ public: virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer); virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); virtual int ItemShouldRespawn(CItem *pItem); - virtual void CheckMapConditions(void) { } + virtual void CheckMapConditions(void) {}; virtual void CheckWinConditions(void); #ifdef HOOK_GAMEDLL diff --git a/regamedll/dlls/trains.h b/regamedll/dlls/trains.h index 678e653b..2044f7e9 100644 --- a/regamedll/dlls/trains.h +++ b/regamedll/dlls/trains.h @@ -54,46 +54,46 @@ class CPathTrack: public CPointEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData* pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void Activate(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - -#ifdef HOOK_GAMEDLL - - void Spawn_(void); - void KeyValue_(KeyValueData* pkvd); - int Save_(CSave &save); - int Restore_(CRestore &restore); - void Activate_(void); - void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - -#endif // HOOK_GAMEDLL - - NOBODY void SetPrevious(CPathTrack *pprevious); - NOBODY void Link(void); - - // Returns ppath if enabled, NULL otherwise - NOBODY CPathTrack *ValidPath(CPathTrack *ppath, int testFlag); - NOBODY void Project(CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist); - - NOBODY static CPathTrack *Instance(edict_t *pent); - - NOBODY CPathTrack *LookAhead(Vector *origin, float dist, int move); - NOBODY CPathTrack *Nearest(Vector origin); - - NOBODY CPathTrack *GetNext(void); - NOBODY CPathTrack *GetPrevious(void); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData* pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void Activate(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); -public: - static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[5]; - - float m_length; - string_t m_altName; - CPathTrack *m_pnext; - CPathTrack *m_pprevious; +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void KeyValue_(KeyValueData* pkvd); + int Save_(CSave &save); + int Restore_(CRestore &restore); + void Activate_(void); + void Use_(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + +#endif // HOOK_GAMEDLL + + void SetPrevious(CPathTrack *pprevious); + void Link(void); + + // Returns ppath if enabled, NULL otherwise + CPathTrack *ValidPath(CPathTrack *ppath, int testFlag); + void Project(CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist); + + static CPathTrack *Instance(edict_t *pent); + + CPathTrack *LookAhead(Vector *origin, float dist, int move); + CPathTrack *Nearest(Vector origin); + + CPathTrack *GetNext(void); + CPathTrack *GetPrevious(void); + +public: + static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[5]; + + float m_length; + string_t m_altName; + CPathTrack *m_pnext; + CPathTrack *m_pprevious; CPathTrack *m_paltpath; };/* size: 172, cachelines: 3, members: 7 */ @@ -102,20 +102,20 @@ public: class CFuncTrackTrain: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData* pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual void Restart(void); + virtual void KeyValue(KeyValueData* pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void OverrideReset(void); - NOBODY virtual BOOL OnControls(entvars_t *pev); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual void Blocked(CBaseEntity *pOther); + virtual void OverrideReset(void); + virtual BOOL OnControls(entvars_t *pev); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Blocked(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -137,22 +137,21 @@ public: #endif // HOOK_GAMEDLL public: + void EXPORT Next(void); + void EXPORT Find(void); + void EXPORT NearestPath(void); + void EXPORT DeadEnd(void); - NOBODY void EXPORT Next(void); - NOBODY void EXPORT Find(void); - NOBODY void EXPORT NearestPath(void); - NOBODY void EXPORT DeadEnd(void); - - NOBODY void NextThink(float thinkTime, BOOL alwaysThink); + void NextThink(float thinkTime, BOOL alwaysThink); void SetTrack(CPathTrack *track) { m_ppath = track->Nearest(pev->origin); } - NOBODY void SetControls(entvars_t *pevControls); - NOBODY void StopSound(void); - NOBODY void UpdateSound(void); + void SetControls(entvars_t *pevControls); + void StopSound(void); + void UpdateSound(void); - NOBODY static CFuncTrackTrain *Instance(edict_t *pent); + static CFuncTrackTrain *Instance(edict_t *pent); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[12]; @@ -180,24 +179,24 @@ private: };/* size: 236, cachelines: 4, members: 19 */ /* <1ba5f9> ../cstrike/dlls/trains.h:134 */ -class CFuncVehicle: public CBaseEntity -{ +class CFuncVehicle: public CBaseEntity +{ public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); virtual void Precache(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Restart(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } virtual int Classify(void); - NOBODY virtual void OverrideReset(void); + virtual void OverrideReset(void); virtual BOOL OnControls(entvars_t *pev); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY virtual void Blocked(CBaseEntity *pOther); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Blocked(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -220,27 +219,27 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT Next(void); - NOBODY void EXPORT Find(void); - NOBODY void EXPORT NearestPath(void); - NOBODY void EXPORT DeadEnd(void); + void EXPORT Next(void); + void EXPORT Find(void); + void EXPORT NearestPath(void); + void EXPORT DeadEnd(void); - NOBODY void NextThink(float thinkTime, BOOL alwaysThink); - NOBODY void CollisionDetection(void); - NOBODY void TerrainFollowing(void); - NOBODY void CheckTurning(void); + void NextThink(float thinkTime, BOOL alwaysThink); + void CollisionDetection(void); + void TerrainFollowing(void); + void CheckTurning(void); - NOBODY void SetTrack(CPathTrack *track) + void SetTrack(CPathTrack *track) { m_ppath = track->Nearest(pev->origin); } - NOBODY void SetControls(entvars_t *pevControls); - - NOBODY void StopSound(void); - NOBODY void UpdateSound(void); + void SetControls(entvars_t *pevControls); + + void StopSound(void); + void UpdateSound(void); public: - NOBODY static CFuncVehicle *Instance(edict_t *pent); + static CFuncVehicle *Instance(edict_t *pent); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[12]; @@ -283,15 +282,7 @@ private: };/* size: 364, cachelines: 6, members: 35 */ - - - - - - - - - - +// linked objects +C_DLLEXPORT void path_track(entvars_t *pev); #endif // TRAINS_H diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index a65c44b6..8f73c383 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -5,6 +5,7 @@ */ #ifndef HOOK_GAMEDLL +// Global Savedata for changelevel friction modifier TYPEDESCRIPTION CFrictionModifier::m_SaveData[] = { DEFINE_FIELD(CFrictionModifier, m_frictionFraction, FIELD_FLOAT), @@ -21,6 +22,7 @@ TYPEDESCRIPTION CTriggerRelay::m_SaveData[1] = DEFINE_FIELD(CTriggerRelay, triggerType, FIELD_INTEGER), }; +// Global Savedata for multi_manager TYPEDESCRIPTION CMultiManager::m_SaveData[] = { DEFINE_FIELD(CMultiManager, m_cTargets, FIELD_INTEGER), @@ -30,6 +32,7 @@ TYPEDESCRIPTION CMultiManager::m_SaveData[] = DEFINE_ARRAY(CMultiManager, m_flTargetDelay, FIELD_FLOAT, MAX_MULTI_TARGETS), }; +// Global Savedata for changelevel trigger TYPEDESCRIPTION CChangeLevel::m_SaveData[] = { DEFINE_ARRAY(CChangeLevel, m_szMapName, FIELD_CHARACTER, 32), @@ -42,6 +45,7 @@ TYPEDESCRIPTION CTriggerChangeTarget::m_SaveData[] = DEFINE_FIELD(CTriggerChangeTarget, m_iszNewTarget, FIELD_STRING), }; +// Global Savedata for changelevel friction modifier TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = { DEFINE_FIELD(CTriggerCamera, m_hPlayer, FIELD_EHANDLE), @@ -59,15 +63,21 @@ TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = DEFINE_FIELD(CTriggerCamera, m_state, FIELD_INTEGER), }; +FILE_GLOBAL char st_szNextMap[cchMapNameMost]; +FILE_GLOBAL char st_szNextSpot[cchMapNameMost]; + #else -TYPEDESCRIPTION (*CFrictionModifier::pm_SaveData)[1]; -TYPEDESCRIPTION (*CAutoTrigger::pm_SaveData)[2]; -TYPEDESCRIPTION (*CTriggerRelay::pm_SaveData)[1]; -TYPEDESCRIPTION (*CMultiManager::pm_SaveData)[5]; -TYPEDESCRIPTION (*CChangeLevel::pm_SaveData)[4]; -TYPEDESCRIPTION (*CTriggerChangeTarget::pm_SaveData)[1]; -TYPEDESCRIPTION (*CTriggerCamera::pm_SaveData)[13]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFrictionModifier, m_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CAutoTrigger, m_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CTriggerRelay, m_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CMultiManager, m_SaveData)[5]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CChangeLevel, m_SaveData)[4]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CTriggerChangeTarget, m_SaveData)[1]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CTriggerCamera, m_SaveData)[13]; + +char st_szNextMap[cchMapNameMost]; +char st_szNextSpot[cchMapNameMost]; #endif // HOOK_GAMEDLL @@ -78,18 +88,40 @@ LINK_ENTITY_TO_CLASS(func_friction, CFrictionModifier); IMPLEMENT_SAVERESTORE(CFrictionModifier, CBaseEntity); /* <19fa7d> ../cstrike/dlls/triggers.cpp:72 */ -NOBODY void CFrictionModifier::__MAKE_VHOOK(Spawn)(void) +void CFrictionModifier::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_TRIGGER; + + // set size and link into world + SET_MODEL(ENT(pev), STRING(pev->model)); + + pev->movetype = MOVETYPE_NONE; + SetTouch(&CFrictionModifier::ChangeFriction); } +// Sets toucher's friction to m_frictionFraction (1.0 = normal friction) + /* <19faa6> ../cstrike/dlls/triggers.cpp:82 */ -NOBODY void CFrictionModifier::ChangeFriction(CBaseEntity *pOther) +void CFrictionModifier::ChangeFriction(CBaseEntity *pOther) { + if (pOther->pev->movetype != MOVETYPE_BOUNCEMISSILE && pOther->pev->movetype != MOVETYPE_BOUNCE) + { + pOther->pev->friction = m_frictionFraction; + } } +// Sets toucher's friction to m_frictionFraction (1.0 = normal friction) + /* <1a1c39> ../cstrike/dlls/triggers.cpp:91 */ -NOBODY void CFrictionModifier::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CFrictionModifier::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { + if (FStrEq(pkvd->szKeyName, "modifier")) + { + m_frictionFraction = Q_atof(pkvd->szValue) / 100.0; + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } /* <1a2657> ../cstrike/dlls/triggers.cpp:126 */ @@ -99,33 +131,58 @@ LINK_ENTITY_TO_CLASS(trigger_auto, CAutoTrigger); IMPLEMENT_SAVERESTORE(CAutoTrigger, CBaseDelay); /* <1a1b64> ../cstrike/dlls/triggers.cpp:136 */ -NOBODY void CAutoTrigger::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CAutoTrigger::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 138 -// FStrEq(const char *sz1, -// const char *sz2); // 143 -// { -// int type; // 145 -// atoi(const char *__nptr); // 145 -// } -// KeyValue(class CAutoTrigger *const this, -// KeyValueData *pkvd); // 136 + if (FStrEq(pkvd->szKeyName, "globalstate")) + { + m_globalstate = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "triggerstate")) + { + int type = Q_atoi(pkvd->szValue); + switch (type) + { + case 0: + triggerType = USE_OFF; + break; + case 2: + triggerType = USE_TOGGLE; + break; + default: + triggerType = USE_ON; + break; + } + pkvd->fHandled = TRUE; + } + else + CBaseDelay::KeyValue(pkvd); } /* <19fb05> ../cstrike/dlls/triggers.cpp:165 */ -NOBODY void CAutoTrigger::__MAKE_VHOOK(Spawn)(void) +void CAutoTrigger::__MAKE_VHOOK(Spawn)(void) { + Precache(); } /* <19fb2d> ../cstrike/dlls/triggers.cpp:171 */ -NOBODY void CAutoTrigger::__MAKE_VHOOK(Precache)(void) +void CAutoTrigger::__MAKE_VHOOK(Precache)(void) { + pev->nextthink = gpGlobals->time + 0.1; } /* <19d48c> ../cstrike/dlls/triggers.cpp:177 */ -NOBODY void CAutoTrigger::__MAKE_VHOOK(Think)(void) +void CAutoTrigger::__MAKE_VHOOK(Think)(void) { + if (!m_globalstate || gGlobalState.EntityGetState(m_globalstate) == GLOBAL_ON) + { + SUB_UseTargets(this, triggerType, 0); + + if (pev->spawnflags & SF_AUTO_FIREONCE) + { + UTIL_Remove(this); + } + } } /* <1a2730> ../cstrike/dlls/triggers.cpp:207 */ @@ -135,22 +192,43 @@ LINK_ENTITY_TO_CLASS(trigger_relay, CTriggerRelay); IMPLEMENT_SAVERESTORE(CTriggerRelay, CBaseDelay); /* <1a1abc> ../cstrike/dlls/triggers.cpp:216 */ -NOBODY void CTriggerRelay::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CTriggerRelay::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 218 -// KeyValue(class CTriggerRelay *const this, -// KeyValueData *pkvd); // 216 + if (FStrEq(pkvd->szKeyName, "triggerstate")) + { + int type = Q_atoi(pkvd->szValue); + switch (type) + { + case 0: + triggerType = USE_OFF; + break; + case 2: + triggerType = USE_TOGGLE; + break; + default: + triggerType = USE_ON; + break; + } + pkvd->fHandled = TRUE; + } + else + CBaseDelay::KeyValue(pkvd); } /* <19fb7e> ../cstrike/dlls/triggers.cpp:240 */ -NOBODY void CTriggerRelay::__MAKE_VHOOK(Spawn)(void) +void CTriggerRelay::__MAKE_VHOOK(Spawn)(void) { + ; } /* <1a01d7> ../cstrike/dlls/triggers.cpp:247 */ -NOBODY void CTriggerRelay::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CTriggerRelay::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { + SUB_UseTargets(this, triggerType, 0); + if (pev->spawnflags & SF_RELAY_FIREONCE) + { + UTIL_Remove(this); + } } /* <1a283f> ../cstrike/dlls/triggers.cpp:304 */ @@ -160,133 +238,274 @@ LINK_ENTITY_TO_CLASS(multi_manager, CMultiManager); IMPLEMENT_SAVERESTORE(CMultiManager, CBaseToggle); /* <1a19ed> ../cstrike/dlls/triggers.cpp:318 */ -NOBODY void CMultiManager::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CMultiManager::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 325 -// { -// char tmp; // 335 -// atof(const char *__nptr); // 339 -// } -// KeyValue(class CMultiManager *const this, -// KeyValueData *pkvd); // 318 + if (FStrEq(pkvd->szKeyName, "wait")) + { + m_flWait = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else // add this field to the target list + { + // this assumes that additional fields are targetnames and their values are delay values. + if (m_cTargets < MAX_MULTI_TARGETS) + { + char tmp[128]; + + UTIL_StripToken(pkvd->szKeyName, tmp); + m_iTargetName[m_cTargets] = ALLOC_STRING(tmp); + m_flTargetDelay[m_cTargets] = Q_atof(pkvd->szValue); + m_cTargets++; + + pkvd->fHandled = TRUE; + } + } } /* <19fbce> ../cstrike/dlls/triggers.cpp:347 */ -NOBODY void CMultiManager::__MAKE_VHOOK(Spawn)(void) +void CMultiManager::__MAKE_VHOOK(Spawn)(void) { -// { -// int swapped; // 355 -// { -// int i; // 360 -// { -// int name; // 365 -// float delay; // 366 -// } -// } -// } + pev->solid = SOLID_NOT; + SetUse(&CMultiManager::ManagerUse); + SetThink(&CMultiManager::ManagerThink); + + // Sort targets + // Quick and dirty bubble sort + int swapped = 1; + + while (swapped) + { + swapped = 0; + for (int i = 1; i < m_cTargets; i++) + { + if (m_flTargetDelay[i] < m_flTargetDelay[i - 1]) + { + // Swap out of order elements + int name = m_iTargetName[i]; + float delay = m_flTargetDelay[i]; + + m_iTargetName[i] = m_iTargetName[i - 1]; + m_flTargetDelay[i] = m_flTargetDelay[i - 1]; + m_iTargetName[i - 1] = name; + m_flTargetDelay[i - 1] = delay; + swapped = 1; + } + } + } } /* <1a03e5> ../cstrike/dlls/triggers.cpp:377 */ -NOBODY void CMultiManager::__MAKE_VHOOK(Restart)(void) +void CMultiManager::__MAKE_VHOOK(Restart)(void) { -// { -// int i; // 379 -// edict_t *pentTarget; // 380 -// const char *name; // 381 -// { -// class CBaseEntity *pTarget; // 399 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 395 -// FNullEnt(const edict_t *pent); // 396 -// Instance(edict_t *pent); // 399 -// } -// IsClone(class CMultiManager *const this); // 410 -// } + edict_t *pentTarget = NULL; + + for (int i = 0; i < m_cTargets; i++) + { + const char *name = STRING(m_iTargetName[i]); + + if (!name) + continue; + + pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); + + if (FNullEnt(pentTarget)) + break; + + CBaseEntity *pTarget = (CBaseEntity *)CBaseEntity::Instance(pentTarget); + + if (pTarget && !(pTarget->pev->flags & FL_KILLME)) + { + pTarget->Restart(); + } + } + + SetThink(NULL); + + if (IsClone()) + { + UTIL_Remove(this); + return; + } + + SetUse(&CMultiManager::ManagerUse); + m_index = 0; } /* <1a1402> ../cstrike/dlls/triggers.cpp:420 */ -NOBODY BOOL CMultiManager::__MAKE_VHOOK(HasTarget)(string_t targetname) +BOOL CMultiManager::__MAKE_VHOOK(HasTarget)(string_t targetname) { -// { -// int i; // 422 -// FStrEq(const char *sz1, -// const char *sz2); // 423 -// } + for (int i = 0; i < m_cTargets; i++) + { + if (FStrEq(STRING(targetname), STRING(m_iTargetName[i]))) + { + return TRUE; + } + } + + return FALSE; } +// Designers were using this to fire targets that may or may not exist -- +// so I changed it to use the standard target fire code, made it a little simpler. + /* <1a0393> ../cstrike/dlls/triggers.cpp:432 */ -NOBODY void CMultiManager::ManagerThink(void) +void CMultiManager::ManagerThink(void) { -// { -// float time; // 434 -// IsClone(class CMultiManager *const this); // 446 -// } + float time; + + time = gpGlobals->time - m_startTime; + while (m_index < m_cTargets && m_flTargetDelay[ m_index ] <= time) + { + FireTargets(STRING(m_iTargetName[ m_index ]), m_hActivator, this, USE_TOGGLE, 0); + m_index++; + } + + // have we fired all targets? + if (m_index >= m_cTargets) + { + SetThink(NULL); + if (IsClone()) + { + UTIL_Remove(this); + return; + } + + // allow manager re-use + SetUse(&CMultiManager::ManagerUse); + } + else + pev->nextthink = m_startTime + m_flTargetDelay[ m_index ]; } /* <1a291b> ../cstrike/dlls/triggers.cpp:457 */ -NOBODY CMultiManager *CMultiManager::Clone(void) +CMultiManager *CMultiManager::Clone(void) { CMultiManager *pMulti = GetClassPtr((CMultiManager *)NULL); - edict_t *pEdict = pMulti->pev->pContainingEntity; + edict_t *pEdict = pMulti->pev->pContainingEntity; Q_memcpy(pMulti->pev, pev, sizeof(*pev)); + pMulti->pev->pContainingEntity = pEdict; pMulti->pev->spawnflags |= SF_MULTIMAN_CLONE; pMulti->m_cTargets = m_cTargets; + Q_memcpy(pMulti->m_iTargetName, m_iTargetName, sizeof(m_iTargetName)); Q_memcpy(pMulti->m_flTargetDelay, m_flTargetDelay, sizeof(m_flTargetDelay)); + return pMulti; } +// The USE function builds the time table and starts the entity thinking. + /* <1a2a24> ../cstrike/dlls/triggers.cpp:475 */ -NOBODY void CMultiManager::ManagerUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CMultiManager::ManagerUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// ShouldClone(class CMultiManager *const this); // 479 -// { -// class CMultiManager *pClone; // 481 -// } + // In multiplayer games, clone the MM and execute in the clone (like a thread) + // to allow multiple players to trigger the same multimanager + if (ShouldClone()) + { + CMultiManager *pClone = Clone(); + pClone->ManagerUse(pActivator, pCaller, useType, value); + return; + } + + m_hActivator = pActivator; + m_index = 0; + m_startTime = gpGlobals->time; + + // disable use until all targets have fired + SetUse(NULL); + SetThink(&CMultiManager::ManagerThink); + + pev->nextthink = gpGlobals->time; } /* <1a2ada> ../cstrike/dlls/triggers.cpp:532 */ LINK_ENTITY_TO_CLASS(env_render, CRenderFxManager); /* <19fc52> ../cstrike/dlls/triggers.cpp:535 */ -NOBODY void CRenderFxManager::__MAKE_VHOOK(Spawn)(void) +void CRenderFxManager::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_NOT; } /* <1a0c95> ../cstrike/dlls/triggers.cpp:540 */ -NOBODY void CRenderFxManager::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CRenderFxManager::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// Use(class CRenderFxManager *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 540 + if (!FStringNull(pev->target)) + { + edict_t *pentTarget = NULL; + while (true) + { + pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); + + if (FNullEnt(pentTarget)) + break; + + entvars_t *pevTarget = VARS(pentTarget); + + if (!(pev->spawnflags & SF_RENDER_MASKFX)) + pevTarget->renderfx = pev->renderfx; + + if (!(pev->spawnflags & SF_RENDER_MASKAMT)) + pevTarget->renderamt = pev->renderamt; + + if (!(pev->spawnflags & SF_RENDER_MASKMODE)) + pevTarget->rendermode = pev->rendermode; + + if (!(pev->spawnflags & SF_RENDER_MASKCOLOR)) + pevTarget->rendercolor = pev->rendercolor; + } + } } /* <1a2bb6> ../cstrike/dlls/triggers.cpp:583 */ LINK_ENTITY_TO_CLASS(trigger, CBaseTrigger); /* <1a2c92> ../cstrike/dlls/triggers.cpp:590 */ -NOBODY void CBaseTrigger::InitTrigger(void) +void CBaseTrigger::InitTrigger(void) { -// operator!=(const class Vector *const this, -// const class Vector &const v); // 594 + // trigger angles are used for one-way touches. An angle of 0 is assumed + // to mean no restrictions, so use a yaw of 360 instead. + if (pev->angles != g_vecZero) + { + SetMovedir(pev); + } + + pev->solid = SOLID_TRIGGER; + pev->movetype = MOVETYPE_NONE; + + // set size and link into world + SET_MODEL(ENT(pev), STRING(pev->model)); + + if (CVAR_GET_FLOAT("showtriggers") == 0) + { + pev->effects |= EF_NODRAW; + } } +// Cache user-entity-field values until spawn is called. + /* <1a17cf> ../cstrike/dlls/triggers.cpp:608 */ -NOBODY void CBaseTrigger::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CBaseTrigger::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 610 -// FStrEq(const char *sz1, -// const char *sz2); // 615 -// KeyValue(class CBaseTrigger *const this, -// KeyValueData *pkvd); // 608 -// atof(const char *__nptr); // 612 -// atof(const char *__nptr); // 617 + if (FStrEq(pkvd->szKeyName, "damage")) + { + pev->dmg = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "count")) + { + m_cTriggersLeft = (int)Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "damagetype")) + { + m_bitsDamageInflict = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseToggle::KeyValue(pkvd); } /* <1a3060> ../cstrike/dlls/triggers.cpp:636 */ @@ -296,219 +515,654 @@ LINK_ENTITY_TO_CLASS(trigger_hurt, CTriggerHurt); LINK_ENTITY_TO_CLASS(trigger_monsterjump, CTriggerMonsterJump); /* <1a2fdc> ../cstrike/dlls/triggers.cpp:652 */ -NOBODY void CTriggerMonsterJump::__MAKE_VHOOK(Spawn)(void) +void CTriggerMonsterJump::__MAKE_VHOOK(Spawn)(void) { -// Spawn(class CTriggerMonsterJump *const this); // 652 + SetMovedir(pev); + + InitTrigger(); + + pev->nextthink = 0; + pev->speed = 200; + m_flHeight = 150; + + if (!FStringNull(pev->targetname)) + { + // if targetted, spawn turned off + pev->solid = SOLID_NOT; + + // Unlink from trigger list + UTIL_SetOrigin(pev, pev->origin); + SetUse(&CTriggerMonsterJump::ToggleUse); + } } /* <1a00e4> ../cstrike/dlls/triggers.cpp:671 */ -NOBODY void CTriggerMonsterJump::__MAKE_VHOOK(Think)(void) +void CTriggerMonsterJump::__MAKE_VHOOK(Think)(void) { + // kill the trigger for now !!!UNDONE + pev->solid = SOLID_NOT; + + // Unlink from trigger list + UTIL_SetOrigin(pev, pev->origin); + SetThink(NULL); } /* <19fca2> ../cstrike/dlls/triggers.cpp:678 */ -NOBODY void CTriggerMonsterJump::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +void CTriggerMonsterJump::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { -// { -// entvars_t *pevOther; // 680 -// operator*(const class Vector *const this, -// float fl); // 695 -// } + entvars_t *pevOther = pOther->pev; + + if (!(pevOther->flags & FL_MONSTER)) + { + // touched by a non-monster. + return; + } + + pevOther->origin.z += 1; + + if ((pevOther->flags & FL_ONGROUND)) + { + // clear the onground so physics don't bitch + pevOther->flags &= ~FL_ONGROUND; + } + + // toss the monster! + pevOther->velocity = pev->movedir * pev->speed; + pevOther->velocity.z += m_flHeight; + pev->nextthink = gpGlobals->time; } /* <1a3218> ../cstrike/dlls/triggers.cpp:715 */ LINK_ENTITY_TO_CLASS(trigger_cdaudio, CTriggerCDAudio); +// Changes tracks or stops CD when player touches +// !!!HACK - overloaded HEALTH to avoid adding new field + /* <1a2382> ../cstrike/dlls/triggers.cpp:721 */ -NOBODY void CTriggerCDAudio::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +void CTriggerCDAudio::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { -// PlayTrack(class CTriggerCDAudio *const this); // 728 + // only clients may trigger these events + if (!pOther->IsPlayer()) + { + return; + } + + PlayTrack(); } /* <1a2fb4> ../cstrike/dlls/triggers.cpp:731 */ -NOBODY void CTriggerCDAudio::__MAKE_VHOOK(Spawn)(void) +void CTriggerCDAudio::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); } /* <1a2288> ../cstrike/dlls/triggers.cpp:736 */ -NOBODY void CTriggerCDAudio::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CTriggerCDAudio::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// PlayTrack(class CTriggerCDAudio *const this); // 738 + PlayTrack(); } /* <19e08b> ../cstrike/dlls/triggers.cpp:741 */ -NOBODY void PlayCDTrack(int iTrack) +void PlayCDTrack(int iTrack) { -// { -// edict_t *pClient; // 743 -// { -// char string; // 764 -// } -// } + edict_t *pClient; + + // manually find the single player. + pClient = INDEXENT(1); + + // Can't play if the client is not connected! + if (!pClient) + return; + + if (iTrack < -1 || iTrack > 30) + { + ALERT(at_console, "TriggerCDAudio - Track %d out of range\n"); + return; + } + + if (iTrack == -1) + { + CLIENT_COMMAND(pClient, "cd stop\n"); + } + else + { + char string[64]; + Q_sprintf(string, "cd play %3d\n", iTrack); + CLIENT_COMMAND(pClient, string); + } + } +// only plays for ONE client, so only use in single play! + /* <1a3372> ../cstrike/dlls/triggers.cpp:773 */ -NOBODY void CTriggerCDAudio::PlayTrack(void) +void CTriggerCDAudio::PlayTrack(void) { -// PlayCDTrack(int iTrack); // 775 + PlayCDTrack((int)pev->health); + + SetTouch(NULL); + UTIL_Remove(this); } /* <1a340c> ../cstrike/dlls/triggers.cpp:794 */ LINK_ENTITY_TO_CLASS(target_cdaudio, CTargetCDAudio); /* <1a170f> ../cstrike/dlls/triggers.cpp:796 */ -NOBODY void CTargetCDAudio::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CTargetCDAudio::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 798 -// KeyValue(class CBaseEntity *const this, -// KeyValueData *pkvd); // 804 -// KeyValue(class CTargetCDAudio *const this, -// KeyValueData *pkvd); // 796 + if (FStrEq(pkvd->szKeyName, "radius")) + { + pev->scale = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CPointEntity::KeyValue(pkvd); } /* <1a066a> ../cstrike/dlls/triggers.cpp:807 */ -NOBODY void CTargetCDAudio::__MAKE_VHOOK(Spawn)(void) +void CTargetCDAudio::__MAKE_VHOOK(Spawn)(void) { -// Spawn(class CTargetCDAudio *const this); // 807 + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + + if (pev->scale > 0) + { + pev->nextthink = gpGlobals->time + 1.0; + } } /* <1a2175> ../cstrike/dlls/triggers.cpp:816 */ -NOBODY void CTargetCDAudio::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CTargetCDAudio::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// Play(class CTargetCDAudio *const this); // 818 + Play(); } +// only plays for ONE client, so only use in single play! + /* <1a2465> ../cstrike/dlls/triggers.cpp:822 */ -NOBODY void CTargetCDAudio::__MAKE_VHOOK(Think)(void) +void CTargetCDAudio::__MAKE_VHOOK(Think)(void) { -// { -// edict_t *pClient; // 824 -// operator-(const class Vector *const this, -// const class Vector &const v); // 835 -// Length(const class Vector *const this); // 835 -// Play(class CTargetCDAudio *const this); // 836 -// } + edict_t *pClient; + + // manually find the single player. + pClient = INDEXENT(1); + + // Can't play if the client is not connected! + if (!pClient) + return; + + pev->nextthink = gpGlobals->time + 0.5; + + if ((pClient->v.origin - pev->origin).Length() <= pev->scale) + { + Play(); + } } /* <1a34e8> ../cstrike/dlls/triggers.cpp:840 */ -NOBODY void CTargetCDAudio::Play(void) +void CTargetCDAudio::Play(void) { -// PlayCDTrack(int iTrack); // 842 + PlayCDTrack((int)pev->health); + UTIL_Remove(this); } /* <1a2f8b> ../cstrike/dlls/triggers.cpp:853 */ -NOBODY void CTriggerHurt::__MAKE_VHOOK(Spawn)(void) +void CTriggerHurt::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); + SetTouch(&CTriggerHurt::HurtTouch); + + if (!FStringNull(pev->targetname)) + { + SetUse(&CTriggerHurt::ToggleUse); + } + else + { + SetUse(NULL); + } + + if (m_bitsDamageInflict & DMG_RADIATION) + { + SetThink(&CTriggerHurt::RadiationThink); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.0, 0.5); + } + + if (pev->spawnflags & SF_TRIGGER_HURT_START_OFF) + { + // if flagged to Start Turned Off, make trigger nonsolid. + pev->solid = SOLID_NOT; + } + + // Link into the list + UTIL_SetOrigin(pev, pev->origin); } +// trigger hurt that causes radiation will do a radius +// check and set the player's geiger counter level +// according to distance from center of trigger + /* <1a5df2> ../cstrike/dlls/triggers.cpp:883 */ -NOBODY void CTriggerHurt::RadiationThink(void) +void CTriggerHurt::RadiationThink(void) { + edict_t *pentPlayer; + CBasePlayer *pPlayer = NULL; + float_precision flRange; + entvars_t *pevTarget; + Vector vecSpot1; + Vector vecSpot2; + Vector vecRange; + Vector origin; + Vector view_ofs; + // check to see if a player is in pvs + // if not, continue + + // set origin to center of trigger so that this check works + origin = pev->origin; + view_ofs = pev->view_ofs; + + pev->origin = (pev->absmin + pev->absmax) * 0.5; + pev->view_ofs = pev->view_ofs * 0.0; + + pentPlayer = FIND_CLIENT_IN_PVS(edict()); + + pev->origin = origin; + pev->view_ofs = view_ofs; + + // reset origin + if (!FNullEnt(pentPlayer)) + { + pPlayer = GetClassPtr((CBasePlayer *)VARS(pentPlayer)); + + pevTarget = VARS(pentPlayer); + + // get range to player; + vecSpot1 = (pev->absmin + pev->absmax) * 0.5; + vecSpot2 = (pevTarget->absmin + pevTarget->absmax) * 0.5; + + vecRange = vecSpot1 - vecSpot2; + flRange = vecRange.Length(); + + // if player's current geiger counter range is larger + // than range to this trigger hurt, reset player's + // geiger counter range + + if (pPlayer->m_flgeigerRange >= flRange) + { + pPlayer->m_flgeigerRange = flRange; + } + } + + pev->nextthink = gpGlobals->time + 0.25; } +// ToggleUse - If this is the USE function for a trigger, its state will toggle every time it's fired + /* <1a007c> ../cstrike/dlls/triggers.cpp:942 */ -NOBODY void CBaseTrigger::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CBaseTrigger::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { + if (pev->solid == SOLID_NOT) + { + // if the trigger is off, turn it on + pev->solid = SOLID_TRIGGER; + + // Force retouch + gpGlobals->force_retouch++; + } + else + { + // turn the trigger off + pev->solid = SOLID_NOT; + } + + UTIL_SetOrigin(pev, pev->origin); } +// When touched, a hurt trigger does DMG points of damage each half-second + /* <1a0d93> ../cstrike/dlls/triggers.cpp:959 */ -NOBODY void CBaseTrigger::HurtTouch(CBaseEntity *pOther) +void CBaseTrigger::HurtTouch(CBaseEntity *pOther) { -// { -// float fldmg; // 961 -// } -// HurtTouch(class CBaseTrigger *const this, -// class CBaseEntity *pOther); // 959 + float fldmg; + + if (!pOther->pev->takedamage) + { + return; + } + + if ((pev->spawnflags & SF_TRIGGER_HURT_CLIENTONLYTOUCH) && !pOther->IsPlayer()) + { + // this trigger is only allowed to touch clients, and this ain't a client. + return; + } + + if ((pev->spawnflags & SF_TRIGGER_HURT_NO_CLIENTS) && pOther->IsPlayer()) + { + return; + } + + // HACKHACK -- In multiplayer, players touch this based on packet receipt. + // So the players who send packets later aren't always hurt. Keep track of + // how much time has passed and whether or not you've touched that player + if (g_pGameRules->IsMultiplayer()) + { + if (pev->dmgtime > gpGlobals->time) + { + if (gpGlobals->time != pev->pain_finished) + { + // too early to hurt again, and not same frame with a different entity + if (!pOther->IsPlayer()) + { + return; + } + + int playerMask = 1 << (pOther->entindex() - 1); + + // If I've already touched this player (this time), then bail out + if (pev->impulse & playerMask) + return; + + // Mark this player as touched + // BUGBUG - There can be only 32 players! + pev->impulse |= playerMask; + } + } + else + { + // New clock, "un-touch" all players + pev->impulse = 0; + if (pOther->IsPlayer()) + { + int playerMask = 1 << (pOther->entindex() - 1); + + // Mark this player as touched + // BUGBUG - There can be only 32 players! + pev->impulse |= playerMask; + } + } + } + else + { + // Original code -- single player + if (pev->dmgtime > gpGlobals->time && gpGlobals->time != pev->pain_finished) + { + // too early to hurt again, and not same frame with a different entity + return; + } + } + + // If this is time_based damage (poison, radiation), override the pev->dmg with a + // default for the given damage type. Monsters only take time-based damage + // while touching the trigger. Player continues taking damage for a while after + // leaving the trigger + + // 0.5 seconds worth of damage, pev->dmg is damage/second + fldmg = pev->dmg * 0.5; + + if (fldmg < 0) + { + pOther->TakeHealth(-fldmg, m_bitsDamageInflict); + } + else + { + pOther->TakeDamage(pev, pev, fldmg, m_bitsDamageInflict); + } + + // Store pain time so we can get all of the other entities on this frame + pev->pain_finished = gpGlobals->time; + + // Apply damage every half second + // half second delay until this trigger can hurt toucher again + pev->dmgtime = gpGlobals->time + 0.5; + + if (pev->target) + { + // trigger has a target it wants to fire. + if (pev->spawnflags & SF_TRIGGER_HURT_CLIENTONLYFIRE) + { + // if the toucher isn't a client, don't fire the target! + if (!pOther->IsPlayer()) + { + return; + } + } + + SUB_UseTargets(pOther, USE_TOGGLE, 0); + if (pev->spawnflags & SF_TRIGGER_HURT_TARGETONCE) + { + pev->target = 0; + } + } } /* <1a3582> ../cstrike/dlls/triggers.cpp:1086 */ LINK_ENTITY_TO_CLASS(trigger_multiple, CTriggerMultiple); /* <1a2f67> ../cstrike/dlls/triggers.cpp:1089 */ -NOBODY void CTriggerMultiple::__MAKE_VHOOK(Spawn)(void) +void CTriggerMultiple::__MAKE_VHOOK(Spawn)(void) { + if (m_flWait == 0) + m_flWait = 0.2; + + InitTrigger(); + + assert(("trigger_multiple with health", pev->health == 0)); + + //UTIL_SetOrigin(pev, pev->origin); + //SET_MODEL(ENT(pev), STRING(pev->model)); + + //if (pev->health > 0) + //{ + // if (FBitSet(pev->spawnflags, SPAWNFLAG_NOTOUCH)) + // { + // ALERT(at_error, "trigger_multiple spawn: health and notouch don't make sense"); + // } + // pev->max_health = pev->health; + // //UNDONE: where to get pfnDie from? + // pev->pfnDie = multi_killed; + // pev->takedamage = DAMAGE_YES; + // pev->solid = SOLID_BBOX; + // // make sure it links into the world + // UTIL_SetOrigin(pev, pev->origin); + //} + //else + { + SetTouch(&CTriggerMultiple::MultiTouch); + } } /* <1a365e> ../cstrike/dlls/triggers.cpp:1135 */ LINK_ENTITY_TO_CLASS(trigger_once, CTriggerOnce); /* <1a301c> ../cstrike/dlls/triggers.cpp:1136 */ -NOBODY void CTriggerOnce::__MAKE_VHOOK(Spawn)(void) +void CTriggerOnce::__MAKE_VHOOK(Spawn)(void) { -// Spawn(class CTriggerMultiple *const this); // 1140 + m_flWait = -1; + CTriggerMultiple::Spawn(); } /* <1a20a4> ../cstrike/dlls/triggers.cpp:1145 */ -NOBODY void CBaseTrigger::MultiTouch(CBaseEntity *pOther) +void CBaseTrigger::MultiTouch(CBaseEntity *pOther) { -// { -// entvars_t *pevToucher; // 1147 -// ActivateMultiTrigger(class CBaseTrigger *const this, -// class CBaseEntity *pActivator); // 1157 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 1154 -// } + entvars_t *pevToucher; + + pevToucher = pOther->pev; + + // Only touch clients, monsters, or pushables (depending on flags) + if ((pevToucher->flags & FL_CLIENT && !(pev->spawnflags & SF_TRIGGER_NOCLIENTS)) + || (pevToucher->flags & FL_MONSTER && (pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS)) + || (pev->spawnflags & SF_TRIGGER_PUSHABLES && FClassnameIs(pevToucher,"func_pushable"))) + { + ActivateMultiTrigger(pOther); + } } +// the trigger was just touched/killed/used +// self.enemy should be set to the activator so it can be held through a delay +// so wait for the delay time before firing + /* <1a373a> ../cstrike/dlls/triggers.cpp:1167 */ -NOBODY void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator) +void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator) { + if (pev->nextthink > gpGlobals->time) + { + // still waiting for reset time + return; + } + + if (!UTIL_IsMasterTriggered(m_sMaster, pActivator)) + { + return; + } + + if (FClassnameIs(pev, "trigger_secret")) + { + if (pev->enemy == NULL || !FClassnameIs(pev->enemy, "player")) + return; + + gpGlobals->found_secrets++; + } + + if (!FStringNull(pev->noise)) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), VOL_NORM, ATTN_NORM); + } + + // don't trigger again until reset + // pev->takedamage = DAMAGE_NO; + m_hActivator = pActivator; + SUB_UseTargets(m_hActivator, USE_TOGGLE, 0); + + if (pev->message && pActivator->IsPlayer()) + { + UTIL_ShowMessage(STRING(pev->message), pActivator); + } + + if (m_flWait > 0) + { + SetThink(&CBaseTrigger::MultiWaitOver); + pev->nextthink = gpGlobals->time + m_flWait; + } + else + { + // we can't just remove (self) here, because this is a touch function + // called while C code is looping through area links... + SetTouch(NULL); + pev->nextthink = gpGlobals->time + 0.1; + SetThink(&CBaseTrigger::SUB_Remove); + } } +// the wait time has passed, so set back up for another activation + /* <19fd1a> ../cstrike/dlls/triggers.cpp:1214 */ -NOBODY void CBaseTrigger::MultiWaitOver(void) +void CBaseTrigger::MultiWaitOver(void) { + SetThink(NULL); } /* <1a1f98> ../cstrike/dlls/triggers.cpp:1231 */ -NOBODY void CBaseTrigger::CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CBaseTrigger::CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// BOOL fTellActivator; // 1239 -// } -// CounterUse(class CBaseTrigger *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 1231 + m_cTriggersLeft--; + m_hActivator = pActivator; + + if (m_cTriggersLeft < 0) + { + return; + } + + BOOL fTellActivator = (m_hActivator != 0 && FClassnameIs(m_hActivator->pev, "player") && !(pev->spawnflags & SPAWNFLAG_NOMESSAGE)); + + if (m_cTriggersLeft != 0) + { + if (fTellActivator) + { + // UNDONE: I don't think we want these Quakesque messages + switch (m_cTriggersLeft) + { + case 1: ALERT(at_console, "Only 1 more to go..."); break; + case 2: ALERT(at_console, "Only 2 more to go..."); break; + case 3: ALERT(at_console, "Only 3 more to go..."); break; + default: ALERT(at_console, "There are more to go..."); break; + } + } + + return; + } + + // !!!UNDONE: I don't think we want these Quakesque messages + if (fTellActivator) + { + ALERT(at_console, "Sequence completed!"); + } + + ActivateMultiTrigger(m_hActivator); } /* <1a3767> ../cstrike/dlls/triggers.cpp:1278 */ LINK_ENTITY_TO_CLASS(trigger_counter, CTriggerCounter); /* <19fd42> ../cstrike/dlls/triggers.cpp:1280 */ -NOBODY void CTriggerCounter::__MAKE_VHOOK(Spawn)(void) +void CTriggerCounter::__MAKE_VHOOK(Spawn)(void) { + // By making the flWait be -1, this counter-trigger will disappear after it's activated + // (but of course it needs cTriggersLeft "uses" before that happens). + m_flWait = -1; + + if (m_cTriggersLeft == 0) + { + m_cTriggersLeft = 2; + } + + SetUse(&CTriggerCounter::CounterUse); } /* <1a3843> ../cstrike/dlls/triggers.cpp:1299 */ LINK_ENTITY_TO_CLASS(trigger_transition, CTriggerVolume); +// Define space that travels across a level transition + /* <19fd6a> ../cstrike/dlls/triggers.cpp:1302 */ -NOBODY void CTriggerVolume::__MAKE_VHOOK(Spawn)(void) +void CTriggerVolume::__MAKE_VHOOK(Spawn)(void) { + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + + // set size and link into world + SET_MODEL(ENT(pev), STRING(pev->model)); + + pev->model = NULL; + pev->modelindex = 0; } /* <1a3955> ../cstrike/dlls/triggers.cpp:1321 */ LINK_ENTITY_TO_CLASS(fireanddie, CFireAndDie); /* <1a0618> ../cstrike/dlls/triggers.cpp:1323 */ -NOBODY void CFireAndDie::__MAKE_VHOOK(Spawn)(void) +void CFireAndDie::__MAKE_VHOOK(Spawn)(void) { -// MAKE_STRING_CLASS(const char *str, -// entvars_t *pev); // 1325 + if (pev->classname) + { + RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + } + + MAKE_STRING_CLASS("fireanddie", pev); + AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + // Don't call Precache() - it should be called on restore } /* <19fdbb> ../cstrike/dlls/triggers.cpp:1330 */ -NOBODY void CFireAndDie::__MAKE_VHOOK(Precache)(void) +void CFireAndDie::__MAKE_VHOOK(Precache)(void) { + pev->nextthink = gpGlobals->time + m_flDelay; } /* <1a01ae> ../cstrike/dlls/triggers.cpp:1337 */ -NOBODY void CFireAndDie::__MAKE_VHOOK(Think)(void) +void CFireAndDie::__MAKE_VHOOK(Think)(void) { + SUB_UseTargets(this, USE_TOGGLE, 0); + UTIL_Remove(this); } /* <1a3a67> ../cstrike/dlls/triggers.cpp:1371 */ @@ -517,31 +1171,80 @@ LINK_ENTITY_TO_CLASS(trigger_changelevel, CChangeLevel); /* <1a098d> ../cstrike/dlls/triggers.cpp:1382 */ IMPLEMENT_SAVERESTORE(CChangeLevel, CBaseTrigger); +// Cache user-entity-field values until spawn is called. + /* <1a1d4a> ../cstrike/dlls/triggers.cpp:1388 */ -NOBODY void CChangeLevel::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CChangeLevel::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 1390 -// KeyValue(class CChangeLevel *const this, -// KeyValueData *pkvd); // 1388 + if (FStrEq(pkvd->szKeyName, "map")) + { + if (Q_strlen(pkvd->szValue) >= cchMapNameMost) + { + ALERT(at_error, "Map name '%s' too long (32 chars)\n", pkvd->szValue); + } + + Q_strcpy(m_szMapName, pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "landmark")) + { + if (Q_strlen(pkvd->szValue) >= cchMapNameMost) + { + ALERT(at_error, "Landmark name '%s' too long (32 chars)\n", pkvd->szValue); + } + + Q_strcpy(m_szLandmarkName, pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "changetarget")) + { + m_changeTarget = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "changedelay")) + { + m_changeTargetDelay = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseTrigger::KeyValue(pkvd); } /* <1a2f25> ../cstrike/dlls/triggers.cpp:1423 */ -NOBODY void CChangeLevel::__MAKE_VHOOK(Spawn)(void) +void CChangeLevel::__MAKE_VHOOK(Spawn)(void) { + if (FStrEq(m_szMapName, "")) + { + ALERT(at_console, "a trigger_changelevel doesn't have a map"); + } + + if (FStrEq(m_szLandmarkName, "")) + { + ALERT(at_console, "trigger_changelevel to %s doesn't have a landmark", m_szMapName); + } + + if (!FStringNull(pev->targetname)) + { + SetUse(&CChangeLevel::UseChangeLevel); + } + + InitTrigger(); + if (!(pev->spawnflags & SF_CHANGELEVEL_USEONLY)) + { + SetTouch(&CChangeLevel::TouchChangeLevel); + } } /* <19fde3> ../cstrike/dlls/triggers.cpp:1441 */ -NOBODY void CChangeLevel::ExecuteChangeLevel(void) +void CChangeLevel::ExecuteChangeLevel(void) { -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 1443 -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// edict_t *ed); // 1448 + MESSAGE_BEGIN(MSG_ALL, SVC_CDTRACK); + WRITE_BYTE(3); + WRITE_BYTE(3); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ALL, SVC_INTERMISSION); + MESSAGE_END(); } /* <1a3b43> ../cstrike/dlls/triggers.cpp:1456 */ @@ -561,73 +1264,124 @@ edict_t *CChangeLevel::FindLandmark(const char *pLandmarkName) return NULL; } +// CChangeLevel::Use - allows level transitions to be +// triggered by buttons, etc. + /* <1a3e4f> ../cstrike/dlls/triggers.cpp:1479 */ -NOBODY void CChangeLevel::UseChangeLevel(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CChangeLevel::UseChangeLevel(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// ChangeLevelNow(class CChangeLevel *const this, -// class CBaseEntity *pActivator); // 1481 + ChangeLevelNow(pActivator); } /* <1a3fb2> ../cstrike/dlls/triggers.cpp:1484 */ -NOBODY void CChangeLevel::ChangeLevelNow(CBaseEntity *pActivator) +void CChangeLevel::ChangeLevelNow(CBaseEntity *pActivator) { -// { -// edict_t *pentLandmark; // 1486 -// LEVELLIST levels; // 1487 -// class CBaseEntity *pPlayer; // 1502 -// Instance(edict_t *pent); // 1502 -// InTransitionVolume(class CBaseEntity *pEntity, -// char *pVolumeName); // 1503 -// { -// class CFireAndDie *pFireAndDie; // 1512 -// GetClassPtr(class CFireAndDie *a); // 1512 -// edict(class CBaseEntity *const this); // 1520 -// } -// FNullEnt(const edict_t *pent); // 1532 -// } + edict_t *pentLandmark; + LEVELLIST levels[16]; + + // Don't work in deathmatch + if (g_pGameRules->IsDeathmatch()) + { + return; + } + + // Some people are firing these multiple times in a frame, disable + if (gpGlobals->time == pev->dmgtime) + { + return; + } + + pev->dmgtime = gpGlobals->time; + + CBaseEntity *pPlayer = CBaseEntity::Instance(INDEXENT(1)); + if (!InTransitionVolume(pPlayer, m_szLandmarkName)) + { + ALERT(at_aiconsole, "Player isn't in the transition volume %s, aborting\n", m_szLandmarkName); + return; + } + + // Create an entity to fire the changetarget + if (m_changeTarget) + { + CFireAndDie *pFireAndDie = GetClassPtr((CFireAndDie *)NULL); + + if (pFireAndDie) + { + // Set target and delay + pFireAndDie->pev->target = m_changeTarget; + pFireAndDie->m_flDelay = m_changeTargetDelay; + pFireAndDie->pev->origin = pPlayer->pev->origin; + + // Call spawn + DispatchSpawn(pFireAndDie->edict()); + } + } + + // This object will get removed in the call to CHANGE_LEVEL, copy the params into "safe" memory + Q_strcpy(st_szNextMap, m_szMapName); + + m_hActivator = pActivator; + SUB_UseTargets(pActivator, USE_TOGGLE, 0); + + // Init landmark to NULL + st_szNextSpot[0] = '\0'; + + // look for a landmark entity + pentLandmark = FindLandmark(m_szLandmarkName); + + if (!FNullEnt(pentLandmark)) + { + Q_strcpy(st_szNextSpot, m_szLandmarkName); + gpGlobals->vecLandmarkOffset = VARS(pentLandmark)->origin; + } + + ALERT(at_console, "CHANGE LEVEL: %s %s\n", st_szNextMap, st_szNextSpot); + CHANGE_LEVEL(st_szNextMap, st_szNextSpot); } /* <1a3ef5> ../cstrike/dlls/triggers.cpp:1545 */ -NOBODY void CChangeLevel::TouchChangeLevel(CBaseEntity *pOther) +void CChangeLevel::TouchChangeLevel(CBaseEntity *pOther) { -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 1547 -// ChangeLevelNow(class CChangeLevel *const this, -// class CBaseEntity *pActivator); // 1550 + if (!FClassnameIs(pOther->pev, "player")) + { + return; + } + + ChangeLevelNow(pOther); } -// Add a transition to the list, but ignore duplicates +// Add a transition to the list, but ignore duplicates // (a designer may have placed multiple trigger_changelevels with the same landmark) /* <1a3ff8> ../cstrike/dlls/triggers.cpp:1556 */ int CChangeLevel::AddTransitionToList(LEVELLIST *pLevelList, int listCount, const char *pMapName, const char *pLandmarkName, edict_t *pentLandmark) { - int i; - - if (!pLevelList || !pMapName || !pLandmarkName || !pentLandmark) - { - return 0; - } - - for (i = 0; i < listCount; i++) - { - if (pLevelList[i].pentLandmark == pentLandmark && Q_strcmp(pLevelList[i].mapName, pMapName) == 0) - { - return 0; - } - } - - Q_strcpy(pLevelList[ listCount ].mapName, pMapName); - Q_strcpy(pLevelList[ listCount ].landmarkName, pLandmarkName); - - pLevelList[ listCount ].pentLandmark = pentLandmark; - pLevelList[ listCount ].vecLandmarkOrigin = VARS(pentLandmark)->origin; - + int i; + + if (!pLevelList || !pMapName || !pLandmarkName || !pentLandmark) + { + return 0; + } + + for (i = 0; i < listCount; i++) + { + if (pLevelList[i].pentLandmark == pentLandmark && Q_strcmp(pLevelList[i].mapName, pMapName) == 0) + { + return 0; + } + } + + Q_strcpy(pLevelList[ listCount ].mapName, pMapName); + Q_strcpy(pLevelList[ listCount ].landmarkName, pLandmarkName); + + pLevelList[ listCount ].pentLandmark = pentLandmark; + pLevelList[ listCount ].vecLandmarkOrigin = VARS(pentLandmark)->origin; + return 1; } /* <1a44ba> ../cstrike/dlls/triggers.cpp:1576 */ -NOBODY int BuildChangeList(LEVELLIST *pLevelList, int maxList) +int BuildChangeList(LEVELLIST *pLevelList, int maxList) { CChangeLevel::ChangeList(pLevelList, maxList); } @@ -635,51 +1389,51 @@ NOBODY int BuildChangeList(LEVELLIST *pLevelList, int maxList) /* <1a4075> ../cstrike/dlls/triggers.cpp:1582 */ int CChangeLevel::InTransitionVolume(CBaseEntity *pEntity, char *pVolumeName) { - edict_t *pentVolume; - - if (pEntity->ObjectCaps() & FCAP_FORCE_TRANSITION) - { - return 1; - } - - // If you're following another entity, follow it through the transition (weapons follow the player) - if (pEntity->pev->movetype == MOVETYPE_FOLLOW) - { - if (pEntity->pev->aiment != NULL) - { - pEntity = CBaseEntity::Instance(pEntity->pev->aiment); - } - } - - // Unless we find a trigger_transition, everything is in the volume - int inVolume = 1; - - pentVolume = FIND_ENTITY_BY_TARGETNAME(NULL, pVolumeName); - while (!FNullEnt(pentVolume)) - { - CBaseEntity *pVolume = CBaseEntity::Instance(pentVolume); - - if (pVolume && FClassnameIs(pVolume->pev, "trigger_transition")) - { - // It touches one, it's in the volume - if (pVolume->Intersects(pEntity)) - return 1; - else - { - // Found a trigger_transition, but I don't intersect it -- if I don't find another, don't go! - inVolume = 0; - } - } - - pentVolume = FIND_ENTITY_BY_TARGETNAME(pentVolume, pVolumeName); - } - + edict_t *pentVolume; + + if (pEntity->ObjectCaps() & FCAP_FORCE_TRANSITION) + { + return 1; + } + + // If you're following another entity, follow it through the transition (weapons follow the player) + if (pEntity->pev->movetype == MOVETYPE_FOLLOW) + { + if (pEntity->pev->aiment != NULL) + { + pEntity = CBaseEntity::Instance(pEntity->pev->aiment); + } + } + + // Unless we find a trigger_transition, everything is in the volume + int inVolume = 1; + + pentVolume = FIND_ENTITY_BY_TARGETNAME(NULL, pVolumeName); + while (!FNullEnt(pentVolume)) + { + CBaseEntity *pVolume = CBaseEntity::Instance(pentVolume); + + if (pVolume && FClassnameIs(pVolume->pev, "trigger_transition")) + { + // It touches one, it's in the volume + if (pVolume->Intersects(pEntity)) + return 1; + else + { + // Found a trigger_transition, but I don't intersect it -- if I don't find another, don't go! + inVolume = 0; + } + } + + pentVolume = FIND_ENTITY_BY_TARGETNAME(pentVolume, pVolumeName); + } + return inVolume; } -// This has grown into a complicated beast -// Can we make this more elegant? -// This builds the list of all transitions on this level and which entities are in their PVS's and can / should +// This has grown into a complicated beast +// Can we make this more elegant? +// This builds the list of all transitions on this level and which entities are in their PVS's and can / should // be moved across. /* <1a40b1> ../cstrike/dlls/triggers.cpp:1625 */ @@ -705,7 +1459,7 @@ int CChangeLevel::ChangeList(LEVELLIST *pLevelList, int maxList) if (pentLandmark) { // Build a list of unique transitions - if (AddTransitionToList( pLevelList, count, pTrigger->m_szMapName, pTrigger->m_szLandmarkName, pentLandmark)) + if (AddTransitionToList(pLevelList, count, pTrigger->m_szMapName, pTrigger->m_szLandmarkName, pentLandmark)) { count++; @@ -759,7 +1513,7 @@ int CChangeLevel::ChangeList(LEVELLIST *pLevelList, int maxList) if (entityCount > MAX_ENTITY) { - ALERT( at_error, "Too many entities across a transition!" ); + ALERT(at_error, "Too many entities across a transition!"); } } } @@ -784,94 +1538,229 @@ int CChangeLevel::ChangeList(LEVELLIST *pLevelList, int maxList) return count; } +// go to the next level for deathmatch +// only called if a time or frag limit has expired + /* <1a44fc> ../cstrike/dlls/triggers.cpp:1722 */ -NOBODY void NextLevel(void) +NOXREF void NextLevel(void) { -// { -// edict_t *pent; // 1724 -// class CChangeLevel *pChange; // 1725 -// FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, -// const char *pszName); // 1728 -// FNullEnt(const edict_t *pent); // 1731 -// GetClassPtr(class CChangeLevel *a); // 1738 -// VARS(edict_t *pent); // 1738 -// GetClassPtr(class CChangeLevel *a); // 1734 -// } + edict_t *pent; + CChangeLevel *pChange; + + // find a trigger_changelevel + pent = FIND_ENTITY_BY_CLASSNAME(NULL, "trigger_changelevel"); + + // go back to start if no trigger_changelevel + if (FNullEnt(pent)) + { + gpGlobals->mapname = ALLOC_STRING("start"); + pChange = GetClassPtr((CChangeLevel *)NULL); + Q_strcpy(pChange->m_szMapName, "start"); + } + else + pChange = GetClassPtr((CChangeLevel *)VARS(pent)); + + Q_strcpy(st_szNextMap, pChange->m_szMapName); + g_fGameOver = TRUE; + + if (pChange->pev->nextthink < gpGlobals->time) + { + pChange->SetThink(&CChangeLevel::ExecuteChangeLevel); + pChange->pev->nextthink = gpGlobals->time + 0.1; + } } /* <1a4709> ../cstrike/dlls/triggers.cpp:1760 */ LINK_ENTITY_TO_CLASS(func_ladder, CLadder); /* <1a1937> ../cstrike/dlls/triggers.cpp:1763 */ -NOBODY void CLadder::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CLadder::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { + CBaseTrigger::KeyValue(pkvd); } +// func_ladder - makes an area vertically negotiable + /* <19fe6c> ../cstrike/dlls/triggers.cpp:1772 */ -NOBODY void CLadder::__MAKE_VHOOK(Precache)(void) +void CLadder::__MAKE_VHOOK(Precache)(void) { + // Do all of this in here because we need to 'convert' old saved games + pev->solid = SOLID_NOT; + pev->skin = CONTENTS_LADDER; + + if (CVAR_GET_FLOAT("showtriggers") == 0) + { + pev->rendermode = kRenderTransTexture; + pev->renderamt = 0; + } + + pev->effects &= ~EF_NODRAW; } /* <19fe95> ../cstrike/dlls/triggers.cpp:1786 */ -NOBODY void CLadder::__MAKE_VHOOK(Spawn)(void) +void CLadder::__MAKE_VHOOK(Spawn)(void) { + Precache(); + + // set size and link into world + SET_MODEL(ENT(pev), STRING(pev->model)); + pev->movetype = MOVETYPE_PUSH; } /* <1a47e5> ../cstrike/dlls/triggers.cpp:1804 */ LINK_ENTITY_TO_CLASS(trigger_push, CTriggerPush); /* <1a18ff> ../cstrike/dlls/triggers.cpp:1807 */ -NOBODY void CTriggerPush::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CTriggerPush::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { + CBaseTrigger::KeyValue(pkvd); } /* <1a2eda> ../cstrike/dlls/triggers.cpp:1817 */ -NOBODY void CTriggerPush::__MAKE_VHOOK(Spawn)(void) +void CTriggerPush::__MAKE_VHOOK(Spawn)(void) { -// operator==(const class Vector *const this, -// const class Vector &const v); // 1819 + if (pev->angles == g_vecZero) + { + pev->angles.y = 360; + } + + InitTrigger(); + + if (pev->speed == 0) + { + pev->speed = 100; + } + + // if flagged to Start Turned Off, make trigger nonsolid. + if (pev->spawnflags & SF_TRIGGER_PUSH_START_OFF) + { + pev->solid = SOLID_NOT; + } + + SetUse(&CTriggerPush::ToggleUse); + + // Link into the list + UTIL_SetOrigin(pev, pev->origin); } /* <1a023c> ../cstrike/dlls/triggers.cpp:1835 */ -NOBODY void CTriggerPush::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +void CTriggerPush::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { -// { -// entvars_t *pevToucher; // 1837 -// operator*(float fl, -// const class Vector &const v); // 1854 -// operator+(const class Vector *const this, -// const class Vector &const v); // 1854 -// { -// class Vector vecPush; // 1861 -// operator*(float fl, -// const class Vector &const v); // 1861 -// operator+(const class Vector *const this, -// const class Vector &const v); // 1863 -// } -// } + entvars_t *pevToucher = pOther->pev; + + // UNDONE: Is there a better way than health to detect things that have physics? (clients/monsters) + switch (pevToucher->movetype) + { + case MOVETYPE_NONE: + case MOVETYPE_PUSH: + case MOVETYPE_NOCLIP: + case MOVETYPE_FOLLOW: + return; + } + + if (pevToucher->solid != SOLID_NOT && pevToucher->solid != SOLID_BSP) + { + // Instant trigger, just transfer velocity and remove + if (pev->spawnflags & SF_TRIG_PUSH_ONCE) + { + pevToucher->velocity = pevToucher->velocity + (pev->speed * pev->movedir); + + if (pevToucher->velocity.z > 0) + { + pevToucher->flags &= ~FL_ONGROUND; + } + + UTIL_Remove(this); + } + else + { + // Push field, transfer to base velocity + Vector vecPush = (pev->speed * pev->movedir); + if (pevToucher->flags & FL_BASEVELOCITY) + { + vecPush = vecPush + pevToucher->basevelocity; + } + + pevToucher->basevelocity = vecPush; + pevToucher->flags |= FL_BASEVELOCITY; + } + } } /* <1a051f> ../cstrike/dlls/triggers.cpp:1878 */ -NOBODY void CBaseTrigger::TeleportTouch(CBaseEntity *pOther) +void CBaseTrigger::TeleportTouch(CBaseEntity *pOther) { -// { -// entvars_t *pevToucher; // 1880 -// edict_t *pentTarget; // 1881 -// class Vector tmp; // 1910 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1906 -// FNullEnt(const edict_t *pent); // 1907 -// Vector(class Vector *const this, -// const class Vector &const v); // 1910 -// } + entvars_t *pevToucher = pOther->pev; + edict_t *pentTarget = NULL; + + // Only teleport monsters or clients + if (!(pevToucher->flags & (FL_CLIENT | FL_MONSTER))) + { + return; + } + + if (!UTIL_IsMasterTriggered(m_sMaster, pOther)) + { + return; + } + + if (!(pev->spawnflags & SF_TRIGGER_ALLOWMONSTERS)) + { + // no monsters allowed! + if (pevToucher->flags & FL_MONSTER) + { + return; + } + } + + if ((pev->spawnflags & SF_TRIGGER_NOCLIENTS)) + { + // no clients allowed + if (pOther->IsPlayer()) + { + return; + } + } + + pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)); + if (FNullEnt(pentTarget)) + { + return; + } + + Vector tmp = VARS(pentTarget)->origin; + + if (pOther->IsPlayer()) + { + // make origin adjustments in case the teleportee is a player. (origin in center, not at feet) + tmp.z -= pOther->pev->mins.z; + } + + tmp.z++; + + pevToucher->flags &= ~FL_ONGROUND; + + UTIL_SetOrigin(pevToucher, tmp); + + pevToucher->angles = pentTarget->v.angles; + + if (pOther->IsPlayer()) + { + pevToucher->v_angle = pentTarget->v.angles; + } + + pevToucher->fixangle = 1; + pevToucher->velocity = pevToucher->basevelocity = g_vecZero; } /* <1a48c1> ../cstrike/dlls/triggers.cpp:1940 */ LINK_ENTITY_TO_CLASS(trigger_teleport, CTriggerTeleport); /* <1a2eb1> ../cstrike/dlls/triggers.cpp:1942 */ -NOBODY void CTriggerTeleport::__MAKE_VHOOK(Spawn)(void) +void CTriggerTeleport::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); + SetTouch(&CTriggerTeleport::TeleportTouch); } /* <1a499d> ../cstrike/dlls/triggers.cpp:1950 */ @@ -881,161 +1770,295 @@ LINK_ENTITY_TO_CLASS(info_teleport_destination, CPointEntity); LINK_ENTITY_TO_CLASS(func_buyzone, CBuyZone); /* <1a2e71> ../cstrike/dlls/triggers.cpp:1973 */ -NOBODY void CBuyZone::__MAKE_VHOOK(Spawn)(void) +void CBuyZone::__MAKE_VHOOK(Spawn)(void) { -// Spawn(class CBuyZone *const this); // 1973 + InitTrigger(); + SetTouch(&CBuyZone::BuyTouch); + + if (pev->team > CT || pev->team < UNASSIGNED) + { + ALERT(at_console, "Bad team number (%i) in func_buyzone\n", pev->team); + pev->team = UNASSIGNED; + } } /* <1a116b> ../cstrike/dlls/triggers.cpp:1986 */ -NOBODY void CBuyZone::BuyTouch(CBaseEntity *pOther) +void CBuyZone::BuyTouch(CBaseEntity *pOther) { -// { -// class CBasePlayer *p; // 1991 -// } -// BuyTouch(class CBuyZone *const this, -// class CBaseEntity *pOther); // 1986 + if (!pOther->IsPlayer()) + return; + + CBasePlayer *p = reinterpret_cast(pOther); + + if (pev->team == UNASSIGNED || pev->team == p->m_iTeam) + { + p->m_signals.Signal(SIGNAL_BUY); + } } /* <1a4b55> ../cstrike/dlls/triggers.cpp:2016 */ LINK_ENTITY_TO_CLASS(func_bomb_target, CBombTarget); /* <1a2e48> ../cstrike/dlls/triggers.cpp:2019 */ -NOBODY void CBombTarget::__MAKE_VHOOK(Spawn)(void) +void CBombTarget::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); + + SetTouch(&CBombTarget::BombTargetTouch); + SetUse(&CBombTarget::BombTargetUse); } /* <1a10c1> ../cstrike/dlls/triggers.cpp:2027 */ -NOBODY void CBombTarget::BombTargetTouch(CBaseEntity *pOther) +void CBombTarget::BombTargetTouch(CBaseEntity *pOther) { -// { -// class CBasePlayer *p; // 2031 -// } -// BombTargetTouch(class CBombTarget *const this, -// class CBaseEntity *pOther); // 2027 + if (!pOther->IsPlayer()) + return; + + CBasePlayer *p = reinterpret_cast(pOther); + + if (p->m_bHasC4) + { + p->m_signals.Signal(SIGNAL_BOMB); + p->m_pentCurBombTarget = ENT(pev); + } } /* <1a0014> ../cstrike/dlls/triggers.cpp:2042 */ -NOBODY void CBombTarget::BombTargetUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CBombTarget::BombTargetUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { + SUB_UseTargets(NULL, USE_TOGGLE, 0); } /* <1a4c31> ../cstrike/dlls/triggers.cpp:2064 */ LINK_ENTITY_TO_CLASS(func_hostage_rescue, CHostageRescue); /* <1a2e1f> ../cstrike/dlls/triggers.cpp:2067 */ -NOBODY void CHostageRescue::__MAKE_VHOOK(Spawn)(void) +void CHostageRescue::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); + SetTouch(&CHostageRescue::HostageRescueTouch); } /* <19ffbf> ../cstrike/dlls/triggers.cpp:2074 */ -NOBODY void CHostageRescue::HostageRescueTouch(CBaseEntity *pOther) +void CHostageRescue::HostageRescueTouch(CBaseEntity *pOther) { -// Signal(class CUnifiedSignals *const this, -// int flSignal); // 2078 + if (pOther->IsPlayer()) + { + ((CBasePlayer *)pOther)->m_signals.Signal(SIGNAL_RESCUE); + } + + if (FClassnameIs(pOther->pev, "hostage_entity")) + { + ((CHostage *)pOther)->m_bRescueMe = TRUE; + } } /* <1a4d0d> ../cstrike/dlls/triggers.cpp:2105 */ LINK_ENTITY_TO_CLASS(func_escapezone, CEscapeZone); /* <1a2df6> ../cstrike/dlls/triggers.cpp:2108 */ -NOBODY void CEscapeZone::__MAKE_VHOOK(Spawn)(void) +void CEscapeZone::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); + SetTouch(&CEscapeZone::EscapeTouch); } /* <1a0f88> ../cstrike/dlls/triggers.cpp:2115 */ -NOBODY void CEscapeZone::EscapeTouch(CBaseEntity *pOther) +void CEscapeZone::EscapeTouch(CBaseEntity *pOther) { -// { -// class CBasePlayer *p; // 2120 -// Signal(class CUnifiedSignals *const this, -// int flSignal); // 2147 -// } -// EscapeTouch(class CEscapeZone *const this, -// class CBaseEntity *pOther); // 2115 + if (!pOther->IsPlayer()) + return; + + CBasePlayer *p = reinterpret_cast(pOther); + + switch (p->m_iTeam) + { + case TERRORIST: + if (!p->m_bEscaped) + { + p->m_bEscaped = true; + g_pGameRules->CheckWinConditions(); + + UTIL_LogPrintf + ( + "\"%s<%i><%s>\" triggered \"Terrorist_Escaped\"\n", + STRING(p->pev->netname), + GETPLAYERUSERID(p->edict()), + GETPLAYERAUTHID(p->edict()) + ); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (pPlayer == NULL || FNullEnt(pPlayer->pev)) + continue; + + if (pPlayer->m_iTeam == p->m_iTeam) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Terrorist_Escaped"); + } + } + } + break; + case CT: + p->m_signals.Signal(SIGNAL_ESCAPE); + break; + } } /* <1a4de9> ../cstrike/dlls/triggers.cpp:2163 */ LINK_ENTITY_TO_CLASS(func_vip_safetyzone, CVIP_SafetyZone); /* <1a2dcd> ../cstrike/dlls/triggers.cpp:2166 */ -NOBODY void CVIP_SafetyZone::__MAKE_VHOOK(Spawn)(void) +void CVIP_SafetyZone::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); + SetTouch(&CVIP_SafetyZone::VIP_SafetyTouch); } /* <1a0ec7> ../cstrike/dlls/triggers.cpp:2173 */ -NOBODY void CVIP_SafetyZone::VIP_SafetyTouch(CBaseEntity *pOther) +void CVIP_SafetyZone::VIP_SafetyTouch(CBaseEntity *pOther) { -// { -// class CBasePlayer *p; // 2178 -// Signal(class CUnifiedSignals *const this, -// int flSignal); // 2180 -// } -// VIP_SafetyTouch(class CVIP_SafetyZone *const this, -// class CBaseEntity *pOther); // 2173 + if (!pOther->IsPlayer()) + return; + + CBasePlayer *p = reinterpret_cast(pOther); + p->m_signals.Signal(SIGNAL_VIPSAFETY); + + if (p->m_bIsVIP) + { + UTIL_LogPrintf + ( + "\"%s<%i><%s>\" triggered \"Escaped_As_VIP\"\n", + STRING(p->pev->netname), + GETPLAYERUSERID(p->edict()), + GETPLAYERAUTHID(p->edict()) + ); + + p->m_bEscaped = true; + + p->Disappear(); + p->AddAccount(REWARD_VIP_HAVE_SELF_RESCUED); + } } /* <1a4ec5> ../cstrike/dlls/triggers.cpp:2204 */ LINK_ENTITY_TO_CLASS(trigger_autosave, CTriggerSave); /* <1a2d8e> ../cstrike/dlls/triggers.cpp:2206 */ -NOBODY void CTriggerSave::__MAKE_VHOOK(Spawn)(void) +void CTriggerSave::__MAKE_VHOOK(Spawn)(void) { - //Spawn(class CTriggerSave *const this); // 2206 + if (g_pGameRules->IsDeathmatch()) + { + REMOVE_ENTITY(ENT(pev)); + return; + } + + InitTrigger(); + SetTouch(&CTriggerSave::SaveTouch); } /* <1a0c01> ../cstrike/dlls/triggers.cpp:2218 */ -NOBODY void CTriggerSave::SaveTouch(CBaseEntity *pOther) +void CTriggerSave::SaveTouch(CBaseEntity *pOther) { -// SaveTouch(class CTriggerSave *const this, -// class CBaseEntity *pOther); // 2218 + if (!UTIL_IsMasterTriggered(m_sMaster, pOther)) + return; + + // Only save on clients + if (!pOther->IsPlayer()) + return; + + SetTouch(NULL); + UTIL_Remove(this); + SERVER_COMMAND("autosave\n"); } /* <1a4fa1> ../cstrike/dlls/triggers.cpp:2242 */ LINK_ENTITY_TO_CLASS(trigger_endsection, CTriggerEndSection); /* <1a0b7f> ../cstrike/dlls/triggers.cpp:2245 */ -NOBODY void CTriggerEndSection::EndSectionUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CTriggerEndSection::EndSectionUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// EndSectionUse(class CTriggerEndSection *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 2245 + // Only save on clients + if (pActivator && !pActivator->IsNetClient()) + return; + + SetUse(NULL); + if (!FStringNull(pev->message)) + { + END_SECTION(STRING(pev->message)); + } + + UTIL_Remove(this); } /* <1a2d4f> ../cstrike/dlls/triggers.cpp:2260 */ -NOBODY void CTriggerEndSection::__MAKE_VHOOK(Spawn)(void) +void CTriggerEndSection::__MAKE_VHOOK(Spawn)(void) { -// Spawn(class CTriggerEndSection *const this); // 2260 + if (g_pGameRules->IsDeathmatch()) + { + REMOVE_ENTITY(ENT(pev)); + return; + } + + InitTrigger(); + SetUse(&CTriggerEndSection::EndSectionUse); + + // If it is a "use only" trigger, then don't set the touch function. + if (!(pev->spawnflags & SF_ENDSECTION_USEONLY)) + { + SetTouch(&CTriggerEndSection::EndSectionTouch); + } } /* <1a0b29> ../cstrike/dlls/triggers.cpp:2276 */ -NOBODY void CTriggerEndSection::EndSectionTouch(CBaseEntity *pOther) +void CTriggerEndSection::EndSectionTouch(CBaseEntity *pOther) { -// EndSectionTouch(class CTriggerEndSection *const this, -// class CBaseEntity *pOther); // 2276 + // Only save on clients + if (!pOther->IsNetClient()) + return; + + SetTouch(NULL); + if (!FStringNull(pev->message)) + { + END_SECTION(STRING(pev->message)); + } + + UTIL_Remove(this); } /* <1a196f> ../cstrike/dlls/triggers.cpp:2291 */ -NOBODY void CTriggerEndSection::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CTriggerEndSection::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 2293 -// KeyValue(class CTriggerEndSection *const this, -// KeyValueData *pkvd); // 2291 + if (FStrEq(pkvd->szKeyName, "section")) + { + // Store this in message so we don't have to write save/restore for this ent + pev->message = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseTrigger::KeyValue(pkvd); } /* <1a507d> ../cstrike/dlls/triggers.cpp:2311 */ LINK_ENTITY_TO_CLASS(trigger_gravity, CTriggerGravity); /* <1a2d26> ../cstrike/dlls/triggers.cpp:2313 */ -NOBODY void CTriggerGravity::__MAKE_VHOOK(Spawn)(void) +void CTriggerGravity::__MAKE_VHOOK(Spawn)(void) { + InitTrigger(); + SetTouch(&CTriggerGravity::GravityTouch); } /* <19febe> ../cstrike/dlls/triggers.cpp:2319 */ -NOBODY void CTriggerGravity::GravityTouch(CBaseEntity *pOther) +void CTriggerGravity::GravityTouch(CBaseEntity *pOther) { + // Only save on clients + if (!pOther->IsPlayer()) + return; + + pOther->pev->gravity = pev->gravity; } /* <1a5159> ../cstrike/dlls/triggers.cpp:2351 */ @@ -1045,28 +2068,39 @@ LINK_ENTITY_TO_CLASS(trigger_changetarget, CTriggerChangeTarget); IMPLEMENT_SAVERESTORE(CTriggerChangeTarget, CBaseDelay); /* <1a1691> ../cstrike/dlls/triggers.cpp:2360 */ -NOBODY void CTriggerChangeTarget::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CTriggerChangeTarget::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 2362 -// KeyValue(class CTriggerChangeTarget *const this, -// KeyValueData *pkvd); // 2360 + if (FStrEq(pkvd->szKeyName, "m_iszNewTarget")) + { + m_iszNewTarget = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseDelay::KeyValue(pkvd); } /* <19ff1f> ../cstrike/dlls/triggers.cpp:2371 */ -NOBODY void CTriggerChangeTarget::__MAKE_VHOOK(Spawn)(void) +void CTriggerChangeTarget::__MAKE_VHOOK(Spawn)(void) { + ; } /* <1a010d> ../cstrike/dlls/triggers.cpp:2376 */ -NOBODY void CTriggerChangeTarget::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CTriggerChangeTarget::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// { -// class CBaseEntity *pTarget; // 2378 -// { -// class CBaseMonster *pMonster; // 2383 -// } -// } + CBaseEntity *pTarget = UTIL_FindEntityByString(NULL, "targetname", STRING(pev->target)); + + if (pTarget != NULL) + { + pTarget->pev->target = m_iszNewTarget; + + CBaseMonster *pMonster = pTarget->MyMonsterPointer(); + + if (pMonster) + { + pMonster->m_pGoalEnt = NULL; + } + } } /* <1a5235> ../cstrike/dlls/triggers.cpp:2425 */ @@ -1076,64 +2110,272 @@ LINK_ENTITY_TO_CLASS(trigger_camera, CTriggerCamera); IMPLEMENT_SAVERESTORE(CTriggerCamera, CBaseDelay); /* <19ff6f> ../cstrike/dlls/triggers.cpp:2447 */ -NOBODY void CTriggerCamera::__MAKE_VHOOK(Spawn)(void) +void CTriggerCamera::__MAKE_VHOOK(Spawn)(void) { + pev->movetype = MOVETYPE_NOCLIP; + + // Remove model & collisions + pev->solid = SOLID_NOT; + + // The engine won't draw this model if this is set to 0 and blending is on + pev->renderamt = 0; + pev->rendermode = kRenderTransTexture; + + m_initialSpeed = pev->speed; + + if (m_acceleration == 0) + { + m_acceleration = 500; + } + if (m_deceleration == 0) + { + m_deceleration = 500; + } } /* <1a1537> ../cstrike/dlls/triggers.cpp:2462 */ -NOBODY void CTriggerCamera::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CTriggerCamera::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 2464 -// FStrEq(const char *sz1, -// const char *sz2); // 2469 -// KeyValue(CTriggerCamera *const this, -// KeyValueData *pkvd); // 2462 -// atof(const char *__nptr); // 2466 + if (FStrEq(pkvd->szKeyName, "wait")) + { + m_flWait = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "moveto")) + { + m_sPath = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "acceleration")) + { + m_acceleration = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "deceleration")) + { + m_deceleration = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseDelay::KeyValue(pkvd); } /* <1a55e4> ../cstrike/dlls/triggers.cpp:2490 */ -NOBODY void CTriggerCamera::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CTriggerCamera::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { -// Use(CTriggerCamera *const this, -// class CBaseEntity *pActivator, -// class CBaseEntity *pCaller, -// USE_TYPE useType, -// float value); // 2490 + if (!ShouldToggle(useType, m_state)) + return; + + // Toggle state + m_state = !m_state; + if (m_state == 0) + { + m_flReturnTime = gpGlobals->time; + + if (pActivator->IsPlayer()) + { + ((CBasePlayer *)pActivator)->ResetMaxSpeed(); + } + + return; + } + + if (!pActivator || !pActivator->IsPlayer()) + { + pActivator = CBaseEntity::Instance(INDEXENT(1)); + } + + m_hPlayer = pActivator; + m_flReturnTime = gpGlobals->time + m_flWait; + + pev->speed = m_initialSpeed; + m_targetSpeed = m_initialSpeed; + + if (pev->spawnflags & SF_CAMERA_PLAYER_TARGET) + { + m_hTarget = m_hPlayer; + } + else + { + m_hTarget = GetNextTarget(); + } + + // Nothing to look at! + if (m_hTarget == NULL) + { + return; + } + + if (pActivator->IsPlayer()) + { + SET_CLIENT_MAXSPEED(pActivator->edict(), 0.001); + } + + if (pev->spawnflags & SF_CAMERA_PLAYER_TAKECONTROL) + { + ((CBasePlayer *)pActivator)->EnableControl(FALSE); + } + + if (m_sPath) + { + m_pentPath = Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_sPath))); + } + else + { + m_pentPath = NULL; + } + + m_flStopTime = gpGlobals->time; + if (m_pentPath) + { + if (m_pentPath->pev->speed != 0) + m_targetSpeed = m_pentPath->pev->speed; + + m_flStopTime += m_pentPath->GetDelay(); + } + + // copy over player information + if (pev->spawnflags & SF_CAMERA_PLAYER_POSITION) + { + UTIL_SetOrigin(pev, pActivator->pev->origin + pActivator->pev->view_ofs); + + pev->angles.x = -pActivator->pev->angles.x; + pev->angles.y = pActivator->pev->angles.y; + pev->angles.z = 0; + pev->velocity = pActivator->pev->velocity; + } + else + { + pev->velocity = Vector(0, 0, 0); + } + + SET_VIEW(pActivator->edict(), edict()); + SET_MODEL(ENT(pev), STRING(pActivator->pev->model)); + + // follow the player down + SetThink(&CTriggerCamera::FollowTarget); + + pev->nextthink = gpGlobals->time; + m_moveDistance = 0; + Move(); } /* <1a5494> ../cstrike/dlls/triggers.cpp:2587 */ -NOBODY void CTriggerCamera::FollowTarget(void) +void CTriggerCamera::FollowTarget(void) { -// { -// class Vector vecGoal; // 2606 -// float dx; // 2615 -// float dy; // 2616 -// } -// FollowTarget(CTriggerCamera *const this); // 2587 + if (m_hPlayer == NULL) + return; + + if (m_hTarget == NULL || m_flReturnTime < gpGlobals->time) + { + if (m_hPlayer->IsAlive()) + { + SET_VIEW(m_hPlayer->edict(), m_hPlayer->edict()); + ((CBasePlayer *)((CBaseEntity *)m_hPlayer))->EnableControl(TRUE); + } + + SUB_UseTargets(this, USE_TOGGLE, 0); + pev->avelocity = Vector(0, 0, 0); + m_state = 0; + return; + } + + Vector vecGoal = UTIL_VecToAngles(m_hTarget->pev->origin - pev->origin); + vecGoal.x = -vecGoal.x; + + if (pev->angles.y > 360) + pev->angles.y -= 360; + + if (pev->angles.y < 0) + pev->angles.y += 360; + + float_precision dx = vecGoal.x - pev->angles.x; + float_precision dy = vecGoal.y - pev->angles.y; + + if (dx < -180) + dx += 360; + if (dx > 180) + dx = dx - 360; + + if (dy < -180) + dy += 360; + if (dy > 180) + dy = dy - 360; + + pev->avelocity.x = dx * 40 * gpGlobals->frametime; + pev->avelocity.y = dy * 40 * gpGlobals->frametime; + + if (!(pev->spawnflags & SF_CAMERA_PLAYER_TAKECONTROL)) + { + pev->velocity = pev->velocity * 0.8; + + if (pev->velocity.Length() < 10.0) + { + pev->velocity = g_vecZero; + } + } + + pev->nextthink = gpGlobals->time; + Move(); } /* <1a5311> ../cstrike/dlls/triggers.cpp:2644 */ -NOBODY void CTriggerCamera::Move(void) +void CTriggerCamera::Move(void) { -// { -// float fraction; // 2688 -// { -// class Vector delta; // 2676 -// operator-(const class Vector *const this, -// const class Vector &const v); // 2676 -// Length(const class Vector *const this); // 2677 -// Normalize(const class Vector *const this); // 2678 -// } -// operator*(const class Vector *const this, -// float fl); // 2689 -// operator*(const class Vector *const this, -// float fl); // 2689 -// operator*(const class Vector *const this, -// float fl); // 2689 -// operator+(const class Vector *const this, -// const class Vector &const v); // 2689 -// } + // Not moving on a path, return + if (!m_pentPath) + return; + + // Subtract movement from the previous frame + m_moveDistance -= pev->speed * gpGlobals->frametime; + + // Have we moved enough to reach the target? + if (m_moveDistance <= 0) + { + // Fire the passtarget if there is one + if (!FStringNull(m_pentPath->pev->message)) + { + FireTargets(STRING(m_pentPath->pev->message), this, this, USE_TOGGLE, 0); + + if (m_pentPath->pev->spawnflags, SF_CORNER_FIREONCE) + { + m_pentPath->pev->message = 0; + } + } + + // Time to go to the next target + m_pentPath = m_pentPath->GetNextTarget(); + + // Set up next corner + if (!m_pentPath) + { + pev->velocity = g_vecZero; + } + else + { + if (m_pentPath->pev->speed != 0) + { + m_targetSpeed = m_pentPath->pev->speed; + } + + Vector delta = m_pentPath->pev->origin - pev->origin; + m_moveDistance = delta.Length(); + pev->movedir = delta.Normalize(); + m_flStopTime = gpGlobals->time + m_pentPath->GetDelay(); + } + } + + if (m_flStopTime > gpGlobals->time) + { + pev->speed = UTIL_Approach(0, pev->speed, m_deceleration * gpGlobals->frametime); + } + else + { + pev->speed = UTIL_Approach(m_targetSpeed, pev->speed, m_acceleration * gpGlobals->frametime); + } + + float_precision fraction = 2 * gpGlobals->frametime; + pev->velocity = ((pev->movedir * pev->speed) * fraction) + (pev->velocity * (1 - fraction)); } /* <1a5815> ../cstrike/dlls/triggers.cpp:2699 */ @@ -1148,20 +2390,48 @@ LINK_ENTITY_TO_CLASS(env_rain, CWeather); /* <1a5aa9> ../cstrike/dlls/triggers.cpp:2702 */ LINK_ENTITY_TO_CLASS(func_rain, CWeather); -/* <1a1477> ../cstrike/dlls/triggers.cpp:2716 */ -NOBODY void CClientFog::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +/* <1a2cfe> ../cstrike/dlls/triggers.cpp:2704 */ +void CWeather::__MAKE_VHOOK(Spawn)(void) { -// FStrEq(const char *sz1, -// const char *sz2); // 2718 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 2730 -// KeyValue(CClientFog *const this, -// KeyValueData *pkvd); // 2716 + InitTrigger(); +} + +/* <1a1477> ../cstrike/dlls/triggers.cpp:2716 */ +void CClientFog::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ +#if 0 + if (FStrEq(pkvd->szKeyName, "startdist")) + { + m_iStartDist = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "enddist")) + { + m_iEndDist = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else +#endif + if (FStrEq(pkvd->szKeyName, "density")) + { + m_fDensity = Q_atof(pkvd->szValue); + + if (m_fDensity < 0 || m_fDensity > 0.01) + m_fDensity = 0; + + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } /* <19ff97> ../cstrike/dlls/triggers.cpp:2735 */ -NOBODY void CClientFog::__MAKE_VHOOK(Spawn)(void) +void CClientFog::__MAKE_VHOOK(Spawn)(void) { + pev->movetype = MOVETYPE_NOCLIP; + pev->solid = SOLID_NOT; // Remove model & collisions + pev->renderamt = 0; // The engine won't draw this model if this is set to 0 and blending is on + pev->rendermode = kRenderTransTexture; } /* <1a5ba9> ../cstrike/dlls/triggers.cpp:2744 */ @@ -1536,4 +2806,9 @@ void CClientFog::KeyValue(KeyValueData *pkvd) KeyValue_(pkvd); } +void CWeather::Spawn(void) +{ + Spawn_(); +} + #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/triggers.h b/regamedll/dlls/triggers.h index 164d78c2..77354053 100644 --- a/regamedll/dlls/triggers.h +++ b/regamedll/dlls/triggers.h @@ -38,15 +38,21 @@ #define MAX_ITEM_COUNTS 32 #define MAX_ENTITY 512 // We can only ever move 512 entities across a transition -#define SF_TRIGGER_PUSH_START_OFF 2 -#define SF_TRIGGER_HURT_TARGETONCE 1 -#define SF_TRIGGER_HURT_START_OFF 2 -#define SF_TRIGGER_HURT_NO_CLIENTS 8 -#define SF_TRIGGER_HURT_CLIENTONLYFIRE 16 -#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 +// triggers +#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger +#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger +#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger + +#define SF_TRIGGER_PUSH_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF +#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once +#define SF_TRIGGER_HURT_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF +#define SF_TRIGGER_HURT_NO_CLIENTS 8 // spawnflag that makes trigger_push spawn turned OFF +#define SF_TRIGGER_HURT_CLIENTONLYFIRE 16 // trigger hurt will only fire its target if it is hurting a client +#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // only clients may touch this trigger. #define SF_AUTO_FIREONCE 0x0001 #define SF_RELAY_FIREONCE 0x0001 +#define SF_ENDSECTION_USEONLY 0x0001 #define SF_MULTIMAN_CLONE 0x80000000 #define SF_MULTIMAN_THREAD 0x00000001 @@ -56,14 +62,20 @@ #define SF_CAMERA_PLAYER_TARGET 2 #define SF_CAMERA_PLAYER_TAKECONTROL 4 +// Flags to indicate masking off various render parameters that are normally copied to the targets +#define SF_RENDER_MASKFX (1<<0) +#define SF_RENDER_MASKAMT (1<<1) +#define SF_RENDER_MASKMODE (1<<2) +#define SF_RENDER_MASKCOLOR (1<<3) + class CFrictionModifier: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } @@ -82,7 +94,7 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT ChangeFriction(CBaseEntity *pOther); + void EXPORT ChangeFriction(CBaseEntity *pOther); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[1]; @@ -91,20 +103,23 @@ public: };/* size: 156, cachelines: 3, members: 3 */ +// This trigger will fire when the level spawns (or respawns if not fire once) +// It will check a global state before firing. It supports delay and killtargets + /* <19e39c> ../cstrike/dlls/triggers.cpp:108 */ class CAutoTrigger: public CBaseDelay { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Think(void); + virtual void Think(void); #ifdef HOOK_GAMEDLL @@ -124,8 +139,8 @@ public: public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[2]; - int m_globalstate; // 160 - USE_TYPE triggerType; // 164 + int m_globalstate; + USE_TYPE triggerType; };/* size: 168, cachelines: 3, members: 4 */ @@ -133,16 +148,15 @@ public: class CTriggerRelay: public CBaseDelay { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); -public: + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -165,21 +179,25 @@ public: };/* size: 164, cachelines: 3, members: 3 */ +// The Multimanager Entity - when fired, will fire up to 16 targets +// at specified times. +// FLAG: THREAD (create clones when triggered) +// FLAG: CLONE (this is a clone for a threaded execution) + /* <19e4d6> ../cstrike/dlls/triggers.cpp:264 */ class CMultiManager: public CBaseToggle { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Restart(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual BOOL HasTarget(string_t targetname); -public: + virtual BOOL HasTarget(string_t targetname); #ifdef HOOK_GAMEDLL @@ -196,27 +214,37 @@ public: #endif // HOOK_GAMEDLL - NOBODY void EXPORT ManagerThink(void); - NOBODY void EXPORT ManagerUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); +public: + void EXPORT ManagerThink(void); + void EXPORT ManagerUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); private: /* <19dfe1> ../cstrike/dlls/triggers.cpp:293 */ inline BOOL IsClone(void) { if (pev->spawnflags & SF_MULTIMAN_CLONE) + { return TRUE; + } + return FALSE; } /* <19e4f3> ../cstrike/dlls/triggers.cpp:294 */ inline BOOL ShouldClone(void) { if (IsClone()) + { return FALSE; + } + if (pev->spawnflags & SF_MULTIMAN_THREAD) + { return TRUE; + } + return FALSE; } - NOBODY CMultiManager *Clone(void); + CMultiManager *Clone(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[5]; @@ -230,12 +258,17 @@ public: };/* size: 452, cachelines: 8, members: 7 */ /* Linux - 452 | Windows - 432 */ +// Render parameters trigger +// +// This entity will copy its render parameters (renderfx, rendermode, rendercolor, renderamt) +// to its targets when triggered. + /* <19e50c> ../cstrike/dlls/triggers.cpp:525 */ class CRenderFxManager: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -250,8 +283,8 @@ public: class CBaseTrigger: public CBaseToggle { public: - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int ObjectCaps(void) + virtual void KeyValue(KeyValueData *pkvd); + virtual int ObjectCaps(void) { return ObjectCaps_(); } @@ -267,23 +300,26 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT TeleportTouch(CBaseEntity *pOther); - NOBODY void EXPORT MultiTouch(CBaseEntity *pOther); - NOBODY void EXPORT HurtTouch(CBaseEntity *pOther); - NOXREF NOBODY void EXPORT CDAudioTouch(CBaseEntity *pOther); - NOBODY void ActivateMultiTrigger(CBaseEntity *pActivator); - NOBODY void EXPORT MultiWaitOver(void); - NOBODY void EXPORT CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOBODY void InitTrigger(void); + void EXPORT TeleportTouch(CBaseEntity *pOther); + void EXPORT MultiTouch(CBaseEntity *pOther); + void EXPORT HurtTouch(CBaseEntity *pOther); + NOXREF void EXPORT CDAudioTouch(CBaseEntity *pOther); + void ActivateMultiTrigger(CBaseEntity *pActivator); + void EXPORT MultiWaitOver(void); + void EXPORT CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void InitTrigger(void); };/* size: 312, cachelines: 5, members: 1 */ +// trigger_hurt - hurts anything that touches it. if the trigger has a targetname, firing it will toggle state +// int gfToggleState = 0; // used to determine when all radiation trigger hurts have called 'RadiationThink' + /* <19e5b2> ../cstrike/dlls/triggers.cpp:629 */ class CTriggerHurt: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -291,7 +327,7 @@ public: #endif // HOOK_GAMEDLL - NOBODY void EXPORT RadiationThink(void); + void EXPORT RadiationThink(void); };/* size: 312, cachelines: 5, members: 1 */ @@ -299,9 +335,9 @@ public: class CTriggerMonsterJump: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Think(void); - NOBODY virtual void Touch(CBaseEntity *pOther); + virtual void Spawn(void); + virtual void Think(void); + virtual void Touch(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -313,13 +349,15 @@ public: };/* size: 312, cachelines: 5, members: 1 */ +// trigger_cdaudio - starts/stops cd audio tracks + /* <19e65d> ../cstrike/dlls/triggers.cpp:705 */ class CTriggerCDAudio: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Touch(CBaseEntity *pOther); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void Touch(CBaseEntity *pOther); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -330,18 +368,20 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY virtual void PlayTrack(void); + virtual void PlayTrack(void); };/* size: 312, cachelines: 5, members: 1 */ +// This plays a CD track when fired or when the player enters it's radius + /* <19e6d2> ../cstrike/dlls/triggers.cpp:783 */ class CTargetCDAudio: public CPointEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual void Think(void); - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual void Think(void); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -353,15 +393,30 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void Play(void); + void Play(void); };/* size: 152, cachelines: 3, members: 1 */ +// QUAKED trigger_multiple (.5 .5 .5) ? notouch +// Variable sized repeatable trigger. Must be targeted at one or more entities. +// If "health" is set, the trigger must be killed to activate each time. +// If "delay" is set, the trigger waits some time after activating before firing. +// "wait" : Seconds between triggerings. (.2 default) +// If notouch is set, the trigger is only fired by other entities, not by touching. +// NOTOUCH has been obsoleted by trigger_relay! +// sounds +// 1) secret +// 2) beep beep +// 3) large switch +// 4) +// NEW +// if a trigger has a NETNAME, that NETNAME will become the TARGET of the triggered object. + /* <19e725> ../cstrike/dlls/triggers.cpp:1080 */ class CTriggerMultiple: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -371,11 +426,23 @@ public: };/* size: 312, cachelines: 5, members: 1 */ +// QUAKED trigger_once (.5 .5 .5) ? notouch +// Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching +// "targetname". If "health" is set, the trigger must be killed to activate. +// If notouch is set, the trigger is only fired by other entities, not by touching. +// if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired. +// if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0. +// sounds +// 1) secret +// 2) beep beep +// 3) large switch +// 4) + /* <19e77d> ../cstrike/dlls/triggers.cpp:1129 */ class CTriggerOnce: public CTriggerMultiple { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -385,11 +452,17 @@ public: };/* size: 312, cachelines: 5, members: 1 */ +// QUAKED trigger_counter (.5 .5 .5) ? nomessage +// Acts as an intermediary for an action that takes multiple inputs. +// If nomessage is not set, it will print "1 more.. " etc when triggered and +// "sequence complete" when finished. After the counter has been triggered "cTriggersLeft" +// times (default 2), it will fire all of it's targets and remove itself. + /* <19e7d5> ../cstrike/dlls/triggers.cpp:1273 */ class CTriggerCounter: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -399,11 +472,13 @@ public: };/* size: 312, cachelines: 5, members: 1 */ +// Derive from point entity so this doesn't move across levels + /* <19e82d> ../cstrike/dlls/triggers.cpp:1293 */ class CTriggerVolume: public CPointEntity { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -413,17 +488,19 @@ public: };/* size: 152, cachelines: 3, members: 1 */ +// Fires a target after level transition and then dies + /* <19e885> ../cstrike/dlls/triggers.cpp:1313 */ class CFireAndDie: public CBaseDelay { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void Precache(void); + virtual int ObjectCaps(void) // Always go across transitions { return ObjectCaps_(); } - NOBODY virtual void Think(void); + virtual void Think(void); #ifdef HOOK_GAMEDLL @@ -439,14 +516,17 @@ public: };/* size: 160, cachelines: 3, members: 1 */ +// QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION +// When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats. + /* <19e906> ../cstrike/dlls/triggers.cpp:1345 */ class CChangeLevel: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); #ifdef HOOK_GAMEDLL @@ -458,12 +538,11 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT UseChangeLevel(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - NOXREF NOBODY void EXPORT TriggerChangeLevel(void); - NOBODY void EXPORT ExecuteChangeLevel(void); - NOBODY void EXPORT TouchChangeLevel(CBaseEntity *pOther); - - NOBODY void ChangeLevelNow(CBaseEntity *pActivator); + void EXPORT UseChangeLevel(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + NOXREF void EXPORT TriggerChangeLevel(void); + void EXPORT ExecuteChangeLevel(void); + void EXPORT TouchChangeLevel(CBaseEntity *pOther); + void ChangeLevelNow(CBaseEntity *pActivator); static edict_t *FindLandmark(const char *pLandmarkName); static int ChangeList(LEVELLIST *pLevelList, int maxList); @@ -473,8 +552,8 @@ public: public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[4]; - char m_szMapName[ cchMapNameMost ]; - char m_szLandmarkName[ cchMapNameMost ]; + char m_szMapName[ cchMapNameMost ]; // trigger_changelevel only: next map + char m_szLandmarkName[ cchMapNameMost ]; // trigger_changelevel only: landmark on next map int m_changeTarget; float m_changeTargetDelay; @@ -484,9 +563,9 @@ public: class CLadder: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); #ifdef HOOK_GAMEDLL @@ -502,9 +581,9 @@ public: class CTriggerPush: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual void Touch(CBaseEntity *pOther); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual void Touch(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -520,7 +599,7 @@ public: class CTriggerTeleport: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -534,7 +613,7 @@ public: class CBuyZone: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -542,7 +621,7 @@ public: #endif // HOOK_GAMEDLL - NOBODY void EXPORT BuyTouch(CBaseEntity *pOther); + void EXPORT BuyTouch(CBaseEntity *pOther); };/* size: 312, cachelines: 5, members: 1 */ @@ -550,7 +629,7 @@ public: class CBombTarget: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -559,8 +638,8 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT BombTargetTouch(CBaseEntity *pOther); - NOBODY void EXPORT BombTargetUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void EXPORT BombTargetTouch(CBaseEntity *pOther); + void EXPORT BombTargetUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); };/* size: 312, cachelines: 5, members: 1 */ @@ -568,7 +647,7 @@ public: class CHostageRescue: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -577,7 +656,7 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT HostageRescueTouch(CBaseEntity *pOther); + void EXPORT HostageRescueTouch(CBaseEntity *pOther); };/* size: 312, cachelines: 5, members: 1 */ @@ -585,7 +664,7 @@ public: class CEscapeZone: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -593,7 +672,7 @@ public: #endif // HOOK_GAMEDLL - NOBODY void EXPORT EscapeTouch(CBaseEntity *pOther); + void EXPORT EscapeTouch(CBaseEntity *pOther); };/* size: 312, cachelines: 5, members: 1 */ @@ -601,7 +680,7 @@ public: class CVIP_SafetyZone: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -609,7 +688,7 @@ public: #endif // HOOK_GAMEDLL - NOBODY void EXPORT VIP_SafetyTouch(CBaseEntity *pOther); + void EXPORT VIP_SafetyTouch(CBaseEntity *pOther); };/* size: 312, cachelines: 5, members: 1 */ @@ -617,7 +696,7 @@ public: class CTriggerSave: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -625,7 +704,7 @@ public: #endif // HOOK_GAMEDLL - NOBODY void EXPORT SaveTouch(CBaseEntity *pOther); + void EXPORT SaveTouch(CBaseEntity *pOther); };/* size: 312, cachelines: 5, members: 1 */ @@ -633,8 +712,8 @@ public: class CTriggerEndSection: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); #ifdef HOOK_GAMEDLL @@ -644,16 +723,16 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT EndSectionTouch(CBaseEntity *pOther); - NOBODY void EXPORT EndSectionUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); -};/* size: 312, cachelines: 5, members: 1 */ + void EXPORT EndSectionTouch(CBaseEntity *pOther); + void EXPORT EndSectionUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); +};/* size: 312, cachelines: 5, members: 1 */ /* <19ed25> ../cstrike/dlls/triggers.cpp:2305 */ class CTriggerGravity: public CBaseTrigger { public: - NOBODY virtual void Spawn(void); + virtual void Spawn(void); #ifdef HOOK_GAMEDLL @@ -661,23 +740,25 @@ public: #endif // HOOK_GAMEDLL - NOBODY void EXPORT GravityTouch(CBaseEntity *pOther); + void EXPORT GravityTouch(CBaseEntity *pOther); };/* size: 312, cachelines: 5, members: 1 */ +// this is a really bad idea. + /* <19ed7d> ../cstrike/dlls/triggers.cpp:2335 */ class CTriggerChangeTarget: public CBaseDelay { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); virtual int ObjectCaps(void) { - return (CBaseDelay::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); + return ObjectCaps_(); } - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -705,15 +786,15 @@ private: class CTriggerCamera: public CBaseDelay { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps(void) { return ObjectCaps_(); } - NOBODY virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); #ifdef HOOK_GAMEDLL @@ -730,8 +811,8 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT FollowTarget(void); - NOBODY void Move(void); + void EXPORT FollowTarget(void); + void Move(void); public: static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[13]; @@ -756,16 +837,12 @@ public: class CWeather: public CBaseTrigger { public: - NOBODY virtual void Spawn(void) - { - Spawn_(); - } + virtual void Spawn(void); #ifdef HOOK_GAMEDLL - void Spawn_(void) - { - InitTrigger(); - } + + void Spawn_(void); + #endif // HOOK_GAMEDLL };/* size: 312, cachelines: 5, members: 1 */ @@ -774,8 +851,8 @@ public: class CClientFog: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); + virtual void Spawn(void); + virtual void KeyValue(KeyValueData *pkvd); #ifdef HOOK_GAMEDLL @@ -791,8 +868,59 @@ public: };/* size: 164, cachelines: 3, members: 4 */ -NOBODY void PlayCDTrack(int iTrack); -NOBODY int BuildChangeList(LEVELLIST * pLevelList, int maxList); -NOBODY void NextLevel(void); +#ifdef HOOK_GAMEDLL + +#define st_szNextMap (*pst_szNextMap) +#define st_szNextSpot (*pst_szNextSpot) + +#endif // HOOK_GAMEDLL + +extern char st_szNextMap[cchMapNameMost]; +extern char st_szNextSpot[cchMapNameMost]; + +void PlayCDTrack(int iTrack); +int BuildChangeList(LEVELLIST * pLevelList, int maxList); +NOXREF void NextLevel(void); + +#ifdef HOOK_GAMEDLL + +// linked objects +C_DLLEXPORT void func_friction(entvars_t *pev); +C_DLLEXPORT void trigger_auto(entvars_t *pev); +C_DLLEXPORT void trigger_relay(entvars_t *pev); +C_DLLEXPORT void multi_manager(entvars_t *pev); +C_DLLEXPORT void env_render(entvars_t *pev); +C_DLLEXPORT void trigger(entvars_t *pev); +C_DLLEXPORT void trigger_hurt(entvars_t *pev); +C_DLLEXPORT void trigger_monsterjump(entvars_t *pev); +C_DLLEXPORT void trigger_cdaudio(entvars_t *pev); +C_DLLEXPORT void target_cdaudio(entvars_t *pev); +C_DLLEXPORT void trigger_multiple(entvars_t *pev); +C_DLLEXPORT void trigger_once(entvars_t *pev); +C_DLLEXPORT void trigger_counter(entvars_t *pev); +C_DLLEXPORT void trigger_transition(entvars_t *pev); +C_DLLEXPORT void fireanddie(entvars_t *pev); +C_DLLEXPORT void trigger_changelevel(entvars_t *pev); +C_DLLEXPORT void func_ladder(entvars_t *pev); +C_DLLEXPORT void trigger_push(entvars_t *pev); +C_DLLEXPORT void trigger_teleport(entvars_t *pev); +C_DLLEXPORT void info_teleport_destination(entvars_t *pev); +C_DLLEXPORT void func_buyzone(entvars_t *pev); +C_DLLEXPORT void func_bomb_target(entvars_t *pev); +C_DLLEXPORT void func_hostage_rescue(entvars_t *pev); +C_DLLEXPORT void func_escapezone(entvars_t *pev); +C_DLLEXPORT void func_vip_safetyzone(entvars_t *pev); +C_DLLEXPORT void trigger_autosave(entvars_t *pev); +C_DLLEXPORT void trigger_endsection(entvars_t *pev); +C_DLLEXPORT void trigger_gravity(entvars_t *pev); +C_DLLEXPORT void trigger_changetarget(entvars_t *pev); +C_DLLEXPORT void trigger_camera(entvars_t *pev); +C_DLLEXPORT void env_snow(entvars_t *pev); +C_DLLEXPORT void func_snow(entvars_t *pev); +C_DLLEXPORT void env_rain(entvars_t *pev); +C_DLLEXPORT void func_rain(entvars_t *pev); +C_DLLEXPORT void env_fog(entvars_t *pev); + +#endif // HOOK_GAMEDLL #endif // TRIGGERS_H diff --git a/regamedll/dlls/tutor.cpp b/regamedll/dlls/tutor.cpp index 70ad7252..a2bcb8eb 100644 --- a/regamedll/dlls/tutor.cpp +++ b/regamedll/dlls/tutor.cpp @@ -55,15 +55,15 @@ void InstallTutor(bool start) /* <1dfde7> ../cstrike/dlls/tutor.cpp:51 */ void Tutor_RegisterCVars(void) { - CVAR_REGISTER(&cv_tutor_message_repeats); - CVAR_REGISTER(&cv_tutor_debug_level); - CVAR_REGISTER(&cv_tutor_view_distance); - CVAR_REGISTER(&cv_tutor_viewable_check_interval); - CVAR_REGISTER(&cv_tutor_look_distance); - CVAR_REGISTER(&cv_tutor_look_angle); - CVAR_REGISTER(&cv_tutor_examine_time); - CVAR_REGISTER(&cv_tutor_message_minimum_display_time); - CVAR_REGISTER(&cv_tutor_message_character_display_time_coefficient); + CVAR_REGISTER(&cv_tutor_message_repeats); + CVAR_REGISTER(&cv_tutor_debug_level); + CVAR_REGISTER(&cv_tutor_view_distance); + CVAR_REGISTER(&cv_tutor_viewable_check_interval); + CVAR_REGISTER(&cv_tutor_look_distance); + CVAR_REGISTER(&cv_tutor_look_angle); + CVAR_REGISTER(&cv_tutor_examine_time); + CVAR_REGISTER(&cv_tutor_message_minimum_display_time); + CVAR_REGISTER(&cv_tutor_message_character_display_time_coefficient); CVAR_REGISTER(&cv_tutor_hint_interval_time); } @@ -90,7 +90,7 @@ void MonitorTutorStatus(void) } else tutor_enableCvarExists = false; - + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = reinterpret_cast(UTIL_PlayerByIndex(i)); diff --git a/regamedll/dlls/tutor_base_states.h b/regamedll/dlls/tutor_base_states.h index b7669007..a8c8d248 100644 --- a/regamedll/dlls/tutor_base_states.h +++ b/regamedll/dlls/tutor_base_states.h @@ -38,7 +38,7 @@ public: CBaseTutorState(void); virtual ~CBaseTutorState(void); - virtual int CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; + virtual int CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; virtual char *GetStateString(void) = 0; public: @@ -51,15 +51,15 @@ protected: class CBaseTutorStateSystem { -public: - CBaseTutorStateSystem(void); - - virtual ~CBaseTutorStateSystem(void); - virtual bool UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; - virtual char *GetCurrentStateString(void) = 0; - virtual CBaseTutorState *ConstructNewState(int stateType) = 0; - -public: +public: + CBaseTutorStateSystem(void); + + virtual ~CBaseTutorStateSystem(void); + virtual bool UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; + virtual char *GetCurrentStateString(void) = 0; + virtual CBaseTutorState *ConstructNewState(int stateType) = 0; + +public: int GetCurrentStateType(void); protected: diff --git a/regamedll/dlls/tutor_cs_states.cpp b/regamedll/dlls/tutor_cs_states.cpp index 20ac619f..aa0f7774 100644 --- a/regamedll/dlls/tutor_cs_states.cpp +++ b/regamedll/dlls/tutor_cs_states.cpp @@ -5,7 +5,7 @@ */ #ifndef HOOK_GAMEDLL -char *const g_TutorStateStrings[20] = +char *const g_TutorStateStrings[20] = { "#Cstrike_TutorState_Undefined", "#Cstrike_TutorState_Looking_For_Hostage", @@ -260,51 +260,51 @@ int CCSTutorBuyMenuState::HandleRoundStart(CBaseEntity *entity, CBaseEntity *oth return TUTOR_STATE_FLAG_1; } -#ifdef HOOK_GAMEDLL - -bool CCSTutorStateSystem::UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) -{ - return UpdateState_(event, entity, other); -} - -char *CCSTutorStateSystem::GetCurrentStateString(void) -{ - return GetCurrentStateString_(); -} - -CBaseTutorState *CCSTutorStateSystem::ConstructNewState(int stateType) -{ - return ConstructNewState_(stateType); -} - -int CCSTutorUndefinedState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) -{ - return CheckForStateTransition_(event, entity, other); -} - -char *CCSTutorUndefinedState::GetStateString(void) -{ - return GetStateString_(); -} - -int CCSTutorWaitingForStartState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) -{ - return CheckForStateTransition_(event, entity, other); -} - -char *CCSTutorWaitingForStartState::GetStateString(void) -{ - return GetStateString_(); -} - -int CCSTutorBuyMenuState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) -{ - return CheckForStateTransition_(event, entity, other); -} - -char *CCSTutorBuyMenuState::GetStateString(void) -{ - return GetStateString_(); -} - +#ifdef HOOK_GAMEDLL + +bool CCSTutorStateSystem::UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +{ + return UpdateState_(event, entity, other); +} + +char *CCSTutorStateSystem::GetCurrentStateString(void) +{ + return GetCurrentStateString_(); +} + +CBaseTutorState *CCSTutorStateSystem::ConstructNewState(int stateType) +{ + return ConstructNewState_(stateType); +} + +int CCSTutorUndefinedState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +{ + return CheckForStateTransition_(event, entity, other); +} + +char *CCSTutorUndefinedState::GetStateString(void) +{ + return GetStateString_(); +} + +int CCSTutorWaitingForStartState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +{ + return CheckForStateTransition_(event, entity, other); +} + +char *CCSTutorWaitingForStartState::GetStateString(void) +{ + return GetStateString_(); +} + +int CCSTutorBuyMenuState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +{ + return CheckForStateTransition_(event, entity, other); +} + +char *CCSTutorBuyMenuState::GetStateString(void) +{ + return GetStateString_(); +} + #endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/tutor_cs_states.h b/regamedll/dlls/tutor_cs_states.h index ac67cc3b..b31044d3 100644 --- a/regamedll/dlls/tutor_cs_states.h +++ b/regamedll/dlls/tutor_cs_states.h @@ -70,21 +70,21 @@ public: virtual ~CCSTutorStateSystem(void); virtual bool UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other); virtual char *GetCurrentStateString(void); + +#ifdef HOOK_GAMEDLL +public: + + bool UpdateState_(GameEventType event, CBaseEntity *entity, CBaseEntity *other); + char *GetCurrentStateString_(void); + CBaseTutorState *ConstructNewState_(int stateType); + +#endif // HOOK_GAMEDLL #ifndef HOOK_GAMEDLL protected: #endif // HOOK_GAMEDLL - virtual CBaseTutorState *ConstructNewState(int stateType); - -#ifdef HOOK_GAMEDLL -public: - - bool UpdateState_(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - char *GetCurrentStateString_(void); - CBaseTutorState *ConstructNewState_(int stateType); - -#endif // HOOK_GAMEDLL + virtual CBaseTutorState *ConstructNewState(int stateType); };/* size: 8, cachelines: 1, members: 1 */ diff --git a/regamedll/dlls/tutor_cs_tutor.cpp b/regamedll/dlls/tutor_cs_tutor.cpp index 54ea8610..709fb616 100644 --- a/regamedll/dlls/tutor_cs_tutor.cpp +++ b/regamedll/dlls/tutor_cs_tutor.cpp @@ -166,10 +166,6 @@ const char *TutorIdentifierList[ TUTOR_NUM_MESSAGES ]; #endif // HOOK_GAMEDLL -//#ifdef HOOK_GAMEDLL -//static TutorMessageMap m_messageMap_; -//#endif // HOOK_GAMEDLL - /* <212575> ../cstrike/dlls/tutor_cs_tutor.cpp:197 */ CCSTutor::CCSTutor(void) { @@ -217,7 +213,6 @@ CCSTutor::~CCSTutor(void) void ParseMessageParameters(char *&messageData, TutorMessage *ret) { char *token; - static int iNumP = 0; while (true) { @@ -423,10 +418,8 @@ void CCSTutor::ReadTutorMessageFile(void) defaultMessage.m_minDisplayTimeOverride = 0; defaultMessage.m_minRepeatInterval = 0; - int d = 0; - while (d < 200) + while (true) { - d++; messageData = MP_COM_Parse(messageData); if (!messageData) @@ -1195,7 +1188,7 @@ void CCSTutor::UpdateCurrentMessage(TutorMessageEvent *event) void CCSTutor::__MAKE_VHOOK(ShowTutorMessage)(TutorMessageEvent *event) { TutorMessageID mid = static_cast(event->GetID()); - + if (mid < 0 || mid >= TUTOR_NUM_MESSAGES) { return; diff --git a/regamedll/dlls/tutor_cs_tutor.h b/regamedll/dlls/tutor_cs_tutor.h index 131a82a9..6f2722d3 100644 --- a/regamedll/dlls/tutor_cs_tutor.h +++ b/regamedll/dlls/tutor_cs_tutor.h @@ -33,7 +33,6 @@ #endif #include -#include enum TutorMessageClass { diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index 95a9e98d..eb7e8efb 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" -#if 0 +#if 1 void *addr_orig; char patchByte[5]; @@ -314,7 +314,7 @@ int UTIL_EntitiesInBox(CBaseEntity **pList, int listMax, const Vector &mins, con edict_t *pEdict = INDEXENT(1); CBaseEntity *pEntity; int count = 0; - + if (!pEdict) return 0; @@ -1003,17 +1003,17 @@ float UTIL_Approach(float target, float value, float speed) value += speed; else if (delta < -speed) value -= speed; - else + else value = target; return value; } /* <1aedeb> ../cstrike/dlls/util.cpp:1190 */ -float UTIL_ApproachAngle(float target, float value, float speed) +float_precision UTIL_ApproachAngle(float target, float value, float speed) { target = UTIL_AngleMod(target); value = UTIL_AngleMod(target); - + float delta = target - value; if (speed < 0.0f) speed = -speed; @@ -1027,13 +1027,13 @@ float UTIL_ApproachAngle(float target, float value, float speed) value += speed; else if (delta < -speed) value -= speed; - else + else value = target; return value; } /* <1aeec5> ../cstrike/dlls/util.cpp:1217 */ -float UTIL_AngleDistance(float next, float cur) +float_precision UTIL_AngleDistance(float next, float cur) { float_precision delta; @@ -1048,17 +1048,6 @@ float UTIL_AngleDistance(float next, float cur) return delta; } -/*float UTIL_AngleDistance(float next, float cur) -{ - //TODO: variable need double, or will testdemo to crashed - double delta = (double)(next - cur); - if (delta < -180.0f) - delta += 360.0f; - else if ( delta > 180.0f) - delta -= 360.0f; - return (float)delta; -}*/ - /* <1aef1c> ../cstrike/dlls/util.cpp:1230 */ float UTIL_SplineFraction(float value, float scale) { @@ -1148,7 +1137,7 @@ void UTIL_BloodStream(const Vector &origin, const Vector &direction, int color, WRITE_COORD(direction.y); WRITE_COORD(direction.z); WRITE_BYTE(color); - WRITE_BYTE(_min( amount, 255 )); + WRITE_BYTE(Q_min(amount, 255)); MESSAGE_END(); } @@ -1178,7 +1167,7 @@ void UTIL_BloodDrips(const Vector &origin, const Vector &direction, int color, i WRITE_SHORT(g_sModelIndexBloodSpray); WRITE_SHORT(g_sModelIndexBloodDrop); WRITE_BYTE(color); - WRITE_BYTE(_min( _max( 3, amount / 10 ), 16 )); + WRITE_BYTE(Q_min(Q_max(3, amount / 10), 16)); MESSAGE_END(); } @@ -1704,7 +1693,7 @@ extern "C" shift &= 0x1f; - while (shift--) + while (shift--) { lobit = num & 1; num >>= 1; @@ -2433,28 +2422,35 @@ char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd) NOXREF int GetPlayerTeam(int index) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(index); - if (pPlayer) + if (pPlayer != NULL) + { return pPlayer->m_iTeam; + } + return 0; } /* <1b5412> ../cstrike/dlls/util.cpp:2775 */ bool UTIL_IsGame(const char *gameName) { - if (gameName) + if (gameName != NULL) { static char gameDir[256]; GET_GAME_DIR(gameDir); return (Q_stricmp(gameDir, gameName) == 0); } + return false; } /* <1b5470> ../cstrike/dlls/util.cpp:2802 */ -float UTIL_GetPlayerGaitYaw(int playerIndex) +float_precision UTIL_GetPlayerGaitYaw(int playerIndex) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(playerIndex); - if (pPlayer) + if (pPlayer != NULL) + { return pPlayer->m_flGaityaw; - return 0.0f; + } + + return 0; } diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 14e13a6d..904a7573 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -64,7 +64,11 @@ #define CBSENTENCENAME_MAX 16 #define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in engine\sound.h!!! +#ifdef CLIENT_WEAPONS #define WEAPON_TIMEBASED 0.0f +#else +#define WEAPON_TIMEBASED gpGlobals->time +#endif // CLIENT_WEAPONS #define GROUP_OP_AND 0 #define GROUP_OP_NAND 1 @@ -102,6 +106,25 @@ extern globalvars_t *gpGlobals; #define SVC_WEAPONANIM 35 #define SVC_ROOMTYPE 37 #define SVC_DIRECTOR 51 + +#define SF_TRIG_PUSH_ONCE 1 + +// func_rotating +#define SF_BRUSH_ROTATE_Y_AXIS 0 +#define SF_BRUSH_ROTATE_INSTANT 1 +#define SF_BRUSH_ROTATE_BACKWARDS 2 +#define SF_BRUSH_ROTATE_Z_AXIS 4 +#define SF_BRUSH_ROTATE_X_AXIS 8 +#define SF_PENDULUM_AUTO_RETURN 16 +#define SF_PENDULUM_PASSABLE 32 + +#define SF_BRUSH_ROTATE_SMALLRADIUS 128 +#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 +#define SF_BRUSH_ROTATE_LARGERADIUS 512 + +#define SPAWNFLAG_NOMESSAGE 1 +#define SPAWNFLAG_NOTOUCH 1 +#define SPAWNFLAG_DROIDONLY 4 #define VEC_HULL_MIN_Z Vector(0, 0, -36) #define VEC_DUCK_HULL_MIN_Z Vector(0, 0, -18) @@ -417,8 +440,8 @@ float UTIL_VecToYaw(const Vector &vec); void UTIL_SetOrigin(entvars_t *pev, const Vector &vecOrigin); NOXREF void UTIL_ParticleEffect(const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount); float UTIL_Approach(float target, float value, float speed); -float UTIL_ApproachAngle(float target, float value, float speed); -float UTIL_AngleDistance(float next, float cur); +float_precision UTIL_ApproachAngle(float target, float value, float speed); +float_precision UTIL_AngleDistance(float next, float cur); float UTIL_SplineFraction(float value, float scale); char *UTIL_VarArgs(char *format, ...); NOXREF Vector UTIL_GetAimVector(edict_t *pent, float flSpeed); @@ -451,7 +474,7 @@ void EntvarsKeyvalue(entvars_t *pev, KeyValueData *pkvd); char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd); NOXREF int GetPlayerTeam(int index); bool UTIL_IsGame(const char *gameName); -float UTIL_GetPlayerGaitYaw(int playerIndex); +float_precision UTIL_GetPlayerGaitYaw(int playerIndex); /* * Declared for function overload @@ -478,7 +501,7 @@ typedef int (CSaveRestoreBuffer::*CSAVERESTOREBUFFER_POINTER)(const char *,const #endif // HOOK_GAMEDLL -#if 0 +#if 1 extern void *addr_orig; extern char patchByte[5]; @@ -486,8 +509,4 @@ extern char patchByteOriginal[5]; #endif -// Refs - -extern Vector (*pFireBullets3)(Vector, Vector, float, float, int, int, int, float, entvars_t *, bool, int); - #endif // UTIL_H diff --git a/regamedll/dlls/vector.h b/regamedll/dlls/vector.h index ce9e3e6b..41aba08d 100644 --- a/regamedll/dlls/vector.h +++ b/regamedll/dlls/vector.h @@ -95,7 +95,7 @@ public: return Vector2D(0, 0); flLen = 1 / flLen; - + #ifdef HOOK_GAMEDLL return Vector2D((vec_t)(x * flLen), (vec_t)(y * flLen)); #else @@ -130,6 +130,7 @@ public: return (x > -tolerance && x < tolerance && y > -tolerance && y < tolerance); } + };/* size: 8, cachelines: 1, members: 2 */ inline float DotProduct(const Vector2D &a, const Vector2D &b) @@ -227,7 +228,6 @@ public: float_precision y1 = (float_precision)y; float_precision z1 = (float_precision)z; - return sqrt(x1 * x1 + y1 * y1 + z1 * z1); //return sqrt((float_precision)(x * x + y * y + z * z)); @@ -250,8 +250,8 @@ public: float flLen = Length(); if (flLen == 0) return Vector(0, 0, 1); - - flLen = 1 / flLen; + + flLen = 1 / flLen; return Vector(x * flLen, y * flLen, z * flLen); } #else @@ -260,8 +260,8 @@ public: float_precision flLen = Length(); if (flLen == 0) return Vector(0, 0, 1); - - vec_t fTemp = (vec_t)(1 / flLen); + + vec_t fTemp = (vec_t)(1 / flLen); return Vector(x * fTemp, y * fTemp, z * fTemp); } // for out precision normalize @@ -273,8 +273,8 @@ public: float_precision flLen = Length(); if (flLen == 0) return Vector(0, 0, 1); - - flLen = 1 / flLen; + + flLen = 1 / flLen; return Vector((vec_t)(x * flLen), (vec_t)(y * flLen), (vec_t)(z * flLen)); #endif // HOOK_GAMEDLL } @@ -356,7 +356,7 @@ template< typename Z, typename LenType > -inline LenType LenghtSubtract(Vector vecStart, Vector vecDest) +inline LenType LengthSubtract(Vector vecStart, Vector vecDest) { X floatX = (vecDest.x - vecStart.x); Y floatY = (vecDest.y - vecStart.y); @@ -389,10 +389,10 @@ inline Vector NormalizeSubtract(Vector vecStart, Vector vecDest) } else { - flLen = 1.0 / flLen; - - dir.x = (vec_t)(floatX * flLen); - dir.y = (vec_t)(floatY * flLen); + flLen = 1.0 / flLen; + + dir.x = (vec_t)(floatX * flLen); + dir.y = (vec_t)(floatY * flLen); dir.z = (vec_t)(floatZ * flLen); } #else diff --git a/regamedll/dlls/vehicle.cpp b/regamedll/dlls/vehicle.cpp index a2c8c6a2..db54af35 100644 --- a/regamedll/dlls/vehicle.cpp +++ b/regamedll/dlls/vehicle.cpp @@ -19,347 +19,734 @@ TYPEDESCRIPTION CFuncVehicle::m_SaveData[] = DEFINE_FIELD(CFuncVehicle, m_flVolume, FIELD_FLOAT), DEFINE_FIELD(CFuncVehicle, m_flBank, FIELD_FLOAT), DEFINE_FIELD(CFuncVehicle, m_oldSpeed, FIELD_FLOAT), -}; - -#else - -TYPEDESCRIPTION (*CFuncVehicle::pm_SaveData)[12]; - +}; + +#else + +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CFuncVehicle, m_SaveData)[12]; + #endif // HOOK_GAMEDLL -/* <1bc835> ../cstrike/dlls/vehicle.cpp:20 */ -NOBODY void FixupAngles2(Vector &v) -{ +/* <1ba031> ../cstrike/dlls/vehicle.cpp:9 */ +float_precision Fix2(float angle) +{ + while (angle < 0) + angle += 360; + + while (angle > 360) + angle -= 360; + + return angle; } -/* <1bb2f1> ../cstrike/dlls/vehicle.cpp:54 */ -IMPLEMENT_SAVERESTORE(CFuncVehicle, CBaseEntity); +/* <1bc835> ../cstrike/dlls/vehicle.cpp:20 */ +void FixupAngles2(Vector &v) +{ + v.x = Fix2(v.x); + v.y = Fix2(v.y); + v.z = Fix2(v.z); +} -/* <1bbf8f> ../cstrike/dlls/vehicle.cpp:55 */ +/* <1bb2f1> ../cstrike/dlls/vehicle.cpp:54 */ +IMPLEMENT_SAVERESTORE(CFuncVehicle, CBaseEntity); + +/* <1bbf8f> ../cstrike/dlls/vehicle.cpp:55 */ LINK_ENTITY_TO_CLASS(func_vehicle, CFuncVehicle); -/* <1bb408> ../cstrike/dlls/vehicle.cpp:57 */ -NOBODY void CFuncVehicle::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ -// FStrEq(const char *sz1, -// const char *sz2); // 59 -// FStrEq(const char *sz1, -// const char *sz2); // 64 -// FStrEq(const char *sz1, -// const char *sz2); // 69 -// FStrEq(const char *sz1, -// const char *sz2); // 74 -// FStrEq(const char *sz1, -// const char *sz2); // 79 -// FStrEq(const char *sz1, -// const char *sz2); // 84 -// FStrEq(const char *sz1, -// const char *sz2); // 90 -// FStrEq(const char *sz1, -// const char *sz2); // 95 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 105 -// atof(const char *__nptr); // 61 -// atof(const char *__nptr); // 66 -// atof(const char *__nptr); // 76 -// atoi(const char *__nptr); // 97 -// atof(const char *__nptr); // 71 -// atoi(const char *__nptr); // 81 -// atoi(const char *__nptr); // 86 -// atof(const char *__nptr); // 92 +/* <1bb408> ../cstrike/dlls/vehicle.cpp:57 */ +void CFuncVehicle::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "length")) + { + m_length = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "width")) + { + m_width = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "height")) + { + m_height = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "startspeed")) + { + m_startSpeed = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "sounds")) + { + m_sounds = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "volume")) + { + m_flVolume = (float)Q_atoi(pkvd->szValue); + m_flVolume *= 0.1; + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "bank")) + { + m_flBank = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "acceleration")) + { + m_acceleration = Q_atoi(pkvd->szValue); + + if (m_acceleration < 1) + m_acceleration = 1; + + else if (m_acceleration > 10) + m_acceleration = 10; + + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } -/* <1bc059> ../cstrike/dlls/vehicle.cpp:109 */ -NOBODY void CFuncVehicle::NextThink(float thinkTime, BOOL alwaysThink) -{ -} - -/* <1bb9d0> ../cstrike/dlls/vehicle.cpp:120 */ -NOBODY void CFuncVehicle::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) -{ -// { -// entvars_t *pevOther; // 122 -// Vector vFrontLeft; // 150 -// Vector vFrontRight; // 150 -// Vector vBackLeft; // 150 -// Vector vBackRight; // 150 -// Vector forward; // 151 -// Vector right; // 152 -// Vector vOrigin; // 159 -// float minx; // 161 -// float miny; // 161 -// float minz; // 161 -// float maxx; // 162 -// float maxy; // 162 -// float maxz; // 162 -// VARS(edict_t *pent); // 125 -// operator-(const Vector *const this, -// const Vector &v); // 139 -// Normalize(const Vector *const this); // 139 -// operator*(const Vector *const this, -// float fl); // 139 -// operator*(const Vector *const this, -// float fl); // 143 -// { -// float deltaSpeed; // 130 -// } -// operator*(const Vector *const this, -// float fl); // 151 -// operator*(const Vector *const this, -// float fl); // 151 -// operator*(const Vector *const this, -// float fl); // 152 -// operator*(const Vector *const this, -// float fl); // 152 -// operator+(const Vector *const this, -// const Vector &v); // 154 -// operator-(const Vector *const this, -// const Vector &v); // 154 -// operator-(const Vector *const this, -// const Vector &v); // 157 -// operator+(const Vector *const this, -// const Vector &v); // 157 -// Vector(Vector *const this, -// const Vector &v); // 159 -// } -} - -/* <1bcf96> ../cstrike/dlls/vehicle.cpp:179 */ -NOBODY void CFuncVehicle::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ -// StopSound(CFuncVehicle *const this); // 197 -// { -// float delta; // 210 -// float flSpeedRatio; // 211 -// StopSound(CFuncVehicle *const this); // 207 -// } +/* <1bc059> ../cstrike/dlls/vehicle.cpp:109 */ +void CFuncVehicle::NextThink(float thinkTime, BOOL alwaysThink) +{ + if (alwaysThink) + pev->flags |= FL_ALWAYSTHINK; + else + pev->flags &= ~FL_ALWAYSTHINK; + + pev->nextthink = thinkTime; } -/* <1bc0bd> ../cstrike/dlls/vehicle.cpp:303 */ -NOBODY void CFuncVehicle::StopSound(void) -{ -// { -// short unsigned int us_encode; // 308 -// short unsigned int us_sound; // 309 -// } +/* <1bb9d0> ../cstrike/dlls/vehicle.cpp:120 */ +void CFuncVehicle::__MAKE_VHOOK(Blocked)(CBaseEntity *pOther) +{ + entvars_t *pevOther = pOther->pev; + + if ((pevOther->flags & FL_ONGROUND) && VARS(pevOther->groundentity) == pev) + { + pevOther->velocity = pev->velocity; + return; + } + + std::vector da; + + pevOther->velocity = (pevOther->origin - pev->origin).Normalize() * pev->dmg; + pevOther->velocity.z += 300; + pev->velocity = pev->velocity * 0.85; + + ALERT(at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING(pev->targetname), STRING(pOther->pev->classname), pev->dmg); + UTIL_MakeVectors(pev->angles); + + Vector forward, right, vOrigin; + Vector vFrontLeft = (gpGlobals->v_forward * -1) * (m_length * 0.5); + Vector vFrontRight = (gpGlobals->v_right * -1) * (m_width * 0.5); + + Vector vBackLeft = pev->origin + vFrontLeft - vFrontRight; + Vector vBackRight = pev->origin - vFrontLeft + vFrontRight; + + float minx = Q_min(vBackLeft.x, vBackRight.x); + float miny = Q_min(vBackLeft.y, vBackRight.y); + float maxx = Q_max(vBackLeft.x, vBackRight.x); + float maxy = Q_max(vBackLeft.y, vBackRight.y); + + float minz = pev->origin.z; + float maxz = pev->origin.z + (2 * abs((int)(pev->mins.z - pev->maxs.z))); + + if (pOther->pev->origin.x < minx + || pOther->pev->origin.x > maxx + || pOther->pev->origin.y < miny + || pOther->pev->origin.y > maxy + || pOther->pev->origin.z < pev->origin.z + || pOther->pev->origin.z > maxz) + { + pOther->TakeDamage(pev, pev, 150, DMG_CRUSH); + } } -/* <1bb33d> ../cstrike/dlls/vehicle.cpp:324 */ -NOBODY void CFuncVehicle::UpdateSound(void) -{ -// { -// float flpitch; // 326 -// { -// short unsigned int us_encode; // 355 -// short unsigned int us_sound; // 356 -// short unsigned int us_pitch; // 357 -// short unsigned int us_volume; // 358 -// } -// } +/* <1bcf96> ../cstrike/dlls/vehicle.cpp:179 */ +void CFuncVehicle::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + float delta = value; + + if (useType != USE_SET) + { + if (ShouldToggle(useType, pev->speed != 0)) + { + if (pev->speed == 0) + { + pev->speed = m_dir * m_speed; + Next(); + } + else + { + pev->speed = 0; + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + + StopSound(); + SetThink(NULL); + } + } + + return; + } + + if (delta < 10) + { + if (delta < 0) + { + if (pev->speed > 145) + { + StopSound(); + } + } + + float_precision flSpeedRatio = delta; + + if (delta > 0) + { + flSpeedRatio = (float)(pev->speed / m_speed); + + if (pev->speed < 0) flSpeedRatio = m_acceleration * 0.0005 + flSpeedRatio + VEHICLE_SPEED0_ACCELERATION; + else if (pev->speed < 10) flSpeedRatio = m_acceleration * 0.0006 + flSpeedRatio + VEHICLE_SPEED1_ACCELERATION; + else if (pev->speed < 20) flSpeedRatio = m_acceleration * 0.0007 + flSpeedRatio + VEHICLE_SPEED2_ACCELERATION; + else if (pev->speed < 30) flSpeedRatio = m_acceleration * 0.0007 + flSpeedRatio + VEHICLE_SPEED3_ACCELERATION; + else if (pev->speed < 45) flSpeedRatio = m_acceleration * 0.0007 + flSpeedRatio + VEHICLE_SPEED4_ACCELERATION; + else if (pev->speed < 60) flSpeedRatio = m_acceleration * 0.0008 + flSpeedRatio + VEHICLE_SPEED5_ACCELERATION; + else if (pev->speed < 80) flSpeedRatio = m_acceleration * 0.0008 + flSpeedRatio + VEHICLE_SPEED6_ACCELERATION; + else if (pev->speed < 100) flSpeedRatio = m_acceleration * 0.0009 + flSpeedRatio + VEHICLE_SPEED7_ACCELERATION; + else if (pev->speed < 150) flSpeedRatio = m_acceleration * 0.0008 + flSpeedRatio + VEHICLE_SPEED8_ACCELERATION; + else if (pev->speed < 225) flSpeedRatio = m_acceleration * 0.0007 + flSpeedRatio + VEHICLE_SPEED9_ACCELERATION; + else if (pev->speed < 300) flSpeedRatio = m_acceleration * 0.0006 + flSpeedRatio + VEHICLE_SPEED10_ACCELERATION; + else if (pev->speed < 400) flSpeedRatio = m_acceleration * 0.0005 + flSpeedRatio + VEHICLE_SPEED11_ACCELERATION; + else if (pev->speed < 550) flSpeedRatio = m_acceleration * 0.0005 + flSpeedRatio + VEHICLE_SPEED12_ACCELERATION; + else if (pev->speed < 800) flSpeedRatio = m_acceleration * 0.0005 + flSpeedRatio + VEHICLE_SPEED13_ACCELERATION; + } + else if (delta < 0) + { + flSpeedRatio = pev->speed / m_speed; + + // TODO: fix float for test demo + if (flSpeedRatio > 0) flSpeedRatio = (float)flSpeedRatio - 0.0125; + else if (flSpeedRatio <= 0 && flSpeedRatio > -0.05) flSpeedRatio = (float)flSpeedRatio - 0.0075; + else if (flSpeedRatio <= 0.05 && flSpeedRatio > -0.1) flSpeedRatio = (float)flSpeedRatio - 0.01; + else if (flSpeedRatio <= 0.15 && flSpeedRatio > -0.15) flSpeedRatio = (float)flSpeedRatio - 0.0125; + else if (flSpeedRatio <= 0.15 && flSpeedRatio > -0.22) flSpeedRatio = (float)flSpeedRatio - 0.01375; + else if (flSpeedRatio <= 0.22 && flSpeedRatio > -0.3) flSpeedRatio = (float)flSpeedRatio - 0.0175; + else if (flSpeedRatio <= 0.3) flSpeedRatio = (float)flSpeedRatio - 0.0125; + } + + if (flSpeedRatio > 1) + { + flSpeedRatio = 1; + } + else if (flSpeedRatio < -0.35) + { + flSpeedRatio = -0.35; + } + + pev->speed = flSpeedRatio * m_speed; + Next(); + m_flAcceleratorDecay = gpGlobals->time + 0.25; + + } + else if (m_flCanTurnNow < gpGlobals->time) + { + if (delta == 20) + { + m_iTurnAngle++; + m_flSteeringWheelDecay = gpGlobals->time + 0.075; + + if (m_iTurnAngle > 8) + { + m_iTurnAngle = 8; + } + } + else if (delta == 30) + { + m_iTurnAngle--; + m_flSteeringWheelDecay = gpGlobals->time + 0.075; + + if (m_iTurnAngle < -8) + { + m_iTurnAngle = -8; + } + } + + m_flCanTurnNow = gpGlobals->time + 0.05; + } } -/* <1bc12b> ../cstrike/dlls/vehicle.cpp:368 */ -NOBODY void CFuncVehicle::CheckTurning(void) -{ -// { -// float maxspeed; // 370 -// TraceResult tr; // 371 -// bool bTurnIntoWall; // 373 -// operator*(const Vector *const this, -// float fl); // 398 -// operator+(const Vector *const this, -// const Vector &v); // 398 -// operator*(const Vector *const this, -// float fl); // 387 -// operator+(const Vector *const this, -// const Vector &v); // 387 -// operator*(const Vector *const this, -// float fl); // 379 -// operator-(const Vector *const this, -// const Vector &v); // 379 -// operator*(const Vector *const this, -// float fl); // 406 -// operator-(const Vector *const this, -// const Vector &v); // 406 -// } +/* <1bc0bd> ../cstrike/dlls/vehicle.cpp:303 */ +void CFuncVehicle::StopSound(void) +{ + if (m_soundPlaying && pev->noise) + { + unsigned short us_sound = ((unsigned short)m_sounds & 0x0007) << 12; + unsigned short us_encode = us_sound; + + PLAYBACK_EVENT_FULL(FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, us_encode, 0, 1, 0); + } + + m_soundPlaying = 0; } -/* <1bc358> ../cstrike/dlls/vehicle.cpp:466 */ -NOBODY void CFuncVehicle::CollisionDetection(void) -{ -// { -// TraceResult tr; // 468 -// bool bHitSomething; // 469 -// operator*(const Vector *const this, -// float fl); // 533 -// operator-(const Vector *const this, -// const Vector &v); // 533 -// operator*(const Vector *const this, -// float fl); // 551 -// operator-(const Vector *const this, -// const Vector &v); // 551 -// operator*(const Vector *const this, -// float fl); // 569 -// operator-(const Vector *const this, -// const Vector &v); // 569 -// DotProduct(Vector &a, -// const Vector &b); // 573 -// operator*(const Vector *const this, -// float fl); // 573 -// { -// class CBaseEntity *pHit; // 490 -// DotProduct(Vector &a, -// const Vector &b); // 479 -// operator*(const Vector *const this, -// float fl); // 479 -// Instance(edict_t *pent); // 490 -// } -// operator*(const Vector *const this, -// float fl); // 496 -// operator+(const Vector *const this, -// const Vector &v); // 496 -// operator*(const Vector *const this, -// float fl); // 514 -// operator+(const Vector *const this, -// const Vector &v); // 514 -// DotProduct(Vector &a, -// const Vector &b); // 517 -// operator*(const Vector *const this, -// float fl); // 517 -// operator*(const Vector *const this, -// float fl); // 475 -// operator+(const Vector *const this, -// const Vector &v); // 475 -// } +/* <1bb33d> ../cstrike/dlls/vehicle.cpp:324 */ +void CFuncVehicle::UpdateSound(void) +{ + if (!pev->noise) + return; + + float flpitch = VEHICLE_STARTPITCH + (abs((int)pev->speed) * (VEHICLE_MAXPITCH - VEHICLE_STARTPITCH) / VEHICLE_MAXSPEED); + + if (flpitch > 200) + flpitch = 200; + + if (!m_soundPlaying) + { + if (m_sounds < 5) + { + EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "plats/vehicle_brake1.wav", m_flVolume, ATTN_NORM, 0, 100); + } + + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noise), m_flVolume, ATTN_NORM, 0, (int)flpitch); + m_soundPlaying = 1; + } + else + { + unsigned short us_sound = ((unsigned short)(m_sounds) & 0x0007) << 12; + unsigned short us_pitch = ((unsigned short)(flpitch / 10.0) & 0x003F) << 6; + unsigned short us_volume = ((unsigned short)(m_flVolume * 40) & 0x003F); + unsigned short us_encode = us_sound | us_pitch | us_volume; + + PLAYBACK_EVENT_FULL(FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 0, 0); + } } -/* <1bc7aa> ../cstrike/dlls/vehicle.cpp:588 */ -NOBODY void CFuncVehicle::TerrainFollowing(void) -{ -// { -// TraceResult tr; // 590 -// operator+(const Vector *const this, -// const Vector &v); // 593 -// } +/* <1bc12b> ../cstrike/dlls/vehicle.cpp:368 */ +void CFuncVehicle::CheckTurning(void) +{ + float_precision maxspeed; + TraceResult tr; + bool bTurnIntoWall = false; + + if (m_iTurnAngle < 0) + { + if (pev->speed > 0) + { + UTIL_TraceLine(m_vFrontRight, m_vFrontRight - (gpGlobals->v_right * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + } + else if (pev->speed < 0) + { + UTIL_TraceLine(m_vBackLeft, m_vBackLeft + (gpGlobals->v_right * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + } + + if (tr.flFraction != 1.0f) + { + m_iTurnAngle = 1; + } + } + else if (m_iTurnAngle > 0) + { + if (pev->speed > 0) + { + UTIL_TraceLine(m_vFrontLeft, m_vFrontLeft + (gpGlobals->v_right * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + } + else if (pev->speed < 0) + { + UTIL_TraceLine(m_vBackRight, m_vBackRight - (gpGlobals->v_right * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + } + + if (tr.flFraction != 1.0f) + { + m_iTurnAngle = -1; + } + } + + if (pev->speed > 0) + { + int iCountTurn = abs(m_iTurnAngle); + + if (iCountTurn > 4) + { + if (m_flTurnStartTime != -1) + { + float flTurnTime = gpGlobals->time - m_flTurnStartTime; + + if (flTurnTime >= 0) maxspeed = m_speed * 0.98; + else if (flTurnTime > 0.3) maxspeed = m_speed * 0.95; + else if (flTurnTime > 0.6) maxspeed = m_speed * 0.9; + else if (flTurnTime > 0.8) maxspeed = m_speed * 0.8; + else if (flTurnTime > 1) maxspeed = m_speed * 0.7; + else if (flTurnTime > 1.2) maxspeed = m_speed * 0.5; + else maxspeed = flTurnTime; + } + else + { + m_flTurnStartTime = gpGlobals->time; + maxspeed = m_speed; + } + } + else + { + m_flTurnStartTime = -1; + + if (iCountTurn > 2) + maxspeed = m_speed * 0.9; + else + maxspeed = m_speed; + } + + if (maxspeed < pev->speed) + { + pev->speed -= m_speed * 0.1; + } + } } -/* <1bc856> ../cstrike/dlls/vehicle.cpp:609 */ -NOBODY void CFuncVehicle::Next(void) -{ -// { -// Vector vGravityVector; // 611 -// Vector forward; // 615 -// Vector right; // 616 -// Vector up; // 617 -// float time; // 633 -// Vector(Vector *const this, -// const Vector &v); // 611 -// operator*(const Vector *const this, -// float fl); // 615 -// operator*(const Vector *const this, -// float fl); // 615 -// operator*(const Vector *const this, -// float fl); // 616 -// operator*(const Vector *const this, -// float fl); // 616 -// operator*(const Vector *const this, -// float fl); // 617 -// operator+(const Vector *const this, -// const Vector &v); // 619 -// operator-(const Vector *const this, -// const Vector &v); // 619 -// operator+(const Vector *const this, -// const Vector &v); // 619 -// operator+(const Vector *const this, -// const Vector &v); // 620 -// operator+(const Vector *const this, -// const Vector &v); // 620 -// operator+(const Vector *const this, -// const Vector &v); // 620 -// operator+(const Vector *const this, -// const Vector &v); // 621 -// operator+(const Vector *const this, -// const Vector &v); // 621 -// operator-(const Vector *const this, -// const Vector &v); // 622 -// operator-(const Vector *const this, -// const Vector &v); // 622 -// operator+(const Vector *const this, -// const Vector &v); // 622 -// operator-(const Vector *const this, -// const Vector &v); // 623 -// operator+(const Vector *const this, -// const Vector &v); // 623 -// operator+(const Vector *const this, -// const Vector &v); // 623 -// operator-(const Vector *const this, -// const Vector &v); // 624 -// operator+(const Vector *const this, -// const Vector &v); // 624 -// { -// Vector temp; // 737 -// operator!=(const Vector *const this, -// const Vector &v); // 678 -// NextThink(CFuncVehicle *const this, -// float thinkTime, -// BOOL alwaysThink); // 755 -// { -// Vector vTargetAngle; // 683 -// Vector vAngle; // 683 -// float vx; // 684 -// float vy; // 684 -// CrossProduct(Vector &a, -// const Vector &b); // 680 -// CrossProduct(Vector &a, -// const Vector &b); // 681 -// FixupAngles2(Vector &v); // 693 -// FixupAngles2(Vector &v); // 694 -// } -// operator!=(const Vector *const this, -// const Vector &v); // 746 -// Normalize(const Vector *const this); // 748 -// operator*(float fl, -// const Vector &v); // 748 -// operator*(const Vector *const this, -// float fl); // 721 -// { -// float flAirTime; // 725 -// } -// operator*(const Vector *const this, -// float fl); // 734 -// operator+(const Vector *const this, -// const Vector &v); // 752 -// UpdateSound(CFuncVehicle *const this); // 742 -// } -// } +/* <1bc358> ../cstrike/dlls/vehicle.cpp:466 */ +void CFuncVehicle::CollisionDetection(void) +{ + TraceResult tr; + bool bHitSomething = false; + + if (pev->speed < 0) + { + UTIL_TraceLine(m_vBackLeft, m_vBackLeft + (gpGlobals->v_forward * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + + if (tr.flFraction == 1.0f) + { + UTIL_TraceLine(m_vBackRight, m_vBackRight + (gpGlobals->v_forward * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + + if (tr.flFraction == 1.0f) + { + UTIL_TraceLine(m_vBack, m_vBack + (gpGlobals->v_forward * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + + if (tr.flFraction == 1.0f) + { + return; + } + } + + if (DotProduct(gpGlobals->v_forward, tr.vecPlaneNormal * -1.0) < 0.7 && tr.vecPlaneNormal.z < 0.1) + { + m_vSurfaceNormal = tr.vecPlaneNormal; + m_vSurfaceNormal.z = 0; + + pev->speed *= 0.99; + } + else if (tr.vecPlaneNormal.z < 0.65 || tr.fStartSolid) + { + pev->speed *= -1.0; + } + else + { + m_vSurfaceNormal = tr.vecPlaneNormal; + } + } + else + { + if (DotProduct(gpGlobals->v_forward, tr.vecPlaneNormal * -1.0) < 0.7 && tr.vecPlaneNormal.z < 0.1) + { + m_vSurfaceNormal = tr.vecPlaneNormal; + m_vSurfaceNormal.z = 0; + + pev->speed *= 0.99; + } + else if (tr.vecPlaneNormal[2] < 0.65 || tr.fStartSolid) + { + pev->speed *= -1.0; + } + else + { + m_vSurfaceNormal = tr.vecPlaneNormal; + } + + CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit); + + if (pHit && pHit->Classify() == CLASS_VEHICLE) + { + bHitSomething = true; + ALERT(at_console, "I hit another vehicle\n"); + } + } + } + else if (pev->speed > 0) + { + UTIL_TraceLine(m_vFrontLeft, m_vFrontLeft - (gpGlobals->v_forward * 16.0), dont_ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + + if (tr.flFraction == 1.0f) + { + UTIL_TraceLine(m_vFrontRight, m_vFrontRight - (gpGlobals->v_forward * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + + if (tr.flFraction == 1.0f) + { + UTIL_TraceLine(m_vFront, m_vFront - (gpGlobals->v_forward * 16.0), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + + if (tr.flFraction == 1.0f) + { + return; + } + } + } + + if (DotProduct(gpGlobals->v_forward, tr.vecPlaneNormal * -1.0) > -0.7 && tr.vecPlaneNormal.z < 0.1) + { + m_vSurfaceNormal = tr.vecPlaneNormal; + m_vSurfaceNormal.z = 0; + + pev->speed *= 0.99; + } + else if (tr.vecPlaneNormal.z < 0.65 || tr.fStartSolid) + { + pev->speed *= -1.0; + } + else + { + m_vSurfaceNormal = tr.vecPlaneNormal; + } + } } -/* <1bd087> ../cstrike/dlls/vehicle.cpp:764 */ -NOBODY void CFuncVehicle::DeadEnd(void) -{ -// { -// class CPathTrack *pTrack; // 767 -// class CPathTrack *pNext; // 767 -// } +/* <1bc7aa> ../cstrike/dlls/vehicle.cpp:588 */ +void CFuncVehicle::TerrainFollowing(void) +{ + TraceResult tr; + UTIL_TraceLine(pev->origin, pev->origin + Vector(0, 0, (m_height + 48) * -1), ignore_monsters, dont_ignore_glass, ENT(pev), &tr); + + if (tr.flFraction != 1.0f) + { + m_vSurfaceNormal = tr.vecPlaneNormal; + } + else if (tr.fInWater) + { + m_vSurfaceNormal = Vector(0, 0, 1); + } } -/* <1bd0d4> ../cstrike/dlls/vehicle.cpp:810 */ -NOBODY void CFuncVehicle::SetControls(entvars_t *pevControls) -{ -// { -// Vector offset; // 812 -// operator-(const Vector *const this, -// const Vector &v); // 812 -// operator+(const Vector *const this, -// const Vector &v); // 814 -// operator+(const Vector *const this, -// const Vector &v); // 815 -// } +/* <1bc856> ../cstrike/dlls/vehicle.cpp:609 */ +void CFuncVehicle::Next(void) +{ + Vector vGravityVector, forward, right, up; + float time = 0.1; + + vGravityVector = g_vecZero; + UTIL_MakeVectors(pev->angles); + + forward = (gpGlobals->v_forward * -1) * (m_length * 0.5); + right = (gpGlobals->v_right * -1) * (m_width * 0.5); + up = gpGlobals->v_up * 16; + + m_vFrontLeft = pev->origin + forward - right + up; + m_vFrontRight = pev->origin + forward + right + up; + m_vFront = pev->origin + forward + up; + m_vBackLeft = pev->origin - forward - right + up; + m_vBackRight = pev->origin - forward + right + up; + m_vBack = pev->origin - forward + up; + m_vSurfaceNormal = g_vecZero; + + CheckTurning(); + + if (m_flSteeringWheelDecay < gpGlobals->time) + { + m_flSteeringWheelDecay = gpGlobals->time + 0.1; + + if (m_iTurnAngle < 0) + m_iTurnAngle++; + + else if (m_iTurnAngle > 0) + m_iTurnAngle--; + } + + if (m_flAcceleratorDecay < gpGlobals->time) + { + m_flAcceleratorDecay = gpGlobals->time + 0.1; + + if (pev->speed < 0) + { + pev->speed += 20; + + if (pev->speed > 0) + pev->speed = 0; + } + else if (pev->speed > 0) + { + pev->speed -= 20; + + if (pev->speed < 0) + pev->speed = 0; + } + } + + if (pev->speed == 0) + { + m_iTurnAngle = 0; + pev->avelocity = g_vecZero; + pev->velocity = g_vecZero; + + SetThink(&CFuncVehicle::Next); + NextThink(pev->ltime + time, TRUE); + return; + } + + TerrainFollowing(); + CollisionDetection(); + + Vector temp; + if (m_vSurfaceNormal != g_vecZero) + { + Vector vTargetAngle, vAngle; + + float vx; + float_precision vy; + + m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, gpGlobals->v_forward); + m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, m_vVehicleDirection); + + vTargetAngle = UTIL_VecToAngles(m_vVehicleDirection); + vAngle = pev->angles; + + vTargetAngle.y += 180; + + if (m_iTurnAngle != 0) + { + vTargetAngle.y += m_iTurnAngle; + } + + FixupAngles2(vTargetAngle); + FixupAngles2(vAngle); + + vx = UTIL_AngleDistance(vTargetAngle.x, vAngle.x); + vy = UTIL_AngleDistance(vTargetAngle.y, vAngle.y); + + if (vx > 10) + vx = 10; + else if (vx < -10) + vx = -10; + + if (vy > 10) + vy = 10; + else if (vy < -10) + vy = -10; + + pev->avelocity.y = (int)(vy * 10); + pev->avelocity.x = (int)(vx * 10); + + m_flLaunchTime = -1; + m_flLastNormalZ = m_vSurfaceNormal.z; + } + else + { + if (m_flLaunchTime != -1) + { + vGravityVector.x = 0; + vGravityVector.y = 0; + vGravityVector.z = (gpGlobals->time - m_flLaunchTime) * -35; + + if (vGravityVector.z < -400) + { + vGravityVector.z = -400; + } + } + else + { + m_flLaunchTime = gpGlobals->time; + vGravityVector = Vector(0, 0, 0); + pev->velocity = pev->velocity * 1.5; + } + + m_vVehicleDirection = gpGlobals->v_forward * -1; + } + + UTIL_VecToAngles(m_vVehicleDirection); + + if (m_flUpdateSound < gpGlobals->time) + { + UpdateSound(); + m_flUpdateSound = gpGlobals->time + 1.0; + } + + if (m_vSurfaceNormal != g_vecZero) + { + pev->velocity = m_vVehicleDirection.Normalize() * pev->speed; + } + else + { + pev->velocity = pev->velocity + vGravityVector; + } + + SetThink(&CFuncVehicle::Next); + NextThink(pev->ltime + time, TRUE); } -/* <1bb1b2> ../cstrike/dlls/vehicle.cpp:819 */ -BOOL CFuncVehicle::__MAKE_VHOOK(OnControls)(entvars_t *pevTest) -{ +/* <1bd087> ../cstrike/dlls/vehicle.cpp:764 */ +void CFuncVehicle::DeadEnd(void) +{ + CPathTrack *pTrack = m_ppath; + ALERT(at_aiconsole, "TRAIN(%s): Dead end ", STRING(pev->targetname)); + + if (pTrack != NULL) + { + CPathTrack *pNext; + + if (m_oldSpeed < 0) + { + do + { + pNext = pTrack->ValidPath(pTrack->GetPrevious(), TRUE); + + if (pNext != NULL) + { + pTrack = pNext; + } + } + while (pNext != NULL); + } + else + { + do + { + pNext = pTrack->ValidPath(pTrack->GetNext(), TRUE); + + if (pNext != NULL) + { + pTrack = pNext; + } + } + while (pNext != NULL); + } + } + + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + + if (pTrack != NULL) + { + ALERT(at_aiconsole, "at %s\n", STRING(pTrack->pev->targetname)); + + if (!FStringNull(pTrack->pev->netname)) + { + FireTargets(STRING(pTrack->pev->netname), this, this, USE_TOGGLE, 0); + } + } + else + ALERT(at_aiconsole, "\n"); +} + +/* <1bd0d4> ../cstrike/dlls/vehicle.cpp:810 */ +void CFuncVehicle::SetControls(entvars_t *pevControls) +{ + Vector offset = pevControls->origin - pev->oldorigin; + m_controlMins = pevControls->mins + offset; + m_controlMaxs = pevControls->maxs + offset; +} + +/* <1bb1b2> ../cstrike/dlls/vehicle.cpp:819 */ +BOOL CFuncVehicle::__MAKE_VHOOK(OnControls)(entvars_t *pevTest) +{ Vector offset = pevTest->origin - pev->origin; if (pev->spawnflags & SF_TRACKTRAIN_NOCONTROL) @@ -372,100 +759,202 @@ BOOL CFuncVehicle::__MAKE_VHOOK(OnControls)(entvars_t *pevTest) local.y = -DotProduct(offset, gpGlobals->v_right); local.z = DotProduct(offset, gpGlobals->v_up); - return (local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z - && local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z); + return (local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z + && local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z); } -/* <1bb676> ../cstrike/dlls/vehicle.cpp:841 */ -NOBODY void CFuncVehicle::Find(void) -{ -// { -// entvars_t *pevTarget; // 847 -// Vector nextPos; // 855 -// Vector look; // 858 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 843 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 848 -// Vector(Vector *const this, -// const Vector &v); // 855 -// Vector(Vector *const this, -// const Vector &v); // 858 -// operator-(const Vector *const this, -// const Vector &v); // 863 -// NextThink(CFuncVehicle *const this, -// float thinkTime, -// BOOL alwaysThink); // 870 -// UpdateSound(CFuncVehicle *const this); // 874 -// } +/* <1bb676> ../cstrike/dlls/vehicle.cpp:841 */ +void CFuncVehicle::Find(void) +{ + m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); + + if (!m_ppath) + return; + + entvars_t *pevTarget = m_ppath->pev; + + if (!FClassnameIs(pevTarget, "path_track")) + { + ALERT(at_error, "func_track_train must be on a path of path_track\n"); + m_ppath = NULL; + return; + } + + Vector nextPos = pevTarget->origin; + nextPos.z += m_height; + + Vector look = nextPos; + look.z -= m_height; + m_ppath->LookAhead(&look, m_length, 0); + look.z += m_height; + + pev->angles = UTIL_VecToAngles(look - nextPos); + pev->angles.y += 180; + + if (pev->spawnflags & SF_TRACKTRAIN_NOPITCH) + { + pev->angles.x = 0; + } + + UTIL_SetOrigin(pev, nextPos); + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncVehicle::Next); + pev->speed = m_startSpeed; + UpdateSound(); } -/* <1bb840> ../cstrike/dlls/vehicle.cpp:878 */ -NOBODY void CFuncVehicle::NearestPath(void) -{ -// { -// class CBaseEntity *pTrack; // 880 -// class CBaseEntity *pNearest; // 881 -// float dist; // 882 -// float closest; // 882 -// FClassnameIs(entvars_t *pev, -// const char *szClassname); // 889 -// operator-(const Vector *const this, -// const Vector &v); // 891 -// Length(const Vector *const this); // 891 -// operator-(const Vector *const this, -// const Vector &v); // 912 -// Length(const Vector *const this); // 912 -// operator-(const Vector *const this, -// const Vector &v); // 912 -// Length(const Vector *const this); // 912 -// NextThink(CFuncVehicle *const this, -// float thinkTime, -// BOOL alwaysThink); // 920 -// } +/* <1bb840> ../cstrike/dlls/vehicle.cpp:878 */ +void CFuncVehicle::NearestPath(void) +{ + CBaseEntity *pTrack = NULL; + CBaseEntity *pNearest = NULL; + float_precision dist; + float closest = 1024; + + while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024)) != NULL) + { + if (!(pTrack->pev->flags & (FL_CLIENT | FL_MONSTER)) && FClassnameIs(pTrack->pev, "path_track")) + { + dist = (pev->origin - pTrack->pev->origin).Length(); + + if (dist < closest) + { + closest = dist; + pNearest = pTrack; + } + } + } + + if (!pNearest) + { + ALERT(at_console, "Can't find a nearby track !!!\n"); + SetThink(NULL); + return; + } + + ALERT(at_aiconsole, "TRAIN: %s, Nearest track is %s\n", STRING(pev->targetname), STRING(pNearest->pev->targetname)); + pTrack = ((CPathTrack *)pNearest)->GetNext(); + + if (pTrack != NULL) + { + if ((pev->origin - pTrack->pev->origin).Length() < (pev->origin - pNearest->pev->origin).Length()) + { + pNearest = pTrack; + } + } + + m_ppath = reinterpret_cast(pNearest); + if (pev->speed != 0) + { + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncVehicle::Next); + } } -/* <1bb00a> ../cstrike/dlls/vehicle.cpp:926 */ -NOBODY void CFuncVehicle::__MAKE_VHOOK(OverrideReset)(void) -{ -// NextThink(class CFuncVehicle *const this, float thinkTime, BOOL alwaysThink); // 928 +/* <1bb00a> ../cstrike/dlls/vehicle.cpp:926 */ +void CFuncVehicle::__MAKE_VHOOK(OverrideReset)(void) +{ + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncVehicle::NearestPath); } -/* <1bd198> ../cstrike/dlls/vehicle.cpp:933 */ -NOBODY CFuncVehicle *CFuncVehicle::Instance(edict_t *pent) -{ -// FClassnameIs(edict_t *pent, -// const char *szClassname); // 935 -// GET_PRIVATE(edict_t *pent); // 936 -} - -/* <1bb055> ../cstrike/dlls/vehicle.cpp:951 */ -int CFuncVehicle::__MAKE_VHOOK(Classify)(void) -{ - return CLASS_VEHICLE; -} - -/* <1bb0ef> ../cstrike/dlls/vehicle.cpp:956 */ -NOBODY void CFuncVehicle::__MAKE_VHOOK(Spawn)(void) -{ -// NextThink(CFuncVehicle::Spawn(// float thinkTime, -// BOOL alwaysThink); // 999 -} - -/* <1bb13e> ../cstrike/dlls/vehicle.cpp:1005 */ -NOBODY void CFuncVehicle::__MAKE_VHOOK(Restart)(void) -{ -// STOP_SOUND(edict_t *entity, -// int channel, -// const char *sample); // 1024 -// NextThink(CFuncVehicle *const this, -// float thinkTime, -// BOOL alwaysThink); // 1027 -} - -/* <1bb07b> ../cstrike/dlls/vehicle.cpp:1032 */ -void CFuncVehicle::__MAKE_VHOOK(Precache)(void) -{ +/* <1bd198> ../cstrike/dlls/vehicle.cpp:933 */ +CFuncVehicle *CFuncVehicle::Instance(edict_t *pent) +{ + if (FClassnameIs(pent, "func_vehicle")) + { + return (CFuncVehicle *)GET_PRIVATE(pent); + } + + return NULL; +} + +/* <1bb055> ../cstrike/dlls/vehicle.cpp:951 */ +int CFuncVehicle::__MAKE_VHOOK(Classify)(void) +{ + return CLASS_VEHICLE; +} + +/* <1bb0ef> ../cstrike/dlls/vehicle.cpp:956 */ +void CFuncVehicle::__MAKE_VHOOK(Spawn)(void) +{ + if (pev->speed == 0) + m_speed = 165; + else + m_speed = pev->speed; + + if (!m_sounds) + m_sounds = 3; + + ALERT(at_console, "M_speed = %f\n", m_speed); + + pev->speed = 0; + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + + pev->impulse = (int)m_speed; + m_acceleration = 5; + + m_dir = 1; + m_flTurnStartTime = -1; + + if (FStringNull(pev->target)) + { + ALERT(at_console, "Vehicle with no target"); + } + + if (pev->spawnflags & SF_TRACKTRAIN_PASSABLE) + pev->solid = SOLID_NOT; + else + pev->solid = SOLID_BSP; + + pev->movetype = MOVETYPE_PUSH; + + SET_MODEL(ENT(pev), STRING(pev->model)); + UTIL_SetSize(pev, pev->mins, pev->maxs); + UTIL_SetOrigin(pev, pev->origin); + + pev->oldorigin = pev->origin; + + m_controlMins = pev->mins; + m_controlMaxs = pev->maxs; + m_controlMaxs.z += 72; + + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncVehicle::Find); + Precache(); +} + +/* <1bb13e> ../cstrike/dlls/vehicle.cpp:1005 */ +void CFuncVehicle::__MAKE_VHOOK(Restart)(void) +{ + ALERT(at_console, "M_speed = %f\n", m_speed); + + pev->speed = 0; + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + + pev->impulse = (int)m_speed; + m_flTurnStartTime = -1; + m_flUpdateSound = -1; + m_dir = 1; + m_pDriver = NULL; + + if (FStringNull(pev->target)) + { + ALERT(at_console, "Vehicle with no target"); + } + + UTIL_SetOrigin(pev, pev->oldorigin); + STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noise)); + + NextThink(pev->ltime + 0.1, FALSE); + SetThink(&CFuncVehicle::Find); +} + +/* <1bb07b> ../cstrike/dlls/vehicle.cpp:1032 */ +void CFuncVehicle::__MAKE_VHOOK(Precache)(void) +{ if (m_flVolume == 0.0f) m_flVolume = 1.0f; @@ -500,35 +989,49 @@ void CFuncVehicle::__MAKE_VHOOK(Precache)(void) PRECACHE_SOUND("plats/vehicle_brake1.wav"); PRECACHE_SOUND("plats/vehicle_start1.wav"); - m_usAdjustPitch = PRECACHE_EVENT(1, "events/vehicle.sc"); -} - -/* <1bd23c> ../cstrike/dlls/vehicle.cpp:1064 */ -LINK_ENTITY_TO_CLASS(func_vehiclecontrols, CFuncVehicleControls); - -/* <1bbd36> ../cstrike/dlls/vehicle.cpp:1067 */ -NOBODY void CFuncVehicleControls::Find(void) -{ -// { -// edict_t *pTarget; // 1069 -// class CFuncVehicle *pvehicle; // 1082 -// Instance(edict_t *pent); // 1082 -// FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, -// const char *pszName); // 1073 -// FNullEnt(const edict_t *pent); // 1074 -// FNullEnt(const edict_t *pent); // 1076 -// SetControls(CFuncVehicle *const this, -// entvars_t *pevControls); // 1083 -// FClassnameIs(edict_t *pent, -// const char *szClassname); // 1074 -// } -} - -/* <1bb0c8> ../cstrike/dlls/vehicle.cpp:1088 */ -NOBODY void CFuncVehicleControls::__MAKE_VHOOK(Spawn)(void) -{ -} - + m_usAdjustPitch = PRECACHE_EVENT(1, "events/vehicle.sc"); +} + +/* <1bd23c> ../cstrike/dlls/vehicle.cpp:1064 */ +LINK_ENTITY_TO_CLASS(func_vehiclecontrols, CFuncVehicleControls); + +/* <1bbd36> ../cstrike/dlls/vehicle.cpp:1067 */ +void CFuncVehicleControls::Find(void) +{ + edict_t *pTarget = NULL; + + do + { + pTarget = FIND_ENTITY_BY_TARGETNAME(pTarget, STRING(pev->target)); + } + while (!FNullEnt(pTarget) && !FClassnameIs(pTarget, "func_vehicle")); + + if (FNullEnt(pTarget)) + { + ALERT(at_console, "No vehicle %s\n", STRING(pev->target)); + return; + } + + CFuncVehicle *pvehicle = CFuncVehicle::Instance(pTarget); + + pvehicle->SetControls(pev); + UTIL_Remove(this); +} + +/* <1bb0c8> ../cstrike/dlls/vehicle.cpp:1088 */ +void CFuncVehicleControls::__MAKE_VHOOK(Spawn)(void) +{ + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + SET_MODEL(ENT(pev), STRING(pev->model)); + + UTIL_SetSize(pev, pev->mins, pev->maxs); + UTIL_SetOrigin(pev, pev->origin); + + SetThink(&CFuncVehicleControls::Find); + pev->nextthink = gpGlobals->time; +} + #ifdef HOOK_GAMEDLL void CFuncVehicle::Spawn(void) diff --git a/regamedll/dlls/vehicle.h b/regamedll/dlls/vehicle.h index bb7d4560..673467f8 100644 --- a/regamedll/dlls/vehicle.h +++ b/regamedll/dlls/vehicle.h @@ -46,7 +46,6 @@ #define VEHICLE_SPEED11_ACCELERATION 0.001444444444444444 #define VEHICLE_SPEED12_ACCELERATION 0.001200000000000000 #define VEHICLE_SPEED13_ACCELERATION 0.000916666666666666 -#define VEHICLE_SPEED14_ACCELERATION 0.001444444444444444 #define VEHICLE_STARTPITCH 60 #define VEHICLE_MAXPITCH 200 @@ -56,8 +55,8 @@ class CFuncVehicleControls: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual int ObjectCaps(void) + virtual void Spawn(void); + virtual int ObjectCaps(void) { return ObjectCaps_(); } @@ -73,10 +72,15 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT Find(void); + void EXPORT Find(void); };/* size: 152, cachelines: 3, members: 1 */ -NOBODY void FixupAngles2(Vector &v); +float_precision Fix2(float angle); +void FixupAngles2(Vector &v); + +// linked objects +C_DLLEXPORT void func_vehicle(entvars_t *pev); +C_DLLEXPORT void func_vehiclecontrols(entvars_t *pev); #endif // VEHICLE_H diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 148f712c..b208fca8 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -38,12 +38,12 @@ const char *g_pModelNameLaser = "sprites/laserbeam.spr"; #else // HOOK_GAMEDLL -ItemInfo (*CBasePlayerItem::pItemInfoArray)[32]; -AmmoInfo (*CBasePlayerItem::pAmmoInfoArray)[32]; +ItemInfo IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[32]; +AmmoInfo IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[32]; -TYPEDESCRIPTION (*CBasePlayerItem::pm_SaveData)[3]; -TYPEDESCRIPTION (*CBasePlayerWeapon::pm_SaveData)[7]; -TYPEDESCRIPTION (*CWeaponBox::pm_SaveData)[4]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, m_SaveData)[3]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBasePlayerWeapon, m_SaveData)[7]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CWeaponBox, m_SaveData)[4]; const char *g_pModelNameLaser; @@ -71,24 +71,34 @@ int giAmmoIndex; MULTIDAMAGE gMultiDamage; +// MaxAmmoCarry - pass in a name and this function will tell +// you the maximum amount of that type of ammunition that a +// player can carry. + /* <1d018e> ../cstrike/dlls/weapons.cpp:82 */ int MaxAmmoCarry(int iszName) { for (int i = 0; i < MAX_WEAPONS; i++) { - ItemInfo *pInfo = &IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[ i ]; + ItemInfo *info = &IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[ i ]; - if (pInfo->pszAmmo1 && !Q_strcmp(STRING(iszName), pInfo->pszAmmo1)) - return pInfo->iMaxAmmo1; + if (info->pszAmmo1 && !Q_strcmp(STRING(iszName), info->pszAmmo1)) + { + return info->iMaxAmmo1; + } - if (pInfo->pszAmmo2 && !Q_strcmp(STRING(iszName), pInfo->pszAmmo2)) - return pInfo->iMaxAmmo2; + if (info->pszAmmo2 && !Q_strcmp(STRING(iszName), info->pszAmmo2)) + { + return info->iMaxAmmo2; + } } ALERT(at_console, "MaxAmmoCarry() doesn't recognize '%s'!\n", STRING(iszName)); return -1; } +// ClearMultiDamage - resets the global multi damage accumulator + /* <1d2a29> ../cstrike/dlls/weapons.cpp:110 */ void ClearMultiDamage(void) { @@ -97,89 +107,156 @@ void ClearMultiDamage(void) gMultiDamage.type = 0; } +// ApplyMultiDamage - inflicts contents of global multi damage register on gMultiDamage.pEntity + /* <1d2a41> ../cstrike/dlls/weapons.cpp:124 */ void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker) { - if (gMultiDamage.pEntity) - gMultiDamage.pEntity->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type); + //Vector vecSpot1;//where blood comes from + //Vector vecDir;//direction blood should go + //TraceResult tr; + + if (!gMultiDamage.pEntity) + return; + + gMultiDamage.pEntity->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type); + } /* <1d2ad3> ../cstrike/dlls/weapons.cpp:140 */ void AddMultiDamage(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { - if (pEntity) + if (!pEntity) + return; + + gMultiDamage.type |= bitsDamageType; + + if (pEntity != gMultiDamage.pEntity) { - gMultiDamage.type |= bitsDamageType; - if (pEntity != gMultiDamage.pEntity) - { - ApplyMultiDamage(pevInflictor,pevInflictor); - gMultiDamage.pEntity = pEntity; - gMultiDamage.amount = flDamage; - } - else - gMultiDamage.amount += flDamage; + // UNDONE: wrong attacker! + ApplyMultiDamage(pevInflictor, pevInflictor); + gMultiDamage.pEntity = pEntity; + gMultiDamage.amount = 0; } + + gMultiDamage.amount += flDamage; } /* <1d2b6f> ../cstrike/dlls/weapons.cpp:162 */ void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { - UTIL_BloodDrips(vecSpot, g_vecAttackDir, bloodColor, flDamage); + UTIL_BloodDrips(vecSpot, g_vecAttackDir, bloodColor, (int)flDamage); } /* <1d2bbb> ../cstrike/dlls/weapons.cpp:168 */ NOXREF int DamageDecal(CBaseEntity *pEntity, int bitsDamageType) { if (pEntity) + { return pEntity->DamageDecal(bitsDamageType); - return RANDOM_LONG(3, 4); + } + + return RANDOM_LONG(DECAL_GUNSHOT4, DECAL_GUNSHOT5); } /* <1d2bfa> ../cstrike/dlls/weapons.cpp:176 */ -NOXREF void DecalGunshot(TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars_t *pShooter, bool bHitMetal) +void DecalGunshot(TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars_t *pShooter, bool bHitMetal) { ; } +// EjectBrass - tosses a brass shell from passed origin at passed velocity + /* <1d07b3> ../cstrike/dlls/weapons.cpp:184 */ -NOBODY void EjectBrass(Vector &vecOrigin, Vector &vecLeft, Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex) +void EjectBrass(const Vector &vecOrigin, const Vector &vecLeft, const Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex) { -// { -// class CBaseEntity *ent; // 188 -// bool useNewBehavior; // 190 -// } + //CBaseEntity *ent = UTIL_PlayerByIndex(entityIndex); // unused + bool useNewBehavior = UTIL_IsGame("czero"); + + MESSAGE_BEGIN(MSG_PVS, gmsgBrass, vecOrigin); + if (!useNewBehavior) + { + // noxref + WRITE_BYTE(TE_MODEL); + } + WRITE_COORD(vecOrigin.x); // origin + WRITE_COORD(vecOrigin.y); + WRITE_COORD(vecOrigin.z); + if (!useNewBehavior) + { + // noxref + // it parses the client side, but does not use it + WRITE_COORD(vecLeft.x); + WRITE_COORD(vecLeft.y); + WRITE_COORD(vecLeft.z); + } + WRITE_COORD(vecVelocity.x); // velocity + WRITE_COORD(vecVelocity.y); + WRITE_COORD(vecVelocity.z); + WRITE_ANGLE(rotation); + WRITE_SHORT(model); + WRITE_BYTE(soundtype); + if (!useNewBehavior) + { + // noxref + WRITE_BYTE(25);// 2.5 seconds + } + WRITE_BYTE(entityIndex); + MESSAGE_END(); } /* <1d2cfd> ../cstrike/dlls/weapons.cpp:220 */ -NOBODY void EjectBrass2(Vector &vecOrigin, Vector &vecVelocity, float rotation, int model, int soundtype, entvars_t *pev) +NOXREF void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype, entvars_t *pev) { -// MESSAGE_BEGIN(int msg_dest, -// int msg_type, -// const float *pOrigin, -// entvars_t *ent); // 224 + MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, NULL, pev); + WRITE_BYTE(TE_MODEL); + WRITE_COORD(vecOrigin.x); + WRITE_COORD(vecOrigin.y); + WRITE_COORD(vecOrigin.z); + WRITE_COORD(vecVelocity.x); + WRITE_COORD(vecVelocity.y); + WRITE_COORD(vecVelocity.z); + WRITE_ANGLE(rotation); + WRITE_SHORT(model); + WRITE_BYTE(0); + WRITE_BYTE(5);// 0.5 seconds + MESSAGE_END(); } +// Precaches the ammo and queues the ammo info for sending to clients + /* <1d020f> ../cstrike/dlls/weapons.cpp:242 */ -NOXREF void AddAmmoNameToAmmoRegistry(const char *szAmmoname) +void AddAmmoNameToAmmoRegistry(const char *szAmmoname) { + // make sure it's not already in the registry for (int i = 0; i < MAX_AMMO_SLOTS; i++) { if (!IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ i ].pszName) continue; if (!Q_stricmp(IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ i ].pszName, szAmmoname)) + { + // ammo already in registry, just quite return; + } } giAmmoIndex++; + assert(giAmmoIndex < MAX_AMMO_SLOTS); if (giAmmoIndex >= MAX_AMMO_SLOTS) + { giAmmoIndex = 0; + } IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ giAmmoIndex ].pszName = szAmmoname; + + // yes, this info is redundant IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ giAmmoIndex ].iId = giAmmoIndex; } +// Precaches the weapon and queues the weapon info for sending to clients + /* <1d2e01> ../cstrike/dlls/weapons.cpp:265 */ void UTIL_PrecacheOtherWeapon(const char *szClassname) { @@ -193,21 +270,25 @@ void UTIL_PrecacheOtherWeapon(const char *szClassname) CBaseEntity *pEntity = CBaseEntity::Instance(VARS(pent)); - if (pEntity) + if (pEntity != NULL) { ItemInfo II; - pEntity->Precache(); Q_memset(&II, 0, sizeof(II)); + pEntity->Precache(); if (((CBasePlayerItem *)pEntity)->GetItemInfo(&II)) { IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[ II.iId ] = II; - if (II.pszAmmo1 && *II.pszAmmo1) + if (II.pszAmmo1 != NULL && *II.pszAmmo1 != '\0') + { AddAmmoNameToAmmoRegistry(II.pszAmmo1); + } - if (II.pszAmmo2 && *II.pszAmmo2) + if (II.pszAmmo2 != NULL && *II.pszAmmo2 != '\0') + { AddAmmoNameToAmmoRegistry(II.pszAmmo2); + } } } @@ -227,33 +308,44 @@ NOXREF void UTIL_PrecacheOtherWeapon2(const char *szClassname) CBaseEntity *pEntity = CBaseEntity::Instance(VARS(pent)); - if (pEntity) + if (pEntity != NULL) { ItemInfo II; - pEntity->Precache(); Q_memset(&II, 0, sizeof(II)); + pEntity->Precache(); + if (((CBasePlayerItem *)pEntity)->GetItemInfo(&II)) { IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[ II.iId ] = II; - if (II.pszAmmo1 && *II.pszAmmo1) + if (II.pszAmmo1 != NULL && *II.pszAmmo1 != '\0') + { AddAmmoNameToAmmoRegistry(II.pszAmmo1); + } - if (II.pszAmmo2 && *II.pszAmmo2) + if (II.pszAmmo2 != NULL && *II.pszAmmo2 != '\0') + { AddAmmoNameToAmmoRegistry(II.pszAmmo2); + } } } REMOVE_ENTITY(pent); } +// called by worldspawn + /* <1d3191> ../cstrike/dlls/weapons.cpp:345 */ void W_Precache(void) { Q_memset(IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray), 0, ARRAYSIZE(IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray))); + Q_memset(IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray), 0, ARRAYSIZE(IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray))); giAmmoIndex = 0; + // custom items... + + // common world objects UTIL_PrecacheOther("item_suit"); UTIL_PrecacheOther("item_battery"); UTIL_PrecacheOther("item_antidote"); @@ -263,39 +355,56 @@ void W_Precache(void) UTIL_PrecacheOther("item_assaultsuit"); UTIL_PrecacheOther("item_thighpack"); + // awp magnum UTIL_PrecacheOtherWeapon("weapon_awp"); UTIL_PrecacheOther("ammo_338magnum"); + UTIL_PrecacheOtherWeapon("weapon_g3sg1"); UTIL_PrecacheOtherWeapon("weapon_ak47"); UTIL_PrecacheOtherWeapon("weapon_scout"); UTIL_PrecacheOther("ammo_762nato"); + + // m249 UTIL_PrecacheOtherWeapon("weapon_m249"); UTIL_PrecacheOther("ammo_556natobox"); + UTIL_PrecacheOtherWeapon("weapon_m4a1"); UTIL_PrecacheOtherWeapon("weapon_sg552"); UTIL_PrecacheOtherWeapon("weapon_aug"); UTIL_PrecacheOtherWeapon("weapon_sg550"); UTIL_PrecacheOther("ammo_556nato"); + + // shotgun UTIL_PrecacheOtherWeapon("weapon_m3"); UTIL_PrecacheOtherWeapon("weapon_xm1014"); UTIL_PrecacheOther("ammo_buckshot"); + UTIL_PrecacheOtherWeapon("weapon_usp"); UTIL_PrecacheOtherWeapon("weapon_mac10"); UTIL_PrecacheOtherWeapon("weapon_ump45"); UTIL_PrecacheOther("ammo_45acp"); + UTIL_PrecacheOtherWeapon("weapon_fiveseven"); UTIL_PrecacheOtherWeapon("weapon_p90"); UTIL_PrecacheOther("ammo_57mm"); + + // deagle UTIL_PrecacheOtherWeapon("weapon_deagle"); UTIL_PrecacheOther("ammo_50ae"); + + // p228 UTIL_PrecacheOtherWeapon("weapon_p228"); UTIL_PrecacheOther("ammo_357sig"); + + // knife UTIL_PrecacheOtherWeapon("weapon_knife"); + UTIL_PrecacheOtherWeapon("weapon_glock18"); UTIL_PrecacheOtherWeapon("weapon_mp5navy"); UTIL_PrecacheOtherWeapon("weapon_tmp"); UTIL_PrecacheOtherWeapon("weapon_elite"); UTIL_PrecacheOther("ammo_9mm"); + UTIL_PrecacheOtherWeapon("weapon_flashbang"); UTIL_PrecacheOtherWeapon("weapon_hegrenade"); UTIL_PrecacheOtherWeapon("weapon_smokegrenade"); @@ -305,15 +414,17 @@ void W_Precache(void) if (g_pGameRules->IsDeathmatch()) { + // container for dropped deathmatch weapons UTIL_PrecacheOther("weaponbox"); } - g_sModelIndexFireball = PRECACHE_MODEL("sprites/zerogxplode.spr"); - g_sModelIndexWExplosion = PRECACHE_MODEL("sprites/WXplo1.spr"); - g_sModelIndexSmoke = PRECACHE_MODEL("sprites/steam1.spr"); - g_sModelIndexBubbles = PRECACHE_MODEL("sprites/bubble.spr"); - g_sModelIndexBloodSpray = PRECACHE_MODEL("sprites/bloodspray.spr"); - g_sModelIndexBloodDrop = PRECACHE_MODEL("sprites/blood.spr"); + g_sModelIndexFireball = PRECACHE_MODEL("sprites/zerogxplode.spr"); // fireball + g_sModelIndexWExplosion = PRECACHE_MODEL("sprites/WXplo1.spr"); // underwater fireball + g_sModelIndexSmoke = PRECACHE_MODEL("sprites/steam1.spr"); // smoke + g_sModelIndexBubbles = PRECACHE_MODEL("sprites/bubble.spr"); // bubbles + g_sModelIndexBloodSpray = PRECACHE_MODEL("sprites/bloodspray.spr"); // initial blood + g_sModelIndexBloodDrop = PRECACHE_MODEL("sprites/blood.spr"); // splattered blood + g_sModelIndexSmokePuff = PRECACHE_MODEL("sprites/smokepuff.spr"); g_sModelIndexFireball2 = PRECACHE_MODEL("sprites/eexplo.spr"); g_sModelIndexFireball3 = PRECACHE_MODEL("sprites/fexplo.spr"); @@ -327,35 +438,25 @@ void W_Precache(void) g_sModelIndexLaser = PRECACHE_MODEL((char *)g_pModelNameLaser); g_sModelIndexLaserDot = PRECACHE_MODEL("sprites/laserdot.spr"); + // used by explosions PRECACHE_MODEL("models/grenade.mdl"); PRECACHE_MODEL("sprites/explode1.spr"); - PRECACHE_SOUND("weapons/debris1.wav"); - PRECACHE_SOUND("weapons/debris2.wav"); - PRECACHE_SOUND("weapons/debris3.wav"); - PRECACHE_SOUND("weapons/grenade_hit1.wav"); - PRECACHE_SOUND("weapons/grenade_hit2.wav"); - PRECACHE_SOUND("weapons/grenade_hit3.wav"); - PRECACHE_SOUND("weapons/bullet_hit1.wav"); - PRECACHE_SOUND("weapons/bullet_hit2.wav"); - PRECACHE_SOUND("items/weapondrop1.wav"); + + PRECACHE_SOUND("weapons/debris1.wav"); // explosion aftermaths + PRECACHE_SOUND("weapons/debris2.wav"); // explosion aftermaths + PRECACHE_SOUND("weapons/debris3.wav"); // explosion aftermaths + + PRECACHE_SOUND("weapons/grenade_hit1.wav"); // grenade + PRECACHE_SOUND("weapons/grenade_hit2.wav"); // grenade + PRECACHE_SOUND("weapons/grenade_hit3.wav"); // grenade + + PRECACHE_SOUND("weapons/bullet_hit1.wav"); // hit by bullet + PRECACHE_SOUND("weapons/bullet_hit2.wav"); // hit by bullet + + PRECACHE_SOUND("items/weapondrop1.wav"); // weapon falls to the ground PRECACHE_SOUND("weapons/generic_reload.wav"); } -/* <1d31ab> ../cstrike/dlls/weapons.cpp:485 */ -void CBasePlayerItem::FallInit(void) -{ - pev->movetype = MOVETYPE_TOSS; - pev->solid = SOLID_BBOX; - - UTIL_SetOrigin(pev, pev->origin); - UTIL_SetSize(pev, Vector(0,0,0), Vector(0,0,0)); - - SetTouch(&CBasePlayerItem::DefaultTouch); - SetThink(&CBasePlayerItem::FallThink); - - pev->nextthink = gpGlobals->time + 0.1; -} - /* <1d20a8> ../cstrike/dlls/weapons.cpp:458 */ IMPLEMENT_SAVERESTORE(CBasePlayerItem, CBaseAnimating); @@ -363,24 +464,53 @@ IMPLEMENT_SAVERESTORE(CBasePlayerItem, CBaseAnimating); IMPLEMENT_SAVERESTORE(CBasePlayerWeapon, CBasePlayerItem); /* <1d1730> ../cstrike/dlls/weapons.cpp:475 */ -NOBODY void CBasePlayerItem::__MAKE_VHOOK(SetObjectCollisionBox)(void) +void CBasePlayerItem::__MAKE_VHOOK(SetObjectCollisionBox)(void) { -// operator+(const Vector ::SetObjectCollisionBox(// const Vector &v); // 477 -// operator+(const Vector *const this, -// const Vector &v); // 478 + pev->absmin = pev->origin + Vector(-24, -24, 0); + pev->absmax = pev->origin + Vector(24, 24, 16); } +// Sets up movetype, size, solidtype for a new weapon. + +/* <1d31ab> ../cstrike/dlls/weapons.cpp:485 */ +void CBasePlayerItem::FallInit(void) +{ + pev->movetype = MOVETYPE_TOSS; + pev->solid = SOLID_BBOX; + + UTIL_SetOrigin(pev, pev->origin); + + //pointsize until it lands on the ground. + UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + + SetTouch(&CBasePlayerItem::DefaultTouch); + SetThink(&CBasePlayerItem::FallThink); + + pev->nextthink = gpGlobals->time + 0.1f; +} + +// FallThink - Items that have just spawned run this think +// to catch them when they hit the ground. Once we're sure +// that the object is grounded, we change its solid type +// to trigger and set it in a large box that helps the +// player get it. + /* <1d32bc> ../cstrike/dlls/weapons.cpp:506 */ void CBasePlayerItem::FallThink(void) { - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; + if (pev->flags & FL_ONGROUND) { + // clatter if we have an owner (i.e., dropped by someone) + // don't clatter if the gun is waiting to respawn (if it's waiting, it is invisible!) if (!FNullEnt(pev->owner)) { int pitch = RANDOM_LONG(0, 29) + 95; EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "items/weapondrop1.wav", VOL_NORM, ATTN_NORM, 0, pitch); } + + // lie flat pev->angles.x = 0.0f; pev->angles.z = 0.0f; @@ -388,11 +518,14 @@ void CBasePlayerItem::FallThink(void) } } +// Materialize - make a CBasePlayerItem visible and tangible + /* <1d3252> ../cstrike/dlls/weapons.cpp:531 */ void CBasePlayerItem::Materialize(void) { if (pev->effects & EF_NODRAW) { + // changing from invisible state to visible. if (g_pGameRules->IsMultiplayer()) { EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", VOL_NORM, ATTN_NORM, 0, 150); @@ -403,13 +536,17 @@ void CBasePlayerItem::Materialize(void) } pev->solid = SOLID_TRIGGER; - UTIL_SetOrigin(pev, pev->origin); + // link into world. + UTIL_SetOrigin(pev, pev->origin); SetTouch(&CBasePlayerItem::DefaultTouch); + if (g_pGameRules->IsMultiplayer()) { if (!CanDrop()) + { SetTouch(NULL); + } SetThink(&CBaseEntity::SUB_Remove); pev->nextthink = gpGlobals->time + 1.0f; @@ -418,14 +555,26 @@ void CBasePlayerItem::Materialize(void) SetThink(NULL); } +// AttemptToMaterialize - the item is trying to rematerialize, +// should it do so now or wait longer? + /* <1d327b> ../cstrike/dlls/weapons.cpp:567 */ -NOBODY void CBasePlayerItem::AttemptToMaterialize(void) +void CBasePlayerItem::AttemptToMaterialize(void) { -// { -// float time; // 569 -// } + float time = g_pGameRules->FlWeaponTryRespawn(this); + + if (time == 0) + { + Materialize(); + return; + } + + pev->nextthink = gpGlobals->time + time; } +// CheckRespawn - a player is taking this weapon, should +// it respawn? + /* <1d3348> ../cstrike/dlls/weapons.cpp:584 */ void CBasePlayerItem::CheckRespawn(void) { @@ -438,13 +587,37 @@ void CBasePlayerItem::CheckRespawn(void) } } +// Respawn- this item is already in the world, but it is +// invisible and intangible. Make it visible and tangible. + /* <1d1e09> ../cstrike/dlls/weapons.cpp:616 */ -NOBODY CBaseEntity *CBasePlayerItem::__MAKE_VHOOK(Respawn)(void) +CBaseEntity *CBasePlayerItem::__MAKE_VHOOK(Respawn)(void) { -// { -// class CBaseEntity *pNewWeapon; // 620 -// } - return NULL; + // make a copy of this weapon that is invisible and inaccessible to players (no touch function). The weapon spawn/respawn code + // will decide when to make the weapon visible and touchable. + CBaseEntity *pNewWeapon = CBaseEntity::Create((char *)STRING(pev->classname), g_pGameRules->VecWeaponRespawnSpot(this), pev->angles, pev->owner); + + if (pNewWeapon != NULL) + { + // invisible for now + pNewWeapon->pev->effects |= EF_NODRAW; + + // no touch + pNewWeapon->SetTouch(NULL); + pNewWeapon->SetThink(&CBasePlayerItem::AttemptToMaterialize); + + DROP_TO_FLOOR(ENT(pev)); + + // not a typo! We want to know when the weapon the player just picked up should respawn! This new entity we created is the replacement, + // but when it should respawn is based on conditions belonging to the weapon that was taken. + pNewWeapon->pev->nextthink = g_pGameRules->FlWeaponRespawnTime(this); + } + else + { + ALERT(at_console, "Respawn failed to create %s!\n", STRING(pev->classname)); + } + + return pNewWeapon; } /* <1d26f0> ../cstrike/dlls/weapons.cpp:642 */ @@ -495,9 +668,13 @@ void CBasePlayerWeapon::SetPlayerShieldAnim(void) if (m_pPlayer->HasShield()) { if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN) + { Q_strcpy(m_pPlayer->m_szAnimExtention, "shield"); + } else + { Q_strcpy(m_pPlayer->m_szAnimExtention, "shieldgun"); + } } } @@ -507,51 +684,36 @@ void CBasePlayerWeapon::ResetPlayerShieldAnim(void) if (m_pPlayer->HasShield()) { if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN) + { Q_strcpy(m_pPlayer->m_szAnimExtention, "shieldgun"); + } } } /* <1d33c3> ../cstrike/dlls/weapons.cpp:699 */ -NOBODY void CBasePlayerWeapon::EjectBrassLate(void) +void CBasePlayerWeapon::EjectBrassLate(void) { -// { -// Vector vecShellVelocity; // 702 -// int soundType; // 707 -// operator+(const Vector *const this, -// const Vector &v); // 701 -// operator*(const Vector *const this, -// float fl); // 705 -// operator*(const Vector *const this, -// float fl); // 705 -// operator*(const Vector *const this, -// float fl); // 705 -// operator+(const Vector *const this, -// const Vector &v); // 705 -// operator+(const Vector *const this, -// const Vector &v); // 705 -// operator+(const Vector *const this, -// const Vector &v); // 705 -// ENTINDEX(edict_t *pEdict); // 714 -// operator*(const Vector *const this, -// float fl); // 714 -// operator*(const Vector *const this, -// float fl); // 714 -// operator*(const Vector *const this, -// float fl); // 714 -// operator+(const Vector *const this, -// const Vector &v); // 714 -// operator+(const Vector *const this, -// const Vector &v); // 714 -// operator+(const Vector *const this, -// const Vector &v); // 714 -// EjectBrass(Vector &vecOrigin, -// const Vector &vecLeft, -// const Vector &vecVelocity, -// float rotation, -// int model, -// int soundtype, -// int entityIndex); // 714 -// } + int soundType; + Vector vecUp, vecRight, vecShellVelocity; + + UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); + + vecUp = RANDOM_FLOAT(100, 150) * gpGlobals->v_up; + vecRight = RANDOM_FLOAT(50, 70) * gpGlobals->v_right; + + vecShellVelocity = (m_pPlayer->pev->velocity + vecRight + vecUp) + gpGlobals->v_forward * 25; + soundType = (m_iId == WEAPON_XM1014 || m_iId == WEAPON_M3) ? 2 : 1; + + EjectBrass + ( + pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_up * -9 + gpGlobals->v_forward * 16, + gpGlobals->v_right * -9, + vecShellVelocity, + pev->angles.y, + m_iShellId, + soundType, + ENTINDEX(ENT(m_pPlayer->pev)) + ); } /* <1d372a> ../cstrike/dlls/weapons.cpp:717 */ @@ -588,108 +750,364 @@ bool CBasePlayerWeapon::ShieldSecondaryFire(int iUpAnim, int iDownAnim) } /* <1d3773> ../cstrike/dlls/weapons.cpp:752 */ -NOBODY void CBasePlayerWeapon::KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change) +void CBasePlayerWeapon::KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change) { -// { -// float flKickUp; // 754 -// float flKickLateral; // 755 -// } -} + float_precision flKickUp; + float flKickLateral; -/* <1d242e> ../cstrike/dlls/weapons.cpp:792 */ -NOBODY void CBasePlayerWeapon::FireRemaining(int &shotsFired, float &shootTime, BOOL bIsGlock) -{ -// { -// float nexttime; // 794 -// Vector vecSrc; // 810 -// int flag; // 828 -// Vector vecAiming; // 811 -// Vector vecDir; // 814 -// operator+(const Vector *const this, -// const Vector &v); // 808 -// Vector(Vector *const this, -// const Vector &v); // 818 -// Vector(Vector *const this, -// const Vector &v); // 818 -// Vector(Vector *const this, -// const Vector &v); // 824 -// Vector(Vector *const this, -// const Vector &v); // 824 -// } -} - -/* <1d389e> ../cstrike/dlls/weapons.cpp:876 */ -NOXREF BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted) -{ - if (isPredicted) + if (m_iShotsFired == 1) { - if (attack_time > 0.0) - return FALSE; + flKickUp = up_base; + flKickLateral = lateral_base; } else { - if (attack_time > curtime) - return FALSE; + flKickUp = m_iShotsFired * up_modifier + up_base; + flKickLateral = m_iShotsFired * lateral_modifier + lateral_base; + } + + m_pPlayer->pev->punchangle.x -= flKickUp; + + if (m_pPlayer->pev->punchangle.x < -up_max) + { + m_pPlayer->pev->punchangle.x = -up_max; + } + + if (m_iDirection == 1) + { + m_pPlayer->pev->punchangle.y += flKickLateral; + + if (m_pPlayer->pev->punchangle.y > lateral_max) + m_pPlayer->pev->punchangle.y = lateral_max; + } + else + { + m_pPlayer->pev->punchangle.y -= flKickLateral; + + if (m_pPlayer->pev->punchangle.y < -lateral_max) + m_pPlayer->pev->punchangle.y = -lateral_max; + } + + if (!RANDOM_LONG(0, direction_change)) + { + m_iDirection = !m_iDirection; + } +} + +/* <1d242e> ../cstrike/dlls/weapons.cpp:792 */ +void CBasePlayerWeapon::FireRemaining(int &shotsFired, float &shootTime, BOOL bIsGlock) +{ + m_iClip--; + + if (m_iClip < 0) + { + m_iClip = 0; + shotsFired = 3; + shootTime = 0; + return; + } + + UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); + + Vector vecSrc = m_pPlayer->GetGunPosition(); + Vector vecDir; + + int flag; +#ifdef CLIENT_WEAPONS + flag = FEV_NOTHOST; +#else + flag = 0; +#endif // CLIENT_WEAPONS + + if (bIsGlock) + { + vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, 0.05, 8192, 1, BULLET_PLAYER_9MM, 18, 0.9, m_pPlayer->pev, true, m_pPlayer->random_seed); + m_pPlayer->ammo_9mm--; + + PLAYBACK_EVENT_FULL + ( + flag, + ENT(m_pPlayer->pev), + m_usFireGlock18, + 0, + (float *)&g_vecZero, + (float *)&g_vecZero, + vecDir.x, + vecDir.y, + (int)(m_pPlayer->pev->punchangle.x * 10000.0), + (int)(m_pPlayer->pev->punchangle.y * 10000.0), + m_iClip == 0, + 0 + ); + } + else + { + + vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, m_fBurstSpread, 8192, 2, BULLET_PLAYER_556MM, 30, 0.96, m_pPlayer->pev, false, m_pPlayer->random_seed); + m_pPlayer->ammo_556nato--; + + PLAYBACK_EVENT_FULL + ( + flag, + ENT(m_pPlayer->pev), + m_usFireFamas, + 0, + (float *)&g_vecZero, + (float *)&g_vecZero, + vecDir.x, + vecDir.y, + (int)(m_pPlayer->pev->punchangle.x * 10000000.0), + (int)(m_pPlayer->pev->punchangle.y * 10000000.0), + 0, + 0 + ); + } + + m_pPlayer->pev->effects |= EF_MUZZLEFLASH; + m_pPlayer->SetAnimation(PLAYER_ATTACK1); + shotsFired++; + + float nexttime = 0; + + if (shotsFired != 3) + { + nexttime = gpGlobals->time + 0.1f; + } + + shootTime = nexttime; +} + +/* <1d389e> ../cstrike/dlls/weapons.cpp:876 */ +BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted) +{ +#ifdef CLIENT_WEAPONS + if (!isPredicted) +#else + if (1) +#endif // CLIENT_WEAPONS + { + return (attack_time <= curtime) ? TRUE : FALSE; + } + else + { + return (attack_time <= 0.0f) ? TRUE : FALSE; } - return TRUE; } /* <1d38f0> ../cstrike/dlls/weapons.cpp:890 */ -NOBODY bool CBasePlayerWeapon::HasSecondaryAttack(void) +bool CBasePlayerWeapon::HasSecondaryAttack(void) { if (m_pPlayer->HasShield()) + { return true; + } - if (m_iId != WEAPON_AK47 - && m_iId != WEAPON_XM1014 - && m_iId != WEAPON_MAC10 - && m_iId != WEAPON_ELITE - && m_iId != WEAPON_FIVESEVEN - && m_iId != WEAPON_MP5N - && m_iId != WEAPON_M249 - && m_iId != WEAPON_M3 - && m_iId != WEAPON_TMP - && m_iId != WEAPON_DEAGLE - && m_iId != WEAPON_P228 - && m_iId != WEAPON_P90 - && m_iId != WEAPON_C4 - && m_iId != WEAPON_GALIL) - return true; - return false; + switch (m_iId) + { + case WEAPON_AK47: + case WEAPON_XM1014: + case WEAPON_MAC10: + case WEAPON_ELITE: + case WEAPON_FIVESEVEN: + case WEAPON_MP5N: + case WEAPON_M249: + case WEAPON_M3: + case WEAPON_TMP: + case WEAPON_DEAGLE: + case WEAPON_P228: + case WEAPON_P90: + case WEAPON_C4: + case WEAPON_GALIL: + return false; + default: + break; + } + + return true; } /* <1d3919> ../cstrike/dlls/weapons.cpp:915 */ -NOBODY void CBasePlayerWeapon::__MAKE_VHOOK(ItemPostFrame)(void) +void CBasePlayerWeapon::__MAKE_VHOOK(ItemPostFrame)(void) { -// { -// int usableButtons; // 918 -// pszAmmo2(CBasePlayerItem *const this); // 982 -// pszAmmo1(CBasePlayerItem *const this); // 992 -// iMaxClip(CBasePlayerItem *const this); // 1006 -// { -// int j; // 969 -// iMaxClip(CBasePlayerItem *const this); // 969 -// } -// FireRemaining(CBasePlayerWeapon *const this, -// int &shotsFired, -// float &shootTime, -// BOOL bIsGlock); // 923 -// FireRemaining(CBasePlayerWeapon *const this, -// int &shotsFired, -// float &shootTime, -// BOOL bIsGlock); // 925 -// iFlags(CBasePlayerItem *const this); // 1051 -// iMaxClip(CBasePlayerItem *const this); // 992 -// } + int usableButtons = m_pPlayer->pev->button; + + if (!HasSecondaryAttack()) + { + usableButtons &= ~IN_ATTACK2; + } + + if (m_flGlock18Shoot != 0) + { + FireRemaining(m_iGlock18ShotsFired, m_flGlock18Shoot, TRUE); + } + else if (gpGlobals->time > m_flFamasShoot && m_flFamasShoot != 0) + { + FireRemaining(m_iFamasShotsFired, m_flFamasShoot, FALSE); + } + + if (m_flNextPrimaryAttack <= WEAPON_TIMEBASED) + { + if (m_pPlayer->m_bResumeZoom) + { + m_pPlayer->m_iFOV = m_pPlayer->m_iLastZoom; + m_pPlayer->pev->fov = m_pPlayer->m_iFOV; + + if (m_pPlayer->m_iFOV == m_pPlayer->m_iLastZoom) + { + m_pPlayer->m_bResumeZoom = false; + } + } + } + + if (m_pPlayer->m_flEjectBrass != 0 && m_pPlayer->m_flEjectBrass <= gpGlobals->time) + { + m_pPlayer->m_flEjectBrass = 0; + EjectBrassLate(); + } + + if (!(m_pPlayer->pev->button & IN_ATTACK)) + { + m_flLastFireTime = 0; + } + + if (m_pPlayer->HasShield()) + { + if (m_fInReload && (m_pPlayer->pev->button & IN_ATTACK2)) + { + SecondaryAttack(); + m_pPlayer->pev->button &= ~IN_ATTACK2; + m_fInReload = FALSE; + m_pPlayer->m_flNextAttack = WEAPON_TIMEBASED; + } + } + + if (m_fInReload && m_pPlayer->m_flNextAttack <= WEAPON_TIMEBASED) + { + // complete the reload. + int j = Q_min(iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + + // Add them to the clip + m_iClip += j; + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; + m_pPlayer->TabulateAmmo(); + m_fInReload = FALSE; + } + + if ((usableButtons & IN_ATTACK2) && CanAttack(m_flNextSecondaryAttack, WEAPON_TIMEBASED, UseDecrement())) + { + if (pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()]) + { + m_fFireOnEmpty = TRUE; + } + + SecondaryAttack(); + m_pPlayer->pev->button &= ~IN_ATTACK2; + } + else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack(m_flNextPrimaryAttack, WEAPON_TIMEBASED, UseDecrement())) + { + if ((m_iClip == 0 && pszAmmo1()) || (iMaxClip() == WEAPON_NOCLIP && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()])) + { + m_fFireOnEmpty = TRUE; + } + + m_pPlayer->TabulateAmmo(); + + if ((m_pPlayer->m_bCanShoot && g_pGameRules->IsMultiplayer() && !g_pGameRules->IsFreezePeriod() && !m_pPlayer->m_bIsDefusing) || !g_pGameRules->IsMultiplayer()) + { + PrimaryAttack(); + } + } + else if ((m_pPlayer->pev->button & IN_RELOAD) && iMaxClip() != WEAPON_NOCLIP && !m_fInReload && m_flNextPrimaryAttack < WEAPON_TIMEBASED) + { + if (m_flFamasShoot == 0 && m_flGlock18Shoot == 0) + { + if (!(m_iWeaponState & WPNSTATE_SHIELD_DRAWN)) + { + // reload when reload is pressed, or if no buttons are down and weapon is empty. + Reload(); + } + } + } + else if (!(usableButtons & (IN_ATTACK | IN_ATTACK2))) + { + // no fire buttons down + if (m_bDelayFire) + { + m_bDelayFire = false; + + if (m_iShotsFired > 15) + { + m_iShotsFired = 15; + } + + m_flDecreaseShotsFired = gpGlobals->time + 0.4f; + } + + m_fFireOnEmpty = FALSE; + + if (m_iId != WEAPON_USP && m_iId != WEAPON_GLOCK18 && m_iId != WEAPON_P228 && m_iId != WEAPON_DEAGLE && m_iId != WEAPON_ELITE && m_iId != WEAPON_FIVESEVEN) + { + if (m_iShotsFired > 0 && m_flDecreaseShotsFired < gpGlobals->time) + { + m_iShotsFired--; + m_flDecreaseShotsFired = gpGlobals->time + 0.0225; + } + } + else + m_iShotsFired = 0; + + if (!IsUseable() && m_flNextPrimaryAttack < WEAPON_TIMEBASED) + { +#if 0 + // weapon isn't useable, switch. + if (!(iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && g_pGameRules->GetNextBestWeapon(m_pPlayer, this)) + { + m_flNextPrimaryAttack = WEAPON_TIMEBASED + 0.3; + return; + } +#endif + } + else + { + if (!(m_iWeaponState & WPNSTATE_SHIELD_DRAWN)) + { + // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing + if (!m_iClip && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < WEAPON_TIMEBASED) + { + if (m_flFamasShoot == 0 && m_flGlock18Shoot == 0) + { + Reload(); + return; + } + } + } + } + + WeaponIdle(); + return; + } + + // catch all + if (ShouldWeaponIdle()) + { + WeaponIdle(); + } } /* <1d3aac> ../cstrike/dlls/weapons.cpp:1069 */ -NOBODY void CBasePlayerItem::DestroyItem(void) +void CBasePlayerItem::DestroyItem(void) { + if (m_pPlayer != NULL) + { + // if attached to a player, remove. + m_pPlayer->RemovePlayerItem(this); + } + + Kill(); } /* <1d17d4> ../cstrike/dlls/weapons.cpp:1081 */ -NOXREF int CBasePlayerItem::__MAKE_VHOOK(AddToPlayer)(CBasePlayer *pPlayer) +int CBasePlayerItem::__MAKE_VHOOK(AddToPlayer)(CBasePlayer *pPlayer) { m_pPlayer = pPlayer; @@ -697,7 +1115,7 @@ NOXREF int CBasePlayerItem::__MAKE_VHOOK(AddToPlayer)(CBasePlayer *pPlayer) WRITE_BYTE(m_iId); MESSAGE_END(); - return 1; + return TRUE; } /* <1d183d> ../cstrike/dlls/weapons.cpp:1092 */ @@ -705,7 +1123,7 @@ void CBasePlayerItem::__MAKE_VHOOK(Drop)(void) { SetTouch(NULL); SetThink(&CBaseEntity::SUB_Remove); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } /* <1d1866> ../cstrike/dlls/weapons.cpp:1099 */ @@ -713,7 +1131,7 @@ void CBasePlayerItem::__MAKE_VHOOK(Kill)(void) { SetTouch(NULL); SetThink(&CBaseEntity::SUB_Remove); - pev->nextthink = gpGlobals->time + 0.1; + pev->nextthink = gpGlobals->time + 0.1f; } /* <1d188f> ../cstrike/dlls/weapons.cpp:1106 */ @@ -730,6 +1148,8 @@ void CBasePlayerItem::__MAKE_VHOOK(AttachToPlayer)(CBasePlayer *pPlayer) pev->solid = SOLID_NOT; pev->aiment = pPlayer->edict(); pev->effects = EF_NODRAW; + + // server won't send down to clients if modelindex == 0 pev->modelindex = 0; pev->model = 0; pev->owner = pPlayer->edict(); @@ -738,13 +1158,20 @@ void CBasePlayerItem::__MAKE_VHOOK(AttachToPlayer)(CBasePlayer *pPlayer) SetTouch(NULL); } +// CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal + /* <1d1e4a> ../cstrike/dlls/weapons.cpp:1126 */ int CBasePlayerWeapon::__MAKE_VHOOK(AddDuplicate)(CBasePlayerItem *pOriginal) { if (m_iDefaultAmmo) + { return ExtractAmmo((CBasePlayerWeapon *)pOriginal); + } else + { + // a dead player dropped this. return ExtractClipAmmo((CBasePlayerWeapon *)pOriginal); + } } /* <1d237f> ../cstrike/dlls/weapons.cpp:1140 */ @@ -761,13 +1188,10 @@ int CBasePlayerWeapon::__MAKE_VHOOK(AddToPlayer)(CBasePlayer *pPlayer) if (AddWeapon()) { - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); - WRITE_BYTE(m_iId); - MESSAGE_END(); - - return 1; + return CBasePlayerItem::AddToPlayer(pPlayer); } - return 0; + + return FALSE; } /* <1d24a3> ../cstrike/dlls/weapons.cpp:1164 */ @@ -804,14 +1228,15 @@ int CBasePlayerWeapon::__MAKE_VHOOK(UpdateClientData)(CBasePlayer *pPlayer) WRITE_BYTE(m_iClip); MESSAGE_END(); - m_iClientWeaponState = state; m_iClientClip = m_iClip; - + m_iClientWeaponState = state; pPlayer->m_fWeapon = TRUE; } - if (m_pNext) + if (m_pNext != NULL) + { m_pNext->UpdateClientData(pPlayer); + } return 1; } @@ -820,65 +1245,95 @@ int CBasePlayerWeapon::__MAKE_VHOOK(UpdateClientData)(CBasePlayer *pPlayer) void CBasePlayerWeapon::__MAKE_VHOOK(SendWeaponAnim)(int iAnim, int skiplocal) { m_pPlayer->pev->weaponanim = iAnim; - if (!skiplocal || !ENGINE_CANSKIP(ENT(m_pPlayer->pev))) - { - MESSAGE_BEGIN(MSG_ONE, SVC_WEAPONANIM, NULL, m_pPlayer->pev); - WRITE_BYTE(iAnim); - WRITE_BYTE(pev->body); - MESSAGE_END(); - } + +#ifdef CLIENT_WEAPONS + if (skiplocal && ENGINE_CANSKIP(m_pPlayer->edict())) + return; +#endif // CLIENT_WEAPONS + + MESSAGE_BEGIN(MSG_ONE, SVC_WEAPONANIM, NULL, m_pPlayer->pev); + WRITE_BYTE(iAnim); // sequence number + WRITE_BYTE(pev->body); // weaponmodel bodygroup. + MESSAGE_END(); } /* <1d3ad5> ../cstrike/dlls/weapons.cpp:1231 */ BOOL CBasePlayerWeapon::AddPrimaryAmmo(int iCount, char *szName, int iMaxClip, int iMaxCarry) { int iIdAmmo; + if (iMaxClip < 1) { m_iClip = -1; iIdAmmo = m_pPlayer->GiveAmmo(iCount, szName, iMaxCarry); } - else if (m_iClip) - iIdAmmo = m_pPlayer->GiveAmmo(iCount, szName, iMaxCarry); - else + else if (m_iClip == 0) { - int i = _min(m_iClip + iCount, iMaxClip); - m_iClip = i; + int i; + i = Q_min(m_iClip + iCount, iMaxClip); + m_iClip += i; iIdAmmo = m_pPlayer->GiveAmmo(iCount - i, szName, iMaxCarry); } + else + { + iIdAmmo = m_pPlayer->GiveAmmo(iCount, szName, iMaxCarry); + } + if (iIdAmmo > 0) { m_iPrimaryAmmoType = iIdAmmo; if (m_pPlayer->HasPlayerItem(this)) + { + // play the "got ammo" sound only if we gave some ammo to a player that already had this gun. + // if the player is just getting this gun for the first time, DefaultTouch will play the "picked up gun" sound for us. EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); + } } + return iIdAmmo > 0 ? TRUE : FALSE; } /* <1d3cd7> ../cstrike/dlls/weapons.cpp:1267 */ -NOXREF BOOL CBasePlayerWeapon::AddSecondaryAmmo(int iCount, char *szName, int iMax) +BOOL CBasePlayerWeapon::AddSecondaryAmmo(int iCount, char *szName, int iMax) { - int iIdAmmo = m_pPlayer->GiveAmmo(iCount, szName, iMax); + int iIdAmmo; + + iIdAmmo = m_pPlayer->GiveAmmo(iCount, szName, iMax); + if (iIdAmmo > 0) { m_iSecondaryAmmoType = iIdAmmo; EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); } + return iIdAmmo > 0 ? TRUE : FALSE; } +// IsUseable - this function determines whether or not a +// weapon is useable by the player in its current state. +// (does it have ammo loaded? do I have any ammo for the +// weapon?, etc) + /* <1d19ba> ../cstrike/dlls/weapons.cpp:1287 */ -NOBODY BOOL CBasePlayerWeapon::__MAKE_VHOOK(IsUseable)(void) +BOOL CBasePlayerWeapon::__MAKE_VHOOK(IsUseable)(void) { -// iMaxAmmo1(CBasePlayerItem *const this); // 1291 - return FALSE; + if (m_iClip <= 0) + { + if (m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] <= 0 && iMaxAmmo1() != -1) + { + // clip is empty (or nonexistant) and the player has no more ammo of this type. + return FALSE; + } + } + + return TRUE; } /* <1d19f4> ../cstrike/dlls/weapons.cpp:1301 */ -NOBODY BOOL CBasePlayerWeapon::__MAKE_VHOOK(CanDeploy)(void) +BOOL CBasePlayerWeapon::__MAKE_VHOOK(CanDeploy)(void) { - return FALSE; + return TRUE; } /* <1d3d7a> ../cstrike/dlls/weapons.cpp:1306 */ @@ -899,10 +1354,10 @@ BOOL CBasePlayerWeapon::DefaultDeploy(char *szViewModel, char *szWeaponModel, in m_flLastFireTime = 0.0f; m_flDecreaseShotsFired = gpGlobals->time; - m_pPlayer->m_iFOV = 90; - m_pPlayer->pev->fov = 90.0f; + m_pPlayer->m_iFOV = DEFAULT_FOV; + m_pPlayer->pev->fov = DEFAULT_FOV; + m_pPlayer->m_iLastZoom = DEFAULT_FOV; m_pPlayer->m_bResumeZoom = false; - m_pPlayer->m_iLastZoom = 90; return TRUE; } @@ -932,7 +1387,7 @@ void CBasePlayerWeapon::ReloadSound(void) { MESSAGE_BEGIN(MSG_ONE, gmsgReloadSound, NULL, pPlayer->pev); WRITE_BYTE((int)((1.0f - (distance / 512.0f)) * 255.0f)); - if (!Q_memcmp(STRING(pev->classname), "weapon_m3", 10) || !Q_memcmp(STRING(pev->classname), "weapon_xm1014", 14)) + if (!Q_strcmp(STRING(pev->classname), "weapon_m3") || !Q_strcmp(STRING(pev->classname), "weapon_xm1014")) WRITE_BYTE(0); else WRITE_BYTE(1); @@ -946,15 +1401,18 @@ int CBasePlayerWeapon::DefaultReload(int iClipSize, int iAnim, float fDelay) { if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) return FALSE; - - int j = _min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + + int j = Q_min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + if (!j) + { return FALSE; + } m_pPlayer->m_flNextAttack = fDelay; ReloadSound(); - SendWeaponAnim(iAnim, UseDecrement() != FALSE); + SendWeaponAnim(iAnim, UseDecrement() ? 1 : 0); m_fInReload = TRUE; m_flTimeWeaponIdle = fDelay + 0.5f; @@ -967,11 +1425,22 @@ BOOL CBasePlayerWeapon::__MAKE_VHOOK(PlayEmptySound)(void) { if (m_iPlayEmptySound) { - if (m_iId == WEAPON_USP || m_iId == WEAPON_GLOCK18 || m_iId == WEAPON_P228 || m_iId == WEAPON_DEAGLE || m_iId == WEAPON_ELITE || m_iId == WEAPON_FIVESEVEN) + switch (m_iId) + { + case WEAPON_USP: + case WEAPON_GLOCK18: + case WEAPON_P228: + case WEAPON_DEAGLE: + case WEAPON_ELITE: + case WEAPON_FIVESEVEN: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/dryfire_pistol.wav", 0.8, ATTN_NORM); - else + break; + default: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/dryfire_rifle.wav", 0.8, ATTN_NORM); + break; + } } + return FALSE; } @@ -982,21 +1451,22 @@ void CBasePlayerWeapon::__MAKE_VHOOK(ResetEmptySound)(void) } /* <1d1a44> ../cstrike/dlls/weapons.cpp:1421 */ -NOBODY int CBasePlayerWeapon::__MAKE_VHOOK(PrimaryAmmoIndex)(void) +int CBasePlayerWeapon::__MAKE_VHOOK(PrimaryAmmoIndex)(void) { - return 0; + return m_iPrimaryAmmoType; } /* <1d1a6c> ../cstrike/dlls/weapons.cpp:1428 */ -NOBODY int CBasePlayerWeapon::__MAKE_VHOOK(SecondaryAmmoIndex)(void) +int CBasePlayerWeapon::__MAKE_VHOOK(SecondaryAmmoIndex)(void) { - return 0; + return -1; } /* <1d1a94> ../cstrike/dlls/weapons.cpp:1433 */ void CBasePlayerWeapon::__MAKE_VHOOK(Holster)(int skiplocal) { - m_fInReload = 0; + // cancel any reload in progress. + m_fInReload = FALSE; m_pPlayer->pev->viewmodel = 0; m_pPlayer->pev->weaponmodel = 0; } @@ -1024,6 +1494,7 @@ CBaseEntity *CBasePlayerAmmo::__MAKE_VHOOK(Respawn)(void) pev->effects |= EF_NODRAW; SetTouch(NULL); + // move to wherever I'm supposed to repawn. UTIL_SetOrigin(pev, g_pGameRules->VecAmmoRespawnSpot(this)); SetThink(&CBasePlayerAmmo::Materialize); @@ -1037,6 +1508,7 @@ void CBasePlayerAmmo::Materialize(void) { if (pev->effects & EF_NODRAW) { + // changing from invisible state to visible. if (g_pGameRules->IsMultiplayer()) { EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", VOL_NORM, ATTN_NORM, 0, 150); @@ -1045,6 +1517,7 @@ void CBasePlayerAmmo::Materialize(void) pev->effects &= ~EF_NODRAW; pev->effects |= EF_MUZZLEFLASH; } + SetTouch(&CBasePlayerAmmo::DefaultTouch); } @@ -1069,43 +1542,70 @@ void CBasePlayerAmmo::DefaultTouch(CBaseEntity *pOther) } else if (gEvilImpulse101) { + // evil impulse 101 hack, kill always SetTouch(NULL); SetThink(&CBaseEntity::SUB_Remove); pev->nextthink = gpGlobals->time + 0.1f; } } +// called by the new item with the existing item as parameter +// +// if we call ExtractAmmo(), it's because the player is picking up this type of weapon for +// the first time. If it is spawned by the world, m_iDefaultAmmo will have a default ammo amount in it. +// if this is a weapon dropped by a dying player, has 0 m_iDefaultAmmo, which means only the ammo in +// the weapon clip comes along. + /* <1d3bc3> ../cstrike/dlls/weapons.cpp:1525 */ int CBasePlayerWeapon::__MAKE_VHOOK(ExtractAmmo)(CBasePlayerWeapon *pWeapon) { int iReturn = 0; - if (pszAmmo1()) + + if (pszAmmo1() != NULL) { + // blindly call with m_iDefaultAmmo. It's either going to be a value or zero. If it is zero, + // we only get the ammo in the weapon's clip, which is what we want. iReturn = pWeapon->AddPrimaryAmmo(m_iDefaultAmmo, (char *)pszAmmo1(), iMaxClip(), iMaxAmmo1()); m_iDefaultAmmo = 0; } - if (pszAmmo2()) + + if (pszAmmo2() != NULL) + { iReturn = AddSecondaryAmmo(0, (char *)pszAmmo2(), iMaxAmmo2()); + } return iReturn; } +// called by the new item's class with the existing item as parameter + /* <1d1acc> ../cstrike/dlls/weapons.cpp:1548 */ int CBasePlayerWeapon::__MAKE_VHOOK(ExtractClipAmmo)(CBasePlayerWeapon *pWeapon) { int iAmmo; if (m_iClip == WEAPON_NOCLIP) + { + // guns with no clips always come empty if they are second-hand iAmmo = 0; + } else + { iAmmo = m_iClip; + } return pWeapon->m_pPlayer->GiveAmmo(iAmmo, (char *)pszAmmo1(), iMaxAmmo1()); } -/* <1d1b2e> ../cstrike/dlls/weapons.cpp:1567 */ -NOBODY void CBasePlayerWeapon::__MAKE_VHOOK(RetireWeapon)(void) -{ +// RetireWeapon - no more ammo for this gun, put it away. +/* <1d1b2e> ../cstrike/dlls/weapons.cpp:1567 */ +void CBasePlayerWeapon::__MAKE_VHOOK(RetireWeapon)(void) +{ + // first, no viewmodel at all. + m_pPlayer->pev->viewmodel = iStringNull; + m_pPlayer->pev->weaponmodel = iStringNull; + + g_pGameRules->GetNextBestWeapon(m_pPlayer, this); } // GetNextAttackDelay - An accurate way of calcualting the next attack time. @@ -1131,20 +1631,22 @@ float CBasePlayerWeapon::GetNextAttackDelay(float delay) float flTimeBetweenFires = gpGlobals->time - m_flLastFireTime; float flCreep = 0.0f; - if (flTimeBetweenFires > 0.0f) + if (flTimeBetweenFires > 0) + { flCreep = flTimeBetweenFires - m_flPrevPrimaryAttack; + } - float flNextAttack = delay - flCreep + 0.0f; + float flNextAttack = WEAPON_TIMEBASED + delay - flCreep; #else - float flNextAttack = delay + 0.0f; + float flNextAttack = WEAPON_TIMEBASED + delay; #endif // REGAMEDLL_BUILD_6153 // save the last fire time m_flLastFireTime = gpGlobals->time; - // we need to remember what the m_flNextPrimaryAttack time is set to for each shot, + // we need to remember what the m_flNextPrimaryAttack time is set to for each shot, // store it as m_flPrevPrimaryAttack. - m_flPrevPrimaryAttack = flNextAttack; + m_flPrevPrimaryAttack = flNextAttack - WEAPON_TIMEBASED; return flNextAttack; } @@ -1156,15 +1658,25 @@ LINK_ENTITY_TO_CLASS(weaponbox, CWeaponBox); IMPLEMENT_SAVERESTORE(CWeaponBox, CBaseEntity); /* <1d1b57> ../cstrike/dlls/weapons.cpp:1629 */ -NOBODY void CWeaponBox::__MAKE_VHOOK(Precache)(void) +void CWeaponBox::__MAKE_VHOOK(Precache)(void) { + PRECACHE_MODEL("models/w_weaponbox.mdl"); } /* <1d2978> ../cstrike/dlls/weapons.cpp:1636 */ -NOBODY void CWeaponBox::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +void CWeaponBox::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// KeyValue(CWeaponBox *const this, -// KeyValueData *pkvd); // 1636 + if (m_cAmmoTypes >= MAX_AMMO_SLOTS) + { + ALERT(at_console, "WeaponBox too full! only %d ammotypes allowed\n", MAX_AMMO_SLOTS); + return; + } + + PackAmmo(ALLOC_STRING(pkvd->szKeyName), Q_atoi(pkvd->szValue)); + + // count this new ammo type. + m_cAmmoTypes++; + pkvd->fHandled = TRUE; } /* <1d48ba> ../cstrike/dlls/weapons.cpp:1652 */ @@ -1199,85 +1711,305 @@ void CWeaponBox::BombThink(void) } /* <1d1ce7> ../cstrike/dlls/weapons.cpp:1687 */ -NOBODY void CWeaponBox::__MAKE_VHOOK(Spawn)(void) +void CWeaponBox::__MAKE_VHOOK(Spawn)(void) { + Precache(); + + pev->movetype = MOVETYPE_TOSS; + pev->solid = SOLID_TRIGGER; + + m_bIsBomb = false; + + UTIL_SetSize(pev, g_vecZero, g_vecZero); + SET_MODEL(ENT(pev), "models/w_weaponbox.mdl"); } +// CWeaponBox - Kill - the think function that removes the +// box from the world. + /* <1d40c4> ../cstrike/dlls/weapons.cpp:1704 */ void CWeaponBox::Kill(void) { - for (int i = 0; i < MAX_ITEM_TYPES; i++) + CBasePlayerItem *pWeapon; + int i; + + // destroy the weapons + for (i = 0; i < MAX_ITEM_TYPES; i++) { - CBasePlayerItem *pWeapon = m_rgpPlayerItems[i]; + pWeapon = m_rgpPlayerItems[i]; while (pWeapon != NULL) { pWeapon->SetThink(&CBaseEntity::SUB_Remove); - pWeapon->pev->nextthink = gpGlobals->time + 0.1; + pWeapon->pev->nextthink = gpGlobals->time + 0.1f; pWeapon = pWeapon->m_pNext; } } + + // remove the box UTIL_Remove(this); } +// CWeaponBox - Touch: try to add my contents to the toucher +// if the toucher is a player. + /* <1d0640> ../cstrike/dlls/weapons.cpp:1732 */ -NOBODY void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { -// { -// class CBasePlayer *pPlayer; // 1751 -// int i; // 1769 -// bool bRemove; // 1770 -// bool bEmitSound; // 1771 -// { -// class CBasePlayerItem *pItem; // 1779 -// { -// class CCSBotManager *ctrl; // 1795 -// } -// { -// class CBaseEntity *pEntity; // 1839 -// class CBasePlayer *pTempPlayer; // 1840 -// class CCSBotManager *csBots; // 1864 -// } -// { -// class CBasePlayerWeapon *pGrenade; // 1881 -// int playerGrenades; // 1889 -// int maxGrenades; // 1890 -// const char *grenadeName; // 1891 -// } -// } -// { -// int n; // 1951 -// } -// } + if (!(pev->flags & FL_ONGROUND)) + { + return; + } + + if (!pOther->IsPlayer()) + { + // only players may touch a weaponbox. + return; + } + + if (!pOther->IsAlive()) + { + // no dead guys. + return; + } + + CBasePlayer *pPlayer = reinterpret_cast(pOther); + + if (pPlayer->m_bIsVIP || pPlayer->m_bShieldDrawn) + return; + + pPlayer->OnTouchingWeapon(this); + + bool bRemove = true; + bool bEmitSound = false; + + // go through my weapons and try to give the usable ones to the player. + // it's important the the player be given ammo first, so the weapons code doesn't refuse + // to deploy a better weapon that the player may pick up because he has no ammo for it. + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + if (!m_rgpPlayerItems[i]) + { + continue; + } + + CBasePlayerItem *pItem = m_rgpPlayerItems[i]; + + // have at least one weapon in this slot + while (pItem != NULL) + { + CCSBotManager *ctrl = TheCSBots(); + + if ((pPlayer->HasShield() && pItem->m_iId == WEAPON_ELITE) + || (pPlayer->IsBot() && !ctrl->IsWeaponUseable(pItem))) + { + return; + } + + if (FClassnameIs(pItem->pev, "weapon_c4")) + { + if (pPlayer->m_iTeam != TERRORIST || pPlayer->pev->deadflag != DEAD_NO) + return; + + if (pPlayer->m_bShowHints && !(pPlayer->m_flDisplayHistory & DHF_BOMB_RETRIEVED)) + { + pPlayer->m_flDisplayHistory |= DHF_BOMB_RETRIEVED; + pPlayer->HintMessage("#Hint_you_have_the_bomb"); + } + else + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Got_bomb"); + + UTIL_LogPrintf + ( + "\"%s<%i><%s>\" triggered \"Got_The_Bomb\"\n", + STRING(pPlayer->pev->netname), + GETPLAYERUSERID(pPlayer->edict()), + GETPLAYERAUTHID(pPlayer->edict()) + ); + + g_pGameRules->m_bBombDropped = FALSE; + + MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); + WRITE_BYTE(9); + WRITE_BYTE(DRC_CMD_EVENT); + WRITE_SHORT(ENTINDEX(pPlayer->edict())); + WRITE_SHORT(ENTINDEX(edict())); + WRITE_LONG(6); + MESSAGE_END(); + + pPlayer->m_bHasC4 = true; + pPlayer->SetBombIcon(FALSE); + pPlayer->pev->body = 1; + + CBaseEntity *pEntity = NULL; + + while (pEntity = UTIL_FindEntityByClassname(pEntity, "player")) + { + if (FNullEnt(pEntity->edict())) + break; + + if (!pEntity->IsPlayer()) + continue; + + if (pEntity->pev->flags == FL_DORMANT) + continue; + + CBasePlayer *pTempPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); + + if (pTempPlayer->pev->deadflag == DEAD_NO && pTempPlayer->m_iTeam == TERRORIST) + { + if (pTempPlayer != pPlayer) + { + ClientPrint(pTempPlayer->pev, HUD_PRINTCENTER, "#Game_bomb_pickup", STRING(pPlayer->pev->netname)); + } + + MESSAGE_BEGIN(MSG_ONE, gmsgBombPickup, NULL, pTempPlayer->pev); + MESSAGE_END(); + } + } + + CCSBotManager *csBots = TheCSBots(); + + csBots->SetLooseBomb(NULL); + TheBots->OnEvent(EVENT_BOMB_PICKED_UP, pPlayer); + } + + if (i >= PRIMARY_WEAPON_SLOT && i <= PISTOL_SLOT && pPlayer->m_rgpPlayerItems[i] != NULL) + { + // ... + } + else if (i == GRENADE_SLOT) + { + if (m_rgpPlayerItems[i]->IsWeapon() && m_rgpPlayerItems[i]) + { + CBasePlayerWeapon *pGrenade = reinterpret_cast(m_rgpPlayerItems[i]); + int playerGrenades = pPlayer->m_rgAmmo[pGrenade->m_iPrimaryAmmoType]; + int maxGrenades = 0; + const char *grenadeName = NULL; + + switch (pGrenade->m_iId) + { + case WEAPON_HEGRENADE: + grenadeName = "weapon_hegrenade"; + maxGrenades = 1; + break; + case WEAPON_SMOKEGRENADE: + grenadeName = "weapon_smokegrenade"; + maxGrenades = 1; + break; + case WEAPON_FLASHBANG: + grenadeName = "weapon_flashbang"; + maxGrenades = 2; + break; + } + + if (playerGrenades < maxGrenades && grenadeName != NULL) + { + bEmitSound = true; + pPlayer->GiveNamedItem(grenadeName); + + // unlink this weapon from the box + pItem = m_rgpPlayerItems[i]->m_pNext; + m_rgpPlayerItems[i] = pItem; + + continue; + } + } + } + else if (pPlayer->HasShield() && i == PRIMARY_WEAPON_SLOT) + { + // ... + } + else + { + if (pPlayer->AddPlayerItem(pItem)) + { + pItem->AttachToPlayer(pPlayer); + bEmitSound = true; + } + + // unlink this weapon from the box + pItem = m_rgpPlayerItems[i]->m_pNext; + m_rgpPlayerItems[i] = pItem; + + continue; + } + + bRemove = false; + pItem = m_rgpPlayerItems[i]->m_pNext; + } + } + + if (bRemove) + { + // dole out ammo + for (int n = 0; n < MAX_AMMO_SLOTS; n++) + { + if (!FStringNull(m_rgiszAmmo[n])) + { + // there's some ammo of this type. + pPlayer->GiveAmmo(m_rgAmmo[n], (char *)STRING(m_rgiszAmmo[n]), MaxAmmoCarry(m_rgiszAmmo[n])); + + // now empty the ammo from the weaponbox since we just gave it to the player + m_rgiszAmmo[n] = iStringNull; + m_rgAmmo[n] = 0; + } + } + } + + if (bEmitSound) + { + EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); + } + + if (bRemove) + { + SetTouch(NULL); + UTIL_Remove(this); + } } +// CWeaponBox - PackWeapon: Add this weapon to the box + /* <1d4148> ../cstrike/dlls/weapons.cpp:1981 */ BOOL CWeaponBox::PackWeapon(CBasePlayerItem *pWeapon) { + // is one of these weapons already packed in this box? if (HasWeapon(pWeapon)) + { + // box can only hold one of each weapon type return FALSE; + } if (pWeapon->m_pPlayer) { if (pWeapon->m_pPlayer->m_pActiveItem == pWeapon) + { pWeapon->Holster(); - + } + if (!pWeapon->m_pPlayer->RemovePlayerItem(pWeapon)) + { + // failed to unhook the weapon from the player! return FALSE; + } } int iWeaponSlot = pWeapon->iItemSlot(); if (m_rgpPlayerItems[iWeaponSlot]) { + // there's already one weapon in this slot, so link this into the slot's column pWeapon->m_pNext = m_rgpPlayerItems[iWeaponSlot]; m_rgpPlayerItems[iWeaponSlot] = pWeapon; } else { + // first weapon we have for this slot m_rgpPlayerItems[iWeaponSlot] = pWeapon; pWeapon->m_pNext = NULL; } + // never respawn pWeapon->pev->spawnflags |= SF_NORESPAWN; pWeapon->pev->movetype = MOVETYPE_NONE; pWeapon->pev->solid = SOLID_NOT; @@ -1297,11 +2029,13 @@ int CWeaponBox::PackAmmo(int iszName, int iCount) { if (!iszName) { + // error here ALERT(at_console, "NULL String in PackAmmo!\n"); return FALSE; } int iMaxCarry = MaxAmmoCarry(iszName); + if (iMaxCarry != -1 && iCount > 0) { GiveAmmo(iCount, (char *)STRING(iszName), iMaxCarry); @@ -1314,18 +2048,20 @@ int CWeaponBox::PackAmmo(int iszName, int iCount) /* <1d426b> ../cstrike/dlls/weapons.cpp:2061 */ int CWeaponBox::GiveAmmo(int iCount, char *szName, int iMax, int *pIndex) { - int i = 1; - for (; i < MAX_AMMO_SLOTS && m_rgiszAmmo[i] != 0; i++) + int i; + + for (i = 1; i < MAX_AMMO_SLOTS && !FStringNull(m_rgiszAmmo[i]); i++) { if (!Q_stricmp(szName, STRING(m_rgiszAmmo[i]))) { if (pIndex) *pIndex = i; - int iAdd = _min(iCount, iMax - m_rgAmmo[i]); - if (iCount <= 0 || iAdd > 0) + int iAdd = Q_min(iCount, iMax - m_rgAmmo[i]); + if (iCount == 0 || iAdd > 0) { m_rgAmmo[i] += iAdd; + return i; } return -1; @@ -1347,103 +2083,340 @@ int CWeaponBox::GiveAmmo(int iCount, char *szName, int iMax, int *pIndex) return i; } +// CWeaponBox::HasWeapon - is a weapon of this type already +// packed in this box? + /* <1d42d5> ../cstrike/dlls/weapons.cpp:2100 */ BOOL CWeaponBox::HasWeapon(CBasePlayerItem *pCheckItem) { CBasePlayerItem *pItem = m_rgpPlayerItems[pCheckItem->iItemSlot()]; - while (pItem) + + while (pItem != NULL) { if (FClassnameIs(pItem->pev, STRING(pCheckItem->pev->classname))) + { return TRUE; + } pItem = pItem->m_pNext; } + return FALSE; } +// CWeaponBox::IsEmpty - is there anything in this box? + /* <1d4354> ../cstrike/dlls/weapons.cpp:2119 */ BOOL CWeaponBox::IsEmpty(void) { int i; + for (i = 0; i < MAX_ITEM_TYPES; i++) { if (m_rgpPlayerItems[i]) + { return FALSE; + } } for (i = 0; i < MAX_AMMO_SLOTS; i++) { if (m_rgiszAmmo[i]) + { + // still have a bit of this type of ammo return FALSE; + } } + return TRUE; } /* <1d1b7f> ../cstrike/dlls/weapons.cpp:2145 */ -NOBODY void CWeaponBox::__MAKE_VHOOK(SetObjectCollisionBox)(void) +void CWeaponBox::__MAKE_VHOOK(SetObjectCollisionBox)(void) { -// operator+(const Vector ::SetObjectCollisionBox(// const Vector &v); // 2147 -// operator+(const Vector *const this, -// const Vector &v); // 2148 + pev->absmin = pev->origin + Vector(-16, -16, 0); + pev->absmax = pev->origin + Vector(16, 16, 16); } /* <1d1d39> ../cstrike/dlls/weapons.cpp:2167 */ -NOBODY void CArmoury::Spawn(void) +void CArmoury::__MAKE_VHOOK(Spawn)(void) { -// Vector(Vector::Spawn(// float X, -// float Y, -// float Z); // 2172 -// Vector(Vector *const this, -// float X, -// float Y, -// float Z); // 2172 + Precache(); + pev->movetype = MOVETYPE_TOSS; + pev->solid = SOLID_TRIGGER; + + UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); + UTIL_SetOrigin(pev, pev->origin); + SetTouch(&CArmoury::ArmouryTouch); + + switch (m_iItem) + { + case ARMOURY_MP5NAVY: SET_MODEL(ENT(pev), "models/w_mp5.mdl"); break; + case ARMOURY_TMP: SET_MODEL(ENT(pev), "models/w_tmp.mdl"); break; + case ARMOURY_P90: SET_MODEL(ENT(pev), "models/w_p90.mdl"); break; + case ARMOURY_MAC10: SET_MODEL(ENT(pev), "models/w_mac10.mdl"); break; + case ARMOURY_AK47: SET_MODEL(ENT(pev), "models/w_ak47.mdl"); break; + case ARMOURY_SG552: SET_MODEL(ENT(pev), "models/w_sg552.mdl"); break; + case ARMOURY_M4A1: SET_MODEL(ENT(pev), "models/w_m4a1.mdl"); break; + case ARMOURY_AUG: SET_MODEL(ENT(pev), "models/w_aug.mdl"); break; + case ARMOURY_SCOUT: SET_MODEL(ENT(pev), "models/w_scout.mdl"); break; + case ARMOURY_G3SG1: SET_MODEL(ENT(pev), "models/w_g3sg1.mdl"); break; + case ARMOURY_AWP: SET_MODEL(ENT(pev), "models/w_awp.mdl"); break; + case ARMOURY_M3: SET_MODEL(ENT(pev), "models/w_m3.mdl"); break; + case ARMOURY_XM1014: SET_MODEL(ENT(pev), "models/w_xm1014.mdl"); break; + case ARMOURY_M249: SET_MODEL(ENT(pev), "models/w_m249.mdl"); break; + case ARMOURY_FLASHBANG: SET_MODEL(ENT(pev), "models/w_flashbang.mdl"); break; + case ARMOURY_HEGRENADE: SET_MODEL(ENT(pev), "models/w_hegrenade.mdl"); break; + case ARMOURY_KEVLAR: SET_MODEL(ENT(pev), "models/w_kevlar.mdl"); break; + case ARMOURY_ASSAULT: SET_MODEL(ENT(pev), "models/w_assault.mdl"); break; + case ARMOURY_SMOKEGRENADE: SET_MODEL(ENT(pev), "models/w_smokegrenade.mdl"); break; + default: SET_MODEL(ENT(pev), "models/w_kevlar.mdl"); break; + } + + if (m_iCount <= 0) + { + m_iCount = 1; + } + + m_bAlreadyCounted = false; + m_iInitialCount = m_iCount; } /* <1d1bfb> ../cstrike/dlls/weapons.cpp:2207 */ -NOBODY void CArmoury::Restart(void) +void CArmoury::__MAKE_VHOOK(Restart)(void) { -// { -// class CHalfLifeMultiplay *mp; // 2209 -// { -// float flRatio; // 2257 -// } -// { -// float flRatio; // 2239 -// } -// { -// float flRatio; // 2221 -// } -// } + CHalfLifeMultiplay *mp = g_pGameRules; + + if (m_iItem == ARMOURY_FLASHBANG || m_iItem == ARMOURY_HEGRENADE) + { + if (!m_bAlreadyCounted) + { + m_bAlreadyCounted = true; + mp->m_iTotalGrenadeCount += m_iInitialCount; + m_iCount = m_iInitialCount; + pev->effects &= ~EF_NODRAW; + return; + } + + float flRatio = (float_precision)(m_iInitialCount / mp->m_iTotalGrenadeCount) * (float_precision)mp->m_iNumTerrorist * 1.75; + m_iCount = (int)flRatio; + } + else if (m_iItem == ARMOURY_KEVLAR || m_iItem == ARMOURY_ASSAULT) + { + if (!m_bAlreadyCounted) + { + m_bAlreadyCounted = true; + mp->m_iTotalArmourCount += m_iInitialCount; + m_iCount = m_iInitialCount; + pev->effects &= ~EF_NODRAW; + return; + } + + float flRatio = (float_precision)(m_iInitialCount / mp->m_iTotalArmourCount) * (float_precision)mp->m_iNumTerrorist; + m_iCount = (int)flRatio; + } + else + { + if (!m_bAlreadyCounted) + { + m_bAlreadyCounted = true; + mp->m_iTotalGunCount += m_iInitialCount; + m_iCount = m_iInitialCount; + pev->effects &= ~EF_NODRAW; + return; + } + + float flRatio = (float_precision)(m_iInitialCount / mp->m_iTotalGunCount) * (float_precision)mp->m_iNumTerrorist * 0.85; + m_iCount = (int)flRatio; + } + + if (m_iCount < 1) + { + m_iCount = 1; + } + + pev->effects &= ~EF_NODRAW; } /* <1d1ee9> ../cstrike/dlls/weapons.cpp:2268 */ -NOBODY void CArmoury::Precache(void) +void CArmoury::__MAKE_VHOOK(Precache)(void) { -// Precache(CArmoury *const this); // 2268 + switch (m_iItem) + { + case ARMOURY_MP5NAVY: PRECACHE_MODEL("models/w_mp5.mdl"); break; + case ARMOURY_TMP: PRECACHE_MODEL("models/w_tmp.mdl"); break; + case ARMOURY_P90: PRECACHE_MODEL("models/w_p90.mdl"); break; + case ARMOURY_MAC10: PRECACHE_MODEL("models/w_mac10.mdl"); break; + case ARMOURY_AK47: PRECACHE_MODEL("models/w_ak47.mdl"); break; + case ARMOURY_SG552: PRECACHE_MODEL("models/w_sg552.mdl"); break; + case ARMOURY_M4A1: PRECACHE_MODEL("models/w_m4a1.mdl"); break; + case ARMOURY_AUG: PRECACHE_MODEL("models/w_aug.mdl"); break; + case ARMOURY_SCOUT: PRECACHE_MODEL("models/w_scout.mdl"); break; + case ARMOURY_G3SG1: PRECACHE_MODEL("models/w_g3sg1.mdl"); break; + case ARMOURY_AWP: PRECACHE_MODEL("models/w_awp.mdl"); break; + case ARMOURY_M3: PRECACHE_MODEL("models/w_m3.mdl"); break; + case ARMOURY_XM1014: PRECACHE_MODEL("models/w_xm1014.mdl"); break; + case ARMOURY_M249: PRECACHE_MODEL("models/w_m249.mdl"); break; + case ARMOURY_FLASHBANG: PRECACHE_MODEL("models/w_flashbang.mdl"); break; + case ARMOURY_HEGRENADE: PRECACHE_MODEL("models/w_hegrenade.mdl"); break; + case ARMOURY_KEVLAR: PRECACHE_MODEL("models/w_kevlar.mdl"); break; + case ARMOURY_ASSAULT: PRECACHE_MODEL("models/w_assault.mdl"); break; + case ARMOURY_SMOKEGRENADE: PRECACHE_MODEL("models/w_smokegrenade.mdl"); break; + default: PRECACHE_MODEL("models/w_kevlar.mdl"); break; + } } /* <1d1f2f> ../cstrike/dlls/weapons.cpp:2294 */ -NOBODY void CArmoury::ArmouryTouch(CBaseEntity *pOther) +void CArmoury::ArmouryTouch(CBaseEntity *pOther) { -// { -// class CBasePlayer *p; // 2299 -// } -// ArmouryTouch(CArmoury *const this, -// class CBaseEntity *pOther); // 2294 + if (!pOther->IsPlayer()) + return; + + CBasePlayer *p = reinterpret_cast(pOther); + + if (p->m_bIsVIP) + return; + + if (m_iCount > 0 && m_iItem <= ARMOURY_M249) + { + if (p->m_bHasPrimary) + return; + + m_iCount--; + + switch (m_iItem) + { + case ARMOURY_MP5NAVY: + p->GiveNamedItem("weapon_mp5navy"); + p->GiveAmmo(60, "9mm", MAX_AMMO_9MM); + break; + case ARMOURY_TMP: + p->GiveNamedItem("weapon_tmp"); + p->GiveAmmo(60, "9mm", MAX_AMMO_9MM); + break; + case ARMOURY_P90: + p->GiveNamedItem("weapon_p90"); + p->GiveAmmo(50, "57mm", MAX_AMMO_57MM); + break; + case ARMOURY_MAC10: + p->GiveNamedItem("weapon_mac10"); + p->GiveAmmo(60, "45acp", MAX_AMMO_45ACP); + break; + case ARMOURY_AK47: + p->GiveNamedItem("weapon_ak47"); + p->GiveAmmo(60, "762Nato", MAX_AMMO_762NATO); + break; + case ARMOURY_SG552: + p->GiveNamedItem("weapon_sg552"); + p->GiveAmmo(60, "556Nato", MAX_AMMO_556NATO); + break; + case ARMOURY_M4A1: + p->GiveNamedItem("weapon_m4a1"); + p->GiveAmmo(60, "556Nato", MAX_AMMO_556NATO); + break; + case ARMOURY_AUG: + p->GiveNamedItem("weapon_aug"); + p->GiveAmmo(60, "556Nato", MAX_AMMO_556NATO); + break; + case ARMOURY_SCOUT: + p->GiveNamedItem("weapon_scout"); + p->GiveAmmo(30, "762Nato", MAX_AMMO_762NATO); + break; + case ARMOURY_G3SG1: + p->GiveNamedItem("weapon_g3sg1"); + p->GiveAmmo(30, "762Nato", MAX_AMMO_762NATO); + break; + case ARMOURY_AWP: + p->GiveNamedItem("weapon_awp"); + p->GiveAmmo(20, "338Magnum", MAX_AMMO_338MAGNUM); + break; + case ARMOURY_M3: + p->GiveNamedItem("weapon_m3"); + p->GiveAmmo(24, "buckshot", MAX_AMMO_BUCKSHOT); + break; + case ARMOURY_XM1014: + p->GiveNamedItem("weapon_xm1014"); + p->GiveAmmo(24, "buckshot", MAX_AMMO_BUCKSHOT); + break; + case ARMOURY_M249: + p->GiveNamedItem("weapon_m249"); + p->GiveAmmo(60, "556NatoBox", MAX_AMMO_556NATOBOX); + break; + } + } + else if (m_iCount > 0 && m_iItem >= ARMOURY_FLASHBANG) + { + switch (m_iItem) + { + case ARMOURY_FLASHBANG: + { + if (p->AmmoInventory(p->GetAmmoIndex("Flashbang")) >= 2) + return; + + p->GiveNamedItem("weapon_flashbang"); + m_iCount--; + break; + } + case ARMOURY_HEGRENADE: + { + if (p->AmmoInventory(p->GetAmmoIndex("HEGrenade")) >= 1) + return; + + p->GiveNamedItem("weapon_hegrenade"); + m_iCount--; + break; + } + case ARMOURY_KEVLAR: + { + if (p->m_iKevlar == ARMOR_TYPE_KEVLAR) + return; + + p->GiveNamedItem("item_kevlar"); + m_iCount--; + break; + } + case ARMOURY_ASSAULT: + { + if (p->m_iKevlar == ARMOR_TYPE_HELMET) + return; + + p->GiveNamedItem("item_assaultsuit"); + m_iCount--; + break; + } + case ARMOURY_SMOKEGRENADE: + { + if (p->AmmoInventory(p->GetAmmoIndex("SmokeGrenade")) >= 1) + return; + + p->GiveNamedItem("weapon_smokegrenade"); + m_iCount--; + break; + } + } + } + + if (!m_iCount) + { + pev->effects |= EF_NODRAW; + } } /* <1d21bd> ../cstrike/dlls/weapons.cpp:2352 */ -NOBODY void CArmoury::KeyValue(KeyValueData *pkvd) +void CArmoury::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { -// FStrEq(const char *sz1, -// const char *sz2); // 2354 -// FStrEq(const char *sz1, -// const char *sz2); // 2359 -// KeyValue(CBaseEntity *const this, -// KeyValueData *pkvd); // 2364 -// atoi(const char *__nptr); // 2356 -// KeyValue(CArmoury *const this, -// KeyValueData *pkvd); // 2352 + if (FStrEq(pkvd->szKeyName, "item")) + { + m_iItem = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "count")) + { + m_iCount = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseEntity::KeyValue(pkvd); } /* <1d4392> ../cstrike/dlls/weapons.cpp:2368 */ @@ -1451,6 +2424,26 @@ LINK_ENTITY_TO_CLASS(armoury_entity, CArmoury); #ifdef HOOK_GAMEDLL +void CArmoury::Spawn(void) +{ + Spawn_(); +} + +void CArmoury::Precache(void) +{ + Precache_(); +} + +void CArmoury::Restart(void) +{ + Restart_(); +} + +void CArmoury::KeyValue(KeyValueData *pkvd) +{ + KeyValue_(pkvd); +} + void CBasePlayerAmmo::Spawn(void) { Spawn_(); diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index bc953383..e8a3258a 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -37,7 +37,7 @@ class CBasePlayer; #define MAX_WEAPONS 32 -#define MAX_NORMAL_BATTERY 100 +#define MAX_NORMAL_BATTERY 100.0f #define ITEM_FLAG_SELECTONEMPTY 1 #define ITEM_FLAG_NOAUTORELOAD 2 @@ -71,6 +71,30 @@ class CBasePlayer; // spawn flags #define SF_DETONATE 0x0001 // Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges +// custom enum +enum ArmouryItemPack +{ + ARMOURY_MP5NAVY, + ARMOURY_TMP, + ARMOURY_P90, + ARMOURY_MAC10, + ARMOURY_AK47, + ARMOURY_SG552, + ARMOURY_M4A1, + ARMOURY_AUG, + ARMOURY_SCOUT, + ARMOURY_G3SG1, + ARMOURY_AWP, + ARMOURY_M3, + ARMOURY_XM1014, + ARMOURY_M249, + ARMOURY_FLASHBANG, + ARMOURY_HEGRENADE, + ARMOURY_KEVLAR, + ARMOURY_ASSAULT, + ARMOURY_SMOKEGRENADE, +}; + typedef struct { WeaponType type; @@ -118,17 +142,28 @@ typedef struct class CArmoury: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void Restart(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); + virtual void Spawn(void); + virtual void Precache(void); + virtual void Restart(void); + virtual void KeyValue(KeyValueData *pkvd); + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Precache_(void); + void Restart_(void); + void KeyValue_(KeyValueData *pkvd); + +#endif // HOOK_GAMEDLL + public: - NOBODY void EXPORT ArmouryTouch(CBaseEntity *pOther); + void EXPORT ArmouryTouch(CBaseEntity *pOther); public: int m_iItem; int m_iCount; int m_iInitialCount; bool m_bAlreadyCounted; + };/* size: 168, cachelines: 3, members: 5 */ /* <14ed46> ../cstrike/dlls/weapons.h:56 */ @@ -252,11 +287,11 @@ public: class CBasePlayerItem: public CBaseAnimating { public: - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void SetObjectCollisionBox(void); - NOBODY virtual CBaseEntity *Respawn(void); - NOXREF virtual int AddToPlayer(CBasePlayer *pPlayer); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void SetObjectCollisionBox(void); + virtual CBaseEntity *Respawn(void); + virtual int AddToPlayer(CBasePlayer *pPlayer); virtual int AddDuplicate(CBasePlayerItem *pItem) { return FALSE; @@ -294,7 +329,7 @@ public: virtual void Drop(void); virtual void Kill(void); - NOBODY virtual void AttachToPlayer(CBasePlayer *pPlayer); + virtual void AttachToPlayer(CBasePlayer *pPlayer); virtual int PrimaryAmmoIndex(void) { return -1; @@ -351,11 +386,11 @@ public: #endif // HOOK_GAMEDLL public: - NOBODY void EXPORT DestroyItem(void); + void EXPORT DestroyItem(void); void EXPORT DefaultTouch(CBaseEntity *pOther); void EXPORT FallThink(void); void EXPORT Materialize(void); - NOBODY void EXPORT AttemptToMaterialize(void); + void EXPORT AttemptToMaterialize(void); void FallInit(void); void CheckRespawn(void); @@ -412,21 +447,21 @@ public: class CBasePlayerWeapon: public CBasePlayerItem { public: - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); virtual int AddToPlayer(CBasePlayer *pPlayer); virtual int AddDuplicate(CBasePlayerItem *pItem); - NOBODY virtual BOOL CanDeploy(void); + virtual BOOL CanDeploy(void); virtual BOOL IsWeapon(void) { return TRUE; } - NOBODY virtual void Holster(int skiplocal = 0); + virtual void Holster(int skiplocal = 0); virtual void UpdateItemInfo(void) {}; - NOBODY virtual void ItemPostFrame(void); - NOBODY virtual int PrimaryAmmoIndex(void); - NOBODY virtual int SecondaryAmmoIndex(void); + virtual void ItemPostFrame(void); + virtual int PrimaryAmmoIndex(void); + virtual int SecondaryAmmoIndex(void); virtual int UpdateClientData(CBasePlayer *pPlayer); virtual CBasePlayerItem *GetWeaponPtr(void) { @@ -441,13 +476,13 @@ public: } virtual BOOL PlayEmptySound(void); virtual void ResetEmptySound(void); - virtual void SendWeaponAnim(int iAnim,int skiplocal = 0); - NOBODY virtual BOOL IsUseable(void); - virtual void PrimaryAttack(void) {} - virtual void SecondaryAttack(void) {} - virtual void Reload(void) {} - virtual void WeaponIdle(void) {} - NOBODY virtual void RetireWeapon(void); + virtual void SendWeaponAnim(int iAnim, int skiplocal = 0); + virtual BOOL IsUseable(void); + virtual void PrimaryAttack(void) {}; + virtual void SecondaryAttack(void) {}; + virtual void Reload(void) {}; + virtual void WeaponIdle(void) {}; + virtual void RetireWeapon(void); virtual BOOL ShouldWeaponIdle(void) { return FALSE; @@ -473,26 +508,26 @@ public: int ExtractClipAmmo_(CBasePlayerWeapon *pWeapon); BOOL PlayEmptySound_(void); void ResetEmptySound_(void); - void SendWeaponAnim_(int iAnim,int skiplocal = 0); + void SendWeaponAnim_(int iAnim, int skiplocal = 0); BOOL IsUseable_(void); void RetireWeapon_(void); #endif // HOOK_GAMEDLL public: - BOOL AddPrimaryAmmo(int iCount,char *szName,int iMaxClip,int iMaxCarry); - NOXREF BOOL AddSecondaryAmmo(int iCount,char *szName,int iMaxCarry); - BOOL DefaultDeploy(char *szViewModel,char *szWeaponModel,int iAnim,char *szAnimExt,int skiplocal = 0); - int DefaultReload(int iClipSize,int iAnim,float fDelay); - NOBODY void FireRemaining(int &shotsFired,float &shootTime,BOOL isGlock18); - NOBODY void KickBack(float up_base,float lateral_base,float up_modifier,float lateral_modifier,float up_max,float lateral_max,int direction_change); - NOBODY void EjectBrassLate(void); - NOBODY void MakeBeam(void); - NOBODY void BeamUpdate(void); + BOOL AddPrimaryAmmo(int iCount, char *szName, int iMaxClip, int iMaxCarry); + BOOL AddSecondaryAmmo(int iCount, char *szName, int iMaxCarry); + BOOL DefaultDeploy(char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0); + int DefaultReload(int iClipSize, int iAnim, float fDelay); + void FireRemaining(int &shotsFired, float &shootTime, BOOL isGlock18); + void KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change); + void EjectBrassLate(void); + NOXREF void MakeBeam(void); + NOXREF void BeamUpdate(void); void ReloadSound(void); float GetNextAttackDelay(float delay); float GetNextAttackDelay2(float delay); - NOBODY bool HasSecondaryAttack(void); + bool HasSecondaryAttack(void); BOOL IsPistol(void) { return FALSE; @@ -502,7 +537,6 @@ public: bool ShieldSecondaryFire(int iUpAnim,int iDownAnim); public: - static TYPEDESCRIPTION IMPLEMENT_ARRAY(m_SaveData)[7]; int m_iPlayEmptySound; @@ -553,30 +587,29 @@ public: return TRUE; } virtual CBaseEntity *Respawn(void); + +#ifdef HOOK_GAMEDLL + void Spawn_(void); + CBaseEntity *Respawn_(void); +#endif // HOOK_GAMEDLL + public: void EXPORT DefaultTouch(CBaseEntity *pOther); void EXPORT Materialize(void); -#ifdef HOOK_GAMEDLL -public: - void Spawn_(void); - //NOBODY BOOL AddAmmo_(CBaseEntity *pOther); - CBaseEntity *Respawn_(void); -#endif // HOOK_GAMEDLL - };/* size: 152, cachelines: 3, members: 1 */ /* <1d03c1> ../cstrike/dlls/weapons.h:508 */ class CWeaponBox: public CBaseEntity { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual void KeyValue(KeyValueData *pkvd); - NOBODY virtual int Save(CSave &save); - NOBODY virtual int Restore(CRestore &restore); - NOBODY virtual void SetObjectCollisionBox(void); - NOBODY virtual void Touch(CBaseEntity *pOther); + virtual void Spawn(void); + virtual void Precache(void); + virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual void SetObjectCollisionBox(void); + virtual void Touch(CBaseEntity *pOther); #ifdef HOOK_GAMEDLL @@ -617,7 +650,7 @@ class CUSP: public CBasePlayerWeapon { public: virtual void Spawn(void); - NOBODY virtual void Precache(void); + virtual void Precache(void); virtual int GetItemInfo(ItemInfo *p); virtual BOOL Deploy(void); virtual float GetMaxSpeed(void) @@ -628,8 +661,8 @@ public: { return PISTOL_SLOT; } - NOBODY virtual void PrimaryAttack(void); - NOBODY virtual void SecondaryAttack(void); + virtual void PrimaryAttack(void); + virtual void SecondaryAttack(void); virtual void Reload(void); virtual void WeaponIdle(void); virtual BOOL UseDecrement(void) @@ -640,9 +673,22 @@ public: { return TRUE; } + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Precache_(void); + int GetItemInfo_(ItemInfo *p); + BOOL Deploy_(void); + void PrimaryAttack_(void); + void SecondaryAttack_(void); + void Reload_(void); + void WeaponIdle_(void); + +#endif // HOOK_GAMEDLL + public: - //TOOD: this func changed access to private?! - UNTESTED void USPFire(float flSpread,float flCycleTime,BOOL fUseSemi); + void USPFire(float flSpread,float flCycleTime,BOOL fUseSemi); NOXREF void MakeBeam(void); NOXREF void BeamUpdate(void); public: @@ -650,34 +696,6 @@ public: private: unsigned short m_usFireUSP; -#ifdef HOOK_GAMEDLL -public: - void Spawn_(void); - void Precache_(void); - int GetItemInfo_(ItemInfo *p); - BOOL Deploy_(void); - float GetMaxSpeed_(void) - { - return m_fMaxSpeed; - } - int iItemSlot_(void) - { - return PISTOL_SLOT; - } - NOBODY void PrimaryAttack_(void); - NOBODY void SecondaryAttack_(void); - void Reload_(void); - void WeaponIdle_(void); - BOOL UseDecrement_(void) - { - return TRUE; - } - BOOL IsPistol_(void) - { - return TRUE; - } -#endif // HOOK_GAMEDLL - };/* size: 344, cachelines: 6, members: 3 */ /* <28adc9> ../cstrike/dlls/weapons.h:599 */ @@ -710,6 +728,7 @@ public: int iShellOn; private: unsigned short m_usFireMP5N; + };/* size: 348, cachelines: 6, members: 4 */ /* <2a553c> ../cstrike/dlls/weapons.h:624 */ @@ -766,6 +785,19 @@ public: { return TRUE; } +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Precache_(void); + int GetItemInfo_(ItemInfo *p); + BOOL Deploy_(void); + void PrimaryAttack_(void); + void SecondaryAttack_(void); + void Reload_(void); + void WeaponIdle_(void); + +#endif // HOOK_GAMEDLL + public: NOBODY void AK47Fire(float flSpread,float flCycleTime,BOOL fUseAutoAim); @@ -813,29 +845,59 @@ private: class CAWP: public CBasePlayerWeapon { public: - NOBODY virtual void Spawn(void); - NOBODY virtual void Precache(void); - NOBODY virtual int GetItemInfo(ItemInfo *p); - NOBODY virtual BOOL Deploy(void); - NOBODY virtual float GetMaxSpeed(void); + virtual void Spawn(void); + virtual void Precache(void); + virtual int GetItemInfo(ItemInfo *p); + virtual BOOL Deploy(void); + virtual float GetMaxSpeed(void); virtual int iItemSlot(void) { return PRIMARY_WEAPON_SLOT; } - NOBODY virtual void PrimaryAttack(void); - NOBODY virtual void SecondaryAttack(void); - NOBODY virtual void Reload(void); - NOBODY virtual void WeaponIdle(void); + virtual void PrimaryAttack(void); + virtual void SecondaryAttack(void); + virtual void Reload(void); + virtual void WeaponIdle(void); virtual BOOL UseDecrement(void) + { + #ifdef CLIENT_WEAPONS + return TRUE; + #else + return FALSE; + #endif + } + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Precache_(void); + int GetItemInfo_(ItemInfo *p); + BOOL Deploy_(void); + float GetMaxSpeed_(void); + int iItemSlot_(void) + { + return PRIMARY_WEAPON_SLOT; + } + void PrimaryAttack_(void); + void SecondaryAttack_(void); + void Reload_(void); + void WeaponIdle_(void); + BOOL UseDecrement_(void) { return TRUE; } + +#endif // HOOK_GAMEDLL + public: - NOBODY void AWPFire(float flSpread,float flCycleTime,BOOL fUseAutoAim); + void AWPFire(float flSpread,float flCycleTime,BOOL fUseAutoAim); + public: int m_iShell; + private: unsigned short m_usFireAWP; + };/* size: 344, cachelines: 6, members: 3 */ /* <245949> ../cstrike/dlls/weapons.h:721 */ @@ -1260,10 +1322,7 @@ public: NOBODY virtual void Precache(void); NOBODY virtual int GetItemInfo(ItemInfo *p); NOBODY virtual BOOL Deploy(void); - virtual float GetMaxSpeed(void) - { - return 245.0f; - } + virtual float GetMaxSpeed(void); virtual int iItemSlot(void) { return PRIMARY_WEAPON_SLOT; @@ -1275,6 +1334,20 @@ public: { return TRUE; } + +#ifdef HOOK_GAMEDLL + + void Spawn_(void); + void Precache_(void); + int GetItemInfo_(ItemInfo *p); + BOOL Deploy_(void); + float GetMaxSpeed_(void); + void PrimaryAttack_(void); + void Reload_(void); + void WeaponIdle_(void); + +#endif // HOOK_GAMEDLL + public: NOBODY void P90Fire(float flSpread,float flCycleTime,BOOL fUseAutoAim); public: @@ -1307,10 +1380,13 @@ public: } public: NOBODY void SCOUTFire(float flSpread,float flCycleTime,BOOL fUseAutoAim); + public: int m_iShell; + private: unsigned short m_usFireScout; + };/* size: 344, cachelines: 6, members: 3 */ /* <2aa3d5> ../cstrike/dlls/weapons.h:1089 */ @@ -1666,16 +1742,21 @@ void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker); void AddMultiDamage(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType); void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage); NOXREF int DamageDecal(CBaseEntity *pEntity, int bitsDamageType); -NOXREF void DecalGunshot(TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars_t *pShooter, bool bHitMetal); -NOBODY void EjectBrass(Vector &vecOrigin, Vector &vecLeft, Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex); -NOBODY void EjectBrass2(Vector &vecOrigin, Vector &vecVelocity, float rotation, int model, int soundtype, entvars_t *pev); -NOXREF void AddAmmoNameToAmmoRegistry(const char *szAmmoname); +void DecalGunshot(TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars_t *pShooter, bool bHitMetal); +void EjectBrass(const Vector &vecOrigin, const Vector &vecLeft, const Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex); +NOXREF void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype, entvars_t *pev); +void AddAmmoNameToAmmoRegistry(const char *szAmmoname); void UTIL_PrecacheOtherWeapon(const char *szClassname); NOXREF void UTIL_PrecacheOtherWeapon2(const char *szClassname); void W_Precache(void); -NOXREF BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted); +BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted); // linked object +C_DLLEXPORT void weapon_knife(entvars_t *pev); C_DLLEXPORT void weapon_usp(entvars_t *pev); +C_DLLEXPORT void weapon_awp(entvars_t *pev); +C_DLLEXPORT void armoury_entity(entvars_t *pev); +C_DLLEXPORT void weaponbox(entvars_t *pev); +C_DLLEXPORT void weapon_p90(entvars_t *pev); #endif // WEAPONS_H diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp index f1d0bf70..b6f0c886 100644 --- a/regamedll/dlls/weapontype.cpp +++ b/regamedll/dlls/weapontype.cpp @@ -237,6 +237,7 @@ WeaponIdType AliasToWeaponID(const char *alias) return weaponAliasInfo[i].id; } } + return WEAPON_NONE; } @@ -254,6 +255,7 @@ const char *BuyAliasToWeaponID(const char *alias, WeaponIdType &id) } } } + id = WEAPON_NONE; return NULL; } @@ -266,6 +268,7 @@ const char *WeaponIDToAlias(int id) if (weaponAliasInfo[i].id == id) return weaponAliasInfo[i].alias; } + return NULL; } @@ -280,13 +283,14 @@ WeaponClassType AliasToWeaponClass(const char *alias) return weaponClassAliasInfo[i].id; } } + return WEAPONCLASS_NONE; } /* <22ce5a> ../cstrike/dlls/weapontype.cpp:276 */ WeaponClassType WeaponIDToWeaponClass(int id) { - return AliasToWeaponClass( WeaponIDToAlias(id) ); + return AliasToWeaponClass(WeaponIDToAlias(id)); } /* <22cee3> ../cstrike/dlls/weapontype.cpp:285 */ @@ -313,19 +317,18 @@ bool IsPrimaryWeapon(int id) case WEAPON_AK47: case WEAPON_P90: case WEAPON_SHIELDGUN: - { return true; - } default: break; } + return false; } /* <22cf19> ../cstrike/dlls/weapontype.cpp:318 */ NOXREF bool IsSecondaryWeapon(int id) { - switch(id) + switch (id) { case WEAPON_P228: case WEAPON_ELITE: @@ -337,6 +340,7 @@ NOXREF bool IsSecondaryWeapon(int id) default: break; } + return false; } @@ -348,6 +352,7 @@ WeaponInfoStruct *GetWeaponInfo(int weaponID) if (weaponInfo[i].id == weaponID) return &weaponInfo[i]; } + return NULL; } @@ -474,5 +479,6 @@ bool CanBuyWeaponByMaptype(int playerTeam, WeaponIdType weaponID, bool useAssasi } } } + return false; } diff --git a/regamedll/dlls/weapontype.h b/regamedll/dlls/weapontype.h index c83ed276..c3a729a3 100644 --- a/regamedll/dlls/weapontype.h +++ b/regamedll/dlls/weapontype.h @@ -138,6 +138,41 @@ enum WeaponState WPNSTATE_SHIELD_DRAWN = (1 << 5), }; +// custom enum +// the default amount of ammo that comes with each gun when it spawns +enum ClipGiveDefault +{ + P228_DEFAULT_GIVE = 13, + GLOCK18_DEFAULT_GIVE = 20, + SCOUT_DEFAULT_GIVE = 10, + HEGRENADE_DEFAULT_GIVE = 1, + XM1014_DEFAULT_GIVE = 7, + C4_DEFAULT_GIVE = 1, + MAC10_DEFAULT_GIVE = 30, + AUG_DEFAULT_GIVE = 30, + SMOKEGRENADE_DEFAULT_GIVE = 1, + ELITE_DEFAULT_GIVE = 30, + FIVESEVEN_DEFAULT_GIVE = 20, + UMP45_DEFAULT_GIVE = 25, + SG550_DEFAULT_GIVE = 30, + GALIL_DEFAULT_GIVE = 35, + FAMAS_DEFAULT_GIVE = 25, + USP_DEFAULT_GIVE = 12, + AWP_DEFAULT_GIVE = 10, + MP5N_DEFAULT_GIVE = 30, + M249_DEFAULT_GIVE = 100, + M3_DEFAULT_GIVE = 8, + M4A1_DEFAULT_GIVE = 30, + TMP_DEFAULT_GIVE = 30, + G3SG1_DEFAULT_GIVE = 20, + FLASHBANG_DEFAULT_GIVE = 1, + DEAGLE_DEFAULT_GIVE = 7, + SG552_DEFAULT_GIVE = 30, + AK47_DEFAULT_GIVE = 30, + /*KNIFE_DEFAULT_GIVE = 1,*/ + P90_DEFAULT_GIVE = 50, +}; + enum ClipSizeType { P228_MAX_CLIP = 13, @@ -166,6 +201,39 @@ enum ClipSizeType P90_MAX_CLIP = 50, }; +enum WeightWeapon +{ + P228_WEIGHT = 5, + GLOCK18_WEIGHT = 5, + SCOUT_WEIGHT = 20, + HEGRENADE_WEIGHT = 1, + XM1014_WEIGHT = 20, + C4_WEIGHT = 3, + MAC10_WEIGHT = 25, + AUG_WEIGHT = 25, + SMOKEGRENADE_WEIGHT = 1, + ELITE_WEIGHT = 5, + FIVESEVEN_WEIGHT = 5, + UMP45_WEIGHT = 25, + SG550_WEIGHT = 20, + GALIL_WEIGHT = 25, + FAMAS_WEIGHT = 75,// + USP_WEIGHT = 5,// + AWP_WEIGHT = 30,// + MP5N_WEIGHT = 25, + M249_WEIGHT = 25, + M3_WEIGHT = 20, + M4A1_WEIGHT = 25, + TMP_WEIGHT = 30, + G3SG1_WEIGHT = 20, + FLASHBANG_WEIGHT = 1, + DEAGLE_WEIGHT = 7, + SG552_WEIGHT = 25, + AK47_WEIGHT = 25, + P90_WEIGHT = 26,// + KNIFE_WEIGHT = 0, +}; + enum MaxAmmoType { MAX_AMMO_BUCKSHOT = 32, diff --git a/regamedll/dlls/world.cpp b/regamedll/dlls/world.cpp index 1cda0090..1b0c532d 100644 --- a/regamedll/dlls/world.cpp +++ b/regamedll/dlls/world.cpp @@ -1,10 +1,10 @@ #include "precompiled.h" -#define SF_WORLD_DARK 0x0001 // Fade from black at startup -#define SF_WORLD_TITLE 0x0002 // Display game title at startup +#define SF_WORLD_DARK 0x0001 // Fade from black at startup +#define SF_WORLD_TITLE 0x0002 // Display game title at startup #define SF_WORLD_FORCETEAM 0x0004 // Force teams -edict_t *g_pBodyQueueHead; +edict_t *g_pBodyQueueHead; CGlobalState gGlobalState; float g_flWeaponCheat; @@ -13,50 +13,50 @@ float g_flWeaponCheat; */ #ifndef HOOK_GAMEDLL -DLL_DECALLIST gDecals[] = -{ - { "{shot1", 0 }, // DECAL_GUNSHOT1 - { "{shot2", 0 }, // DECAL_GUNSHOT2 - { "{shot3", 0 }, // DECAL_GUNSHOT3 - { "{shot4", 0 }, // DECAL_GUNSHOT4 - { "{shot5", 0 }, // DECAL_GUNSHOT5 - { "{lambda01", 0 }, // DECAL_LAMBDA1 - { "{lambda02", 0 }, // DECAL_LAMBDA2 - { "{lambda03", 0 }, // DECAL_LAMBDA3 - { "{lambda04", 0 }, // DECAL_LAMBDA4 - { "{lambda05", 0 }, // DECAL_LAMBDA5 - { "{lambda06", 0 }, // DECAL_LAMBDA6 - { "{scorch1", 0 }, // DECAL_SCORCH1 - { "{scorch2", 0 }, // DECAL_SCORCH2 - { "{blood1", 0 }, // DECAL_BLOOD1 - { "{blood2", 0 }, // DECAL_BLOOD2 - { "{blood3", 0 }, // DECAL_BLOOD3 - { "{blood4", 0 }, // DECAL_BLOOD4 - { "{blood5", 0 }, // DECAL_BLOOD5 - { "{blood6", 0 }, // DECAL_BLOOD6 - { "{yblood1", 0 }, // DECAL_YBLOOD1 - { "{yblood2", 0 }, // DECAL_YBLOOD2 - { "{yblood3", 0 }, // DECAL_YBLOOD3 - { "{yblood4", 0 }, // DECAL_YBLOOD4 - { "{yblood5", 0 }, // DECAL_YBLOOD5 - { "{yblood6", 0 }, // DECAL_YBLOOD6 - { "{break1", 0 }, // DECAL_GLASSBREAK1 - { "{break2", 0 }, // DECAL_GLASSBREAK2 - { "{break3", 0 }, // DECAL_GLASSBREAK3 - { "{bigshot1", 0 }, // DECAL_BIGSHOT1 - { "{bigshot2", 0 }, // DECAL_BIGSHOT2 - { "{bigshot3", 0 }, // DECAL_BIGSHOT3 - { "{bigshot4", 0 }, // DECAL_BIGSHOT4 - { "{bigshot5", 0 }, // DECAL_BIGSHOT5 - { "{spit1", 0 }, // DECAL_SPIT1 - { "{spit2", 0 }, // DECAL_SPIT2 - { "{bproof1", 0 }, // DECAL_BPROOF1 - { "{gargstomp", 0 }, // DECAL_GARGSTOMP1, // Gargantua stomp crack - { "{smscorch1", 0 }, // DECAL_SMALLSCORCH1, // Small scorch mark - { "{smscorch2", 0 }, // DECAL_SMALLSCORCH2, // Small scorch mark - { "{smscorch3", 0 }, // DECAL_SMALLSCORCH3, // Small scorch mark - { "{mommablob", 0 }, // DECAL_MOMMABIRTH // BM Birth spray - { "{mommablob", 0 }, // DECAL_MOMMASPLAT // BM Mortar spray?? need decal*/ +DLL_DECALLIST gDecals[] = +{ + { "{shot1", 0 }, // DECAL_GUNSHOT1 + { "{shot2", 0 }, // DECAL_GUNSHOT2 + { "{shot3", 0 }, // DECAL_GUNSHOT3 + { "{shot4", 0 }, // DECAL_GUNSHOT4 + { "{shot5", 0 }, // DECAL_GUNSHOT5 + { "{lambda01", 0 }, // DECAL_LAMBDA1 + { "{lambda02", 0 }, // DECAL_LAMBDA2 + { "{lambda03", 0 }, // DECAL_LAMBDA3 + { "{lambda04", 0 }, // DECAL_LAMBDA4 + { "{lambda05", 0 }, // DECAL_LAMBDA5 + { "{lambda06", 0 }, // DECAL_LAMBDA6 + { "{scorch1", 0 }, // DECAL_SCORCH1 + { "{scorch2", 0 }, // DECAL_SCORCH2 + { "{blood1", 0 }, // DECAL_BLOOD1 + { "{blood2", 0 }, // DECAL_BLOOD2 + { "{blood3", 0 }, // DECAL_BLOOD3 + { "{blood4", 0 }, // DECAL_BLOOD4 + { "{blood5", 0 }, // DECAL_BLOOD5 + { "{blood6", 0 }, // DECAL_BLOOD6 + { "{yblood1", 0 }, // DECAL_YBLOOD1 + { "{yblood2", 0 }, // DECAL_YBLOOD2 + { "{yblood3", 0 }, // DECAL_YBLOOD3 + { "{yblood4", 0 }, // DECAL_YBLOOD4 + { "{yblood5", 0 }, // DECAL_YBLOOD5 + { "{yblood6", 0 }, // DECAL_YBLOOD6 + { "{break1", 0 }, // DECAL_GLASSBREAK1 + { "{break2", 0 }, // DECAL_GLASSBREAK2 + { "{break3", 0 }, // DECAL_GLASSBREAK3 + { "{bigshot1", 0 }, // DECAL_BIGSHOT1 + { "{bigshot2", 0 }, // DECAL_BIGSHOT2 + { "{bigshot3", 0 }, // DECAL_BIGSHOT3 + { "{bigshot4", 0 }, // DECAL_BIGSHOT4 + { "{bigshot5", 0 }, // DECAL_BIGSHOT5 + { "{spit1", 0 }, // DECAL_SPIT1 + { "{spit2", 0 }, // DECAL_SPIT2 + { "{bproof1", 0 }, // DECAL_BPROOF1 + { "{gargstomp", 0 }, // DECAL_GARGSTOMP1, // Gargantua stomp crack + { "{smscorch1", 0 }, // DECAL_SMALLSCORCH1, // Small scorch mark + { "{smscorch2", 0 }, // DECAL_SMALLSCORCH2, // Small scorch mark + { "{smscorch3", 0 }, // DECAL_SMALLSCORCH3, // Small scorch mark + { "{mommablob", 0 }, // DECAL_MOMMABIRTH // BM Birth spray + { "{mommablob", 0 }, // DECAL_MOMMASPLAT // BM Mortar spray?? need decal*/ }; TYPEDESCRIPTION CGlobalState::m_SaveData[] = @@ -72,12 +72,12 @@ TYPEDESCRIPTION gGlobalEntitySaveData[] = }; #else // HOOK_GAMEDLL - + DLL_DECALLIST gDecals[42]; TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CGlobalState, m_SaveData)[1]; TYPEDESCRIPTION gGlobalEntitySaveData[3]; - + #endif // HOOK_GAMEDLL /* <1db42b> ../cstrike/dlls/world.cpp:120 */ @@ -110,64 +110,64 @@ void CDecal::__MAKE_VHOOK(Spawn)(void) /* <1dad69> ../cstrike/dlls/world.cpp:145 */ void CDecal::TriggerDecal(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - // this is set up as a USE function for infodecals that have targetnames, so that the - // decal doesn't get applied until it is fired. (usually by a scripted sequence) - TraceResult trace; - int entityIndex; - - UTIL_TraceLine(pev->origin - Vector(5, 5, 5), pev->origin + Vector(5, 5, 5), ignore_monsters, ENT(pev), &trace); - - MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); - WRITE_BYTE(TE_BSPDECAL); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z); - WRITE_SHORT((int)pev->skin); - entityIndex = (short)ENTINDEX(trace.pHit); - WRITE_SHORT(entityIndex); - if (entityIndex) - { - WRITE_SHORT((int)VARS(trace.pHit)->modelindex); - } - MESSAGE_END(); - - SetThink(&CDecal::SUB_Remove); + // this is set up as a USE function for infodecals that have targetnames, so that the + // decal doesn't get applied until it is fired. (usually by a scripted sequence) + TraceResult trace; + int entityIndex; + + UTIL_TraceLine(pev->origin - Vector(5, 5, 5), pev->origin + Vector(5, 5, 5), ignore_monsters, ENT(pev), &trace); + + MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); + WRITE_BYTE(TE_BSPDECAL); + WRITE_COORD(pev->origin.x); + WRITE_COORD(pev->origin.y); + WRITE_COORD(pev->origin.z); + WRITE_SHORT((int)pev->skin); + entityIndex = (short)ENTINDEX(trace.pHit); + WRITE_SHORT(entityIndex); + if (entityIndex) + { + WRITE_SHORT((int)VARS(trace.pHit)->modelindex); + } + MESSAGE_END(); + + SetThink(&CDecal::SUB_Remove); pev->nextthink = gpGlobals->time + 0.1f; } /* <1daee2> ../cstrike/dlls/world.cpp:171 */ void CDecal::StaticDecal(void) { - TraceResult trace; - int entityIndex, modelIndex; - - UTIL_TraceLine(pev->origin - Vector(5, 5, 5), pev->origin + Vector(5, 5, 5), ignore_monsters, ENT(pev), &trace); - - entityIndex = (short)ENTINDEX(trace.pHit); - - if (entityIndex) - modelIndex = (int)VARS(trace.pHit)->modelindex; - else - modelIndex = 0; - - STATIC_DECAL(pev->origin, (int)pev->skin, entityIndex, modelIndex); + TraceResult trace; + int entityIndex, modelIndex; + + UTIL_TraceLine(pev->origin - Vector(5, 5, 5), pev->origin + Vector(5, 5, 5), ignore_monsters, ENT(pev), &trace); + + entityIndex = (short)ENTINDEX(trace.pHit); + + if (entityIndex) + modelIndex = (int)VARS(trace.pHit)->modelindex; + else + modelIndex = 0; + + STATIC_DECAL(pev->origin, (int)pev->skin, entityIndex, modelIndex); SUB_Remove(); } /* <1db068> ../cstrike/dlls/world.cpp:190 */ void CDecal::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { - if (FStrEq(pkvd->szKeyName, "texture")) - { - pev->skin = DECAL_INDEX(pkvd->szValue); - - // Found - if (pev->skin >= 0) - return; - - ALERT(at_console, "Can't find decal %s\n", pkvd->szValue); - } - else + if (FStrEq(pkvd->szKeyName, "texture")) + { + pev->skin = DECAL_INDEX(pkvd->szValue); + + // Found + if (pev->skin >= 0) + return; + + ALERT(at_console, "Can't find decal %s\n", pkvd->szValue); + } + else CBaseEntity::KeyValue(pkvd); } @@ -187,31 +187,31 @@ static void InitBodyQue(void) void CopyToBodyQue(entvars_t *pev) { #if 0 - if (pev->effects & EF_NODRAW) - return; - - entvars_t *pevHead = VARS(g_pBodyQueueHead); - - pevHead->angles = pev->angles; - pevHead->model = pev->model; - pevHead->modelindex = pev->modelindex; - pevHead->frame = pev->frame; - pevHead->colormap = pev->colormap; - pevHead->movetype = MOVETYPE_TOSS; - pevHead->velocity = pev->velocity; - pevHead->flags = 0; - pevHead->deadflag = pev->deadflag; - pevHead->renderfx = kRenderFxDeadPlayer; - pevHead->renderamt = ENTINDEX(ENT(pev)); - - pevHead->effects = pev->effects | EF_NOINTERP; - - pevHead->sequence = pev->sequence; - pevHead->animtime = pev->animtime; - - UTIL_SetOrigin(pevHead, pev->origin); - UTIL_SetSize(pevHead, pev->mins, pev->maxs); - + if (pev->effects & EF_NODRAW) + return; + + entvars_t *pevHead = VARS(g_pBodyQueueHead); + + pevHead->angles = pev->angles; + pevHead->model = pev->model; + pevHead->modelindex = pev->modelindex; + pevHead->frame = pev->frame; + pevHead->colormap = pev->colormap; + pevHead->movetype = MOVETYPE_TOSS; + pevHead->velocity = pev->velocity; + pevHead->flags = 0; + pevHead->deadflag = pev->deadflag; + pevHead->renderfx = kRenderFxDeadPlayer; + pevHead->renderamt = ENTINDEX(ENT(pev)); + + pevHead->effects = pev->effects | EF_NOINTERP; + + pevHead->sequence = pev->sequence; + pevHead->animtime = pev->animtime; + + UTIL_SetOrigin(pevHead, pev->origin); + UTIL_SetSize(pevHead, pev->mins, pev->maxs); + g_pBodyQueueHead = pevHead->owner; #endif } @@ -231,7 +231,7 @@ CGlobalState::CGlobalState(void) /* <1db63b> ../cstrike/dlls/world.cpp:299 */ void CGlobalState::Reset(void) { - m_pList = NULL; + m_pList = NULL; m_listCount = 0; } @@ -276,17 +276,17 @@ void CGlobalState::DumpGlobals(void) /* <1db76a> ../cstrike/dlls/world.cpp:345 */ void CGlobalState::EntityAdd(string_t globalname, string_t mapName, GLOBALESTATE state) { - assert(!Find(globalname)); - - globalentity_t *pNewEntity = (globalentity_t *)calloc(sizeof(globalentity_t), 1); - assert(pNewEntity != NULL); - - pNewEntity->pNext = m_pList; - m_pList = pNewEntity; - Q_strcpy(pNewEntity->name, STRING(globalname)); - Q_strcpy(pNewEntity->levelName, STRING(mapName)); - pNewEntity->state = state; - + assert(!Find(globalname)); + + globalentity_t *pNewEntity = (globalentity_t *)calloc(sizeof(globalentity_t), 1); + assert(pNewEntity != NULL); + + pNewEntity->pNext = m_pList; + m_pList = pNewEntity; + Q_strcpy(pNewEntity->name, STRING(globalname)); + Q_strcpy(pNewEntity->levelName, STRING(mapName)); + pNewEntity->state = state; + m_listCount++; } @@ -304,87 +304,87 @@ void CGlobalState::EntitySetState(string_t globalname, GLOBALESTATE state) /* <1db873> ../cstrike/dlls/world.cpp:369 */ const globalentity_t *CGlobalState::EntityFromTable(string_t globalname) { - globalentity_t *pEnt = Find(globalname); - + globalentity_t *pEnt = Find(globalname); + return pEnt; } /* <1db91c> ../cstrike/dlls/world.cpp:377 */ GLOBALESTATE CGlobalState::EntityGetState(string_t globalname) { - globalentity_t *pEnt = Find(globalname); - - if (pEnt != NULL) - { - return pEnt->state; - } - + globalentity_t *pEnt = Find(globalname); + + if (pEnt != NULL) + { + return pEnt->state; + } + return GLOBAL_OFF; } /* <1db9c5> ../cstrike/dlls/world.cpp:402 */ int CGlobalState::Save(CSave &save) { - int i; - globalentity_t *pEntity; - - if (!save.WriteFields("GLOBAL", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData)))) - { - return 0; - } - - pEntity = m_pList; - for (i = 0; i < m_listCount && pEntity != NULL; i++) - { - if (!save.WriteFields("GENT", pEntity, gGlobalEntitySaveData, ARRAYSIZE(gGlobalEntitySaveData))) - { - return 0; - } - - pEntity = pEntity->pNext; - } - + int i; + globalentity_t *pEntity; + + if (!save.WriteFields("GLOBAL", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData)))) + { + return 0; + } + + pEntity = m_pList; + for (i = 0; i < m_listCount && pEntity != NULL; i++) + { + if (!save.WriteFields("GENT", pEntity, gGlobalEntitySaveData, ARRAYSIZE(gGlobalEntitySaveData))) + { + return 0; + } + + pEntity = pEntity->pNext; + } + return 1; } /* <1dba07> ../cstrike/dlls/world.cpp:422 */ int CGlobalState::Restore(CRestore &restore) { - int i, listCount; - globalentity_t tmpEntity; - - ClearStates(); - - if (!restore.ReadFields("GLOBAL", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData)))) - { - return 0; - } - - // Get new list count - listCount = m_listCount; - - // Clear loaded data - m_listCount = 0; - - for (i = 0; i < listCount; i++) - { - if (!restore.ReadFields("GENT", &tmpEntity, gGlobalEntitySaveData, ARRAYSIZE(gGlobalEntitySaveData))) - { - return 0; - } - - EntityAdd(MAKE_STRING(tmpEntity.name), MAKE_STRING(tmpEntity.levelName), tmpEntity.state); - } - + int i, listCount; + globalentity_t tmpEntity; + + ClearStates(); + + if (!restore.ReadFields("GLOBAL", this, IMPLEMENT_ARRAY(m_SaveData), ARRAYSIZE(IMPLEMENT_ARRAY(m_SaveData)))) + { + return 0; + } + + // Get new list count + listCount = m_listCount; + + // Clear loaded data + m_listCount = 0; + + for (i = 0; i < listCount; i++) + { + if (!restore.ReadFields("GENT", &tmpEntity, gGlobalEntitySaveData, ARRAYSIZE(gGlobalEntitySaveData))) + { + return 0; + } + + EntityAdd(MAKE_STRING(tmpEntity.name), MAKE_STRING(tmpEntity.levelName), tmpEntity.state); + } + return 1; } /* <1dbaf2> ../cstrike/dlls/world.cpp:444 */ void CGlobalState::EntityUpdate(string_t globalname, string_t mapname) { - globalentity_t *pEnt = Find(globalname); - - if (pEnt != NULL) + globalentity_t *pEnt = Find(globalname); + + if (pEnt != NULL) { Q_strcpy(pEnt->levelName, STRING(mapname)); } @@ -393,39 +393,39 @@ void CGlobalState::EntityUpdate(string_t globalname, string_t mapname) /* <1dbbae> ../cstrike/dlls/world.cpp:453 */ void CGlobalState::ClearStates(void) { - globalentity_t *pFree = m_pList; - - while (pFree != NULL) - { - globalentity_t *pNext = pFree->pNext; - - free(pFree); - pFree = pNext; - } - + globalentity_t *pFree = m_pList; + + while (pFree != NULL) + { + globalentity_t *pNext = pFree->pNext; + + free(pFree); + pFree = pNext; + } + Reset(); } /* <1dbc13> ../cstrike/dlls/world.cpp:466 */ void SaveGlobalState(SAVERESTOREDATA *pSaveData) { - CSave saveHelper(pSaveData); + CSave saveHelper(pSaveData); gGlobalState.Save(saveHelper); } /* <1dbcde> ../cstrike/dlls/world.cpp:473 */ void RestoreGlobalState(SAVERESTOREDATA *pSaveData) { - CRestore restoreHelper(pSaveData); + CRestore restoreHelper(pSaveData); gGlobalState.Restore(restoreHelper); } /* <1dbe72> ../cstrike/dlls/world.cpp:480 */ void ResetGlobalState(void) { - gGlobalState.ClearStates(); - - // Init the HUD on a new game / load game + gGlobalState.ClearStates(); + + // Init the HUD on a new game / load game gInitHUD = TRUE; } @@ -486,8 +486,8 @@ void CWorld::__MAKE_VHOOK(Precache)(void) g_pLastCTSpawn = NULL; g_pLastTerroristSpawn = NULL; - CVAR_SET_STRING("sv_gravity", "800"); - CVAR_SET_STRING("sv_maxspeed", "900"); + CVAR_SET_STRING("sv_gravity", "800"); + CVAR_SET_STRING("sv_maxspeed", "900"); CVAR_SET_STRING("sv_stepsize", "18"); // clear DSP @@ -501,64 +501,64 @@ void CWorld::__MAKE_VHOOK(Precache)(void) g_pGameRules = (CHalfLifeMultiplay *)InstallGameRules(); - //!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here - - ///!!!LATER - do we want a sound ent in deathmatch? (sjb) - //pSoundEnt = CBaseEntity::Create( "soundent", g_vecZero, g_vecZero, edict() ); + //!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here + + ///!!!LATER - do we want a sound ent in deathmatch? (sjb) + //pSoundEnt = CBaseEntity::Create("soundent", g_vecZero, g_vecZero, edict()); pSoundEnt = GetClassPtr((CSoundEnt *)NULL); pSoundEnt->Spawn(); - if (!pSoundEnt) - { - ALERT(at_console, "**COULD NOT CREATE SOUNDENT**\n"); - } - + if (!pSoundEnt) + { + ALERT(at_console, "**COULD NOT CREATE SOUNDENT**\n"); + } + InitBodyQue(); - // init sentence group playback stuff from sentences.txt. - // ok to call this multiple times, calls after first are ignored. - SENTENCEG_Init(); - - // init texture type array from materials.txt - TEXTURETYPE_Init(); - - // the area based ambient sounds MUST be the first precache_sounds - // player precaches - // get weapon precaches - - W_Precache(); + // init sentence group playback stuff from sentences.txt. + // ok to call this multiple times, calls after first are ignored. + SENTENCEG_Init(); + + // init texture type array from materials.txt + TEXTURETYPE_Init(); + + // the area based ambient sounds MUST be the first precache_sounds + // player precaches + // get weapon precaches + + W_Precache(); ClientPrecache(); BotPrecache(); - // sounds used from C physics code - // clears sound channels - PRECACHE_SOUND("common/null.wav"); - - //!!! temporary sound for respawning weapons. - PRECACHE_SOUND("items/suitchargeok1.wav"); - - // player picks up a gun. - PRECACHE_SOUND("items/gunpickup2.wav"); - - // dead bodies hitting the ground (animation events) - PRECACHE_SOUND("common/bodydrop3.wav"); + // sounds used from C physics code + // clears sound channels + PRECACHE_SOUND("common/null.wav"); + + //!!! temporary sound for respawning weapons. + PRECACHE_SOUND("items/suitchargeok1.wav"); + + // player picks up a gun. + PRECACHE_SOUND("items/gunpickup2.wav"); + + // dead bodies hitting the ground (animation events) + PRECACHE_SOUND("common/bodydrop3.wav"); PRECACHE_SOUND("common/bodydrop4.wav"); - g_Language = (int)CVAR_GET_FLOAT("sv_language"); - if (g_Language == LANGUAGE_GERMAN) - { - PRECACHE_MODEL("models/germangibs.mdl"); - } - else - { - PRECACHE_MODEL("models/hgibs.mdl"); - PRECACHE_MODEL("models/agibs.mdl"); + g_Language = (int)CVAR_GET_FLOAT("sv_language"); + if (g_Language == LANGUAGE_GERMAN) + { + PRECACHE_MODEL("models/germangibs.mdl"); + } + else + { + PRECACHE_MODEL("models/hgibs.mdl"); + PRECACHE_MODEL("models/agibs.mdl"); } - PRECACHE_SOUND("weapons/ric1.wav"); - PRECACHE_SOUND("weapons/ric2.wav"); - PRECACHE_SOUND("weapons/ric3.wav"); - PRECACHE_SOUND("weapons/ric4.wav"); + PRECACHE_SOUND("weapons/ric1.wav"); + PRECACHE_SOUND("weapons/ric2.wav"); + PRECACHE_SOUND("weapons/ric3.wav"); + PRECACHE_SOUND("weapons/ric4.wav"); PRECACHE_SOUND("weapons/ric5.wav"); PRECACHE_SOUND("weapons/ric_metal-1.wav"); @@ -604,142 +604,142 @@ void CWorld::__MAKE_VHOOK(Precache)(void) // 11 SLOW PULSE NOT FADE TO BLACK LIGHT_STYLE(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); - // 12 UNDERWATER LIGHT MUTATION - // this light only distorts the lightmap - no contribution + // 12 UNDERWATER LIGHT MUTATION + // this light only distorts the lightmap - no contribution // is made to the brightness of affected surfaces LIGHT_STYLE(12, "mmnnmmnnnmmnn"); - // styles 32-62 are assigned by the light program for switchable lights + // styles 32-62 are assigned by the light program for switchable lights // 63 testing LIGHT_STYLE(63, "a"); - for (int i = 0; i < ARRAYSIZE(gDecals); i++) + for (int i = 0; i < ARRAYSIZE(gDecals); i++) gDecals[i].index = DECAL_INDEX(gDecals[i].name); - // init the WorldGraph. + // init the WorldGraph. WorldGraph.InitGraph(); - // make sure the .NOD file is newer than the .BSP file. - if (!WorldGraph.CheckNODFile((char *)STRING(gpGlobals->mapname))) - { - // NOD file is not present, or is older than the BSP file. - WorldGraph.AllocNodes(); - } - else - { - // Load the node graph for this level - if (!WorldGraph.FLoadGraph((char *)STRING(gpGlobals->mapname))) - { - // couldn't load, so alloc and prepare to build a graph. - ALERT(at_console, "*Error opening .NOD file\n"); - WorldGraph.AllocNodes(); - } - else - { - ALERT(at_console, "\n*Graph Loaded!\n"); - } + // make sure the .NOD file is newer than the .BSP file. + if (!WorldGraph.CheckNODFile((char *)STRING(gpGlobals->mapname))) + { + // NOD file is not present, or is older than the BSP file. + WorldGraph.AllocNodes(); + } + else + { + // Load the node graph for this level + if (!WorldGraph.FLoadGraph((char *)STRING(gpGlobals->mapname))) + { + // couldn't load, so alloc and prepare to build a graph. + ALERT(at_console, "*Error opening .NOD file\n"); + WorldGraph.AllocNodes(); + } + else + { + ALERT(at_console, "\n*Graph Loaded!\n"); + } } - if (pev->speed > 0) - CVAR_SET_FLOAT("sv_zmax", pev->speed); - else + if (pev->speed > 0) + CVAR_SET_FLOAT("sv_zmax", pev->speed); + else CVAR_SET_FLOAT("sv_zmax", 4096); - if (pev->netname) - { - ALERT(at_aiconsole, "Chapter title: %s\n", STRING(pev->netname)); - - CBaseEntity *pEntity = CBaseEntity::Create("env_message", g_vecZero, g_vecZero, NULL); - - if (pEntity != NULL) - { - pEntity->SetThink(&CBaseEntity::SUB_CallUseToggle); - pEntity->pev->message = pev->netname; - pev->netname = 0; - pEntity->pev->nextthink = gpGlobals->time + 0.3f; - pEntity->pev->spawnflags = SF_MESSAGE_ONCE; - } + if (pev->netname) + { + ALERT(at_aiconsole, "Chapter title: %s\n", STRING(pev->netname)); + + CBaseEntity *pEntity = CBaseEntity::Create("env_message", g_vecZero, g_vecZero, NULL); + + if (pEntity != NULL) + { + pEntity->SetThink(&CBaseEntity::SUB_CallUseToggle); + pEntity->pev->message = pev->netname; + pev->netname = 0; + pEntity->pev->nextthink = gpGlobals->time + 0.3f; + pEntity->pev->spawnflags = SF_MESSAGE_ONCE; + } } - if (pev->spawnflags & SF_WORLD_DARK) - CVAR_SET_FLOAT("v_dark", 1); - else + if (pev->spawnflags & SF_WORLD_DARK) + CVAR_SET_FLOAT("v_dark", 1); + else CVAR_SET_FLOAT("v_dark", 0); - if (pev->spawnflags & SF_WORLD_TITLE) - { - // display the game title if this key is set - gDisplayTitle = TRUE; - } - else + if (pev->spawnflags & SF_WORLD_TITLE) + { + // display the game title if this key is set + gDisplayTitle = TRUE; + } + else gDisplayTitle = FALSE; } /* <1db153> ../cstrike/dlls/world.cpp:731 */ void CWorld::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ - if (FStrEq(pkvd->szKeyName, "skyname")) - { - CVAR_SET_STRING("sv_skyname", pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "sounds")) - { - gpGlobals->cdAudioTrack = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "WaveHeight")) - { - pev->scale = Q_atof(pkvd->szValue) * 0.125; - CVAR_SET_FLOAT("sv_wateramp", pev->scale); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "MaxRange")) - { - pev->speed = Q_atof(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "chaptertitle")) - { - pev->netname = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "startdark")) - { +{ + if (FStrEq(pkvd->szKeyName, "skyname")) + { + CVAR_SET_STRING("sv_skyname", pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "sounds")) + { + gpGlobals->cdAudioTrack = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "WaveHeight")) + { + pev->scale = Q_atof(pkvd->szValue) * 0.125; + CVAR_SET_FLOAT("sv_wateramp", pev->scale); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "MaxRange")) + { + pev->speed = Q_atof(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "chaptertitle")) + { + pev->netname = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "startdark")) + { int flag = Q_atoi(pkvd->szValue); if (flag) - { - pev->spawnflags |= SF_WORLD_DARK; - } - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "newunit")) - { - if (Q_atoi(pkvd->szValue)) + { + pev->spawnflags |= SF_WORLD_DARK; + } + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "newunit")) + { + if (Q_atoi(pkvd->szValue)) CVAR_SET_FLOAT("sv_newunit", 1.0); - - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "gametitle")) - { - if (Q_atoi(pkvd->szValue)) + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "gametitle")) + { + if (Q_atoi(pkvd->szValue)) pev->spawnflags |= SF_WORLD_TITLE; - - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "mapteams")) - { - pev->team = ALLOC_STRING(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "defaultteam")) - { - if (Q_atoi(pkvd->szValue)) + + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "mapteams")) + { + pev->team = ALLOC_STRING(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "defaultteam")) + { + if (Q_atoi(pkvd->szValue)) pev->spawnflags |= SF_WORLD_FORCETEAM; - - pkvd->fHandled = TRUE; - } - else + + pkvd->fHandled = TRUE; + } + else CBaseEntity::KeyValue(pkvd); } diff --git a/regamedll/dlls/wpn_shared/wpn_ak47.cpp b/regamedll/dlls/wpn_shared/wpn_ak47.cpp index fb9c1acb..4cea4c33 100644 --- a/regamedll/dlls/wpn_shared/wpn_ak47.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ak47.cpp @@ -4,32 +4,32 @@ LINK_ENTITY_TO_CLASS(weapon_ak47, CAK47); /* <235327> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:52 */ -NOBODY void CAK47::Spawn(void) +NOBODY void CAK47::__MAKE_VHOOK(Spawn)(void) { } /* <235280> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:66 */ -NOBODY void CAK47::Precache(void) +NOBODY void CAK47::__MAKE_VHOOK(Precache)(void) { } /* <2352a7> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:82 */ -NOBODY int CAK47::GetItemInfo(ItemInfo *p) +NOBODY int CAK47::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p) { } /* <235300> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:99 */ -NOBODY BOOL CAK47::Deploy(void) +NOBODY BOOL CAK47::__MAKE_VHOOK(Deploy)(void) { } /* <2352da> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:108 */ -NOBODY void CAK47::SecondaryAttack(void) +NOBODY void CAK47::__MAKE_VHOOK(SecondaryAttack)(void) { } /* <235523> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:112 */ -NOBODY void CAK47::PrimaryAttack(void) +NOBODY void CAK47::__MAKE_VHOOK(PrimaryAttack)(void) { // Length2D(const Vector *const this); // 116 // PrimaryAttack(CAK47 *const this); // 112 @@ -54,13 +54,57 @@ NOBODY void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) } /* <2353d8> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:204 */ -NOBODY void CAK47::Reload(void) +NOBODY void CAK47::__MAKE_VHOOK(Reload)(void) { // Reload(CAK47 *const this); // 204 } /* <23539d> ../cstrike/dlls/wpn_shared/wpn_ak47.cpp:219 */ -NOBODY void CAK47::WeaponIdle(void) +NOBODY void CAK47::__MAKE_VHOOK(WeaponIdle)(void) { // WeaponIdle(CAK47 *const this); // 219 } + +#ifdef HOOK_GAMEDLL + +void CAK47::Spawn(void) +{ + Spawn_(); +} + +void CAK47::Precache(void) +{ + Precache_(); +} + +int CAK47::GetItemInfo(ItemInfo *p) +{ + return GetItemInfo_(p); +} + +BOOL CAK47::Deploy(void) +{ + return Deploy_(); +} + +void CAK47::PrimaryAttack(void) +{ + PrimaryAttack_(); +} + +void CAK47::SecondaryAttack(void) +{ + SecondaryAttack_(); +} + +void CAK47::Reload(void) +{ + Reload_(); +} + +void CAK47::WeaponIdle(void) +{ + WeaponIdle_(); +} + +#endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/wpn_shared/wpn_awp.cpp b/regamedll/dlls/wpn_shared/wpn_awp.cpp index ebda507c..34632433 100644 --- a/regamedll/dlls/wpn_shared/wpn_awp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_awp.cpp @@ -1,79 +1,327 @@ #include "precompiled.h" +#define AWP_MAX_SPEED 210 +#define AWP_MAX_SPEED_ZOOM 150 +#define AWP_RELOAD_TIME 2.5 + +enum awp_e +{ + AWP_IDLE, + AWP_SHOOT, + AWP_SHOOT2, + AWP_SHOOT3, + AWP_RELOAD, + AWP_DRAW, +}; + /* <23fdac> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:50 */ LINK_ENTITY_TO_CLASS(weapon_awp, CAWP); /* <23fb10> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:52 */ -NOBODY void CAWP::Spawn(void) +void CAWP::__MAKE_VHOOK(Spawn)(void) { + Precache(); + m_iId = WEAPON_AWP; + SET_MODEL(ENT(pev), "models/w_awp.mdl"); + + m_iDefaultAmmo = AWP_DEFAULT_GIVE; + FallInit(); } /* <23fa2c> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:64 */ -NOBODY void CAWP::Precache(void) +void CAWP::__MAKE_VHOOK(Precache)(void) { + PRECACHE_MODEL("models/v_awp.mdl"); + PRECACHE_MODEL("models/w_awp.mdl"); + + PRECACHE_SOUND("weapons/awp1.wav"); + PRECACHE_SOUND("weapons/boltpull1.wav"); + PRECACHE_SOUND("weapons/boltup.wav"); + PRECACHE_SOUND("weapons/boltdown.wav"); + PRECACHE_SOUND("weapons/zoom.wav"); + PRECACHE_SOUND("weapons/awp_deploy.wav"); + PRECACHE_SOUND("weapons/awp_clipin.wav"); + PRECACHE_SOUND("weapons/awp_clipout.wav"); + + m_iShell = PRECACHE_MODEL("models/rshell_big.mdl"); + m_iShellId = m_iShell; + m_usFireAWP = PRECACHE_EVENT(1, "events/awp.sc"); } /* <23fa53> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:83 */ -NOBODY int CAWP::GetItemInfo(ItemInfo *p) +int CAWP::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p) { + p->pszName = STRING(pev->classname); + p->pszAmmo1 = "338Magnum"; + p->iMaxAmmo1 = MAX_AMMO_338MAGNUM; + p->pszAmmo2 = NULL; + p->iMaxAmmo2 = -1; + p->iMaxClip = AWP_MAX_CLIP; + p->iSlot = 0; + p->iPosition = 2; + + m_iId = WEAPON_AWP; + p->iId = WEAPON_AWP; + + p->iFlags = 0; + p->iWeight = AWP_WEIGHT; + + return 1; } /* <23fc19> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:100 */ -NOBODY BOOL CAWP::Deploy(void) +BOOL CAWP::__MAKE_VHOOK(Deploy)(void) { -// Deploy(CAWP *const this); // 100 + if (DefaultDeploy("models/v_awp.mdl", "models/p_awp.mdl", AWP_DRAW, "rifle", UseDecrement() != FALSE)) + { + m_pPlayer->m_flNextAttack = GetNextAttackDelay(1.45); + m_flNextPrimaryAttack = m_pPlayer->m_flNextAttack; + + m_flNextSecondaryAttack = WEAPON_TIMEBASED + 1.0; + + return TRUE; + } + + return FALSE; } /* <23faac> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:113 */ -NOBODY void CAWP::SecondaryAttack(void) +void CAWP::__MAKE_VHOOK(SecondaryAttack)(void) { -// EMIT_SOUND(edict_t *entity, -// int channel, -// const char *sample, -// float volume, -// float attenuation); // 139 + switch (m_pPlayer->m_iFOV) + { + case 90: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 40; break; + case 40: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 10; break; + default: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90; break; + } + + if (TheBots != NULL) + { + TheBots->OnEvent(EVENT_WEAPON_ZOOMED, m_pPlayer); + } + + m_pPlayer->ResetMaxSpeed(); + EMIT_SOUND(m_pPlayer->edict(), CHAN_ITEM, "weapons/zoom.wav", 0.2, 2.4); + + m_flNextSecondaryAttack = WEAPON_TIMEBASED + 0.3; } /* <23fd53> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:143 */ -NOBODY void CAWP::PrimaryAttack(void) +void CAWP::__MAKE_VHOOK(PrimaryAttack)(void) { -// Length2D(const Vector *const this); // 147 -// PrimaryAttack(CAWP *const this); // 143 + if (!(m_pPlayer->pev->flags & FL_ONGROUND)) + { + AWPFire(0.85, 1.45, FALSE); + } + else if (m_pPlayer->pev->velocity.Length2D() > 140) + { + AWPFire(0.25, 1.45, FALSE); + } + else if (m_pPlayer->pev->velocity.Length2D() > 10) + { + AWPFire(0.1, 1.45, FALSE); + } + else if (m_pPlayer->pev->flags & FL_DUCKING) + { + AWPFire(0.0, 1.45, FALSE); + } + else + { + AWPFire(0.001, 1.45, FALSE); + } } /* <23fe76> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:157 */ -NOBODY void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) -{ -// { -// Vector vecAiming; // 205 -// Vector vecSrc; // 207 -// Vector vecDir; // 209 -// int flag; // 212 -// operator+(const Vector *const this, -// const Vector &v); // 194 -// Vector(Vector *const this, -// const Vector &v); // 210 -// Vector(Vector *const this, -// const Vector &v); // 210 -// } +void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) +{ + Vector vecAiming; + Vector vecSrc; + Vector vecDir; + int flag; + + if (m_pPlayer->pev->fov != DEFAULT_FOV) + { + m_pPlayer->m_bResumeZoom = true; + m_pPlayer->m_iLastZoom = m_pPlayer->m_iFOV; + + // reset a fov + m_pPlayer->m_iFOV = DEFAULT_FOV; + m_pPlayer->pev->fov = DEFAULT_FOV; + } + else + { + flSpread += 0.08; + } + + if (m_iClip <= 0) + { + if (m_fFireOnEmpty) + { + PlayEmptySound(); + m_flNextPrimaryAttack = GetNextAttackDelay(0.2); + } + + if (TheBots != NULL) + { + TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer, 0); + } + + return; + } + + m_iClip--; + + m_pPlayer->pev->effects |= EF_MUZZLEFLASH; + m_pPlayer->SetAnimation(PLAYER_ATTACK1); + + UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); + + m_pPlayer->m_flEjectBrass = gpGlobals->time + 0.55; + m_pPlayer->m_iWeaponVolume = BIG_EXPLOSION_VOLUME; + m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; + + vecSrc = m_pPlayer->GetGunPosition(); + vecDir = gpGlobals->v_forward; + + vecAiming = m_pPlayer->FireBullets3 + ( + vecSrc, + vecDir, + flSpread, + 8192.0, + 3, + BULLET_PLAYER_338MAG, + 115, + 0.99, + m_pPlayer->pev, + true, + m_pPlayer->random_seed + ); + +#ifdef CLIENT_WEAPONS + flag = FEV_NOTHOST; +#else + flag = 0; +#endif // CLIENT_WEAPONS + + PLAYBACK_EVENT_FULL + ( + flag, + ENT(m_pPlayer->pev), + m_usFireAWP, + 0, + (float *)&g_vecZero, + (float *)&g_vecZero, + vecAiming.x, + vecAiming.y, + (int)(m_pPlayer->pev->punchangle.x * 100), + (int)(m_pPlayer->pev->punchangle.x * 100), + FALSE, + FALSE + ); + + m_flNextSecondaryAttack = GetNextAttackDelay(flCycleTime); + m_flNextPrimaryAttack = m_flNextSecondaryAttack; + + if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + { + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + } + + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 2.0; + m_pPlayer->pev->punchangle.x -= 2; } /* <23fbc1> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:239 */ -NOBODY void CAWP::Reload(void) +void CAWP::__MAKE_VHOOK(Reload)(void) { -// { -// int iResult; // 244 -// } -// Reload(CAWP *const this); // 239 + int iResult; + + if (m_pPlayer->ammo_338mag <= 0) + { + return; + } + + iResult = DefaultReload(AWP_MAX_CLIP, AWP_RELOAD, AWP_RELOAD_TIME); + + if (iResult) + { + m_pPlayer->SetAnimation(PLAYER_RELOAD); + + if (m_pPlayer->pev->fov != DEFAULT_FOV) + { + m_pPlayer->m_iFOV = 10; + m_pPlayer->pev->fov = 10; + + SecondaryAttack(); + } + } } /* <23fb86> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:265 */ -NOBODY void CAWP::WeaponIdle(void) +void CAWP::__MAKE_VHOOK(WeaponIdle)(void) { -// WeaponIdle(CAWP *const this); // 265 + ResetEmptySound(); + m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); + + if (m_flTimeWeaponIdle <= WEAPON_TIMEBASED && m_iClip) + { + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 60; + SendWeaponAnim(AWP_IDLE, UseDecrement() != FALSE); + } } /* <23fa86> ../cstrike/dlls/wpn_shared/wpn_awp.cpp:283 */ -NOBODY float CAWP::GetMaxSpeed(void) +float CAWP::__MAKE_VHOOK(GetMaxSpeed)(void) { + return m_pPlayer->m_iFOV == DEFAULT_FOV ? AWP_MAX_SPEED : AWP_MAX_SPEED_ZOOM; } + +#ifdef HOOK_GAMEDLL + +void CAWP::Spawn(void) +{ + Spawn_(); +} + +void CAWP::Precache(void) +{ + Precache_(); +} + +int CAWP::GetItemInfo(ItemInfo *p) +{ + return GetItemInfo_(p); +} + +BOOL CAWP::Deploy(void) +{ + return Deploy_(); +} + +float CAWP::GetMaxSpeed(void) +{ + return GetMaxSpeed_(); +} + +void CAWP::PrimaryAttack(void) +{ + PrimaryAttack_(); +} + +void CAWP::SecondaryAttack(void) +{ + SecondaryAttack_(); +} + +void CAWP::Reload(void) +{ + Reload_(); +} + +void CAWP::WeaponIdle(void) +{ + WeaponIdle_(); +} + +#endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/wpn_shared/wpn_p90.cpp b/regamedll/dlls/wpn_shared/wpn_p90.cpp index 701e7c3f..971ffd11 100644 --- a/regamedll/dlls/wpn_shared/wpn_p90.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p90.cpp @@ -1,61 +1,289 @@ #include "precompiled.h" +#define P90_MAX_SPEED 245 +#define P90_RELOAD_TIME 3.4 + +enum p90_e +{ + P90_IDLE1, + P90_RELOAD, + P90_DRAW, + P90_SHOOT1, + P90_SHOOT2, + P90_SHOOT3 +}; + /* <29657d> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:49 */ LINK_ENTITY_TO_CLASS(weapon_p90, CP90); /* <296337> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:51 */ -NOBODY void CP90::Spawn(void) +void CP90::__MAKE_VHOOK(Spawn)(void) { + Precache(); + m_iId = WEAPON_P90; + SET_MODEL(edict(), "models/w_p90.mdl"); + + m_iDefaultAmmo = P90_DEFAULT_GIVE; + m_flAccuracy = 0.2; + m_iShotsFired = 0; + m_bDelayFire = false; + + FallInit(); } /* <2962b6> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:66 */ -NOBODY void CP90::Precache(void) +void CP90::__MAKE_VHOOK(Precache)(void) { + PRECACHE_MODEL("models/v_p90.mdl"); + PRECACHE_MODEL("models/w_p90.mdl"); + + PRECACHE_SOUND("weapons/p90-1.wav"); + PRECACHE_SOUND("weapons/p90_clipout.wav"); + PRECACHE_SOUND("weapons/p90_clipin.wav"); + PRECACHE_SOUND("weapons/p90_boltpull.wav"); + PRECACHE_SOUND("weapons/p90_cliprelease.wav"); + + m_iShell = PRECACHE_MODEL("models/rshell.mdl"); + m_usFireP90 = PRECACHE_EVENT(1, "events/p90.sc"); } /* <2962dd> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:83 */ -NOBODY int CP90::GetItemInfo(ItemInfo *p) +int CP90::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p) { + p->pszName = STRING(pev->classname); + p->pszAmmo1 = "57mm"; + p->iMaxAmmo1 = MAX_AMMO_57MM; + p->pszAmmo2 = NULL; + p->iMaxAmmo2 = -1; + p->iMaxClip = P90_MAX_CLIP; + p->iSlot = 0; + p->iPosition = 8; + + m_iId = WEAPON_P90; + p->iId = WEAPON_P90; + + p->iFlags = 0; + p->iWeight = P90_WEIGHT; + + return 1; } /* <296310> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:100 */ -NOBODY BOOL CP90::Deploy(void) -{ +BOOL CP90::__MAKE_VHOOK(Deploy)(void) +{ + m_iShotsFired = 0; + m_bDelayFire = false; + m_flAccuracy = 0.2; + + iShellOn = 1; + + return DefaultDeploy("models/v_p90.mdl", "models/p_p90.mdl", P90_DRAW, "carbine", UseDecrement() != FALSE); } /* <296533> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:110 */ -NOBODY void CP90::PrimaryAttack(void) +void CP90::__MAKE_VHOOK(PrimaryAttack)(void) { -// Length2D(const Vector *const this); // 114 -// PrimaryAttack(CP90 *const this); // 110 + if (!(m_pPlayer->pev->flags & FL_ONGROUND)) + { + P90Fire(0.3 * m_flAccuracy, 0.066, FALSE); + } + else if (m_pPlayer->pev->velocity.Length2D() > 170) + { + P90Fire(0.115 * m_flAccuracy, 0.066, FALSE); + } + else + { + P90Fire(0.045 * m_flAccuracy, 0.066, FALSE); + } } /* <296647> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:120 */ -NOBODY void CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) +void CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) { -// { -// Vector vecAiming; // 161 -// Vector vecSrc; // 163 -// Vector vecDir; // 164 -// int flag; // 168 -// operator+(const Vector *const this, -// const Vector &v); // 155 -// Vector(Vector *const this, -// const Vector &v); // 165 -// Vector(Vector *const this, -// const Vector &v); // 165 -// Length2D(const Vector *const this); // 193 -// } + Vector vecAiming; + Vector vecSrc; + Vector vecDir; + int flag; + + m_bDelayFire = true; + m_iShotsFired++; + + m_flAccuracy = (m_iShotsFired * m_iShotsFired / 175) + 0.45; + + if (m_flAccuracy > 1) + m_flAccuracy = 1; + + if (m_iClip <= 0) + { + if (m_fFireOnEmpty) + { + PlayEmptySound(); + m_flNextPrimaryAttack = GetNextAttackDelay(0.2); + } + + if (TheBots != NULL) + { + TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); + } + + return; + } + + m_iClip--; + + m_pPlayer->pev->effects |= EF_MUZZLEFLASH; + m_pPlayer->SetAnimation(PLAYER_ATTACK1); + + UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); + + m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; + m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; + + vecSrc = m_pPlayer->GetGunPosition(); + vecDir = gpGlobals->v_forward; + + vecAiming = m_pPlayer->FireBullets3 + ( + vecSrc, + vecDir, + flSpread, + 8192, + 1, + BULLET_PLAYER_57MM, + 21, + 0.885, + m_pPlayer->pev, + false, + m_pPlayer->random_seed + ); + +#ifdef CLIENT_WEAPONS + flag = FEV_NOTHOST; +#else + flag = 0; +#endif // CLIENT_WEAPONS + + PLAYBACK_EVENT_FULL + ( + flag, + m_pPlayer->edict(), + m_usFireP90, + 0, + (float *)&g_vecZero, + (float *)&g_vecZero, + vecAiming.x, + vecAiming.y, + (int)(m_pPlayer->pev->punchangle.x * 100), + (int)(m_pPlayer->pev->punchangle.y * 100), + 5, + FALSE + ); + + m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(flCycleTime); + + if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + { + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + } + + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 2.0; + + if (!(m_pPlayer->pev->flags & FL_ONGROUND)) + { + KickBack(0.9, 0.45, 0.35, 0.04, 5.25, 3.5, 4); + } + else if (m_pPlayer->pev->velocity.Length2D() > 0) + { + KickBack(0.45, 0.3, 0.2, 0.0275, 4.0, 2.25, 7); + } + else if (m_pPlayer->pev->flags & FL_DUCKING) + { + KickBack(0.275, 0.2, 0.125, 0.02, 3.0, 1.0, 9); + } + else + { + KickBack(0.3, 0.225, 0.125, 0.02, 3.25, 1.25, 8); + } } /* <2963e8> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:202 */ -NOBODY void CP90::Reload(void) +void CP90::__MAKE_VHOOK(Reload)(void) { -// Reload(CP90 *const this); // 202 + if (m_pPlayer->ammo_57mm <= 0) + { + return; + } + + if (DefaultReload(P90_MAX_CLIP, P90_RELOAD, P90_RELOAD_TIME)) + { + m_pPlayer->SetAnimation(PLAYER_RELOAD); + + m_flAccuracy = 0.2; + m_iShotsFired = 0; + } } /* <2963ad> ../cstrike/dlls/wpn_shared/wpn_p90.cpp:216 */ -NOBODY void CP90::WeaponIdle(void) +void CP90::__MAKE_VHOOK(WeaponIdle)(void) { -// WeaponIdle(CP90 *const this); // 216 + ResetEmptySound(); + m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); + + if (m_flTimeWeaponIdle > WEAPON_TIMEBASED) + { + return; + } + + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 20.0; + SendWeaponAnim(P90_IDLE1, UseDecrement() != FALSE); } + +/* <29626a> ../cstrike/dlls/weapons.h:1052 */ +float CP90::__MAKE_VHOOK(GetMaxSpeed)(void) +{ + return P90_MAX_SPEED; +} + +#ifdef HOOK_GAMEDLL + +void CP90::Spawn(void) +{ + Spawn_(); +} + +void CP90::Precache(void) +{ + Precache_(); +} + +int CP90::GetItemInfo(ItemInfo *p) +{ + return GetItemInfo_(p); +} + +BOOL CP90::Deploy(void) +{ + return Deploy_(); +} + +void CP90::PrimaryAttack(void) +{ + PrimaryAttack_(); +} + +void CP90::Reload(void) +{ + Reload_(); +} + +void CP90::WeaponIdle(void) +{ + WeaponIdle_(); +} + +float CP90::GetMaxSpeed(void) +{ + return GetMaxSpeed_(); +} + +#endif // HOOK_GAMEDLL diff --git a/regamedll/dlls/wpn_shared/wpn_usp.cpp b/regamedll/dlls/wpn_shared/wpn_usp.cpp index 1312806f..444c62e4 100644 --- a/regamedll/dlls/wpn_shared/wpn_usp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_usp.cpp @@ -1,5 +1,8 @@ #include "precompiled.h" +#define USP_MAX_SPEED 250 +#define USP_RELOAD_TIME 2.7 + enum usp_e { USP_IDLE, @@ -40,11 +43,14 @@ LINK_ENTITY_TO_CLASS(weapon_usp, CUSP); void CUSP::__MAKE_VHOOK(Spawn)(void) { Precache(); + m_iId = WEAPON_USP; SET_MODEL(ENT(pev), "models/w_usp.mdl"); + m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - m_iDefaultAmmo = 12;//TODO: Default clip USP_MAX_CLIP + m_iDefaultAmmo = USP_DEFAULT_GIVE; m_flAccuracy = 0.92f; + FallInit(); } @@ -80,9 +86,11 @@ int CUSP::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p) p->iSlot = 1; p->iPosition = 4; p->iFlags = 0; + m_iId = WEAPON_USP; p->iId = WEAPON_USP; - p->iWeight = 5; + + p->iWeight = USP_WEIGHT; return 1; } @@ -92,57 +100,126 @@ BOOL CUSP::__MAKE_VHOOK(Deploy)(void) { m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; m_flAccuracy = 0.92f; - m_fMaxSpeed = 250.0f; + m_fMaxSpeed = USP_MAX_SPEED; m_pPlayer->m_bShieldDrawn = false; if (m_pPlayer->HasShield()) { m_iWeaponState &= ~WPNSTATE_USP_SILENCED; - return DefaultDeploy("models/shield/v_shield_usp.mdl", "models/shield/p_shield_usp.mdl", USP_SHIELD_DRAW, "shieldgun", UseDecrement() != FALSE); + return DefaultDeploy("models/shield/v_shield_usp.mdl", "models/shield/p_shield_usp.mdl", USP_SHIELD_DRAW, "shieldgun", UseDecrement()); } else if (m_iWeaponState & WPNSTATE_USP_SILENCED) - return DefaultDeploy("models/v_usp.mdl", "models/p_usp.mdl", USP_DRAW, "onehanded", UseDecrement() != FALSE); - return DefaultDeploy("models/v_usp.mdl", "models/p_usp.mdl", USP_UNSIL_DRAW, "onehanded", UseDecrement() != FALSE); + { + return DefaultDeploy("models/v_usp.mdl", "models/p_usp.mdl", USP_DRAW, "onehanded", UseDecrement()); + } + + return DefaultDeploy("models/v_usp.mdl", "models/p_usp.mdl", USP_UNSIL_DRAW, "onehanded", UseDecrement()); } /* <2bae77> ../cstrike/dlls/wpn_shared/wpn_usp.cpp:147 */ -NOBODY void CUSP::__MAKE_VHOOK(SecondaryAttack)(void) +void CUSP::__MAKE_VHOOK(SecondaryAttack)(void) { -// SecondaryAttack(CUSP *const this); // 147 + if (ShieldSecondaryFire(USP_SHIELD_UP, USP_SHIELD_DOWN)) + { + return; + } + + if (m_iWeaponState & WPNSTATE_USP_SILENCED) + { + m_iWeaponState &= ~WPNSTATE_USP_SILENCED; + + SendWeaponAnim(USP_DETACH_SILENCER, UseDecrement() != FALSE); + Q_strcpy(m_pPlayer->m_szAnimExtention, "onehanded"); + } + else + { + m_iWeaponState |= WPNSTATE_USP_SILENCED; + + SendWeaponAnim(USP_ATTACH_SILENCER, UseDecrement() != FALSE); + Q_strcpy(m_pPlayer->m_szAnimExtention, "onehanded"); + } + + m_flNextSecondaryAttack = WEAPON_TIMEBASED + 3.0; + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 3.0; + + m_flNextPrimaryAttack = GetNextAttackDelay(3.0); } /* <2bb000> ../cstrike/dlls/wpn_shared/wpn_usp.cpp:173 */ -NOBODY void CUSP::__MAKE_VHOOK(PrimaryAttack)(void) +void CUSP::__MAKE_VHOOK(PrimaryAttack)(void) { -// Length2D(const Vector *const this); // 179 -// Length2D(const Vector *const this); // 190 + if (m_iWeaponState & WPNSTATE_USP_SILENCED) + { + if (!(m_pPlayer->pev->flags & FL_ONGROUND)) + { + USPFire(1.3 * (1 - m_flAccuracy), 0.225, FALSE); + } + else if (m_pPlayer->pev->velocity.Length2D() > 0) + { + USPFire(0.25 * (1 - m_flAccuracy), 0.225, FALSE); + } + else if (m_pPlayer->pev->flags & FL_DUCKING) + { + USPFire(0.125 * (1 - m_flAccuracy), 0.225, FALSE); + } + else + { + USPFire(0.15 * (1 - m_flAccuracy), 0.225, FALSE); + } + } + else + { + if (!(m_pPlayer->pev->flags & FL_ONGROUND)) + { + USPFire(1.2 * (1 - m_flAccuracy), 0.225, FALSE); + } + else if (m_pPlayer->pev->velocity.Length2D() > 0) + { + USPFire(0.225 * (1 - m_flAccuracy), 0.225, FALSE); + } + else if (m_pPlayer->pev->flags & FL_DUCKING) + { + USPFire(0.08 * (1 - m_flAccuracy), 0.225, FALSE); + } + else + { + USPFire(0.1 * (1 - m_flAccuracy), 0.225, FALSE); + } + } } /* <2bb10f> ../cstrike/dlls/wpn_shared/wpn_usp.cpp:200 */ -UNTESTED void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) +void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) { int flag; - //int iDamage;//unused - //Vector vecAiming;//unused - //Vector vecSrc;//unused + int iDamage; + Vector vecAiming; + Vector vecSrc; Vector vecDir; - flCycleTime -= 0.075f; - - m_iShotsFired++; - if (m_iShotsFired > 1) - return; - - if (m_flLastFire != 0.0f) + flCycleTime -= 0.075; + + if (++m_iShotsFired > 1) { - m_flAccuracy -= (0.3f - (gpGlobals->time - m_flLastFire)) * 0.275f; - if (m_flAccuracy > 0.92f) - m_flAccuracy = 0.92f; - else if (m_flAccuracy < 0.6f) - m_flAccuracy = 0.6f; + return; } - + + if (m_flLastFire != 0.0) + { + m_flAccuracy -= (0.3 - (gpGlobals->time - m_flLastFire)) * 0.275; + + if (m_flAccuracy > 0.92) + { + m_flAccuracy = 0.92; + } + else if (m_flAccuracy < 0.6) + { + m_flAccuracy = 0.6; + } + } + m_flLastFire = gpGlobals->time; + if (m_iClip <= 0) { if (m_fFireOnEmpty) @@ -150,44 +227,81 @@ UNTESTED void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) PlayEmptySound(); m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } + if (TheBots != NULL) { - TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer, NULL); + TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } + return; } m_flNextSecondaryAttack = GetNextAttackDelay(flCycleTime); m_flNextPrimaryAttack = m_flNextSecondaryAttack; + m_iClip--; - SetPlayerShieldAnim(); - m_pPlayer->SetAnimation(PLAYER_ATTACK1); + m_pPlayer->SetAnimation(PLAYER_ATTACK1); m_pPlayer->m_iWeaponVolume = 2048; m_pPlayer->m_iWeaponFlash = 128; - UTIL_MakeVectors(m_pPlayer->pev->punchangle + m_pPlayer->pev->v_angle); + UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); if (!(m_iWeaponState & WPNSTATE_USP_SILENCED)) + { m_pPlayer->pev->effects |= EF_MUZZLEFLASH; + } - vecDir = FireBullets3(m_pPlayer->GetGunPosition(), gpGlobals->v_forward, flSpread, 4096, 1, BULLET_PLAYER_45ACP, (m_iWeaponState & WPNSTATE_USP_SILENCED) ? 30 : 34, 0.79f, m_pPlayer->pev, true, m_pPlayer->random_seed); + vecSrc = m_pPlayer->GetGunPosition(); + vecDir = gpGlobals->v_forward; + + iDamage = (m_iWeaponState & WPNSTATE_USP_SILENCED) ? 30 : 34; + + vecAiming = m_pPlayer->FireBullets3 + ( + vecSrc, + vecDir, + flSpread, + 4096.0, + 1, + BULLET_PLAYER_45ACP, + iDamage, + 0.79, + m_pPlayer->pev, + true, + m_pPlayer->random_seed + ); #ifdef CLIENT_WEAPONS flag = FEV_NOTHOST; #else flag = 0; -#endif - PLAYBACK_EVENT_FULL(flag, m_pPlayer->edict(), m_usFireUSP, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100.0f), 0, m_iClip == 0, (int)(m_iWeaponState & WPNSTATE_USP_SILENCED)); +#endif // CLIENT_WEAPONS + + PLAYBACK_EVENT_FULL + ( + flag, + ENT(m_pPlayer->pev), + m_usFireUSP, + 0, + (float *)&g_vecZero, + (float *)&g_vecZero, + vecAiming.x, + vecAiming.y, + (int)(m_pPlayer->pev->punchangle.x * 100), + 0, + m_iClip == 0, + (m_iWeaponState & WPNSTATE_USP_SILENCED) + ); if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) - { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", 0, 0); - } - - m_flTimeWeaponIdle = 2.0f; - m_pPlayer->pev->punchangle.x -= 2.0f; + { + m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, FALSE); + } + + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 2; + m_pPlayer->pev->punchangle.x -= 2; ResetPlayerShieldAnim(); } @@ -195,15 +309,21 @@ UNTESTED void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) void CUSP::__MAKE_VHOOK(Reload)(void) { if (m_pPlayer->ammo_45acp <= 0) + { return; + } int iResult; if (m_pPlayer->HasShield()) - iResult = DefaultReload(USP_MAX_CLIP, USP_SHIELD_RELOAD, 2.7); + { + iResult = DefaultReload(USP_MAX_CLIP, USP_SHIELD_RELOAD, USP_RELOAD_TIME); + } else if (m_iWeaponState & WPNSTATE_USP_SILENCED) - iResult = DefaultReload(USP_MAX_CLIP, USP_RELOAD, 2.7); + { + iResult = DefaultReload(USP_MAX_CLIP, USP_RELOAD, USP_RELOAD_TIME); + } else - iResult = DefaultReload(USP_MAX_CLIP, USP_UNSIL_RELOAD, 2.7); + iResult = DefaultReload(USP_MAX_CLIP, USP_UNSIL_RELOAD, USP_RELOAD_TIME); if (iResult) { @@ -216,23 +336,28 @@ void CUSP::__MAKE_VHOOK(Reload)(void) void CUSP::__MAKE_VHOOK(WeaponIdle)(void) { ResetEmptySound(); - m_pPlayer->GetAutoaimVector(0.173648); - - if (m_flTimeWeaponIdle > 0.0f) + m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); + + if (m_flTimeWeaponIdle > 0) + { return; + } if (m_pPlayer->HasShield()) { - m_flTimeWeaponIdle = 20.0f; + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 20.0; + if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN) - SendWeaponAnim(USP_DRAW, UseDecrement() != FALSE); + { + SendWeaponAnim(USP_DRAW, UseDecrement()); + } } else if (m_iClip) { - //int iAnim = USP_UNSIL_IDLE * (~m_iWeaponState & WPNSTATE_USP_SILENCED); - int iAnim = (~m_iWeaponState & WPNSTATE_USP_SILENCED) ? USP_UNSIL_IDLE: USP_IDLE;// : USP_UNSIL_IDLE; - m_flTimeWeaponIdle = 60.0f; - SendWeaponAnim(iAnim, UseDecrement() != FALSE); + int iAnim = (~m_iWeaponState & WPNSTATE_USP_SILENCED) ? USP_UNSIL_IDLE: USP_IDLE; + + m_flTimeWeaponIdle = WEAPON_TIMEBASED + 60.0; + SendWeaponAnim(iAnim, UseDecrement()); } } @@ -242,30 +367,37 @@ void CUSP::Spawn(void) { Spawn_(); } + void CUSP::Precache(void) { Precache_(); } + int CUSP::GetItemInfo(ItemInfo *p) { return GetItemInfo_(p); } + BOOL CUSP::Deploy(void) { return Deploy_(); } + void CUSP::SecondaryAttack(void) { SecondaryAttack_(); } + void CUSP::PrimaryAttack(void) { PrimaryAttack_(); } + void CUSP::Reload(void) { Reload_(); } + void CUSP::WeaponIdle(void) { WeaponIdle_(); diff --git a/regamedll/engine/anorms.h b/regamedll/engine/anorms.h index c90f8d6f..32fa2d1f 100644 --- a/regamedll/engine/anorms.h +++ b/regamedll/engine/anorms.h @@ -1,9 +1,9 @@ /*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting @@ -13,165 +13,165 @@ * ****/ -{-0.525731, 0.000000, 0.850651}, -{-0.442863, 0.238856, 0.864188}, -{-0.295242, 0.000000, 0.955423}, -{-0.309017, 0.500000, 0.809017}, -{-0.162460, 0.262866, 0.951056}, -{0.000000, 0.000000, 1.000000}, -{0.000000, 0.850651, 0.525731}, -{-0.147621, 0.716567, 0.681718}, -{0.147621, 0.716567, 0.681718}, -{0.000000, 0.525731, 0.850651}, -{0.309017, 0.500000, 0.809017}, -{0.525731, 0.000000, 0.850651}, -{0.295242, 0.000000, 0.955423}, -{0.442863, 0.238856, 0.864188}, -{0.162460, 0.262866, 0.951056}, -{-0.681718, 0.147621, 0.716567}, -{-0.809017, 0.309017, 0.500000}, -{-0.587785, 0.425325, 0.688191}, -{-0.850651, 0.525731, 0.000000}, -{-0.864188, 0.442863, 0.238856}, -{-0.716567, 0.681718, 0.147621}, -{-0.688191, 0.587785, 0.425325}, -{-0.500000, 0.809017, 0.309017}, -{-0.238856, 0.864188, 0.442863}, -{-0.425325, 0.688191, 0.587785}, -{-0.716567, 0.681718, -0.147621}, -{-0.500000, 0.809017, -0.309017}, -{-0.525731, 0.850651, 0.000000}, -{0.000000, 0.850651, -0.525731}, -{-0.238856, 0.864188, -0.442863}, -{0.000000, 0.955423, -0.295242}, -{-0.262866, 0.951056, -0.162460}, -{0.000000, 1.000000, 0.000000}, -{0.000000, 0.955423, 0.295242}, -{-0.262866, 0.951056, 0.162460}, -{0.238856, 0.864188, 0.442863}, -{0.262866, 0.951056, 0.162460}, -{0.500000, 0.809017, 0.309017}, -{0.238856, 0.864188, -0.442863}, -{0.262866, 0.951056, -0.162460}, -{0.500000, 0.809017, -0.309017}, -{0.850651, 0.525731, 0.000000}, -{0.716567, 0.681718, 0.147621}, -{0.716567, 0.681718, -0.147621}, -{0.525731, 0.850651, 0.000000}, -{0.425325, 0.688191, 0.587785}, -{0.864188, 0.442863, 0.238856}, -{0.688191, 0.587785, 0.425325}, -{0.809017, 0.309017, 0.500000}, -{0.681718, 0.147621, 0.716567}, -{0.587785, 0.425325, 0.688191}, -{0.955423, 0.295242, 0.000000}, -{1.000000, 0.000000, 0.000000}, -{0.951056, 0.162460, 0.262866}, -{0.850651, -0.525731, 0.000000}, -{0.955423, -0.295242, 0.000000}, -{0.864188, -0.442863, 0.238856}, -{0.951056, -0.162460, 0.262866}, -{0.809017, -0.309017, 0.500000}, -{0.681718, -0.147621, 0.716567}, -{0.850651, 0.000000, 0.525731}, -{0.864188, 0.442863, -0.238856}, -{0.809017, 0.309017, -0.500000}, -{0.951056, 0.162460, -0.262866}, -{0.525731, 0.000000, -0.850651}, -{0.681718, 0.147621, -0.716567}, -{0.681718, -0.147621, -0.716567}, -{0.850651, 0.000000, -0.525731}, -{0.809017, -0.309017, -0.500000}, -{0.864188, -0.442863, -0.238856}, -{0.951056, -0.162460, -0.262866}, -{0.147621, 0.716567, -0.681718}, -{0.309017, 0.500000, -0.809017}, -{0.425325, 0.688191, -0.587785}, -{0.442863, 0.238856, -0.864188}, -{0.587785, 0.425325, -0.688191}, -{0.688191, 0.587785, -0.425325}, -{-0.147621, 0.716567, -0.681718}, -{-0.309017, 0.500000, -0.809017}, -{0.000000, 0.525731, -0.850651}, -{-0.525731, 0.000000, -0.850651}, -{-0.442863, 0.238856, -0.864188}, -{-0.295242, 0.000000, -0.955423}, -{-0.162460, 0.262866, -0.951056}, -{0.000000, 0.000000, -1.000000}, -{0.295242, 0.000000, -0.955423}, -{0.162460, 0.262866, -0.951056}, -{-0.442863, -0.238856, -0.864188}, -{-0.309017, -0.500000, -0.809017}, -{-0.162460, -0.262866, -0.951056}, -{0.000000, -0.850651, -0.525731}, -{-0.147621, -0.716567, -0.681718}, -{0.147621, -0.716567, -0.681718}, -{0.000000, -0.525731, -0.850651}, -{0.309017, -0.500000, -0.809017}, -{0.442863, -0.238856, -0.864188}, -{0.162460, -0.262866, -0.951056}, -{0.238856, -0.864188, -0.442863}, -{0.500000, -0.809017, -0.309017}, -{0.425325, -0.688191, -0.587785}, -{0.716567, -0.681718, -0.147621}, -{0.688191, -0.587785, -0.425325}, -{0.587785, -0.425325, -0.688191}, -{0.000000, -0.955423, -0.295242}, -{0.000000, -1.000000, 0.000000}, -{0.262866, -0.951056, -0.162460}, -{0.000000, -0.850651, 0.525731}, -{0.000000, -0.955423, 0.295242}, -{0.238856, -0.864188, 0.442863}, -{0.262866, -0.951056, 0.162460}, -{0.500000, -0.809017, 0.309017}, -{0.716567, -0.681718, 0.147621}, -{0.525731, -0.850651, 0.000000}, -{-0.238856, -0.864188, -0.442863}, -{-0.500000, -0.809017, -0.309017}, -{-0.262866, -0.951056, -0.162460}, -{-0.850651, -0.525731, 0.000000}, -{-0.716567, -0.681718, -0.147621}, -{-0.716567, -0.681718, 0.147621}, -{-0.525731, -0.850651, 0.000000}, -{-0.500000, -0.809017, 0.309017}, -{-0.238856, -0.864188, 0.442863}, -{-0.262866, -0.951056, 0.162460}, -{-0.864188, -0.442863, 0.238856}, -{-0.809017, -0.309017, 0.500000}, -{-0.688191, -0.587785, 0.425325}, -{-0.681718, -0.147621, 0.716567}, -{-0.442863, -0.238856, 0.864188}, -{-0.587785, -0.425325, 0.688191}, -{-0.309017, -0.500000, 0.809017}, -{-0.147621, -0.716567, 0.681718}, -{-0.425325, -0.688191, 0.587785}, -{-0.162460, -0.262866, 0.951056}, -{0.442863, -0.238856, 0.864188}, -{0.162460, -0.262866, 0.951056}, -{0.309017, -0.500000, 0.809017}, -{0.147621, -0.716567, 0.681718}, -{0.000000, -0.525731, 0.850651}, -{0.425325, -0.688191, 0.587785}, -{0.587785, -0.425325, 0.688191}, -{0.688191, -0.587785, 0.425325}, -{-0.955423, 0.295242, 0.000000}, -{-0.951056, 0.162460, 0.262866}, -{-1.000000, 0.000000, 0.000000}, -{-0.850651, 0.000000, 0.525731}, -{-0.955423, -0.295242, 0.000000}, -{-0.951056, -0.162460, 0.262866}, -{-0.864188, 0.442863, -0.238856}, -{-0.951056, 0.162460, -0.262866}, -{-0.809017, 0.309017, -0.500000}, -{-0.864188, -0.442863, -0.238856}, -{-0.951056, -0.162460, -0.262866}, -{-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.688191, 0.587785, -0.425325}, -{-0.587785, 0.425325, -0.688191}, -{-0.425325, 0.688191, -0.587785}, -{-0.425325, -0.688191, -0.587785}, -{-0.587785, -0.425325, -0.688191}, -{-0.688191, -0.587785, -0.425325}, +{-0.525731, 0.000000, 0.850651}, +{-0.442863, 0.238856, 0.864188}, +{-0.295242, 0.000000, 0.955423}, +{-0.309017, 0.500000, 0.809017}, +{-0.162460, 0.262866, 0.951056}, +{0.000000, 0.000000, 1.000000}, +{0.000000, 0.850651, 0.525731}, +{-0.147621, 0.716567, 0.681718}, +{0.147621, 0.716567, 0.681718}, +{0.000000, 0.525731, 0.850651}, +{0.309017, 0.500000, 0.809017}, +{0.525731, 0.000000, 0.850651}, +{0.295242, 0.000000, 0.955423}, +{0.442863, 0.238856, 0.864188}, +{0.162460, 0.262866, 0.951056}, +{-0.681718, 0.147621, 0.716567}, +{-0.809017, 0.309017, 0.500000}, +{-0.587785, 0.425325, 0.688191}, +{-0.850651, 0.525731, 0.000000}, +{-0.864188, 0.442863, 0.238856}, +{-0.716567, 0.681718, 0.147621}, +{-0.688191, 0.587785, 0.425325}, +{-0.500000, 0.809017, 0.309017}, +{-0.238856, 0.864188, 0.442863}, +{-0.425325, 0.688191, 0.587785}, +{-0.716567, 0.681718, -0.147621}, +{-0.500000, 0.809017, -0.309017}, +{-0.525731, 0.850651, 0.000000}, +{0.000000, 0.850651, -0.525731}, +{-0.238856, 0.864188, -0.442863}, +{0.000000, 0.955423, -0.295242}, +{-0.262866, 0.951056, -0.162460}, +{0.000000, 1.000000, 0.000000}, +{0.000000, 0.955423, 0.295242}, +{-0.262866, 0.951056, 0.162460}, +{0.238856, 0.864188, 0.442863}, +{0.262866, 0.951056, 0.162460}, +{0.500000, 0.809017, 0.309017}, +{0.238856, 0.864188, -0.442863}, +{0.262866, 0.951056, -0.162460}, +{0.500000, 0.809017, -0.309017}, +{0.850651, 0.525731, 0.000000}, +{0.716567, 0.681718, 0.147621}, +{0.716567, 0.681718, -0.147621}, +{0.525731, 0.850651, 0.000000}, +{0.425325, 0.688191, 0.587785}, +{0.864188, 0.442863, 0.238856}, +{0.688191, 0.587785, 0.425325}, +{0.809017, 0.309017, 0.500000}, +{0.681718, 0.147621, 0.716567}, +{0.587785, 0.425325, 0.688191}, +{0.955423, 0.295242, 0.000000}, +{1.000000, 0.000000, 0.000000}, +{0.951056, 0.162460, 0.262866}, +{0.850651, -0.525731, 0.000000}, +{0.955423, -0.295242, 0.000000}, +{0.864188, -0.442863, 0.238856}, +{0.951056, -0.162460, 0.262866}, +{0.809017, -0.309017, 0.500000}, +{0.681718, -0.147621, 0.716567}, +{0.850651, 0.000000, 0.525731}, +{0.864188, 0.442863, -0.238856}, +{0.809017, 0.309017, -0.500000}, +{0.951056, 0.162460, -0.262866}, +{0.525731, 0.000000, -0.850651}, +{0.681718, 0.147621, -0.716567}, +{0.681718, -0.147621, -0.716567}, +{0.850651, 0.000000, -0.525731}, +{0.809017, -0.309017, -0.500000}, +{0.864188, -0.442863, -0.238856}, +{0.951056, -0.162460, -0.262866}, +{0.147621, 0.716567, -0.681718}, +{0.309017, 0.500000, -0.809017}, +{0.425325, 0.688191, -0.587785}, +{0.442863, 0.238856, -0.864188}, +{0.587785, 0.425325, -0.688191}, +{0.688191, 0.587785, -0.425325}, +{-0.147621, 0.716567, -0.681718}, +{-0.309017, 0.500000, -0.809017}, +{0.000000, 0.525731, -0.850651}, +{-0.525731, 0.000000, -0.850651}, +{-0.442863, 0.238856, -0.864188}, +{-0.295242, 0.000000, -0.955423}, +{-0.162460, 0.262866, -0.951056}, +{0.000000, 0.000000, -1.000000}, +{0.295242, 0.000000, -0.955423}, +{0.162460, 0.262866, -0.951056}, +{-0.442863, -0.238856, -0.864188}, +{-0.309017, -0.500000, -0.809017}, +{-0.162460, -0.262866, -0.951056}, +{0.000000, -0.850651, -0.525731}, +{-0.147621, -0.716567, -0.681718}, +{0.147621, -0.716567, -0.681718}, +{0.000000, -0.525731, -0.850651}, +{0.309017, -0.500000, -0.809017}, +{0.442863, -0.238856, -0.864188}, +{0.162460, -0.262866, -0.951056}, +{0.238856, -0.864188, -0.442863}, +{0.500000, -0.809017, -0.309017}, +{0.425325, -0.688191, -0.587785}, +{0.716567, -0.681718, -0.147621}, +{0.688191, -0.587785, -0.425325}, +{0.587785, -0.425325, -0.688191}, +{0.000000, -0.955423, -0.295242}, +{0.000000, -1.000000, 0.000000}, +{0.262866, -0.951056, -0.162460}, +{0.000000, -0.850651, 0.525731}, +{0.000000, -0.955423, 0.295242}, +{0.238856, -0.864188, 0.442863}, +{0.262866, -0.951056, 0.162460}, +{0.500000, -0.809017, 0.309017}, +{0.716567, -0.681718, 0.147621}, +{0.525731, -0.850651, 0.000000}, +{-0.238856, -0.864188, -0.442863}, +{-0.500000, -0.809017, -0.309017}, +{-0.262866, -0.951056, -0.162460}, +{-0.850651, -0.525731, 0.000000}, +{-0.716567, -0.681718, -0.147621}, +{-0.716567, -0.681718, 0.147621}, +{-0.525731, -0.850651, 0.000000}, +{-0.500000, -0.809017, 0.309017}, +{-0.238856, -0.864188, 0.442863}, +{-0.262866, -0.951056, 0.162460}, +{-0.864188, -0.442863, 0.238856}, +{-0.809017, -0.309017, 0.500000}, +{-0.688191, -0.587785, 0.425325}, +{-0.681718, -0.147621, 0.716567}, +{-0.442863, -0.238856, 0.864188}, +{-0.587785, -0.425325, 0.688191}, +{-0.309017, -0.500000, 0.809017}, +{-0.147621, -0.716567, 0.681718}, +{-0.425325, -0.688191, 0.587785}, +{-0.162460, -0.262866, 0.951056}, +{0.442863, -0.238856, 0.864188}, +{0.162460, -0.262866, 0.951056}, +{0.309017, -0.500000, 0.809017}, +{0.147621, -0.716567, 0.681718}, +{0.000000, -0.525731, 0.850651}, +{0.425325, -0.688191, 0.587785}, +{0.587785, -0.425325, 0.688191}, +{0.688191, -0.587785, 0.425325}, +{-0.955423, 0.295242, 0.000000}, +{-0.951056, 0.162460, 0.262866}, +{-1.000000, 0.000000, 0.000000}, +{-0.850651, 0.000000, 0.525731}, +{-0.955423, -0.295242, 0.000000}, +{-0.951056, -0.162460, 0.262866}, +{-0.864188, 0.442863, -0.238856}, +{-0.951056, 0.162460, -0.262866}, +{-0.809017, 0.309017, -0.500000}, +{-0.864188, -0.442863, -0.238856}, +{-0.951056, -0.162460, -0.262866}, +{-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.688191, 0.587785, -0.425325}, +{-0.587785, 0.425325, -0.688191}, +{-0.425325, 0.688191, -0.587785}, +{-0.425325, -0.688191, -0.587785}, +{-0.587785, -0.425325, -0.688191}, +{-0.688191, -0.587785, -0.425325}, diff --git a/regamedll/engine/bspfile.h b/regamedll/engine/bspfile.h index 37cc9f95..a2e5ddf4 100644 --- a/regamedll/engine/bspfile.h +++ b/regamedll/engine/bspfile.h @@ -36,145 +36,157 @@ #define BSPVERSION 30 -#define MAX_MAP_HULLS 4 +#define MAX_MAP_HULLS 4 -#define CONTENTS_ORIGIN -7 // removed at csg time -#define CONTENTS_CLIP -8 // changed to contents_solid +#define CONTENTS_ORIGIN -7 // removed at csg time +#define CONTENTS_CLIP -8 // changed to contents_solid #define CONTENTS_CURRENT_0 -9 #define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 +#define CONTENTS_CURRENT_180 -11 +#define CONTENTS_CURRENT_270 -12 #define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 +#define CONTENTS_CURRENT_DOWN -14 -#define CONTENTS_TRANSLUCENT -15 +#define CONTENTS_TRANSLUCENT -15 -#define LUMP_ENTITIES 0 -#define LUMP_PLANES 1 -#define LUMP_TEXTURES 2 -#define LUMP_VERTEXES 3 -#define LUMP_VISIBILITY 4 -#define LUMP_NODES 5 -#define LUMP_TEXINFO 6 -#define LUMP_FACES 7 -#define LUMP_LIGHTING 8 -#define LUMP_CLIPNODES 9 -#define LUMP_LEAFS 10 -#define LUMP_MARKSURFACES 11 -#define LUMP_EDGES 12 -#define LUMP_SURFEDGES 13 -#define LUMP_MODELS 14 +#define LUMP_ENTITIES 0 +#define LUMP_PLANES 1 +#define LUMP_TEXTURES 2 +#define LUMP_VERTEXES 3 +#define LUMP_VISIBILITY 4 +#define LUMP_NODES 5 +#define LUMP_TEXINFO 6 +#define LUMP_FACES 7 +#define LUMP_LIGHTING 8 +#define LUMP_CLIPNODES 9 +#define LUMP_LEAFS 10 +#define LUMP_MARKSURFACES 11 +#define LUMP_EDGES 12 +#define LUMP_SURFEDGES 13 +#define LUMP_MODELS 14 -#define HEADER_LUMPS 15 +#define HEADER_LUMPS 15 /* ../engine/bspfile.h:41 */ -typedef struct lump_s +typedef struct lump_s { - int fileofs; - int filelen; + int fileofs; + int filelen; + } lump_t; /* ../engine/bspfile.h:64 */ typedef struct dmodel_s { - float mins[3], maxs[3]; - float origin[3]; - int headnode[MAX_MAP_HULLS]; - int visleafs; // not including the solid leaf 0 - int firstface, numfaces; + float mins[3], maxs[3]; + float origin[3]; + int headnode[MAX_MAP_HULLS]; + int visleafs; // not including the solid leaf 0 + int firstface, numfaces; + } dmodel_t; /* ../engine/bspfile.h:73 */ typedef struct dheader_s { - int version; - lump_t lumps[15]; + int version; + lump_t lumps[15]; + } dheader_t; /* <485b2> ../engine/bspfile.h:79 */ typedef struct dmiptexlump_s { - int _nummiptex; - int dataofs[4]; + int _nummiptex; + int dataofs[4]; + } dmiptexlump_t; /* <1ce18> ../engine/bspfile.h:86 */ typedef struct miptex_s { - char name[16]; - unsigned width; - unsigned height; - unsigned offsets[4]; + char name[16]; + unsigned width; + unsigned height; + unsigned offsets[4]; + } miptex_t; /* <48652> ../engine/bspfile.h:94 */ typedef struct dvertex_s { - float point[3]; + float point[3]; + } dvertex_t; /* <48674> ../engine/bspfile.h:110 */ typedef struct dplane_s { - float normal[3]; - float dist; - int type; + float normal[3]; + float dist; + int type; + } dplane_t; /* <486b2> ../engine/bspfile.h:132 */ typedef struct dnode_s { - int planenum; - short children[2]; - short mins[3]; - short maxs[3]; - unsigned short firstface; - unsigned short numfaces; + int planenum; + short children[2]; + short mins[3]; + short maxs[3]; + unsigned short firstface; + unsigned short numfaces; + } dnode_t; /* ../engine/bspfile.h:142 */ typedef struct dclipnode_s { - int planenum; - short children[2]; // negative numbers are contents + int planenum; + short children[2]; // negative numbers are contents + } dclipnode_t; /* <4876a> ../engine/bspfile.h:149 */ typedef struct texinfo_s { - float vecs[2][4]; - int _miptex; - int flags; + float vecs[2][4]; + int _miptex; + int flags; + } texinfo_t; /* <487c2> ../engine/bspfile.h:159 */ typedef struct dedge_s { - unsigned short v[2]; + unsigned short v[2]; + } dedge_t; /* <487f2> ../engine/bspfile.h:165 */ typedef struct dface_s { - short planenum; - short side; - int firstedge; - short numedges; - short texinfo; - byte styles[4]; - int lightofs; + short planenum; + short side; + int firstedge; + short numedges; + short texinfo; + byte styles[4]; + int lightofs; + } dface_t; typedef struct dleaf_s { - int contents; - int visofs; - short mins[3]; - short maxs[3]; - unsigned short firstmarksurface; - unsigned short nummarksurfaces; - byte ambient_level[4]; + int contents; + int visofs; + short mins[3]; + short maxs[3]; + unsigned short firstmarksurface; + unsigned short nummarksurfaces; + byte ambient_level[4]; + } dleaf_t; - #endif // BSPFILE_H diff --git a/regamedll/engine/cdll_int.h b/regamedll/engine/cdll_int.h index 2c70fa53..022da6df 100644 --- a/regamedll/engine/cdll_int.h +++ b/regamedll/engine/cdll_int.h @@ -1,9 +1,9 @@ /*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting @@ -15,7 +15,7 @@ // // cdll_int.h // -// 4-23-98 +// 4-23-98 // JOHN: client dll interface declarations // @@ -159,7 +159,7 @@ typedef struct cl_enginefuncs_s int ( *GetMaxClients ) ( void ); void ( *Cvar_SetValue ) ( char *cvar, float value ); - int (*Cmd_Argc) (void); + int (*Cmd_Argc) (void); char *( *Cmd_Argv ) ( int arg ); void ( *Con_Printf ) ( char *fmt, ... ); void ( *Con_DPrintf ) ( char *fmt, ... ); @@ -211,7 +211,7 @@ typedef struct cl_enginefuncs_s byte* (*COM_LoadFile) ( char *path, int usehunk, int *pLength ); char* (*COM_ParseFile) ( char *data, char *token ); void (*COM_FreeFile) ( void *buffer ); - + struct triangleapi_s *pTriAPI; struct efx_api_s *pEfxAPI; struct event_api_s *pEventAPI; diff --git a/regamedll/engine/custom.h b/regamedll/engine/custom.h index 077832ac..08d60b8f 100644 --- a/regamedll/engine/custom.h +++ b/regamedll/engine/custom.h @@ -1,9 +1,9 @@ /*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting @@ -82,7 +82,7 @@ typedef struct customization_s { qboolean bInUse; // Is this customization in use; 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 *) int nUserData1; // Customization specific data int nUserData2; // Customization specific data @@ -96,8 +96,8 @@ typedef struct customization_s #define FCUST_IGNOREINIT ( 1<<2 ) void COM_ClearCustomizationList( struct customization_s *pHead, qboolean bCleanDecals); -qboolean COM_CreateCustomization( struct customization_s *pListHead, struct resource_s *pResource, int playernumber, int flags, - struct customization_s **pCustomization, int *nLumps ); +qboolean COM_CreateCustomization( struct customization_s *pListHead, struct resource_s *pResource, int playernumber, int flags, + struct customization_s **pCustomization, int *nLumps ); int COM_SizeofResourceList ( struct resource_s *pList, struct resourceinfo_s *ri ); #endif // CUSTOM_H diff --git a/regamedll/engine/customentity.h b/regamedll/engine/customentity.h index 49139790..6facf852 100644 --- a/regamedll/engine/customentity.h +++ b/regamedll/engine/customentity.h @@ -38,7 +38,7 @@ #define BEAMENT_ATTACHMENT(x) (((x)>>12) & 0xF) // Beam types, encoded as a byte -enum +enum { BEAM_POINTS = 0, BEAM_ENTPOINT, diff --git a/regamedll/engine/eiface.h b/regamedll/engine/eiface.h index cc180af8..d9da07b1 100644 --- a/regamedll/engine/eiface.h +++ b/regamedll/engine/eiface.h @@ -1,9 +1,9 @@ /*** * * Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting @@ -87,7 +87,7 @@ struct TraceResult }; // CD audio status -typedef struct +typedef struct { int fPlaying;// is sound playing right now? int fWasPlaying;// if not, CD is paused if WasPlaying is true. @@ -188,8 +188,8 @@ typedef struct enginefuncs_s const char *(*pfnNameForFunction) ( uint32 function ); void (*pfnClientPrintf) ( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint) ( const char *szMsg ); - const char *(*pfnCmd_Args) ( void ); // these 3 added - const char *(*pfnCmd_Argv) ( int argc ); // so game DLL can easily + const char *(*pfnCmd_Args) ( void ); // these 3 added + const char *(*pfnCmd_Argv) ( int argc ); // so game DLL can easily int (*pfnCmd_Argc) ( void ); // access client 'cmd' strings void (*pfnGetAttachment) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); void (*pfnCRC32_Init) (CRC32_t *pulCRC); @@ -270,7 +270,7 @@ typedef struct enginefuncs_s // PSV: Added for CZ training map // const char *(*pfnKeyNameForBinding) ( const char* pBinding ); - + sequenceEntry_s* (*pfnSequenceGet) ( const char* fileName, const char* entryName ); sentenceEntry_s* (*pfnSequencePickSentence) ( const char* groupName, int pickMethod, int *picked ); @@ -325,7 +325,7 @@ typedef struct } LEVELLIST; #define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags -typedef struct +typedef struct { int id; // Ordinal ID of this entity (used for entity <--> pointer conversions) edict_t *pent; // Pointer to the in-game entity @@ -345,7 +345,7 @@ typedef struct typedef struct saverestore_s SAVERESTOREDATA; #ifdef _WIN32 -typedef +typedef #endif struct saverestore_s { @@ -369,9 +369,9 @@ struct saverestore_s float time; char szCurrentMapName[32]; // To check global entities -} +} #ifdef _WIN32 -SAVERESTOREDATA +SAVERESTOREDATA #endif ; @@ -412,7 +412,7 @@ typedef enum _fieldtypes #define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore -typedef struct +typedef struct { FIELDTYPE fieldType; char *fieldName; @@ -425,10 +425,10 @@ typedef struct #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) #endif -typedef struct +typedef struct { // Initialize/shutdown the game (one-time call after loading of game .dll ) - void (*pfnGameInit) ( void ); + void (*pfnGameInit) ( void ); int (*pfnSpawn) ( edict_t *pent ); void (*pfnThink) ( edict_t *pent ); void (*pfnUse) ( edict_t *pentUsed, edict_t *pentOther ); @@ -447,7 +447,7 @@ typedef struct void (*pfnResetGlobalState) ( void ); qboolean (*pfnClientConnect) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); - + void (*pfnClientDisconnect) ( edict_t *pEntity ); void (*pfnClientKill) ( edict_t *pEntity ); void (*pfnClientPutInServer) ( edict_t *pEntity ); @@ -465,10 +465,10 @@ typedef struct void (*pfnParmsChangeLevel) ( void ); // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life - const char *(*pfnGetGameDescription)( void ); + const char *(*pfnGetGameDescription)( void ); // Notify dll about a player customization. - void (*pfnPlayerCustomization) ( edict_t *pEntity, customization_t *pCustom ); + void (*pfnPlayerCustomization) ( edict_t *pEntity, customization_t *pCustom ); // Spectator funcs void (*pfnSpectatorConnect) ( edict_t *pEntity ); @@ -519,7 +519,7 @@ extern DLL_FUNCTIONS gEntityInterface; typedef struct { - // Called right before the object's memory is freed. + // Called right before the object's memory is freed. // Calls its destructor. void (*pfnOnFreeEntPrivateData)(edict_t *pEnt); void (*pfnGameShutdown)(void); diff --git a/regamedll/engine/keydefs.h b/regamedll/engine/keydefs.h index aec54c98..1289f3ab 100644 --- a/regamedll/engine/keydefs.h +++ b/regamedll/engine/keydefs.h @@ -1,6 +1,6 @@ //========= Copyright 1996-2002, Valve LLC, All rights reserved. ============ // -// Purpose: +// Purpose: // // $NoKeywords: $ //============================================================================= diff --git a/regamedll/engine/maintypes.h b/regamedll/engine/maintypes.h index bf0d6f7d..454d2ce2 100644 --- a/regamedll/engine/maintypes.h +++ b/regamedll/engine/maintypes.h @@ -56,7 +56,7 @@ typedef int BOOL; #ifndef __cplusplus typedef enum { false, true } qboolean; -#else +#else typedef int qboolean; #endif diff --git a/regamedll/engine/model.h b/regamedll/engine/model.h index c88644ed..f382d7ba 100644 --- a/regamedll/engine/model.h +++ b/regamedll/engine/model.h @@ -45,7 +45,7 @@ #define SURF_DRAWSPRITE 8 #define SURF_DRAWTURB 0x10 #define SURF_DRAWTILED 0x20 -#define SURF_DRAWBACKGROUND 0x40 +#define SURF_DRAWBACKGROUND 0x40 #define MAX_MODEL_NAME 64 #define MIPLEVELS 4 diff --git a/regamedll/engine/progdefs.h b/regamedll/engine/progdefs.h index 4a39b319..0b71a7a8 100644 --- a/regamedll/engine/progdefs.h +++ b/regamedll/engine/progdefs.h @@ -30,187 +30,187 @@ #define PROGDEFS_H #ifdef _WIN32 #pragma once -#endif - -typedef struct -{ - float time; - float frametime; - float force_retouch; - string_t mapname; - string_t startspot; - float deathmatch; - float coop; - float teamplay; - float serverflags; - float found_secrets; - Vector v_forward; - Vector v_up; - Vector v_right; - float trace_allsolid; - float trace_startsolid; - float trace_fraction; - Vector trace_endpos; - Vector trace_plane_normal; - float trace_plane_dist; - edict_t *trace_ent; - float trace_inopen; - float trace_inwater; - int trace_hitgroup; - int trace_flags; - int msg_entity; - int cdAudioTrack; - int maxClients; - int maxEntities; - const char *pStringBase; - void *pSaveData; - Vector vecLandmarkOffset; -} globalvars_t; - -typedef struct entvars_s -{ - string_t classname; - string_t globalname; - - Vector origin; - Vector oldorigin; - Vector velocity; - Vector basevelocity; - Vector 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. - Vector movedir; - Vector angles; // Model angles - Vector avelocity; // angle velocity (degrees per second) - Vector punchangle; // auto-decaying view angle adjustment - Vector v_angle; // Viewing angle (player only) - - Vector endpos; - Vector startpos; - float impacttime; - float starttime; - int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity - float idealpitch; - float pitch_speed; - float ideal_yaw; - float yaw_speed; - - int modelindex; - string_t model; - int viewmodel; // player's viewmodel - int weaponmodel; // what other players see - - Vector absmin; // BB max translated to world coord - Vector absmax; // BB max translated to world coord - Vector mins; // local BB min - Vector maxs; // local BB max - Vector size; // maxs - mins - - float ltime; - float nextthink; - int movetype; - int solid; - int skin; - int body; // sub-model selection for studiomodels - int effects; - float gravity; // % of "normal" gravity - float friction; // inverse elasticity of MOVETYPE_BOUNCE - int light_level; - int sequence; // animation sequence - int gaitsequence; // movement animation sequence for player (0 for none) - float frame; // % playback position in animation sequences (0..255) - float animtime; // world time when frame was set - float framerate; // animation playback rate (-8x to 8x) - byte controller[4]; // bone controller setting (0..255) - byte blending[2]; // blending amount between sub-sequences (0..255) - - float scale; // sprite rendering scale (0..255) - int rendermode; - float renderamt; - Vector rendercolor; - int renderfx; - float health; - float frags; - int weapons; // bit mask for available weapons - float takedamage; - - int deadflag; - Vector view_ofs; // eye position - int button; - int impulse; - - edict_t *chain; // Entity pointer when linked into a linked list - edict_t *dmg_inflictor; - edict_t *enemy; - edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW - edict_t *owner; - edict_t *groundentity; - - int spawnflags; - int flags; - int colormap; // lowbyte topcolor, highbyte bottomcolor - int team; - float max_health; - float teleport_time; - float armortype; - float armorvalue; - int waterlevel; - int watertype; - - string_t target; - string_t targetname; - string_t netname; - string_t message; - - float dmg_take; - float dmg_save; - float dmg; - float dmgtime; - - string_t noise; - string_t noise1; - string_t noise2; - string_t noise3; - - float speed; - float air_finished; - float pain_finished; - float radsuit_finished; - - edict_t *pContainingEntity; - - int playerclass; - float maxspeed; - float fov; - int weaponanim; - int pushmsec; - int bInDuck; - int flTimeStepSound; - int flSwimTime; - int flDuckTime; - int iStepLeft; - float flFallVelocity; - - int gamestate; - int oldbuttons; - int groupinfo; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - Vector vuser1; - Vector vuser2; - Vector vuser3; - Vector vuser4; - edict_t *euser1; - edict_t *euser2; - edict_t *euser3; - edict_t *euser4; -} entvars_t; - -#endif // PROGDEFS_H +#endif + +typedef struct +{ + float time; + float frametime; + float force_retouch; + string_t mapname; + string_t startspot; + float deathmatch; + float coop; + float teamplay; + float serverflags; + float found_secrets; + Vector v_forward; + Vector v_up; + Vector v_right; + float trace_allsolid; + float trace_startsolid; + float trace_fraction; + Vector trace_endpos; + Vector trace_plane_normal; + float trace_plane_dist; + edict_t *trace_ent; + float trace_inopen; + float trace_inwater; + int trace_hitgroup; + int trace_flags; + int msg_entity; + int cdAudioTrack; + int maxClients; + int maxEntities; + const char *pStringBase; + void *pSaveData; + Vector vecLandmarkOffset; +} globalvars_t; + +typedef struct entvars_s +{ + string_t classname; + string_t globalname; + + Vector origin; + Vector oldorigin; + Vector velocity; + Vector basevelocity; + Vector 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. + Vector movedir; + Vector angles; // Model angles + Vector avelocity; // angle velocity (degrees per second) + Vector punchangle; // auto-decaying view angle adjustment + Vector v_angle; // Viewing angle (player only) + + Vector endpos; + Vector startpos; + float impacttime; + float starttime; + int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity + float idealpitch; + float pitch_speed; + float ideal_yaw; + float yaw_speed; + + int modelindex; + string_t model; + int viewmodel; // player's viewmodel + int weaponmodel; // what other players see + + Vector absmin; // BB max translated to world coord + Vector absmax; // BB max translated to world coord + Vector mins; // local BB min + Vector maxs; // local BB max + Vector size; // maxs - mins + + float ltime; + float nextthink; + int movetype; + int solid; + int skin; + int body; // sub-model selection for studiomodels + int effects; + float gravity; // % of "normal" gravity + float friction; // inverse elasticity of MOVETYPE_BOUNCE + int light_level; + int sequence; // animation sequence + int gaitsequence; // movement animation sequence for player (0 for none) + float frame; // % playback position in animation sequences (0..255) + float animtime; // world time when frame was set + float framerate; // animation playback rate (-8x to 8x) + byte controller[4]; // bone controller setting (0..255) + byte blending[2]; // blending amount between sub-sequences (0..255) + + float scale; // sprite rendering scale (0..255) + int rendermode; + float renderamt; + Vector rendercolor; + int renderfx; + float health; + float frags; + int weapons; // bit mask for available weapons + float takedamage; + + int deadflag; + Vector view_ofs; // eye position + int button; + int impulse; + + edict_t *chain; // Entity pointer when linked into a linked list + edict_t *dmg_inflictor; + edict_t *enemy; + edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW + edict_t *owner; + edict_t *groundentity; + + int spawnflags; + int flags; + int colormap; // lowbyte topcolor, highbyte bottomcolor + int team; + float max_health; + float teleport_time; + float armortype; + float armorvalue; + int waterlevel; + int watertype; + + string_t target; + string_t targetname; + string_t netname; + string_t message; + + float dmg_take; + float dmg_save; + float dmg; + float dmgtime; + + string_t noise; + string_t noise1; + string_t noise2; + string_t noise3; + + float speed; + float air_finished; + float pain_finished; + float radsuit_finished; + + edict_t *pContainingEntity; + + int playerclass; + float maxspeed; + float fov; + int weaponanim; + int pushmsec; + int bInDuck; + int flTimeStepSound; + int flSwimTime; + int flDuckTime; + int iStepLeft; + float flFallVelocity; + + int gamestate; + int oldbuttons; + int groupinfo; + + // For mods + int iuser1; + int iuser2; + int iuser3; + int iuser4; + float fuser1; + float fuser2; + float fuser3; + float fuser4; + Vector vuser1; + Vector vuser2; + Vector vuser3; + Vector vuser4; + edict_t *euser1; + edict_t *euser2; + edict_t *euser3; + edict_t *euser4; +} entvars_t; + +#endif // PROGDEFS_H diff --git a/regamedll/engine/progs.h b/regamedll/engine/progs.h index 90dac5d5..6dbf5b56 100644 --- a/regamedll/engine/progs.h +++ b/regamedll/engine/progs.h @@ -1,9 +1,9 @@ /*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting @@ -37,10 +37,10 @@ struct event_info_s 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 ) - + event_args_t args; -// CLIENT ONLY +// CLIENT ONLY int flags; // Reliable or not, etc. }; diff --git a/regamedll/engine/shake.h b/regamedll/engine/shake.h index 9b619a95..e677e845 100644 --- a/regamedll/engine/shake.h +++ b/regamedll/engine/shake.h @@ -38,6 +38,7 @@ typedef struct unsigned short amplitude; // FIXED 4.12 amount of shake unsigned short duration; // FIXED 4.12 seconds duration unsigned short frequency; // FIXED 8.8 noise frequency (low frequency is a jerk,high frequency is a rumble) + } ScreenShake; #define FFADE_IN 0x0000 // Just here so we don't pass 0 into the function @@ -52,6 +53,7 @@ typedef struct unsigned short holdTime; // FIXED 4.12 seconds duration until reset (fade & hold) short fadeFlags; // flags byte r,g,b,a; // fade to color ( max alpha ) + } ScreenFade; #endif // SHAKE_H diff --git a/regamedll/engine/studio.h b/regamedll/engine/studio.h index 95c1dd84..51334f20 100644 --- a/regamedll/engine/studio.h +++ b/regamedll/engine/studio.h @@ -56,7 +56,7 @@ // motion flags #define STUDIO_X 0x0001 -#define STUDIO_Y 0x0002 +#define STUDIO_Y 0x0002 #define STUDIO_Z 0x0004 #define STUDIO_XR 0x0008 #define STUDIO_YR 0x0010 @@ -85,7 +85,7 @@ #define RAD_TO_STUDIO (32768.0/M_PI) #define STUDIO_TO_RAD (M_PI/32768.0) -typedef struct +typedef struct { int id; int version; @@ -93,16 +93,16 @@ typedef struct int length; vec3_t eyeposition; // ideal eye position vec3_t min; // ideal movement hull size - vec3_t max; + vec3_t max; vec3_t bbmin; // clipping bounding box - vec3_t bbmax; + vec3_t bbmax; int flags; int numbones; // bones int boneindex; int numbonecontrollers; // bone controllers int bonecontrollerindex; int numhitboxes; // complex bounding boxes - int hitboxindex; + int hitboxindex; int numseq; // animation sequences int seqindex; int numseqgroups; // demand loaded sequences @@ -113,7 +113,7 @@ typedef struct int numskinref; // replaceable textures int numskinfamilies; int skinindex; - int numbodyparts; + int numbodyparts; int bodypartindex; int numattachments; // queryable attachable points int attachmentindex; @@ -127,7 +127,7 @@ typedef struct /* size: 244, cachelines: 4, members: 36 */ // bones -typedef struct +typedef struct { char name[32]; // bone name for symbolic links int parent; // parent bone @@ -139,7 +139,7 @@ typedef struct /* size: 112, cachelines: 2, members: 6 */ // bone controllers -typedef struct +typedef struct { int bone; // -1 == 0 int type; // X, Y, Z, XR, YR, ZR, M @@ -164,7 +164,7 @@ typedef struct typedef struct { char label[32]; // sequence label - float fps; // frames per second + float fps; // frames per second int flags; // looping/non-looping flags int activity; int actweight; @@ -173,13 +173,13 @@ typedef struct int numframes; // number of frames per sequence int numpivots; // number of foot pivots int pivotindex; - int motiontype; + int motiontype; int motionbone; vec3_t linearmovement; int automoveposindex; int automoveangleindex; vec3_t bbmin; // per sequence bounding box - vec3_t bbmax; + vec3_t bbmax; int numblends; int animindex; // mstudioanim_t pointer relative to start of sequence group data // [blend][bone][X, Y, Z, XR, YR, ZR] @@ -202,7 +202,7 @@ typedef struct /* size: 12, cachelines: 1, members: 1 */ // animation frames -typedef union +typedef union { struct { diff --git a/regamedll/engine/unicode_strtools.cpp b/regamedll/engine/unicode_strtools.cpp index 1072ece3..6da4e566 100644 --- a/regamedll/engine/unicode_strtools.cpp +++ b/regamedll/engine/unicode_strtools.cpp @@ -92,7 +92,7 @@ int Q_UChar32ToUTF32(uchar32 uVal, uchar32 *pUTF32) /* ../engine/unicode_strtools.cpp:70 */ template< - typename T_IN, + typename T_IN, typename T_OUT, bool UNK, qboolean(*IN_TO_UCHAR32)(const T_IN *pUTF8, uchar32 &uValueOut, bool &bErrorOut), @@ -128,10 +128,10 @@ int Q_UnicodeConvertT(const T_IN *pIn, T_OUT *pOut, int nOutBytes, enum EStringC pOut[0] = 0; return 0; } - + } }; - + pOut[nOut] = 0; } else @@ -147,7 +147,7 @@ int Q_UnicodeConvertT(const T_IN *pIn, T_OUT *pOut, int nOutBytes, enum EStringC if (ePolicy & STRINGCONVERT_SKIP) { nOut -= nOutElems; - } + } else if (ePolicy & STRINGCONVERT_FAIL) { #ifndef REGAMEDLL_FIXES @@ -156,7 +156,7 @@ int Q_UnicodeConvertT(const T_IN *pIn, T_OUT *pOut, int nOutBytes, enum EStringC #endif // REGAMEDLL_FIXES return 0; } - + } } } @@ -204,7 +204,7 @@ int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out) { *pUTF8Out = uVal; return 1; - } + } else if (uVal <= 0x7FF) { *pUTF8Out = (uVal >> 6) | 0xC0; @@ -543,7 +543,7 @@ uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny) } ++pwchSource; } - + *pwchDest = 0; *pbStrippedAny = pwchSource != pwchDest; return pwch; diff --git a/regamedll/game_shared/bitvec.h b/regamedll/game_shared/bitvec.h index d02e3f62..22f1531b 100644 --- a/regamedll/game_shared/bitvec.h +++ b/regamedll/game_shared/bitvec.h @@ -46,7 +46,7 @@ private: };/* size: 8, cachelines: 1, members: 2 */ -// CBitVec allows you to store a list of bits and do operations on them like they were +// CBitVec allows you to store a list of bits and do operations on them like they were // an atomic type template class CBitVec @@ -136,13 +136,13 @@ inline void CBitVec::Init(int val) template inline CBitVec &CBitVec::operator=(CBitVec const &other) { - memcpy(m_DWords, other.m_DWords, sizeof(m_DWords)); + Q_memcpy(m_DWords, other.m_DWords, sizeof(m_DWords)); return *this; } /* <2d3a41> ../game_shared/bitvec.h:133 */ template -inline CBitVecAccessor CBitVec::operator[](int i) +inline CBitVecAccessor CBitVec::operator[](int i) { assert(i >= 0 && i < GetNumBits()); return CBitVecAccessor(m_DWords, i); @@ -153,8 +153,10 @@ template inline bool CBitVec::operator==(CBitVec const &other) { for (int i = 0; i < NUM_DWORDS; i++) + { if (m_DWords[i] != other.m_DWords[i]) return false; + } return true; } diff --git a/regamedll/game_shared/bot/bot.cpp b/regamedll/game_shared/bot/bot.cpp index d529e751..7216dd81 100644 --- a/regamedll/game_shared/bot/bot.cpp +++ b/regamedll/game_shared/bot/bot.cpp @@ -219,10 +219,12 @@ void CBot::ExecuteCommand_(void) m_flPreviousCommandTime = gpGlobals->time; if (IsCrouching()) + { m_buttonFlags |= IN_DUCK; + } // Run the command - PLAYER_RUN_MOVE( edict(), pev->v_angle, m_forwardSpeed, m_strafeSpeed, m_verticalSpeed, m_buttonFlags, 0, adjustedMSec ); + PLAYER_RUN_MOVE(edict(), pev->v_angle, m_forwardSpeed, m_strafeSpeed, m_verticalSpeed, m_buttonFlags, 0, adjustedMSec); } /* <4900fa> ../game_shared/bot/bot.cpp:362 */ @@ -417,7 +419,7 @@ bool ActiveGrenade::IsValid(void) const /* <490710> ../game_shared/bot/bot.cpp:622 */ NOXREF const Vector *ActiveGrenade::GetPosition(void) const { - return &m_entity->pev->origin; + return &m_entity->pev->origin; } #ifdef HOOK_GAMEDLL @@ -512,4 +514,4 @@ void CBot::ExecuteCommand(void) ExecuteCommand_(); } -#endif // HOOK_GAMEDLL \ No newline at end of file +#endif // HOOK_GAMEDLL diff --git a/regamedll/game_shared/bot/bot.h b/regamedll/game_shared/bot/bot.h index 625cc7ee..180581c1 100644 --- a/regamedll/game_shared/bot/bot.h +++ b/regamedll/game_shared/bot/bot.h @@ -57,7 +57,7 @@ T *CreateBot(const BotProfile *profile) edict_t *pentBot; if (UTIL_ClientsInGame() >= gpGlobals->maxClients) { - CONSOLE_ECHO( "Unable to create bot: Server is full (%d/%d clients).\n", UTIL_ClientsInGame(), gpGlobals->maxClients); + CONSOLE_ECHO("Unable to create bot: Server is full (%d/%d clients).\n", UTIL_ClientsInGame(), gpGlobals->maxClients); return NULL; } @@ -82,7 +82,7 @@ T *CreateBot(const BotProfile *profile) } // The base bot class from which bots for specific games are derived -class CBot: public CBasePlayer +class CBot: public CBasePlayer { public: // constructor initializes all values to zero @@ -100,7 +100,7 @@ public: { CBasePlayer::Killed(pevAttacker, iGib); } - NOBODY virtual void Think(void) { }; + NOBODY virtual void Think(void) {}; virtual BOOL IsBot(void) { return true; @@ -142,7 +142,7 @@ public: NOBODY virtual void Reload(void); // invoked when event occurs in the game (some events have NULL entities) - virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) { }; + virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) {}; // return true if we can see the point virtual bool IsVisible(const Vector *pos, bool testFOV = false) const = 0; @@ -165,7 +165,7 @@ public: // return true if player is facing towards us NOBODY virtual bool IsPlayerFacingMe(CBasePlayer *other) const; - + // returns true if other player is pointing right at us NOBODY virtual bool IsPlayerLookingAtMe(CBasePlayer *other) const; virtual void ExecuteCommand(void); diff --git a/regamedll/game_shared/bot/bot_constants.h b/regamedll/game_shared/bot/bot_constants.h index 6972c705..e0d54339 100644 --- a/regamedll/game_shared/bot/bot_constants.h +++ b/regamedll/game_shared/bot/bot_constants.h @@ -49,16 +49,20 @@ enum BotDifficultyType #ifdef DEFINE_DIFFICULTY_NAMES - char *BotDifficultyName[] = - { - "EASY", "NORMAL", "HARD", "EXPERT", NULL - }; +char *BotDifficultyName[] = +{ + "EASY", + "NORMAL", + "HARD", + "EXPERT", + + NULL +}; #else - extern char *BotDifficultyName[]; +extern char *BotDifficultyName[]; #endif // DEFINE_DIFFICULTY_NAMES - #endif // BOT_CONSTANTS_H diff --git a/regamedll/game_shared/bot/bot_manager.cpp b/regamedll/game_shared/bot/bot_manager.cpp index 224c3201..e9018c33 100644 --- a/regamedll/game_shared/bot/bot_manager.cpp +++ b/regamedll/game_shared/bot/bot_manager.cpp @@ -1,6 +1,7 @@ #include "precompiled.h" -#pragma warning(disable : 4530) // STL uses exceptions, but we are not compiling with them - ignore warning +// STL uses exceptions, but we are not compiling with them - ignore warning +#pragma warning(disable : 4530) //#define DEFINE_EVENT_NAMES @@ -157,10 +158,14 @@ void CBotManager::OnEvent_(GameEventType event, CBaseEntity *entity, CBaseEntity } if (TheTutor) + { TheTutor->OnEvent(event, entity, other); + } if (g_pHostages) + { g_pHostages->OnEvent(event, entity, other); + } } /* <49f7ff> ../game_shared/bot/bot_manager.cpp:257 */ @@ -233,7 +238,7 @@ bool CBotManager::IsInsideSmokeCloud(const Vector *pos) { const Vector *smokeOrigin = ag->GetDetonationPosition(); - if ((*smokeOrigin - *pos).IsLengthLessThan( smokeRadius )) + if ((*smokeOrigin - *pos).IsLengthLessThan(smokeRadius)) return true; } } @@ -313,12 +318,12 @@ bool CBotManager::IsLineBlockedBySmoke(const Vector *from, const Vector *to) if (alongDist > 0.0f) { // ray goes thru 'close' - totalSmokedLength += halfSmokedLength + (close - *from).Length(); + totalSmokedLength += halfSmokedLength + (close - *from).Length(); } else { // ray starts after 'close' - totalSmokedLength += halfSmokedLength - (close - *from).Length(); + totalSmokedLength += halfSmokedLength - (close - *from).Length(); } } } @@ -332,7 +337,7 @@ bool CBotManager::IsLineBlockedBySmoke(const Vector *from, const Vector *to) if (DotProduct(v, sightDir) > 0.0f) { // ray goes thru 'close' - totalSmokedLength += halfSmokedLength + (close - *to).Length(); + totalSmokedLength += halfSmokedLength + (close - *to).Length(); } else { @@ -341,7 +346,7 @@ bool CBotManager::IsLineBlockedBySmoke(const Vector *from, const Vector *to) } } else - { + { // 'from' and 'to' lie outside of the cloud - the line of sight completely crosses it // determine the length of the chord that crosses the cloud diff --git a/regamedll/game_shared/bot/bot_manager.h b/regamedll/game_shared/bot/bot_manager.h index 8ee40eef..e594e78d 100644 --- a/regamedll/game_shared/bot/bot_manager.h +++ b/regamedll/game_shared/bot/bot_manager.h @@ -31,23 +31,24 @@ #ifdef _WIN32 #pragma once #endif - + +// STL uses exceptions, but we are not compiling with them - ignore warning #pragma warning(disable : 4530) #include #include "game_shared/GameEvent.h" - + #ifndef _WIN32 - -//#ifndef max -//#define max(a,b) ((a) > (b) ? (a) : (b)) + +//#ifndef max +//#define max(a,b) ((a) > (b) ? (a) : (b)) //#endif // max - -//#ifndef min -//#define min(a,b) ((a) < (b) ? (a) : (b)) + +//#ifndef min +//#define min(a,b) ((a) < (b) ? (a) : (b)) //#endif // min - -#endif // _WIN32 + +#endif // _WIN32 class CNavArea; class CGrenade; @@ -59,7 +60,7 @@ public: void OnEntityGone(void); bool IsValid(void) const; - NOXREF bool IsEntity( CGrenade *grenade) const + NOXREF bool IsEntity(CGrenade *grenade) const { return (grenade == m_entity) ? true : false; } diff --git a/regamedll/game_shared/bot/bot_profile.h b/regamedll/game_shared/bot/bot_profile.h index d977de7b..5a10e51c 100644 --- a/regamedll/game_shared/bot/bot_profile.h +++ b/regamedll/game_shared/bot/bot_profile.h @@ -32,7 +32,8 @@ #pragma once #endif -#pragma warning(disable : 4786) // long STL names get truncated in browse info. +// long STL names get truncated in browse info. +#pragma warning(disable : 4786) #ifndef _WIN32 #include diff --git a/regamedll/game_shared/bot/bot_util.cpp b/regamedll/game_shared/bot/bot_util.cpp index c2f306d8..588d971d 100644 --- a/regamedll/game_shared/bot/bot_util.cpp +++ b/regamedll/game_shared/bot/bot_util.cpp @@ -567,14 +567,14 @@ NOBODY bool IsGameEventAudible(GameEventType event, CBaseEntity *entity, CBaseEn const float ShortRange = 1000.0f; const float NormalRange = 2000.0f; - switch(event) + switch (event) { case EVENT_WEAPON_FIRED: { if (player->m_pActiveItem == NULL) return false; - switch(player->m_pActiveItem->m_iId) + switch (player->m_pActiveItem->m_iId) { case WEAPON_HEGRENADE: case WEAPON_SMOKEGRENADE: diff --git a/regamedll/game_shared/bot/improv.h b/regamedll/game_shared/bot/improv.h index 9a5538f0..fd9f7291 100644 --- a/regamedll/game_shared/bot/improv.h +++ b/regamedll/game_shared/bot/improv.h @@ -39,7 +39,7 @@ class CNavLadder; class IImprovEvent { public: - virtual void OnMoveToSuccess(const Vector &goal) { } + virtual void OnMoveToSuccess(const Vector &goal) {}; enum MoveToFailureType { @@ -48,15 +48,15 @@ public: FAIL_FELL_OFF, }; - virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) { } - virtual void OnInjury(float amount) { } + virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) {}; + virtual void OnInjury(float amount) {}; };/* size: 4, cachelines: 1, members: 1 */ class CImprov: public IImprovEvent { public: - virtual ~CImprov(void) { } + virtual ~CImprov(void) {}; virtual bool IsAlive(void) const = 0; diff --git a/regamedll/game_shared/bot/nav.h b/regamedll/game_shared/bot/nav.h index ead1df0a..1f034961 100644 --- a/regamedll/game_shared/bot/nav.h +++ b/regamedll/game_shared/bot/nav.h @@ -24,409 +24,409 @@ * you do not wish to do so, delete this exception statement from your * version. * -*/ - +*/ + #ifndef NAV_H #define NAV_H #ifdef _WIN32 #pragma once -#endif - -// STL uses exceptions, but we are not compiling with them - ignore warning -#pragma warning(disable : 4530) - -// to help identify nav files -#define NAV_MAGIC_NUMBER 0xFEEDFACE - -// A place is a named group of navigation areas -typedef unsigned int Place; - -// ie: "no place" -#define UNDEFINED_PLACE 0 -#define ANY_PLACE 0xFFFF - -#define WALK_THRU_DOORS 0x01 -#define WALK_THRU_BREAKABLES 0x02 - -//class CNavArea; -//class CNavNode; - -enum NavErrorType -{ - NAV_OK, - NAV_CANT_ACCESS_FILE, - NAV_INVALID_FILE, - NAV_BAD_FILE_VERSION, - NAV_CORRUPT_DATA, -}; - -enum NavAttributeType -{ - NAV_CROUCH = 0x01, // must crouch to use this node/area - NAV_JUMP = 0x02, // must jump to traverse this area - NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area - NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping -}; - -enum NavDirType -{ - NORTH = 0, - EAST, - SOUTH, - WEST, - - NUM_DIRECTIONS -}; - -// Defines possible ways to move from one area to another -enum NavTraverseType -{ - // NOTE: First 4 directions MUST match NavDirType - GO_NORTH = 0, - GO_EAST, - GO_SOUTH, - GO_WEST, - GO_LADDER_UP, - GO_LADDER_DOWN, - GO_JUMP, - - NUM_TRAVERSE_TYPES -}; - -enum NavCornerType -{ - NORTH_WEST = 0, - NORTH_EAST, - SOUTH_EAST, - SOUTH_WEST, - - NUM_CORNERS -}; - -enum NavRelativeDirType -{ - FORWARD = 0, - RIGHT, - BACKWARD, - LEFT, - UP, - DOWN, - - NUM_RELATIVE_DIRECTIONS -}; - -const float GenerationStepSize = 25.0f; // (30) was 20, but bots can't fit always fit -const float StepHeight = 18.0f; // if delta Z is greater than this, we have to jump to get up -const float JumpHeight = 41.8f; // if delta Z is less than this, we can jump up on it -const float JumpCrouchHeight = 58.0f; // (48) if delta Z is less than or equal to this, we can jumpcrouch up on it - -// Strictly speaking, you CAN get up a slope of 1.643 (about 59 degrees), but you move very, very slowly -// This slope will represent the slope you can navigate without much slowdown -// rise/run - if greater than this, we can't move up it (de_survivor canyon ramps) -const float MaxSlope = 1.4f; - -// instead of MaxSlope, we are using the following max Z component of a unit normal -const float MaxUnitZSlope = 0.7f; - -const float BotRadius = 10.0f; // circular extent that contains bot -const float DeathDrop = 200.0f; // (300) distance at which we will die if we fall - should be about 600, and pay attention to fall damage during pathfind - -const float HalfHumanWidth = 16.0f; -const float HalfHumanHeight = 36.0f; -const float HumanHeight = 72.0f; - -/* <4f7910> ../game_shared/bot/nav.h:104 */ -struct Extent -{ - Vector lo; - Vector hi; - - UNTESTED float SizeX(void) const - { - return hi.x - lo.x; - } - UNTESTED float SizeY(void) const - { - return hi.y - lo.y; - } - UNTESTED float SizeZ(void) const - { - return hi.z - lo.z; - } - UNTESTED float Area(void) const - { - return SizeX() * SizeY(); - } - // return true if 'pos' is inside of this extent - UNTESTED bool Contains(const Vector *pos) const - { - return (pos->x >= lo.x && pos->x <= hi.x && - pos->y >= lo.y && pos->y <= hi.y && - pos->z >= lo.z && pos->z <= hi.z); - } - -};/* size: 24, cachelines: 1, members: 2 */ - -struct Ray -{ - Vector from; - Vector to; - -};/* size: 24, cachelines: 1, members: 2 */ - -/* <34358b> ../game_shared/bot/nav.h:134 */ -inline NavDirType OppositeDirection(NavDirType dir) -{ - switch (dir) - { - case NORTH: - return SOUTH; - case EAST: - return WEST; - case SOUTH: - return NORTH; - case WEST: - return EAST; - } - - return NORTH; -} - -/* <4c3042> ../game_shared/bot/nav.h:148 */ -inline NavDirType DirectionLeft(NavDirType dir) -{ - switch (dir) - { - case NORTH: - return WEST; - case SOUTH: - return EAST; - case EAST: - return NORTH; - case WEST: - return SOUTH; - } - - return NORTH; -} - -/* <4c3061> ../game_shared/bot/nav.h:162 */ -inline NavDirType DirectionRight(NavDirType dir) -{ - switch(dir) - { - case NORTH: - return EAST; - case SOUTH: - return WEST; - case EAST: - return SOUTH; - case WEST: - return NORTH; - } - - return NORTH; -} - -/* <3433a4> ../game_shared/bot/nav.h:176 */ -inline void AddDirectionVector(Vector *v, NavDirType dir, float amount) -{ - switch(dir) - { - case NORTH: - v->y -= amount; - return; - case EAST: - v->x += amount; - return; - case SOUTH: - v->y += amount; - return; - case WEST: - v->x -= amount; - return; - } -} - -/* <38c828> ../game_shared/bot/nav.h:188 */ -inline float DirectionToAngle(NavDirType dir) -{ - switch(dir) - { - case NORTH: - return 270.0f; - case EAST: - return 0.0f; - case SOUTH: - return 90.0f; - case WEST: - return 180.0f; - } - - return 0.0f; -} - -/* <3d8335> ../game_shared/bot/nav.h:202 */ -inline NavDirType AngleToDirection(float angle) -{ - while (angle < 0.0f) - angle += 360.0f; - - while (angle > 360.0f) - angle -= 360.0f; - - if (angle < 45 || angle > 315) - return EAST; - - if (angle >= 45 && angle < 135) - return SOUTH; - - if (angle >= 135 && angle < 225) - return WEST; - - return NORTH; -} - -/* <38ccf5> ../game_shared/bot/nav.h:223 */ -inline void DirectionToVector2D(NavDirType dir, Vector2D *v) -{ - switch (dir) - { - case NORTH: - v->x = 0.0f; - v->y = -1.0f; - break; - case SOUTH: - v->x = 0.0f; - v->y = 1.0f; - break; - case EAST: - v->x = 1.0f; - v->y = 0.0f; - break; - case WEST: - v->x = -1.0f; - v->y = 0.0f; - break; - } -} - -/* <3433d1> ../game_shared/bot/nav.h:235 */ -inline void SnapToGrid(Vector *pos) -{ - int cx = pos->x / GenerationStepSize; - int cy = pos->y / GenerationStepSize; - pos->x = cx * GenerationStepSize; - pos->y = cy * GenerationStepSize; -} - -/* <3433d1> ../game_shared/bot/nav.h:235 */ -inline void SnapToGrid(float *value) -{ - int c = *value / GenerationStepSize; - *value = c * GenerationStepSize; -} - -/* <14ea2f> ../game_shared/bot/nav.h:251 */ -inline float_precision NormalizeAngle(float_precision angle) -{ - while (angle < -180.0f) - angle += 360.0f; - - while (angle > 180.0f) - angle -= 360.0f; - - return angle; -} - -/* <4ad17f> ../game_shared/bot/nav.h:263 */ -inline float NormalizeAnglePositive(float angle) -{ - while (angle < 0.0f) - angle += 360.0f; - - while (angle >= 360.0f) - angle -= 360.0f; - - return angle; -} - -/* <38c40b> ../game_shared/bot/nav.h:275 */ -inline float AngleDifference(float a, float b) -{ - float angleDiff = a - b; - - while (angleDiff > 180.0f) - angleDiff -= 360.0f; - - while (angleDiff < -180.0f) - angleDiff += 360.0f; - - return angleDiff; -} - -/* <38cac9> ../game_shared/bot/nav.h:288 */ -inline bool AnglesAreEqual(float a, float b, float tolerance = 5.0f) -{ - if (abs( AngleDifference( a, b ) ) < tolerance) - return true; - - return false; -} - -/* <3d8457> ../game_shared/bot/nav.h:297 */ -inline bool VectorsAreEqual(const Vector *a, const Vector *b, float tolerance = 0.1f) -{ - if (abs(a->x - b->x) < tolerance && - abs(a->y - b->y) < tolerance && - abs(a->z - b->z) < tolerance) - return true; - - return false; -} - -/* <3436f6> ../game_shared/bot/nav.h:313 */ -inline bool IsEntityWalkable(entvars_t *entity, unsigned int flags) -{ - // if we hit a door, assume its walkable because it will open when we touch it - if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating")) - return (flags & WALK_THRU_DOORS) ? true : false; - - // if we hit a breakable object, assume its walkable because we will shoot it when we touch it - if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES) - return (flags & WALK_THRU_BREAKABLES) ? true : false; - - return false; -} - -// Check LOS, ignoring any entities that we can walk through -/* <38d33d> ../game_shared/bot/nav.h:330 */ -inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flags = 0) -{ - TraceResult result; - edict_t *ignore = NULL; - Vector useFrom = from; - - while (true) - { - UTIL_TraceLine(useFrom, to, ignore_monsters, ignore, &result); - - if (result.flFraction != 1.0f && IsEntityWalkable( VARS( result.pHit ), flags )) - { - ignore = result.pHit; - - Vector dir = to - from; - dir.NormalizeInPlace(); - useFrom = result.vecEndPos + 5.0f * dir; - } - else - break; - } - - if (result.flFraction == 1.0f) - return true; - - return false; -} - -#endif // NAV_H +#endif + +// STL uses exceptions, but we are not compiling with them - ignore warning +#pragma warning(disable : 4530) + +// to help identify nav files +#define NAV_MAGIC_NUMBER 0xFEEDFACE + +// A place is a named group of navigation areas +typedef unsigned int Place; + +// ie: "no place" +#define UNDEFINED_PLACE 0 +#define ANY_PLACE 0xFFFF + +#define WALK_THRU_DOORS 0x01 +#define WALK_THRU_BREAKABLES 0x02 + +//class CNavArea; +//class CNavNode; + +enum NavErrorType +{ + NAV_OK, + NAV_CANT_ACCESS_FILE, + NAV_INVALID_FILE, + NAV_BAD_FILE_VERSION, + NAV_CORRUPT_DATA, +}; + +enum NavAttributeType +{ + NAV_CROUCH = 0x01, // must crouch to use this node/area + NAV_JUMP = 0x02, // must jump to traverse this area + NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area + NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping +}; + +enum NavDirType +{ + NORTH = 0, + EAST, + SOUTH, + WEST, + + NUM_DIRECTIONS +}; + +// Defines possible ways to move from one area to another +enum NavTraverseType +{ + // NOTE: First 4 directions MUST match NavDirType + GO_NORTH = 0, + GO_EAST, + GO_SOUTH, + GO_WEST, + GO_LADDER_UP, + GO_LADDER_DOWN, + GO_JUMP, + + NUM_TRAVERSE_TYPES +}; + +enum NavCornerType +{ + NORTH_WEST = 0, + NORTH_EAST, + SOUTH_EAST, + SOUTH_WEST, + + NUM_CORNERS +}; + +enum NavRelativeDirType +{ + FORWARD = 0, + RIGHT, + BACKWARD, + LEFT, + UP, + DOWN, + + NUM_RELATIVE_DIRECTIONS +}; + +const float GenerationStepSize = 25.0f; // (30) was 20, but bots can't fit always fit +const float StepHeight = 18.0f; // if delta Z is greater than this, we have to jump to get up +const float JumpHeight = 41.8f; // if delta Z is less than this, we can jump up on it +const float JumpCrouchHeight = 58.0f; // (48) if delta Z is less than or equal to this, we can jumpcrouch up on it + +// Strictly speaking, you CAN get up a slope of 1.643 (about 59 degrees), but you move very, very slowly +// This slope will represent the slope you can navigate without much slowdown +// rise/run - if greater than this, we can't move up it (de_survivor canyon ramps) +const float MaxSlope = 1.4f; + +// instead of MaxSlope, we are using the following max Z component of a unit normal +const float MaxUnitZSlope = 0.7f; + +const float BotRadius = 10.0f; // circular extent that contains bot +const float DeathDrop = 200.0f; // (300) distance at which we will die if we fall - should be about 600, and pay attention to fall damage during pathfind + +const float HalfHumanWidth = 16.0f; +const float HalfHumanHeight = 36.0f; +const float HumanHeight = 72.0f; + +/* <4f7910> ../game_shared/bot/nav.h:104 */ +struct Extent +{ + Vector lo; + Vector hi; + + UNTESTED float SizeX(void) const + { + return hi.x - lo.x; + } + UNTESTED float SizeY(void) const + { + return hi.y - lo.y; + } + UNTESTED float SizeZ(void) const + { + return hi.z - lo.z; + } + UNTESTED float Area(void) const + { + return SizeX() * SizeY(); + } + // return true if 'pos' is inside of this extent + UNTESTED bool Contains(const Vector *pos) const + { + return (pos->x >= lo.x && pos->x <= hi.x && + pos->y >= lo.y && pos->y <= hi.y && + pos->z >= lo.z && pos->z <= hi.z); + } + +};/* size: 24, cachelines: 1, members: 2 */ + +struct Ray +{ + Vector from; + Vector to; + +};/* size: 24, cachelines: 1, members: 2 */ + +/* <34358b> ../game_shared/bot/nav.h:134 */ +inline NavDirType OppositeDirection(NavDirType dir) +{ + switch (dir) + { + case NORTH: + return SOUTH; + case EAST: + return WEST; + case SOUTH: + return NORTH; + case WEST: + return EAST; + } + + return NORTH; +} + +/* <4c3042> ../game_shared/bot/nav.h:148 */ +inline NavDirType DirectionLeft(NavDirType dir) +{ + switch (dir) + { + case NORTH: + return WEST; + case SOUTH: + return EAST; + case EAST: + return NORTH; + case WEST: + return SOUTH; + } + + return NORTH; +} + +/* <4c3061> ../game_shared/bot/nav.h:162 */ +inline NavDirType DirectionRight(NavDirType dir) +{ + switch (dir) + { + case NORTH: + return EAST; + case SOUTH: + return WEST; + case EAST: + return SOUTH; + case WEST: + return NORTH; + } + + return NORTH; +} + +/* <3433a4> ../game_shared/bot/nav.h:176 */ +inline void AddDirectionVector(Vector *v, NavDirType dir, float amount) +{ + switch (dir) + { + case NORTH: + v->y -= amount; + return; + case EAST: + v->x += amount; + return; + case SOUTH: + v->y += amount; + return; + case WEST: + v->x -= amount; + return; + } +} + +/* <38c828> ../game_shared/bot/nav.h:188 */ +inline float DirectionToAngle(NavDirType dir) +{ + switch (dir) + { + case NORTH: + return 270.0f; + case EAST: + return 0.0f; + case SOUTH: + return 90.0f; + case WEST: + return 180.0f; + } + + return 0.0f; +} + +/* <3d8335> ../game_shared/bot/nav.h:202 */ +inline NavDirType AngleToDirection(float angle) +{ + while (angle < 0.0f) + angle += 360.0f; + + while (angle > 360.0f) + angle -= 360.0f; + + if (angle < 45 || angle > 315) + return EAST; + + if (angle >= 45 && angle < 135) + return SOUTH; + + if (angle >= 135 && angle < 225) + return WEST; + + return NORTH; +} + +/* <38ccf5> ../game_shared/bot/nav.h:223 */ +inline void DirectionToVector2D(NavDirType dir, Vector2D *v) +{ + switch (dir) + { + case NORTH: + v->x = 0.0f; + v->y = -1.0f; + break; + case SOUTH: + v->x = 0.0f; + v->y = 1.0f; + break; + case EAST: + v->x = 1.0f; + v->y = 0.0f; + break; + case WEST: + v->x = -1.0f; + v->y = 0.0f; + break; + } +} + +/* <3433d1> ../game_shared/bot/nav.h:235 */ +inline void SnapToGrid(Vector *pos) +{ + int cx = pos->x / GenerationStepSize; + int cy = pos->y / GenerationStepSize; + pos->x = cx * GenerationStepSize; + pos->y = cy * GenerationStepSize; +} + +/* <3433d1> ../game_shared/bot/nav.h:235 */ +inline void SnapToGrid(float *value) +{ + int c = *value / GenerationStepSize; + *value = c * GenerationStepSize; +} + +/* <14ea2f> ../game_shared/bot/nav.h:251 */ +inline float_precision NormalizeAngle(float_precision angle) +{ + while (angle < -180.0f) + angle += 360.0f; + + while (angle > 180.0f) + angle -= 360.0f; + + return angle; +} + +/* <4ad17f> ../game_shared/bot/nav.h:263 */ +inline float NormalizeAnglePositive(float angle) +{ + while (angle < 0.0f) + angle += 360.0f; + + while (angle >= 360.0f) + angle -= 360.0f; + + return angle; +} + +/* <38c40b> ../game_shared/bot/nav.h:275 */ +inline float AngleDifference(float a, float b) +{ + float angleDiff = a - b; + + while (angleDiff > 180.0f) + angleDiff -= 360.0f; + + while (angleDiff < -180.0f) + angleDiff += 360.0f; + + return angleDiff; +} + +/* <38cac9> ../game_shared/bot/nav.h:288 */ +inline bool AnglesAreEqual(float a, float b, float tolerance = 5.0f) +{ + if (abs(AngleDifference(a, b)) < tolerance) + return true; + + return false; +} + +/* <3d8457> ../game_shared/bot/nav.h:297 */ +inline bool VectorsAreEqual(const Vector *a, const Vector *b, float tolerance = 0.1f) +{ + if (abs(a->x - b->x) < tolerance && + abs(a->y - b->y) < tolerance && + abs(a->z - b->z) < tolerance) + return true; + + return false; +} + +/* <3436f6> ../game_shared/bot/nav.h:313 */ +inline bool IsEntityWalkable(entvars_t *entity, unsigned int flags) +{ + // if we hit a door, assume its walkable because it will open when we touch it + if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating")) + return (flags & WALK_THRU_DOORS) ? true : false; + + // if we hit a breakable object, assume its walkable because we will shoot it when we touch it + if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES) + return (flags & WALK_THRU_BREAKABLES) ? true : false; + + return false; +} + +// Check LOS, ignoring any entities that we can walk through +/* <38d33d> ../game_shared/bot/nav.h:330 */ +inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flags = 0) +{ + TraceResult result; + edict_t *ignore = NULL; + Vector useFrom = from; + + while (true) + { + UTIL_TraceLine(useFrom, to, ignore_monsters, ignore, &result); + + if (result.flFraction != 1.0f && IsEntityWalkable(VARS(result.pHit), flags)) + { + ignore = result.pHit; + + Vector dir = to - from; + dir.NormalizeInPlace(); + useFrom = result.vecEndPos + 5.0f * dir; + } + else + break; + } + + if (result.flFraction == 1.0f) + return true; + + return false; +} + +#endif // NAV_H diff --git a/regamedll/game_shared/bot/nav_area.cpp b/regamedll/game_shared/bot/nav_area.cpp index fc5a8bc3..9502d7ce 100644 --- a/regamedll/game_shared/bot/nav_area.cpp +++ b/regamedll/game_shared/bot/nav_area.cpp @@ -1,5 +1,25 @@ #include "precompiled.h" +// STL uses exceptions, but we are not compiling with them - ignore warning +#pragma warning(disable : 4530) + +// long STL names get truncated in browse info. +#pragma warning(disable : 4786) + +#include +#include +#include + +#include +#include +#include + +#ifdef _WIN32 +#include +#else +#include +#endif // _WIN32 + /* * Globals initialization */ @@ -85,7 +105,7 @@ NOXREF FILE_GLOBAL void buildGoodSizedList(void) if (extent->SizeX() < minSize || extent->SizeY() < minSize) continue; - goodSizedAreaList.push_back( area ); + goodSizedAreaList.push_back(area); } } @@ -247,7 +267,7 @@ NOBODY void CNavArea::OnDestroyNotify(CNavArea *dead) { NavConnect con; con.area = dead; - for(int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; ++d) m_connect[ d ].remove(con); m_overlapList.remove(dead); @@ -1252,7 +1272,7 @@ float __declspec(naked) CNavArea::GetZ(const Vector *pos) const u = 0.0f; else if (u > 1.0f) u = 1.0f; - + if (v < 0.0f) v = 0.0f; else if (v > 1.0f) @@ -1260,7 +1280,7 @@ float __declspec(naked) CNavArea::GetZ(const Vector *pos) const float northZ = m_extent.lo.z + u * (m_neZ - m_extent.lo.z); float southZ = m_swZ + u * (m_extent.hi.z - m_swZ); - + return northZ + v * (southZ - northZ); */ } @@ -1384,7 +1404,7 @@ NOBODY void CNavArea::ComputePortal(const CNavArea *to, NavDirType dir, Vector * } /* <4cb0d7> ../game_shared/bot/nav_area.cpp:2378 */ -NOBODY void CNavArea::ComputeClosestPointInPortal(const CNavArea *to, NavDirType dir, const Vector *fromPos, Vector *closePos) const +NOBODY void CNavArea::ComputeClosestPointInPortal(const CNavArea *to, NavDirType dir, const Vector *fromPos, Vector *closePos) const { // { // float const margin; // 2380 @@ -1561,7 +1581,7 @@ NOBODY void CNavArea::RemoveFromOpenList(void) m_prevOpen->m_nextOpen = m_nextOpen; else IMPLEMENT_ARRAY(m_openList) = m_nextOpen; - + if (m_nextOpen) m_nextOpen->m_prevOpen = m_prevOpen; @@ -2667,6 +2687,7 @@ bool GetGroundHeight(const Vector *pos, float *height, Vector *normal) { float ground; Vector normal; + } layer[MAX_GROUND_LAYERS]; int layerCount = 0; @@ -2692,7 +2713,7 @@ bool GetGroundHeight(const Vector *pos, float *height, Vector *normal) layer[layerCount].ground = result.vecEndPos.z; layer[layerCount].normal = result.vecPlaneNormal; ++layerCount; - + if (layerCount == MAX_GROUND_LAYERS) break; } @@ -2706,12 +2727,15 @@ bool GetGroundHeight(const Vector *pos, float *height, Vector *normal) for (i = 0; i < layerCount - 1; ++i) { if (layer[i + 1].ground - layer[i].ground >= HalfHumanHeight) - break; + break; } *height = layer[i].ground; + if (normal) + { *normal = layer[i].normal; + } return true; } @@ -2822,7 +2846,7 @@ void CNavAreaGrid::Reset(void) m_gridSizeY = 0; // clear the hash table - for(int i = 0; i < HASH_TABLE_SIZE; i++) + for (int i = 0; i < HASH_TABLE_SIZE; i++) m_hashTable[i] = NULL; m_areaCount = 0; @@ -3007,7 +3031,7 @@ NOBODY __declspec(naked) CNavArea *CNavAreaGrid::GetNearestNavArea(const Vector if (!anyZ) { TraceResult result; - UTIL_TraceLine( source, areaPos + Vector( 0, 0, HalfHumanHeight ), ignore_monsters, ignore_glass, NULL, &result ); + UTIL_TraceLine(source, areaPos + Vector(0, 0, HalfHumanHeight), ignore_monsters, ignore_glass, NULL, &result); if (result.flFraction != 1.0f) continue; } diff --git a/regamedll/game_shared/bot/nav_area.h b/regamedll/game_shared/bot/nav_area.h index 23ae7342..0deba227 100644 --- a/regamedll/game_shared/bot/nav_area.h +++ b/regamedll/game_shared/bot/nav_area.h @@ -33,7 +33,6 @@ #endif #include -//#include "nav.h" class CNavArea; @@ -498,7 +497,7 @@ private: friend class CCSBotManager; void Initialize(void); - + #ifdef HOOK_GAMEDLL public: #endif // HOOK_GAMEDLL diff --git a/regamedll/game_shared/bot/nav_file.cpp b/regamedll/game_shared/bot/nav_file.cpp index 0dcf384b..a2d11c13 100644 --- a/regamedll/game_shared/bot/nav_file.cpp +++ b/regamedll/game_shared/bot/nav_file.cpp @@ -1,7 +1,27 @@ #include "precompiled.h" -#pragma warning(disable : 4530) // STL uses exceptions, but we are not compiling with them - ignore warning -#pragma warning(disable : 4786) // long STL names get truncated in browse info. +// STL uses exceptions, but we are not compiling with them - ignore warning +#pragma warning(disable : 4530) + +// long STL names get truncated in browse info. +#pragma warning(disable : 4786) + +#undef min +#undef max + +#include +#include +#include + +#include +#include +#include + +#ifndef _WIN32 + +#include + +#endif // _WIN32 /* * Globals initialization @@ -42,6 +62,7 @@ PlaceDirectory::EntryType PlaceDirectory::GetEntry(Place place) const assert(false && "PlaceDirectory::GetEntry failure"); return 0; } + return 1 + (it - m_directory.begin()); } @@ -83,7 +104,7 @@ void PlaceDirectory::Save(int fd) EntryType count = m_directory.size(); Q_write(fd, &count, sizeof(EntryType)); - // store entries + // store entries std::vector::iterator it; for (it = m_directory.begin(); it != m_directory.end(); ++it) { @@ -145,7 +166,7 @@ void CNavArea::Save(FILE *fp) const static int base = 1; fprintf(fp, "\n\ng %04dArea%s%s%s%s\n", - m_id, + m_id, (GetAttributes() & NAV_CROUCH) ? "CROUCH" : "", (GetAttributes() & NAV_JUMP) ? "JUMP" : "", (GetAttributes() & NAV_PRECISE) ? "PRECISE" : "", @@ -209,7 +230,7 @@ NOBODY void CNavArea::Save(int fd, unsigned int version) for (HidingSpotList::iterator iter = m_hidingSpotList.begin(); iter != m_hidingSpotList.end(); ++iter) { HidingSpot *spot = *iter; - + spot->Save(fd, version); // overflow check @@ -394,7 +415,7 @@ NOBODY void CNavArea::Load(SteamFile *file, unsigned int version) HidingSpot *spot = new HidingSpot; spot->Load(file, version); - + m_hidingSpotList.push_back(spot); } } @@ -441,7 +462,7 @@ NOBODY void CNavArea::Load(SteamFile *file, unsigned int version) // read list of spots along this path unsigned char spotCount; file->Read(&spotCount, sizeof(unsigned char)); - + for (int s = 0; s < spotCount; ++s) { Vector pos; @@ -470,9 +491,9 @@ NOBODY void CNavArea::Load(SteamFile *file, unsigned int version) // read list of spots along this path unsigned char spotCount; file->Read(&spotCount, sizeof(unsigned char)); - + SpotOrder order; - for( int s = 0; s < spotCount; ++s) + for (int s = 0; s < spotCount; ++s) { file->Read(&order.id, sizeof(unsigned int)); @@ -520,7 +541,7 @@ NOBODY NavErrorType CNavArea::PostLoad(void) CONSOLE_ECHO("ERROR: Corrupt navigation data. Cannot connect Navigation Areas.\n"); error = NAV_CORRUPT_DATA; } - } + } } // resolve approach area IDs @@ -615,14 +636,14 @@ NOBODY NavErrorType CNavArea::PostLoad(void) void COM_FixSlashes(char *pname) { #ifdef _WIN32 - while (*pname) + while (*pname) { if (*pname == '/') *pname = '\\'; pname++; } #else - while (*pname) + while (*pname) { if (*pname == '\\') *pname = '/'; @@ -778,7 +799,7 @@ NOBODY void LoadLocationFile(const char *filename) CNavArea *area = TheNavAreaGrid.GetNavAreaByID(areaID); unsigned int place = (locDirIndex > 0) ? directory[locDirIndex - 1] : UNDEFINED_PLACE; - + if (area) area->SetPlace(place); } @@ -903,7 +924,7 @@ NOBODY NavErrorType __declspec(naked) LoadNavigationMap(void) //result = navFile.Read(&version, sizeof(unsigned int)); //if (!result || version > 5) //{ - // CONSOLE_ECHO( "ERROR: Unknown navigation file version.\n"); + // CONSOLE_ECHO("ERROR: Unknown navigation file version.\n"); // return NAV_BAD_FILE_VERSION; //} @@ -958,7 +979,7 @@ NOBODY NavErrorType __declspec(naked) LoadNavigationMap(void) // // check validity of nav area // if (areaExtent->lo.x >= areaExtent->hi.x || areaExtent->lo.y >= areaExtent->hi.y) - // CONSOLE_ECHO( "WARNING: Degenerate Navigation Area #%d at ( %g, %g, %g )\n", + // CONSOLE_ECHO("WARNING: Degenerate Navigation Area #%d at ( %g, %g, %g )\n", // area->GetID(), area->m_center.x, area->m_center.y, area->m_center.z); // if (areaExtent->lo.x < extent.lo.x) diff --git a/regamedll/game_shared/bot/nav_file.h b/regamedll/game_shared/bot/nav_file.h index 27260204..0facee2d 100644 --- a/regamedll/game_shared/bot/nav_file.h +++ b/regamedll/game_shared/bot/nav_file.h @@ -24,39 +24,22 @@ * you do not wish to do so, delete this exception statement from your * version. * -*/ - -#ifndef NAV_FILE_H +*/ + +#ifndef NAV_FILE_H #define NAV_FILE_H #ifdef _WIN32 #pragma once -#endif +#endif -#undef min -#undef max - -#include -#include -#include - -#include -#include -#include - -#ifndef _WIN32 - -#include - -#endif // _WIN32 - -// The 'place directory' is used to save and load places from -// nav files in a size-efficient manner that also allows for the -// order of the place ID's to change without invalidating the -// nav files. -// -// The place directory is stored in the nav file as a list of -// place name strings. Each nav area then contains an index -// into that directory, or zero if no place has been assigned to +// The 'place directory' is used to save and load places from +// nav files in a size-efficient manner that also allows for the +// order of the place ID's to change without invalidating the +// nav files. +// +// The place directory is stored in the nav file as a list of +// place name strings. Each nav area then contains an index +// into that directory, or zero if no place has been assigned to // that area. /* <4ecb57> ../game_shared/bot/nav_file.cpp:54 */ @@ -78,7 +61,9 @@ private: }; #ifdef HOOK_GAMEDLL + #define placeDirectory (*pplaceDirectory) + #endif // HOOK_GAMEDLL extern PlaceDirectory placeDirectory; @@ -89,7 +74,7 @@ NOBODY bool SaveNavigationMap(const char *filename); NOBODY void LoadLocationFile(const char *filename); NOBODY void SanityCheckNavigationMap(const char *mapName); NOBODY NavErrorType LoadNavigationMap(void); - -extern void (*pLoadNavigationMap)(void); - -#endif // NAV_FILE_H + +extern void (*pLoadNavigationMap)(void); + +#endif // NAV_FILE_H diff --git a/regamedll/game_shared/bot/nav_node.h b/regamedll/game_shared/bot/nav_node.h index 02b17a41..0defd0aa 100644 --- a/regamedll/game_shared/bot/nav_node.h +++ b/regamedll/game_shared/bot/nav_node.h @@ -24,13 +24,13 @@ * you do not wish to do so, delete this exception statement from your * version. * -*/ - -#ifndef NAV_NODE_H +*/ + +#ifndef NAV_NODE_H #define NAV_NODE_H #ifdef _WIN32 #pragma once -#endif +#endif class CNavNode { @@ -64,7 +64,7 @@ public: { return m_next; } - + // create a connection FROM this node TO the given node, in the given direction void ConnectTo(CNavNode *node, NavDirType dir); CNavNode *GetParent(void) const; @@ -88,8 +88,8 @@ public: // assign the given area to this node void AssignArea(CNavArea *area); - // return associated area - CNavArea *GetArea(void) const; + // return associated area + CNavArea *GetArea(void) const; void SetAttributes(unsigned char bits) { @@ -172,19 +172,19 @@ inline CNavArea *CNavNode::GetArea(void) const { return m_area; } - + #ifdef HOOK_GAMEDLL -//#define Opposite (*pOpposite) -//#define m_list (*pm_list) -//#define m_listLength (*pm_listLength) +//#define Opposite (*pOpposite) +//#define m_list (*pm_list) +//#define m_listLength (*pm_listLength) //#define NodeMapExtent (*pNodeMapExtent) #endif // HOOK_GAMEDLL -//extern NavDirType Opposite[ NUM_DIRECTIONS ]; -//extern CNavNode *CNavNode::m_list; -//extern unsigned int CNavNode::m_listLength; -//extern Extent NodeMapExtent; - -#endif // NAV_NODE_H +//extern NavDirType Opposite[ NUM_DIRECTIONS ]; +//extern CNavNode *CNavNode::m_list; +//extern unsigned int CNavNode::m_listLength; +//extern Extent NodeMapExtent; + +#endif // NAV_NODE_H diff --git a/regamedll/game_shared/bot/nav_path.h b/regamedll/game_shared/bot/nav_path.h index 2f6b3be0..eb3059b1 100644 --- a/regamedll/game_shared/bot/nav_path.h +++ b/regamedll/game_shared/bot/nav_path.h @@ -24,14 +24,14 @@ * you do not wish to do so, delete this exception statement from your * version. * -*/ - +*/ + #ifndef NAV_PATH_H #define NAV_PATH_H #ifdef _WIN32 #pragma once #endif - + // STL uses exceptions, but we are not compiling with them - ignore warning #pragma warning(disable : 4530) @@ -178,7 +178,7 @@ private: PathSegment m_path[ MAX_PATH_SEGMENTS ]; int m_segmentCount; - // determine actual path positions + // determine actual path positions bool ComputePathPositions(void); // utility function for when start and goal are in the same area @@ -246,7 +246,7 @@ public: { m_isDebug = status; } - // return true if improv is stuck + // return true if improv is stuck bool IsStuck(void) const { return m_stuckMonitor.IsStuck(); @@ -277,5 +277,5 @@ private: CStuckMonitor m_stuckMonitor; };/* size: 96, cachelines: 2, members: 8 */ - -#endif // NAV_PATH_H + +#endif // NAV_PATH_H diff --git a/regamedll/game_shared/bot/simple_state_machine.h b/regamedll/game_shared/bot/simple_state_machine.h index 8d63d753..13992c74 100644 --- a/regamedll/game_shared/bot/simple_state_machine.h +++ b/regamedll/game_shared/bot/simple_state_machine.h @@ -45,10 +45,10 @@ public: m_parent = NULL; } - virtual ~SimpleState() { }; - virtual void OnEnter(T userData) { }; // when state is entered - virtual void OnUpdate(T userData) { }; // state behavior - virtual void OnExit(T userData) { }; // when state exited + virtual ~SimpleState() {}; + virtual void OnEnter(T userData) {}; // when state is entered + virtual void OnUpdate(T userData) {}; // state behavior + virtual void OnExit(T userData) {}; // when state exited virtual const char *GetName(void) const = 0; // return state name void SetParent(SimpleState *parent) diff --git a/regamedll/game_shared/shared_util.cpp b/regamedll/game_shared/shared_util.cpp index 6619e25e..4217c407 100644 --- a/regamedll/game_shared/shared_util.cpp +++ b/regamedll/game_shared/shared_util.cpp @@ -49,16 +49,16 @@ char *SharedVarArgs(char *format, ...) /* <2d4ba1> ../game_shared/shared_util.cpp:90 */ char *BufPrintf(char *buf, int &len, const char *fmt, ...) { - va_list argptr; - if (len > 0) - { - va_start(argptr, fmt); - Q_vsnprintf(buf, len, fmt, argptr); - va_end(argptr); - - len -= Q_strlen(buf); - return buf + Q_strlen(buf); - } + va_list argptr; + if (len > 0) + { + va_start(argptr, fmt); + Q_vsnprintf(buf, len, fmt, argptr); + va_end(argptr); + + len -= Q_strlen(buf); + return buf + Q_strlen(buf); + } return NULL; } @@ -120,7 +120,7 @@ NOXREF void SharedSetQuoteChar(char c) /* <2d4de7> ../game_shared/shared_util.cpp:173 */ NOBODY const char *SharedParse(const char *data) { -// +// //skipwhite: // 185 // { // int c; // 175 diff --git a/regamedll/game_shared/voice_gamemgr.cpp b/regamedll/game_shared/voice_gamemgr.cpp index 95ecebc8..7d695be4 100644 --- a/regamedll/game_shared/voice_gamemgr.cpp +++ b/regamedll/game_shared/voice_gamemgr.cpp @@ -60,7 +60,7 @@ bool CVoiceGameMgr::Init(IVoiceGameMgrHelper *pHelper, int maxClients) m_msgPlayerVoiceMask = REG_USER_MSG("VoiceMask", VOICE_MAX_PLAYERS_DW * 4 * 2); m_msgRequestState = REG_USER_MSG("ReqState", 0); - + // register voice_serverdebug if it hasn't been registered already if (!CVAR_GET_POINTER("voice_serverdebug")) CVAR_REGISTER(&voice_serverdebug); @@ -119,7 +119,7 @@ bool CVoiceGameMgr::PlayerHasBlockedPlayer(CBasePlayer *pReceiver, CBasePlayer * } /* <2d401a> ../game_shared/voice_gamemgr.cpp:169 */ -bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) +bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) { int playerClientIndex = pPlayer->entindex() - 1; if (playerClientIndex < 0 || playerClientIndex >= m_nMaxPlayers) @@ -173,7 +173,7 @@ void CVoiceGameMgr::UpdateMasks(void) if (!pEnt || !pEnt->IsPlayer()) continue; - + CBasePlayer *pPlayer = (CBasePlayer *)pEnt; CPlayerBitVec gameRulesMask; diff --git a/regamedll/hookers/6153_hooker.cpp b/regamedll/hookers/6153_hooker.cpp index 5d191895..c9631d6b 100644 --- a/regamedll/hookers/6153_hooker.cpp +++ b/regamedll/hookers/6153_hooker.cpp @@ -29,6 +29,7 @@ #include "precompiled.h" #define CBASE_VIRTUAL_COUNT 58 +#define CWEAPON_VIRTUAL_COUNT 94 template size_t mfunc_ptr_cast(MFUNC f) @@ -233,7 +234,7 @@ FunctionHook g_FunctionHooks[] = { 0x01D6FE40, "_ZN4CGib14StickyGibTouchEP11CBaseEntity", mfunc_ptr_cast(&CGib::StickyGibTouch) }, { 0x01D6FBF0, "_ZN4CGib12WaitTillLandEv", mfunc_ptr_cast(&CGib::WaitTillLand) }, { 0x01D6E550, "_ZN4CGib13LimitVelocityEv", mfunc_ptr_cast(&CGib::LimitVelocity) }, - //{ 0x01D6EAB0, "_ZN4CGib12SpawnHeadGibEP9entvars_s", mfunc_ptr_cast(&CGib::SpawnHeadGib) }, + { 0x01D6EAB0, "_ZN4CGib12SpawnHeadGibEP9entvars_s", mfunc_ptr_cast(&CGib::SpawnHeadGib) }, { 0x01D6EEB0, "_ZN4CGib15SpawnRandomGibsEP9entvars_sii", mfunc_ptr_cast(&CGib::SpawnRandomGibs) }, //{ 0x01D6E640, "_ZN4CGib15SpawnStickyGibsEP9entvars_s6Vectori", mfunc_ptr_cast(&CGib::SpawnStickyGibs) }, // NOXREF #endif // Monsters_Region @@ -375,64 +376,64 @@ FunctionHook g_FunctionHooks[] = { 0x01D63060, "_Z14SaveReadFieldsP13saverestore_sPKcPvP15TYPEDESCRIPTIONi", (size_t)&SaveReadFields }, //virtual func //CBaseEntity - //{ 0x01D18590, "_ZN11CBaseEntity5SpawnEv", mfunc_ptr_cast(&CBaseEntity::Spawn_) }, // pure - //{ 0x01D185A0, "_ZN11CBaseEntity8PrecacheEv", mfunc_ptr_cast(&CBaseEntity::Precache) }, - //{ 0x01D01B90, "_ZN11CBaseEntity7RestartEv", mfunc_ptr_cast(&CBaseEntity::Restart) }, - ////{ 0x01D185B0, "_ZN11CBaseEntity8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseEntity::KeyValue_) }, + //{ 0x01D18590, "_ZN11CBaseEntity5SpawnEv", mfunc_ptr_cast(&CBaseEntity::Spawn_) }, // PURE + //{ 0x01D185A0, "_ZN11CBaseEntity8PrecacheEv", mfunc_ptr_cast(&CBaseEntity::Precache_) }, // PURE + //{ 0x01D01B90, "_ZN11CBaseEntity7RestartEv", mfunc_ptr_cast(&CBaseEntity::Restart_) }, // PURE + ////{ 0x01D185B0, "_ZN11CBaseEntity8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseEntity::KeyValue_) }, // default { 0x01D635D0, "_ZN11CBaseEntity4SaveER5CSave", mfunc_ptr_cast(&CBaseEntity::Save_) }, { 0x01D63610, "_ZN11CBaseEntity7RestoreER8CRestore", mfunc_ptr_cast(&CBaseEntity::Restore_) }, - //{ 0x01D01BA0, "_ZN11CBaseEntity10ObjectCapsEv", mfunc_ptr_cast(&CBaseEntity::ObjectCaps) }, - //{ 0x01D01BB0, "_ZN11CBaseEntity8ActivateEv", mfunc_ptr_cast(&CBaseEntity::Activate) }, - //{ 0x01D638B0, "_ZN11CBaseEntity21SetObjectCollisionBoxEv", mfunc_ptr_cast(&CBaseEntity::SetObjectCollisionBox) }, - //{ 0x01D01BC0, "_ZN11CBaseEntity8ClassifyEv", mfunc_ptr_cast(&CBaseEntity::Classify) }, + //{ 0x01D01BA0, "_ZN11CBaseEntity10ObjectCapsEv", mfunc_ptr_cast(&CBaseEntity::ObjectCaps_) }, // default + //{ 0x01D01BB0, "_ZN11CBaseEntity8ActivateEv", mfunc_ptr_cast(&CBaseEntity::Activate_) }, // PURE + //{ 0x01D638B0, "_ZN11CBaseEntity21SetObjectCollisionBoxEv", mfunc_ptr_cast(&CBaseEntity::SetObjectCollisionBox_) }, // default + //{ 0x01D01BC0, "_ZN11CBaseEntity8ClassifyEv", mfunc_ptr_cast(&CBaseEntity::Classify_) }, // default { 0x01D01BD0, "_ZN11CBaseEntity11DeathNoticeEP9entvars_s", mfunc_ptr_cast(&CBaseEntity::DeathNotice_) }, { 0x01D719D0, "_ZN11CBaseEntity11TraceAttackEP9entvars_sf6VectorP11TraceResulti", mfunc_ptr_cast(&CBaseEntity::TraceAttack_) }, { 0x01D63210, "_ZN11CBaseEntity10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CBaseEntity::TakeDamage_) }, { 0x01D63190, "_ZN11CBaseEntity10TakeHealthEfi", mfunc_ptr_cast(&CBaseEntity::TakeHealth_) }, { 0x01D63550, "_ZN11CBaseEntity6KilledEP9entvars_si", mfunc_ptr_cast(&CBaseEntity::Killed_) }, - //{ 0x01D01BE0, "_ZN11CBaseEntity10BloodColorEv", mfunc_ptr_cast(&CBaseEntity::BloodColor) }, + //{ 0x01D01BE0, "_ZN11CBaseEntity10BloodColorEv", mfunc_ptr_cast(&CBaseEntity::BloodColor_) }, // default { 0x01D72EE0, "_ZN11CBaseEntity10TraceBleedEf6VectorP11TraceResulti", mfunc_ptr_cast(&CBaseEntity::TraceBleed_) }, - //{ 0x01D01BF0, "_ZN11CBaseEntity11IsTriggeredEPS_", mfunc_ptr_cast(&CBaseEntity::IsTriggered) }, - //{ 0x01D01C00, "_ZN11CBaseEntity16MyMonsterPointerEv", mfunc_ptr_cast(&CBaseEntity::MyMonsterPointer) }, - //{ 0x01D01C10, "_ZN11CBaseEntity21MySquadMonsterPointerEv", mfunc_ptr_cast(&CBaseEntity::MySquadMonsterPointer) }, + //{ 0x01D01BF0, "_ZN11CBaseEntity11IsTriggeredEPS_", mfunc_ptr_cast(&CBaseEntity::IsTriggered_) }, // default + //{ 0x01D01C00, "_ZN11CBaseEntity16MyMonsterPointerEv", mfunc_ptr_cast(&CBaseEntity::MyMonsterPointer_) }, // default + //{ 0x01D01C10, "_ZN11CBaseEntity21MySquadMonsterPointerEv", mfunc_ptr_cast(&CBaseEntity::MySquadMonsterPointer_) }, // default { 0x01D01C20, "_ZN11CBaseEntity14GetToggleStateEv", mfunc_ptr_cast(&CBaseEntity::GetToggleState_) }, - //{ 0x01D01C30, "_ZN11CBaseEntity9AddPointsEii", mfunc_ptr_cast(&CBaseEntity::AddPoints) }, - //{ 0x01D01C40, "_ZN11CBaseEntity15AddPointsToTeamEii", mfunc_ptr_cast(&CBaseEntity::AddPointsToTeam) }, - //{ 0x01D01C50, "_ZN11CBaseEntity13AddPlayerItemEP15CBasePlayerItem", mfunc_ptr_cast(&CBaseEntity::AddPlayerItem) }, - //{ 0x01D01C60, "_ZN11CBaseEntity16RemovePlayerItemEP15CBasePlayerItem", mfunc_ptr_cast(&CBaseEntity::RemovePlayerItem) }, - //{ 0x01D01C70, "_ZN11CBaseEntity8GiveAmmoEiPci", mfunc_ptr_cast(&CBaseEntity::GiveAmmo) }, + //{ 0x01D01C30, "_ZN11CBaseEntity9AddPointsEii", mfunc_ptr_cast(&CBaseEntity::AddPoints_) }, // PURE + //{ 0x01D01C40, "_ZN11CBaseEntity15AddPointsToTeamEii", mfunc_ptr_cast(&CBaseEntity::AddPointsToTeam_) }, // PURE + //{ 0x01D01C50, "_ZN11CBaseEntity13AddPlayerItemEP15CBasePlayerItem", mfunc_ptr_cast(&CBaseEntity::AddPlayerItem_) }, // default + //{ 0x01D01C60, "_ZN11CBaseEntity16RemovePlayerItemEP15CBasePlayerItem", mfunc_ptr_cast(&CBaseEntity::RemovePlayerItem_) }, // default + //{ 0x01D01C70, "_ZN11CBaseEntity8GiveAmmoEiPci", mfunc_ptr_cast(&CBaseEntity::GiveAmmo_) }, // default { 0x01D01C80, "_ZN11CBaseEntity8GetDelayEv", mfunc_ptr_cast(&CBaseEntity::GetDelay_) }, - ////{ 0x01D01C90, "_ZN11CBaseEntity8IsMovingEv", mfunc_ptr_cast(&CBaseEntity::IsMoving) }, - //{ 0x01D01CE0, "_ZN11CBaseEntity13OverrideResetEv", mfunc_ptr_cast(&CBaseEntity::OverrideReset) }, + ////{ 0x01D01C90, "_ZN11CBaseEntity8IsMovingEv", mfunc_ptr_cast(&CBaseEntity::IsMoving_) }, + //{ 0x01D01CE0, "_ZN11CBaseEntity13OverrideResetEv", mfunc_ptr_cast(&CBaseEntity::OverrideReset_) }, // PURE { 0x01D63AF0, "_ZN11CBaseEntity11DamageDecalEi", mfunc_ptr_cast(&CBaseEntity::DamageDecal_) }, - //{ 0x01D01CF0, "_ZN11CBaseEntity14SetToggleStateEi", mfunc_ptr_cast(&CBaseEntity::SetToggleState) }, - //{ 0x01D01D00, "_ZN11CBaseEntity13StartSneakingEv", mfunc_ptr_cast(&CBaseEntity::StartSneaking) }, - //{ 0x01D01D10, "_ZN11CBaseEntity12StopSneakingEv", mfunc_ptr_cast(&CBaseEntity::StopSneaking) }, - //{ 0x01D01D20, "_ZN11CBaseEntity10OnControlsEP9entvars_s", mfunc_ptr_cast(&CBaseEntity::OnControls) }, - ////{ 0x01D01D30, "_ZN11CBaseEntity10IsSneakingEv", mfunc_ptr_cast(&CBaseEntity::IsSneaking) }, - //{ 0x01D01D40, "_ZN11CBaseEntity7IsAliveEv", mfunc_ptr_cast(&CBaseEntity::IsAlive) }, - //{ 0x01D01D70, "_ZN11CBaseEntity10IsBSPModelEv", mfunc_ptr_cast(&CBaseEntity::IsBSPModel) }, - //{ 0x01D01D90, "_ZN11CBaseEntity12ReflectGaussEv", mfunc_ptr_cast(&CBaseEntity::ReflectGauss) }, - //{ 0x01D01DC0, "_ZN11CBaseEntity9HasTargetEj", mfunc_ptr_cast(&CBaseEntity::HasTarget) }, + //{ 0x01D01CF0, "_ZN11CBaseEntity14SetToggleStateEi", mfunc_ptr_cast(&CBaseEntity::SetToggleState_) }, // PURE + //{ 0x01D01D00, "_ZN11CBaseEntity13StartSneakingEv", mfunc_ptr_cast(&CBaseEntity::StartSneaking_) }, // PURE + //{ 0x01D01D10, "_ZN11CBaseEntity12StopSneakingEv", mfunc_ptr_cast(&CBaseEntity::StopSneaking_) }, // PURE + //{ 0x01D01D20, "_ZN11CBaseEntity10OnControlsEP9entvars_s", mfunc_ptr_cast(&CBaseEntity::OnControls_) }, // default + ////{ 0x01D01D30, "_ZN11CBaseEntity10IsSneakingEv", mfunc_ptr_cast(&CBaseEntity::IsSneaking_) }, // default + //{ 0x01D01D40, "_ZN11CBaseEntity7IsAliveEv", mfunc_ptr_cast(&CBaseEntity::IsAlive_) }, // default + //{ 0x01D01D70, "_ZN11CBaseEntity10IsBSPModelEv", mfunc_ptr_cast(&CBaseEntity::IsBSPModel_) }, // default + //{ 0x01D01D90, "_ZN11CBaseEntity12ReflectGaussEv", mfunc_ptr_cast(&CBaseEntity::ReflectGauss_) }, // default + //{ 0x01D01DC0, "_ZN11CBaseEntity9HasTargetEj", mfunc_ptr_cast(&CBaseEntity::HasTarget_) }, // default { 0x01D639C0, "_ZN11CBaseEntity9IsInWorldEv", mfunc_ptr_cast(&CBaseEntity::IsInWorld_) }, - //{ 0x01D01E30, "_ZN11CBaseEntity8IsPlayerEv", mfunc_ptr_cast(&CBaseEntity::IsPlayer) }, - //{ 0x01D01E40, "_ZN11CBaseEntity11IsNetClientEv", mfunc_ptr_cast(&CBaseEntity::IsNetClient_) }, - //{ 0x01D01E50, "_ZN11CBaseEntity6TeamIDEv", mfunc_ptr_cast(&CBaseEntity::TeamID) }, + //{ 0x01D01E30, "_ZN11CBaseEntity8IsPlayerEv", mfunc_ptr_cast(&CBaseEntity::IsPlayer_) }, // default + //{ 0x01D01E40, "_ZN11CBaseEntity11IsNetClientEv", mfunc_ptr_cast(&CBaseEntity::IsNetClient_) }, // default + //{ 0x01D01E50, "_ZN11CBaseEntity6TeamIDEv", mfunc_ptr_cast(&CBaseEntity::TeamID_) }, // default { 0x01D63580, "_ZN11CBaseEntity13GetNextTargetEv", mfunc_ptr_cast(&CBaseEntity::GetNextTarget_) }, - //{ 0x01D01E60, "_ZN11CBaseEntity5ThinkEv", mfunc_ptr_cast(&CBaseEntity::Think) }, - //{ 0x01D01E70, "_ZN11CBaseEntity5TouchEPS_", mfunc_ptr_cast(&CBaseEntity::Touch) }, - //{ 0x01D01E80, "_ZN11CBaseEntity3UseEPS_S0_8USE_TYPEf", mfunc_ptr_cast(&CBaseEntity::Use) }, - //{ 0x01D01EA0, "_ZN11CBaseEntity7BlockedEPS_", mfunc_ptr_cast(&CBaseEntity::Blocked) }, - //{ 0x01D18B00, "_ZN11CBaseEntity7RespawnEv", mfunc_ptr_cast(&CBaseEntity::Respawn) }, - //{ 0x01D01EC0, "_ZN11CBaseEntity11UpdateOwnerEv", mfunc_ptr_cast(&CBaseEntity::UpdateOwner) }, - //{ 0x01D01ED0, "_ZN11CBaseEntity12FBecomeProneEv", mfunc_ptr_cast(&CBaseEntity::FBecomeProne) }, - //{ 0x01D01EE0, "_ZN11CBaseEntity6CenterEv", mfunc_ptr_cast(&CBaseEntity::Center) }, - //{ 0x01D01F40, "_ZN11CBaseEntity11EyePositionEv", mfunc_ptr_cast(&CBaseEntity::EyePosition) }, - //{ 0x01D01F70, "_ZN11CBaseEntity11EarPositionEv", mfunc_ptr_cast(&CBaseEntity::EarPosition) }, + //{ 0x01D01E60, "_ZN11CBaseEntity5ThinkEv", mfunc_ptr_cast(&CBaseEntity::Think_) }, // default + //{ 0x01D01E70, "_ZN11CBaseEntity5TouchEPS_", mfunc_ptr_cast(&CBaseEntity::Touch_) }, // default + //{ 0x01D01E80, "_ZN11CBaseEntity3UseEPS_S0_8USE_TYPEf", mfunc_ptr_cast(&CBaseEntity::Use_) }, // default + //{ 0x01D01EA0, "_ZN11CBaseEntity7BlockedEPS_", mfunc_ptr_cast(&CBaseEntity::Blocked_) }, // default + //{ 0x01D18B00, "_ZN11CBaseEntity7RespawnEv", mfunc_ptr_cast(&CBaseEntity::Respawn_) }, // default + //{ 0x01D01EC0, "_ZN11CBaseEntity11UpdateOwnerEv", mfunc_ptr_cast(&CBaseEntity::UpdateOwner_) }, // PURE + //{ 0x01D01ED0, "_ZN11CBaseEntity12FBecomeProneEv", mfunc_ptr_cast(&CBaseEntity::FBecomeProne_) }, // default + //{ 0x01D01EE0, "_ZN11CBaseEntity6CenterEv", mfunc_ptr_cast(&CBaseEntity::Center_) }, // default + //{ 0x01D01F40, "_ZN11CBaseEntity11EyePositionEv", mfunc_ptr_cast(&CBaseEntity::EyePosition_) }, // default + //{ 0x01D01F70, "_ZN11CBaseEntity11EarPositionEv", mfunc_ptr_cast(&CBaseEntity::EarPosition_) }, // default { 0x01D01FA0, "_ZN11CBaseEntity10BodyTargetERK6Vector", mfunc_ptr_cast(&CBaseEntity::BodyTarget_) }, - ////{ 0x01D01FC0, "_ZN11CBaseEntity12IlluminationEv", mfunc_ptr_cast(&CBaseEntity::Illumination) }, - //{ 0x01D71950, "_ZN11CBaseEntity8FVisibleERK6Vector", mfunc_ptr_cast(&CBaseEntity::FVisible_) }, - //{ 0x01D71840, "_ZN11CBaseEntity8FVisibleEPS_", mfunc_ptr_cast(&CBaseEntity::FVisible_) }, + //{ 0x01D01FC0, "_ZN11CBaseEntity12IlluminationEv", mfunc_ptr_cast(&CBaseEntity::Illumination_) }, // default + { 0x01D71840, "_ZN11CBaseEntity8FVisibleEPS_", mfunc_ptr_cast(&CBaseEntity::FVisible_) }, + { 0x01D71950, "_ZN11CBaseEntity8FVisibleERK6Vector", mfunc_ptr_cast(&CBaseEntity::FVisible_) }, //non-virtual func //{ 0x01DA7FD0, "", mfunc_ptr_cast(&CBaseEntity::Instance) }, { 0x01DBAF90, "_ZN11CBaseEntity14UpdateOnRemoveEv", mfunc_ptr_cast(&CBaseEntity::UpdateOnRemove) }, @@ -442,8 +443,8 @@ FunctionHook g_FunctionHooks[] = { 0x01D6FB80, "_ZN11CBaseEntity11SUB_FadeOutEv", mfunc_ptr_cast(&CBaseEntity::SUB_FadeOut) }, { 0x01D01EB0, "_ZN11CBaseEntity17SUB_CallUseToggleEv", mfunc_ptr_cast(&CBaseEntity::SUB_CallUseToggle) }, { 0x01D63AC0, "_ZN11CBaseEntity12ShouldToggleE8USE_TYPEi", mfunc_ptr_cast(&CBaseEntity::ShouldToggle) }, - //{ 0x01D71BC0, "_ZN11CBaseEntity11FireBulletsEj6VectorS0_S0_fiiiP9entvars_s", mfunc_ptr_cast(&CBaseEntity::FireBullets) }, - //C!@{ 0x01D72480, "_ZN11CBaseEntity12FireBullets3E6VectorS0_ffiiifP9entvars_sbi", mfunc_ptr_cast(&CBaseEntity::FireBullets3) }, + { 0x01D71BC0, "_ZN11CBaseEntity11FireBulletsEj6VectorS0_S0_fiiiP9entvars_s", mfunc_ptr_cast(&CBaseEntity::FireBullets) }, + { 0x01D72480, "_ZN11CBaseEntity12FireBullets3E6VectorS0_ffiiifP9entvars_sbi", mfunc_ptr_cast(&CBaseEntity::FireBullets3) }, { 0x01DBB190, "_ZN11CBaseEntity14SUB_UseTargetsEPS_8USE_TYPEf", mfunc_ptr_cast(&CBaseEntity::SUB_UseTargets) }, { 0x01DBB260, "_Z11FireTargetsPKcP11CBaseEntityS2_8USE_TYPEf", (size_t)&FireTargets }, { 0x01D638C0, "_ZN11CBaseEntity10IntersectsEPS_", mfunc_ptr_cast(&CBaseEntity::Intersects) }, @@ -452,8 +453,13 @@ FunctionHook g_FunctionHooks[] = //{ 0x0, "_ZN11CBaseEntity16IsLockedByMasterEv", mfunc_ptr_cast(&CBaseEntity::IsLockedByMaster) }, // NOXREF { 0x01D63B20, "_ZN11CBaseEntity6CreateEPcRK6VectorS3_P7edict_s", mfunc_ptr_cast(&CBaseEntity::Create) }, //CPointEntity - //{ 0x01DBACC0, "_ZN12CPointEntity5SpawnEv", mfunc_ptr_cast(&CPointEntity::Spawn) }, - //{ 0x01D60CB0, "_ZN12CPointEntity10ObjectCapsEv", mfunc_ptr_cast(&CPointEntity::ObjectCaps) }, + { 0x01DBACC0, "_ZN12CPointEntity5SpawnEv", mfunc_ptr_cast(&CPointEntity::Spawn_) }, + { 0x01D60CB0, "_ZN12CPointEntity10ObjectCapsEv", mfunc_ptr_cast(&CPointEntity::ObjectCaps_) }, +//CNullEntity + { 0x01DBACD0, "_ZN11CNullEntity5SpawnEv", mfunc_ptr_cast(&CNullEntity::Spawn_) }, +//CBaseDMStart + { 0x01DBAF20, "_ZN12CBaseDMStart8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseDMStart::KeyValue_) }, + { 0x01DBAF70, "_ZN12CBaseDMStart11IsTriggeredEP11CBaseEntity", mfunc_ptr_cast(&CBaseDMStart::IsTriggered_) }, //CBaseDelay //virtual func { 0x01DBB110, "_ZN10CBaseDelay8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseDelay::KeyValue_) }, @@ -495,25 +501,29 @@ FunctionHook g_FunctionHooks[] = //{ 0x01D20F20, "_ZN11CBaseToggle14GetToggleStateEv", mfunc_ptr_cast(&CBaseToggle::GetToggleState_) }, //{ 0x01D20F30, "_ZN11CBaseToggle8GetDelayEv", mfunc_ptr_cast(&CBaseToggle::GetDelay_) }, //non-virtual func - //{ 0x0, "_ZN11CBaseToggle10LinearMoveE6Vectorf", mfunc_ptr_cast(&CBaseToggle::LinearMove) }, - //{ 0x0, "_ZN11CBaseToggle14LinearMoveDoneEv", mfunc_ptr_cast(&CBaseToggle::LinearMoveDone) }, - //{ 0x0, "_ZN11CBaseToggle11AngularMoveE6Vectorf", mfunc_ptr_cast(&CBaseToggle::AngularMove) }, - //{ 0x0, "_ZN11CBaseToggle15AngularMoveDoneEv", mfunc_ptr_cast(&CBaseToggle::AngularMoveDone) }, - //{ 0x0, "_ZN11CBaseToggle16IsLockedByMasterEv", mfunc_ptr_cast(&CBaseToggle::IsLockedByMaster) }, - //{ 0x01DBBCA0, "_ZN11CBaseToggle9AxisValueEiRK6Vector", mfunc_ptr_cast(&CBaseToggle::AxisValue) }, - //{ 0x0, "_ZN11CBaseToggle7AxisDirEP9entvars_s", mfunc_ptr_cast(&CBaseToggle::AxisDir) }, - //{ 0x01DBBD60, "_ZN11CBaseToggle9AxisDeltaEiRK6VectorS2_", mfunc_ptr_cast(&CBaseToggle::AxisDelta) }, + { 0x01DBB920, "_ZN11CBaseToggle10LinearMoveE6Vectorf", mfunc_ptr_cast(&CBaseToggle::LinearMove) }, + { 0x01DBBA60, "_ZN11CBaseToggle14LinearMoveDoneEv", mfunc_ptr_cast(&CBaseToggle::LinearMoveDone) }, + { 0x01DBBAC0, "_ZN11CBaseToggle16IsLockedByMasterEv", mfunc_ptr_cast(&CBaseToggle::IsLockedByMaster) }, // NOXREF + { 0x01DBBB00, "_ZN11CBaseToggle11AngularMoveE6Vectorf", mfunc_ptr_cast(&CBaseToggle::AngularMove) }, + { 0x01DBBC40, "_ZN11CBaseToggle15AngularMoveDoneEv", mfunc_ptr_cast(&CBaseToggle::AngularMoveDone) }, + { 0x01DBBCA0, "_ZN11CBaseToggle9AxisValueEiRK6Vector", mfunc_ptr_cast(&CBaseToggle::AxisValue) }, + { 0x01DBBCD0, "_ZN11CBaseToggle7AxisDirEP9entvars_s", mfunc_ptr_cast(&CBaseToggle::AxisDir) }, + { 0x01DBBD60, "_ZN11CBaseToggle9AxisDeltaEiRK6VectorS2_", mfunc_ptr_cast(&CBaseToggle::AxisDelta) }, //{ 0x01DBBDA0, "_Z13FEntIsVisibleP9entvars_sS0_", (size_t)&FEntIsVisible }, // NOXREF //CWorld //virtual func { 0x01DD1EE0, "_ZN6CWorld5SpawnEv", mfunc_ptr_cast(&CWorld::Spawn_) }, { 0x01DD2000, "_ZN6CWorld8PrecacheEv", mfunc_ptr_cast(&CWorld::Precache_) }, { 0x01DD2440, "_ZN6CWorld8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CWorld::KeyValue_) }, - -//CClientFog - //virtual func - //{ 0x0, "_ZN10CClientFog5SpawnEv", mfunc_ptr_cast(&CClientFog::Spawn) }, - //{ 0x0, "_ZN10CClientFog8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CClientFog::KeyValue) }, +//linked objects + { 0x01DBACF0, "info_null", (size_t)&info_null }, + { 0x01DBAD40, "info_player_deathmatch", (size_t)&info_player_deathmatch }, + { 0x01DBAD90, "info_player_start", (size_t)&info_player_start }, + { 0x01DBADE0, "info_vip_start", (size_t)&info_vip_start }, + { 0x01DBAE30, "info_landmark", (size_t)&info_landmark }, + { 0x01DBAE80, "info_hostage_rescue", (size_t)&info_hostage_rescue }, + { 0x01DBAED0, "info_bomb_target", (size_t)&info_bomb_target }, + { 0x01DBB310, "DelayedUse", (size_t)&DelayedUse }, #endif // Cbase_Region @@ -544,18 +554,18 @@ FunctionHook g_FunctionHooks[] = { 0x01D6F390, "_ZN12CBaseMonster12HasAlienGibsEv", mfunc_ptr_cast(&CBaseMonster::HasAlienGibs_) }, { 0x01D6F3C0, "_ZN12CBaseMonster11FadeMonsterEv", mfunc_ptr_cast(&CBaseMonster::FadeMonster_) }, { 0x01D6F4B0, "_ZN12CBaseMonster10GibMonsterEv", mfunc_ptr_cast(&CBaseMonster::GibMonster_) }, - //{ 0x01D6F5A0, "_ZN12CBaseMonster16GetDeathActivityEv", mfunc_ptr_cast(&CBaseMonster::GetDeathActivity) }, + { 0x01D6F5A0, "_ZN12CBaseMonster16GetDeathActivityEv", mfunc_ptr_cast(&CBaseMonster::GetDeathActivity_) }, { 0x01D6F880, "_ZN12CBaseMonster10BecomeDeadEv", mfunc_ptr_cast(&CBaseMonster::BecomeDead_) }, { 0x01D8AD10, "_ZN12CBaseMonster17ShouldFadeOnDeathEv", mfunc_ptr_cast(&CBaseMonster::ShouldFadeOnDeath_) }, - //{ 0x01D8AD40, "_ZN12CBaseMonster13IRelationshipEP11CBaseEntity", mfunc_ptr_cast(&CBaseMonster::IRelationship) }, - //{ 0x01D20F40, "_ZN12CBaseMonster9PainSoundEv", mfunc_ptr_cast(&CBaseMonster::PainSound_) }, - //{ 0x01D24AD0, "_ZN12CBaseMonster13ResetMaxSpeedEv", mfunc_ptr_cast(&CBaseMonster::ResetMaxSpeed) }, - //{ 0x01D8ABE0, "_ZN12CBaseMonster13ReportAIStateEv", mfunc_ptr_cast(&CBaseMonster::ReportAIState) }, + { 0x01D8AD40, "_ZN12CBaseMonster13IRelationshipEP11CBaseEntity", mfunc_ptr_cast(&CBaseMonster::IRelationship_) }, + //{ 0x01D20F40, "_ZN12CBaseMonster9PainSoundEv", mfunc_ptr_cast(&CBaseMonster::PainSound_) }, // PURE + //{ 0x01D24AD0, "_ZN12CBaseMonster13ResetMaxSpeedEv", mfunc_ptr_cast(&CBaseMonster::ResetMaxSpeed_) }, // PURE + //{ 0x01D8ABE0, "_ZN12CBaseMonster13ReportAIStateEv", mfunc_ptr_cast(&CBaseMonster::ReportAIState_) }, // PURE { 0x01D8AC60, "_ZN12CBaseMonster15MonsterInitDeadEv", mfunc_ptr_cast(&CBaseMonster::MonsterInitDead_) }, - //{ 0x01D8AD70, "_ZN12CBaseMonster4LookEi", mfunc_ptr_cast(&CBaseMonster::Look) }, - //{ 0x01D8AF10, "_ZN12CBaseMonster16BestVisibleEnemyEv", mfunc_ptr_cast(&CBaseMonster::BestVisibleEnemy) }, - //{ 0x01D716D0, "_ZN12CBaseMonster11FInViewConeEP11CBaseEntity", mfunc_ptr_cast(&CBaseMonster::FInViewCone_) }, - //{ 0x01D71790, "_ZN12CBaseMonster11FInViewConeEP6Vector", mfunc_ptr_cast(&CBaseMonster::FInViewCone_) }, + { 0x01D8AD70, "_ZN12CBaseMonster4LookEi", mfunc_ptr_cast(&CBaseMonster::Look_) }, + { 0x01D8AF10, "_ZN12CBaseMonster16BestVisibleEnemyEv", mfunc_ptr_cast(&CBaseMonster::BestVisibleEnemy_) }, + { 0x01D716D0, "_ZN12CBaseMonster11FInViewConeEP11CBaseEntity", mfunc_ptr_cast(&CBaseMonster::FInViewCone_) }, + { 0x01D71790, "_ZN12CBaseMonster11FInViewConeEP6Vector", mfunc_ptr_cast(&CBaseMonster::FInViewCone_) }, //non-virtual func //{ 0x01D8AC00, "_ZN12CBaseMonster12MakeIdealYawE6Vector", mfunc_ptr_cast(&CBaseMonster::MakeIdealYaw) }, // PURE //{ 0x01D6F7F0, "_ZN12CBaseMonster22GetSmallFlinchActivityEv", mfunc_ptr_cast(&CBaseMonster::GetSmallFlinchActivity) }, // NOXREF @@ -567,7 +577,7 @@ FunctionHook g_FunctionHooks[] = { 0x01D71470, "_ZN12CBaseMonster12RadiusDamageEP9entvars_sS1_fii", mfunc_ptr_cast(&CBaseMonster::RadiusDamage) }, //{ 0x01D71520, "_ZN12CBaseMonster12RadiusDamageE6VectorP9entvars_sS2_fii", mfunc_ptr_cast(&CBaseMonster::RadiusDamage) }, // NOXREF //{ 0x0, "_ZN12CBaseMonster13RadiusDamage2E6VectorP9entvars_sS2_fii", mfunc_ptr_cast(&CBaseMonster::RadiusDamage2) }, // NOXREF - //{ 0x01D8AC10, "_ZN12CBaseMonster15CorpseFallThinkEv", mfunc_ptr_cast(&CBaseMonster::CorpseFallThink) }, + { 0x01D8AC10, "_ZN12CBaseMonster15CorpseFallThinkEv", mfunc_ptr_cast(&CBaseMonster::CorpseFallThink) }, //{ 0x01D715D0, "_ZN12CBaseMonster20CheckTraceHullAttackEfii", mfunc_ptr_cast(&CBaseMonster::CheckTraceHullAttack) }, // NOXREF //{ 0x01D730E0, "_ZN12CBaseMonster20MakeDamageBloodDecalEifP11TraceResultRK6Vector", mfunc_ptr_cast(&CBaseMonster::MakeDamageBloodDecal) }, // NOXREF { 0x01D73240, "_ZN12CBaseMonster10BloodSplatER6VectorS1_ii", mfunc_ptr_cast(&CBaseMonster::BloodSplat) }, @@ -832,7 +842,7 @@ FunctionHook g_FunctionHooks[] = //{ 0x01DAD520, "_Z22CurrentWeaponSatisfiesP17CBasePlayerWeaponii", (size_t)&CurrentWeaponSatisfies }, // NOXREF //CWShield //virtual func - { 0x1DA08D0, "_ZN8CWShield5SpawnEv", mfunc_ptr_cast(&CWShield::Spawn_) }, + { 0x01DA08D0, "_ZN8CWShield5SpawnEv", mfunc_ptr_cast(&CWShield::Spawn_) }, { 0x01DA0920, "_ZN8CWShield5TouchEP11CBaseEntity", mfunc_ptr_cast(&CWShield::Touch_) }, //non-virtual func //{ 0x0, "_ZN8CWShield23SetCantBePickedUpByUserEP11CBaseEntityf", mfunc_ptr_cast(&CWShield::SetCantBePickedUpByUser) } // NOXREF INLINEBODY @@ -867,7 +877,7 @@ FunctionHook g_FunctionHooks[] = //virtual func { 0x01DABF20, "_ZN17CInfoIntermission5SpawnEv", mfunc_ptr_cast(&CInfoIntermission::Spawn_) }, { 0x01DABF90, "_ZN17CInfoIntermission5ThinkEv", mfunc_ptr_cast(&CInfoIntermission::Think_) }, -//linked object + //linked objects { 0x01D9B1F0, "player", (size_t)&player }, { 0x01DAC0A0, "info_intermission", (size_t)&info_intermission }, { 0x01DABC70, "player_loadsaved", (size_t)&player_loadsaved }, @@ -996,7 +1006,7 @@ FunctionHook g_FunctionHooks[] = { 0x01D76CB0, "_ZN10CLightning9ToggleUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CLightning::ToggleUse) }, //{ 0x0, "_ZN10CLightning10ServerSideEv", mfunc_ptr_cast(&CLightning::ServerSide) }, // NOXREF { 0x01D77E60, "_ZN10CLightning14BeamUpdateVarsEv", mfunc_ptr_cast(&CLightning::BeamUpdateVars) }, - //{ 0x1D76E70, "_Z13IsPointEntityP11CBaseEntity", (size_t)&IsPointEntity }, // NOXREF + //{ 0x01D76E70, "_Z13IsPointEntityP11CBaseEntity", (size_t)&IsPointEntity }, // NOXREF //CGlow //virtual func { 0x01D78E90, "_ZN5CGlow5SpawnEv", mfunc_ptr_cast(&CGlow::Spawn_) }, @@ -1091,8 +1101,7 @@ FunctionHook g_FunctionHooks[] = //non-virtual func { 0x01D7B790, "_ZN9CItemSoda8CanThinkEv", mfunc_ptr_cast(&CItemSoda::CanThink) }, { 0x01D7B820, "_ZN9CItemSoda8CanTouchEP11CBaseEntity", mfunc_ptr_cast(&CItemSoda::CanTouch) }, - -//linked objects + //linked objects { 0x01D75980, "info_target", (size_t)&info_target }, { 0x01D759D0, "env_bubbles", (size_t)&env_bubbles }, { 0x01D75DB0, "beam", (size_t)&beam }, @@ -1119,138 +1128,147 @@ FunctionHook g_FunctionHooks[] = //CBasePlatTrain //virtual func - //{ 0x0, "_ZN14CBasePlatTrain8PrecacheEv", mfunc_ptr_cast(&CBasePlatTrain::Precache_) }, - //{ 0x0, "_ZN14CBasePlatTrain8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBasePlatTrain::KeyValue_) }, - //{ 0x0, "_ZN14CBasePlatTrain4SaveER5CSave", mfunc_ptr_cast(&CBasePlatTrain::Save_) }, - //{ 0x0, "_ZN14CBasePlatTrain7RestoreER8CRestore", mfunc_ptr_cast(&CBasePlatTrain::Restore_) }, - //{ 0x0, "_ZN14CBasePlatTrain10ObjectCapsEv", mfunc_ptr_cast(&CBasePlatTrain::ObjectCaps_) }, - //{ 0x0, "_ZN14CBasePlatTrain12IsTogglePlatEv", mfunc_ptr_cast(&CBasePlatTrain::IsTogglePlat_) }, + { 0x01D95570, "_ZN14CBasePlatTrain8PrecacheEv", mfunc_ptr_cast(&CBasePlatTrain::Precache_) }, + { 0x01D953E0, "_ZN14CBasePlatTrain8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBasePlatTrain::KeyValue_) }, + { 0x01D95380, "_ZN14CBasePlatTrain4SaveER5CSave", mfunc_ptr_cast(&CBasePlatTrain::Save_) }, + { 0x01D953B0, "_ZN14CBasePlatTrain7RestoreER8CRestore", mfunc_ptr_cast(&CBasePlatTrain::Restore_) }, + { 0x01D95890, "_ZN14CBasePlatTrain10ObjectCapsEv", mfunc_ptr_cast(&CBasePlatTrain::ObjectCaps_) }, + { 0x01D958A0, "_ZN14CBasePlatTrain12IsTogglePlatEv", mfunc_ptr_cast(&CBasePlatTrain::IsTogglePlat_) }, //CFuncPlat //virtual func - //{ 0x0, "_ZN9CFuncPlat5SpawnEv", mfunc_ptr_cast(&CFuncPlat::Spawn_) }, - //{ 0x0, "_ZN9CFuncPlat8PrecacheEv", mfunc_ptr_cast(&CFuncPlat::Precache_) }, - //{ 0x0, "_ZN9CFuncPlat7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncPlat::Blocked_) }, - //{ 0x0, "_ZN9CFuncPlat4GoUpEv", mfunc_ptr_cast(&CFuncPlat::GoUp_) }, - //{ 0x0, "_ZN9CFuncPlat6GoDownEv", mfunc_ptr_cast(&CFuncPlat::GoDown_) }, - //{ 0x0, "_ZN9CFuncPlat6HitTopEv", mfunc_ptr_cast(&CFuncPlat::HitTop_) }, - //{ 0x0, "_ZN9CFuncPlat9HitBottomEv", mfunc_ptr_cast(&CFuncPlat::HitBottom_) }, + { 0x01D95AF0, "_ZN9CFuncPlat5SpawnEv", mfunc_ptr_cast(&CFuncPlat::Spawn_) }, + { 0x01D95A20, "_ZN9CFuncPlat8PrecacheEv", mfunc_ptr_cast(&CFuncPlat::Precache_) }, + { 0x01D95FC0, "_ZN9CFuncPlat7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncPlat::Blocked_) }, + { 0x01D95E90, "_ZN9CFuncPlat4GoUpEv", mfunc_ptr_cast(&CFuncPlat::GoUp_) }, + { 0x01D95D80, "_ZN9CFuncPlat6GoDownEv", mfunc_ptr_cast(&CFuncPlat::GoDown_) }, + { 0x01D95F10, "_ZN9CFuncPlat6HitTopEv", mfunc_ptr_cast(&CFuncPlat::HitTop_) }, + { 0x01D95E00, "_ZN9CFuncPlat9HitBottomEv", mfunc_ptr_cast(&CFuncPlat::HitBottom_) }, //non-virtual func - //{ 0x0, "_ZN9CFuncPlat5SetupEv", mfunc_ptr_cast(&CFuncPlat::Setup) }, - //{ 0x0, "_ZN9CFuncPlat7PlatUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncPlat::PlatUse) }, - //{ 0x0, "_ZN9CFuncPlat10CallGoDownEv", mfunc_ptr_cast(&CFuncPlat::CallGoDown) }, - //{ 0x0, "_ZN9CFuncPlat10CallHitTopEv", mfunc_ptr_cast(&CFuncPlat::CallHitTop) }, - //{ 0x0, "_ZN9CFuncPlat13CallHitBottomEv", mfunc_ptr_cast(&CFuncPlat::CallHitBottom) }, + { 0x01D958B0, "_ZN9CFuncPlat5SetupEv", mfunc_ptr_cast(&CFuncPlat::Setup) }, + { 0x01D95D10, "_ZN9CFuncPlat7PlatUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncPlat::PlatUse) }, + { 0x01D95810, "_ZN9CFuncPlat10CallGoDownEv", mfunc_ptr_cast(&CFuncPlat::CallGoDown) }, + { 0x01D95820, "_ZN9CFuncPlat10CallHitTopEv", mfunc_ptr_cast(&CFuncPlat::CallHitTop) }, + { 0x01D95830, "_ZN9CFuncPlat13CallHitBottomEv", mfunc_ptr_cast(&CFuncPlat::CallHitBottom) }, //CPlatTrigger //virtual func - //{ 0x0, "_ZN12CPlatTrigger10ObjectCapsEv", mfunc_ptr_cast(&CPlatTrigger::ObjectCaps_) }, - //{ 0x0, "_ZN12CPlatTrigger5TouchEP11CBaseEntity", mfunc_ptr_cast(&CPlatTrigger::Touch_) }, + { 0x01D95AE0, "_ZN12CPlatTrigger10ObjectCapsEv", mfunc_ptr_cast(&CPlatTrigger::ObjectCaps_) }, + { 0x01D95C90, "_ZN12CPlatTrigger5TouchEP11CBaseEntity", mfunc_ptr_cast(&CPlatTrigger::Touch_) }, //non-virtual func - //{ 0x0, "_ZN12CPlatTrigger18SpawnInsideTriggerEP9CFuncPlat", mfunc_ptr_cast(&CPlatTrigger::SpawnInsideTrigger) }, + { 0x01D95B50, "_ZN12CPlatTrigger18SpawnInsideTriggerEP9CFuncPlat", mfunc_ptr_cast(&CPlatTrigger::SpawnInsideTrigger) }, //CFuncPlatRot //virtual func - //{ 0x0, "_ZN12CFuncPlatRot5SpawnEv", mfunc_ptr_cast(&CFuncPlatRot::Spawn_) }, - //{ 0x0, "_ZN12CFuncPlatRot4SaveER5CSave", mfunc_ptr_cast(&CFuncPlatRot::Save_) }, - //{ 0x0, "_ZN12CFuncPlatRot7RestoreER8CRestore", mfunc_ptr_cast(&CFuncPlatRot::Restore_) }, - //{ 0x0, "_ZN12CFuncPlatRot4GoUpEv", mfunc_ptr_cast(&CFuncPlat::GoUp_) }, - //{ 0x0, "_ZN12CFuncPlatRot6GoDownEv", mfunc_ptr_cast(&CFuncPlat::GoDown_) }, - //{ 0x0, "_ZN12CFuncPlatRot6HitTopEv", mfunc_ptr_cast(&CFuncPlat::HitTop_) }, - //{ 0x0, "_ZN12CFuncPlatRot9HitBottomEv", mfunc_ptr_cast(&CFuncPlat::HitBottom_) }, + { 0x01D96270, "_ZN12CFuncPlatRot5SpawnEv", mfunc_ptr_cast(&CFuncPlatRot::Spawn_) }, + { 0x01D960C0, "_ZN12CFuncPlatRot4SaveER5CSave", mfunc_ptr_cast(&CFuncPlatRot::Save_) }, + { 0x01D96110, "_ZN12CFuncPlatRot7RestoreER8CRestore", mfunc_ptr_cast(&CFuncPlatRot::Restore_) }, + { 0x01D965C0, "_ZN12CFuncPlatRot4GoUpEv", mfunc_ptr_cast(&CFuncPlatRot::GoUp_) }, + { 0x01D963D0, "_ZN12CFuncPlatRot6GoDownEv", mfunc_ptr_cast(&CFuncPlatRot::GoDown_) }, + { 0x01D966F0, "_ZN12CFuncPlatRot6HitTopEv", mfunc_ptr_cast(&CFuncPlatRot::HitTop_) }, + { 0x01D96500, "_ZN12CFuncPlatRot9HitBottomEv", mfunc_ptr_cast(&CFuncPlatRot::HitBottom_) }, //non-virtual func - //{ 0x0, "_ZN12CFuncPlatRot13SetupRotationEv", mfunc_ptr_cast(&CFuncPlatRot::SetupRotation) }, - //{ 0x0, "_ZN12CFuncPlatRot7RotMoveER6Vectorf", mfunc_ptr_cast(&CFuncPlatRot::RotMove) }, + //{ 0x01D96160, "_ZN12CFuncPlatRot13SetupRotationEv", mfunc_ptr_cast(&CFuncPlatRot::SetupRotation) }, // NOXREF + //{ 0x01D96740, "_ZN12CFuncPlatRot7RotMoveER6Vectorf", mfunc_ptr_cast(&CFuncPlatRot::RotMove) }, // NOXREF //CFuncTrain //virtual func - //{ 0x0, "_ZN10CFuncTrain5SpawnEv", mfunc_ptr_cast(&CFuncTrain::Spawn_) }, - //{ 0x0, "_ZN10CFuncTrain8PrecacheEv", mfunc_ptr_cast(&CFuncTrain::Precache_) }, - //{ 0x0, "_ZN10CFuncTrain7RestartEv", mfunc_ptr_cast(&CFuncTrain::Restart_) }, - //{ 0x0, "_ZN10CFuncTrain8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTrain::KeyValue_) }, - //{ 0x0, "_ZN10CFuncTrain4SaveER5CSave", mfunc_ptr_cast(&CFuncTrain::Save_) }, - //{ 0x0, "_ZN10CFuncTrain7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTrain::Restore_) }, - //{ 0x0, "_ZN10CFuncTrain8ActivateEv", mfunc_ptr_cast(&CFuncTrain::Activate_) }, - //{ 0x0, "_ZN10CFuncTrain13OverrideResetEv", mfunc_ptr_cast(&CFuncTrain::OverrideReset_) }, - //{ 0x0, "_ZN10CFuncTrain3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrain::Use_) }, - //{ 0x0, "_ZN10CFuncTrain7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncTrain::Blocked_) }, + { 0x01D96FD0, "_ZN10CFuncTrain5SpawnEv", mfunc_ptr_cast(&CFuncTrain::Spawn_) }, + { 0x01D971A0, "_ZN10CFuncTrain8PrecacheEv", mfunc_ptr_cast(&CFuncTrain::Precache_) }, + { 0x01D97100, "_ZN10CFuncTrain7RestartEv", mfunc_ptr_cast(&CFuncTrain::Restart_) }, + { 0x01D968E0, "_ZN10CFuncTrain8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTrain::KeyValue_) }, + { 0x01D96840, "_ZN10CFuncTrain4SaveER5CSave", mfunc_ptr_cast(&CFuncTrain::Save_) }, + { 0x01D96890, "_ZN10CFuncTrain7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTrain::Restore_) }, + { 0x01D96EB0, "_ZN10CFuncTrain8ActivateEv", mfunc_ptr_cast(&CFuncTrain::Activate_) }, + { 0x01D971B0, "_ZN10CFuncTrain13OverrideResetEv", mfunc_ptr_cast(&CFuncTrain::OverrideReset_) }, + { 0x01D96970, "_ZN10CFuncTrain3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrain::Use_) }, + { 0x01D96930, "_ZN10CFuncTrain7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncTrain::Blocked_) }, //non-virtual func - //{ 0x0, "_ZN10CFuncTrain4WaitEv", mfunc_ptr_cast(&CFuncTrain::Wait) }, - //{ 0x0, "_ZN10CFuncTrain4NextEv", mfunc_ptr_cast(&CFuncTrain::Next) }, + { 0x01D96A20, "_ZN10CFuncTrain4WaitEv", mfunc_ptr_cast(&CFuncTrain::Wait) }, + { 0x01D96BE0, "_ZN10CFuncTrain4NextEv", mfunc_ptr_cast(&CFuncTrain::Next) }, //CFuncTrackTrain //virtual func - //{ 0x0, "_ZN15CFuncTrackTrain5SpawnEv", mfunc_ptr_cast(&CFuncTrackTrain::Spawn_) }, - //{ 0x0, "_ZN15CFuncTrackTrain8PrecacheEv", mfunc_ptr_cast(&CFuncTrackTrain::Precache_) }, - //{ 0x0, "_ZN15CFuncTrackTrain7RestartEv", mfunc_ptr_cast(&CFuncTrackTrain::Restart_) }, - //{ 0x0, "_ZN15CFuncTrackTrain8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTrackTrain::KeyValue_) }, - //{ 0x0, "_ZN15CFuncTrackTrain4SaveER5CSave", mfunc_ptr_cast(&CFuncTrackTrain::Save_) }, - //{ 0x0, "_ZN15CFuncTrackTrain7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTrackTrain::Restore_) }, - //{ 0x0, "_ZN15CFuncTrackTrain10ObjectCapsEv", mfunc_ptr_cast(&CFuncTrackTrain::ObjectCaps_) }, - //{ 0x0, "_ZN15CFuncTrackTrain13OverrideResetEv", mfunc_ptr_cast(&CFuncTrackTrain::OverrideReset_) }, - //{ 0x0, "_ZN15CFuncTrackTrain10OnControlsEP9entvars_s", mfunc_ptr_cast(&CFuncTrackTrain::OnControls_) }, - //{ 0x0, "_ZN15CFuncTrackTrain3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrackTrain::Use_) }, - //{ 0x0, "_ZN15CFuncTrackTrain7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncTrackTrain::Blocked_) }, + { 0x01D98A10, "_ZN15CFuncTrackTrain5SpawnEv", mfunc_ptr_cast(&CFuncTrackTrain::Spawn_) }, + { 0x01D98CF0, "_ZN15CFuncTrackTrain8PrecacheEv", mfunc_ptr_cast(&CFuncTrackTrain::Precache_) }, + { 0x01D98C00, "_ZN15CFuncTrackTrain7RestartEv", mfunc_ptr_cast(&CFuncTrackTrain::Restart_) }, + { 0x01D97310, "_ZN15CFuncTrackTrain8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTrackTrain::KeyValue_) }, + { 0x01D97260, "_ZN15CFuncTrackTrain4SaveER5CSave", mfunc_ptr_cast(&CFuncTrackTrain::Save_) }, + { 0x01D97290, "_ZN15CFuncTrackTrain7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTrackTrain::Restore_) }, + { 0x01D97630, "_ZN15CFuncTrackTrain10ObjectCapsEv", mfunc_ptr_cast(&CFuncTrackTrain::ObjectCaps_) }, + { 0x01D98980, "_ZN15CFuncTrackTrain13OverrideResetEv", mfunc_ptr_cast(&CFuncTrackTrain::OverrideReset_) }, + { 0x01D98490, "_ZN15CFuncTrackTrain10OnControlsEP9entvars_s", mfunc_ptr_cast(&CFuncTrackTrain::OnControls_) }, + { 0x01D97640, "_ZN15CFuncTrackTrain3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrackTrain::Use_) }, + { 0x01D974B0, "_ZN15CFuncTrackTrain7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncTrackTrain::Blocked_) }, //non-virtual func - //{ 0x0, "_ZN15CFuncTrackTrain4NextEv", mfunc_ptr_cast(&CFuncTrackTrain::Next) }, - //{ 0x0, "_ZN15CFuncTrackTrain4FindEv", mfunc_ptr_cast(&CFuncTrackTrain::Find) }, - //{ 0x0, "_ZN15CFuncTrackTrain11NearestPathEv", mfunc_ptr_cast(&CFuncTrackTrain::NearestPath) }, - //{ 0x0, "_ZN15CFuncTrackTrain7DeadEndEv", mfunc_ptr_cast(&CFuncTrackTrain::DeadEnd) }, - //{ 0x0, "_ZN15CFuncTrackTrain9NextThinkEfi", mfunc_ptr_cast(&CFuncTrackTrain::NextThink) }, + { 0x01D97A40, "_ZN15CFuncTrackTrain4NextEv", mfunc_ptr_cast(&CFuncTrackTrain::Next) }, // TODO: FIX me, pev->angles.y is have difference of values 0.00001 + { 0x01D985C0, "_ZN15CFuncTrackTrain4FindEv", mfunc_ptr_cast(&CFuncTrackTrain::Find) }, + { 0x01D98770, "_ZN15CFuncTrackTrain11NearestPathEv", mfunc_ptr_cast(&CFuncTrackTrain::NearestPath) }, + { 0x01D982B0, "_ZN15CFuncTrackTrain7DeadEndEv", mfunc_ptr_cast(&CFuncTrackTrain::DeadEnd) }, + //{ 0x01D97470, "_ZN15CFuncTrackTrain9NextThinkEfi", mfunc_ptr_cast(&CFuncTrackTrain::NextThink) }, // NOXREF //{ 0x0, "_ZN15CFuncTrackTrain8SetTrackEP10CPathTrack", mfunc_ptr_cast(&CFuncTrackTrain::SetTrack) }, // NOXREF - //{ 0x0, "_ZN15CFuncTrackTrain11SetControlsEP9entvars_s", mfunc_ptr_cast(&CFuncTrackTrain::SetControls) }, - //{ 0x0, "_ZN15CFuncTrackTrain9StopSoundEv", mfunc_ptr_cast(&CFuncTrackTrain::StopSound) }, - //{ 0x0, "_ZN15CFuncTrackTrain11UpdateSoundEv", mfunc_ptr_cast(&CFuncTrackTrain::UpdateSound) }, - //{ 0x0, "_ZN15CFuncTrackTrain8InstanceEP7edict_s", mfunc_ptr_cast(&CFuncTrackTrain::Instance) }, + //{ 0x01D983E0, "_ZN15CFuncTrackTrain11SetControlsEP9entvars_s", mfunc_ptr_cast(&CFuncTrackTrain::SetControls) }, // NOXREF + //{ 0x01D97860, "_ZN15CFuncTrackTrain9StopSoundEv", mfunc_ptr_cast(&CFuncTrackTrain::StopSound) }, // NOXREF + { 0x01D978F0, "_ZN15CFuncTrackTrain11UpdateSoundEv", mfunc_ptr_cast(&CFuncTrackTrain::UpdateSound) }, + //{ 0x01D989C0, "_ZN15CFuncTrackTrain8InstanceEP7edict_s", mfunc_ptr_cast(&CFuncTrackTrain::Instance) }, // NOXREF //CFuncTrainControls //virtual func - //{ 0x0, "_ZN18CFuncTrainControls5SpawnEv", mfunc_ptr_cast(&CFuncTrainControls::Spawn_) }, - //{ 0x0, "_ZN18CFuncTrainControls10ObjectCapsEv", mfunc_ptr_cast(&CFuncTrainControls::ObjectCaps_) }, + { 0x01D98FF0, "_ZN18CFuncTrainControls5SpawnEv", mfunc_ptr_cast(&CFuncTrainControls::Spawn_) }, + { 0x01D98E60, "_ZN18CFuncTrainControls10ObjectCapsEv", mfunc_ptr_cast(&CFuncTrainControls::ObjectCaps_) }, //non-virtual func - //{ 0x0, "_ZN18CFuncTrainControls4FindEv", mfunc_ptr_cast(&CFuncTrainControls::Find) }, + { 0x01D98E70, "_ZN18CFuncTrainControls4FindEv", mfunc_ptr_cast(&CFuncTrainControls::Find) }, //CFuncTrackChange //virtual func - //{ 0x0, "_ZN16CFuncTrackChange5SpawnEv", mfunc_ptr_cast(&CFuncTrackChange::Spawn_) }, - //{ 0x0, "_ZN16CFuncTrackChange8PrecacheEv", mfunc_ptr_cast(&CFuncTrackChange::Precache_) }, - //{ 0x0, "_ZN16CFuncTrackChange8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTrackChange::KeyValue_) }, - //{ 0x0, "_ZN16CFuncTrackChange4SaveER5CSave", mfunc_ptr_cast(&CFuncTrackChange::Save_) }, - //{ 0x0, "_ZN16CFuncTrackChange7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTrackChange::Restore_) }, - //{ 0x0, "_ZN16CFuncTrackChange13OverrideResetEv", mfunc_ptr_cast(&CFuncTrackChange::OverrideReset_) }, - //{ 0x0, "_ZN16CFuncTrackChange5TouchEP11CBaseEntity", mfunc_ptr_cast(&CFuncTrackChange::Touch_) }, - //{ 0x0, "_ZN16CFuncTrackChange3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrackChange::Use_) }, - //{ 0x0, "_ZN16CFuncTrackChange12IsTogglePlatEv", mfunc_ptr_cast(&CFuncTrackChange::IsTogglePlat_) }, - //{ 0x0, "_ZN16CFuncTrackChange4GoUpEv", mfunc_ptr_cast(&CFuncTrackChange::GoUp_) }, - //{ 0x0, "_ZN16CFuncTrackChange6GoDownEv", mfunc_ptr_cast(&CFuncTrackChange::GoDown_) }, - //{ 0x0, "_ZN16CFuncTrackChange9HitBottomEv", mfunc_ptr_cast(&CFuncTrackChange::HitBottom_) }, - //{ 0x0, "_ZN16CFuncTrackChange6HitTopEv", mfunc_ptr_cast(&CFuncTrackChange::HitTop_) }, - //{ 0x0, "_ZN16CFuncTrackChange17UpdateAutoTargetsEi", mfunc_ptr_cast(&CFuncTrackChange::UpdateAutoTargets_) }, + { 0x01D991C0, "_ZN16CFuncTrackChange5SpawnEv", mfunc_ptr_cast(&CFuncTrackChange::Spawn_) }, + { 0x01D99390, "_ZN16CFuncTrackChange8PrecacheEv", mfunc_ptr_cast(&CFuncTrackChange::Precache_) }, + { 0x01D99480, "_ZN16CFuncTrackChange8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTrackChange::KeyValue_) }, + { 0x01D990E0, "_ZN16CFuncTrackChange4SaveER5CSave", mfunc_ptr_cast(&CFuncTrackChange::Save_) }, + { 0x01D99150, "_ZN16CFuncTrackChange7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTrackChange::Restore_) }, + { 0x01D99540, "_ZN16CFuncTrackChange13OverrideResetEv", mfunc_ptr_cast(&CFuncTrackChange::OverrideReset_) }, + { 0x01D99470, "_ZN16CFuncTrackChange5TouchEP11CBaseEntity", mfunc_ptr_cast(&CFuncTrackChange::Touch_) }, // PURE + { 0x01D99EB0, "_ZN16CFuncTrackChange3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrackChange::Use_) }, + { 0x01D990D0, "_ZN16CFuncTrackChange12IsTogglePlatEv", mfunc_ptr_cast(&CFuncTrackChange::IsTogglePlat_) }, + { 0x01D99C90, "_ZN16CFuncTrackChange4GoUpEv", mfunc_ptr_cast(&CFuncTrackChange::GoUp_) }, + { 0x01D99AE0, "_ZN16CFuncTrackChange6GoDownEv", mfunc_ptr_cast(&CFuncTrackChange::GoDown_) }, + { 0x01D99F60, "_ZN16CFuncTrackChange9HitBottomEv", mfunc_ptr_cast(&CFuncTrackChange::HitBottom_) }, + { 0x01D9A090, "_ZN16CFuncTrackChange6HitTopEv", mfunc_ptr_cast(&CFuncTrackChange::HitTop_) }, + { 0x01D99E40, "_ZN16CFuncTrackChange17UpdateAutoTargetsEi", mfunc_ptr_cast(&CFuncTrackChange::UpdateAutoTargets_) }, //non-virtual func - //{ 0x0, "_ZN16CFuncTrackChange4FindEv", mfunc_ptr_cast(&CFuncTrackChange::Find) }, - //{ 0x0, "_ZN16CFuncTrackChange13EvaluateTrainEP10CPathTrack", mfunc_ptr_cast(&CFuncTrackChange::EvaluateTrain) }, - //{ 0x0, "_ZN16CFuncTrackChange11UpdateTrainER6Vector", mfunc_ptr_cast(&CFuncTrackChange::UpdateTrain) }, - //{ 0x0, "_ZN16CFuncTrackChange10DisableUseEv", mfunc_ptr_cast(&CFuncTrackChange::DisableUse) }, // NOXREF - //{ 0x0, "_ZN16CFuncTrackChange9EnableUseEv", mfunc_ptr_cast(&CFuncTrackChange::EnableUse) }, // NOXREF - //{ 0x0, "_ZN16CFuncTrackChange10UseEnabledEv", mfunc_ptr_cast(&CFuncTrackChange::UseEnabled) }, // NOXREF + { 0x01D99560, "_ZN16CFuncTrackChange4FindEv", mfunc_ptr_cast(&CFuncTrackChange::Find) }, + { 0x01D99840, "_ZN16CFuncTrackChange13EvaluateTrainEP10CPathTrack", mfunc_ptr_cast(&CFuncTrackChange::EvaluateTrain) }, + { 0x01D99910, "_ZN16CFuncTrackChange11UpdateTrainER6Vector", mfunc_ptr_cast(&CFuncTrackChange::UpdateTrain) }, + //{ 0x0, "_ZN16CFuncTrackChange10DisableUseEv", mfunc_ptr_cast(&CFuncTrackChange::DisableUse) }, // NOXREF + //{ 0x0, "_ZN16CFuncTrackChange9EnableUseEv", mfunc_ptr_cast(&CFuncTrackChange::EnableUse) }, // NOXREF + //{ 0x0, "_ZN16CFuncTrackChange10UseEnabledEv", mfunc_ptr_cast(&CFuncTrackChange::UseEnabled) }, // NOXREF //CFuncTrackAuto //virtual func - //{ 0x0, "_ZN14CFuncTrackAuto3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrackAuto::Use_) }, - //{ 0x0, "_ZN14CFuncTrackAuto17UpdateAutoTargetsEi", mfunc_ptr_cast(&CFuncTrackAuto::UpdateAutoTargets_) }, + { 0x01D9A270, "_ZN14CFuncTrackAuto3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTrackAuto::Use_) }, + { 0x01D9A1B0, "_ZN14CFuncTrackAuto17UpdateAutoTargetsEi", mfunc_ptr_cast(&CFuncTrackAuto::UpdateAutoTargets_) }, //CGunTarget //virtual func - //{ 0x0, "_ZN10CGunTarget5SpawnEv", mfunc_ptr_cast(&CGunTarget::Spawn_) }, - //{ 0x0, "_ZN10CGunTarget4SaveER5CSave", mfunc_ptr_cast(&CGunTarget::Save_) }, - //{ 0x0, "_ZN10CGunTarget7RestoreER8CRestore", mfunc_ptr_cast(&CGunTarget::Restore_) }, - //{ 0x0, "_ZN10CGunTarget10ObjectCapsEv", mfunc_ptr_cast(&CGunTarget::ObjectCaps_) }, - //{ 0x0, "_ZN10CGunTarget8ActivateEv", mfunc_ptr_cast(&CGunTarget::Activate_) }, - //{ 0x0, "_ZN10CGunTarget8ClassifyEv", mfunc_ptr_cast(&CGunTarget::Classify_) }, - //{ 0x0, "_ZN10CGunTarget10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CGunTarget::TakeDamage_) }, - //{ 0x0, "_ZN10CGunTarget10BloodColorEv", mfunc_ptr_cast(&CGunTarget::BloodColor_) }, - //{ 0x0, "_ZN10CGunTarget3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGunTarget::Use_) }, - //{ 0x0, "_ZN10CGunTarget10BodyTargetERK6Vector", mfunc_ptr_cast(&CGunTarget::BodyTarget_) }, + { 0x01D9A480, "_ZN10CGunTarget5SpawnEv", mfunc_ptr_cast(&CGunTarget::Spawn_) }, + { 0x01D9A420, "_ZN10CGunTarget4SaveER5CSave", mfunc_ptr_cast(&CGunTarget::Save_) }, + { 0x01D9A450, "_ZN10CGunTarget7RestoreER8CRestore", mfunc_ptr_cast(&CGunTarget::Restore_) }, + { 0x01D9A410, "_ZN10CGunTarget10ObjectCapsEv", mfunc_ptr_cast(&CGunTarget::ObjectCaps_) }, + { 0x01D9A550, "_ZN10CGunTarget8ActivateEv", mfunc_ptr_cast(&CGunTarget::Activate_) }, + { 0x01D9A3E0, "_ZN10CGunTarget8ClassifyEv", mfunc_ptr_cast(&CGunTarget::Classify_) }, + { 0x01D9A8D0, "_ZN10CGunTarget10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CGunTarget::TakeDamage_) }, + { 0x01D9A3D0, "_ZN10CGunTarget10BloodColorEv", mfunc_ptr_cast(&CGunTarget::BloodColor_) }, + { 0x01D9A990, "_ZN10CGunTarget3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGunTarget::Use_) }, + { 0x01D9A3F0, "_ZN10CGunTarget10BodyTargetERK6Vector", mfunc_ptr_cast(&CGunTarget::BodyTarget_) }, //non-virtual func - //{ 0x0, "_ZN10CGunTarget4NextEv", mfunc_ptr_cast(&CGunTarget::Next) }, - //{ 0x0, "_ZN10CGunTarget5StartEv", mfunc_ptr_cast(&CGunTarget::Start) }, - //{ 0x0, "_ZN10CGunTarget4WaitEv", mfunc_ptr_cast(&CGunTarget::Wait) }, - //{ 0x0, "_ZN10CGunTarget4StopEv", mfunc_ptr_cast(&CGunTarget::Stop) }, + { 0x01D9A610, "_ZN10CGunTarget4NextEv", mfunc_ptr_cast(&CGunTarget::Next) }, + { 0x01D9A600, "_ZN10CGunTarget5StartEv", mfunc_ptr_cast(&CGunTarget::Start) }, + { 0x01D9A6E0, "_ZN10CGunTarget4WaitEv", mfunc_ptr_cast(&CGunTarget::Wait) }, + //{ 0x01D9A890, "_ZN10CGunTarget4StopEv", mfunc_ptr_cast(&CGunTarget::Stop) }, // NOXREF //CPlane //{ 0x01D952F0, "_ZN6CPlaneC2Ev", mfunc_ptr_cast(&CPlane::CPlane) }, // NOXREF //{ 0x01D95300, "_ZN6CPlane15InitializePlaneERK6VectorS2_", mfunc_ptr_cast(&CPlane::InitializePlane) }, // NOXREF //{ 0x01D95340, "_ZN6CPlane12PointInFrontERK6Vector", mfunc_ptr_cast(&CPlane::PointInFront) }, // NOXREF +//linked objects + { 0x01D95840, "func_plat", (size_t)&func_plat }, + { 0x01D96070, "func_platrot", (size_t)&func_platrot }, + { 0x01D967F0, "func_train", (size_t)&func_train }, + { 0x01D972C0, "func_tracktrain", (size_t)&func_tracktrain }, + { 0x01D98E10, "func_traincontrols", (size_t)&func_traincontrols }, + { 0x01D99070, "func_trackchange", (size_t)&func_trackchange }, + { 0x01D9A150, "func_trackautochange", (size_t)&func_trackautochange }, + { 0x01D9A380, "func_guntarget", (size_t)&func_guntarget }, #endif // Plats_Region @@ -1258,29 +1276,33 @@ FunctionHook g_FunctionHooks[] = //CPathTrack //virtual func - //{ 0x0, "_ZN10CPathTrack5SpawnEv", mfunc_ptr_cast(&CPathTrack::Spawn_) }, - //{ 0x0, "_ZN10CPathTrack8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPathTrack::KeyValue_) }, - //{ 0x0, "_ZN10CPathTrack4SaveER5CSave", mfunc_ptr_cast(&CPathTrack::Save_) }, - //{ 0x0, "_ZN10CPathTrack7RestoreER8CRestore", mfunc_ptr_cast(&CPathTrack::Restore_) }, - //{ 0x0, "_ZN10CPathTrack8ActivateEv", mfunc_ptr_cast(&CPathTrack::Activate_) }, - //{ 0x0, "_ZN10CPathTrack3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CPathTrack::Use_) }, + { 0x01D94980, "_ZN10CPathTrack5SpawnEv", mfunc_ptr_cast(&CPathTrack::Spawn_) }, + { 0x01D946A0, "_ZN10CPathTrack8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPathTrack::KeyValue_) }, + { 0x01D945F0, "_ZN10CPathTrack4SaveER5CSave", mfunc_ptr_cast(&CPathTrack::Save_) }, + { 0x01D94620, "_ZN10CPathTrack7RestoreER8CRestore", mfunc_ptr_cast(&CPathTrack::Restore_) }, + { 0x01D949F0, "_ZN10CPathTrack8ActivateEv", mfunc_ptr_cast(&CPathTrack::Activate_) }, + { 0x01D946F0, "_ZN10CPathTrack3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CPathTrack::Use_) }, //non-virtual func //{ 0x01D94B90, "_ZN10CPathTrack11SetPreviousEPS_", mfunc_ptr_cast(&CPathTrack::SetPrevious) }, // NOXREF - //{ 0x0, "_ZN10CPathTrack4LinkEv", mfunc_ptr_cast(&CPathTrack::Link) }, - //{ 0x01D94A10, "_ZN10CPathTrack9ValidPathEPS_i", mfunc_ptr_cast(&CPathTrack::ValidPath) }, + { 0x01D94790, "_ZN10CPathTrack4LinkEv", mfunc_ptr_cast(&CPathTrack::Link) }, + { 0x01D94A10, "_ZN10CPathTrack9ValidPathEPS_i", mfunc_ptr_cast(&CPathTrack::ValidPath) }, //{ 0x01D94A40, "_ZN10CPathTrack7ProjectEPS_S0_P6Vectorf", mfunc_ptr_cast(&CPathTrack::Project) }, // NOXREF - //{ 0x0, "_ZN10CPathTrack8InstanceEP7edict_s", mfunc_ptr_cast(&CPathTrack::Instance) }, - //{ 0x0, "_ZN10CPathTrack9LookAheadEP6Vectorfi", mfunc_ptr_cast(&CPathTrack::LookAhead) }, - //{ 0x0, "_ZN10CPathTrack7NearestE6Vector", mfunc_ptr_cast(&CPathTrack::Nearest) }, - //{ 0x0, "_ZN10CPathTrack7GetNextEv", mfunc_ptr_cast(&CPathTrack::GetNext) }, - //{ 0x0, "_ZN10CPathTrack11GetPreviousEv", mfunc_ptr_cast(&CPathTrack::GetPrevious) }, + { 0x01D952A0, "_ZN10CPathTrack8InstanceEP7edict_s", mfunc_ptr_cast(&CPathTrack::Instance) }, + { 0x01D94C00, "_ZN10CPathTrack9LookAheadEP6Vectorfi", mfunc_ptr_cast(&CPathTrack::LookAhead) }, + { 0x01D951A0, "_ZN10CPathTrack7NearestE6Vector", mfunc_ptr_cast(&CPathTrack::Nearest) }, + { 0x01D94B30, "_ZN10CPathTrack7GetNextEv", mfunc_ptr_cast(&CPathTrack::GetNext) }, + { 0x01D94B60, "_ZN10CPathTrack11GetPreviousEv", mfunc_ptr_cast(&CPathTrack::GetPrevious) }, + //linked objects + { 0x01D94650, "path_track", (size_t)&path_track }, //CPathCorner //virtual func - //{ 0x0, "_ZN11CPathCorner5SpawnEv", mfunc_ptr_cast(&CPathCorner::Spawn_) }, - //{ 0x0, "_ZN11CPathCorner8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPathCorner::KeyValue_) }, - //{ 0x0, "_ZN11CPathCorner4SaveER5CSave", mfunc_ptr_cast(&CPathCorner::Save_) }, - //{ 0x0, "_ZN11CPathCorner7RestoreER8CRestore", mfunc_ptr_cast(&CPathCorner::Restore_) }, - //{ 0x0, "_ZN11CPathCorner8GetDelayEv", mfunc_ptr_cast(&CPathCorner::GetDelay_) }, + { 0x01D945E0, "_ZN11CPathCorner5SpawnEv", mfunc_ptr_cast(&CPathCorner::Spawn_) }, // PURE + { 0x01D94590, "_ZN11CPathCorner8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPathCorner::KeyValue_) }, + { 0x01D94530, "_ZN11CPathCorner4SaveER5CSave", mfunc_ptr_cast(&CPathCorner::Save_) }, + { 0x01D94560, "_ZN11CPathCorner7RestoreER8CRestore", mfunc_ptr_cast(&CPathCorner::Restore_) }, + { 0x01D94520, "_ZN11CPathCorner8GetDelayEv", mfunc_ptr_cast(&CPathCorner::GetDelay_) }, + //linked objects + { 0x01D944D0, "path_corner", (size_t)&path_corner }, #endif // PathCorner_Region @@ -1288,39 +1310,48 @@ FunctionHook g_FunctionHooks[] = //CFuncVehicle //virtual func - //{ 0x0, "_ZN12CFuncVehicle5SpawnEv", mfunc_ptr_cast(&CFuncVehicle::Spawn_) }, + { 0x01DCBFC0, "_ZN12CFuncVehicle5SpawnEv", mfunc_ptr_cast(&CFuncVehicle::Spawn_) }, { 0x01DCC310, "_ZN12CFuncVehicle8PrecacheEv", mfunc_ptr_cast(&CFuncVehicle::Precache_) }, - //{ 0x0, "_ZN12CFuncVehicle7RestartEv", mfunc_ptr_cast(&CFuncVehicle::Restart_) }, - //{ 0x0, "_ZN12CFuncVehicle8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncVehicle::KeyValue_) }, - //{ 0x0, "_ZN12CFuncVehicle4SaveER5CSave", mfunc_ptr_cast(&CFuncVehicle::Save_) }, - //{ 0x0, "_ZN12CFuncVehicle7RestoreER8CRestore", mfunc_ptr_cast(&CFuncVehicle::Restore_) }, - //{ 0x0, "_ZN12CFuncVehicle10ObjectCapsEv", mfunc_ptr_cast(&CFuncVehicle::ObjectCaps_) }, + { 0x01DCC1D0, "_ZN12CFuncVehicle7RestartEv", mfunc_ptr_cast(&CFuncVehicle::Restart_) }, + { 0x01DC9370, "_ZN12CFuncVehicle8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncVehicle::KeyValue_) }, + { 0x01DC92C0, "_ZN12CFuncVehicle4SaveER5CSave", mfunc_ptr_cast(&CFuncVehicle::Save_) }, + { 0x01DC92F0, "_ZN12CFuncVehicle7RestoreER8CRestore", mfunc_ptr_cast(&CFuncVehicle::Restore_) }, + { 0x01DCB970, "_ZN12CFuncVehicle10ObjectCapsEv", mfunc_ptr_cast(&CFuncVehicle::ObjectCaps_) }, { 0x01DCBFB0, "_ZN12CFuncVehicle8ClassifyEv", mfunc_ptr_cast(&CFuncVehicle::Classify_) }, - //{ 0x0, "_ZN12CFuncVehicle13OverrideResetEv", mfunc_ptr_cast(&CFuncVehicle::OverrideReset_) }, + { 0x01DCBF20, "_ZN12CFuncVehicle13OverrideResetEv", mfunc_ptr_cast(&CFuncVehicle::OverrideReset_) }, { 0x01DCBA30, "_ZN12CFuncVehicle10OnControlsEP9entvars_s", mfunc_ptr_cast(&CFuncVehicle::OnControls_) }, - //{ 0x0, "_ZN12CFuncVehicle3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncVehicle::Use_) }, - //{ 0x0, "_ZN12CFuncVehicle7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncVehicle::Blocked_) }, + { 0x01DC9A10, "_ZN12CFuncVehicle3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncVehicle::Use_) }, + { 0x01DC9590, "_ZN12CFuncVehicle7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncVehicle::Blocked_) }, //non-virtual func - //{ 0x0, "_ZN12CFuncVehicle4NextEv", mfunc_ptr_cast(&CFuncVehicle::Next) }, - //{ 0x0, "_ZN12CFuncVehicle4FindEv", mfunc_ptr_cast(&CFuncVehicle::Find) }, - //{ 0x0, "_ZN12CFuncVehicle11NearestPathEv", mfunc_ptr_cast(&CFuncVehicle::NearestPath) }, - //{ 0x0, "_ZN12CFuncVehicle7DeadEndEv", mfunc_ptr_cast(&CFuncVehicle::DeadEnd) }, - //{ 0x0, "_ZN12CFuncVehicle9NextThinkEfi", mfunc_ptr_cast(&CFuncVehicle::NextThink) }, - //{ 0x0, "_ZN12CFuncVehicle18CollisionDetectionEv", mfunc_ptr_cast(&CFuncVehicle::CollisionDetection) }, - //{ 0x0, "_ZN12CFuncVehicle16TerrainFollowingEv", mfunc_ptr_cast(&CFuncVehicle::TerrainFollowing) }, - //{ 0x0, "_ZN12CFuncVehicle12CheckTurningEv", mfunc_ptr_cast(&CFuncVehicle::CheckTurning) }, + { 0x01DCAD10, "_ZN12CFuncVehicle4NextEv", mfunc_ptr_cast(&CFuncVehicle::Next) }, + { 0x01DCBB60, "_ZN12CFuncVehicle4FindEv", mfunc_ptr_cast(&CFuncVehicle::Find) }, + { 0x01DCBD10, "_ZN12CFuncVehicle11NearestPathEv", mfunc_ptr_cast(&CFuncVehicle::NearestPath) }, + { 0x01DCB840, "_ZN12CFuncVehicle7DeadEndEv", mfunc_ptr_cast(&CFuncVehicle::DeadEnd) }, + { 0x01DC9550, "_ZN12CFuncVehicle9NextThinkEfi", mfunc_ptr_cast(&CFuncVehicle::NextThink) }, + { 0x01DCA6D0, "_ZN12CFuncVehicle18CollisionDetectionEv", mfunc_ptr_cast(&CFuncVehicle::CollisionDetection) }, + //{ 0x01DCAC50, "_ZN12CFuncVehicle16TerrainFollowingEv", mfunc_ptr_cast(&CFuncVehicle::TerrainFollowing) }, // NOXREF + { 0x01DCA2F0, "_ZN12CFuncVehicle12CheckTurningEv", mfunc_ptr_cast(&CFuncVehicle::CheckTurning) }, //{ 0x0, "_ZN12CFuncVehicle8SetTrackEP10CPathTrack", mfunc_ptr_cast(&CFuncVehicle::SetTrack) }, // NOXREF //{ 0x01DCB980, "_ZN12CFuncVehicle11SetControlsEP9entvars_s", mfunc_ptr_cast(&CFuncVehicle::SetControls) }, // NOXREF - //{ 0x0, "_ZN12CFuncVehicle9StopSoundEv", mfunc_ptr_cast(&CFuncVehicle::StopSound) }, - //{ 0x0, "_ZN12CFuncVehicle11UpdateSoundEv", mfunc_ptr_cast(&CFuncVehicle::UpdateSound) }, + //{ 0x01DCA110, "_ZN12CFuncVehicle9StopSoundEv", mfunc_ptr_cast(&CFuncVehicle::StopSound) }, // NOXREF + { 0x01DCA180, "_ZN12CFuncVehicle11UpdateSoundEv", mfunc_ptr_cast(&CFuncVehicle::UpdateSound) }, //{ 0x01DCBF60, "_ZN12CFuncVehicle8InstanceEP7edict_s", mfunc_ptr_cast(&CFuncVehicle::Instance) }, // NOXREF //{ 0x0, "", (size_t)&FixupAngles2 }, // NOXREF + +#ifdef _WIN32 + { 0x01DCB7B0, "", (size_t)&Fix2 }, +#endif // _WIN32 + + //linked objects + { 0x01DC9320, "func_vehicle", (size_t)&func_vehicle }, //CFuncVehicleControls //virtual func - //{ 0x0, "_ZN20CFuncVehicleControls5SpawnEv", mfunc_ptr_cast(&CFuncVehicleControls::Spawn) }, - //{ 0x0, "_ZN20CFuncVehicleControls10ObjectCapsEv", mfunc_ptr_cast(&CFuncVehicleControls::ObjectCaps) }, + { 0x01DCC5F0, "_ZN20CFuncVehicleControls5SpawnEv", mfunc_ptr_cast(&CFuncVehicleControls::Spawn_) }, + { 0x01DCC460, "_ZN20CFuncVehicleControls10ObjectCapsEv", mfunc_ptr_cast(&CFuncVehicleControls::ObjectCaps_) }, //non-virtual func - //{ 0x0, "_ZN20CFuncVehicleControls4FindEv", mfunc_ptr_cast(&CFuncVehicleControls::Find) }, + { 0x01DCC470, "_ZN20CFuncVehicleControls4FindEv", mfunc_ptr_cast(&CFuncVehicleControls::Find) }, + //linked objects + { 0x01DCC410, "func_vehiclecontrols", (size_t)&func_vehiclecontrols }, #endif // Vehicle_Region @@ -1328,62 +1359,68 @@ FunctionHook g_FunctionHooks[] = //CFuncTank //virtual func - //{ 0x0, "_ZN9CFuncTank5SpawnEv", mfunc_ptr_cast(&CFuncTank::Spawn_) }, - //{ 0x0, "_ZN9CFuncTank8PrecacheEv", mfunc_ptr_cast(&CFuncTank::Precache_) }, - //{ 0x0, "_ZN9CFuncTank8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTank::KeyValue_) }, - //{ 0x0, "_ZN9CFuncTank4SaveER5CSave", mfunc_ptr_cast(&CFuncTank::Save_) }, - //{ 0x0, "_ZN9CFuncTank7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTank::Restore_) }, - //{ 0x0, "_ZN9CFuncTank10ObjectCapsEv", mfunc_ptr_cast(&CFuncTank::ObjectCaps_) }, - //{ 0x0, "_ZN9CFuncTank10OnControlsEP9entvars_s", mfunc_ptr_cast(&CFuncTank::OnControls_) }, - //{ 0x0, "_ZN9CFuncTank5ThinkEv", mfunc_ptr_cast(&CFuncTank::Think_) }, - //{ 0x0, "_ZN9CFuncTank3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTank::Use_) }, - //{ 0x0, "_ZN9CFuncTank4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTank::Fire_) }, - //{ 0x0, "_ZN9CFuncTank20UpdateTargetPositionEP11CBaseEntity", mfunc_ptr_cast(&CFuncTank::UpdateTargetPosition_) }, + { 0x01D7DFB0, "_ZN9CFuncTank5SpawnEv", mfunc_ptr_cast(&CFuncTank::Spawn_) }, + { 0x01D7E170, "_ZN9CFuncTank8PrecacheEv", mfunc_ptr_cast(&CFuncTank::Precache_) }, + { 0x01D7E1E0, "_ZN9CFuncTank8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTank::KeyValue_) }, + { 0x01D7DEB0, "_ZN9CFuncTank4SaveER5CSave", mfunc_ptr_cast(&CFuncTank::Save_) }, + { 0x01D7DEE0, "_ZN9CFuncTank7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTank::Restore_) }, + { 0x01D7FA70, "_ZN9CFuncTank10ObjectCapsEv", mfunc_ptr_cast(&CFuncTank::ObjectCaps_) }, + //{ 0x01D7E620, "_ZN9CFuncTank10OnControlsEP9entvars_s", mfunc_ptr_cast(&CFuncTank::OnControls_) }, // DEFAULT + { 0x01D7EBD0, "_ZN9CFuncTank5ThinkEv", mfunc_ptr_cast(&CFuncTank::Think_) }, + { 0x01D7E9A0, "_ZN9CFuncTank3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTank::Use_) }, + { 0x01D7F560, "_ZN9CFuncTank4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTank::Fire_) }, + //{ 0x01D7FA40, "_ZN9CFuncTank20UpdateTargetPositionEP11CBaseEntity", mfunc_ptr_cast(&CFuncTank::UpdateTargetPosition_) }, // DEFAULT //non-virtual func - //{ 0x0, "_ZN9CFuncTank11TrackTargetEv", mfunc_ptr_cast(&CFuncTank::TrackTarget) }, - //{ 0x0, "_ZN9CFuncTank13StartRotSoundEv", mfunc_ptr_cast(&CFuncTank::StartRotSound) }, - //{ 0x0, "_ZN9CFuncTank12StopRotSoundEv", mfunc_ptr_cast(&CFuncTank::StopRotSound) }, + { 0x01D7ECD0, "_ZN9CFuncTank11TrackTargetEv", mfunc_ptr_cast(&CFuncTank::TrackTarget) }, + { 0x01D7F930, "_ZN9CFuncTank13StartRotSoundEv", mfunc_ptr_cast(&CFuncTank::StartRotSound) }, + //{ 0x01D7F990, "_ZN9CFuncTank12StopRotSoundEv", mfunc_ptr_cast(&CFuncTank::StopRotSound) }, // NOXREF //{ 0x0, "_ZN9CFuncTank8IsActiveEv", mfunc_ptr_cast(&CFuncTank::IsActive) }, // NOXREF //{ 0x0, "_ZN9CFuncTank12TankActivateEv", mfunc_ptr_cast(&CFuncTank::TankActivate) }, // NOXREF //{ 0x0, "_ZN9CFuncTank14TankDeactivateEv", mfunc_ptr_cast(&CFuncTank::TankDeactivate) }, // NOXREF //{ 0x0, "_ZN9CFuncTank7CanFireEv", mfunc_ptr_cast(&CFuncTank::CanFire) }, // NOXREF - //{ 0x0, "_ZN9CFuncTank7InRangeEf", mfunc_ptr_cast(&CFuncTank::InRange) }, - //{ 0x0, "_ZN9CFuncTank10FindTargetEP7edict_s", mfunc_ptr_cast(&CFuncTank::FindTarget) }, - //{ 0x0, "_ZN9CFuncTank9TankTraceERK6VectorS2_S2_R11TraceResult", mfunc_ptr_cast(&CFuncTank::TankTrace) }, - //{ 0x0, "_ZN9CFuncTank14BarrelPositionEv", mfunc_ptr_cast(&CFuncTank::BarrelPosition) }, - //{ 0x0, "_ZN9CFuncTank21AdjustAnglesForBarrelER6Vectorf", mfunc_ptr_cast(&CFuncTank::AdjustAnglesForBarrel) }, - //{ 0x0, "_ZN9CFuncTank12StartControlEP11CBasePlayer", mfunc_ptr_cast(&CFuncTank::StartControl) }, - //{ 0x0, "_ZN9CFuncTank11StopControlEv", mfunc_ptr_cast(&CFuncTank::StopControl) }, - //{ 0x0, "_ZN9CFuncTank19ControllerPostFrameEv", mfunc_ptr_cast(&CFuncTank::ControllerPostFrame) }, + //{ 0x01D7EB80, "_ZN9CFuncTank7InRangeEf", mfunc_ptr_cast(&CFuncTank::InRange) }, // NOXREF + //{ 0x01D7EB70, "_ZN9CFuncTank10FindTargetEP7edict_s", mfunc_ptr_cast(&CFuncTank::FindTarget) }, // NOXREF + //{ 0x01D7F7B0, "_ZN9CFuncTank9TankTraceERK6VectorS2_S2_R11TraceResult", mfunc_ptr_cast(&CFuncTank::TankTrace) }, // NOXREF + //{ 0x0, "_ZN9CFuncTank14BarrelPositionEv", mfunc_ptr_cast(&CFuncTank::BarrelPosition) }, // NOXREF + { 0x01D7F4B0, "_ZN9CFuncTank21AdjustAnglesForBarrelER6Vectorf", mfunc_ptr_cast(&CFuncTank::AdjustAnglesForBarrel) }, + { 0x01D7E680, "_ZN9CFuncTank12StartControlEP11CBasePlayer", mfunc_ptr_cast(&CFuncTank::StartControl) }, + //{ 0x01D7E750, "_ZN9CFuncTank11StopControlEv", mfunc_ptr_cast(&CFuncTank::StopControl) }, // NOXREF + { 0x01D7E7F0, "_ZN9CFuncTank19ControllerPostFrameEv", mfunc_ptr_cast(&CFuncTank::ControllerPostFrame) }, //CFuncTankGun //virtual func - //{ 0x0, "_ZN12CFuncTankGun4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankGun::Spawn_) }, + { 0x01D7FA80, "_ZN12CFuncTankGun4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankGun::Fire_) }, //CFuncTankLaser //virtual func - //{ 0x0, "_ZN14CFuncTankLaser8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTankLaser::KeyValue_) }, - //{ 0x0, "_ZN14CFuncTankLaser4SaveER5CSave", mfunc_ptr_cast(&CFuncTankLaser::Save_) }, - //{ 0x0, "_ZN14CFuncTankLaser7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTankLaser::Restore_) }, - //{ 0x0, "_ZN14CFuncTankLaser8ActivateEv", mfunc_ptr_cast(&CFuncTankLaser::Activate_) }, - //{ 0x0, "_ZN14CFuncTankLaser5ThinkEv", mfunc_ptr_cast(&CFuncTankLaser::Think_) }, - //{ 0x0, "_ZN14CFuncTankLaser4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankLaser::Fire_) }, + { 0x01D7FD50, "_ZN14CFuncTankLaser8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTankLaser::KeyValue_) }, + { 0x01D7FBF0, "_ZN14CFuncTankLaser4SaveER5CSave", mfunc_ptr_cast(&CFuncTankLaser::Save_) }, + { 0x01D7FC40, "_ZN14CFuncTankLaser7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTankLaser::Restore_) }, + { 0x01D7FC90, "_ZN14CFuncTankLaser8ActivateEv", mfunc_ptr_cast(&CFuncTankLaser::Activate_) }, + { 0x01D7FE40, "_ZN14CFuncTankLaser5ThinkEv", mfunc_ptr_cast(&CFuncTankLaser::Think_) }, + { 0x01D7FF60, "_ZN14CFuncTankLaser4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankLaser::Fire_) }, //non-virtual func - //{ 0x0, "_ZN14CFuncTankLaser8GetLaserEv", mfunc_ptr_cast(&CFuncTankLaser::GetLaser) }, + //{ 0x01D7FDA0, "_ZN14CFuncTankLaser8GetLaserEv", mfunc_ptr_cast(&CFuncTankLaser::GetLaser) }, // NOXREF //CFuncTankRocket //virtual func - //{ 0x0, "_ZN15CFuncTankRocket8PrecacheEv", mfunc_ptr_cast(&CFuncTankRocket::Precache_) }, - //{ 0x0, "_ZN15CFuncTankRocket4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankRocket::Fire_) }, + { 0x01D80180, "_ZN15CFuncTankRocket8PrecacheEv", mfunc_ptr_cast(&CFuncTankRocket::Precache_) }, + { 0x01D80200, "_ZN15CFuncTankRocket4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankRocket::Fire_) }, //CFuncTankMortar //virtual func - //{ 0x0, "_ZN15CFuncTankMortar8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTankRocket::KeyValue_) }, - //{ 0x0, "_ZN15CFuncTankMortar4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankRocket::Fire_) }, + { 0x01D802E0, "_ZN15CFuncTankMortar8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncTankMortar::KeyValue_) }, + { 0x01D80330, "_ZN15CFuncTankMortar4FireERK6VectorS2_P9entvars_s", mfunc_ptr_cast(&CFuncTankMortar::Fire_) }, //CFuncTankControls //virtual func - //{ 0x0, "_ZN17CFuncTankControls5SpawnEv", mfunc_ptr_cast(&BaseClass::Spawn_) }, - //{ 0x0, "_ZN17CFuncTankControls4SaveER5CSave", mfunc_ptr_cast(&BaseClass::Save_) }, - //{ 0x0, "_ZN17CFuncTankControls7RestoreER8CRestore", mfunc_ptr_cast(&BaseClass::Restore_) }, - //{ 0x0, "_ZN17CFuncTankControls10ObjectCapsEv", mfunc_ptr_cast(&BaseClass::ObjectCaps_) }, - //{ 0x0, "_ZN17CFuncTankControls5ThinkEv", mfunc_ptr_cast(&BaseClass::Think_) }, - //{ 0x0, "_ZN17CFuncTankControls3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&BaseClass::Use_) }, + { 0x01D80590, "_ZN17CFuncTankControls5SpawnEv", mfunc_ptr_cast(&CFuncTankControls::Spawn_) }, + { 0x01D80450, "_ZN17CFuncTankControls4SaveER5CSave", mfunc_ptr_cast(&CFuncTankControls::Save_) }, + { 0x01D80480, "_ZN17CFuncTankControls7RestoreER8CRestore", mfunc_ptr_cast(&CFuncTankControls::Restore_) }, + { 0x01D804B0, "_ZN17CFuncTankControls10ObjectCapsEv", mfunc_ptr_cast(&CFuncTankControls::ObjectCaps_) }, + { 0x01D804E0, "_ZN17CFuncTankControls5ThinkEv", mfunc_ptr_cast(&CFuncTankControls::Think_) }, + { 0x01D804C0, "_ZN17CFuncTankControls3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncTankControls::Use_) }, +//linked objects + { 0x01D7F9F0, "func_tank", (size_t)&func_tank }, + { 0x01D7FBA0, "func_tanklaser", (size_t)&func_tanklaser }, + { 0x01D80130, "func_tankrocket", (size_t)&func_tankrocket }, + { 0x01D80290, "func_tankmortar", (size_t)&func_tankmortar }, + { 0x01D80400, "func_tankcontrols", (size_t)&func_tankcontrols }, #endif // Func_Tank_Region @@ -1391,23 +1428,23 @@ FunctionHook g_FunctionHooks[] = //CBreakable //virtual func - //{ 0x0, "_ZN10CBreakable5SpawnEv", mfunc_ptr_cast(&CBreakable::Spawn_) }, - //{ 0x0, "_ZN10CBreakable8PrecacheEv", mfunc_ptr_cast(&CBreakable::Precache_) }, - //{ 0x0, "_ZN10CBreakable7RestartEv", mfunc_ptr_cast(&CBreakable::Restart_) }, - //{ 0x0, "_ZN10CBreakable8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBreakable::KeyValue_) }, - //{ 0x0, "_ZN10CBreakable4SaveER5CSave", mfunc_ptr_cast(&CBreakable::Save_) }, - //{ 0x0, "_ZN10CBreakable7RestoreER8CRestore", mfunc_ptr_cast(&CBreakable::Restore_) }, - //{ 0x0, "_ZN10CBreakable10ObjectCapsEv", mfunc_ptr_cast(&CBreakable::ObjectCaps_) }, - //{ 0x0, "_ZN10CBreakable11TraceAttackEP9entvars_sf6VectorP11TraceResulti", mfunc_ptr_cast(&CBreakable::TraceAttack_) }, - //{ 0x0, "_ZN10CBreakable10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CBreakable::TakeDamage_) }, - //{ 0x0, "_ZN10CBreakable11DamageDecalEi", mfunc_ptr_cast(&CBreakable::DamageDecal_) }, - //{ 0x0, "_ZN10CBreakable3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBreakable::Use_) }, + { 0x01D7C410, "_ZN10CBreakable5SpawnEv", mfunc_ptr_cast(&CBreakable::Spawn_) }, + { 0x01D7C7A0, "_ZN10CBreakable8PrecacheEv", mfunc_ptr_cast(&CBreakable::Precache_) }, + { 0x01D7C4F0, "_ZN10CBreakable7RestartEv", mfunc_ptr_cast(&CBreakable::Restart_) }, + { 0x01D7C180, "_ZN10CBreakable8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBreakable::KeyValue_) }, + { 0x01D7C3B0, "_ZN10CBreakable4SaveER5CSave", mfunc_ptr_cast(&CBreakable::Save_) }, + { 0x01D7C3E0, "_ZN10CBreakable7RestoreER8CRestore", mfunc_ptr_cast(&CBreakable::Restore_) }, + { 0x01D7DEA0, "_ZN10CBreakable10ObjectCapsEv", mfunc_ptr_cast(&CBreakable::ObjectCaps_) }, + { 0x01D7CDC0, "_ZN10CBreakable11TraceAttackEP9entvars_sf6VectorP11TraceResulti", mfunc_ptr_cast(&CBreakable::TraceAttack_) }, + { 0x01D7CEB0, "_ZN10CBreakable10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CBreakable::TakeDamage_) }, + { 0x01D7D6D0, "_ZN10CBreakable11DamageDecalEi", mfunc_ptr_cast(&CBreakable::DamageDecal_) }, + { 0x01D7CD40, "_ZN10CBreakable3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBreakable::Use_) }, //non-virtual func - //{ 0x0, "_ZN10CBreakable10BreakTouchEP11CBaseEntity", mfunc_ptr_cast(&CBreakable::BreakTouch) }, - //{ 0x0, "_ZN10CBreakable11DamageSoundEv", mfunc_ptr_cast(&CBreakable::DamageSound) }, - //{ 0x0, "_ZN10CBreakable11IsBreakableEv", mfunc_ptr_cast(&CBreakable::IsBreakable) }, - //{ 0x0, "_ZN10CBreakable12SparkWhenHitEv", mfunc_ptr_cast(&CBreakable::SparkWhenHit) }, - //{ 0x0, "_ZN10CBreakable3DieEv", mfunc_ptr_cast(&CBreakable::Die) }, + { 0x01D7CB80, "_ZN10CBreakable10BreakTouchEP11CBaseEntity", mfunc_ptr_cast(&CBreakable::BreakTouch) }, + { 0x01D7C9E0, "_ZN10CBreakable11DamageSoundEv", mfunc_ptr_cast(&CBreakable::DamageSound) }, + //{ 0x01D7D6C0, "_ZN10CBreakable11IsBreakableEv", mfunc_ptr_cast(&CBreakable::IsBreakable) }, // NOXREF + //{ 0x0, "_ZN10CBreakable12SparkWhenHitEv", mfunc_ptr_cast(&CBreakable::SparkWhenHit) }, // NOXREF + { 0x01D7D0E0, "_ZN10CBreakable3DieEv", mfunc_ptr_cast(&CBreakable::Die) }, //{ 0x0, "_ZN10CBreakable10ExplodableEv", mfunc_ptr_cast(&CBreakable::Explodable) }, // NOXREF //{ 0x0, "_ZN10CBreakable18ExplosionMagnitudeEv", mfunc_ptr_cast(&CBreakable::ExplosionMagnitude) }, // NOXREF //{ 0x0, "_ZN10CBreakable21ExplosionSetMagnitudeEi", mfunc_ptr_cast(&CBreakable::ExplosionSetMagnitude) }, // NOXREF @@ -1416,19 +1453,22 @@ FunctionHook g_FunctionHooks[] = //{ 0x01D7C5D0, "_ZN10CBreakable17MaterialSoundListE9MaterialsRi", mfunc_ptr_cast(&CBreakable::MaterialSoundList) }, // NOXREF //CPushable //virtual func - //{ 0x0, "_ZN9CPushable5SpawnEv", mfunc_ptr_cast(&CPushable::Spawn_) }, - //{ 0x0, "_ZN9CPushable8PrecacheEv", mfunc_ptr_cast(&CPushable::Precache_) }, - //{ 0x0, "_ZN9CPushable8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPushable::KeyValue_) }, - //{ 0x0, "_ZN9CPushable4SaveER5CSave", mfunc_ptr_cast(&CPushable::Save_) }, - //{ 0x0, "_ZN9CPushable7RestoreER8CRestore", mfunc_ptr_cast(&CPushable::Restore_) }, - //{ 0x0, "_ZN9CPushable10ObjectCapsEv", mfunc_ptr_cast(&CPushable::ObjectCaps_) }, - //{ 0x0, "_ZN9CPushable10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CPushable::TakeDamage_) }, - //{ 0x0, "_ZN9CPushable5TouchEP11CBaseEntity", mfunc_ptr_cast(&CPushable::Touch_) }, - //{ 0x0, "_ZN9CPushable3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CPushable::Use_) }, + { 0x01D7D800, "_ZN9CPushable5SpawnEv", mfunc_ptr_cast(&CPushable::Spawn_) }, + { 0x01D7D920, "_ZN9CPushable8PrecacheEv", mfunc_ptr_cast(&CPushable::Precache_) }, + { 0x01D7D960, "_ZN9CPushable8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPushable::KeyValue_) }, + { 0x01D7D700, "_ZN9CPushable4SaveER5CSave", mfunc_ptr_cast(&CPushable::Save_) }, + { 0x01D7D750, "_ZN9CPushable7RestoreER8CRestore", mfunc_ptr_cast(&CPushable::Restore_) }, + { 0x01D7D7F0, "_ZN9CPushable10ObjectCapsEv", mfunc_ptr_cast(&CPushable::ObjectCaps_) }, + { 0x01D7DE70, "_ZN9CPushable10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CPushable::TakeDamage_) }, + { 0x01D7DC30, "_ZN9CPushable5TouchEP11CBaseEntity", mfunc_ptr_cast(&CPushable::Touch_) }, + { 0x01D7DB40, "_ZN9CPushable3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CPushable::Use_) }, //non-virtual func - //{ 0x0, "_ZN9CPushable4MoveEP11CBaseEntityi", mfunc_ptr_cast(&CPushable::Move) }, + { 0x01D7DC70, "_ZN9CPushable4MoveEP11CBaseEntityi", mfunc_ptr_cast(&CPushable::Move) }, //{ 0x0, "_ZN9CPushable9StopSoundEv", mfunc_ptr_cast(&CPushable::StopSound) }, //{ 0x0, "_ZN9CPushable8MaxSpeedEv", mfunc_ptr_cast(&CPushable::MaxSpeed) }, // NOXREF +//linked objects + { 0x01D7C360, "func_breakable", (size_t)&func_breakable }, + { 0x01D7D7A0, "func_pushable", (size_t)&func_pushable }, #endif // Func_Break_Region @@ -1436,39 +1476,44 @@ FunctionHook g_FunctionHooks[] = //CBaseDoor //virtual func - //{ 0x0, "_ZN9CBaseDoor5SpawnEv", mfunc_ptr_cast(&CBaseDoor::Spawn_) }, - //{ 0x0, "_ZN9CBaseDoor8PrecacheEv", mfunc_ptr_cast(&CBaseDoor::Precache_) }, - //{ 0x0, "_ZN9CBaseDoor7RestartEv", mfunc_ptr_cast(&CBaseDoor::Restart_) }, - //{ 0x0, "_ZN9CBaseDoor8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseDoor::KeyValue_) }, - //{ 0x0, "_ZN9CBaseDoor4SaveER5CSave", mfunc_ptr_cast(&CBaseDoor::Save_) }, - //{ 0x0, "_ZN9CBaseDoor7RestoreER8CRestore", mfunc_ptr_cast(&CBaseDoor::Restore_) }, - //{ 0x0, "_ZN9CBaseDoor10ObjectCapsEv", mfunc_ptr_cast(&CBaseDoor::ObjectCaps_) }, - //{ 0x0, "_ZN9CBaseDoor14SetToggleStateEi", mfunc_ptr_cast(&CBaseDoor::SetToggleState_) }, - //{ 0x0, "_ZN9CBaseDoor3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseDoor::Use_) }, - //{ 0x0, "_ZN9CBaseDoor7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CBaseDoor::Blocked_) }, + { 0x01D73D70, "_ZN9CBaseDoor5SpawnEv", mfunc_ptr_cast(&CBaseDoor::Spawn_) }, + { 0x01D73FD0, "_ZN9CBaseDoor8PrecacheEv", mfunc_ptr_cast(&CBaseDoor::Precache_) }, + { 0x01D73F50, "_ZN9CBaseDoor7RestartEv", mfunc_ptr_cast(&CBaseDoor::Restart_) }, + { 0x01D73AA0, "_ZN9CBaseDoor8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseDoor::KeyValue_) }, + { 0x01D73820, "_ZN9CBaseDoor4SaveER5CSave", mfunc_ptr_cast(&CBaseDoor::Save_) }, + { 0x01D73850, "_ZN9CBaseDoor7RestoreER8CRestore", mfunc_ptr_cast(&CBaseDoor::Restore_) }, + { 0x01D73D10, "_ZN9CBaseDoor10ObjectCapsEv", mfunc_ptr_cast(&CBaseDoor::ObjectCaps_) }, + { 0x01D73F90, "_ZN9CBaseDoor14SetToggleStateEi", mfunc_ptr_cast(&CBaseDoor::SetToggleState_) }, + { 0x01D74540, "_ZN9CBaseDoor3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseDoor::Use_) }, + { 0x01D74CB0, "_ZN9CBaseDoor7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CBaseDoor::Blocked_) }, //non-virtual func - //{ 0x0, "_ZN9CBaseDoor9DoorTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseDoor::DoorTouch) }, - //{ 0x0, "_ZN9CBaseDoor12DoorActivateEv", mfunc_ptr_cast(&CBaseDoor::DoorActivate) }, - //{ 0x0, "_ZN9CBaseDoor8DoorGoUpEv", mfunc_ptr_cast(&CBaseDoor::DoorGoUp) }, - //{ 0x0, "_ZN9CBaseDoor10DoorGoDownEv", mfunc_ptr_cast(&CBaseDoor::DoorGoDown) }, - //{ 0x0, "_ZN9CBaseDoor10DoorHitTopEv", mfunc_ptr_cast(&CBaseDoor::DoorHitTop) }, - //{ 0x0, "_ZN9CBaseDoor13DoorHitBottomEv", mfunc_ptr_cast(&CBaseDoor::DoorHitBottom) }, + { 0x01D744B0, "_ZN9CBaseDoor9DoorTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseDoor::DoorTouch) }, + { 0x01D74580, "_ZN9CBaseDoor12DoorActivateEv", mfunc_ptr_cast(&CBaseDoor::DoorActivate) }, + { 0x01D74640, "_ZN9CBaseDoor8DoorGoUpEv", mfunc_ptr_cast(&CBaseDoor::DoorGoUp) }, + { 0x01D74AC0, "_ZN9CBaseDoor10DoorGoDownEv", mfunc_ptr_cast(&CBaseDoor::DoorGoDown) }, + { 0x01D74990, "_ZN9CBaseDoor10DoorHitTopEv", mfunc_ptr_cast(&CBaseDoor::DoorHitTop) }, + { 0x01D74BB0, "_ZN9CBaseDoor13DoorHitBottomEv", mfunc_ptr_cast(&CBaseDoor::DoorHitBottom) }, //CRotDoor //virtual func - //{ 0x0, "_ZN8CRotDoor5SpawnEv", mfunc_ptr_cast(&CRotDoor::Spawn_) }, - //{ 0x0, "_ZN8CRotDoor7RestartEv", mfunc_ptr_cast(&CRotDoor::Restart_) }, - //{ 0x0, "_ZN8CRotDoor14SetToggleStateEi", mfunc_ptr_cast(&CRotDoor::SetToggleState_) }, + { 0x01D75150, "_ZN8CRotDoor5SpawnEv", mfunc_ptr_cast(&CRotDoor::Spawn_) }, + { 0x01D75000, "_ZN8CRotDoor7RestartEv", mfunc_ptr_cast(&CRotDoor::Restart_) }, + { 0x01D75380, "_ZN8CRotDoor14SetToggleStateEi", mfunc_ptr_cast(&CRotDoor::SetToggleState_) }, //CMomentaryDoor //virtual func - //{ 0x0, "_ZN14CMomentaryDoor5SpawnEv", mfunc_ptr_cast(&CMomentaryDoor::Spawn_) }, - //{ 0x0, "_ZN14CMomentaryDoor8PrecacheEv", mfunc_ptr_cast(&CMomentaryDoor::Precache_) }, - //{ 0x0, "_ZN14CMomentaryDoor8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMomentaryDoor::KeyValue_) }, - //{ 0x0, "_ZN14CMomentaryDoor4SaveER5CSave", mfunc_ptr_cast(&CMomentaryDoor::Save_) }, - //{ 0x0, "_ZN14CMomentaryDoor7RestoreER8CRestore", mfunc_ptr_cast(&CMomentaryDoor::Restore_) }, - //{ 0x0, "_ZN14CMomentaryDoor10ObjectCapsEv", mfunc_ptr_cast(&CMomentaryDoor::ObjectCaps_) }, - //{ 0x0, "_ZN14CMomentaryDoor3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMomentaryDoor::Use_) }, - - //{ 0x0, "_Z14PlayLockSoundsP9entvars_sP10locksoundsii", (size_t)&PlayLockSounds }, + { 0x01D754B0, "_ZN14CMomentaryDoor5SpawnEv", mfunc_ptr_cast(&CMomentaryDoor::Spawn_) }, + { 0x01D75650, "_ZN14CMomentaryDoor8PrecacheEv", mfunc_ptr_cast(&CMomentaryDoor::Precache_) }, + { 0x01D75780, "_ZN14CMomentaryDoor8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMomentaryDoor::KeyValue_) }, + { 0x01D75450, "_ZN14CMomentaryDoor4SaveER5CSave", mfunc_ptr_cast(&CMomentaryDoor::Save_) }, + { 0x01D75480, "_ZN14CMomentaryDoor7RestoreER8CRestore", mfunc_ptr_cast(&CMomentaryDoor::Restore_) }, + { 0x01D75440, "_ZN14CMomentaryDoor10ObjectCapsEv", mfunc_ptr_cast(&CMomentaryDoor::ObjectCaps_) }, + { 0x01D75820, "_ZN14CMomentaryDoor3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMomentaryDoor::Use_) }, + //non-class func + { 0x01D73880, "_Z14PlayLockSoundsP9entvars_sP10locksoundsii", (size_t)&PlayLockSounds }, +//linked objects + { 0x01D73CC0, "func_door", (size_t)&func_door }, + { 0x01D73D20, "func_water", (size_t)&func_water }, + { 0x01D74FB0, "func_door_rotating", (size_t)&func_door_rotating }, + { 0x01D753F0, "momentary_door", (size_t)&momentary_door }, #endif // Door_Region @@ -1476,62 +1521,72 @@ FunctionHook g_FunctionHooks[] = //CFuncWall //virtual func - //{ 0x0, "_ZN9CFuncWall5SpawnEv", mfunc_ptr_cast(&CFuncWall::Spawn_) }, - //{ 0x0, "_ZN9CFuncWall10ObjectCapsEv", mfunc_ptr_cast(&CFuncWall::ObjectCaps_) }, - //{ 0x0, "_ZN9CFuncWall3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncWall::Use_) }, + { 0x01D5CFE0, "_ZN9CFuncWall5SpawnEv", mfunc_ptr_cast(&CFuncWall::Spawn_) }, + { 0x01D5CFD0, "_ZN9CFuncWall10ObjectCapsEv", mfunc_ptr_cast(&CFuncWall::ObjectCaps_) }, + { 0x01D5D060, "_ZN9CFuncWall3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncWall::Use_) }, //CFuncWallToggle //virtual func - //{ 0x0, "_ZN15CFuncWallToggle5SpawnEv", mfunc_ptr_cast(&CFuncWallToggle::Spawn_) }, - //{ 0x0, "_ZN15CFuncWallToggle3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncWallToggle::Use_) }, + { 0x01D5D0F0, "_ZN15CFuncWallToggle5SpawnEv", mfunc_ptr_cast(&CFuncWallToggle::Spawn_) }, + { 0x01D5D230, "_ZN15CFuncWallToggle3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncWallToggle::Use_) }, //non-virtual func - //{ 0x0, "_ZN15CFuncWallToggle7TurnOffEv", mfunc_ptr_cast(&CFuncWallToggle::TurnOff) }, - //{ 0x0, "_ZN15CFuncWallToggle6TurnOnEv", mfunc_ptr_cast(&CFuncWallToggle::TurnOn) }, - //{ 0x0, "_ZN15CFuncWallToggle4IsOnEv", mfunc_ptr_cast(&CFuncWallToggle::IsOn) }, + //{ 0x01D5D1B0, "_ZN15CFuncWallToggle7TurnOffEv", mfunc_ptr_cast(&CFuncWallToggle::TurnOff) }, // NOXREF + //{ 0x01D5D1E0, "_ZN15CFuncWallToggle6TurnOnEv", mfunc_ptr_cast(&CFuncWallToggle::TurnOn) }, // NOXREF + //{ 0x01D5D210, "_ZN15CFuncWallToggle4IsOnEv", mfunc_ptr_cast(&CFuncWallToggle::IsOn) }, // NOXREF //CFuncConveyor //virtual func - //{ 0x0, "_ZN13CFuncConveyor5SpawnEv", mfunc_ptr_cast(&CFuncConveyor::Spawn_) }, - //{ 0x0, "_ZN13CFuncConveyor3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncConveyor::Use_) }, + { 0x01D5D320, "_ZN13CFuncConveyor5SpawnEv", mfunc_ptr_cast(&CFuncConveyor::Spawn_) }, + { 0x01D5D4F0, "_ZN13CFuncConveyor3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncConveyor::Use_) }, + //non-virtual func + //{ 0x01D5D470, "_ZN13CFuncConveyor11UpdateSpeedEf", mfunc_ptr_cast(&CFuncConveyor::UpdateSpeed) }, // NOXREF //CFuncIllusionary //virtual func - //{ 0x0, "_ZN16CFuncIllusionary5SpawnEv", mfunc_ptr_cast(&CFuncIllusionary::Spawn_) }, - //{ 0x0, "_ZN16CFuncIllusionary8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncIllusionary::KeyValue_) }, - //{ 0x0, "_ZN16CFuncIllusionary10ObjectCapsEv", mfunc_ptr_cast(&CFuncIllusionary::ObjectCaps_) }, + { 0x01D5D640, "_ZN16CFuncIllusionary5SpawnEv", mfunc_ptr_cast(&CFuncIllusionary::Spawn_) }, + { 0x01D5D5E0, "_ZN16CFuncIllusionary8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncIllusionary::KeyValue_) }, + { 0x01D5D5D0, "_ZN16CFuncIllusionary10ObjectCapsEv", mfunc_ptr_cast(&CFuncIllusionary::ObjectCaps_) }, //CFuncMonsterClip //virtual func - //{ 0x0, "_ZN16CFuncMonsterClip5SpawnEv", mfunc_ptr_cast(&CFuncMonsterClip::Spawn_) }, - //{ 0x0, "_ZN16CFuncMonsterClip3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncMonsterClip::Use_) }, // PURE + { 0x01D5D700, "_ZN16CFuncMonsterClip5SpawnEv", mfunc_ptr_cast(&CFuncMonsterClip::Spawn_) }, + //{ 0x01D5D6F0, "_ZN16CFuncMonsterClip3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncMonsterClip::Use_) }, // PURE //CFuncRotating //virtual func - //{ 0x0, "_ZN13CFuncRotating5SpawnEv", mfunc_ptr_cast(&CFuncRotating::Spawn_) }, - //{ 0x0, "_ZN13CFuncRotating8PrecacheEv", mfunc_ptr_cast(&CFuncRotating::Precache_) }, - //{ 0x0, "_ZN13CFuncRotating8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncRotating::KeyValue_) }, - //{ 0x0, "_ZN13CFuncRotating4SaveER5CSave", mfunc_ptr_cast(&CFuncRotating::Save_) }, - //{ 0x0, "_ZN13CFuncRotating7RestoreER8CRestore", mfunc_ptr_cast(&CFuncRotating::Restore_) }, - //{ 0x0, "_ZN13CFuncRotating10ObjectCapsEv", mfunc_ptr_cast(&CFuncRotating::ObjectCaps_) }, - //{ 0x0, "_ZN13CFuncRotating7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncRotating::Blocked_) }, + { 0x01D5D9F0, "_ZN13CFuncRotating5SpawnEv", mfunc_ptr_cast(&CFuncRotating::Spawn_) }, + { 0x01D5DC20, "_ZN13CFuncRotating8PrecacheEv", mfunc_ptr_cast(&CFuncRotating::Precache_) }, + { 0x01D5D870, "_ZN13CFuncRotating8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFuncRotating::KeyValue_) }, + { 0x01D5D7B0, "_ZN13CFuncRotating4SaveER5CSave", mfunc_ptr_cast(&CFuncRotating::Save_) }, + { 0x01D5D7E0, "_ZN13CFuncRotating7RestoreER8CRestore", mfunc_ptr_cast(&CFuncRotating::Restore_) }, + { 0x01D5D860, "_ZN13CFuncRotating10ObjectCapsEv", mfunc_ptr_cast(&CFuncRotating::ObjectCaps_) }, + { 0x01D5E590, "_ZN13CFuncRotating7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CFuncRotating::Blocked_) }, //non-virtual func - //{ 0x0, "_ZN13CFuncRotating6SpinUpEv", mfunc_ptr_cast(&CFuncRotating::SpinUp) }, - //{ 0x0, "_ZN13CFuncRotating8SpinDownEv", mfunc_ptr_cast(&CFuncRotating::SpinDown) }, - //{ 0x0, "_ZN13CFuncRotating9HurtTouchEP11CBaseEntity", mfunc_ptr_cast(&CFuncRotating::HurtTouch) }, - //{ 0x0, "_ZN13CFuncRotating11RotatingUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncRotating::RotatingUse) }, - //{ 0x0, "_ZN13CFuncRotating6RotateEv", mfunc_ptr_cast(&CFuncRotating::Rotate) }, - //{ 0x0, "_ZN13CFuncRotating12RampPitchVolEi", mfunc_ptr_cast(&CFuncRotating::RampPitchVol) }, + { 0x01D5E050, "_ZN13CFuncRotating6SpinUpEv", mfunc_ptr_cast(&CFuncRotating::SpinUp) }, + { 0x01D5E210, "_ZN13CFuncRotating8SpinDownEv", mfunc_ptr_cast(&CFuncRotating::SpinDown) }, + { 0x01D5DDB0, "_ZN13CFuncRotating9HurtTouchEP11CBaseEntity", mfunc_ptr_cast(&CFuncRotating::HurtTouch) }, + { 0x01D5E410, "_ZN13CFuncRotating11RotatingUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CFuncRotating::RotatingUse) }, + { 0x01D5E3F0, "_ZN13CFuncRotating6RotateEv", mfunc_ptr_cast(&CFuncRotating::Rotate) }, + { 0x01D5DF40, "_ZN13CFuncRotating12RampPitchVolEi", mfunc_ptr_cast(&CFuncRotating::RampPitchVol) }, //CPendulum //virtual func - //{ 0x0, "_ZN9CPendulum5SpawnEv", mfunc_ptr_cast(&CPendulum::Spawn_) }, - //{ 0x0, "_ZN9CPendulum8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPendulum::KeyValue_) }, - //{ 0x0, "_ZN9CPendulum4SaveER5CSave", mfunc_ptr_cast(&CPendulum::Save_) }, - //{ 0x0, "_ZN9CPendulum7RestoreER8CRestore", mfunc_ptr_cast(&CPendulum::Restore_) }, - //{ 0x0, "_ZN9CPendulum10ObjectCapsEv", mfunc_ptr_cast(&CPendulum::ObjectCaps_) }, - //{ 0x0, "_ZN9CPendulum5TouchEP11CBaseEntity", mfunc_ptr_cast(&CPendulum::Touch_) }, - //{ 0x0, "_ZN9CPendulum7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CPendulum::Blocked_) }, + { 0x01D5E700, "_ZN9CPendulum5SpawnEv", mfunc_ptr_cast(&CPendulum::Spawn_) }, + { 0x01D5E670, "_ZN9CPendulum8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CPendulum::KeyValue_) }, + { 0x01D5E610, "_ZN9CPendulum4SaveER5CSave", mfunc_ptr_cast(&CPendulum::Save_) }, + { 0x01D5E640, "_ZN9CPendulum7RestoreER8CRestore", mfunc_ptr_cast(&CPendulum::Restore_) }, + { 0x01D5E600, "_ZN9CPendulum10ObjectCapsEv", mfunc_ptr_cast(&CPendulum::ObjectCaps_) }, + { 0x01D5EC10, "_ZN9CPendulum5TouchEP11CBaseEntity", mfunc_ptr_cast(&CPendulum::Touch_) }, + { 0x01D5EA10, "_ZN9CPendulum7BlockedEP11CBaseEntity", mfunc_ptr_cast(&CPendulum::Blocked_) }, //non-virtual func - //{ 0x0, "_ZN9CPendulum5SwingEv", mfunc_ptr_cast(&CPendulum::Swing) }, - //{ 0x0, "_ZN9CPendulum11PendulumUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CPendulum::PendulumUse) }, - //{ 0x0, "_ZN9CPendulum4StopEv", mfunc_ptr_cast(&CPendulum::Stop) }, - //{ 0x0, "_ZN9CPendulum9RopeTouchEP11CBaseEntity", mfunc_ptr_cast(&CPendulum::RopeTouch) }, - + { 0x01D5EA20, "_ZN9CPendulum5SwingEv", mfunc_ptr_cast(&CPendulum::Swing) }, + { 0x01D5E8B0, "_ZN9CPendulum11PendulumUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CPendulum::PendulumUse) }, + { 0x01D5E9C0, "_ZN9CPendulum4StopEv", mfunc_ptr_cast(&CPendulum::Stop) }, + { 0x01D5EDA0, "_ZN9CPendulum9RopeTouchEP11CBaseEntity", mfunc_ptr_cast(&CPendulum::RopeTouch) }, +//non-class func { 0x01D5CF20, "_Z15VecBModelOriginP9entvars_s", (size_t)&VecBModelOrigin }, +//linked objects + { 0x01D5CF80, "func_wall", (size_t)&func_wall }, + { 0x01D5D0A0, "func_wall_toggle", (size_t)&func_wall_toggle }, + { 0x01D5D2D0, "func_conveyor", (size_t)&func_conveyor }, + { 0x01D5D580, "func_illusionary", (size_t)&func_illusionary }, + { 0x01D5D6A0, "func_monsterclip", (size_t)&func_monsterclip }, + { 0x01D5D810, "func_rotating", (size_t)&func_rotating }, + { 0x01D5E5B0, "func_pendulum", (size_t)&func_pendulum }, #endif // BModels_Region @@ -1539,80 +1594,92 @@ FunctionHook g_FunctionHooks[] = //CEnvGlobal //virtual func - //{ 0x0, "_ZN10CEnvGlobal5SpawnEv", mfunc_ptr_cast(&CEnvGlobal::Spawn_) }, - //{ 0x0, "_ZN10CEnvGlobal8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CEnvGlobal::KeyValue_) }, - //{ 0x0, "_ZN10CEnvGlobal4SaveER5CSave", mfunc_ptr_cast(&CEnvGlobal::Save_) }, - //{ 0x0, "_ZN10CEnvGlobal7RestoreER8CRestore", mfunc_ptr_cast(&CEnvGlobal::Restore_) }, - //{ 0x0, "_ZN10CEnvGlobal3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CEnvGlobal::Use_) }, + { 0x01D5EF80, "_ZN10CEnvGlobal5SpawnEv", mfunc_ptr_cast(&CEnvGlobal::Spawn_) }, + { 0x01D5EED0, "_ZN10CEnvGlobal8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CEnvGlobal::KeyValue_) }, + { 0x01D5EE20, "_ZN10CEnvGlobal4SaveER5CSave", mfunc_ptr_cast(&CEnvGlobal::Save_) }, + { 0x01D5EE50, "_ZN10CEnvGlobal7RestoreER8CRestore", mfunc_ptr_cast(&CEnvGlobal::Restore_) }, + { 0x01D5EFE0, "_ZN10CEnvGlobal3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CEnvGlobal::Use_) }, //CMultiSource //virtual func - //{ 0x0, "_ZN12CMultiSource5SpawnEv", mfunc_ptr_cast(&CMultiSource::Spawn_) }, - //{ 0x0, "_ZN12CMultiSource8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMultiSource::KeyValue_) }, - //{ 0x0, "_ZN12CMultiSource3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMultiSource::Use_) }, - //{ 0x0, "_ZN12CMultiSource10ObjectCapsEv", mfunc_ptr_cast(&CMultiSource::ObjectCaps_) }, - //{ 0x0, "_ZN12CMultiSource11IsTriggeredEP11CBaseEntity", mfunc_ptr_cast(&CMultiSource::IsTriggered_) }, - //{ 0x0, "_ZN12CMultiSource4SaveER5CSave", mfunc_ptr_cast(&CMultiSource::Save_) }, - //{ 0x0, "_ZN12CMultiSource7RestoreER8CRestore", mfunc_ptr_cast(&CMultiSource::Restore_) }, + { 0x01D5F1E0, "_ZN12CMultiSource5SpawnEv", mfunc_ptr_cast(&CMultiSource::Spawn_) }, + { 0x01D5F120, "_ZN12CMultiSource8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMultiSource::KeyValue_) }, + { 0x01D5F230, "_ZN12CMultiSource3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMultiSource::Use_) }, + { 0x01D60DF0, "_ZN12CMultiSource10ObjectCapsEv", mfunc_ptr_cast(&CMultiSource::ObjectCaps_) }, + { 0x01D5F310, "_ZN12CMultiSource11IsTriggeredEP11CBaseEntity", mfunc_ptr_cast(&CMultiSource::IsTriggered_) }, + { 0x01D5F070, "_ZN12CMultiSource4SaveER5CSave", mfunc_ptr_cast(&CMultiSource::Save_) }, + { 0x01D5F0A0, "_ZN12CMultiSource7RestoreER8CRestore", mfunc_ptr_cast(&CMultiSource::Restore_) }, //non-virtual func - //{ 0x0, "_ZN12CMultiSource8RegisterEv", mfunc_ptr_cast(&CMultiSource::Register) }, + { 0x01D5F370, "_ZN12CMultiSource8RegisterEv", mfunc_ptr_cast(&CMultiSource::Register) }, //CBaseButton //virtual func - //{ 0x0, "_ZN11CBaseButton5SpawnEv", mfunc_ptr_cast(&CBaseButton::Spawn_) }, - //{ 0x0, "_ZN11CBaseButton8PrecacheEv", mfunc_ptr_cast(&CBaseButton::Precache_) }, - //{ 0x01D5F7D0, "_ZN11CBaseButton8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseButton::KeyValue_) }, - //{ 0x0, "_ZN11CBaseButton4SaveER5CSave", mfunc_ptr_cast(&CBaseButton::Save_) }, - //{ 0x0, "_ZN11CBaseButton7RestoreER8CRestore", mfunc_ptr_cast(&CBaseButton::Restore_) }, - //{ 0x0, "_ZN11CBaseButton10ObjectCapsEv", mfunc_ptr_cast(&CBaseButton::ObjectCaps_) }, - //{ 0x0, "_ZN11CBaseButton10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CBaseButton::TakeDamage_) }, + { 0x01D5FB30, "_ZN11CBaseButton5SpawnEv", mfunc_ptr_cast(&CBaseButton::Spawn_) }, + { 0x01D5F510, "_ZN11CBaseButton8PrecacheEv", mfunc_ptr_cast(&CBaseButton::Precache_) }, + { 0x01D5F7D0, "_ZN11CBaseButton8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseButton::KeyValue_) }, + { 0x01D5F4B0, "_ZN11CBaseButton4SaveER5CSave", mfunc_ptr_cast(&CBaseButton::Save_) }, + { 0x01D5F4E0, "_ZN11CBaseButton7RestoreER8CRestore", mfunc_ptr_cast(&CBaseButton::Restore_) }, + { 0x01D610F0, "_ZN11CBaseButton10ObjectCapsEv", mfunc_ptr_cast(&CBaseButton::ObjectCaps_) }, + { 0x01D5F930, "_ZN11CBaseButton10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CBaseButton::TakeDamage_) }, //non-virtual func - //{ 0x0, "_ZN11CBaseButton8RotSpawnEv", mfunc_ptr_cast(&CBaseButton::RotSpawn) }, - //{ 0x0, "_ZN11CBaseButton14ButtonActivateEv", mfunc_ptr_cast(&CBaseButton::ButtonActivate) }, - //{ 0x0, "_ZN11CBaseButton15SparkSoundCacheEv", mfunc_ptr_cast(&CBaseButton::SparkSoundCache) }, - //{ 0x0, "_ZN11CBaseButton10ButtonShotEv", mfunc_ptr_cast(&CBaseButton::ButtonShot) }, - //{ 0x0, "_ZN11CBaseButton11ButtonTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseButton::ButtonTouch) }, - //{ 0x0, "_ZN11CBaseButton11ButtonSparkEv", mfunc_ptr_cast(&CBaseButton::ButtonSpark) }, - //{ 0x0, "_ZN11CBaseButton14TriggerAndWaitEv", mfunc_ptr_cast(&CBaseButton::TriggerAndWait) }, - //{ 0x0, "_ZN11CBaseButton12ButtonReturnEv", mfunc_ptr_cast(&CBaseButton::ButtonReturn) }, - //{ 0x0, "_ZN11CBaseButton14ButtonBackHomeEv", mfunc_ptr_cast(&CBaseButton::ButtonBackHome) }, - //{ 0x0, "_ZN11CBaseButton9ButtonUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseButton::ButtonUse) }, - //{ 0x0, "_ZN11CBaseButton21ButtonResponseToTouchEv", mfunc_ptr_cast(&CBaseButton::ButtonResponseToTouch) }, + //{ 0x0, "_ZN11CBaseButton8RotSpawnEv", mfunc_ptr_cast(&CBaseButton::RotSpawn) }, // NOXREF + { 0x01D603A0, "_ZN11CBaseButton14ButtonActivateEv", mfunc_ptr_cast(&CBaseButton::ButtonActivate) }, + //{ 0x0, "_ZN11CBaseButton15SparkSoundCacheEv", mfunc_ptr_cast(&CBaseButton::SparkSoundCache) }, // NOXREF + //{ 0x0, "_ZN11CBaseButton10ButtonShotEv", mfunc_ptr_cast(&CBaseButton::ButtonShot) }, // NOXREF + { 0x01D601F0, "_ZN11CBaseButton11ButtonTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseButton::ButtonTouch) }, + { 0x01D60030, "_ZN11CBaseButton11ButtonSparkEv", mfunc_ptr_cast(&CBaseButton::ButtonSpark) }, + { 0x01D60490, "_ZN11CBaseButton14TriggerAndWaitEv", mfunc_ptr_cast(&CBaseButton::TriggerAndWait) }, + { 0x01D60530, "_ZN11CBaseButton12ButtonReturnEv", mfunc_ptr_cast(&CBaseButton::ButtonReturn) }, + { 0x01D605C0, "_ZN11CBaseButton14ButtonBackHomeEv", mfunc_ptr_cast(&CBaseButton::ButtonBackHome) }, + { 0x01D60080, "_ZN11CBaseButton9ButtonUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseButton::ButtonUse) }, + //{ 0x01D60190, "_ZN11CBaseButton21ButtonResponseToTouchEv", mfunc_ptr_cast(&CBaseButton::ButtonResponseToTouch) }, // NOXREF + //non-class func + { 0x01D5FDA0, "_Z11ButtonSoundi", (size_t)&ButtonSound }, + { 0x01D5FE90, "_Z7DoSparkP9entvars_sRK6Vector", (size_t)&DoSpark }, //CRotButton //virtual func - //{ 0x0, "_ZN10CRotButton5SpawnEv", mfunc_ptr_cast(&CRotButton::Spawn_) }, + { 0x01D60730, "_ZN10CRotButton5SpawnEv", mfunc_ptr_cast(&CRotButton::Spawn_) }, //CMomentaryRotButton //virtual func - //{ 0x0, "_ZN19CMomentaryRotButton5SpawnEv", mfunc_ptr_cast(&CMomentaryRotButton::Spawn_) }, - //{ 0x0, "_ZN19CMomentaryRotButton8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMomentaryRotButton::KeyValue_) }, - //{ 0x0, "_ZN19CMomentaryRotButton4SaveER5CSave", mfunc_ptr_cast(&CMomentaryRotButton::Save_) }, - //{ 0x0, "_ZN19CMomentaryRotButton7RestoreER8CRestore", mfunc_ptr_cast(&CMomentaryRotButton::Restore_) }, - //{ 0x0, "_ZN19CMomentaryRotButton10ObjectCapsEv", mfunc_ptr_cast(&CMomentaryRotButton::ObjectCaps_) }, - //{ 0x0, "_ZN19CMomentaryRotButton3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMomentaryRotButton::Use_) }, + { 0x01D60A10, "_ZN19CMomentaryRotButton5SpawnEv", mfunc_ptr_cast(&CMomentaryRotButton::Spawn_) }, + { 0x01D60BF0, "_ZN19CMomentaryRotButton8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMomentaryRotButton::KeyValue_) }, + { 0x01D60940, "_ZN19CMomentaryRotButton4SaveER5CSave", mfunc_ptr_cast(&CMomentaryRotButton::Save_) }, + { 0x01D60970, "_ZN19CMomentaryRotButton7RestoreER8CRestore", mfunc_ptr_cast(&CMomentaryRotButton::Restore_) }, + { 0x01D609F0, "_ZN19CMomentaryRotButton10ObjectCapsEv", mfunc_ptr_cast(&CMomentaryRotButton::ObjectCaps_) }, + { 0x01D60CC0, "_ZN19CMomentaryRotButton3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMomentaryRotButton::Use_) }, //non-virtual func - //{ 0x0, "_ZN19CMomentaryRotButton3OffEv", mfunc_ptr_cast(&CMomentaryRotButton::Off) }, - //{ 0x0, "_ZN19CMomentaryRotButton6ReturnEv", mfunc_ptr_cast(&CMomentaryRotButton::Return) }, - //{ 0x0, "_ZN19CMomentaryRotButton10UpdateSelfEf", mfunc_ptr_cast(&CMomentaryRotButton::UpdateSelf) }, - //{ 0x0, "_ZN19CMomentaryRotButton16UpdateSelfReturnEf", mfunc_ptr_cast(&CMomentaryRotButton::UpdateSelfReturn) }, - //{ 0x0, "_ZN19CMomentaryRotButton16UpdateAllButtonsEfi", mfunc_ptr_cast(&CMomentaryRotButton::UpdateAllButtons) }, - //{ 0x0, "_ZN19CMomentaryRotButton9PlaySoundEv", mfunc_ptr_cast(&CMomentaryRotButton::PlaySound) }, - //{ 0x0, "_ZN19CMomentaryRotButton12UpdateTargetEf", mfunc_ptr_cast(&CMomentaryRotButton::UpdateTarget) }, + { 0x01D61180, "_ZN19CMomentaryRotButton3OffEv", mfunc_ptr_cast(&CMomentaryRotButton::Off) }, + { 0x01D61200, "_ZN19CMomentaryRotButton6ReturnEv", mfunc_ptr_cast(&CMomentaryRotButton::Return) }, + { 0x01D60F60, "_ZN19CMomentaryRotButton10UpdateSelfEf", mfunc_ptr_cast(&CMomentaryRotButton::UpdateSelf) }, + //{ 0x01D613E0, "_ZN19CMomentaryRotButton16UpdateSelfReturnEf", mfunc_ptr_cast(&CMomentaryRotButton::UpdateSelfReturn) }, // NOXREF + //{ 0x01D60E00, "_ZN19CMomentaryRotButton16UpdateAllButtonsEfi", mfunc_ptr_cast(&CMomentaryRotButton::UpdateAllButtons) }, // NOXREF + //{ 0x01D60C70, "_ZN19CMomentaryRotButton9PlaySoundEv", mfunc_ptr_cast(&CMomentaryRotButton::PlaySound) }, // NOXREF + //{ 0x01D61110, "_ZN19CMomentaryRotButton12UpdateTargetEf", mfunc_ptr_cast(&CMomentaryRotButton::UpdateTarget) }, // NOXREF //{ 0x0, "_ZN19CMomentaryRotButton8InstanceEP7edict_s", mfunc_ptr_cast(&CMomentaryRotButton::Instance) }, // NOXREF //CEnvSpark //virtual func - //{ 0x0, "_ZN9CEnvSpark5SpawnEv", mfunc_ptr_cast(&CEnvSpark::Spawn_) }, - //{ 0x0, "_ZN9CEnvSpark8PrecacheEv", mfunc_ptr_cast(&CEnvSpark::Precache_) }, - //{ 0x0, "_ZN9CEnvSpark8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CEnvSpark::KeyValue_) }, - //{ 0x0, "_ZN9CEnvSpark4SaveER5CSave", mfunc_ptr_cast(&CEnvSpark::Save_) }, - //{ 0x0, "_ZN9CEnvSpark7RestoreER8CRestore", mfunc_ptr_cast(&CEnvSpark::Restore_) }, + { 0x01D615A0, "_ZN9CEnvSpark5SpawnEv", mfunc_ptr_cast(&CEnvSpark::Spawn_) }, + { 0x01D61620, "_ZN9CEnvSpark8PrecacheEv", mfunc_ptr_cast(&CEnvSpark::Precache_) }, + { 0x01D61670, "_ZN9CEnvSpark8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CEnvSpark::KeyValue_) }, + { 0x01D614A0, "_ZN9CEnvSpark4SaveER5CSave", mfunc_ptr_cast(&CEnvSpark::Save_) }, + { 0x01D614D0, "_ZN9CEnvSpark7RestoreER8CRestore", mfunc_ptr_cast(&CEnvSpark::Restore_) }, //non-virtual func - //{ 0x0, "_ZN9CEnvSpark10SparkThinkEv", mfunc_ptr_cast(&CEnvSpark::SparkThink) }, - //{ 0x0, "_ZN9CEnvSpark10SparkStartEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CEnvSpark::SparkStart) }, - //{ 0x0, "_ZN9CEnvSpark9SparkStopEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CEnvSpark::SparkStop) }, + { 0x01D61730, "_ZN9CEnvSpark10SparkThinkEv", mfunc_ptr_cast(&CEnvSpark::SparkThink) }, + { 0x01D61770, "_ZN9CEnvSpark10SparkStartEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CEnvSpark::SparkStart) }, + { 0x01D617B0, "_ZN9CEnvSpark9SparkStopEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CEnvSpark::SparkStop) }, //CButtonTarget //virtual func - //{ 0x0, "_ZN13CButtonTarget5SpawnEv", mfunc_ptr_cast(&CButtonTarget::Spawn_) }, - //{ 0x0, "_ZN13CButtonTarget10ObjectCapsEv", mfunc_ptr_cast(&CButtonTarget::ObjectCaps_) }, - //{ 0x0, "_ZN13CButtonTarget10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CButtonTarget::TakeDamage_) }, - //{ 0x0, "_ZN13CButtonTarget3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CButtonTarget::Use_) }, + { 0x01D61820, "_ZN13CButtonTarget5SpawnEv", mfunc_ptr_cast(&CButtonTarget::Spawn_) }, + { 0x01D61910, "_ZN13CButtonTarget10ObjectCapsEv", mfunc_ptr_cast(&CButtonTarget::ObjectCaps_) }, + { 0x01D61930, "_ZN13CButtonTarget10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CButtonTarget::TakeDamage_) }, + { 0x01D61890, "_ZN13CButtonTarget3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CButtonTarget::Use_) }, +// linked objects + { 0x01D5EE80, "env_global", (size_t)&env_global }, + { 0x01D5F0D0, "multisource", (size_t)&multisource }, + { 0x01D5FAE0, "func_button", (size_t)&func_button }, + { 0x01D606E0, "func_rot_button", (size_t)&func_rot_button }, + { 0x01D609A0, "momentary_rot_button", (size_t)&momentary_rot_button }, + { 0x01D61500, "env_spark", (size_t)&env_spark }, + { 0x01D61550, "env_debris", (size_t)&env_debris }, + { 0x01D617D0, "button_target", (size_t)&button_target }, #endif // Button_Region @@ -1710,105 +1777,105 @@ FunctionHook g_FunctionHooks[] = //CRuleEntity //virtual func - //{ 0x0, "_ZN11CRuleEntity5SpawnEv", mfunc_ptr_cast(&CRuleEntity::Spawn_) }, - //{ 0x0, "_ZN11CRuleEntity8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CRuleEntity::KeyValue_) }, - //{ 0x0, "_ZN11CRuleEntity4SaveER5CSave", mfunc_ptr_cast(&CRuleEntity::Save_) }, - //{ 0x0, "_ZN11CRuleEntity7RestoreER8CRestore", mfunc_ptr_cast(&CRuleEntity::Restore_) }, + //{ 0x01D88CC0, "_ZN11CRuleEntity5SpawnEv", mfunc_ptr_cast(&CRuleEntity::Spawn_) }, // NOXREF + { 0x01D88CF0, "_ZN11CRuleEntity8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CRuleEntity::KeyValue_) }, + { 0x01D88C60, "_ZN11CRuleEntity4SaveER5CSave", mfunc_ptr_cast(&CRuleEntity::Save_) }, + { 0x01D88C90, "_ZN11CRuleEntity7RestoreER8CRestore", mfunc_ptr_cast(&CRuleEntity::Restore_) }, //non-virtual func - //{ 0x0, "_ZN11CRuleEntity9SetMasterEi", mfunc_ptr_cast(&CRuleEntity::SetMaster) }, // NOXREF - //{ 0x0, "_ZN11CRuleEntity19CanFireForActivatorEP11CBaseEntity", mfunc_ptr_cast(&CRuleEntity::CanFireForActivator) }, + //{ 0x0, "_ZN11CRuleEntity9SetMasterEi", mfunc_ptr_cast(&CRuleEntity::SetMaster) }, // NOXREF + //{ 0x01D88D40, "_ZN11CRuleEntity19CanFireForActivatorEP11CBaseEntity", mfunc_ptr_cast(&CRuleEntity::CanFireForActivator) }, // NOXREF //CRulePointEntity //virtual func - //{ 0x0, "_ZN16CRulePointEntity5SpawnEv", mfunc_ptr_cast(&CRulePointEntity::Spawn_) }, + { 0x01D88D70, "_ZN16CRulePointEntity5SpawnEv", mfunc_ptr_cast(&CRulePointEntity::Spawn_) }, //CRuleBrushEntity //virtual func - //{ 0x0, "_ZN16CRuleBrushEntity5SpawnEv", mfunc_ptr_cast(&CRuleBrushEntity::Spawn_) }, + { 0x01D88DB0, "_ZN16CRuleBrushEntity5SpawnEv", mfunc_ptr_cast(&CRuleBrushEntity::Spawn_) }, //CGameScore //virtual func - //{ 0x0, "_ZN10CGameScore5SpawnEv", mfunc_ptr_cast(&CGameScore::Spawn_) }, - //{ 0x0, "_ZN10CGameScore8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGameScore::KeyValue_) }, - //{ 0x0, "_ZN10CGameScore3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameScore::Use_) }, + { 0x01D88E50, "_ZN10CGameScore5SpawnEv", mfunc_ptr_cast(&CGameScore::Spawn_) }, + { 0x01D88E90, "_ZN10CGameScore8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGameScore::KeyValue_) }, + { 0x01D88F20, "_ZN10CGameScore3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameScore::Use_) }, //non-virtual func //{ 0x0, "_ZN10CGameScore6PointsEv", mfunc_ptr_cast(&CGameScore::Points) }, // NOXREF //{ 0x0, "_ZN10CGameScore18AllowNegativeScoreEv", mfunc_ptr_cast(&CGameScore::AllowNegativeScore) }, // NOXREF //{ 0x0, "_ZN10CGameScore11AwardToTeamEv", mfunc_ptr_cast(&CGameScore::AwardToTeam) }, // NOXREF //{ 0x0, "_ZN10CGameScore9SetPointsEi", mfunc_ptr_cast(&CGameScore::SetPoints) }, // NOXREF //CGameEnd - //{ 0x0, "_ZN8CGameEnd3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameEnd::Use_) }, + { 0x01D88FE0, "_ZN8CGameEnd3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameEnd::Use_) }, //CGameText //virtual func - //{ 0x0, "_ZN9CGameText8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGameText::KeyValue_) }, - //{ 0x0, "_ZN9CGameText4SaveER5CSave", mfunc_ptr_cast(&CGameText::Save_) }, - //{ 0x0, "_ZN9CGameText7RestoreER8CRestore", mfunc_ptr_cast(&CGameText::Restore_) }, - //{ 0x0, "_ZN9CGameText3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameText::Use_) }, + { 0x01D89100, "_ZN9CGameText8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGameText::KeyValue_) }, + { 0x01D89060, "_ZN9CGameText4SaveER5CSave", mfunc_ptr_cast(&CGameText::Save_) }, + { 0x01D890B0, "_ZN9CGameText7RestoreER8CRestore", mfunc_ptr_cast(&CGameText::Restore_) }, + { 0x01D893C0, "_ZN9CGameText3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameText::Use_) }, //non-virtual func //{ 0x0, "_ZN9CGameText12MessageToAllEv", mfunc_ptr_cast(&CGameText::MessageToAll) }, // NOXREF //{ 0x0, "_ZN9CGameText10MessageSetEPKc", mfunc_ptr_cast(&CGameText::MessageSet) }, // NOXREF //{ 0x0, "_ZN9CGameText10MessageGetEv", mfunc_ptr_cast(&CGameText::MessageGet) }, // NOXREF //CGameTeamMaster //virtual func - //{ 0x0, "_ZN15CGameTeamMaster8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGameTeamMaster::KeyValue_) }, - //{ 0x0, "_ZN15CGameTeamMaster10ObjectCapsEv", mfunc_ptr_cast(&CGameTeamMaster::ObjectCaps_) }, - //{ 0x0, "_ZN15CGameTeamMaster11IsTriggeredEP11CBaseEntity", mfunc_ptr_cast(&CGameTeamMaster::IsTriggered_) }, - //{ 0x0, "_ZN15CGameTeamMaster6TeamIDEv", mfunc_ptr_cast(&CGameTeamMaster::TeamID_) }, - //{ 0x0, "_ZN15CGameTeamMaster3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameTeamMaster::Use_) }, + { 0x01D894B0, "_ZN15CGameTeamMaster8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGameTeamMaster::KeyValue_) }, + { 0x01D894A0, "_ZN15CGameTeamMaster10ObjectCapsEv", mfunc_ptr_cast(&CGameTeamMaster::ObjectCaps_) }, + { 0x01D89690, "_ZN15CGameTeamMaster11IsTriggeredEP11CBaseEntity", mfunc_ptr_cast(&CGameTeamMaster::IsTriggered_) }, + { 0x01D896E0, "_ZN15CGameTeamMaster6TeamIDEv", mfunc_ptr_cast(&CGameTeamMaster::TeamID_) }, + { 0x01D895A0, "_ZN15CGameTeamMaster3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameTeamMaster::Use_) }, //non-virtual func //{ 0x0, "_ZN15CGameTeamMaster12RemoveOnFireEv", mfunc_ptr_cast(&CGameTeamMaster::RemoveOnFire) }, // NOXREF //{ 0x0, "_ZN15CGameTeamMaster7AnyTeamEv", mfunc_ptr_cast(&CGameTeamMaster::AnyTeam) }, // NOXREF - //{ 0x0, "_ZN15CGameTeamMaster9TeamMatchEP11CBaseEntity", mfunc_ptr_cast(&CGameTeamMaster::TeamMatch) }, + //{ 0x01D89700, "_ZN15CGameTeamMaster9TeamMatchEP11CBaseEntity", mfunc_ptr_cast(&CGameTeamMaster::TeamMatch) }, // NOXREF //CGameTeamSet //virtual func - //{ 0x0, "_ZN12CGameTeamSet3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameTeamSet::Use_) }, + { 0x01D897A0, "_ZN12CGameTeamSet3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameTeamSet::Use_) }, //non-virtual func //{ 0x0, "_ZN12CGameTeamSet12RemoveOnFireEv", mfunc_ptr_cast(&CGameTeamSet::RemoveOnFire) }, // NOXREF - //{ 0x0, "_ZN12CGameTeamSet15ShouldClearTeamEv", mfunc_ptr_cast(&CGameTeamSet::ShouldClearTeam) }, // NOXREF + //{ 0x0, "_ZN12CGameTeamSet15ShouldClearTeamEv", mfunc_ptr_cast(&CGameTeamSet::ShouldClearTeam) }, // NOXREF //CGamePlayerZone //virtual func - //{ 0x0, "_ZN15CGamePlayerZone8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGamePlayerZone::KeyValue_) }, - //{ 0x0, "_ZN15CGamePlayerZone4SaveER5CSave", mfunc_ptr_cast(&CGamePlayerZone::Save_) }, - //{ 0x0, "_ZN15CGamePlayerZone7RestoreER8CRestore", mfunc_ptr_cast(&CGamePlayerZone::Restore_) }, - //{ 0x0, "_ZN15CGamePlayerZone3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerZone::Use_) }, + { 0x01D898F0, "_ZN15CGamePlayerZone8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGamePlayerZone::KeyValue_) }, + { 0x01D89850, "_ZN15CGamePlayerZone4SaveER5CSave", mfunc_ptr_cast(&CGamePlayerZone::Save_) }, + { 0x01D898A0, "_ZN15CGamePlayerZone7RestoreER8CRestore", mfunc_ptr_cast(&CGamePlayerZone::Restore_) }, + { 0x01D89A10, "_ZN15CGamePlayerZone3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerZone::Use_) }, //CGamePlayerHurt //virtual func - //{ 0x0, "_ZN15CGamePlayerHurt3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerHurt::Use_) }, + { 0x01D89BE0, "_ZN15CGamePlayerHurt3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerHurt::Use_) }, //non-virtual func //{ 0x0, "_ZN15CGamePlayerHurt12RemoveOnFireEv", mfunc_ptr_cast(&CGamePlayerHurt::RemoveOnFire) }, // NOXREF //CGameCounter //virtual func - //{ 0x0, "_ZN12CGameCounter5SpawnEv", mfunc_ptr_cast(&CGameCounter::Spawn) }, - //{ 0x0, "_ZN12CGameCounter3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameCounter::Use) }, + { 0x01D89CD0, "_ZN12CGameCounter5SpawnEv", mfunc_ptr_cast(&CGameCounter::Spawn_) }, + { 0x01D89D30, "_ZN12CGameCounter3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameCounter::Use_) }, //non-virtual func - //{ 0x0, "_ZN12CGameCounter12RemoveOnFireEv", mfunc_ptr_cast(&CGameCounter::RemoveOnFire) }, // NOXREF - //{ 0x0, "_ZN12CGameCounter11ResetOnFireEv", mfunc_ptr_cast(&CGameCounter::ResetOnFire) }, // NOXREF + //{ 0x0, "_ZN12CGameCounter12RemoveOnFireEv", mfunc_ptr_cast(&CGameCounter::RemoveOnFire) }, // NOXREF + //{ 0x0, "_ZN12CGameCounter11ResetOnFireEv", mfunc_ptr_cast(&CGameCounter::ResetOnFire) }, // NOXREF //{ 0x0, "_ZN12CGameCounter7CountUpEv", mfunc_ptr_cast(&CGameCounter::CountUp) }, // NOXREF //{ 0x0, "_ZN12CGameCounter9CountDownEv", mfunc_ptr_cast(&CGameCounter::CountDown) }, // NOXREF - //{ 0x0, "_ZN12CGameCounter10ResetCountEv", mfunc_ptr_cast(&CGameCounter::ResetCount) }, // NOXREF - //{ 0x0, "_ZN12CGameCounter10CountValueEv", mfunc_ptr_cast(&CGameCounter::CountValue) }, // NOXREF - //{ 0x0, "_ZN12CGameCounter10LimitValueEv", mfunc_ptr_cast(&CGameCounter::LimitValue) }, // NOXREF + //{ 0x0, "_ZN12CGameCounter10ResetCountEv", mfunc_ptr_cast(&CGameCounter::ResetCount) }, // NOXREF + //{ 0x0, "_ZN12CGameCounter10CountValueEv", mfunc_ptr_cast(&CGameCounter::CountValue) }, // NOXREF + //{ 0x0, "_ZN12CGameCounter10LimitValueEv", mfunc_ptr_cast(&CGameCounter::LimitValue) }, // NOXREF //{ 0x0, "_ZN12CGameCounter8HitLimitEv", mfunc_ptr_cast(&CGameCounter::HitLimit) }, // NOXREF - //{ 0x0, "_ZN12CGameCounter13SetCountValueEi", mfunc_ptr_cast(&CGameCounter::SetCountValue) }, // NOXREF - //{ 0x0, "_ZN12CGameCounter15SetInitialValueEi", mfunc_ptr_cast(&CGameCounter::SetInitialValue) }, // NOXREF + //{ 0x0, "_ZN12CGameCounter13SetCountValueEi", mfunc_ptr_cast(&CGameCounter::SetCountValue) }, // NOXREF + //{ 0x0, "_ZN12CGameCounter15SetInitialValueEi", mfunc_ptr_cast(&CGameCounter::SetInitialValue) }, // NOXREF //CGameCounterSet //virtual func - //{ 0x0, "_ZN15CGameCounterSet3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameCounterSet::Use_) }, + { 0x01D89E70, "_ZN15CGameCounterSet3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGameCounterSet::Use_) }, //non-virtual func //{ 0x0, "_ZN15CGameCounterSet12RemoveOnFireEv", mfunc_ptr_cast(&CGameCounterSet::RemoveOnFire) }, // NOXREF //CGamePlayerEquip //virtual func - //{ 0x0, "_ZN16CGamePlayerEquip8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGamePlayerEquip::KeyValue_) }, - //{ 0x0, "_ZN16CGamePlayerEquip5TouchEP11CBaseEntity", mfunc_ptr_cast(&CGamePlayerEquip::Touch_) }, - //{ 0x0, "_ZN16CGamePlayerEquip3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerEquip::Use_) }, + { 0x01D89F10, "_ZN16CGamePlayerEquip8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CGamePlayerEquip::KeyValue_) }, + { 0x01D89FE0, "_ZN16CGamePlayerEquip5TouchEP11CBaseEntity", mfunc_ptr_cast(&CGamePlayerEquip::Touch_) }, + { 0x01D8A0D0, "_ZN16CGamePlayerEquip3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerEquip::Use_) }, //non-virtual func //{ 0x0, "_ZN16CGamePlayerEquip7UseOnlyEv", mfunc_ptr_cast(&CGamePlayerEquip::UseOnly) }, // NOXREF - //{ 0x0, "_ZN16CGamePlayerEquip11EquipPlayerEP11CBaseEntity", mfunc_ptr_cast(&CGamePlayerEquip::EquipPlayer) }, + //{ 0x01D8A070, "_ZN16CGamePlayerEquip11EquipPlayerEP11CBaseEntity", mfunc_ptr_cast(&CGamePlayerEquip::EquipPlayer) }, // NOXREF //CGamePlayerTeam //virtual func - //{ 0x0, "_ZN15CGamePlayerTeam3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerTeam::Use) }, + { 0x01D8A1E0, "_ZN15CGamePlayerTeam3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CGamePlayerTeam::Use_) }, //non-virtual func - //{ 0x0, "_ZN15CGamePlayerTeam12RemoveOnFireEv", mfunc_ptr_cast(&CGamePlayerTeam::RemoveOnFire) }, - //{ 0x0, "_ZN15CGamePlayerTeam16ShouldKillPlayerEv", mfunc_ptr_cast(&CGamePlayerTeam::ShouldKillPlayer) }, - //{ 0x0, "_ZN15CGamePlayerTeam15ShouldGibPlayerEv", mfunc_ptr_cast(&CGamePlayerTeam::ShouldGibPlayer) }, - //{ 0x0, "_ZN15CGamePlayerTeam14TargetTeamNameEPKc", mfunc_ptr_cast(&CGamePlayerTeam::TargetTeamName) }, + //{ 0x0, "_ZN15CGamePlayerTeam12RemoveOnFireEv", mfunc_ptr_cast(&CGamePlayerTeam::RemoveOnFire) }, // NOXREF + //{ 0x0, "_ZN15CGamePlayerTeam16ShouldKillPlayerEv", mfunc_ptr_cast(&CGamePlayerTeam::ShouldKillPlayer) }, // NOXREF + //{ 0x0, "_ZN15CGamePlayerTeam15ShouldGibPlayerEv", mfunc_ptr_cast(&CGamePlayerTeam::ShouldGibPlayer) }, // NOXREF + //{ 0x01D8A180, "_ZN15CGamePlayerTeam14TargetTeamNameEPKc", mfunc_ptr_cast(&CGamePlayerTeam::TargetTeamName) }, // NOXREF #endif // MapRules_Region @@ -1887,255 +1954,242 @@ FunctionHook g_FunctionHooks[] = //CFrictionModifier //virtual func - //{ 0x0, "_ZN17CFrictionModifier5SpawnEv", mfunc_ptr_cast(&CFrictionModifier::Spawn_) }, - //{ 0x0, "_ZN17CFrictionModifier8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFrictionModifier::KeyValue_) }, - //{ 0x0, "_ZN17CFrictionModifier4SaveER5CSave", mfunc_ptr_cast(&CFrictionModifier::Save_) }, - //{ 0x0, "_ZN17CFrictionModifier7RestoreER8CRestore", mfunc_ptr_cast(&CFrictionModifier::Restore_) }, - //{ 0x0, "_ZN17CFrictionModifier10ObjectCapsEv", mfunc_ptr_cast(&CFrictionModifier::ObjectCaps_) }, + { 0x01DBD1A0, "_ZN17CFrictionModifier5SpawnEv", mfunc_ptr_cast(&CFrictionModifier::Spawn_) }, + { 0x01DBD220, "_ZN17CFrictionModifier8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CFrictionModifier::KeyValue_) }, + { 0x01DBD140, "_ZN17CFrictionModifier4SaveER5CSave", mfunc_ptr_cast(&CFrictionModifier::Save_) }, + { 0x01DBD170, "_ZN17CFrictionModifier7RestoreER8CRestore", mfunc_ptr_cast(&CFrictionModifier::Restore_) }, + { 0x01DBD130, "_ZN17CFrictionModifier10ObjectCapsEv", mfunc_ptr_cast(&CFrictionModifier::ObjectCaps_) }, //non-virtual func - //{ 0x01DBD0E0, "func_friction", (size_t)&func_friction }, - //{ 0x0, "_ZN17CFrictionModifier14ChangeFrictionEP11CBaseEntity", mfunc_ptr_cast(&CFrictionModifier::ChangeFriction) }, + { 0x01DBD1F0, "_ZN17CFrictionModifier14ChangeFrictionEP11CBaseEntity", mfunc_ptr_cast(&CFrictionModifier::ChangeFriction) }, //CAutoTrigger //virtual func - //{ 0x0, "_ZN12CAutoTrigger5SpawnEv", mfunc_ptr_cast(&CAutoTrigger::Spawn_) }, - //{ 0x0, "_ZN12CAutoTrigger8PrecacheEv", mfunc_ptr_cast(&CAutoTrigger::Precache_) }, - //{ 0x01DBD340, "_ZN12CAutoTrigger8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CAutoTrigger::KeyValue_) }, - //{ 0x0, "_ZN12CAutoTrigger10ObjectCapsEv", mfunc_ptr_cast(&CAutoTrigger::ObjectCaps_) }, - //{ 0x0, "_ZN12CAutoTrigger4SaveER5CSave", mfunc_ptr_cast(&CAutoTrigger::Save_) }, - //{ 0x0, "_ZN12CAutoTrigger7RestoreER8CRestore", mfunc_ptr_cast(&CAutoTrigger::Restore_) }, - //{ 0x0, "_ZN12CAutoTrigger5ThinkEv", mfunc_ptr_cast(&CAutoTrigger::Think_) }, - //non-virtual func - //{ 0x01DBD280, "trigger_auto", (size_t)&trigger_auto }, + { 0x01DBD400, "_ZN12CAutoTrigger5SpawnEv", mfunc_ptr_cast(&CAutoTrigger::Spawn_) }, + { 0x01DBD410, "_ZN12CAutoTrigger8PrecacheEv", mfunc_ptr_cast(&CAutoTrigger::Precache_) }, + { 0x01DBD340, "_ZN12CAutoTrigger8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CAutoTrigger::KeyValue_) }, + { 0x01DBD2D0, "_ZN12CAutoTrigger10ObjectCapsEv", mfunc_ptr_cast(&CAutoTrigger::ObjectCaps_) }, + { 0x01DBD2E0, "_ZN12CAutoTrigger4SaveER5CSave", mfunc_ptr_cast(&CAutoTrigger::Save_) }, + { 0x01DBD310, "_ZN12CAutoTrigger7RestoreER8CRestore", mfunc_ptr_cast(&CAutoTrigger::Restore_) }, + { 0x01DBD430, "_ZN12CAutoTrigger5ThinkEv", mfunc_ptr_cast(&CAutoTrigger::Think_) }, //CTriggerRelay //virtual func - //{ 0x0, "_ZN13CTriggerRelay5SpawnEv", mfunc_ptr_cast(&CTriggerRelay::Spawn_) }, - //{ 0x0, "_ZN13CTriggerRelay8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerRelay::KeyValue_) }, - //{ 0x0, "_ZN13CTriggerRelay4SaveER5CSave", mfunc_ptr_cast(&CTriggerRelay::Save_) }, - //{ 0x0, "_ZN13CTriggerRelay7RestoreER8CRestore", mfunc_ptr_cast(&CTriggerRelay::Restore_) }, - //{ 0x0, "_ZN13CTriggerRelay10ObjectCapsEv", mfunc_ptr_cast(&CTriggerRelay::ObjectCaps_) }, - //{ 0x0, "_ZN13CTriggerRelay3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerRelay::Use_) }, - //non-virtual func - //{ 0x01DBD480, "trigger_relay", (size_t)&trigger_relay }, + { 0x01DBD5C0, "_ZN13CTriggerRelay5SpawnEv", mfunc_ptr_cast(&CTriggerRelay::Spawn_) }, + { 0x01DBD540, "_ZN13CTriggerRelay8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerRelay::KeyValue_) }, + { 0x01DBD4E0, "_ZN13CTriggerRelay4SaveER5CSave", mfunc_ptr_cast(&CTriggerRelay::Save_) }, + { 0x01DBD510, "_ZN13CTriggerRelay7RestoreER8CRestore", mfunc_ptr_cast(&CTriggerRelay::Restore_) }, + { 0x01DBD4D0, "_ZN13CTriggerRelay10ObjectCapsEv", mfunc_ptr_cast(&CTriggerRelay::ObjectCaps_) }, + { 0x01DBD5D0, "_ZN13CTriggerRelay3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerRelay::Use_) }, //CMultiManager //virtual func - //{ 0x0, "_ZN13CMultiManager5SpawnEv", mfunc_ptr_cast(&CMultiManager::Spawn_) }, - //{ 0x0, "_ZN13CMultiManager7RestartEv", mfunc_ptr_cast(&CMultiManager::Restart_) }, - //{ 0x0, "_ZN13CMultiManager8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMultiManager::KeyValue_) }, - //{ 0x0, "_ZN13CMultiManager4SaveER5CSave", mfunc_ptr_cast(&CMultiManager::Save_) }, - //{ 0x0, "_ZN13CMultiManager7RestoreER8CRestore", mfunc_ptr_cast(&CMultiManager::Restore_) }, - //{ 0x0, "_ZN13CMultiManager10ObjectCapsEv", mfunc_ptr_cast(&CMultiManager::ObjectCaps_) }, - //{ 0x0, "_ZN13CMultiManager9HasTargetEj", mfunc_ptr_cast(&CMultiManager::HasTarget_) }, + { 0x01DBD780, "_ZN13CMultiManager5SpawnEv", mfunc_ptr_cast(&CMultiManager::Spawn_) }, + { 0x01DBD7F0, "_ZN13CMultiManager7RestartEv", mfunc_ptr_cast(&CMultiManager::Restart_) }, + { 0x01DBD6C0, "_ZN13CMultiManager8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CMultiManager::KeyValue_) }, + { 0x01DBD660, "_ZN13CMultiManager4SaveER5CSave", mfunc_ptr_cast(&CMultiManager::Save_) }, + { 0x01DBD690, "_ZN13CMultiManager7RestoreER8CRestore", mfunc_ptr_cast(&CMultiManager::Restore_) }, + { 0x01DBD650, "_ZN13CMultiManager10ObjectCapsEv", mfunc_ptr_cast(&CMultiManager::ObjectCaps_) }, + { 0x01DBD8A0, "_ZN13CMultiManager9HasTargetEj", mfunc_ptr_cast(&CMultiManager::HasTarget_) }, //non-virtual func - //{ 0x01DBD600, "multi_manager", (size_t)&multi_manager }, - //{ 0x0, "_ZN13CMultiManager12ManagerThinkEv", mfunc_ptr_cast(&CMultiManager::ManagerThink) }, - //{ 0x0, "_ZN13CMultiManager10ManagerUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMultiManager::ManagerUse) }, - //{ 0x0, "_ZN13CMultiManager5CloneEv", mfunc_ptr_cast(&CMultiManager::Clone) }, // NOXREF + { 0x01DBD930, "_ZN13CMultiManager12ManagerThinkEv", mfunc_ptr_cast(&CMultiManager::ManagerThink) }, + { 0x01DBDAD0, "_ZN13CMultiManager10ManagerUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CMultiManager::ManagerUse) }, + //{ 0x01DBDA10, "_ZN13CMultiManager5CloneEv", mfunc_ptr_cast(&CMultiManager::Clone) }, // NOXREF //CRenderFxManager //virtual func - //{ 0x0, "_ZN16CRenderFxManager5SpawnEv", mfunc_ptr_cast(&CRenderFxManager::Spawn_) }, - //{ 0x0, "_ZN16CRenderFxManager3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CRenderFxManager::Use_) }, - //non-virtual func - //{ 0x01DBDBF0, "env_render", (size_t)&env_render }, + { 0x01DBDC40, "_ZN16CRenderFxManager5SpawnEv", mfunc_ptr_cast(&CRenderFxManager::Spawn_) }, + { 0x01DBDC50, "_ZN16CRenderFxManager3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CRenderFxManager::Use_) }, //CBaseTrigger //virtual func - //{ 0x0, "_ZN12CBaseTrigger8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseTrigger::KeyValue_) }, - //{ 0x0, "_ZN12CBaseTrigger10ObjectCapsEv", mfunc_ptr_cast(&CBaseTrigger::ObjectCaps_) }, + { 0x01DBDE40, "_ZN12CBaseTrigger8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CBaseTrigger::KeyValue_) }, + { 0x01DBDD80, "_ZN12CBaseTrigger10ObjectCapsEv", mfunc_ptr_cast(&CBaseTrigger::ObjectCaps_) }, //non-virtual func - //{ 0x01DBDD30, "trigger", (size_t)&trigger }, - //{ 0x0, "_ZN12CBaseTrigger13TeleportTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::TeleportTouch) }, - //{ 0x0, "_ZN12CBaseTrigger10MultiTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::MultiTouch) }, - //{ 0x0, "_ZN12CBaseTrigger9HurtTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::HurtTouch) }, - //{ 0x0, "_ZN12CBaseTrigger12CDAudioTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::CDAudioTouch) }, // NOXREF - //{ 0x0, "_ZN12CBaseTrigger20ActivateMultiTriggerEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::ActivateMultiTrigger) }, - //{ 0x0, "_ZN12CBaseTrigger13MultiWaitOverEv", mfunc_ptr_cast(&CBaseTrigger::MultiWaitOver) }, - //{ 0x0, "_ZN12CBaseTrigger10CounterUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseTrigger::CounterUse) }, - //{ 0x0, "_ZN12CBaseTrigger9ToggleUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseTrigger::ToggleUse) }, - //{ 0x0, "_ZN12CBaseTrigger11InitTriggerEv", mfunc_ptr_cast(&CBaseTrigger::InitTrigger) }, + //{ 0x01DBDD90, "_ZN12CBaseTrigger11InitTriggerEv", mfunc_ptr_cast(&CBaseTrigger::InitTrigger) }, // NOXREF + { 0x01DC06D0, "_ZN12CBaseTrigger13TeleportTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::TeleportTouch) }, + { 0x01DBF070, "_ZN12CBaseTrigger10MultiTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::MultiTouch) }, + { 0x01DBEC40, "_ZN12CBaseTrigger9HurtTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::HurtTouch) }, + //{ 0x0, "_ZN12CBaseTrigger12CDAudioTouchEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::CDAudioTouch) }, // NOXREF + { 0x01DBF0E0, "_ZN12CBaseTrigger20ActivateMultiTriggerEP11CBaseEntity", mfunc_ptr_cast(&CBaseTrigger::ActivateMultiTrigger) }, + { 0x01DBF290, "_ZN12CBaseTrigger13MultiWaitOverEv", mfunc_ptr_cast(&CBaseTrigger::MultiWaitOver) }, + { 0x01DBF2A0, "_ZN12CBaseTrigger10CounterUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseTrigger::CounterUse) }, + { 0x01DBEBE0, "_ZN12CBaseTrigger9ToggleUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBaseTrigger::ToggleUse) }, //CTriggerHurt //virtual func - //{ 0x0, "_ZN12CTriggerHurt5SpawnEv", mfunc_ptr_cast(&CTriggerHurt::Spawn_) }, + { 0x01DBE810, "_ZN12CTriggerHurt5SpawnEv", mfunc_ptr_cast(&CTriggerHurt::Spawn_) }, //non-virtual func - //{ 0x01DBDF00, "trigger_hurt", (size_t)&trigger_hurt }, - //{ 0x0, "_ZN12CTriggerHurt14RadiationThinkEv", mfunc_ptr_cast(&CTriggerHurt::RadiationThink) }, + { 0x01DBE940, "_ZN12CTriggerHurt14RadiationThinkEv", mfunc_ptr_cast(&CTriggerHurt::RadiationThink) }, //CTriggerMonsterJump //virtual func - //{ 0x0, "_ZN19CTriggerMonsterJump5SpawnEv", mfunc_ptr_cast(&CTriggerMonsterJump::Spawn_) }, - //{ 0x0, "_ZN19CTriggerMonsterJump5ThinkEv", mfunc_ptr_cast(&CTriggerMonsterJump::Think_) }, - //{ 0x0, "_ZN19CTriggerMonsterJump5TouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerMonsterJump::Touch_) }, - //non-virtual func - //{ 0x01DBDF50, "trigger_monsterjump", (size_t)&trigger_monsterjump }, + { 0x01DBDFA0, "_ZN19CTriggerMonsterJump5SpawnEv", mfunc_ptr_cast(&CTriggerMonsterJump::Spawn_) }, + { 0x01DBE0B0, "_ZN19CTriggerMonsterJump5ThinkEv", mfunc_ptr_cast(&CTriggerMonsterJump::Think_) }, + { 0x01DBE0E0, "_ZN19CTriggerMonsterJump5TouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerMonsterJump::Touch_) }, //CTriggerCDAudio //virtual func - //{ 0x0, "_ZN15CTriggerCDAudio5SpawnEv", mfunc_ptr_cast(&CTriggerCDAudio::Spawn_) }, - //{ 0x0, "_ZN15CTriggerCDAudio5TouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerCDAudio::Touch_) }, - //{ 0x0, "_ZN15CTriggerCDAudio3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerCDAudio::Use_) }, + { 0x01DBE270, "_ZN15CTriggerCDAudio5SpawnEv", mfunc_ptr_cast(&CTriggerCDAudio::Spawn_) }, + { 0x01DBE1C0, "_ZN15CTriggerCDAudio5TouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerCDAudio::Touch_) }, + { 0x01DBE320, "_ZN15CTriggerCDAudio3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerCDAudio::Use_) }, //non-virtual func - //{ 0x01DBE170, "trigger_cdaudio", (size_t)&trigger_cdaudio }, - //{ 0x0, "_ZN15CTriggerCDAudio9PlayTrackEv", mfunc_ptr_cast(&CTriggerCDAudio::PlayTrack) }, + //{ 0x01DBE430, "_ZN15CTriggerCDAudio9PlayTrackEv", mfunc_ptr_cast(&CTriggerCDAudio::PlayTrack) }, // NOXREF + //{ 0x01DBE3B0, "_Z11PlayCDTracki", (size_t)&PlayCDTrack }, // NOXREF //CTargetCDAudio //virtual func - //{ 0x0, "_ZN14CTargetCDAudio5SpawnEv", mfunc_ptr_cast(&CTargetCDAudio::Spawn_) }, - //{ 0x0, "_ZN14CTargetCDAudio8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTargetCDAudio::KeyValue_) }, - //{ 0x0, "_ZN14CTargetCDAudio5ThinkEv", mfunc_ptr_cast(&CTargetCDAudio::Think_) }, - //{ 0x0, "_ZN14CTargetCDAudio3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTargetCDAudio::Use_) }, + { 0x01DBE560, "_ZN14CTargetCDAudio5SpawnEv", mfunc_ptr_cast(&CTargetCDAudio::Spawn_) }, + { 0x01DBE510, "_ZN14CTargetCDAudio8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTargetCDAudio::KeyValue_) }, + { 0x01DBE640, "_ZN14CTargetCDAudio5ThinkEv", mfunc_ptr_cast(&CTargetCDAudio::Think_) }, + { 0x01DBE5A0, "_ZN14CTargetCDAudio3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTargetCDAudio::Use_) }, //non-virtual func - //{ 0x01DBE4C0, "target_cdaudio", (size_t)&target_cdaudio }, - //{ 0x0, "_Z11PlayCDTracki", (size_t)&PlayCDTrack }, - //{ 0x0, "_ZN14CTargetCDAudio4PlayEv", mfunc_ptr_cast(&CTargetCDAudio::Play) }, + //{ 0x01DBE760, "_ZN14CTargetCDAudio4PlayEv", mfunc_ptr_cast(&CTargetCDAudio::Play) }, // NOXREF //CTriggerMultiple //virtual func - //{ 0x0, "_ZN16CTriggerMultiple5SpawnEv", mfunc_ptr_cast(&CTriggerMultiple::Spawn_) }, - //non-virtual func - //{ 0x01DBEE40, "trigger_multiple", (size_t)&trigger_multiple }, + { 0x01DBEE90, "_ZN16CTriggerMultiple5SpawnEv", mfunc_ptr_cast(&CTriggerMultiple::Spawn_) }, //CTriggerOnce //virtual func - //{ 0x0, "_ZN12CTriggerOnce5SpawnEv", mfunc_ptr_cast(&CTriggerOnce::Spawn_) }, - //non-virtual func - //{ 0x01DBEF60, "trigger_once", (size_t)&trigger_once }, + { 0x01DBEFB0, "_ZN12CTriggerOnce5SpawnEv", mfunc_ptr_cast(&CTriggerOnce::Spawn_) }, //CTriggerCounter //virtual func - //{ 0x0, "_ZN15CTriggerCounter5SpawnEv", mfunc_ptr_cast(&CTriggerCounter::Spawn_) }, - //non-virtual func - //{ 0x01DBF3C0, "trigger_counter", (size_t)&trigger_counter }, + { 0x01DBF410, "_ZN15CTriggerCounter5SpawnEv", mfunc_ptr_cast(&CTriggerCounter::Spawn_) }, //CTriggerVolume //virtual func - //{ 0x0, "_ZN14CTriggerVolume5SpawnEv", mfunc_ptr_cast(&CTriggerVolume::Spawn_) }, - //non-virtual func - //{ 0x01DBF440, "trigger_transition", (size_t)&trigger_transition }, + { 0x01DBF490, "_ZN14CTriggerVolume5SpawnEv", mfunc_ptr_cast(&CTriggerVolume::Spawn_) }, //CFireAndDie //virtual func - //{ 0x0, "_ZN11CFireAndDie5SpawnEv", mfunc_ptr_cast(&CFireAndDie::Spawn_) }, - //{ 0x0, "_ZN11CFireAndDie8PrecacheEv", mfunc_ptr_cast(&CFireAndDie::Precache_) }, - //{ 0x0, "_ZN11CFireAndDie10ObjectCapsEv", mfunc_ptr_cast(&CFireAndDie::ObjectCaps_) }, - //{ 0x0, "_ZN11CFireAndDie5ThinkEv", mfunc_ptr_cast(&CFireAndDie::Think) }, - //non-virtual func - //{ 0x01DBF4F0, "fireanddie", (size_t)&fireanddie }, + { 0x01DBF550, "_ZN11CFireAndDie5SpawnEv", mfunc_ptr_cast(&CFireAndDie::Spawn_) }, + { 0x01DBF5B0, "_ZN11CFireAndDie8PrecacheEv", mfunc_ptr_cast(&CFireAndDie::Precache_) }, + { 0x01DBF540, "_ZN11CFireAndDie10ObjectCapsEv", mfunc_ptr_cast(&CFireAndDie::ObjectCaps_) }, + { 0x01DBF5D0, "_ZN11CFireAndDie5ThinkEv", mfunc_ptr_cast(&CFireAndDie::Think_) }, //CChangeLevel //virtual func - //{ 0x0, "_ZN12CChangeLevel5SpawnEv", mfunc_ptr_cast(&CChangeLevel::Spawn_) }, - //{ 0x0, "_ZN12CChangeLevel8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CChangeLevel::KeyValue_) }, - //{ 0x0, "_ZN12CChangeLevel4SaveER5CSave", mfunc_ptr_cast(&CChangeLevel::Save_) }, - //{ 0x0, "_ZN12CChangeLevel7RestoreER8CRestore", mfunc_ptr_cast(&CChangeLevel::Restore_) }, + { 0x01DBF7E0, "_ZN12CChangeLevel5SpawnEv", mfunc_ptr_cast(&CChangeLevel::Spawn_) }, + { 0x01DBF6A0, "_ZN12CChangeLevel8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CChangeLevel::KeyValue_) }, + { 0x01DBF640, "_ZN12CChangeLevel4SaveER5CSave", mfunc_ptr_cast(&CChangeLevel::Save_) }, + { 0x01DBF670, "_ZN12CChangeLevel7RestoreER8CRestore", mfunc_ptr_cast(&CChangeLevel::Restore_) }, //non-virtual func - //{ 0x01DBF5F0, "trigger_changelevel", (size_t)&trigger_changelevel }, { 0x01DBFD80, "_Z15BuildChangeListP9LEVELLISTi", (size_t)&BuildChangeList }, - //{ 0x0, "_Z9NextLevelv", (size_t)&NextLevel }, - //{ 0x0, "_ZN12CChangeLevel14UseChangeLevelEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CChangeLevel::UseChangeLevel) }, - //{ 0x0, "_ZN12CChangeLevel18TriggerChangeLevelEv", mfunc_ptr_cast(&CChangeLevel::TriggerChangeLevel) }, // NOXREF - //{ 0x0, "_ZN12CChangeLevel18ExecuteChangeLevelEv", mfunc_ptr_cast(&CChangeLevel::ExecuteChangeLevel) }, - //{ 0x0, "_ZN12CChangeLevel16TouchChangeLevelEP11CBaseEntity", mfunc_ptr_cast(&CChangeLevel::TouchChangeLevel) }, - //{ 0x0, "_ZN12CChangeLevel14ChangeLevelNowEP11CBaseEntity", mfunc_ptr_cast(&CChangeLevel::ChangeLevelNow) }, - //{ 0x01DBF990, "_ZN12CChangeLevel12FindLandmarkEPKc", mfunc_ptr_cast(&CChangeLevel::FindLandmark) }, // NOXREF + //{ 0x01DC0150, "_Z9NextLevelv", (size_t)&NextLevel }, // NOXREF + { 0x01DBFA10, "_ZN12CChangeLevel14UseChangeLevelEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CChangeLevel::UseChangeLevel) }, + //{ 0x0, "_ZN12CChangeLevel18TriggerChangeLevelEv", mfunc_ptr_cast(&CChangeLevel::TriggerChangeLevel) }, // NOXREF + { 0x01DBF950, "_ZN12CChangeLevel18ExecuteChangeLevelEv", mfunc_ptr_cast(&CChangeLevel::ExecuteChangeLevel) }, + { 0x01DBFC60, "_ZN12CChangeLevel16TouchChangeLevelEP11CBaseEntity", mfunc_ptr_cast(&CChangeLevel::TouchChangeLevel) }, + { 0x01DBFA20, "_ZN12CChangeLevel14ChangeLevelNowEP11CBaseEntity", mfunc_ptr_cast(&CChangeLevel::ChangeLevelNow) }, + //{ 0x01DBF990, "_ZN12CChangeLevel12FindLandmarkEPKc", mfunc_ptr_cast(&CChangeLevel::FindLandmark) }, // NOXREF { 0x01DBFE50, "_ZN12CChangeLevel10ChangeListEP9LEVELLISTi", mfunc_ptr_cast(&CChangeLevel::ChangeList) }, { 0x01DBFCA0, "_ZN12CChangeLevel19AddTransitionToListEP9LEVELLISTiPKcS3_P7edict_s", mfunc_ptr_cast(&CChangeLevel::AddTransitionToList) }, { 0x01DBFD90, "_ZN12CChangeLevel18InTransitionVolumeEP11CBaseEntityPc", mfunc_ptr_cast(&CChangeLevel::InTransitionVolume) }, //CLadder //virtual func - //{ 0x0, "_ZN7CLadder5SpawnEv", mfunc_ptr_cast(&CLadder::Spawn_) }, - //{ 0x0, "_ZN7CLadder8PrecacheEv", mfunc_ptr_cast(&CLadder::Precache_) }, - //{ 0x0, "_ZN7CLadder8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CLadder::KeyValue_) }, - //non-virtual func - //{ 0x01DC02A0, "func_ladder", (size_t)&func_ladder }, + { 0x01DC0370, "_ZN7CLadder5SpawnEv", mfunc_ptr_cast(&CLadder::Spawn_) }, + { 0x01DC0300, "_ZN7CLadder8PrecacheEv", mfunc_ptr_cast(&CLadder::Precache_) }, + { 0x01DC02F0, "_ZN7CLadder8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CLadder::KeyValue_) }, //CTriggerPush //virtual func - //{ 0x0, "_ZN12CTriggerPush5SpawnEv", mfunc_ptr_cast(&CTriggerPush::Spawn_) }, - //{ 0x0, "_ZN12CTriggerPush8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerPush::KeyValue_) }, - //{ 0x0, "_ZN12CTriggerPush5TouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerPush::Touch_) }, - //non-virtual func - //{ 0x01DC03C0, "trigger_push", (size_t)&trigger_push }, + { 0x01DC0420, "_ZN12CTriggerPush5SpawnEv", mfunc_ptr_cast(&CTriggerPush::Spawn_) }, + { 0x01DC0410, "_ZN12CTriggerPush8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerPush::KeyValue_) }, + { 0x01DC0560, "_ZN12CTriggerPush5TouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerPush::Touch_) }, //CTriggerTeleport //virtual func - //{ 0x0, "_ZN16CTriggerTeleport5SpawnEv", mfunc_ptr_cast(&CTriggerTeleport::Spawn_) }, - //non-virtual func - //{ 0x01DC0860, "trigger_teleport", (size_t)&trigger_teleport }, - //{ 0x01DC0970, "info_teleport_destination", (size_t)&info_teleport_destination }, + { 0x01DC08B0, "_ZN16CTriggerTeleport5SpawnEv", mfunc_ptr_cast(&CTriggerTeleport::Spawn_) }, //CBuyZone //virtual func - //{ 0x0, "_ZN8CBuyZone5SpawnEv", mfunc_ptr_cast(&CBuyZone::Spawn_) }, + { 0x01DC0A10, "_ZN8CBuyZone5SpawnEv", mfunc_ptr_cast(&CBuyZone::Spawn_) }, //non-virtual func - //{ 0x01DC09C0, "func_buyzone", (size_t)&func_buyzone }, - //{ 0x0, "_ZN8CBuyZone8BuyTouchEP11CBaseEntity", mfunc_ptr_cast(&CBuyZone::BuyTouch) }, + { 0x01DC0B00, "_ZN8CBuyZone8BuyTouchEP11CBaseEntity", mfunc_ptr_cast(&CBuyZone::BuyTouch) }, //CBombTarget //virtual func - //{ 0x0, "_ZN11CBombTarget5SpawnEv", mfunc_ptr_cast(&CBombTarget::Spawn_) }, + { 0x01DC0B90, "_ZN11CBombTarget5SpawnEv", mfunc_ptr_cast(&CBombTarget::Spawn_) }, //non-virtual func - //{ 0x01DC0B40, "func_bomb_target", (size_t)&func_bomb_target }, - //{ 0x0, "_ZN11CBombTarget15BombTargetTouchEP11CBaseEntity", mfunc_ptr_cast(&CBombTarget::BombTargetTouch) }, - //{ 0x0, "_ZN11CBombTarget13BombTargetUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBombTarget::BombTargetUse) }, + { 0x01DC0C50, "_ZN11CBombTarget15BombTargetTouchEP11CBaseEntity", mfunc_ptr_cast(&CBombTarget::BombTargetTouch) }, + { 0x01DC0CA0, "_ZN11CBombTarget13BombTargetUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CBombTarget::BombTargetUse) }, //CHostageRescue //virtual func - //{ 0x0, "_ZN14CHostageRescue5SpawnEv", mfunc_ptr_cast(&CHostageRescue::Spawn_) }, + { 0x01DC0D00, "_ZN14CHostageRescue5SpawnEv", mfunc_ptr_cast(&CHostageRescue::Spawn_) }, //non-virtual func - //{ 0x01DC0CB0, "func_hostage_rescue", (size_t)&func_hostage_rescue }, - //{ 0x0, "_ZN14CHostageRescue18HostageRescueTouchEP11CBaseEntity", mfunc_ptr_cast(&CHostageRescue::HostageRescueTouch) }, + { 0x01DC0DC0, "_ZN14CHostageRescue18HostageRescueTouchEP11CBaseEntity", mfunc_ptr_cast(&CHostageRescue::HostageRescueTouch) }, //CEscapeZone //virtual func - //{ 0x0, "_ZN11CEscapeZone5SpawnEv", mfunc_ptr_cast(&CEscapeZone::Spawn_) }, + { 0x01DC0E70, "_ZN11CEscapeZone5SpawnEv", mfunc_ptr_cast(&CEscapeZone::Spawn_) }, //non-virtual func - //{ 0x01DC0E20, "func_escapezone", (size_t)&func_escapezone }, - //{ 0x0, "_ZN11CEscapeZone11EscapeTouchEP11CBaseEntity", mfunc_ptr_cast(&CEscapeZone::EscapeTouch) }, + { 0x01DC0F30, "_ZN11CEscapeZone11EscapeTouchEP11CBaseEntity", mfunc_ptr_cast(&CEscapeZone::EscapeTouch) }, //CVIP_SafetyZone //virtual func - //{ 0x0, "_ZN15CVIP_SafetyZone5SpawnEv", mfunc_ptr_cast(&CVIP_SafetyZone::Spawn_) }, + { 0x01DC10A0, "_ZN15CVIP_SafetyZone5SpawnEv", mfunc_ptr_cast(&CVIP_SafetyZone::Spawn_) }, //non-virtual func - //{ 0x01DC1050, "func_vip_safetyzone", (size_t)&func_vip_safetyzone }, - //{ 0x0, "_ZN15CVIP_SafetyZone15VIP_SafetyTouchEP11CBaseEntity", mfunc_ptr_cast(&CVIP_SafetyZone::VIP_SafetyTouch) }, + { 0x01DC1160, "_ZN15CVIP_SafetyZone15VIP_SafetyTouchEP11CBaseEntity", mfunc_ptr_cast(&CVIP_SafetyZone::VIP_SafetyTouch) }, //CTriggerSave //virtual func - //{ 0x0, "_ZN12CTriggerSave5SpawnEv", mfunc_ptr_cast(&CTriggerSave::Spawn_) }, + { 0x01DC1240, "_ZN12CTriggerSave5SpawnEv", mfunc_ptr_cast(&CTriggerSave::Spawn_) }, //non-virtual func - //{ 0x01DC11F0, "trigger_autosave", (size_t)&trigger_autosave }, - //{ 0x0, "_ZN12CTriggerSave9SaveTouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerSave::SaveTouch) }, + { 0x01DC1320, "_ZN12CTriggerSave9SaveTouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerSave::SaveTouch) }, //CTriggerEndSection //virtual func - //{ 0x0, "_ZN18CTriggerEndSection5SpawnEv", mfunc_ptr_cast(&CTriggerEndSection::Spawn_) }, - //{ 0x0, "_ZN18CTriggerEndSection8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerEndSection::KeyValue_) }, + { 0x01DC1410, "_ZN18CTriggerEndSection5SpawnEv", mfunc_ptr_cast(&CTriggerEndSection::Spawn_) }, + { 0x01DC1550, "_ZN18CTriggerEndSection8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerEndSection::KeyValue_) }, //non-virtual func - //{ 0x01DC1370, "trigger_endsection", (size_t)&trigger_endsection }, - //{ 0x0, "_ZN18CTriggerEndSection15EndSectionTouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerEndSection::EndSectionTouch) }, - //{ 0x0, "_ZN18CTriggerEndSection13EndSectionUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerEndSection::EndSectionUse) }, + { 0x01DC13C0, "_ZN18CTriggerEndSection15EndSectionTouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerEndSection::EndSectionTouch) }, + { 0x01DC1500, "_ZN18CTriggerEndSection13EndSectionUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerEndSection::EndSectionUse) }, //CTriggerGravity //virtual func - //{ 0x0, "_ZN15CTriggerGravity5SpawnEv", mfunc_ptr_cast(&CTriggerGravity::Spawn_) }, + { 0x01DC15F0, "_ZN15CTriggerGravity5SpawnEv", mfunc_ptr_cast(&CTriggerGravity::Spawn_) }, //non-virtual func - //{ 0x01DC15A0, "trigger_gravity", (size_t)&trigger_gravity }, - //{ 0x0, "_ZN15CTriggerGravity12GravityTouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerGravity::GravityTouch) }, + { 0x01DC16B0, "_ZN15CTriggerGravity12GravityTouchEP11CBaseEntity", mfunc_ptr_cast(&CTriggerGravity::GravityTouch) }, //CTriggerChangeTarget //virtual func - //{ 0x0, "_ZN20CTriggerChangeTarget5SpawnEv", mfunc_ptr_cast(&CTriggerChangeTarget::Spawn_) }, - //{ 0x0, "_ZN20CTriggerChangeTarget8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerChangeTarget::KeyValue_) }, - //{ 0x0, "_ZN20CTriggerChangeTarget4SaveER5CSave", mfunc_ptr_cast(&CTriggerChangeTarget::Save_) }, - //{ 0x0, "_ZN20CTriggerChangeTarget7RestoreER8CRestore", mfunc_ptr_cast(&CTriggerChangeTarget::Restore_) }, - //{ 0x0, "_ZN20CTriggerChangeTarget10ObjectCapsEv", mfunc_ptr_cast(&CTriggerChangeTarget::ObjectCaps_) }, - //{ 0x0, "_ZN20CTriggerChangeTarget3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerChangeTarget::Use_) }, - //non-virtual func - //{ 0x01DC16E0, "trigger_changetarget", (size_t)&trigger_changetarget }, + { 0x01DC17F0, "_ZN20CTriggerChangeTarget5SpawnEv", mfunc_ptr_cast(&CTriggerChangeTarget::Spawn_) }, + { 0x01DC17A0, "_ZN20CTriggerChangeTarget8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerChangeTarget::KeyValue_) }, + { 0x01DC1740, "_ZN20CTriggerChangeTarget4SaveER5CSave", mfunc_ptr_cast(&CTriggerChangeTarget::Save_) }, + { 0x01DC1770, "_ZN20CTriggerChangeTarget7RestoreER8CRestore", mfunc_ptr_cast(&CTriggerChangeTarget::Restore_) }, + { 0x01DC1730, "_ZN20CTriggerChangeTarget10ObjectCapsEv", mfunc_ptr_cast(&CTriggerChangeTarget::ObjectCaps_) }, + { 0x01DC1800, "_ZN20CTriggerChangeTarget3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerChangeTarget::Use_) }, //CTriggerCamera //virtual func - //{ 0x0, "_ZN14CTriggerCamera5SpawnEv", mfunc_ptr_cast(&CTriggerCamera::Spawn_) }, - //{ 0x0, "_ZN14CTriggerCamera8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerCamera::KeyValue_) }, - //{ 0x0, "_ZN14CTriggerCamera4SaveER5CSave", mfunc_ptr_cast(&CTriggerCamera::Save_) }, - //{ 0x0, "_ZN14CTriggerCamera7RestoreER8CRestore", mfunc_ptr_cast(&CTriggerCamera::Restore_) }, - //{ 0x0, "_ZN14CTriggerCamera10ObjectCapsEv", mfunc_ptr_cast(&CTriggerCamera::ObjectCap_s) }, - //{ 0x0, "_ZN14CTriggerCamera3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerCamera::Use_) }, + { 0x01DC1920, "_ZN14CTriggerCamera5SpawnEv", mfunc_ptr_cast(&CTriggerCamera::Spawn_) }, + { 0x01DC19A0, "_ZN14CTriggerCamera8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CTriggerCamera::KeyValue_) }, + { 0x01DC18C0, "_ZN14CTriggerCamera4SaveER5CSave", mfunc_ptr_cast(&CTriggerCamera::Save_) }, + { 0x01DC18F0, "_ZN14CTriggerCamera7RestoreER8CRestore", mfunc_ptr_cast(&CTriggerCamera::Restore_) }, + { 0x01DC18B0, "_ZN14CTriggerCamera10ObjectCapsEv", mfunc_ptr_cast(&CTriggerCamera::ObjectCaps_) }, + { 0x01DC1A90, "_ZN14CTriggerCamera3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CTriggerCamera::Use_) }, //non-virtual func - //{ 0x01DC1860, "trigger_camera", (size_t)&trigger_camera }, - //{ 0x0, "_ZN14CTriggerCamera12FollowTargetEv", mfunc_ptr_cast(&CTriggerCamera::FollowTarget) }, - //{ 0x0, "_ZN14CTriggerCamera4MoveEv", mfunc_ptr_cast(&CTriggerCamera::Move) }, + { 0x01DC1DC0, "_ZN14CTriggerCamera12FollowTargetEv", mfunc_ptr_cast(&CTriggerCamera::FollowTarget) }, + { 0x01DC20A0, "_ZN14CTriggerCamera4MoveEv", mfunc_ptr_cast(&CTriggerCamera::Move) }, //CWeather //virtual func - //{ 0x0, "_ZN8CWeather5SpawnEv", mfunc_ptr_cast(&CWeather::Spawn_) }, - //non-virtual func - //{ 0x01DC2350, "env_snow", (size_t)&env_snow }, - //{ 0x01DC23A0, "func_snow", (size_t)&func_snow }, - //{ 0x01DC23F0, "env_rain", (size_t)&env_rain }, - //{ 0x01DC2440, "func_rain", (size_t)&func_rain }, + { 0x01DC2490, "_ZN8CWeather5SpawnEv", mfunc_ptr_cast(&CWeather::Spawn_) }, //CClientFog //virtual func - //{ 0x0, "_ZN10CClientFog5SpawnEv", mfunc_ptr_cast(&CClientFog::Spawn_) }, - //{ 0x0, "_ZN10CClientFog8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CClientFog::KeyValue) }, - //non-virtual func - //{ 0x01DC2610, "env_fog", (size_t)&env_fog }, + { 0x01DC25E0, "_ZN10CClientFog5SpawnEv", mfunc_ptr_cast(&CClientFog::Spawn_) }, + { 0x01DC2560, "_ZN10CClientFog8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CClientFog::KeyValue_) }, + +//linked objects + { 0x01DBD0E0, "func_friction", (size_t)&func_friction }, + { 0x01DBD280, "trigger_auto", (size_t)&trigger_auto }, + { 0x01DBD480, "trigger_relay", (size_t)&trigger_relay }, + { 0x01DBD600, "multi_manager", (size_t)&multi_manager }, + { 0x01DBDBF0, "env_render", (size_t)&env_render }, + { 0x01DBDD30, "trigger", (size_t)&trigger }, + { 0x01DBDF00, "trigger_hurt", (size_t)&trigger_hurt }, + { 0x01DBDF50, "trigger_monsterjump", (size_t)&trigger_monsterjump }, + { 0x01DBE170, "trigger_cdaudio", (size_t)&trigger_cdaudio }, + { 0x01DBE4C0, "target_cdaudio", (size_t)&target_cdaudio }, + { 0x01DBEE40, "trigger_multiple", (size_t)&trigger_multiple }, + { 0x01DBEF60, "trigger_once", (size_t)&trigger_once }, + { 0x01DBF3C0, "trigger_counter", (size_t)&trigger_counter }, + { 0x01DBF440, "trigger_transition", (size_t)&trigger_transition }, + { 0x01DBF4F0, "fireanddie", (size_t)&fireanddie }, + { 0x01DBF5F0, "trigger_changelevel", (size_t)&trigger_changelevel }, + { 0x01DC02A0, "func_ladder", (size_t)&func_ladder }, + { 0x01DC03C0, "trigger_push", (size_t)&trigger_push }, + { 0x01DC0860, "trigger_teleport", (size_t)&trigger_teleport }, + { 0x01DC0970, "info_teleport_destination", (size_t)&info_teleport_destination }, + { 0x01DC09C0, "func_buyzone", (size_t)&func_buyzone }, + { 0x01DC0B40, "func_bomb_target", (size_t)&func_bomb_target }, + { 0x01DC0CB0, "func_hostage_rescue", (size_t)&func_hostage_rescue }, + { 0x01DC0E20, "func_escapezone", (size_t)&func_escapezone }, + { 0x01DC1050, "func_vip_safetyzone", (size_t)&func_vip_safetyzone }, + { 0x01DC11F0, "trigger_autosave", (size_t)&trigger_autosave }, + { 0x01DC1370, "trigger_endsection", (size_t)&trigger_endsection }, + { 0x01DC15A0, "trigger_gravity", (size_t)&trigger_gravity }, + { 0x01DC16E0, "trigger_changetarget", (size_t)&trigger_changetarget }, + { 0x01DC1860, "trigger_camera", (size_t)&trigger_camera }, + { 0x01DC2350, "env_snow", (size_t)&env_snow }, + { 0x01DC23A0, "func_snow", (size_t)&func_snow }, + { 0x01DC23F0, "env_rain", (size_t)&env_rain }, + { 0x01DC2440, "func_rain", (size_t)&func_rain }, + { 0x01DC2610, "env_fog", (size_t)&env_fog }, #endif // Triggers_Region @@ -2159,6 +2213,7 @@ FunctionHook g_FunctionHooks[] = #endif // SharedUtil_Region #ifndef World_Region + //virtual func { 0x01DD1750, "_ZN7CCorpse10ObjectCapsEv", mfunc_ptr_cast(&CCorpse::ObjectCaps_) }, //non-virtual func @@ -2180,15 +2235,14 @@ FunctionHook g_FunctionHooks[] = //{ 0x01DD1AB0, "_ZN12CGlobalState7RestoreER8CRestore", mfunc_ptr_cast(&CGlobalState::Restore) }, // NOXREF { 0x01DD1BD0, "_ZN12CGlobalState12EntityUpdateEjj", mfunc_ptr_cast(&CGlobalState::EntityUpdate) }, //{ 0x01DD1C50, "_ZN12CGlobalState11ClearStatesEv", mfunc_ptr_cast(&CGlobalState::ClearStates) }, // NOXREF - { 0x01DD1C80, "_Z15SaveGlobalStateP13saverestore_s", (size_t)&SaveGlobalState }, { 0x01DD1D00, "_Z18RestoreGlobalStateP13saverestore_s", (size_t)&RestoreGlobalState }, { 0x01DD1E50, "_Z16ResetGlobalStatev", (size_t)&ResetGlobalState }, - //linked objects { 0x01DD13D0, "infodecal", (size_t)&infodecal }, { 0x01DD1700, "bodyque", (size_t)&bodyque }, { 0x01DD1E90, "worldspawn", (size_t)&worldspawn }, + #endif // World_Region #ifndef Graph_Region @@ -2208,51 +2262,67 @@ FunctionHook g_FunctionHooks[] = //CSound //non-virtual func - //{ 0x0, "_ZN6CSound5ClearEv", mfunc_ptr_cast(&CSound::Clear) }, + //{ 0x01DBA520, "_ZN6CSound5ClearEv", mfunc_ptr_cast(&CSound::Clear) }, // NOXREF { 0x01DBA560, "_ZN6CSound5ResetEv", mfunc_ptr_cast(&CSound::Reset) }, - //{ 0x0, "_ZN6CSound8FIsSoundEv", mfunc_ptr_cast(&CSound::FIsSound) }, - //{ 0x0, "_ZN6CSound8FIsScentEv", mfunc_ptr_cast(&CSound::FIsScent) }, + //{ 0x01DBA590, "_ZN6CSound8FIsSoundEv", mfunc_ptr_cast(&CSound::FIsSound) }, // NOXREF + //{ 0x01DBA5A0, "_ZN6CSound8FIsScentEv", mfunc_ptr_cast(&CSound::FIsScent) }, // NOXREF + //linked objects + { 0x01DBA4D0, "soundent", (size_t)&soundent }, //CSoundEnt //virtual func - //{ 0x0, "_ZN9CSoundEnt5SpawnEv", mfunc_ptr_cast(&CSoundEnt::Spawn_) }, - //{ 0x0, "_ZN9CSoundEnt8PrecacheEv", mfunc_ptr_cast(&CSoundEnt::Precache_) }, - //{ 0x0, "_ZN9CSoundEnt10ObjectCapsEv", mfunc_ptr_cast(&CSoundEnt::ObjectCaps_) }, - //{ 0x0, "_ZN9CSoundEnt5ThinkEv", mfunc_ptr_cast(&CSoundEnt::Think_) }, + { 0x01DBA5B0, "_ZN9CSoundEnt5SpawnEv", mfunc_ptr_cast(&CSoundEnt::Spawn_) }, + { 0x01DBA760, "_ZN9CSoundEnt8PrecacheEv", mfunc_ptr_cast(&CSoundEnt::Precache_) }, + { 0x01DBAB10, "_ZN9CSoundEnt10ObjectCapsEv", mfunc_ptr_cast(&CSoundEnt::ObjectCaps_) }, + { 0x01DBA5E0, "_ZN9CSoundEnt5ThinkEv", mfunc_ptr_cast(&CSoundEnt::Think_) }, //non-virtual func - //{ 0x0, "_ZN9CSoundEnt10InitializeEv", mfunc_ptr_cast(&CSoundEnt::Initialize) }, + { 0x01DBA8F0, "_ZN9CSoundEnt10InitializeEv", mfunc_ptr_cast(&CSoundEnt::Initialize) }, { 0x01DBA820, "_ZN9CSoundEnt11InsertSoundEiRK6Vectorif", mfunc_ptr_cast(&CSoundEnt::InsertSound) }, - //{ 0x0, "_ZN9CSoundEnt9FreeSoundEii", mfunc_ptr_cast(&CSoundEnt::FreeSound) }, - //{ 0x0, "_ZN9CSoundEnt10ActiveListEv", mfunc_ptr_cast(&CSoundEnt::ActiveList) }, - //{ 0x0, "_ZN9CSoundEnt8FreeListEv", mfunc_ptr_cast(&CSoundEnt::FreeList) }, + //{ 0x01DBA770, "_ZN9CSoundEnt9FreeSoundEii", mfunc_ptr_cast(&CSoundEnt::FreeSound) }, // NOXREF + //{ 0x01DBAA70, "_ZN9CSoundEnt10ActiveListEv", mfunc_ptr_cast(&CSoundEnt::ActiveList) }, // NOXREF + //{ 0x01DBAA90, "_ZN9CSoundEnt8FreeListEv", mfunc_ptr_cast(&CSoundEnt::FreeList) }, // NOXREF { 0x01DBAAB0, "_ZN9CSoundEnt20SoundPointerForIndexEi", mfunc_ptr_cast(&CSoundEnt::SoundPointerForIndex) }, { 0x01DBAB00, "_ZN9CSoundEnt16ClientSoundIndexEP7edict_s", mfunc_ptr_cast(&CSoundEnt::ClientSoundIndex) }, - //{ 0x0, "_ZN9CSoundEnt7IsEmptyEv", mfunc_ptr_cast(&CSoundEnt::IsEmpty) }, // NOXREF - //{ 0x0, "_ZN9CSoundEnt13ISoundsInListEi", mfunc_ptr_cast(&CSoundEnt::ISoundsInList) }, + //{ 0x0, "_ZN9CSoundEnt7IsEmptyEv", mfunc_ptr_cast(&CSoundEnt::IsEmpty) }, // NOXREF + //{ 0x01DBAA20, "_ZN9CSoundEnt13ISoundsInListEi", mfunc_ptr_cast(&CSoundEnt::ISoundsInList) }, // NOXREF //{ 0x01DBA7D0, "_ZN9CSoundEnt11IAllocSoundEv", mfunc_ptr_cast(&CSoundEnt::IAllocSound) }, // NOXREF #endif // SoundEnt_Region #ifndef Sound_Region - - //{ 0x01DB6C30, "ambient_generic", (size_t)&ambient_generic }, - //{ 0x01DB7E10, "env_sound", (size_t)&env_sound }, - //{ 0x01DB9F10, "speaker", (size_t)&speaker }, - //{ 0x0, "_ZN15CAmbientGeneric4SaveER5CSave", mfunc_ptr_cast(&CAmbientGeneric::Save) }, - //{ 0x0, "_ZN15CAmbientGeneric7RestoreER8CRestore", mfunc_ptr_cast(&CAmbientGeneric::Restore) }, - //{ 0x0, "_ZN15CAmbientGeneric5SpawnEv", mfunc_ptr_cast(&CAmbientGeneric::Spawn) }, - //{ 0x0, "_ZN15CAmbientGeneric10ObjectCapsEv", mfunc_ptr_cast(&CAmbientGeneric::ObjectCaps) }, - //{ 0x0, "_ZN15CAmbientGeneric7RestartEv", mfunc_ptr_cast(&CAmbientGeneric::Restart) }, - //{ 0x0, "_ZN15CAmbientGeneric8PrecacheEv", mfunc_ptr_cast(&CAmbientGeneric::Precache) }, - //{ 0x0, "_ZN15CAmbientGeneric9RampThinkEv", mfunc_ptr_cast(&CAmbientGeneric::RampThink) }, - //{ 0x0, "_ZN15CAmbientGeneric19InitModulationParmsEv", mfunc_ptr_cast(&CAmbientGeneric::InitModulationParms) }, - //{ 0x0, "_ZN15CAmbientGeneric9ToggleUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CAmbientGeneric::ToggleUse) }, - //{ 0x0, "_ZN15CAmbientGeneric8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CAmbientGeneric::KeyValue) }, - //{ 0x0, "_ZN9CEnvSound4SaveER5CSave", mfunc_ptr_cast(&CEnvSound::Save) }, - //{ 0x0, "_ZN9CEnvSound7RestoreER8CRestore", mfunc_ptr_cast(&CEnvSound::Restore) }, - //{ 0x0, "_ZN9CEnvSound8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CEnvSound::KeyValue) }, - //{ 0x01DB7F30, "_Z16FEnvSoundInRangeP9entvars_sS0_Pf", (size_t)&FEnvSoundInRange }, - //{ 0x01DB8090, "_ZN9CEnvSound5ThinkEv", mfunc_ptr_cast(&CEnvSound::Think) }, - //{ 0x01DB8270, "_ZN9CEnvSound5SpawnEv", mfunc_ptr_cast(&CEnvSound::Spawn_) }, + +//CAmbientGeneric + //virtual func + { 0x01DB6CF0, "_ZN15CAmbientGeneric5SpawnEv", mfunc_ptr_cast(&CAmbientGeneric::Spawn_) }, + { 0x01DB6F90, "_ZN15CAmbientGeneric8PrecacheEv", mfunc_ptr_cast(&CAmbientGeneric::Precache_) }, + { 0x01DB6E00, "_ZN15CAmbientGeneric7RestartEv", mfunc_ptr_cast(&CAmbientGeneric::Restart_) }, + { 0x01DB7900, "_ZN15CAmbientGeneric8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CAmbientGeneric::KeyValue_) }, + { 0x01DB6C90, "_ZN15CAmbientGeneric4SaveER5CSave", mfunc_ptr_cast(&CAmbientGeneric::Save_) }, + { 0x01DB6CC0, "_ZN15CAmbientGeneric7RestoreER8CRestore", mfunc_ptr_cast(&CAmbientGeneric::Restore_) }, + { 0x01DB6C80, "_ZN15CAmbientGeneric10ObjectCapsEv", mfunc_ptr_cast(&CAmbientGeneric::ObjectCaps_) }, + //non-virtual func + { 0x01DB7060, "_ZN15CAmbientGeneric9RampThinkEv", mfunc_ptr_cast(&CAmbientGeneric::RampThink) }, + { 0x01DB7440, "_ZN15CAmbientGeneric19InitModulationParmsEv", mfunc_ptr_cast(&CAmbientGeneric::InitModulationParms) }, + { 0x01DB76A0, "_ZN15CAmbientGeneric9ToggleUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CAmbientGeneric::ToggleUse) }, +//CEnvSound + //virtual func + { 0x01DB8270, "_ZN9CEnvSound5SpawnEv", mfunc_ptr_cast(&CEnvSound::Spawn_) }, + { 0x01DB7EC0, "_ZN9CEnvSound8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CEnvSound::KeyValue_) }, + { 0x01DB7E60, "_ZN9CEnvSound4SaveER5CSave", mfunc_ptr_cast(&CEnvSound::Save_) }, + { 0x01DB7E90, "_ZN9CEnvSound7RestoreER8CRestore", mfunc_ptr_cast(&CEnvSound::Restore_) }, + { 0x01DB8090, "_ZN9CEnvSound5ThinkEv", mfunc_ptr_cast(&CEnvSound::Think_) }, +//CSpeaker + //virtual func + { 0x01DB9FD0, "_ZN8CSpeaker5SpawnEv", mfunc_ptr_cast(&CSpeaker::Spawn_) }, + { 0x01DBA090, "_ZN8CSpeaker8PrecacheEv", mfunc_ptr_cast(&CSpeaker::Precache_) }, + { 0x01DBA480, "_ZN8CSpeaker8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CSpeaker::KeyValue_) }, + { 0x01DB9F70, "_ZN8CSpeaker4SaveER5CSave", mfunc_ptr_cast(&CSpeaker::Save_) }, + { 0x01DB9FA0, "_ZN8CSpeaker7RestoreER8CRestore", mfunc_ptr_cast(&CSpeaker::Restore_) }, + { 0x01DB9F60, "_ZN8CSpeaker10ObjectCapsEv", mfunc_ptr_cast(&CSpeaker::ObjectCaps_) }, + //non-virtual func + { 0x01DBA3F0, "_ZN8CSpeaker9ToggleUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CSpeaker::ToggleUse) }, + { 0x01DBA0D0, "_ZN8CSpeaker12SpeakerThinkEv", mfunc_ptr_cast(&CSpeaker::SpeakerThink) }, + //non-class func + { 0x01DB7F30, "_Z16FEnvSoundInRangeP9entvars_sS0_Pf", (size_t)&FEnvSoundInRange }, //{ 0x01DB82A0, "_Z18USENTENCEG_InitLRUPhi", (size_t)&USENTENCEG_InitLRU }, // NOXREF { 0x01DB8310, "_Z25USENTENCEG_PickSequentialiPcii", (size_t)&USENTENCEG_PickSequential }, { 0x01DB8420, "_Z15USENTENCEG_PickiPc", (size_t)&USENTENCEG_Pick }, @@ -2271,14 +2341,11 @@ FunctionHook g_FunctionHooks[] = { 0x01DB97C0, "_Z16TEXTURETYPE_Initv", (size_t)&TEXTURETYPE_Init }, { 0x01DB99A0, "_Z16TEXTURETYPE_FindPc", (size_t)&TEXTURETYPE_Find }, { 0x01DB99F0, "_Z21TEXTURETYPE_PlaySoundP11TraceResult6VectorS1_i", (size_t)&TEXTURETYPE_PlaySound }, - //{ 0x0, "_ZN8CSpeaker10ObjectCapsEv", mfunc_ptr_cast(&CSpeaker::ObjectCaps) }, - //{ 0x0, "_ZN8CSpeaker4SaveER5CSave", mfunc_ptr_cast(&CSpeaker::Save) }, - //{ 0x0, "_ZN8CSpeaker7RestoreER8CRestore", mfunc_ptr_cast(&CSpeaker::Restore) }, - //{ 0x0, "_ZN8CSpeaker5SpawnEv", mfunc_ptr_cast(&CSpeaker::Spawn) }, - //{ 0x0, "_ZN8CSpeaker8PrecacheEv", mfunc_ptr_cast(&CSpeaker::Precache) }, - //{ 0x0, "_ZN8CSpeaker12SpeakerThinkEv", mfunc_ptr_cast(&CSpeaker::SpeakerThink) }, - //{ 0x0, "_ZN8CSpeaker9ToggleUseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CSpeaker::ToggleUse) }, - //{ 0x0, "_ZN8CSpeaker8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CSpeaker::KeyValue) }, + + //linked objects + { 0x01DB6C30, "ambient_generic", (size_t)&ambient_generic }, + { 0x01DB7E10, "env_sound", (size_t)&env_sound }, + { 0x01DB9F10, "speaker", (size_t)&speaker }, #endif // Sound_Region @@ -2747,10 +2814,10 @@ FunctionHook g_FunctionHooks[] = { 0x01DCCE80, "_Z16ApplyMultiDamageP9entvars_sS0_", (size_t)&ApplyMultiDamage }, { 0x01DCCEB0, "_Z14AddMultiDamageP9entvars_sP11CBaseEntityfi", (size_t)&AddMultiDamage }, { 0x01DCCF20, "_Z10SpawnBlood6Vectorif", (size_t)&SpawnBlood }, - ////{ 0x0, "_Z11DamageDecalP11CBaseEntityi", (size_t)&DamageDecal }, // NOXREF - ////{ 0x0, "_Z12DecalGunshotP11TraceResultibP9entvars_sb", (size_t)&DecalGunshot }, // NOXREF - //{ 0x01DCCF90, "_Z10EjectBrassRK6VectorS1_S1_fiii", (size_t)&EjectBrass }, - //{ 0x0, "_Z11EjectBrass2RK6VectorS1_fiiP9entvars_s", (size_t)&EjectBrass2 }, + //{ 0x01DCCF50, "_Z11DamageDecalP11CBaseEntityi", (size_t)&DamageDecal }, // NOXREF + //{ 0x01DCCF80, "_Z12DecalGunshotP11TraceResultibP9entvars_sb", (size_t)&DecalGunshot }, // NOXREF + { 0x01DCCF90, "_Z10EjectBrassRK6VectorS1_S1_fiii", (size_t)&EjectBrass }, + //{ 0x01DCD080, "_Z11EjectBrass2RK6VectorS1_fiiP9entvars_s", (size_t)&EjectBrass2 }, // NOXREF //{ 0x01DCD120, "_Z25AddAmmoNameToAmmoRegistryPKc", (size_t)&AddAmmoNameToAmmoRegistry }, // NOXREF { 0x01DCD180, "_Z24UTIL_PrecacheOtherWeaponPKc", (size_t)&UTIL_PrecacheOtherWeapon }, //{ 0x01DCD310, "_Z25UTIL_PrecacheOtherWeapon2PKc", (size_t)&UTIL_PrecacheOtherWeapon2 }, // NOXREF @@ -2760,23 +2827,22 @@ FunctionHook g_FunctionHooks[] = //virtual func //{ 0x01DCD860, "_ZN15CBasePlayerItem4SaveER5CSave", mfunc_ptr_cast(&CBasePlayerItem::Save_) }, // NOXREF //{ 0x01DCD890, "_ZN15CBasePlayerItem7RestoreER8CRestore", mfunc_ptr_cast(&CBasePlayerItem::Restore_) }, // NOXREF - //{ 0x0, "_ZN15CBasePlayerItem21SetObjectCollisionBoxEv", mfunc_ptr_cast(&CBasePlayerItem::SetObjectCollisionBox) }, - //{ 0x01DCDC80, "_ZN15CBasePlayerItem7RespawnEv", mfunc_ptr_cast(&CBasePlayerItem::Respawn) }, + { 0x01DCD960, "_ZN15CBasePlayerItem21SetObjectCollisionBoxEv", mfunc_ptr_cast(&CBasePlayerItem::SetObjectCollisionBox_) }, + { 0x01DCDC80, "_ZN15CBasePlayerItem7RespawnEv", mfunc_ptr_cast(&CBasePlayerItem::Respawn_) }, //{ 0x01DCEC60, "_ZN15CBasePlayerItem11AddToPlayerEP11CBasePlayer", mfunc_ptr_cast(&CBasePlayerItem::AddToPlayer_) }, // NOXREF - //{ 0x0, "_ZN15CBasePlayerItem12AddDuplicateEPS_", mfunc_ptr_cast(&CBasePlayerItem::AddDuplicate) }, // NOXREF - //{ 0x0, "_ZN15CBasePlayerItem11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CBasePlayerItem::GetItemInfo) }, - //{ 0x0, "_ZN15CBasePlayerItem9CanDeployEv", mfunc_ptr_cast(&CBasePlayerItem::CanDeploy) }, - - //{ 0x0, "_ZN15CBasePlayerItem7CanDropEv", mfunc_ptr_cast(&CBasePlayerItem::CanDrop_) }, + //{ 0x0, "_ZN15CBasePlayerItem12AddDuplicateEPS_", mfunc_ptr_cast(&CBasePlayerItem::AddDuplicate_) }, // NOXREF + //{ 0x0, "_ZN15CBasePlayerItem11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CBasePlayerItem::GetItemInfo_) }, + //{ 0x0, "_ZN15CBasePlayerItem9CanDeployEv", mfunc_ptr_cast(&CBasePlayerItem::CanDeploy_) }, + //{ 0x01D01FF0, "_ZN15CBasePlayerItem7CanDropEv", mfunc_ptr_cast(&CBasePlayerItem::CanDrop_) }, //0x01DCF160 - CBasePlayerItem::??? //0x01D861D0 - CBasePlayerItem::??? //{ 0x0, "_ZN15CBasePlayerItem6DeployEv", mfunc_ptr_cast(&CBasePlayerItem::Deploy) }, //{ 0x0, "_ZN15CBasePlayerItem8IsWeaponEv", mfunc_ptr_cast(&CBasePlayerItem::IsWeapon) }, - //{ 0x0, "_ZN15CBasePlayerItem10CanHolsterEv", mfunc_ptr_cast(&CBasePlayerItem::CanHolster) }, + //{ 0x01D02000, "_ZN15CBasePlayerItem10CanHolsterEv", mfunc_ptr_cast(&CBasePlayerItem::CanHolster) }, //{ 0x01DCED10, "_ZN15CBasePlayerItem7HolsterEi", mfunc_ptr_cast(&CBasePlayerItem::Holster) }, // NOXREF //{ 0x0, "_ZN15CBasePlayerItem14UpdateItemInfoEv", mfunc_ptr_cast(&CBasePlayerItem::UpdateItemInfo) }, // NOXREF - //{ 0x0, "_ZN15CBasePlayerItem12ItemPreFrameEv", mfunc_ptr_cast(&CBasePlayerItem::ItemPreFrame) }, + //{ 0x01D02010, "_ZN15CBasePlayerItem12ItemPreFrameEv", mfunc_ptr_cast(&CBasePlayerItem::ItemPreFrame) }, // NOXREF PURE //{ 0x0, "_ZN15CBasePlayerItem13ItemPostFrameEv", mfunc_ptr_cast(&CBasePlayerItem::ItemPostFrame) }, { 0x01DCECB0, "_ZN15CBasePlayerItem4DropEv", mfunc_ptr_cast(&CBasePlayerItem::Drop_) }, { 0x01DCECE0, "_ZN15CBasePlayerItem4KillEv", mfunc_ptr_cast(&CBasePlayerItem::Kill_) }, @@ -2785,14 +2851,14 @@ FunctionHook g_FunctionHooks[] = //{ 0x0, "_ZN15CBasePlayerItem18SecondaryAmmoIndexEv", mfunc_ptr_cast(&CBasePlayerItem::SecondaryAmmoIndex) }, //{ 0x0, "_ZN15CBasePlayerItem16UpdateClientDataEP11CBasePlayer", mfunc_ptr_cast(&CBasePlayerItem::UpdateClientData) }, //{ 0x0, "_ZN15CBasePlayerItem12GetWeaponPtrEv", mfunc_ptr_cast(&CBasePlayerItem::GetWeaponPtr) }, - //{ 0x0, "_ZN15CBasePlayerItem11GetMaxSpeedEv", mfunc_ptr_cast(&CBasePlayerItem::GetMaxSpeed) }, + //{ 0x01D861A0, "_ZN15CBasePlayerItem11GetMaxSpeedEv", mfunc_ptr_cast(&CBasePlayerItem::GetMaxSpeed) }, //{ 0x0, "_ZN15CBasePlayerItem9iItemSlotEv", mfunc_ptr_cast(&CBasePlayerItem::iItemSlot) }, //non-virtual func - //{ 0x0, "_ZN15CBasePlayerItem11DestroyItemEv", mfunc_ptr_cast(&CBasePlayerItem::DestroyItem) }, + { 0x01DCEC40, "_ZN15CBasePlayerItem11DestroyItemEv", mfunc_ptr_cast(&CBasePlayerItem::DestroyItem) }, { 0x01DCDD50, "_ZN15CBasePlayerItem12DefaultTouchEP11CBaseEntity", mfunc_ptr_cast(&CBasePlayerItem::DefaultTouch) }, { 0x01DCDAA0, "_ZN15CBasePlayerItem9FallThinkEv", mfunc_ptr_cast(&CBasePlayerItem::FallThink) }, { 0x01DCDB30, "_ZN15CBasePlayerItem11MaterializeEv", mfunc_ptr_cast(&CBasePlayerItem::Materialize) }, - //{ 0x0, "_ZN15CBasePlayerItem20AttemptToMaterializeEv", mfunc_ptr_cast(&CBasePlayerItem::AttemptToMaterialize) }, + { 0x01DCDC10, "_ZN15CBasePlayerItem20AttemptToMaterializeEv", mfunc_ptr_cast(&CBasePlayerItem::AttemptToMaterialize) }, { 0x01DCDA00, "_ZN15CBasePlayerItem8FallInitEv", mfunc_ptr_cast(&CBasePlayerItem::FallInit) }, { 0x01DCDC50, "_ZN15CBasePlayerItem12CheckRespawnEv", mfunc_ptr_cast(&CBasePlayerItem::CheckRespawn) }, //{ 0x0, "_ZN15CBasePlayerItem8pszAmmo1Ev", mfunc_ptr_cast(&CBasePlayerItem::pszAmmo1) }, @@ -2809,37 +2875,39 @@ FunctionHook g_FunctionHooks[] = { 0x01DCD910, "_ZN17CBasePlayerWeapon7RestoreER8CRestore", mfunc_ptr_cast(&CBasePlayerWeapon::Restore_) }, { 0x01DCEDE0, "_ZN17CBasePlayerWeapon11AddToPlayerEP11CBasePlayer", mfunc_ptr_cast(&CBasePlayerWeapon::AddToPlayer_) }, { 0x01DCEDC0, "_ZN17CBasePlayerWeapon12AddDuplicateEP15CBasePlayerItem", mfunc_ptr_cast(&CBasePlayerWeapon::AddDuplicate_) }, - //{ 0x01D02050, "_ZN17CBasePlayerWeapon9CanDeployEv", mfunc_ptr_cast(&CBasePlayerWeapon::CanDeploy) }, - //{ 0x01D02000, "_ZN17CBasePlayerWeapon8IsWeaponEv", mfunc_ptr_cast(&CBasePlayerWeapon::IsWeapon) }, + { 0x01DCF1A0, "_ZN17CBasePlayerWeapon9CanDeployEv", mfunc_ptr_cast(&CBasePlayerWeapon::CanDeploy_) }, + //{ 0x01D02050, "_ZN17CBasePlayerWeapon8IsWeaponEv", mfunc_ptr_cast(&CBasePlayerWeapon::IsWeapon_) }, + + //{ 0x0, "_ZN17CBasePlayerWeapon8IsWeaponEv", mfunc_ptr_cast(&CBasePlayerWeapon::IsWeapon_) }, { 0x01DCF570, "_ZN17CBasePlayerWeapon7HolsterEi", mfunc_ptr_cast(&CBasePlayerWeapon::Holster_) }, - //{ 0x0, "_ZN17CBasePlayerWeapon14UpdateItemInfoEv", mfunc_ptr_cast(&CBasePlayerWeapon::UpdateItemInfo) }, // NOXREF - //{ 0x0, "_ZN17CBasePlayerWeapon13ItemPostFrameEv", mfunc_ptr_cast(&CBasePlayerWeapon::ItemPostFrame) }, - //{ 0x0, "_ZN17CBasePlayerWeapon16PrimaryAmmoIndexEv", mfunc_ptr_cast(&CBasePlayerWeapon::PrimaryAmmoIndex) }, - //{ 0x0, "_ZN17CBasePlayerWeapon18SecondaryAmmoIndexEv", mfunc_ptr_cast(&CBasePlayerWeapon::SecondaryAmmoIndex) }, + //{ 0x01D02030, "_ZN17CBasePlayerWeapon14UpdateItemInfoEv", mfunc_ptr_cast(&CBasePlayerWeapon::UpdateItemInfo_) }, // NOXREF PURE + { 0x01DCE6A0, "_ZN17CBasePlayerWeapon13ItemPostFrameEv", mfunc_ptr_cast(&CBasePlayerWeapon::ItemPostFrame_) }, + { 0x01DCF550, "_ZN17CBasePlayerWeapon16PrimaryAmmoIndexEv", mfunc_ptr_cast(&CBasePlayerWeapon::PrimaryAmmoIndex_) }, + { 0x01DCF560, "_ZN17CBasePlayerWeapon18SecondaryAmmoIndexEv", mfunc_ptr_cast(&CBasePlayerWeapon::SecondaryAmmoIndex_) }, { 0x01DCEEB0, "_ZN17CBasePlayerWeapon16UpdateClientDataEP11CBasePlayer", mfunc_ptr_cast(&CBasePlayerWeapon::UpdateClientData_) }, - //{ 0x0, "_ZN17CBasePlayerWeapon12GetWeaponPtrEv", mfunc_ptr_cast(&CBasePlayerWeapon::GetWeaponPtr) }, + //{ 0x01D02060, "_ZN17CBasePlayerWeapon12GetWeaponPtrEv", mfunc_ptr_cast(&CBasePlayerWeapon::GetWeaponPtr_) }, { 0x01DCF7E0, "_ZN17CBasePlayerWeapon11ExtractAmmoEPS_", mfunc_ptr_cast(&CBasePlayerWeapon::ExtractAmmo_) }, { 0x01DCF8A0, "_ZN17CBasePlayerWeapon15ExtractClipAmmoEPS_", mfunc_ptr_cast(&CBasePlayerWeapon::ExtractClipAmmo_) }, - //{ 0x01D02020, "_ZN17CBasePlayerWeapon9AddWeaponEv", mfunc_ptr_cast(&CBasePlayerWeapon::AddWeapon) }, + //{ 0x01D02020, "_ZN17CBasePlayerWeapon9AddWeaponEv", mfunc_ptr_cast(&CBasePlayerWeapon::AddWeapon_) }, { 0x01DCF4C0, "_ZN17CBasePlayerWeapon14PlayEmptySoundEv", mfunc_ptr_cast(&CBasePlayerWeapon::PlayEmptySound_) }, { 0x01DCF540, "_ZN17CBasePlayerWeapon15ResetEmptySoundEv", mfunc_ptr_cast(&CBasePlayerWeapon::ResetEmptySound_) }, { 0x01DCEFB0, "_ZN17CBasePlayerWeapon14SendWeaponAnimEii", mfunc_ptr_cast(&CBasePlayerWeapon::SendWeaponAnim_) }, - //{ 0x0, "_ZN17CBasePlayerWeapon9IsUseableEv", mfunc_ptr_cast(&CBasePlayerWeapon::IsUseable) }, - //{ 0x0, "_ZN17CBasePlayerWeapon13PrimaryAttackEv", mfunc_ptr_cast(&CBasePlayerWeapon::PrimaryAttack) }, - //{ 0x0, "_ZN17CBasePlayerWeapon15SecondaryAttackEv", mfunc_ptr_cast(&CBasePlayerWeapon::SecondaryAttack) }, - //{ 0x0, "_ZN17CBasePlayerWeapon6ReloadEv", mfunc_ptr_cast(&CBasePlayerWeapon::Reload) }, - //{ 0x0, "_ZN17CBasePlayerWeapon10WeaponIdleEv", mfunc_ptr_cast(&CBasePlayerWeapon::WeaponIdle) }, - //{ 0x01DCF8F0, "_ZN17CBasePlayerWeapon12RetireWeaponEv", mfunc_ptr_cast(&CBasePlayerWeapon::RetireWeapon) }, - //{ 0x0, "_ZN17CBasePlayerWeapon16ShouldWeaponIdleEv", mfunc_ptr_cast(&CBasePlayerWeapon::ShouldWeaponIdle) }, - //{ 0x0, "_ZN17CBasePlayerWeapon12UseDecrementEv", mfunc_ptr_cast(&CBasePlayerWeapon::UseDecrement) }, + { 0x01DCF150, "_ZN17CBasePlayerWeapon9IsUseableEv", mfunc_ptr_cast(&CBasePlayerWeapon::IsUseable_) }, + //{ 0x0, "_ZN17CBasePlayerWeapon13PrimaryAttackEv", mfunc_ptr_cast(&CBasePlayerWeapon::PrimaryAttack_) }, + //{ 0x01D03A50, "_ZN17CBasePlayerWeapon15SecondaryAttackEv", mfunc_ptr_cast(&CBasePlayerWeapon::SecondaryAttack_) }, // PURE + //{ 0x01D03A60, "_ZN17CBasePlayerWeapon6ReloadEv", mfunc_ptr_cast(&CBasePlayerWeapon::Reload_) }, // PURE + //{ 0x01D861B0, "_ZN17CBasePlayerWeapon10WeaponIdleEv", mfunc_ptr_cast(&CBasePlayerWeapon::WeaponIdle_) }, // PURE + { 0x01DCF8F0, "_ZN17CBasePlayerWeapon12RetireWeaponEv", mfunc_ptr_cast(&CBasePlayerWeapon::RetireWeapon_) }, + //{ 0x01D02040, "_ZN17CBasePlayerWeapon16ShouldWeaponIdleEv", mfunc_ptr_cast(&CBasePlayerWeapon::ShouldWeaponIdle_) }, + //{ 0x01D861C0, "_ZN17CBasePlayerWeapon12UseDecrementEv", mfunc_ptr_cast(&CBasePlayerWeapon::UseDecrement_) }, //non-virtual func { 0x01DCF030, "_ZN17CBasePlayerWeapon14AddPrimaryAmmoEiPcii", mfunc_ptr_cast(&CBasePlayerWeapon::AddPrimaryAmmo) }, //{ 0x01DCF0F0, "_ZN17CBasePlayerWeapon16AddSecondaryAmmoEiPci", mfunc_ptr_cast(&CBasePlayerWeapon::AddSecondaryAmmo) }, // NOXREF { 0x01DCF1B0, "_ZN17CBasePlayerWeapon13DefaultDeployEPcS0_iS0_i", mfunc_ptr_cast(&CBasePlayerWeapon::DefaultDeploy) }, { 0x01DCF430, "_ZN17CBasePlayerWeapon13DefaultReloadEiif", mfunc_ptr_cast(&CBasePlayerWeapon::DefaultReload) }, - //{ 0x01DCE380, "_ZN17CBasePlayerWeapon13FireRemainingERiRfi", mfunc_ptr_cast(&CBasePlayerWeapon::FireRemaining) }, - //{ 0x0, "_ZN17CBasePlayerWeapon8KickBackEffffffi", mfunc_ptr_cast(&CBasePlayerWeapon::KickBack) }, - //{ 0x0, "_ZN17CBasePlayerWeapon14EjectBrassLateEv", mfunc_ptr_cast(&CBasePlayerWeapon::EjectBrassLate) }, + { 0x01DCE380, "_ZN17CBasePlayerWeapon13FireRemainingERiRfi", mfunc_ptr_cast(&CBasePlayerWeapon::FireRemaining) }, + //{ 0x01DCE260, "_ZN17CBasePlayerWeapon8KickBackEffffffi", mfunc_ptr_cast(&CBasePlayerWeapon::KickBack) }, + { 0x01DCDEA0, "_ZN17CBasePlayerWeapon14EjectBrassLateEv", mfunc_ptr_cast(&CBasePlayerWeapon::EjectBrassLate) }, //{ 0x0, "_ZN17CBasePlayerWeapon8MakeBeamEv", mfunc_ptr_cast(&CBasePlayerWeapon::MakeBeam) }, //{ 0x0, "_ZN17CBasePlayerWeapon10BeamUpdateEv", mfunc_ptr_cast(&CBasePlayerWeapon::BeamUpdate) }, { 0x01DCF2D0, "_ZN17CBasePlayerWeapon11ReloadSoundEv", mfunc_ptr_cast(&CBasePlayerWeapon::ReloadSound) }, @@ -2920,15 +2988,15 @@ FunctionHook g_FunctionHooks[] = { 0x01D59D80, "ammo_357sig", (size_t)&ammo_357sig }, //CWeaponBox //virtual func - //{ 0x01DCFD80, "_ZN10CWeaponBox5SpawnEv", mfunc_ptr_cast(&CWeaponBox::Spawn_) }, - //{ 0x01DCFA40, "_ZN10CWeaponBox8PrecacheEv", mfunc_ptr_cast(&CWeaponBox::Precache_) }, - //{ 0x01DCFA50, "_ZN10CWeaponBox8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CWeaponBox::KeyValue_) }, - //{ 0x01DCF9E0, "_ZN10CWeaponBox4SaveER5CSave", mfunc_ptr_cast(&CWeaponBox::Save_) }, - //{ 0x01DCFA10, "_ZN10CWeaponBox7RestoreER8CRestore", mfunc_ptr_cast(&CWeaponBox::Restore_) }, - //{ 0x01DD0970, "_ZN10CWeaponBox21SetObjectCollisionBoxEv", mfunc_ptr_cast(&CWeaponBox::SetObjectCollisionBox_) }, - //{ 0x01DCFE30, "_ZN10CWeaponBox5TouchEP11CBaseEntity", mfunc_ptr_cast(&CWeaponBox::Touch_) }, + { 0x01DCFD80, "_ZN10CWeaponBox5SpawnEv", mfunc_ptr_cast(&CWeaponBox::Spawn_) }, + { 0x01DCFA40, "_ZN10CWeaponBox8PrecacheEv", mfunc_ptr_cast(&CWeaponBox::Precache_) }, + { 0x01DCFA50, "_ZN10CWeaponBox8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CWeaponBox::KeyValue_) }, + { 0x01DCF9E0, "_ZN10CWeaponBox4SaveER5CSave", mfunc_ptr_cast(&CWeaponBox::Save_) }, + { 0x01DCFA10, "_ZN10CWeaponBox7RestoreER8CRestore", mfunc_ptr_cast(&CWeaponBox::Restore_) }, + { 0x01DD0970, "_ZN10CWeaponBox21SetObjectCollisionBoxEv", mfunc_ptr_cast(&CWeaponBox::SetObjectCollisionBox_) }, + { 0x01DCFE30, "_ZN10CWeaponBox5TouchEP11CBaseEntity", mfunc_ptr_cast(&CWeaponBox::Touch_) }, //non-virtual func - //{ 0x01DCF990, "weaponbox", (size_t)&weaponbox }, + { 0x01DCF990, "weaponbox", (size_t)&weaponbox }, //{ 0x01DD0930, "_ZN10CWeaponBox7IsEmptyEv", mfunc_ptr_cast(&CWeaponBox::IsEmpty) }, // NOXREF { 0x01DD07C0, "_ZN10CWeaponBox8GiveAmmoEiPciPi", mfunc_ptr_cast(&CWeaponBox::GiveAmmo) }, { 0x01DCFDE0, "_ZN10CWeaponBox4KillEv", mfunc_ptr_cast(&CWeaponBox::Kill) }, @@ -2938,23 +3006,23 @@ FunctionHook g_FunctionHooks[] = { 0x01DD0670, "_ZN10CWeaponBox8PackAmmoEii", mfunc_ptr_cast(&CWeaponBox::PackAmmo) }, //CUSP //virtual func - //!@{ 0x01D0F8B0, "_ZN4CUSP5SpawnEv", mfunc_ptr_cast(&CUSP::Spawn_) }, + { 0x01D0F8B0, "_ZN4CUSP5SpawnEv", mfunc_ptr_cast(&CUSP::Spawn_) }, { 0x01D0F910, "_ZN4CUSP8PrecacheEv", mfunc_ptr_cast(&CUSP::Precache_) }, - //!@{ 0x01D0F9D0, "_ZN4CUSP11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CUSP::GetItemInfo_) }, - //!@{ 0x01D0FA40, "_ZN4CUSP6DeployEv", mfunc_ptr_cast(&CUSP::Deploy_) }, - //{ 0x0, "_ZN4CUSP11GetMaxSpeedEv", mfunc_ptr_cast(&CUSP::GetMaxSpeed) }, - //{ 0x0, "_ZN4CUSP9iItemSlotEv", mfunc_ptr_cast(&CUSP::iItemSlot) }, - //{ 0x0, "_ZN4CUSP13PrimaryAttackEv", mfunc_ptr_cast(&CUSP::PrimaryAttack) }, - //{ 0x0, "_ZN4CUSP15SecondaryAttackEv", mfunc_ptr_cast(&CUSP::SecondaryAttack) }, - //!@{ 0x01D10060, "_ZN4CUSP6ReloadEv", mfunc_ptr_cast(&CUSP::Reload_) }, - //!@{ 0x01D100C0, "_ZN4CUSP10WeaponIdleEv", mfunc_ptr_cast(&CUSP::WeaponIdle_) }, - //{ 0x0, "_ZN4CUSP12UseDecrementEv", mfunc_ptr_cast(&CUSP::UseDecrement) }, - //{ 0x0, "_ZN4CUSP8IsPistolEv", mfunc_ptr_cast(&CUSP::IsPistol) }, + { 0x01D0F9D0, "_ZN4CUSP11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CUSP::GetItemInfo_) }, + { 0x01D0FA40, "_ZN4CUSP6DeployEv", mfunc_ptr_cast(&CUSP::Deploy_) }, + //{ 0x01D101A0, "_ZN4CUSP11GetMaxSpeedEv", mfunc_ptr_cast(&CUSP::GetMaxSpeed_) }, // DEFAULT + //{ 0x01D10190, "_ZN4CUSP9iItemSlotEv", mfunc_ptr_cast(&CUSP::iItemSlot_) }, // DEFAULT + { 0x01D0FBE0, "_ZN4CUSP13PrimaryAttackEv", mfunc_ptr_cast(&CUSP::PrimaryAttack_) }, + { 0x01D0FB20, "_ZN4CUSP15SecondaryAttackEv", mfunc_ptr_cast(&CUSP::SecondaryAttack_) }, + { 0x01D10060, "_ZN4CUSP6ReloadEv", mfunc_ptr_cast(&CUSP::Reload_) }, + { 0x01D100C0, "_ZN4CUSP10WeaponIdleEv", mfunc_ptr_cast(&CUSP::WeaponIdle_) }, + //{ 0x01D101B0, "_ZN4CUSP12UseDecrementEv", mfunc_ptr_cast(&CUSP::UseDecrement_) }, // DEFAULT + //{ 0x01D101C0, "_ZN4CUSP8IsPistolEv", mfunc_ptr_cast(&CUSP::IsPistol_) }, // DEFAULT //non-virtual func { 0x01D0F860, "weapon_usp", (size_t)&weapon_usp }, - //@{ 0x01D0FD50, "_ZN4CUSP7USPFireEffi", mfunc_ptr_cast(&CUSP::USPFire) }, // UNTESTED TODO: Reverse ME - ////{ 0x0, "_ZN4CUSP8MakeBeamEv", mfunc_ptr_cast(&CUSP::MakeBeam) }, // NOXREF - ////{ 0x0, "_ZN4CUSP10BeamUpdateEv", mfunc_ptr_cast(&CUSP::BeamUpdate) }, // NOXREF + { 0x01D0FD50, "_ZN4CUSP7USPFireEffi", mfunc_ptr_cast(&CUSP::USPFire) }, + //{ 0x0, "_ZN4CUSP8MakeBeamEv", mfunc_ptr_cast(&CUSP::MakeBeam) }, // NOXREF + //{ 0x0, "_ZN4CUSP10BeamUpdateEv", mfunc_ptr_cast(&CUSP::BeamUpdate) }, // NOXREF //CMP5N //virtual func //{ 0x0, "_ZN5CMP5N5SpawnEv", mfunc_ptr_cast(&CMP5N::Spawn) }, @@ -2972,33 +3040,33 @@ FunctionHook g_FunctionHooks[] = //{ 0x0, "_ZN5CMP5N8MP5NFireEffi", mfunc_ptr_cast(&CMP5N::USPFire) }, //CSG552 //virtual func - //{ 0x0, "_ZN6CSG5525SpawnEv", mfunc_ptr_cast(&CSG552::Spawn) }, - //{ 0x0, "_ZN6CSG5528PrecacheEv", mfunc_ptr_cast(&CSG552::Precache) }, - //{ 0x0, "_ZN6CSG55211GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CSG552::GetItemInfo) }, - //{ 0x0, "_ZN6CSG5526DeployEv", mfunc_ptr_cast(&CSG552::Deploy) }, - //{ 0x0, "_ZN6CSG55211GetMaxSpeedEv", mfunc_ptr_cast(&CSG552::GetMaxSpeed) }, - //{ 0x0, "_ZN6CSG5529iItemSlotEv", mfunc_ptr_cast(&CSG552::iItemSlot) }, - //{ 0x0, "_ZN6CSG55213PrimaryAttackEv", mfunc_ptr_cast(&CSG552::PrimaryAttack) }, - //{ 0x0, "_ZN6CSG55215SecondaryAttackEv", mfunc_ptr_cast(&CSG552::SecondaryAttack) }, - //{ 0x0, "_ZN6CSG5526ReloadEv", mfunc_ptr_cast(&CSG552::Reload) }, - //{ 0x0, "_ZN6CSG55210WeaponIdleEv", mfunc_ptr_cast(&CSG552::WeaponIdle) }, - //{ 0x0, "_ZN6CSG55212UseDecrementEv", mfunc_ptr_cast(&CSG552::UseDecrement) }, + //{ 0x0, "_ZN6CSG5525SpawnEv", mfunc_ptr_cast(&CSG552::Spawn_) }, + //{ 0x0, "_ZN6CSG5528PrecacheEv", mfunc_ptr_cast(&CSG552::Precache_) }, + //{ 0x0, "_ZN6CSG55211GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CSG552::GetItemInfo_) }, + //{ 0x0, "_ZN6CSG5526DeployEv", mfunc_ptr_cast(&CSG552::Deploy_) }, + //{ 0x0, "_ZN6CSG55211GetMaxSpeedEv", mfunc_ptr_cast(&CSG552::GetMaxSpeed_) }, + //{ 0x0, "_ZN6CSG5529iItemSlotEv", mfunc_ptr_cast(&CSG552::iItemSlot_) }, + //{ 0x0, "_ZN6CSG55213PrimaryAttackEv", mfunc_ptr_cast(&CSG552::PrimaryAttack_) }, + //{ 0x0, "_ZN6CSG55215SecondaryAttackEv", mfunc_ptr_cast(&CSG552::SecondaryAttack_) }, + //{ 0x0, "_ZN6CSG5526ReloadEv", mfunc_ptr_cast(&CSG552::Reload_) }, + //{ 0x0, "_ZN6CSG55210WeaponIdleEv", mfunc_ptr_cast(&CSG552::WeaponIdle_) }, + //{ 0x0, "_ZN6CSG55212UseDecrementEv", mfunc_ptr_cast(&CSG552::UseDecrement_) }, //non-virtual func //{ 0x0, "weapon_sg552", (size_t)&weapon_sg552 }, //{ 0x0, "_ZN6CSG5529SG552FireEffi", mfunc_ptr_cast(&CSG552::SG552Fire) }, //CAK47 //virtual func - //{ 0x0, "_ZN5CAK475SpawnEv", mfunc_ptr_cast(&CAK47::Spawn) }, - //{ 0x0, "_ZN5CAK478PrecacheEv", mfunc_ptr_cast(&CAK47::Precache) }, - //{ 0x0, "_ZN5CAK4711GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CAK47::GetItemInfo) }, - //{ 0x0, "_ZN5CAK476DeployEv", mfunc_ptr_cast(&CAK47::Deploy) }, - //{ 0x01D02080, "_ZN5CAK4711GetMaxSpeedEv", mfunc_ptr_cast(&CAK47::GetMaxSpeed) }, - //{ 0x0, "_ZN5CAK479iItemSlotEv", mfunc_ptr_cast(&CAK47::iItemSlot) }, - //{ 0x0, "_ZN5CAK4713PrimaryAttackEv", mfunc_ptr_cast(&CAK47::PrimaryAttack) }, - //{ 0x0, "_ZN5CAK4715SecondaryAttackEv", mfunc_ptr_cast(&CAK47::SecondaryAttack) }, - //{ 0x0, "_ZN5CAK476ReloadEv", mfunc_ptr_cast(&CAK47::Reload) }, - //{ 0x0, "_ZN5CAK4710WeaponIdleEv", mfunc_ptr_cast(&CAK47::WeaponIdle) }, - //{ 0x0, "_ZN5CAK4712UseDecrementEv", mfunc_ptr_cast(&CAK47::UseDecrement) }, + //{ 0x0, "_ZN5CAK475SpawnEv", mfunc_ptr_cast(&CAK47::Spawn_) }, + //{ 0x0, "_ZN5CAK478PrecacheEv", mfunc_ptr_cast(&CAK47::Precache_) }, + //{ 0x0, "_ZN5CAK4711GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CAK47::GetItemInfo_) }, + //{ 0x0, "_ZN5CAK476DeployEv", mfunc_ptr_cast(&CAK47::Deploy_) }, + //{ 0x01D02080, "_ZN5CAK4711GetMaxSpeedEv", mfunc_ptr_cast(&CAK47::GetMaxSpeed_) }, // DEFAULT + //{ 0x0, "_ZN5CAK479iItemSlotEv", mfunc_ptr_cast(&CAK47::iItemSlot_) }, // DEFAULT + //{ 0x0, "_ZN5CAK4713PrimaryAttackEv", mfunc_ptr_cast(&CAK47::PrimaryAttack_) }, + //{ 0x0, "_ZN5CAK4715SecondaryAttackEv", mfunc_ptr_cast(&CAK47::SecondaryAttack_) }, + //{ 0x0, "_ZN5CAK476ReloadEv", mfunc_ptr_cast(&CAK47::Reload_) }, + //{ 0x0, "_ZN5CAK4710WeaponIdleEv", mfunc_ptr_cast(&CAK47::WeaponIdle_) }, + //{ 0x0, "_ZN5CAK4712UseDecrementEv", mfunc_ptr_cast(&CAK47::UseDecrement_) }, // DEFAULT //non-virtual func //{ 0x0, "weapon_ak47", (size_t)&weapon_ak47 }, //{ 0x0, "_ZN5CAK478AK47FireEffi", mfunc_ptr_cast(&CAK47::USPFire) }, @@ -3020,20 +3088,20 @@ FunctionHook g_FunctionHooks[] = //{ 0x0, "_ZN4CAUG7AUGFireEffi", mfunc_ptr_cast(&CAUG::AUGFire) }, //CAWP //virtual func - //{ 0x0, "_ZN4CAWP5SpawnEv", mfunc_ptr_cast(&CAWP::Spawn) }, - //{ 0x0, "_ZN4CAWP8PrecacheEv", mfunc_ptr_cast(&CAWP::Precache) }, - //{ 0x0, "_ZN4CAWP11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CAWP::GetItemInfo) }, - //{ 0x0, "_ZN4CAWP6DeployEv", mfunc_ptr_cast(&CAWP::Deploy) }, - //{ 0x0, "_ZN4CAWP11GetMaxSpeedEv", mfunc_ptr_cast(&CAWP::GetMaxSpeed) }, - //{ 0x0, "_ZN4CAWP9iItemSlotEv", mfunc_ptr_cast(&CAWP::iItemSlot) }, - //{ 0x0, "_ZN4CAWP13PrimaryAttackEv", mfunc_ptr_cast(&CAWP::PrimaryAttack) }, - //{ 0x0, "_ZN4CAWP15SecondaryAttackEv", mfunc_ptr_cast(&CAWP::SecondaryAttack) }, - //{ 0x0, "_ZN4CAWP6ReloadEv", mfunc_ptr_cast(&CAWP::Reload) }, - //{ 0x0, "_ZN4CAWP10WeaponIdleEv", mfunc_ptr_cast(&CAWP::WeaponIdle) }, - //{ 0x0, "_ZN4CAWP12UseDecrementEv", mfunc_ptr_cast(&CAWP::UseDecrement) }, + { 0x01D02890, "_ZN4CAWP5SpawnEv", mfunc_ptr_cast(&CAWP::Spawn_) }, + { 0x01D028D0, "_ZN4CAWP8PrecacheEv", mfunc_ptr_cast(&CAWP::Precache_) }, + { 0x01D02980, "_ZN4CAWP11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CAWP::GetItemInfo_) }, + { 0x01D029F0, "_ZN4CAWP6DeployEv", mfunc_ptr_cast(&CAWP::Deploy_) }, + { 0x01D02FA0, "_ZN4CAWP11GetMaxSpeedEv", mfunc_ptr_cast(&CAWP::GetMaxSpeed_) }, + //{ 0x01D02FC0, "_ZN4CAWP9iItemSlotEv", mfunc_ptr_cast(&CAWP::iItemSlot_) }, // DEFAULT + { 0x01D02B40, "_ZN4CAWP13PrimaryAttackEv", mfunc_ptr_cast(&CAWP::PrimaryAttack_) }, + { 0x01D02A60, "_ZN4CAWP15SecondaryAttackEv", mfunc_ptr_cast(&CAWP::SecondaryAttack_) }, + { 0x01D02EA0, "_ZN4CAWP6ReloadEv", mfunc_ptr_cast(&CAWP::Reload_) }, + { 0x01D02F20, "_ZN4CAWP10WeaponIdleEv", mfunc_ptr_cast(&CAWP::WeaponIdle_) }, + //{ 0x01D02FD0, "_ZN4CAWP12UseDecrementEv", mfunc_ptr_cast(&CAWP::UseDecrement_) }, // DEFAULT //non-virtual func - //{ 0x0, "weapon_awp", (size_t)&weapon_awp }, - //{ 0x0, "_ZN4CAWP7AWPFireEffi", mfunc_ptr_cast(&CAWP::AWPFire) }, + { 0x01D02840, "weapon_awp", (size_t)&weapon_awp }, + { 0x01D02BF0, "_ZN4CAWP7AWPFireEffi", mfunc_ptr_cast(&CAWP::AWPFire) }, //CC4 //virtual func //{ 0x0, "_ZN3CC45SpawnEv", mfunc_ptr_cast(&CC4::Spawn) }, @@ -3156,7 +3224,7 @@ FunctionHook g_FunctionHooks[] = //{ 0x0, "_ZN6CKnife12UseDecrementEv", mfunc_ptr_cast(&CKnife::UseDecrement) }, //{ 0x0, "_ZN6CKnife10WeaponIdleEv", mfunc_ptr_cast(&CKnife::WeaponIdle) }, //non-virtual func - //{ 0x0, "weapon_knife", (size_t)&weapon_knife }, + { 0x01D084B0, "weapon_knife", (size_t)&weapon_knife }, //{ 0x0, "FindHullIntersection", (size_t)&FindHullIntersection }, //{ 0x0, "_ZN6CKnife10SwingAgainEv", mfunc_ptr_cast(&CKnife::SwingAgain) }, //{ 0x0, "_ZN6CKnife5SmackEv", mfunc_ptr_cast(&CKnife::Smack) }, @@ -3247,19 +3315,19 @@ FunctionHook g_FunctionHooks[] = ////{ 0x0, "_ZN5CP22810BeamUpdateEv", mfunc_ptr_cast(&CP228::BeamUpdate) }, // NOXREF //CP90 //virtual func - //{ 0x0, "_ZN4CP905SpawnEv", mfunc_ptr_cast(&CP90::Spawn) }, - //{ 0x0, "_ZN4CP908PrecacheEv", mfunc_ptr_cast(&CP90::Precache) }, - //{ 0x0, "_ZN4CP9011GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CP90::GetItemInfo) }, - //{ 0x0, "_ZN4CP906DeployEv", mfunc_ptr_cast(&CP90::Deploy) }, - //{ 0x0, "_ZN4CP9011GetMaxSpeedEv", mfunc_ptr_cast(&CP90::GetMaxSpeed) }, - //{ 0x0, "_ZN4CP909iItemSlotEv", mfunc_ptr_cast(&CP90::iItemSlot) }, - //{ 0x0, "_ZN4CP9013PrimaryAttackEv", mfunc_ptr_cast(&CP90::PrimaryAttack) }, - //{ 0x0, "_ZN4CP906ReloadEv", mfunc_ptr_cast(&CP90::Reload) }, - //{ 0x0, "_ZN4CP9010WeaponIdleEv", mfunc_ptr_cast(&CP90::WeaponIdle) }, - //{ 0x0, "_ZN4CP9012UseDecrementEv", mfunc_ptr_cast(&CP90::UseDecrement) }, + { 0x01D0C520, "_ZN4CP905SpawnEv", mfunc_ptr_cast(&CP90::Spawn_) }, + { 0x01D0C580, "_ZN4CP908PrecacheEv", mfunc_ptr_cast(&CP90::Precache_) }, + { 0x01D0C600, "_ZN4CP9011GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CP90::GetItemInfo_) }, + { 0x01D0C670, "_ZN4CP906DeployEv", mfunc_ptr_cast(&CP90::Deploy_) }, + { 0x01D0CB90, "_ZN4CP9011GetMaxSpeedEv", mfunc_ptr_cast(&CP90::GetMaxSpeed_) }, + //{ 0x01D0CB80, "_ZN4CP909iItemSlotEv", mfunc_ptr_cast(&CP90::iItemSlot_) }, // DEFAULT + { 0x01D0C6C0, "_ZN4CP9013PrimaryAttackEv", mfunc_ptr_cast(&CP90::PrimaryAttack_) }, + { 0x01D0CAC0, "_ZN4CP906ReloadEv", mfunc_ptr_cast(&CP90::Reload_) }, + { 0x01D0CB10, "_ZN4CP9010WeaponIdleEv", mfunc_ptr_cast(&CP90::WeaponIdle_) }, + //{ 0x01D0CBA0, "_ZN4CP9012UseDecrementEv", mfunc_ptr_cast(&CP90::UseDecrement_) }, // DEFAULT //non-virtual func - //{ 0x0, "weapon_p90", (size_t)&weapon_p90 }, - //{ 0x0, "_ZN4CP907P90FireEffi", mfunc_ptr_cast(&CP90::P90Fire) }, + { 0x01D0C4D0, "weapon_p90", (size_t)&weapon_p90 }, + { 0x01D0C750, "_ZN4CP907P90FireEffi", mfunc_ptr_cast(&CP90::P90Fire) }, //CSCOUT //virtual func //{ 0x0, "_ZN6CSCOUT5SpawnEv", mfunc_ptr_cast(&CSCOUT::Spawn) }, @@ -3425,12 +3493,12 @@ FunctionHook g_FunctionHooks[] = //{ 0x0, "_ZN6CFamas9FamasFireEffii", mfunc_ptr_cast(&CFamas::FamasFire) }, //CArmoury //virtual func - //{ 0x0, "_ZN8CArmoury5SpawnEv", mfunc_ptr_cast(&CArmoury::Spawn) }, - //{ 0x0, "_ZN8CArmoury8PrecacheEv", mfunc_ptr_cast(&CArmoury::Precache) }, - //{ 0x0, "_ZN8CArmoury7RestartEv", mfunc_ptr_cast(&CArmoury::Restart) }, - //{ 0x01DD0D80, "_ZN8CArmoury8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CArmoury::KeyValue) }, + { 0x01DD0E50, "_ZN8CArmoury5SpawnEv", mfunc_ptr_cast(&CArmoury::Spawn_) }, + { 0x01DD1230, "_ZN8CArmoury8PrecacheEv", mfunc_ptr_cast(&CArmoury::Precache_) }, + { 0x01DD10A0, "_ZN8CArmoury7RestartEv", mfunc_ptr_cast(&CArmoury::Restart_) }, + { 0x01DD0D80, "_ZN8CArmoury8KeyValueEP14KeyValueData_s", mfunc_ptr_cast(&CArmoury::KeyValue_) }, //non-virtual func - //{ 0x0, "armoury_entity", (size_t)&armoury_entity }, + { 0x01DD0E00, "armoury_entity", (size_t)&armoury_entity }, //{ 0x0, "_ZN8CArmoury12ArmouryTouchEP11CBaseEntity", mfunc_ptr_cast(&CArmoury::ArmouryTouch) }, #endif // Weapons_Region @@ -4386,59 +4454,56 @@ FunctionHook g_FunctionHooks[] = { 0x01D85570, "_ZN9CRecharge8RechargeEv", mfunc_ptr_cast(&CRecharge::Recharge) }, //CCycler //virtual func - //{ 0x0, "_ZN7CCycler5SpawnEv", mfunc_ptr_cast(&CCycler::Spawn_) }, - //{ 0x0, "_ZN7CCycler4SaveER5CSave", mfunc_ptr_cast(&CCycler::Save_) }, - //{ 0x0, "_ZN7CCycler7RestoreER8CRestore", mfunc_ptr_cast(&CCycler::Restore_) }, - ////{ 0x0, "_ZN7CCycler10ObjectCapsEv", mfunc_ptr_cast(&CCycler::ObjectCaps_) }, - //{ 0x0, "_ZN7CCycler10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CCycler::TakeDamage_) }, - ////{ 0x0, "_ZN7CCycler7IsAliveEv", mfunc_ptr_cast(&CCycler::IsAlive_) }, - //{ 0x0, "_ZN7CCycler5ThinkEv", mfunc_ptr_cast(&CCycler::Think_) }, - //{ 0x0, "_ZN7CCycler3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CCycler::Use_) }, + { 0x01D85AA0, "_ZN7CCycler5SpawnEv", mfunc_ptr_cast(&CCycler::Spawn_) }, + { 0x01D85630, "_ZN7CCycler4SaveER5CSave", mfunc_ptr_cast(&CCycler::Save_) }, + { 0x01D85660, "_ZN7CCycler7RestoreER8CRestore", mfunc_ptr_cast(&CCycler::Restore_) }, + { 0x01D856E0, "_ZN7CCycler10ObjectCapsEv", mfunc_ptr_cast(&CCycler::ObjectCaps_) }, + { 0x01D85C60, "_ZN7CCycler10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CCycler::TakeDamage_) }, + //{ 0x01D856F0, "_ZN7CCycler7IsAliveEv", mfunc_ptr_cast(&CCycler::IsAlive_) }, // DEFAULT + { 0x01D85B80, "_ZN7CCycler5ThinkEv", mfunc_ptr_cast(&CCycler::Think_) }, + { 0x01D85C20, "_ZN7CCycler3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CCycler::Use_) }, //non-virtual func - //{ 0x0, "_ZN7CCycler18GenericCyclerSpawnEPc6VectorS1__part_11_constprop_16", mfunc_ptr_cast(&CCycler::GenericCyclerSpawn) }, + //{ 0x01D859B0, "_ZN7CCycler18GenericCyclerSpawnEPc6VectorS1__part_11_constprop_16", mfunc_ptr_cast(&CCycler::GenericCyclerSpawn) }, // NOXREF //CCyclerProbe //virtual func - //{ 0x0, "_ZN12CCyclerProbe5SpawnEv", mfunc_ptr_cast(&CCyclerProbe::Spawn_) }, - //non-virtual func - //{ 0x01D85810, "cycler_prdroid", (size_t)&cycler_prdroid }, + { 0x01D85860, "_ZN12CCyclerProbe5SpawnEv", mfunc_ptr_cast(&CCyclerProbe::Spawn_) }, //CGenericCycler //virtual func - //{ 0x0, "_ZN14CGenericCycler5SpawnEv", mfunc_ptr_cast(&CGenericCycler::Spawn_) }, - //non-virtual func - //{ 0x01D85690, "cycler", (size_t)&cycler }, + { 0x01D85700, "_ZN14CGenericCycler5SpawnEv", mfunc_ptr_cast(&CGenericCycler::Spawn_) }, //CCyclerSprite //virtual func - //{ 0x0, "_ZN13CCyclerSprite5SpawnEv", mfunc_ptr_cast(&CCyclerSprite::Spawn_) }, - //{ 0x0, "_ZN13CCyclerSprite7RestartEv", mfunc_ptr_cast(&CCyclerSprite::Restart_) }, - //{ 0x0, "_ZN13CCyclerSprite4SaveER5CSave", mfunc_ptr_cast(&CCyclerSprite::Save_) }, - //{ 0x0, "_ZN13CCyclerSprite7RestoreER8CRestore", mfunc_ptr_cast(&CCyclerSprite::Restore_) }, - ////{ 0x01D85D70, "_ZN13CCyclerSprite10ObjectCapsEv", mfunc_ptr_cast(&CCyclerSprite::ObjectCaps_) }, - //{ 0x0, "_ZN13CCyclerSprite10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CCyclerSprite::TakeDamage_) }, - //{ 0x0, "_ZN13CCyclerSprite5ThinkEv", mfunc_ptr_cast(&CCyclerSprite::Think_) }, - //{ 0x0, "_ZN13CCyclerSprite3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CCyclerSprite::Use_) }, + { 0x01D85DE0, "_ZN13CCyclerSprite5SpawnEv", mfunc_ptr_cast(&CCyclerSprite::Spawn_) }, + { 0x01D85F00, "_ZN13CCyclerSprite7RestartEv", mfunc_ptr_cast(&CCyclerSprite::Restart_) }, + { 0x01D85D80, "_ZN13CCyclerSprite4SaveER5CSave", mfunc_ptr_cast(&CCyclerSprite::Save_) }, + { 0x01D85DB0, "_ZN13CCyclerSprite7RestoreER8CRestore", mfunc_ptr_cast(&CCyclerSprite::Restore_) }, + { 0x01D85D70, "_ZN13CCyclerSprite10ObjectCapsEv", mfunc_ptr_cast(&CCyclerSprite::ObjectCaps_) }, + { 0x01D86090, "_ZN13CCyclerSprite10TakeDamageEP9entvars_sS1_fi", mfunc_ptr_cast(&CCyclerSprite::TakeDamage_) }, + { 0x01D85FB0, "_ZN13CCyclerSprite5ThinkEv", mfunc_ptr_cast(&CCyclerSprite::Think_) }, + { 0x01D86050, "_ZN13CCyclerSprite3UseEP11CBaseEntityS1_8USE_TYPEf", mfunc_ptr_cast(&CCyclerSprite::Use_) }, //non-virtual func - //{ 0x01D85D20, "cycler_sprite", (size_t)&cycler_sprite }, - //{ 0x0, "_ZN13CCyclerSprite7AnimateEf", mfunc_ptr_cast(&CCyclerSprite::Animate) }, + //{ 0x01D86100, "_ZN13CCyclerSprite7AnimateEf", mfunc_ptr_cast(&CCyclerSprite::Animate) }, // NOXREF //CWeaponCycler //virtual func - //{ 0x0, "_ZN13CWeaponCycler5SpawnEv", mfunc_ptr_cast(&CWeaponCycler::Spawn_) }, - ////{ 0x0, "_ZN13CWeaponCycler11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CWeaponCycler::GetItemInfo_) }, - //{ 0x0, "_ZN13CWeaponCycler6DeployEv", mfunc_ptr_cast(&CWeaponCycler::Deploy_) }, - //{ 0x0, "_ZN13CWeaponCycler7HolsterEi", mfunc_ptr_cast(&CWeaponCycler::Holster_) }, - ////{ 0x0, "_ZN13CWeaponCycler9iItemSlotEv", mfunc_ptr_cast(&CWeaponCycler::iItemSlot_) }, - //{ 0x0, "_ZN13CWeaponCycler13PrimaryAttackEv", mfunc_ptr_cast(&CWeaponCycler::PrimaryAttack_) }, - //{ 0x0, "_ZN13CWeaponCycler15SecondaryAttackEv", mfunc_ptr_cast(&CWeaponCycler::SecondaryAttack_) }, - //non-virtual func - //{ 0x01D86150, "cycler_weapon", (size_t)&cycler_weapon }, + { 0x01D861F0, "_ZN13CWeaponCycler5SpawnEv", mfunc_ptr_cast(&CWeaponCycler::Spawn_) }, + //{ 0x01D861E0, "_ZN13CWeaponCycler11GetItemInfoEP8ItemInfo", mfunc_ptr_cast(&CWeaponCycler::GetItemInfo_) }, // DEFAULT + { 0x01D862D0, "_ZN13CWeaponCycler6DeployEv", mfunc_ptr_cast(&CWeaponCycler::Deploy_) }, + { 0x01D86320, "_ZN13CWeaponCycler7HolsterEi", mfunc_ptr_cast(&CWeaponCycler::Holster_) }, + //{ 0x01D861D0, "_ZN13CWeaponCycler9iItemSlotEv", mfunc_ptr_cast(&CWeaponCycler::iItemSlot_) }, // DEFAULT + { 0x01D86340, "_ZN13CWeaponCycler13PrimaryAttackEv", mfunc_ptr_cast(&CWeaponCycler::PrimaryAttack_) }, + { 0x01D86370, "_ZN13CWeaponCycler15SecondaryAttackEv", mfunc_ptr_cast(&CWeaponCycler::SecondaryAttack_) }, //CWreckage //virtual func - //{ 0x0, "_ZN9CWreckage5SpawnEv", mfunc_ptr_cast(&CWreckage::Spawn_) }, - //{ 0x0, "_ZN9CWreckage8PrecacheEv", mfunc_ptr_cast(&CWreckage::Precache_) }, - //{ 0x0, "_ZN9CWreckage4SaveER5CSave", mfunc_ptr_cast(&CWreckage::Save_) }, - //{ 0x0, "_ZN9CWreckage7RestoreER8CRestore", mfunc_ptr_cast(&CWreckage::Restore_) }, - //{ 0x0, "_ZN9CWreckage5ThinkEv", mfunc_ptr_cast(&CWreckage::Think_) }, - //non-virtual func - //{ 0x01D86480, "cycler_wreckage", (size_t)&cycler_wreckage }, + { 0x01D864D0, "_ZN9CWreckage5SpawnEv", mfunc_ptr_cast(&CWreckage::Spawn_) }, + { 0x01D86580, "_ZN9CWreckage8PrecacheEv", mfunc_ptr_cast(&CWreckage::Precache_) }, + { 0x01D86420, "_ZN9CWreckage4SaveER5CSave", mfunc_ptr_cast(&CWreckage::Save_) }, + { 0x01D86450, "_ZN9CWreckage7RestoreER8CRestore", mfunc_ptr_cast(&CWreckage::Restore_) }, + { 0x01D865B0, "_ZN9CWreckage5ThinkEv", mfunc_ptr_cast(&CWreckage::Think_) }, +//linked objects + { 0x01D85690, "cycler", (size_t)&cycler }, + { 0x01D85810, "cycler_prdroid", (size_t)&cycler_prdroid }, + { 0x01D85D20, "cycler_sprite", (size_t)&cycler_sprite }, + { 0x01D86150, "cycler_weapon", (size_t)&cycler_weapon }, + { 0x01D86480, "cycler_wreckage", (size_t)&cycler_wreckage }, #endif // H_Region @@ -4607,9 +4672,9 @@ FunctionHook g_FunctionHooks[] = //virtual func //{ 0x01DD2970, "_ZN21CBaseTutorStateSystemC2Ev", mfunc_ptr_cast(&CBaseTutorStateSystem::CBaseTutorStateSystem) }, //{ 0x01DD2980, "_ZN21CBaseTutorStateSystemD0Ev", mfunc_ptr_cast(&CBaseTutorStateSystem::~CBaseTutorStateSystem) }, - //{ 0x0, "_ZN21CBaseTutorStateSystem11UpdateStateE13GameEventTypeP11CBaseEntityS2_", mfunc_ptr_cast(&CBaseTutorStateSystem::UpdateState) }, - //{ 0x0, "_ZN21CBaseTutorStateSystem21GetCurrentStateStringEv", mfunc_ptr_cast(&CBaseTutorStateSystem::GetCurrentStateString) }, - //{ 0x0, "_ZN21CBaseTutorStateSystem17ConstructNewStateEi", mfunc_ptr_cast(&CBaseTutorStateSystem::ConstructNewState) }, + //{ 0x0, "_ZN21CBaseTutorStateSystem11UpdateStateE13GameEventTypeP11CBaseEntityS2_", mfunc_ptr_cast(&CBaseTutorStateSystem::UpdateState) }, // NOXREF PURE + //{ 0x0, "_ZN21CBaseTutorStateSystem21GetCurrentStateStringEv", mfunc_ptr_cast(&CBaseTutorStateSystem::GetCurrentStateString) }, // NOXREF PURE + //{ 0x0, "_ZN21CBaseTutorStateSystem17ConstructNewStateEi", mfunc_ptr_cast(&CBaseTutorStateSystem::ConstructNewState) }, // NOXREF PURE //non-virtual func //{ 0x01DD29B0, "_ZN21CBaseTutorStateSystem19GetCurrentStateTypeEv", mfunc_ptr_cast(&CBaseTutorStateSystem::GetCurrentStateType) }, // NOXREF //CBaseTutorState @@ -4726,6 +4791,7 @@ FunctionHook g_FunctionHooks[] = { 0x01D12570, "", mfunc_ptr_cast(&Vector::Length) }, { 0x01D4EA30, "", mfunc_ptr_cast(&Vector::Normalize) }, + { 0x01DCB800, "", mfunc_ptr_cast(&Vector::operator==) }, #endif // _WIN32 @@ -5262,12 +5328,18 @@ FunctionHook g_FunctionHooks[] = // refs for uncompleted virtual function VirtualTableRef g_TableRefs[] = { + // Weapon shared + { 0x01DF46BC, "CKnife", CWEAPON_VIRTUAL_COUNT }, + { 0x01DF46BC, "CKnife", CWEAPON_VIRTUAL_COUNT }, + { 0x01DF34E4, "CAWP", CWEAPON_VIRTUAL_COUNT }, + { 0x01DF51AC, "CP90", CWEAPON_VIRTUAL_COUNT }, + // CBaseEntity { 0x01DF8A94, "CGib", CBASE_VIRTUAL_COUNT }, { 0x01DFD824, "CBaseDelay", CBASE_VIRTUAL_COUNT }, { 0x01DF607C, "CBaseEntity", CBASE_VIRTUAL_COUNT }, { 0x01DFA894, "CGrenade", 77 }, - { 0x01DF67D4, "CBaseToggle", 60 }, + { 0x01DF67D4, "CBaseToggle", 59 }, { 0x01DF652C, "CBasePlayer", 88 }, { 0x01DF6694, "CBaseMonster", 76 }, { 0x01DFDA84, "CSprayCan", CBASE_VIRTUAL_COUNT }, @@ -5280,7 +5352,11 @@ VirtualTableRef g_TableRefs[] = { 0x01DF61DC, "CCSBot", 116 }, { 0x01DF64F0, "CCSBotManager", 12 }, { 0x01DF6C9C, "CHostage", 76 }, + { 0x01E00BBC, "CArmoury", CBASE_VIRTUAL_COUNT }, { 0x01DFE4E4, "CSoundEnt", CBASE_VIRTUAL_COUNT }, + { 0x01DFE20C, "CAmbientGeneric", CBASE_VIRTUAL_COUNT }, + { 0x01DFE2FC, "CEnvSound", CBASE_VIRTUAL_COUNT }, + { 0x01DFE3F4, "CSpeaker", CBASE_VIRTUAL_COUNT }, { 0x01E00D9C, "CCorpse", CBASE_VIRTUAL_COUNT }, { 0x01E00CAC, "CDecal", CBASE_VIRTUAL_COUNT }, { 0x01E00E8C, "CWorld", CBASE_VIRTUAL_COUNT }, @@ -5288,11 +5364,104 @@ VirtualTableRef g_TableRefs[] = { 0x01DFE9C4, "CFuncWeaponCheck", CBASE_VIRTUAL_COUNT }, { 0x01E00ACC, "CWeaponBox", CBASE_VIRTUAL_COUNT }, { 0x01DF9F94, "CShower", CBASE_VIRTUAL_COUNT }, + { 0x01DFA1BC, "CBreakable", CBASE_VIRTUAL_COUNT }, + { 0x01DFA2AC, "CPushable", CBASE_VIRTUAL_COUNT }, + + { 0x01DF7D1C, "CFuncWall", CBASE_VIRTUAL_COUNT }, + { 0x01DF7E0C, "CFuncWallToggle", CBASE_VIRTUAL_COUNT }, + { 0x01DF7EFC, "CFuncConveyor", CBASE_VIRTUAL_COUNT }, + { 0x01DF7FF4, "CFuncIllusionary", 59 }, + { 0x01DF80E4, "CFuncMonsterClip", CBASE_VIRTUAL_COUNT }, + { 0x01DF81D4, "CFuncRotating", CBASE_VIRTUAL_COUNT }, + { 0x01DF82C4, "CPendulum", CBASE_VIRTUAL_COUNT }, + + { 0x01DFAAF4, "CGenericCycler", 76 }, + { 0x01DFAC2C, "CCyclerProbe", 76 }, + { 0x01DFAD64, "CCyclerSprite", CBASE_VIRTUAL_COUNT }, + { 0x01DFAFD4, "CWreckage", 76 }, + + //{ 0x0, "CFuncTank", 60 }, + { 0x01DFA3BC, "CFuncTankGun", 60 }, + { 0x01DFA4B4, "CFuncTankLaser", 60 }, + { 0x01DFA5AC, "CFuncTankRocket", 60 }, + { 0x01DFA6A4, "CFuncTankMortar", 60 }, + { 0x01DFA79C, "CFuncTankControls", CBASE_VIRTUAL_COUNT }, + + { 0x01DF83BC, "CEnvGlobal", CBASE_VIRTUAL_COUNT }, + { 0x01DF84AC, "CMultiSource", CBASE_VIRTUAL_COUNT }, + { 0x01DF859C, "CBaseButton", 59 }, + { 0x01DF868C, "CRotButton", 59 }, + { 0x01DF877C, "CMomentaryRotButton", 59 }, + { 0x01DF886C, "CEnvSpark", CBASE_VIRTUAL_COUNT }, + { 0x01DF895C, "CButtonTarget", CBASE_VIRTUAL_COUNT }, + + { 0x01DFE5D4, "CNullEntity", CBASE_VIRTUAL_COUNT }, + { 0x01DFE6C4, "CBaseDMStart", CBASE_VIRTUAL_COUNT }, + { 0x01DF8EAC, "CPointEntity", CBASE_VIRTUAL_COUNT }, + { 0x01DFEAB4, "CFrictionModifier", CBASE_VIRTUAL_COUNT }, + { 0x01DFEBA4, "CAutoTrigger", CBASE_VIRTUAL_COUNT }, + { 0x01DFEC94, "CTriggerRelay", CBASE_VIRTUAL_COUNT }, + { 0x01DFF6E4, "CTriggerVolume", CBASE_VIRTUAL_COUNT }, + { 0x01DFF7D4, "CFireAndDie", CBASE_VIRTUAL_COUNT }, + { 0x01E00404, "CTriggerChangeTarget", CBASE_VIRTUAL_COUNT }, + { 0x01E004F4, "CTriggerCamera", CBASE_VIRTUAL_COUNT }, + { 0x01E006D4, "CClientFog", CBASE_VIRTUAL_COUNT }, + { 0x01DFEE74, "CRenderFxManager", CBASE_VIRTUAL_COUNT }, + { 0x01DFF324, "CTargetCDAudio", CBASE_VIRTUAL_COUNT }, + + { 0x01DFCD1C, "CPathCorner", CBASE_VIRTUAL_COUNT }, + { 0x01DFCE0C, "CPathTrack", CBASE_VIRTUAL_COUNT }, + { 0x01E007D4, "CFuncVehicle", CBASE_VIRTUAL_COUNT }, + { 0x01E009C4, "CFuncVehicleControls", CBASE_VIRTUAL_COUNT }, + + { 0x01DFBD4C, "CGameScore", CBASE_VIRTUAL_COUNT }, + { 0x01DFBE3C, "CGameEnd", CBASE_VIRTUAL_COUNT }, + { 0x01DFBF2C, "CGameText", CBASE_VIRTUAL_COUNT }, + { 0x01DFC01C, "CGameTeamMaster", CBASE_VIRTUAL_COUNT }, + { 0x01DFC10C, "CGameTeamSet", CBASE_VIRTUAL_COUNT }, + { 0x01DFC1FC, "CGamePlayerZone", CBASE_VIRTUAL_COUNT }, + { 0x01DFC2EC, "CGamePlayerHurt", CBASE_VIRTUAL_COUNT }, + { 0x01DFC3DC, "CGameCounter", CBASE_VIRTUAL_COUNT }, + { 0x01DFC4CC, "CGameCounterSet", CBASE_VIRTUAL_COUNT }, + { 0x01DFC5BC, "CGamePlayerEquip", CBASE_VIRTUAL_COUNT }, + { 0x01DFC6AC, "CGamePlayerTeam", CBASE_VIRTUAL_COUNT }, + + { 0x01DFCEFC, "CFuncPlat", 64 }, + { 0x01DFD0F4, "CFuncPlatRot", 64 }, + { 0x01DFD1FC, "CFuncTrain", 60 }, + { 0x01DFD2F4, "CFuncTrackTrain", CBASE_VIRTUAL_COUNT }, + { 0x01DFD3EC, "CFuncTrainControls", CBASE_VIRTUAL_COUNT }, + { 0x01DFD4DC, "CFuncTrackChange", 65 }, + { 0x01DFD5E4, "CFuncTrackAuto", 65 }, + { 0x01DFD6EC, "CGunTarget", 76 }, + { 0x01DFD004, "CPlatTrigger", CBASE_VIRTUAL_COUNT }, + + { 0x01DFED84, "CMultiManager", 59 }, + { 0x01DFEF64, "CBaseTrigger", 59 }, + { 0x01DFF054, "CTriggerHurt", 59 }, + { 0x01DFF144, "CTriggerMonsterJump", 59 }, + { 0x01DFF234, "CTriggerCDAudio", 59 }, + { 0x01DFF414, "CTriggerMultiple", 59 }, + { 0x01DFF504, "CTriggerOnce", 59 }, + { 0x01DFF5F4, "CTriggerCounter", 59 }, + { 0x01DFF8C4, "CChangeLevel", 59 }, + { 0x01DFF9B4, "CLadder", 59 }, + { 0x01DFFAA4, "CTriggerPush", 59 }, + { 0x01DFFB94, "CTriggerTeleport", 59 }, + { 0x01DFFC84, "CBuyZone", 59 }, + { 0x01DFFD74, "CBombTarget", 59 }, + { 0x01DFFE64, "CHostageRescue", 59 }, + { 0x01DFFF54, "CEscapeZone", 59 }, + { 0x01E00044, "CVIP_SafetyZone", 59 }, + { 0x01E00134, "CTriggerSave", 59 }, + { 0x01E00224, "CTriggerEndSection", 59 }, + { 0x01E00314, "CTriggerGravity", 59 }, + { 0x01E005E4, "CWeather", 59 }, + { 0x01DFA084, "CEnvExplosion", 76 }, { 0x01DFC79C, "CFuncMortarField", 59 }, { 0x01DF7204, "CAirtank", 77 }, { 0x01DFC88C, "CMortar", 77 }, - { 0x01DF7344, "C9MMAmmo", 59 }, { 0x01DF7434, "CBuckShotAmmo", 59 }, { 0x01DF7524, "C556NatoAmmo", 59 }, @@ -5304,15 +5473,19 @@ VirtualTableRef g_TableRefs[] = { 0x01DF7AC4, "C57MMAmmo", 59 }, { 0x01DF7BB4, "C357SIGAmmo", 59 }, + // doors + { 0x01DF8BDC, "CBaseDoor", 59 }, + { 0x01DF8CCC, "CRotDoor", 59 }, + { 0x01DF8DBC, "CMomentaryDoor", 59 }, + // rules { 0x01DFCBFC, "CGameRules", 63 }, { 0x01DFE10C, "CHalfLifeRules", 63 }, { 0x01DFCADC, "CHalfLifeMultiplay", 70 }, { 0x01DFE7B4, "CHalfLifeTraining", 70 }, - { 0x01DFC9D4, "CMapInfo", 0 }, + { 0x01DFC9D4, "CMapInfo", CBASE_VIRTUAL_COUNT }, // effects - { 0x01DF8EAC, "CPointEntity", CBASE_VIRTUAL_COUNT }, { 0x01DF8F9C, "CBubbling", CBASE_VIRTUAL_COUNT }, { 0x01DF908C, "CBeam", CBASE_VIRTUAL_COUNT }, { 0x01DF917C, "CLightning", CBASE_VIRTUAL_COUNT }, @@ -5357,7 +5530,6 @@ AddressRef g_FunctionRefs[] = { 0x01D3CA60, "_ZNK8CNavArea4GetZEPK6Vector", (size_t)&pGetZ__Vector }, { 0x01D43860, "_ZNK12CNavAreaGrid17GetNearestNavAreaEPK6Vectorb", (size_t)&pGetNearestNavArea }, { 0x01D43710, "_ZNK12CNavAreaGrid10GetNavAreaEPK6Vectorf", (size_t)&pGetNavArea }, - { 0x01D72480, "_ZN11CBaseEntity12FireBullets3E6VectorS0_ffiiifP9entvars_sbi", (size_t)&pFireBullets3 }, { 0x01D2EDD0, "_ZN6CCSBot16UpdateLookAnglesEv", (size_t)&pCCSBot__UpdateLookAngles }, { 0x01D2D9B0, "_ZN6CCSBot6UpdateEv", (size_t)&pCCSBot__Update }, { 0x01D5B350, "_Z16QuaternionMatrixPfPA4_f", (size_t)&pQuaternionMatrix }, @@ -5368,7 +5540,6 @@ AddressRef g_FunctionRefs[] = { 0x01D19C70, "_ZN9BotPhrase9RandomizeEv", (size_t)&pBotPhrase__Randomize }, { 0x01D25270, "_ZN13CCSBotManager6AddBotEPK10BotProfile18BotProfileTeamType", (size_t)&pCCSBotManager__AddBot }, - { 0x01D6EAB0, "_ZN4CGib12SpawnHeadGibEP9entvars_s", (size_t)&pCGib__SpawnHeadGib }, { 0x01D3A060, "_Z20DestroyNavigationMapv", (size_t)&pDestroyNavigationMap }, { 0x01D80C90, "_Z16InstallGameRulesv", (size_t)&pInstallGameRules }, { 0x01D4C450, "_ZN8CHostage9IdleThinkEv", (size_t)&pCHostage__IdleThink }, @@ -5396,6 +5567,8 @@ AddressRef g_DataRefs[] = { 0x01E61BBC, "g_iSkillLevel", (size_t)&pg_iSkillLevel }, { 0x01E61B9C, "gDisplayTitle", (size_t)&pgDisplayTitle }, { 0x01E61BA0, "g_fGameOver", (size_t)&pg_fGameOver }, + { 0x01E754B8, "st_szNextMap", (size_t)&pst_szNextMap }, + { 0x01E75498, "st_szNextSpot", (size_t)&pst_szNextSpot }, { 0x01E683A0, "gSkillData", (size_t)&pgSkillData }, { 0x01E75EC8, "g_sModelIndexLaser", (size_t)&pg_sModelIndexLaser }, { 0x01E227A8, "g_pModelNameLaser", (size_t)&pg_pModelNameLaser }, @@ -5441,7 +5614,7 @@ AddressRef g_DataRefs[] = { 0x01E683E0, "rgsentenceg", (size_t)&prgsentenceg }, { 0x01E75480, "fSentencesInit", (size_t)&pfSentencesInit }, { 0x01E75484, "gcallsentences", (size_t)&pgcallsentences }, - + { 0x01E1F5B0, "rgdpvpreset", (size_t)&prgdpvpreset }, { 0x01E75488, "fTextureTypeInit", (size_t)&pfTextureTypeInit }, { 0x01E7548C, "gcTextures_1", (size_t)&pgcTextures }, @@ -5664,10 +5837,9 @@ AddressRef g_DataRefs[] = { 0x01E10738, "g_flBotCommandInterval", (size_t)&pg_flBotCommandInterval }, { 0x01E1073C, "g_flBotFullThinkInterval", (size_t)&pg_flBotFullThinkInterval }, - + { 0x01E61B44, "_ZL11gTankSpread", (size_t)&pgTankSpread }, { 0x01E28A20, "BotArgs", (size_t)&pBotArgs }, { 0x01E28A30, "UseBotArgs", (size_t)&pUseBotArgs }, - { 0x01E1E040, "g_weaponStruct", (size_t)&pg_weaponStruct }, { 0x01E0EFF8, "cv_bot_traceview", (size_t)&pcv_bot_traceview }, @@ -5699,7 +5871,6 @@ AddressRef g_DataRefs[] = { 0x01E0F200, "cv_bot_defer_to_human", (size_t)&pcv_bot_defer_to_human }, { 0x01E0F214, "cv_bot_chatter", (size_t)&pcv_bot_chatter }, { 0x01E0F228, "cv_bot_profile_db", (size_t)&pcv_bot_profile_db }, - { 0x01E233BC, "cv_tutor_message_repeats", (size_t)&pcv_tutor_message_repeats }, { 0x01E233D0, "cv_tutor_debug_level", (size_t)&pcv_tutor_debug_level }, { 0x01E233E4, "cv_tutor_view_distance", (size_t)&pcv_tutor_view_distance }, @@ -5720,67 +5891,65 @@ AddressRef g_DataRefs[] = { 0x01E2A3E0, "_ZN9CLocalNav11tot_inqueueE", mfunc_ptr_cast(&CLocalNav::ptot_inqueue) }, { 0x01E2A3DC, "_ZN9CLocalNav4qptrE", mfunc_ptr_cast(&CLocalNav::pqptr) }, { 0x01E2A338, "_ZN9CLocalNav5queueE", mfunc_ptr_cast(&CLocalNav::pqueue) }, - { 0x01E287F8, "_ZL12navAreaCount", (size_t)&pnavAreaCount }, { 0x01E287FC, "_ZL12currentIndex", (size_t)&pcurrentIndex }, - - //{ 0x0, "_ZN10CBreakable13pSpawnObjectsE", mfunc_ptr_cast(&CBreakable::ppSpawnObjects) }, - //{ 0x0, "_ZN10CBreakable11pSoundsWoodE", mfunc_ptr_cast(&CBreakable::ppSoundsWood) }, - //{ 0x0, "_ZN10CBreakable12pSoundsFleshE", mfunc_ptr_cast(&CBreakable::ppSoundsFlesh) }, - //{ 0x0, "_ZN10CBreakable12pSoundsMetalE", mfunCBaseEntity::Savec_ptr_cast(&CBreakable::ppSoundsMetal) }, - //{ 0x0, "_ZN10CBreakable15pSoundsConcreteE", mfunc_ptr_cast(&CBreakable::ppSoundsConcrete) }, - //{ 0x0, "_ZN10CBreakable12pSoundsGlassE", mfunc_ptr_cast(&CBreakable::ppSoundsGlass) }, - //{ 0x0, "_ZN9CPushable12m_soundNamesE", mfunc_ptr_cast(&CPushable::pm_soundNames) }, + { 0x01E17AD0, "_ZN10CBreakable13pSpawnObjectsE", mfunc_ptr_cast(&CBreakable::ppSpawnObjects) }, + { 0x01E17BA0, "_ZN10CBreakable11pSoundsWoodE", mfunc_ptr_cast(&CBreakable::ppSoundsWood) }, + { 0x01E17BAC, "_ZN10CBreakable12pSoundsFleshE", mfunc_ptr_cast(&CBreakable::ppSoundsFlesh) }, + { 0x01E17BC4, "_ZN10CBreakable12pSoundsMetalE", mfunc_ptr_cast(&CBreakable::ppSoundsMetal) }, + { 0x01E17BD0, "_ZN10CBreakable15pSoundsConcreteE", mfunc_ptr_cast(&CBreakable::ppSoundsConcrete) }, + { 0x01E17BDC, "_ZN10CBreakable12pSoundsGlassE", mfunc_ptr_cast(&CBreakable::ppSoundsGlass) }, + { 0x01E17C08, "_ZN9CPushable12m_soundNamesE", mfunc_ptr_cast(&CPushable::pm_soundNames) }, { 0x01E1E00C, "_ZN8CDeadHEV9m_szPosesE", mfunc_ptr_cast(&CDeadHEV::pm_szPoses) }, { 0x01E1DD88, "_ZN11CBasePlayer16m_playerSaveDataE", mfunc_ptr_cast(&CBasePlayer::pm_playerSaveData) }, { 0x01E14A68, "_ZN11CBaseEntity10m_SaveDataE", mfunc_ptr_cast(&CBaseEntity::pm_SaveData) }, { 0x01E22DAC, "_ZN12CGlobalState10m_SaveDataE", mfunc_ptr_cast(&CGlobalState::pm_SaveData) }, - //{ 0x0, "_ZN9CEnvSpark10m_SaveDataE", mfunc_ptr_cast(&CEnvSpark::pm_SaveData) }, - //{ 0x0, "_ZN19CMomentaryRotButton10m_SaveDataE", mfunc_ptr_cast(&CMomentaryRotButton::pm_SaveData) }, - //{ 0x0, "_ZN10CEnvGlobal10m_SaveDataE", mfunc_ptr_cast(&CEnvGlobal::pm_SaveData) }, + { 0x01E14390, "_ZN9CEnvSpark10m_SaveDataE", mfunc_ptr_cast(&CEnvSpark::pm_SaveData) }, + { 0x01E14330, "_ZN19CMomentaryRotButton10m_SaveDataE", mfunc_ptr_cast(&CMomentaryRotButton::pm_SaveData) }, + { 0x01E14240, "_ZN10CEnvGlobal10m_SaveDataE", mfunc_ptr_cast(&CEnvGlobal::pm_SaveData) }, { 0x01E1B4C0, "_ZN8CGrenade10m_SaveDataE", mfunc_ptr_cast(&CGrenade::pm_SaveData) }, - //{ 0x0, "_ZN9CWreckage10m_SaveDataE", mfunc_ptr_cast(&CWreckage::pm_SaveData) }, - //{ 0x0, "_ZN13CCyclerSprite10m_SaveDataE", mfunc_ptr_cast(&CCyclerSprite::pm_SaveData) }, - //{ 0x0, "_ZN7CCycler10m_SaveDataE", mfunc_ptr_cast(&CCycler::pm_SaveData) }, + { 0x01E1B998, "_ZN9CWreckage10m_SaveDataE", mfunc_ptr_cast(&CWreckage::pm_SaveData) }, + { 0x01E1B968, "_ZN13CCyclerSprite10m_SaveDataE", mfunc_ptr_cast(&CCyclerSprite::pm_SaveData) }, + { 0x01E1B958, "_ZN7CCycler10m_SaveDataE", mfunc_ptr_cast(&CCycler::pm_SaveData) }, { 0x01E1BE38, "_ZN6CLight10m_SaveDataE", mfunc_ptr_cast(&CLight::pm_SaveData) }, { 0x01E1BB00, "_ZN11CWallHealth10m_SaveDataE", mfunc_ptr_cast(&CWallHealth::pm_SaveData) }, { 0x01E1B850, "_ZN9CRecharge10m_SaveDataE", mfunc_ptr_cast(&CRecharge::pm_SaveData) }, { 0x01E1C248, "_ZN16CFuncMortarField10m_SaveDataE", mfunc_ptr_cast(&CFuncMortarField::pm_SaveData) }, { 0x01E17A08, "_ZN13CEnvExplosion10m_SaveDataE", mfunc_ptr_cast(&CEnvExplosion::pm_SaveData) }, - //{ 0x0, "_ZN13CFuncRotating10m_SaveDataE", mfunc_ptr_cast(&CFuncRotating::pm_SaveData) }, - //{ 0x0, "_ZN9CPendulum10m_SaveDataE", mfunc_ptr_cast(&CPendulum::pm_SaveData) }, - //{ 0x0, "_ZN9CBaseDoor10m_SaveDataE", mfunc_ptr_cast(&CBaseDoor::pm_SaveData) }, - //{ 0x0, "_ZN14CMomentaryDoor10m_SaveDataE", mfunc_ptr_cast(&CMomentaryDoor::pm_SaveData) }, - //{ 0x0, "_ZN10CBreakable10m_SaveDataE", mfunc_ptr_cast(&CBreakable::pm_SaveData) }, - //{ 0x0, "_ZN9CPushable10m_SaveDataE", mfunc_ptr_cast(&CPushable::pm_SaveData) }, - //{ 0x0, "_ZN9CFuncTank10m_SaveDataE", mfunc_ptr_cast(&CFuncTank::pm_SaveData) }, - //{ 0x0, "_ZN14CFuncTankLaser10m_SaveDataE", mfunc_ptr_cast(&CFuncTankLaser::pm_SaveData) }, - //{ 0x0, "_ZN17CFuncTankControls10m_SaveDataE", mfunc_ptr_cast(&CFuncTankControls::pm_SaveData) }, - //{ 0x0, "_ZN12CFuncVehicle10m_SaveDataE", mfunc_ptr_cast(&CFuncVehicle::pm_SaveData) }, - //{ 0x0, "_ZN11CPathCorner10m_SaveDataE", mfunc_ptr_cast(&CPathCorner::pm_SaveData) }, - //{ 0x0, "_ZN10CPathTrack10m_SaveDataE", mfunc_ptr_cast(&CPathTrack::pm_SaveData) }, + { 0x01E13F38, "_ZN13CFuncRotating10m_SaveDataE", mfunc_ptr_cast(&CFuncRotating::pm_SaveData) }, + { 0x01E13F88, "_ZN9CPendulum10m_SaveDataE", mfunc_ptr_cast(&CPendulum::pm_SaveData) }, + { 0x01E16FB0, "_ZN9CBaseDoor10m_SaveDataE", mfunc_ptr_cast(&CBaseDoor::pm_SaveData) }, + { 0x01E17020, "_ZN14CMomentaryDoor10m_SaveDataE", mfunc_ptr_cast(&CMomentaryDoor::pm_SaveData) }, + { 0x01E17B50, "_ZN10CBreakable10m_SaveDataE", mfunc_ptr_cast(&CBreakable::pm_SaveData) }, + { 0x01E17BE8, "_ZN9CPushable10m_SaveDataE", mfunc_ptr_cast(&CPushable::pm_SaveData) }, + { 0x01E18180, "_ZN9CFuncTank10m_SaveDataE", mfunc_ptr_cast(&CFuncTank::pm_SaveData) }, + { 0x01E18320, "_ZN14CFuncTankLaser10m_SaveDataE", mfunc_ptr_cast(&CFuncTankLaser::pm_SaveData) }, + { 0x01E18340, "_ZN17CFuncTankControls10m_SaveDataE", mfunc_ptr_cast(&CFuncTankControls::pm_SaveData) }, + { 0x01E22408, "_ZN12CFuncVehicle10m_SaveDataE", mfunc_ptr_cast(&CFuncVehicle::pm_SaveData) }, + { 0x01E1D2D8, "_ZN11CPathCorner10m_SaveDataE", mfunc_ptr_cast(&CPathCorner::pm_SaveData) }, + { 0x01E1D2E8, "_ZN10CPathTrack10m_SaveDataE", mfunc_ptr_cast(&CPathTrack::pm_SaveData) }, { 0x01E1E01C, "_ZN12CRevertSaved10m_SaveDataE", mfunc_ptr_cast(&CRevertSaved::pm_SaveData) }, - //{ 0x0, "_ZN11CRuleEntity10m_SaveDataE", mfunc_ptr_cast(&CRuleEntity::pm_SaveData) }, - //{ 0x0, "_ZN9CGameText10m_SaveDataE", mfunc_ptr_cast(&CGameText::pm_SaveData) }, - //{ 0x0, "_ZN15CGamePlayerZone10m_SaveDataE", mfunc_ptr_cast(&CGamePlayerZone::pm_SaveData) }, - //{ 0x0, "_ZN17CFrictionModifier10m_SaveDataE", mfunc_ptr_cast(&CFrictionModifier::pm_SaveData) }, - //{ 0x0, "_ZN12CAutoTrigger10m_SaveDataE", mfunc_ptr_cast(&CAutoTrigger::pm_SaveData) }, - //{ 0x0, "_ZN13CTriggerRelay10m_SaveDataE", mfunc_ptr_cast(&CTriggerRelay::pm_SaveData) }, - //{ 0x0, "_ZN13CMultiManager10m_SaveDataE", mfunc_ptr_cast(&CMultiManager::pm_SaveData) }, - //{ 0x0, "_ZN12CChangeLevel10m_SaveDataE", mfunc_ptr_cast(&CChangeLevel::pm_SaveData) }, - //{ 0x0, "_ZN20CTriggerChangeTarget10m_SaveDataE", mfunc_ptr_cast(&CTriggerChangeTarget::pm_SaveData) }, - //{ 0x0, "_ZN14CTriggerCamera10m_SaveDataE", mfunc_ptr_cast(&CTriggerCamera::pm_SaveData) }, + { 0x01E1BF38, "_ZN11CRuleEntity10m_SaveDataE", mfunc_ptr_cast(&CRuleEntity::pm_SaveData) }, + { 0x01E1BF48, "_ZN9CGameText10m_SaveDataE", mfunc_ptr_cast(&CGameText::pm_SaveData) }, + { 0x01E1BF58, "_ZN15CGamePlayerZone10m_SaveDataE", mfunc_ptr_cast(&CGamePlayerZone::pm_SaveData) }, + { 0x01E20B10, "_ZN17CFrictionModifier10m_SaveDataE", mfunc_ptr_cast(&CFrictionModifier::pm_SaveData) }, + { 0x01E20B20, "_ZN12CAutoTrigger10m_SaveDataE", mfunc_ptr_cast(&CAutoTrigger::pm_SaveData) }, + { 0x01E20B40, "_ZN13CTriggerRelay10m_SaveDataE", mfunc_ptr_cast(&CTriggerRelay::pm_SaveData) }, + { 0x01E20B50, "_ZN13CMultiManager10m_SaveDataE", mfunc_ptr_cast(&CMultiManager::pm_SaveData) }, + { 0x01E20BA0, "_ZN12CChangeLevel10m_SaveDataE", mfunc_ptr_cast(&CChangeLevel::pm_SaveData) }, + { 0x01E20BE0, "_ZN20CTriggerChangeTarget10m_SaveDataE", mfunc_ptr_cast(&CTriggerChangeTarget::pm_SaveData) }, + { 0x01E20BF0, "_ZN14CTriggerCamera10m_SaveDataE", mfunc_ptr_cast(&CTriggerCamera::pm_SaveData) }, { 0x01E208D8, "_ZN16CFuncWeaponCheck10m_SaveDataE", mfunc_ptr_cast(&CFuncWeaponCheck::pm_SaveData) }, { 0x01E20888, "_ZN14CBaseGrenCatch10m_SaveDataE", mfunc_ptr_cast(&CBaseGrenCatch::pm_SaveData) }, { 0x01E13228, "_ZN8CAirtank10m_SaveDataE", mfunc_ptr_cast(&CAirtank::pm_SaveData) }, - //{ 0x0, "_ZN12CMultiSource10m_SaveDataE", mfunc_ptr_cast(&CMultiSource::pm_SaveData) }, + { 0x01E14270, "_ZN12CMultiSource10m_SaveDataE", mfunc_ptr_cast(&CMultiSource::pm_SaveData) }, { 0x01E20538, "_ZN10CBaseDelay10m_SaveDataE", mfunc_ptr_cast(&CBaseDelay::pm_SaveData) }, { 0x01E13438, "_ZN14CBaseAnimating10m_SaveDataE", mfunc_ptr_cast(&CBaseAnimating::pm_SaveData) }, { 0x01E20558, "_ZN11CBaseToggle10m_SaveDataE", mfunc_ptr_cast(&CBaseToggle::pm_SaveData) }, - //{ 0x0, "_ZN11CBaseButton10m_SaveDataE", mfunc_ptr_cast(&CBaseButton::pm_SaveData) }, - //{ 0x0, "_ZN15CAmbientGeneric10m_SaveDataE", mfunc_ptr_cast(&CAmbientGeneric::pm_SaveData) }, - //{ 0x0, "_ZN9CEnvSound10m_SaveDataE", mfunc_ptr_cast(&CEnvSound::pm_SaveData) }, - //{ 0x0, "_ZN8CSpeaker10m_SaveDataE", mfunc_ptr_cast(&CSpeaker::pm_SaveData) }, + { 0x01E142B0, "_ZN11CBaseButton10m_SaveDataE", mfunc_ptr_cast(&CBaseButton::pm_SaveData) }, + { 0x01E20040, "_ZN15CAmbientGeneric10m_SaveDataE", mfunc_ptr_cast(&CAmbientGeneric::pm_SaveData) }, + { 0x01E20080, "_ZN9CEnvSound10m_SaveDataE", mfunc_ptr_cast(&CEnvSound::pm_SaveData) }, + { 0x01E200A0, "_ZN8CSpeaker10m_SaveDataE", mfunc_ptr_cast(&CSpeaker::pm_SaveData) }, { 0x01E17258, "_ZN9CBubbling10m_SaveDataE", mfunc_ptr_cast(&CBubbling::pm_SaveData) }, { 0x01E17288, "_ZN10CLightning10m_SaveDataE", mfunc_ptr_cast(&CLightning::pm_SaveData) }, { 0x01E17358, "_ZN6CLaser10m_SaveDataE", mfunc_ptr_cast(&CLaser::pm_SaveData) }, @@ -5790,12 +5959,12 @@ AddressRef g_DataRefs[] = { 0x01E227AC, "_ZN15CBasePlayerItem10m_SaveDataE", mfunc_ptr_cast(&CBasePlayerItem::pm_SaveData) }, { 0x01E227E0, "_ZN17CBasePlayerWeapon10m_SaveDataE", mfunc_ptr_cast(&CBasePlayerWeapon::pm_SaveData) }, { 0x01E22850, "_ZN10CWeaponBox10m_SaveDataE", mfunc_ptr_cast(&CWeaponBox::pm_SaveData) }, - //{ 0x0, "_ZN14CBasePlatTrain10m_SaveDataE", mfunc_ptr_cast(&CBasePlatTrain::pm_SaveData) }, - //{ 0x0, "_ZN12CFuncPlatRot10m_SaveDataE", mfunc_ptr_cast(&CFuncPlatRot::pm_SaveData) }, - //{ 0x0, "_ZN10CFuncTrain10m_SaveDataE", mfunc_ptr_cast(&CFuncTrain::pm_SaveData) }, - //{ 0x0, "_ZN15CFuncTrackTrain10m_SaveDataE", mfunc_ptr_cast(&CFuncTrackTrain::pm_SaveData) }, - //{ 0x0, "_ZN16CFuncTrackChange10m_SaveDataE", mfunc_ptr_cast(&CFuncTrackChange::pm_SaveData) }, - //{ 0x0, "_ZN10CGunTarget10m_SaveDataE", mfunc_ptr_cast(&CGunTarget::pm_SaveData) }, + { 0x01E1D420, "_ZN14CBasePlatTrain10m_SaveDataE", mfunc_ptr_cast(&CBasePlatTrain::pm_SaveData) }, + { 0x01E1D450, "_ZN12CFuncPlatRot10m_SaveDataE", mfunc_ptr_cast(&CFuncPlatRot::pm_SaveData) }, + { 0x01E1D470, "_ZN10CFuncTrain10m_SaveDataE", mfunc_ptr_cast(&CFuncTrain::pm_SaveData) }, + { 0x01E1D4A0, "_ZN15CFuncTrackTrain10m_SaveDataE", mfunc_ptr_cast(&CFuncTrackTrain::pm_SaveData) }, + { 0x01E1D560, "_ZN16CFuncTrackChange10m_SaveDataE", mfunc_ptr_cast(&CFuncTrackChange::pm_SaveData) }, + { 0x01E1D5F0, "_ZN10CGunTarget10m_SaveDataE", mfunc_ptr_cast(&CGunTarget::pm_SaveData) }, { 0x01E75FE0, "_ZN15CBasePlayerItem13ItemInfoArrayE", mfunc_ptr_cast(&CBasePlayerItem::pItemInfoArray) }, { 0x01E75ED8, "_ZN15CBasePlayerItem13AmmoInfoArrayE", mfunc_ptr_cast(&CBasePlayerItem::pAmmoInfoArray) }, { 0x01E28816, "_ZN13CCSBotManager17m_isMapDataLoadedE", mfunc_ptr_cast(&CCSBotManager::pm_isMapDataLoaded) }, @@ -5803,18 +5972,16 @@ AddressRef g_DataRefs[] = { 0x01E2881C, "_ZN13CCSBotManager17m_flNextCVarCheckE", mfunc_ptr_cast(&CCSBotManager::pm_flNextCVarCheck) }, { 0x01E28814, "_ZN13CCSBotManager15m_isLearningMapE", mfunc_ptr_cast(&CCSBotManager::pm_isLearningMap) }, { 0x01E28815, "_ZN13CCSBotManager21m_isAnalysisRequestedE", mfunc_ptr_cast(&CCSBotManager::pm_isAnalysisRequested) }, - - //{ 0x01E233BC, "cv_tutor_message_repeats", (size_t)&pcv_tutor_message_repeats }, - //{ 0x01E233D0, "cv_tutor_debug_level", (size_t)&pcv_tutor_debug_level }, - //{ 0x01E233E4, "cv_tutor_view_distance", (size_t)&pcv_tutor_view_distance }, - //{ 0x01E233F8, "cv_tutor_viewable_check_interval", (size_t)&pcv_tutor_viewable_check_interval }, - //{ 0x01E2340C, "cv_tutor_look_distance", (size_t)&pcv_tutor_look_distance }, - //{ 0x01E23420, "cv_tutor_look_angle", (size_t)&pcv_tutor_look_angle }, - //{ 0x01E23434, "cv_tutor_examine_time", (size_t)&pcv_tutor_examine_time }, - //{ 0x01E23448, "cv_tutor_message_minimum_display_time", (size_t)&pcv_tutor_message_minimum_display_time }, - //{ 0x01E2345C, "cv_tutor_message_character_display_time_coefficient", (size_t)&pcv_tutor_message_character_display_time_coefficient }, - //{ 0x01E23470, "cv_tutor_hint_interval_time", (size_t)&pcv_tutor_hint_interval_time }, - + { 0x01E233BC, "cv_tutor_message_repeats", (size_t)&pcv_tutor_message_repeats }, + { 0x01E233D0, "cv_tutor_debug_level", (size_t)&pcv_tutor_debug_level }, + { 0x01E233E4, "cv_tutor_view_distance", (size_t)&pcv_tutor_view_distance }, + { 0x01E233F8, "cv_tutor_viewable_check_interval", (size_t)&pcv_tutor_viewable_check_interval }, + { 0x01E2340C, "cv_tutor_look_distance", (size_t)&pcv_tutor_look_distance }, + { 0x01E23420, "cv_tutor_look_angle", (size_t)&pcv_tutor_look_angle }, + { 0x01E23434, "cv_tutor_examine_time", (size_t)&pcv_tutor_examine_time }, + { 0x01E23448, "cv_tutor_message_minimum_display_time", (size_t)&pcv_tutor_message_minimum_display_time }, + { 0x01E2345C, "cv_tutor_message_character_display_time_coefficient", (size_t)&pcv_tutor_message_character_display_time_coefficient }, + { 0x01E23470, "cv_tutor_hint_interval_time", (size_t)&pcv_tutor_hint_interval_time }, { 0x01E11EE4, "cv_hostage_debug", (size_t)&pcv_hostage_debug }, { 0x01E11EF8, "cv_hostage_stop", (size_t)&pcv_hostage_stop }, diff --git a/regamedll/hookers/hooker.cpp b/regamedll/hookers/hooker.cpp index 5579e5ab..25548b4d 100644 --- a/regamedll/hookers/hooker.cpp +++ b/regamedll/hookers/hooker.cpp @@ -77,7 +77,7 @@ void *GetFunctionEntity(const char *szClassName) return Sys_GetProcAddress((HMODULE)g_GameDLLModule.base, szClassName); } -void printAddrRebase(size_t addr,const char *funcName) +void printAddrRebase(size_t addr, const char *funcName) { static int inum = 0; addr += g_BaseOffset - g_GameDLLModule.base; @@ -160,8 +160,8 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address *)refData, g_BaseOffset)) { -#if _DEBUG - printf(__FUNCTION__ ": symbol not found \"%s\", symbol index: %i\n", refData->symbolName, refData->symbolIndex); +#if defined(_DEBUG) || !defined(_WIN32) + _logf(__FUNCTION__ ": symbol not found \"%s\", symbol index: %i\n", refData->symbolName, refData->symbolIndex); success = false; #endif // _DEBUG } @@ -173,8 +173,8 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address *)refFunc, g_BaseOffset)) { -#if _DEBUG - printf(__FUNCTION__ ": symbol not found \"%s\", symbol index: %i\n", refFunc->symbolName, refFunc->symbolIndex); +#if defined(_DEBUG) || !defined(_WIN32) + _logf(__FUNCTION__ ": symbol not found \"%s\", symbol index: %i\n", refFunc->symbolName, refFunc->symbolIndex); success = false; #endif // _DEBUG } @@ -186,8 +186,8 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address*)hookFunc, g_BaseOffset)) { -#if _DEBUG - printf(__FUNCTION__ ": symbol not found \"%s\", symbol index: %i\n", hookFunc->symbolName, hookFunc->symbolIndex); +#if defined(_DEBUG) || !defined(_WIN32) + _logf(__FUNCTION__ ": symbol not found \"%s\", symbol index: %i\n", hookFunc->symbolName, hookFunc->symbolIndex); success = false; #endif // _DEBUG } @@ -199,8 +199,8 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address *)refVtbl, g_BaseOffset)) { -#if _DEBUG - printf(__FUNCTION__ ": symbol not found \"%s\"\n", refVtbl->symbolName); +#if defined(_DEBUG) || !defined(_WIN32) + _logf(__FUNCTION__ ": symbol not found \"%s\"\n", refVtbl->symbolName); success = false; #endif // _DEBUG } @@ -209,8 +209,8 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) if (!success) { -#if _DEBUG - printf(__FUNCTION__ ": failed to hook gamedll!\n"); +#if defined(_DEBUG) || !defined(_WIN32) + _logf(__FUNCTION__ ": failed to hook gamedll!\n"); #endif // _DEBUG return (FALSE); } diff --git a/regamedll/hookers/hooker.h b/regamedll/hookers/hooker.h index d1450900..0d4307d7 100644 --- a/regamedll/hookers/hooker.h +++ b/regamedll/hookers/hooker.h @@ -12,3 +12,11 @@ extern void *GetOriginalFuncAddrOrDie(const char *funcName); extern void *GetOriginalFuncAddrOrDefault(const char *funcName, void *def); extern void *GetFuncRefAddrOrDie(const char *funcName); extern void *GetFuncRefAddrOrDefault(const char *funcName, void *def); + +#if defined(HOOK_GAMEDLL) && !defined(REGAMEDLL_UNIT_TESTS) + +extern void Regamedll_Game_Init(void); +extern void _printf2(const char *fmt, ...); +extern void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...); + +#endif // HOOK_GAMEDLL diff --git a/regamedll/hookers/memory.cpp b/regamedll/hookers/memory.cpp index 43cad5e0..061df5ec 100644 --- a/regamedll/hookers/memory.cpp +++ b/regamedll/hookers/memory.cpp @@ -725,7 +725,7 @@ bool HIDDEN HookFunction(Module *module, FunctionHook *hook) *(size_t *)&patch[1] = hook->handlerFunc - hook->originalAddress - 5; patch[0] = 0xE9; -#if 0 +#if 1 if (strcmp(hook->symbolName,"_ZNK9BotPhrase12GetSpeakableEiPf")==0) { addr_orig = (void *)hook->originalAddress; diff --git a/regamedll/hookers/osconfig.h b/regamedll/hookers/osconfig.h index d9d02f83..32ef578d 100644 --- a/regamedll/hookers/osconfig.h +++ b/regamedll/hookers/osconfig.h @@ -184,7 +184,7 @@ #define HIDDEN __attribute__((visibility("hidden"))) #define _DLLEXPORT __attribute__((visibility("default"))) #define _DECL_NAKED __attribute__((naked)) - #define C_DLLEXPORT extern "C" + #define C_DLLEXPORT extern "C" __attribute__((visibility("default"))) typedef int SOCKET; #define INVALID_SOCKET (SOCKET)(~0) diff --git a/regamedll/hookers/regamedll_debug.cpp b/regamedll/hookers/regamedll_debug.cpp index 0c9693a2..58763852 100644 --- a/regamedll/hookers/regamedll_debug.cpp +++ b/regamedll/hookers/regamedll_debug.cpp @@ -2,45 +2,6 @@ std::ofstream g_ReGameDLLDebugLog; -void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...) -{ - static char Dest[4096]; - - va_list ap; - va_start(ap, fmt); - vsnprintf(Dest, sizeof(Dest), fmt, ap); - va_end(ap); - - if (Q_strlen(Dest) < sizeof(Dest) - 2) - Q_strcat(Dest, "\n"); - - else Dest[Q_strlen(Dest) - 1] = '\n'; - - UTIL_SayText(Dest, (class CBaseEntity *)pPlayer); -} - -void _printf2(const char *fmt, ...) -{ - /* - * check is null, test the demo started before than searches pointer to refs - */ - if (&g_engfuncs == NULL || g_engfuncs.pfnServerPrint == NULL) - return; - - static char Dest[4096]; - va_list ap; - va_start(ap, fmt); - vsnprintf(Dest, sizeof(Dest), fmt, ap); - va_end(ap); - - if (Q_strlen(Dest) < sizeof(Dest) - 2) - Q_strcat(Dest, "\n"); - - else Dest[Q_strlen(Dest) - 1] = '\n'; - - SERVER_PRINT(Dest); -} - void Regamedll_Debug_logAlloc(size_t sz, void *ptr) { g_ReGameDLLDebugLog << "malloc(" << sz << ") => " << std::hex << (size_t)ptr << "\n"; @@ -65,20 +26,62 @@ void Regamedll_Debug_logStrDup(const char *s, void *ptr) g_ReGameDLLDebugLog.flush(); } -#if defined(_WIN32) && !defined(REGAMEDLL_UNIT_TESTS) - -extern int nCountHook; - -void Regamedll_Game_Init(void) -{ - if (!g_ReGameDLLRuntimeConfig.disableAllHooks) - printf2("[Hooker]: The total number hooks of functions is - %d", nCountHook); -} - -#endif // _WIN32 && REGAMEDLL_UNIT_TESTS - void Regamedll_Debug_Init(void) { //g_ReGameDLLDebugLog.exceptions(std::ios::badbit | std::ios::failbit); //g_ReGameDLLDebugLog.open("d:\\REGAME_SERVER\\regamedll_debug.log", std::ios::out | std::ios::binary); } + +void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...) +{ + static char Dest[4096]; + + va_list ap; + va_start(ap, fmt); + vsnprintf(Dest, sizeof(Dest), fmt, ap); + va_end(ap); + + if (Q_strlen(Dest) < sizeof(Dest) - 2) + Q_strcat(Dest, "\n"); + + else Dest[Q_strlen(Dest) - 1] = '\n'; + + UTIL_SayText(Dest, (class CBaseEntity *)pPlayer); +} + +void _printf2(const char *fmt, ...) +{ + /* + * check is null, test the demo started before than searches pointer to refs + */ + if (&g_engfuncs == NULL || g_engfuncs.pfnServerPrint == NULL) + return; + + static char Dest[4096]; + va_list ap; + va_start(ap, fmt); + vsnprintf(Dest, sizeof(Dest), fmt, ap); + va_end(ap); + + if (Q_strlen(Dest) < sizeof(Dest) - 2) + Q_strcat(Dest, "\n"); + + else Dest[Q_strlen(Dest) - 1] = '\n'; + + SERVER_PRINT(Dest); +} + +#if defined(HOOK_GAMEDLL) && !defined(REGAMEDLL_UNIT_TESTS) +extern int nCountHook; + +void Regamedll_Game_Init(void) +{ +#ifdef _WIN32 + if (g_ReGameDLLRuntimeConfig.disableAllHooks) + return; +#endif // _WIN32 + + _printf2("[Hooker]: The total number hooks of functions is - %d", nCountHook); +} +#endif // HOOK_GAMEDLL + diff --git a/regamedll/hookers/regamedll_debug.h b/regamedll/hookers/regamedll_debug.h index 7e3ef2b5..d1eca4ec 100644 --- a/regamedll/hookers/regamedll_debug.h +++ b/regamedll/hookers/regamedll_debug.h @@ -12,11 +12,11 @@ extern void Regamedll_Debug_logFree(void *ptr); extern void Regamedll_Debug_logStrDup(const char *s, void *ptr); extern void Regamedll_Debug_Init(void); -#if defined(_WIN32) && !defined(REGAMEDLL_UNIT_TESTS) +#endif // _WIN32 + +#if defined(HOOK_GAMEDLL) && !defined(REGAMEDLL_UNIT_TESTS) extern void Regamedll_Game_Init(void); -#endif // _WIN32 && REGAMEDLL_UNIT_TESTS +#endif // HOOK_GAMEDLL extern void _printf2(const char *fmt, ...); extern void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...); - -#endif // _WIN32 diff --git a/regamedll/msvc/ReGameDLL.vcxproj b/regamedll/msvc/ReGameDLL.vcxproj index fbf6b4fe..36462c5c 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj +++ b/regamedll/msvc/ReGameDLL.vcxproj @@ -841,7 +841,7 @@ Level3 Disabled true - HOOK_GAMEDLL;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + HOOK_GAMEDLL;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;NOMINMAX;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug @@ -991,7 +991,7 @@ true true true - HOOK_GAMEDLL;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + HOOK_GAMEDLL;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions) MultiThreaded /arch:IA32 %(AdditionalOptions) Use diff --git a/regamedll/pm_shared/pm_defs.h b/regamedll/pm_shared/pm_defs.h index ace98ac9..7ac088de 100644 --- a/regamedll/pm_shared/pm_defs.h +++ b/regamedll/pm_shared/pm_defs.h @@ -92,6 +92,7 @@ typedef struct physent_s vec3_t vuser2; vec3_t vuser3; vec3_t vuser4; + } physent_t; /* size: 224, cachelines: 4, members: 33 */ @@ -193,6 +194,7 @@ typedef struct playermove_s void (*PM_PlaySound)(int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch); const char *(*PM_TraceTexture)(int ground, float *vstart, float *vend); void (*PM_PlaybackEventFull)(int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); + } playermove_t; /* size: 325056, cachelines: 5079, members: 94 */ diff --git a/regamedll/pm_shared/pm_math.cpp b/regamedll/pm_shared/pm_math.cpp index c437337d..bc4231a2 100644 --- a/regamedll/pm_shared/pm_math.cpp +++ b/regamedll/pm_shared/pm_math.cpp @@ -1,13 +1,13 @@ #include "precompiled.h" -/* -* Globals initialization -*/ -#ifndef HOOK_GAMEDLL - +/* +* Globals initialization +*/ +#ifndef HOOK_GAMEDLL + vec3_t vec3_origin = {0, 0, 0}; -int nanmask = 255<<23; - +int nanmask = 255<<23; + #else vec3_t vec3_origin; @@ -18,48 +18,48 @@ int nanmask; /* <2ce436> ../cstrike/pm_shared/pm_math.c:35 */ NOBODY float anglemod(float a) { - a = (360.0 / 65536) * ((int)(a *(65536 / 360.0)) & 65535); + a = (360.0 / 65536) * ((int)(a *(65536 / 360.0)) & 65535); return a; } /* <2ce461> ../cstrike/pm_shared/pm_math.c:41 */ -void AngleVectors(const vec_t *angles, vec_t *forward, vec_t *right, vec_t *up) -{ - float sr, sp, sy, cr, cp; - - float_precision cy; - float_precision angle; - - angle = (float_precision)(angles[YAW] * (M_PI * 2 / 360)); - sy = sin(angle); - cy = cos(angle); - - angle = (float_precision)(angles[PITCH] * (M_PI * 2 / 360)); - sp = sin(angle); - cp = cos(angle); - - angle = (float_precision)(angles[ROLL] * (M_PI * 2 / 360)); - sr = sin(angle); - cr = cos(angle); - - if (forward) - { - forward[0] = cp * cy; - forward[1] = cp * sy; - forward[2] = -sp; - } - if (right) - { - right[0] = (-1 * sr * sp * cy + -1 * cr * -sy); - right[1] = (-1 * sr * sp * sy + -1 * cr * cy); - right[2] = -1 * sr * cp; - } - if (up) - { - up[0] = (cr * sp * cy + -sr * -sy); - up[1] = (cr * sp * sy + -sr * cy); - up[2] = cr * cp; - } +void AngleVectors(const vec_t *angles, vec_t *forward, vec_t *right, vec_t *up) +{ + float sr, sp, sy, cr, cp; + + float_precision cy; + float_precision angle; + + angle = (float_precision)(angles[YAW] * (M_PI * 2 / 360)); + sy = sin(angle); + cy = cos(angle); + + angle = (float_precision)(angles[PITCH] * (M_PI * 2 / 360)); + sp = sin(angle); + cp = cos(angle); + + angle = (float_precision)(angles[ROLL] * (M_PI * 2 / 360)); + sr = sin(angle); + cr = cos(angle); + + if (forward) + { + forward[0] = cp * cy; + forward[1] = cp * sy; + forward[2] = -sp; + } + if (right) + { + right[0] = (-1 * sr * sp * cy + -1 * cr * -sy); + right[1] = (-1 * sr * sp * sy + -1 * cr * cy); + right[2] = -1 * sr * cp; + } + if (up) + { + up[0] = (cr * sp * cy + -sr * -sy); + up[1] = (cr * sp * sy + -sr * cy); + up[2] = cr * cp; + } } /* <2ce521> ../cstrike/pm_shared/pm_math.c:76 */ @@ -79,33 +79,33 @@ void AngleMatrix(const vec_t *angles, float (*matrix)[4]) { float_precision angle; float_precision sr, sp, sy, cr, cp, cy; - - angle = (float_precision)(angles[ROLL] * (M_PI * 2 / 360)); - sy = sin(angle); - cy = cos(angle); - - angle = (float_precision)(angles[YAW] * (M_PI * 2 / 360)); - sp = sin(angle); - cp = cos(angle); - - angle = (float_precision)(angles[PITCH] * (M_PI * 2 / 360)); - sr = sin(angle); + + angle = (float_precision)(angles[ROLL] * (M_PI * 2 / 360)); + sy = sin(angle); + cy = cos(angle); + + angle = (float_precision)(angles[YAW] * (M_PI * 2 / 360)); + sp = sin(angle); + cp = cos(angle); + + angle = (float_precision)(angles[PITCH] * (M_PI * 2 / 360)); + sr = sin(angle); cr = cos(angle); - - matrix[0][0] = cr * cp; - matrix[1][0] = cr * sp; - matrix[2][0] = -sr; - - matrix[0][1] = (sy * sr) * cp - cy * sp; - matrix[1][1] = (sy * sr) * sp + cy * cp; - matrix[2][1] = sy * cr; - - matrix[0][2] = (cy * sr) * cp + sy * sp; - matrix[1][2] = (cy * sr) * sp - sy * cp; - matrix[2][2] = cy * cr; - - matrix[0][3] = 0.0f; - matrix[1][3] = 0.0f; + + matrix[0][0] = cr * cp; + matrix[1][0] = cr * sp; + matrix[2][0] = -sr; + + matrix[0][1] = (sy * sr) * cp - cy * sp; + matrix[1][1] = (sy * sr) * sp + cy * cp; + matrix[2][1] = sy * cr; + + matrix[0][2] = (cy * sr) * cp + sy * sp; + matrix[1][2] = (cy * sr) * sp - sy * cp; + matrix[2][2] = cy * cr; + + matrix[0][3] = 0.0f; + matrix[1][3] = 0.0f; matrix[2][3] = 0.0f; } @@ -158,7 +158,7 @@ NOBODY void VectorTransform(const vec_t *in1, float *in2, vec_t *out) int VectorCompare(const vec_t *v1, const vec_t *v2) { int i; - for (i = 0 ; i < 3 ; i++) + for (i = 0; i < 3; i++) { if (v1[i] != v2[i]) return 0; @@ -217,7 +217,7 @@ float_precision Length(const vec_t *v) { int i; float_precision length = 0.0f; - + for (i = 0; i < 3; i++) length += v[i] * v[i]; @@ -233,7 +233,7 @@ NOBODY float Distance(const vec_t *v1, const vec_t *v2) /* <2cec3c> ../cstrike/pm_shared/pm_math.c:332 */ float_precision VectorNormalize(vec_t *v) -{ +{ float_precision length; float_precision ilength; @@ -243,8 +243,8 @@ float_precision VectorNormalize(vec_t *v) { ilength = 1.0 / length; - v[0] *= ilength; - v[1] *= ilength; + v[0] *= ilength; + v[1] *= ilength; v[2] *= ilength; } @@ -259,18 +259,18 @@ NOBODY void VectorInverse(vec_t *v) /* <2cecc9> ../cstrike/pm_shared/pm_math.c:358 */ void VectorScale(const vec_t *in, vec_t scale, vec_t *out) { - out[0] = scale * in[0]; - out[1] = scale * in[1]; + out[0] = scale * in[0]; + out[1] = scale * in[1]; out[2] = scale * in[2]; } /* <2ced0f> ../cstrike/pm_shared/pm_math.c:366 */ NOBODY int Q_log2(int val) { - int answer = 0; - while (val >>= 1) - answer++; - + int answer = 0; + while (val >>= 1) + answer++; + return answer; } diff --git a/regamedll/pm_shared/pm_movevars.h b/regamedll/pm_shared/pm_movevars.h index 2436e36a..464556f5 100644 --- a/regamedll/pm_shared/pm_movevars.h +++ b/regamedll/pm_shared/pm_movevars.h @@ -36,17 +36,17 @@ typedef struct movevars_s { float gravity; // Gravity for map float stopspeed; // Deceleration when not moving - float maxspeed; // Max allowed speed + float maxspeed; // Max allowed speed float spectatormaxspeed; float accelerate; // Acceleration factor float airaccelerate; // Same for when in open air - float wateraccelerate; // Same for when in water + float wateraccelerate; // Same for when in water float friction; float edgefriction; // Extra friction near dropofs float waterfriction; // Less in water float entgravity; // 1.0 float bounce; // Wall bounce value. 1.0 - float stepsize; // sv_stepsize; + float stepsize; // sv_stepsize; float maxvelocity; // maximum server velocity. float zmax; // Max z-buffer range (for GL) float waveHeight; // Water wave height (for GL) @@ -55,11 +55,12 @@ typedef struct movevars_s float rollangle; float rollspeed; float skycolor_r; // Sky color - float skycolor_g; // - float skycolor_b; // - float skyvec_x; // Sky vector - float skyvec_y; // - float skyvec_z; // + float skycolor_g; + float skycolor_b; + float skyvec_x; // Sky vector + float skyvec_y; + float skyvec_z; + } movevars_t; #endif // PM_MOVEVARS_H diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp index e3337da6..186134f3 100644 --- a/regamedll/pm_shared/pm_shared.cpp +++ b/regamedll/pm_shared/pm_shared.cpp @@ -6,7 +6,7 @@ #define PLAYER_DUCKING_MULTIPLIER 0.333 #define PM_CHECKSTUCK_MINTIME 0.05 // Don't check again too quickly. -// Ducking time +// Ducking time #define TIME_TO_DUCK 0.4 #define STUCK_MOVEUP 1 @@ -19,7 +19,7 @@ #define PM_PLAYER_MIN_BOUNCE_SPEED 350 #define PM_PLAYER_FALL_PUNCH_THRESHHOLD 250 // won't punch player's screen/make scrape noise unless player falling at least this fast. -// Only allow bunny jumping up to 1.2x server / player maxspeed setting +// Only allow bunny jumping up to 1.2x server / player maxspeed setting #define BUNNYJUMP_MAX_SPEED_FACTOR 1.2f /* @@ -76,7 +76,7 @@ NOXREF int PM_IsThereGrassTexture(void) { int i; - for (i = 0 ; i < pm_gcTextures; i++) + for (i = 0; i < pm_gcTextures; i++) { if (pm_grgchTextureType[i] == CHAR_TEX_GRASS) return 1; @@ -163,7 +163,7 @@ void PM_InitTextureTypes(void) continue; // null-terminate name and save in sentences array - j = _min(j, CBTEXTURENAMEMAX - 1 + i); + j = Q_min(j, CBTEXTURENAMEMAX - 1 + i); buffer[j] = '\0'; Q_strcpy(&(pm_grgszTextureName[pm_gcTextures++][0]), &(buffer[i])); @@ -179,12 +179,12 @@ void PM_InitTextureTypes(void) /* <2cc7c5> ../cstrike/pm_shared/pm_shared.c:283 */ char PM_FindTextureType(char *name) { - int left, right, pivot; + int left, right, pivot; int val; assert(pm_shared_initialized); - left = 0; + left = 0; right = gcTextures - 1; while (left <= right) @@ -219,8 +219,8 @@ void PM_PlayStepSound(int step, float fvol) pmove->iStepLeft = !pmove->iStepLeft; if (!pmove->runfuncs) - { - return; + { + return; } irand = pmove->RandomLong(0, 1) + (pmove->iStepLeft * 2); @@ -229,8 +229,8 @@ void PM_PlayStepSound(int step, float fvol) if (pmove->multiplayer && !pmove->movevars->footsteps) return; - // irand - 0,1 for right foot, 2,3 for left foot - // used to alternate left and right foot + // irand - 0,1 for right foot, 2,3 for left foot + // used to alternate left and right foot // FIXME, move to player state switch (step) { @@ -270,7 +270,7 @@ void PM_PlayStepSound(int step, float fvol) break; case STEP_VENT: switch (irand) - { + { // right foot case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_duct1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_duct3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; @@ -317,15 +317,15 @@ void PM_PlayStepSound(int step, float fvol) } break; case STEP_WADE: - if (iSkipStep == 0) - { - iSkipStep++; - break; + if (iSkipStep == 0) + { + iSkipStep++; + break; } - if (iSkipStep++ == 3) - { - iSkipStep = 0; + if (iSkipStep++ == 3) + { + iSkipStep = 0; } switch (irand) @@ -484,7 +484,7 @@ void PM_UpdateStepSound(void) } else { - // find texture under player, if different from current texture, + // find texture under player, if different from current texture, // get material type step = PM_MapTextureTypeStepType(pmove->chtexturetype); @@ -532,7 +532,7 @@ void PM_UpdateStepSound(void) { pmove->flTimeStepSound += 100; // slower step time if ducking - // play the sound + // play the sound // 35% volume if ducking if (pmove->flags & FL_DUCKING && pmove->flDuckTime < 950.0) { @@ -549,27 +549,27 @@ void PM_UpdateStepSound(void) /* <2cca3d> ../cstrike/pm_shared/pm_shared.c:679 */ qboolean PM_AddToTouched(pmtrace_t tr, vec_t *impactvelocity) { - int i; - for (i = 0; i < pmove->numtouch; i++) - { - if (pmove->touchindex[i].ent == tr.ent) - break; - } - - // Already in list. - if (i != pmove->numtouch) - { - return false; - } - - VectorCopy(impactvelocity, tr.deltavelocity); - - if (pmove->numtouch >= MAX_PHYSENTS) - { - pmove->Con_DPrintf("Too many entities were touched!\n"); - } - - pmove->touchindex[pmove->numtouch++] = tr; + int i; + for (i = 0; i < pmove->numtouch; i++) + { + if (pmove->touchindex[i].ent == tr.ent) + break; + } + + // Already in list. + if (i != pmove->numtouch) + { + return false; + } + + VectorCopy(impactvelocity, tr.deltavelocity); + + if (pmove->numtouch >= MAX_PHYSENTS) + { + pmove->Con_DPrintf("Too many entities were touched!\n"); + } + + pmove->touchindex[pmove->numtouch++] = tr; return true; } @@ -579,105 +579,105 @@ void PM_CheckVelocity(void) int i; // bound velocity - for (i = 0; i < 3; i++) - { - // See if it's bogus. - if (IS_NAN(pmove->velocity[i])) - { - pmove->Con_Printf("PM Got a NaN velocity %i\n", i); - pmove->velocity[i] = 0; - } - - if (IS_NAN(pmove->origin[i])) - { - pmove->Con_Printf("PM Got a NaN origin on %i\n", i); - pmove->origin[i] = 0; - } - - // Bound it. - if (pmove->velocity[i] > pmove->movevars->maxvelocity) - { - pmove->Con_DPrintf("PM Got a velocity too high on %i\n", i); - pmove->velocity[i] = pmove->movevars->maxvelocity; - } - else if (pmove->velocity[i] < -pmove->movevars->maxvelocity) - { - pmove->Con_DPrintf("PM Got a velocity too low on %i\n", i); - pmove->velocity[i] = -pmove->movevars->maxvelocity; - } + for (i = 0; i < 3; i++) + { + // See if it's bogus. + if (IS_NAN(pmove->velocity[i])) + { + pmove->Con_Printf("PM Got a NaN velocity %i\n", i); + pmove->velocity[i] = 0; + } + + if (IS_NAN(pmove->origin[i])) + { + pmove->Con_Printf("PM Got a NaN origin on %i\n", i); + pmove->origin[i] = 0; + } + + // Bound it. + if (pmove->velocity[i] > pmove->movevars->maxvelocity) + { + pmove->Con_DPrintf("PM Got a velocity too high on %i\n", i); + pmove->velocity[i] = pmove->movevars->maxvelocity; + } + else if (pmove->velocity[i] < -pmove->movevars->maxvelocity) + { + pmove->Con_DPrintf("PM Got a velocity too low on %i\n", i); + pmove->velocity[i] = -pmove->movevars->maxvelocity; + } } } -// Slide off of the impacting object -// returns the blocked flags: -// 0x01 == floor +// Slide off of the impacting object +// returns the blocked flags: +// 0x01 == floor // 0x02 == step / wall /* <2ccbe9> ../cstrike/pm_shared/pm_shared.c:752 */ int PM_ClipVelocity(vec_t *in, vec_t *normal, vec_t *out, float overbounce) -{ - float change; +{ + float change; float_precision angle; - float_precision backoff; - int i, blocked; - - angle = normal[2]; - - // Assume unblocked. - blocked = 0x00; - - // If the plane that is blocking us has a positive z component, then assume it's a floor. - if (angle > 0) - { - blocked |= 0x01; - } - - // If the plane has no Z, it is vertical (wall/step) - if (!angle) - { - blocked |= 0x02; - } - - // Determine how far along plane to slide based on incoming direction. - // Scale by overbounce factor. - backoff = DotProduct(in, normal) * overbounce; - - for (i = 0; i < 3; i++) - { - change = in[i] - normal[i] * backoff; - out[i] = change; - - // If out velocity is too small, zero it out. - if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) - { - out[i] = 0; - } - } - - // Return blocking flags. + float_precision backoff; + int i, blocked; + + angle = normal[2]; + + // Assume unblocked. + blocked = 0x00; + + // If the plane that is blocking us has a positive z component, then assume it's a floor. + if (angle > 0) + { + blocked |= 0x01; + } + + // If the plane has no Z, it is vertical (wall/step) + if (!angle) + { + blocked |= 0x02; + } + + // Determine how far along plane to slide based on incoming direction. + // Scale by overbounce factor. + backoff = DotProduct(in, normal) * overbounce; + + for (i = 0; i < 3; i++) + { + change = in[i] - normal[i] * backoff; + out[i] = change; + + // If out velocity is too small, zero it out. + if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) + { + out[i] = 0; + } + } + + // Return blocking flags. return blocked; } /* <2ccc93> ../cstrike/pm_shared/pm_shared.c:784 */ void PM_AddCorrectGravity(void) { - float_precision ent_gravity; - - if (pmove->waterjumptime) - return; - - if (pmove->gravity != 0.0f) - ent_gravity = pmove->gravity; - else - ent_gravity = 1.0f; - - // Add gravity so they'll be in the correct position during movement - // yes, this 0.5 looks wrong, but it's not. - pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * 0.5f * pmove->frametime); - pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; - - pmove->basevelocity[2] = 0; - + float_precision ent_gravity; + + if (pmove->waterjumptime) + return; + + if (pmove->gravity != 0.0f) + ent_gravity = pmove->gravity; + else + ent_gravity = 1.0f; + + // Add gravity so they'll be in the correct position during movement + // yes, this 0.5 looks wrong, but it's not. + pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * 0.5f * pmove->frametime); + pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; + + pmove->basevelocity[2] = 0; + PM_CheckVelocity(); } @@ -686,8 +686,8 @@ void PM_FixupGravityVelocity(void) { float_precision ent_gravity; - if (pmove->waterjumptime) - return; + if (pmove->waterjumptime) + return; if (pmove->gravity != 0.0) ent_gravity = pmove->gravity; @@ -702,134 +702,134 @@ void PM_FixupGravityVelocity(void) /* <2ccd08> ../cstrike/pm_shared/pm_shared.c:831 */ int PM_FlyMove(void) { - int bumpcount, numbumps; - vec3_t dir; - float d; - int numplanes; - vec3_t planes[MAX_CLIP_PLANES]; - vec3_t primal_velocity, original_velocity; - vec3_t new_velocity; - int i, j; - pmtrace_t trace; - vec3_t end; - float time_left, allFraction; + int bumpcount, numbumps; + vec3_t dir; + float d; + int numplanes; + vec3_t planes[MAX_CLIP_PLANES]; + vec3_t primal_velocity, original_velocity; + vec3_t new_velocity; + int i, j; + pmtrace_t trace; + vec3_t end; + float time_left, allFraction; int blocked; - numbumps = 4; // Bump up to four times - blocked = 0x00; // Assume not blocked - numplanes = 0; // and not sliding along any planes - - VectorCopy(pmove->velocity, original_velocity); // Store original velocity + numbumps = 4; // Bump up to four times + blocked = 0x00; // Assume not blocked + numplanes = 0; // and not sliding along any planes + + VectorCopy(pmove->velocity, original_velocity); // Store original velocity VectorCopy(pmove->velocity, primal_velocity); - allFraction = 0; + allFraction = 0; time_left = pmove->frametime; // Total time for this movement operation. - for (bumpcount = 0; bumpcount < numbumps; bumpcount++) + for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { - if (!pmove->velocity[0] && !pmove->velocity[1] && !pmove->velocity[2]) - break; - - // Assume we can move all the way from the current origin to the - // end point. - for (i = 0; i < 3; i++) + if (!pmove->velocity[0] && !pmove->velocity[1] && !pmove->velocity[2]) + break; + + // Assume we can move all the way from the current origin to the + // end point. + for (i = 0; i < 3; i++) { float_precision flScale = time_left * pmove->velocity[i]; end[i] = pmove->origin[i] + flScale; } - // See if we can make it from origin to end point. - trace = pmove->PM_PlayerTrace(pmove->origin, end, PM_NORMAL, -1); - - allFraction += trace.fraction; - - // If we started in a solid object, or we were in solid space - // the whole way, zero out our velocity and return that we - // are blocked by floor and wall. - if (trace.allsolid) - { - // entity is trapped in another solid - VectorCopy(vec3_origin, pmove->velocity); - return 4; + // See if we can make it from origin to end point. + trace = pmove->PM_PlayerTrace(pmove->origin, end, PM_NORMAL, -1); + + allFraction += trace.fraction; + + // If we started in a solid object, or we were in solid space + // the whole way, zero out our velocity and return that we + // are blocked by floor and wall. + if (trace.allsolid) + { + // entity is trapped in another solid + VectorCopy(vec3_origin, pmove->velocity); + return 4; } - // If we moved some portion of the total distance, then - // copy the end position into the pmove->origin and - // zero the plane counter. - if (trace.fraction > 0.0f) - { - // actually covered some distance - VectorCopy(trace.endpos, pmove->origin); - VectorCopy(pmove->velocity, original_velocity); - - numplanes = 0; + // If we moved some portion of the total distance, then + // copy the end position into the pmove->origin and + // zero the plane counter. + if (trace.fraction > 0.0f) + { + // actually covered some distance + VectorCopy(trace.endpos, pmove->origin); + VectorCopy(pmove->velocity, original_velocity); + + numplanes = 0; } - // If we covered the entire distance, we are done - // and can return. - if (trace.fraction == 1.0f) + // If we covered the entire distance, we are done + // and can return. + if (trace.fraction == 1.0f) { // moved the entire distance break; } - // Save entity that blocked us (since fraction was < 1.0) - // for contact - // Add it if it's not already in the list!!! + // Save entity that blocked us (since fraction was < 1.0) + // for contact + // Add it if it's not already in the list!!! PM_AddToTouched(trace, pmove->velocity); - // If the plane we hit has a high z component in the normal, then - // it's probably a floor - if (trace.plane.normal[2] > 0.7f) - { - // floor - blocked |= 0x01; + // If the plane we hit has a high z component in the normal, then + // it's probably a floor + if (trace.plane.normal[2] > 0.7f) + { + // floor + blocked |= 0x01; } - // If the plane has a zero z component in the normal, then it's a - // step or wall - if (!trace.plane.normal[2]) - { - // step / wall - blocked |= 0x02; + // If the plane has a zero z component in the normal, then it's a + // step or wall + if (!trace.plane.normal[2]) + { + // step / wall + blocked |= 0x02; } - - // Reduce amount of pmove->frametime left by total time left * fraction - // that we covered. + + // Reduce amount of pmove->frametime left by total time left * fraction + // that we covered. time_left -= time_left * trace.fraction; - // Did we run out of planes to clip against? - if (numplanes >= MAX_CLIP_PLANES) - { - // this shouldn't really happen - // Stop our movement if so. - VectorCopy(vec3_origin, pmove->velocity); - break; + // Did we run out of planes to clip against? + if (numplanes >= MAX_CLIP_PLANES) + { + // this shouldn't really happen + // Stop our movement if so. + VectorCopy(vec3_origin, pmove->velocity); + break; } - // Set up next clipping plane - VectorCopy(trace.plane.normal, planes[numplanes]); + // Set up next clipping plane + VectorCopy(trace.plane.normal, planes[numplanes]); numplanes++; - // modify original_velocity so it parallels all of the clip planes - // relfect player velocity - if (numplanes == 1 && pmove->movetype == MOVETYPE_WALK && (pmove->onground == -1 || pmove->friction != 1)) - { - for (i = 0; i < numplanes; i++) - { - if (planes[i][2] > 0.7f) - { - // floor or slope - PM_ClipVelocity(original_velocity, planes[i], new_velocity, 1); - VectorCopy(new_velocity, original_velocity); - } - else - PM_ClipVelocity(original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * (1.0 - pmove->friction)); - } - - VectorCopy(new_velocity, pmove->velocity); - VectorCopy(new_velocity, original_velocity); + // modify original_velocity so it parallels all of the clip planes + // relfect player velocity + if (numplanes == 1 && pmove->movetype == MOVETYPE_WALK && (pmove->onground == -1 || pmove->friction != 1)) + { + for (i = 0; i < numplanes; i++) + { + if (planes[i][2] > 0.7f) + { + // floor or slope + PM_ClipVelocity(original_velocity, planes[i], new_velocity, 1); + VectorCopy(new_velocity, original_velocity); + } + else + PM_ClipVelocity(original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * (1.0 - pmove->friction)); + } + + VectorCopy(new_velocity, pmove->velocity); + VectorCopy(new_velocity, original_velocity); } else { @@ -881,41 +881,41 @@ int PM_FlyMove(void) /* <2cce2e> ../cstrike/pm_shared/pm_shared.c:1027 */ void PM_Accelerate(vec_t *wishdir, float_precision wishspeed, float accel) { - int i; - float addspeed; - - float_precision currentspeed; - float_precision accelspeed; - - // Dead player's don't accelerate - if (pmove->dead) - return; - - // If waterjumping, don't accelerate - if (pmove->waterjumptime) - return; - - // See if we are changing direction a bit - currentspeed = DotProduct(pmove->velocity, wishdir); - - // Reduce wishspeed by the amount of veer. - addspeed = wishspeed - currentspeed; - - // If not going to add any speed, done. - if (addspeed <= 0) - return; - - // Determine amount of accleration. - accelspeed = accel * pmove->frametime * wishspeed * pmove->friction; - - // Cap at addspeed - if (accelspeed > addspeed) - accelspeed = addspeed; - - // Adjust velocity. - for (i = 0; i < 3; i++) - { - pmove->velocity[i] += accelspeed * wishdir[i]; + int i; + float addspeed; + + float_precision currentspeed; + float_precision accelspeed; + + // Dead player's don't accelerate + if (pmove->dead) + return; + + // If waterjumping, don't accelerate + if (pmove->waterjumptime) + return; + + // See if we are changing direction a bit + currentspeed = DotProduct(pmove->velocity, wishdir); + + // Reduce wishspeed by the amount of veer. + addspeed = wishspeed - currentspeed; + + // If not going to add any speed, done. + if (addspeed <= 0) + return; + + // Determine amount of accleration. + accelspeed = accel * pmove->frametime * wishspeed * pmove->friction; + + // Cap at addspeed + if (accelspeed > addspeed) + accelspeed = addspeed; + + // Adjust velocity. + for (i = 0; i < 3; i++) + { + pmove->velocity[i] += accelspeed * wishdir[i]; } } @@ -924,188 +924,188 @@ void PM_Accelerate(vec_t *wishdir, float_precision wishspeed, float accel) /* <2cceaf> ../cstrike/pm_shared/pm_shared.c:1071 */ void PM_WalkMove(void) { - int clip; - int oldonground; - int i; - - vec3_t wishvel; - float_precision spd; - float fmove, smove; - vec3_t wishdir; - float_precision wishspeed; - - //vec3_t start; // TODO: unused - vec3_t dest; - vec3_t original, originalvel; - vec3_t down, downvel; + int clip; + int oldonground; + int i; + + vec3_t wishvel; + float_precision spd; + float fmove, smove; + vec3_t wishdir; + float_precision wishspeed; + + //vec3_t start; // TODO: unused + vec3_t dest; + vec3_t original, originalvel; + vec3_t down, downvel; float downdist, updist; pmtrace_t trace; - - if (pmove->fuser2 > 0.0) - { - float_precision flRatio = (100 - pmove->fuser2 * 0.001 * 19) * 0.01; - - pmove->velocity[0] *= flRatio; - pmove->velocity[1] *= flRatio; - } - - // Copy movement amounts - fmove = pmove->cmd.forwardmove; - smove = pmove->cmd.sidemove; - - // Zero out z components of movement vectors - pmove->forward[2] = 0; - pmove->right[2] = 0; - - // Normalize remainder of vectors. - VectorNormalize(pmove->forward); - VectorNormalize(pmove->right); - - // Determine x and y parts of velocity - for (i = 0; i < 2; i++) - { - wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; - } - - // Zero out z part of velocity - wishvel[2] = 0; - - // Determine maginitude of speed of move - VectorCopy(wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); - - // Clamp to server defined max speed - if (wishspeed > pmove->maxspeed) - { - VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel); - wishspeed = pmove->maxspeed; - } - - // Set pmove velocity - pmove->velocity[2] = 0; - PM_Accelerate(wishdir, wishspeed, pmove->movevars->accelerate); - pmove->velocity[2] = 0; - - // Add in any base velocity to the current velocity. - VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); - - spd = Length(pmove->velocity); - - if (spd < 1.0) - { - VectorClear(pmove->velocity); - return; - } - - // If we are not moving, do nothing - //if (!pmove->velocity[0] && !pmove->velocity[1] && !pmove->velocity[2]) - // return; - - oldonground = pmove->onground; - - // first try just moving to the destination - dest[0] = pmove->origin[0] + pmove->velocity[0] * pmove->frametime; - dest[1] = pmove->origin[1] + pmove->velocity[1] * pmove->frametime; - dest[2] = pmove->origin[2]; - - // first try moving directly to the next spot - // VectorCopy(dest, start); - - trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); - - // If we made it all the way, then copy trace end - // as new player position. - if (trace.fraction == 1.0f) - { - VectorCopy(trace.endpos, pmove->origin); - return; - } - - // Don't walk up stairs if not on ground. - if (oldonground == -1 && pmove->waterlevel == 0) - { - return; - } - - // If we are jumping out of water, don't do anything more. - if (pmove->waterjumptime) - return; - - // Try sliding forward both on ground and up 16 pixels - // take the move that goes farthest - - // Save out original pos & - VectorCopy(pmove->origin, original); - - // velocity. - VectorCopy(pmove->velocity, originalvel); - - // Slide move - clip = PM_FlyMove(); - - // Copy the results out - VectorCopy(pmove->origin, down); - VectorCopy(pmove->velocity, downvel); - - // Reset original values. - VectorCopy(original, pmove->origin); - VectorCopy(originalvel, pmove->velocity); - - // Start out up one stair height - VectorCopy(pmove->origin, dest); - - dest[2] += pmove->movevars->stepsize; - - trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); - - // If we started okay and made it part of the way at least, - // copy the results to the movement start position and then - // run another move try. - if (!trace.startsolid && !trace.allsolid) - { - VectorCopy(trace.endpos, pmove->origin); - } - - // slide move the rest of the way. - clip = PM_FlyMove(); - - // Now try going back down from the end point - // press down the stepheight - VectorCopy(pmove->origin, dest); - dest[2] -= pmove->movevars->stepsize; - - trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); - - // If we are not on the ground any more then - // use the original movement attempt - if (trace.plane.normal[2] < 0.7f) - goto usedown; - - // If the trace ended up in empty space, copy the end - // over to the origin. - if (!trace.startsolid && !trace.allsolid) - { - VectorCopy(trace.endpos, pmove->origin); - } - - // Copy this origion to up. - VectorCopy(pmove->origin, pmove->up); - - // decide which one went farther + + if (pmove->fuser2 > 0.0) + { + float_precision flRatio = (100 - pmove->fuser2 * 0.001 * 19) * 0.01; + + pmove->velocity[0] *= flRatio; + pmove->velocity[1] *= flRatio; + } + + // Copy movement amounts + fmove = pmove->cmd.forwardmove; + smove = pmove->cmd.sidemove; + + // Zero out z components of movement vectors + pmove->forward[2] = 0; + pmove->right[2] = 0; + + // Normalize remainder of vectors. + VectorNormalize(pmove->forward); + VectorNormalize(pmove->right); + + // Determine x and y parts of velocity + for (i = 0; i < 2; i++) + { + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; + } + + // Zero out z part of velocity + wishvel[2] = 0; + + // Determine maginitude of speed of move + VectorCopy(wishvel, wishdir); + wishspeed = VectorNormalize(wishdir); + + // Clamp to server defined max speed + if (wishspeed > pmove->maxspeed) + { + VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel); + wishspeed = pmove->maxspeed; + } + + // Set pmove velocity + pmove->velocity[2] = 0; + PM_Accelerate(wishdir, wishspeed, pmove->movevars->accelerate); + pmove->velocity[2] = 0; + + // Add in any base velocity to the current velocity. + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); + + spd = Length(pmove->velocity); + + if (spd < 1.0) + { + VectorClear(pmove->velocity); + return; + } + + // If we are not moving, do nothing + //if (!pmove->velocity[0] && !pmove->velocity[1] && !pmove->velocity[2]) + // return; + + oldonground = pmove->onground; + + // first try just moving to the destination + dest[0] = pmove->origin[0] + pmove->velocity[0] * pmove->frametime; + dest[1] = pmove->origin[1] + pmove->velocity[1] * pmove->frametime; + dest[2] = pmove->origin[2]; + + // first try moving directly to the next spot + // VectorCopy(dest, start); + + trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); + + // If we made it all the way, then copy trace end + // as new player position. + if (trace.fraction == 1.0f) + { + VectorCopy(trace.endpos, pmove->origin); + return; + } + + // Don't walk up stairs if not on ground. + if (oldonground == -1 && pmove->waterlevel == 0) + { + return; + } + + // If we are jumping out of water, don't do anything more. + if (pmove->waterjumptime) + return; + + // Try sliding forward both on ground and up 16 pixels + // take the move that goes farthest + + // Save out original pos & + VectorCopy(pmove->origin, original); + + // velocity. + VectorCopy(pmove->velocity, originalvel); + + // Slide move + clip = PM_FlyMove(); + + // Copy the results out + VectorCopy(pmove->origin, down); + VectorCopy(pmove->velocity, downvel); + + // Reset original values. + VectorCopy(original, pmove->origin); + VectorCopy(originalvel, pmove->velocity); + + // Start out up one stair height + VectorCopy(pmove->origin, dest); + + dest[2] += pmove->movevars->stepsize; + + trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); + + // If we started okay and made it part of the way at least, + // copy the results to the movement start position and then + // run another move try. + if (!trace.startsolid && !trace.allsolid) + { + VectorCopy(trace.endpos, pmove->origin); + } + + // slide move the rest of the way. + clip = PM_FlyMove(); + + // Now try going back down from the end point + // press down the stepheight + VectorCopy(pmove->origin, dest); + dest[2] -= pmove->movevars->stepsize; + + trace = pmove->PM_PlayerTrace(pmove->origin, dest, PM_NORMAL, -1); + + // If we are not on the ground any more then + // use the original movement attempt + if (trace.plane.normal[2] < 0.7f) + goto usedown; + + // If the trace ended up in empty space, copy the end + // over to the origin. + if (!trace.startsolid && !trace.allsolid) + { + VectorCopy(trace.endpos, pmove->origin); + } + + // Copy this origion to up. + VectorCopy(pmove->origin, pmove->up); + + // decide which one went farther downdist = (down[0] - original[0]) * (down[0] - original[0]) + (down[1] - original[1]) * (down[1] - original[1]); - updist = (pmove->up[0] - original[0]) * (pmove->up[0] - original[0]) + (pmove->up[1] - original[1]) * (pmove->up[1] - original[1]); - - if (downdist > updist) - { -usedown: - VectorCopy(down, pmove->origin); - VectorCopy(downvel, pmove->velocity); - } - else - { - // copy z value from slide move - pmove->velocity[2] = downvel[2]; + updist = (pmove->up[0] - original[0]) * (pmove->up[0] - original[0]) + (pmove->up[1] - original[1]) * (pmove->up[1] - original[1]); + + if (downdist > updist) + { +usedown: + VectorCopy(down, pmove->origin); + VectorCopy(downvel, pmove->velocity); + } + else + { + // copy z value from slide move + pmove->velocity[2] = downvel[2]; } } @@ -1114,282 +1114,282 @@ usedown: /* <2ccffb> ../cstrike/pm_shared/pm_shared.c:1249 */ void PM_Friction(void) { - float *vel; - float speed; - float_precision newspeed, control, friction, drop; + float *vel; + float speed; + float_precision newspeed, control, friction, drop; vec3_t newvel; - // If we are in water jump cycle, don't apply friction - if (pmove->waterjumptime) + // If we are in water jump cycle, don't apply friction + if (pmove->waterjumptime) return; - // Get velocity - vel = pmove->velocity; - - // Calculate speed - speed = sqrt((float_precision)(vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2])); - - // If too slow, return - if (speed < 0.1f) - { - return; - } - - drop = 0; - - // apply ground friction - // On an entity that is the ground - if (pmove->onground != -1) - { - vec3_t start, stop; - pmtrace_t trace; - - start[0] = stop[0] = pmove->origin[0] + vel[0] / speed * 16; - start[1] = stop[1] = pmove->origin[1] + vel[1] / speed * 16; - start[2] = pmove->origin[2] + pmove->_player_mins[pmove->usehull][2]; - stop[2] = start[2] - 34; - - trace = pmove->PM_PlayerTrace(start, stop, PM_NORMAL, -1); - - if (trace.fraction == 1.0f) - friction = pmove->movevars->friction * pmove->movevars->edgefriction; - else - friction = pmove->movevars->friction; - - // Grab friction value. - //friction = pmove->movevars->friction; - - // player friction? - friction *= pmove->friction; - - // Bleed off some speed, but if we have less than the bleed - // threshhold, bleed the theshold amount. - control = (speed < pmove->movevars->stopspeed) ? pmove->movevars->stopspeed : speed; - - // Add the amount to t'he drop amount. - drop += friction * (control * pmove->frametime); - } - - // apply water friction - //if (pmove->waterlevel) - //{ - // drop += speed * pmove->movevars->waterfriction * waterlevel * pmove->frametime; - //} - - // scale the velocity - newspeed = speed - drop; - - if (newspeed < 0) - { - newspeed = 0; - } - - // Determine proportion of old speed we are using. - newspeed /= speed; - - // Adjust velocity according to proportion. - newvel[0] = vel[0] * newspeed; - newvel[1] = vel[1] * (float)newspeed; - newvel[2] = vel[2] * (float)newspeed; - + // Get velocity + vel = pmove->velocity; + + // Calculate speed + speed = sqrt((float_precision)(vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2])); + + // If too slow, return + if (speed < 0.1f) + { + return; + } + + drop = 0; + + // apply ground friction + // On an entity that is the ground + if (pmove->onground != -1) + { + vec3_t start, stop; + pmtrace_t trace; + + start[0] = stop[0] = pmove->origin[0] + vel[0] / speed * 16; + start[1] = stop[1] = pmove->origin[1] + vel[1] / speed * 16; + start[2] = pmove->origin[2] + pmove->_player_mins[pmove->usehull][2]; + stop[2] = start[2] - 34; + + trace = pmove->PM_PlayerTrace(start, stop, PM_NORMAL, -1); + + if (trace.fraction == 1.0f) + friction = pmove->movevars->friction * pmove->movevars->edgefriction; + else + friction = pmove->movevars->friction; + + // Grab friction value. + //friction = pmove->movevars->friction; + + // player friction? + friction *= pmove->friction; + + // Bleed off some speed, but if we have less than the bleed + // threshhold, bleed the theshold amount. + control = (speed < pmove->movevars->stopspeed) ? pmove->movevars->stopspeed : speed; + + // Add the amount to t'he drop amount. + drop += friction * (control * pmove->frametime); + } + + // apply water friction + //if (pmove->waterlevel) + //{ + // drop += speed * pmove->movevars->waterfriction * waterlevel * pmove->frametime; + //} + + // scale the velocity + newspeed = speed - drop; + + if (newspeed < 0) + { + newspeed = 0; + } + + // Determine proportion of old speed we are using. + newspeed /= speed; + + // Adjust velocity according to proportion. + newvel[0] = vel[0] * newspeed; + newvel[1] = vel[1] * (float)newspeed; + newvel[2] = vel[2] * (float)newspeed; + VectorCopy(newvel, pmove->velocity); } /* <2cd0ba> ../cstrike/pm_shared/pm_shared.c:1326 */ void PM_AirAccelerate(vec_t *wishdir, float wishspeed, float accel) { - int i; - float addspeed; - float wishspd = wishspeed; - - float_precision currentspeed; - float_precision accelspeed; - - if (pmove->dead || pmove->waterjumptime) - return; - - // Cap speed - if (wishspd > 30) - wishspd = 30; - - // Determine veer amount - currentspeed = DotProduct(pmove->velocity, wishdir); - - // See how much to add - addspeed = wishspd - currentspeed; - - // If not adding any, done. - if (addspeed <= 0) - return; - - // Determine acceleration speed after acceleration - accelspeed = accel * wishspeed * pmove->frametime * pmove->friction; - - // Cap it - if (accelspeed > addspeed) - accelspeed = addspeed; - - // Adjust pmove vel. - for (i = 0; i < 3; i++) - { - pmove->velocity[i] += accelspeed * wishdir[i]; + int i; + float addspeed; + float wishspd = wishspeed; + + float_precision currentspeed; + float_precision accelspeed; + + if (pmove->dead || pmove->waterjumptime) + return; + + // Cap speed + if (wishspd > 30) + wishspd = 30; + + // Determine veer amount + currentspeed = DotProduct(pmove->velocity, wishdir); + + // See how much to add + addspeed = wishspd - currentspeed; + + // If not adding any, done. + if (addspeed <= 0) + return; + + // Determine acceleration speed after acceleration + accelspeed = accel * wishspeed * pmove->frametime * pmove->friction; + + // Cap it + if (accelspeed > addspeed) + accelspeed = addspeed; + + // Adjust pmove vel. + for (i = 0; i < 3; i++) + { + pmove->velocity[i] += accelspeed * wishdir[i]; } } /* <2cd14b> ../cstrike/pm_shared/pm_shared.c:1368 */ void PM_WaterMove(void) -{ - int i; - vec3_t wishvel; - vec3_t wishdir; - vec3_t start, dest; - vec3_t temp; - pmtrace_t trace; - - float_precision speed, accelspeed, wishspeed; - float newspeed, addspeed; - - // user intentions - for (i = 0; i < 3; i++) - { - wishvel[i] = (pmove->forward[i] * pmove->cmd.forwardmove) + (pmove->cmd.sidemove * pmove->right[i]); - } - - // Sinking after no other movement occurs - if (!pmove->cmd.forwardmove && !pmove->cmd.sidemove && !pmove->cmd.upmove) - { - // drift towards bottom - wishvel[2] -= 60.0f; - } - else - { - // Go straight up by upmove amount. - wishvel[2] += pmove->cmd.upmove; - } - - // Copy it over and determine speed - VectorCopy(wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); - - // Cap speed. - if (wishspeed > pmove->maxspeed) - { - VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel); - wishspeed = pmove->maxspeed; - } - - // Slow us down a bit. - wishspeed *= 0.8; - VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); - - // Water friction - VectorCopy(pmove->velocity, temp); - speed = VectorNormalize(temp); - - if (speed) - { - newspeed = speed - pmove->movevars->friction * pmove->friction * pmove->frametime * speed; - - if (newspeed < 0.0f) - { - newspeed = 0.0f; - } - - VectorScale(pmove->velocity, newspeed / speed, pmove->velocity); - } - else - newspeed = 0; - - // water acceleration - if ((float)wishspeed < 0.1f) - { - return; - } - - addspeed = (float)wishspeed - newspeed; - - if (addspeed > 0.0f) - { - VectorNormalize(wishvel); - accelspeed = pmove->movevars->accelerate * pmove->friction * pmove->frametime * (float)wishspeed; - - if (accelspeed > addspeed) - { - accelspeed = addspeed; - } - - for (i = 0; i < 3; i++) - { - pmove->velocity[i] += accelspeed * wishvel[i]; - } - } - - // Now move - // assume it is a stair or a slope, so press down from stepheight above - VectorMA(pmove->origin, pmove->frametime, pmove->velocity, dest); - VectorCopy(dest, start); - - start[2] += pmove->movevars->stepsize + 1; - trace = pmove->PM_PlayerTrace(start, dest, PM_NORMAL, -1); - - // FIXME: check steep slope? - if (!trace.startsolid && !trace.allsolid) - { - // walked up the step, so just keep result and exit - VectorCopy(trace.endpos, pmove->origin); - return; - } - - // Try moving straight along out normal path. +{ + int i; + vec3_t wishvel; + vec3_t wishdir; + vec3_t start, dest; + vec3_t temp; + pmtrace_t trace; + + float_precision speed, accelspeed, wishspeed; + float newspeed, addspeed; + + // user intentions + for (i = 0; i < 3; i++) + { + wishvel[i] = (pmove->forward[i] * pmove->cmd.forwardmove) + (pmove->cmd.sidemove * pmove->right[i]); + } + + // Sinking after no other movement occurs + if (!pmove->cmd.forwardmove && !pmove->cmd.sidemove && !pmove->cmd.upmove) + { + // drift towards bottom + wishvel[2] -= 60.0f; + } + else + { + // Go straight up by upmove amount. + wishvel[2] += pmove->cmd.upmove; + } + + // Copy it over and determine speed + VectorCopy(wishvel, wishdir); + wishspeed = VectorNormalize(wishdir); + + // Cap speed. + if (wishspeed > pmove->maxspeed) + { + VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel); + wishspeed = pmove->maxspeed; + } + + // Slow us down a bit. + wishspeed *= 0.8; + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); + + // Water friction + VectorCopy(pmove->velocity, temp); + speed = VectorNormalize(temp); + + if (speed) + { + newspeed = speed - pmove->movevars->friction * pmove->friction * pmove->frametime * speed; + + if (newspeed < 0.0f) + { + newspeed = 0.0f; + } + + VectorScale(pmove->velocity, newspeed / speed, pmove->velocity); + } + else + newspeed = 0; + + // water acceleration + if ((float)wishspeed < 0.1f) + { + return; + } + + addspeed = (float)wishspeed - newspeed; + + if (addspeed > 0.0f) + { + VectorNormalize(wishvel); + accelspeed = pmove->movevars->accelerate * pmove->friction * pmove->frametime * (float)wishspeed; + + if (accelspeed > addspeed) + { + accelspeed = addspeed; + } + + for (i = 0; i < 3; i++) + { + pmove->velocity[i] += accelspeed * wishvel[i]; + } + } + + // Now move + // assume it is a stair or a slope, so press down from stepheight above + VectorMA(pmove->origin, pmove->frametime, pmove->velocity, dest); + VectorCopy(dest, start); + + start[2] += pmove->movevars->stepsize + 1; + trace = pmove->PM_PlayerTrace(start, dest, PM_NORMAL, -1); + + // FIXME: check steep slope? + if (!trace.startsolid && !trace.allsolid) + { + // walked up the step, so just keep result and exit + VectorCopy(trace.endpos, pmove->origin); + return; + } + + // Try moving straight along out normal path. PM_FlyMove(); } /* <2cd220> ../cstrike/pm_shared/pm_shared.c:1464 */ void PM_AirMove(void) { - int i; - vec3_t wishvel; - float fmove, smove; - vec3_t wishdir; + int i; + vec3_t wishvel; + float fmove, smove; + vec3_t wishdir; float wishspeed; - // Copy movement amounts - fmove = pmove->cmd.forwardmove; - smove = pmove->cmd.sidemove; - - // Zero out z components of movement vectors - pmove->forward[2] = 0; - pmove->right[2] = 0; - - // Renormalize - VectorNormalize(pmove->forward); - VectorNormalize(pmove->right); - - // Determine x and y parts of velocity - for (i = 0; i < 2; i++) - { - wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; - } - - // Zero out z part of velocity - wishvel[2] = 0; - - // Determine maginitude of speed of move - VectorCopy(wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); - - // Clamp to server defined max speed - if (wishspeed > pmove->maxspeed) - { - VectorScale(wishvel, pmove->maxspeed/wishspeed, wishvel); - wishspeed = pmove->maxspeed; - } - - PM_AirAccelerate(wishdir, wishspeed, pmove->movevars->airaccelerate); - - // Add in any base velocity to the current velocity. - VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); - + // Copy movement amounts + fmove = pmove->cmd.forwardmove; + smove = pmove->cmd.sidemove; + + // Zero out z components of movement vectors + pmove->forward[2] = 0; + pmove->right[2] = 0; + + // Renormalize + VectorNormalize(pmove->forward); + VectorNormalize(pmove->right); + + // Determine x and y parts of velocity + for (i = 0; i < 2; i++) + { + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; + } + + // Zero out z part of velocity + wishvel[2] = 0; + + // Determine maginitude of speed of move + VectorCopy(wishvel, wishdir); + wishspeed = VectorNormalize(wishdir); + + // Clamp to server defined max speed + if (wishspeed > pmove->maxspeed) + { + VectorScale(wishvel, pmove->maxspeed/wishspeed, wishvel); + wishspeed = pmove->maxspeed; + } + + PM_AirAccelerate(wishdir, wishspeed, pmove->movevars->airaccelerate); + + // Add in any base velocity to the current velocity. + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); + PM_FlyMove(); } @@ -1404,152 +1404,152 @@ qboolean PM_InWater(void) /* <2cd2a7> ../cstrike/pm_shared/pm_shared.c:1522 */ qboolean PM_CheckWater(void) { - vec3_t point; - int cont; - int truecont; - float height; - float heightover2; - - // Pick a spot just above the players feet. - point[0] = pmove->origin[0] + (pmove->_player_mins[pmove->usehull][0] + pmove->_player_maxs[pmove->usehull][0]) * 0.5; - point[1] = pmove->origin[1] + (pmove->_player_mins[pmove->usehull][1] + pmove->_player_maxs[pmove->usehull][1]) * 0.5; - point[2] = pmove->origin[2] + pmove->_player_mins[pmove->usehull][2] + 1; - - // Assume that we are not in water at all. - pmove->waterlevel = 0; - pmove->watertype = CONTENTS_EMPTY; - - // Grab point contents. - cont = pmove->PM_PointContents(point, &truecont); - - // Are we under water? (not solid and not empty?) - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) - { - // Set water type - pmove->watertype = cont; - - // We are at least at level one - pmove->waterlevel = 1; - - height = (pmove->_player_mins[pmove->usehull][2] + pmove->_player_maxs[pmove->usehull][2]); - heightover2 = height * 0.5; - - // Now check a point that is at the player hull midpoint. - point[2] = pmove->origin[2] + heightover2; - cont = pmove->PM_PointContents(point, NULL); - - // If that point is also under water... - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) - { - // Set a higher water level. - pmove->waterlevel = 2; - - // Now check the eye position. (view_ofs is relative to the origin) - point[2] = pmove->origin[2] + pmove->view_ofs[2]; - - cont = pmove->PM_PointContents(point, NULL); - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) - { - // In over our eyes - pmove->waterlevel = 3; - } - } - - // Adjust velocity based on water current, if any. - if ((truecont <= CONTENTS_CURRENT_0) && (truecont >= CONTENTS_CURRENT_DOWN)) - { - // The deeper we are, the stronger the current. - static vec_t current_table[][3] = - { - {1, 0, 0}, {0, 1, 0}, {-1, 0, 0}, - {0, -1, 0}, {0, 0, 1}, {0, 0, -1} - }; - - VectorMA(pmove->basevelocity, 50.0 * pmove->waterlevel, current_table[CONTENTS_CURRENT_0 - truecont], pmove->basevelocity); - } - } - + vec3_t point; + int cont; + int truecont; + float height; + float heightover2; + + // Pick a spot just above the players feet. + point[0] = pmove->origin[0] + (pmove->_player_mins[pmove->usehull][0] + pmove->_player_maxs[pmove->usehull][0]) * 0.5; + point[1] = pmove->origin[1] + (pmove->_player_mins[pmove->usehull][1] + pmove->_player_maxs[pmove->usehull][1]) * 0.5; + point[2] = pmove->origin[2] + pmove->_player_mins[pmove->usehull][2] + 1; + + // Assume that we are not in water at all. + pmove->waterlevel = 0; + pmove->watertype = CONTENTS_EMPTY; + + // Grab point contents. + cont = pmove->PM_PointContents(point, &truecont); + + // Are we under water? (not solid and not empty?) + if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) + { + // Set water type + pmove->watertype = cont; + + // We are at least at level one + pmove->waterlevel = 1; + + height = (pmove->_player_mins[pmove->usehull][2] + pmove->_player_maxs[pmove->usehull][2]); + heightover2 = height * 0.5; + + // Now check a point that is at the player hull midpoint. + point[2] = pmove->origin[2] + heightover2; + cont = pmove->PM_PointContents(point, NULL); + + // If that point is also under water... + if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) + { + // Set a higher water level. + pmove->waterlevel = 2; + + // Now check the eye position. (view_ofs is relative to the origin) + point[2] = pmove->origin[2] + pmove->view_ofs[2]; + + cont = pmove->PM_PointContents(point, NULL); + if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT) + { + // In over our eyes + pmove->waterlevel = 3; + } + } + + // Adjust velocity based on water current, if any. + if ((truecont <= CONTENTS_CURRENT_0) && (truecont >= CONTENTS_CURRENT_DOWN)) + { + // The deeper we are, the stronger the current. + static vec_t current_table[][3] = + { + {1, 0, 0}, {0, 1, 0}, {-1, 0, 0}, + {0, -1, 0}, {0, 0, 1}, {0, 0, -1} + }; + + VectorMA(pmove->basevelocity, 50.0 * pmove->waterlevel, current_table[CONTENTS_CURRENT_0 - truecont], pmove->basevelocity); + } + } + return pmove->waterlevel > 1; } /* <2cd33a> ../cstrike/pm_shared/pm_shared.c:1593 */ void PM_CatagorizePosition(void) { - vec3_t point; + vec3_t point; pmtrace_t tr; - // if the player hull point one unit down is solid, the player - // is on ground - - // see if standing on something solid - - // Doing this before we move may introduce a potential latency in water detection, but - // doing it after can get us stuck on the bottom in water if the amount we move up - // is less than the 1 pixel 'threshold' we're about to snap to. Also, we'll call - // this several times per frame, so we really need to avoid sticking to the bottom of + // if the player hull point one unit down is solid, the player + // is on ground + + // see if standing on something solid + + // Doing this before we move may introduce a potential latency in water detection, but + // doing it after can get us stuck on the bottom in water if the amount we move up + // is less than the 1 pixel 'threshold' we're about to snap to. Also, we'll call + // this several times per frame, so we really need to avoid sticking to the bottom of // water on each call, and the converse case will correct itself if called twice. - PM_CheckWater(); - - point[0] = pmove->origin[0]; - point[1] = pmove->origin[1]; + PM_CheckWater(); + + point[0] = pmove->origin[0]; + point[1] = pmove->origin[1]; point[2] = pmove->origin[2] - 2; // Shooting up really fast. Definitely not on ground. - if (pmove->velocity[2] > 180) - { - pmove->onground = -1; + if (pmove->velocity[2] > 180) + { + pmove->onground = -1; } else { - // Try and move down. - tr = pmove->PM_PlayerTrace(pmove->origin, point, PM_NORMAL, -1); - - // If we hit a steep plane, we are not on ground - if (tr.plane.normal[2] < 0.7f) - { - // too steep - pmove->onground = -1; - } - else - { - // Otherwise, point to index of ent under us. - pmove->onground = tr.ent; - } - - // If we are on something... - if (pmove->onground != -1) - { - // Then we are not in water jump sequence - pmove->waterjumptime = 0; - - // If we could make the move, drop us down that 1 pixel - if (pmove->waterlevel < 2 && !tr.startsolid && !tr.allsolid) - { - VectorCopy(tr.endpos, pmove->origin); - } - } - - // Standing on an entity other than the world - // So signal that we are touching something. - if (tr.ent > 0) - { - PM_AddToTouched(tr, pmove->velocity); + // Try and move down. + tr = pmove->PM_PlayerTrace(pmove->origin, point, PM_NORMAL, -1); + + // If we hit a steep plane, we are not on ground + if (tr.plane.normal[2] < 0.7f) + { + // too steep + pmove->onground = -1; + } + else + { + // Otherwise, point to index of ent under us. + pmove->onground = tr.ent; + } + + // If we are on something... + if (pmove->onground != -1) + { + // Then we are not in water jump sequence + pmove->waterjumptime = 0; + + // If we could make the move, drop us down that 1 pixel + if (pmove->waterlevel < 2 && !tr.startsolid && !tr.allsolid) + { + VectorCopy(tr.endpos, pmove->origin); + } + } + + // Standing on an entity other than the world + // So signal that we are touching something. + if (tr.ent > 0) + { + PM_AddToTouched(tr, pmove->velocity); } } } -// When a player is stuck, it's costly to try and unstick them +// When a player is stuck, it's costly to try and unstick them // Grab a test offset for the player based on a passed in index /* <2cc4c5> ../cstrike/pm_shared/pm_shared.c:1654 */ int PM_GetRandomStuckOffsets(int nIndex, int server, vec_t *offset) { - // Last time we did a full - int idx; - idx = rgStuckLast[nIndex][server]++; - - VectorCopy(rgv3tStuckTable[idx % 54], offset); - + // Last time we did a full + int idx; + idx = rgStuckLast[nIndex][server]++; + + VectorCopy(rgv3tStuckTable[idx % 54], offset); + return (idx % 54); } @@ -1559,263 +1559,263 @@ void PM_ResetStuckOffsets(int nIndex, int server) rgStuckLast[nIndex][server] = 0; } -// If pmove->origin is in a solid position, -// try nudging slightly on all axis to +// If pmove->origin is in a solid position, +// try nudging slightly on all axis to // allow for the cut precision of the net coordinates /* <2cd3cf> ../cstrike/pm_shared/pm_shared.c:1681 */ int PM_CheckStuck(void) { - vec3_t base; - vec3_t offset; - vec3_t test; - int hitent; - int idx; - float_precision fTime; - int i; + vec3_t base; + vec3_t offset; + vec3_t test; + int hitent; + int idx; + float_precision fTime; + int i; pmtrace_t traceresult; // Last time we did a full static float rgStuckCheckTime[MAX_CLIENTS][2]; - // If position is okay, exit - hitent = pmove->PM_TestPlayerPosition(pmove->origin, &traceresult); - if (hitent == -1) - { - PM_ResetStuckOffsets(pmove->player_index, pmove->server); - return 0; + // If position is okay, exit + hitent = pmove->PM_TestPlayerPosition(pmove->origin, &traceresult); + if (hitent == -1) + { + PM_ResetStuckOffsets(pmove->player_index, pmove->server); + return 0; } - VectorCopy(pmove->origin, base); - - // Deal with precision error in network. - if (!pmove->server) - { - // World or BSP model - if (hitent == 0 || pmove->physents[hitent].model != NULL) - { - int nReps = 0; - PM_ResetStuckOffsets(pmove->player_index, pmove->server); - do - { - i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); - - VectorAdd(base, offset, test); - if (pmove->PM_TestPlayerPosition(test, &traceresult) == -1) - { - PM_ResetStuckOffsets(pmove->player_index, pmove->server); - VectorCopy(test, pmove->origin); - return 0; - } - - nReps++; - } - while (nReps < 54); - } + VectorCopy(pmove->origin, base); + + // Deal with precision error in network. + if (!pmove->server) + { + // World or BSP model + if (hitent == 0 || pmove->physents[hitent].model != NULL) + { + int nReps = 0; + PM_ResetStuckOffsets(pmove->player_index, pmove->server); + do + { + i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); + + VectorAdd(base, offset, test); + if (pmove->PM_TestPlayerPosition(test, &traceresult) == -1) + { + PM_ResetStuckOffsets(pmove->player_index, pmove->server); + VectorCopy(test, pmove->origin); + return 0; + } + + nReps++; + } + while (nReps < 54); + } + } + + // Only an issue on the client. + + if (pmove->server) + idx = 0; + else + idx = 1; + + fTime = pmove->Sys_FloatTime(); + + // Too soon? + if (rgStuckCheckTime[pmove->player_index][idx] >= (fTime - PM_CHECKSTUCK_MINTIME)) + { + return 1; + } + + rgStuckCheckTime[pmove->player_index][idx] = fTime; + + pmove->PM_StuckTouch(hitent, &traceresult); + + i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); + + VectorAdd(base, offset, test); + if ((hitent = pmove->PM_TestPlayerPosition(test, NULL)) == -1) + { + PM_ResetStuckOffsets(pmove->player_index, pmove->server); + + if (i >= 27) + { + VectorCopy(test, pmove->origin); + } + + return 0; + } + + // If player is flailing while stuck in another player (should never happen), then see + // if we can't "unstick" them forceably. + if ((pmove->cmd.buttons & (IN_JUMP | IN_DUCK | IN_ATTACK)) && pmove->physents[hitent].player != 0) + { + float x, y, z; + float xystep = 8.0; + float zstep = 18.0; + float xyminmax = xystep; + float zminmax = 4 * zstep; + + for (z = 0; z <= zminmax; z += zstep) + { + for (x = -xyminmax; x <= xyminmax; x += xystep) + { + for (y = -xyminmax; y <= xyminmax; y += xystep) + { + VectorCopy(base, test); + + test[0] += x; + test[1] += y; + test[2] += z; + + if (pmove->PM_TestPlayerPosition(test, NULL) == -1) + { + VectorCopy(test, pmove->origin); + return 0; + } + } + } + } } - // Only an issue on the client. - - if (pmove->server) - idx = 0; - else - idx = 1; - - fTime = pmove->Sys_FloatTime(); - - // Too soon? - if (rgStuckCheckTime[pmove->player_index][idx] >= (fTime - PM_CHECKSTUCK_MINTIME)) - { - return 1; - } - - rgStuckCheckTime[pmove->player_index][idx] = fTime; - - pmove->PM_StuckTouch(hitent, &traceresult); - - i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); - - VectorAdd(base, offset, test); - if ((hitent = pmove->PM_TestPlayerPosition(test, NULL)) == -1) - { - PM_ResetStuckOffsets(pmove->player_index, pmove->server); - - if (i >= 27) - { - VectorCopy(test, pmove->origin); - } - - return 0; - } - - // If player is flailing while stuck in another player (should never happen), then see - // if we can't "unstick" them forceably. - if ((pmove->cmd.buttons & (IN_JUMP | IN_DUCK | IN_ATTACK)) && pmove->physents[hitent].player != 0) - { - float x, y, z; - float xystep = 8.0; - float zstep = 18.0; - float xyminmax = xystep; - float zminmax = 4 * zstep; - - for (z = 0; z <= zminmax; z += zstep) - { - for (x = -xyminmax; x <= xyminmax; x += xystep) - { - for (y = -xyminmax; y <= xyminmax; y += xystep) - { - VectorCopy(base, test); - - test[0] += x; - test[1] += y; - test[2] += z; - - if (pmove->PM_TestPlayerPosition(test, NULL) == -1) - { - VectorCopy(test, pmove->origin); - return 0; - } - } - } - } - } - return 1; } /* <2cd61f> ../cstrike/pm_shared/pm_shared.c:1807 */ void PM_SpectatorMove(void) { - float_precision speed, drop, friction; - float_precision control, newspeed; - float currentspeed, addspeed; - float_precision accelspeed; - int i; - vec3_t wishvel; - float fmove, smove; - vec3_t wishdir; - float_precision wishspeed; - - // this routine keeps track of the spectators psoition - // there a two different main move types : track player or moce freely (OBS_ROAMING) - // doesn't need excate track position, only to generate PVS, so just copy - // targets position and real view position is calculated on client (saves server CPU) - if (pmove->iuser1 == OBS_ROAMING) - { - // Move around in normal spectator method - speed = Length (pmove->velocity); - - if (speed >= 1.0) - { - drop = 0; - - // extra friction - friction = pmove->movevars->friction * 1.5; - control = speed < pmove->movevars->stopspeed ? pmove->movevars->stopspeed : speed; - drop += friction * (control * pmove->frametime); - - // scale the velocity - newspeed = speed - drop; - - if (newspeed < 0) - { - newspeed = 0; - } - newspeed /= speed; - - VectorScale(pmove->velocity, newspeed, pmove->velocity); - } - else - { - VectorCopy(vec3_origin, pmove->velocity) - } - - // accelerate - fmove = pmove->cmd.forwardmove; - smove = pmove->cmd.sidemove; - - VectorNormalize(pmove->forward); - VectorNormalize(pmove->right); - - for (i = 0; i < 3; i++) - { - wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; - } - - wishvel[2] += pmove->cmd.upmove; - - VectorCopy(wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); - - // clamp to server defined max speed - if (wishspeed > pmove->movevars->spectatormaxspeed) - { - VectorScale(wishvel, pmove->movevars->spectatormaxspeed / wishspeed, wishvel); - wishspeed = pmove->movevars->spectatormaxspeed; - } - - currentspeed = DotProduct(pmove->velocity, wishdir); - - addspeed = wishspeed - currentspeed; - if (addspeed <= 0) - { - return; - } - - accelspeed = pmove->movevars->accelerate * pmove->frametime * wishspeed; - if (accelspeed > addspeed) - { - accelspeed = addspeed; - } - - for (i = 0; i < 3; i++) - { - pmove->velocity[i] += accelspeed * wishdir[i]; - } - - // move - VectorMA(pmove->origin, pmove->frametime, pmove->velocity, pmove->origin); - } - else - { - // all other modes just track some kind of target, so spectator PVS = target PVS - int target; - - // no valid target ? - if (pmove->iuser2 <= 0) - return; - - // Find the client this player's targeting - for (target = 0; target < pmove->numphysent; target++) - { - if (pmove->physents[target].info == pmove->iuser2) - break; - } - - if (target == pmove->numphysent) - return; - - // use targets position as own origin for PVS - VectorCopy(pmove->physents[target].angles, pmove->angles); - VectorCopy(pmove->physents[target].origin, pmove->origin); - - // no velocity - VectorCopy(vec3_origin, pmove->velocity); + float_precision speed, drop, friction; + float_precision control, newspeed; + float currentspeed, addspeed; + float_precision accelspeed; + int i; + vec3_t wishvel; + float fmove, smove; + vec3_t wishdir; + float_precision wishspeed; + + // this routine keeps track of the spectators psoition + // there a two different main move types : track player or moce freely (OBS_ROAMING) + // doesn't need excate track position, only to generate PVS, so just copy + // targets position and real view position is calculated on client (saves server CPU) + if (pmove->iuser1 == OBS_ROAMING) + { + // Move around in normal spectator method + speed = Length (pmove->velocity); + + if (speed >= 1.0) + { + drop = 0; + + // extra friction + friction = pmove->movevars->friction * 1.5; + control = speed < pmove->movevars->stopspeed ? pmove->movevars->stopspeed : speed; + drop += friction * (control * pmove->frametime); + + // scale the velocity + newspeed = speed - drop; + + if (newspeed < 0) + { + newspeed = 0; + } + newspeed /= speed; + + VectorScale(pmove->velocity, newspeed, pmove->velocity); + } + else + { + VectorCopy(vec3_origin, pmove->velocity) + } + + // accelerate + fmove = pmove->cmd.forwardmove; + smove = pmove->cmd.sidemove; + + VectorNormalize(pmove->forward); + VectorNormalize(pmove->right); + + for (i = 0; i < 3; i++) + { + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; + } + + wishvel[2] += pmove->cmd.upmove; + + VectorCopy(wishvel, wishdir); + wishspeed = VectorNormalize(wishdir); + + // clamp to server defined max speed + if (wishspeed > pmove->movevars->spectatormaxspeed) + { + VectorScale(wishvel, pmove->movevars->spectatormaxspeed / wishspeed, wishvel); + wishspeed = pmove->movevars->spectatormaxspeed; + } + + currentspeed = DotProduct(pmove->velocity, wishdir); + + addspeed = wishspeed - currentspeed; + if (addspeed <= 0) + { + return; + } + + accelspeed = pmove->movevars->accelerate * pmove->frametime * wishspeed; + if (accelspeed > addspeed) + { + accelspeed = addspeed; + } + + for (i = 0; i < 3; i++) + { + pmove->velocity[i] += accelspeed * wishdir[i]; + } + + // move + VectorMA(pmove->origin, pmove->frametime, pmove->velocity, pmove->origin); + } + else + { + // all other modes just track some kind of target, so spectator PVS = target PVS + int target; + + // no valid target ? + if (pmove->iuser2 <= 0) + return; + + // Find the client this player's targeting + for (target = 0; target < pmove->numphysent; target++) + { + if (pmove->physents[target].info == pmove->iuser2) + break; + } + + if (target == pmove->numphysent) + return; + + // use targets position as own origin for PVS + VectorCopy(pmove->physents[target].angles, pmove->angles); + VectorCopy(pmove->physents[target].origin, pmove->origin); + + // no velocity + VectorCopy(vec3_origin, pmove->velocity); } } -// Use for ease-in, ease-out style interpolation (accel/decel) +// Use for ease-in, ease-out style interpolation (accel/decel) // Used by ducking code. /* <2cc509> ../cstrike/pm_shared/pm_shared.c:1941 */ float PM_SplineFraction(float value, float scale) { - float_precision valueSquared; - - value = scale * value; - valueSquared = value * value; - - // Nice little ease-in, ease-out spline-like curve + float_precision valueSquared; + + value = scale * value; + valueSquared = value * value; + + // Nice little ease-in, ease-out spline-like curve return 3 * valueSquared - 2 * valueSquared * value; } @@ -1832,104 +1832,104 @@ NOXREF float PM_SimpleSpline(float value) /* <2cc595> ../cstrike/pm_shared/pm_shared.c:1959 */ void PM_FixPlayerCrouchStuck(int direction) { - int hitent; - int i; - vec3_t test; - - hitent = pmove->PM_TestPlayerPosition (pmove->origin, NULL); - - if (hitent == -1) - { - return; - } - - VectorCopy(pmove->origin, test); - - for (i = 0; i < 36; i++) - { - pmove->origin[2] += direction; - hitent = pmove->PM_TestPlayerPosition(pmove->origin, NULL); - - if (hitent == -1) - { - return; - } - } - - // Failed + int hitent; + int i; + vec3_t test; + + hitent = pmove->PM_TestPlayerPosition (pmove->origin, NULL); + + if (hitent == -1) + { + return; + } + + VectorCopy(pmove->origin, test); + + for (i = 0; i < 36; i++) + { + pmove->origin[2] += direction; + hitent = pmove->PM_TestPlayerPosition(pmove->origin, NULL); + + if (hitent == -1) + { + return; + } + } + + // Failed VectorCopy(test, pmove->origin); } /* <2cd7cd> ../cstrike/pm_shared/pm_shared.c:1983 */ void PM_Duck(void) -{ - float_precision duckFraction; - - int buttonsChanged = (pmove->oldbuttons ^ pmove->cmd.buttons); // These buttons have changed this frame - int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" - - int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; - int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; +{ + float_precision duckFraction; - if (pmove->cmd.buttons & IN_DUCK) - { - pmove->oldbuttons |= IN_DUCK; - } - else - { - pmove->oldbuttons &= ~IN_DUCK; - } - - if (pmove->dead || (!(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING))) - { - return; - } - - pmove->cmd.forwardmove *= PLAYER_DUCKING_MULTIPLIER; - pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER; - pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER; + int buttonsChanged = (pmove->oldbuttons ^ pmove->cmd.buttons); // These buttons have changed this frame + int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" + + int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; + int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; if (pmove->cmd.buttons & IN_DUCK) { - if ((nButtonPressed & IN_DUCK) && !(pmove->flags & FL_DUCKING)) - { - // Use 1 second so super long jump will work - pmove->flDuckTime = 1000; - pmove->bInDuck = true; + pmove->oldbuttons |= IN_DUCK; + } + else + { + pmove->oldbuttons &= ~IN_DUCK; + } + + if (pmove->dead || (!(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING))) + { + return; + } + + pmove->cmd.forwardmove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER; + + if (pmove->cmd.buttons & IN_DUCK) + { + if ((nButtonPressed & IN_DUCK) && !(pmove->flags & FL_DUCKING)) + { + // Use 1 second so super long jump will work + pmove->flDuckTime = 1000; + pmove->bInDuck = true; } - float_precision time = _max(0.0, (1.0 - pmove->flDuckTime / 1000.0)); + float_precision time = Q_max(0.0, (1.0 - pmove->flDuckTime / 1000.0)); - if (pmove->bInDuck) - { - // Finish ducking immediately if duck time is over or not on ground - if (((pmove->flDuckTime / 1000.0) <= (1.0 - TIME_TO_DUCK)) || pmove->onground == -1) - { - pmove->usehull = 1; - pmove->view_ofs[2] = PM_VEC_DUCK_VIEW; - pmove->flags |= FL_DUCKING; - pmove->bInDuck = FALSE; - - // HACKHACK - Fudge for collision bug - no time to fix this properly - if (pmove->onground != -1) - { - pmove->origin[2] = pmove->origin[2] - 18.0; - - // See if we are stuck? - PM_FixPlayerCrouchStuck(STUCK_MOVEUP); - - // Recatagorize position since ducking can change origin - PM_CatagorizePosition(); - } - } - else - { - float fMore = (PM_VEC_DUCK_HULL_MIN - PM_VEC_HULL_MIN); - - // Calc parametric time - duckFraction = PM_SplineFraction(time, (1.0 / TIME_TO_DUCK)); - pmove->view_ofs[2] = ((PM_VEC_DUCK_VIEW - fMore) * duckFraction) + (PM_VEC_VIEW * (1 - duckFraction)); - } + if (pmove->bInDuck) + { + // Finish ducking immediately if duck time is over or not on ground + if (((pmove->flDuckTime / 1000.0) <= (1.0 - TIME_TO_DUCK)) || pmove->onground == -1) + { + pmove->usehull = 1; + pmove->view_ofs[2] = PM_VEC_DUCK_VIEW; + pmove->flags |= FL_DUCKING; + pmove->bInDuck = FALSE; + + // HACKHACK - Fudge for collision bug - no time to fix this properly + if (pmove->onground != -1) + { + pmove->origin[2] = pmove->origin[2] - 18.0; + + // See if we are stuck? + PM_FixPlayerCrouchStuck(STUCK_MOVEUP); + + // Recatagorize position since ducking can change origin + PM_CatagorizePosition(); + } + } + else + { + float fMore = (PM_VEC_DUCK_HULL_MIN - PM_VEC_HULL_MIN); + + // Calc parametric time + duckFraction = PM_SplineFraction(time, (1.0 / TIME_TO_DUCK)); + pmove->view_ofs[2] = ((PM_VEC_DUCK_VIEW - fMore) * duckFraction) + (PM_VEC_VIEW * (1 - duckFraction)); + } } } @@ -1938,46 +1938,46 @@ void PM_Duck(void) pmtrace_t trace; vec3_t newOrigin; - VectorCopy(pmove->origin, newOrigin); - - if (pmove->onground != -1) - { - newOrigin[2] += 18.0; + VectorCopy(pmove->origin, newOrigin); + + if (pmove->onground != -1) + { + newOrigin[2] += 18.0; } - trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); - - if (!trace.startsolid) - { - pmove->usehull = 0; - - // Oh, no, changing hulls stuck us into something, try unsticking downward first. - trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); - - if (trace.startsolid) - { - // See if we are stuck? If so, stay ducked with the duck hull until we have a clear spot - // Con_Printf("unstick got stuck\n"); - pmove->usehull = 1; - return; - } - - pmove->flags &= ~FL_DUCKING; - pmove->bInDuck = FALSE; - pmove->view_ofs[2] = PM_VEC_VIEW; - pmove->flDuckTime = 0; - + trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); + + if (!trace.startsolid) + { + pmove->usehull = 0; + + // Oh, no, changing hulls stuck us into something, try unsticking downward first. + trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); + + if (trace.startsolid) + { + // See if we are stuck? If so, stay ducked with the duck hull until we have a clear spot + // Con_Printf("unstick got stuck\n"); + pmove->usehull = 1; + return; + } + + pmove->flags &= ~FL_DUCKING; + pmove->bInDuck = FALSE; + pmove->view_ofs[2] = PM_VEC_VIEW; + pmove->flDuckTime = 0; + pmove->flTimeStepSound -= 100; if (pmove->flTimeStepSound < 0) { pmove->flTimeStepSound = 0; - } - - VectorCopy(newOrigin, pmove->origin); - - // Recatagorize position since ducking can change origin - PM_CatagorizePosition(); + } + + VectorCopy(newOrigin, pmove->origin); + + // Recatagorize position since ducking can change origin + PM_CatagorizePosition(); } } } @@ -1985,117 +1985,117 @@ void PM_Duck(void) /* <2cd8c2> ../cstrike/pm_shared/pm_shared.c:2332 */ void PM_LadderMove(physent_t *pLadder) { - vec3_t ladderCenter; - trace_t trace; - qboolean onFloor; - vec3_t floor; + vec3_t ladderCenter; + trace_t trace; + qboolean onFloor; + vec3_t floor; vec3_t modelmins, modelmaxs; - if (pmove->movetype == MOVETYPE_NOCLIP) + if (pmove->movetype == MOVETYPE_NOCLIP) return; - pmove->PM_GetModelBounds(pLadder->model, modelmins, modelmaxs); - - VectorAdd(modelmins, modelmaxs, ladderCenter); + pmove->PM_GetModelBounds(pLadder->model, modelmins, modelmaxs); + + VectorAdd(modelmins, modelmaxs, ladderCenter); VectorScale(ladderCenter, 0.5, ladderCenter); - pmove->movetype = MOVETYPE_FLY; - - // On ladder, convert movement to be relative to the ladder - VectorCopy(pmove->origin, floor); - floor[2] += pmove->_player_mins[pmove->usehull][2] - 1; - - if (pmove->PM_PointContents(floor, NULL) == CONTENTS_SOLID) - onFloor = true; - else + pmove->movetype = MOVETYPE_FLY; + + // On ladder, convert movement to be relative to the ladder + VectorCopy(pmove->origin, floor); + floor[2] += pmove->_player_mins[pmove->usehull][2] - 1; + + if (pmove->PM_PointContents(floor, NULL) == CONTENTS_SOLID) + onFloor = true; + else onFloor = false; - pmove->gravity = 0; - pmove->PM_TraceModel(pLadder, pmove->origin, ladderCenter, &trace); - - if (trace.fraction != 1.0f) + pmove->gravity = 0; + pmove->PM_TraceModel(pLadder, pmove->origin, ladderCenter, &trace); + + if (trace.fraction != 1.0f) { - float forward = 0, right = 0; - vec3_t vpn, v_right; + float forward = 0, right = 0; + vec3_t vpn, v_right; float flSpeed = MAX_CLIMB_SPEED; - // they shouldn't be able to move faster than their maxspeed - if (flSpeed > pmove->maxspeed) - { - flSpeed = pmove->maxspeed; + // they shouldn't be able to move faster than their maxspeed + if (flSpeed > pmove->maxspeed) + { + flSpeed = pmove->maxspeed; } AngleVectors(pmove->angles, vpn, v_right, NULL); - if (pmove->flags & FL_DUCKING) - { - flSpeed *= PLAYER_DUCKING_MULTIPLIER; + if (pmove->flags & FL_DUCKING) + { + flSpeed *= PLAYER_DUCKING_MULTIPLIER; } - if (pmove->cmd.buttons & IN_BACK) - { - forward -= flSpeed; - } - if (pmove->cmd.buttons & IN_FORWARD) - { - forward += flSpeed; - } - if (pmove->cmd.buttons & IN_MOVELEFT) - { - right -= flSpeed; - } - if (pmove->cmd.buttons & IN_MOVERIGHT) - { - right += flSpeed; + if (pmove->cmd.buttons & IN_BACK) + { + forward -= flSpeed; + } + if (pmove->cmd.buttons & IN_FORWARD) + { + forward += flSpeed; + } + if (pmove->cmd.buttons & IN_MOVELEFT) + { + right -= flSpeed; + } + if (pmove->cmd.buttons & IN_MOVERIGHT) + { + right += flSpeed; } - if (pmove->cmd.buttons & IN_JUMP) - { - pmove->movetype = MOVETYPE_WALK; - VectorScale(trace.plane.normal, 270, pmove->velocity); + if (pmove->cmd.buttons & IN_JUMP) + { + pmove->movetype = MOVETYPE_WALK; + VectorScale(trace.plane.normal, 270, pmove->velocity); } - else - { - if (forward != 0 || right != 0) - { - vec3_t velocity, perp, cross, lateral, tmp; - float normal; - - VectorScale(vpn, forward, velocity); - VectorMA(velocity, right, v_right, velocity); - - VectorClear(tmp); - tmp[2] = 1; - - _CrossProduct(tmp, trace.plane.normal, perp); - VectorNormalize(perp); - - // decompose velocity into ladder plane - normal = DotProduct(velocity, trace.plane.normal); - // This is the velocity into the face of the ladder - VectorScale(trace.plane.normal, normal, cross); - - // This is the player's additional velocity - VectorSubtract(velocity, cross, lateral); - - // This turns the velocity into the face of the ladder into velocity that - // is roughly vertically perpendicular to the face of the ladder. - // NOTE: It IS possible to face up and move down or face down and move up - // because the velocity is a sum of the directional velocity and the converted - // velocity through the face of the ladder -- by design. - _CrossProduct(trace.plane.normal, perp, tmp); - VectorMA(lateral, -normal, tmp, pmove->velocity); - - // On ground moving away from the ladder - if (onFloor && normal > 0) - { - VectorMA(pmove->velocity, MAX_CLIMB_SPEED, trace.plane.normal, pmove->velocity); - } - } - else - { - VectorClear(pmove->velocity); - } + else + { + if (forward != 0 || right != 0) + { + vec3_t velocity, perp, cross, lateral, tmp; + float normal; + + VectorScale(vpn, forward, velocity); + VectorMA(velocity, right, v_right, velocity); + + VectorClear(tmp); + tmp[2] = 1; + + _CrossProduct(tmp, trace.plane.normal, perp); + VectorNormalize(perp); + + // decompose velocity into ladder plane + normal = DotProduct(velocity, trace.plane.normal); + // This is the velocity into the face of the ladder + VectorScale(trace.plane.normal, normal, cross); + + // This is the player's additional velocity + VectorSubtract(velocity, cross, lateral); + + // This turns the velocity into the face of the ladder into velocity that + // is roughly vertically perpendicular to the face of the ladder. + // NOTE: It IS possible to face up and move down or face down and move up + // because the velocity is a sum of the directional velocity and the converted + // velocity through the face of the ladder -- by design. + _CrossProduct(trace.plane.normal, perp, tmp); + VectorMA(lateral, -normal, tmp, pmove->velocity); + + // On ground moving away from the ladder + if (onFloor && normal > 0) + { + VectorMA(pmove->velocity, MAX_CLIMB_SPEED, trace.plane.normal, pmove->velocity); + } + } + else + { + VectorClear(pmove->velocity); + } } } } @@ -2103,59 +2103,59 @@ void PM_LadderMove(physent_t *pLadder) /* <2cda06> ../cstrike/pm_shared/pm_shared.c:2457 */ physent_t *PM_Ladder(void) { - int i; - physent_t *pe; - hull_t *hull; - int num; + int i; + physent_t *pe; + hull_t *hull; + int num; vec3_t test; - for (i = 0; i < pmove->nummoveent; i++) - { - pe = &pmove->moveents[i]; - - if (pe->model && (modtype_t)pmove->PM_GetModelType(pe->model) == mod_brush && pe->skin == CONTENTS_LADDER) - { - hull = (hull_t *)pmove->PM_HullForBsp(pe, test); - num = hull->firstclipnode; - - // Offset the test point appropriately for this hull. - VectorSubtract(pmove->origin, test, test); - - // Test the player's hull for intersection with this model - if (pmove->PM_HullPointContents(hull, num, test) == CONTENTS_EMPTY) - { - continue; - } - - return pe; - } - } - + for (i = 0; i < pmove->nummoveent; i++) + { + pe = &pmove->moveents[i]; + + if (pe->model && (modtype_t)pmove->PM_GetModelType(pe->model) == mod_brush && pe->skin == CONTENTS_LADDER) + { + hull = (hull_t *)pmove->PM_HullForBsp(pe, test); + num = hull->firstclipnode; + + // Offset the test point appropriately for this hull. + VectorSubtract(pmove->origin, test, test); + + // Test the player's hull for intersection with this model + if (pmove->PM_HullPointContents(hull, num, test) == CONTENTS_EMPTY) + { + continue; + } + + return pe; + } + } + return NULL; } /* <2cda77> ../cstrike/pm_shared/pm_shared.c:2491 */ void PM_WaterJump(void) { - if (pmove->waterjumptime > 10000) - { - pmove->waterjumptime = 10000; - } - - if (!pmove->waterjumptime) - { - return; - } - - pmove->waterjumptime -= pmove->cmd.msec; - - if (pmove->waterjumptime < 0 || !pmove->waterlevel) - { - pmove->waterjumptime = 0; - pmove->flags &= ~FL_WATERJUMP; - } - - pmove->velocity[0] = pmove->movedir[0]; + if (pmove->waterjumptime > 10000) + { + pmove->waterjumptime = 10000; + } + + if (!pmove->waterjumptime) + { + return; + } + + pmove->waterjumptime -= pmove->cmd.msec; + + if (pmove->waterjumptime < 0 || !pmove->waterlevel) + { + pmove->waterjumptime = 0; + pmove->flags &= ~FL_WATERJUMP; + } + + pmove->velocity[0] = pmove->movedir[0]; pmove->velocity[1] = pmove->movedir[1]; } @@ -2202,141 +2202,141 @@ pmtrace_t PM_PushEntity(vec_t *push) /* <2cdb13> ../cstrike/pm_shared/pm_shared.c:2569 */ void PM_Physics_Toss(void) { - pmtrace_t trace; - vec3_t move; - float backoff; - - PM_CheckWater(); - - if (pmove->velocity[2] > 0) - { - pmove->onground = -1; - } - - // If on ground and not moving, return. - if (pmove->onground != -1) - { - if (VectorCompare(pmove->basevelocity, vec3_origin) && VectorCompare(pmove->velocity, vec3_origin)) - { - return; - } - } - - PM_CheckVelocity(); - - // add gravity - if (pmove->movetype != MOVETYPE_FLY && pmove->movetype != MOVETYPE_BOUNCEMISSILE && pmove->movetype != MOVETYPE_FLYMISSILE) - { - PM_AddGravity(); - } - - // move origin - // Base velocity is not properly accounted for since this entity will move again after the bounce without - // taking it into account - VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); - - PM_CheckVelocity(); - VectorScale(pmove->velocity, pmove->frametime, move); - VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); - - // Should this clear basevelocity - trace = PM_PushEntity(move); - - PM_CheckVelocity(); - - if (trace.allsolid) - { - // entity is trapped in another solid - pmove->onground = trace.ent; - VectorCopy(vec3_origin, pmove->velocity); - return; - } - - if (trace.fraction == 1.0f) - { - PM_CheckWater(); - return; - } - - if (pmove->movetype == MOVETYPE_BOUNCE) - { - backoff = 2.0f - pmove->friction; - } - else if (pmove->movetype == MOVETYPE_BOUNCEMISSILE) - { - backoff = 2.0f; - } - else - backoff = 1.0f; - - PM_ClipVelocity(pmove->velocity, trace.plane.normal, pmove->velocity, backoff); - - // stop if on ground - if (trace.plane.normal[2] > 0.7f) - { - float vel; - vec3_t base; - - VectorClear(base); - if (pmove->velocity[2] < pmove->movevars->gravity * pmove->frametime) - { - // we're rolling on the ground, add static friction. - pmove->onground = trace.ent; - pmove->velocity[2] = 0; - } - - vel = DotProduct(pmove->velocity, pmove->velocity); - - if (vel < (30 * 30) || (pmove->movetype != MOVETYPE_BOUNCE && pmove->movetype != MOVETYPE_BOUNCEMISSILE)) - { - pmove->onground = trace.ent; - VectorCopy(vec3_origin, pmove->velocity); - } - else - { - VectorScale(pmove->velocity, (1.0f - trace.fraction) * pmove->frametime * 0.9f, move); - trace = PM_PushEntity(move); - } - - VectorSubtract(pmove->velocity, base, pmove->velocity) - } - - // check for in water + pmtrace_t trace; + vec3_t move; + float backoff; + + PM_CheckWater(); + + if (pmove->velocity[2] > 0) + { + pmove->onground = -1; + } + + // If on ground and not moving, return. + if (pmove->onground != -1) + { + if (VectorCompare(pmove->basevelocity, vec3_origin) && VectorCompare(pmove->velocity, vec3_origin)) + { + return; + } + } + + PM_CheckVelocity(); + + // add gravity + if (pmove->movetype != MOVETYPE_FLY && pmove->movetype != MOVETYPE_BOUNCEMISSILE && pmove->movetype != MOVETYPE_FLYMISSILE) + { + PM_AddGravity(); + } + + // move origin + // Base velocity is not properly accounted for since this entity will move again after the bounce without + // taking it into account + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); + + PM_CheckVelocity(); + VectorScale(pmove->velocity, pmove->frametime, move); + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); + + // Should this clear basevelocity + trace = PM_PushEntity(move); + + PM_CheckVelocity(); + + if (trace.allsolid) + { + // entity is trapped in another solid + pmove->onground = trace.ent; + VectorCopy(vec3_origin, pmove->velocity); + return; + } + + if (trace.fraction == 1.0f) + { + PM_CheckWater(); + return; + } + + if (pmove->movetype == MOVETYPE_BOUNCE) + { + backoff = 2.0f - pmove->friction; + } + else if (pmove->movetype == MOVETYPE_BOUNCEMISSILE) + { + backoff = 2.0f; + } + else + backoff = 1.0f; + + PM_ClipVelocity(pmove->velocity, trace.plane.normal, pmove->velocity, backoff); + + // stop if on ground + if (trace.plane.normal[2] > 0.7f) + { + float vel; + vec3_t base; + + VectorClear(base); + if (pmove->velocity[2] < pmove->movevars->gravity * pmove->frametime) + { + // we're rolling on the ground, add static friction. + pmove->onground = trace.ent; + pmove->velocity[2] = 0; + } + + vel = DotProduct(pmove->velocity, pmove->velocity); + + if (vel < (30 * 30) || (pmove->movetype != MOVETYPE_BOUNCE && pmove->movetype != MOVETYPE_BOUNCEMISSILE)) + { + pmove->onground = trace.ent; + VectorCopy(vec3_origin, pmove->velocity); + } + else + { + VectorScale(pmove->velocity, (1.0f - trace.fraction) * pmove->frametime * 0.9f, move); + trace = PM_PushEntity(move); + } + + VectorSubtract(pmove->velocity, base, pmove->velocity) + } + + // check for in water PM_CheckWater(); } /* <2cdba2> ../cstrike/pm_shared/pm_shared.c:2674 */ void PM_NoClip(void) { - int i; - vec3_t wishvel; + int i; + vec3_t wishvel; float fmove, smove; - // Copy movement amounts - fmove = pmove->cmd.forwardmove; - smove = pmove->cmd.sidemove; - - VectorNormalize(pmove->forward); - VectorNormalize(pmove->right); - - // Determine x and y parts of velocity - for (i = 0; i < 3; i++) - { - wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; - } - - wishvel[2] += pmove->cmd.upmove; - - VectorMA(pmove->origin, pmove->frametime, wishvel, pmove->origin); - - // Zero out the velocity so that we don't accumulate a huge downward velocity from - // gravity, etc. + // Copy movement amounts + fmove = pmove->cmd.forwardmove; + smove = pmove->cmd.sidemove; + + VectorNormalize(pmove->forward); + VectorNormalize(pmove->right); + + // Determine x and y parts of velocity + for (i = 0; i < 3; i++) + { + wishvel[i] = pmove->forward[i] * fmove + pmove->right[i] * smove; + } + + wishvel[2] += pmove->cmd.upmove; + + VectorMA(pmove->origin, pmove->frametime, wishvel, pmove->origin); + + // Zero out the velocity so that we don't accumulate a huge downward velocity from + // gravity, etc. VectorClear(pmove->velocity); } -// Purpose: Corrects bunny jumping (where player initiates a bunny jump before other -// movement logic runs, thus making onground == -1 thus making PM_Friction get skipped and -// running PM_AirMove, which doesn't crop velocity to maxspeed like the ground / other +// Purpose: Corrects bunny jumping (where player initiates a bunny jump before other +// movement logic runs, thus making onground == -1 thus making PM_Friction get skipped and +// running PM_AirMove, which doesn't crop velocity to maxspeed like the ground / other // movement logic does. /* <2ccab0> ../cstrike/pm_shared/pm_shared.c:2711 */ @@ -2351,13 +2351,13 @@ void PM_PreventMegaBunnyJumping(void) maxscaledspeed = BUNNYJUMP_MAX_SPEED_FACTOR * pmove->maxspeed; - // Don't divide by zero - if (maxscaledspeed <= 0.0f) + // Don't divide by zero + if (maxscaledspeed <= 0.0f) return; - + spd = Length(pmove->velocity); - if (spd <= maxscaledspeed) + if (spd <= maxscaledspeed) return; // Returns the modifier for the velocity @@ -2430,14 +2430,14 @@ void PM_Jump(void) // in air, so no effect if (pmove->onground == -1) { - // Flag that we jumped. + // Flag that we jumped. // don't jump again until released pmove->oldbuttons |= IN_JUMP; return; } // don't pogo stick - if (pmove->oldbuttons & IN_JUMP) + if (pmove->oldbuttons & IN_JUMP) { return; } @@ -2453,11 +2453,11 @@ void PM_Jump(void) pmove->onground = -1; PM_PreventMegaBunnyJumping(); - + float_precision fvel = Length(pmove->velocity); float fvol = 1.0f; - if (fvel >= 150.0f) + if (fvel >= 150.0f) { PM_PlayStepSound(PM_MapTextureTypeStepType(pmove->chtexturetype), fvol); } @@ -2483,125 +2483,125 @@ void PM_Jump(void) /* <2cdc4b> ../cstrike/pm_shared/pm_shared.c:2869 */ void PM_CheckWaterJump(void) { - vec3_t vecStart, vecEnd; - vec3_t flatforward; - vec3_t flatvelocity; - float curspeed; - pmtrace_t tr; - int savehull; - - // Already water jumping. - if (pmove->waterjumptime) - return; - - // Don't hop out if we just jumped in - if (pmove->velocity[2] < -180) - { - // only hop out if we are moving up - return; - } - - // See if we are backing up - flatvelocity[0] = pmove->velocity[0]; - flatvelocity[1] = pmove->velocity[1]; - flatvelocity[2] = 0; - - // Must be moving - curspeed = VectorNormalize(flatvelocity); - - // see if near an edge - flatforward[0] = pmove->forward[0]; - flatforward[1] = pmove->forward[1]; - flatforward[2] = 0; - VectorNormalize(flatforward); - - // Are we backing into water from steps or something? If so, don't pop forward - if (curspeed != 0.0 && (DotProduct(flatvelocity, flatforward) < 0.0)) - { - return; - } - - VectorCopy(pmove->origin, vecStart); - vecStart[2] += WJ_HEIGHT; - - VectorMA(vecStart, 24, flatforward, vecEnd); - - // Trace, this trace should use the point sized collision hull - savehull = pmove->usehull; - pmove->usehull = 2; - - tr = pmove->PM_PlayerTrace(vecStart, vecEnd, PM_NORMAL, -1); - - // Facing a near vertical wall? - if (tr.fraction < 1.0 && fabs((float_precision)(tr.plane.normal[2])) < 0.1f) - { - vecStart[2] += pmove->_player_maxs[savehull][2] - WJ_HEIGHT; - - VectorMA(vecStart, 24, flatforward, vecEnd); - VectorMA(vec3_origin, -50, tr.plane.normal, pmove->movedir); - - tr = pmove->PM_PlayerTrace(vecStart, vecEnd, PM_NORMAL, -1); - - if (tr.fraction == 1.0f) - { - pmove->waterjumptime = 2000.0f; - pmove->velocity[2] = 225.0f; - - pmove->oldbuttons |= IN_JUMP; - pmove->flags |= FL_WATERJUMP; - } - } - - // Reset the collision hull + vec3_t vecStart, vecEnd; + vec3_t flatforward; + vec3_t flatvelocity; + float curspeed; + pmtrace_t tr; + int savehull; + + // Already water jumping. + if (pmove->waterjumptime) + return; + + // Don't hop out if we just jumped in + if (pmove->velocity[2] < -180) + { + // only hop out if we are moving up + return; + } + + // See if we are backing up + flatvelocity[0] = pmove->velocity[0]; + flatvelocity[1] = pmove->velocity[1]; + flatvelocity[2] = 0; + + // Must be moving + curspeed = VectorNormalize(flatvelocity); + + // see if near an edge + flatforward[0] = pmove->forward[0]; + flatforward[1] = pmove->forward[1]; + flatforward[2] = 0; + VectorNormalize(flatforward); + + // Are we backing into water from steps or something? If so, don't pop forward + if (curspeed != 0.0 && (DotProduct(flatvelocity, flatforward) < 0.0)) + { + return; + } + + VectorCopy(pmove->origin, vecStart); + vecStart[2] += WJ_HEIGHT; + + VectorMA(vecStart, 24, flatforward, vecEnd); + + // Trace, this trace should use the point sized collision hull + savehull = pmove->usehull; + pmove->usehull = 2; + + tr = pmove->PM_PlayerTrace(vecStart, vecEnd, PM_NORMAL, -1); + + // Facing a near vertical wall? + if (tr.fraction < 1.0 && fabs((float_precision)(tr.plane.normal[2])) < 0.1f) + { + vecStart[2] += pmove->_player_maxs[savehull][2] - WJ_HEIGHT; + + VectorMA(vecStart, 24, flatforward, vecEnd); + VectorMA(vec3_origin, -50, tr.plane.normal, pmove->movedir); + + tr = pmove->PM_PlayerTrace(vecStart, vecEnd, PM_NORMAL, -1); + + if (tr.fraction == 1.0f) + { + pmove->waterjumptime = 2000.0f; + pmove->velocity[2] = 225.0f; + + pmove->oldbuttons |= IN_JUMP; + pmove->flags |= FL_WATERJUMP; + } + } + + // Reset the collision hull pmove->usehull = savehull; } /* <2cdcd3> ../cstrike/pm_shared/pm_shared.c:2933 */ void PM_CheckFalling(void) { - if (pmove->onground != -1 && !pmove->dead && pmove->flFallVelocity >= PM_PLAYER_FALL_PUNCH_THRESHHOLD) - { - float fvol = 0.5f; - - if (pmove->waterlevel <= 0) - { - if (pmove->flFallVelocity > PM_PLAYER_MAX_SAFE_FALL_SPEED) - { - fvol = 1.0f; - } - else if (pmove->flFallVelocity > PM_PLAYER_MAX_SAFE_FALL_SPEED / 2) - { - fvol = 0.85f; - } - else if (pmove->flFallVelocity < PM_PLAYER_MIN_BOUNCE_SPEED) - { - fvol = 0.0f; - } - } - - if (fvol > 0.0f) - { - PM_CatagorizeTextureType(); - - // play step sound for current texture - PM_PlayStepSound(PM_MapTextureTypeStepType(pmove->chtexturetype), fvol); - - pmove->flTimeStepSound = 300; - - // Knock the screen around a little bit, temporary effect - // punch z axis - pmove->punchangle[2] = pmove->flFallVelocity * 0.013; - - if (pmove->punchangle[0] > 8.0f) - { - pmove->punchangle[0] = 8.0f; - } - } - } - - if (pmove->onground != -1) - { - pmove->flFallVelocity = 0; + if (pmove->onground != -1 && !pmove->dead && pmove->flFallVelocity >= PM_PLAYER_FALL_PUNCH_THRESHHOLD) + { + float fvol = 0.5f; + + if (pmove->waterlevel <= 0) + { + if (pmove->flFallVelocity > PM_PLAYER_MAX_SAFE_FALL_SPEED) + { + fvol = 1.0f; + } + else if (pmove->flFallVelocity > PM_PLAYER_MAX_SAFE_FALL_SPEED / 2) + { + fvol = 0.85f; + } + else if (pmove->flFallVelocity < PM_PLAYER_MIN_BOUNCE_SPEED) + { + fvol = 0.0f; + } + } + + if (fvol > 0.0f) + { + PM_CatagorizeTextureType(); + + // play step sound for current texture + PM_PlayStepSound(PM_MapTextureTypeStepType(pmove->chtexturetype), fvol); + + pmove->flTimeStepSound = 300; + + // Knock the screen around a little bit, temporary effect + // punch z axis + pmove->punchangle[2] = pmove->flFallVelocity * 0.013; + + if (pmove->punchangle[0] > 8.0f) + { + pmove->punchangle[0] = 8.0f; + } + } + } + + if (pmove->onground != -1) + { + pmove->flFallVelocity = 0; } } @@ -2619,117 +2619,117 @@ void PM_PlayWaterSounds(void) if (pmove->waterlevel == 0) return; } - - switch (pmove->RandomLong(0, 3)) - { - case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; - case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; - case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; - case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade4.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; + + switch (pmove->RandomLong(0, 3)) + { + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade3.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_wade4.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); break; } } /* <2cdd76> ../cstrike/pm_shared/pm_shared.c:3018 */ float PM_CalcRoll(vec_t *angles, vec_t *velocity, float rollangle, float rollspeed) { - float sign; - float_precision side; - float value; - vec3_t forward, right, up; - - AngleVectors(angles, forward, right, up); - - side = DotProduct(velocity, right); - - sign = side < 0 ? -1 : 1; - - side = fabs(side); - - value = rollangle; - - if (side < rollspeed) - { - side = side * value / rollspeed; - } - else - { - side = value; - } - + float sign; + float_precision side; + float value; + vec3_t forward, right, up; + + AngleVectors(angles, forward, right, up); + + side = DotProduct(velocity, right); + + sign = side < 0 ? -1 : 1; + + side = fabs(side); + + value = rollangle; + + if (side < rollspeed) + { + side = side * value / rollspeed; + } + else + { + side = value; + } + return side * sign; } /* <2cde69> ../cstrike/pm_shared/pm_shared.c:3053 */ void PM_DropPunchAngle(vec_t *punchangle) { - float_precision len; - - len = VectorNormalize(punchangle); - len -= (10.0 + len * 0.5) * pmove->frametime; - len = _max(len, 0.0); + float_precision len; + + len = VectorNormalize(punchangle); + len -= (10.0 + len * 0.5) * pmove->frametime; + len = Q_max(len, 0.0); VectorScale(punchangle, len, punchangle); } /* <2cdeb8> ../cstrike/pm_shared/pm_shared.c:3069 */ void PM_CheckParamters(void) -{ - float spd; - float_precision maxspeed; - vec3_t v_angle; - - spd = sqrt((float_precision)(pmove->cmd.sidemove * pmove->cmd.sidemove + pmove->cmd.forwardmove * pmove->cmd.forwardmove + pmove->cmd.upmove * pmove->cmd.upmove)); - - maxspeed = pmove->clientmaxspeed; - - if (maxspeed != 0.0f) - { - pmove->maxspeed = _min(maxspeed, pmove->maxspeed); - } - - if (spd != 0.0f && spd > (float_precision)pmove->maxspeed) - { - float_precision fRatio = pmove->maxspeed / spd; - - pmove->cmd.forwardmove *= fRatio; - pmove->cmd.sidemove *= fRatio; - pmove->cmd.upmove *= fRatio; - } - - if ((pmove->flags & (FL_FROZEN | FL_ONTRAIN)) || pmove->dead) - { - pmove->cmd.forwardmove = 0; - pmove->cmd.sidemove = 0; - pmove->cmd.upmove = 0; - } - - PM_DropPunchAngle(pmove->punchangle); - - // Take angles from command. - if (!pmove->dead) - { - VectorCopy(pmove->cmd.viewangles, v_angle); - VectorAdd(v_angle, pmove->punchangle, v_angle); - - // Set up view angles. - pmove->angles[ROLL] = PM_CalcRoll(v_angle, pmove->velocity, pmove->movevars->rollangle, pmove->movevars->rollspeed) * 4; - pmove->angles[PITCH] = v_angle[PITCH]; - pmove->angles[YAW] = v_angle[YAW]; - } - else - { - VectorCopy(pmove->oldangles, pmove->angles); - } - - // Set dead player view_offset - if (pmove->dead) - { - pmove->view_ofs[2] = PM_DEAD_VIEWHEIGHT; - } - - // Adjust client view angles to match values used on server. - if (pmove->angles[YAW] > 180.0f) - { - pmove->angles[YAW] -= 360.0f; +{ + float spd; + float_precision maxspeed; + vec3_t v_angle; + + spd = sqrt((float_precision)(pmove->cmd.sidemove * pmove->cmd.sidemove + pmove->cmd.forwardmove * pmove->cmd.forwardmove + pmove->cmd.upmove * pmove->cmd.upmove)); + + maxspeed = pmove->clientmaxspeed; + + if (maxspeed != 0.0f) + { + pmove->maxspeed = Q_min(maxspeed, (float_precision)pmove->maxspeed); + } + + if (spd != 0.0f && spd > (float_precision)pmove->maxspeed) + { + float_precision fRatio = pmove->maxspeed / spd; + + pmove->cmd.forwardmove *= fRatio; + pmove->cmd.sidemove *= fRatio; + pmove->cmd.upmove *= fRatio; + } + + if ((pmove->flags & (FL_FROZEN | FL_ONTRAIN)) || pmove->dead) + { + pmove->cmd.forwardmove = 0; + pmove->cmd.sidemove = 0; + pmove->cmd.upmove = 0; + } + + PM_DropPunchAngle(pmove->punchangle); + + // Take angles from command. + if (!pmove->dead) + { + VectorCopy(pmove->cmd.viewangles, v_angle); + VectorAdd(v_angle, pmove->punchangle, v_angle); + + // Set up view angles. + pmove->angles[ROLL] = PM_CalcRoll(v_angle, pmove->velocity, pmove->movevars->rollangle, pmove->movevars->rollspeed) * 4; + pmove->angles[PITCH] = v_angle[PITCH]; + pmove->angles[YAW] = v_angle[YAW]; + } + else + { + VectorCopy(pmove->oldangles, pmove->angles); + } + + // Set dead player view_offset + if (pmove->dead) + { + pmove->view_ofs[2] = PM_DEAD_VIEWHEIGHT; + } + + // Adjust client view angles to match values used on server. + if (pmove->angles[YAW] > 180.0f) + { + pmove->angles[YAW] -= 360.0f; } } @@ -2783,259 +2783,259 @@ qboolean PM_ShouldDoSpectMode(void) return (pmove->iuser3 <= 0 || pmove->deadflag == DEAD_DEAD); } -// Returns with origin, angles, and velocity modified in place. -// Numtouch and touchindex[] will be set if any of the physents +// Returns with origin, angles, and velocity modified in place. +// Numtouch and touchindex[] will be set if any of the physents // were contacted during the move. /* <2cdfe9> ../cstrike/pm_shared/pm_shared.c:3225 */ void PM_PlayerMove(qboolean server) { - physent_t *pLadder = NULL; - - // Are we running server code? - pmove->server = server; - - // Adjust speeds etc. - PM_CheckParamters(); - - // Assume we don't touch anything - pmove->numtouch = 0; - - // # of msec to apply movement - - //double v2 = (double)pmove->cmd.msec * 0.001; - pmove->frametime = pmove->cmd.msec * 0.001; - - PM_ReduceTimers(); - - // Convert view angles to vectors - AngleVectors(pmove->angles, pmove->forward, pmove->right, pmove->up); - - //PM_ShowClipBox(); - - // Special handling for spectator and observers. (iuser1 is set if the player's in observer mode) - if ((pmove->spectator || pmove->iuser1 > 0) && PM_ShouldDoSpectMode()) - { - PM_SpectatorMove(); - PM_CatagorizePosition(); - return; - } - - // Always try and unstick us unless we are in NOCLIP mode - if (pmove->movetype != MOVETYPE_NOCLIP && pmove->movetype != MOVETYPE_NONE) - { - if (PM_CheckStuck()) - { - // Can't move, we're stuck - return; - } - } - - // Now that we are "unstuck", see where we are (waterlevel and type, pmove->onground). - PM_CatagorizePosition(); - - // Store off the starting water level - pmove->oldwaterlevel = pmove->waterlevel; - - // If we are not on ground, store off how fast we are moving down - if (pmove->onground == -1) - { - pmove->flFallVelocity = -pmove->velocity[2]; - } - - g_onladder = 0; - - // Don't run ladder code if dead or on a train - if (!pmove->dead && !(pmove->flags & FL_ONTRAIN)) - { - pLadder = PM_Ladder(); - - if (pLadder != NULL) - { - g_onladder = 1; - } - } - - PM_Duck(); - PM_UpdateStepSound(); - - // Don't run ladder code if dead or on a train - if (!pmove->dead && !(pmove->flags & FL_ONTRAIN)) - { - if (pLadder != NULL) - { - PM_LadderMove(pLadder); - } - else if (pmove->movetype != MOVETYPE_WALK && pmove->movetype != MOVETYPE_NOCLIP) - { - // Clear ladder stuff unless player is noclipping - // it will be set immediately again next frame if necessary - pmove->movetype = MOVETYPE_WALK; - } - } - - // Handle movement - switch (pmove->movetype) - { - default: - pmove->Con_DPrintf("Bogus pmove player movetype %i on (%i) 0=cl 1=sv\n", pmove->movetype, pmove->server); - break; - - case MOVETYPE_NONE: - break; - - case MOVETYPE_NOCLIP: - PM_NoClip(); - break; - - case MOVETYPE_TOSS: - case MOVETYPE_BOUNCE: - PM_Physics_Toss(); - break; - - case MOVETYPE_FLY: - PM_CheckWater(); - - // Was jump button pressed? - // If so, set velocity to 270 away from ladder. This is currently wrong. - // Also, set MOVE_TYPE to walk, too. - if (pmove->cmd.buttons & IN_JUMP) - { - if (!pLadder) - { - PM_Jump(); - } - } - else - { - pmove->oldbuttons &= ~IN_JUMP; - } - - // Perform the move accounting for any base velocity. - VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); - PM_FlyMove(); - VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); - break; - - case MOVETYPE_WALK: - if (!PM_InWater()) - { - PM_AddCorrectGravity(); - } - - // If we are leaping out of the water, just update the counters. - if (pmove->waterjumptime != 0.0f) - { - PM_WaterJump(); - PM_FlyMove(); - - // Make sure waterlevel is set correctly - PM_CheckWater(); - return; - } - - // If we are swimming in the water, see if we are nudging against a place we can jump up out - // of, and, if so, start out jump. Otherwise, if we are not moving up, then reset jump timer to 0 - if (pmove->waterlevel >= 2) - { - if (pmove->waterlevel == 2) - { - PM_CheckWaterJump(); - } - - // If we are falling again, then we must not trying to jump out of water any more. - if (pmove->velocity[2] < 0 && pmove->waterjumptime) - { - pmove->waterjumptime = 0; - } - - // Was jump button pressed? - if (pmove->cmd.buttons & IN_JUMP) - { - PM_Jump(); - } - else - { - pmove->oldbuttons &= ~IN_JUMP; - } - - // Perform regular water movement - PM_WaterMove(); - - VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); - - // Get a final position - PM_CatagorizePosition(); - } - // Not underwater - else - { - // Was jump button pressed? - if (pmove->cmd.buttons & IN_JUMP) - { - if (!pLadder) - { - PM_Jump(); - } - } - else - { - pmove->oldbuttons &= ~IN_JUMP; - } - - // Fricion is handled before we add in any base velocity. That way, if we are on a conveyor, - // we don't slow when standing still, relative to the conveyor. - if (pmove->onground != -1) - { - pmove->velocity[2] = 0; - PM_Friction(); - } - - // Make sure velocity is valid. - PM_CheckVelocity(); - - // Are we on ground now - if (pmove->onground != -1) - { - PM_WalkMove(); - } - else - { - // Take into account movement when in air. - PM_AirMove(); - } - - // Set final flags. - PM_CatagorizePosition(); - - // Now pull the base velocity back out. - // Base velocity is set if you are on a moving object, like - // a conveyor (or maybe another monster?) - VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); - - // Make sure velocity is valid. - PM_CheckVelocity(); - - // Add any remaining gravitational component. - if (!PM_InWater()) - { - PM_FixupGravityVelocity(); - } - - // If we are on ground, no downward velocity. - if (pmove->onground != -1) - { - pmove->velocity[2] = 0; - } - - // See if we landed on the ground with enough force to play - // a landing sound. - PM_CheckFalling(); - } - - // Did we enter or leave the water? - PM_PlayWaterSounds(); - break; + physent_t *pLadder = NULL; + + // Are we running server code? + pmove->server = server; + + // Adjust speeds etc. + PM_CheckParamters(); + + // Assume we don't touch anything + pmove->numtouch = 0; + + // # of msec to apply movement + + //double v2 = (double)pmove->cmd.msec * 0.001; + pmove->frametime = pmove->cmd.msec * 0.001; + + PM_ReduceTimers(); + + // Convert view angles to vectors + AngleVectors(pmove->angles, pmove->forward, pmove->right, pmove->up); + + //PM_ShowClipBox(); + + // Special handling for spectator and observers. (iuser1 is set if the player's in observer mode) + if ((pmove->spectator || pmove->iuser1 > 0) && PM_ShouldDoSpectMode()) + { + PM_SpectatorMove(); + PM_CatagorizePosition(); + return; + } + + // Always try and unstick us unless we are in NOCLIP mode + if (pmove->movetype != MOVETYPE_NOCLIP && pmove->movetype != MOVETYPE_NONE) + { + if (PM_CheckStuck()) + { + // Can't move, we're stuck + return; + } + } + + // Now that we are "unstuck", see where we are (waterlevel and type, pmove->onground). + PM_CatagorizePosition(); + + // Store off the starting water level + pmove->oldwaterlevel = pmove->waterlevel; + + // If we are not on ground, store off how fast we are moving down + if (pmove->onground == -1) + { + pmove->flFallVelocity = -pmove->velocity[2]; + } + + g_onladder = 0; + + // Don't run ladder code if dead or on a train + if (!pmove->dead && !(pmove->flags & FL_ONTRAIN)) + { + pLadder = PM_Ladder(); + + if (pLadder != NULL) + { + g_onladder = 1; + } + } + + PM_Duck(); + PM_UpdateStepSound(); + + // Don't run ladder code if dead or on a train + if (!pmove->dead && !(pmove->flags & FL_ONTRAIN)) + { + if (pLadder != NULL) + { + PM_LadderMove(pLadder); + } + else if (pmove->movetype != MOVETYPE_WALK && pmove->movetype != MOVETYPE_NOCLIP) + { + // Clear ladder stuff unless player is noclipping + // it will be set immediately again next frame if necessary + pmove->movetype = MOVETYPE_WALK; + } + } + + // Handle movement + switch (pmove->movetype) + { + default: + pmove->Con_DPrintf("Bogus pmove player movetype %i on (%i) 0=cl 1=sv\n", pmove->movetype, pmove->server); + break; + + case MOVETYPE_NONE: + break; + + case MOVETYPE_NOCLIP: + PM_NoClip(); + break; + + case MOVETYPE_TOSS: + case MOVETYPE_BOUNCE: + PM_Physics_Toss(); + break; + + case MOVETYPE_FLY: + PM_CheckWater(); + + // Was jump button pressed? + // If so, set velocity to 270 away from ladder. This is currently wrong. + // Also, set MOVE_TYPE to walk, too. + if (pmove->cmd.buttons & IN_JUMP) + { + if (!pLadder) + { + PM_Jump(); + } + } + else + { + pmove->oldbuttons &= ~IN_JUMP; + } + + // Perform the move accounting for any base velocity. + VectorAdd(pmove->velocity, pmove->basevelocity, pmove->velocity); + PM_FlyMove(); + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); + break; + + case MOVETYPE_WALK: + if (!PM_InWater()) + { + PM_AddCorrectGravity(); + } + + // If we are leaping out of the water, just update the counters. + if (pmove->waterjumptime != 0.0f) + { + PM_WaterJump(); + PM_FlyMove(); + + // Make sure waterlevel is set correctly + PM_CheckWater(); + return; + } + + // If we are swimming in the water, see if we are nudging against a place we can jump up out + // of, and, if so, start out jump. Otherwise, if we are not moving up, then reset jump timer to 0 + if (pmove->waterlevel >= 2) + { + if (pmove->waterlevel == 2) + { + PM_CheckWaterJump(); + } + + // If we are falling again, then we must not trying to jump out of water any more. + if (pmove->velocity[2] < 0 && pmove->waterjumptime) + { + pmove->waterjumptime = 0; + } + + // Was jump button pressed? + if (pmove->cmd.buttons & IN_JUMP) + { + PM_Jump(); + } + else + { + pmove->oldbuttons &= ~IN_JUMP; + } + + // Perform regular water movement + PM_WaterMove(); + + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); + + // Get a final position + PM_CatagorizePosition(); + } + // Not underwater + else + { + // Was jump button pressed? + if (pmove->cmd.buttons & IN_JUMP) + { + if (!pLadder) + { + PM_Jump(); + } + } + else + { + pmove->oldbuttons &= ~IN_JUMP; + } + + // Fricion is handled before we add in any base velocity. That way, if we are on a conveyor, + // we don't slow when standing still, relative to the conveyor. + if (pmove->onground != -1) + { + pmove->velocity[2] = 0; + PM_Friction(); + } + + // Make sure velocity is valid. + PM_CheckVelocity(); + + // Are we on ground now + if (pmove->onground != -1) + { + PM_WalkMove(); + } + else + { + // Take into account movement when in air. + PM_AirMove(); + } + + // Set final flags. + PM_CatagorizePosition(); + + // Now pull the base velocity back out. + // Base velocity is set if you are on a moving object, like + // a conveyor (or maybe another monster?) + VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); + + // Make sure velocity is valid. + PM_CheckVelocity(); + + // Add any remaining gravitational component. + if (!PM_InWater()) + { + PM_FixupGravityVelocity(); + } + + // If we are on ground, no downward velocity. + if (pmove->onground != -1) + { + pmove->velocity[2] = 0; + } + + // See if we landed on the ground with enough force to play + // a landing sound. + PM_CheckFalling(); + } + + // Did we enter or leave the water? + PM_PlayWaterSounds(); + break; } } @@ -3130,7 +3130,7 @@ void PM_CreateStuckTable(void) z = 0; // Y moves - for (y = -2.0f ; y <= 2.0f ; y += 2.0) + for (y = -2.0f; y <= 2.0f; y += 2.0) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3143,7 +3143,7 @@ void PM_CreateStuckTable(void) z = 0; // X moves - for (x = -2.0f ; x <= 2.0f ; x += 2.0f) + for (x = -2.0f; x <= 2.0f; x += 2.0f) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3157,9 +3157,9 @@ void PM_CreateStuckTable(void) { z = zi[i]; - for (x = -2.0f ; x <= 2.0f ; x += 2.0f) + for (x = -2.0f; x <= 2.0f; x += 2.0f) { - for (y = -2.0f ; y <= 2.0f ; y += 2.0) + for (y = -2.0f; y <= 2.0f; y += 2.0) { rgv3tStuckTable[idx][0] = x; rgv3tStuckTable[idx][1] = y; @@ -3171,9 +3171,9 @@ void PM_CreateStuckTable(void) } } -// This module implements the shared player physics code between any particular game and -// the engine. The same PM_Move routine is built into the game .dll and the client .dll and is -// invoked by each side as appropriate. There should be no distinction, internally, between server +// This module implements the shared player physics code between any particular game and +// the engine. The same PM_Move routine is built into the game .dll and the client .dll and is +// invoked by each side as appropriate. There should be no distinction, internally, between server // and client. This will ensure that prediction behaves appropriately. /* <2ce182> ../cstrike/pm_shared/pm_shared.c:3596 */ @@ -3184,7 +3184,7 @@ void PM_Move(struct playermove_s *ppmove, int server) pmove = ppmove; PM_PlayerMove((server != 0) ? TRUE : FALSE); - + if (pmove->onground != -1) pmove->flags |= FL_ONGROUND; else diff --git a/regamedll/public/MemPool.cpp b/regamedll/public/MemPool.cpp index fdd43149..e858f9e3 100644 --- a/regamedll/public/MemPool.cpp +++ b/regamedll/public/MemPool.cpp @@ -69,7 +69,7 @@ void *CMemoryPool::Alloc(unsigned int amount) return NULL; _blocksAllocated++; - _peakAlloc = _max(_peakAlloc, _blocksAllocated); + _peakAlloc = Q_max(_peakAlloc, _blocksAllocated); if (_blocksAllocated >= _numElements) AddNewBlob(); diff --git a/regamedll/public/basetypes.h b/regamedll/public/basetypes.h index 4effc596..44ba3ffb 100644 --- a/regamedll/public/basetypes.h +++ b/regamedll/public/basetypes.h @@ -47,13 +47,13 @@ // In case this ever changes #define M_PI 3.14159265358979323846 -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +// #ifndef min +// #define min(a,b) (((a) < (b)) ? (a) : (b)) +// #endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +// #ifndef max +// #define max(a,b) (((a) > (b)) ? (a) : (b)) +// #endif #ifdef __cplusplus template diff --git a/regamedll/public/utlvector.h b/regamedll/public/utlvector.h index e7ece810..46a21f44 100644 --- a/regamedll/public/utlvector.h +++ b/regamedll/public/utlvector.h @@ -1,6 +1,5 @@ #ifndef UTLVECTOR_H #define UTLVECTOR_H - #ifdef _WIN32 #pragma once #endif @@ -15,18 +14,18 @@ public: typedef T ElemType_t; // constructor, destructor - CUtlVector( int growSize = 0, int initSize = 0 ); - CUtlVector( T* pMemory, int numElements ); + CUtlVector(int growSize = 0, int initSize = 0); + CUtlVector(T* pMemory, int numElements); ~CUtlVector(); - + // Copy the array. - CUtlVector& operator=( const CUtlVector &other ); + CUtlVector& operator=(const CUtlVector &other); // element access - T& operator[]( int i ); - T const& operator[]( int i ) const; - T& Element( int i ); - T const& Element( int i ) const; + T& operator[](int i); + T const& operator[](int i) const; + T& Element(int i); + T const& Element(int i) const; // Gets the base address (can change when adding elements!) T* Base(); @@ -38,53 +37,53 @@ public: int Size() const; // don't use me! // Is element index valid? - bool IsValidIndex( int i ) const; - static int InvalidIndex( void ); + bool IsValidIndex(int i) const; + static int InvalidIndex(void); // Adds an element, uses default constructor int AddToHead(); int AddToTail(); - int InsertBefore( int elem ); - int InsertAfter( int elem ); + int InsertBefore(int elem); + int InsertAfter(int elem); // Adds an element, uses copy constructor - int AddToHead( T const& src ); - int AddToTail( T const& src ); - int InsertBefore( int elem, T const& src ); - int InsertAfter( int elem, T const& src ); + int AddToHead(T const& src); + int AddToTail(T const& src); + int InsertBefore(int elem, T const& src); + int InsertAfter(int elem, T const& src); // Adds multiple elements, uses default constructor - int AddMultipleToHead( int num ); - int AddMultipleToTail( int num, const T *pToCopy=NULL ); - int InsertMultipleBefore( int elem, int num, const T *pToCopy=NULL ); // If pToCopy is set, then it's an array of length 'num' and - int InsertMultipleAfter( int elem, int num ); + int AddMultipleToHead(int num); + int AddMultipleToTail(int num, const T *pToCopy=NULL); + int InsertMultipleBefore(int elem, int num, const T *pToCopy=NULL); // If pToCopy is set, then it's an array of length 'num' and + int InsertMultipleAfter(int elem, int num); // Calls RemoveAll() then AddMultipleToTail. - void SetSize( int size ); - void SetCount( int count ); - + void SetSize(int size); + void SetCount(int count); + // Calls SetSize and copies each element. - void CopyArray( T const *pArray, int size ); - + void CopyArray(T const *pArray, int size); + // Add the specified array to the tail. - int AddVectorToTail( CUtlVector const &src ); + int AddVectorToTail(CUtlVector const &src); // Finds an element (element needs operator== defined) - int Find( T const& src ) const; + int Find(T const& src) const; - bool HasElement( T const& src ); + bool HasElement(T const& src); // Makes sure we have enough memory allocated to store a requested # of elements - void EnsureCapacity( int num ); + void EnsureCapacity(int num); // Makes sure we have at least this many elements - void EnsureCount( int num ); + void EnsureCount(int num); // Element removal - void FastRemove( int elem ); // doesn't preserve order - void Remove( int elem ); // preserves order, shifts elements - void FindAndRemove( T const& src ); // removes first occurrence of src, preserves order, shifts elements - void RemoveMultiple( int elem, int num ); // preserves order, shifts elements + void FastRemove(int elem); // doesn't preserve order + void Remove(int elem); // preserves order, shifts elements + void FindAndRemove(T const& src); // removes first occurrence of src, preserves order, shifts elements + void RemoveMultiple(int elem, int num); // preserves order, shifts elements void RemoveAll(); // doesn't deallocate memory // Memory deallocation @@ -94,18 +93,18 @@ public: void PurgeAndDeleteElements(); // Set the size by which it grows when it needs to allocate more memory. - void SetGrowSize( int size ); + void SetGrowSize(int size); protected: // Can't copy this unless we explicitly do it! - CUtlVector( CUtlVector const& vec ) { assert(0); } + CUtlVector(CUtlVector const& vec) { assert(0); } // Grows the vector - void GrowVector( int num = 1 ); + void GrowVector(int num = 1); // Shifts elements.... - void ShiftElementsRight( int elem, int num = 1 ); - void ShiftElementsLeft( int elem, int num = 1 ); + void ShiftElementsRight(int elem, int num = 1); + void ShiftElementsLeft(int elem, int num = 1); // For easier access to the elements through the debugger void ResetDbgInfo(); @@ -118,7 +117,6 @@ protected: T *m_pElements; }; - //----------------------------------------------------------------------------- // For easier access to the elements through the debugger //----------------------------------------------------------------------------- @@ -134,14 +132,14 @@ inline void CUtlVector::ResetDbgInfo() //----------------------------------------------------------------------------- template< class T > -inline CUtlVector::CUtlVector( int growSize, int initSize ) : +inline CUtlVector::CUtlVector(int growSize, int initSize) : m_Memory(growSize, initSize), m_Size(0) { ResetDbgInfo(); } template< class T > -inline CUtlVector::CUtlVector( T* pMemory, int numElements ) : +inline CUtlVector::CUtlVector(T* pMemory, int numElements) : m_Memory(pMemory, numElements), m_Size(0) { ResetDbgInfo(); @@ -154,9 +152,9 @@ inline CUtlVector::~CUtlVector() } template -inline CUtlVector& CUtlVector::operator=( const CUtlVector &other ) +inline CUtlVector& CUtlVector::operator=(const CUtlVector &other) { - CopyArray( other.Base(), other.Count() ); + CopyArray(other.Base(), other.Count()); return *this; } @@ -165,34 +163,33 @@ inline CUtlVector& CUtlVector::operator=( const CUtlVector &other ) //----------------------------------------------------------------------------- template< class T > -inline T& CUtlVector::operator[]( int i ) +inline T& CUtlVector::operator[](int i) { - assert( IsValidIndex(i) ); + assert(IsValidIndex(i)); return m_Memory[i]; } template< class T > -inline T const& CUtlVector::operator[]( int i ) const +inline T const& CUtlVector::operator[](int i) const { - assert( IsValidIndex(i) ); + assert(IsValidIndex(i)); return m_Memory[i]; } template< class T > -inline T& CUtlVector::Element( int i ) +inline T& CUtlVector::Element(int i) { - assert( IsValidIndex(i) ); + assert(IsValidIndex(i)); return m_Memory[i]; } template< class T > -inline T const& CUtlVector::Element( int i ) const +inline T const& CUtlVector::Element(int i) const { - assert( IsValidIndex(i) ); + assert(IsValidIndex(i)); return m_Memory[i]; } - //----------------------------------------------------------------------------- // Gets the base address (can change when adding elements!) //----------------------------------------------------------------------------- @@ -225,89 +222,83 @@ inline int CUtlVector::Count() const return m_Size; } - //----------------------------------------------------------------------------- // Is element index valid? //----------------------------------------------------------------------------- template< class T > -inline bool CUtlVector::IsValidIndex( int i ) const +inline bool CUtlVector::IsValidIndex(int i) const { return (i >= 0) && (i < m_Size); } - //----------------------------------------------------------------------------- // Returns in invalid index //----------------------------------------------------------------------------- template< class T > -inline int CUtlVector::InvalidIndex( void ) +inline int CUtlVector::InvalidIndex(void) { return -1; } - //----------------------------------------------------------------------------- // Grows the vector //----------------------------------------------------------------------------- template< class T > -void CUtlVector::GrowVector( int num ) +void CUtlVector::GrowVector(int num) { if (m_Size + num - 1 >= m_Memory.NumAllocated()) { - m_Memory.Grow( m_Size + num - m_Memory.NumAllocated() ); + m_Memory.Grow(m_Size + num - m_Memory.NumAllocated()); } m_Size += num; ResetDbgInfo(); } - //----------------------------------------------------------------------------- // Makes sure we have enough memory allocated to store a requested # of elements //----------------------------------------------------------------------------- template< class T > -void CUtlVector::EnsureCapacity( int num ) +void CUtlVector::EnsureCapacity(int num) { m_Memory.EnsureCapacity(num); ResetDbgInfo(); } - //----------------------------------------------------------------------------- // Makes sure we have at least this many elements //----------------------------------------------------------------------------- template< class T > -void CUtlVector::EnsureCount( int num ) +void CUtlVector::EnsureCount(int num) { if (Count() < num) - AddMultipleToTail( num - Count() ); + AddMultipleToTail(num - Count()); } - //----------------------------------------------------------------------------- // Shifts elements //----------------------------------------------------------------------------- template< class T > -void CUtlVector::ShiftElementsRight( int elem, int num ) +void CUtlVector::ShiftElementsRight(int elem, int num) { - assert( IsValidIndex(elem) || ( m_Size == 0 ) || ( num == 0 )); + assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); int numToMove = m_Size - elem - num; if ((numToMove > 0) && (num > 0)) - memmove( &Element(elem+num), &Element(elem), numToMove * sizeof(T) ); + memmove(&Element(elem+num), &Element(elem), numToMove * sizeof(T)); } template< class T > -void CUtlVector::ShiftElementsLeft( int elem, int num ) +void CUtlVector::ShiftElementsLeft(int elem, int num) { - assert( IsValidIndex(elem) || ( m_Size == 0 ) || ( num == 0 )); + assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); int numToMove = m_Size - elem - num; if ((numToMove > 0) && (num > 0)) { - memmove( &Element(elem), &Element(elem+num), numToMove * sizeof(T) ); + memmove(&Element(elem), &Element(elem+num), numToMove * sizeof(T)); #ifdef _DEBUG - memset( &Element(m_Size-num), 0xDD, num * sizeof(T) ); + memset(&Element(m_Size-num), 0xDD, num * sizeof(T)); #endif } } @@ -325,59 +316,58 @@ inline int CUtlVector::AddToHead() template< class T > inline int CUtlVector::AddToTail() { - return InsertBefore( m_Size ); + return InsertBefore(m_Size); } template< class T > -inline int CUtlVector::InsertAfter( int elem ) +inline int CUtlVector::InsertAfter(int elem) { - return InsertBefore( elem + 1 ); + return InsertBefore(elem + 1); } template< class T > -int CUtlVector::InsertBefore( int elem ) +int CUtlVector::InsertBefore(int elem) { // Can insert at the end - assert( (elem == Count()) || IsValidIndex(elem) ); + assert((elem == Count()) || IsValidIndex(elem)); GrowVector(); ShiftElementsRight(elem); - Construct( &Element(elem) ); + Construct(&Element(elem)); return elem; } - //----------------------------------------------------------------------------- // Adds an element, uses copy constructor //----------------------------------------------------------------------------- template< class T > -inline int CUtlVector::AddToHead( T const& src ) +inline int CUtlVector::AddToHead(T const& src) { - return InsertBefore( 0, src ); + return InsertBefore(0, src); } template< class T > -inline int CUtlVector::AddToTail( T const& src ) +inline int CUtlVector::AddToTail(T const& src) { - return InsertBefore( m_Size, src ); + return InsertBefore(m_Size, src); } template< class T > -inline int CUtlVector::InsertAfter( int elem, T const& src ) +inline int CUtlVector::InsertAfter(int elem, T const& src) { - return InsertBefore( elem + 1, src ); + return InsertBefore(elem + 1, src); } template< class T > -int CUtlVector::InsertBefore( int elem, T const& src ) +int CUtlVector::InsertBefore(int elem, T const& src) { // Can insert at the end - assert( (elem == Count()) || IsValidIndex(elem) ); + assert((elem == Count()) || IsValidIndex(elem)); GrowVector(); ShiftElementsRight(elem); - CopyConstruct( &Element(elem), src ); + CopyConstruct(&Element(elem), src); return elem; } @@ -387,82 +377,82 @@ int CUtlVector::InsertBefore( int elem, T const& src ) //----------------------------------------------------------------------------- template< class T > -inline int CUtlVector::AddMultipleToHead( int num ) +inline int CUtlVector::AddMultipleToHead(int num) { - return InsertMultipleBefore( 0, num ); + return InsertMultipleBefore(0, num); } template< class T > -inline int CUtlVector::AddMultipleToTail( int num, const T *pToCopy ) +inline int CUtlVector::AddMultipleToTail(int num, const T *pToCopy) { - return InsertMultipleBefore( m_Size, num, pToCopy ); + return InsertMultipleBefore(m_Size, num, pToCopy); } template< class T > -int CUtlVector::InsertMultipleAfter( int elem, int num ) +int CUtlVector::InsertMultipleAfter(int elem, int num) { - return InsertMultipleBefore( elem + 1, num ); + return InsertMultipleBefore(elem + 1, num); } template< class T > -void CUtlVector::SetCount( int count ) +void CUtlVector::SetCount(int count) { RemoveAll(); - AddMultipleToTail( count ); + AddMultipleToTail(count); } template< class T > -inline void CUtlVector::SetSize( int size ) +inline void CUtlVector::SetSize(int size) { - SetCount( size ); + SetCount(size); } template< class T > -void CUtlVector::CopyArray( T const *pArray, int size ) +void CUtlVector::CopyArray(T const *pArray, int size) { - SetSize( size ); - for( int i=0; i < size; i++ ) + SetSize(size); + for(int i=0; i < size; i++) (*this)[i] = pArray[i]; } template< class T > -int CUtlVector::AddVectorToTail( CUtlVector const &src ) +int CUtlVector::AddVectorToTail(CUtlVector const &src) { int base = Count(); - - // Make space. - AddMultipleToTail( src.Count() ); - // Copy the elements. - for ( int i=0; i < src.Count(); i++ ) + // Make space. + AddMultipleToTail(src.Count()); + + // Copy the elements. + for (int i=0; i < src.Count(); i++) (*this)[base + i] = src[i]; return base; } template< class T > -inline int CUtlVector::InsertMultipleBefore( int elem, int num, const T *pToInsert ) +inline int CUtlVector::InsertMultipleBefore(int elem, int num, const T *pToInsert) { - if( num == 0 ) + if(num == 0) return elem; - + // Can insert at the end - assert( (elem == Count()) || IsValidIndex(elem) ); + assert((elem == Count()) || IsValidIndex(elem)); GrowVector(num); ShiftElementsRight(elem, num); // Invoke default constructors for (int i = 0; i < num; ++i) - Construct( &Element(elem+i) ); + Construct(&Element(elem+i)); // Copy stuff in? - if ( pToInsert ) + if (pToInsert) { - for ( int i=0; i < num; i++ ) + for (int i=0; i < num; i++) { - Element( elem+i ) = pToInsert[i]; + Element(elem+i) = pToInsert[i]; } } @@ -473,9 +463,9 @@ inline int CUtlVector::InsertMultipleBefore( int elem, int num, const T *pToI // Finds an element (element needs operator== defined) //----------------------------------------------------------------------------- template< class T > -int CUtlVector::Find( T const& src ) const +int CUtlVector::Find(T const& src) const { - for ( int i = 0; i < Count(); ++i ) + for (int i = 0; i < Count(); ++i) { if (Element(i) == src) return i; @@ -484,9 +474,9 @@ int CUtlVector::Find( T const& src ) const } template< class T > -bool CUtlVector::HasElement( T const& src ) +bool CUtlVector::HasElement(T const& src) { - return ( Find(src) >= 0 ); + return (Find(src) >= 0); } //----------------------------------------------------------------------------- @@ -494,43 +484,43 @@ bool CUtlVector::HasElement( T const& src ) //----------------------------------------------------------------------------- template< class T > -void CUtlVector::FastRemove( int elem ) +void CUtlVector::FastRemove(int elem) { - assert( IsValidIndex(elem) ); + assert(IsValidIndex(elem)); - Destruct( &Element(elem) ); + Destruct(&Element(elem)); if (m_Size > 0) { - memcpy( &Element(elem), &Element(m_Size-1), sizeof(T) ); + Q_memcpy(&Element(elem), &Element(m_Size-1), sizeof(T)); --m_Size; } } template< class T > -void CUtlVector::Remove( int elem ) +void CUtlVector::Remove(int elem) { - Destruct( &Element(elem) ); + Destruct(&Element(elem)); ShiftElementsLeft(elem); --m_Size; } template< class T > -void CUtlVector::FindAndRemove( T const& src ) +void CUtlVector::FindAndRemove(T const& src) { - int elem = Find( src ); - if ( elem != -1 ) + int elem = Find(src); + if (elem != -1) { - Remove( elem ); + Remove(elem); } } template< class T > -void CUtlVector::RemoveMultiple( int elem, int num ) +void CUtlVector::RemoveMultiple(int elem, int num) { - assert( IsValidIndex(elem) ); - assert( elem + num <= Count() ); + assert(IsValidIndex(elem)); + assert(elem + num <= Count()); - for (int i = elem + num; --i >= elem; ) + for (int i = elem + num; --i >= elem;) Destruct(&Element(i)); ShiftElementsLeft(elem, num); @@ -540,13 +530,12 @@ void CUtlVector::RemoveMultiple( int elem, int num ) template< class T > void CUtlVector::RemoveAll() { - for (int i = m_Size; --i >= 0; ) + for (int i = m_Size; --i >= 0;) Destruct(&Element(i)); m_Size = 0; } - //----------------------------------------------------------------------------- // Memory deallocation //----------------------------------------------------------------------------- @@ -555,26 +544,23 @@ template< class T > void CUtlVector::Purge() { RemoveAll(); - m_Memory.Purge( ); + m_Memory.Purge(); ResetDbgInfo(); } - template inline void CUtlVector::PurgeAndDeleteElements() { - for( int i=0; i < m_Size; i++ ) + for(int i=0; i < m_Size; i++) delete Element(i); Purge(); } - template< class T > -void CUtlVector::SetGrowSize( int size ) +void CUtlVector::SetGrowSize(int size) { - m_Memory.SetGrowSize( size ); + m_Memory.SetGrowSize(size); } - #endif // CCVECTOR_H diff --git a/regamedll/regamedll/dlls.h b/regamedll/regamedll/dlls.h index 8e5fa9ea..55a32c12 100644 --- a/regamedll/regamedll/dlls.h +++ b/regamedll/regamedll/dlls.h @@ -26,6 +26,7 @@ * */ +#include "mathlib.h" #include "extdll.h" #include "h_export.h" @@ -114,17 +115,16 @@ #include "game_shared/bot/nav_file.h" #include "game_shared/bot/nav_path.h" -// Hostage -#include "hostage/hostage.h" -#include "hostage/hostage_localnav.h" - #include "airtank.h" #include "h_ai.h" #include "h_cycler.h" #include "h_battery.h" +// Hostage +#include "hostage/hostage.h" +#include "hostage/hostage_localnav.h" + #include "bot/cs_bot.h" -#include "bot/cs_gamestate.h" // Tutor #include "tutor.h" diff --git a/regamedll/regamedll/precompiled.h b/regamedll/regamedll/precompiled.h index 111c2a32..efe357c5 100644 --- a/regamedll/regamedll/precompiled.h +++ b/regamedll/regamedll/precompiled.h @@ -22,7 +22,6 @@ #include "hooker.h" #endif // HOOK_GAMEDLL -#include "mathlib.h" #include "dlls.h" #include "basetypes.h"