diff --git a/README.md b/README.md index 5c84712..12992da 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Current milestones are separated by "Tiers", which are as follows: ### Tier 2 - Add *-at least minimal-* death messages. *-Example: "\ was killed by a \".-* **[DONE]** -- Implement HUD info about the monsters, along with the "displayname" keyvalue. +- Implement HUD info about the monsters, along with the "displayname" keyvalue. **[DONE]** - Implement custom monster classification, the "classify" keyvalue. ### Tier 3 diff --git a/src/dlls/agrunt.cpp b/src/dlls/agrunt.cpp index 4806075..ae26fc8 100644 --- a/src/dlls/agrunt.cpp +++ b/src/dlls/agrunt.cpp @@ -543,6 +543,11 @@ void CMAGrunt :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_alien_grunt" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Alien Grunt" ); + } } //========================================================= diff --git a/src/dlls/apache.cpp b/src/dlls/apache.cpp index 37a612e..554372b 100644 --- a/src/dlls/apache.cpp +++ b/src/dlls/apache.cpp @@ -86,6 +86,11 @@ void CMApache :: Spawn( void ) m_iSoundState = 0; pev->classname = MAKE_STRING( "monster_apache" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Apache" ); + } } diff --git a/src/dlls/barney.cpp b/src/dlls/barney.cpp index d1d4c78..673c7ee 100644 --- a/src/dlls/barney.cpp +++ b/src/dlls/barney.cpp @@ -359,6 +359,11 @@ void CMBarney :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_barney" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Barney" ); + } } //========================================================= diff --git a/src/dlls/bigmomma.cpp b/src/dlls/bigmomma.cpp index e5839a0..62a5175 100644 --- a/src/dlls/bigmomma.cpp +++ b/src/dlls/bigmomma.cpp @@ -48,6 +48,7 @@ public: void CMInfoBM::Spawn( void ) { + pev->classname = MAKE_STRING( "info_bigmomma" ); } void CMInfoBM::KeyValue( KeyValueData* pkvd ) @@ -612,6 +613,11 @@ void CMBigMomma :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_bigmomma" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Big Momma" ); + } } //========================================================= diff --git a/src/dlls/bullsquid.cpp b/src/dlls/bullsquid.cpp index d1a4729..82c06e5 100644 --- a/src/dlls/bullsquid.cpp +++ b/src/dlls/bullsquid.cpp @@ -619,6 +619,11 @@ void CMBullsquid :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_bullchicken" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Bullsquid" ); + } } //========================================================= diff --git a/src/dlls/cmbase.h b/src/dlls/cmbase.h index be21e6a..a83ac8b 100644 --- a/src/dlls/cmbase.h +++ b/src/dlls/cmbase.h @@ -540,7 +540,6 @@ public: class CMBaseMonster; - extern int GetMonsterIndex(void); // diff --git a/src/dlls/cmbasemonster.h b/src/dlls/cmbasemonster.h index 9f9b666..cae8a1e 100644 --- a/src/dlls/cmbasemonster.h +++ b/src/dlls/cmbasemonster.h @@ -101,7 +101,9 @@ public: string_t m_iszTriggerTarget;// name of target that should be fired. Vector m_HackedGunPos; // HACK until we can query end of gun - + + string_t m_szMonsterName; // Monster name to display on HUD + void KeyValue( KeyValueData *pkvd ); // monster use function diff --git a/src/dlls/combat.cpp b/src/dlls/combat.cpp index ae34eaa..44a0b3a 100644 --- a/src/dlls/combat.cpp +++ b/src/dlls/combat.cpp @@ -589,7 +589,11 @@ void CMBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) { unsigned int cCount = 0; BOOL fDone = FALSE; - + + // If a player killed this monster, add score + if ( UTIL_IsPlayer( ENT( pevAttacker ) ) ) + pevAttacker->frags += 1.0; + if ( HasMemory( bits_MEMORY_KILLED ) ) { if ( ShouldGibMonster( iGib ) ) @@ -822,7 +826,7 @@ int CMBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker { float flTake; Vector vecDir; - + if (!pev->takedamage) return 0; diff --git a/src/dlls/controller.cpp b/src/dlls/controller.cpp index 1a9b1e5..1c70705 100644 --- a/src/dlls/controller.cpp +++ b/src/dlls/controller.cpp @@ -312,6 +312,11 @@ void CMController :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_alien_controller" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Alien Controller" ); + } } //========================================================= @@ -1115,6 +1120,8 @@ void CMControllerHeadBall :: Spawn( void ) m_hOwner = pev->owner; pev->dmgtime = gpGlobals->time; + + pev->classname = MAKE_STRING( "controller_head_ball" ); } @@ -1299,9 +1306,10 @@ void CMControllerZapBall :: Spawn( void ) m_hOwner = pev->owner; pev->dmgtime = gpGlobals->time; // keep track of when ball spawned pev->nextthink = gpGlobals->time + 0.1; + + pev->classname = MAKE_STRING( "controller_energy_ball" ); } - void CMControllerZapBall :: Precache( void ) { PRECACHE_MODEL("sprites/xspark4.spr"); diff --git a/src/dlls/dllapi.cpp b/src/dlls/dllapi.cpp index 3e33026..860d549 100644 --- a/src/dlls/dllapi.cpp +++ b/src/dlls/dllapi.cpp @@ -59,6 +59,7 @@ extern gamedll_funcs_t *gpGamedllFuncs; extern cvar_t *dllapi_log; extern cvar_t *monster_spawn; extern cvar_t *monster_show_deaths; +extern cvar_t *monster_show_info; // Player TakeDamage and Killed int g_DamageMsg; @@ -322,7 +323,7 @@ void check_monster_hurt(edict_t *pAttacker) } -void check_monster_dead(void) +void check_monster_dead(edict_t *pAttacker) { for (int index = 0; index < monster_ents_used; index++) { @@ -341,8 +342,9 @@ void check_monster_dead(void) pent->v.flags &= ~FL_KILLME; // clear FL_KILLME bit pent->v.deadflag = DEAD_NO; // bring back to life - - monsters[index].pMonster->Killed(VARS(pent), 0); + + monsters[index].pMonster->Killed(VARS(pAttacker), 0); + monsters[index].killed = TRUE; } } @@ -386,8 +388,17 @@ void check_player_dead( edict_t *pPlayer ) // Killed by a monster? if ( pAttacker->v.flags & FL_MONSTER ) { - // TODO: Custom monster name - sprintf( szMessage, "* %s was killed by a monster.\n", szPlayerName ); + // Check the first character for 'aeiou'. + CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pAttacker)); + char szCheck[2]; + strncpy( szCheck, STRING( pMonster->m_szMonsterName ), 1 ); + + // Make the first character lowercase + szCheck[0] = tolower( szCheck[ 0 ] ); + if ( strncmp( szCheck, "a", 1 ) == 0 || strncmp( szCheck, "e", 1 ) == 0 || strncmp( szCheck, "i", 1 ) == 0 || strncmp( szCheck, "o", 1 ) == 0 || strncmp( szCheck, "u", 1 ) == 0 ) + sprintf( szMessage, "* %s was killed by an %s.\n", szPlayerName, STRING( pMonster->m_szMonsterName ) ); + else + sprintf( szMessage, "* %s was killed by a %s.\n", szPlayerName, STRING( pMonster->m_szMonsterName ) ); } else { @@ -475,8 +486,8 @@ void check_player_dead( edict_t *pPlayer ) void check_monster_info( edict_t *pPlayer ) { // Monster Info is disabled - //if (!monster_show_info->value) - //return; + if (!monster_show_info->value) + return; // Player must be alive if ( UTIL_IsAlive( pPlayer ) ) @@ -508,10 +519,10 @@ void check_monster_info( edict_t *pPlayer ) if (tr.pHit->v.flags & FL_MONSTER) { // Get monster info - // TODO: Add monster custom name and count monster frags - edict_t *pMonster = tr.pHit; + CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(tr.pHit)); + char szInfo[512]; - sprintf(szInfo, "Enemy: %s\nHealth: %.0f\nFrags: %.0f\n", STRING( pMonster->v.classname ), pMonster->v.health, pMonster->v.frags ); + sprintf(szInfo, "Enemy: %s\nHealth: %.0f\nFrags: %.0f\n", STRING( pMonster->m_szMonsterName ), pMonster->pev->health, pMonster->pev->frags ); // Create a TE_TEXTMESSAGE and show the monster information MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, NULL, pPlayer ); @@ -1229,7 +1240,7 @@ void mmDispatchThink( edict_t *pent ) { monsters[index].pMonster->Think(); - check_monster_dead(); + check_monster_dead(pent); RETURN_META(MRES_SUPERCEDE); } @@ -1251,7 +1262,7 @@ void mmDispatchTouch( edict_t *pentTouched, edict_t *pentOther ) { monsters[index].pMonster->Touch(pentOther); - check_monster_dead(); + check_monster_dead(pentOther); RETURN_META(MRES_SUPERCEDE); } @@ -1463,7 +1474,7 @@ C_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVers void mmDispatchThink_Post( edict_t *pent ) { check_monster_hurt(pent); - check_monster_dead(); + check_monster_dead(pent); RETURN_META(MRES_IGNORED); } @@ -1471,7 +1482,7 @@ void mmDispatchThink_Post( edict_t *pent ) void mmPlayerPostThink_Post( edict_t *pEntity ) { check_monster_hurt(pEntity); - check_monster_dead(); + check_monster_dead(pEntity); check_player_dead(pEntity); check_monster_info(pEntity); diff --git a/src/dlls/gargantua.cpp b/src/dlls/gargantua.cpp index 41415a4..3fc32b6 100755 --- a/src/dlls/gargantua.cpp +++ b/src/dlls/gargantua.cpp @@ -686,6 +686,11 @@ void CMGargantua :: Spawn() m_flameTime = gpGlobals->time + 2; pev->classname = MAKE_STRING( "monster_gargantua" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Gargantua" ); + } } diff --git a/src/dlls/hassassin.cpp b/src/dlls/hassassin.cpp index 7b84d10..e9cd210 100644 --- a/src/dlls/hassassin.cpp +++ b/src/dlls/hassassin.cpp @@ -228,10 +228,15 @@ void CMHAssassin :: Spawn() m_iTargetRanderamt = 20; pev->renderamt = 20; pev->rendermode = kRenderTransTexture; - + MonsterInit(); pev->classname = MAKE_STRING( "monster_human_assassin" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Female Assassin" ); + } } //========================================================= diff --git a/src/dlls/headcrab.cpp b/src/dlls/headcrab.cpp index a912331..341ac98 100644 --- a/src/dlls/headcrab.cpp +++ b/src/dlls/headcrab.cpp @@ -258,6 +258,11 @@ void CMHeadCrab :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_headcrab" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Head Crab" ); + } } //========================================================= diff --git a/src/dlls/hgrunt.cpp b/src/dlls/hgrunt.cpp index 317a0e1..4d8b4ac 100644 --- a/src/dlls/hgrunt.cpp +++ b/src/dlls/hgrunt.cpp @@ -888,6 +888,11 @@ void CMHGrunt :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_human_grunt" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Human Grunt" ); + } } //========================================================= diff --git a/src/dlls/hornet.cpp b/src/dlls/hornet.cpp index bbcc97d..fecd5e2 100644 --- a/src/dlls/hornet.cpp +++ b/src/dlls/hornet.cpp @@ -49,7 +49,7 @@ void CMHornet :: Spawn( void ) pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; pev->takedamage = DAMAGE_YES; - pev->flags |= FL_MONSTER; + pev->flags |= FL_MONSTER; // I have a bad feeling about this pev->health = 1;// weak! // hornets don't live as long in multiplayer @@ -83,6 +83,8 @@ void CMHornet :: Spawn( void ) pev->nextthink = gpGlobals->time + 0.1; ResetSequenceInfo( ); + + pev->classname = MAKE_STRING( "hornet" ); } diff --git a/src/dlls/houndeye.cpp b/src/dlls/houndeye.cpp index b4dbeb0..bb198f9 100644 --- a/src/dlls/houndeye.cpp +++ b/src/dlls/houndeye.cpp @@ -279,6 +279,11 @@ void CMHoundeye :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_houndeye" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Houndeye" ); + } } //========================================================= diff --git a/src/dlls/islave.cpp b/src/dlls/islave.cpp index 2b1ff93..f92733a 100644 --- a/src/dlls/islave.cpp +++ b/src/dlls/islave.cpp @@ -434,6 +434,11 @@ void CMISlave :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_alien_slave" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Alien Slave" ); + } } //========================================================= diff --git a/src/dlls/monster_api.cpp b/src/dlls/monster_api.cpp index 746501b..9d4304c 100644 --- a/src/dlls/monster_api.cpp +++ b/src/dlls/monster_api.cpp @@ -85,6 +85,8 @@ cvar_t init_monster_spawn = {"monster_spawn", "1", FCVAR_EXTDLL, 0, NULL}; cvar_t *monster_spawn = NULL; cvar_t init_monster_show_deaths = {"monster_show_deaths", "1", FCVAR_EXTDLL, 0, NULL}; cvar_t *monster_show_deaths = NULL; +cvar_t init_monster_show_info = {"monster_show_info", "1", FCVAR_EXTDLL, 0, NULL}; +cvar_t *monster_show_info = NULL; // Metamod requesting info about this plugin: @@ -141,6 +143,9 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m CVAR_REGISTER(&init_monster_show_deaths); monster_show_deaths = CVAR_GET_POINTER("monster_show_deaths"); + CVAR_REGISTER(&init_monster_show_info); + monster_show_info = CVAR_GET_POINTER("monster_show_info"); + return(TRUE); } diff --git a/src/dlls/monsters.cpp b/src/dlls/monsters.cpp index 8655a6a..4ff1bbe 100644 --- a/src/dlls/monsters.cpp +++ b/src/dlls/monsters.cpp @@ -2504,11 +2504,16 @@ void CMBaseMonster :: KeyValue( KeyValueData *pkvd ) m_iszTriggerTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "TriggerCondition") ) + else if (FStrEq(pkvd->szKeyName, "TriggerCondition")) { m_iTriggerCondition = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } + else if (FStrEq(pkvd->szKeyName, "displayname")) + { + m_szMonsterName = ALLOC_STRING( pkvd->szValue ); + pkvd->fHandled = TRUE; + } else { CMBaseToggle::KeyValue( pkvd ); diff --git a/src/dlls/scientist.cpp b/src/dlls/scientist.cpp index 39a9a4a..2116b95 100644 --- a/src/dlls/scientist.cpp +++ b/src/dlls/scientist.cpp @@ -618,6 +618,11 @@ void CMScientist :: Spawn( void ) MonsterInit(); pev->classname = MAKE_STRING( "monster_scientist" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Scientist" ); + } } //========================================================= diff --git a/src/dlls/squeakgrenade.cpp b/src/dlls/squeakgrenade.cpp index 60581a6..4d62247 100644 --- a/src/dlls/squeakgrenade.cpp +++ b/src/dlls/squeakgrenade.cpp @@ -86,6 +86,11 @@ void CMSqueakGrenade :: Spawn( void ) m_hEnemy = NULL; pev->classname = MAKE_STRING( "monster_snark" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // hi :3 + m_szMonsterName = MAKE_STRING( "Snark" ); + } } void CMSqueakGrenade::Precache( void ) diff --git a/src/dlls/turret.cpp b/src/dlls/turret.cpp index 4c9fe0f..3e8c0c5 100755 --- a/src/dlls/turret.cpp +++ b/src/dlls/turret.cpp @@ -144,6 +144,11 @@ void CMTurret::Spawn() pev->nextthink = gpGlobals->time + 0.3; pev->classname = MAKE_STRING( "monster_turret" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Turret" ); + } } void CMTurret::Precache() @@ -172,6 +177,11 @@ void CMMiniTurret::Spawn() pev->nextthink = gpGlobals->time + 0.3; pev->classname = MAKE_STRING( "monster_miniturret" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Mini-Turret" ); + } } @@ -1014,6 +1024,11 @@ void CMSentry::Spawn() pev->nextthink = gpGlobals->time + 0.3; pev->classname = MAKE_STRING( "monster_sentry" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Sentry Turret" ); + } } void CMSentry::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) diff --git a/src/dlls/util.cpp b/src/dlls/util.cpp index 360a34a..d36c6db 100644 --- a/src/dlls/util.cpp +++ b/src/dlls/util.cpp @@ -1762,6 +1762,10 @@ int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAtt { pEdict->v.health = 1; // can't suicide if already dead! gpGamedllFuncs->dllapi_table->pfnClientKill(pEdict); + + // Add 1 score to the monster that killed this player + if ( pevAttacker->flags & FL_MONSTER ) + pevAttacker->frags += 1.0; } // tell director about it diff --git a/src/dlls/zombie.cpp b/src/dlls/zombie.cpp index 9755be9..b8240c5 100644 --- a/src/dlls/zombie.cpp +++ b/src/dlls/zombie.cpp @@ -256,6 +256,11 @@ void CMZombie :: Spawn() MonsterInit(); pev->classname = MAKE_STRING( "monster_zombie" ); + if ( strlen( STRING( m_szMonsterName ) ) == 0 ) + { + // default name + m_szMonsterName = MAKE_STRING( "Zombie" ); + } } //=========================================================