Night Owl
8 years ago
23 changed files with 889 additions and 300 deletions
@ -0,0 +1,288 @@
@@ -0,0 +1,288 @@
|
||||
/***
|
||||
* |
||||
* 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. |
||||
* All Rights Reserved. |
||||
* |
||||
* Use, distribution, and modification of this source code and/or resulting |
||||
* object code is restricted to non-commercial enhancements to products from |
||||
* Valve LLC. All other use, distribution, or modification is prohibited |
||||
* without written permission from Valve LLC. |
||||
* |
||||
****/ |
||||
|
||||
#include "hud.h" |
||||
#include "cl_util.h" |
||||
#include "parsemsg.h" |
||||
|
||||
#include <string.h> |
||||
#include <stdio.h> |
||||
|
||||
#define SCOPE_SMALL 0 |
||||
#define SCOPE_MEDIUM 1 |
||||
#define SCOPE_LARGE 2 |
||||
|
||||
static int HUD_IsWidescreen(int iWidth, int iHeight) |
||||
{ |
||||
float ratio = iWidth / iHeight; |
||||
|
||||
return (ratio >= 1.77) ? 1 : 0; |
||||
} |
||||
|
||||
DECLARE_MESSAGE(m_Scope, Scope) |
||||
|
||||
int CHudScope::Init(void) |
||||
{ |
||||
HOOK_MESSAGE(Scope); |
||||
|
||||
// Make inactive.
|
||||
m_iFlags &= ~HUD_ACTIVE; |
||||
|
||||
gHUD.AddHudElem(this); |
||||
|
||||
return 1; |
||||
}; |
||||
|
||||
void CHudScope::Reset(void) |
||||
{ |
||||
// Make inactive.
|
||||
m_iFlags &= ~HUD_ACTIVE; |
||||
} |
||||
|
||||
int CHudScope::VidInit(void) |
||||
{ |
||||
for (int i = 0; i < SCOPE_HSPRITE_COUNT; i++) |
||||
m_scopes[i] = 0; |
||||
|
||||
m_ScopeSize = 0; |
||||
|
||||
int sw = ScreenWidth, sh = ScreenHeight; |
||||
|
||||
//
|
||||
// Determine the ideal scope size to use.
|
||||
//
|
||||
|
||||
// Widescreen support. 1:77
|
||||
if (HUD_IsWidescreen(sw, sh)) |
||||
{ |
||||
if (sh > 576) |
||||
{ |
||||
if (sh > 800) |
||||
{ |
||||
m_ScopeSize = SCOPE_LARGE; |
||||
} |
||||
else |
||||
{ |
||||
m_ScopeSize = SCOPE_MEDIUM; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
m_ScopeSize = SCOPE_SMALL; |
||||
} |
||||
} |
||||
// Normal display. 1:33
|
||||
else |
||||
{ |
||||
if (sh > 600) |
||||
{ |
||||
if (sh > 768) |
||||
{ |
||||
m_ScopeSize = SCOPE_LARGE; |
||||
} |
||||
else |
||||
{ |
||||
m_ScopeSize = SCOPE_MEDIUM; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
m_ScopeSize = SCOPE_SMALL; |
||||
} |
||||
} |
||||
|
||||
// Make inactive.
|
||||
m_iFlags &= ~HUD_ACTIVE; |
||||
|
||||
return 1; |
||||
}; |
||||
|
||||
int CHudScope::Draw(float flTime) |
||||
{ |
||||
if (!(m_iFlags & HUD_ACTIVE)) |
||||
return 1; |
||||
|
||||
int x, y, w, h; |
||||
|
||||
x = y = 0; |
||||
|
||||
if (!m_scopes[0]) |
||||
{ |
||||
switch (m_ScopeSize) |
||||
{ |
||||
default: |
||||
case SCOPE_SMALL: |
||||
m_scopes[0] = LoadSprite("sprites/scope/0.spr"); |
||||
break; |
||||
|
||||
case SCOPE_MEDIUM: |
||||
m_scopes[SCOPE_U_L] = LoadSprite("sprites/scope/800/U_L.spr"); |
||||
m_scopes[SCOPE_U_M_L] = LoadSprite("sprites/scope/800/U_M_L.spr"); |
||||
m_scopes[SCOPE_U_M_R] = LoadSprite("sprites/scope/800/U_M_R.spr"); |
||||
m_scopes[SCOPE_U_R] = LoadSprite("sprites/scope/800/U_R.spr"); |
||||
m_scopes[SCOPE_M_L] = LoadSprite("sprites/scope/800/M_L.spr"); |
||||
m_scopes[SCOPE_M_R] = LoadSprite("sprites/scope/800/M_R.spr"); |
||||
m_scopes[SCOPE_L_L] = LoadSprite("sprites/scope/800/L_L.spr"); |
||||
m_scopes[SCOPE_L_M_L] = LoadSprite("sprites/scope/800/L_M_L.spr"); |
||||
m_scopes[SCOPE_L_M_R] = LoadSprite("sprites/scope/800/L_M_R.spr"); |
||||
m_scopes[SCOPE_L_R] = LoadSprite("sprites/scope/800/L_R.spr"); |
||||
break; |
||||
|
||||
case SCOPE_LARGE: |
||||
m_scopes[SCOPE_U_L] = LoadSprite("sprites/scope/1024/U_L.spr"); |
||||
m_scopes[SCOPE_U_M_L] = LoadSprite("sprites/scope/1024/U_M_L.spr"); |
||||
m_scopes[SCOPE_U_M_R] = LoadSprite("sprites/scope/1024/U_M_R.spr"); |
||||
m_scopes[SCOPE_U_R] = LoadSprite("sprites/scope/1024/U_R.spr"); |
||||
m_scopes[SCOPE_M_L] = LoadSprite("sprites/scope/1024/M_L.spr"); |
||||
m_scopes[SCOPE_M_R] = LoadSprite("sprites/scope/1024/M_R.spr"); |
||||
m_scopes[SCOPE_L_L] = LoadSprite("sprites/scope/1024/L_L.spr"); |
||||
m_scopes[SCOPE_L_M_L] = LoadSprite("sprites/scope/1024/L_M_L.spr"); |
||||
m_scopes[SCOPE_L_M_R] = LoadSprite("sprites/scope/1024/L_M_R.spr"); |
||||
m_scopes[SCOPE_L_R] = LoadSprite("sprites/scope/1024/L_R.spr"); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
w = SPR_Width(m_scopes[0], 0); |
||||
h = SPR_Height(m_scopes[0], 0); |
||||
|
||||
int r, g, b, a; |
||||
UnpackRGB(r, g, b, RGB_YELLOWISH); |
||||
|
||||
switch (m_ScopeSize) |
||||
{ |
||||
default: |
||||
|
||||
//
|
||||
// Small scope.
|
||||
//
|
||||
case SCOPE_SMALL: |
||||
//
|
||||
// This uses one sprite.
|
||||
//
|
||||
|
||||
x = ScreenWidth / 2 - w; |
||||
y = ScreenHeight / 2 - h; |
||||
|
||||
//-----------------------
|
||||
// Top left scope.
|
||||
//-----------------------
|
||||
SPR_Set(m_scopes[0], r, g, b); |
||||
SPR_DrawHoles(0, x, y, NULL); |
||||
|
||||
//-----------------------
|
||||
// Top right scope.
|
||||
//-----------------------
|
||||
SPR_Set(m_scopes[0], r, g, b); |
||||
SPR_DrawHoles(1, x + w, y, NULL); |
||||
|
||||
//-----------------------
|
||||
// Bottom right scope.
|
||||
//-----------------------
|
||||
SPR_Set(m_scopes[0], r, g, b); |
||||
SPR_DrawHoles(2, x + w, y + h, NULL); |
||||
|
||||
//-----------------------
|
||||
// Bottom left scope.
|
||||
//-----------------------
|
||||
SPR_Set(m_scopes[0], r, g, b); |
||||
SPR_DrawHoles(3, x, y + h, NULL); |
||||
break; |
||||
|
||||
//
|
||||
// Medium & Large scopes.
|
||||
//
|
||||
case SCOPE_MEDIUM: |
||||
case SCOPE_LARGE: |
||||
x = ScreenWidth / 2 - w * 2; |
||||
y = ScreenHeight / 2 - (h * 3) / 2; |
||||
|
||||
//-----------------------
|
||||
// Upper part.
|
||||
//-----------------------
|
||||
SPR_Set(m_scopes[SCOPE_U_L], r, g, b); |
||||
SPR_DrawHoles(0, x, y, NULL); |
||||
|
||||
SPR_Set(m_scopes[SCOPE_U_M_L], r, g, b); |
||||
SPR_DrawHoles(0, x + w, y, NULL); |
||||
|
||||
SPR_Set(m_scopes[SCOPE_U_M_R], r, g, b); |
||||
SPR_DrawHoles(0, x + w * 2, y, NULL); |
||||
|
||||
SPR_Set(m_scopes[SCOPE_U_R], r, g, b); |
||||
SPR_DrawHoles(0, x + w * 3, y, NULL); |
||||
|
||||
//-----------------------
|
||||
// Middle part.
|
||||
//-----------------------
|
||||
SPR_Set(m_scopes[SCOPE_M_L], r, g, b); |
||||
SPR_DrawHoles(0, x, y + h, NULL); |
||||
|
||||
SPR_Set(m_scopes[SCOPE_M_R], r, g, b); |
||||
SPR_DrawHoles(0, x + w * 3, y + h, NULL); |
||||
|
||||
//-----------------------
|
||||
// Lower part.
|
||||
//-----------------------
|
||||
SPR_Set(m_scopes[SCOPE_L_L], r, g, b); |
||||
SPR_DrawHoles(0, x, y + h * 2, NULL); |
||||
|
||||
SPR_Set(m_scopes[SCOPE_L_M_L], r, g, b); |
||||
SPR_DrawHoles(0, x + w, y + h * 2, NULL); |
||||
|
||||
SPR_Set(m_scopes[SCOPE_L_M_R], r, g, b); |
||||
SPR_DrawHoles(0, x + w * 2, y + h * 2, NULL); |
||||
|
||||
SPR_Set(m_scopes[SCOPE_L_R], r, g, b); |
||||
SPR_DrawHoles(0, x + w * 3, y + h * 2, NULL); |
||||
break; |
||||
} |
||||
|
||||
r = g = b = 0; |
||||
a = 255; |
||||
|
||||
// Draw left bar.
|
||||
gEngfuncs.pfnFillRGBABlend(0, 0, x + 1, ScreenHeight, r, g, b, a); |
||||
|
||||
// Draw right bar.
|
||||
gEngfuncs.pfnFillRGBABlend(ScreenWidth - x - 1, 0, ScreenWidth, ScreenHeight, r, g, b, a); |
||||
|
||||
// Draw top bar.
|
||||
gEngfuncs.pfnFillRGBABlend(0, 0, ScreenWidth, y + 1, r, g, b, a); |
||||
|
||||
// Draw bottom bar.
|
||||
gEngfuncs.pfnFillRGBABlend(0, ScreenHeight - y - 1, ScreenWidth, ScreenHeight, r, g, b, a); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
int CHudScope::MsgFunc_Scope(const char *pszName, int iSize, void *pbuf) |
||||
{ |
||||
BEGIN_READ(pbuf, iSize); |
||||
int fOn = READ_BYTE(); |
||||
|
||||
if (fOn) |
||||
{ |
||||
// Make active.
|
||||
m_iFlags |= HUD_ACTIVE; |
||||
} |
||||
else |
||||
{ |
||||
// Make inactive.
|
||||
m_iFlags &= ~HUD_ACTIVE; |
||||
} |
||||
|
||||
return 1; |
||||
} |
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* 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 |
||||
* object code is restricted to non-commercial enhancements to products from |
||||
* Valve LLC. All other use, distribution, or modification is prohibited |
||||
* without written permission from Valve LLC. |
||||
* |
||||
****/ |
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "monsters.h" |
||||
#include "customentity.h" |
||||
#include "effects.h" |
||||
#include "weapons.h" |
||||
|
||||
class CTriggerCommand : public CPointEntity |
||||
{ |
||||
public: |
||||
void Spawn(void); |
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); |
||||
|
||||
private: |
||||
void PlayMP3(CBaseEntity* pClient, const char* song); |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(trigger_command, CTriggerCommand); |
||||
|
||||
void CTriggerCommand::Spawn(void) |
||||
{ |
||||
pev->solid = SOLID_NOT; |
||||
pev->movetype = MOVETYPE_NONE; |
||||
pev->effects = 0; |
||||
pev->frame = 0; |
||||
} |
||||
|
||||
void CTriggerCommand::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) |
||||
{ |
||||
if (!pActivator || !pActivator->IsNetClient()) |
||||
return; |
||||
|
||||
const char* command = STRING(pev->netname); |
||||
|
||||
if (!command || !*command) |
||||
return; |
||||
|
||||
// ALERT(at_console, "%s with command \"%s\"\n", STRING(pev->classname), command);
|
||||
|
||||
char* str = NULL; |
||||
|
||||
if ((str = (char*)strstr(command, "playmp3")) != NULL) |
||||
{ |
||||
int pchlen = 0; |
||||
int extlen = 3; // "mp3" excluding NULL terminator.
|
||||
int ideallen = 0; |
||||
|
||||
char* pch = NULL, *lastpch = NULL; |
||||
char* song = NULL; |
||||
|
||||
pch = strtok(str, " ."); |
||||
|
||||
while (pch) |
||||
{ |
||||
pchlen = strlen(pch); |
||||
ideallen = (pchlen <= extlen) ? pchlen : extlen; |
||||
|
||||
if (strncmp(pch, "mp3", sizeof(char) * ideallen) == 0) |
||||
{ |
||||
pch = NULL; |
||||
} |
||||
else |
||||
{ |
||||
lastpch = pch; |
||||
pch = strtok(NULL, " ."); |
||||
} |
||||
} |
||||
|
||||
song = lastpch; |
||||
|
||||
PlayMP3(pActivator, song); |
||||
} |
||||
|
||||
UTIL_Remove(this); |
||||
} |
||||
|
||||
void CTriggerCommand::PlayMP3(CBaseEntity* pClient, const char* song) |
||||
{ |
||||
ASSERT(pClient != NULL); |
||||
|
||||
char cmd[128]; |
||||
sprintf(cmd, "play media/%s.mp3\n", song); |
||||
|
||||
CLIENT_COMMAND(ENT(pClient->pev),cmd); |
||||
} |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* This product contains software technology licensed from Id |
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. |
||||
* All Rights Reserved. |
||||
* |
||||
* This source code contains proprietary and confidential information of |
||||
* Valve LLC and its suppliers. Access to this code is restricted to |
||||
* persons who have executed a written SDK license with Valve. Any access, |
||||
* use or distribution of this code by or to any unlicensed person is illegal. |
||||
* |
||||
****/ |
||||
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "monsters.h" |
||||
#include "talkmonster.h" |
||||
#include "schedule.h" |
||||
#include "defaultai.h" |
||||
#include "scripted.h" |
||||
#include "animation.h" |
||||
#include "soundent.h" |
||||
#include "scientist.h" |
||||
|
||||
class CScientist2 : public CScientist |
||||
{ |
||||
public: |
||||
void Spawn(void); |
||||
void Precache(void); |
||||
|
||||
BOOL CanHeal(void) { return FALSE; } |
||||
|
||||
MONSTERSTATE GetIdealState(void); |
||||
|
||||
void DeathSound(void) {} |
||||
void PainSound(void) {} |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(monster_scientist2, CScientist2); |
||||
|
||||
void CScientist2::Spawn(void) |
||||
{ |
||||
Precache(); |
||||
|
||||
SET_MODEL(ENT(pev), "models/scientist2.mdl"); |
||||
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); |
||||
|
||||
pev->solid = SOLID_SLIDEBOX; |
||||
pev->movetype = MOVETYPE_STEP; |
||||
m_bloodColor = BLOOD_COLOR_RED; |
||||
pev->health = gSkillData.scientistHealth; |
||||
pev->view_ofs = Vector(0, 0, 50);// position of the eyes relative to monster's origin.
|
||||
m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello
|
||||
m_MonsterState = MONSTERSTATE_NONE; |
||||
|
||||
// m_flDistTooFar = 256.0;
|
||||
|
||||
m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE; |
||||
|
||||
// White hands
|
||||
pev->skin = 0; |
||||
|
||||
if (pev->body == -1) |
||||
{// -1 chooses a random head
|
||||
pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS - 1);// pick a head, any head
|
||||
} |
||||
|
||||
MonsterInit(); |
||||
SetUse(&CScientist2::FollowerUse); |
||||
} |
||||
|
||||
void CScientist2::Precache(void) |
||||
{ |
||||
PRECACHE_MODEL("models/scientist2.mdl"); |
||||
|
||||
// every new scientist must call this, otherwise
|
||||
// when a level is loaded, nobody will talk (time is reset to 0)
|
||||
TalkInit(); |
||||
|
||||
CTalkMonster::Precache(); |
||||
} |
||||
|
||||
MONSTERSTATE CScientist2::GetIdealState(void) |
||||
{ |
||||
switch (m_MonsterState) |
||||
{ |
||||
case MONSTERSTATE_ALERT: |
||||
case MONSTERSTATE_IDLE: |
||||
return CScientist::GetIdealState(); |
||||
|
||||
case MONSTERSTATE_COMBAT: |
||||
m_IdealMonsterState = MONSTERSTATE_ALERT; |
||||
return CScientist::GetIdealState(); |
||||
|
||||
default: |
||||
return CScientist::GetIdealState(); |
||||
} |
||||
|
||||
return CScientist::GetIdealState(); |
||||
} |
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
/***
|
||||
* |
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved. |
||||
* |
||||
* 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 |
||||
* object code is restricted to non-commercial enhancements to products from |
||||
* Valve LLC. All other use, distribution, or modification is prohibited |
||||
* without written permission from Valve LLC. |
||||
* |
||||
****/ |
||||
|
||||
#ifndef SCIENTIST_H |
||||
#define SCIENTIST_H |
||||
|
||||
#if defined ( THEGATE_DLL ) |
||||
#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model
|
||||
enum { HEAD_GLASSES = 0, HEAD_EINSTEIN = 1, HEAD_LUTHER = 2, HEAD_SLICK = 3 }; |
||||
|
||||
//=======================================================
|
||||
// Scientist
|
||||
//=======================================================
|
||||
|
||||
class CScientist : public CTalkMonster |
||||
{ |
||||
public: |
||||
void Spawn( void ); |
||||
void Precache( void ); |
||||
|
||||
void SetYawSpeed( void ); |
||||
int Classify ( void ); |
||||
void HandleAnimEvent( MonsterEvent_t *pEvent ); |
||||
void RunTask( Task_t *pTask ); |
||||
void StartTask( Task_t *pTask ); |
||||
int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; } |
||||
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); |
||||
virtual int FriendNumber( int arrayNumber ); |
||||
void SetActivity ( Activity newActivity ); |
||||
Activity GetStoppedActivity( void ); |
||||
int ISoundMask( void ); |
||||
void DeclineFollowing( void ); |
||||
|
||||
float CoverRadius( void ) { return 1200; } // Need more room for cover because scientists want to get far away!
|
||||
BOOL DisregardEnemy( CBaseEntity *pEnemy ) { return !pEnemy->IsAlive() || (gpGlobals->time - m_fearTime) > 15; } |
||||
|
||||
BOOL CanHeal( void ); |
||||
void Heal( void ); |
||||
void Scream( void ); |
||||
|
||||
// Override these to set behavior
|
||||
Schedule_t *GetScheduleOfType ( int Type ); |
||||
Schedule_t *GetSchedule ( void ); |
||||
MONSTERSTATE GetIdealState ( void ); |
||||
|
||||
void DeathSound( void ); |
||||
void PainSound( void ); |
||||
|
||||
void TalkInit( void ); |
||||
|
||||
void Killed( entvars_t *pevAttacker, int iGib ); |
||||
|
||||
virtual int Save( CSave &save ); |
||||
virtual int Restore( CRestore &restore ); |
||||
static TYPEDESCRIPTION m_SaveData[]; |
||||
|
||||
CUSTOM_SCHEDULES; |
||||
|
||||
private: |
||||
float m_painTime; |
||||
float m_healTime; |
||||
float m_fearTime; |
||||
}; |
||||
|
||||
|
||||
//=========================================================
|
||||
// Dead Scientist PROP
|
||||
//=========================================================
|
||||
class CDeadScientist : public CBaseMonster |
||||
{ |
||||
public: |
||||
void Spawn(void); |
||||
int Classify(void) { return CLASS_HUMAN_PASSIVE; } |
||||
|
||||
void KeyValue(KeyValueData *pkvd); |
||||
int m_iPose;// which sequence to display
|
||||
static char *m_szPoses[7]; |
||||
}; |
||||
|
||||
//=========================================================
|
||||
// Sitting Scientist PROP
|
||||
//=========================================================
|
||||
class CSittingScientist : public CScientist // kdb: changed from public CBaseMonster so he can speak
|
||||
{ |
||||
public: |
||||
void Spawn( void ); |
||||
void Precache( void ); |
||||
|
||||
void EXPORT SittingThink( void ); |
||||
int Classify ( void ); |
||||
virtual int Save( CSave &save ); |
||||
virtual int Restore( CRestore &restore ); |
||||
static TYPEDESCRIPTION m_SaveData[]; |
||||
|
||||
virtual void SetAnswerQuestion( CTalkMonster *pSpeaker ); |
||||
int FriendNumber( int arrayNumber ); |
||||
|
||||
int FIdleSpeak ( void ); |
||||
int m_baseSequence; |
||||
int m_headTurn; |
||||
float m_flResponseDelay; |
||||
}; |
||||
|
||||
|
||||
#endif // defined ( THEGATE_DLL )
|
||||
|
||||
#endif // SCIENTIST_H
|
Loading…
Reference in new issue