Added turrets code.

This commit is contained in:
Julian
2020-03-14 21:03:52 -03:00
parent 73fb0c4d1e
commit d4ddcd48d9
6 changed files with 1332 additions and 42 deletions

View File

@@ -40,6 +40,7 @@ OBJ = \
squeakgrenade.o \
subs.o \
talkmonster.o \
turret.o \
util.o \
weapons.o \
zombie.o

View File

@@ -1096,4 +1096,142 @@ private:
float m_flameY;
};
// maybe put this on a separate header file?
typedef enum
{
TURRET_ANIM_NONE = 0,
TURRET_ANIM_FIRE,
TURRET_ANIM_SPIN,
TURRET_ANIM_DEPLOY,
TURRET_ANIM_RETIRE,
TURRET_ANIM_DIE,
} TURRET_ANIM;
class CMBaseTurret : public CMBaseMonster
{
public:
void Spawn(void);
virtual void Precache(void);
void KeyValue( KeyValueData *pkvd );
void EXPORT TurretUse( edict_t *pActivator, edict_t *pCaller, USE_TYPE useType, float value );
virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
virtual int Classify(void);
int BloodColor( void ) { return DONT_BLEED; }
void GibMonster( void ) {} // UNDONE: Throw turret gibs?
// Think functions
void EXPORT ActiveThink(void);
void EXPORT SearchThink(void);
void EXPORT AutoSearchThink(void);
void EXPORT TurretDeath(void);
virtual void EXPORT SpinDownCall(void) { m_iSpin = 0; }
virtual void EXPORT SpinUpCall(void) { m_iSpin = 1; }
// void SpinDown(void);
// float EXPORT SpinDownCall( void ) { return SpinDown(); }
// virtual float SpinDown(void) { return 0;}
// virtual float Retire(void) { return 0;}
void EXPORT Deploy(void);
void EXPORT Retire(void);
void EXPORT Initialize(void);
virtual void Ping(void);
virtual void EyeOn(void);
virtual void EyeOff(void);
// other functions
void SetTurretAnim(TURRET_ANIM anim);
int MoveTurret(void);
virtual void Shoot(Vector &vecSrc, Vector &vecDirToEnemy) { };
float m_flMaxSpin; // Max time to spin the barrel w/o a target
int m_iSpin;
CMSprite *m_pEyeGlow;
int m_eyeBrightness;
int m_iDeployHeight;
int m_iRetractHeight;
int m_iMinPitch;
int m_iBaseTurnRate; // angles per second
float m_fTurnRate; // actual turn rate
int m_iOrientation; // 0 = floor, 1 = Ceiling
int m_iOn;
int m_fBeserk; // Sometimes this bitch will just freak out
int m_iAutoStart; // true if the turret auto deploys when a target
// enters its range
Vector m_vecLastSight;
float m_flLastSight; // Last time we saw a target
float m_flMaxWait; // Max time to seach w/o a target
int m_iSearchSpeed; // Not Used!
// movement
float m_flStartYaw;
Vector m_vecCurAngles;
Vector m_vecGoalAngles;
float m_flPingTime; // Time until the next ping, used when searching
float m_flSpinUpTime; // Amount of time until the barrel should spin down when searching
};
class CMTurret : public CMBaseTurret
{
public:
void Spawn(void);
void Precache(void);
// Think functions
void SpinUpCall(void);
void SpinDownCall(void);
// other functions
void Shoot(Vector &vecSrc, Vector &vecDirToEnemy);
void Killed( entvars_t *pevAttacker, int iGib );
private:
int m_iStartSpin;
};
class CMMiniTurret : public CMBaseTurret
{
public:
void Spawn( );
void Precache(void);
// other functions
void Shoot(Vector &vecSrc, Vector &vecDirToEnemy);
void Killed( entvars_t *pevAttacker, int iGib );
};
//=========================================================
// Sentry gun - smallest turret, placed near grunt entrenchments
//=========================================================
class CMSentry : public CMBaseTurret
{
public:
void Spawn( );
void Precache(void);
// other functions
void Shoot(Vector &vecSrc, Vector &vecDirToEnemy);
int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
void Killed( entvars_t *pevAttacker, int iGib );
void EXPORT SentryTouch( edict_t *pOther );
void EXPORT SentryDeath( void );
};
#endif // BASEMONSTER_H

View File

