sin-2015/securityturret.cpp
1999-04-22 00:00:00 +00:00

98 lines
1.9 KiB
C++

// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// DESCRIPTION:
// Security turret. Senses when player is near and raises up, searches for player,
// and fires. When player is dead or not near, it lowers down and goes back to
// sleep.
//
#include "securityturret.h"
CLASS_DECLARATION( Turret, TurretTop, "trap_securityturret" )
ResponseDef TurretTop::Responses[] =
{
{ NULL, NULL }
};
TurretTop::TurretTop
(
void
)
{
setModel( "turtop.def" );
setSize( "-16 -16 0", "16 16 26" );
RandomAnimate( "down_idle", NULL );
gunoffset = "0 0 0";
neworientation = angles.yaw();
setMoveType( MOVETYPE_NONE );
setSolidType( SOLID_BBOX );
health = G_GetFloatArg( "health", 100 );
takedamage = DAMAGE_YES;
flags |= FL_SPARKS;
wakeupdistance = G_GetFloatArg( "wakeupdistance", 750 );
firingdistance = G_GetFloatArg( "firingdistance", 800 );
SetupBase();
}
void TurretTop::SetupBase
(
void
)
{
TurretBase *baseptr;
baseptr = new TurretBase;
baseptr->setOrigin( worldorigin );
base = baseptr->entnum;
}
CLASS_DECLARATION( Entity, TurretBase, NULL )
ResponseDef TurretBase::Responses[] =
{
{ &EV_Turret_GoUp, ( Response )TurretBase::GoUp },
{ &EV_Turret_GoDown, ( Response )TurretBase::GoDown },
{ NULL, NULL }
};
TurretBase::TurretBase()
{
setModel( "turbase.def" );
setSize( "-16 -16 0", "16 16 1" );
setMoveType( MOVETYPE_NONE );
setSolidType( SOLID_BBOX );
RandomAnimate( "down_idle", NULL );
takedamage = DAMAGE_NO;
}
void TurretBase::GoUp
(
Event *ev
)
{
RandomAnimate( "raise", NULL );
}
void TurretBase::GoDown
(
Event *ev
)
{
RandomAnimate( "lower", NULL );
}