as released 1998-12-20

This commit is contained in:
archive 1998-12-20 00:00:00 +00:00
commit 09e039d47e
192 changed files with 120936 additions and 0 deletions

6225
actor.cpp Normal file

File diff suppressed because it is too large Load Diff

1333
actor.h Normal file

File diff suppressed because it is too large Load Diff

228
ammo.cpp Normal file
View File

@ -0,0 +1,228 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/ammo.cpp $
// $Revision:: 28 $
// $Author:: Aldie $
// $Date:: 10/24/98 2:07p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/ammo.cpp $
//
// 28 10/24/98 2:07p Aldie
// Moved pickupable function out.
//
// 27 10/21/98 9:05p Aldie
// Added spear ammo
//
// 26 10/21/98 5:24p Aldie
// Don't let mutants pickup ammo
//
// 25 10/14/98 1:01a Jimdose
// change Ammo::Ammo so that it used Set to set amount so that spawnarg values
// are not cleared out
//
// 24 10/05/98 11:59p Aldie
// Fix spidermines
//
// 23 6/28/98 4:13p Markd
// simplified setup
//
// 22 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 21 6/24/98 1:35p Aldie
// Implementation of inventory system and picking stuff up
//
// 20 6/17/98 1:19a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 19 6/10/98 5:10p Markd
// Using ExpandAlias method
//
// 18 6/10/98 1:19p Markd
// Added SetAmmoName and SetAmmoAmount, removed 357 ammo
//
// 17 6/08/98 7:21p Aldie
// Added SpiderMine ammo
//
// 16 5/26/98 4:44p Aldie
// Added remove ammo
//
// 15 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 14 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 13 5/08/98 2:55p Markd
// Put in Ammo pickup sounds
//
// 12 4/28/98 5:28p Jimdose
// Changed rocket and sniper ammo from 20 to 10
//
// 11 4/18/98 3:30p Markd
// Added new shotgun clip type
//
// 10 4/07/98 9:18p Jimdose
// Added Rockets
//
// 9 4/07/98 6:42p Jimdose
// Turned off respawn in singleplayer
//
// 8 4/04/98 6:00p Jimdose
// Made response to EV_Touch be response to EV_Trigger_Effect
//
// 7 3/31/98 4:21p Jimdose
// Changed model names
//
// 6 3/30/98 9:54p Jimdose
// Changed location of .def files
//
// 5 3/30/98 2:31p Jimdose
// Created file
//
// DESCRIPTION:
// Base class for all ammunition for entities derived from the Weapon class.
//
#include "g_local.h"
#include "item.h"
#include "ammo.h"
CLASS_DECLARATION( Item, Ammo, NULL );
ResponseDef Ammo::Responses[] =
{
{ NULL, NULL }
};
Ammo::Ammo()
{
Set( 0 );
}
void Ammo::Setup
(
const char *model
)
{
const char * m;
m = G_GetSpawnArg( "model" );
if ( m )
{
setModel( m );
}
else
{
assert( model );
setModel( model );
}
}
CLASS_DECLARATION( Ammo, Bullet10mm, "ammo_10mm" );
ResponseDef Bullet10mm::Responses[] =
{
{ NULL, NULL }
};
Bullet10mm::Bullet10mm()
{
Setup( "357.def" );
}
CLASS_DECLARATION( Ammo, Bullet50mm, "ammo_50mm" );
ResponseDef Bullet50mm::Responses[] =
{
{ NULL, NULL }
};
Bullet50mm::Bullet50mm()
{
Setup( "50mm.def" );
}
CLASS_DECLARATION( Ammo, BulletPulse, "ammo_pulserifle" );
ResponseDef BulletPulse::Responses[] =
{
{ NULL, NULL }
};
BulletPulse::BulletPulse()
{
Setup( "pulse_ammo.def" );
}
CLASS_DECLARATION( Ammo, BulletSniper, "ammo_sniperrifle" );
ResponseDef BulletSniper::Responses[] =
{
{ NULL, NULL }
};
BulletSniper::BulletSniper()
{
Setup( "sniper_ammo.def" );
}
CLASS_DECLARATION( Ammo, Rockets, "ammo_rockets" );
ResponseDef Rockets::Responses[] =
{
{ NULL, NULL }
};
Rockets::Rockets()
{
Setup( "rockets.def" );
}
CLASS_DECLARATION( Ammo, Spears, "ammo_speargun" );
ResponseDef Spears::Responses[] =
{
{ NULL, NULL }
};
Spears::Spears()
{
Setup( "spear_ammo.def" );
}
CLASS_DECLARATION( Ammo, ShotgunClip, "ammo_shotgunclip" );
ResponseDef ShotgunClip::Responses[] =
{
{ NULL, NULL }
};
ShotgunClip::ShotgunClip()
{
Setup( "shotgunclip.def" );
}
CLASS_DECLARATION( Ammo, SpiderMines, "ammo_spidermines" );
ResponseDef SpiderMines::Responses[] =
{
{ NULL, NULL }
};
SpiderMines::SpiderMines()
{
Setup( "mine.def" );
}

149
ammo.h Normal file
View File

@ -0,0 +1,149 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/ammo.h $
// $Revision:: 19 $
// $Author:: Aldie $
// $Date:: 10/24/98 2:09p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/ammo.h $
//
// 19 10/24/98 2:09p Aldie
// Moved pickupable out of ammo
//
// 18 10/21/98 10:39p Aldie
// Added spears
//
// 17 10/21/98 5:29p Aldie
// Added a pickupable function to ammo which restricts mutants
//
// 16 6/28/98 4:13p Markd
// simplified setup
//
// 15 6/25/98 8:48p Markd
// Rewrote Item class, added keyed items to triggers, cleaned up item system
//
// 14 6/24/98 1:38p Aldie
// Implementation of inventory system and picking stuff up
//
// 13 6/17/98 1:16a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 12 6/10/98 1:18p Markd
// Added SetAmmoAmount and SetAmmoName, also removed 357 bullets
//
// 11 6/08/98 7:22p Aldie
// Added spidermines
//
// 10 5/26/98 4:44p Aldie
// Added remove ammo
//
// 9 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 8 5/08/98 2:57p Markd
// Added pickup sound
//
// 7 4/18/98 3:29p Markd
// Added new shotgunclip ammo
//
// 6 4/07/98 9:19p Jimdose
// Added rockets
//
// 5 3/30/98 2:31p Jimdose
// Created file
//
// DESCRIPTION:
// Base class for all ammunition for entities derived from the Weapon class.
//
#ifndef __AMMO_H__
#define __AMMO_H__
#include "g_local.h"
#include "item.h"
#include "sentient.h"
#include "item.h"
class EXPORT_FROM_DLL Ammo : public Item
{
protected:
virtual void Setup( const char *model );
public:
CLASS_PROTOTYPE( Ammo );
Ammo();
};
class EXPORT_FROM_DLL Bullet10mm : public Ammo
{
public:
CLASS_PROTOTYPE( Bullet10mm );
Bullet10mm();
};
class EXPORT_FROM_DLL Bullet50mm : public Ammo
{
public:
CLASS_PROTOTYPE( Bullet50mm );
Bullet50mm();
};
class EXPORT_FROM_DLL BulletPulse : public Ammo
{
public:
CLASS_PROTOTYPE( BulletPulse );
BulletPulse();
};
class EXPORT_FROM_DLL BulletSniper : public Ammo
{
public:
CLASS_PROTOTYPE( BulletSniper );
BulletSniper();
};
class EXPORT_FROM_DLL Rockets : public Ammo
{
public:
CLASS_PROTOTYPE( Rockets );
Rockets();
};
class EXPORT_FROM_DLL Spears : public Ammo
{
public:
CLASS_PROTOTYPE( Spears );
Spears();
};
class EXPORT_FROM_DLL ShotgunClip : public Ammo
{
public:
CLASS_PROTOTYPE( ShotgunClip );
ShotgunClip();
};
class EXPORT_FROM_DLL SpiderMines : public Ammo
{
public:
CLASS_PROTOTYPE( SpiderMines );
SpiderMines();
};
#endif /* ammo.h */

289
animals.cpp Normal file
View File

@ -0,0 +1,289 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/animals.cpp $
// $Revision:: 8 $
// $Author:: Markd $
// $Date:: 11/16/98 11:15p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/animals.cpp $
//
// 8 11/16/98 11:15p Markd
// Added fish
//
// 7 10/25/98 9:10p Markd
// made bats be more like rats but with wings
//
// 6 10/19/98 12:04a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 5 10/13/98 11:13p Markd
// Redid mouse, allowed mutation
//
// 4 9/22/98 5:19p Markd
// Put in new consolidated gib function
//
// 3 9/22/98 3:21p Markd
// put in parentmode lockout for blood and gibs
//
// 2 8/10/98 6:51p Aldie
// First version of rat
//
// DESCRIPTION:
// Animals behavior
#include "actor.h"
#include "gibs.h"
class EXPORT_FROM_DLL Rat : public Actor
{
public:
CLASS_PROTOTYPE( Rat );
void Killed( Event *ev );
void Touched( Event *ev );
void Mutate( Event *ev );
};
CLASS_DECLARATION( Actor, Rat, "animals_rat" );
ResponseDef Rat::Responses[] =
{
{ &EV_Killed, ( Response )Rat::Killed },
{ &EV_Touch, ( Response )Rat::Touched },
{ &EV_Mutate, ( Response )Rat::Mutate },
{ NULL, NULL }
};
void Rat::Touched
(
Event *ev
)
{
Event *event;
Entity *other;
other = ev->GetEntity( 1 );
assert( other != this );
if ( other->isSubclassOf( Sentient ) )
{
event = new Event( EV_Actor_Attack );
event->AddEntity( other );
ProcessEvent( event );
}
}
void Rat::Mutate
(
Event *ev
)
{
Vector tempmins;
Vector tempmaxs;
Event *event;
assert( !( flags & FL_MUTATED ) );
flags |= FL_MUTATED;
edict->s.scale = 3;
health *= edict->s.scale;
max_health *= edict->s.scale;
tempmins = mins * edict->s.scale;
tempmaxs = maxs * edict->s.scale;
setSize( tempmins, tempmaxs );
unlink();
KillBox( this );
link();
event = new Event( EV_Actor_MeleeDamage );
event->AddFloat( melee_damage * edict->s.scale );
ProcessEvent( event );
event = new Event( EV_Actor_MeleeRange );
event->AddFloat( melee_range * edict->s.scale );
ProcessEvent( event );
}
void Rat::Killed
(
Event *ev
)
{
takedamage = DAMAGE_NO;
setSolidType( SOLID_NOT );
hideModel();
if ( sv_gibs->value && !parentmode->value )
{
int numgibs;
float gibsize;
gibsize = size.length() / 175;
numgibs = gibsize * 6;
if ( numgibs > 4 )
numgibs = 4;
CreateGibs( this, health, gibsize, numgibs );
}
PostEvent( EV_Remove, 0 );
}
class EXPORT_FROM_DLL Bat : public Actor
{
public:
CLASS_PROTOTYPE( Bat );
void Killed( Event *ev );
void Touched( Event *ev );
void Mutate( Event *ev );
};
CLASS_DECLARATION( Actor, Bat, "animals_bat" );
ResponseDef Bat::Responses[] =
{
{ &EV_Killed, ( Response )Bat::Killed },
{ &EV_Touch, ( Response )Bat::Touched },
{ &EV_Mutate, ( Response )Bat::Mutate },
{ NULL, NULL }
};
void Bat::Touched
(
Event *ev
)
{
Event *event;
Entity *other;
other = ev->GetEntity( 1 );
assert( other != this );
if ( other->isSubclassOf( Sentient ) )
{
event = new Event( EV_Actor_Attack );
event->AddEntity( other );
ProcessEvent( event );
}
}
void Bat::Mutate
(
Event *ev
)
{
Vector tempmins;
Vector tempmaxs;
Event *event;
assert( !( flags & FL_MUTATED ) );
flags |= FL_MUTATED;
edict->s.scale = 5;
health *= edict->s.scale;
max_health *= edict->s.scale;
tempmins = mins * edict->s.scale;
tempmaxs = maxs * edict->s.scale;
setSize( tempmins, tempmaxs );
unlink();
KillBox( this );
link();
event = new Event( EV_Actor_MeleeDamage );
event->AddFloat( melee_damage * edict->s.scale );
ProcessEvent( event );
event = new Event( EV_Actor_MeleeRange );
event->AddFloat( melee_range * edict->s.scale );
ProcessEvent( event );
}
void Bat::Killed
(
Event *ev
)
{
takedamage = DAMAGE_NO;
setSolidType( SOLID_NOT );
hideModel();
if ( sv_gibs->value && !parentmode->value )
{
int numgibs;
float gibsize;
gibsize = size.length() / 175;
numgibs = gibsize * 6;
if ( numgibs > 4 )
numgibs = 4;
CreateGibs( this, health, gibsize, numgibs );
}
PostEvent( EV_Remove, 0 );
}
class EXPORT_FROM_DLL Fish : public Actor
{
public:
CLASS_PROTOTYPE( Fish );
void Killed( Event *ev );
};
CLASS_DECLARATION( Actor, Fish, "animals_fish" );
ResponseDef Fish::Responses[] =
{
{ &EV_Killed, ( Response )Fish::Killed },
{ NULL, NULL }
};
void Fish::Killed
(
Event *ev
)
{
takedamage = DAMAGE_NO;
setSolidType( SOLID_NOT );
hideModel();
if ( sv_gibs->value && !parentmode->value )
{
int numgibs;
float gibsize;
gibsize = size.length() / 175;
numgibs = gibsize * 6;
if ( numgibs > 4 )
numgibs = 4;
CreateGibs( this, health, gibsize, numgibs );
}
PostEvent( EV_Remove, 0 );
}

182
arcade_comm.cpp Normal file
View File

@ -0,0 +1,182 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/arcade_comm.cpp $
// $Revision:: 4 $
// $Author:: Aldie $
// $Date:: 12/14/98 8:16p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/arcade_comm.cpp $
//
// 4 12/14/98 8:16p Aldie
// Added a disablecom command
//
// 3 12/14/98 5:23p Aldie
// Added generic COM ports
//
// 2 12/08/98 7:04p Aldie
// First version of serial comm for arcade
//
// DESCRIPTION:
// Sin Arcade Serial Communications
#ifdef SIN_ARCADE
#include "arcade_comm.h"
#include <windows.h>
static LPDCB lpDCB=NULL;
static HANDLE COMHANDLE=NULL;
static cvar_t *disable_com;
void ARCADE_ComError
(
void
)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR)&lpMsgBuf,
0,
NULL );
// Display the string.
gi.error( (const char *)lpMsgBuf );
// Free the buffer.
LocalFree( lpMsgBuf );
}
qboolean ARCADE_ComWriteByte
(
byte b
)
{
DWORD bytesWritten;
LPBYTE lpByte;
BOOL retval;
if ( disable_com->value )
return( true );
lpByte = (BYTE *)"UB";
if ( !lpDCB || !COMHANDLE )
{
return false;
}
retval = WriteFile( COMHANDLE,
lpByte,
2,
&bytesWritten,
NULL );
if (!retval)
{
return false;
}
// 50 millisecond wait for the board
Sleep( 50 );
// Byte command to send to the Universal Board
lpByte = &b;
// Send over the byte command
retval = WriteFile( COMHANDLE,
lpByte,
2,
&bytesWritten,
NULL );
if (!retval)
{
return false;
}
return true;
}
void ARCADE_SetupCommunications
(
void
)
{
LPCTSTR lpDef;
BOOL retval;
cvar_t *comport;
const char *comstring;
if ( lpDCB ) // Already setup
return;
disable_com = gi.cvar( "disablecom", "0", 0 );
if ( disable_com->value )
return;
comport = gi.cvar( "comport", "1", 0 );
if ( comport->value == 2 )
{
lpDef = "COM2: baud=9600 parity=N data=8 stop=1";
comstring = "COM2";
}
else
{
lpDef = "COM1: baud=9600 parity=N data=8 stop=1";
comstring = "COM1";
}
lpDCB = new DCB;
retval = BuildCommDCB( lpDef, lpDCB );
if ( !retval )
{
// An error occurred creating the device
ARCADE_ComError();
return;
}
if ( ( COMHANDLE = ( CreateFile( comstring,
GENERIC_WRITE,
0, // exclusive access
NULL, // no security attrs
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
) ) ) == (HANDLE) -1 )
{
gi.error( "Could not create COM I/O file\n");
}
else
{
PurgeComm( COMHANDLE, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR );
}
}
void ARCADE_CloseCommunications
(
void
)
{
CloseHandle( COMHANDLE );
free( lpDCB );
}
#endif

26
arcade_comm.h Normal file
View File

@ -0,0 +1,26 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/arcade_comm.h $
// $Revision:: 2 $
// $Author:: Aldie $
// $Date:: 12/14/98 5:55p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/arcade_comm.h $
//
// 2 12/14/98 5:55p Aldie
// First version of arcade communications
//
// DESCRIPTION:
// Arcade Communications Functions
#include "g_local.h"
void ARCADE_SetupCommunications( void );
void ARCADE_CloseCommunications( void );
qboolean ARCADE_ComWriteByte( byte b );

1164
archive.cpp Normal file

File diff suppressed because it is too large Load Diff

213
archive.h Normal file
View File

@ -0,0 +1,213 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/archive.h $
// $Revision:: 9 $
// $Author:: Jimdose $
// $Date:: 11/12/98 2:31a $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/archive.h $
//
// 9 11/12/98 2:31a Jimdose
// Added ReadFile. Archives now read from pak files
//
// 8 10/25/98 11:52p Jimdose
// added EXPORT_TEMPLATE
//
// 7 10/07/98 11:41p Jimdose
// Got savegames working!!!
// Rewrote event archiving
//
// 6 9/21/98 10:15p Markd
// Putting archiving and unarchiving functions in
//
// 5 9/21/98 4:21p Markd
// Put in archive functions and rewrote all archive routines
//
// 4 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 3 5/08/98 2:50p Jimdose
// Base archivable class is now Class instead of Listener
//
// 2 5/07/98 10:39p Jimdose
// created file
//
// 1 5/06/98 8:19p Jimdose
//
// DESCRIPTION:
// Class for archiving objects
//
#ifndef __ARCHIVE_H__
#define __ARCHIVE_H__
#include "g_local.h"
#include "str.h"
#define ARCHIVE_NULL_POINTER ( -654321 )
#define ARCHIVE_POINTER_VALID ( 0 )
#define ARCHIVE_POINTER_NULL ( ARCHIVE_NULL_POINTER )
#define ARCHIVE_POINTER_SELF_REFERENTIAL ( -123456 )
enum
{
pointer_fixup_normal,
pointer_fixup_safe
};
typedef struct
{
void **ptr;
int index;
int type;
} pointer_fixup_t;
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<Class *>;
template class EXPORT_FROM_DLL Container<pointer_fixup_t *>;
#endif
class EXPORT_FROM_DLL ReadFile : public Class
{
protected:
str filename;
size_t length;
byte *buffer;
byte *pos;
public:
CLASS_PROTOTYPE( ReadFile );
ReadFile();
~ReadFile();
void Close( void );
const char *Filename( void );
size_t Length( void );
size_t Pos( void );
qboolean Seek( size_t newpos );
qboolean Open( const char *name );
qboolean Read( void *dest, size_t size );
};
class EXPORT_FROM_DLL Archiver : public Class
{
private:
Container<Class *> classpointerList;
Container<pointer_fixup_t *> fixupList;
protected:
str filename;
qboolean fileerror;
FILE *file;
ReadFile readfile;
int archivemode;
int numclassespos;
void CheckRead( void );
void CheckType( int type );
int ReadType( void );
size_t ReadSize( void );
void CheckSize( int type, size_t size );
void ReadData( int type, void *data, size_t size );
void CheckWrite( void );
void WriteType( int type );
void WriteSize( size_t size );
void WriteData( int type, const void *data, size_t size );
public:
CLASS_PROTOTYPE( Archiver );
Archiver();
~Archiver();
void FileError( const char *fmt, ... );
void Close( void );
void Read( str &name );
void Read( const char *name );
//
// return methods
//
Vector ReadVector( void );
Quat ReadQuat( void );
int ReadInteger( void );
unsigned ReadUnsigned( void );
byte ReadByte( void );
char ReadChar( void );
short ReadShort( void );
unsigned short ReadUnsignedShort( void );
float ReadFloat( void );
double ReadDouble( void );
qboolean ReadBoolean( void );
str ReadString( void );
Event ReadEvent( void );
//
// ptr methods
//
void ReadVector( Vector * vec );
void ReadQuat( Quat * quat );
void ReadInteger( int * num );
void ReadUnsigned( unsigned * unum);
void ReadByte( byte * num );
void ReadChar( char * ch );
void ReadShort( short * num );
void ReadUnsignedShort( unsigned short * num );
void ReadFloat( float * num );
void ReadDouble( double * num );
void ReadBoolean( qboolean * bool );
void ReadString( str * string );
void ReadObjectPointer( Class ** ptr );
void ReadSafePointer( SafePtrBase * ptr );
void ReadEvent( Event * ev );
void ReadRaw( void *data, size_t size );
Class *ReadObject( void );
Class *ReadObject( Class *obj );
void Create( str &name );
void Create( const char *name );
void WriteVector( Vector &v );
void WriteQuat( Quat &quat );
void WriteInteger( int v );
void WriteUnsigned( unsigned v );
void WriteByte( byte v );
void WriteChar( char v );
void WriteShort( short v );
void WriteUnsignedShort( unsigned short v );
void WriteFloat( float v );
void WriteDouble( double v );
void WriteBoolean( qboolean v );
void WriteRaw( const void *data, size_t size );
void WriteString( str &string );
void WriteObject( Class *obj );
void WriteObjectPointer( Class * ptr );
void WriteSafePointer( Class * ptr );
void WriteEvent( Event &ev );
};
inline EXPORT_FROM_DLL void Archiver::Read
(
str &name
)
{
Read( name.c_str() );
}
inline EXPORT_FROM_DLL void Archiver::Create
(
str &name
)
{
Create( name.c_str() );
}
#endif /* archive.h */

212
areaportal.cpp Normal file
View File

@ -0,0 +1,212 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/areaportal.cpp $
// $Revision:: 8 $
// $Author:: Jimdose $
// $Date:: 10/19/98 6:08p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/areaportal.cpp $
//
// 8 10/19/98 6:08p Jimdose
// SetAreaPortals now cancels any waiting open or close portal events
//
// 7 8/28/98 7:14p Markd
// added world to trigger event
//
// 6 8/28/98 2:54p Markd
// Added Targets to AreaPortals
//
// 5 5/24/98 8:55p Jimdose
// Removed the char * cast from Q_stricmp call
//
// 4 5/20/98 11:11a Markd
// removed char * dependency
//
// 3 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 2 3/11/98 2:25p Jimdose
// Created file
//
// DESCRIPTION:
//
#include "g_local.h"
#include "entity.h"
#include "areaportal.h"
Event EV_AreaPortal_Open( "open" );
Event EV_AreaPortal_Close( "close" );
void SetAreaPortals
(
const char *name,
qboolean open
)
{
int t;
Entity *ent;
float time;
Event event;
if ( !name )
{
return;
}
// delay turning a portal off so that lerping models are in place when the portal goes off
if ( open )
{
time = 0;
event = EV_AreaPortal_Open;
}
else
{
time = FRAMETIME;
event = EV_AreaPortal_Close;
}
t = 0;
while( t = G_FindTarget( t, name ) )
{
ent = G_GetEntity( t );
assert( ent );
if ( Q_stricmp( ent->getClassID(), "func_areaportal" ) == 0 )
{
// Cancel any waiting portal events
ent->CancelEventsOfType( EV_AreaPortal_Open );
ent->CancelEventsOfType( EV_AreaPortal_Close );
ent->PostEvent( event, time );
}
}
}
/*****************************************************************************/
/*SINED func_areaportal (0 0 0) ?
This is a non-visible object that divides the world into
areas that are seperated when this portal is not activated.
Usually enclosed in the middle of a door.
/*****************************************************************************/
CLASS_DECLARATION( Entity, AreaPortal, "func_areaportal" );
ResponseDef AreaPortal::Responses[] =
{
{ &EV_AreaPortal_Open, ( Response )AreaPortal::Open },
{ &EV_AreaPortal_Close, ( Response )AreaPortal::Close },
{ NULL, NULL }
};
void AreaPortal::SetPortalState
(
qboolean state
)
{
portalstate = state;
gi.SetAreaPortalState( portalnum, portalstate );
}
qboolean AreaPortal::PortalOpen
(
void
)
{
return portalstate;
}
void AreaPortal::Open
(
Event *ev
)
{
const char *name;
SetPortalState( true );
//
// fire targets
//
name = Target();
if ( name && strcmp( name, "" ) )
{
int num;
Event *event;
Entity *ent;
num = 0;
do
{
num = G_FindTarget( num, name );
if ( !num )
{
break;
}
ent = G_GetEntity( num );
event = new Event( EV_Activate );
event->AddEntity( world );
ent->ProcessEvent( event );
}
while ( 1 );
}
}
void AreaPortal::Close
(
Event *ev
)
{
const char *name;
SetPortalState( false );
//
// fire targets
//
name = Target();
if ( name && strcmp( name, "" ) )
{
int num;
Event *event;
Entity *ent;
num = 0;
do
{
num = G_FindTarget( num, name );
if ( !num )
{
break;
}
ent = G_GetEntity( num );
event = new Event( EV_Activate );
event->AddEntity( world );
ent->ProcessEvent( event );
}
while ( 1 );
}
}
AreaPortal::AreaPortal()
{
portalnum = G_GetIntArg( "style" );
if ( !LoadingSavegame )
{
// always start closed, except during savegames
SetPortalState( false );
}
}

82
areaportal.h Normal file
View File

@ -0,0 +1,82 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/areaportal.h $
// $Revision:: 5 $
// $Author:: Markd $
// $Date:: 9/29/98 5:58p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/areaportal.h $
//
// 5 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 4 5/20/98 11:12a Markd
// removed char * dependency
//
// 3 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 2 3/11/98 2:25p Jimdose
// Created file
//
// DESCRIPTION:
//
#ifndef __AREAPORTAL_H__
#define __AREAPORTAL_H__
#include "g_local.h"
#include "entity.h"
extern Event EV_AreaPortal_Open;
extern Event EV_AreaPortal_Close;
void SetAreaPortals( const char *name, qboolean open );
class EXPORT_FROM_DLL AreaPortal : public Entity
{
private:
int portalstate;
int portalnum;
public:
CLASS_PROTOTYPE( AreaPortal );
AreaPortal();
void SetPortalState( qboolean state );
qboolean PortalOpen( void );
void Open( Event *ev );
void Close( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void AreaPortal::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteInteger( portalstate );
arc.WriteInteger( portalnum );
}
inline EXPORT_FROM_DLL void AreaPortal::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadInteger( &portalstate );
arc.ReadInteger( &portalnum );
}
#endif

202
armor.cpp Normal file
View File

@ -0,0 +1,202 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/armor.cpp $
// $Revision:: 21 $
// $Author:: Aldie $
// $Date:: 10/24/98 2:07p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/armor.cpp $
//
// 21 10/24/98 2:07p Aldie
// Mutants can't pickup armor
//
// 20 10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 19 10/09/98 2:05a Aldie
// Updated DMFLAGS
//
// 18 7/24/98 5:02p Aldie
// Armor never adds, only replaces
//
// 17 7/24/98 3:46p Aldie
// dmflags - armor
//
// 16 7/11/98 5:55p Aldie
// Fix pickup for armor
//
// 15 6/30/98 6:47p Aldie
// If no amount in armor, then you can't pick it up.
//
// 14 6/28/98 4:13p Markd
// simplified setup
//
// 13 6/25/98 8:58p Markd
// made Pickupable comparison check for >=
//
// 12 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 11 6/25/98 7:31p Aldie
// Changed the icon names
//
// 10 6/24/98 1:35p Aldie
// Implementation of inventory system and picking stuff up
//
// 9 6/17/98 1:19a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 8 6/15/98 3:35p Aldie
// Updated picking up of armor to have a maxout value
//
// 7 6/05/98 6:22p Aldie
//
// 6 6/05/98 2:45p Aldie
// New version of armor
//
// 4 11/07/97 5:59p Markd
// Removed QUAKE specific sound effects
//
// 3 10/27/97 3:30p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 5:30p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Standard armor that prevents a percentage of damage per hit.
//
#include "g_local.h"
#include "armor.h"
/*
========
ARMOR
========
*/
CLASS_DECLARATION( Item, Armor, NULL )
ResponseDef Armor::Responses[] =
{
{ NULL, NULL }
};
Armor::Armor
(
)
{
if ( DM_FLAG( DF_NO_ARMOR ) )
{
PostEvent( EV_Remove, 0 );
return;
}
Set( 0 );
}
void Armor::Setup
(
const char *model,
int amount
)
{
assert( model );
setModel( model );
Set( amount );
}
void Armor::Add
(
int num
)
{
// Armor never adds, it only replaces
amount = num;
if ( amount >= MaxAmount() )
amount = MaxAmount();
}
qboolean Armor::Pickupable
(
Entity *other
)
{
if ( !other->isSubclassOf( Sentient ) )
{
return false;
}
else
{
Sentient * sent;
Item * item;
sent = ( Sentient * )other;
// Mutants don't get armor
if ( sent->flags & ( FL_MUTANT | FL_SP_MUTANT ) )
{
return false;
}
item = sent->FindItem( getClassname() );
// If our armor is > than our current armor or armor has no value, then leave it alone.
if ( item )
if ( ( item->Amount() >= this->Amount() ) || !this->Amount() )
{
return false;
}
}
return true;
}
CLASS_DECLARATION( Armor, RiotHelmet, "armor_riothelmet" );
ResponseDef RiotHelmet::Responses[] =
{
{ NULL, NULL }
};
RiotHelmet::RiotHelmet()
{
Setup( "riothelm.def", MAX_ARMOR );
}
CLASS_DECLARATION( Armor, FlakJacket, "armor_flakjacket" );
ResponseDef FlakJacket::Responses[] =
{
{ NULL, NULL }
};
FlakJacket::FlakJacket()
{
Setup( "flakjack.def", MAX_ARMOR );
}
CLASS_DECLARATION( Armor, FlakPants, "armor_flakpants" );
ResponseDef FlakPants::Responses[] =
{
{ NULL, NULL }
};
FlakPants::FlakPants()
{
Setup( "flakpants.def", MAX_ARMOR );
}

87
armor.h Normal file
View File

@ -0,0 +1,87 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/armor.h $
// $Revision:: 11 $
// $Author:: Aldie $
// $Date:: 7/24/98 5:03p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/armor.h $
//
// 11 7/24/98 5:03p Aldie
// Armor never adds, only replaces
//
// 10 6/28/98 4:13p Markd
// simplified setup
//
// 9 6/25/98 8:48p Markd
// Rewrote Item class, added keyed items to triggers, cleaned up item system
//
// 8 6/24/98 1:38p Aldie
// Implementation of inventory system and picking stuff up
//
// 7 6/17/98 1:16a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 6 6/15/98 3:36p Aldie
// Updated armor for maxout values
//
// 5 6/05/98 2:45p Aldie
// New version of armor
//
// 3 10/27/97 2:48p Jimdose
//
// 2 9/26/97 5:30p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Standard armor that prevents a percentage of damage per hit.
//
#ifndef __ARMOR_H__
#define __ARMOR_H__
#include "item.h"
#define MAX_ARMOR 100
class EXPORT_FROM_DLL Armor : public Item
{
protected:
virtual void Setup( const char *model, int amount );
virtual void Add( int amount );
public:
CLASS_PROTOTYPE( Armor );
Armor( );
virtual qboolean Pickupable( Entity *other );
};
class EXPORT_FROM_DLL RiotHelmet : public Armor
{
public:
CLASS_PROTOTYPE( RiotHelmet );
RiotHelmet();
};
class EXPORT_FROM_DLL FlakJacket : public Armor
{
public:
CLASS_PROTOTYPE( FlakJacket );
FlakJacket();
};
class EXPORT_FROM_DLL FlakPants : public Armor
{
public:
CLASS_PROTOTYPE( FlakPants );
FlakPants();
};
#endif /* armor.h */

151
assaultrifle.cpp Normal file
View File

@ -0,0 +1,151 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/assaultrifle.cpp $
// $Revision:: 33 $
// $Author:: Markd $
// $Date:: 11/15/98 9:12p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/assaultrifle.cpp $
//
// 33 11/15/98 9:12p Markd
// Put in more precaching for models and sprites
//
// 32 11/13/98 3:30p Markd
// put in more precaching on weapons
//
// 31 10/05/98 10:18p Aldie
// Covnverted over to new silencer methods
//
// 30 8/29/98 5:26p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 29 8/19/98 6:37p Markd
// Moved Assault rifle tracer into def file
//
// 28 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and
// rocket jumping.
//
// 27 8/04/98 11:57a Aldie
// Increased spread
//
// 26 8/01/98 3:24p Aldie
// Added server effects flag for specific weapons
//
// 25 8/01/98 3:03p Aldie
// Client side muzzle flash (dynamic light)
//
// 24 7/26/98 4:06p Aldie
//
// 23 7/26/98 3:59p Aldie
// Less muzzleflashes
//
// 22 7/22/98 10:40p Aldie
// Fixed tracers
//
// 21 7/22/98 9:57p Markd
// Defined weapon type
//
// 20 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 19 7/12/98 5:48p Jimdose
// changed timing on tracers to once every 5 frames
//
// 18 7/12/98 5:37p Jimdose
// Recoded the tracer fire based on framenum. Frametime was being used as if
// it had millisecond precision.
//
// 17 6/19/98 9:29p Jimdose
// Moved gun orientation code to Weapon
//
// 16 6/18/98 3:56p Aldie
// Made a tracer for the assaultrifle.
//
// 15 6/15/98 9:08p Aldie
// Added SilencedBullet class for silencers
//
// 14 6/10/98 2:10p Aldie
// Updated damage function.
//
// 13 6/08/98 7:21p Aldie
// Updated attack time
//
// 12 4/20/98 1:56p Markd
// SINED decelration is now in def file
//
// 11 4/18/98 3:08p Markd
// Changed view weapon naming convention
//
// 10 4/09/98 3:29p Jimdose
// Removed sound from shoot since anim plays it
//
// 9 4/07/98 6:42p Jimdose
// Rewrote weapon code.
// Added order to rank
//
// 8 4/05/98 2:58a Jimdose
// changed attack time (again)
//
// 7 4/04/98 6:01p Jimdose
// Changed attack time
//
// 6 4/02/98 4:20p Jimdose
// Tweaked for DM
//
// 5 3/30/98 9:54p Jimdose
// Changed location of .def files
//
// 4 3/30/98 2:34p Jimdose
// Moved firing to BulletWeapon to make more general
// Added Ammo
// Added world models
//
// 3 3/27/98 11:04p Jimdose
// added muzzle flash
//
// 2 3/27/98 6:34p Jimdose
// created file
//
// DESCRIPTION:
// Assault rifle
//
#include "g_local.h"
#include "assaultrifle.h"
CLASS_DECLARATION( BulletWeapon, AssaultRifle, "weapon_assaultrifle" );
ResponseDef AssaultRifle::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )AssaultRifle::Shoot },
{ NULL, NULL }
};
AssaultRifle::AssaultRifle()
{
SetModels( "asrifle.def", "view_asrifle.def" );
SetAmmo( "Bullet10mm", 1, 30 );
SetRank( 40, 40 );
SetType( WEAPON_2HANDED_LO );
modelIndex( "10mm.def" );
modelIndex( "sprites/gunblast.spr" );
modelIndex( "shell.def" );
silenced = true;
}
void AssaultRifle::Shoot
(
Event *ev
)
{
FireBullets( 1, "120 120 120", 8, 14, DAMAGE_BULLET, MOD_ASSRIFLE, false );
NextAttack( 0 );
}

55
assaultrifle.h Normal file
View File

@ -0,0 +1,55 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/assaultrifle.h $
// $Revision:: 7 $
// $Author:: Aldie $
// $Date:: 10/05/98 10:38p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/assaultrifle.h $
//
// 7 10/05/98 10:38p Aldie
// Converted over to new silencer methods
//
// 6 7/22/98 10:41p Aldie
// Fixed tracers
//
// 5 6/18/98 3:57p Aldie
// Made a fire tracer function.
//
// 4 6/15/98 9:11p Aldie
// Added SilencedBullet calss for silencer
//
// 3 3/30/98 2:35p Jimdose
// Changed from subclass of Magnum to subclass of BulletWeapon
//
// 2 3/27/98 6:36p Jimdose
// Created file
//
// DESCRIPTION:
// Assault rifle
//
#ifndef __ASSAULTRIFLE_H__
#define __ASSAULTRIFLE_H__
#include "g_local.h"
#include "item.h"
#include "weapon.h"
#include "bullet.h"
class EXPORT_FROM_DLL AssaultRifle : public BulletWeapon
{
public:
CLASS_PROTOTYPE( AssaultRifle );
AssaultRifle::AssaultRifle();
virtual void Shoot( Event *ev );
};
#endif /* assaultrifle.h */

76
bacrodai.cpp Normal file
View File

@ -0,0 +1,76 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bacrodai.cpp $
// $Revision:: 3 $
// $Author:: Markd $
// $Date:: 10/22/98 7:57p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bacrodai.cpp $
//
// 3 10/22/98 7:57p Markd
// put in proper pre-caching in all the classes
//
// 2 10/20/98 3:25a Markd
// first time
//
// 1 10/20/98 3:10a Markd
//
// DESCRIPTION:
// Bacrodai
//
#include "g_local.h"
#include "actor.h"
#include "bacrodai.h"
CLASS_DECLARATION( Actor, Bacrodai, "monster_bachrodai" );
Event EV_Bacrodai_SpawnBat( "spawnbat" );
ResponseDef Bacrodai::Responses[] =
{
{ &EV_Bacrodai_SpawnBat, ( Response )Bacrodai::SpawnBat },
{ NULL, NULL }
};
Bacrodai::Bacrodai()
{
setModel( "bacrodai.def" );
modelIndex( "bat.def" );
}
void Bacrodai::SpawnBat
(
Event *ev
)
{
Actor * ent;
str text;
Vector pos;
if ( !currentEnemy )
return;
pos = centroid - ( Vector( orientation[ 0 ] ) * 48 );
// create a new entity
G_InitSpawnArguments();
G_SetSpawnArg( "model", "bat.def" );
text = va( "%f %f %f", pos[ 0 ], pos[ 1 ], pos[ 2 ] );
G_SetSpawnArg( "origin", text.c_str() );
ent = new Actor;
G_InitSpawnArguments();
ent->MakeEnemy( currentEnemy, true );
}

40
bacrodai.h Normal file
View File

@ -0,0 +1,40 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bacrodai.h $
// $Revision:: 2 $
// $Author:: Markd $
// $Date:: 10/20/98 3:25a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bacrodai.h $
//
// 2 10/20/98 3:25a Markd
// first time
//
// 1 10/20/98 3:10a Markd
//
// DESCRIPTION:
// Bacrodai
//
#ifndef __BACRODAI_H__
#define __BACRODAI_H__
#include "g_local.h"
#include "actor.h"
class EXPORT_FROM_DLL Bacrodai : public Actor
{
public:
CLASS_PROTOTYPE( Bacrodai );
Bacrodai::Bacrodai();
virtual void SpawnBat( Event *ev );
};
#endif /* assaultrifle.h */

5186
behavior.cpp Normal file

File diff suppressed because it is too large Load Diff

1721
behavior.h Normal file

File diff suppressed because it is too large Load Diff

396
bouncingbetty.cpp Normal file
View File

@ -0,0 +1,396 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bouncingbetty.cpp $
// $Revision:: 24 $
// $Author:: Jimdose $
// $Date:: 11/12/98 11:30p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bouncingbetty.cpp $
//
// 24 11/12/98 11:30p Jimdose
// changed impact_bodyimpact to impact_goryimpact
//
// 23 10/26/98 2:17p Aldie
// Upped the damage
//
// 22 10/24/98 12:50a Aldie
// Made betty launcher take damage
//
// 21 10/22/98 7:57p Markd
// put in proper pre-caching in all the classes
//
// 20 10/07/98 8:04p Aldie
// Move bubbles to client
//
// 19 9/01/98 3:05p Markd
// Rewrote explosion code
//
// 18 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 17 8/18/98 11:08p Markd
// Added new Alias System
//
// 16 7/23/98 6:17p Aldie
// Updated damage system and fixed some damage related bugs. Also put tracers
// back to the way they were, and added gib event to funcscriptmodels
//
// 15 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 14 7/09/98 12:09a Jimdose
// explode no longer scales the explosion (explosion creates a temp entity now)
//
// 13 6/10/98 2:10p Aldie
// Updated damage function.
//
// 12 5/11/98 2:19p Markd
// Fixed randomsound stuff
//
// 11 5/03/98 4:30p Jimdose
// Changed Vector class. No longer includes PointsTo
//
// 10 4/18/98 5:45p Markd
// Removed SINED calls, because they are now in DEF file format
//
// 9 4/10/98 4:54p Jimdose
// made bubbles work
//
// 8 4/10/98 2:36a Jimdose
// Works with Q2
//
// 7 4/08/98 4:22p Jimdose
// Getting ready to conver to Q2
//
// 5 12/15/97 3:33p Jimdose
// BettyLauncher first switches to the betty model before going to the iris
// model in order to precache the sounds that the betty model uses.
//
// 4 12/15/97 1:34a Jimdose
// Increased splash damage from betty exploding
//
// 3 12/14/97 5:48p Jimdose
// Finished basic behaviour code
//
// 2 12/13/97 4:43p Jimdose
// Created file
//
// DESCRIPTION:
//
#include "g_local.h"
#include "bouncingbetty.h"
#include "explosion.h"
#include "specialfx.h"
Event EV_Betty_CheckVicinity( "checkvicinity" );
Event EV_Betty_Launch( "launch" );
Event EV_Betty_AttackFinished( "attack_finished" );
Event EV_Betty_Fire( "fire" );
Event EV_Betty_Detonate( "detonate" );
Event EV_Betty_Explode( "explode" );
Event EV_BettySpike_Bubbles( "bubble" );
CLASS_DECLARATION( Entity, BettyLauncher, "trap_bouncingbetty" );
ResponseDef BettyLauncher::Responses[] =
{
{ &EV_Betty_CheckVicinity, ( Response )BettyLauncher::CheckVicinity },
{ &EV_Activate, ( Response )BettyLauncher::Launch },
{ &EV_Betty_Launch, ( Response )BettyLauncher::Launch },
{ &EV_Betty_AttackFinished, ( Response )BettyLauncher::AttackFinished },
{ &EV_Betty_Fire, ( Response )BettyLauncher::ReleaseBetty },
{ &EV_Killed, ( Response )BettyLauncher::Killed },
{ NULL, NULL }
};
BettyLauncher::BettyLauncher
(
)
{
setModel( "iris.def" );
modelIndex( "betty.def" );
modelIndex( "bettyspike.def" );
RandomAnimate( "idle", NULL );
setSize( "-16 -16 0", "16 16 2" );
setMoveType( MOVETYPE_NONE );
setSolidType( SOLID_BBOX );
health = G_GetFloatArg( "health", 200 );
takedamage = DAMAGE_YES;
flags |= FL_SPARKS;
firing = false;
activator = 0;
if ( !Targeted() )
{
PostEvent( EV_Betty_CheckVicinity, 0.3f );
}
}
void BettyLauncher::Killed
(
Event *ev
)
{
takedamage = DAMAGE_NO;
CreateExplosion( worldorigin, 30, 0.5, true, this, this, this );
PostEvent( EV_Remove, 0 );
}
qboolean BettyLauncher::inRange
(
Entity *ent
)
{
Vector delta;
float dist;
delta = worldorigin - ent->worldorigin;
dist = delta.length();
if ( dist > BOUNCINGBETTY_RANGE )
{
return false;
}
return true;
}
void BettyLauncher::CheckVicinity
(
Event *ev
)
{
Entity *ent;
edict_t *ed;
int i;
Event *e;
if ( firing )
{
return;
}
for( i = 0; i < game.maxclients; i++ )
{
ed = &g_edicts[ 1 + i ];
if ( !ed->inuse || !ed->entity )
{
continue;
}
ent = ed->entity;
if ( ( ent->health < 0 ) || ( ent->flags & FL_NOTARGET ) )
{
continue;
}
if ( inRange( ent ) )
{
e = new Event( EV_Betty_Launch );
e->AddEntity( ent );
ProcessEvent( e );
// wait a couple seconds before checking again
PostEvent( EV_Betty_CheckVicinity, 2 );
return;
}
}
PostEvent( EV_Betty_CheckVicinity, 0.3f );
}
void BettyLauncher::Launch
(
Event *ev
)
{
if ( !firing )
{
firing = true;
activator = ( int )ev->GetEntity( 1 )->entnum;
RandomAnimate( "open", NULL );
}
}
void BettyLauncher::AttackFinished
(
Event *ev
)
{
firing = false;
}
void BettyLauncher::ReleaseBetty
(
Event *ev
)
{
BouncingBetty *betty;
betty = new BouncingBetty;
betty->Launch( worldorigin, activator );
activator = 0;
}
CLASS_DECLARATION( Entity, BouncingBetty, NULL );
ResponseDef BouncingBetty::Responses[] =
{
{ &EV_Betty_Detonate, ( Response )BouncingBetty::Detonate },
{ &EV_Betty_Explode, ( Response )BouncingBetty::Explode },
{ NULL, NULL }
};
BouncingBetty::BouncingBetty()
{
setModel( "betty.def" );
setSize( "-4 -4 0", "4 4 8" );
setMoveType( MOVETYPE_BOUNCE );
setSolidType( SOLID_BBOX );
activator = 0;
}
void BouncingBetty::Launch
(
Vector pos,
int activatorEnt
)
{
activator = activatorEnt;
setOrigin( pos );
worldorigin.copyTo( edict->s.old_origin );
velocity = "0 0 400";
avelocity = "0 180 0";
watertype = gi.pointcontents( worldorigin.vec3() );
RandomAnimate( "detonate", NULL );
}
void BouncingBetty::Detonate
(
Event *ev
)
{
RandomAnimate( "detonate", NULL );
}
void BouncingBetty::Explode
(
Event *ev
)
{
BettySpike *spike;
Entity *ent;
Vector vec;
Vector v;
int i;
float r;
ent = G_GetEntity( activator );
CreateExplosion( worldorigin, 150, 1.0f, true, this, ent, this );
vec = Vector( 25, 0, 0 );
r = G_Random( 360 );
for( i = 0; i < 12; i++ )
{
vec[ 1 ] = r;
vec.AngleVectors( &v, NULL, NULL );
spike = new BettySpike;
spike->Setup( worldorigin + v * 8, v );
r += 360.0 / 12.0;
}
PostEvent( EV_Remove, 0 );
}
CLASS_DECLARATION( Entity, BettySpike, NULL );
ResponseDef BettySpike::Responses[] =
{
{ &EV_Touch, ( Response )BettySpike::SpikeTouch },
{ NULL, NULL }
};
EXPORT_FROM_DLL void BettySpike::SpikeTouch
(
Event *ev
)
{
Entity *other;
int kick = 10;
if ( HitSky() )
{
PostEvent( EV_Remove, 0 );
return;
}
other = ev->GetEntity( 1 );
assert( other );
if ( other->health )
{
other->Damage( this, this, 10, worldorigin, velocity, level.impact_trace.plane.normal, kick, 0, MOD_BETTYSPIKE, -1, -1, 1.0f);
RandomGlobalSound( "impact_goryimpact", 1 );
}
else
{
RandomGlobalSound( "impact_bulletcase", 0.3 );
}
PostEvent( EV_Remove, 0 );
}
EXPORT_FROM_DLL void BettySpike::Setup
(
Vector pos,
Vector dir
)
{
setModel( "bettyspike.def" );
setMoveType( MOVETYPE_FLYMISSILE );
setSolidType( SOLID_BBOX );
setSize( "0 0 0", "0 0 0" );
setOrigin( pos );
worldorigin.copyTo( edict->s.old_origin );
watertype = gi.pointcontents( worldorigin.vec3() );
// set missile speed
velocity = dir;
velocity.normalize();
velocity *= 500 + G_CRandom( 100 );
angles = dir.toAngles();
angles[ PITCH ] = - angles[ PITCH ];
setAngles( angles );
PostEvent( EV_Remove, 5 );
}

163
bouncingbetty.h Normal file
View File

@ -0,0 +1,163 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bouncingbetty.h $
// $Revision:: 10 $
// $Author:: Aldie $
// $Date:: 10/24/98 12:52a $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bouncingbetty.h $
//
// 10 10/24/98 12:52a Aldie
// Added killed event
//
// 9 10/07/98 8:04p Aldie
// Move bubbles to client
//
// 8 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 7 4/10/98 2:36a Jimdose
// Works with Q2
//
// 6 4/08/98 4:22p Jimdose
// Getting ready to conver to Q2
//
// 4 12/15/97 1:34a Jimdose
// Increased the detection range for the betty
//
// 3 12/14/97 5:48p Jimdose
// Finished basic behaviour code
//
// 2 12/13/97 4:43p Jimdose
// Created file
//
// DESCRIPTION:
//
#ifndef __BOUNCINGBETTY_H__
#define __BOUNCINGBETTY_H__
#include "g_local.h"
#include "entity.h"
#define BOUNCINGBETTY_RANGE 192
class EXPORT_FROM_DLL BettyLauncher : public Entity
{
protected:
qboolean firing;
int activator;
public:
CLASS_PROTOTYPE( BettyLauncher );
BettyLauncher();
qboolean inRange( Entity *ent );
void CheckVicinity( Event *ev );
void Launch( Event *ev );
void AttackFinished( Event *ev );
void ReleaseBetty( Event *ev );
void Killed( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void BettyLauncher::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteBoolean( firing );
arc.WriteInteger( activator );
}
inline EXPORT_FROM_DLL void BettyLauncher::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadBoolean( &firing );
arc.ReadInteger( &activator );
}
class EXPORT_FROM_DLL BouncingBetty : public Entity
{
protected:
int activator;
public:
CLASS_PROTOTYPE( BouncingBetty );
BouncingBetty();
void Launch( Vector pos, int activatorEnt );
void Detonate( Event *ev );
void Explode( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void BouncingBetty::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteInteger( activator );
}
inline EXPORT_FROM_DLL void BouncingBetty::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadInteger( &activator );
}
class EXPORT_FROM_DLL BettySpike : public Entity
{
protected:
int activator;
public:
CLASS_PROTOTYPE( BettySpike );
void SpikeTouch( Event *ev );
void Setup( Vector pos, Vector dir );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void BettySpike::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteInteger( activator );
}
inline EXPORT_FROM_DLL void BettySpike::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadInteger( &activator );
}
#endif /* bouncingbetty.h */

410
box.cpp Normal file
View File

@ -0,0 +1,410 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/box.cpp $
// $Revision:: 36 $
// $Author:: Markd $
// $Date:: 11/15/98 7:51p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/box.cpp $
//
// 36 11/15/98 7:51p Markd
// fixed boxes so that they wouldn't be case as Item's
//
// 35 11/13/98 2:41p Markd
// fixed box precaching
//
// 34 11/09/98 12:13a Aldie
// Do a modelindex on stuff in boxes
//
// 33 10/26/98 12:28a Markd
// Put in no jc support
//
// 32 10/25/98 2:38a Markd
// put in dialog time in box code
//
// 31 10/25/98 12:47a Markd
// fixed mutant flag for dialog
//
// 30 10/25/98 12:24a Markd
// Put in sounds when blade blows up boxes
//
// 29 10/19/98 12:10a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 28 10/17/98 7:35p Jimdose
// Changed G_CallSpawn to G_CallSpawn2
//
// 27 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 26 8/18/98 11:08p Markd
// Added new Alias System
//
// 25 8/18/98 5:50p Aldie
// Added target activation to box killed function
//
// 24 8/12/98 3:18p Aldie
//
// 23 8/09/98 6:10p Aldie
// New box behavior
//
// 22 8/08/98 9:02p Aldie
// Removed unused var
//
// 21 8/08/98 8:22p Markd
// Took out random items from box code
//
// 20 7/14/98 6:56p Aldie
// Updated healths
//
// 19 6/24/98 12:39p Markd
// Added default tesselation percentage
//
// 18 6/18/98 5:41p Markd
// Fixed crash with boxes
//
// 17 6/18/98 2:00p Markd
// rewrote tesselation code
//
// 16 6/10/98 1:19p Markd
// Removed 357 bullets
//
// 15 5/27/98 9:04p Markd
// weighted boxes with more ammo
//
// 14 5/27/98 8:34p Markd
// Put more health in boxes
//
// 13 5/27/98 5:01a Markd
// Put in dynamic spawning of goodies when box is destroyed
//
// 12 5/25/98 7:51p Jimdose
// Made TellNeighborsToFall use G_NextEntity to check all entities
//
// 11 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 10 5/24/98 1:03a Jimdose
// Added breaking sound event when killed
//
// 9 5/11/98 3:51p Markd
// Changed crate blowup sound
//
// 8 5/01/98 11:09a Markd
// Added sound to tesselation event
//
// 7 4/14/98 6:55p Markd
// Added thickness to tesselation
//
// 6 4/08/98 4:19p Jimdose
// Converted to Q2
//
// 4 10/31/97 7:18p Markd
// Changed triagulate call and added a hidemodel call when blowing up
//
// 3 10/31/97 4:32p Markd
// Added shatter sound and also fixed a swapped MOVETYPE/SOLIDTYPE bug
//
// 2 10/30/97 7:42p Jimdose
// Created file
//
// DESCRIPTION:
// Explodable box that falls when boxes below it are destroyed.
//
#include "g_local.h"
#include "entity.h"
#include "box.h"
#include "ammo.h"
#include "health.h"
#include "specialfx.h"
Event EV_Box_Think( "think" );
ResponseDef Box::Responses[] =
{
{ &EV_Box_Think, ( Response )Box::Falling },
{ &EV_Killed, ( Response )Box::Killed },
{ NULL, NULL }
};
/*****************************************************************************/
/*SINED func_box (0 .5 .8) ?
Explodable box that falls when boxes below it are destroyed.
"items" - List of classnames to spawn when the box is destroyed. Separate
each classname by spaces (E.g. Adrenaline RocketLauncher). Default is NULL.
"angles" - Orientation of the item that is spawned.
"health" - Health of the box ( default is 60 )
/*****************************************************************************/
CLASS_DECLARATION( Entity, Box, "func_box" );
EXPORT_FROM_DLL void Box::StartFalling
(
void
)
{
movetime = 0;
velocity += "0 0 100";
setMoveType( MOVETYPE_TOSS );
setSolidType( SOLID_BBOX );
setOrigin( worldorigin + Vector( 0, 0, 1 ) );
PostEvent( EV_Box_Think, FRAMETIME );
}
EXPORT_FROM_DLL void Box::Falling
(
Event *ev
)
{
if ( velocity != vec_zero )
{
movetime = level.time + 1;
}
if ( movetime < level.time )
{
setMoveType( MOVETYPE_PUSH );
setSolidType( SOLID_BSP );
}
else
{
PostEvent( EV_Box_Think, FRAMETIME );
}
}
void Box::TellNeighborsToFall
(
void
)
{
Entity *ent;
//Event *e;
Vector min;
Vector max;
Entity *next;
min = absmin + Vector( 6, 6, 6 );
max = absmax + Vector( -6, -6, 0 );
for( ent = G_NextEntity( world ); ent != NULL; ent = next )
{
next = G_NextEntity( ent );
if ( ( ent != this ) && ent->isSubclassOf( Box ) )
{
if ( !( ( ent->absmax[ 0 ] < min[ 0 ] ) ||
( ent->absmax[ 1 ] < min[ 1 ] ) ||
( ent->absmax[ 2 ] < min[ 2 ] ) ||
( ent->absmin[ 0 ] > max[ 0 ] ) ||
( ent->absmin[ 1 ] > max[ 1 ] ) ||
( ent->absmin[ 2 ] > max[ 2 ] ) ) )
{
if ( ent->takedamage != DAMAGE_NO )
( ( Box * )ent )->StartFalling();
// Ok, it's a hack.
//if ( ent->takedamage != DAMAGE_NO )
// {
// e = new Event( ev );
// ent->ProcessEvent( e );
// }
}
}
}
}
void Box::Killed
(
Event *ev
)
{
Entity *attacker;
Vector dir;
Vector org;
Entity *ent;
const char *s;
const char *token;
int width = 0;
int depth = 0;
int boxwidth;
char temp[ 128 ];
const char *name;
int num;
Event *event;
qboolean spawned;
static float last_dialog_time = 0;
hideModel();
RandomGlobalSound( "impact_crateexplo", 1, CHAN_BODY, ATTN_NORM );
takedamage = DAMAGE_NO;
TellNeighborsToFall();
ProcessEvent( EV_BreakingSound );
attacker = ev->GetEntity( 1 );
dir = worldorigin - attacker->worldorigin;
TesselateModel
(
this,
tess_min_size,
tess_max_size,
dir,
ev->GetInteger( 2 ),
tess_percentage,
tess_thickness,
vec3_origin
);
//
// fire off targets
//
name = Target();
if ( name && strcmp( name, "" ) )
{
num = 0;
do
{
num = G_FindTarget( num, name );
if ( !num )
{
break;
}
ent = G_GetEntity( num );
event = new Event( EV_Activate );
event->AddEntity( attacker );
ent->PostEvent( event, 0 );
}
while ( 1 );
}
// items holds the list of def files to spawn
s = items.c_str();
G_InitSpawnArguments();
if ( setangles )
{
sprintf( temp, "%f %f %f", angles[ 0 ],angles[ 1 ],angles[ 2 ] );
G_SetSpawnArg( "angles", temp );
}
spawned = false;
boxwidth = maxs[0];
while (1)
{
token = COM_Parse(&s);
if (!token[0])
break;
G_SetSpawnArg( "model", token );
if ( ( width * 32 ) > boxwidth )
{
width = 0;
depth++;
}
// Calculate and set the origin
org = worldorigin + Vector("0 0 32") + Vector("32 0 0") * width + Vector("0 32 0") * depth;
width++;
sprintf( temp, "%f %f %f", org[ 0 ], org[ 1 ], org[ 2 ] );
G_SetSpawnArg( "origin", temp );
// Create the item
ent = ( Entity * )G_CallSpawn();
spawned = true;
// Postpone the Drop because the box is still there.
ent->PostponeEvent( EV_Item_DropToFloor, 0.1f );
}
G_InitSpawnArguments();
if (
spawned &&
attacker->isClient() &&
( last_dialog_time < level.time ) &&
( !( attacker->flags & FL_SP_MUTANT ) ) &&
( !deathmatch->value )
)
{
char name[ 128 ];
int num;
last_dialog_time = level.time + 25;
if ( level.no_jc )
{
num = (int)G_Random( 3 ) + 1;
}
else
{
num = (int)G_Random( 5 ) + 1;
}
sprintf( name, "global/universal_script.scr::blade_finds_item%d", num );
ExecuteThread( name, true );
}
PostEvent( EV_Remove, 0 );
}
Box::Box()
{
const char *text;
const char *s;
char token[ MAX_TOKEN_CHARS ];
movetime = 0;
showModel();
setMoveType( MOVETYPE_PUSH );
setSolidType( SOLID_BSP );
setOrigin( origin );
health = G_GetIntArg( "health", 60 );
max_health = health;
takedamage = DAMAGE_YES;
tess_thickness = 20;
text = G_GetSpawnArg( "items" );
if ( text )
{
items = text;
s = items.c_str();
while ( 1 )
{
strcpy( token, COM_Parse(&s) );
if ( !token[0] )
break;
modelIndex( token );
}
}
setangles = ( G_GetSpawnArg( "angle" ) || G_GetSpawnArg( "angles" ) );
if ( setangles )
{
float angle;
angle = G_GetFloatArg( "angle", 0 );
angles = G_GetVectorArg( "angles", Vector( 0, angle, 0 ) );
}
}

81
box.h Normal file
View File

@ -0,0 +1,81 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/box.h $
// $Revision:: 6 $
// $Author:: Markd $
// $Date:: 9/29/98 5:58p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/box.h $
//
// 6 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 5 8/09/98 6:11p Aldie
// New box behavior
//
// 4 4/08/98 4:19p Jimdose
// Converted to Q2
//
// 2 10/30/97 7:42p Jimdose
// Created file
//
// DESCRIPTION:
// Explodable box that falls when boxes below it are destroyed.
//
#ifndef __BOX_H__
#define __BOX_H__
#include "g_local.h"
#include "entity.h"
class EXPORT_FROM_DLL Box : public Entity
{
private:
float movetime;
str items;
qboolean setangles;
public:
CLASS_PROTOTYPE( Box );
Box();
void StartFalling( void );
void Falling( Event *ev );
void TellNeighborsToFall( void );
virtual void Killed( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Box::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteFloat( movetime );
arc.WriteString( items );
arc.WriteBoolean( setangles );
}
inline EXPORT_FROM_DLL void Box::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadFloat( &movetime );
arc.ReadString( &items );
arc.ReadBoolean( &setangles );
}
#endif /* box.h */

677
bspline.cpp Normal file
View File

@ -0,0 +1,677 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bspline.cpp $
// $Revision:: 12 $
// $Author:: Jimdose $
// $Date:: 10/19/98 9:51p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bspline.cpp $
//
// 12 10/19/98 9:51p Jimdose
// fixed savegame bugs with bspline
//
// 11 10/10/98 9:12p Markd
// Fixed angle errors with bsplines
//
// 10 8/15/98 2:39p Markd
// fixed up some bspline stuff
//
// 9 7/11/98 6:31p Markd
// removed valid orientation, simplified code
//
// 8 7/10/98 1:11p Markd
// Added additional two paramter append control point
//
// 7 7/08/98 12:41p Markd
// Added speed and quaternion support
//
// 6 7/02/98 9:48p Markd
// added orientation
//
// 5 5/26/98 7:55p Jimdose
// Added Drawcurve with offset
//
// 4 5/07/98 10:40p Jimdose
// Added spline type for selecting between looping and non-looping curves
//
// 3 5/05/98 2:37p Jimdose
// Added code to allow spline loop and clamping the spline start and end
//
// 2 5/03/98 4:42p Jimdose
// Added file to Sin
//
// DESCRIPTION:
// Uniform non-rational bspline class.
//
#include "g_local.h"
#include "BSpline.h"
void BSpline::Set
(
Vector *control_points_,
int num_control_points_,
splinetype_t type
)
{
int i;
SetType( type );
has_orientation = false;
if ( control_points )
{
delete [] control_points;
control_points = NULL;
}
num_control_points = num_control_points_;
if ( num_control_points )
{
control_points = new BSplineControlPoint[ num_control_points ];
assert( control_points );
for( i = 0; i < num_control_points; i++ )
{
control_points[ i ].Set( control_points_[ i ] );
}
}
}
void BSpline::Set
(
Vector *control_points_,
Vector *control_orients_,
float *control_speeds_,
int num_control_points_,
splinetype_t type
)
{
int i;
SetType( type );
has_orientation = true;
if ( control_points )
{
delete [] control_points;
control_points = NULL;
}
num_control_points = num_control_points_;
if ( num_control_points )
{
control_points = new BSplineControlPoint[ num_control_points ];
assert( control_points );
for( i = 0; i < num_control_points; i++ )
{
control_points[ i ].Set( control_points_[ i ], control_orients_[ i ], control_speeds_[ i ] );
}
}
}
void BSpline::Clear
(
void
)
{
if( control_points )
{
delete [] control_points;
control_points = NULL;
}
num_control_points = 0;
has_orientation = false;
}
inline float BSpline::EvalNormal
(
float u,
Vector& pos,
Vector& orient
)
{
int segment_id;
float B[ 4 ];
float tmp;
float u_2;
float u_3;
Vector ang;
float roll;
float speed;
segment_id = ( int )u;
if ( segment_id < 0 )
{
segment_id = 0;
}
if ( segment_id > num_control_points - 4 )
{
segment_id = num_control_points - 4;
}
u -= ( float )segment_id;
u_2 = u * u;
u_3 = u * u_2;
tmp = 1 - u;
B[ 0 ] = ( tmp * tmp * tmp ) * ( 1.0f / 6.0f );
B[ 1 ] = ( 3.0f * u_3 - 6.0f * u_2 + 4.0f ) * ( 1.0f / 6.0f );
B[ 2 ] = ( -3.0f * u_3 + 3.0f * u_2 + 3.0f * u + 1 ) * ( 1.0f / 6.0f );
B[ 3 ] = u_3 * ( 1.0f / 6.0f );
pos =
*control_points[ 0 + segment_id ].GetPosition() * B[ 0 ] +
*control_points[ 1 + segment_id ].GetPosition() * B[ 1 ] +
*control_points[ 2 + segment_id ].GetPosition() * B[ 2 ] +
*control_points[ 3 + segment_id ].GetPosition() * B[ 3 ];
ang =
*control_points[ 0 + segment_id ].GetOrientation() * B[ 0 ] +
*control_points[ 1 + segment_id ].GetOrientation() * B[ 1 ] +
*control_points[ 2 + segment_id ].GetOrientation() * B[ 2 ] +
*control_points[ 3 + segment_id ].GetOrientation() * B[ 3 ];
roll =
*control_points[ 0 + segment_id ].GetRoll() * B[ 0 ] +
*control_points[ 1 + segment_id ].GetRoll() * B[ 1 ] +
*control_points[ 2 + segment_id ].GetRoll() * B[ 2 ] +
*control_points[ 3 + segment_id ].GetRoll() * B[ 3 ];
speed =
*control_points[ 0 + segment_id ].GetSpeed() * B[ 0 ] +
*control_points[ 1 + segment_id ].GetSpeed() * B[ 1 ] +
*control_points[ 2 + segment_id ].GetSpeed() * B[ 2 ] +
*control_points[ 3 + segment_id ].GetSpeed() * B[ 3 ];
orient = ang.toAngles();
orient[ ROLL ] = roll;
return speed;
}
inline float BSpline::EvalLoop
(
float t,
Vector& pos,
Vector& orient
)
{
Vector retval;
Vector ang;
float speed;
float roll;
int segment_id;
int next_id;
float B[ 4 ];
float tmp;
float u;
float u_2;
float u_3;
int i;
int j;
segment_id = ( int )floor( t );
u = t - floor( t );
segment_id %= num_control_points;
if ( segment_id < 0 )
{
segment_id += num_control_points;
}
u_2 = u * u;
u_3 = u * u_2;
tmp = 1 - u;
B[ 0 ] = ( tmp * tmp * tmp ) * ( 1.0f / 6.0f );
B[ 1 ] = ( 3.0f * u_3 - 6.0f * u_2 + 4.0f ) * ( 1.0f / 6.0f );
B[ 2 ] = ( -3.0f * u_3 + 3.0f * u_2 + 3.0f * u + 1 ) * ( 1.0f / 6.0f );
B[ 3 ] = u_3 * ( 1.0f / 6.0f );
speed = 0;
roll = 0;
for( i = 0, j = segment_id; i < 4; i++, j++ )
{
if ( j >= num_control_points )
{
j -= ( num_control_points - loop_control_point );
}
retval += *control_points[ j ].GetPosition() * B[ i ];
ang += *control_points[ j ].GetOrientation() * B[ i ];
speed += *control_points[ j ].GetSpeed() * B[ i ];
roll += *control_points[ j ].GetRoll() * B[ i ];
}
pos = retval;
next_id = segment_id + 1;
if ( next_id >= num_control_points )
{
next_id -= ( num_control_points - loop_control_point );
}
orient = ang.toAngles();
orient[ ROLL ] = roll;
return speed;
}
inline float BSpline::EvalClamp
(
float t,
Vector& pos,
Vector& orient
)
{
Vector retval;
Vector ang;
int segment_id;
int next_id;
float B[ 4 ];
float tmp;
float u;
float u_2;
float u_3;
int i;
int j;
float speed;
float roll;
segment_id = ( int )floor( t );
u = t - floor( t );
u_2 = u * u;
u_3 = u * u_2;
tmp = 1 - u;
B[ 0 ] = ( tmp * tmp * tmp ) * ( 1.0f / 6.0f );
B[ 1 ] = ( 3.0f * u_3 - 6.0f * u_2 + 4.0f ) * ( 1.0f / 6.0f );
B[ 2 ] = ( -3.0f * u_3 + 3.0f * u_2 + 3.0f * u + 1 ) * ( 1.0f / 6.0f );
B[ 3 ] = u_3 * ( 1.0f / 6.0f );
speed = 0;
roll = 0;
for( i = 0; i < 4; i++, segment_id++ )
{
j = segment_id;
if ( j < 0 )
{
j = 0;
}
else if ( j >= num_control_points )
{
j = num_control_points - 1;
}
retval += *control_points[ j ].GetPosition() * B[ i ];
ang += *control_points[ j ].GetOrientation() * B[ i ];
speed += *control_points[ j ].GetSpeed() * B[ i ];
roll += *control_points[ j ].GetRoll() * B[ i ];
}
pos = retval;
next_id = segment_id + 1;
if ( segment_id < 0 )
{
segment_id = 0;
}
if ( segment_id >= num_control_points )
{
segment_id = num_control_points - 1;
}
if ( next_id < 0 )
{
next_id = 0;
}
if ( next_id >= num_control_points )
{
next_id = num_control_points - 1;
}
orient = ang.toAngles();
orient[ ROLL ] = roll;
return speed;
}
Vector BSpline::Eval
(
float u
)
{
Vector pos;
Vector orient;
switch( curvetype )
{
default:
case SPLINE_NORMAL :
EvalNormal( u, pos, orient );
break;
case SPLINE_CLAMP:
EvalClamp( u, pos, orient );
break;
case SPLINE_LOOP:
EvalLoop( u, pos, orient );
break;
}
return pos;
}
float BSpline::Eval
(
float u,
Vector &pos,
Vector &orient
)
{
switch( curvetype )
{
default:
case SPLINE_NORMAL :
return EvalNormal( u, pos, orient );
break;
case SPLINE_CLAMP:
return EvalClamp( u, pos, orient );
break;
case SPLINE_LOOP:
return EvalLoop( u, pos, orient );
break;
}
}
void BSpline::DrawControlSegments
(
void
)
{
int i;
G_BeginLine();
for( i = 0; i < num_control_points; i++ )
{
G_Vertex( *control_points[ i ].GetPosition() );
}
G_EndLine();
}
void BSpline::DrawCurve
(
int num_subdivisions
)
{
float u;
float du;
du = 1.0f / ( float )num_subdivisions;
G_BeginLine();
for( u = 0.0f; u <= ( float )num_control_points; u += du )
{
G_Vertex( ( Vector )Eval( u ) );
}
G_EndLine();
}
void BSpline::DrawCurve
(
Vector offset,
int num_subdivisions
)
{
float u;
float du;
du = 1.0f / ( float )num_subdivisions;
G_BeginLine();
for( u = 0.0f; u <= ( float )num_control_points; u += du )
{
G_Vertex( offset + ( Vector )Eval( u ) );
}
G_EndLine();
}
void BSpline::AppendControlPoint
(
const Vector& new_control_point
)
{
BSplineControlPoint *old_control_points;
int i;
old_control_points = control_points;
num_control_points++;
control_points = new BSplineControlPoint[num_control_points];
assert( control_points );
if ( old_control_points )
{
for( i = 0; i < num_control_points - 1; i++ )
{
control_points[ i ] = old_control_points[ i ];
}
delete [] old_control_points;
}
control_points[ num_control_points - 1 ].Set( new_control_point );
}
void BSpline::AppendControlPoint
(
const Vector& new_control_point,
const float& speed
)
{
BSplineControlPoint *old_control_points;
int i;
old_control_points = control_points;
num_control_points++;
control_points = new BSplineControlPoint[num_control_points];
assert( control_points );
if ( old_control_points )
{
for( i = 0; i < num_control_points - 1; i++ )
{
control_points[ i ] = old_control_points[ i ];
}
delete [] old_control_points;
}
control_points[ num_control_points - 1 ].Set( new_control_point, speed );
}
void BSpline::AppendControlPoint
(
const Vector& new_control_point,
const Vector& new_control_orient,
const float& new_control_speed
)
{
BSplineControlPoint *old_control_points;
int i;
has_orientation = true;
old_control_points = control_points;
num_control_points++;
control_points = new BSplineControlPoint[num_control_points];
assert( control_points );
if ( old_control_points )
{
for( i = 0; i < num_control_points - 1; i++ )
{
control_points[ i ] = old_control_points[ i ];
}
delete [] old_control_points;
}
control_points[ num_control_points - 1 ].Set( new_control_point, new_control_orient, new_control_speed );
}
void BSpline::SetLoopPoint
(
const Vector& pos
)
{
int i;
for( i = 0; i < num_control_points; i++ )
{
if ( pos == *control_points[ i ].GetPosition() )
{
loop_control_point = i;
break;
}
}
}
int BSpline::PickControlPoint
(
const Vector& window_point,
float pick_size
)
{
int i;
float closest_dist_2;
int closest_index;
float dist_2;
Vector delta;
closest_index = -1;
closest_dist_2 = 1000000.0f;
for( i = 0; i < num_control_points; i++ )
{
delta = window_point - *control_points[ i ].GetPosition();
dist_2 = delta * delta;
if ( dist_2 < closest_dist_2 )
{
closest_dist_2 = dist_2;
closest_index = i;
}
}
if ( pick_size * pick_size >= closest_dist_2 )
{
return closest_index;
}
else
{
return -1;
}
}
CLASS_DECLARATION( Entity, SplinePath, "info_splinepath" );
Event EV_SplinePath_Create( "SplinePath_create" );
ResponseDef SplinePath::Responses[] =
{
{ &EV_SplinePath_Create, ( Response )SplinePath::CreatePath },
{ NULL, NULL }
};
SplinePath::SplinePath()
{
owner = this;
next = NULL;
loop = NULL;
loop_name = G_GetStringArg( "loop" );
angles = G_GetVectorArg( "angles" );
speed = G_GetFloatArg( "speed", 1 );
setMoveType( MOVETYPE_NONE );
setSolidType( SOLID_NOT );
hideModel();
if ( !LoadingSavegame )
{
PostEvent( EV_SplinePath_Create, 0 );
}
}
void SplinePath::CreatePath
(
Event *ev
)
{
const char *target;
int num;
// Make the path from the targetlist.
target = Target();
if ( target[ 0 ] )
{
if ( num = G_FindTarget( 0, target ) )
{
next = ( SplinePath * )G_GetEntity( num );
next->owner = this;
}
else
{
gi.error( "SplinePath::CreatePath: target %s not found\n", target );
}
}
if ( loop_name.length() )
{
if ( num = G_FindTarget( 0, loop_name.c_str() ) )
{
loop = ( SplinePath * )G_GetEntity( num );
}
}
}
SplinePath *SplinePath::GetNext
(
void
)
{
return next;
}
SplinePath *SplinePath::GetLoop
(
void
)
{
return loop;
}

609
bspline.h Normal file
View File

@ -0,0 +1,609 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bspline.h $
// $Revision:: 19 $
// $Author:: Jimdose $
// $Date:: 10/25/98 11:52p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bspline.h $
//
// 19 10/25/98 11:52p Jimdose
// added EXPORT_TEMPLATE
//
// 18 10/19/98 9:52p Jimdose
// fixed savegame bugs with bspline
//
// 17 10/11/98 2:03p Markd
// Inverted pitch on orientation
//
// 16 10/10/98 9:12p Markd
// Fixed angle errors with bsplines
//
// 15 9/24/98 1:19a Markd
// bullet proofed some equating bspline code
//
// 14 9/23/98 11:00p Markd
// put in some garbage collection on stuff that wasn't freed up
//
// 13 9/21/98 10:15p Markd
// Putting archiving and unarchiving functions in
//
// 12 8/15/98 2:40p Markd
// fixed bspline stuff
//
// 11 7/11/98 6:31p Markd
// removed valid orientation, simplified code
//
// 10 7/10/98 2:10p Markd
// Endpoint now returns number of controlpoints.
//
// 9 7/10/98 1:12p Markd
// Added additonal setup function which takes speed as well as position
//
// 8 7/09/98 11:54p Markd
// Put in default speed of 1
//
// 7 7/08/98 12:42p Markd
// Added quaternion support
//
// 6 7/02/98 9:48p Markd
// added orientation
//
// 5 5/26/98 7:56p Jimdose
// added scripted cameras
//
// 4 5/07/98 10:41p Jimdose
// Added spline type for selecting between looping and non-looping curves
//
// 3 5/05/98 2:37p Jimdose
// Added code to allow spline loop and clamping the spline start and end
//
// 2 5/03/98 4:42p Jimdose
// Added file to Sin
//
// DESCRIPTION:
// Uniform non-rational bspline class.
//
#ifndef __BSPLINE_H__
#define __BSPLINE_H__
#include "g_local.h"
#include "Vector.h"
typedef enum
{
SPLINE_NORMAL,
SPLINE_LOOP,
SPLINE_CLAMP
} splinetype_t;
class EXPORT_FROM_DLL BSplineControlPoint
{
private:
float roll;
Vector position;
Vector orientation;
float speed;
public:
BSplineControlPoint();
BSplineControlPoint( Vector pos, Vector orient, float speed );
BSplineControlPoint( Vector pos );
void Clear( void );
void Set( Vector pos );
void Set( Vector pos, float speed );
void Set( Vector pos, Vector orient, float speed );
void Get( Vector& pos, Vector& orient, float& speed );
void Get( Vector& pos );
Vector *GetPosition( void );
Vector *GetOrientation( void );
float *GetRoll( void );
float *GetSpeed( void );
void operator=( BSplineControlPoint &point );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void BSplineControlPoint::Archive
(
Archiver &arc
)
{
arc.WriteVector( position );
arc.WriteVector( orientation );
arc.WriteFloat( speed );
arc.WriteFloat( roll );
}
inline EXPORT_FROM_DLL void BSplineControlPoint::Unarchive
(
Archiver &arc
)
{
arc.ReadVector( &position );
arc.ReadVector( &orientation );
arc.ReadFloat( &speed );
arc.ReadFloat( &roll );
}
inline void BSplineControlPoint::operator=
(
BSplineControlPoint &point
)
{
position = point.position;
orientation = point.orientation;
speed = point.speed;
roll = point.roll;
}
inline BSplineControlPoint::BSplineControlPoint()
{
roll = 0;
speed = 1;
}
inline BSplineControlPoint::BSplineControlPoint
(
Vector pos
)
{
speed = 1;
position = pos;
}
inline BSplineControlPoint::BSplineControlPoint
(
Vector pos,
Vector orient,
float speed
)
{
position = pos;
orient[ PITCH ] = -orient[ PITCH ];
orient.AngleVectors( &orientation, NULL, NULL );
roll = orient[ ROLL ];
if ( roll > 180 )
{
roll -= 360;
}
if ( roll < -180 )
{
roll += 360;
}
this->speed = speed;
}
inline void BSplineControlPoint::Clear
(
void
)
{
roll = 0;
position = "0 0 0";
vec_zero.AngleVectors( &orientation, NULL, NULL );
speed = 1.0f;
}
inline void BSplineControlPoint::Set
(
Vector pos
)
{
speed = 1;
position = pos;
}
inline void BSplineControlPoint::Set
(
Vector pos,
float pointspeed
)
{
speed = pointspeed;
position = pos;
}
inline void BSplineControlPoint::Set
(
Vector pos,
Vector orient,
float speed
)
{
position = pos;
orient[ PITCH ] = -orient[ PITCH ];
orient.AngleVectors( &orientation, NULL, NULL );
roll = orient[ ROLL ];
if ( roll > 180 )
{
roll -= 360;
}
if ( roll < -180 )
{
roll += 360;
}
this->speed = speed;
}
inline void BSplineControlPoint::Get
(
Vector& pos
)
{
pos = position;
}
inline Vector *BSplineControlPoint::GetPosition
(
void
)
{
return &position;
}
inline void BSplineControlPoint::Get
(
Vector& pos,
Vector& orient,
float& speed
)
{
pos = position;
orient = orientation;
speed = this->speed;
}
inline Vector *BSplineControlPoint::GetOrientation
(
void
)
{
return &orientation;
}
inline float *BSplineControlPoint::GetRoll
(
void
)
{
return &roll;
}
inline float *BSplineControlPoint::GetSpeed
(
void
)
{
return &speed;
}
class EXPORT_FROM_DLL BSpline
{
private:
BSplineControlPoint *control_points;
int num_control_points;
int loop_control_point;
splinetype_t curvetype;
qboolean has_orientation;
float EvalNormal( float u, Vector &pos, Vector& orient );
float EvalLoop( float u, Vector &pos, Vector& orient );
float EvalClamp( float u, Vector &pos, Vector& orient );
public:
BSpline();
~BSpline();
BSpline( Vector *control_points_, int num_control_points_, splinetype_t type );
BSpline( Vector *control_points_, Vector *control_orients_, float *control_speeds_, int num_control_points_, splinetype_t type );
void operator=( BSpline &spline );
void SetType( splinetype_t type );
int GetType( void );
void Clear( void );
void Set( Vector *control_points_, int num_control_points_, splinetype_t type );
void Set( Vector *control_points_, Vector *control_orients_, float *control_speeds_, int num_control_points_, splinetype_t type );
void AppendControlPoint( const Vector& new_control_point );
void AppendControlPoint( const Vector& new_control_point, const float& speed );
void AppendControlPoint( const Vector& new_control_point, const Vector& new_control_orient, const float& speed );
Vector Eval( float u );
float Eval( float u, Vector& pos, Vector& orient );
void DrawControlSegments( void );
void DrawCurve( int num_subdivisions );
void DrawCurve( Vector offset, int num_subdivisions );
void SetLoopPoint( const Vector& pos );
float EndPoint( void );
// return the index of the control point picked or -1 if none.
int PickControlPoint( const Vector& window_point, float pick_size );
Vector *GetControlPoint( int id );
void GetControlPoint( int id, Vector& pos, Vector& orient, float& speed );
void SetControlPoint( int id, const Vector& new_control_point );
void SetControlPoint( int id, const Vector& new_control_point, const Vector& new_control_orient, const float& speed );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline BSpline::BSpline()
{
has_orientation = false;
control_points = NULL;
num_control_points = 0;
loop_control_point = 0;
curvetype = SPLINE_NORMAL;
}
inline BSpline::~BSpline()
{
if ( control_points )
{
delete [] control_points;
control_points = NULL;
}
}
inline BSpline::BSpline
(
Vector *control_points_,
int num_control_points_,
splinetype_t type
)
{
has_orientation = false;
control_points = NULL;
num_control_points = 0;
loop_control_point = 0;
curvetype = SPLINE_NORMAL;
Set( control_points_, num_control_points_, type );
}
inline BSpline::BSpline
(
Vector *control_points_,
Vector *control_orients_,
float *control_speeds_,
int num_control_points_,
splinetype_t type
)
{
has_orientation = false;
control_points = NULL;
num_control_points = 0;
loop_control_point = 0;
curvetype = SPLINE_NORMAL;
Set( control_points_, control_orients_, control_speeds_, num_control_points_, type );
}
inline void BSpline::operator=
(
BSpline &spline
)
{
int i;
Clear();
num_control_points = spline.num_control_points;
loop_control_point = spline.loop_control_point;
curvetype = spline.curvetype;
has_orientation = spline.has_orientation;
control_points = new BSplineControlPoint[num_control_points];
assert( control_points );
for ( i = 0; i < num_control_points ; i++ )
control_points[ i ] = spline.control_points[ i ];
}
inline void BSpline::SetType
(
splinetype_t type
)
{
curvetype = type;
}
inline int BSpline::GetType
(
void
)
{
return curvetype;
}
inline float BSpline::EndPoint
(
void
)
{
return num_control_points;
}
inline Vector *BSpline::GetControlPoint
(
int id
)
{
assert( id >= 0 );
assert( id < num_control_points );
if ( ( id < 0 ) && ( id >= num_control_points ) )
{
// probably wrong, but if we're in release mode we have no recourse
id = 0;
}
return control_points[ id ].GetPosition();
}
inline void BSpline::GetControlPoint
(
int id,
Vector& pos,
Vector& orient,
float& speed
)
{
assert( id >= 0 );
assert( id < num_control_points );
if ( ( id >= 0 ) && ( id < num_control_points ) )
{
control_points[ id ].Get( pos, orient, speed );
}
}
inline void BSpline::SetControlPoint
(
int id,
const Vector& new_control_point
)
{
assert( id >= 0 );
assert( id < num_control_points );
if ( ( id >= 0 ) && ( id < num_control_points ) )
{
control_points[ id ].Set( new_control_point );
}
}
inline void BSpline::SetControlPoint
(
int id,
const Vector& new_control_point,
const Vector& new_control_orient,
const float& speed
)
{
assert( id >= 0 );
assert( id < num_control_points );
if ( ( id >= 0 ) && ( id < num_control_points ) )
{
control_points[ id ].Set( new_control_point, new_control_orient, speed );
}
}
inline EXPORT_FROM_DLL void BSpline::Archive
(
Archiver &arc
)
{
int i;
arc.WriteInteger( num_control_points );
arc.WriteInteger( loop_control_point );
arc.WriteInteger( curvetype );
arc.WriteBoolean( has_orientation );
for( i = 0; i < num_control_points; i++ )
{
control_points[ i ].Archive( arc );
}
}
inline EXPORT_FROM_DLL void BSpline::Unarchive
(
Archiver &arc
)
{
int i;
arc.ReadInteger( &num_control_points );
arc.ReadInteger( &loop_control_point );
arc.ReadInteger( &i );
curvetype = ( splinetype_t )i;
arc.ReadBoolean( &has_orientation );
control_points = new BSplineControlPoint[ num_control_points ];
for( i = 0; i < num_control_points; i++ )
{
control_points[ i ].Unarchive( arc );
}
}
class SplinePath;
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL SafePtr<SplinePath>;
#endif
typedef SafePtr<SplinePath> SplinePathPtr;
class EXPORT_FROM_DLL SplinePath : public Entity
{
protected:
SplinePathPtr owner;
SplinePathPtr next;
SplinePathPtr loop;
str loop_name;
void CreatePath( Event *ev );
public:
float speed;
CLASS_PROTOTYPE( SplinePath );
SplinePath();
SplinePath *GetNext( void );
SplinePath *GetLoop( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void SplinePath::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteSafePointer( owner );
arc.WriteSafePointer( next );
arc.WriteSafePointer( loop );
arc.WriteString( loop_name );
arc.WriteFloat( speed );
}
inline EXPORT_FROM_DLL void SplinePath::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadSafePointer( &owner );
arc.ReadSafePointer( &next );
arc.ReadSafePointer( &loop );
arc.ReadString( &loop_name );
arc.ReadFloat( &speed );
}
#endif /* __BSPLINE_H__ */

515
bullet.cpp Normal file
View File

@ -0,0 +1,515 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bullet.cpp $
// $Revision:: 71 $
// $Author:: Markd $
// $Date:: 10/22/98 7:57p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bullet.cpp $
//
// 71 10/22/98 7:57p Markd
// put in proper pre-caching in all the classes
//
// 70 10/20/98 8:26p Markd
// Added Attacker to DamageSurface stuff
//
// 69 10/13/98 5:27p Markd
// revamped ricochet stuff
//
// 68 10/13/98 12:35p Markd
// Fixed tracers and bullet holes on non-player guys
//
// 67 10/05/98 11:30p Markd
// Added MakeBreakingSound when firing at things
//
// 66 10/04/98 10:36p Markd
// put in ricochet code
//
// 65 9/27/98 3:53p Aldie
// Put in some debugging information
//
// 64 9/18/98 8:14p Markd
// rewrote surface system so that surfaces are now damaged by surface name
// instead of by surfinfo
//
// 63 8/31/98 7:45p Aldie
// Updated surface data structure and removed surfinfo field
//
// 62 8/29/98 9:39p Jimdose
// Added call info to G_Trace
//
// 61 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 60 8/25/98 7:55p Markd
// Fixed weapon angles
//
// 59 8/19/98 6:38p Markd
// Moved Assault rifle tracer into def file
//
// 58 8/14/98 5:37p Aldie
// Moved blood stuff to sentient
//
// 57 8/13/98 8:09p Aldie
// Moved blood particles to armor damage.
//
// 56 8/10/98 6:52p Aldie
// Added scale to bloodsplats
//
// 55 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and
// rocket jumping.
//
// 54 8/04/98 3:27p Aldie
// Revert back to sending PITCH and YAW
//
// 53 8/03/98 3:28p Aldie
// Only send over the PITCH of the gun when firing it
//
// 52 8/01/98 4:39p Aldie
// Put some debug prints
//
// 51 8/01/98 3:24p Aldie
// Added server effects flag for specific weapons
//
// 50 7/31/98 7:42p Aldie
// Client side bullet effects
//
// 49 7/25/98 5:48p Aldie
// Remove shotgun effect
//
// 48 7/24/98 10:03p Aldie
// Fixed bullet damage with invalid traces
//
// 47 7/23/98 6:17p Aldie
// Updated damage system and fixed some damage related bugs. Also put tracers
// back to the way they were, and added gib event to funcscriptmodels
//
// 46 7/22/98 10:41p Aldie
// Fixed tracers
//
// 45 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 44 7/17/98 7:57p Markd
// Added radius to FullTrace
//
// 43 7/15/98 9:57p Markd
// Added shields support
//
// 42 6/20/98 7:48p Markd
// using FullTrace now, also checking to make sure we have a valid intersection
// before trying to determine group num etc.
//
// 41 6/19/98 9:29p Jimdose
// Moved gun orientation code to Weapon
//
// 40 6/15/98 10:52p Jimdose
// Disabled fulltrace until bmodels are checked.
//
// 39 6/15/98 10:07p Jimdose
// Made bullet weapons use G_FullTrace
//
// 38 6/11/98 3:34p Jimdose
// TraceAttack was damaging the entity before checking the blood and sparks
// flags, so if the entity died before the check, we got a NULL pointer
// TraceAttack was doing the ricochet trace before checking if it should
// ricochet
//
// 37 6/10/98 2:10p Aldie
// Updated damage function.
//
// 36 6/08/98 11:35a Aldie
// Updated location based damage stuff
//
// 35 6/05/98 6:23p Aldie
// Added location to AddMultiDamage
//
// 34 5/27/98 7:34p Markd
// commented out damage reduction if not hitting body part
//
// 33 5/27/98 5:21p Markd
// fixed up ray intersection a bit
//
// 32 5/27/98 5:02a Markd
// increased nominal multiplier to 0.5f
//
// 31 5/26/98 8:44p Markd
// Put in DamageSkin suport
//
// 30 5/26/98 4:22p Markd
// Working on tri-ray intersection stuff
//
// 29 5/23/98 4:46p Aldie
// Added bulletholes.
//
// 28 5/05/98 7:38p Markd
// Added timeofs to ricochets in bulllet smoke events
//
// 27 5/03/98 8:08p Markd
// Took out old code
//
// 26 5/03/98 4:30p Jimdose
// Changed Vector class
//
// 25 5/02/98 8:41p Markd
// Put in recursive bullet attacks and got rid of ricochets
//
// 24 4/10/98 1:22a Markd
// Added FL_BLOOD support
//
// 23 4/07/98 6:42p Jimdose
// Rewrote weapon code.
// Added order to rank
//
// 22 4/06/98 7:52p Aldie
// Increased range of bullets.
//
// 21 4/04/98 7:31p Jimdose
// Bullets don't spark or ricochet against sky
//
// 20 4/02/98 4:48p Jimdose
// Changed TraceAttack to properly place bloodsplats
//
// 19 3/30/98 2:35p Jimdose
// Moved firing from Magnum to make more general
// Added Ammo
// Added world models
//
// 18 3/27/98 6:34p Jimdose
// Added sparks to show impact of bullets
//
// 17 3/26/98 8:16p Jimdose
// Added precaching of sounds
//
// 16 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 15 3/05/98 5:44p Aldie
// Support for ricochet flag.
//
// 14 3/04/98 8:02p Aldie
// More support for damage surfaces.
//
// 13 3/04/98 5:12p Aldie
// Added support for damage surfaces.
//
// 12 2/19/98 2:35p Jimdose
// Updated to work with Q2 based progs
//
// 10 12/11/97 3:30p Markd
// Moved SpawnBlood to Weapon
//
// 9 11/18/97 5:28p Markd
// Commented out shotgun
//
// 8 11/11/97 9:41p Markd
// tweaked minimum scale in blood splats
//
// 7 11/11/97 9:38p Markd
// made blood splats be based off of distance as well as damage.
//
// 6 10/31/97 9:02p Jimdose
// Made it so that bsp objects don't leave bloodsplats
//
// 5 10/31/97 7:18p Markd
// Put in BloodSpray
//
// 4 10/31/97 4:28p Jimdose
// Removed redefinition of owner in base class Weapon, so any reference to
// gunoffset through owner had to use type overriding.
//
// 3 10/27/97 3:29p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 4:43p Jimdose
// Added standard Ritual header
//
// DESCRIPTION:
// Base class for all bullet (hitscan) weapons. Includes definition for shotgun.
//
#include "g_local.h"
#include "specialfx.h"
#include "misc.h"
#include "bullet.h"
#include "q_shared.h"
#include "surface.h"
CLASS_DECLARATION( Weapon, BulletWeapon, NULL );
ResponseDef BulletWeapon::Responses[] =
{
{ NULL, NULL }
};
BulletWeapon::BulletWeapon()
{
modelIndex( "sprites/tracer.spr" );
modelIndex( "sprites/bullethole.spr" );
}
void BulletWeapon::TraceAttack
(
Vector start,
Vector end,
int damage,
trace_t *trace,
int numricochets,
int kick,
int dflags,
int meansofdeath,
qboolean server_effects
)
{
Vector org;
Vector dir;
Vector endpos;
int surfflags;
int surftype;
int timeofs;
Entity *ent;
qboolean ricochet;
if ( HitSky( trace ) )
{
return;
}
ricochet = false;
dir = end - start;
dir.normalize();
org = end - dir;
ent = trace->ent->entity;
if ( !trace->surface )
{
surfflags = 0;
surftype = 0;
}
else
{
surfflags = trace->surface->flags;
surftype = SURFACETYPE_FROM_FLAGS( surfflags );
surfaceManager.DamageSurface( trace, damage, owner );
if ( surfflags & SURF_RICOCHET )
ricochet = true;
}
if ( trace->intersect.valid && ent )
{
//
// see if the parent group has ricochet turned on
//
if ( trace->intersect.parentgroup >= 0 )
{
int flags;
flags = gi.Group_Flags( ent->edict->s.modelindex, trace->intersect.parentgroup );
if ( flags & MDL_GROUP_RICOCHET )
{
surftype = ( flags >> 8 ) & 0xf;
ricochet = true;
}
}
}
if ( ent )
{
if ( !(ent->flags & FL_SHIELDS) )
{
if ( ent->flags & FL_SPARKS )
{
// Take care of ricochet effects on the server
if ( server_effects && !ricochet )
{
timeofs = MAX_RICOCHETS - numricochets;
if ( timeofs > 0xf )
{
timeofs = 0xf;
}
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_GUNSHOT );
gi.WritePosition( org.vec3() );
gi.WriteDir( trace->plane.normal );
gi.WriteByte( 0 );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
MadeBreakingSound( org, owner );
}
if ( ent->takedamage )
{
if ( trace->intersect.valid )
{
// We hit a valid group so send in location based damage
ent->Damage( this,
owner,
damage,
trace->endpos,
dir,
trace->plane.normal,
kick,
dflags,
meansofdeath,
trace->intersect.parentgroup,
-1,
trace->intersect.damage_multiplier );
}
else
{
// We didn't hit any groups, so send in generic damage
ent->Damage( this,
owner,
damage,
trace->endpos,
dir,
trace->plane.normal,
kick,
dflags,
meansofdeath,
-1,
-1,
1 );
}
}
}
else
{
surftype = SURF_TYPE_METAL;
ricochet = true;
}
}
if ( ricochet && ( server_effects || ( numricochets < MAX_RICOCHETS ) ) )
{
timeofs = MAX_RICOCHETS - numricochets;
if ( timeofs > 0xf )
{
timeofs = 0xf;
}
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_GUNSHOT );
gi.WritePosition( org.vec3() );
gi.WriteDir( trace->plane.normal );
gi.WriteByte( timeofs );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
if (
ricochet &&
numricochets &&
damage
)
{
dir += Vector( trace->plane.normal ) * 2;
endpos = org + dir * 8192;
//
// since this is a ricochet, we don't ignore the wewapon owner this time.
//
*trace = G_FullTrace( org, vec_zero, vec_zero, endpos, 5, NULL, MASK_SHOT, "BulletWeapon::TraceAttack" );
if ( trace->fraction != 1.0 )
{
endpos = trace->endpos;
TraceAttack( org, endpos, damage * 0.8f, trace, numricochets - 1, kick, dflags, meansofdeath, true );
}
}
}
void BulletWeapon::FireBullets
(
int numbullets,
Vector spread,
int mindamage,
int maxdamage,
int dflags,
int meansofdeath,
qboolean server_effects
)
{
Vector src;
Vector dir;
Vector end;
trace_t trace;
Vector right;
Vector up;
int i;
assert( owner );
if ( !owner )
{
return;
}
GetMuzzlePosition( &src, &dir );
owner->angles.AngleVectors( NULL, &right, &up );
angles = dir.toAngles();
setAngles( angles );
for( i = 0; i < numbullets; i++ )
{
end = src +
dir * 8192 +
right * G_CRandom() * spread.x +
up * G_CRandom() * spread.y;
trace = G_FullTrace( src, vec_zero, vec_zero, end, 5, owner, MASK_SHOT, "BulletWeapon::FireBullets" );
#if 0
Com_Printf("Server OWNER Angles:%0.2f %0.2f %0.2f\n",owner->angles[0],owner->angles[1],owner->angles[2]);
Com_Printf("Server Bullet Angles:%0.2f %0.2f %0.2f\n",angles[0],angles[1],angles[2]);
Com_Printf("Right :%0.2f %0.2f %0.2f\n",right[0],right[1],right[2]);
Com_Printf("Up :%0.2f %0.2f %0.2f\n",up[0],up[1],up[2]);
Com_Printf("Direction :%0.2f %0.2f %0.2f\n",dir[0],dir[1],dir[2]);
Com_Printf("Endpoint :%0.2f %0.2f %0.2f\n",end[0],end[1],end[2]);
Com_Printf("Server Trace Start :%0.2f %0.2f %0.2f\n",src[0],src[1],src[2]);
Com_Printf("Server Trace End :%0.2f %0.2f %0.2f\n",trace.endpos[0],trace.endpos[1],trace.endpos[2]);
Com_Printf("\n");
#endif
if ( trace.fraction != 1.0 )
{
TraceAttack( src, trace.endpos, mindamage + (int)G_Random( maxdamage - mindamage + 1 ), &trace, MAX_RICOCHETS, kick, dflags, meansofdeath, server_effects );
}
}
}
void BulletWeapon::FireTracer( void )
{
Entity *tracer;
Vector src,dir,end;
trace_t trace;
GetMuzzlePosition( &src, &dir );
end = src + dir * 8192;
trace = G_Trace( src, vec_zero, vec_zero, end, owner, MASK_SHOT, "BulletWeapon::FireTracer" );
tracer = new Entity;
tracer->angles = dir.toAngles();
tracer->angles[ PITCH ] = -tracer->angles[ PITCH ] + 90;
//tracer->angles[PITCH] *= -1;
tracer->setAngles( tracer->angles );
tracer->setMoveType( MOVETYPE_NONE );
tracer->setSolidType( SOLID_NOT );
tracer->setModel( "sprites/tracer.spr" );
tracer->setSize( "0 0 0", "0 0 0" );
tracer->setOrigin( trace.endpos );
tracer->edict->s.renderfx &= ~RF_FRAMELERP;
VectorCopy( src, tracer->edict->s.old_origin );
tracer->PostEvent(EV_Remove,0.1f);
}

101
bullet.h Normal file
View File

@ -0,0 +1,101 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/bullet.h $
// $Revision:: 21 $
// $Author:: Aldie $
// $Date:: 8/06/98 10:53p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/bullet.h $
//
// 21 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and
// rocket jumping.
//
// 20 8/01/98 3:24p Aldie
// Added server effects flag for specific weapons
//
// 19 7/22/98 10:41p Aldie
// Fixed tracers
//
// 18 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 17 6/10/98 2:10p Aldie
// Updated damage function.
//
// 16 5/05/98 7:38p Markd
// Got rid of RicochetSound from header
//
// 15 5/02/98 8:44p Markd
// Got rid of RicochetSound, modified TraceAttack
//
// 14 4/02/98 4:51p Jimdose
// Changed TraceAttack
//
// 13 3/30/98 2:38p Jimdose
// Moved firing to BulletWeapon to make more general
// Added Ammo
// Added world models
//
// 12 3/26/98 8:10p Jimdose
// Added constructor
//
// 11 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 10 3/05/98 6:06p Aldie
// Added ricochet sounds.
//
// 9 3/02/98 8:49p Jimdose
// Changed CLASS_PROTOTYPE to only take the classname
//
// 8 2/19/98 2:35p Jimdose
// Updated to work with Q2 based progs
//
// 6 12/11/97 3:31p Markd
// Removed SpawnBlood
//
// 5 11/18/97 5:27p Markd
// Commented out ShotGun
//
// 4 10/31/97 7:18p Markd
// Added bloodspray
//
// 3 10/27/97 2:48p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 4:44p Jimdose
// Added standard Ritual header
//
// DESCRIPTION:
// Base class for all bullet (hitscan) weapons. Includes definition for shotgun.
//
#ifndef __BULLET_H__
#define __BULLET_H__
#include "g_local.h"
#include "item.h"
#include "weapon.h"
#define MAX_RICOCHETS 10
class EXPORT_FROM_DLL BulletWeapon : public Weapon
{
protected:
BulletWeapon();
virtual void TraceAttack( Vector start, Vector end, int damage, trace_t *trace, int numricochets, int kick, int dflags, int meansofdeath, qboolean server_effects );
virtual void FireBullets( int numbullets, Vector spread, int mindamage, int maxdamage, int dflags, int meansofdeath, qboolean server_effects );
virtual void FireTracer( void );
public:
CLASS_PROTOTYPE( BulletWeapon );
};
#endif /* BULLET.h */

1359
camera.cpp Normal file

File diff suppressed because it is too large Load Diff

513
camera.h Normal file
View File

@ -0,0 +1,513 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/camera.h $
// $Revision:: 25 $
// $Author:: Jimdose $
// $Date:: 10/25/98 11:53p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/camera.h $
//
// 25 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 24 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 23 9/24/98 1:19a Markd
// bullet proofed some equating bspline code
//
// 22 9/20/98 6:49p Markd
// Added Thread ability to cameras when they are looked through
//
// 21 8/17/98 7:42p Markd
// Added SetOverlay
//
// 20 8/17/98 6:20p Markd
// Changed SetCamera to a Player method
//
// 19 8/17/98 4:35p Markd
// Added SecurityCamera
//
// 18 8/14/98 8:18p Markd
// reworked camera class
//
// 17 8/08/98 7:29p Aldie
// Added intermissions for deathmatch
//
// 16 7/22/98 5:22p Markd
// Added MoveToPos and TurnTo
//
// 15 7/22/98 4:12p Markd
// Redid camera stuff
//
// 14 7/18/98 6:14p Markd
// Added optional watch commands at the end of follow and orbit events
//
// 13 7/13/98 12:58p Markd
// added fixed_position
//
// 12 7/11/98 6:31p Markd
// removed valid orientation, simplified code
//
// 11 7/10/98 1:12p Markd
// Added more functionality to camera stuff
//
// 10 7/08/98 12:42p Markd
// Removed CameraPath with SplinePath
//
// 9 7/02/98 9:48p Markd
// Added orientation support to cameras
//
// 8 5/27/98 3:18a Jimdose
// cameras can now watch specific entities
//
// 7 5/26/98 8:49p Jimdose
// Added yaw commands
//
// 6 5/26/98 8:18p Jimdose
// added height event
//
// 5 5/26/98 7:56p Jimdose
// added scripted cameras
//
// 4 5/13/98 4:55p Jimdose
// now uses SafePtrs
//
// 3 5/07/98 10:41p Jimdose
// fleshed out functionality a bit more
//
// 2 5/05/98 2:37p Jimdose
// Created file
//
// DESCRIPTION:
// Camera. Duh.
//
#ifndef __CAMERA_H__
#define __CAMERA_H__
#include "g_local.h"
#include "entity.h"
#include "bspline.h"
#define ORBIT 1
#define START_ON 2
#define PANNING 4
extern Event EV_Camera_FollowingPath;
extern Event EV_Camera_StartMoving;
extern Event EV_Camera_Pause;
extern Event EV_Camera_Continue;
extern Event EV_Camera_StopMoving;
extern Event EV_Camera_SetSpeed;
extern Event EV_Camera_SetDistance;
extern Event EV_Camera_SetHeight;
extern Event EV_Camera_SetYaw;
extern Event EV_Camera_FixedYaw;
extern Event EV_Camera_RelativeYaw;
extern Event EV_Camera_SetFOV;
extern Event EV_Camera_Orbit;
extern Event EV_Camera_Follow;
extern Event EV_Camera_Watch;
extern Event EV_Camera_LookAt;
extern Event EV_Camera_TurnTo;
extern Event EV_Camera_MoveToEntity;
extern Event EV_Camera_MoveToPos;
extern Event EV_Camera_NoWatch;
extern Event EV_Camera_IgnoreAngles;
extern Event EV_Camera_UseAngles;
extern Event EV_Camera_SplineAngles;
extern Event EV_Camera_NormalAngles;
extern Event EV_Camera_FixedPosition;
extern Event EV_Camera_NoFixedPosition;
extern Event EV_Camera_JumpTime;
extern Event EV_Camera_JumpCut;
extern Event EV_Camera_Pan;
extern Event EV_Camera_StopPan;
extern Event EV_Camera_PanSpeed;
extern Event EV_Camera_PanMax;
extern Event EV_Camera_SetPanAngles;
class EXPORT_FROM_DLL CameraMoveState
{
public:
Vector pos;
BSpline cameraPath;
float cameraTime;
EntityPtr followEnt;
EntityPtr orbitEnt;
qboolean followingpath;
float speed;
qboolean fixed_position;
float fov;
float height;
float follow_dist;
int follow_mask;
void operator=( CameraMoveState &newstate );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline void CameraMoveState::operator=
(
CameraMoveState &newstate
)
{
pos = newstate.pos;
cameraPath = newstate.cameraPath;
cameraTime = newstate.cameraTime;
followEnt = newstate.followEnt;
orbitEnt = newstate.orbitEnt;
followingpath = newstate.followingpath;
speed = newstate.speed;
fixed_position = newstate.fixed_position;
fov = newstate.fov;
height = newstate.height;
follow_dist = newstate.follow_dist;
follow_mask = newstate.follow_mask;
}
inline EXPORT_FROM_DLL void CameraMoveState::Archive
(
Archiver &arc
)
{
arc.WriteVector( pos );
cameraPath.Archive( arc );
arc.WriteFloat( cameraTime );
arc.WriteSafePointer( followEnt );
arc.WriteSafePointer( orbitEnt );
arc.WriteBoolean( followingpath );
arc.WriteFloat( speed );
arc.WriteBoolean( fixed_position );
arc.WriteFloat( fov );
arc.WriteFloat( height );
arc.WriteFloat( follow_dist );
arc.WriteInteger( follow_mask );
}
inline EXPORT_FROM_DLL void CameraMoveState::Unarchive
(
Archiver &arc
)
{
arc.ReadVector( &pos );
cameraPath.Unarchive( arc );
arc.ReadFloat( &cameraTime );
arc.ReadSafePointer( &followEnt );
arc.ReadSafePointer( &orbitEnt );
arc.ReadBoolean( &followingpath );
arc.ReadFloat( &speed );
arc.ReadBoolean( &fixed_position );
arc.ReadFloat( &fov );
arc.ReadFloat( &height );
arc.ReadFloat( &follow_dist );
arc.ReadInteger( &follow_mask );
}
class EXPORT_FROM_DLL CameraWatchState
{
public:
Vector dir;
EntityPtr watchEnt;
qboolean ignoreangles;
qboolean splineangles;
qboolean panning;
float pan_offset;
float pan_dir;
float pan_max;
float pan_speed;
Vector pan_angles;
float yaw;
qboolean fixedyaw;
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void CameraWatchState::Archive
(
Archiver &arc
)
{
arc.WriteVector( dir );
arc.WriteSafePointer( watchEnt );
arc.WriteBoolean( ignoreangles );
arc.WriteBoolean( splineangles );
arc.WriteBoolean( panning );
arc.WriteFloat( pan_offset );
arc.WriteFloat( pan_dir );
arc.WriteFloat( pan_max );
arc.WriteFloat( pan_speed );
arc.WriteVector( pan_angles );
arc.WriteFloat( yaw );
arc.WriteBoolean( fixedyaw );
}
inline EXPORT_FROM_DLL void CameraWatchState::Unarchive
(
Archiver &arc
)
{
arc.ReadVector( &dir );
arc.ReadSafePointer( &watchEnt );
arc.ReadBoolean( &ignoreangles );
arc.ReadBoolean( &splineangles );
arc.ReadBoolean( &panning );
arc.ReadFloat( &pan_offset );
arc.ReadFloat( &pan_dir );
arc.ReadFloat( &pan_max );
arc.ReadFloat( &pan_speed );
arc.ReadVector( &pan_angles );
arc.ReadFloat( &yaw );
arc.ReadBoolean( &fixedyaw );
}
class EXPORT_FROM_DLL CameraState
{
public:
CameraMoveState move;
CameraWatchState watch;
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void CameraState::Archive
(
Archiver &arc
)
{
move.Archive( arc );
watch.Archive( arc );
}
inline EXPORT_FROM_DLL void CameraState::Unarchive
(
Archiver &arc
)
{
move.Unarchive( arc );
watch.Unarchive( arc );
}
class EXPORT_FROM_DLL Camera : public Entity
{
private:
float default_fov;
float default_yaw;
float default_follow_dist;
float default_height;
float default_speed;
float default_pan_max;
float default_pan_speed;
Vector default_angles;
protected:
CameraState currentstate;
CameraState newstate;
float watchTime;
float followTime;
float jumpTime;
EntityPtr targetEnt;
EntityPtr targetWatchEnt;
str nextCamera;
str overlay;
str thread;
qboolean showcamera;
Event moveevent;
void FollowingPath( Event *ev );
void CreateOribit( Vector pos, float radius );
void CreatePath( SplinePath *path, splinetype_t type );
void InitializeMoveState( CameraMoveState &movestate );
void InitializeWatchState( CameraWatchState &watchstate );
void InitializeState( CameraState &state );
public:
CLASS_PROTOTYPE( Camera );
float fov;
Camera();
void Stop( void );
void FollowPath( SplinePath *path, qboolean loop, Entity *watch );
void Orbit( Entity *ent, float dist, Entity *watch );
void FollowEntity( Entity *ent, float dist, int mask, Entity *watch = NULL );
void StartMoving( Event *ev );
void StopMoving( Event *ev );
void Pause( Event *ev );
void Continue( Event *ev );
void SetSpeed( Event *ev );
void SetDistance( Event *ev );
void SetHeight( Event *ev );
void SetYaw( Event *ev );
void FixedYaw( Event *ev );
void RelativeYaw( Event *ev );
void SetFOV( Event *ev );
void OrbitEvent( Event *ev );
void FollowEvent( Event *ev );
void WatchEvent( Event *ev );
void NoWatchEvent( Event *ev );
void LookAt( Event *ev );
void MoveToEntity( Event *ev );
void MoveToPos( Event *ev );
void IgnoreAngles( Event *ev );
void UseAngles( Event *ev );
void SplineAngles( Event *ev );
void NormalAngles( Event *ev );
void FixedPosition( Event *ev );
void NoFixedPosition( Event *ev );
void JumpCut( Event *ev );
void JumpTime( Event *ev );
void TurnTo( Event *ev );
void EvaluatePosition( CameraState &state );
void PanEvent( Event *ev );
void StopPanEvent( Event *ev );
void PanSpeedEvent( Event *ev );
void PanMaxEvent( Event *ev );
void SetPanAngles( Event *ev );
void SetNextCamera( Event *ev );
void SetOverlay( Event *ev );
void SetThread( Event *ev );
str &NextCamera( void );
str &Thread( void );
str &Overlay( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Camera::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteFloat( default_fov );
arc.WriteFloat( default_yaw );
arc.WriteFloat( default_follow_dist );
arc.WriteFloat( default_height );
arc.WriteFloat( default_speed );
arc.WriteFloat( default_pan_max );
arc.WriteFloat( default_pan_speed );
arc.WriteVector( default_angles );
// currentstate
currentstate.Archive( arc );
// newstate
newstate.Archive( arc );
arc.WriteFloat( watchTime );
arc.WriteFloat( followTime );
arc.WriteFloat( jumpTime );
arc.WriteSafePointer( targetEnt );
arc.WriteSafePointer( targetWatchEnt );
arc.WriteString( nextCamera );
arc.WriteString( overlay );
arc.WriteString( thread );
arc.WriteBoolean( showcamera );
arc.WriteEvent( moveevent );
arc.WriteFloat( fov );
}
inline EXPORT_FROM_DLL void Camera::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadFloat( &default_fov );
arc.ReadFloat( &default_yaw );
arc.ReadFloat( &default_follow_dist );
arc.ReadFloat( &default_height );
arc.ReadFloat( &default_speed );
arc.ReadFloat( &default_pan_max );
arc.ReadFloat( &default_pan_speed );
arc.ReadVector( &default_angles );
// currentstate
currentstate.Unarchive( arc );
// newstate
newstate.Unarchive( arc );
arc.ReadFloat( &watchTime );
arc.ReadFloat( &followTime );
arc.ReadFloat( &jumpTime );
arc.ReadSafePointer( &targetEnt );
arc.ReadSafePointer( &targetWatchEnt );
arc.ReadString( &nextCamera );
arc.ReadString( &overlay );
arc.ReadString( &thread );
arc.ReadBoolean( &showcamera );
arc.ReadEvent( &moveevent );
arc.ReadFloat( &fov );
}
void SetCamera( Entity *ent );
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL SafePtr<Camera>;
#endif
typedef SafePtr<Camera> CameraPtr;
class EXPORT_FROM_DLL SecurityCamera : public Camera
{
public:
CLASS_PROTOTYPE( SecurityCamera );
SecurityCamera();
};
#endif /* camera.h */

298
camgun.cpp Normal file
View File

@ -0,0 +1,298 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/camgun.cpp $
// $Revision:: 18 $
// $Author:: Markd $
// $Date:: 10/15/98 3:39p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/camgun.cpp $
//
// 18 10/15/98 3:39p Markd
// Moved health parsing into turrets constructor
//
// 17 10/01/98 4:01p Markd
// Added Archive and Unarchive functions
//
// 16 9/22/98 4:57p Aldie
// Moved lagtime check right before firing
//
// 15 9/20/98 9:08p Aldie
// Fixed some stuff with the patience of turrets
//
// 14 9/19/98 6:09p Aldie
// Made wakeupdistance and firingdistance spawn args
//
// 13 8/27/98 9:01p Jimdose
// Centroid is now a variable
//
// 12 8/17/98 8:36p Aldie
// Fixed angle clamping
//
// 11 8/17/98 2:56p Aldie
// Make camgun take into account angles
//
// 10 8/15/98 2:18p Aldie
// Added health to camguns
//
// 9 8/10/98 6:52p Aldie
// Fixed an error in ClassDeclaration
//
// 8 7/26/98 6:54a Aldie
// Tweaked range and no damage
//
// 7 7/26/98 6:43a Aldie
// Increase distance
//
// 6 7/22/98 5:15p Aldie
// Fixed general behavior
//
// 5 7/17/98 7:04p Aldie
// Increased next seek time and removed some useless code.
//
// 4 7/17/98 4:39p Aldie
// Fixed some camgun stuff.
//
// 3 7/10/98 5:38p Aldie
// Changed camgun's health and made it take damage
//
// 2 7/07/98 4:10p Aldie
// First version of camgun
//
// DESCRIPTION:
// Generic turret
#include "turret.h"
#include "weapon.h"
class EXPORT_FROM_DLL Camgun : public Turret
{
private:
Vector zeroangle;
float yawrange;
float pitchrange;
float maxpitch;
float maxyaw;
Vector new_orientation;
public:
CLASS_PROTOTYPE( Camgun );
Camgun();
virtual void Seek( Event *ev );
virtual void Turn( Event *ev );
virtual void Down( Event *ev );
virtual void ClampOrientation( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
EXPORT_FROM_DLL void Camgun::Archive
(
Archiver &arc
)
{
Turret::Archive( arc );
arc.WriteVector( zeroangle );
arc.WriteFloat( yawrange );
arc.WriteFloat( pitchrange );
arc.WriteFloat( maxpitch );
arc.WriteFloat( maxyaw );
arc.WriteVector( new_orientation );
}
EXPORT_FROM_DLL void Camgun::Unarchive
(
Archiver &arc
)
{
Turret::Unarchive( arc );
arc.ReadVector( &zeroangle );
arc.ReadFloat( &yawrange );
arc.ReadFloat( &pitchrange );
arc.ReadFloat( &maxpitch );
arc.ReadFloat( &maxyaw );
arc.ReadVector( &new_orientation );
}
CLASS_DECLARATION( Turret, Camgun, "trap_camgun" );
ResponseDef Camgun::Responses[] =
{
{ NULL, NULL }
};
Camgun::Camgun
(
void
)
{
setModel( "camgun2.def" );
RandomAnimate( "down_idle", NULL );
setMoveType( MOVETYPE_NONE );
setSolidType( SOLID_BBOX );
gunoffset = "0 0 0";
neworientation = angles.yaw();
flags |= FL_SPARKS;
zeroangle = Vector ( 0, G_GetFloatArg( "angle", 0 ), 0 );
if ( zeroangle[ YAW ] > 180 )
zeroangle[ YAW ] -= 360;
if ( zeroangle[ YAW ] < -180 )
zeroangle[ YAW ] += 360;
yawrange = G_GetFloatArg( "yawrange", 180 );
maxyaw = yawrange;
pitchrange = G_GetFloatArg( "pitchrange", 180 );
maxpitch = pitchrange;
wakeupdistance = G_GetFloatArg( "wakeupdistance", 750 );
firingdistance = G_GetFloatArg( "firingdistance", 800 );
}
void Camgun::ClampOrientation
(
)
{
Vector delta;
delta = new_orientation - zeroangle;
if ( delta[ PITCH ] > 180 )
delta[ PITCH ] -= 360;
if ( delta[ PITCH ] < -180 )
delta[ PITCH ] += 360;
if ( delta[ PITCH ] > maxpitch )
delta[ PITCH ] = maxpitch;
if ( delta[ PITCH ] < -maxpitch )
delta[ PITCH ] = -maxpitch;
if ( delta[ YAW ] > 180 )
delta[ YAW ] -= 360;
if ( delta[ YAW ] < -180 )
delta[ YAW ] += 360;
if ( delta[YAW] > maxyaw )
delta[YAW] = maxyaw;
if ( delta[YAW] < -maxyaw )
delta[YAW] = -maxyaw;
new_orientation[ PITCH ] = zeroangle[ PITCH ] + delta[ PITCH ];
new_orientation[ YAW ] = zeroangle[ YAW ] + delta[ YAW ];
}
void Camgun::Seek
(
Event *ev
)
{
Entity *ent;
Vector v;
Vector s;
int range;
Vector f;
Vector pos;
active = true;
ent = NULL;
if ( enemy )
{
ent = G_GetEntity( enemy );
if ( ( !ent ) || ( ent->health <= 0 ) || ( ent->flags & FL_NOTARGET ) || ( ent == this ) )
{
enemy = 0;
ent = NULL;
}
else
{
range = Range( Distance( ent ) );
}
}
if ( ( lastSightTime ) && ( ( lastSightTime + patience ) < level.time ) )
{
ProcessEvent( EV_Turret_GoDown );
}
if ( !enemy )
{
FindTarget();
PostEvent( EV_Turret_Seek, FRAMETIME * 2 );
return;
}
if ( ( range != TURRET_OUTOFRANGE ) && ent && CanSee( ent ) )
{
lastSightTime = level.time;
v = ent->centroid - worldorigin;
new_orientation = v.toAngles();
ClampOrientation();
}
if ( ( angles[ YAW ] != new_orientation[ YAW ] ) && !turning)
{
Event *event;
event = new Event( EV_Turret_Turn );
event->AddVector( new_orientation );
ProcessEvent( event );
}
if ( range == TURRET_FIRERANGE && !attacking)
{
// Allow some freetime to let player get somewhere before turret shoots
if ( level.time < firetime )
{
PostEvent( EV_Turret_Seek, FRAMETIME );
return;
}
PostEvent( EV_Turret_Attack, 0.1 );
}
PostEvent( EV_Turret_Seek, FRAMETIME );
}
void Camgun::Turn
(
Event *ev
)
{
Vector new_angle = ev->GetVector( 1 );
if ( angles[ YAW ] != new_angle[ YAW ] )
{
turntime = level.time + 0.2;
turning = true;
}
else if ( turntime < level.time )
{
turning = false;
angles[ PITCH ] = -new_angle[ PITCH ];
return;
}
angles[ PITCH ] = -new_angle[ PITCH ];
angles[ YAW ] = new_angle[ YAW ];//AdjustAngle( 12, angles[ YAW ], new_angle[ YAW ] );
setAngles( angles );
PostEvent( ev, FRAMETIME );
}
void Camgun::Down
(
Event *ev
)
{
}

365
chaingun.cpp Normal file
View File

@ -0,0 +1,365 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/chaingun.cpp $
// $Revision:: 43 $
// $Author:: Jimdose $
// $Date:: 11/18/98 6:11p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/chaingun.cpp $
//
// 43 11/18/98 6:11p Jimdose
// fix problems with gravaxis
//
// 42 11/15/98 9:12p Markd
// Put in more precaching for models and sprites
//
// 41 11/13/98 3:30p Markd
// put in more precaching on weapons
//
// 40 10/27/98 3:43a Aldie
// Tweak damage
//
// 39 10/26/98 2:50p Aldie
// Fixed a bug with checking of NULL owners
//
// 38 10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
//
// 37 10/23/98 5:38a Jimdose
// Added SpawnBlastDamage
//
// 36 10/22/98 7:57p Markd
// put in proper pre-caching in all the classes
//
// 35 10/22/98 5:56p Markd
// Made a bunch of global sounds local to that entity
//
// 34 10/20/98 8:26p Markd
// Added Attacker to DamageSurface stuff
//
// 33 10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 32 10/16/98 10:22p Aldie
// Updated single player damage settings
//
// 31 10/16/98 9:49p Aldie
// Added SecondaryAmmo command
//
// 30 10/10/98 7:40p Aldie
// Added a smoke anim
//
// 29 10/10/98 7:14p Aldie
// Tweaked damage
//
// 28 9/27/98 4:19p Aldie
// Increase the damage a little
//
// 27 9/18/98 8:14p Markd
// rewrote surface system so that surfaces are now damaged by surface name instead
// of by surfinfo
//
// 26 9/05/98 12:10p Aldie
// Bounce grenades off things with < 0 health
//
// 25 9/01/98 3:05p Markd
// Rewrote explosion code
//
// 24 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 23 8/24/98 6:51p Jimdose
// Added SetGravityAxis
//
// 22 8/22/98 9:37p Jimdose
// Added support for alternate gravity axis
//
// 21 8/18/98 11:08p Markd
// Added new Alias System
//
// 20 8/18/98 8:12p Aldie
// Added dual mode weapons to base class
//
// 19 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and rocket
// jumping.
//
// 18 8/01/98 3:24p Aldie
// Added server effects flag for specific weapons
//
// 17 8/01/98 3:03p Aldie
// Client side muzzle flash (dynamic light)
//
// 16 7/25/98 7:19p Aldie
// Client side explosion
//
// 15 7/25/98 7:10p Markd
// Put in EV_Removes for demo
//
// 14 7/23/98 6:17p Aldie
// Updated damage system and fixed some damage related bugs. Also put tracers
// back to the way they were, and added gib event to funcscriptmodels
//
// 13 7/22/98 9:57p Markd
// Defined weapon type
//
// 12 7/22/98 5:15p Aldie
// Fixed NextAttack time
//
// 11 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 10 6/30/98 6:47p Aldie
// Changed damage and explosion effect.
//
// 9 6/19/98 9:29p Jimdose
// Moved gun orientation code to Weapon
//
// 8 6/15/98 10:36a Aldie
// Updated the mode setting
//
// 7 6/10/98 10:03p Aldie
// Updated orientation of shell
//
// 6 6/10/98 2:10p Aldie
// Updated damage function.
//
// 5 6/09/98 12:52p Aldie
// Added alternate use - Grenade Launcher
//
// 4 6/08/98 7:21p Aldie
// Updated attack time
//
// 3 5/27/98 1:33a Markd
// fixed spawn function name
//
// 2 5/11/98 11:24a Markd
// First time
//
// 1 5/11/98 11:13a Markd
//
// 1 5/11/98 9:55a Markd
//
// DESCRIPTION:
// High velocity chain gun
//
#include "g_local.h"
#include "bullet.h"
#include "chaingun.h"
#include "rocketlauncher.h"
#include "explosion.h"
#include "specialfx.h"
#include "misc.h"
#include "surface.h"
#define BULLET_MODE 1
CLASS_DECLARATION( Projectile, Grenade, "grenade" );
Event EV_Grenade_Explode( "grenade_explode" );
ResponseDef Grenade::Responses[] =
{
{ &EV_Touch, ( Response )Grenade::Grenade_Touch },
{ &EV_Grenade_Explode, ( Response )Grenade::Explode },
{ NULL, NULL }
};
EXPORT_FROM_DLL void Grenade::Grenade_Touch
(
Event *ev
)
{
Entity *other;
other = ev->GetEntity( 1 );
assert( other );
if ( other->entnum == owner )
return;
if ( HitSky() )
{
PostEvent( EV_Remove, 0 );
return;
}
if ( !other->takedamage || other->health <= 0 )
{
// Play a bouncy sound
RandomSound( "grenade_bounce", 1 );
return;
}
Explode( ev );
}
EXPORT_FROM_DLL void Grenade::Explode
(
Event *ev
)
{
int damg;
Vector v;
Entity *other;
Entity *owner;
other = ev->GetEntity( 1 );
assert( other );
if ( other->isSubclassOf( Teleporter ) )
{
return;
}
stopsound( CHAN_VOICE );
setSolidType( SOLID_NOT );
hideModel();
if ( HitSky() )
{
PostEvent( EV_Remove, 0 );
return;
}
owner = G_GetEntity( this->owner );
if ( !owner )
owner = world;
damg = 75 + ( int )G_Random( 25 );
if ( !deathmatch->value && owner->isClient() )
damg *= 1.5;
if ( other->takedamage )
other->Damage( this, owner, damg, worldorigin, velocity, level.impact_trace.plane.normal, 30, 0, MOD_GRENADE, -1, -1, 1.0f );
SpawnBlastDamage( &level.impact_trace, damg, owner );
v = velocity;
v.normalize();
// don't do radius damage to the other, because all the damage
// was done in the impact
v = worldorigin - v * 24;
CreateExplosion( v, damg, 1.0f, true, this, owner, other );
PostEvent( EV_Remove, 0.1 );
}
EXPORT_FROM_DLL void Grenade::Setup
(
Entity *owner,
Vector pos,
Vector forward,
Vector right,
Vector up
)
{
Event *ev;
setModel( "grenade.def" );
this->owner = owner->entnum;
edict->owner = owner->edict;
setMoveType( MOVETYPE_BOUNCE );
setSolidType( SOLID_BBOX );
takedamage = DAMAGE_YES;
edict->clipmask = MASK_PROJECTILE;
health = 10;
SetGravityAxis( owner->gravaxis );
velocity = forward * ( 500 + G_Random( 200 ) );
velocity += up * ( 200 + crandom() * 10.0 );
velocity += right * ( crandom() * 10.0 );
avelocity = "575 0 0";
ev = new Event( EV_Grenade_Explode );
ev->AddEntity( world );
PostEvent( ev, 2.5 + G_Random(1.0) );
edict->s.effects |= EF_ROCKET;
setOrigin( pos );
worldorigin.copyTo( edict->s.old_origin );
setSize( "-4 -4 -4", "4 4 4" );
edict->s.effects |= EF_EVERYFRAME;
RandomAnimate( "smoke", NULL );
}
CLASS_DECLARATION( BulletWeapon, ChainGun, "weapon_highvelocitygun" );
ResponseDef ChainGun::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )ChainGun::Shoot },
{ NULL, NULL }
};
ChainGun::ChainGun
(
)
{
#ifdef SIN_DEMO
PostEvent( EV_Remove, 0 );
return;
#endif
SetModels( "hvgun.def", "view_hvgun.def" );
SetAmmo( "Bullet50mm", 1, 30 );
SetSecondaryAmmo( "Rockets", 1, 5);
SetRank( 50, 50 );
SetType( WEAPON_2HANDED_LO );
dualmode = true;
modelIndex( "grenade.def" );
modelIndex( "rocket.def" );
modelIndex( "rockets.def" );
modelIndex( "50mm.def" );
modelIndex( "sprites/blastmark.spr" );
modelIndex( "sprites/hvblast.spr" );
modelIndex( "sprites/tracer.spr" );
modelIndex( "hvshell.def" );
}
void ChainGun::Shoot
(
Event *ev
)
{
if ( weaponmode == PRIMARY )
{
if ( deathmatch->value )
FireBullets( 1, "300 300 300", 24, 32, DAMAGE_BULLET, MOD_CHAINGUN, false );
else
FireBullets( 1, "300 300 300", 16, 24, DAMAGE_BULLET, MOD_CHAINGUN, false );
NextAttack( 0 );
}
else
{
Grenade *grenade;
Vector pos;
Vector forward;
Vector up;
Vector right;
GetMuzzlePosition( &pos, &forward, &up, &right );
grenade = new Grenade;
grenade->Setup( owner, pos, forward, up, right );
NextAttack( 0.8 );
}
}

78
chaingun.h Normal file
View File

@ -0,0 +1,78 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/chaingun.h $
// $Revision:: 9 $
// $Author:: Jimdose $
// $Date:: 11/18/98 6:12p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/chaingun.h $
//
// 9 11/18/98 6:12p Jimdose
// fix problems with gravaxis
//
// 8 9/21/98 4:50p Markd
// Fixed projectile owner
//
// 7 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 6 8/18/98 8:12p Aldie
// Added dual mode weapons to base class
//
// 5 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and rocket
// jumping.
//
// 4 6/10/98 2:10p Aldie
// Updated damage function.
//
// 3 6/09/98 12:54p Aldie
// Added grenade launcher alternate use function
//
// 2 5/11/98 11:24a Markd
// First time
//
// 1 5/11/98 11:13a Markd
//
// 1 5/11/98 9:55a Markd
//
// DESCRIPTION:
// High Velocity Gun
//
#ifndef __CHAINGUN_H__
#define __CHAINGUN_H__
#include "g_local.h"
#include "item.h"
#include "weapon.h"
#include "bullet.h"
#include "specialfx.h"
class EXPORT_FROM_DLL Grenade : public Projectile
{
public:
CLASS_PROTOTYPE( Grenade );
virtual void Explode( Event *ev );
virtual void Grenade_Touch( Event *ev );
void Setup( Entity *owner, Vector pos, Vector forward, Vector up, Vector right );
};
class EXPORT_FROM_DLL ChainGun : public BulletWeapon
{
public:
CLASS_PROTOTYPE( ChainGun );
ChainGun::ChainGun();
virtual void Shoot( Event *ev );
};
#endif /* ChainGun.h */

643
class.cpp Normal file
View File

@ -0,0 +1,643 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/class.cpp $
// $Revision:: 20 $
// $Author:: Jimdose $
// $Date:: 10/19/98 12:07a $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/class.cpp $
//
// 20 10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 19 10/07/98 11:42p Jimdose
// Got savegames working
//
// 18 9/24/98 1:49a Jimdose
// Added DisplayMemoryUsage
//
// 17 9/21/98 2:15a Jimdose
// Moved non-type specific code in SafePtr to SafePtrBase to help with save
// games
//
// 16 8/27/98 9:04p Jimdose
// NumEventCommands is now a member of Event
//
// 15 6/27/98 9:18p Jimdose
// Made lookup for event responses for faster processing
//
// 14 6/15/98 9:09p Aldie
// Fixed checkInheritance printfs
//
// 13 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 12 5/11/98 8:06p Jimdose
// Added SafePtr
//
// 11 5/08/98 2:51p Jimdose
// Added archiving functions
//
// 10 3/27/98 6:35p Jimdose
// made checking of classnames case independant
//
// 9 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 8 3/04/98 1:49p Jimdose
// Changed overloaded delete so that it used delete[] instead of delete, since
// we allocate with new[];
//
// 7 3/02/98 8:49p Jimdose
// Changed the classid parameter of CLASS_DECLARATION to a quoted string so
// that you could have a NULL classid.
//
// 6 2/03/98 10:53a Jimdose
// Updated to work with Quake 2 engine
// Made class registration automatic
//
// 5 1/22/98 6:50p Jimdose
// Made Q2 compatible
//
// 3 10/27/97 3:40p Jimdose
// Included stdarg.h
//
// 2 9/26/97 6:13p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Base class that all classes that are used in conjunction with Sin should
// be based off of. Class gives run-time type information about any class
// derived from it. This is really handy when you have a pointer to an object
// that you need to know if it supports certain behaviour.
//
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "g_local.h"
#include "class.h"
#include "linklist.h"
int totalmemallocated = 0;
int numclassesallocated = 0;
static ClassDef *classlist = NULL;
ClassDef::ClassDef()
{
this->classname = NULL;
this->classID = NULL;
this->superclass = NULL;
this->responses = NULL,
this->numEvents = 0;
this->responseLookup = NULL;
this->newInstance = NULL;
this->classSize = 0;
this->super = NULL;
this->prev = this;
this->next = this;
}
ClassDef::ClassDef
(
const char *classname,
const char *classID,
const char *superclass,
ResponseDef *responses,
void *( *newInstance )( void ),
int classSize
)
{
ClassDef *node;
if ( classlist == NULL )
{
classlist = new ClassDef;
}
this->classname = classname;
this->classID = classID;
this->superclass = superclass;
this->responses = responses;
this->numEvents = 0;
this->responseLookup = NULL;
this->newInstance = newInstance;
this->classSize = classSize;
this->super = getClass( superclass );
// It's not uncommon for classes to not have a class id, so just set it
// to an empty string so that we're not checking for it all the time.
if ( !classID )
{
this->classID = "";
}
// Check if any subclasses were initialized before their superclass
for( node = classlist->next; node != classlist; node = node->next )
{
if ( ( node->super == NULL ) && ( !Q_stricmp( node->superclass, this->classname ) ) &&
( Q_stricmp( node->classname, "Class" ) ) )
{
node->super = this;
}
}
// Add to front of list
LL_Add( classlist, this, prev, next );
}
ClassDef::~ClassDef()
{
ClassDef *node;
if ( classlist != this )
{
LL_Remove( this, prev, next );
// Check if any subclasses were initialized before their superclass
for( node = classlist->next; node != classlist; node = node->next )
{
if ( node->super == this )
{
node->super = NULL;
}
}
}
else
{
// If the head of the list is deleted before the list is cleared, then we may have problems
assert( this->next == this->prev );
}
if ( responseLookup )
{
delete[] responseLookup;
responseLookup = NULL;
}
}
EXPORT_FROM_DLL void ClassDef::BuildResponseList
(
void
)
{
ClassDef *c;
ResponseDef *r;
int ev;
int i;
qboolean *set;
int num;
if ( responseLookup )
{
delete[] responseLookup;
responseLookup = NULL;
}
num = Event::NumEventCommands();
responseLookup = ( Response ** )new char[ sizeof( Response * ) * num ];
memset( responseLookup, 0, sizeof( Response * ) * num );
set = new qboolean[ num ];
memset( set, 0, sizeof( qboolean ) * num );
this->numEvents = num;
for( c = this; c != NULL; c = c->super )
{
r = c->responses;
if ( r )
{
for( i = 0; r[ i ].event != NULL; i++ )
{
ev = ( int )*r[ i ].event;
if ( !set[ ev ] )
{
set[ ev ] = true;
if ( r[ i ].response )
{
responseLookup[ ev ] = &r[ i ].response;
}
else
{
responseLookup[ ev ] = NULL;
}
}
}
}
}
delete[] set;
}
EXPORT_FROM_DLL void BuildEventResponses
(
void
)
{
ClassDef *c;
int amount;
int numclasses;
amount = 0;
numclasses = 0;
for( c = classlist->next; c != classlist; c = c->next )
{
c->BuildResponseList();
amount += c->numEvents * sizeof( Response * );
numclasses++;
}
gi.dprintf( "\n------------------\nEvent system initialized:\n"
"%d classes\n%d events\n%d total memory in response list\n\n",
numclasses, Event::NumEventCommands(), amount );
}
EXPORT_FROM_DLL ClassDef *getClassForID
(
const char *name
)
{
ClassDef *c;
for( c = classlist->next; c != classlist; c = c->next )
{
if ( c->classID && !Q_stricmp( c->classID, name ) )
{
return c;
}
}
return NULL;
}
EXPORT_FROM_DLL ClassDef *getClass
(
const char *name
)
{
ClassDef *c;
for( c = classlist->next; c != classlist; c = c->next )
{
if ( !Q_stricmp( c->classname, name ) )
{
return c;
}
}
return NULL;
}
EXPORT_FROM_DLL ClassDef *getClassList
(
void
)
{
return classlist;
}
EXPORT_FROM_DLL void listAllClasses
(
void
)
{
ClassDef *c;
for( c = classlist->next; c != classlist; c = c->next )
{
gi.dprintf( "%s\n", c->classname );
}
}
EXPORT_FROM_DLL void listInheritanceOrder
(
const char *classname
)
{
ClassDef *cls;
ClassDef *c;
cls = getClass( classname );
if ( !cls )
{
gi.dprintf( "Unknown class: %s\n", classname );
return;
}
for( c = cls; c != NULL; c = c->super )
{
gi.dprintf( "%s\n", c->classname );
}
}
EXPORT_FROM_DLL qboolean checkInheritance
(
ClassDef *superclass,
ClassDef *subclass
)
{
ClassDef *c;
for( c = subclass; c != NULL; c = c->super )
{
if ( c == superclass )
{
return true;
}
}
return false;
}
EXPORT_FROM_DLL qboolean checkInheritance
(
ClassDef *superclass,
const char *subclass
)
{
ClassDef *c;
c = getClass( subclass );
if ( c == NULL )
{
gi.dprintf( "Unknown class: %s\n", subclass );
return false;
}
return checkInheritance( superclass, c );
}
EXPORT_FROM_DLL qboolean checkInheritance
(
const char *superclass,
const char *subclass
)
{
ClassDef *c1;
ClassDef *c2;
c1 = getClass( superclass );
c2 = getClass( subclass );
if ( c1 == NULL )
{
gi.dprintf( "Unknown class: %s\n", superclass );
return false;
}
if ( c2 == NULL )
{
gi.dprintf( "Unknown class: %s\n", subclass );
return false;
}
return checkInheritance( c1, c2 );
}
CLASS_DECLARATION( NULL, Class, NULL );
ResponseDef Class::Responses[] =
{
{ NULL, NULL }
};
#ifdef NDEBUG
EXPORT_FROM_DLL void * Class::operator new( size_t s )
{
int *p;
s += sizeof( int );
p = ( int * )::new char[ s ];
*p = s;
totalmemallocated += s;
numclassesallocated++;
return p + 1;
}
EXPORT_FROM_DLL void Class::operator delete( void *ptr )
{
int *p;
p = ( ( int * )ptr ) - 1;
totalmemallocated -= *p;
numclassesallocated--;
::delete[]( p );
}
#else
EXPORT_FROM_DLL void * Class::operator new( size_t s )
{
int *p;
s += sizeof( int ) * 3;
p = ( int * )::new char[ s ];
p[ 0 ] = 0x12348765;
*( int * )( ((byte *)p) + s - sizeof( int ) ) = 0x56784321;
p[ 1 ] = s;
totalmemallocated += s;
numclassesallocated++;
return p + 2;
}
EXPORT_FROM_DLL void Class::operator delete( void *ptr )
{
int *p;
p = ( ( int * )ptr ) - 2;
assert( p[ 0 ] == 0x12348765 );
assert( *( int * )( ((byte *)p) + p[ 1 ] - sizeof( int ) ) == 0x56784321 );
totalmemallocated -= p[ 1 ];
numclassesallocated--;
::delete[]( p );
}
#endif
EXPORT_FROM_DLL void DisplayMemoryUsage
(
void
)
{
gi.printf( "Classes %-5d Class memory used: %d\n", numclassesallocated, totalmemallocated );
}
Class::Class()
{
SafePtrList = NULL;
}
Class::~Class()
{
while( SafePtrList != NULL )
{
SafePtrList->Clear();
}
}
EXPORT_FROM_DLL void Class::Archive
(
Archiver &arc
)
{
}
EXPORT_FROM_DLL void Class::Unarchive
(
Archiver &arc
)
{
}
EXPORT_FROM_DLL void Class::warning
(
const char *function,
const char *fmt,
...
)
{
va_list argptr;
char text[ 1024 ];
va_start( argptr, fmt );
vsprintf( text, fmt, argptr );
va_end( argptr );
if ( getClassID() )
{
gi.dprintf( "%s::%s : %s\n", getClassID(), function, text );
}
else
{
gi.dprintf( "%s::%s : %s\n", getClassname(), function, text );
}
}
EXPORT_FROM_DLL void Class::error
(
const char *function,
const char *fmt,
...
)
{
va_list argptr;
char text[ 1024 ];
va_start( argptr, fmt );
vsprintf( text, fmt, argptr );
va_end( argptr );
if ( getClassID() )
{
gi.error( "%s::%s : %s\n", getClassID(), function, text );
}
else
{
gi.error( "%s::%s : %s\n", getClassname(), function, text );
}
}
EXPORT_FROM_DLL qboolean Class::inheritsFrom
(
const char *name
)
{
ClassDef *c;
c = getClass( name );
if ( c == NULL )
{
gi.dprintf( "Unknown class: %s\n", name );
return false;
}
return checkInheritance( c, classinfo() );
}
EXPORT_FROM_DLL qboolean Class::isInheritedBy
(
const char *name
)
{
ClassDef *c;
c = getClass( name );
if ( c == NULL )
{
gi.dprintf( "Unknown class: %s\n", name );
return false;
}
return checkInheritance( classinfo(), c );
}
EXPORT_FROM_DLL const char *Class::getClassname
(
void
)
{
ClassDef *cls;
cls = classinfo();
return cls->classname;
}
EXPORT_FROM_DLL const char *Class::getClassID
(
void
)
{
ClassDef *cls;
cls = classinfo();
return cls->classID;
}
EXPORT_FROM_DLL const char *Class::getSuperclass
(
void
)
{
ClassDef *cls;
cls = classinfo();
return cls->superclass;
}
EXPORT_FROM_DLL void *Class::newInstance
(
void
)
{
ClassDef *cls;
cls = classinfo();
return cls->newInstance();
}

447
class.h Normal file
View File

@ -0,0 +1,447 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/class.h $
// $Revision:: 17 $
// $Author:: Jimdose $
// $Date:: 10/25/98 11:53p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/class.h $
//
// 17 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 16 10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 15 10/07/98 11:42p Jimdose
// Got savegames working
//
// 14 9/24/98 1:49a Jimdose
// Added DisplayMemoryUsage
//
// 13 9/21/98 2:15a Jimdose
// Moved non-type specific code in SafePtr to SafePtrBase to help with save
// games
//
// 12 9/03/98 9:08p Jimdose
// Overrided == and != for SafePtr
//
// 11 6/27/98 9:18p Jimdose
// Made lookup for event responses for faster processing
//
// 10 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 9 5/11/98 8:06p Jimdose
// Added SafePtr
//
// 8 5/08/98 2:51p Jimdose
// Added archiving functions
//
// 7 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 6 3/02/98 8:49p Jimdose
// Changed CLASS_PROTOTYPE to only take the classname
//
// 5 2/03/98 10:53a Jimdose
// Updated to work with Quake 2 engine
// Made class registration automatic
//
// 4 1/22/98 6:50p Jimdose
// Made Q2 compatible
//
// 2 9/26/97 6:13p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Base class that all classes that are used in conjunction with Sin should
// be based off of. Class gives run-time type information about any class
// derived from it. This is really handy when you have a pointer to an object
// that you need to know if it supports certain behaviour.
//
#ifndef __CLASS_H__
#define __CLASS_H__
#include "g_local.h"
class Class;
class Event;
class Archiver;
typedef void ( Class::*Response )( Event *event );
typedef struct
{
Event *event;
Response response;
} ResponseDef;
/***********************************************************************
ClassDef
***********************************************************************/
class EXPORT_FROM_DLL ClassDef
{
public:
const char *classname;
const char *classID;
const char *superclass;
void *( *newInstance )( void );
int classSize;
ResponseDef *responses;
int numEvents;
Response **responseLookup;
ClassDef *super;
ClassDef *next;
ClassDef *prev;
ClassDef();
~ClassDef();
ClassDef( const char *classname, const char *classID, const char *superclass,
ResponseDef *responses, void *( *newInstance )( void ), int classSize );
void BuildResponseList( void );
};
/***********************************************************************
SafePtr
***********************************************************************/
class SafePtrBase;
class Class;
class EXPORT_FROM_DLL SafePtrBase
{
private:
void AddReference( Class *ptr );
void RemoveReference( Class *ptr );
protected:
SafePtrBase *prevSafePtr;
SafePtrBase *nextSafePtr;
Class *ptr;
public:
SafePtrBase();
virtual ~SafePtrBase();
void InitSafePtr( Class *newptr );
void Clear( void );
};
/***********************************************************************
Class
***********************************************************************/
#define CLASS_DECLARATION( nameofsuperclass, nameofclass, classid ) \
ClassDef nameofclass::ClassInfo \
( \
#nameofclass, classid, #nameofsuperclass, \
nameofclass::Responses, nameofclass::_newInstance, \
sizeof( nameofclass ) \
); \
EXPORT_FROM_DLL void *nameofclass::_newInstance( void ) \
{ \
return new nameofclass; \
} \
ClassDef *nameofclass::classinfo( void ) \
{ \
return &( nameofclass::ClassInfo ); \
}
#define CLASS_PROTOTYPE( nameofclass ) \
public: \
static ClassDef ClassInfo; \
static void *nameofclass::_newInstance( void ); \
virtual ClassDef *nameofclass::classinfo( void ); \
static ResponseDef nameofclass::Responses[];
class EXPORT_FROM_DLL Class
{
private:
SafePtrBase *SafePtrList;
friend class SafePtrBase;
public:
CLASS_PROTOTYPE( Class );
void * operator new( size_t );
void operator delete( void * );
Class();
virtual ~Class();
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
void warning( const char *function, const char *fmt, ... );
void error( const char *function, const char *fmt, ... );
qboolean inheritsFrom( ClassDef *c );
qboolean inheritsFrom( const char *name );
qboolean isInheritedBy( const char *name );
qboolean isInheritedBy( ClassDef *c );
const char *getClassname( void );
const char *getClassID( void );
const char *getSuperclass( void );
void *newInstance( void );
};
EXPORT_FROM_DLL void BuildEventResponses( void );
EXPORT_FROM_DLL ClassDef *getClassForID( const char *name );
EXPORT_FROM_DLL ClassDef *getClass( const char *name );
EXPORT_FROM_DLL ClassDef *getClassList( void );
EXPORT_FROM_DLL void listAllClasses( void );
EXPORT_FROM_DLL void listInheritanceOrder( const char *classname );
EXPORT_FROM_DLL qboolean checkInheritance( ClassDef *superclass, ClassDef *subclass );
EXPORT_FROM_DLL qboolean checkInheritance( ClassDef *superclass, const char *subclass );
EXPORT_FROM_DLL qboolean checkInheritance( const char *superclass, const char *subclass );
EXPORT_FROM_DLL void DisplayMemoryUsage( void );
inline EXPORT_FROM_DLL qboolean Class::inheritsFrom
(
ClassDef *c
)
{
return checkInheritance( c, classinfo() );
}
inline EXPORT_FROM_DLL qboolean Class::isInheritedBy
(
ClassDef *c
)
{
return checkInheritance( classinfo(), c );
}
// The lack of a space between the ")" and "inheritsFrom" is intentional.
// It allows the macro to compile like a function call. However, this
// may cause problems in some compilers (like gcc), so we may have to
// change this to work like a normal macro with the object passed in
// as a parameter to the macro.
#define isSubclassOf( classname )inheritsFrom( &classname::ClassInfo )
#define isSuperclassOf( classname )isInheritedBy( &classname::ClassInfo )
/***********************************************************************
SafePtr
***********************************************************************/
inline EXPORT_FROM_DLL SafePtrBase::SafePtrBase()
{
prevSafePtr = NULL;
nextSafePtr = NULL;
ptr = NULL;
}
inline EXPORT_FROM_DLL SafePtrBase::~SafePtrBase()
{
Clear();
}
inline EXPORT_FROM_DLL void SafePtrBase::Clear
(
void
)
{
if ( ptr )
{
RemoveReference( ptr );
ptr = NULL;
}
}
inline EXPORT_FROM_DLL void SafePtrBase::InitSafePtr
(
Class *newptr
)
{
if ( ptr != newptr )
{
if ( ptr )
{
RemoveReference( ptr );
}
ptr = newptr;
if ( ptr == NULL )
{
return;
}
AddReference( ptr );
}
}
inline EXPORT_FROM_DLL void SafePtrBase::AddReference
(
Class *ptr
)
{
if ( !ptr->SafePtrList )
{
ptr->SafePtrList = this;
LL_Reset( this, nextSafePtr, prevSafePtr );
}
else
{
LL_Add( ptr->SafePtrList, this, nextSafePtr, prevSafePtr );
}
}
inline EXPORT_FROM_DLL void SafePtrBase::RemoveReference
(
Class *ptr
)
{
if ( ptr->SafePtrList == this )
{
if ( ptr->SafePtrList->nextSafePtr == this )
{
ptr->SafePtrList = NULL;
}
else
{
ptr->SafePtrList = nextSafePtr;
LL_Remove( this, nextSafePtr, prevSafePtr );
}
}
else
{
LL_Remove( this, nextSafePtr, prevSafePtr );
}
}
template<class T>
class EXPORT_FROM_DLL SafePtr : public SafePtrBase
{
public:
SafePtr( T* objptr = 0 );
SafePtr( const SafePtr& obj );
SafePtr& operator=( const SafePtr& obj );
SafePtr& operator=( T * const obj );
friend EXPORT_FROM_DLL int operator==( SafePtr<T> a, T *b );
friend EXPORT_FROM_DLL int operator!=( SafePtr<T> a, T *b );
friend EXPORT_FROM_DLL int operator==( T *a, SafePtr<T> b );
friend EXPORT_FROM_DLL int operator!=( T *a, SafePtr<T> b );
operator T*() const;
T* operator->() const;
T& operator*() const;
};
template<class T>
inline EXPORT_FROM_DLL SafePtr<T>::SafePtr( T* objptr )
{
InitSafePtr( objptr );
}
template<class T>
inline EXPORT_FROM_DLL SafePtr<T>::SafePtr( const SafePtr& obj )
{
InitSafePtr( obj.ptr );
}
template<class T>
inline EXPORT_FROM_DLL SafePtr<T>& SafePtr<T>::operator=( const SafePtr& obj )
{
InitSafePtr( obj.ptr );
return *this;
}
template<class T>
inline EXPORT_FROM_DLL SafePtr<T>& SafePtr<T>::operator=( T * const obj )
{
InitSafePtr( obj );
return *this;
}
template<class T>
inline EXPORT_FROM_DLL int operator==
(
SafePtr<T> a,
T* b
)
{
return a.ptr == b;
}
template<class T>
inline EXPORT_FROM_DLL int operator!=
(
SafePtr<T> a,
T* b
)
{
return a.ptr != b;
}
template<class T>
inline EXPORT_FROM_DLL int operator==
(
T* a,
SafePtr<T> b
)
{
return a == b.ptr;
}
template<class T>
inline EXPORT_FROM_DLL int operator!=
(
T* a,
SafePtr<T> b
)
{
return a != b.ptr;
}
template<class T>
inline SafePtr<T>::operator T*() const
{
return ( T * )ptr;
}
template<class T>
inline T* SafePtr<T>::operator->() const
{
return ( T * )ptr;
}
template<class T>
inline T& SafePtr<T>::operator*() const
{
return *( T * )ptr;
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL SafePtr<Class>;
#endif
typedef SafePtr<Class> ClassPtr;
#include "archive.h"
#endif /* class.h */

1394
console.cpp Normal file

File diff suppressed because it is too large Load Diff

272
console.h Normal file
View File

@ -0,0 +1,272 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/console.h $
// $Revision:: 30 $
// $Author:: Jimdose $
// $Date:: 10/25/98 11:53p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/console.h $
//
// 30 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 29 10/19/98 6:13p Jimdose
// Unarchive now accounts for the mission computer
//
// 28 10/10/98 9:59p Jimdose
// working on console savegames
//
// 27 10/07/98 11:43p Jimdose
// Rewrote archiving functions
//
// 26 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 25 5/25/98 2:28p Aldie
// Fixed issues with not loading game dll
//
// 24 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 23 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 22 5/02/98 8:37p Aldie
// More console stuff for demos
//
// 21 4/30/98 4:46p Aldie
// Server side console states.
//
// 20 4/27/98 1:51p Aldie
// Added activate to console.
//
// 19 4/21/98 2:25p Aldie
//
// 18 4/18/98 6:12p Aldie
//
// 17 4/07/98 3:49p Aldie
//
// 16 4/05/98 9:27p Aldie
// Added foreground color to consoles.
//
//
// DESCRIPTION:
// Consoles are script controlled decals that can change dynamically. Eventually,
// their behaviour will be expanded to include interaction with the player as well.
//
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
#include "g_local.h"
#include "trigger.h"
#include "container.h"
// Console stuff
extern Event EV_EnterConsole;
extern Event EV_ExitConsole;
extern Event EV_KickFromConsole;
class EXPORT_FROM_DLL Console : public TriggerUse
{
private:
str console_name;
str menufile;
int rows;
int cols;
int console_number;
qboolean scroll;
qboolean menu;
float virtual_width;
float virtual_height;
float fraction;
qboolean created;
public:
CLASS_PROTOTYPE( Console );
Console( );
~Console( );
void Activate( Event *ev );
void ProcessCmd( Event *ev );
void Use(Event *ev);
const char *ConsoleName() { return console_name.c_str(); };
int ConsoleNumber() {return console_number;};
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Console::Archive
(
Archiver &arc
)
{
TriggerUse::Archive( arc );
arc.WriteString( console_name );
arc.WriteString( menufile );
arc.WriteInteger( rows );
arc.WriteInteger( cols );
arc.WriteInteger( console_number );
arc.WriteBoolean( scroll );
arc.WriteBoolean( menu );
arc.WriteFloat( virtual_width );
arc.WriteFloat( virtual_height );
arc.WriteFloat( fraction );
arc.WriteBoolean( created );
}
inline EXPORT_FROM_DLL void Console::Unarchive
(
Archiver &arc
)
{
TriggerUse::Unarchive( arc );
arc.ReadString( &console_name );
arc.ReadString( &menufile );
arc.ReadInteger( &rows );
arc.ReadInteger( &cols );
arc.ReadInteger( &console_number );
arc.ReadBoolean( &scroll );
arc.ReadBoolean( &menu );
arc.ReadFloat( &virtual_width );
arc.ReadFloat( &virtual_height );
arc.ReadFloat( &fraction );
arc.ReadBoolean( &created );
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<Console *>;
#endif
class EXPORT_FROM_DLL ConsoleManager : public Listener
{
private:
Container<Console *> consoleList;
int mission_console_number;
public:
CLASS_PROTOTYPE( ConsoleManager );
int AddConsole( Console *console );
void RemoveConsole( Console *console );
void CreateMissionComputer( void );
void Reset();
int ConsoleExists( str con_name );
qboolean ConsoleExists(int con_number);
void ProcessCmd(Event *ev);
void ProcessVar(Event *ev);
void ConsolePositionPositive( Event *ev );
void ConsolePositionNegative( Event *ev );
void ConsolePositionReturn( Event *ev );
void ConsoleMenuInfo( Event *ev );
void ConsolePrint( Event *ev );
void ConsoleNewline( Event *ev );
void ConsoleLayout( Event *ev );
void ConsoleLayoutFile( Event *ev );
void ConsoleAppLayout( Event *ev );
void ConsoleClearLayout( Event *ev );
void ConsoleVirtualWidth ( Event *ev );
void ConsoleVirtualHeight ( Event *ev );
void ConsoleFraction ( Event *ev );
void ConsoleDeactivate ( Event *ev );
void ConsoleActivate( Event *ev );
void ConsoleRows ( Event *ev );
void ConsoleColumns ( Event *ev );
void ConsoleClear ( Event *ev );
void ConsoleLoadMenuFile ( Event *ev );
void ConsoleFocus ( Event *ev );
void ConsoleForeground ( Event *ev );
void ConsoleMenuActive ( Event *ev );
void ConsoleMenuInactive ( Event *ev );
void ConsoleStatusBar ( Event *ev );
void ConsoleStatusBarValue ( Event *ev );
void ConsoleKickUsers ( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void ConsoleManager::Archive
(
Archiver &arc
)
{
int i;
int num;
netconsole_t *s;
Listener::Archive( arc );
arc.WriteInteger( mission_console_number );
num = consoleList.NumObjects();
arc.WriteInteger( num );
for( i = 1; i <= num; i++ )
{
arc.WriteObjectPointer( consoleList.ObjectAt( i ) );
}
// read the console states
s = g_consoles;
for( i = 0; i < game.maxconsoles; i++, s++ )
{
arc.WriteBoolean( s->inuse );
if ( s->inuse )
{
arc.WriteRaw( &s->s, sizeof( s->s ) );
}
}
}
inline EXPORT_FROM_DLL void ConsoleManager::Unarchive
(
Archiver &arc
)
{
int i;
int num;
netconsole_t *s;
Reset();
Listener::Unarchive( arc );
arc.ReadInteger( &mission_console_number );
arc.ReadInteger( &num );
consoleList.Resize( num );
for( i = 1; i <= num; i++ )
{
arc.ReadObjectPointer( ( Class ** )consoleList.AddressOfObjectAt( i ) );
}
// write the console states
s = g_consoles;
for( i = 0; i < game.maxconsoles; i++, s++ )
{
arc.ReadBoolean( &s->inuse );
if ( s->inuse )
{
arc.ReadRaw( &s->s, sizeof( s->s ) );
}
}
// account for mission computer since we don't create an object for it.
globals.num_consoles++;
}
extern ConsoleManager consoleManager;
#endif /* console.h */

464
container.h Normal file
View File

@ -0,0 +1,464 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/container.h $
// $Revision:: 17 $
// $Author:: Jimdose $
// $Date:: 10/25/98 11:53p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/container.h $
//
// 17 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 16 10/07/98 11:45p Jimdose
// Added \n to dprintf's
// Made resize assert only when size was negative
//
// 15 9/21/98 6:01p Markd
// tried putting archiving back in, but took it out again, when I realized it
// wouldn't work because the class hierarchy hasn't been created yet.
//
// 14 9/21/98 4:21p Markd
// Put in archive functions and rewrote all archive routines
//
// 13 8/20/98 4:42p Jimdose
// Added Sort function.
//
// 12 7/09/98 1:40a Jimdose
// ClearObjectList now only reallocates the list if there are any objects in
// the list
//
// 11 5/25/98 2:29p Aldie
// Fixed issues with not loading game dll
//
// 10 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 9 3/04/98 1:43p Jimdose
// Changed IndexOfObject so that it did a comparison instead of a memcmp
//
// 8 3/02/98 5:27p Jimdose
// Changed Container to a template to make it more flexible
//
// 7 2/03/98 10:51a Jimdose
// Updated to work with Quake 2 engine
//
// 5 11/20/97 9:03p Jimdose
// Changed Container class to use entity # (int) instead of void *
//
// 4 11/07/97 6:37p Jimdose
// Added FreeObjectList to empty the list and free up the memory.
// Changed ClearObjectList to only empty the list, but keep the memory
// allocated.
// Changed all functions from being virtual to being exported by the DLL.
//
// 3 10/27/97 2:49p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 6:13p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Base class for a dynamic array. Allows adding, removing, index of,
// and finding of entries with specified value. Originally created for
// cataloging entities, but pointers to objects that may be removed at
// any time are bad to keep around, so only entity numbers should be
// used in the future.
//
#ifndef __CONTAINER_H__
#define __CONTAINER_H__
#include "g_local.h"
#include <stdlib.h>
template< class Type >
class EXPORT_FROM_DLL Container
{
private:
Type *objlist;
int numobjects;
int maxobjects;
public:
Container();
~Container<Type>();
void FreeObjectList( void );
void ClearObjectList( void );
int NumObjects( void );
void Resize( int maxelements );
void SetObjectAt( int index, Type& obj );
int AddObject( Type& obj );
int AddUniqueObject( Type& obj );
void AddObjectAt( int index, Type& obj );
int IndexOfObject( Type& obj );
qboolean ObjectInList( Type& obj );
Type& ObjectAt( int index );
Type *AddressOfObjectAt( int index );
void RemoveObjectAt( int index );
void RemoveObject( Type& obj );
void Sort( int ( __cdecl *compare )( const void *elem1, const void *elem2 ) );
// virtual void Archive( Archiver &arc );
// virtual void Unarchive( Archiver &arc );
};
/*
template< class Type >
EXPORT_FROM_DLL void Container<Type>::Archive
(
Archiver &arc
)
{
int i;
arc.WriteInteger( maxobjects );
arc.WriteInteger( numobjects );
for ( i = 0; i < numobjects; i++ )
{
arc.WriteRaw( objlist[ i ], sizeof( Type ) );
}
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::Unarchive
(
Archiver &arc
)
{
int i;
FreeObjectList();
maxobjects = arc.ReadInteger();
numobjects = arc.ReadInteger();
objlist = new Type[ maxobjects ];
for ( i = 0; i < numobjects; i++ )
{
arc.ReadRaw( &objlist[ i ], sizeof( Type ) );
}
}
*/
template< class Type >
Container<Type>::Container()
{
objlist = NULL;
FreeObjectList();
}
template< class Type >
Container<Type>::~Container<Type>()
{
FreeObjectList();
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::FreeObjectList
(
void
)
{
if ( objlist )
{
delete[] objlist;
}
objlist = NULL;
numobjects = 0;
maxobjects = 0;
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::ClearObjectList
(
void
)
{
// only delete the list if we have objects in it
if ( objlist && numobjects )
{
delete[] objlist;
objlist = new Type[ maxobjects ];
numobjects = 0;
}
}
template< class Type >
EXPORT_FROM_DLL int Container<Type>::NumObjects
(
void
)
{
return numobjects;
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::Resize
(
int maxelements
)
{
Type *temp;
int i;
assert( maxelements >= 0 );
if ( maxelements <= 0 )
{
FreeObjectList();
return;
}
if ( !objlist )
{
maxobjects = maxelements;
objlist = new Type[ maxobjects ];
}
else
{
temp = objlist;
maxobjects = maxelements;
if ( maxobjects < numobjects )
{
maxobjects = numobjects;
}
objlist = new Type[ maxobjects ];
for( i = 0; i < numobjects; i++ )
{
objlist[ i ] = temp[ i ];
}
delete[] temp;
}
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::SetObjectAt
(
int index,
Type& obj
)
{
if ( ( index <= 0 ) || ( index > numobjects ) )
{
gi.error( "Container::SetObjectAt : index out of range" );
}
objlist[ index - 1 ] = obj;
}
template< class Type >
EXPORT_FROM_DLL int Container<Type>::AddObject
(
Type& obj
)
{
if ( !objlist )
{
Resize( 10 );
}
if ( numobjects == maxobjects )
{
Resize( maxobjects * 2 );
}
objlist[ numobjects ] = obj;
numobjects++;
return numobjects;
}
template< class Type >
EXPORT_FROM_DLL int Container<Type>::AddUniqueObject
(
Type& obj
)
{
int index;
index = IndexOfObject( obj );
if ( !index )
index = AddObject( obj );
return index;
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::AddObjectAt
(
int index,
Type& obj
)
{
//
// this should only be used when reconstructing a list that has to be identical to the original
//
if ( index > maxobjects )
{
Resize( index );
}
if ( index > numobjects )
{
numobjects = index;
}
SetObjectAt( index, obj );
}
template< class Type >
EXPORT_FROM_DLL int Container<Type>::IndexOfObject
(
Type& obj
)
{
int i;
for( i = 0; i < numobjects; i++ )
{
if ( objlist[ i ] == obj )
{
return i + 1;
}
}
return 0;
}
template< class Type >
EXPORT_FROM_DLL qboolean Container<Type>::ObjectInList
(
Type& obj
)
{
if ( !IndexOfObject( obj ) )
{
return false;
}
return true;
}
template< class Type >
EXPORT_FROM_DLL Type& Container<Type>::ObjectAt
(
int index
)
{
if ( ( index <= 0 ) || ( index > numobjects ) )
{
gi.error( "Container::ObjectAt : index out of range" );
}
return objlist[ index - 1 ];
}
template< class Type >
EXPORT_FROM_DLL Type * Container<Type>::AddressOfObjectAt
(
int index
)
{
//
// this should only be used when reconstructing a list that has to be identical to the original
//
if ( index > maxobjects )
{
gi.error( "Container::AddressOfObjectAt : index is greater than maxobjects" );
}
if ( index > numobjects )
{
numobjects = index;
}
return &objlist[ index - 1 ];
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::RemoveObjectAt
(
int index
)
{
int i;
if ( !objlist )
{
gi.dprintf( "Container::RemoveObjectAt : Empty list\n" );
return;
}
if ( ( index <= 0 ) || ( index > numobjects ) )
{
gi.error( "Container::RemoveObjectAt : index out of range" );
return;
}
i = index - 1;
numobjects--;
for( i = index - 1; i < numobjects; i++ )
{
objlist[ i ] = objlist[ i + 1 ];
}
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::RemoveObject
(
Type& obj
)
{
int index;
index = IndexOfObject( obj );
if ( !index )
{
gi.dprintf( "Container::RemoveObject : Object not in list\n" );
return;
}
RemoveObjectAt( index );
}
template< class Type >
EXPORT_FROM_DLL void Container<Type>::Sort
(
int ( __cdecl *compare )( const void *elem1, const void *elem2 )
)
{
if ( !objlist )
{
gi.dprintf( "Container::RemoveObjectAt : Empty list\n" );
return;
}
qsort( ( void * )objlist, ( size_t )numobjects, sizeof( Type ), compare );
}
//
// Exported templated classes must be explicitly instantiated
//
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<int>;
#endif
#endif /* container.h */

66
ctf.cpp Normal file
View File

@ -0,0 +1,66 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/ctf.cpp $
// $Revision:: 3 $
// $Author:: Jimdose $
// $Date:: 10/10/98 3:37a $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/ctf.cpp $
//
// 3 10/10/98 3:37a Jimdose
// Began converting to Sin
//
// 2 10/10/98 3:03a Jimdose
// Created file
//
// 1 10/10/98 3:02a Jimdose
//
// DESCRIPTION:
// Game code for Threewave Capture the Flag.
//
// The original source for this code was graciously provided by Zoid and
// Id Software. Many thanks!
//
// Original credits:
//
// Programming - Dave 'Zoid' Kirsch
// Original CTF Art Design - Brian 'Whaleboy' Cozzens
//
#include "g_local.h"
#include "ctf.h"
#include "ctf_player.h"
cvar_t *ctf;
cvar_t *ctf_forcejoin;
typedef struct ctfgame_s
{
int team1, team2;
int total1, total2; // these are only set when going into intermission!
float last_flag_capture;
int last_capture_team;
} ctfgame_t;
ctfgame_t ctfgame;
qboolean techspawn = false;
void CTFInit
(
void
)
{
ctf = gi.cvar("ctf", "1", CVAR_SERVERINFO);
ctf_forcejoin = gi.cvar("ctf_forcejoin", "", 0);
memset( &ctfgame, 0, sizeof( ctfgame ) );
techspawn = false;
}

167
ctf.h Normal file
View File

@ -0,0 +1,167 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/ctf.h $
// $Revision:: 2 $
// $Author:: Jimdose $
// $Date:: 10/10/98 3:03a $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/ctf.h $
//
// 2 10/10/98 3:03a Jimdose
// Created file
//
// 1 10/10/98 3:02a Jimdose
//
// DESCRIPTION:
// Game code for Threewave Capture the Flag.
//
// The original source for this code was graciously provided by Zoid and
// Id Software. Many thanks!
//
// Original credits:
//
// Programming - Dave 'Zoid' Kirsch
// Original CTF Art Design - Brian 'Whaleboy' Cozzens
//
#ifndef __CTF_H__
#define __CTF_H__
#include "g_local.h"
#define CTF_VERSION 1.02
#define CTF_VSTRING2(x) #x
#define CTF_VSTRING(x) CTF_VSTRING2(x)
#define CTF_STRING_VERSION CTF_VSTRING(CTF_VERSION)
#define STAT_CTF_TEAM1_PIC 17
#define STAT_CTF_TEAM1_CAPS 18
#define STAT_CTF_TEAM2_PIC 19
#define STAT_CTF_TEAM2_CAPS 20
#define STAT_CTF_FLAG_PIC 21
#define STAT_CTF_JOINED_TEAM1_PIC 22
#define STAT_CTF_JOINED_TEAM2_PIC 23
#define STAT_CTF_TEAM1_HEADER 24
#define STAT_CTF_TEAM2_HEADER 25
#define STAT_CTF_TECH 26
#define STAT_CTF_ID_VIEW 27
typedef enum
{
CTF_NOTEAM,
CTF_TEAM1,
CTF_TEAM2
} ctfteam_t;
typedef enum
{
CTF_STATE_START,
CTF_STATE_PLAYING
} ctfstate_t;
typedef enum
{
CTF_GRAPPLE_STATE_FLY,
CTF_GRAPPLE_STATE_PULL,
CTF_GRAPPLE_STATE_HANG
} ctfgrapplestate_t;
extern cvar_t *ctf;
#define CTF_TEAM1_SKIN "ctf_r"
#define CTF_TEAM2_SKIN "ctf_b"
#define DF_CTF_FORCEJOIN 131072
#define DF_ARMOR_PROTECT 262144
#define DF_CTF_NO_TECH 524288
#define CTF_CAPTURE_BONUS 15 // what you get for capture
#define CTF_TEAM_BONUS 10 // what your team gets for capture
#define CTF_RECOVERY_BONUS 1 // what you get for recovery
#define CTF_FLAG_BONUS 0 // what you get for picking up enemy flag
#define CTF_FRAG_CARRIER_BONUS 2 // what you get for fragging enemy flag carrier
#define CTF_FLAG_RETURN_TIME 40 // seconds until auto return
#define CTF_CARRIER_DANGER_PROTECT_BONUS 2 // bonus for fraggin someone who has recently hurt your flag carrier
#define CTF_CARRIER_PROTECT_BONUS 1 // bonus for fraggin someone while either you or your target are near your flag carrier
#define CTF_FLAG_DEFENSE_BONUS 1 // bonus for fraggin someone while either you or your target are near your flag
#define CTF_RETURN_FLAG_ASSIST_BONUS 1 // awarded for returning a flag that causes a capture to happen almost immediately
#define CTF_FRAG_CARRIER_ASSIST_BONUS 2 // award for fragging a flag carrier if a capture happens almost immediately
#define CTF_TARGET_PROTECT_RADIUS 400 // the radius around an object being defended where a target will be worth extra frags
#define CTF_ATTACKER_PROTECT_RADIUS 400 // the radius around an object being defended where an attacker will get extra frags when making kills
#define CTF_CARRIER_DANGER_PROTECT_TIMEOUT 8
#define CTF_FRAG_CARRIER_ASSIST_TIMEOUT 10
#define CTF_RETURN_FLAG_ASSIST_TIMEOUT 10
#define CTF_AUTO_FLAG_RETURN_TIMEOUT 30 // number of seconds before dropped flag auto-returns
#define CTF_TECH_TIMEOUT 60 // seconds before techs spawn again
#define CTF_GRAPPLE_SPEED 650 // speed of grapple in flight
#define CTF_GRAPPLE_PULL_SPEED 650 // speed player is pulled at
#if 0
void CTFInit(void);
void SP_info_player_team1(edict_t *self);
void SP_info_player_team2(edict_t *self);
char *CTFTeamName(int team);
char *CTFOtherTeamName(int team);
void CTFAssignSkin(edict_t *ent, char *s);
void CTFAssignTeam(gclient_t *who);
edict_t *SelectCTFSpawnPoint (edict_t *ent);
qboolean CTFPickup_Flag(edict_t *ent, edict_t *other);
qboolean CTFDrop_Flag(edict_t *ent, gitem_t *item);
void CTFEffects(edict_t *player);
void CTFCalcScores(void);
void SetCTFStats(edict_t *ent);
void CTFDeadDropFlag(edict_t *self);
void CTFScoreboardMessage (edict_t *ent, edict_t *killer);
void CTFTeam_f (edict_t *ent);
void CTFID_f (edict_t *ent);
void CTFSay_Team(edict_t *who, char *msg);
void CTFFlagSetup (edict_t *ent);
void CTFResetFlag(int ctf_team);
void CTFFragBonuses(edict_t *targ, edict_t *inflictor, edict_t *attacker);
void CTFCheckHurtCarrier(edict_t *targ, edict_t *attacker);
// GRAPPLE
void CTFWeapon_Grapple (edict_t *ent);
void CTFPlayerResetGrapple(edict_t *ent);
void CTFGrapplePull(edict_t *self);
void CTFResetGrapple(edict_t *self);
//TECH
gitem_t *CTFWhat_Tech(edict_t *ent);
qboolean CTFPickup_Tech (edict_t *ent, edict_t *other);
void CTFDrop_Tech(edict_t *ent, gitem_t *item);
void CTFDeadDropTech(edict_t *ent);
void CTFSetupTechSpawn(void);
int CTFApplyResistance(edict_t *ent, int dmg);
int CTFApplyStrength(edict_t *ent, int dmg);
qboolean CTFApplyStrengthSound(edict_t *ent);
qboolean CTFApplyHaste(edict_t *ent);
void CTFApplyHasteSound(edict_t *ent);
void CTFApplyRegeneration(edict_t *ent);
qboolean CTFHasRegeneration(edict_t *ent);
void CTFRespawnTech(edict_t *ent);
void CTFOpenJoinMenu(edict_t *ent);
qboolean CTFStartClient(edict_t *ent);
qboolean CTFCheckRules(void);
void SP_misc_ctf_banner (edict_t *ent);
void SP_misc_ctf_small_banner (edict_t *ent);
#endif
#endif /* ctf.h */

208
ctf_player.cpp Normal file
View File

@ -0,0 +1,208 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/ctf_player.cpp $
// $Revision:: 4 $
// $Author:: Markd $
// $Date:: 10/10/98 12:38p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/ctf_player.cpp $
//
// 4 10/10/98 12:38p Markd
// Fixed a misnamed function
//
// 3 10/10/98 3:37a Jimdose
// Began converting to Sin
//
// 2 10/10/98 3:03a Jimdose
// Created file
//
// 1 10/10/98 3:02a Jimdose
//
// DESCRIPTION:
// Player code for Threewave Capture the Flag.
//
// The original source for this code was graciously provided by Zoid and
// Id Software. Many thanks!
//
// Original credits:
//
// Programming - Dave 'Zoid' Kirsch
// Original CTF Art Design - Brian 'Whaleboy' Cozzens
//
#include "g_local.h"
#include "ctf_player.h"
extern Event EV_Player_Respawn;
CLASS_DECLARATION( Player, CTF_Player, "player" );
ResponseDef CTF_Player::Responses[] =
{
{ &EV_ClientMove, ( Response )CTF_Player::ClientThink },
{ &EV_Player_Respawn, ( Response )CTF_Player::Respawn },
{ &EV_Killed, ( Response )CTF_Player::Killed },
{ &EV_GotKill, ( Response )CTF_Player::GotKill },
{ &EV_ClientEndFrame, ( Response )CTF_Player::EndFrame },
{ NULL, NULL }
};
CTF_Player::CTF_Player()
{
}
void CTF_Player::Init
(
void
)
{
Player::Init();
}
CTF_Player::~CTF_Player()
{
}
void CTF_Player::Respawn
(
Event *ev
)
{
Player::Respawn( ev );
}
const char *CTF_Player::TeamName
(
void
)
{
switch ( team )
{
case CTF_TEAM1:
return "RED";
case CTF_TEAM2:
return "BLUE";
}
return "UKNOWN";
}
const char *CTF_Player::OtherTeamName
(
void
)
{
switch ( team )
{
case CTF_TEAM1:
return "BLUE";
case CTF_TEAM2:
return "RED";
}
return "UKNOWN";
}
int CTF_Player::Team
(
void
)
{
return team;
}
int CTF_Player::OtherTeam
(
void
)
{
switch ( team )
{
case CTF_TEAM1:
return CTF_TEAM2;
case CTF_TEAM2:
return CTF_TEAM1;
}
// invalid value
return -1;
}
void CTF_Player::Killed
(
Event *ev
)
{
Player::Killed( ev );
}
void CTF_Player::Prethink
(
void
)
{
Player::Prethink();
}
void CTF_Player::Postthink
(
void
)
{
Player::Postthink();
}
void CTF_Player::ClientThink
(
Event *ev
)
{
Player::ClientThink( ev );
}
void CTF_Player::UpdateStats
(
void
)
{
Player::UpdateStats();
}
void CTF_Player::EndFrame
(
Event *ev
)
{
Player::EndFrame( ev );
}
void CTF_Player::GotKill
(
Event *ev
)
{
Player::GotKill( ev );
}

93
ctf_player.h Normal file
View File

@ -0,0 +1,93 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/ctf_player.h $
// $Revision:: 3 $
// $Author:: Jimdose $
// $Date:: 10/10/98 3:37a $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/ctf_player.h $
//
// 3 10/10/98 3:37a Jimdose
// Began converting to Sin
//
// 2 10/10/98 3:03a Jimdose
// Created file
//
// 1 10/10/98 3:02a Jimdose
//
// DESCRIPTION:
// Player code for Threewave Capture the Flag.
//
// The original source for this code was graciously provided by Zoid and
// Id Software. Many thanks!
//
// Original credits:
//
// Programming - Dave 'Zoid' Kirsch
// Original CTF Art Design - Brian 'Whaleboy' Cozzens
//
#ifndef __CTF_PLAYER_H__
#define __CTF_PLAYER_H__
#include "player.h"
#include "ctf.h"
class EXPORT_FROM_DLL CTF_Player : public Player
{
private:
int team;
public:
CLASS_PROTOTYPE( CTF_Player );
CTF_Player();
virtual ~CTF_Player();
virtual void Init( void );
const char *TeamName( void );
const char *OtherTeamName( void );
int Team( void );
int OtherTeam( void );
virtual void Respawn( Event *ev );
virtual void Killed( Event *ev );
virtual void GotKill( Event *ev );
void ClientThink( Event *ev );
virtual void EndFrame( Event *ev );
virtual void UpdateStats( void );
virtual void Prethink( void );
virtual void Postthink( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void CTF_Player::Archive
(
Archiver &arc
)
{
Player::Archive( arc );
}
inline EXPORT_FROM_DLL void CTF_Player::Unarchive
(
Archiver &arc
)
{
Player::Unarchive( arc );
}
#endif /* ctf_player.h */

437
datamap.h Normal file
View File

@ -0,0 +1,437 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/datamap.h $
// $Revision:: 2 $
// $Author:: Jimdose $
// $Date:: 8/31/98 5:40p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/datamap.h $
//
// 2 8/31/98 5:40p Jimdose
// Created file. Still need to test it.
//
// 1 8/31/98 5:40p Jimdose
//
// DESCRIPTION:
// Template class for mapping values of one data type to another.
//
#ifndef __DATAMAP_H__
#define __DATAMAP_H__
#include "g_local.h"
#include <stdlib.h>
template< class Key, class Value >
class EXPORT_FROM_DLL DataMap
{
private:
Key **keyarray;
Value **valuearray;
int numobjects;
int maxobjects;
public:
DataMap();
DataMap( DataMap<Key,Value> &map );
~DataMap<Key,Value>();
void FreeObjectList( void );
void ClearObjectList( void );
int NumObjects( void );
void Resize( int maxelements );
Value& operator[]( Key key );
int SetValue( Key key, Value obj );
void SetValueAt( int index, Value& obj );
int AddKey( Key& key );
int AddKeyPair( Key& key, Value& value );
int FindKey( Key& key );
void KeyInList( Key& key );
Value& ValueAt( int index );
Key& KeyAt( int index );
void RemoveKeyAt( int index );
void RemoveKey( Key& key );
};
template< class Key, class Value>
DataMap<Key,Value>::DataMap()
{
keyarray = NULL;
valuearray = NULL;
numobjects = 0;
maxobjects = 0;
}
template< class Key, class Value>
DataMap<Key,Value>::DataMap( DataMap<Key,Value> &map )
{
numobjects = 0;
maxobjects = 0;
keyarray = NULL;
valuearray = NULL;
Resize( map.maxobjects );
for( i = 0; i < map.numobjects; i++ )
{
AddKeyPair( map.KeyAt( i ), map.ValueAt( i ) );
}
}
template< class Key, class Value>
DataMap<Key,Value>::~DataMap<Key,Value>()
{
FreeObjectList();
}
template< class Key, class Value>
EXPORT_FROM_DLL void DataMap<Key,Value>::FreeObjectList
(
void
)
{
if ( keyarray )
{
ClearObjectList();
delete[] keyarray;
delete[] valuearray;
}
keyarray = NULL;
valuearray = NULL;
numobjects = 0;
maxobjects = 0;
}
template< class Key, class Value>
EXPORT_FROM_DLL void DataMap<Key,Value>::ClearObjectList
(
void
)
{
// only delete the list if we have objects in it
if ( keyarray && numobjects )
{
for( i = 0; i < numobjects; i++ )
{
delete keyarray[ i ];
delete valuearray[ i ];
}
memset( keyarray, 0, maxobjects * sizeof( Key * ) );
memset( valuearray, 0, maxobjects * sizeof( Value * ) );
numobjects = 0;
}
}
template< class Key, class Value>
EXPORT_FROM_DLL int DataMap<Key,Value>::NumObjects
(
void
)
{
return numobjects;
}
template< class Key, class Value>
EXPORT_FROM_DLL void DataMap<Key,Value>::Resize
(
int maxelements
)
{
Key *keytemp;
Value *valuetemp;
assert( maxelements > 0 );
if ( maxelements <= 0 )
{
FreeObjectList();
return;
}
if ( !keyarray )
{
maxobjects = maxelements;
keyarray = new Key[ maxobjects ];
memset( keyarray, 0, maxobjects * sizeof( Key * ) );
valuearray = new Value[ maxobjects ];
memset( valuearray, 0, maxobjects * sizeof( Value * ) );
}
else
{
keytemp = keyarray;
valuetemp = valuearray;
maxobjects = maxelements;
if ( maxobjects < numobjects )
{
maxobjects = numobjects;
}
keyarray = new Key[ maxobjects ];
valuearray = new Value[ maxobjects ];
memcpy( keyarray, keytemp, sizeof( Key * ) * maxobjects );
memcpy( valuearray, valuetemp, sizeof( Value * ) * maxobjects );
delete[] keytemp;
delete[] valuetemp;
}
}
template< class Key, class Value>
EXPORT_FROM_DLL inline Value& DataMap<Key,Value>::operator[]
(
Key key
)
{
int index;
index = FindKey( key );
if ( index == -1 )
{
index = AddKey( key );
}
assert( ( index >= 0 ) && ( index < numobjects ) );
assert( valuearray );
return *valuearray[ index ];
}
template< class Key, class Value>
EXPORT_FROM_DLL inline int DataMap<Key,Value>::SetValue
(
Key key,
Value value
)
{
int index;
index = FindKey( key );
if ( index == -1 )
{
index = AddKey( key );
}
assert( ( index >= 0 ) && ( index < numobjects ) );
assert( valuearray );
*valuearray[ index ] = value;
return index;
}
template< class Key, class Value>
EXPORT_FROM_DLL void DataMap<Key,Value>::SetValueAt
(
int index,
Value& obj
)
{
if ( ( index < 0 ) || ( index >= numobjects ) )
{
gi.error( "DataMap::SetValueAt : index out of range" );
}
assert( valuearray );
*valuearray[ index ] = obj;
}
template< class Key, class Value>
EXPORT_FROM_DLL int DataMap<Key,Value>::AddKey
(
Key& key
)
{
int index;
if ( !keyarray )
{
Resize( 10 );
}
if ( numobjects == maxobjects )
{
Resize( maxobjects * 2 );
}
index = numobjects;
numobjects++;
keyarray[ index ] = new Key;
valuearray[ index ] = new Value;
*keyarray[ index ] = key;
return index;
}
template< class Key, class Value>
EXPORT_FROM_DLL int DataMap<Key,Value>::AddKeyPair
(
Key& key,
Value& value
)
{
int index;
if ( !keyarray )
{
Resize( 10 );
}
if ( numobjects == maxobjects )
{
Resize( maxobjects * 2 );
}
index = numobjects;
numobjects++;
keyarray[ index ] = new Key;
valuearray[ index ] = new Value;
*keyarray[ index ] = key;
*valuearray[ index ] = value;
return index;
}
template< class Key, class Value>
EXPORT_FROM_DLL int DataMap<Key,Value>::FindKey
(
Key& key
)
{
int i;
for( i = 0; i < numobjects; i++ )
{
if ( *keyarray[ i ] == key )
{
return i;
}
}
return -1;
}
template< class Key, class Value>
EXPORT_FROM_DLL void DataMap<Key,Value>::KeyInList
(
Key& key
)
{
if ( FindKey( key ) == -1 )
{
return false;
}
return true;
}
template< class Key, class Value>
EXPORT_FROM_DLL Value &DataMap<Key,Value>::ValueAt
(
int index
)
{
if ( ( index < 0 ) || ( index >= numobjects ) )
{
gi.error( "DataMap::ValueAt : index out of range" );
}
return *valuearray[ index ];
}
template< class Key, class Value>
EXPORT_FROM_DLL Key &DataMap<Key,Value>::KeyAt
(
int index
)
{
if ( ( index < 0 ) || ( index >= numobjects ) )
{
gi.error( "DataMap::KeyAt : index out of range" );
}
return *keyarray[ index ];
}
template< class Key, class Value>
EXPORT_FROM_DLL void DataMap<Key,Value>::RemoveKeyAt
(
int index
)
{
int i;
if ( !keyarray )
{
gi.dprintf( "DataMap::RemoveKeyAt : Empty list" );
return;
}
if ( ( index < 0 ) || ( index >= numobjects ) )
{
gi.error( "DataMap::RemoveKeyAt : index out of range" );
return;
}
delete keyarray[ index ];
delete valuearray[ index ];
for( i = index; i < numobjects; i++ )
{
keyarray[ i ] = keyarray[ i + 1 ];
valuearray[ i ] = valuearray[ i + 1 ];
}
numobjects--;
keyarray[ numobjects ] = NULL;
valuearray[ numobjects ] = NULL;
}
template< class Key, class Value>
EXPORT_FROM_DLL void DataMap<Key,Value>::RemoveKey
(
Key& key
)
{
int index;
index = FindKey( key );
if ( index == -1 )
{
gi.dprintf( "DataMap::RemoveKey : Object not in list" );
return;
}
RemoveKeyAt( index );
}
#endif /* datamap.h */

135
deadbody.cpp Normal file
View File

@ -0,0 +1,135 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/deadbody.cpp $
// $Revision:: 13 $
// $Author:: Jimdose $
// $Date:: 11/19/98 9:28p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/deadbody.cpp $
//
// 13 11/19/98 9:28p Jimdose
// made deadbodies copy the gravaxis
//
// 12 11/11/98 11:11p Aldie
// Make deadbodies do blood and gib properly
//
// 11 11/10/98 7:20p Aldie
// Fix for deadbodies not displaying death properly
//
// 10 10/17/98 9:40p Markd
// dead body queue won't initialize unless in deathmatch or coop
//
// 9 10/10/98 1:26a Jimdose
// InitializeBodyQueue is disabled while loading savegames
//
// 8 9/22/98 5:19p Markd
// Put in new consolidated gib function
//
// 7 9/22/98 3:21p Markd
// put in parentmode lockout for blood and gibs
//
// 6 9/19/98 6:09p Markd
// changed linkentity to link() call
//
// 5 8/29/98 9:40p Jimdose
// Moved bodyque to deadbody
//
// 4 7/29/98 2:31p Aldie
// Changed health to a float
//
// 3 7/23/98 6:17p Aldie
// Updated damage system and fixed some damage related bugs. Also put tracers
// back to the way they were, and added gib event to funcscriptmodels
//
// 2 7/13/98 4:59p Aldie
// Added dead player bodies with gibbing
//
// DESCRIPTION:
// Dead body
#include "deadbody.h"
#include "gibs.h"
CLASS_DECLARATION( Sentient, Deadbody, "deadbody" );
ResponseDef Deadbody::Responses[] =
{
{ &EV_Gib, ( Response )Deadbody::GibEvent },
{ NULL, NULL }
};
void Deadbody::GibEvent
(
Event *ev
)
{
takedamage = DAMAGE_NO;
if ( sv_gibs->value && !parentmode->value )
{
setSolidType( SOLID_NOT );
hideModel();
CreateGibs( this, health, 1.0f, 3 );
}
}
void CopyToBodyQueue
(
edict_t *ent
)
{
edict_t *body;
// grab a body from the queue and cycle to the next one
body = &g_edicts[ ( int )maxclients->value + level.body_queue + 1 ];
level.body_queue = ( level.body_queue + 1 ) % BODY_QUEUE_SIZE;
gi.unlinkentity( ent );
gi.unlinkentity( body );
body->s = ent->s;
body->s.number = body - g_edicts;
body->svflags = ent->svflags;
body->solid = ent->solid;
body->clipmask = ent->clipmask;
body->owner = ent->owner;
body->entity->movetype = ent->entity->movetype;
body->entity->takedamage = DAMAGE_YES;
body->entity->deadflag = DEAD_DEAD;
body->s.renderfx &= ~RF_DONTDRAW;
body->entity->origin = ent->entity->worldorigin;
body->entity->setSize(ent->mins,ent->maxs);
body->entity->link();
body->entity->SetGravityAxis( ent->entity->gravaxis );
}
void InitializeBodyQueue
(
void
)
{
int i;
Deadbody *body;
if ( ( !LoadingSavegame ) && ( deathmatch->value || coop->value ) )
{
level.body_queue = 0;
for ( i=0; i<BODY_QUEUE_SIZE ; i++ )
{
body = new Deadbody;
body->edict->owner = NULL;
body->edict->s.skinnum = -1;
body->flags |= (FL_DIE_GIBS|FL_BLOOD);
}
}
}

50
deadbody.h Normal file
View File

@ -0,0 +1,50 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/deadbody.h $
// $Revision:: 5 $
// $Author:: Jimdose $
// $Date:: 11/18/98 9:18p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/deadbody.h $
//
// 5 11/18/98 9:18p Jimdose
// lowered number of bodies to 4
//
// 4 11/11/98 11:13p Aldie
// Made deadbodies blood and gib properly
//
// 3 8/29/98 9:48p Jimdose
// Added bodyqueue code to deadbody
//
// 2 7/13/98 5:01p Aldie
// Added dead player bodies with gibbing
//
// DESCRIPTION:
// Dead body
#ifndef __DEADBODY_H__
#define __DEADBODY_H__
#include "g_local.h"
#include "sentient.h"
#define BODY_QUEUE_SIZE 4
EXPORT_FROM_DLL void InitializeBodyQueue( void );
EXPORT_FROM_DLL void CopyToBodyQueue( edict_t *ent );
class EXPORT_FROM_DLL Deadbody : public Sentient
{
public:
CLASS_PROTOTYPE( Deadbody );
virtual void GibEvent( Event *ev );
};
#endif /* deadbody.h */

1433
doors.cpp Normal file

File diff suppressed because it is too large Load Diff

368
doors.h Normal file
View File

@ -0,0 +1,368 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/doors.h $
// $Revision:: 26 $
// $Author:: Jimdose $
// $Date:: 11/08/98 10:50p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/doors.h $
//
// 26 11/08/98 10:50p Jimdose
// reordered archived variables so that they match the order in the struct
//
// 25 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 24 10/23/98 11:10p Jimdose
// removed trigger_finished
//
// 23 10/21/98 10:58p Jimdose
// fixed (hopefully) most of the door bugs
//
// 22 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 21 9/03/98 9:07p Jimdose
// Added CanBeOpenedBy so that the AI can check if a door is useable by an
// actor
// changed owner to master
// Fixed bug with doors that don't stop
// opened doors can be used again to close them
// fixed door blocked
//
// 20 8/28/98 4:14p Markd
// Added sound_locked to doors
//
// 19 8/24/98 6:10p Markd
// removed dmg from doors
//
// 18 8/21/98 3:48p Markd
// Added openthread and closethread events
//
// 17 8/21/98 1:43a Markd
// Added full ScriptDoor functionality
//
// 16 7/26/98 3:40p Jimdose
// made locked public
//
// 15 7/10/98 2:09p Markd
// Added locking capability to doors
//
// 14 6/25/98 8:48p Markd
// Rewrote Item class, added keyed items to triggers, cleaned up item system
//
// 13 6/24/98 8:45p Markd
// Rewrote Door Code
//
// 12 5/13/98 4:54p Jimdose
// now uses SafePtrs
//
// 11 4/30/98 9:24p Jimdose
// Changed use of string to str class
//
// 10 3/29/98 9:38p Jimdose
// Changed killed to an event
//
// 9 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 8 3/11/98 2:25p Jimdose
// Updated to work with areaportals
//
// 7 3/07/98 5:06p Jimdose
// Converted to Quake2
//
// 5 12/06/97 4:50p Markd
// Added interpretCommands.
// Added GetArgs as commands for future processing
// Removed dmg,attentuatioin and volume, moved these to Trigger
//
// 4 10/27/97 2:50p Jimdose
// Removed dependency on quakedef.h
//
// 3 10/27/97 2:38p Jimdose
// Changed nextdoor from a Door * into an int.
//
// 2 9/26/97 5:23p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Doors are environment objects that slide open when activated by triggers
// or when used by the player.
//
#ifndef __DOORS_H__
#define __DOORS_H__
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
#include "scriptslave.h"
extern Event EV_Door_TryOpen;
extern Event EV_Door_GoDown;
extern Event EV_Door_GoUp;
extern Event EV_Door_HitBottom;
extern Event EV_Door_HitTop;
extern Event EV_Door_Fire;
extern Event EV_Door_Link;
extern Event EV_Door_SetSpeed;
extern Event EV_Door_Lock;
extern Event EV_Door_Unlock;
class Door;
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL SafePtr<Door>;
#endif
typedef SafePtr<Door> DoorPtr;
class EXPORT_FROM_DLL Door : public ScriptSlave
{
protected:
str sound_stop;
str sound_move;
str sound_message;
str sound_locked;
float lastblocktime;
float angle;
Vector dir;
Vector doormin;
Vector doormax;
float diropened;
int state;
int previous_state;
int trigger;
int nextdoor;
DoorPtr master;
void OpenEnd( Event *ev );
void CloseEnd( Event *ev );
void Close( Event *ev );
void Open( Event *ev );
void DoorUse( Event *ev );
void DoorFire( Event *ev );
void DoorBlocked( Event *ev );
void FieldTouched( Event *ev );
void TryOpen( Event *ev );
void SpawnTriggerField( Vector fmins, Vector fmaxs );
qboolean DoorTouches( Door *e1 );
void LinkDoors( Event *ev );
void SetTime( Event *ev );
void LockDoor( Event *ev );
void UnlockDoor( Event *ev );
public:
CLASS_PROTOTYPE( Door );
qboolean locked;
Door();
qboolean isOpen( void );
qboolean CanBeOpenedBy( Entity *ent );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Door::Archive
(
Archiver &arc
)
{
ScriptSlave::Archive( arc );
arc.WriteString( sound_stop );
arc.WriteString( sound_move );
arc.WriteString( sound_message );
arc.WriteString( sound_locked );
arc.WriteFloat( lastblocktime );
arc.WriteFloat( angle );
arc.WriteVector( dir );
arc.WriteVector( doormin );
arc.WriteVector( doormax );
arc.WriteFloat( diropened );
arc.WriteInteger( state );
arc.WriteInteger( previous_state );
arc.WriteInteger( trigger );
arc.WriteInteger( nextdoor );
arc.WriteSafePointer( master );
arc.WriteBoolean( locked );
}
inline EXPORT_FROM_DLL void Door::Unarchive
(
Archiver &arc
)
{
ScriptSlave::Unarchive( arc );
arc.ReadString( &sound_stop );
arc.ReadString( &sound_move );
arc.ReadString( &sound_message );
arc.ReadString( &sound_locked );
arc.ReadFloat( &lastblocktime );
arc.ReadFloat( &angle );
arc.ReadVector( &dir );
arc.ReadVector( &doormin );
arc.ReadVector( &doormax );
arc.ReadFloat( &diropened );
arc.ReadInteger( &state );
arc.ReadInteger( &previous_state );
arc.ReadInteger( &trigger );
arc.ReadInteger( &nextdoor );
arc.ReadSafePointer( &master );
arc.ReadBoolean( &locked );
}
class EXPORT_FROM_DLL SlidingDoor : public Door
{
protected:
float totalmove;
float lip;
Vector pos1;
Vector pos2;
public:
CLASS_PROTOTYPE( SlidingDoor );
void DoOpen( Event *ev );
void DoClose( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
SlidingDoor();
};
inline EXPORT_FROM_DLL void SlidingDoor::Archive
(
Archiver &arc
)
{
Door::Archive( arc );
arc.WriteFloat( totalmove );
arc.WriteFloat( lip );
arc.WriteVector( pos1 );
arc.WriteVector( pos2 );
}
inline EXPORT_FROM_DLL void SlidingDoor::Unarchive
(
Archiver &arc
)
{
Door::Unarchive( arc );
arc.ReadFloat( &totalmove );
arc.ReadFloat( &lip );
arc.ReadVector( &pos1 );
arc.ReadVector( &pos2 );
}
class EXPORT_FROM_DLL RotatingDoor : public Door
{
protected:
float angle;
Vector startangle;
int init_door_direction;
public:
CLASS_PROTOTYPE( RotatingDoor );
void DoOpen( Event *ev );
void DoClose( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
RotatingDoor();
};
inline EXPORT_FROM_DLL void RotatingDoor::Archive
(
Archiver &arc
)
{
Door::Archive( arc );
arc.WriteFloat( angle );
arc.WriteVector( startangle );
arc.WriteInteger( init_door_direction );
}
inline EXPORT_FROM_DLL void RotatingDoor::Unarchive
(
Archiver &arc
)
{
Door::Unarchive( arc );
arc.ReadFloat( &angle );
arc.ReadVector( &startangle );
arc.ReadInteger( &init_door_direction );
}
class EXPORT_FROM_DLL ScriptDoor : public Door
{
protected:
ThreadPtr doorthread;
str initthreadname;
str openthreadname;
str closethreadname;
float doorsize;
Vector startangle;
Vector startorigin;
Vector movedir;
public:
CLASS_PROTOTYPE( ScriptDoor );
void DoInit( Event *ev );
void DoOpen( Event *ev );
void DoClose( Event *ev );
void SetOpenThread( Event *ev );
void SetCloseThread( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
ScriptDoor();
};
inline EXPORT_FROM_DLL void ScriptDoor::Archive
(
Archiver &arc
)
{
Door::Archive( arc );
arc.WriteSafePointer( doorthread );
arc.WriteString( initthreadname );
arc.WriteString( openthreadname );
arc.WriteString( closethreadname );
arc.WriteFloat( doorsize );
arc.WriteVector( startangle );
arc.WriteVector( startorigin );
arc.WriteVector( movedir );
}
inline EXPORT_FROM_DLL void ScriptDoor::Unarchive
(
Archiver &arc
)
{
Door::Unarchive( arc );
arc.ReadSafePointer( &doorthread );
arc.ReadString( &initthreadname );
arc.ReadString( &openthreadname );
arc.ReadString( &closethreadname );
arc.ReadFloat( &doorsize );
arc.ReadVector( &startangle );
arc.ReadVector( &startorigin );
arc.ReadVector( &movedir );
}
#endif /* doors.h */

122
earthquake.cpp Normal file
View File

@ -0,0 +1,122 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/earthquake.cpp $
// $Revision:: 13 $
// $Author:: Jimdose $
// $Date:: 11/08/98 10:47p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/earthquake.cpp $
//
// 13 11/08/98 10:47p Jimdose
// moved earthquake to level struct
//
// 12 10/22/98 5:56p Markd
// Made a bunch of global sounds local to that entity
//
// 11 8/18/98 11:08p Markd
// Added new Alias System
//
// 10 7/30/98 4:34p Aldie
// Don't respond to touch
//
// 9 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 8 5/22/98 12:35p Aldie
// Removed some unused functions
//
// 7 5/22/98 12:19p Aldie
// Updated color of earthquake in SinEd
//
// 6 5/21/98 10:58a Aldie
// Removed a printf
//
// 5 5/20/98 10:21p Aldie
// Updated earthquake to new event system, may want to add radius later.
//
// 3 12/06/97 4:50p Markd
// Added interpretCommands.
// Added GetArgs as commands for future processing
//
// 2 10/27/97 7:32p Jimdose
// Created file
//
// DESCRIPTION:
// Earthquake trigger causes a localized earthquake when triggered.
// The earthquake effect is visible to the user as the shaking of his screen.
//
#include "earthquake.h"
/*****************************************************************************/
/*SINED func_earthquake (.5 .5 .8) (-8 -8 -8) (8 8 8)
Causes an earthquake
"duration" is the duration of the earthquake. Default is 0.8 seconds.
/*****************************************************************************/
CLASS_DECLARATION( Trigger, Earthquake, "func_earthquake" )
Event EV_Earthquake_Deactivate( "earthquake_deactivate" );
ResponseDef Earthquake::Responses[] =
{
{ &EV_Touch, NULL },
{ &EV_Trigger_Effect, ( Response )Earthquake::Activate },
{ &EV_Earthquake_Deactivate, ( Response )Earthquake::Deactivate },
{ NULL, NULL }
};
Earthquake::Earthquake
(
void
)
{
const char * name;
duration = G_GetFloatArg( "duration", 0.8f );
quakeactive = false;
// cache in the quake sound
name = gi.GlobalAlias_FindRandom( "earthquake" );
gi.soundindex( name );
}
EXPORT_FROM_DLL void Earthquake::Activate
(
Event *ev
)
{
float newtime;
Event *event;
newtime = duration + level.time;
if ( newtime > level.earthquake )
{
level.earthquake = newtime;
}
quakeactive = true;
RandomGlobalSound( "earthquake", 1, CHAN_VOICE|CHAN_NO_PHS_ADD, ATTN_NONE );
event = new Event(EV_Earthquake_Deactivate);
PostEvent(event,duration);
};
EXPORT_FROM_DLL void Earthquake::Deactivate
(
Event *ev
)
{
quakeactive = false;
level.earthquake = 0;
RandomGlobalSound( "null_sound", 1, CHAN_VOICE|CHAN_NO_PHS_ADD, ATTN_NORM );
}

86
earthquake.h Normal file
View File

@ -0,0 +1,86 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/earthquake.h $
// $Revision:: 8 $
// $Author:: Jimdose $
// $Date:: 11/08/98 10:47p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/earthquake.h $
//
// 8 11/08/98 10:47p Jimdose
// moved earthquake to level struct
//
// 7 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 6 5/22/98 12:35p Aldie
// Removed some unused functions
//
// 5 5/20/98 10:22p Aldie
// Converted earthquake to new event system.
//
// 3 12/06/97 4:49p Markd
// Moved duration to Trigger
// Added interpretCommand
//
// 2 10/27/97 7:32p Jimdose
// Created file
//
// DESCRIPTION:
// Earthquake trigger causes a localized earthquake when triggered.
// The earthquake effect is visible to the user as the shaking of his screen.
//
#ifndef __EARTHQUAKE_H__
#define __EARTHQUAKE_H__
#include "g_local.h"
#include "trigger.h"
#define EARTHQUAKE_STRENGTH 100
class EXPORT_FROM_DLL Earthquake : public Trigger
{
protected:
qboolean quakeactive;
float duration;
public:
CLASS_PROTOTYPE( Earthquake )
Earthquake();
void Activate(Event *ev);
void Deactivate(Event *ev);
qboolean EarthquakeActive() {return quakeactive;};
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Earthquake::Archive
(
Archiver &arc
)
{
Trigger::Archive( arc );
arc.WriteBoolean( quakeactive );
arc.WriteFloat( duration );
}
inline EXPORT_FROM_DLL void Earthquake::Unarchive
(
Archiver &arc
)
{
Trigger::Unarchive( arc );
arc.ReadBoolean( &quakeactive );
arc.ReadFloat( &duration );
}
#endif /* Earthquake.h */

5139
entity.cpp Normal file

File diff suppressed because it is too large Load Diff

1662
entity.h Normal file

File diff suppressed because it is too large Load Diff

218
eonandpeon.cpp Normal file
View File

@ -0,0 +1,218 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/eonandpeon.cpp $
// $Revision:: 8 $
// $Author:: Markd $
// $Date:: 11/09/98 12:31a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/eonandpeon.cpp $
//
// 8 11/09/98 12:31a Markd
// slowed down eonbomb
//
// 7 11/09/98 12:24a Markd
// make sure we have a currentEnemy when dieing
//
// 6 10/27/98 3:47p Markd
// fixed potential eon and peon bug
//
// 5 10/27/98 5:24a Markd
// made eon and peon not fade out
//
// 4 10/27/98 3:53a Markd
// Put in eon throwing
//
// 3 10/25/98 4:43a Markd
// incremental
//
// 2 10/23/98 3:41p Markd
// incremental check in
//
// 1 10/23/98 5:06a Markd
//
// DESCRIPTION:
// Eon and Peon
//
#include "g_local.h"
#include "actor.h"
#include "eonandpeon.h"
#include "specialfx.h"
#include "gibs.h"
class EXPORT_FROM_DLL EonBomb : public Projectile
{
public:
CLASS_PROTOTYPE( EonBomb );
virtual void Setup( Entity *owner, Vector pos, Vector vel );
virtual void EonBombTouch( Event *ev );
};
CLASS_DECLARATION( Projectile, EonBomb, NULL );
ResponseDef EonBomb::Responses[] =
{
{ &EV_Touch, ( Response )EonBomb::EonBombTouch },
{ NULL, NULL }
};
void EonBomb::EonBombTouch
(
Event *ev
)
{
if ( sv_gibs->value && !parentmode->value )
{
CreateGibs( this, health, 0.3, 10 );
}
PostEvent( EV_Remove, 0 );
}
void EonBomb::Setup
(
Entity *owner,
Vector pos,
Vector vel
)
{
// Flies like a grenade
setMoveType( MOVETYPE_TOSS );
setSolidType( SOLID_BBOX );
edict->clipmask = MASK_PROJECTILE;
setModel( "eon.def" );
RandomAnimate( "idle", NULL );
// Set the flying velocity
velocity = vel;
takedamage = DAMAGE_NO;
setSize( "-1 -1 -1", "1 1 1" );
setOrigin( pos );
worldorigin.copyTo(edict->s.old_origin);
// Remove the projectile in the future
PostEvent( EV_Remove, 30 );
}
CLASS_DECLARATION( Peon, EonAndPeon, "boss_eonandpeon" );
Event EV_EonAndPeon_SpawnGoo( "spawngoo" );
ResponseDef EonAndPeon::Responses[] =
{
{ &EV_EonAndPeon_SpawnGoo, ( Response )EonAndPeon::SpawnGoo },
{ &EV_Killed, ( Response )EonAndPeon::Killed },
{ &EV_FadeOut, NULL },
{ NULL, NULL }
};
EonAndPeon::EonAndPeon()
{
eon = new Entity;
eon->setModel( "boss_eon.def" );
levelVars.SetVariable( "eon", eon );
setModel( "boss_peon.def" );
flags |= FL_POSTTHINK;
}
void EonAndPeon::Chatter
(
const char *snd,
float chance,
float volume,
int channel
)
{
if ( chattime > level.time )
{
return;
}
if ( eon )
eon->RandomSound( snd, volume, channel, ATTN_NONE );
RandomSound( snd, volume, channel, ATTN_NONE );
chattime = level.time + 7 + G_Random( 5 );
}
void EonAndPeon::Postthink
(
void
)
{
if ( eon )
{
eon->setOrigin( worldorigin );
eon->setAngles( worldangles );
eon->edict->s.anim = edict->s.anim;
eon->edict->s.frame = edict->s.frame;
eon->edict->s.scale = edict->s.scale;
}
}
void EonAndPeon::Killed
(
Event *ev
)
{
EonBomb * eonbomb;
Vector vel;
Vector pos;
Vector target;
float speed;
pos = worldorigin;
pos.z = absmax.z;
speed = 250;
if ( currentEnemy )
{
target = G_PredictPosition( pos, currentEnemy->centroid, currentEnemy->velocity, speed );
vel = G_CalculateImpulse
(
pos,
target,
speed,
0.1f
);
}
else
{
vel.z = 200;
}
eonbomb = new EonBomb;
eonbomb->gravity = 0.1f;
eonbomb->Setup( this, pos, vel );
eonbomb->RandomSound( "snd_yell" );
// delete the real eon
eon->PostEvent( EV_Remove, 0 );
eon = NULL;
levelVars.SetVariable( "eon", 0 );
//
// call normal actor function
//
Actor::Killed( ev );
}

79
eonandpeon.h Normal file
View File

@ -0,0 +1,79 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/eonandpeon.h $
// $Revision:: 5 $
// $Author:: Jimdose $
// $Date:: 11/08/98 10:51p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/eonandpeon.h $
//
// 5 11/08/98 10:51p Jimdose
// added archive functions
//
// 4 10/27/98 3:53a Markd
// Added Killed and Chatter
//
// 3 10/25/98 4:44a Markd
// incremental
//
// 2 10/23/98 3:41p Markd
// incremental check in
//
// 1 10/23/98 5:06a Markd
//
// DESCRIPTION:
// Eon and Peon
//
#ifndef __EONANDPEON_H__
#define __EONANDPEON_H__
#include "g_local.h"
#include "actor.h"
#include "peon.h"
class EXPORT_FROM_DLL EonAndPeon : public Peon
{
private:
EntityPtr eon;
public:
CLASS_PROTOTYPE( EonAndPeon );
EonAndPeon::EonAndPeon();
void Postthink( void );
void Killed( Event *ev );
virtual void Chatter( const char *sound, float chance = 10, float volume = 1.0f, int channel = CHAN_VOICE );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void EonAndPeon::Archive
(
Archiver &arc
)
{
Peon::Archive( arc );
arc.WriteSafePointer( eon );
}
inline EXPORT_FROM_DLL void EonAndPeon::Unarchive
(
Archiver &arc
)
{
Peon::Unarchive( arc );
arc.ReadSafePointer( &eon );
}
#endif /* eonandpeon.h */

522
explosion.cpp Normal file
View File

@ -0,0 +1,522 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/explosion.cpp $
// $Revision:: 48 $
// $Author:: Markd $
// $Date:: 10/24/98 12:42a $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/explosion.cpp $
//
// 48 10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
//
// 47 10/22/98 7:57p Markd
// put in proper pre-caching in all the classes
//
// 46 10/22/98 5:03p Jimdose
// Made MakeExplosion properly use the activator
//
// 45 10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 44 10/14/98 10:55p Jimdose
// made CreateExplosion not ignore the explosion if attacker and ignore are not
// set
//
// 43 10/07/98 11:47p Jimdose
// made FlashPlayers only check clients instead of using findradius
//
// 42 10/05/98 10:23p Aldie
// Made flash based on distance
//
// 41 10/04/98 10:28p Aldie
// Added multiple weapon changes. Damage, flashes, quantum stuff
//
// 40 10/02/98 7:19p Aldie
// Added FlashPlayers to do blinding flashes
//
// 39 9/05/98 12:09p Aldie
// Made RadiusDamage non static
//
// 38 9/01/98 3:05p Markd
// Rewrote explosion code
//
// 37 8/30/98 7:06p Markd
// forgot to put scale into func_exploder
//
// 36 8/29/98 7:15p Markd
// Added big explosion support
//
// 35 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 34 8/27/98 9:01p Jimdose
// Changed centroid to a variable
//
// 33 8/17/98 2:55p Aldie
// Increased splash damage a little
//
// 32 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and
// rocket jumping.
//
// 31 7/26/98 1:18a Aldie
// Put explosion stuff back in
//
// 30 7/25/98 7:59p Aldie
// Moved more stuff client side.
//
// 29 7/23/98 6:17p Aldie
// Updated damage system and fixed some damage related bugs. Also put tracers
// back to the way they were, and added gib event to funcscriptmodels
//
// 28 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 27 7/15/98 9:58p Markd
// changed syntax of TempDLight
//
// 26 7/09/98 12:02a Jimdose
// Changed remove event to be posted instead of processed
//
// 25 6/29/98 8:21p Aldie
// Updated explosion methods
//
// 24 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 23 6/15/98 10:37a Aldie
// Made explosion more generic
//
// 22 6/10/98 2:10p Aldie
// Updated damage function.
//
// 21 5/25/98 8:00p Markd
// Accidentally left AUTO_ANIMATE on
//
// 20 5/25/98 7:58p Markd
// Cleaned it up a bunch
//
// 19 5/25/98 7:04p Markd
// Changed to TE_TEMPMODEL system
//
// 18 5/24/98 11:01p Markd
// made sure activator is valid
//
// 17 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 16 5/24/98 2:47p Markd
// Made char *'s into const char *'s
//
// 15 5/24/98 1:03a Jimdose
// Added sound events for ai
//
// 14 5/23/98 6:28p Jimdose
// Fixed bug in RadiusDamage where the entity could be freed by damage and the
// pointer then used in findradius. Damage is now posted as an event
//
// 13 5/03/98 4:31p Jimdose
// Changed Vector class. No longer includes PointsTo
//
// 12 4/28/98 5:32p Jimdose
// Changed the radius back again
//
// 11 4/18/98 2:31p Jimdose
// Changed radius of splash damage from explosion
//
// 10 4/06/98 5:30p Jimdose
// Fixed NULL attacker bug in MakeExplosion
//
// 9 4/05/98 6:42p Jimdose
// Added Exploders and MultiExploders
//
// 8 3/27/98 11:03p Jimdose
// changed explode.def to explode.spr
//
// 7 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 6 3/18/98 2:27p Jimdose
// Converted to work with new sin
//
// 4 10/27/97 3:30p Jimdose
// Removed dependency on quakedef.h
//
// 3 10/03/97 12:45a Jimdose
// Made explosion give off Redish-orange flash
//
// 2 9/26/97 5:23p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Standard explosion object that is spawned by other entites and not map designers.
// Explosion is used by many of the weapons for the blast effect, but is also used
// by the Exploder and MultiExploder triggers. These triggers create one or more
// explosions each time they are activated.
//
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
#include "explosion.h"
#include "specialfx.h"
#include "player.h"
#define RANDOM_TIME (1<<1)
#define RANDOM_SCALE (1<<2)
#define BIG_EXPLOSION (1<<3)
void FlashPlayers
(
Vector org,
float r,
float g,
float b,
float a,
float rad
)
{
Event *ev1;
trace_t trace;
Vector delta;
float length;
Player *player;
edict_t *edict;
int i;
for( i = 0; i < maxclients->value; i++ )
{
edict = g_edicts + 1 + i;
if ( !edict->inuse || !edict->client || !edict->entity || !edict->entity->isSubclassOf( Player ) ||
!edict->entity->WithinDistance( org, rad ) )
{
continue;
}
player = ( Player * )edict->entity;
trace = G_Trace( org, vec_zero, vec_zero, player->worldorigin + player->eyeposition, player, MASK_OPAQUE, "FlashPlayers" );
if ( trace.fraction != 1.0 )
{
continue;
}
delta = org - trace.endpos;
length = delta.length();
a = a * ( 1 - length / rad );
ev1 = new Event( EV_Player_SetFlashColor );
ev1->AddFloat( r );
ev1->AddFloat( g );
ev1->AddFloat( b );
ev1->AddFloat( a );
player->ProcessEvent( ev1 );
}
}
void RadiusDamage
(
Entity *inflictorent,
Entity *attackerent,
int damage,
Entity *ignoreent,
int mod
)
{
float points;
Entity *ent;
Vector org;
Vector v;
float rad;
rad = ( float )( damage + 60 );
ent = findradius( NULL, inflictorent->worldorigin.vec3(), rad );
while( ent )
{
if ( ( ent != ignoreent ) && ( ent->takedamage ) )
{
org = ent->centroid;
v = org - inflictorent->worldorigin;
points = v.length() * 0.5f;
if ( points < 0 )
{
points = 0;
}
points = damage - points;
if ( ent == attackerent )
{
points *= 0.5;
}
if ( points > 0 )
{
if ( inflictorent->CanDamage( ent ) )
{
ent->Damage(inflictorent, attackerent, points,
org, v, vec_zero, points,
DAMAGE_RADIUS, mod,
-1, -1, 1.0f );
}
}
}
ent = findradius( ent, inflictorent->worldorigin.vec3(), rad );
}
}
void CreateExplosion
(
Vector pos,
float damage,
float scale,
qboolean bigexplosion,
Entity *inflictor,
Entity *attacker,
Entity *ignore,
float volume,
float attenuation,
float r,
float g,
float b,
float light_radius,
float life,
float decay
)
{
assert( inflictor );
if ( !inflictor )
{
return;
}
if ( !attacker )
{
attacker = world;
}
if ( volume > 4.0f )
volume = 4.0f;
if ( damage < 120 )
{
inflictor->RandomPositionedSound( pos, "impact_smallexplosion", volume, CHAN_AUTO, attenuation );
}
else
{
inflictor->RandomPositionedSound( pos, "impact_bigexplosion", volume, CHAN_AUTO, attenuation );
}
RadiusDamage( inflictor, attacker, damage, ignore, MOD_ROCKETSPLASH );
inflictor->ProcessEvent( EV_WeaponSound );
if ( bigexplosion )
SpawnScaledExplosion( pos, scale );
else
TempModel( NULL, pos, "0 0 0", "sprites/explode.spr", 0, scale, 1.0f, TEMPMODEL_ANIMATE_ONCE, 10 );
}
/*****************************************************************************/
/*SINED func_exploder (0.4 0 0) (0 0 0) (8 8 8) x x x BIG_EXPLOSION
Spawns an explosion when triggered. Triggers any targets.
"dmg" specifies how much damage to cause. Default indicates 120.
"volume" volume at which to play explosions (default 1.0)
"attenuation" attenuation for explosions (default normal)
"key" The item needed to activate this. (default nothing)
/*****************************************************************************/
ResponseDef Exploder::Responses[] =
{
{ &EV_Touch, NULL },
{ &EV_Trigger_Effect, ( Response )Exploder::MakeExplosion },
{ NULL, NULL }
};
CLASS_DECLARATION( Trigger, Exploder, "func_exploder" );
void Exploder::MakeExplosion
(
Event *ev
)
{
CreateExplosion
(
worldorigin,
edict->s.scale * damage,
edict->s.scale,
( spawnflags & BIG_EXPLOSION ),
this,
ev->GetEntity( 1 ),
this,
volume * edict->s.scale,
attenuation
);
}
Exploder::Exploder()
{
damage = G_GetIntArg( "dmg", 120 );
if ( damage < 0 )
{
damage = 0;
}
modelIndex( "sprites/explode.spr" );
attenuation = G_GetFloatArg( "attenuation", 1.0 );
volume = G_GetFloatArg( "volume", 1.0 );
respondto = TRIGGER_PLAYERS | TRIGGER_MONSTERS | TRIGGER_PROJECTILES;
}
/*****************************************************************************/
/*SINED func_multi_exploder (0.4 0 0) ? x RANDOM_TIME RANDOM_SCALE BIG_EXPLOSION
Spawns an explosion when triggered. Triggers any targets.
size of brush determines where explosions will occur.
"dmg" specifies how much damage to cause from each explosion. (Default 120)
"delay" delay before exploding (Default 0 seconds)
"duration" how long to explode for (Default 1 second)
"wait" time between each explosion (default 0.25 seconds)
"volume" volume to play explosion sound at (default 0.5)
"attenuation" attenuation for explosions (default normal)
"random" random factor (default 0.25)
"key" The item needed to activate this. (default nothing)
RANDOM_TIME adjusts the wait between each explosion by the random factor
RANDOM_SCALE adjusts the size of each explosion by the random factor
/*****************************************************************************/
CLASS_DECLARATION( Trigger, MultiExploder, "func_multi_exploder" );
ResponseDef MultiExploder::Responses[] =
{
{ &EV_Touch, NULL },
{ &EV_Trigger_Effect, ( Response )MultiExploder::MakeExplosion },
{ NULL, NULL }
};
void MultiExploder::MakeExplosion
(
Event *ev
)
{
Vector pos;
float t;
float r;
float v;
Entity *other;
Event *event;
other = ev->GetEntity( 1 );
// make sure other is valid
if ( !other )
{
other = world;
}
// prevent the trigger from triggering again
trigger_time = -1;
if ( !explode_time )
{
explode_time = level.time + duration;
}
if ( spawnflags & RANDOM_TIME )
{
t = explodewait * ( 1 + G_CRandom( randomness ) );
}
else
{
t = explodewait;
}
event = new Event( EV_Trigger_Effect );
event->AddEntity( other );
PostEvent( event, t );
if ( level.time > explode_time )
{
PostEvent( EV_Remove, 0 );
return;
}
pos[ 0 ] = absmin[ 0 ] + G_Random( absmax[ 0 ] - absmin[ 0 ] );
pos[ 1 ] = absmin[ 1 ] + G_Random( absmax[ 1 ] - absmin[ 1 ] );
pos[ 2 ] = absmin[ 2 ] + G_Random( absmax[ 2 ] - absmin[ 2 ] );
if ( spawnflags & RANDOM_SCALE )
{
r = edict->s.scale + G_CRandom( randomness );
}
else
{
r = edict->s.scale;
}
if ( r < 1 )
{
v = volume * r;
}
else
{
v = volume;
}
CreateExplosion
(
pos,
damage * r,
r,
( spawnflags & BIG_EXPLOSION ),
this,
other,
this,
volume,
attenuation
);
}
MultiExploder::MultiExploder()
{
damage = G_GetIntArg( "dmg", 120 );
if ( damage < 0 )
{
damage = 0;
}
attenuation = G_GetFloatArg( "attenuation", 1.0 );
volume = G_GetFloatArg( "volume", 1.0 );
duration = G_GetFloatArg( "duration", 1.0 );
explodewait = G_GetFloatArg( "wait", 0.25 );
randomness = G_GetFloatArg( "random", 0.25 );
explode_time = 0;
// So that we don't get deleted after we're triggered
count = -1;
respondto = TRIGGER_PLAYERS | TRIGGER_MONSTERS | TRIGGER_PROJECTILES;
modelIndex( "sprites/explode.spr" );
}

201
explosion.h Normal file
View File

@ -0,0 +1,201 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/explosion.h $
// $Revision:: 14 $
// $Author:: Aldie $
// $Date:: 10/02/98 7:20p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/explosion.h $
//
// 14 10/02/98 7:20p Aldie
// Added flashplayers to do blinding flashes
//
// 13 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 12 9/05/98 12:13p Aldie
// externed RadiusDamage
//
// 11 9/01/98 3:05p Markd
// Rewrote explosion code
//
// 10 6/15/98 10:39a Aldie
// Updated explosion
//
// 9 5/25/98 7:08p Markd
// commented out some stuff
//
// 8 4/05/98 6:42p Jimdose
// Added Exploders and MultiExploders
//
// 7 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 6 3/18/98 2:27p Jimdose
// Converted to work with new sin
//
// 4 12/06/97 4:48p Markd
// Added interpretCommands.
// Added GetArgs as commands for future processing
// Removed dmg,attentuatioin and volume, moved these to Trigger
//
// 3 10/27/97 2:59p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 5:23p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Standard explosion object that is spawned by other entites and not map designers.
// Explosion is used by many of the weapons for the blast effect, but is also used
// by the Exploder and MultiExploder triggers. These triggers create one or more
// explosions each time they are activated.
//
#ifndef __EXPLOSION_H__
#define __EXPLOSION_H__
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
class EXPORT_FROM_DLL Exploder : public Trigger
{
private:
int damage;
float attenuation;
float volume;
virtual void MakeExplosion( Event *ev );
public:
CLASS_PROTOTYPE( Exploder )
Exploder();
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Exploder::Archive
(
Archiver &arc
)
{
Trigger::Archive( arc );
arc.WriteInteger( damage );
arc.WriteFloat( attenuation );
arc.WriteFloat( volume );
}
inline EXPORT_FROM_DLL void Exploder::Unarchive
(
Archiver &arc
)
{
Trigger::Unarchive( arc );
arc.ReadInteger( &damage );
arc.ReadFloat( &attenuation );
arc.ReadFloat( &volume );
}
class EXPORT_FROM_DLL MultiExploder : public Trigger
{
private:
float explodewait;
float explode_time;
float duration;
int damage;
float attenuation;
float volume;
float randomness;
virtual void MakeExplosion( Event *ev );
public:
CLASS_PROTOTYPE( MultiExploder );
MultiExploder();
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void MultiExploder::Archive
(
Archiver &arc
)
{
Trigger::Archive( arc );
arc.WriteFloat( explodewait );
arc.WriteFloat( explode_time );
arc.WriteFloat( duration );
arc.WriteInteger( damage );
arc.WriteFloat( attenuation );
arc.WriteFloat( volume );
arc.WriteFloat( randomness );
}
inline EXPORT_FROM_DLL void MultiExploder::Unarchive
(
Archiver &arc
)
{
Trigger::Unarchive( arc );
arc.ReadFloat( &explodewait );
arc.ReadFloat( &explode_time );
arc.ReadFloat( &duration );
arc.ReadInteger( &damage );
arc.ReadFloat( &attenuation );
arc.ReadFloat( &volume );
arc.ReadFloat( &randomness );
}
void CreateExplosion
(
Vector pos,
float damage = 120,
float scale = 1.0f,
qboolean bigexplosion = true,
Entity *inflictor = NULL,
Entity *attacker = NULL,
Entity *ignore = NULL,
float volume = 1.0f,
float attenuation = ATTN_NORM,
float r = 1.0f,
float g = 0.2f,
float b = 0.0f,
float light_radius = 240,
float life = 1,
float decay = 0.95
);
void RadiusDamage
(
Entity *inflictorent,
Entity *attackerent,
int damage,
Entity *ignoreent,
int mod
);
void FlashPlayers
(
Vector org,
float r,
float g,
float b,
float a,
float rad
);
#endif /* explosion.h */

264
fists.cpp Normal file
View File

@ -0,0 +1,264 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/fists.cpp $
// $Revision:: 34 $
// $Author:: Markd $
// $Date:: 11/17/98 1:31a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/fists.cpp $
//
// 34 11/17/98 1:31a Markd
// took out damage multiplier for fists
//
// 33 11/12/98 11:31p Jimdose
// changed impact_bodyimpact to impact_goryimpact
// increased kick from melee
//
// 32 10/20/98 8:26p Markd
// Added Attacker to DamageSurface stuff
//
// 31 10/20/98 3:59p Aldie
// Tweaked fist radius
//
// 30 10/14/98 12:12a Aldie
// Tweak damage
//
// 29 10/11/98 5:35p Aldie
// Added meansofdeath
//
// 28 10/05/98 10:23p Aldie
// Fixed rank
//
// 27 10/01/98 3:35p Onethumb
//
// 26 9/18/98 10:12p Markd
// made fists not use MASK_SHOT, MASK_PROJECTILE instead
//
// 25 9/18/98 8:14p Markd
// rewrote surface system so that surfaces are now damaged by surface name instead
// of by surfinfo
//
// 24 8/31/98 7:45p Aldie
// Updated surface data structure and removed surfinfo field
//
// 23 8/31/98 4:33p Markd
// Made fists use fulltrace
//
// 22 8/29/98 9:40p Jimdose
// Added call info to G_Trace
//
// 21 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 20 8/18/98 11:08p Markd
// Added new Alias System
//
// 19 8/17/98 3:16p Aldie
// Made fists not ignore armor
//
// 18 8/06/98 6:58p Jimdose
// Added min/max range, and projectile speed
//
// 17 7/23/98 6:17p Aldie
// Updated damage system and fixed some damage related bugs. Also put tracers
// back to the way they were, and added gib event to funcscriptmodels
//
// 16 7/22/98 9:57p Markd
// Defined weapon type
//
// 15 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 14 7/19/98 10:33p Aldie
// Update fist damage
//
// 13 6/19/98 9:29p Jimdose
// Moved gun orientation code to Weapon
//
// 12 6/10/98 10:03p Markd
// Got working with reach and damage
//
// 11 6/10/98 4:00p Aldie
// Updated fists to do damage skins
//
// 10 6/10/98 2:10p Aldie
// Updated damage function.
//
// 9 5/27/98 5:21a Markd
// changed ranking of fists
//
// 8 5/26/98 5:42p Markd
// Made fists more realistic damage wise
//
// 7 5/25/98 7:58p Markd
// Moved TakeDamage a bit
//
// 6 5/25/98 5:38p Markd
// Put in strike sound and stuff
//
// 5 5/25/98 1:00a Markd
// Fixed Fists
//
// 4 5/23/98 5:38p Markd
// slowed down firing rate
//
// 3 5/20/98 10:43p Markd
// made fists into bullets
//
// 2 5/11/98 11:24a Markd
// First time
//
// DESCRIPTION:
// Normal Hands
//
#include "g_local.h"
#include "fists.h"
#include "misc.h"
#include "specialfx.h"
#include "surface.h"
CLASS_DECLARATION( Weapon, Fists, NULL);
ResponseDef Fists::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )Fists::Shoot },
{ NULL, NULL }
};
Fists::Fists()
{
SetModels( NULL, "view_punch.def" );
SetAmmo( NULL, 0, 0 );
SetRank( 10, 10 );
strike_reach = 64;
strike_damage = 20;
SetMaxRange( strike_reach );
SetType( WEAPON_MELEE );
kick = 40;
meansofdeath = MOD_FISTS;
}
void Fists::Shoot( Event * ev )
{
trace_t trace;
Vector start;
Vector end;
float damage;
Vector org;
Vector dir;
int surfflags;
int surftype;
assert( owner );
if ( !owner )
{
return;
}
NextAttack( 1 );
damage = G_Random(strike_damage)+strike_damage;
GetMuzzlePosition( &start, &dir );
end = start + dir * strike_reach;
trace = G_FullTrace( start, vec_zero, vec_zero, end, 64, owner, MASK_PROJECTILE, "Fists::Shoot" );
if ( !trace.surface )
{
surfflags = 0;
surftype = 0;
}
else
{
surfflags = trace.surface->flags;
surftype = SURFACETYPE_FROM_FLAGS( surfflags );
surfaceManager.DamageSurface( &trace, damage, owner );
}
dir = Vector(trace.endpos) - start;
dir.normalize();
org = Vector(trace.endpos) - dir;
if ( (trace.fraction < 1.0f) )
{
if ( trace.ent->entity && trace.ent->entity->takedamage )
{
if ( trace.ent->entity->flags & FL_BLOOD )
{
if ( ( meansofdeath == MOD_MUTANTHANDS ) || ( trace.ent->entity->health < -500 ) )
{
owner->RandomGlobalSound("impact_goryimpact");
}
else
{
owner->RandomGlobalSound("impact_bodyimpact");
}
SpawnBlood( org, trace.plane.normal, damage );
}
else
{
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_STRIKE );
gi.WritePosition( org.vec3() );
gi.WriteDir( trace.plane.normal );
gi.WriteByte( 120 );
gi.WriteByte( surftype );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
if ( trace.intersect.valid )
{
// take the ground out so that the kick works
trace.ent->entity->groundentity = NULL;
// We hit a valid group so send in location based damage
trace.ent->entity->Damage( this,
owner,
damage,
trace.endpos,
dir,
trace.plane.normal,
kick,
0,
meansofdeath,
trace.intersect.parentgroup,
-1,
1 );
//trace.intersect.damage_multiplier );
}
else
{
// We didn't hit any groups, so send in generic damage
trace.ent->entity->Damage( this,
owner,
damage,
trace.endpos,
dir,
trace.plane.normal,
kick,
0,
meansofdeath,
-1,
-1,
1 );
}
}
else
{
gi.WriteByte( svc_temp_entity );
gi.WriteByte( TE_STRIKE );
gi.WritePosition( org.vec3() );
gi.WriteDir( trace.plane.normal );
gi.WriteByte( 120 );
gi.WriteByte( surftype );
gi.multicast( org.vec3(), MULTICAST_PVS );
}
}
}

92
fists.h Normal file
View File

@ -0,0 +1,92 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/fists.h $
// $Revision:: 7 $
// $Author:: Aldie $
// $Date:: 10/11/98 5:34p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/fists.h $
//
// 7 10/11/98 5:34p Aldie
// Added meansofdeath
//
// 6 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 5 6/10/98 10:02p Markd
// put reach and damage into fists
//
// 4 5/25/98 1:08a Markd
// Made fists a Weapon, not a BulletWeapon
//
// 3 5/20/98 10:43p Markd
// made fists into bullets!
//
// 2 5/11/98 11:25a Markd
// First time
//
// 1 5/11/98 10:28a Markd
//
// 1 5/11/98 10:20a Markd
//
// 1 5/11/98 10:18a Markd
//
// 1 5/11/98 9:55a Markd
//
// DESCRIPTION:
// Mutant Hands
//
#ifndef __FISTS_H__
#define __FISTS_H__
#include "g_local.h"
#include "item.h"
#include "weapon.h"
class EXPORT_FROM_DLL Fists : public Weapon
{
public:
float strike_reach;
float strike_damage;
int meansofdeath;
CLASS_PROTOTYPE( Fists );
Fists::Fists();
virtual void Shoot( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Fists::Archive
(
Archiver &arc
)
{
Weapon::Archive( arc );
arc.WriteFloat( strike_reach );
arc.WriteFloat( strike_damage );
arc.WriteInteger( meansofdeath );
}
inline EXPORT_FROM_DLL void Fists::Unarchive
(
Archiver &arc
)
{
Weapon::Unarchive( arc );
arc.ReadFloat( &strike_reach );
arc.ReadFloat( &strike_damage );
arc.ReadInteger( &meansofdeath );
}
#endif /* Fists.h */

580
g_local.h Normal file
View File

@ -0,0 +1,580 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/g_local.h $
// $Revision:: 98 $
// $Author:: Jimdose $
// $Date:: 11/10/98 5:51p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/g_local.h $
//
// 98 11/10/98 5:51p Jimdose
// disabled exporting symbols from the dll
//
// 97 11/10/98 4:34p Jimdose
// added clearsavegames to level
//
// 96 11/08/98 10:47p Jimdose
// moved earthquake to level struct
//
// 95 11/06/98 5:18p Jimdose
// added missionfailed and missionfailedtime to level vars
// when a mission has failed or the player is dead in single player, the game
// code immediately shows the loadmenu, preventing them from letting the game
// continue running if they exit the menu
//
// 94 10/27/98 9:46p Aldie
// Changed training cvar to level.training
//
// 93 10/26/98 2:16p Aldie
// Added AirClamp
//
// 92 10/25/98 11:49p Jimdose
// added EXPORT_TEMPLATE
// moved playerfrozen to level
//
// 91 10/25/98 6:26p Markd
// Added in no_jc abililty
//
// 90 10/24/98 2:18p Markd
// Added stufftext service
//
// 89 10/19/98 9:52p Jimdose
// changed slime variables to lightvolume
//
// 88 10/10/98 1:33a Jimdose
// moved include of g_utils.h to be before g_spawn.h
//
// 87 10/08/98 12:38a Jimdose
// Made savegames work
//
// 86 9/30/98 5:39p Aldie
// Added showinfo command
//
// 85 9/27/98 6:28p Aldie
// Added water, slime, and lava colors to worldspawn
//
// 84 9/19/98 5:01p Markd
// took out current_music and fallback_music
//
// 83 9/10/98 8:34p Markd
// Removed hidestats and drawoverlay from level variables
//
// 82 9/07/98 8:29p Markd
// Added fullmins fullmaxs and fullradius
//
// 81 9/02/98 7:48p Aldie
// Added ValidPlayerModels list
//
// 80 8/29/98 9:52p Jimdose
// General cleanup of g_local.h
// got rid of unused variables and macros
// moved prototypes to their appropriate headers
//
// 79 8/28/98 3:46p Markd
// Added centroid to edict_s
//
// 78 8/27/98 9:06p Jimdose
// Moved some prototypes that didn't belong here to g_utils.h
// Made STEPSIZE global
//
// 77 8/27/98 2:31p Aldie
// Added adrenaline flags
//
// 76 8/25/98 7:47p Jimdose
// Added gravaxis to SelectSpawnPoint
//
// 75 8/21/98 5:26p Markd
// Added sv_precache and cl_precache
//
// 74 8/19/98 8:50p Aldie
// Changed MOD to enumerated type
//
// 73 8/17/98 7:43p Markd
// Added MOD_LAVA and MOD_SLIME
//
// 72 8/17/98 4:35p Markd
// Added cinematic variable
//
// 71 8/14/98 8:14p Aldie
// Added generic overlay system
//
// 70 8/08/98 8:24p Markd
// Added MOD_THROWOBJECT
//
// 69 8/07/98 6:01p Aldie
// Added frag credits for falling damage
//
// 68 8/04/98 6:06p Aldie
// Relocated SPAWNFLAG_DETAIL
//
// 67 8/03/98 7:53p Jimdose
// Added G_DrawDebugNumber
//
// 66 8/03/98 7:36p Markd
// Added MOD_DEBRIS
//
// 65 8/02/98 9:00p Markd
// Merged code 3.17
//
// 64 7/24/98 6:19p Aldie
// enable and disable huds and dialog checking
//
// 63 7/23/98 2:32p Aldie
// Made speed of rocket a tweak cvar
//
// 62 7/21/98 10:05p Markd
// Added FL_DIE_EXPLODE
//
// 61 7/21/98 9:06p Markd
// Added current_mood and fallback_mood
//
// 60 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 59 7/18/98 5:08p Aldie
// Added showdamage
//
// 58 7/17/98 7:58p Markd
// Added radius to G_FullTrace
//
// 57 7/15/98 9:59p Markd
// Added FL_SHIELDS
//
// 56 7/13/98 5:01p Aldie
// Added dead player bodies with gibbing
//
// 55 7/09/98 10:38p Aldie
// Moved body parts to game
//
// 54 7/08/98 12:58p Jimdose
// made developer cvar global
//
// 53 7/03/98 12:02p Aldie
// Updated client persistent data
//
// 52 7/02/98 2:34p Aldie
// Mission computer
//
// 51 6/23/98 9:55p Jimdose
// Fixed infinite loop bug in G_RunFrame
//
// 50 6/15/98 10:07p Jimdose
// Added G_FullTrace
//
// 49 6/08/98 11:42a Aldie
// Added MOVETYPE_SLIDE
//
// 48 5/27/98 5:28a Aldie
// Added sv_gibs
//
// 47 5/27/98 5:04a Aldie
// Added queue for bloodsplats
//
// 46 5/25/98 6:52a Aldie
// Added maxbulletholes
//
// 45 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 44 5/23/98 12:53p Aldie
// Updated surfaces networking.
//
// 43 5/20/98 7:17p Markd
// Added G_DebugBBox
//
// 42 5/20/98 11:12a Markd
// removed char * dependency
//
// 41 5/14/98 10:21p Jimdose
// Added G_NextEntity
// Made G_MoveStep return extended failure information
//
// 40 5/13/98 4:47p Aldie
// Update damage surfaces
//
// 39 5/12/98 7:07p Markd
// Put in development spawnflag
//
// 38 5/11/98 5:53p Markd
// Added FL_DIE_GIBS
//
// 37 5/08/98 7:01p Markd
// Added FL_DARKEN flag
//
// 36 5/05/98 2:49p Jimdose
// removed kick_angles, kick_origin, v_dmg_roll, v_dmg_pitch, v_dmg_time,
// fall_time, fall_value, damage_alpha, bonus_alpha, damage_blend, v_angle,
// bobtime, oldviewangles, and oldvelocity from gclient_t. Most are moved into
// Player class.
//
// 35 5/05/98 2:41p Aldie
// added server side surface states
//
// 34 5/03/98 4:44p Jimdose
// added line drawing utility functions similar to opengl
//
// 33 5/02/98 8:46p Markd
// Changed gamedir from Basesin1 to BASE
//
// 32 5/01/98 5:08p Jimdose
// added prototype for world as an Entity *. This points to the entity created
// by WorldSpawn
//
// 31 4/30/98 9:24p Jimdose
// Changed use of string to str class
//
// 30 4/30/98 4:48p Aldie
// Server side console states
//
// 29 4/28/98 7:00p Aldie
// Added sever side console buffer
//
// 28 4/27/98 3:21p Jimdose
// Added DebugLines
//
// 27 4/27/98 1:51p Aldie
// Added server side console states.
//
// 26 4/16/98 2:09p Jimdose
// Removed navigation_numbeacons
//
// 25 4/10/98 4:57p Jimdose
// added spawntime to edict
//
// 24 4/10/98 1:24a Markd
// Added new FL_ flags for sparks, blood, tesselation, blastmarks and
// die_tesselation
//
// 23 4/07/98 3:49p Aldie
// Added zooming crosshair
//
// 22 4/04/98 6:14p Jimdose
// Added G_GetNameForSurface
//
// 21 4/02/98 4:51p Jimdose
// Added stats and deathmatch scoreboard
//
// 20 3/30/98 10:43p Jimdose
// Added G_Movestep
//
// 19 3/28/98 4:36p Jimdose
// Added deathmatch starts
//
// 18 3/27/98 5:39p Jimdose
// Made BeginIntermission accept a string instead of an edict
//
// 17 3/26/98 8:15p Jimdose
// Added coop variable
// Removed unused structures and prototypes
// Added prototypes of game interface functions
//
// 16 3/24/98 5:03p Jimdose
// Included listener.h in place of g_event.h
//
// 15 3/24/98 4:30p Aldie
// New svc commands for consoles.
//
// 14 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 13 3/11/98 7:38p Markd
// Added current_viewthing
//
// 12 3/04/98 8:00p Aldie
// More support for damage surfaces.
//
// 11 3/02/98 5:49p Jimdose
// Added num_navbeacons to level_locals_t
// Added entname to edict_s
// Added findradius
// Removed unused Q2 functions
// Added include of string.h from standard C++ library
//
// 10 2/21/98 1:16p Jimdose
// Added G_TestMove and G_TestStepMove for use in pathfinding code
// Removed buttons, oldbuttons, and latched_buttons from gclient_t structure
//
// 9 2/18/98 8:08p Jimdose
// Prototyped IsNumeric
//
// 8 2/16/98 2:23p Jimdose
// Added active_edicts and free_edicts for faster entity processing and for
// operations that depend on the order that physics is processed on entities
// (such as binding).
// Added next and prev fields to edict_t
// Included linklist.h
//
// 7 2/09/98 2:35p Aldie
// Removed const of vec_origin and vec_zero
//
// 6 2/09/98 11:55a Jimdose
// Made vec_zero and vec_origin const
// Prototyped G_PushMove
//
// 5 2/06/98 5:50p Jimdose
// Update prototypes
//
// 4 2/03/98 11:06a Jimdose
// In process of converting to work with Sin progs
//
// 3 12/30/97 6:04p Jimdose
// Added header text
//
// DESCRIPTION:
// local definitions for game module
//
#ifndef __G_LOCAL_H__
#define __G_LOCAL_H__
#if 0
#define EXPORT_FROM_DLL __declspec( dllexport )
#define EXPORT_TEMPLATE
#else
#define EXPORT_FROM_DLL
#endif
#include "q_shared.h"
// define GAME_INCLUDE so that game.h does not define the
// short, server-visible gclient_t and edict_t structures,
// because we define the full size ones in this file
#define GAME_INCLUDE
#include "game.h"
#include "container.h"
#include "str.h"
// the "gameversion" client command will print this plus compile date
#define GAMEVERSION "base"
// memory tags to allow dynamic memory to be cleaned up
#define TAG_GAME 765 // clear when unloading the dll
#define TAG_LEVEL 766 // clear when loading a new level
// protocol bytes that can be directly added to messages
#define svc_muzzleflash 1
#define svc_muzzleflash2 2
#define svc_temp_entity 3
#define svc_layout 4
#define svc_inventory 5
#define svc_console_command 6
#define svc_stufftext 12
// handedness values
#define RIGHT_HANDED 0
#define LEFT_HANDED 1
#define CENTER_HANDED 2
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5))
// predefine Entity so that we can add it to edict_t without any errors
class Entity;
//
// Exported templated classes must be explicitly instantiated
//
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<str>;
#endif
// client data that stays across multiple level loads
typedef struct
{
char userinfo[MAX_INFO_STRING];
char netname[16];
char model[MAX_QPATH];
char skin[MAX_QPATH];
int hand;
// values saved and restored from edicts when changing levels
int health;
int max_health;
} client_persistant_t;
// client data that stays across deathmatch respawns
typedef struct
{
int enterframe; // level.framenum the client entered the game
int score; // frags, etc
vec3_t cmd_angles; // angles sent over in the last command
} client_respawn_t;
// this structure is cleared on each PutClientInServer(),
// except for 'client->pers'
typedef struct gclient_s
{
// known to server
player_state_t ps; // communicated by server to clients
int ping;
// private to game
client_persistant_t pers;
client_respawn_t resp;
qboolean showinfo;
} gclient_t;
struct edict_s
{
entity_state_t s;
gclient_t *client; // NULL if not a player
// the server expects the first part
// of gclient_t to be a player_state_t
// but the rest of it is opaque
qboolean inuse;
int linkcount;
// FIXME: move these fields to a server private sv_entity_t
link_t area; // linked to a division node or leaf
int num_clusters; // if -1, use headnode instead
int clusternums[MAX_ENT_CLUSTERS];
int headnode; // unused if num_clusters != -1
int areanum, areanum2;
//================================
int svflags;
vec3_t mins, maxs;
vec3_t absmin, absmax, size;
vec3_t fullmins, fullmaxs;
float fullradius;
vec3_t centroid;
solid_t solid;
int clipmask;
edict_t *owner;
// DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
// EXPECTS THE FIELDS IN THAT ORDER!
//================================
Entity *entity;
float freetime; // sv.time when the object was freed
float spawntime; // sv.time when the object was spawned
char entname[ 64 ];
edict_t *next;
edict_t *prev;
};
#include "vector.h"
#include "linklist.h"
#include "class.h"
//
// this structure is left intact through an entire game
// it should be initialized at dll load time, and read/written to
// the server.ssv file for savegames
//
class EXPORT_FROM_DLL game_locals_t : public Class
{
public:
CLASS_PROTOTYPE( game_locals_t );
gclient_t *clients; // [maxclients]
qboolean autosaved;
// can't store spawnpoint in level, because
// it would get overwritten by the savegame restore
str spawnpoint; // needed for coop respawns
// store latched cvars here that we want to get at often
int maxclients;
int maxentities;
int maxconsoles;
int maxsurfaces;
qboolean force_entnum;
int spawn_entnum;
// List of valid player models loaded from players global scriptfile
Container<str> ValidPlayerModels;
game_locals_t();
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
//
// this structure is cleared as each map is entered
// it is read/written to the level.sav file for savegames
//
class EXPORT_FROM_DLL level_locals_t : public Class
{
public:
CLASS_PROTOTYPE( level_locals_t );
int framenum;
float time;
str level_name; // the descriptive name (Outer Base, etc)
str mapname; // the server name (base1, etc)
str nextmap; // go here when fraglimit is hit
// used for cinematics
qboolean playerfrozen;
// used to prevent players from continuing failed games
qboolean missionfailed;
float missionfailedtime;
// intermission state
float intermissiontime; // time the intermission was started
int exitintermission;
edict_t *next_edict; // Used to keep track of the next edict to process in G_RunFrame
int total_secrets;
int found_secrets;
Entity *current_entity; // entity running from G_RunFrame
// FIXME - remove this later when it is passed in the event.
trace_t impact_trace;
int body_queue;
float earthquake;
qboolean clearsavegames;
qboolean cinematic;
qboolean no_jc;
// Blending color for water, light volumes,lava
Vector water_color;
Vector lightvolume_color;
Vector lava_color;
float water_alpha;
float lightvolume_alpha;
float lava_alpha;
qboolean airclamp;
qboolean training;
level_locals_t();
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
#include "g_main.h"
#include "listener.h"
#include "g_utils.h"
#include "g_spawn.h"
#include "g_phys.h"
#endif

3330
g_main.cpp Normal file

File diff suppressed because it is too large Load Diff

187
g_main.h Normal file
View File

@ -0,0 +1,187 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/g_main.h $
// $Revision:: 14 $
// $Author:: Aldie $
// $Date:: 11/13/98 2:35a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/g_main.h $
//
// 14 11/13/98 2:35a Aldie
// Declared fixbodiesforplayer
//
// 13 11/09/98 12:55a Jimdose
// added sv_footsteps cvar so that server admins can turn footsteps off
// completely
//
// 12 10/27/98 9:46p Aldie
// Changed training cvar to level.training
//
// 11 10/25/98 10:16p Aldie
// Added training cvar
//
// 10 10/22/98 5:02p Aldie
// Removed blastscale_z
//
// 9 10/21/98 6:42p Markd
// Added sv_drawtrace
//
// 8 10/16/98 1:56a Jimdose
// Added autosave variable to G_WriteLevel
//
// 7 10/11/98 8:50p Jimdose
// Added LoadingServer
//
// 6 10/09/98 2:07a Aldie
// Updated DMFLAGS
//
// 5 10/08/98 7:41p Jimdose
// changed noexit to a dmflag
// added server commands
// Added ip filtering
//
// 4 10/08/98 12:38a Jimdose
// Made savegames work
//
// 3 9/22/98 3:21p Markd
// put in parentmode lockout for blood and gibs
//
// 2 8/29/98 9:49p Jimdose
// created file
//
// 1 8/29/98 6:44p Jimdose
//
// DESCRIPTION:
// Global header file for g_main.cpp
//
#ifndef __G_MAIN_H__
#define __G_MAIN_H__
#include "g_local.h"
extern Vector vec_origin;
extern Vector vec_zero;
extern qboolean LoadingSavegame;
extern qboolean LoadingServer;
extern game_locals_t game;
extern level_locals_t level;
extern game_import_t gi;
extern game_export_t globals;
extern edict_t *g_edicts;
extern edict_t active_edicts;
extern edict_t free_edicts;
extern netconsole_t *g_consoles;
extern netconbuffer_t *g_conbuffers;
extern netsurface_t *g_surfaces;
extern cvar_t *developer;
extern cvar_t *precache;
extern cvar_t *maxentities;
extern cvar_t *maxconsoles;
extern cvar_t *deathmatch;
extern cvar_t *coop;
extern cvar_t *dmflags;
extern cvar_t *skill;
extern cvar_t *fraglimit;
extern cvar_t *timelimit;
extern cvar_t *filterban;
extern cvar_t *flood_msgs;
extern cvar_t *flood_persecond;
extern cvar_t *flood_waitdelay;
extern cvar_t *g_select_empty;
extern cvar_t *g_unlimited_ammo;
extern cvar_t *nomonsters;
extern cvar_t *dialog;
extern cvar_t *sv_gravity;
extern cvar_t *sv_maxvelocity;
extern cvar_t *sv_maxbulletholes;
extern cvar_t *sv_maxbloodsplats;
extern cvar_t *sv_gore;
extern cvar_t *sv_gibs;
extern cvar_t *sv_showdamage;
extern cvar_t *sv_showdamagelocation;
extern cvar_t *gun_x, *gun_y, *gun_z;
extern cvar_t *sv_rollspeed;
extern cvar_t *sv_rollangle;
extern cvar_t *run_pitch;
extern cvar_t *run_roll;
extern cvar_t *bob_up;
extern cvar_t *bob_pitch;
extern cvar_t *bob_roll;
extern cvar_t *sv_cheats;
extern cvar_t *maxclients;
extern cvar_t *sv_rocketspeed;
extern cvar_t *sv_rocketrate;
extern cvar_t *sv_stopspeed;
extern cvar_t *sv_friction;
extern cvar_t *sv_waterfriction;
extern cvar_t *sv_waterspeed;
extern cvar_t *sv_footsteps;
extern cvar_t *sv_traceinfo;
extern cvar_t *sv_drawtrace;
extern int sv_numtraces;
extern cvar_t *parentmode;
extern usercmd_t *current_ucmd;
#define DM_FLAG( flag ) ( deathmatch->value && ( ( int )dmflags->value & ( flag ) ) )
void G_BeginIntermission( const char *map );
void G_PutClientInServer( edict_t *ent );
void G_SaveClientData( void );
void G_MoveClientToIntermission( Entity *client );
void G_DeathmatchScoreboard( Entity *ent );
void G_DeathmatchScoreboardMessage( Entity *client, Entity *killer );
void G_WriteClient( Archiver &arc, gclient_t *client );
void G_AllocGameData( void );
extern "C" {
void G_ClientEndServerFrames( void );
void G_ClientThink( edict_t *ent, usercmd_t *cmd );
qboolean G_ClientConnect( edict_t *ent, const char *userinfo );
void G_ClientUserinfoChanged( edict_t *ent, const char *userinfo );
void G_ClientDisconnect( edict_t *ent );
void G_ClientBegin( edict_t *ent, qboolean loadgame );
void G_ClientCommand( edict_t *ent );
void G_WriteGame( const char *filename, qboolean autosave );
void G_ReadGame( const char *filename );
void G_WriteLevel( const char *filename, qboolean autosave );
void G_ReadLevel( const char *filename );
void G_InitGame( void );
void G_ShutdownGame( void );
void G_RunFrame( void );
void G_ServerCommand( void );
void G_ClientThink( edict_t *ent, usercmd_t *ucmd );
void FixDeadBodiesForPlayer( edict_t *ent );
};
qboolean SV_FilterPacket( const char *from );
void SVCmd_AddIP_f( void );
void SVCmd_RemoveIP_f( void );
void SVCmd_ListIP_f( void );
void SVCmd_WriteIP_f( void );
#endif /* g_main.h */

1740
g_phys.cpp Normal file

File diff suppressed because it is too large Load Diff

75
g_phys.h Normal file
View File

@ -0,0 +1,75 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/g_phys.h $
// $Revision:: 5 $
// $Author:: Jimdose $
// $Date:: 11/13/98 10:04p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/g_phys.h $
//
// 5 11/13/98 10:04p Jimdose
// added G_CheckWater
// got rid of unused physics functions
//
// 4 10/04/98 10:28p Aldie
// Added multiple weapon changes. Damage, flashes, quantum stuff
//
// 3 9/14/98 6:12p Markd
// Added MOVETYPE_VEHICLE
//
// 2 8/29/98 9:49p Jimdose
// created file
//
// 1 8/29/98 6:44p Jimdose
//
// DESCRIPTION:
// Global header file for g_phys.cpp
//
#ifndef __G_PHYS_H__
#define __G_PHYS_H__
#include "g_local.h"
typedef enum
{
STEPMOVE_OK,
STEPMOVE_BLOCKED_BY_ENTITY,
STEPMOVE_BLOCKED_BY_WORLD,
STEPMOVE_BLOCKED_BY_WATER,
STEPMOVE_BLOCKED_BY_FALL,
STEPMOVE_STUCK,
} stepmoveresult_t;
#define STEPSIZE 18
// movetype values
typedef enum
{
MOVETYPE_NONE, // never moves
MOVETYPE_NOCLIP, // origin and angles change with no interaction
MOVETYPE_PUSH, // no clip to world, push on box contact
MOVETYPE_STOP, // no clip to world, stops on box contact
MOVETYPE_WALK, // gravity
MOVETYPE_STEP, // gravity, special edge handling
MOVETYPE_FLY,
MOVETYPE_TOSS, // gravity
MOVETYPE_FLYMISSILE, // extra size to monsters
MOVETYPE_BOUNCE,
MOVETYPE_SLIDE,
MOVETYPE_VEHICLE,
MOVETYPE_HURL
} movetype_t;
void G_RunEntity (Entity *ent);
void G_Impact( Entity *e1, trace_t *trace );
qboolean G_PushMove( Entity *pusher, Vector move, Vector amove );
void G_CheckWater( Entity *ent );
#endif /* g_phys.h */

1785
g_spawn.cpp Normal file

File diff suppressed because it is too large Load Diff

254
g_spawn.h Normal file
View File

@ -0,0 +1,254 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/g_spawn.h $
// $Revision:: 18 $
// $Author:: Jimdose $
// $Date:: 11/07/98 10:01p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/g_spawn.h $
//
// 18 11/07/98 10:01p Jimdose
// added G_GetClassFromArgs
//
// 17 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 16 10/17/98 8:12p Jimdose
// Changed G_CallSpawn2 to G_CallSpawn
//
// 15 10/17/98 12:21a Jimdose
// Added G_ResetEdicts
//
// 14 10/15/98 7:13p Jimdose
// Overrode = for SpawnArgGroup. Fixes crash on level change with multiplayer
//
// 13 10/14/98 10:58p Jimdose
// added archive functions to spawnargs classes
// G_MapInit now accepts mapname
//
// 12 10/14/98 1:20a Jimdose
// Got cross-level persistant info working
//
// 11 10/10/98 1:33a Jimdose
// Added G_LevelStart and G_Precache
//
// 10 10/07/98 11:47p Jimdose
// Added G_LevelShutdown and G_MapInit
//
// 9 8/29/98 9:49p Jimdose
// Moved prototypes from g_local.h
//
// 8 8/27/98 9:05p Jimdose
// Moved some prototypes that didn't belong here to g_utils.h
//
// 7 8/12/98 3:19p Aldie
// Added G_CallSpawn2 that returns pointer to entity created.
//
// 6 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 5 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 4 5/24/98 2:46p Markd
// Made char *'s into const char *'s
//
// 3 3/13/98 7:25p Aldie
// Added GetVector
//
// 2 2/03/98 11:06a Jimdose
// Converted to work with Sin progs
//
// DESCRIPTION:
//
#ifndef __G_SPAWN_H__
#define __G_SPAWN_H__
#ifdef __cplusplus
#include "entity.h"
// spawnflags
// these are set with checkboxes on each entity in the map editor
#define SPAWNFLAG_NOT_EASY 0x00000100
#define SPAWNFLAG_NOT_MEDIUM 0x00000200
#define SPAWNFLAG_NOT_HARD 0x00000400
#define SPAWNFLAG_NOT_DEATHMATCH 0x00000800
#define SPAWNFLAG_NOT_COOP 0x00001000
#define SPAWNFLAG_DEVELOPMENT 0x00002000
#define SPAWNFLAG_DETAIL 0x00004000
class EXPORT_FROM_DLL SpawnArg : public Class
{
public:
char key[ 64 ];
char value[ 256 ];
CLASS_PROTOTYPE( SpawnArg );
SpawnArg();
SpawnArg( SpawnArg &arg );
friend int operator==( SpawnArg a, SpawnArg b );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline int operator==
(
SpawnArg a,
SpawnArg b
)
{
int i;
i = strcmp( a.key, b.key );
if ( i )
{
return i;
}
return strcmp( a.value, b.value );
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<SpawnArg>;
#endif
class EXPORT_FROM_DLL SpawnArgs : public Class
{
public:
Container<SpawnArg> argList;
CLASS_PROTOTYPE( SpawnArgs );
SpawnArgs();
SpawnArgs( SpawnArgs &arglist );
int NumArgs( void );
void SetArgs( void );
void RestoreArgs( void );
void operator=( SpawnArgs &a );
friend int operator==( SpawnArgs a, SpawnArgs b );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline int operator==
(
SpawnArgs a,
SpawnArgs b
)
{
return -1;
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<SpawnArgs>;
#endif
class EXPORT_FROM_DLL SpawnArgGroup : public Class
{
public:
Container<SpawnArgs> spawnArgList;
CLASS_PROTOTYPE( SpawnArgGroup );
SpawnArgGroup();
SpawnArgGroup( SpawnArgGroup &group );
int NumInGroup( void );
void AddArgs( void );
void RestoreArgs( int i );
void operator=( SpawnArgGroup &a );
friend int operator==( SpawnArgGroup a, SpawnArgGroup b );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline int operator==
(
SpawnArgGroup a,
SpawnArgGroup b
)
{
return -1;
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<SpawnArgGroup>;
#endif
class EXPORT_FROM_DLL SpawnArgsForEntity : public Class
{
public:
Container<SpawnArgGroup> groupList;
Container<int> entnumList;
CLASS_PROTOTYPE( SpawnArgsForEntity );
void Reset( void );
void AddEnt( Entity *ent );
qboolean RestoreEnt( Entity *ent );
void RestoreEnts( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
extern SpawnArgsForEntity PersistantData;
void G_SetFloatArg( const char *key, double value );
void G_SetIntArg( const char *key, int value );
qboolean G_SetSpawnArg( const char *keyname, const char *value );
void G_DefaultArg( const char *key, const char *defaultvalue );
void G_DefaultFloatArg( const char *key, double defaultvalue );
void G_DefaultIntArg( const char *key, int defaultvalue );
float G_GetFloatArg( const char *key, double defaultvalue = 0 );
Vector G_GetVectorArg( const char *key, Vector defaultvalue = Vector( 0, 0, 0 ) );
int G_GetIntArg( const char *key, int defaultvalue = 0 );
str G_GetStringArg( const char *key, const char *defaultvalue = NULL );
const char *G_GetSpawnArg( const char *key, const char *defaultvalue = NULL );
void G_InitSpawnArguments( void );
int G_GetNumSpawnArgs( void );
void G_InitClientPersistant( gclient_t *client );
void G_InitClientResp( gclient_t *client );
ClassDef *G_GetClassFromArgs( void );
Entity *G_CallSpawn( void );
const char *G_ParseEdict( const char *data, edict_t *ent);
void G_FindTeams( void );
void G_LevelShutdown( void );
void G_ResetEdicts( void );
void G_MapInit( const char *mapname );
void G_LevelStart( void );
void G_Precache( void );
#endif
#ifdef __cplusplus
extern "C" {
#endif
EXPORT_FROM_DLL void G_SpawnEntities( const char *mapname, const char *entities, const char *spawnpoint );
#ifdef __cplusplus
}
#endif
#endif

2163
g_utils.cpp Normal file

File diff suppressed because it is too large Load Diff

289
g_utils.h Normal file
View File

@ -0,0 +1,289 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/g_utils.h $
// $Revision:: 15 $
// $Author:: Markd $
// $Date:: 10/26/98 3:50a $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/g_utils.h $
//
// 15 10/26/98 3:50a Markd
// put in prediction
//
// 14 10/18/98 3:23a Jimdose
// Added G_Milliseconds and G_DebugPrintf
//
// 13 10/16/98 7:18p Markd
// Changed ExecuteThread a little bit
//
// 12 10/10/98 1:34a Jimdose
// added edict archiving functions
//
// 11 10/09/98 4:54p Markd
// Added ExecuteThread
//
// 10 10/07/98 11:48p Jimdose
// Added G_FixSlashes
//
// 9 10/03/98 1:10p Aldie
// added findclientsinradius
//
// 8 9/14/98 5:41p Jimdose
// Added G_CalcBoundsOfMove
//
// 7 8/29/98 9:50p Jimdose
// Moved prototypes from g_local.h
// Moved all debugline functions from g_main.cpp
// Added trace info to G_Trace
//
// 6 8/27/98 9:05p Jimdose
// Moved several short functions to g_utils.h as inline
//
// 5 8/24/98 4:55p Markd
// Added G_CalculateImpulse
//
// 4 2/18/98 8:08p Jimdose
// Prototyped IsNumeric
//
// 3 2/06/98 5:51p Jimdose
// Added KillBox
// Changed G_TouchTriggers and M_CheckBottom to be .cpp compatible
//
// 2 2/03/98 10:49a Jimdose
// Created file.
//
// DESCRIPTION:
//
#ifndef __G_UTILS_H__
#define __G_UTILS_H__
class Archiver;
EXPORT_FROM_DLL void G_ArchiveEdict( Archiver &arc, edict_t *edict );
EXPORT_FROM_DLL void G_UnarchiveEdict( Archiver &arc, edict_t *edict );
#include "entity.h"
EXPORT_FROM_DLL void G_InitEdict (edict_t *e);
EXPORT_FROM_DLL edict_t *G_Spawn (void);
EXPORT_FROM_DLL void G_FreeEdict (edict_t *e);
EXPORT_FROM_DLL void G_TouchTriggers (Entity *ent);
EXPORT_FROM_DLL void G_TouchSolids (Entity *ent);
EXPORT_FROM_DLL char *G_CopyString (const char *in);
EXPORT_FROM_DLL int G_FindClass( int entnum, const char *classname );
EXPORT_FROM_DLL Entity *G_NextEntity( Entity *ent );
EXPORT_FROM_DLL void G_CalcBoundsOfMove( Vector &start, Vector &end, Vector &mins, Vector &maxs, Vector *minbounds, Vector *maxbounds );
EXPORT_FROM_DLL void G_ShowTrace( trace_t *trace, edict_t *passent, const char *reason );
EXPORT_FROM_DLL trace_t G_Trace( Vector &start, Vector &mins, Vector &maxs, Vector &end, Entity *passent, int contentmask, const char *reason );
EXPORT_FROM_DLL trace_t G_Trace( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask, const char *reason );
EXPORT_FROM_DLL trace_t G_FullTrace( Vector &start, Vector &mins, Vector &maxs, Vector &end, float radius, Entity *passent, int contentmask, const char *reason );
EXPORT_FROM_DLL trace_t G_FullTrace( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, float radius, edict_t *passent, int contentmask, const char *reason );
EXPORT_FROM_DLL void SelectSpawnPoint( Vector &origin, Vector &angles, int *gravaxis = NULL );
EXPORT_FROM_DLL int G_FindTarget( int entnum, const char *name );
EXPORT_FROM_DLL Entity *G_NextEntity( Entity *ent );
EXPORT_FROM_DLL qboolean M_CheckBottom( Entity *ent );
EXPORT_FROM_DLL Vector G_GetMovedir( void );
EXPORT_FROM_DLL qboolean KillBox( Entity *ent );
EXPORT_FROM_DLL qboolean IsNumeric( const char *str );
EXPORT_FROM_DLL Entity *findradius( Entity *startent, Vector org, float rad );
EXPORT_FROM_DLL Entity *findclientsinradius( Entity *startent, Vector org, float rad );
EXPORT_FROM_DLL const char *G_GetNameForSurface( csurface_t *s );
EXPORT_FROM_DLL Vector G_CalculateImpulse( Vector start, Vector end, float speed, float gravity );
EXPORT_FROM_DLL Vector G_PredictPosition( Vector start, Vector target, Vector targetvelocity, float speed );
EXPORT_FROM_DLL void G_InitDebugLines( void );
EXPORT_FROM_DLL void G_DebugLine( Vector start, Vector end, float r, float g, float b, float alpha );
EXPORT_FROM_DLL void G_Color3f( float r, float g, float b );
EXPORT_FROM_DLL void G_Color3v( Vector color );
EXPORT_FROM_DLL void G_Color4f( float r, float g, float b, float alpha );
EXPORT_FROM_DLL void G_Color3vf( Vector color, float alpha );
EXPORT_FROM_DLL void G_BeginLine( void );
EXPORT_FROM_DLL void G_Vertex( Vector v );
EXPORT_FROM_DLL void G_EndLine( void );
EXPORT_FROM_DLL void G_DebugBBox( Vector origin, Vector mins, Vector maxs, float r, float g, float b, float alpha );
EXPORT_FROM_DLL void G_DrawDebugNumber( Vector origin, int number, float scale, float r, float g, float b );
EXPORT_FROM_DLL void G_LoadAndExecScript( const char *filename, const char *label = NULL );
EXPORT_FROM_DLL ScriptThread *ExecuteThread( str thread_name, qboolean start = true );
EXPORT_FROM_DLL int G_Milliseconds( void );
EXPORT_FROM_DLL void G_DebugPrintf( const char *fmt, ... );
//==================================================================
//
// Inline functions
//
//==================================================================
inline EXPORT_FROM_DLL float angmod
(
float v
)
{
int b;
b = ( int )v;
b = b - ( b % 360 );
if ( b < 0 )
{
b -= 360;
}
return v - ( float )b;
}
/*
=================
G_GetEntity
Takes an index to an entity and returns pointer to it.
=================
*/
inline EXPORT_FROM_DLL Entity *G_GetEntity
(
int entnum
)
{
if ( ( entnum < 0 ) || ( entnum >= globals.max_edicts ) )
{
gi.error ("G_GetEntity: %d out of valid range.", entnum );
}
return ( Entity * )g_edicts[ entnum ].entity;
}
/*
=================
G_Random
Returns a number from 0<= num < 1
random()
=================
*/
inline EXPORT_FROM_DLL float G_Random
(
void
)
{
return ( ( float )( rand() & 0x7fff ) ) / ( ( float )0x8000 );
}
/*
=================
G_Random
Returns a number from 0 <= num < n
random()
=================
*/
inline EXPORT_FROM_DLL float G_Random
(
float n
)
{
return G_Random() * n;
}
/*
=================
G_CRandom
Returns a number from -1 <= num < 1
crandom()
=================
*/
inline EXPORT_FROM_DLL float G_CRandom
(
void
)
{
return G_Random( 2 ) - 1;
}
/*
=================
G_CRandom
Returns a number from -n <= num < n
crandom()
=================
*/
inline EXPORT_FROM_DLL float G_CRandom
(
float n
)
{
return G_CRandom() * n;
}
/*
=================
G_FixSlashes
Converts all backslashes in a string to forward slashes.
Used to make filenames consistant.
=================
*/
inline EXPORT_FROM_DLL str G_FixSlashes
(
const char *filename
)
{
int i;
int len;
str text;
if ( filename )
{
// Convert all forward slashes to back slashes
text = filename;
len = text.length();
for( i = 0; i < len; i++ )
{
if ( text[ i ] == '\\' )
{
text[ i ] = '/';
}
}
}
return text;
}
#endif /* g_utils.h */

2
game.def Normal file
View File

@ -0,0 +1,2 @@
EXPORTS
GetGameAPI

868
game.dsp Normal file
View File

@ -0,0 +1,868 @@
# Microsoft Developer Studio Project File - Name="game" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=game - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "game.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "game.mak" CFG="game - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "game - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "game - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/Quake 2 Engine/Sin/code/game", FTDAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "game - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Release"
# PROP BASE Intermediate_Dir ".\Release"
# PROP BASE Target_Dir "."
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\Release"
# PROP Intermediate_Dir ".\Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir "."
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /G5 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "SIN" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "SIN" /d "SIN_DISABLECOPYPROTECTION"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winmm.lib /nologo /base:"0x11000000" /subsystem:windows /dll /machine:I386 /out:"Release/gamex86.dll"
# SUBTRACT LINK32 /incremental:yes /map /debug
!ELSEIF "$(CFG)" == "game - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ".\Debug"
# PROP BASE Intermediate_Dir ".\Debug"
# PROP BASE Target_Dir "."
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\Debug"
# PROP Intermediate_Dir ".\Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir "."
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /G5 /W3 /Gm /GX /Zi /Od /I "\newsin\code\game" /D "BUILDING_REF_GL" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "SIN" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "SIN" /d "SIN_DISABLECOPYPROTECTION"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /base:"0x11000000" /subsystem:windows /dll /map /debug /machine:I386 /out:"Debug/gamex86.dll"
!ENDIF
# Begin Target
# Name "game - Win32 Release"
# Name "game - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\actor.cpp
# End Source File
# Begin Source File
SOURCE=.\ammo.cpp
# End Source File
# Begin Source File
SOURCE=.\animals.cpp
# End Source File
# Begin Source File
SOURCE=.\arcade_comm.cpp
# End Source File
# Begin Source File
SOURCE=.\archive.cpp
# End Source File
# Begin Source File
SOURCE=.\areaportal.cpp
# End Source File
# Begin Source File
SOURCE=.\armor.cpp
# End Source File
# Begin Source File
SOURCE=.\assaultrifle.cpp
# End Source File
# Begin Source File
SOURCE=.\bacrodai.cpp
# End Source File
# Begin Source File
SOURCE=.\behavior.cpp
# End Source File
# Begin Source File
SOURCE=.\bouncingbetty.cpp
# End Source File
# Begin Source File
SOURCE=.\box.cpp
# End Source File
# Begin Source File
SOURCE=.\bspline.cpp
# End Source File
# Begin Source File
SOURCE=.\bullet.cpp
# End Source File
# Begin Source File
SOURCE=.\camera.cpp
# End Source File
# Begin Source File
SOURCE=.\camgun.cpp
# End Source File
# Begin Source File
SOURCE=.\chaingun.cpp
# End Source File
# Begin Source File
SOURCE=.\class.cpp
# End Source File
# Begin Source File
SOURCE=.\console.cpp
# End Source File
# Begin Source File
SOURCE=.\ctf.cpp
# End Source File
# Begin Source File
SOURCE=.\ctf_player.cpp
# End Source File
# Begin Source File
SOURCE=.\deadbody.cpp
# End Source File
# Begin Source File
SOURCE=.\doors.cpp
# End Source File
# Begin Source File
SOURCE=.\earthquake.cpp
# End Source File
# Begin Source File
SOURCE=.\entity.cpp
# End Source File
# Begin Source File
SOURCE=.\eonandpeon.cpp
# End Source File
# Begin Source File
SOURCE=.\explosion.cpp
# End Source File
# Begin Source File
SOURCE=.\fists.cpp
# End Source File
# Begin Source File
SOURCE=.\g_main.cpp
# End Source File
# Begin Source File
SOURCE=.\g_phys.cpp
# End Source File
# Begin Source File
SOURCE=.\g_spawn.cpp
# End Source File
# Begin Source File
SOURCE=.\g_utils.cpp
# End Source File
# Begin Source File
SOURCE=.\gamescript.cpp
# End Source File
# Begin Source File
SOURCE=.\genericbullet.cpp
# End Source File
# Begin Source File
SOURCE=.\genericrocket.cpp
# End Source File
# Begin Source File
SOURCE=.\gibs.cpp
# End Source File
# Begin Source File
SOURCE=.\glowstick.cpp
# End Source File
# Begin Source File
SOURCE=.\gravpath.cpp
# End Source File
# Begin Source File
SOURCE=.\hammer.cpp
# End Source File
# Begin Source File
SOURCE=.\health.cpp
# End Source File
# Begin Source File
SOURCE=.\heligun.cpp
# End Source File
# Begin Source File
SOURCE=.\inventoryitem.cpp
# End Source File
# Begin Source File
SOURCE=.\item.cpp
# End Source File
# Begin Source File
SOURCE=.\keys.cpp
# End Source File
# Begin Source File
SOURCE=.\launcher.cpp
# End Source File
# Begin Source File
SOURCE=.\lensflare.cpp
# End Source File
# Begin Source File
SOURCE=.\light.cpp
# End Source File
# Begin Source File
SOURCE=.\listener.cpp
# End Source File
# Begin Source File
SOURCE=.\magnum.cpp
# End Source File
# Begin Source File
SOURCE=.\misc.cpp
# End Source File
# Begin Source File
SOURCE=.\mover.cpp
# End Source File
# Begin Source File
SOURCE=.\mutanthands.cpp
# End Source File
# Begin Source File
SOURCE=.\navigate.cpp
# End Source File
# Begin Source File
SOURCE=.\object.cpp
# End Source File
# Begin Source File
SOURCE=.\path.cpp
# End Source File
# Begin Source File
SOURCE=.\peon.cpp
# End Source File
# Begin Source File
SOURCE=.\player.cpp
# End Source File
# Begin Source File
SOURCE=.\PlayerStart.cpp
# End Source File
# Begin Source File
SOURCE=.\powerups.cpp
# End Source File
# Begin Source File
SOURCE=.\pulserifle.cpp
# End Source File
# Begin Source File
SOURCE=.\q_shared.c
# End Source File
# Begin Source File
SOURCE=.\quantumd.cpp
# End Source File
# Begin Source File
SOURCE=.\reactiveshields.cpp
# End Source File
# Begin Source File
SOURCE=.\rocket_turret.cpp
# End Source File
# Begin Source File
SOURCE=.\rocketlauncher.cpp
# End Source File
# Begin Source File
SOURCE=.\script.cpp
# End Source File
# Begin Source File
SOURCE=.\scriptmaster.cpp
# End Source File
# Begin Source File
SOURCE=.\scriptslave.cpp
# End Source File
# Begin Source File
SOURCE=.\scriptvariable.cpp
# End Source File
# Begin Source File
SOURCE=.\secgun.cpp
# End Source File
# Begin Source File
SOURCE=.\securityturret.cpp
# End Source File
# Begin Source File
SOURCE=.\sentient.cpp
# End Source File
# Begin Source File
SOURCE=.\shield.cpp
# End Source File
# Begin Source File
SOURCE=.\shotgun.cpp
# End Source File
# Begin Source File
SOURCE=.\shotrocketlauncher.cpp
# End Source File
# Begin Source File
SOURCE=.\silencer.cpp
# End Source File
# Begin Source File
SOURCE=.\skeet.cpp
# End Source File
# Begin Source File
SOURCE=.\sniperrifle.cpp
# End Source File
# Begin Source File
SOURCE=.\speargun.cpp
# End Source File
# Begin Source File
SOURCE=.\specialfx.cpp
# End Source File
# Begin Source File
SOURCE=.\spidermine.cpp
# End Source File
# Begin Source File
SOURCE=.\steering.cpp
# End Source File
# Begin Source File
SOURCE=.\str.cpp
!IF "$(CFG)" == "game - Win32 Release"
# ADD CPP /FR
!ELSEIF "$(CFG)" == "game - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\stungun.cpp
# End Source File
# Begin Source File
SOURCE=.\surface.cpp
# End Source File
# Begin Source File
SOURCE=.\testweapon.cpp
# End Source File
# Begin Source File
SOURCE=.\thrall.cpp
# End Source File
# Begin Source File
SOURCE=.\trigger.cpp
# End Source File
# Begin Source File
SOURCE=.\turret.cpp
# End Source File
# Begin Source File
SOURCE=.\vehicle.cpp
# End Source File
# Begin Source File
SOURCE=.\viewthing.cpp
# End Source File
# Begin Source File
SOURCE=.\weapon.cpp
# End Source File
# Begin Source File
SOURCE=.\worldspawn.cpp
# End Source File
# Begin Source File
SOURCE=.\wrench.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\actor.h
# End Source File
# Begin Source File
SOURCE=.\ammo.h
# End Source File
# Begin Source File
SOURCE=.\arcade_comm.h
# End Source File
# Begin Source File
SOURCE=.\archive.h
# End Source File
# Begin Source File
SOURCE=.\areaportal.h
# End Source File
# Begin Source File
SOURCE=.\armor.h
# End Source File
# Begin Source File
SOURCE=.\assaultrifle.h
# End Source File
# Begin Source File
SOURCE=.\bacrodai.h
# End Source File
# Begin Source File
SOURCE=.\behavior.h
# End Source File
# Begin Source File
SOURCE=.\bouncingbetty.h
# End Source File
# Begin Source File
SOURCE=.\box.h
# End Source File
# Begin Source File
SOURCE=.\bspline.h
# End Source File
# Begin Source File
SOURCE=.\bullet.h
# End Source File
# Begin Source File
SOURCE=.\camera.h
# End Source File
# Begin Source File
SOURCE=.\chaingun.h
# End Source File
# Begin Source File
SOURCE=.\class.h
# End Source File
# Begin Source File
SOURCE=.\console.h
# End Source File
# Begin Source File
SOURCE=.\container.h
# End Source File
# Begin Source File
SOURCE=.\ctf.h
# End Source File
# Begin Source File
SOURCE=.\ctf_player.h
# End Source File
# Begin Source File
SOURCE=.\datamap.h
# End Source File
# Begin Source File
SOURCE=.\deadbody.h
# End Source File
# Begin Source File
SOURCE=.\doors.h
# End Source File
# Begin Source File
SOURCE=.\earthquake.h
# End Source File
# Begin Source File
SOURCE=.\entity.h
# End Source File
# Begin Source File
SOURCE=.\eonandpeon.h
# End Source File
# Begin Source File
SOURCE=.\explosion.h
# End Source File
# Begin Source File
SOURCE=.\fists.h
# End Source File
# Begin Source File
SOURCE=.\g_local.h
# End Source File
# Begin Source File
SOURCE=.\g_main.h
# End Source File
# Begin Source File
SOURCE=.\g_phys.h
# End Source File
# Begin Source File
SOURCE=.\g_spawn.h
# End Source File
# Begin Source File
SOURCE=.\g_utils.h
# End Source File
# Begin Source File
SOURCE=.\game.h
# End Source File
# Begin Source File
SOURCE=.\gamescript.h
# End Source File
# Begin Source File
SOURCE=.\genericbullet.h
# End Source File
# Begin Source File
SOURCE=.\genericrocket.h
# End Source File
# Begin Source File
SOURCE=.\gibs.h
# End Source File
# Begin Source File
SOURCE=.\gravpath.h
# End Source File
# Begin Source File
SOURCE=.\health.h
# End Source File
# Begin Source File
SOURCE=.\heligun.h
# End Source File
# Begin Source File
SOURCE=.\inventoryitem.h
# End Source File
# Begin Source File
SOURCE=.\item.h
# End Source File
# Begin Source File
SOURCE=.\lensflare.h
# End Source File
# Begin Source File
SOURCE=.\light.h
# End Source File
# Begin Source File
SOURCE=.\LINKLIST.H
# End Source File
# Begin Source File
SOURCE=.\listener.h
# End Source File
# Begin Source File
SOURCE=.\magnum.h
# End Source File
# Begin Source File
SOURCE=.\misc.h
# End Source File
# Begin Source File
SOURCE=.\mover.h
# End Source File
# Begin Source File
SOURCE=.\mutanthands.h
# End Source File
# Begin Source File
SOURCE=.\navigate.h
# End Source File
# Begin Source File
SOURCE=.\object.h
# End Source File
# Begin Source File
SOURCE=.\path.h
# End Source File
# Begin Source File
SOURCE=.\peon.h
# End Source File
# Begin Source File
SOURCE=.\player.h
# End Source File
# Begin Source File
SOURCE=.\PlayerStart.h
# End Source File
# Begin Source File
SOURCE=.\powerups.h
# End Source File
# Begin Source File
SOURCE=.\prioritystack.h
# End Source File
# Begin Source File
SOURCE=.\pulserifle.h
# End Source File
# Begin Source File
SOURCE=.\q_shared.h
# End Source File
# Begin Source File
SOURCE=.\quantumd.h
# End Source File
# Begin Source File
SOURCE=.\queue.h
# End Source File
# Begin Source File
SOURCE=.\rocket_turret.h
# End Source File
# Begin Source File
SOURCE=.\rocketlauncher.h
# End Source File
# Begin Source File
SOURCE=.\script.h
# End Source File
# Begin Source File
SOURCE=.\scriptmaster.h
# End Source File
# Begin Source File
SOURCE=.\scriptslave.h
# End Source File
# Begin Source File
SOURCE=.\scriptvariable.h
# End Source File
# Begin Source File
SOURCE=.\secgun.h
# End Source File
# Begin Source File
SOURCE=.\securityturret.h
# End Source File
# Begin Source File
SOURCE=.\sentient.h
# End Source File
# Begin Source File
SOURCE=.\shotgun.h
# End Source File
# Begin Source File
SOURCE=.\shotrocketlauncher.h
# End Source File
# Begin Source File
SOURCE=.\silencer.h
# End Source File
# Begin Source File
SOURCE=.\skeet.h
# End Source File
# Begin Source File
SOURCE=.\sniperrifle.h
# End Source File
# Begin Source File
SOURCE=.\speargun.h
# End Source File
# Begin Source File
SOURCE=.\specialfx.h
# End Source File
# Begin Source File
SOURCE=.\spidermine.h
# End Source File
# Begin Source File
SOURCE=.\stack.h
# End Source File
# Begin Source File
SOURCE=.\steering.h
# End Source File
# Begin Source File
SOURCE=.\str.h
# End Source File
# Begin Source File
SOURCE=.\stungun.h
# End Source File
# Begin Source File
SOURCE=.\surface.h
# End Source File
# Begin Source File
SOURCE=.\testweapon.h
# End Source File
# Begin Source File
SOURCE=.\thrall.h
# End Source File
# Begin Source File
SOURCE=.\trigger.h
# End Source File
# Begin Source File
SOURCE=.\turret.h
# End Source File
# Begin Source File
SOURCE=.\vector.h
# End Source File
# Begin Source File
SOURCE=.\vehicle.h
# End Source File
# Begin Source File
SOURCE=.\viewthing.h
# End Source File
# Begin Source File
SOURCE=.\weapon.h
# End Source File
# Begin Source File
SOURCE=.\worldspawn.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\game.def
# End Source File
# End Group
# End Target
# End Project

564
game.h Normal file
View File

@ -0,0 +1,564 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/game.h $
// $Revision:: 51 $
// $Author:: Jimdose $
// $Date:: 12/18/98 11:05p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/game.h $
//
// 51 12/18/98 11:05p Jimdose
// added definitions of server side stuff to get rid of qcommon.h includes
//
// 50 11/11/98 10:04p Jimdose
// Removed comment
//
// 49 11/11/98 10:02p Jimdose
// added SVF_MONSTERCLIP and SVF_PLAYERCLIP
//
// 48 10/20/98 9:46p Jimdose
// made CalcCRC take a const char *
//
// 47 10/20/98 9:39p Jimdose
// Added CalcCRC
// Upped GAME_API_VERSION
//
// 46 10/16/98 1:56a Jimdose
// Added autosave to WriteLevel function
// Increased GAME_API_VERSION
//
// 45 10/10/98 5:58p Aldie
// More quantumdestab fixes
//
// 44 10/08/98 7:42p Jimdose
// Added ServerCommand
//
// 43 9/08/98 7:09p Jimdose
// added printf to game_import_t
//
// 42 9/07/98 8:29p Markd
// Added fullmins fullmaxs and fullradius
//
// 41 9/05/98 11:55a Markd
// Upped game api version
//
// 40 9/01/98 7:47p Aldie
// Added itemname to inventory stuff
//
// 39 8/31/98 7:45p Aldie
// Updated surface data structure and removed surfinfo field
//
// 38 8/29/98 9:51p Jimdose
// made netconsole_s, netconbuffer_s, and netsurface_s visible to game dll to
// get rid of it in g_local.h
//
// 37 8/29/98 2:53p Aldie
// Added status meter for loading levels.
//
// 36 8/28/98 3:46p Markd
// Added centroid to edict_s
//
// 35 8/25/98 7:55p Markd
// Added SVF_ONLYPARENT flag
//
// 34 8/18/98 11:08p Markd
// Added new Alias System
//
// 33 8/02/98 9:00p Markd
// Merged code 3.17
//
// 32 7/17/98 7:58p Markd
// Added radius to fulltrace, also added SVF_USEBBOX
//
// 31 6/27/98 6:40p Markd
// Added SoundLength
//
// 30 6/20/98 7:50p Markd
// Added BoneGroupName function
//
// 29 6/15/98 10:06p Jimdose
// added gi.fulltrace
//
// 28 6/15/98 7:57p Markd
// Put in Group_Flags
//
// 27 6/08/98 7:23p Aldie
// Added some surface in the game import
//
// 26 5/26/98 8:42p Markd
// Added NumGroups to interface
//
// 25 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 24 5/24/98 2:46p Markd
// Made char *'s into const char *'s
//
// 23 5/23/98 12:53p Aldie
// Updated surfaces networking.
//
// 22 5/20/98 11:12a Markd
// removed char * dependency
//
// 21 5/13/98 4:47p Aldie
// Update damage surfaces
//
// 20 5/09/98 8:01p Jimdose
// added GameDir, PlayerDir, and CreatePath to the import list for the dll
//
// 19 5/05/98 2:44p Aldie
// Added server side surface states
//
// 18 4/30/98 4:48p Aldie
// Server side console states
//
// 17 4/28/98 7:00p Aldie
// Added sever side console buffer
//
// 16 4/27/98 3:20p Jimdose
// Added DebugLines
//
// 15 4/27/98 1:51p Aldie
// Added server side console states.
//
// 14 4/09/98 1:40p Markd
// Added SVF_SHOOTABLE
//
// 13 4/07/98 8:01p Markd
// Changed all SINMDL commands to non-SINMDL prefix
//
// 12 3/30/98 6:12p Markd
// Added Alias commands
//
// 11 3/29/98 8:33p Markd
// Changed nature of InitCmds and FrameCommands
//
// 10 3/27/98 7:00p Markd
// Changed Bone functions a bit
//
// 9 3/25/98 1:22p Markd
//
// 8 3/24/98 9:59a Markd
// Added new bone, and group stuff for models
//
// 7 3/18/98 8:01p Markd
// Accidentally made fadetime an int instead of a float
//
// 6 3/18/98 7:15p Markd
// Changed sound code stuff
//
// 5 3/05/98 6:44p Markd
// Added SINMDL stuff
//
// 4 2/03/98 11:08a Jimdose
// Converted to work with Sin progs
// Could use a little clean up.
//
// 3 12/30/97 6:04p Jimdose
// Added header text
//
// DESCRIPTION:
// game dll information visible to server
//
#ifndef __GAME_H__
#define __GAME_H__
#ifdef __cplusplus
extern "C" {
#endif
#define GAME_API_VERSION 13
// edict->svflags
#define FRAMETIME 0.1
#define SVF_NOCLIENT 0x00000001 // don't send entity to clients, even if it has effects
#define SVF_DEADMONSTER 0x00000002 // treat as CONTENTS_DEADMONSTER for collision
#define SVF_MONSTER 0x00000004 // treat as CONTENTS_MONSTER for collision
#define SVF_SHOOTABLE 0x00000008 // treat as CONTENTS_SHOOTABLE for collision
#define SVF_USEBBOX 0x00000010 // do not perform perfect collision use the bbox instead
#define SVF_ONLYPARENT 0x00000020 // only send this entity to its parent
#define SVF_HIDEOWNER 0x00000040 // hide the owner of the client
#define SVF_MONSTERCLIP 0x00000080 // treat as CONTENTS_MONSTERCLIP for collision
#define SVF_PLAYERCLIP 0x00000100 // treat as CONTENTS_PLAYERCLIP for collision
// edict->solid values
typedef enum
{
SOLID_NOT, // no interaction with other objects
SOLID_TRIGGER, // only touch when inside, after moving
SOLID_BBOX, // touch on edge
SOLID_BSP // bsp clip, touch on edge
} solid_t;
//===============================================================
// link_t is only used for entity area links now
typedef struct link_s
{
struct link_s *prev, *next;
} link_t;
#define MAX_ENT_CLUSTERS 16
typedef struct edict_s edict_t;
typedef struct gclient_s gclient_t;
typedef struct netconsole_s netconsole_t;
typedef struct netconbuffer_s netconbuffer_t;
typedef struct netsurface_s netsurface_t;
#ifndef QCOMMON
// If this is modified in qcommon.h, it must be reflected here.
#define MAX_MSGLEN 1400 // max length of a message
// If this is modified in qcommon.h, it must be reflected here.
enum svc_ops_e
{
svc_bad,
svc_muzzleflash,
svc_muzzleflash2,
svc_temp_entity,
svc_layout,
svc_inventory,
svc_console_command
};
#endif
#ifndef GAME_INCLUDE
typedef struct gclient_s
{
player_state_t ps; // communicated by server to clients
int ping;
// the game dll can add anything it wants after
// this point in the structure
} gclient_t;
struct edict_s
{
entity_state_t s;
struct gclient_s *client;
qboolean inuse;
int linkcount;
// FIXME: move these fields to a server private sv_entity_t
link_t area; // linked to a division node or leaf
int num_clusters; // if -1, use headnode instead
int clusternums[MAX_ENT_CLUSTERS];
int headnode; // unused if num_clusters != -1
int areanum, areanum2;
//================================
int svflags; // SVF_NOCLIENT, SVF_DEADMONSTER, SVF_MONSTER, etc
vec3_t mins, maxs;
vec3_t absmin, absmax, size;
vec3_t fullmins, fullmaxs;
float fullradius;
vec3_t centroid;
solid_t solid;
int clipmask;
edict_t *owner;
// the game dll can add anything it wants after
// this point in the structure
};
#endif // GAME_INCLUDE
struct netconsole_s
{
console_state_t s;
qboolean inuse;
};
struct netconbuffer_s
{
console_buffer_state_t s;
};
struct netsurface_s
{
surface_state_t s;
qboolean inuse;
};
//===============================================================
//
// functions provided by the main engine
//
typedef struct
{
// special messages
void (*bprintf) (int printlevel, const char *fmt, ...);
void (*dprintf) (const char *fmt, ...);
void (*printf) (const char *fmt, ...);
void (*cprintf) (edict_t *ent, int printlevel, const char *fmt, ...);
void (*centerprintf) (edict_t *ent, const char *fmt, ...);
void (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs, float pitch, float fadetime, int flags);
void (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs, float pitch, float fadetime, int flags);
// config strings hold all the index strings, the lightstyles,
// and misc data like the sky definition and cdtrack.
// All of the current configstrings are sent to clients when
// they connect, and changes are sent to all connected clients.
void (*configstring) (int num, const char *string);
void (*error) (const char *fmt, ...);
// new names can only be added during spawning
// existing names can be looked up at any time
int (*modelindex) (const char *name);
int (*soundindex) (const char *name);
int (*imageindex) (const char *name);
int (*itemindex) (const char *name);
void (*setmodel) (edict_t *ent, const char *name);
// collision detection against world and bboxes of a-models
trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask);
// for full ray intersection tests against a-model polys and world
trace_t (*fulltrace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, float radius, edict_t *passent, int contentmask);
int (*pointcontents) (vec3_t point);
qboolean (*inPVS) (vec3_t p1, vec3_t p2);
qboolean (*inPHS) (vec3_t p1, vec3_t p2);
void (*SetAreaPortalState) (int portalnum, qboolean open);
qboolean (*AreasConnected) (int area1, int area2);
// an entity will never be sent to a client or used for collision
// if it is not passed to linkentity. If the size, position, or
// solidity changes, it must be relinked.
void (*linkentity) (edict_t *ent);
void (*unlinkentity) (edict_t *ent); // call before removing an interactive edict
int (*BoxEdicts) (vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype);
void (*Pmove) (pmove_t *pmove); // player movement code common with client prediction
// network messaging
void (*multicast) (vec3_t origin, multicast_t to);
void (*unicast) (edict_t *ent, qboolean reliable);
void (*WriteChar) (int c);
void (*WriteByte) (int c);
void (*WriteShort) (int c);
void (*WriteLong) (int c);
void (*WriteFloat) (float f);
void (*WriteString) (const char *s);
void (*WritePosition) (vec3_t pos); // some fractional bits
void (*WriteDir) (vec3_t pos); // single byte encoded, very coarse
void (*WriteAngle) (float f);
// managed memory allocation
void *(*TagMalloc) (int size, int tag);
void (*TagFree) (void *block);
void (*FreeTags) (int tag);
// console variable interaction
cvar_t *(*cvar) (const char *var_name, const char *value, int flags);
cvar_t *(*cvar_set) (const char *var_name, const char *value);
cvar_t *(*cvar_forceset) (const char *var_name, const char *value);
// ClientCommand and coneole command parameter checking
int (*argc) (void);
const char *(*argv) (int n);
const char *(*args) (void);
// add commands to the server console as if they were typed in
// for map changing, etc
void (*AddCommandString) (const char *text);
void (*DebugGraph) (float value, int color);
int (*LoadFile) ( const char *path, void **buffer, int tag);
const char *(*GameDir)( void );
const char *(*PlayerDir)( void );
void (*CreatePath)(const char *path);
float (*SoundLength) ( const char *path );
//
// Model support
//
qboolean (*IsModel) ( int index );
//
// MODEL UTILITY FUNCTIONS
//
// DEF SPECIFIC STUFF
int (*NumAnims) ( int modelindex );
int (*NumSkins) ( int modelindex );
int (*NumGroups) ( int modelindex );
sinmdl_cmd_t * (*InitCommands) ( int modelindex );
void (*CalculateBounds) ( int modelindex, float scale, vec3_t mins, vec3_t maxs );
// ANIM SPECIFIC STUFF
const char * (*Anim_NameForNum) ( int modelindex, int animnum );
int (*Anim_NumForName) ( int modelindex, const char * name );
int (*Anim_Random) ( int modelindex, const char * name );
int (*Anim_NumFrames) ( int modelindex, int animnum );
float (*Anim_Time) ( int modelindex, int animnum );
void (*Anim_Delta) ( int modelindex, int animnum, vec3_t delta );
// FRAME SPECIFIC STUFF
sinmdl_cmd_t * (*Frame_Commands) ( int modelindex, int animnum, int framenum );
void (*Frame_Delta) ( int modelindex, int animnum, int framenum, vec3_t delta );
float (*Frame_Time) ( int modelindex, int animnum, int framenum );
// SKIN SPECIFIC STUFF
const char * (*Skin_NameForNum) ( int modelindex, int skinnum );
int (*Skin_NumForName) ( int modelindex, const char * name );
// GROUP SPECIFIC STUFF
int (*Group_NameToNum) ( int modelindex, const char * name );
const char * (*Group_NumToName) ( int modelindex, int num );
float (*Group_DamageMultiplier) ( int modelindex, int num );
int (*Group_Flags) ( int modelindex, int num );
// BONE SPECIFIC STUFF
qboolean (*GetBoneInfo)
(
int modelindex,
const char * bonename,
int * groupindex,
int * tri_num,
vec3_t orientation
);
const char * (*GetBoneGroupName)
(
int modelindex,
const char * bonename
);
qboolean (*GetBoneTransform)
(
int modelindex,
int groupindex,
int tri_num,
vec3_t orientation,
int anim,
int frame,
float scale,
vec3_t trans[3],
vec3_t pos
);
//
// ALIAS SYSTEM
//
qboolean (*Alias_Add)( int modelindex, const char * alias, const char * name, float weight );
const char * (*Alias_FindRandom)( int modelindex, const char * alias );
void (*Alias_Dump)( int modelindex );
void (*Alias_Clear)( int modelindex );
//
// GLOBAL ALIAS SYSTEM
//
qboolean (*GlobalAlias_Add)( const char * alias, const char * name, float weight );
const char * (*GlobalAlias_FindRandom)( const char * alias );
void (*GlobalAlias_Dump)( void );
void (*GlobalAlias_Clear)( void );
unsigned short ( *CalcCRC )( const char *start, int count );
//
// SURFACES
//
int (*Surf_NumSurfaces)( void );
csurface_t * (*Surf_Surfaces)( void );
void (*IncrementStatusCount)( int i );
debugline_t **DebugLines;
int *numDebugLines;
} game_import_t;
//
// functions exported by the game subsystem
//
typedef struct
{
int apiversion;
// the init function will only be called when a game starts,
// not each time a level is loaded. Persistant data for clients
// and the server can be allocated in init
void (*Init) (void);
void (*Shutdown) (void);
// each new level entered will cause a call to SpawnEntities
void (*SpawnEntities) (const char *mapname, const char *entstring, const char *spawnpoint);
// Read/Write Game is for storing persistant cross level information
// about the world state and the clients.
// WriteGame is called every time a level is exited.
// ReadGame is called on a loadgame.
void (*WriteGame) (const char *filename, qboolean autosave);
void (*ReadGame) (const char *filename);
// ReadLevel is called after the default map information has been
// loaded with SpawnEntities, so any stored client spawn spots will
// be used when the clients reconnect.
void (*WriteLevel) (const char *filename, qboolean autosave );
void (*ReadLevel) (const char *filename);
qboolean (*ClientConnect) (edict_t *ent, const char *userinfo );
void (*ClientBegin) (edict_t *ent, qboolean loadgame);
void (*ClientUserinfoChanged) (edict_t *ent, const char *userinfo);
void (*ClientDisconnect) (edict_t *ent);
void (*ClientCommand) (edict_t *ent);
void (*ClientThink) (edict_t *ent, usercmd_t *cmd);
void (*RunFrame) (void);
// ServerCommand will be called when an "sv <command>" command is issued on the
// server console.
// The game can issue gi.argc() / gi.argv() commands to get the rest
// of the parameters
void (*ServerCommand) (void);
void (*CreateSurfaces) (csurface_t *surfaces, int count);
//
// global variables shared between game and server
//
// The edict array is allocated in the game dll so it
// can vary in size from one game to another.
//
// The size will be fixed when ge->Init() is called
struct edict_s *edicts;
int edict_size;
int num_edicts; // current number, <= max_edicts
int max_edicts;
struct netconsole_s *consoles;
int console_size;
int num_consoles;
int max_consoles;
struct netconbuffer_s *conbuffers;
int conbuffer_size;
struct netsurface_s *surfaces;
int surface_size;
int max_surfaces;
int num_surfaces;
} game_export_t;
game_export_t *GetGameApi (game_import_t *import);
#ifdef __cplusplus
}
#endif
#endif

533
gamescript.cpp Normal file
View File

@ -0,0 +1,533 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/gamescript.cpp $
// $Revision:: 15 $
// $Author:: Jimdose $
// $Date:: 10/20/98 10:30p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/gamescript.cpp $
//
// 15 10/20/98 10:30p Jimdose
// added crc checking to unarchive
//
// 14 10/10/98 1:28a Jimdose
// CloseScripts clears the game and dialog scripts
//
// 13 10/07/98 11:49p Jimdose
// Rewrote archiving functions for savegames
// got rid of type
//
// 12 9/22/98 4:00a Jimdose
// SetSourceScript now copies the sourcescript from the script that is passed
// in. This guarantees that it works if we pass in a copy of a script.
//
// 11 9/22/98 1:49a Jimdose
// Fixed bug where GetScript made a copy of the script that it found. All
// functions that call GetScript were then making copies of the copy, so when
// those scripts checked for labels, they checked their sourcescript's labels
// which were NULL since the sourcescript was itself a copy. whew!
//
// 10 9/21/98 10:15p Markd
// Putting archiving and unarchiving functions in
//
// 9 7/21/98 5:24p Jimdose
// GameScript now initializes type
//
// 8 7/13/98 5:56p Markd
// Added GetGameScript and SetGameScript
//
// 7 7/11/98 8:43p Markd
// Added SetDialogScript command
//
// 6 7/10/98 9:41p Jimdose
// Fixed SetSourceScript so that model scripts don't change types
//
// 5 7/07/98 11:36p Jimdose
// Added GameScriptMarker
//
// 4 6/27/98 5:45p Jimdose
// Removed call to FindLabels in Parse. This caused the script to search for
// labels anytime a new thread started
//
// 3 6/09/98 4:20p Jimdose
// Multi-file scripting implemented
//
// 2 6/05/98 2:37p Jimdose
// Created file
//
// DESCRIPTION:
// Subclass of script that preprocesses labels
//
#include "g_local.h"
#include "script.h"
#include "gamescript.h"
ScriptLibrarian ScriptLib;
CLASS_DECLARATION( Class, GameScriptMarker, NULL );
ResponseDef GameScriptMarker::Responses[] =
{
{ NULL, NULL }
};
CLASS_DECLARATION( Class, ScriptLibrarian, NULL );
ResponseDef ScriptLibrarian::Responses[] =
{
{ NULL, NULL }
};
ScriptLibrarian::~ScriptLibrarian()
{
int i;
int num;
num = scripts.NumObjects();
for( i = 1; i <= num; i++ )
{
delete scripts.ObjectAt( i );
}
}
void ScriptLibrarian::CloseScripts
(
void
)
{
int i;
int num;
GameScript *scr;
// Clear out the game and dialog scripts
SetGameScript( "" );
SetDialogScript( "" );
num = scripts.NumObjects();
for( i = num; i > 0; i-- )
{
scr = scripts.ObjectAt( i );
scripts.RemoveObjectAt( i );
delete scr;
}
}
void ScriptLibrarian::SetDialogScript
(
str scriptname
)
{
dialog_script = scriptname;
}
void ScriptLibrarian::SetGameScript
(
str scriptname
)
{
game_script = scriptname;
}
const char *ScriptLibrarian::GetGameScript
(
void
)
{
return game_script.c_str();
}
GameScript *ScriptLibrarian::FindScript
(
const char *name
)
{
int i;
int num;
GameScript *scr;
str n;
// Convert all forward slashes to back slashes
n = G_FixSlashes( name );
num = scripts.NumObjects();
for( i = 1; i <= num; i++ )
{
scr = scripts.ObjectAt( i );
if ( scr->Filename() == n )
{
return scr;
}
}
return NULL;
}
GameScript *ScriptLibrarian::GetScript
(
const char *name
)
{
GameScript *scr;
str n;
n = G_FixSlashes( name );
scr = FindScript( n.c_str() );
if ( !scr && ( gi.LoadFile( name, NULL, 0 ) != -1 ) )
{
scr = new GameScript();
scr->LoadFile( n.c_str() );
scripts.AddObject( scr );
}
return scr;
}
qboolean ScriptLibrarian::Goto
(
GameScript *scr,
const char *name
)
{
const char *p;
GameScript *s;
str n;
p = strstr( name, "::" );
if ( !p )
{
return scr->Goto( name );
}
else
{
n = str( name, 0, p - name );
if ( n == str( "dialog" ) )
{
n = dialog_script;
}
s = GetScript( n.c_str() );
if ( !s )
{
return false;
}
p += 2;
if ( s->labelExists( p ) )
{
scr->SetSourceScript( s );
return scr->Goto( p );
}
}
return false;
}
qboolean ScriptLibrarian::labelExists
(
GameScript *scr,
const char *name
)
{
const char *p;
GameScript *s;
str n;
p = strstr( name, "::" );
if ( !p )
{
return scr->labelExists( name );
}
else
{
n = str( name, 0, p - name );
if ( n == str( "dialog" ) )
{
n = dialog_script;
}
s = GetScript( n.c_str() );
if ( !s )
{
return false;
}
p += 2;
return s->labelExists( p );
}
return false;
}
CLASS_DECLARATION( Script, GameScript, NULL );
ResponseDef GameScript::Responses[] =
{
{ NULL, NULL }
};
GameScript::GameScript()
{
sourcescript = this;
labelList = NULL;
crc = 0;
}
GameScript::GameScript
(
GameScript *scr
)
{
crc = 0;
labelList = NULL;
SetSourceScript( scr );
}
GameScript::~GameScript()
{
Close();
}
void GameScript::Close
(
void
)
{
FreeLabels();
Script::Close();
sourcescript = this;
crc = 0;
}
void GameScript::SetSourceScript
(
GameScript *scr
)
{
if ( scr != this )
{
Close();
sourcescript = scr->sourcescript;
crc = sourcescript->crc;
Parse( scr->buffer, scr->length, scr->Filename() );
}
}
void GameScript::FreeLabels
(
void
)
{
int i;
int num;
if ( labelList )
{
num = labelList->NumObjects();
for( i = 1; i <= num; i++ )
{
delete labelList->ObjectAt( i );
}
delete labelList;
}
labelList = NULL;
}
void GameScript::LoadFile
(
const char *name
)
{
str n;
// Convert all forward slashes to back slashes
n = G_FixSlashes( name );
sourcescript = this;
Script::LoadFile( n.c_str() );
FindLabels();
crc = gi.CalcCRC( buffer, length );
}
void GameScript::FindLabels
(
void
)
{
scriptmarker_t mark;
const char *tok;
script_label_t *label;
int len;
FreeLabels();
labelList = new Container<script_label_t *>;
MarkPosition( &mark );
Reset();
while( TokenAvailable( true ) )
{
tok = GetToken( true );
// see if it is a label
if ( tok )
{
len = strlen( tok );
if ( len && tok[ len - 1 ] == ':' )
{
if ( !labelExists( tok ) )
{
label = new script_label_t;
MarkPosition( &label->pos );
label->labelname = tok;
labelList->AddObject( label );
}
else
{
warning( "FindLabels", "Duplicate labels %s\n", tok );
}
}
}
}
RestorePosition( &mark );
}
EXPORT_FROM_DLL qboolean GameScript::labelExists
(
const char *name
)
{
str labelname;
script_label_t *label;
int i;
int num;
if ( !sourcescript->labelList )
{
return false;
}
labelname = name;
if ( !labelname.length() )
{
return false;
}
if ( labelname[ labelname.length() - 1 ] != ':' )
{
labelname += ":";
}
num = sourcescript->labelList->NumObjects();
for( i = 1; i <= num; i++ )
{
label = sourcescript->labelList->ObjectAt( i );
if ( labelname == label->labelname )
{
return true;
}
}
return false;
}
EXPORT_FROM_DLL qboolean GameScript::Goto
(
const char *name
)
{
str labelname;
script_label_t *label;
int i;
int num;
if ( !sourcescript->labelList )
{
return false;
}
labelname = name;
if ( !labelname.length() )
{
return false;
}
if ( labelname[ labelname.length() - 1 ] != ':' )
{
labelname += ":";
}
num = sourcescript->labelList->NumObjects();
for( i = 1; i <= num; i++ )
{
label = sourcescript->labelList->ObjectAt( i );
if ( labelname == label->labelname )
{
RestorePosition( &label->pos );
return true;
}
}
return false;
}
EXPORT_FROM_DLL void GameScript::Mark
(
GameScriptMarker *mark
)
{
assert( mark );
assert( sourcescript );
mark->filename = sourcescript->Filename();
MarkPosition( &mark->scriptmarker );
}
EXPORT_FROM_DLL void GameScript::Restore
(
GameScriptMarker *mark
)
{
// If we change this function, we must update the unarchive function as well
GameScript *scr;
assert( mark );
scr = ScriptLib.FindScript( mark->filename.c_str() );
if ( scr )
{
SetSourceScript( scr );
}
else
{
LoadFile( mark->filename.c_str() );
}
RestorePosition( &mark->scriptmarker );
}

264
gamescript.h Normal file
View File

@ -0,0 +1,264 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/gamescript.h $
// $Revision:: 11 $
// $Author:: Jimdose $
// $Date:: 10/25/98 11:53p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/gamescript.h $
//
// 11 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 10 10/20/98 10:30p Jimdose
// added crc checking to unarchive
//
// 9 10/07/98 11:50p Jimdose
// Rewrote archiving functions for savegames
// got rid of type
//
// 8 9/22/98 1:49a Jimdose
// removed freelabels
//
// 7 9/21/98 10:15p Markd
// Putting archiving and unarchiving functions in
//
// 6 7/13/98 5:57p Markd
// Added Setgamescript and Getgamescript methods
//
// 5 7/11/98 8:43p Markd
// Added SetDialogScript
//
// 4 7/07/98 11:36p Jimdose
// Added GameScriptMarker
//
// 3 6/09/98 4:24p Jimdose
// finished implimentation
//
// 2 6/05/98 2:37p Jimdose
// Created file
//
// DESCRIPTION:
// Subclass of script that preprocesses labels
//
#ifndef __GAMESCRIPT_H__
#define __GAMESCRIPT_H__
#include "class.h"
#include "script.h"
typedef struct
{
scriptmarker_t pos;
str labelname;
} script_label_t;
class GameScript;
class EXPORT_FROM_DLL GameScriptMarker : public Class
{
public:
CLASS_PROTOTYPE( GameScriptMarker );
str filename;
scriptmarker_t scriptmarker;
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void GameScriptMarker::Archive
(
Archiver &arc
)
{
// Game scripts are unique in that we don't call our superclass to archive it's data.
// Instead, we only read enough info to then initialize the script ourselves.
arc.WriteString( filename );
arc.WriteBoolean( scriptmarker.tokenready );
arc.WriteInteger( scriptmarker.offset );
arc.WriteInteger( scriptmarker.line );
arc.WriteRaw( scriptmarker.token, sizeof( scriptmarker.token ) );
}
inline EXPORT_FROM_DLL void GameScriptMarker::Unarchive
(
Archiver &arc
)
{
// Game scripts are unique in that we don't call our superclass to archive it's data.
// Instead, we only read enough info to then initialize the script ourselves.
arc.ReadString( &filename );
arc.ReadBoolean( &scriptmarker.tokenready );
arc.ReadInteger( &scriptmarker.offset );
arc.ReadInteger( &scriptmarker.line );
arc.ReadRaw( scriptmarker.token, sizeof( scriptmarker.token ) );
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<script_label_t *>;
#endif
class EXPORT_FROM_DLL GameScript : public Script
{
protected:
Container<script_label_t *> *labelList;
GameScript *sourcescript;
unsigned crc;
public:
CLASS_PROTOTYPE( GameScript );
GameScript();
GameScript( GameScript *scr );
~GameScript();
void Close( void );
void SetSourceScript( GameScript *scr );
void LoadFile( const char *filename );
void Mark( GameScriptMarker *mark );
void Restore( GameScriptMarker *mark );
void FreeLabels( void );
void FindLabels( void );
qboolean labelExists( const char *name );
qboolean Goto( const char *name );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<GameScript *>;
#endif
class EXPORT_FROM_DLL ScriptLibrarian : public Class
{
protected:
Container<GameScript *> scripts;
str dialog_script;
str game_script;
public:
CLASS_PROTOTYPE( ScriptLibrarian );
~ScriptLibrarian();
void CloseScripts( void );
void SetDialogScript( str scriptname );
void SetGameScript( str scriptname );
const char *GetGameScript( void );
GameScript *FindScript( const char *name );
GameScript *GetScript( const char *name );
qboolean Goto( GameScript *scr, const char *name );
qboolean labelExists( GameScript *scr, const char *name );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void ScriptLibrarian::Archive
(
Archiver &arc
)
{
GameScript * scr;
int i, num;
Class::Archive( arc );
num = scripts.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
scr = scripts.ObjectAt( i );
arc.WriteObject( scr );
}
arc.WriteString( dialog_script );
arc.WriteString( game_script );
}
inline EXPORT_FROM_DLL void ScriptLibrarian::Unarchive
(
Archiver &arc
)
{
GameScript * scr;
int i, num;
Class::Unarchive( arc );
scripts.FreeObjectList();
arc.ReadInteger( &num );
for ( i = 1; i <= num; i++ )
{
scr = new GameScript;
arc.ReadObject( scr );
scripts.AddObject( scr );
}
arc.ReadString( &dialog_script );
arc.ReadString( &game_script );
}
extern ScriptLibrarian ScriptLib;
inline EXPORT_FROM_DLL void GameScript::Archive
(
Archiver &arc
)
{
// Game scripts are unique in that we don't call our superclass to archive it's data.
// Instead, we only read enough info to then initialize the script ourselves.
GameScriptMarker mark;
arc.WriteUnsigned( crc );
Mark( &mark );
arc.WriteObject( &mark );
}
inline EXPORT_FROM_DLL void GameScript::Unarchive
(
Archiver &arc
)
{
// This function is based in part on Restore, so it changes, we must update this function as well.
// Game scripts are unique in that we don't call our superclass to archive it's data.
// Instead, we only read enough info to then initialize the script ourselves.
GameScriptMarker mark;
unsigned filecrc;
GameScript *scr;
arc.ReadUnsigned( &filecrc );
arc.ReadObject( &mark );
scr = ScriptLib.FindScript( mark.filename.c_str() );
if ( scr )
{
SetSourceScript( scr );
}
else
{
LoadFile( mark.filename.c_str() );
}
// Error out if CRCs have changed
if ( filecrc != crc )
{
gi.error( "File '%s' has changed from when this savegame was written. Load cancelled.\n", filename.c_str() );
}
RestorePosition( &mark.scriptmarker );
}
#endif

133
genericbullet.cpp Normal file
View File

@ -0,0 +1,133 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/genericbullet.cpp $
// $Revision:: 16 $
// $Author:: Aldie $
// $Date:: 10/27/98 3:44a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/genericbullet.cpp $
//
// 16 10/27/98 3:44a Aldie
// Tweak damage
//
// 15 10/23/98 4:45a Aldie
// Added BeeGun for the Beecadrone
//
// 14 10/13/98 2:28p Aldie
// Do a tracer on every shot
//
// 13 10/05/98 11:23p Markd
// Added ReconahGun
//
// 12 10/04/98 10:22p Markd
// Took out NextAttack delerations
//
// 11 8/26/98 5:36p Aldie
// Don't need a worldmodel for genbullet.
//
// 10 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and
// rocket jumping.
//
// 9 8/01/98 3:24p Aldie
// Added server effects flag for specific weapons
//
// 8 7/26/98 3:53p Aldie
// Network tweaking
//
// 7 7/26/98 3:12a Aldie
// Changed muzzle flash
//
// 6 7/22/98 10:41p Aldie
// Fixed tracers
//
// 5 7/22/98 5:16p Aldie
// Added tracers
//
// 4 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 3 7/17/98 4:40p Aldie
// Changed models to genbullet.def
//
// 2 7/08/98 11:23p Markd
// first time
//
// 1 7/08/98 9:07p Markd
//
// DESCRIPTION:
// Generic Bullet Weapon.
//
#include "g_local.h"
#include "genericbullet.h"
CLASS_DECLARATION( BulletWeapon, GenericBullet, "weapon_genericbullet" );
ResponseDef GenericBullet::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )GenericBullet::Shoot },
{ NULL, NULL }
};
GenericBullet::GenericBullet()
{
SetModels( NULL, "view_genbullet.def" );
SetAmmo( "Bullet10mm", 1, 100 );
}
void GenericBullet::Shoot
(
Event *ev
)
{
FireTracer();
FireBullets( 1, "10 10 10", 2, 3, DAMAGE_BULLET, MOD_GENBULLET, true );
NextAttack( 0 );
}
CLASS_DECLARATION( GenericBullet, ReconahGun, "weapon_reconahgun" );
ResponseDef ReconahGun::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )ReconahGun::Shoot },
{ NULL, NULL }
};
void ReconahGun::Shoot
(
Event *ev
)
{
if ( ( level.framenum % 3 ) == ( entnum % 3 ) )
{
FireTracer();
}
FireBullets( 1, "10 10 10", 14, 26, DAMAGE_BULLET, MOD_GENBULLET, true );
}
CLASS_DECLARATION( GenericBullet, BeeGun, "weapon_beegun" );
ResponseDef BeeGun::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )BeeGun::Shoot },
{ NULL, NULL }
};
void BeeGun::Shoot
(
Event *ev
)
{
FireBullets( 1, "10 10 10", 4, 8, DAMAGE_BULLET, MOD_GENBULLET, true );
}

70
genericbullet.h Normal file
View File

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/genericbullet.h $
// $Revision:: 6 $
// $Author:: Aldie $
// $Date:: 10/23/98 5:09a $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/genericbullet.h $
//
// 6 10/23/98 5:09a Aldie
// Added BeeGun
//
// 5 10/05/98 11:23p Markd
// Added ReconahGun
//
// 4 7/22/98 10:41p Aldie
// Fixed tracers
//
// 3 7/22/98 5:17p Aldie
// Added tracers
//
// 2 7/08/98 11:23p Markd
// first time
//
// 1 7/08/98 9:07p Markd
//
// DESCRIPTION:
// Generic Bullet Weapon.
//
#ifndef __GENERIC_BULLET_H__
#define __GENERIC_BULLET_H__
#include "g_local.h"
#include "item.h"
#include "weapon.h"
#include "bullet.h"
class EXPORT_FROM_DLL GenericBullet : public BulletWeapon
{
public:
CLASS_PROTOTYPE( GenericBullet );
GenericBullet::GenericBullet();
virtual void Shoot( Event *ev );
};
class EXPORT_FROM_DLL ReconahGun : public GenericBullet
{
public:
CLASS_PROTOTYPE( ReconahGun );
virtual void Shoot( Event *ev );
};
class EXPORT_FROM_DLL BeeGun : public GenericBullet
{
public:
CLASS_PROTOTYPE( BeeGun );
virtual void Shoot( Event *ev );
};
#endif /* generic bullet.h */

65
genericrocket.cpp Normal file
View File

@ -0,0 +1,65 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/genericrocket.cpp $
// $Revision:: 3 $
// $Author:: Markd $
// $Date:: 10/04/98 10:23p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/genericrocket.cpp $
//
// 3 10/04/98 10:23p Markd
// Took out NextAttack stuff
//
// 2 9/15/98 6:46p Aldie
// Generic rocket for pinphat
//
// DESCRIPTION:
// Generic Rocket Launcher - to be used on monsters that have rocket launchers
// shown in their models
#include "g_local.h"
#include "genericrocket.h"
#include "rocketlauncher.h"
CLASS_DECLARATION( RocketLauncher, GenericRocket, "weapon_genericrocket" );
ResponseDef GenericRocket::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )GenericRocket::Shoot },
{ NULL, NULL }
};
GenericRocket::GenericRocket()
{
SetModels( NULL, "view_genrocket.def" );
SetAmmo( "Rockets", 1, 5 );
}
void GenericRocket::Shoot
(
Event *ev
)
{
Rocket *rocket;
Vector pos;
Vector dir;
assert( owner );
if ( !owner )
{
return;
}
GetMuzzlePosition( &pos, &dir );
rocket = new Rocket;
rocket->Setup( owner, pos, dir );
}

43
genericrocket.h Normal file
View File

@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/genericrocket.h $
// $Revision:: 3 $
// $Author:: Markd $
// $Date:: 10/04/98 10:26p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/genericrocket.h $
//
// 3 10/04/98 10:26p Markd
// Made it a subclass of RocketLauncher
//
// 2 9/15/98 6:47p Aldie
// Generic rocket for pinphat
//
// DESCRIPTION:
// Generic Rocket Launcher - to be used on monsters that have rocket launchers
// shown in their models
#ifndef __GENERIC_ROCKET_H__
#define __GENERIC_ROCKET_H__
#include "g_local.h"
#include "item.h"
#include "weapon.h"
#include "rocketlauncher.h"
class EXPORT_FROM_DLL GenericRocket : public RocketLauncher
{
public:
CLASS_PROTOTYPE( GenericRocket );
GenericRocket::GenericRocket();
virtual void Shoot( Event *ev );
};
#endif /* genericrocket.h */

301
gibs.cpp Normal file
View File

@ -0,0 +1,301 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/gibs.cpp $
// $Revision:: 21 $
// $Author:: Jimdose $
// $Date:: 11/19/98 9:29p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/gibs.cpp $
//
// 21 11/19/98 9:29p Jimdose
// gibs copy gravaxis
//
// 20 11/09/98 1:09a Aldie
// Changed fadesplat to fade in 30 secs
//
// 19 11/08/98 8:31p Aldie
// Added ability to not fade splats
//
// 18 10/22/98 9:30p Aldie
// Modified gib physics a little
//
// 17 10/07/98 11:51p Jimdose
// moved body_parts out of game structure
//
// 16 9/22/98 5:26p Markd
// fixed small gib bug
//
// 15 9/22/98 5:19p Markd
// Put in new consolidated gib function
//
// 14 9/20/98 5:11p Aldie
// Added blood trail to gib constructor
//
// 13 8/29/98 9:43p Jimdose
// Added call info to G_Trace
//
// 12 8/27/98 9:02p Jimdose
// Changed centroid to a variable
//
// 11 8/19/98 8:49p Aldie
// Increased gibbage velocity
//
// 10 8/10/98 6:52p Aldie
// Changed the gib throwing code
//
// 9 7/29/98 2:31p Aldie
// Changed health to a float
//
// 8 7/26/98 3:58p Aldie
// Reversed a logic bug
//
// 7 7/25/98 8:39p Aldie
// Bloodsplat only in single player
//
// 6 7/24/98 10:04p Aldie
// Changed the gibs layout
//
// 5 7/23/98 6:55p Aldie
// Fun with gibs
//
// 4 7/23/98 6:17p Aldie
// Updated damage system and fixed some damage related bugs. Also put tracers
// back to the way they were, and added gib event to funcscriptmodels
//
// 3 6/30/98 12:40p Aldie
// Changed bloodsplat scale.
//
// 2 5/27/98 5:03a Aldie
// First version of gibs
//
// DESCRIPTION:
// Gibs - nuff said
#include "gibs.h"
const char *body_parts[] =
{
"gib1.def", "gibtorso.def", "gibhead.def", "gibleg.def"
//"gib1.def", "gib2.def", "gibhead.def", "gibleg.def", "gibarm.def", "gibribs.def"
};
const int num_body_parts = ( sizeof( body_parts ) / sizeof( body_parts[ 0 ] ) );
CLASS_DECLARATION( Entity, Gib, "gib" );
Event EV_ThrowGib("throwgib");
ResponseDef Gib::Responses[] =
{
{ &EV_ThrowGib, ( Response )Gib::Throw },
{ &EV_Touch, ( Response )Gib::Splat },
{ NULL, NULL }
};
Gib::Gib
(
const char *name,
qboolean blood_trail
)
{
setSize("0 0 0", "0 0 0");
setModel(name);
setMoveType( MOVETYPE_BOUNCE );
setSolidType( SOLID_BBOX );
if ( blood_trail )
edict->s.effects |= EF_GIB;
sprayed = false;
fadesplat = true;
}
Gib::Gib()
{
setSize("0 0 0", "0 0 0");
setModel("gib1.def");
setMoveType( MOVETYPE_BOUNCE );
setSolidType( SOLID_BBOX );
edict->s.effects |= EF_GIB;
sprayed = false;
fadesplat = true;
}
void Gib::Splat
(
Event *ev
)
{
Vector end;
if (deathmatch->value)
return;
if (!sv_gore->value)
return;
if (sprayed)
return;
sprayed = true;
end = origin;
end.z -= 1024;
SprayBlood(origin, end, 25);
setSolidType(SOLID_NOT);
}
void Gib::SprayBlood
(
Vector start,
Vector end,
int damage
)
{
trace_t trace;
float dist;
float scale;
Entity *splat;
Vector norm;
trace = G_Trace( start, vec_zero, vec_zero, end, NULL, MASK_SOLIDNONFENCE, "Gib::SprayBlood" );
if ( HitSky( &trace ) || ( trace.ent->solid != SOLID_BSP ) )
{
return;
}
dist = ( Vector( trace.endpos ) - start ).length();
scale = ( float )damage / ( dist * 0.3 );
if ( scale > 0.6 )
{
scale = 0.6;
}
if ( scale < 0.02 )
{
return;
}
// Do a bloodsplat
splat = new Entity;
splat->setMoveType( MOVETYPE_NONE );
splat->setSolidType( SOLID_NOT );
splat->setModel( "sprites/bloodsplat.spr" );
splat->edict->s.frame = G_Random( 4 );
splat->setSize( "0 0 0", "0 0 0" );
splat->edict->s.scale = scale * this->edict->s.scale;
norm = trace.plane.normal;
norm.x = -norm.x;
norm.y = -norm.y;
splat->angles = norm.toAngles();
splat->angles.z = G_Random( 360 );
splat->setAngles( splat->angles );
splat->setOrigin( Vector( trace.endpos ) + ( Vector( trace.plane.normal ) * 0.2 ) );
if ( fadesplat )
splat->PostEvent( EV_FadeOut, 3 );
else
splat->PostEvent( EV_FadeOut, 30 );
}
void Gib::ClipGibVelocity
(
void
)
{
if (velocity[0] < -400)
velocity[0] = -400;
else if (velocity[0] > 400)
velocity[0] = 400;
if (velocity[1] < -400)
velocity[1] = -400;
else if (velocity[1] > 400)
velocity[1] = 400;
if (velocity[2] < 200)
velocity[2] = 200; // always some upwards
else if (velocity[2] > 600)
velocity[2] = 600;
}
void Gib::SetVelocity
(
float damage
)
{
velocity[0] = 100.0 * crandom();
velocity[1] = 100.0 * crandom();
velocity[2] = 200.0 + 100.0 * random();
avelocity = Vector( G_Random( 600 ), G_Random( 600 ), G_Random( 600 ) );
if ( ( damage < -150 ) && ( G_Random() > 0.95f ) )
velocity *= 2.0f;
else if ( damage < -100 )
velocity *= 1.5f;
ClipGibVelocity();
}
void Gib::Throw
(
Event *ev
)
{
Entity *ent;
ent = ev->GetEntity(1);
setOrigin(ent->centroid);
worldorigin.copyTo(edict->s.old_origin);
SetVelocity(ev->GetInteger(2));
edict->s.scale = ev->GetFloat(3);
PostEvent(EV_FadeOut, 10 + G_Random(5));
}
void CreateGibs
(
Entity * ent,
float damage,
float scale,
int num,
const char * modelname
)
{
int i;
Gib * gib;
assert( ent );
if ( !ent )
return;
ent->RandomGlobalSound( "impact_gib" );
for ( i = 0; i < num; i++ )
{
if ( modelname )
{
gib = new Gib( modelname );
}
else
{
gib = new Gib( body_parts[ i % num_body_parts ] );
}
gib->setOrigin(ent->centroid);
gib->worldorigin.copyTo(gib->edict->s.old_origin);
gib->SetVelocity( damage );
gib->edict->s.scale = scale + G_Random( scale * 0.3 );
gib->SetGravityAxis( ent->gravaxis );
gib->PostEvent(EV_FadeOut, 10 + G_Random(5));
}
}

97
gibs.h Normal file
View File

@ -0,0 +1,97 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/gibs.h $
// $Revision:: 8 $
// $Author:: Aldie $
// $Date:: 11/08/98 8:30p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/gibs.h $
//
// 8 11/08/98 8:30p Aldie
// Added ability to not fade splats
//
// 7 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 6 9/22/98 5:19p Markd
// Put in new consolidated gib function
//
// 5 9/20/98 5:13p Aldie
// Added blood trail to gib
//
// 4 8/10/98 6:53p Aldie
// Changed the gib throwing
//
// 3 7/29/98 2:32p Aldie
// Changed health to a float
//
// 2 5/27/98 5:04a Aldie
// First version of gibs
//
// DESCRIPTION:
// Gibs - nuff said
#ifndef __GIBS_H__
#define __GIBS_H__
#include "g_local.h"
class EXPORT_FROM_DLL Gib : public Entity
{
private:
qboolean sprayed;
public:
CLASS_PROTOTYPE( Gib );
qboolean fadesplat;
Gib();
Gib(const char *name, qboolean blood_trail=true);
void SetVelocity( float health );
void SprayBlood( Vector start, Vector end, int damage );
void Throw(Event *ev);
void Splat(Event *ev);
void ClipGibVelocity( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Gib::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteBoolean( sprayed );
arc.WriteBoolean( fadesplat );
}
inline EXPORT_FROM_DLL void Gib::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadBoolean( &sprayed );
arc.ReadBoolean( &fadesplat );
}
void CreateGibs
(
Entity * ent,
float damage = -50,
float scale = 1.0f,
int num = 1,
const char * modelname = NULL
);
extern Event EV_ThrowGib;
#endif // gibs.h

124
glowstick.cpp Normal file
View File

@ -0,0 +1,124 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/glowstick.cpp $
// $Revision:: 12 $
// $Author:: Aldie $
// $Date:: 10/24/98 3:14p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/glowstick.cpp $
//
// 12 10/24/98 3:14p Aldie
// Upped the life of sticks
//
// 11 10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
//
// 10 10/07/98 1:17a Aldie
// New model
//
// 9 7/25/98 7:10p Markd
// Put in EV_Removes for demo
//
// 8 7/21/98 7:33p Aldie
// Changed def file
//
// 7 7/20/98 3:52p Aldie
// Fixed the icon
//
// 6 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 5 6/24/98 1:36p Aldie
// Implementation of inventory system and picking stuff up
//
// 4 6/20/98 7:03p Aldie
// Changed the avel
//
// 3 6/20/98 6:53p Aldie
// Changed the model back to hvshell.def
//
// 2 6/19/98 6:37p Aldie
// First version of glowstick
//
// DESCRIPTION:
// Glowstick for a lightsource
#include "inventoryitem.h"
class EXPORT_FROM_DLL GlowStick : public InventoryItem
{
public:
CLASS_PROTOTYPE( GlowStick );
GlowStick();
void Use( Event *ev );
};
CLASS_DECLARATION( InventoryItem, GlowStick, "powerups_glowstick" )
ResponseDef GlowStick::Responses[] =
{
{ &EV_InventoryItem_Use, ( Response )GlowStick::Use },
{ NULL, NULL }
};
GlowStick::GlowStick
(
)
{
#ifdef SIN_DEMO
PostEvent( EV_Remove, 0 );
return;
#endif
setModel( "glowstick.def" );
Set( 1 );
}
void GlowStick::Use
(
Event *ev
)
{
Entity *glowstick;
Vector dir;
assert( owner );
// Make sure there is a glowstick to
assert( amount );
amount--;
if (amount <= 0)
{
owner->RemoveItem( this );
}
dir = owner->orientation[ 0 ];
glowstick = new Entity;
glowstick->angles = dir.toAngles();
glowstick->setAngles( glowstick->angles );
glowstick->setMoveType( MOVETYPE_BOUNCE );
glowstick->setSolidType( SOLID_NOT );
glowstick->setModel( "glowstick.def" );
glowstick->edict->s.renderfx |= RF_DLIGHT;
glowstick->avelocity = "500 0 0";
glowstick->velocity = dir * 500;
glowstick->edict->s.color_r = 0.4;
glowstick->edict->s.color_g = 1.0;
glowstick->edict->s.color_b = 0.1;
glowstick->edict->s.radius = 200;
glowstick->setOrigin( owner->worldorigin + Vector(0,0,owner->viewheight) );
glowstick->PostEvent(EV_Remove, 60);
}

722
gravpath.cpp Normal file
View File

@ -0,0 +1,722 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/gravpath.cpp $
// $Revision:: 18 $
// $Author:: Markd $
// $Date:: 10/24/98 12:42a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/gravpath.cpp $
//
// 18 10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
//
// 17 10/21/98 2:24a Jimdose
// Made GravPath not add to the gravPathManager while loading savegames
//
// 16 10/09/98 5:22p Aldie
// Changed commands to activate and deactivate
//
// 15 10/07/98 11:52p Jimdose
// Added destructor for GravPathManager
//
// 14 9/30/98 4:34p Aldie
// Free gravpath when level changes
//
// 13 9/30/98 1:17p Markd
// Fixed gravpath null pointer checks
//
// 12 9/29/98 5:33p Aldie
// Added force gravity to the path
//
// 11 8/29/98 9:43p Jimdose
// Added call info to G_Trace
//
// 10 8/27/98 2:55p Aldie
// Added a headnode spawnflag
//
// 9 8/27/98 2:33p Aldie
// Added functionality so gravpaths work out of water
//
// 8 8/26/98 8:46p Aldie
// Added activate and deactivate commands
//
// 7 5/26/98 4:45p Aldie
// Fixed an error printf
//
// 6 5/25/98 2:28p Aldie
// Fixed issues with not loading game dll
//
// 5 5/23/98 10:21p Aldie
// Removed drawing of gravpath.
//
// 4 5/23/98 5:15p Aldie
// Removed traces checking for obstacles when finding the closest grav point.
//
// 3 5/22/98 12:24p Aldie
// Updated defaults
//
// 2 5/22/98 12:19p Aldie
// First version of gravity path
//
// DESCRIPTION:
// Gravity path - Used for underwater currents and wells.
#include "g_local.h"
#include "entity.h"
#include "gravpath.h"
#include "container.h"
#include "navigate.h"
#include "misc.h"
#include "player.h"
GravPathManager gravPathManager;
CLASS_DECLARATION(Class, GravPathManager, NULL);
ResponseDef GravPathManager::Responses[] =
{
{ NULL,NULL }
};
GravPathManager::~GravPathManager()
{
Reset();
}
void GravPathManager::Reset( void )
{
while( pathList.NumObjects() > 0 )
{
delete ( GravPath * )pathList.ObjectAt( 1 );
}
pathList.FreeObjectList();
}
void GravPathManager::AddPath(GravPath *p)
{
int num;
num = pathList.AddObject( p );
pathList.Resize( pathList.NumObjects() );
}
void GravPathManager::RemovePath(GravPath *p)
{
pathList.RemoveObject( p );
pathList.Resize( pathList.NumObjects() );
}
Vector GravPathManager::CalculateGravityPull(Entity &ent, Vector pos, qboolean *force)
{
int i,num;
GravPath *p;
GravPathNode *node;
Vector point;
Vector newpoint;
Vector dir;
float bestdist = 99999;
float dist;
float speed;
float radius;
Vector velocity;
int bestpath = 0;
int entity_contents, grav_contents;
num = pathList.NumObjects();
entity_contents = gi.pointcontents( ent.worldorigin.vec3() );
for( i = 1; i <= num; i++ )
{
p = ( GravPath * )pathList.ObjectAt( i );
if ( !p )
continue;
// Check to see if path is active
node = p->GetNode( 1 );
if ( !node || !node->active )
continue;
// Check to see if the contents are the same
grav_contents = gi.pointcontents( node->worldorigin.vec3() );
// If grav node is in water, make sure ent is too.
if ( ( grav_contents & CONTENTS_WATER ) && !( entity_contents & CONTENTS_WATER ) )
continue;
// Test to see if we are in this path's bounding box
if ( (pos.x < p->maxs.x) && (pos.y < p->maxs.y) && (pos.z < p->maxs.z) &&
(pos.x > p->mins.x) && (pos.y > p->mins.y) && (pos.z > p->mins.z) )
{
point = p->ClosestPointOnPath(pos, ent, &dist, &speed, &radius);
// If the closest distance on the path is greater than the radius, then
// do not consider this path.
if (dist > radius)
{
continue;
}
else if (dist < bestdist)
{
bestpath = i;
bestdist = dist;
}
}
}
if (!bestpath)
{
return vec_zero;
}
p = ( GravPath * )pathList.ObjectAt( bestpath );
if ( !p )
return velocity;
*force = p->force;
dist = p->DistanceAlongPath(pos, &speed);
newpoint = p->PointAtDistance( dist + speed);
dir = newpoint-pos;
dir.normalize();
velocity = dir * speed;
return velocity;
}
/*****************************************************************************/
/*SINED info_grav_pathnode (0 0 .5) (-16 -16 0) (16 16 32) HEADNODE FORCE
"radius" Radius of the effect of the pull (Default is 256)
"speed" Speed of the pull (Use negative for a repulsion) (Default is 100)
Set HEADNODE to signify the head of the path.
Set FORCE if you want un-fightable gravity ( i.e. can't go backwards )
/*****************************************************************************/
CLASS_DECLARATION( Entity, GravPathNode, "info_grav_pathnode" );
Event EV_GravPath_Create( "gravpath_create" );
Event EV_GravPath_Activate( "activate" );
Event EV_GravPath_Deactivate( "deactivate" );
ResponseDef GravPathNode::Responses[] =
{
{ &EV_GravPath_Create, ( Response )GravPathNode::CreatePath },
{ &EV_GravPath_Activate, ( Response )GravPathNode::Activate },
{ &EV_GravPath_Deactivate, ( Response )GravPathNode::Deactivate },
{ NULL, NULL }
};
GravPathNode::GravPathNode()
{
setMoveType( MOVETYPE_NONE );
setSolidType( SOLID_NOT );
hideModel();
speed = G_GetFloatArg( "speed",100.0f );
radius = G_GetFloatArg( "radius",256.0f );
headnode = spawnflags & 1;
active = true;
// This is the head of a new path, post an event to create the path
if ( headnode )
{
PostEvent( EV_GravPath_Create, 0 );
}
}
float GravPathNode::Speed( void )
{
if ( active )
return speed;
else
return 0;
};
void GravPathNode::Activate(Event *ev)
{
GravPathNode *node;
int num;
const char *target;
active = true;
node = this;
// Go through the entire path and activate it
target = node->Target();
while (target[0])
{
if (num = G_FindTarget(0, target))
{
node = (GravPathNode *)G_GetEntity( num );
assert( node );
node->active = true;
}
else
{
gi.error("GravPathNode::CreatePath: target %s not found\n",target);
}
target = node->Target();
}
}
void GravPathNode::Deactivate(Event *ev)
{
GravPathNode *node;
int num;
const char *target;
active = false;
node = this;
// Go through the entire path and activate it
target = node->Target();
while (target[0])
{
if (num = G_FindTarget(0, target))
{
node = (GravPathNode *)G_GetEntity( num );
assert( node );
node->active = false;
}
else
{
gi.error("GravPathNode::CreatePath: target %s not found\n",target);
}
target = node->Target();
}
}
void GravPathNode::CreatePath(Event *ev)
{
const char *target;
GravPath *path = new GravPath;
GravPathNode *node;
int num;
ClearBounds(path->mins.vec3(),path->maxs.vec3());
// This node is the head of a path, create a new path in the path manager.
// and add it in, then add all of it's children in the path.
node = this;
path->AddNode(node);
path->force = spawnflags & 2;
// Make the path from the targetlist.
target = node->Target();
while (target[0])
{
if (num = G_FindTarget(0, target))
{
node = (GravPathNode *)G_GetEntity( num );
assert( node );
path->AddNode(node);
}
else
{
gi.error("GravPathNode::CreatePath: target %s not found\n",target);
}
target = node->Target();
}
// Set the origin.
path->origin = path->mins + path->maxs;
path->origin *= 0.5f;
}
CLASS_DECLARATION( Listener, GravPath, NULL );
Event EV_DrawGravPath( "drawpath" );
ResponseDef GravPath::Responses[] =
{
{ &EV_DrawGravPath, (Response)GravPath::DrawPath },
{ NULL, NULL }
};
GravPath::GravPath()
{
// Event *event;
pathlength = 0;
from = NULL;
to = NULL;
nextnode = 1;
if ( !LoadingSavegame )
{
gravPathManager.AddPath(this);
}
// event = new Event(EV_DrawGravPath);
// event->AddFloat(1);
// event->AddFloat(0);
// event->AddFloat(0);
// PostEvent(event,0.1f);
}
GravPath::~GravPath()
{
pathlength = 0;
from = NULL;
to = NULL;
nextnode = 1;
gravPathManager.RemovePath(this);
}
void GravPath::Clear
(
void
)
{
nextnode = 1;
pathlength = 0;
from = NULL;
to = NULL;
pathlist.FreeObjectList();
}
void GravPath::Reset
(
void
)
{
nextnode = 1;
}
GravPathNode *GravPath::Start
(
void
)
{
return from;
}
GravPathNode *GravPath::End
(
void
)
{
return to;
}
void GravPath::AddNode
(
GravPathNode *node
)
{
int num;
Vector r,addp;
if ( !from )
{
from = node;
}
to = node;
pathlist.AddObject( GravPathNodePtr( node ) );
num = NumNodes();
if ( num > 1 )
{
pathlength += ( node->worldorigin - GetNode( num )->worldorigin ).length();
}
r.setXYZ(node->Radius(),node->Radius(),node->Radius());
addp = node->worldorigin + r;
AddPointToBounds(addp.vec3(),mins.vec3(),maxs.vec3());
addp = node->worldorigin - r;
AddPointToBounds(addp.vec3(),mins.vec3(),maxs.vec3());
}
GravPathNode *GravPath::GetNode
(
int num
)
{
return pathlist.ObjectAt( num );
}
GravPathNode *GravPath::NextNode
(
void
)
{
if ( nextnode <= NumNodes() )
{
return pathlist.ObjectAt( nextnode++ );
}
return NULL;
}
Vector GravPath::ClosestPointOnPath
(
Vector pos,
Entity &ent,
float *ret_dist,
float *speed,
float *radius
)
{
GravPathNode *s;
GravPathNode *e;
int num;
int i;
float bestdist;
Vector bestpoint;
float dist;
float segmentlength;
Vector delta;
Vector p1;
Vector p2;
Vector p3;
float t;
trace_t trace;
num = NumNodes();
s = GetNode( 1 );
trace = G_Trace( pos, ent.mins, ent.maxs, s->worldorigin, &ent, MASK_PLAYERSOLID, "GravPath::ClosestPointOnPath 1" );
bestpoint = s->worldorigin;
delta = bestpoint - pos;
bestdist = delta.length();
*speed = s->Speed();
*radius = s->Radius();
for( i = 2; i <= num; i++ )
{
e = GetNode( i );
// check if we're closest to the endpoint
delta = e->worldorigin - pos;
dist = delta.length();
if ( dist < bestdist )
{
trace = G_Trace( pos, ent.mins, ent.maxs, e->worldorigin, &ent, MASK_PLAYERSOLID, "GravPath::ClosestPointOnPath 2" );
bestdist = dist;
bestpoint = e->worldorigin;
*speed = e->Speed();
*radius = e->Radius();
}
// check if we're closest to the segment
p1 = e->worldorigin - s->worldorigin;
segmentlength = p1.length();
p1 *= 1 / segmentlength;
p2 = pos - s->worldorigin;
t = p1 * p2;
if ( ( t > 0 ) && ( t < segmentlength ) )
{
p3 = ( p1 * t ) + s->worldorigin;
delta = p3 - pos;
dist = delta.length();
if ( dist < bestdist )
{
trace = G_Trace( pos, ent.mins, ent.maxs, p3, &ent, MASK_PLAYERSOLID, "GravPath::ClosestPointOnPath 3" );
bestdist = dist;
bestpoint = p3;
*speed = (e->Speed() * t) + (s->Speed() * (1.0f - t));
*radius = (e->Radius() * t) + (s->Radius() * (1.0f - t));
}
}
s = e;
}
*ret_dist = bestdist;
return bestpoint;
}
float GravPath::DistanceAlongPath
(
Vector pos,
float *speed
)
{
GravPathNode *s;
GravPathNode *e;
int num;
int i;
float bestdist;
float dist;
float segmentlength;
Vector delta;
Vector segment;
Vector p1;
Vector p2;
Vector p3;
float t;
float pathdist;
float bestdistalongpath;
float oosl;
pathdist = 0;
num = NumNodes();
s = GetNode( 1 );
delta = s->worldorigin - pos;
bestdist = delta.length();
bestdistalongpath = 0;
*speed = s->Speed();
for( i = 2; i <= num; i++ )
{
e = GetNode( i );
segment = e->worldorigin - s->worldorigin;
segmentlength = segment.length();
// check if we're closest to the endpoint
delta = e->worldorigin - pos;
dist = delta.length();
if ( dist < bestdist )
{
bestdist = dist;
bestdistalongpath = pathdist + segmentlength;
*speed = e->Speed();
}
// check if we're closest to the segment
oosl = ( 1 / segmentlength );
p1 = segment * oosl;
p1.normalize();
p2 = pos - s->worldorigin;
t = p1 * p2;
if ( ( t > 0 ) && ( t < segmentlength ) )
{
p3 = ( p1 * t ) + s->worldorigin;
delta = p3 - pos;
dist = delta.length();
if ( dist < bestdist )
{
bestdist = dist;
bestdistalongpath = pathdist + t;
t *= oosl;
*speed = (e->Speed() * t) + (s->Speed() * (1.0f - t));
}
}
s = e;
pathdist += segmentlength;
}
return bestdistalongpath;
}
Vector GravPath::PointAtDistance
(
float dist
)
{
GravPathNode *s;
GravPathNode *e;
int num;
int i;
Vector delta;
Vector p1;
float t;
float pathdist;
float segmentlength;
num = NumNodes();
s = GetNode( 1 );
pathdist = 0;
for( i = 2; i <= num; i++ )
{
e = GetNode( i );
delta = e->worldorigin - s->worldorigin;
segmentlength = delta.length();
if ( ( pathdist + segmentlength ) > dist )
{
t = dist - pathdist;
p1 = delta * ( t / segmentlength );
return p1 + s->worldorigin;
}
s = e;
pathdist += segmentlength;
}
// cap it off at start or end of path
return s->worldorigin;
}
void GravPath::DrawPath
(
Event *ev
)
{
Vector s;
Vector e;
Vector offset;
GravPathNode *node;
int num;
int i;
float r = ev->GetFloat(1);
float g = ev->GetFloat(2);
float b = ev->GetFloat(3);
Event *event;
num = NumNodes();
node = GetNode( 1 );
s = node->worldorigin;
offset = Vector( r, g, b ) * 4 + Vector( 0, 0, 0 );
offset = Vector(0, 0, 0);
for( i = 2; i <= num; i++ )
{
node = GetNode( i );
e = node->worldorigin;
G_DebugLine( s + offset, e + offset, r, g, b, 1 );
s = e;
}
G_DebugBBox(origin,mins-origin,maxs-origin,1,0,0,1);
event = new Event(EV_DrawGravPath);
event->AddFloat(r);
event->AddFloat(g);
event->AddFloat(b);
PostEvent(event,0.1f);
}
int GravPath::NumNodes
(
void
)
{
return pathlist.NumObjects();
}
float GravPath::Length
(
void
)
{
return pathlength;
}

271
gravpath.h Normal file
View File

@ -0,0 +1,271 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/gravpath.h $
// $Revision:: 11 $
// $Author:: Jimdose $
// $Date:: 10/25/98 11:53p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/gravpath.h $
//
// 11 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 10 10/21/98 2:18a Jimdose
// Added Reset to Unarchive
//
// 9 10/07/98 11:51p Jimdose
// Added destructor for GravPathManager
// added Reset to GravPath::Unarchive
//
// 8 9/30/98 4:36p Aldie
// Added reset
//
// 7 9/29/98 11:46p Aldie
// Added force spawnflag
//
// 6 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 5 8/27/98 2:54p Aldie
// Added a headnode flag
//
// 4 8/27/98 2:31p Aldie
// Update active flag as a public var
//
// 3 8/26/98 9:45p Aldie
// Added activate and deactivate
//
// 2 5/22/98 12:19p Aldie
// First version of gravpath
//
// DESCRIPTION:
// Gravity path - Used for underwater currents and wells.
#ifndef __GRAVPATH_H__
#define __GRAVPATH_H__
#include "g_local.h"
#include "class.h"
#include "container.h"
class EXPORT_FROM_DLL GravPathNode : public Entity
{
private:
float speed;
float radius;
qboolean headnode;
public:
qboolean active;
CLASS_PROTOTYPE(GravPathNode);
GravPathNode();
void CreatePath(Event *ev);
void Activate(Event *ev);
void Deactivate(Event *ev);
float Speed(void);
float Radius(void) {return radius;};
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void GravPathNode::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteFloat( speed );
arc.WriteFloat( radius );
arc.WriteBoolean( headnode );
arc.WriteBoolean( active );
}
inline EXPORT_FROM_DLL void GravPathNode::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadFloat( &speed );
arc.ReadFloat( &radius );
arc.ReadBoolean( &headnode );
arc.ReadBoolean( &active );
}
typedef SafePtr<GravPathNode> GravPathNodePtr;
//
// Exported templated classes must be explicitly instantiated
//
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL SafePtr<GravPathNode>;
template class EXPORT_FROM_DLL Container<GravPathNodePtr>;
#endif
class EXPORT_FROM_DLL GravPath : public Listener
{
private:
Container<GravPathNodePtr> pathlist;
float pathlength;
GravPathNodePtr from;
GravPathNodePtr to;
int nextnode;
public:
CLASS_PROTOTYPE( GravPath );
GravPath();
~GravPath();
void Clear(void);
void Reset(void);
void AddNode(GravPathNode *node);
GravPathNode *GetNode(int num);
GravPathNode *NextNode(void);
Vector ClosestPointOnPath(Vector pos, Entity &ent,float *bestdist,float *speed,float *radius);
float DistanceAlongPath(Vector pos, float *speed);
Vector PointAtDistance(float dist);
void DrawPath(Event *ev);
int NumNodes(void);
float Length(void);
GravPathNode *Start(void);
GravPathNode *End(void);
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
Vector mins;
Vector maxs;
Vector origin;
qboolean force;
};
inline EXPORT_FROM_DLL void GravPath::Archive
(
Archiver &arc
)
{
int i, num;
Listener::Archive( arc );
num = pathlist.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
arc.WriteSafePointer( pathlist.ObjectAt( i ) );
}
arc.WriteFloat( pathlength );
arc.WriteSafePointer( from );
arc.WriteSafePointer( to );
arc.WriteInteger( nextnode );
arc.WriteVector( mins );
arc.WriteVector( maxs );
arc.WriteVector( origin );
arc.WriteBoolean( force );
}
inline EXPORT_FROM_DLL void GravPath::Unarchive
(
Archiver &arc
)
{
int i, num;
Reset();
Listener::Unarchive( arc );
arc.ReadInteger( &num );
pathlist.Resize( num );
for ( i = 1; i <= num; i++ )
{
arc.ReadSafePointer( pathlist.AddressOfObjectAt( i ) );
}
arc.ReadFloat( &pathlength );
arc.ReadSafePointer( &from );
arc.ReadSafePointer( &to );
arc.ReadInteger( &nextnode );
arc.ReadVector( &mins );
arc.ReadVector( &maxs );
arc.ReadVector( &origin );
arc.ReadBoolean( &force );
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<GravPath *>;
#endif
class EXPORT_FROM_DLL GravPathManager : public Class
{
private:
Container<GravPath *> pathList;
public:
CLASS_PROTOTYPE( GravPathManager );
~GravPathManager();
void Reset( void );
void AddPath(GravPath *p);
void RemovePath(GravPath *p);
Vector CalculateGravityPull(Entity &ent, Vector position, qboolean *force);
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void GravPathManager::Archive
(
Archiver &arc
)
{
int i, num;
Class::Archive( arc );
num = pathList.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
arc.WriteObject( pathList.ObjectAt( i ) );
}
}
inline EXPORT_FROM_DLL void GravPathManager::Unarchive
(
Archiver &arc
)
{
int i, num;
Reset();
Class::Unarchive( arc );
arc.ReadInteger( &num );
for ( i = 1; i <= num; i++ )
{
GravPath * ptr;
ptr = new GravPath;
arc.ReadObject( ptr );
pathList.AddObject( ptr );
}
}
extern GravPathManager gravPathManager;
extern Event EV_DrawGravPath;
#endif /* gravpath.h */

74
hammer.cpp Normal file
View File

@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/hammer.cpp $
// $Revision:: 4 $
// $Author:: Markd $
// $Date:: 10/04/98 10:25p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/hammer.cpp $
//
// 4 10/04/98 10:25p Markd
// Added IsDroppable
//
// 3 9/29/98 7:07p Markd
// changed models for these weapons
//
// 2 9/24/98 12:03p Markd
// new melee weapons
//
// 1 9/24/98 11:59a Markd
//
// DESCRIPTION:
// Hammer Melee weapon
//
#include "g_local.h"
#include "item.h"
#include "weapon.h"
#include "fists.h"
class EXPORT_FROM_DLL Hammer : public Fists
{
public:
CLASS_PROTOTYPE( Hammer );
Hammer::Hammer();
virtual qboolean IsDroppable( void );
};
CLASS_DECLARATION( Fists, Hammer, NULL);
ResponseDef Hammer::Responses[] =
{
{ NULL, NULL }
};
Hammer::Hammer()
{
#ifdef SIN_DEMO
PostEvent( EV_Remove, 0 );
return;
#endif
SetModels( "sledgeham.def", "view_sledge.def" );
SetAmmo( NULL, 0, 0 );
SetRank( 11, 11 );
strike_reach = 48;
strike_damage = 55;
SetMaxRange( strike_reach );
SetType( WEAPON_MELEE );
kick = 25;
}
qboolean Hammer::IsDroppable
(
void
)
{
return false;
}

255
health.cpp Normal file
View File

@ -0,0 +1,255 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/health.cpp $
// $Revision:: 19 $
// $Author:: Jimdose $
// $Date:: 11/17/98 6:08a $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/health.cpp $
//
// 19 11/17/98 6:08a Jimdose
// made PickupHealth take health from player's inventory before checking if
// they can pick it up. Fixes bug where player can't pickup health due to
// health somehow being in their inventory.
//
// 18 10/27/98 5:19p Aldie
// Added a few items for health
//
// 17 10/09/98 2:06a Aldie
// Updated DMFLAGS
//
// 16 8/27/98 2:33p Aldie
// Changed adrenaline to megahealth
//
// 15 7/23/98 11:25p Aldie
// Fixed health for hopefully the last time.
//
// 14 7/15/98 11:22p Markd
// Don't set the model unless one hasn't been setup yet
//
// 13 7/14/98 6:58p Aldie
// Updated healths
//
// 12 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 11 6/24/98 1:36p Aldie
// Implementation of inventory system and picking stuff up
//
// 10 5/27/98 7:33p Markd
// clear out damage if healed
//
// 9 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 8 5/13/98 4:45p Jimdose
// Startup event is now posted with 0 delay
//
// 7 5/08/98 2:56p Markd
// Put in health pickup sounds
//
// 6 4/18/98 3:41p Markd
// Changed health types to health_ instead of item_health_
//
// 5 4/07/98 6:43p Jimdose
// turned off respawn in single player
//
// 4 4/04/98 6:04p Jimdose
// Made response from EV_Trigger_ActivateTargets to EV_Trigger_Effect
//
// 3 3/30/98 9:54p Jimdose
// Changed location of .def files
//
// 2 3/30/98 2:30p Jimdose
// Created file
//
// DESCRIPTION:
// Health powerup
//
#include "g_local.h"
#include "item.h"
#include "sentient.h"
#include "health.h"
CLASS_DECLARATION( Item, Health, "health_020" );
ResponseDef Health::Responses[] =
{
{ &EV_Item_Pickup, ( Response )Health::PickupHealth },
{ NULL, NULL }
};
Health::Health()
{
if ( DM_FLAG( DF_NO_HEALTH ) )
{
PostEvent( EV_Remove, 0 );
return;
}
Set( 20 );
if ( !edict->s.modelindex )
setModel( "health.def" );
}
void Health::PickupHealth
(
Event *ev
)
{
Sentient *sen;
Item * item;
Entity *other;
other = ev->GetEntity( 1 );
if ( !other || !other->isSubclassOf( Sentient ) )
{
return;
}
sen = ( Sentient * )other;
//
// We don't want the player to hold on to a box of health!
// This can happen if a player is given a health object,
// so as a precaution, get rid of any health he's carrying.
//
item = sen->FindItem( getClassname() );
if ( item )
{
sen->RemoveItem( item );
item->PostEvent( EV_Remove, 0 );
}
if ( !ItemPickup( other ) )
{
return;
}
sen->health += amount;
if ( sen->health > 200 )
{
sen->health = 200;
}
//
// clear out damage if healed
//
if ( sen->health > 90 )
{
// clear the damage states
memset( sen->edict->s.groups, 0, sizeof( sen->edict->s.groups ) );
}
//
// we don't want the player to hold on to a box of health!
//
item = sen->FindItem( getClassname() );
if ( item )
{
sen->RemoveItem( item );
item->PostEvent( EV_Remove, 0 );
}
}
CLASS_DECLARATION( Health, SmallHealth, "health_005" );
ResponseDef SmallHealth::Responses[] =
{
{ NULL, NULL }
};
SmallHealth::SmallHealth()
{
Set( 5 );
setModel( "health_small.def" );
}
CLASS_DECLARATION( Health, LargeHealth, "health_050" );
ResponseDef LargeHealth::Responses[] =
{
{ NULL, NULL }
};
LargeHealth::LargeHealth()
{
Set( 50 );
setModel( "health_large.def" );
}
CLASS_DECLARATION( Health, MegaHealth, "health_100" );
ResponseDef MegaHealth::Responses[] =
{
{ NULL, NULL }
};
MegaHealth::MegaHealth()
{
Set( 100 );
setModel( "health_medkit.def" );
}
CLASS_DECLARATION( Health, Apple, NULL );
ResponseDef Apple::Responses[] =
{
{ NULL, NULL }
};
Apple::Apple()
{
setModel( "health_apple.def" );
}
CLASS_DECLARATION( Health, Banana, NULL );
ResponseDef Banana::Responses[] =
{
{ NULL, NULL }
};
Banana::Banana()
{
setModel( "health_banana.def" );
}
CLASS_DECLARATION( Health, Sandwich, NULL );
ResponseDef Sandwich::Responses[] =
{
{ NULL, NULL }
};
Sandwich::Sandwich()
{
setModel( "health_sandwich.def" );
}
CLASS_DECLARATION( Health, Soda, NULL );
ResponseDef Soda::Responses[] =
{
{ NULL, NULL }
};
Soda::Soda()
{
setModel( "health_soda.def" );
}

103
health.h Normal file
View File

@ -0,0 +1,103 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/health.h $
// $Revision:: 6 $
// $Author:: Aldie $
// $Date:: 10/27/98 5:18p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/health.h $
//
// 6 10/27/98 5:18p Aldie
// Added a few items for health
//
// 5 8/27/98 2:32p Aldie
// Changed health adrenaline to megahealth
//
// 4 7/14/98 6:59p Aldie
// Updated healths
//
// 3 6/25/98 8:48p Markd
// Rewrote Item class, added keyed items to triggers, cleaned up item system
//
// 2 3/30/98 2:30p Jimdose
// Created file
//
// 1 3/30/98 1:47a Jimdose
//
// DESCRIPTION:
// Health powerup
//
#ifndef __HEALTH_H__
#define __HEALTH_H__
#include "g_local.h"
#include "item.h"
#include "sentient.h"
#include "item.h"
class EXPORT_FROM_DLL Health : public Item
{
public:
CLASS_PROTOTYPE( Health );
Health();
virtual void PickupHealth( Event *ev );
};
class EXPORT_FROM_DLL SmallHealth : public Health
{
public:
CLASS_PROTOTYPE( SmallHealth );
SmallHealth();
};
class EXPORT_FROM_DLL LargeHealth : public Health
{
public:
CLASS_PROTOTYPE( LargeHealth );
LargeHealth();
};
class EXPORT_FROM_DLL MegaHealth : public Health
{
public:
CLASS_PROTOTYPE( MegaHealth );
MegaHealth();
};
class EXPORT_FROM_DLL Apple : public Health
{
public:
CLASS_PROTOTYPE( Apple );
Apple();
};
class EXPORT_FROM_DLL Banana : public Health
{
public:
CLASS_PROTOTYPE( Banana );
Banana();
};
class EXPORT_FROM_DLL Sandwich : public Health
{
public:
CLASS_PROTOTYPE( Sandwich );
Sandwich();
};
class EXPORT_FROM_DLL Soda : public Health
{
public:
CLASS_PROTOTYPE( Soda );
Soda();
};
#endif /* health.h */

86
heligun.cpp Normal file
View File

@ -0,0 +1,86 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/heligun.cpp $
// $Revision:: 11 $
// $Author:: Aldie $
// $Date:: 8/06/98 10:53p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/heligun.cpp $
//
// 11 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and rocket
// jumping.
//
// 10 8/01/98 3:24p Aldie
// Added server effects flag for specific weapons
//
// 9 8/01/98 3:03p Aldie
// Client side muzzle flash (dynamic light)
//
// 8 7/26/98 11:58a Aldie
// Remove tracers
//
// 7 7/26/98 4:15a Aldie
// Tracers
//
// 6 7/26/98 12:15a Markd
// removed world model from heli gun
//
// 5 7/25/98 4:36p Markd
// Doubled bullet damage
//
// 4 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 3 7/17/98 3:56p Markd
// changed world model
//
// 2 7/08/98 11:55p Markd
// first time
//
// 1 7/08/98 11:33p Markd
//
// DESCRIPTION:
// Helicopter gun
//
#include "g_local.h"
#include "bullet.h"
#include "heligun.h"
#include "rocketlauncher.h"
#include "explosion.h"
CLASS_DECLARATION( BulletWeapon, HeliGun, "weapon_heligun" );
ResponseDef HeliGun::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )HeliGun::Shoot },
{ NULL, NULL }
};
HeliGun::HeliGun
(
)
{
SetModels( NULL, "view_heligun.def" );
SetAmmo( "Bullet50mm", 0, 0 );
SetRank( 50, 50 );
}
void HeliGun::Shoot
(
Event *ev
)
{
FireBullets( 1, "20 20 20", 16, 28, DAMAGE_BULLET, MOD_HELIGUN, false );
NextAttack( 0 );
}

43
heligun.h Normal file
View File

@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/heligun.h $
// $Revision:: 2 $
// $Author:: Markd $
// $Date:: 7/08/98 11:55p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/heligun.h $
//
// 2 7/08/98 11:55p Markd
// First time
//
// 1 7/08/98 11:33p Markd
//
// DESCRIPTION:
// Helicopter gun
//
#ifndef __HELIGUN_H__
#define __HELIGUN_H__
#include "g_local.h"
#include "item.h"
#include "weapon.h"
#include "bullet.h"
#include "misc.h"
class EXPORT_FROM_DLL HeliGun : public BulletWeapon
{
public:
CLASS_PROTOTYPE( HeliGun );
HeliGun::HeliGun();
virtual void Shoot( Event *ev );
};
#endif /* HeliGun.h */

70
inventoryitem.cpp Normal file
View File

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/inventoryitem.cpp $
// $Revision:: 7 $
// $Author:: Aldie $
// $Date:: 10/09/98 2:06a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/inventoryitem.cpp $
//
// 7 10/09/98 2:06a Aldie
// Updated DMFLAGS
//
// 6 7/19/98 5:40p Markd
// Removed constructor again
//
// 5 7/19/98 5:38p Markd
// Made constructor process all initcommands
//
// 4 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 3 6/24/98 1:36p Aldie
// Implementation of inventory system and picking stuff up
//
// 2 6/19/98 6:38p Aldie
// Inventory item subclass of Item
//
// DESCRIPTION:
// Inventory items
#include "inventoryitem.h"
CLASS_DECLARATION( Item, InventoryItem, NULL );
Event EV_InventoryItem_Use( "useinvitem" );
ResponseDef InventoryItem::Responses[] =
{
{ &EV_InventoryItem_Use, (Response)InventoryItem::Use },
{ NULL, NULL }
};
InventoryItem::InventoryItem
(
)
{
// All powerups are inventory items
if ( DM_FLAG( DF_NO_POWERUPS ) )
{
PostEvent( EV_Remove, 0 );
return;
}
}
void InventoryItem::Use
(
Event *ev
)
{
}

49
inventoryitem.h Normal file
View File

@ -0,0 +1,49 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/inventoryitem.h $
// $Revision:: 5 $
// $Author:: Aldie $
// $Date:: 10/09/98 2:07a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/inventoryitem.h $
//
// 5 10/09/98 2:07a Aldie
// Updated DMFLAGS
//
// 4 6/25/98 8:48p Markd
// Rewrote Item class, added keyed items to triggers, cleaned up item system
//
// 3 6/24/98 1:38p Aldie
// Implementation of inventory system and picking stuff up
//
// 2 6/19/98 6:38p Aldie
// Inventory item first version
//
// DESCRIPTION:
// Items that are visible in the player's inventory
#ifndef __INVITEM_H__
#define __INVITEM_H__
#include "item.h"
class EXPORT_FROM_DLL InventoryItem : public Item
{
public:
CLASS_PROTOTYPE( InventoryItem );
InventoryItem();
virtual void Use( Event *ev );
};
extern Event EV_InventoryItem_Use;
#endif /* inventoryitem.h */

830
item.cpp Normal file
View File

@ -0,0 +1,830 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/item.cpp $
// $Revision:: 51 $
// $Author:: Markd $
// $Date:: 11/12/98 9:20p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/item.cpp $
//
// 51 11/12/98 9:20p Markd
// fixed null sounds for snd_pickup
//
// 50 10/24/98 2:07p Aldie
// Mutants can only pickup health
//
// 49 10/22/98 10:22p Markd
// Put in support for game and level item script variables
//
// 48 10/19/98 12:05a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
// got rid of warning in Set
//
// 47 10/14/98 1:18a Jimdose
// Got cross-level persistant info working
// Added amount_override
//
// 46 10/11/98 8:57p Aldie
// Don't print out error message unecessarily
//
// 45 10/10/98 1:28a Jimdose
// items no longer drop to the floor when loading savegames
//
// 44 10/09/98 2:06a Aldie
// Updated DMFLAGS
//
// 43 10/07/98 5:51p Markd
// Fixed small sized enemies getting resized and causing fall out of level
// errors
//
// 42 10/04/98 6:15p Markd
// fixed pickup sounds
//
// 41 9/29/98 5:59p Markd
// Added dialog_needed stuff
//
// 40 9/29/98 11:05a Markd
// Added respawnsound support
//
// 39 9/15/98 6:37p Markd
// Added RotatedBounds flag support
//
// 38 9/08/98 9:29p Markd
// fixed picking things up by using them
//
// 37 9/02/98 11:53a Markd
// Put in pickup by pressing the use key
//
// 36 9/01/98 7:45p Aldie
// Added itemname
//
// 35 8/29/98 7:23p Aldie
// Added itemname to get around targetname problem.
//
// 34 8/18/98 11:08p Markd
// Added new Alias System
//
// 33 8/15/98 1:48p Aldie
// Don't turn off glow when objects are picked up
//
// 32 8/12/98 4:19p Aldie
// Fixed icons not showing up correctly
//
// 31 7/26/98 1:17a Markd
// Put in respawn sounds for items
//
// 30 7/14/98 6:57p Aldie
// Made dropped weapons fade out
//
// 29 7/14/98 3:53p Markd
// made pickup sounds work properly
//
// 28 7/12/98 4:34p Markd
// Fixed bounding boxes on items
//
// 27 7/11/98 8:19p Jimdose
// Drop now returns true or false depending upon whether the item can be
// dropped or not
//
// 26 7/10/98 2:48p Aldie
// Cleared targetname for all items to circumvent an error when removing an
// actor carrying a weapon of the same targetname as him.
//
// 25 6/26/98 11:30a Markd
// Changed ItemPickup
//
// 24 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 23 6/24/98 1:36p Aldie
// Implementation of inventory system and picking stuff up
//
// 22 6/17/98 1:20a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 21 6/16/98 9:37p Markd
// made items capable of being orientated
//
// 20 6/16/98 4:08p Jimdose
// Gave dropping weapons velocity
//
// 19 6/04/98 7:36p Jimdose
// PlaceItem now posts the EV_Remove instead of processing it
//
// 18 6/03/98 4:37p Markd
// When picking an item up, stop glowing, when dropping it start glowing
//
// 17 5/13/98 4:45p Jimdose
// droptofloor event is now posted with 0 delay
//
// 16 5/03/98 4:50p Jimdose
// Fixed bug where items fell through ground
//
// 15 5/03/98 4:44p Jimdose
// changed Vector class
//
// 14 5/02/98 12:39a Jimdose
// Changed PlaceItem so that items only test if they can drop to the floor. If
// they can, they're left where they were spawned so that they fall, otherwise
// they're removed
//
// 13 4/05/98 9:41p Markd
// Put in RF_GLOW
//
// 12 4/04/98 6:05p Jimdose
// ItemPickup no longer activates targets, since the item should alread have
// triggered its targets when it was touched
//
// 11 4/02/98 4:49p Jimdose
// changed droptofloor
//
// 10 3/30/98 2:32p Jimdose
// now shows model on placement
//
// 9 3/28/98 8:57p Jimdose
// changed bounding box
//
// 8 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 7 3/02/98 8:49p Jimdose
// Changed the classid parameter of CLASS_DECLARATION to a quoted string so
// that you could have a NULL classid.
//
// 6 2/19/98 2:35p Jimdose
// Updated to work with Q2 based progs
//
// 4 11/07/97 5:59p Markd
// Removed QUAKE specific sound effects
//
// 3 10/27/97 3:29p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 5:30p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Base class for respawnable, carryable objects.
//
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
#include "item.h"
#include "inventoryitem.h"
#include "scriptmaster.h"
#include "health.h"
Event EV_Item_Pickup( "item_pickup" );
Event EV_Item_DropToFloor( "droptofloor" );
Event EV_Item_Respawn( "respawn" );
Event EV_Item_SetAmount( "amount" );
Event EV_Item_SetMaxAmount( "maxamount" );
Event EV_Item_SetIconName( "iconname" );
Event EV_Item_SetItemName( "itemname" );
Event EV_Item_RespawnSound( "respawnsound" );
Event EV_Item_DialogNeeded( "dialogneeded" );
CLASS_DECLARATION( Trigger, Item, NULL );
ResponseDef Item::Responses[] =
{
{ &EV_Trigger_Effect, ( Response )Item::ItemTouch },
{ &EV_Item_DropToFloor, ( Response )Item::DropToFloor },
{ &EV_Item_Respawn, ( Response )Item::Respawn },
{ &EV_Item_SetAmount, ( Response )Item::SetAmount },
{ &EV_Item_SetMaxAmount, ( Response )Item::SetMaxAmount },
{ &EV_Item_SetIconName, ( Response )Item::SetIconName },
{ &EV_Item_SetItemName, ( Response )Item::SetItemName },
{ &EV_Item_Pickup, ( Response )Item::Pickup },
{ &EV_Use, ( Response )Item::TriggerStuff },
{ &EV_Item_RespawnSound, ( Response )Item::RespawnSound },
{ &EV_Item_DialogNeeded, ( Response )Item::DialogNeeded },
{ NULL, NULL }
};
Item::Item()
{
str fullname;
Vector defangles;
setRespawnTime( 20 );
setRespawn( false );
setSolidType( SOLID_NOT );
// Set default respawn behavior
// Derived classes should use setRespawn
// if they want to override the default behavior
if ( deathmatch->value )
{
setRespawn( true );
}
else
{
setRespawn( false );
}
edict->s.renderfx |= RF_GLOW;
// angles
defangles = Vector( 0, G_GetFloatArg( "angle", 0 ), 0 );
if (defangles.y == -1)
{
defangles = Vector( -90, 0, 0 );
}
else if (defangles.y == -2)
{
defangles = Vector( 90, 0, 0 );
}
angles = G_GetVectorArg( "angles", defangles );
setAngles( angles );
//
// we want the bounds of this model auto-rotated
//
flags |= FL_ROTATEDBOUNDS;
//
// rotate the mins and maxs for the model
//
if ( size.length() < 10 )
setSize( "-10 -10 0", "10 10 20" );
//
// reset the mins and maxs to pickup the FL_ROTATEDBOUNDS flag
//
setSize( mins, maxs );
if ( !LoadingSavegame )
{
// Items can't be immediately dropped to floor, because they might
// be on an entity that hasn't spawned yet.
PostEvent( EV_Item_DropToFloor, 0 );
}
respondto = TRIGGER_PLAYERS;
icon_name = str("");
icon_index = 0;
item_index = 0;
maximum_amount = 1;
playrespawn = false;
amount_override = false;
amount = 1;
// FIXME
// If the targetname is set by the spawn args, then this item
// will have a targetname. If we try to remove the owner of this
// item, then we will remove the owner, then try to remove the item
// which will already have been removed by the previous event.
// This doesn't allow any items to have a targetname.
SetTargetName( "" );
// Using itemname as a temporary fix to this problem
itemname = G_GetSpawnArg( "itemname", "");
if ( G_GetSpawnArg( "amount" ) )
{
amount = G_GetIntArg( "amount" );
if ( amount >= MaxAmount() )
{
SetMax( amount );
}
amount_override = true;
}
}
Item::~Item()
{
if ( owner )
{
owner->RemoveItem( this );
owner = NULL;
}
}
void Item::CreateSpawnArgs
(
void
)
{
G_SetIntArg( "amount", amount );
G_SetSpawnArg( "model", model.c_str() );
}
/*
============
PlaceItem
Puts an item back in the world
============
*/
void Item::PlaceItem
(
void
)
{
setSolidType( SOLID_TRIGGER );
setMoveType( MOVETYPE_TOSS );
showModel();
edict->s.renderfx |= RF_GLOW;
groundentity = NULL;
}
/*
============
DropToFloor
plants the object on the floor
============
*/
void Item::DropToFloor
(
Event *ev
)
{
str fullname;
Vector save;
PlaceItem();
setOrigin( origin + "0 0 1" );
save = origin;
if ( !droptofloor( 8192 ) )
{
gi.dprintf( "%s fell out of level at '%5.1f %5.1f %5.1f'\n",
getClassID(), origin.x, origin.y, origin.z );
PostEvent( EV_Remove, 0 );
return;
}
//
// if the our global variable doesn't exist, lets zero it out
//
fullname = str( "playeritem_" ) + getClassname();
if ( !gameVars.VariableExists( fullname.c_str() ) )
{
gameVars.SetVariable( fullname.c_str(), 0 );
}
if ( !levelVars.VariableExists( fullname.c_str() ) )
{
levelVars.SetVariable( fullname.c_str(), 0 );
}
setOrigin( save );
groundentity = NULL;
}
qboolean Item::Drop
(
void
)
{
if ( !owner )
{
return false;
}
setOrigin( owner->worldorigin + "0 0 40" );
// drop the item
PlaceItem();
velocity = owner->velocity * 0.5 + Vector( G_CRandom( 50 ), G_CRandom( 50 ), 100 );
setAngles( owner->angles );
avelocity = Vector( 0, G_CRandom( 360 ), 0 );
trigger_time = level.time + 1;
if ( owner->isClient() )
{
spawnflags |= DROPPED_PLAYER_ITEM;
}
else
{
spawnflags |= DROPPED_ITEM;
}
// Remove this from the owner's item list
owner->RemoveItem( this );
owner = NULL;
return true;
}
void Item::ItemTouch
(
Event *ev
)
{
Entity *other;
Event *e;
if ( owner )
{
// Don't respond to trigger events after item is picked up.
gi.dprintf( "%s with targetname of %s was triggered unexpectedly.\n", getClassID(), TargetName() );
return;
}
other = ev->GetEntity( 1 );
e = new Event( EV_Item_Pickup );
e->AddEntity( other );
ProcessEvent( e );
}
void Item::SetOwner
(
Sentient *ent
)
{
assert( ent );
if ( !ent )
{
// return to avoid any buggy behaviour
return;
}
owner = ent;
setRespawn( false );
edict->s.renderfx &= ~RF_GLOW;
setSolidType( SOLID_NOT );
hideModel();
CancelEventsOfType( EV_Item_DropToFloor );
CancelEventsOfType( EV_Remove );
// ItemPickup( ent );
}
Item * Item::ItemPickup
(
Entity *other
)
{
Sentient * sent;
Item * item;
str realname;
if ( !Pickupable( other ) )
{
return NULL;
}
sent = ( Sentient * )other;
item = sent->giveItem( getClassname(), Amount(), icon_index );
if ( !item )
return NULL;
realname = GetRandomAlias( "snd_pickup" );
if ( realname.length() > 1 )
sent->sound( realname, 1, CHAN_ITEM, ATTN_NORM );
if ( !Removable() )
{
// leave the item for others to pickup
return item;
}
CancelEventsOfType( EV_Item_DropToFloor );
CancelEventsOfType( EV_Item_Respawn );
CancelEventsOfType( EV_FadeOut );
setSolidType( SOLID_NOT );
hideModel();
if ( Respawnable() )
{
PostEvent( EV_Item_Respawn, RespawnTime() );
}
else
{
PostEvent( EV_Remove, 0.1 );
}
if ( DM_FLAG( DF_INSTANT_ITEMS ) )
{
Event *ev;
ev = new Event( EV_InventoryItem_Use );
ev->AddEntity( other );
item->ProcessEvent( ev );
}
return item;
}
void Item::Respawn
(
Event *ev
)
{
showModel();
// allow it to be touched again
setSolidType( SOLID_TRIGGER );
// play respawn sound
if ( playrespawn )
{
RandomGlobalSound( "snd_itemspawn" );
}
setOrigin( origin );
};
void Item::setRespawn
(
qboolean flag
)
{
respawnable = flag;
}
qboolean Item::Respawnable
(
void
)
{
return respawnable;
}
void Item::setRespawnTime
(
float time
)
{
respawntime = time;
}
float Item::RespawnTime
(
void
)
{
return respawntime;
}
int Item::Amount
(
void
)
{
return amount;
}
int Item::MaxAmount
(
void
)
{
return maximum_amount;
}
qboolean Item::Pickupable
(
Entity *other
)
{
if ( !other->isSubclassOf( Sentient ) )
{
return false;
}
else
{
Sentient * sent;
Item * item;
sent = ( Sentient * )other;
item = sent->FindItem( getClassname() );
if ( item && ( item->Amount() >= item->MaxAmount() ) )
{
return false;
}
// Mutants can't pick up anything but health
if ( other->flags & (FL_MUTANT|FL_SP_MUTANT) && !( this->isSubclassOf( Health ) ) )
{
return false;
}
// If deathmatch and already in a powerup, don't pickup anymore when DF_INSTANT_ITEMS is on
if ( DM_FLAG( DF_INSTANT_ITEMS ) &&
this->isSubclassOf( InventoryItem ) &&
sent->PowerupActive()
)
{
return false;
}
}
return true;
}
void Item::Pickup
(
Event * ev
)
{
ItemPickup( ev->GetEntity( 1 ) );
}
void Item::setIcon
(
const char *i
)
{
icon_name = i;
icon_index = gi.imageindex( i );
}
void Item::setName
(
const char *i
)
{
item_name = i;
item_index = gi.itemindex( i );
}
int Item::Icon
(
void
)
{
if ( icon_name.length() )
return icon_index;
else
return -1;
}
void Item::Set
(
int startamount
)
{
if ( !amount_override )
{
amount = startamount;
if ( amount >= MaxAmount() )
SetMax( amount );
}
}
void Item::SetMax
(
int maxamount
)
{
maximum_amount = maxamount;
}
void Item::SetAmount
(
Event *ev
)
{
Set( ev->GetInteger( 1 ) );
}
void Item::SetMaxAmount
(
Event *ev
)
{
SetMax( ev->GetInteger( 1 ) );
}
void Item::SetIconName
(
Event *ev
)
{
setIcon( ev->GetString( 1 ) );
}
void Item::SetItemName
(
Event *ev
)
{
setName( ev->GetString( 1 ) );
}
void Item::Add
(
int num
)
{
amount += num;
if ( amount >= MaxAmount() )
amount = MaxAmount();
}
void Item::Remove
(
int num
)
{
amount -= num;
if (amount < 0)
amount = 0;
}
qboolean Item::Use
(
int num
)
{
if ( num > amount )
{
return false;
}
amount -= num;
return true;
}
qboolean Item::Removable
(
void
)
{
return true;
}
void Item::RespawnSound
(
Event *ev
)
{
playrespawn = true;
}
void Item::DialogNeeded
(
Event *ev
)
{
//
// if this item is needed for a trigger, play this dialog
//
dialog_needed = ev->GetString( 1 );
}
str Item::GetDialogNeeded
(
void
)
{
return dialog_needed;
}

215
item.h Normal file
View File

@ -0,0 +1,215 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/item.h $
// $Revision:: 23 $
// $Author:: Jimdose $
// $Date:: 11/08/98 10:52p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/item.h $
//
// 23 11/08/98 10:52p Jimdose
// amountoverride wasn't archived
// made icon_index and item_index be calculated in unarchive
//
// 22 10/14/98 1:20a Jimdose
// Got cross-level persistant info working
//
// 21 9/29/98 5:59p Markd
// Added dialog_needed stuff
//
// 20 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 19 9/01/98 7:47p Aldie
// Added itemname to inventory stuff
//
// 18 8/29/98 7:23p Aldie
// Added itemname to get around targetname problem
//
// 17 7/14/98 3:55p Markd
// Got rid of pickup_sound
//
// 16 7/11/98 8:19p Jimdose
// Drop now returns true or false depending upon whether the item can be
// dropped or not
//
// 15 6/26/98 11:29a Markd
// Changed what ItemPickup returns
//
// 14 6/25/98 8:48p Markd
// Rewrote Item class, added keyed items to triggers, cleaned up item system
//
// 13 6/24/98 1:38p Aldie
// Implementation of inventory system and picking stuff up
//
// 12 6/19/98 6:38p Aldie
// Moved icon to inventory item
//
// 11 6/18/98 9:26p Aldie
// Started inventory system
//
// 10 6/17/98 1:16a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 9 6/16/98 4:09p Jimdose
// Added DropToFloor
//
// 8 4/04/98 6:15p Jimdose
// Defined DROPPED_ITEM and DROPPED_PLAYER_ITEM
//
// 7 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 6 3/02/98 8:49p Jimdose
// Changed CLASS_PROTOTYPE to only take the classname
//
// 5 2/19/98 2:35p Jimdose
// Updated to work with Q2 based progs
//
// 3 10/27/97 2:59p Jimdose
// Removed dependency on quakedef.h
//
// 2 9/26/97 5:30p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Base class for respawnable, carryable objects.
//
#ifndef __ITEM_H__
#define __ITEM_H__
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
#include "sentient.h"
extern Event EV_Item_Pickup;
extern Event EV_Item_DropToFloor;
extern Event EV_Item_Respawn;
extern Event EV_Item_SetAmount;
extern Event EV_Item_SetMaxAmount;
extern Event EV_Item_SetIconName;
extern Event EV_Item_RespawnSound;
extern Event EV_Item_DialogNeeded;
#define DROPPED_ITEM 0x00008000
#define DROPPED_PLAYER_ITEM 0x00010000
class EXPORT_FROM_DLL Item : public Trigger
{
protected:
SentientPtr owner;
qboolean respawnable;
qboolean playrespawn;
float respawntime;
str icon_name;
str dialog_needed;
str item_name;
int icon_index;
int item_index;
int maximum_amount;
int amount;
qboolean amount_override;
void ItemTouch( Event *ev );
public:
str itemname;
CLASS_PROTOTYPE( Item );
Item::Item();
Item::~Item();
virtual void CreateSpawnArgs( void );
virtual void PlaceItem( void );
virtual void SetOwner( Sentient *ent );
virtual void DropToFloor( Event *ev );
virtual Item *ItemPickup( Entity *other );
virtual void Respawn( Event *ev );
virtual void setRespawn( qboolean flag );
virtual qboolean Respawnable( void );
virtual void setRespawnTime( float time );
virtual float RespawnTime( void );
virtual int GetIconIndex( void ) { return icon_index; };
virtual int GetItemIndex( void ) { return item_index; };
virtual int Amount( void );
virtual int MaxAmount( void );
virtual int Icon( void );
virtual qboolean Pickupable( Entity *other );
virtual void setIcon( const char *i );
virtual void setName( const char *i );
virtual void SetAmount( Event *ev );
virtual void SetMaxAmount( Event *ev );
virtual void SetIconName( Event *ev );
virtual void SetItemName( Event *ev );
virtual void Set( int startamount );
virtual void SetMax( int maxamount );
virtual void Add( int num );
virtual void Remove( int num );
virtual qboolean Use( int amount );
virtual qboolean Removable( void );
virtual void Pickup( Event *ev );
virtual qboolean Drop( void );
virtual void RespawnSound( Event *ev );
virtual void DialogNeeded( Event *ev );
virtual str GetDialogNeeded( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void Item::Archive
(
Archiver &arc
)
{
Trigger::Archive( arc );
arc.WriteSafePointer( owner );
arc.WriteBoolean( respawnable );
arc.WriteBoolean( playrespawn );
arc.WriteFloat( respawntime );
arc.WriteString( icon_name );
arc.WriteString( dialog_needed );
arc.WriteString( item_name );
arc.WriteInteger( maximum_amount );
arc.WriteInteger( amount );
arc.WriteBoolean( amount_override );
arc.WriteString( itemname );
}
inline EXPORT_FROM_DLL void Item::Unarchive
(
Archiver &arc
)
{
Trigger::Unarchive( arc );
arc.ReadSafePointer( &owner );
arc.ReadBoolean( &respawnable );
arc.ReadBoolean( &playrespawn );
arc.ReadFloat( &respawntime );
arc.ReadString( &icon_name );
icon_index = gi.imageindex( icon_name.c_str() );
arc.ReadString( &dialog_needed );
arc.ReadString( &item_name );
item_index = gi.itemindex( item_name.c_str() );
arc.ReadInteger( &maximum_amount );
arc.ReadInteger( &amount );
arc.ReadBoolean( &amount_override );
arc.ReadString( &itemname );
}
#endif /* item.h */

784
keys.cpp Normal file
View File

@ -0,0 +1,784 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/keys.cpp $
// $Revision:: 24 $
// $Author:: Markd $
// $Date:: 11/15/98 4:30p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/keys.cpp $
//
// 24 11/15/98 4:30p Markd
// don't play pulse part dialog if jc not present
//
// 23 10/26/98 2:17p Aldie
// Updated evidence.def
//
// 22 10/25/98 1:51a Aldie
// Added passcode2
//
// 21 10/25/98 12:23a Markd
// Put in pulse parts
//
// 20 10/23/98 10:15p Aldie
// Changed class name of identity card
//
// 19 10/22/98 6:27p Aldie
// Fixed typo with identity card
//
// 18 10/20/98 3:00a Aldie
// Set oldorigin of pulseparts
//
// 17 10/19/98 12:05a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
// moved ScubaGear to powerups.cpp
//
// 16 10/17/98 6:58p Aldie
// Made pulseparts work
//
// 15 10/16/98 11:01p Aldie
// Added Hand
//
// 14 10/12/98 3:49p Aldie
// More items
//
// 13 10/07/98 9:06p Aldie
// Added a bunch of inventory items
//
// 12 9/07/98 6:20p Markd
// added inventory_dollar
//
// 11 8/08/98 8:04p Markd
// Added money bag
//
// 10 7/20/98 3:52p Aldie
// Fixed the icons
//
// 9 7/19/98 5:40p Markd
// Added keyring
//
// 8 7/19/98 5:32p Markd
// Added KeyRing
//
// 7 7/19/98 3:43p Markd
// Added a setIcon for keys
//
// 6 6/27/98 8:13p Markd
// Added additional inventory items
//
// 5 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// DESCRIPTION:
// Access cards and keys
#include "inventoryitem.h"
#include "player.h"
class EXPORT_FROM_DLL BlueCard : public InventoryItem
{
public:
CLASS_PROTOTYPE( BlueCard );
BlueCard();
};
CLASS_DECLARATION( InventoryItem, BlueCard, "inventory_bluecard" )
ResponseDef BlueCard::Responses[] =
{
{ NULL, NULL }
};
BlueCard::BlueCard
(
)
{
setModel( "card_blu.def" );
}
class EXPORT_FROM_DLL OrangeCard : public InventoryItem
{
public:
CLASS_PROTOTYPE( OrangeCard );
OrangeCard();
};
CLASS_DECLARATION( InventoryItem, OrangeCard, "inventory_orangecard" )
ResponseDef OrangeCard::Responses[] =
{
{ NULL, NULL }
};
OrangeCard::OrangeCard
(
)
{
setModel( "card_orng.def" );
}
class EXPORT_FROM_DLL YellowCard : public InventoryItem
{
public:
CLASS_PROTOTYPE( YellowCard );
YellowCard();
};
CLASS_DECLARATION( InventoryItem, YellowCard, "inventory_yellowcard" )
ResponseDef YellowCard::Responses[] =
{
{ NULL, NULL }
};
YellowCard::YellowCard
(
)
{
setModel( "card_yel.def" );
}
class EXPORT_FROM_DLL GreenCard : public InventoryItem
{
public:
CLASS_PROTOTYPE( GreenCard );
GreenCard();
};
CLASS_DECLARATION( InventoryItem, GreenCard, "inventory_greencard" )
ResponseDef GreenCard::Responses[] =
{
{ NULL, NULL }
};
GreenCard::GreenCard
(
)
{
setModel( "card_grn.def" );
}
class EXPORT_FROM_DLL IdentCard : public InventoryItem
{
public:
CLASS_PROTOTYPE( IdentCard );
IdentCard();
};
CLASS_DECLARATION( InventoryItem, IdentCard, "inventory_identcard" )
ResponseDef IdentCard::Responses[] =
{
{ NULL, NULL }
};
IdentCard::IdentCard
(
)
{
setModel( "identcard.def" );
}
class EXPORT_FROM_DLL Cookies : public InventoryItem
{
public:
CLASS_PROTOTYPE( Cookies );
Cookies();
};
CLASS_DECLARATION( InventoryItem, Cookies, "inventory_cookies" )
ResponseDef Cookies::Responses[] =
{
{ NULL, NULL }
};
Cookies::Cookies
(
)
{
setModel( "cookies.def" );
}
class EXPORT_FROM_DLL ComLink : public InventoryItem
{
public:
CLASS_PROTOTYPE( ComLink );
ComLink();
};
CLASS_DECLARATION( InventoryItem, ComLink, "inventory_comlink" )
ResponseDef ComLink::Responses[] =
{
{ NULL, NULL }
};
ComLink::ComLink
(
)
{
setModel( "comlink.def" );
}
class EXPORT_FROM_DLL Coin : public InventoryItem
{
public:
CLASS_PROTOTYPE( Coin );
Coin();
};
CLASS_DECLARATION( InventoryItem, Coin, "inventory_coin" )
ResponseDef Coin::Responses[] =
{
{ NULL, NULL }
};
Coin::Coin
(
)
{
setModel( "coin.def" );
}
class EXPORT_FROM_DLL Code : public InventoryItem
{
public:
CLASS_PROTOTYPE( Code );
Code();
};
CLASS_DECLARATION( InventoryItem, Code, "inventory_code" )
ResponseDef Code::Responses[] =
{
{ NULL, NULL }
};
Code::Code
(
)
{
setModel( "code.def" );
}
class EXPORT_FROM_DLL KeyRing : public InventoryItem
{
public:
CLASS_PROTOTYPE( KeyRing );
KeyRing();
};
CLASS_DECLARATION( InventoryItem, KeyRing, "inventory_keyring" )
ResponseDef KeyRing::Responses[] =
{
{ NULL, NULL }
};
KeyRing::KeyRing
(
)
{
setModel( "keys.def" );
}
class EXPORT_FROM_DLL MoneyBag : public InventoryItem
{
public:
CLASS_PROTOTYPE( MoneyBag );
MoneyBag();
};
CLASS_DECLARATION( InventoryItem, MoneyBag, "inventory_moneybag" )
ResponseDef MoneyBag::Responses[] =
{
{ NULL, NULL }
};
MoneyBag::MoneyBag
(
)
{
setModel( "moneybag_inv.def" );
}
class EXPORT_FROM_DLL Dollar : public InventoryItem
{
public:
CLASS_PROTOTYPE( Dollar );
Dollar();
};
CLASS_DECLARATION( InventoryItem, Dollar, "inventory_dollar" )
ResponseDef Dollar::Responses[] =
{
{ NULL, NULL }
};
Dollar::Dollar
(
)
{
setModel( "dollar.def" );
}
class EXPORT_FROM_DLL Evidence : public InventoryItem
{
public:
CLASS_PROTOTYPE( Evidence );
Evidence();
};
CLASS_DECLARATION( InventoryItem, Evidence, "inventory_evidence" )
ResponseDef Evidence::Responses[] =
{
{ NULL, NULL }
};
Evidence::Evidence
(
)
{
setModel( "evidence.def" );
}
class EXPORT_FROM_DLL Decoder : public InventoryItem
{
public:
CLASS_PROTOTYPE( Decoder );
Decoder();
};
CLASS_DECLARATION( InventoryItem, Decoder, "inventory_decoder" )
ResponseDef Decoder::Responses[] =
{
{ NULL, NULL }
};
Decoder::Decoder
(
)
{
setModel( "code.def" );
}
class EXPORT_FROM_DLL PulsePart1 : public InventoryItem
{
public:
CLASS_PROTOTYPE( PulsePart1 );
PulsePart1();
virtual Item *ItemPickup( Entity *other );
};
CLASS_DECLARATION( InventoryItem, PulsePart1, "inventory_pulsepart1" )
ResponseDef PulsePart1::Responses[] =
{
{ NULL, NULL }
};
PulsePart1::PulsePart1
(
)
{
ExecuteThread( "global/pulse_parts.scr::precache", true );
setModel( "pulsepart1.def" );
}
Item *PulsePart1::ItemPickup
(
Entity *other
)
{
if ( !level.no_jc )
ExecuteThread( "global/pulse_parts.scr::blade_finds_piece1", true );
gameVars.CreateVariable( "pulse1", 1 );
if ( other->isClient() )
{
Player *player;
ScriptVariable *var1,*var2,*var3;
var1 = gameVars.GetVariable( "pulse1" );
var2 = gameVars.GetVariable( "pulse2" );
var3 = gameVars.GetVariable( "pulse3" );
if ( var1 && var2 && var3 )
{
player = ( Player * )other;
player->giveWeapon( "PulseRifle" );
player->FreeInventoryOfType( "PulsePart2" );
player->FreeInventoryOfType( "PulsePart3" );
CancelEventsOfType( EV_Item_DropToFloor );
CancelEventsOfType( EV_Item_Respawn );
CancelEventsOfType( EV_FadeOut );
PostEvent( EV_Remove, 0 );
return NULL;
}
}
return Item::ItemPickup( other );
}
class EXPORT_FROM_DLL PulsePart2 : public InventoryItem
{
public:
CLASS_PROTOTYPE( PulsePart2 );
PulsePart2();
virtual Item *ItemPickup( Entity *other );
};
CLASS_DECLARATION( InventoryItem, PulsePart2, "inventory_pulsepart2" )
ResponseDef PulsePart2::Responses[] =
{
{ NULL, NULL }
};
PulsePart2::PulsePart2
(
)
{
ExecuteThread( "global/pulse_parts.scr::precache", true );
setModel( "pulsepart2.def" );
}
Item *PulsePart2::ItemPickup
(
Entity *other
)
{
if ( !level.no_jc )
ExecuteThread( "global/pulse_parts.scr::blade_finds_piece2", true );
gameVars.CreateVariable( "pulse2", 1 );
if ( other->isClient() )
{
Player *player;
ScriptVariable *var1,*var2,*var3;
var1 = gameVars.GetVariable( "pulse1" );
var2 = gameVars.GetVariable( "pulse2" );
var3 = gameVars.GetVariable( "pulse3" );
if ( var1 && var2 && var3 )
{
player = ( Player * )other;
player->giveWeapon( "PulseRifle" );
player->FreeInventoryOfType( "PulsePart1" );
player->FreeInventoryOfType( "PulsePart3" );
CancelEventsOfType( EV_Item_DropToFloor );
CancelEventsOfType( EV_Item_Respawn );
CancelEventsOfType( EV_FadeOut );
PostEvent( EV_Remove, 0 );
return NULL;
}
}
return Item::ItemPickup( other );
}
class EXPORT_FROM_DLL PulsePart3 : public InventoryItem
{
public:
CLASS_PROTOTYPE( PulsePart3 );
PulsePart3();
virtual Item *ItemPickup( Entity *other );
};
CLASS_DECLARATION( InventoryItem, PulsePart3, "inventory_pulsepart3" )
ResponseDef PulsePart3::Responses[] =
{
{ NULL, NULL }
};
PulsePart3::PulsePart3
(
)
{
ExecuteThread( "global/pulse_parts.scr::precache", true );
setModel( "pulsepart3.def" );
}
Item *PulsePart3::ItemPickup
(
Entity *other
)
{
if ( !level.no_jc )
ExecuteThread( "global/pulse_parts.scr::blade_finds_piece3", true );
gameVars.CreateVariable( "pulse3", 1 );
if ( other->isClient() )
{
Player *player;
ScriptVariable *var1,*var2,*var3;
var1 = gameVars.GetVariable( "pulse1" );
var2 = gameVars.GetVariable( "pulse2" );
var3 = gameVars.GetVariable( "pulse3" );
if ( var1 && var2 && var3 )
{
player = ( Player * )other;
player->giveWeapon( "PulseRifle" );
player->FreeInventoryOfType( "PulsePart1" );
player->FreeInventoryOfType( "PulsePart2" );
CancelEventsOfType( EV_Item_DropToFloor );
CancelEventsOfType( EV_Item_Respawn );
CancelEventsOfType( EV_FadeOut );
PostEvent( EV_Remove, 0 );
return NULL;
}
}
return Item::ItemPickup( other );
}
class EXPORT_FROM_DLL Chemsuit : public InventoryItem
{
public:
CLASS_PROTOTYPE( Chemsuit );
Chemsuit();
};
CLASS_DECLARATION( InventoryItem, Chemsuit, "inventory_chembiosuit" )
ResponseDef Chemsuit::Responses[] =
{
{ NULL, NULL }
};
Chemsuit::Chemsuit
(
)
{
setModel( "chemsuit.def" );
}
class EXPORT_FROM_DLL Blueprints : public InventoryItem
{
public:
CLASS_PROTOTYPE( Blueprints );
Blueprints();
};
CLASS_DECLARATION( InventoryItem, Blueprints, "inventory_blueprints" )
ResponseDef Blueprints::Responses[] =
{
{ NULL, NULL }
};
Blueprints::Blueprints
(
)
{
setModel( "blueprints.def" );
}
class EXPORT_FROM_DLL U4Sample : public InventoryItem
{
public:
CLASS_PROTOTYPE( U4Sample );
U4Sample();
};
CLASS_DECLARATION( InventoryItem, U4Sample, "inventory_u4sample" )
ResponseDef U4Sample::Responses[] =
{
{ NULL, NULL }
};
U4Sample::U4Sample
(
)
{
setModel( "u4_sample.def" );
}
class EXPORT_FROM_DLL Envelope : public InventoryItem
{
public:
CLASS_PROTOTYPE( Envelope );
Envelope();
};
CLASS_DECLARATION( InventoryItem, Envelope, "inventory_envelope" )
ResponseDef Envelope::Responses[] =
{
{ NULL, NULL }
};
Envelope::Envelope
(
)
{
setModel( "envelope.def" );
}
class EXPORT_FROM_DLL CandyBar : public InventoryItem
{
public:
CLASS_PROTOTYPE( CandyBar );
CandyBar();
};
CLASS_DECLARATION( InventoryItem, CandyBar, "inventory_candybar" )
ResponseDef CandyBar::Responses[] =
{
{ NULL, NULL }
};
CandyBar::CandyBar
(
)
{
setModel( "CandyBar.def" );
}
class EXPORT_FROM_DLL PassCode : public InventoryItem
{
public:
CLASS_PROTOTYPE( PassCode );
PassCode();
};
CLASS_DECLARATION( InventoryItem, PassCode, "inventory_passcode" )
ResponseDef PassCode::Responses[] =
{
{ NULL, NULL }
};
PassCode::PassCode
(
)
{
setModel( "password.def" );
}
class EXPORT_FROM_DLL PassCode2 : public InventoryItem
{
public:
CLASS_PROTOTYPE( PassCode2 );
PassCode2();
};
CLASS_DECLARATION( InventoryItem, PassCode2, "inventory_passcode2" )
ResponseDef PassCode2::Responses[] =
{
{ NULL, NULL }
};
PassCode2::PassCode2
(
)
{
setModel( "password2.def" );
}
class EXPORT_FROM_DLL Hand : public InventoryItem
{
public:
CLASS_PROTOTYPE( Hand );
Hand();
};
CLASS_DECLARATION( InventoryItem, Hand, "inventory_hand" )
ResponseDef Hand::Responses[] =
{
{ NULL, NULL }
};
Hand::Hand
(
)
{
setModel( "hand.def" );
}
/*SINED inventory_genericpulsepart (.3 1 .3) (-8 -8 0) (8 8 16) NOT_SOLID NOT_DAMAGABLE
Pulse Weapon Part - Will always spawn as the next piece that the user needs
to complete the weapon. When the user picks up 3 of these, they will get the PulseRifle
*/
class EXPORT_FROM_DLL GenericPulsePart : public InventoryItem
{
public:
CLASS_PROTOTYPE( GenericPulsePart );
GenericPulsePart();
};
CLASS_DECLARATION( InventoryItem, GenericPulsePart, "inventory_genericpulsepart" )
ResponseDef GenericPulsePart::Responses[] =
{
{ NULL, NULL }
};
GenericPulsePart::GenericPulsePart
(
)
{
ScriptVariable *var1,*var2,*var3;
var1 = gameVars.GetVariable( "pulse1" );
var2 = gameVars.GetVariable( "pulse2" );
var3 = gameVars.GetVariable( "pulse3" );
// Based on what pulserifle pieces that have already been found,
// spawn the correct model in the game.
if ( !var1 )
{
PulsePart1 *part1;
part1 = new PulsePart1;
part1->setModel( "pulsepart1.def" );
part1->setOrigin( origin );
part1->worldorigin.copyTo(part1->edict->s.old_origin);
}
else if ( !var2 )
{
PulsePart2 *part2;
part2 = new PulsePart2;
part2->setModel( "pulsepart2.def" );
part2->setOrigin( origin );
part2->worldorigin.copyTo(part2->edict->s.old_origin);
}
else if ( !var3 )
{
PulsePart3 *part3;
part3 = new PulsePart3;
part3->setModel( "pulsepart3.def" );
part3->setOrigin( origin );
part3->worldorigin.copyTo(part3->edict->s.old_origin);
}
PostEvent( EV_Remove, 0 );
}

261
launcher.cpp Normal file
View File

@ -0,0 +1,261 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/launcher.cpp $
// $Revision:: 12 $
// $Author:: Markd $
// $Date:: 10/24/98 12:42a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/launcher.cpp $
//
// 12 10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
//
// 11 10/13/98 5:04p Markd
// Fixed launcher sounds
//
// 10 10/13/98 12:55a Markd
// Fixed launcher that uses info_notnulls
//
// 9 10/01/98 4:01p Markd
// Added Archive and Unarchive functions
//
// 8 8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
//
// 7 7/06/98 4:07p Aldie
// Removed some dependencies on some headers.
//
// 6 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 5 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 4 5/20/98 11:11a Markd
// removed char * dependency
//
// 3 5/06/98 3:14p Aldie
// Added targeting of the launcher.
//
// 2 5/05/98 8:35p Aldie
// First version of Generic launcher
//
// DESCRIPTION: Generic Projectile Launcher
//
#include "g_local.h"
#include "misc.h"
#include "specialfx.h"
/****************************************************************************
/*SINED func_launcher (0 1 0) ?
Creates an object that launches projectiles.
"projectile" Sets the projectile that you want to launch (Examples: Rocket, Spear, etc...)
"launchsound" Sets the launching sound.
/*****************************************************************************/
class EXPORT_FROM_DLL GenericLauncher : public Entity
{
private:
Vector launchAngle;
float x_var;
float y_var;
float z_var;
str projectile;
str launchsound;
public:
CLASS_PROTOTYPE( GenericLauncher );
GenericLauncher( );
void Launch(Event *ev);
void LaunchProjectile(Event *ev);
void Setdir(Event *ev);
void SetXdir(Event *ev);
void SetYdir(Event *ev);
void SetZdir(Event *ev);
void SetXvar(Event *ev);
void SetYvar(Event *ev);
void SetZvar(Event *ev);
void SetupDir(Event *ev);
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
EXPORT_FROM_DLL void GenericLauncher::Archive
(
Archiver &arc
)
{
Entity::Archive( arc );
arc.WriteVector( launchAngle );
arc.WriteFloat( x_var );
arc.WriteFloat( y_var );
arc.WriteFloat( z_var );
arc.WriteString( projectile );
arc.WriteString( launchsound );
}
EXPORT_FROM_DLL void GenericLauncher::Unarchive
(
Archiver &arc
)
{
Entity::Unarchive( arc );
arc.ReadVector( &launchAngle );
arc.ReadFloat( &x_var );
arc.ReadFloat( &y_var );
arc.ReadFloat( &z_var );
arc.ReadString( &projectile );
arc.ReadString( &launchsound );
}
CLASS_DECLARATION( Entity, GenericLauncher, "func_launcher" );
Event EV_GenericLauncher_Launch( "launch" );
Event EV_GenericLauncher_Setdir( "setdir" );
Event EV_GenericLauncher_SetXdir( "setXdir" );
Event EV_GenericLauncher_SetYdir( "setYdir" );
Event EV_GenericLauncher_SetZdir( "setZdir" );
Event EV_GenericLauncher_SetXvar( "setXvar" );
Event EV_GenericLauncher_SetYvar( "setYvar" );
Event EV_GenericLauncher_SetZvar( "setZvar" );
Event EV_GenericLauncher_SetupDir( "setupdir" );
ResponseDef GenericLauncher::Responses[] =
{
{ &EV_Activate, ( Response )GenericLauncher::LaunchProjectile },
{ &EV_GenericLauncher_Launch, ( Response )GenericLauncher::Launch },
{ &EV_GenericLauncher_SetXdir, ( Response )GenericLauncher::SetXdir },
{ &EV_GenericLauncher_SetYdir, ( Response )GenericLauncher::SetYdir },
{ &EV_GenericLauncher_SetZdir, ( Response )GenericLauncher::SetZdir },
{ &EV_GenericLauncher_SetXvar, ( Response )GenericLauncher::SetXvar },
{ &EV_GenericLauncher_SetYvar, ( Response )GenericLauncher::SetYvar },
{ &EV_GenericLauncher_SetZvar, ( Response )GenericLauncher::SetZvar },
{ &EV_GenericLauncher_SetupDir, ( Response )GenericLauncher::SetupDir },
{ NULL, NULL }
};
GenericLauncher::GenericLauncher( )
{
showModel();
setSolidType( SOLID_BSP );
projectile = G_GetStringArg( "projectile" );
launchsound = G_GetStringArg( "launchsound" );
launchAngle = G_GetMovedir();
x_var = 0;
y_var = 0;
z_var = 0;
PostEvent( EV_GenericLauncher_SetupDir, 0 );
}
void GenericLauncher::SetupDir( Event *ev )
{
int num;
const char *target;
Entity *dest;
target = Target();
if (target)
{
if (num = G_FindTarget(0, target))
{
dest = G_GetEntity( num );
assert( dest );
VectorSubtract(dest->worldorigin, origin, launchAngle);
}
}
}
void GenericLauncher::SetXdir( Event *ev )
{
launchAngle.x = ev->GetFloat( 1 );
}
void GenericLauncher::SetYdir( Event *ev )
{
launchAngle.y = ev->GetFloat(1);
}
void GenericLauncher::SetZdir( Event *ev )
{
launchAngle.z = ev->GetFloat(1);
}
void GenericLauncher::Setdir(Event *ev)
{
launchAngle = ev->GetVector(1);
}
void GenericLauncher::SetXvar( Event *ev )
{
x_var = ev->GetFloat(1);
}
void GenericLauncher::SetYvar( Event *ev )
{
y_var = ev->GetFloat(1);
}
void GenericLauncher::SetZvar( Event *ev )
{
z_var = ev->GetFloat(1);
}
void GenericLauncher::LaunchProjectile(Event *ev)
{
Vector ang;
ClassDef *cls;
Projectile *obj;
ang.x = launchAngle.x + G_CRandom(x_var);
ang.y = launchAngle.y + G_CRandom(y_var);
ang.z = launchAngle.z + G_CRandom(z_var);
cls = getClass( projectile.c_str() );
if (cls)
{
if ( launchsound.length() )
{
this->sound( launchsound, 1, CHAN_WEAPON, ATTN_NORM );
}
obj = (Projectile *)cls->newInstance();
obj->Setup( this, worldorigin, ang.normalize());
}
}
void GenericLauncher::Launch(Event *ev)
{
Vector ang;
ClassDef *cls;
Projectile *obj;
ang.x = launchAngle.x + G_CRandom(x_var);
ang.y = launchAngle.y + G_CRandom(y_var);
ang.z = launchAngle.z + G_CRandom(z_var);
cls = getClass( ev->GetString(1));
if (cls)
{
if ( launchsound.length() )
{
this->sound( launchsound, 1, CHAN_WEAPON, ATTN_NORM );
}
obj = (Projectile *)cls->newInstance();
obj->Setup( this, worldorigin, ang.normalize());
}
}

197
lensflare.cpp Normal file
View File

@ -0,0 +1,197 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/lensflare.cpp $
// $Revision:: 17 $
// $Author:: Jimdose $
// $Date:: 10/19/98 12:07a $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/lensflare.cpp $
//
// 17 10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
//
// 16 10/09/98 8:58p Aldie
// Lightstyle on lensflare from Lights
//
// 15 10/09/98 5:23p Aldie
// Added some commands for lightstyle.
//
// 14 9/25/98 2:59p Aldie
// More lensflare stuff. Added lightstyles
//
// 13 5/03/98 4:34p Jimdose
// Changed Vector class
//
// 12 3/30/98 11:39p Markd
// Added modelIndex stuff
//
// 11 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 10 3/18/98 2:05p Aldie
// Changed the filename of the sprite model extension to .spr
//
// 9 3/14/98 4:40p Aldie
// Added scale to lensflare.
//
// 8 3/13/98 7:25p Aldie
// Expanded lensflare to have color, dlights, and radius.
//
// 7 3/12/98 5:37p Markd
// Changed model file for lensflare from sp3 file to def file
//
// 6 3/12/98 3:02p Aldie
// Cleaned up lensflare.
//
// 5 3/12/98 2:42p Aldie
// Random starting positions for lensflare rotation offset.
//
// 4 3/10/98 7:45p Aldie
//
// 3 3/07/98 5:16p Aldie
// Added new sprite.
//
// 2 3/06/98 7:16p Aldie
// First try at lensflare.
//
// DESCRIPTION:LensFlare effect
//
#include "g_local.h"
#include "entity.h"
#include "lensflare.h"
#include "light.h"
CLASS_DECLARATION( Trigger, LensFlare, "lensflare" );
/*****************************************************************************/
/*SINED lensflare (0 1 0) (-8 -8 -8) (8 8 8)
"color" (r g b) 3 values between 0 and 1.0 (Default is 1.0 1.0 1.0)
"light" If set,make the flare emit a dynamic light. (Default is not set)
"radius" Radius of the dynamic light (Default is 200)
"scale" Factor to scale the lensflare (Default is 0.5)
"sprite" Sprite model to use for the flare (Default is sprites/glow.spr")
"lightstyle" Lightstyle of the lensflare (Default is none)
/*****************************************************************************/
Event EV_LensFlare_Activate( "activate" );
Event EV_LensFlare_Deactivate( "deactivate" );
Event EV_LensFlare_Lightstyle( "lightstyle" );
Event EV_LensFlare_SetLightstyle( "setlightstyle" );
ResponseDef LensFlare::Responses[] =
{
{ &EV_LensFlare_Activate, ( Response )LensFlare::Activate },
{ &EV_LensFlare_Deactivate, ( Response )LensFlare::Deactivate },
{ &EV_LensFlare_Lightstyle, ( Response )LensFlare::Lightstyle },
{ &EV_LensFlare_SetLightstyle, ( Response )LensFlare::SetLightstyle },
{ NULL, NULL }
};
LensFlare::LensFlare( void )
{
Vector color;
Vector def;
int dlight,radius;
float scale;
int lightstyle;
color = G_GetVectorArg("color",Vector(1,1,1));
dlight = G_GetIntArg("light",0);
radius = G_GetIntArg("radius",0);
scale = G_GetFloatArg("scale", 0.5f);
model = G_GetSpawnArg("sprite", "sprites/glow.spr" );
lightstyle = G_GetIntArg("lightstyle", 255 );
setModel( model );
setMoveType( MOVETYPE_NONE );
setSolidType( SOLID_NOT );
edict->s.renderfx |= (RF_LENSFLARE);
if (dlight)
edict->s.renderfx |= (RF_DLIGHT);
edict->s.angles[ROLL] = rand() % 360;
edict->s.alpha = 1.0f;
edict->s.color_r = color.x;
edict->s.color_g = color.y;
edict->s.color_b = color.z;
edict->s.radius = radius;
edict->s.scale = scale;
edict->s.skinnum = lightstyle;
PostEvent( EV_LensFlare_SetLightstyle, 0 );
}
void LensFlare::SetLightstyle
(
Event *ev
)
{
int num;
const char *name;
Entity *ent;
name = Target();
if ( name && strcmp( name, "" ) )
{
num = 0;
do
{
num = G_FindTarget( num, name );
if ( !num )
{
break;
}
ent = G_GetEntity( num );
assert( ent );
if ( ent->isSubclassOf( Light ) )
{
Light *light;
light = ( Light * )ent;
edict->s.skinnum = light->GetStyle();
}
}
while ( 1 );
}
}
void LensFlare::Activate
(
Event *ev
)
{
setSolidType( SOLID_BSP );
showModel();
}
void LensFlare::Deactivate
(
Event *ev
)
{
hideModel();
}
void LensFlare::Lightstyle
(
Event *ev
)
{
edict->s.skinnum = ev->GetInteger( 1 );
}

62
lensflare.h Normal file
View File

@ -0,0 +1,62 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/lensflare.h $
// $Revision:: 9 $
// $Author:: Aldie $
// $Date:: 10/09/98 9:02p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/lensflare.h $
//
// 9 10/09/98 9:02p Aldie
// Lightstyle on lensflare from Lights
//
// 8 10/09/98 5:23p Aldie
// Added some new commands (lightstyle)
//
// 7 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 6 9/25/98 3:00p Aldie
// Prototypes
//
// 5 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 4 3/13/98 7:25p Aldie
// Updated lensflare to have dlights, color, and radius.
//
// 3 3/10/98 7:45p Aldie
//
// 2 3/06/98 7:16p Aldie
// First try at LensFlare.
//
// DESCRIPTION:LensFlare effect
//
#ifndef __LENSFLARE_H__
#define __LENSFLARE_H__
#include "g_local.h"
#include "entity.h"
class EXPORT_FROM_DLL LensFlare : public Entity
{
public:
CLASS_PROTOTYPE( LensFlare );
LensFlare( void );
void Activate( Event *ev );
void Deactivate( Event *ev );
void Lightstyle( Event *ev );
void SetLightstyle( Event *ev );
};
#endif /* lensflare.h */

98
license.doc Normal file
View File

@ -0,0 +1,98 @@
{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\nowidctlpar\adjustright \snext0 Normal;}{\s1\qc\keepn\nowidctlpar\widctlpar\tx0\tqc\tx4680\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright \b\fs22 \sbasedon0 \snext0 heading 1;}{\*\cs10 \additive Default Paragraph Font;}{\*\cs15 \additive footnote reference;}{\s16\qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright \fs22 \sbasedon0 \snext16 Body Text 2;}{\s17\qc\nowidctlpar\widctlpar\adjustright \b\fs22 \sbasedon0 \snext17 Title;}}{\info{\title ATTENTION}{\author Harry Miller}{\operator Mark Dochtermann}{\creatim\yr1998\mo10\dy18\hr18\min36}{\revtim\yr1998\mo10\dy18\hr18\min36}{\printim\yr1998\mo10\dy15\hr16\min36}{\version2}{\edmins0}{\nofpages7}{\nofwords3117}{\nofchars17768}{\*\company Ritual Entertainment}{\nofcharsws21820}{\vern71}}\margl1440\margr1440\margb288 \widowctrl\ftnbj\aenddoc\aftnnar\notabind\wraptrsp\transmf\truncatefontheight\subfontbysize\sprsbsp\wpjst\lytprtmet\hyphcaps0\viewkind4\viewscale100 \fet0\sectd \linex0\headery1440\footery288\sectdefaultcl {\footer \pard\plain \sl-240\slmult0\nowidctlpar\adjustright {
\par
\par }\pard \nowidctlpar\tx0\tqc\tx4680\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {Software License Agreement\tab }{\field{\*\fldinst {PAGE }}{\fldrslt {\lang1024 6}}}{
\par }{\fs14 08656 00001 CORP 209544.3}{
\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s17\qc\nowidctlpar\widctlpar\adjustright \b\fs22 {ATTENTION
\par }\pard\plain \qj\fi720\nowidctlpar\widctlpar\adjustright {\fs22
\par Here is a brief summary of certain of the terms and conditions in our Limited Software Warranty and License Agreement. You must read the full text of the agreement before using this product so that You understand all of the terms and conditions of our agreement regarding this product.
\par }\pard \qj\nowidctlpar\widctlpar\adjustright {\fs22
\par WHAT IS OKAY FOR YOU TO DO:
\par
\par }\pard \qj\fi-720\li720\nowidctlpar\widctlpar\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 $\tab Playing and enjoying the shareware and/or registered/full retail version of the game, demo and/or level editor.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi-720\li720\nowidctlpar\widctlpar\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 $\tab Setting up a shareware, demo, and/or registered/full retail version based server on a not-for-profit and non-commercially exploited basis.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi-720\li720\nowidctlpar\widctlpar\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 $\tab Playing the shareware, demo, and/or registered/full retail version of the game and/or setting up a registered/full retail version of the game using user-developed levels on a not-for-profit and non-commercially exploited bases.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par WHAT IS NOT OKAY FOR YOU TO DO:
\par
\par }\pard \qj\fi-720\li720\nowidctlpar\widctlpar\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 $\tab You cannot sell or otherwise commercially exploit or utilize the shareware, registered/full retail version, demo or level editor in any way or sell user-developed levels and/or tools.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi-720\li720\nowidctlpar\widctlpar\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 $\tab Commercially exploiting or otherwise utilizing any copyrighted and/or trademarked property of Ritual Entertainment or any other party contained in or associated with the shareware, demo, level editor or registered/full retail version, demo, single player game and/or level editor, including without limitation game names, logos, graphics, characters, etc.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par \sect }\sectd \linex0\headery1440\footery288\sectdefaultcl \pard\plain \s1\qc\keepn\nowidctlpar\widctlpar\tqc\tx4680\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\outlinelevel0\adjustright \b\fs22 {LIMITED SOFTWARE WARRANTY AND LICENSE AGREEMENT
\par }\pard\plain \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard\plain \s16\qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright \fs22 {This LIMITED SOFTWARE WARRANTY AND LICENSE AGREEMENT (this \ldblquote Agreement\rdblquote ), including the Limited Warranty and other special provisions, is a legal agreement between You (either an individual or an entity) and Ritual Entertainment, Inc., a Texas corporation (the \ldblquote Owner\rdblquote ), regarding this software product and the materials contained therein and related thereto. Your act of downloading, installing and/or otherwise using the software constitutes Your agreement to be bound by the terms of this Agreement. If You do not agree to the terms of this Agreement cease loading or installing this product and, if applicable, promptly return the software packaging and the accompanying materials (including any hardware, manuals, other written materials and packaging) to the place You obtained them, along with Your receipt, for a full refund.
\par }\pard\plain \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Grant of Limited Non-Exclusive License}{\fs22 . (A) In the event that You are currently encountering this Agreement in conjunction with or as a result of Your downloading or otherwise installing the SOFTWARE (as defined herein), this Agreement permits You to use one (1) copy of the software program(s), in executable or object code form only, contained in the registered/full retail version of the game program entitled SiN, as contained in the disk(s) making up all or part of the registered/full retail software product, including without limitation the data files, images, level editors, death match levels, charters and screen displays (the \ldblquote SOFTWARE\rdblquote ), included in this download for Your personal use on a single home or portable computer. This license also permits You to use the SOFTWARE\rquote s level editor to create new game levels, weapons, characters and/or entities for non-commercial personal use, and to non-commercially distribute such game levels, weapons, characters, and/or entities to personal acquaintances for non-commercial use via the Internet pursuant to subparagraph (C) below. This license does NOT authorize You to sell, lease or otherwise profit from or commercially distribute the SOFTWARE (see \ldblquote Restrictions\rdblquote below). The SOFTWARE is in \ldblquote use\rdblquote on a computer when it is loaded into temporary memory (i.e., RAM) or installed into the permanent memory (e.g., hard disk, CD-ROM, or other storage device) of that computer. Installation on a network server is strictly prohibited, except under a special and separate network license obtained from Owner; this Agreement shall not serve as such necessary special network license. Installation on a network server constitutes \ldblquote use\rdblquote that must comply with the terms of this Agreement. This license is not a sale of the original SOFTWARE or any copy thereof.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 (B)\tab In the event that You are currently encountering this Agreement in conjunction with or as a result of Your downloading or otherwise installing a DEMO PRODUCT (as defined herein), this Agreement permits You to use the software program(s) included in and received solely as a result of the loaded or otherwise installed version of the demo, free standing level editor and/or shareware version of the game entitled Sin, as the case may be, for Your personal use (each such item referred to herein, individually as a \ldblquote DEMO PRODUCT\rdblquote and collectively as the \ldblquote DEMO PRODUCTS\rdblquote ). This license also permits You to use the level editor, as contained in and received solely as a result of the downloading or other installation or utilization of such DEMO PRODUCT, to create new game levels, weapons, characters and/or entities for non-commercial personal use, and to non-commercially distribute such games levels, weapons, characters, and/or entities to personal acquaintances for non-commercial use via the Internet pursuant to subparagraph (C) below. This license does NOT authorize You to sell, lease or otherwise profit from or commercially exploit a DEMO PRODUCT (see \ldblquote Restrictions\rdblquote below). A DEMO PRODUCT is in \ldblquote use\rdblquote on a computer when it is loaded into temporary memory (i.e., RAM) or installed into the permanent memory (e.g., hard disk, CD-ROM, or other storage device) of that computer or accessed via the Internet. Installation of any DEMO PRODUCTS on a network server for profit or other commercial benefit to You or any other person is strictly prohibited, except under a special and separate network license obtained from Owner; this Agreement shall not serve as such necessary special network license. Installation on a network server constitutes \ldblquote use\rdblquote that must comply with the terms of this Agreement. This license is not a sale of the original DEMO PRODUCTS or any copy thereof.
\par \sect }\sectd \sbknone\linex0\headery1440\footery288\sectdefaultcl \pard\plain \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 (C)\tab Subject to the terms and conditions of this Agreement, Owner grants to You the non-exclusive and limited right to create additional levels (the \ldblquote USER LEVELS\rdblquote ) which are operable with the SOFTWARE or DEMO PRODUCT. You may include within the USER LEVELS certain textures and other images (the \ldblquote Owner Images\rdblquote ) from the SOFTWARE or DEMO PRODUCT, as the case may be. You agree that the USER LEVELS will not be shipped, transferred or exported into any country in violation of the U.S. Export Administration Act (or any other law governing such matters) by You or anyone at Your direction and that You will not utilize and will not authorize anyone to utilize, in any other manner, the USER LEVELS in violation of any applicable law. The USER LEVELS may not be downloaded or otherwise exported or re-exported into (or to a national or resident of) any country to which the United States has embargoed goods or to anyone or unto any country who/which are prohibited by applicable law, from receiving such property. You shall not rent, sell, lease, lend, offer on a pay-per-play basis or otherwise commercially exploit or commercially distribute any USER LEVELS. You are only permitted to distribute for free, without any cost or charge, the USER LEVELS to other end-users. As noted below, in the event You commercially distribute or commercially exploit any USER LEVELS or commit any other breach of this Agreement, Your license, as granted in this Agreement, shall automatically terminate, without notice. IN ADDITION TO YOUR INDEMNIFICATION OBLIGATIONS AS SET FORTH BELOW, YOU HEREBY AGREE TO INDEMNIFY, DEFEND AND HOLD HARMLESS OWNER AND OWNER\rquote S RESPECTIVE OFFICERS, EMPLOYEES, DIRECTORS, AGENTS, LICENSEES (EXCLUDING YOU), SUBLICENSEES (EXCLUDING YOU), SUCCESSORS AND ASSIGNS FROM AND AGAINST ANY AND ALL DIRECT AND/OR INDIRECT LOSSES, LAWSUITS, DAMAGES, CAUSES OF ACTIONS AND CLAIMS RELATING TO AND/OR ARISING FROM THE USER LEVELS AND/OR THE DISTRIBUTION OR OTHER USE OF ANY USER LEVELS.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Intellectual Property Ownership}{\fs22 . Owner retains all right, title and interest to the SOFTWARE and/or DEMO PRODUCTS and any accompanying instructions or other documentation (collectively, the \ldblquote ACCOMPANYING MATERIALS\rdblquote ), including, but not limited to, all copyrights, trademarks, trade secrets, trade names, proprietary rights, patents, titles, computer codes, audiovisual effects, themes, characters, character names, stories, dialog, settings, artwork, sounds effects, musical works, and moral rights. The SOFTWARE, DEMO PRODUCTS and ACCOMPANYING MATERIALS are protected by United States copyright law and applicable copyright laws and treaties throughout the World. All rights are reserved. The SOFTWARE and ACCOMPANYING MATERIALS may not be copied or reproduced in any manner or medium, in whole or in part, without prior written consent from Owner except as specifically provided under \ldblquote Grant of Limited Non-Exclusive License\rdblquote above. Any persons copying or reproducing all or any portion of the SOFTWARE or ACCOMPANYING MATERIALS, except as specifically provided under \ldblquote Grant of Limited Non-Exclusive License\rdblquote above, in any manner or medium, will be willfully violating the copyright laws and may be subject to civil or criminal penalties.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul SOFTWARE Backup or Archiving}{\fs22 . After You install the SOFTWARE into the permanent memory of a computer, You may keep and use the original disk(s) and/or CD-ROM (the \ldblquote Storage Media\rdblquote ) only for backup or archival purposes. You are expressly prohibited from transmitting the SOFTWARE or ACCOMPANYING MATERIALS electronically or otherwise over the Internet or through any other media or to any other party.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par \sect }\sectd \sbknone\linex0\headery1440\footery288\sectdefaultcl \pard\plain \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Restrictions}{\fs22 . Other than as provided specifically in this Agreement, You are not permitted to copy or otherwise reproduce the SOFTWARE or ACCOMPANYING MATERIALS; modify or prepare derivative copies based on the SOFTWARE or ACCOMPANYING MATERIALS; distribute copies of the SOFTWARE or ACCOMPANYING MATERIALS by sale or other transfer of ownership; rent, lease, or lend the SOFTWARE, DEMO PRODUCTS or ACCOMPANYING MATERIALS; or to display the SOFTWARE or ACCOMPANYING MATERIALS publicly. You are expressly prohibited from selling, leasing, charging for access to, or otherwise using for profit or commercially exploiting any USER LEVELS, level packs, add-on packs, sequels, characters or other components or items created by utilization of the SOFTWARE\rquote s or DEMO PRODUCT\rquote s level editor and/or based upon or related to the SOFTWARE, DEMO PRODUCT or ACCOMPANYING MATERIALS. YOU ARE NOT PERMITTED TO REVERSE ENGINEER, DECOMPILE OR DISASSEMBLE THE SOFTWARE OR ANY DEMO PRODUCT IN ANY WAY. Any copying or distribution of the SOFTWARE or ACCOMPANYING MATERIALS not specifically allowed in this Agreement is a violation of this Agreement. You may create USER LEVELS for the SOFTWARE or any DEMO PRODUCT; provided, however, that such USER LEVELS are created in accordance with the non-exclusive license set forth above and no USER LEVELS may be sold or otherwise commercially exploited, whether by You or by any other person or entity, but You may exchange USER LEVELS at no charge with other end-users.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Limited Warranty and Warranty Disclaimers}{\fs22 .
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 LIMITED WARRANTY. Owner warrants that the original Storage Media holding the SOFTWARE is free from defects in materials and workmanship under normal use and service for a period of ninety (90) days from the date that You downloaded the SOFTWARE. If for any reason You find defects in the Storage Media, or if You are unable to install the SOFTWARE on Your home or portable computer, You may return the SOFTWARE, ACCOMPANYING MATERIALS and all packaging related thereto to the place you purchased such products for a full refund or replacement thereof. This limited warranty does not apply if You have damaged the SOFTWARE by accident or abuse.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 CUSTOMER\rquote S REMEDY. Your exclusive remedies, and the entire liability of Owner, shall be replacement of the SOFTWARE or DEMO PRODUCT, as the case may be. By downloading, installing and/or otherwise using the SOFTWARE, DEMO PRODUCT or ACCOMPANYING MATERIALS, as the case may be, You hereby agree to waive any and all other remedies You may have at law or in equity. Any such remedies You may not waive as a matter of public policy, You hereby assign, or shall assign as they become available, over to Owner.
\par
\par NOTWITHSTANDING ANYTHING TO THE CONTRARY IN THIS AGREEMENT, WITH RESPECT TO THE DEMO PRODUCTS, OWNER MAKES NO REPRESENTATIONS OR WARRANTIES (EXPRESS, IMPLIED OR OTHERWISE), INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND/OR NON-INFRINGEMENT. THE DEMO PRODUCTS ARE PROVIDED GRATUITOUSLY TO YOU \ldblquote AS IS\rdblquote AND YOU TAKE, INSTALL, LOAD OR OTHERWISE USE SUCH DEMO PRODUCTS AT YOUR OWN RISK. OWNER HAS NO LIABILITIES ARISING FROM OR RELATED TO YOUR USE OF ANY DEMO PRODUCTS.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par \sect }\sectd \sbknone\linex0\headery1440\footery288\sectdefaultcl \pard\plain \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul WARRANTY DISCLAIMERS}{\fs22 . EXCEPT FOR THE EXPRESS LIMITED WARRANTY SET FORTH ABOVE, OWNER MAKES NO WARRANTIES, EXPRESS OR IMPLIED, ORAL OR WRITTEN, CONCERNING THE PRODUCTS REFERENCED HEREIN OR ANY COMPONENT PART THEREOF. ANY IMPLIED WARRANTIES THAT MAY BE IMPOSED BY APPLICABLE LAW ARE LIMITED IN ALL RESPECTS TO THE FULLEST EXTENT ALLOWED AND TO THE DURATION OF THE LIMITED WARRANTY. OWNER DOES NOT REPRESENT, WARRANT OR GUARANTEE THE QUALITY OR THE PERFORMANCE OF THE SOFTWARE, DEMO PRODUCTS OR ACCOMPANYING MATERIALS OTHER THAN AS SET FORTH IN THE ABOVE LIMITED WARRANTY. OWNER ALSO DOES NOT REPRESENT, WARRANT OR GUARANTEE THAT THE SOFTWARE, DEMO PRODUCTS OR ACCOMPANYING MATERIALS CAPABILITIES WILL MEET YOUR NEEDS OR THAT THE SOFTWARE OR DEMO PRODUCTS WILL CONTINUOUSLY OPERATE, BE ERROR FREE, OR THAT PROBLEMS WILL BE CORRECTED. OWNER DOES NOT REPRESENT THAT THE SOFTWARE OR DEMO PRODUCTS WILL OPERATE IN A MULTI-USER ENVIRONMENT.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY OWNER, ITS DEALERS, DISTRIBUTORS, DIRECTORS, OFFICERS, EMPLOYEES, AGENTS, CONTRACTORS OR AFFILIATES SHALL CREATE ANY OTHER WARRANTY OR EXTEND OR EXPAND THE SCOPE OF THIS WARRANTY. YOU MAY NOT RELY ON ANY SUCH INFORMATION OR ADVICE.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 SOME STATES DO NOT ALLOW LIMITATIONS ON HOW LONG AN IMPLIED WARRANTY LASTS, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH MAY VARY FROM STATE TO STATE.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }{\fs22\ul LIABILITY LIMITATION}{\fs22 . To the maximum extent permitted by applicable law, and regardless of whether any remedy set forth herein fails of its essential purpose,
\par
\par IN NO EVENT WILL OWNER, ITS DIRECTORS, OFFICERS, EMPLOYEES, AGENTS, LICENSES (EXCLUDING YOU), SUBLICENSEES (EXCLUDING YOU) OR AFFILIATES NOR ANYONE ELSE INVOLVED IN THE DEVELOPMENT, MANUFACTURE OR DISTRIBUTION OF THE SOFTWARE, THE DEMO PRODUCTS, THE ACCOMPANYING MATERIALS OR THE USER LEVELS (OTHER THAN YOU) BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, DIRECT OR INDIRECT; INCIDENTAL; OR CONSEQUENTIAL DAMAGES FOR PERSONAL INJURY, PERSONAL PROPERTY, LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, LOSS OF TEXT OR DATA STORED IN OR USED WITH SUCH PRODUCT INCLUDING THE COST OF RECOVERING OR REPRODUCING THE TEXT OR DATA, OR ANY OTHER PECUNIARY LOSS, ARISING FROM OR OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, THE DEMO PRODUCTS OR ANY USER LEVELS. THIS LIABILITY LIMITATION APPLIES EVEN IF YOU OR ANYONE ELSE HAS ADVISED OWNER OR ANY OF ITS AUTHORIZED REPRESENTATIVES OF THE POSSIBILITY OF SUCH DAMAGES. EVEN IF SUCH IS CAUSED BY, ARISES OUT OF OR RESULTS FROM THE ORDINARY, STRICT, SOLE OR CONTRIBUTORY NEGLIGENCE OF OWNER OR ITS DIRECTORS, OFFICERS, EMPLOYEES, AGENTS, CONTRACTORS OR AFFILIATES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY TO YOU.
\par
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Product Support and Updates}{\fs22 . This SOFTWARE is intended to be user-friendly and limited product support is provided by Owner as specified in the ACCOMPANYING MATERIALS.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Jurisdiction}{\fs22 . TEXAS LAWS GOVERN THIS AGREEMENT, REGARDLESS OF SUCH STATE\rquote S CHOICE OF LAW PRINCIPLES, WITH A FORUM AND VENUE OF DALLAS COUNTY, TEXAS. This Agreement may be modified only by a written instrument specifying the modification and executed by both parties. In the event that any provision of this Agreement shall be held to be unenforceable, such provision shall be enforced to the greatest possible extent, with the other provisions of this Agreement to remain in full force and effect.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Entire Agreement}{\fs22 . This Agreement represents the entire agreement between the parties, and supersedes any oral or written communications, proposals or prior agreements between the parties or any dealers, distributors, agents or employees.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par \sect }\sectd \sbknone\linex0\headery1440\footery288\sectdefaultcl \pard\plain \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul U.S. Government Restricted Rights}{\fs22 . Each of the SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING MATERIALS is provided with RESTRICTED RIGHTS (as found in 48 C.F.R. '52.227-7013). This provision only applies if the U.S. Government or any of its entities obtains the SOFTWARE or DEMO PRODUCTS either directly or indirectly. Owner created the SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING MATERIALS exclusively with private funds. Additionally, information contained in the SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING MATERIALS is a trade secret of Owner for all purposes of the Freedom of Information Act or otherwise. Furthermore, the SOFTWARE and the DEMO PRODUCTS are \ldblquote commercial computer software\rdblquote subject to limited use as set forth in any contract that may be entered into between the seller and the governmental entity. Owner owns, in all respects, the proprietary information and proprietary data found in the SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING MATERIALS.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 U.S. DEPARTMENT OF DEFENSE PERSONNEL. Owner only sells this SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING MATERIALS with \ldblquote Restricted Rights\rdblquote as defined in DFARS 52.227-7013 (also found at 48 C.F.R. '252.227-7013). Any U.S. Government use, duplication, or disclosure is subject to the restrictions including, but not limited to those found in the Rights in Technological Data clause at DFARS 52.227-7013 (48 C.F.R. '252.227-7013) that may be amended from time to time.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 NON-DEPARTMENT OF DEFENSE PERSONNEL. Other governmental personnel are on notice through this Agreement that any use of the SOFTWARE, DEMO PRODUCTS and/or the ACCOMPANYING MATERIALS is subject to similar limitations as those stated above, including but not limited to, those stated in Commercial Computer Software -- Restricted Rights found in 48 C.F.R. '52.227-19, that may also be amended from time to time. Manufacturer is Owner at the location listed below.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul U.S. Export Laws Prohibitions}{\fs22 . By downloading, installing or otherwise using the SOFTWARE, DEMO PRODUCTS and/or ACCOMPANYING MATERIALS, You also agree and confirm that the SOFTWARE, DEMO PRODUCTS and/or ACCOMPANYING MATERIALS and any of the SOFTWARE\rquote s or DEMO PRODUCTS\rquote direct products are not being and will not be transported, exported or re-exported (directly or indirectly through the Internet or otherwise) into (or to a national or resident of) any country forbidden to receive such SOFTWARE, DEMO PRODUCTS and/or ACCOMPANYING MATERIALS by any U.S. export laws or accompanying regulations or otherwise violate such laws or regulations, that may be amended from time to time. You also agree and confirm that the SOFTWARE, DEMO PRODUCTS and ACCOMPANYING MATERIALS will not be used for any purpose that may be restricted by the same laws and regulations.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Termination}{\fs22 . This Agreement is valid until terminated. This Agreement ceases automatically (without any form of notice) if You do not comply with any Agreement provision. You can also end this Agreement by destroying the SOFTWARE and ACCOMPANYING MATERIALS or DEMO PRODUCTS, as the case may be, and all copies and reproductions of the SOFTWARE and ACCOMPANYING MATERIALS or DEMO PRODUCTS, as the case may be, and deleting and permanently purging the SOFTWARE or DEMO PRODUCTS, as the case may be, from any client server or computer on which it has been installed.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Program Transfer}{\fs22 . You may permanently transfer all of Your rights under this Agreement, provided that the recipient agrees to all of the terms of this Agreement, and You agree to transfer all ACCOMPANYING MATERIALS and related documents and components and, if applicable, remove the SOFTWARE from Your computer prior thereto. With respect to the SOFTWARE and the ACCOMPANYING MATERIALS, transferring the SOFTWARE automatically terminates Your license under this Agreement.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par \sect }\sectd \sbknone\linex0\headery1440\footery288\sectdefaultcl \pard\plain \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Equitable Remedies.}{\fs22 You hereby agree that if the terms of this Agreement are not specifically enforced, Owner will be irreparably damaged, and therefore You agree that Owner shall be entitled, without bond, other security, proof of damages, to appropriate equitable remedies with respect to any breach(es) of this Agreement, in addition to any other available remedies.
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par }\pard \qj\fi720\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22\ul Owner.}{\fs22 If You have any questions regarding this Agreement, the enclosed materials, or otherwise, please contact in writing:
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par
\par }\pard \qj\li1440\nowidctlpar\widctlpar\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 Ritual Entertainment
\par Attn: Customer Service\tab \tab \tab \tab \tab
\par }\pard \qj\fi1440\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22 2019 North Lamar Street, Suite 220\tab \tab \tab \tab
\par Dallas, Texas 75202-1744
\par
\par Fax: (214) 871-7390\tab \tab \tab \tab \tab
\par
\par E-mail: legal@ritual.com\tab \tab \tab
\par }\pard \qj\nowidctlpar\widctlpar\tx0\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\adjustright {\fs22
\par
\par
\par
\par }{\b\fs22 Sin}{\fs22 , }{\b\fs22 Ritual }{\fs22 and}{\b\fs22 Ritual Entertainment }{\fs22 are trademarks of Ritual Entertainment, Inc.}{\b\fs22
\par }{\fs22 Copyright © 1998 Ritual Entertainment, Inc. All Rights Reserved.
\par
\par }{\b\fs22 Microsoft }{\fs22 and}{\b\fs22 Windows 95, Windows 98 }{\fs22 and}{\b\fs22 Windows NT}{\fs22 are registered trademarks of Microsoft Corporation. All other trademarks and trade names are properties of their respective owners.
\par
\par U.S. Government Restricted Rights
\par Manufactured in the U.S.A.}{
\par }}

359
license.txt Normal file
View File

@ -0,0 +1,359 @@
ATTENTION
Here is a brief summary of certain of the terms and conditions in our Limited
Software Warranty and License Agreement. You must read the full text of the
agreement before using this product so that You understand all of the terms
and conditions of our agreement regarding this product.
WHAT IS OKAY FOR YOU TO DO:
$ Playing and enjoying the shareware and/or registered/full retail
version of the game, demo and/or level editor.
$ Setting up a shareware, demo, and/or registered/full retail version
based server on a not-for-profit and non-commercially exploited basis.
$ Playing the shareware, demo, and/or registered/full retail version of
the game and/or setting up a registered/full retail version of the game using
user-developed levels on a not-for-profit and non-commercially exploited
bases.
WHAT IS NOT OKAY FOR YOU TO DO:
$ You cannot sell or otherwise commercially exploit or utilize the
shareware, registered/full retail version, demo or level editor in any way or
sell user-developed levels and/or tools.
$ Commercially exploiting or otherwise utilizing any copyrighted and/or
trademarked property of Ritual Entertainment or any other party contained in
or associated with the shareware, demo, level editor or registered/full retail
version, demo, single player game and/or level editor, including without
limitation game names, logos, graphics, characters, etc.
LIMITED SOFTWARE WARRANTY AND LICENSE AGREEMENT
This LIMITED SOFTWARE WARRANTY AND LICENSE AGREEMENT (this "Agreement"),
including the Limited Warranty and other special provisions, is a legal
agreement between You (either an individual or an entity) and Ritual
Entertainment, Inc., a Texas corporation (the "Owner"), regarding this
software product and the materials contained therein and related thereto. Your
act of downloading, installing and/or otherwise using the software constitutes
Your agreement to be bound by the terms of this Agreement. If You do not agree
to the terms of this Agreement cease loading or installing this product and,
if applicable, promptly return the software packaging and the accompanying
materials (including any hardware, manuals, other written materials and
packaging) to the place You obtained them, along with Your receipt, for a full
refund.
Grant of Limited Non-Exclusive License. (A) In the event that You are
currently encountering this Agreement in conjunction with or as a result of
Your downloading or otherwise installing the SOFTWARE (as defined herein),
this Agreement permits You to use one (1) copy of the software program(s), in
executable or object code form only, contained in the registered/full retail
version of the game program entitled SiN, as contained in the disk(s) making
up all or part of the registered/full retail software product, including
without limitation the data files, images, level editors, death match levels,
charters and screen displays (the "SOFTWARE"), included in this download for
Your personal use on a single home or portable computer. This license also
permits You to use the SOFTWARE's level editor to create new game levels,
weapons, characters and/or entities for non-commercial personal use, and to
non-commercially distribute such game levels, weapons, characters, and/or
entities to personal acquaintances for non-commercial use via the Internet
pursuant to subparagraph (C) below. This license does NOT authorize You to
sell, lease or otherwise profit from or commercially distribute the SOFTWARE
(see "Restrictions" below). The SOFTWARE is in "use" on a computer when it is
loaded into temporary memory (i.e., RAM) or installed into the permanent
memory (e.g., hard disk, CD-ROM, or other storage device) of that computer.
Installation on a network server is strictly prohibited, except under a
special and separate network license obtained from Owner; this Agreement shall
not serve as such necessary special network license. Installation on a network
server constitutes "use" that must comply with the terms of this Agreement.
This license is not a sale of the original SOFTWARE or any copy thereof.
(B) In the event that You are currently encountering this Agreement in
conjunction with or as a result of Your downloading or otherwise installing a
DEMO PRODUCT (as defined herein), this Agreement permits You to use the
software program(s) included in and received solely as a result of the loaded
or otherwise installed version of the demo, free standing level editor and/or
shareware version of the game entitled Sin, as the case may be, for Your
personal use (each such item referred to herein, individually as a "DEMO
PRODUCT" and collectively as the "DEMO PRODUCTS"). This license also permits
You to use the level editor, as contained in and received solely as a result
of the downloading or other installation or utilization of such DEMO PRODUCT,
to create new game levels, weapons, characters and/or entities for
non-commercial personal use, and to non-commercially distribute such games
levels, weapons, characters, and/or entities to personal acquaintances for
non-commercial use via the Internet pursuant to subparagraph (C) below. This
license does NOT authorize You to sell, lease or otherwise profit from or
commercially exploit a DEMO PRODUCT (see "Restrictions" below). A DEMO PRODUCT
is in "use" on a computer when it is loaded into temporary memory (i.e., RAM)
or installed into the permanent memory (e.g., hard disk, CD-ROM, or other
storage device) of that computer or accessed via the Internet. Installation of
any DEMO PRODUCTS on a network server for profit or other commercial benefit
to You or any other person is strictly prohibited, except under a special and
separate network license obtained from Owner; this Agreement shall not serve
as such necessary special network license. Installation on a network server
constitutes "use" that must comply with the terms of this Agreement. This
license is not a sale of the original DEMO PRODUCTS or any copy thereof.
(C) Subject to the terms and conditions of this Agreement, Owner grants to
You the non-exclusive and limited right to create additional levels (the "USER
LEVELS") which are operable with the SOFTWARE or DEMO PRODUCT. You may include
within the USER LEVELS certain textures and other images (the "Owner Images")
from the SOFTWARE or DEMO PRODUCT, as the case may be. You agree that the USER
LEVELS will not be shipped, transferred or exported into any country in
violation of the U.S. Export Administration Act (or any other law governing
such matters) by You or anyone at Your direction and that You will not utilize
and will not authorize anyone to utilize, in any other manner, the USER LEVELS
in violation of any applicable law. The USER LEVELS may not be downloaded or
otherwise exported or re-exported into (or to a national or resident of) any
country to which the United States has embargoed goods or to anyone or unto
any country who/which are prohibited by applicable law, from receiving such
property. You shall not rent, sell, lease, lend, offer on a pay-per- play
basis or otherwise commercially exploit or commercially distribute any USER
LEVELS. You are only permitted to distribute for free, without any cost or
charge, the USER LEVELS to other end-users. As noted below, in the event You
commercially distribute or commercially exploit any USER LEVELS or commit any
other breach of this Agreement, Your license, as granted in this Agreement,
shall automatically terminate, without notice. IN ADDITION TO YOUR
INDEMNIFICATION OBLIGATIONS AS SET FORTH BELOW, YOU HEREBY AGREE TO INDEMNIFY,
DEFEND AND HOLD HARMLESS OWNER AND OWNER'S RESPECTIVE OFFICERS, EMPLOYEES,
DIRECTORS, AGENTS, LICENSEES (EXCLUDING YOU), SUBLICENSEES (EXCLUDING YOU),
SUCCESSORS AND ASSIGNS FROM AND AGAINST ANY AND ALL DIRECT AND/OR INDIRECT
LOSSES, LAWSUITS, DAMAGES, CAUSES OF ACTIONS AND CLAIMS RELATING TO AND/OR
ARISING FROM THE USER LEVELS AND/OR THE DISTRIBUTION OR OTHER USE OF ANY USER
LEVELS.
Intellectual Property Ownership. Owner retains all right, title and interest
to the SOFTWARE and/or DEMO PRODUCTS and any accompanying instructions or
other documentation (collectively, the "ACCOMPANYING MATERIALS"), including,
but not limited to, all copyrights, trademarks, trade secrets, trade names,
proprietary rights, patents, titles, computer codes, audiovisual effects,
themes, characters, character names, stories, dialog, settings, artwork,
sounds effects, musical works, and moral rights. The SOFTWARE, DEMO PRODUCTS
and ACCOMPANYING MATERIALS are protected by United States copyright law and
applicable copyright laws and treaties throughout the World. All rights are
reserved. The SOFTWARE and ACCOMPANYING MATERIALS may not be copied or
reproduced in any manner or medium, in whole or in part, without prior written
consent from Owner except as specifically provided under "Grant of Limited
Non- Exclusive License" above. Any persons copying or reproducing all or any
portion of the SOFTWARE or ACCOMPANYING MATERIALS, except as specifically
provided under "Grant of Limited Non-Exclusive License" above, in any manner
or medium, will be willfully violating the copyright laws and may be subject
to civil or criminal penalties.
SOFTWARE Backup or Archiving. After You install the SOFTWARE into the
permanent memory of a computer, You may keep and use the original disk(s)
and/or CD-ROM (the "Storage Media") only for backup or archival purposes. You
are expressly prohibited from transmitting the SOFTWARE or ACCOMPANYING
MATERIALS electronically or otherwise over the Internet or through any other
media or to any other party.
Restrictions. Other than as provided specifically in this Agreement, You are
not permitted to copy or otherwise reproduce the SOFTWARE or ACCOMPANYING
MATERIALS; modify or prepare derivative copies based on the SOFTWARE or
ACCOMPANYING MATERIALS; distribute copies of the SOFTWARE or ACCOMPANYING
MATERIALS by sale or other transfer of ownership; rent, lease, or lend the
SOFTWARE, DEMO PRODUCTS or ACCOMPANYING MATERIALS; or to display the SOFTWARE
or ACCOMPANYING MATERIALS publicly. You are expressly prohibited from selling,
leasing, charging for access to, or otherwise using for profit or commercially
exploiting any USER LEVELS, level packs, add-on packs, sequels, characters or
other components or items created by utilization of the SOFTWARE's or DEMO
PRODUCT's level editor and/or based upon or related to the SOFTWARE, DEMO
PRODUCT or ACCOMPANYING MATERIALS. YOU ARE NOT PERMITTED TO REVERSE ENGINEER,
DECOMPILE OR DISASSEMBLE THE SOFTWARE OR ANY DEMO PRODUCT IN ANY WAY. Any
copying or distribution of the SOFTWARE or ACCOMPANYING MATERIALS not
specifically allowed in this Agreement is a violation of this Agreement. You
may create USER LEVELS for the SOFTWARE or any DEMO PRODUCT; provided,
however, that such USER LEVELS are created in accordance with the
non-exclusive license set forth above and no USER LEVELS may be sold or
otherwise commercially exploited, whether by You or by any other person or
entity, but You may exchange USER LEVELS at no charge with other end-users.
Limited Warranty and Warranty Disclaimers.
LIMITED WARRANTY. Owner warrants that the original Storage Media holding the
SOFTWARE is free from defects in materials and workmanship under normal use
and service for a period of ninety (90) days from the date that You downloaded
the SOFTWARE. If for any reason You find defects in the Storage Media, or if
You are unable to install the SOFTWARE on Your home or portable computer, You
may return the SOFTWARE, ACCOMPANYING MATERIALS and all packaging related
thereto to the place you purchased such products for a full refund or
replacement thereof. This limited warranty does not apply if You have damaged
the SOFTWARE by accident or abuse.
CUSTOMER'S REMEDY. Your exclusive remedies, and the entire liability of Owner,
shall be replacement of the SOFTWARE or DEMO PRODUCT, as the case may be. By
downloading, installing and/or otherwise using the SOFTWARE, DEMO PRODUCT or
ACCOMPANYING MATERIALS, as the case may be, You hereby agree to waive any and
all other remedies You may have at law or in equity. Any such remedies You may
not waive as a matter of public policy, You hereby assign, or shall assign as
they become available, over to Owner.
NOTWITHSTANDING ANYTHING TO THE CONTRARY IN THIS AGREEMENT, WITH RESPECT TO
THE DEMO PRODUCTS, OWNER MAKES NO REPRESENTATIONS OR WARRANTIES (EXPRESS,
IMPLIED OR OTHERWISE), INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND/OR NON-INFRINGEMENT. THE
DEMO PRODUCTS ARE PROVIDED GRATUITOUSLY TO YOU "AS IS" AND YOU TAKE, INSTALL,
LOAD OR OTHERWISE USE SUCH DEMO PRODUCTS AT YOUR OWN RISK. OWNER HAS NO
LIABILITIES ARISING FROM OR RELATED TO YOUR USE OF ANY DEMO PRODUCTS.
WARRANTY DISCLAIMERS. EXCEPT FOR THE EXPRESS LIMITED WARRANTY SET FORTH ABOVE,
OWNER MAKES NO WARRANTIES, EXPRESS OR IMPLIED, ORAL OR WRITTEN, CONCERNING THE
PRODUCTS REFERENCED HEREIN OR ANY COMPONENT PART THEREOF. ANY IMPLIED
WARRANTIES THAT MAY BE IMPOSED BY APPLICABLE LAW ARE LIMITED IN ALL RESPECTS
TO THE FULLEST EXTENT ALLOWED AND TO THE DURATION OF THE LIMITED WARRANTY.
OWNER DOES NOT REPRESENT, WARRANT OR GUARANTEE THE QUALITY OR THE PERFORMANCE
OF THE SOFTWARE, DEMO PRODUCTS OR ACCOMPANYING MATERIALS OTHER THAN AS SET
FORTH IN THE ABOVE LIMITED WARRANTY. OWNER ALSO DOES NOT REPRESENT, WARRANT OR
GUARANTEE THAT THE SOFTWARE, DEMO PRODUCTS OR ACCOMPANYING MATERIALS
CAPABILITIES WILL MEET YOUR NEEDS OR THAT THE SOFTWARE OR DEMO PRODUCTS WILL
CONTINUOUSLY OPERATE, BE ERROR FREE, OR THAT PROBLEMS WILL BE CORRECTED. OWNER
DOES NOT REPRESENT THAT THE SOFTWARE OR DEMO PRODUCTS WILL OPERATE IN A
MULTI-USER ENVIRONMENT.
NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY OWNER, ITS DEALERS,
DISTRIBUTORS, DIRECTORS, OFFICERS, EMPLOYEES, AGENTS, CONTRACTORS OR
AFFILIATES SHALL CREATE ANY OTHER WARRANTY OR EXTEND OR EXPAND THE SCOPE OF
THIS WARRANTY. YOU MAY NOT RELY ON ANY SUCH INFORMATION OR ADVICE.
SOME STATES DO NOT ALLOW LIMITATIONS ON HOW LONG AN IMPLIED WARRANTY LASTS, SO
THE ABOVE LIMITATION MAY NOT APPLY TO YOU. THIS LIMITED WARRANTY GIVES YOU
SPECIFIC LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH MAY VARY FROM
STATE TO STATE.
LIABILITY LIMITATION. To the maximum extent permitted by applicable law, and
regardless of whether any remedy set forth herein fails of its essential
purpose,
IN NO EVENT WILL OWNER, ITS DIRECTORS, OFFICERS, EMPLOYEES, AGENTS, LICENSES
(EXCLUDING YOU), SUBLICENSEES (EXCLUDING YOU) OR AFFILIATES NOR ANYONE ELSE
INVOLVED IN THE DEVELOPMENT, MANUFACTURE OR DISTRIBUTION OF THE SOFTWARE, THE
DEMO PRODUCTS, THE ACCOMPANYING MATERIALS OR THE USER LEVELS (OTHER THAN YOU)
BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, DIRECT OR
INDIRECT; INCIDENTAL; OR CONSEQUENTIAL DAMAGES FOR PERSONAL INJURY, PERSONAL
PROPERTY, LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
INFORMATION, LOSS OF TEXT OR DATA STORED IN OR USED WITH SUCH PRODUCT
INCLUDING THE COST OF RECOVERING OR REPRODUCING THE TEXT OR DATA, OR ANY OTHER
PECUNIARY LOSS, ARISING FROM OR OUT OF THE USE OR INABILITY TO USE THIS
SOFTWARE, THE DEMO PRODUCTS OR ANY USER LEVELS. THIS LIABILITY LIMITATION
APPLIES EVEN IF YOU OR ANYONE ELSE HAS ADVISED OWNER OR ANY OF ITS AUTHORIZED
REPRESENTATIVES OF THE POSSIBILITY OF SUCH DAMAGES. EVEN IF SUCH IS CAUSED BY,
ARISES OUT OF OR RESULTS FROM THE ORDINARY, STRICT, SOLE OR CONTRIBUTORY
NEGLIGENCE OF OWNER OR ITS DIRECTORS, OFFICERS, EMPLOYEES, AGENTS, CONTRACTORS
OR AFFILIATES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF
INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATION OR EXCLUSION MAY
NOT APPLY TO YOU.
Product Support and Updates. This SOFTWARE is intended to be user-friendly and
limited product support is provided by Owner as specified in the ACCOMPANYING
MATERIALS.
Jurisdiction. TEXAS LAWS GOVERN THIS AGREEMENT, REGARDLESS OF SUCH STATE'S
CHOICE OF LAW PRINCIPLES, WITH A FORUM AND VENUE OF DALLAS COUNTY, TEXAS. This
Agreement may be modified only by a written instrument specifying the
modification and executed by both parties. In the event that any provision of
this Agreement shall be held to be unenforceable, such provision shall be
enforced to the greatest possible extent, with the other provisions of this
Agreement to remain in full force and effect.
Entire Agreement. This Agreement represents the entire agreement between the
parties, and supersedes any oral or written communications, proposals or prior
agreements between the parties or any dealers, distributors, agents or
employees.
U.S. Government Restricted Rights. Each of the SOFTWARE, DEMO PRODUCTS and the
ACCOMPANYING MATERIALS is provided with RESTRICTED RIGHTS (as found in 48
C.F.R. '52.227-7013). This provision only applies if the U.S. Government or
any of its entities obtains the SOFTWARE or DEMO PRODUCTS either directly or
indirectly. Owner created the SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING
MATERIALS exclusively with private funds. Additionally, information contained
in the SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING MATERIALS is a trade
secret of Owner for all purposes of the Freedom of Information Act or
otherwise. Furthermore, the SOFTWARE and the DEMO PRODUCTS are "commercial
computer software" subject to limited use as set forth in any contract that
may be entered into between the seller and the governmental entity. Owner
owns, in all respects, the proprietary information and proprietary data found
in the SOFTWARE, DEMO PRODUCTS and the ACCOMPANYING MATERIALS.
U.S. DEPARTMENT OF DEFENSE PERSONNEL. Owner only sells this SOFTWARE, DEMO
PRODUCTS and the ACCOMPANYING MATERIALS with "Restricted Rights" as defined in
DFARS 52.227-7013 (also found at 48 C.F.R. '252.227-7013). Any U.S. Government
use, duplication, or disclosure is subject to the restrictions including, but
not limited to those found in the Rights in Technological Data clause at DFARS
52.227-7013 (48 C.F.R. '252.227-7013) that may be amended from time to time.
NON-DEPARTMENT OF DEFENSE PERSONNEL. Other governmental personnel are on
notice through this Agreement that any use of the SOFTWARE, DEMO PRODUCTS
and/or the ACCOMPANYING MATERIALS is subject to similar limitations as those
stated above, including but not limited to, those stated in Commercial
Computer Software -- Restricted Rights found in 48 C.F.R. '52.227-19, that may
also be amended from time to time. Manufacturer is Owner at the location
listed below.
U.S. Export Laws Prohibitions. By downloading, installing or otherwise using
the SOFTWARE, DEMO PRODUCTS and/or ACCOMPANYING MATERIALS, You also agree and
confirm that the SOFTWARE, DEMO PRODUCTS and/or ACCOMPANYING MATERIALS and any
of the SOFTWARE's or DEMO PRODUCTS' direct products are not being and will not
be transported, exported or re-exported (directly or indirectly through the
Internet or otherwise) into (or to a national or resident of) any country
forbidden to receive such SOFTWARE, DEMO PRODUCTS and/or ACCOMPANYING
MATERIALS by any U.S. export laws or accompanying regulations or otherwise
violate such laws or regulations, that may be amended from time to time. You
also agree and confirm that the SOFTWARE, DEMO PRODUCTS and ACCOMPANYING
MATERIALS will not be used for any purpose that may be restricted by the same
laws and regulations.
Termination. This Agreement is valid until terminated. This Agreement ceases
automatically (without any form of notice) if You do not comply with any
Agreement provision. You can also end this Agreement by destroying the
SOFTWARE and ACCOMPANYING MATERIALS or DEMO PRODUCTS, as the case may be, and
all copies and reproductions of the SOFTWARE and ACCOMPANYING MATERIALS or
DEMO PRODUCTS, as the case may be, and deleting and permanently purging the
SOFTWARE or DEMO PRODUCTS, as the case may be, from any client server or
computer on which it has been installed.
Program Transfer. You may permanently transfer all of Your rights under this
Agreement, provided that the recipient agrees to all of the terms of this
Agreement, and You agree to transfer all ACCOMPANYING MATERIALS and related
documents and components and, if applicable, remove the SOFTWARE from Your
computer prior thereto. With respect to the SOFTWARE and the ACCOMPANYING
MATERIALS, transferring the SOFTWARE automatically terminates Your license
under this Agreement.
Equitable Remedies. You hereby agree that if the terms of this Agreement are
not specifically enforced, Owner will be irreparably damaged, and therefore
You agree that Owner shall be entitled, without bond, other security, proof of
damages, to appropriate equitable remedies with respect to any breach(es) of
this Agreement, in addition to any other available remedies.
Owner. If You have any questions regarding this Agreement, the enclosed
materials, or otherwise, please contact in writing:
Ritual Entertainment Attn: Customer Service 2019 North Lamar Street, Suite 220
Dallas, Texas 75202-1744
Fax: (214) 871-7390
E-mail: legal@ritual.com
Sin, Ritual and Ritual Entertainment are trademarks of Ritual Entertainment,
Inc. Copyright c 1998 Ritual Entertainment, Inc. All Rights Reserved.
Microsoft and Windows 95, Windows 98 and Windows NT are registered trademarks
of Microsoft Corporation. All other trademarks and trade names are properties
of their respective owners.
U.S. Government Restricted Rights Manufactured in the U.S.A.
Software License Agreement 7 08656 00001 CORP 209544.3

386
light.cpp Normal file
View File

@ -0,0 +1,386 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/light.cpp $
// $Revision:: 21 $
// $Author:: Aldie $
// $Date:: 10/09/98 8:58p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/light.cpp $
//
// 21 10/09/98 8:58p Aldie
// Lightstyle on lensflare from Lights
//
// 20 9/22/98 5:19p Markd
// Fixed lights not removing themselves
//
// 19 9/22/98 4:23p Markd
// Fixed some targetname stuff for lights, doors and scriptobjects
//
// 18 9/14/98 11:20a Jimdose
// Made Light process EV_Remove so that we have more edicts at startup
//
// 17 8/30/98 7:05p Markd
// lights don't respond to Touch.
//
// 16 8/29/98 7:46p Markd
// Don't set a light style if style is < 32
//
// 15 7/09/98 12:05a Jimdose
// made constructor post remove event instead of processing it
//
// 14 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 13 6/17/98 7:18p Markd
// Added on_style and off_style support
//
// 12 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 11 4/04/98 6:05p Jimdose
// Made response from EV_Trigger_ActivateTargets to EV_Trigger_Effect
//
// 10 3/27/98 9:47p Jimdose
// Fixed light so that it reacts to activate targets events
//
// 9 3/25/98 3:55p Jimdose
// fixed bug where lightramp wasn't responding to any events.
//
// 8 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 7 3/02/98 8:49p Jimdose
// Changed the classid parameter of CLASS_DECLARATION to a quoted string so
// that you could have a NULL classid.
//
// 6 3/02/98 5:41p Jimdose
// Created file
//
// DESCRIPTION:
// Classes for creating and controlling lights.
//
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
#include "light.h"
#include "scriptmaster.h"
CLASS_DECLARATION( Trigger, BaseLight, NULL );
Event EV_Light_TurnOn( "turnOn" );
Event EV_Light_TurnOff( "turnOff" );
Event EV_Light_SetLightStyle( "lightstyle" );
ResponseDef BaseLight::Responses[] =
{
{ &EV_Light_TurnOn, ( Response )Light::TurnOn },
{ &EV_Light_TurnOff, ( Response )Light::TurnOff },
{ &EV_Light_SetLightStyle, ( Response )Light::EventSetLightStyle },
{ &EV_Touch, NULL },
{ NULL, NULL }
};
BaseLight::BaseLight()
{
hideModel();
edict->svflags |= SVF_NOCLIENT;
setSolidType( SOLID_NOT );
style = G_GetIntArg( "style" );
on_style = G_GetStringArg( "onstyle", "m" );
off_style = G_GetStringArg( "offstyle", "a" );
respondto = TRIGGER_PLAYERS;
}
int BaseLight::GetStyle
(
void
)
{
return style;
}
void BaseLight::SetLightStyle
(
const char *stylestring
)
{
if ( style < 32 )
return;
lightstyle = stylestring;
gi.configstring( CS_LIGHTS + style, lightstyle.c_str() );
}
void BaseLight::EventSetLightStyle
(
Event *ev
)
{
SetLightStyle( ev->GetString( 1 ) );
}
void BaseLight::TurnOn
(
Event *ev
)
{
SetLightStyle( on_style.c_str() );
}
void BaseLight::TurnOff
(
Event *ev
)
{
SetLightStyle( off_style.c_str() );
}
/*****************************************************************************/
/*SINED light_ramp (0 .5 .8) (-8 -8 -8) (8 8 8) TOGGLE
Non-displayed light that ramps its intensity from one level to another when trigger.
time How many seconds the ramping will take (default 1.0)
startlevel Value between 0 and 2.0 (default 0)
endlevel Value between 0 and 2.0 (default 1.0)
"key" The item needed to activate this. (default nothing)
/*****************************************************************************/
CLASS_DECLARATION( BaseLight, LightRamp, "light_ramp" );
Event EV_RampLight( "ramplight" );
ResponseDef LightRamp::Responses[] =
{
{ &EV_Trigger_Effect, ( Response )LightRamp::StartRamp },
{ &EV_RampLight, ( Response )LightRamp::RampLight },
{ NULL, NULL }
};
void LightRamp::RampLight
(
Event *ev
)
{
char st[ 2 ];
currentlevel += rate;
if ( currentlevel >= maxlevel )
{
if ( !( spawnflags & 1 ) )
{
rate = 0;
}
currentlevel = maxlevel;
}
else if ( currentlevel <= minlevel )
{
if ( !( spawnflags & 1 ) )
{
rate = 0;
}
currentlevel = minlevel;
}
else
{
PostEvent( EV_RampLight, FRAMETIME );
}
st[ 0 ] = 'L';
st[ 1 ] = 'a' + ( int )( currentlevel * 12.5 );
st[ 1 ] = min( 'z', st[ 1 ] );
st[ 1 ] = max( 'a', st[ 1 ] );
st[ 2 ] = 0;
SetLightStyle( st );
}
void LightRamp::StartRamp
(
Event *ev
)
{
if ( rate )
{
rate = -rate;
CancelEventsOfType( EV_RampLight );
ProcessEvent( EV_RampLight );
}
ActivateTargets( ev );
}
LightRamp::LightRamp()
{
float startlevel;
float endlevel;
float time;
char st[ 2 ];
startlevel = G_GetFloatArg( "startlevel", 1.0 );
endlevel = G_GetFloatArg( "endlevel", 0 );
time = G_GetFloatArg( "time", 1.0 );
minlevel = min( startlevel, endlevel );
maxlevel = max( startlevel, endlevel );
minlevel = min( 2.0, minlevel );
minlevel = max( 0, minlevel );
maxlevel = min( 2.0, maxlevel );
maxlevel = max( 0, maxlevel );
rate = FRAMETIME * ( maxlevel - minlevel ) / time;
currentlevel = startlevel;
st[ 0 ] = 'a' + ( int )( currentlevel * 12.5 );
st[ 0 ] = min( 'z', st[ 0 ] );
st[ 0 ] = max( 'a', st[ 0 ] );
st[ 1 ] = 0;
SetLightStyle( st );
}
/*****************************************************************************/
/*SINED trigger_lightramp (0 1 0) (-8 -8 -8) (8 8 8) TOGGLE
Ramps light values on surface based light sources.
Set style to the identifier contained in groupname in the surfaces to control.
time How many seconds the ramping will take (default 1.0)
startlevel Value between 0 and 2.0 (default 0)
endlevel Value between 0 and 2.0 (default 1.0)
"key" The item needed to activate this. (default nothing)
Default style is 0.
/*****************************************************************************/
CLASS_DECLARATION( LightRamp, TriggerLightRamp, "trigger_lightramp" );
ResponseDef TriggerLightRamp::Responses[] =
{
{ NULL, NULL }
};
/*****************************************************************************/
/*SINED light (0 1 0) (-8 -8 -8) (8 8 8) START_OFF
Non-displayed light.
Default light value is 300.
Default style is 0.
If targeted, will toggle between on and off.
Default _cone value is 10 (used to set size of light for spotlights)
"on_style" light style to set to when "on" (default is "m")
"off_style" light style to set to when "off" (default is "a")
"key" The item needed to activate this. (default nothing)
/*****************************************************************************/
#define START_OFF 1
CLASS_DECLARATION( BaseLight, Light, "light" );
ResponseDef Light::Responses[] =
{
{ &EV_Trigger_Effect, ( Response )Light::ToggleLight },
{ NULL, NULL }
};
void Light::ToggleLight
(
Event *ev
)
{
if ( style >= 32 )
{
if ( spawnflags & START_OFF )
{
ProcessEvent( EV_Light_TurnOn );
spawnflags &= ~START_OFF;
}
else
{
ProcessEvent( EV_Light_TurnOff );
spawnflags |= START_OFF;
}
}
ActivateTargets( ev );
}
Light::Light()
{
const char * tname;
tname = TargetName();
if ( !tname || !tname[ 0 ] )
{
const char *classname;
classname = G_GetSpawnArg( "classname" );
if ( classname && !strcmp( classname, "light" ) )
{
ProcessEvent( EV_Remove );
}
return;
}
if ( style >= 32 )
{
if ( spawnflags & START_OFF )
{
SetLightStyle( off_style.c_str() );
}
else
{
SetLightStyle( on_style.c_str() );
}
}
}
/*****************************************************************************/
/*SINED trigger_SetLightStyle (0 1 0) (-8 -8 -8) (8 8 8) START_OFF
Used for controlling surface based light sources.
Set style to the identifier contained in groupname in the surfaces to control.
Default style is 0.
If targeted, will toggle between on and off.
"on_style" light style to set to when "on" (default is "m")
"off_style" light style to set to when "off" (default is "a")
"key" The item needed to activate this. (default nothing)
/*****************************************************************************/
CLASS_DECLARATION( Light, TriggerLightStyle, "trigger_SetLightStyle" );
ResponseDef TriggerLightStyle::Responses[] =
{
{ NULL, NULL }
};

165
light.h Normal file
View File

@ -0,0 +1,165 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/light.h $
// $Revision:: 12 $
// $Author:: Aldie $
// $Date:: 10/09/98 9:01p $
//
// 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/light.h $
//
// 12 10/09/98 9:01p Aldie
// Lightstyle on lensflare from Lights
//
// 11 9/28/98 9:12p Markd
// Put in archive and unarchive functions
//
// 10 6/17/98 7:18p Markd
// added off_style and on_style
//
// 9 4/30/98 9:24p Jimdose
// Changed use of string to str class
//
// 8 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 7 3/02/98 8:49p Jimdose
// Changed CLASS_PROTOTYPE to only take the classname
//
// 6 3/02/98 5:41p Jimdose
// Created file
//
// DESCRIPTION:
// Classes for creating and controlling lights.
//
#ifndef __LIGHT_H__
#define __LIGHT_H__
#include "g_local.h"
#include "entity.h"
#include "trigger.h"
extern Event EV_Light_TurnOn;
extern Event EV_Light_TurnOff;
extern Event EV_Light_SetLightStyle;
class EXPORT_FROM_DLL BaseLight : public Trigger
{
protected:
int style;
str lightstyle;
str on_style;
str off_style;
public:
CLASS_PROTOTYPE( BaseLight );
BaseLight();
void SetLightStyle( const char *stylestring );
void EventSetLightStyle( Event *ev );
int GetStyle( void );
void TurnOn( Event *ev );
void TurnOff( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void BaseLight::Archive
(
Archiver &arc
)
{
Trigger::Archive( arc );
arc.WriteInteger( style );
arc.WriteString( lightstyle );
arc.WriteString( on_style );
arc.WriteString( off_style );
}
inline EXPORT_FROM_DLL void BaseLight::Unarchive
(
Archiver &arc
)
{
Trigger::Unarchive( arc );
arc.ReadInteger( &style );
arc.ReadString( &lightstyle );
arc.ReadString( &on_style );
arc.ReadString( &off_style );
}
class EXPORT_FROM_DLL LightRamp : public BaseLight
{
protected:
float minlevel;
float maxlevel;
float currentlevel;
float rate;
public:
CLASS_PROTOTYPE( LightRamp );
LightRamp();
void RampLight( Event *ev );
void StartRamp( Event *ev );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void LightRamp::Archive
(
Archiver &arc
)
{
BaseLight::Archive( arc );
arc.WriteFloat( minlevel );
arc.WriteFloat( maxlevel );
arc.WriteFloat( currentlevel );
arc.WriteFloat( rate );
}
inline EXPORT_FROM_DLL void LightRamp::Unarchive
(
Archiver &arc
)
{
BaseLight::Unarchive( arc );
arc.ReadFloat( &minlevel );
arc.ReadFloat( &maxlevel );
arc.ReadFloat( &currentlevel );
arc.ReadFloat( &rate );
}
class EXPORT_FROM_DLL TriggerLightRamp : public LightRamp
{
public:
CLASS_PROTOTYPE( TriggerLightRamp );
};
class EXPORT_FROM_DLL Light : public BaseLight
{
public:
CLASS_PROTOTYPE( Light );
void ToggleLight( Event *ev );
Light();
};
class EXPORT_FROM_DLL TriggerLightStyle : public Light
{
public:
CLASS_PROTOTYPE( TriggerLightStyle );
};
#endif /* light.h */

118
linklist.h Normal file
View File

@ -0,0 +1,118 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Sin/LINKLIST.H $
// $Revision:: 2 $
// $Author:: Jimdose $
// $Date:: 9/26/97 7:05p $
//
// 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.
//
// $Log:: /Sin/LINKLIST.H $
//
// 2 9/26/97 7:05p Jimdose
// Added standard Ritual Headers
//
// DESCRIPTION:
//
#ifndef __linklist_h
#define __linklist_h
#ifdef __cplusplus
extern "C" {
#endif
#define NewNode(type) ((type *)Z_Malloc(sizeof(type)))
#define LL_New(rootnode,type,next,prev) \
{ \
(rootnode) = NewNode(type); \
(rootnode)->prev = (rootnode); \
(rootnode)->next = (rootnode); \
}
#define LL_Add(rootnode, newnode, next, prev) \
{ \
(newnode)->next = (rootnode); \
(newnode)->prev = (rootnode)->prev; \
(rootnode)->prev->next = (newnode); \
(rootnode)->prev = (newnode); \
}
//MED
#define LL_AddFirst(rootnode, newnode, next, prev) \
{ \
(newnode)->prev = (rootnode); \
(newnode)->next = (rootnode)->next; \
(rootnode)->next->prev = (newnode); \
(rootnode)->next = (newnode); \
}
#define LL_Transfer(oldroot,newroot,next,prev) \
{ \
if (oldroot->prev != oldroot) \
{ \
oldroot->prev->next = newroot; \
oldroot->next->prev = newroot->prev; \
newroot->prev->next = oldroot->next; \
newroot->prev = oldroot->prev; \
oldroot->next = oldroot; \
oldroot->prev = oldroot; \
} \
}
#define LL_Reverse(root,type,next,prev) \
{ \
type *newend,*trav,*tprev; \
\
newend = root->next; \
for(trav = root->prev; trav != newend; trav = tprev) \
{ \
tprev = trav->prev; \
LL_Move(trav,newend,next,prev); \
} \
}
#define LL_Remove(node,next,prev) \
{ \
node->prev->next = node->next; \
node->next->prev = node->prev; \
node->next = node; \
node->prev = node; \
}
#define LL_SortedInsertion(rootnode,insertnode,next,prev,type,sortparm) \
{ \
type *hoya; \
\
hoya = rootnode->next; \
while((hoya != rootnode) && (insertnode->sortparm > hoya->sortparm)) \
{ \
hoya = hoya->next; \
} \
LL_Add(hoya,insertnode,next,prev); \
}
#define LL_Move(node,newroot,next,prev) \
{ \
LL_Remove(node,next,prev); \
LL_Add(newroot,node,next,prev); \
}
#define LL_Empty(list,next,prev) \
( \
((list)->next == (list)) && \
((list)->prev == (list)) \
)
#define LL_Free(list) Z_Free(list)
#define LL_Reset(list,next,prev) (list)->next = (list)->prev = (list)
#ifdef __cplusplus
};
#endif
#endif

1955
listener.cpp Normal file

File diff suppressed because it is too large Load Diff

662
listener.h Normal file
View File

@ -0,0 +1,662 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/listener.h $
// $Revision:: 30 $
// $Author:: Jimdose $
// $Date:: 10/26/98 4:27p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/listener.h $
//
// 30 10/26/98 4:27p Jimdose
// Sped up ValidEvent
// Added FindEvent( const char * )
//
// 29 10/25/98 11:53p Jimdose
// added EXPORT_TEMPLATE
//
// 28 10/18/98 8:45p Jimdose
// changed commandList to a str * container
//
// 27 10/18/98 3:21a Jimdose
// made the assert in getName only fire if eventnum is non-zero
//
// 26 10/17/98 11:33p Jimdose
// Added the event name to Event to help with debugging
//
// 25 10/08/98 12:39a Jimdose
// Added event archiving functions
//
// 24 9/25/98 4:41p Markd
// Changed Find functions to return an Event rather than a &Event, made the
// Exists function
//
// 23 9/24/98 1:45a Jimdose
// Made Event a subclass of Class
//
// 22 9/19/98 4:33p Jimdose
// Added ListCommands and EV_HIDE
//
// 21 9/02/98 7:48p Aldie
// Moved template around
//
// 20 8/27/98 9:04p Jimdose
// Moved a lot of small functions to the header as inline
//
// 19 8/01/98 7:58p Jimdose
// Fixed bug with cheats in dm
//
// 18 7/31/98 8:10p Jimdose
// Script commands now include flags to indicate cheats and console commands
//
// 17 7/31/98 4:19p Jimdose
// Added DepthOfEvent
//
// 16 7/20/98 5:08p Jimdose
// Added ProcessPendingEvents
//
// 15 7/10/98 10:00p Jimdose
// Made remove script command post remove event so that it doesn't cause
// problems during event callbacks which trigger the script
//
// 14 6/30/98 6:05p Jimdose
// Added IsVectorAt, IsEntityAt, and IsNumericAt for doing type checking on
// args
// Changed format for storing vectors to make it easy to identify
//
// 13 6/27/98 9:18p Jimdose
// Made lookup for event responses for faster processing
//
// 12 6/18/98 8:48p Jimdose
// Added better event error handling
// Added source info to events
//
// 11 5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
//
// 10 5/24/98 4:48p Jimdose
// Made char *'s const
//
// 9 5/24/98 1:06a Jimdose
// added const to various char *s
//
// 8 5/08/98 2:51p Jimdose
// Moved archiving functions up to Class
//
// 7 5/07/98 10:42p Jimdose
// Added archive and unarchive
//
// 6 4/30/98 9:24p Jimdose
// Changed use of string to str class
//
// 5 4/02/98 4:47p Jimdose
// Added initCommandList
//
// 4 3/24/98 5:03p Jimdose
// Changed order of prototypes
//
// 3 3/23/98 1:33p Jimdose
// Revamped event and command system
//
// 2 3/04/98 1:01p Jimdose
// Created file
//
// DESCRIPTION:
//
#include "g_local.h"
#include "class.h"
#include "container.h"
#ifndef __LISTENER_H__
#define __LISTENER_H__
class Entity;
class ScriptVariable;
typedef enum
{
EV_FROM_CODE,
EV_FROM_CONSOLE,
EV_FROM_SCRIPT
} eventsource_t;
// Event flags
#define EV_CONSOLE 1 // Allow entry from console
#define EV_CHEAT 2 // Only allow entry from console if cheats are enabled
#define EV_HIDE 4 // Hide from eventlist
#define MAX_EVENT_USE ( ( 1 << 8 ) - 1 )
class ScriptThread;
class Archiver;
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<str *>;
#endif
class EXPORT_FROM_DLL Event : public Class
{
private:
typedef struct EventInfo
{
unsigned inuse : 8; // must change MAX_EVENT_USE to reflect maximum number stored here
unsigned source : 2;
unsigned flags : 2;
unsigned linenumber : 20; // linenumber does double duty in the case of the console commands
};
int eventnum;
EventInfo info;
const char *name;
Container<str> *data;
int threadnum;
Event( int num );
static void initCommandList( void );
friend class Listener;
friend void EXPORT_FROM_DLL G_ProcessPendingEvents( void );
friend void EXPORT_FROM_DLL G_ClearEventList( void );
friend void EXPORT_FROM_DLL G_InitEvents( void );
friend void EXPORT_FROM_DLL G_ArchiveEvents( Archiver &arc );
friend void EXPORT_FROM_DLL G_UnarchiveEvents( Archiver &arc );
static Container<str *> *Event::commandList;
static Container<int> *Event::flagList;
static Container<int> *Event::sortedList;
static qboolean Event::dirtylist;
static int compareEvents( const void *arg1, const void *arg2 );
static void SortEventList( void );
static int FindEvent( const char *name );
static int FindEvent( str &name );
public:
CLASS_PROTOTYPE( Event );
static int NumEventCommands( void );
static void ListCommands( const char *mask = NULL );
Event();
Event( Event &ev );
Event( Event *ev );
Event( const char *command, int flags = -1 );
Event( str &command, int flags = -1 );
~Event();
str getName( void );
void SetSource( eventsource_t source );
void SetLineNumber( int linenumber );
void SetConsoleEdict( edict_t *consoleedict );
void SetThread( ScriptThread *thread );
eventsource_t GetSource( void );
ScriptThread *GetThread( void );
edict_t *GetConsoleEdict( void );
int GetLineNumber( void );
void Error( const char *fmt, ... );
static Event Find( const char *command );
static qboolean Exists( const char *command );
static Event Find( str &command );
Event& printInfo(void);
operator int();
operator const char *();
int NumArgs( void );
qboolean IsVectorAt( int pos );
qboolean IsEntityAt( int pos );
qboolean IsNumericAt( int pos );
const char *GetToken( int pos );
const char *GetString( int pos );
int GetInteger( int pos );
double GetDouble( int pos );
float GetFloat( int pos );
Vector GetVector( int pos );
Entity *GetEntity( int pos );
ScriptVariable *GetVariable( int pos );
void AddToken( const char *text );
void AddTokens( int argc, const char **argv );
void AddString( const char *text );
void AddString( str &text );
void AddInteger( int val );
void AddDouble( double val );
void AddFloat( float val );
void AddVector( Vector &vec );
void AddEntity( Entity *ent );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
extern Event NullEvent;
extern Event EV_Remove;
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<Response>;
#endif
class Listener;
class EXPORT_FROM_DLL Listener : public Class
{
private:
void FloatVarEvent( Event *e );
void IntVarEvent( Event *e );
void StringVarEvent( Event *e );
void CharPtrVarEvent( Event *e );
void VectorVarEvent( Event *e );
void ScriptRemove( Event *e );
protected:
void FloatVar( Event &e, float *var, float defaultvalue = 0 );
void IntVar( Event &e, int *var, float defaultvalue = 0 );
void StringVar( Event &e, str *var, const char *defaultvalue = "" );
void StringVar( Event &e, char **var, const char *defaultvalue = "" );
void VectorVar( Event &e, Vector *var, Vector defaultvalue = Vector( 0, 0, 0 ) );
qboolean CheckEventFlags( Event *event );
public:
CLASS_PROTOTYPE( Listener );
~Listener();
void Remove( Event *e );
qboolean ValidEvent( Event &e );
qboolean ValidEvent( const char *name );
qboolean EventPending( Event &ev );
qboolean ProcessEvent( Event *event );
qboolean ProcessEvent( Event &event );
void PostEvent( Event *event, float time );
void PostEvent( Event &event, float time );
qboolean PostponeEvent( Event &event, float time );
qboolean PostponeEvent( Event *event, float time );
void CancelEventsOfType( Event *event );
void CancelEventsOfType( Event &event );
void CancelPendingEvents( void );
qboolean ProcessPendingEvents( void );
};
inline EXPORT_FROM_DLL qboolean Event::Exists
(
const char *command
)
{
int num;
str c;
if ( !commandList )
{
initCommandList();
}
c = command;
num = FindEvent( c );
if ( num )
{
return true;
}
return false;
}
inline EXPORT_FROM_DLL Event Event::Find
(
const char *command
)
{
int num;
str c;
if ( !commandList )
{
initCommandList();
}
c = command;
num = FindEvent( c );
if ( num )
{
return Event( num );
}
return NullEvent;
}
inline EXPORT_FROM_DLL Event Event::Find
(
str &command
)
{
int num;
if ( !commandList )
{
initCommandList();
}
num = FindEvent( command );
if ( num )
{
return Event( num );
}
return NullEvent;
}
inline EXPORT_FROM_DLL void Event::SetSource
(
eventsource_t source
)
{
info.source = ( unsigned )source;
}
inline EXPORT_FROM_DLL void Event::SetLineNumber
(
int linenumber
)
{
info.linenumber = linenumber;
}
inline EXPORT_FROM_DLL void Event::SetConsoleEdict
(
edict_t *consoleedict
)
{
assert( consoleedict );
// linenumber does double duty in the case of the console commands
if ( consoleedict )
{
info.linenumber = consoleedict->s.number;
}
else
{
// default to player 1
info.linenumber = 1;
}
}
inline EXPORT_FROM_DLL eventsource_t Event::GetSource
(
void
)
{
return ( eventsource_t )info.source;
}
inline EXPORT_FROM_DLL edict_t *Event::GetConsoleEdict
(
void
)
{
// linenumber does double duty in the case of the console commands
if ( ( info.source != EV_FROM_CONSOLE ) || ( info.linenumber < 1 ) || ( info.linenumber > game.maxclients ) )
{
assert( NULL );
// default to player 1 for release
return &g_edicts[ 1 ];
}
return &g_edicts[ info.linenumber ];
}
inline EXPORT_FROM_DLL int Event::GetLineNumber
(
void
)
{
// linenumber does double duty in the case of the console commands
if ( info.source == EV_FROM_SCRIPT )
{
return info.linenumber;
}
return 0;
}
inline EXPORT_FROM_DLL str Event::getName
(
void
)
{
assert( name || !eventnum );
if ( !name )
{
return "NULL";
}
return name;
}
inline EXPORT_FROM_DLL Event& Event::printInfo
(
void
)
{
gi.dprintf( "event '%s' is number %d\n", getName().c_str(), eventnum );
return *this;
}
inline EXPORT_FROM_DLL Event::operator int()
{
return eventnum;
}
inline EXPORT_FROM_DLL Event::operator const char *()
{
return getName().c_str();
}
inline EXPORT_FROM_DLL int Event::NumArgs
(
void
)
{
if ( !data )
{
return 0;
}
return ( data->NumObjects() );
}
inline EXPORT_FROM_DLL void Event::AddToken
(
const char *text
)
{
AddString( text );
}
inline EXPORT_FROM_DLL void Event::AddTokens
(
int argc,
const char **argv
)
{
int i;
for( i = 0; i < argc; i++ )
{
assert( argv[ i ] );
AddString( argv[ i ] );
}
}
inline EXPORT_FROM_DLL void Event::AddString
(
const char *text
)
{
if ( !data )
{
data = new Container<str>;
data->Resize( 1 );
}
data->AddObject( str( text ) );
}
inline EXPORT_FROM_DLL void Event::AddString
(
str &text
)
{
if ( !data )
{
data = new Container<str>;
data->Resize( 1 );
}
data->AddObject( text );
}
inline EXPORT_FROM_DLL void Event::AddInteger
(
int val
)
{
char text[ 128 ];
sprintf( text, "%d", val );
AddString( text );
}
inline EXPORT_FROM_DLL void Event::AddDouble
(
double val
)
{
char text[ 128 ];
sprintf( text, "%f", val );
AddString( text );
}
inline EXPORT_FROM_DLL void Event::AddFloat
(
float val
)
{
char text[ 128 ];
sprintf( text, "%f", val );
AddString( text );
}
inline EXPORT_FROM_DLL void Event::AddVector
(
Vector &vec
)
{
char text[ 128 ];
sprintf( text, "(%f %f %f)", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
AddString( text );
}
inline EXPORT_FROM_DLL const char *Event::GetToken
(
int pos
)
{
if ( !data || ( pos < 1 ) || ( data->NumObjects() < pos ) )
{
Error( "Index %d out of range.", pos );
return "";
}
return data->ObjectAt( pos ).c_str();
}
inline EXPORT_FROM_DLL qboolean Listener::ProcessEvent
(
Event &event
)
{
Event *ev;
ev = new Event( event );
return ProcessEvent( ev );
}
inline EXPORT_FROM_DLL void Listener::PostEvent
(
Event &event,
float time
)
{
Event *ev;
ev = new Event( event );
PostEvent( ev, time );
}
inline EXPORT_FROM_DLL qboolean Listener::PostponeEvent
(
Event *event,
float time
)
{
return PostponeEvent( *event, time );
}
inline EXPORT_FROM_DLL void Listener::CancelEventsOfType
(
Event &event
)
{
CancelEventsOfType( &event );
}
#endif

206
magnum.cpp Normal file
View File

@ -0,0 +1,206 @@
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/magnum.cpp $
// $Revision:: 46 $
// $Author:: Markd $
// $Date:: 11/13/98 3:30p $
//
// Copyright (C) 1998 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.
//
// $Log:: /Quake 2 Engine/Sin/code/game/magnum.cpp $
//
// 46 11/13/98 3:30p Markd
// put in more precaching on weapons
//
// 45 10/19/98 12:06a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
// Added Drop
//
// 44 10/05/98 10:38p Aldie
// Fixed rank
//
// 43 10/05/98 10:18p Aldie
// Covnverted over to new silencer methods
//
// 42 8/06/98 10:53p Aldie
// Added weapon tweaks and kickback. Also modified blast radius damage and
// rocket jumping.
//
// 41 8/01/98 3:24p Aldie
// Added server effects flag for specific weapons
//
// 40 8/01/98 3:03p Aldie
// Client side muzzle flash (dynamic light)
//
// 39 7/22/98 9:57p Markd
// Defined weapon type
//
// 38 7/21/98 1:10p Aldie
// Added meansofdeath to obituaries
//
// 37 7/20/98 3:53p Aldie
// Fixed the icon
//
// 36 7/14/98 5:50p Aldie
// Tweaked the magnum
//
// 35 6/25/98 7:31p Aldie
// Changed the icon
//
// 34 6/24/98 1:36p Aldie
// Implementation of inventory system and picking stuff up
//
// 33 6/19/98 9:30p Jimdose
// Moved gun orientation code to Weapon
//
// 32 6/17/98 10:54a Aldie
// Updated silenced stuff
//
// 31 6/15/98 9:09p Aldie
// Added SilencedBullet class for silencers
//
// 30 6/10/98 7:53p Markd
// reduced time till next attack
//
// 29 6/10/98 2:10p Aldie
// Updated damage function.
//
// 28 6/10/98 1:19p Markd
// Made magnum use 10mm bullets instead of 357
//
// 27 6/08/98 8:18p Markd
// set ammo_clip_size
//
// 26 5/08/98 2:56p Markd
// took out dbshotgn sound
//
// 25 4/20/98 1:56p Markd
// SINED decelration is now in def file
//
// 24 4/18/98 3:07p Markd
// Changed view weapon naming convention
//
// 23 4/16/98 7:46p Aldie
// Updated magnum to 100 bullets temporarily
//
// 22 4/09/98 3:28p Jimdose
// Removed sound from shoot since anim plays it
//
// 21 4/07/98 6:43p Jimdose
// Rewrote weapon code.
// Added order to rank
//
// 20 4/02/98 4:48p Jimdose
// Balanced for DM
//
// 19 3/30/98 9:55p Jimdose
// Changed location of .def files
//
// 18 3/30/98 2:33p Jimdose
// Moved firing to BulletWeapon to make more general
// Added Ammo
// Added world models
//
// 17 3/29/98 9:41p Jimdose
// Reduced the amount of damage bullets do
//
// 16 3/27/98 11:03p Jimdose
// Added muzzle flash
//
// 15 3/26/98 8:17p Jimdose
// Precached sounds
//
// 14 3/23/98 1:31p Jimdose
// Revamped event and command system
//
// 13 3/18/98 2:39p Jimdose
// Added the new model and made work with the new animation system
//
// 12 3/05/98 5:44p Aldie
// Removed gunshot temporarily.
//
// 11 3/02/98 8:49p Jimdose
// Changed the classid parameter of CLASS_DECLARATION to a quoted string so
// that you could have a NULL classid.
//
// 10 2/19/98 2:35p Jimdose
// Updated to work with Q2 based progs
//
// 8 12/11/97 7:41p Markd
// moved note processing into setmodel
//
// 7 12/09/97 7:47p Markd
// Moved some of the init stuff above the initial init call
//
// 6 11/18/97 5:31p Markd
// Changed Fire to Shoot
// Got rid of some thinking funciotns
//
// 5 10/31/97 4:28p Jimdose
// Removed redefinition of owner in base class Weapon, so any reference to
// gunoffset through owner had to use type overriding.
//
// 4 10/30/97 6:55p Jimdose
// Increased the damage for testing
//
// 3 10/28/97 8:36p Jimdose
// Moved model
//
// 2 10/24/97 8:13p Jimdose
// Created file.
//
// DESCRIPTION:
// Magnum.
//
#include "g_local.h"
#include "magnum.h"
CLASS_DECLARATION( BulletWeapon, Magnum, "weapon_magnum" );
ResponseDef Magnum::Responses[] =
{
{ &EV_Weapon_Shoot, ( Response )Magnum::Shoot },
{ NULL, NULL }
};
Magnum::Magnum()
{
SetModels( "magnum.def", "view_magnum.def" );
SetAmmo( "Bullet10mm", 1, 100 );
SetRank( 20, 20 );
SetType( WEAPON_1HANDED );
modelIndex( "10mm.def" );
silenced = true;
}
void Magnum::Shoot
(
Event *ev
)
{
NextAttack( 0.20 );
FireBullets( 1, "10 10 10", 12, 24, DAMAGE_BULLET, MOD_MAGNUM, false );
}
qboolean Magnum::Drop
(
void
)
{
// Don't leave magnums around
if ( owner && owner->deadflag && deathmatch->value )
{
return false;
}
return BulletWeapon::Drop();
}

Some files were not shown because too many files have changed in this diff Show More