@@ -131,6 +131,9 @@ monster_type_t monster_types[]=
"monster_snark", FALSE,
"monster_zombie", FALSE,
"monster_gargantua", FALSE,
"monster_turret", FALSE,
"monster_miniturret", FALSE,
"monster_sentry", FALSE,
"info_node", FALSE, // Nodes
"info_node_air", FALSE,
"", FALSE
@@ -404,6 +407,9 @@ bool spawn_monster(int monster_type, Vector origin, Vector angles, int respawn_i
case 12: monsters[monster_index].pMonster = CreateClassPtr((CMSqueakGrenade *)NULL); break;
case 13: monsters[monster_index].pMonster = CreateClassPtr((CMZombie *)NULL); break;
case 14: monsters[monster_index].pMonster = CreateClassPtr((CMGargantua *)NULL); break;
case 15: monsters[monster_index].pMonster = CreateClassPtr((CMTurret *)NULL); break;
case 16: monsters[monster_index].pMonster = CreateClassPtr((CMMiniTurret *)NULL); break;
case 17: monsters[monster_index].pMonster = CreateClassPtr((CMSentry *)NULL); break;
}
if (monsters[monster_index].pMonster == NULL)
@@ -508,6 +514,9 @@ void MonsterCommand(void)
// check for a valid monster name...
for (index = 0; monster_types[index].name[0]; index++)
{
// ensure it's an actual monster classname
if (strncmp(parg1, "monster", 7) == 0)
{
if (strcmp(parg1, monster_types[index].name) == 0)
{
@@ -515,6 +524,7 @@ void MonsterCommand(void)
break;
}
}
}
if (monster_type != -1)
{
@@ -777,6 +787,9 @@ void MonsterCommand(void)
LOG_MESSAGE(PLID, "valid monster_names are:");
msg[0] = 0;
for (index = 0; monster_types[index].name[0]; index++)
{
// limit list to monster entities only
if (strncmp(monster_types[index].name, "monster", 7) == 0)
{
strcat(msg, monster_types[index].name);
strcat(msg, " ");
@@ -787,6 +800,7 @@ void MonsterCommand(void)
msg[0] = 0;
}
}
}
if (msg[0])
{
//META_CONS("[MONSTER] %s", msg);
@@ -1033,6 +1047,9 @@ void mmServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
CMSqueakGrenade snark;
CMZombie zombie;
CMGargantua gargantua;
CMTurret turret;
CMMiniTurret miniturret;
CMSentry sentry;
g_psv_gravity = CVAR_GET_POINTER( "sv_gravity" );
@@ -1065,6 +1082,9 @@ void mmServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
case 12: snark.Precache(); break;
case 13: zombie.Precache(); break;
case 14: gargantua.Precache(); break;
case 15: turret.Precache(); break;
case 16: miniturret.Precache(); break;
case 17: sentry.Precache(); break;
}
}
}

View File

@@ -57,14 +57,10 @@ skill_cfg_t skill_cfg[] = {
{"sk_islave_dmg_zap", &gSkillData.slaveDmgZap},
{"sk_ichthyosaur_health", &gSkillData.ichthyosaurHealth},
{"sk_ichthyosaur_shake", &gSkillData.ichthyosaurDmgShake},
{"sk_leech_health", &gSkillData.leechHealth},
{"sk_leech_dmg_bite", &gSkillData.leechDmgBite},
{"sk_controller_health", &gSkillData.controllerHealth},
{"sk_controller_dmgzap", &gSkillData.controllerDmgZap},
{"sk_controller_speedball", &gSkillData.controllerSpeedBall},
{"sk_controller_dmgball", &gSkillData.controllerDmgBall},
{"sk_nihilanth_health", &gSkillData.nihilanthHealth},
{"sk_nihilanth_zap", &gSkillData.nihilanthZap},
{"sk_scientist_health", &gSkillData.scientistHealth},
{"sk_scientist_heal", &gSkillData.scientistHeal},
{"sk_snark_health", &gSkillData.snarkHealth},
@@ -73,6 +69,9 @@ skill_cfg_t skill_cfg[] = {
{"sk_zombie_health", &gSkillData.zombieHealth},
{"sk_zombie_dmg_one_slash", &gSkillData.zombieDmgOneSlash},
{"sk_zombie_dmg_both_slash", &gSkillData.zombieDmgBothSlash},
{"sk_turret_health", &gSkillData.turretHealth},
{"sk_miniturret_health", &gSkillData.miniturretHealth},
{"sk_sentry_health", &gSkillData.sentryHealth},
{"sk_12mm_bullet", &gSkillData.monDmg9MM},
{"sk_9mmAR_bullet", &gSkillData.monDmgMP5},
{"sk_9mm_bullet", &gSkillData.monDmg12MM},
@@ -128,14 +127,14 @@ void monster_skill_init(void)
char filename[256];
FILE *fp = NULL;
// Alien Grunt (agrunt)
// Alien Grunt
gSkillData.agruntHealth = 90.0f;
gSkillData.agruntDmgPunch = 20.0f;
// Apache (apache)
// Apache
gSkillData.apacheHealth = 250.0f;
// Barney (barney)
// Barney
gSkillData.barneyHealth = 35.0f;
// Big momma
@@ -144,7 +143,7 @@ void monster_skill_init(void)
gSkillData.bigmommaDmgBlast = 120.0f;
gSkillData.bigmommaRadiusBlast = 250.0f;
// Bullsquid (bullsquid)
// Bullsquid
gSkillData.bullsquidHealth = 40.0f;
gSkillData.bullsquidDmgBite = 25.0f;
gSkillData.bullsquidDmgWhip = 35.0f;
@@ -157,24 +156,24 @@ void monster_skill_init(void)
gSkillData.gargantuaDmgFire = 5.0f;
gSkillData.gargantuaDmgStomp = 100.0f;
// Hassassin (hassassin)
// Hassassin (Female Assassin)
gSkillData.hassassinHealth = 50.0f;
// Headcrab (headcrab)
// Headcrab
gSkillData.headcrabHealth = 10.0f;
gSkillData.headcrabDmgBite = 10.0f;
// Hgrunt (hgrunt)
// Hgrunt (Human Grunt)
gSkillData.hgruntHealth = 50.0f;
gSkillData.hgruntDmgKick = 10.0f;
gSkillData.hgruntShotgunPellets = 5.0f;
gSkillData.hgruntGrenadeSpeed = 600.0f;
// Houndeye (houndeye)
// Houndeye
gSkillData.houndeyeHealth = 20.0f;
gSkillData.houndeyeDmgBlast = 15.0f;
// ISlave (islave)
// Alien Slave
gSkillData.slaveHealth = 30.0f;
gSkillData.slaveDmgClaw = 10.0f;
gSkillData.slaveDmgClawrake = 25.0f;
@@ -184,34 +183,35 @@ void monster_skill_init(void)
gSkillData.ichthyosaurHealth = 200.0f;
gSkillData.ichthyosaurDmgShake = 35.0f;
// Leech
gSkillData.leechHealth = 2.0f;
gSkillData.leechDmgBite = 2.0f;
// Controller
gSkillData.controllerHealth = 60.0f;
gSkillData.controllerDmgZap = 25.0f;
gSkillData.controllerSpeedBall = 800.0f;
gSkillData.controllerDmgBall = 4.0f;
// Nihilanth
gSkillData.nihilanthHealth = 800.0f;
gSkillData.nihilanthZap = 30.0f;
// Scientist (scientist)
// Scientist
gSkillData.scientistHealth = 20.0f;
gSkillData.scientistHeal = 25.0f;
// Snark (snark)
// Snark
gSkillData.snarkHealth = 2.0f;
gSkillData.snarkDmgBite = 10.0f;
gSkillData.snarkDmgPop = 5.0f;
// Zombie (zombie)
// Zombie
gSkillData.zombieHealth = 50.0f;
gSkillData.zombieDmgOneSlash = 20.0f;
gSkillData.zombieDmgBothSlash = 40.0f;
// Turret
gSkillData.turretHealth = 50.0f;
// Mini-Turret
gSkillData.miniturretHealth = 40.0f;
// Sentry
gSkillData.sentryHealth = 40.0f;
// MONSTER WEAPONS
gSkillData.monDmg9MM = 5.0f;
gSkillData.monDmgMP5 = 4.0f;

View File

@@ -66,17 +66,11 @@ struct skilldata_t
float ichthyosaurHealth;
float ichthyosaurDmgShake;
float leechHealth;
float leechDmgBite;
float controllerHealth;
float controllerDmgZap;
float controllerSpeedBall;
float controllerDmgBall;
float nihilanthHealth;
float nihilanthZap;
float scientistHealth;
float scientistHeal;
@@ -88,6 +82,10 @@ struct skilldata_t
float zombieDmgOneSlash;
float zombieDmgBothSlash;
float turretHealth;
float miniturretHealth;
float sentryHealth;
// weapons shared by monsters
float monDmg9MM;
float monDmgMP5;

1133
src/dlls/turret.cpp Executable file

File diff suppressed because it is too large Load Diff