29 #include "../idlib/precompiled.h"
69 lastRenderViewTime = -1;
74 fl.networkSync =
true;
147 float d = dir * renderView->
viewaxis[0];
174 if ( cycle < 0.1
f ) {
176 }
else if ( cycle < 0.2
f ) {
178 }
else if ( cycle < 0.3
f ) {
179 renderEntity->
shaderParms[4] = 1.0f - ( cycle - 0.2f ) * 10.0
f;
205 gameLocal.
Error(
"idItem::ModelCallback: callback with NULL game entity" );
349 if ( player ==
NULL ) {
401 if ( respawn && !dropped && !no_respawn ) {
515 if ( !other->
IsType( idPlayer::Type ) ) {
523 Pickup( static_cast<idPlayer *>(other) );
538 if ( activator && activator->
IsType( idPlayer::Type ) ) {
539 Pickup( static_cast<idPlayer *>( activator ) );
662 const idEventDef EV_FlagReturn(
"flagreturn",
"e" );
663 const idEventDef EV_TakeFlag(
"takeflag",
"e" );
664 const idEventDef EV_DropFlag(
"dropflag",
"d" );
665 const idEventDef EV_FlagCapture(
"flagcapture" );
668 EVENT( EV_FlagReturn, idItemTeam::Event_FlagReturn )
669 EVENT( EV_TakeFlag, idItemTeam::Event_TakeFlag )
670 EVENT( EV_DropFlag, idItemTeam::Event_DropFlag )
671 EVENT( EV_FlagCapture, idItemTeam::Event_FlagCapture )
679 idItemTeam::idItemTeam() {
691 scriptDropped =
NULL;
692 scriptReturned =
NULL;
693 scriptCaptured =
NULL;
704 idItemTeam::~idItemTeam() {
712 void idItemTeam::Spawn(
void ) {
713 team = spawnArgs.GetInt(
"team" );
714 returnOrigin = GetPhysics()->GetOrigin() +
idVec3( 0, 0, 20 );
715 returnAxis = GetPhysics()->GetAxis();
719 const char * skinName;
720 skinName = spawnArgs.GetString(
"skin",
"" );
724 skinName = spawnArgs.GetString(
"skin_carried",
"" );
728 nuggetName = spawnArgs.GetString(
"nugget_name",
"" );
729 if ( !nuggetName[0] ) {
733 scriptTaken = LoadScript(
"script_taken" );
734 scriptDropped = LoadScript(
"script_dropped" );
735 scriptReturned = LoadScript(
"script_returned" );
736 scriptCaptured = LoadScript(
"script_captured" );
764 physicsObj.SetContents( 0 );
766 physicsObj.SetGravity(
idVec3( 0, 0, spawnArgs.GetInt(
"gravity",
"-30" ) ) );
775 function_t * idItemTeam::LoadScript(
const char * script ) {
777 idStr funcname = spawnArgs.GetString( script,
"" );
778 if ( funcname.
Length() ) {
780 if (
function ==
NULL ) {
782 gameLocal.
Warning(
"idItemTeam '%s' at (%s) calls unknown function '%s'",
name.c_str(), GetPhysics()->GetOrigin().ToString(0), funcname.
c_str() );
795 void idItemTeam::Think(
void ) {
811 if (
gameLocal.
isServer && nuggetName && carried && ( !lastNuggetDrop || (
gameLocal.
time - lastNuggetDrop) > spawnArgs.GetInt(
"nugget_frequency") ) ) {
813 SpawnNugget( GetPhysics()->GetOrigin() );
819 if ( dropped && !carried && lastDrop != 0 && (
gameLocal.
time - lastDrop) > ( si_flagDropTimeLimit.GetInteger()*1000 ) ) {
831 bool idItemTeam::Pickup(
idPlayer *player ) {
840 if ( lastDrop != 0 && (
gameLocal.
time - lastDrop) < spawnArgs.GetInt(
"pickupDelay",
"500") )
843 if ( carried ==
false && player->
team != this->team ) {
845 PostEventMS( &EV_TakeFlag, 0, player );
848 }
else if ( carried ==
false && dropped ==
true && player->
team == this->team ) {
853 PostEventMS( &EV_FlagReturn, 0, player );
866 bool idItemTeam::ClientReceiveEvent(
int event,
int time,
const idBitMsg &msg ) {
870 case EVENT_TAKEFLAG: {
872 if ( player ==
NULL ) {
877 Event_TakeFlag( player );
881 case EVENT_DROPFLAG : {
883 Event_DropFlag( death );
887 case EVENT_FLAGRETURN : {
897 case EVENT_FLAGCAPTURE : {
916 void idItemTeam::Drop(
bool death )
920 Event_DropFlag( death );
928 void idItemTeam::Return(
idPlayer * player )
930 if ( team != 0 && team != 1 )
942 void idItemTeam::Capture(
void )
944 if ( team != 0 && team != 1 )
947 PostEventMS( &EV_FlagCapture, 0 );
955 void idItemTeam::PrivateReturn(
void )
961 if ( playerIdx != -1 ) {
963 player->carryingFlag =
false;
972 SetOrigin( returnOrigin );
973 SetAxis( returnAxis );
977 SetSkin( skinDefault );
988 GetPhysics()->SetLinearVelocity(
idVec3(0, 0, 0) );
989 GetPhysics()->SetAngularVelocity(
idVec3(0, 0, 0) );
997 void idItemTeam::Event_TakeFlag(
idPlayer * player ) {
1004 msg.
Init( msgBuf,
sizeof( msgBuf ) );
1007 ServerSendEvent( EVENT_TAKEFLAG, &msg,
false, -1 );
1019 BindToJoint( player, g_flagAttachJoint.GetString(), true );
1020 idVec3 origin( g_flagAttachOffsetX.GetFloat(), g_flagAttachOffsetY.GetFloat(), g_flagAttachOffsetZ.GetFloat() );
1021 idAngles angle( g_flagAttachAngleX.GetFloat(), g_flagAttachAngleY.GetFloat(), g_flagAttachAngleZ.GetFloat() );
1023 SetOrigin( origin );
1034 if ( scriptTaken ) {
1042 player->carryingFlag =
true;
1044 SetSkin( skinCarried );
1062 void idItemTeam::Event_DropFlag(
bool death ) {
1069 msg.
Init( msgBuf,
sizeof( msgBuf ) );
1072 ServerSendEvent( EVENT_DROPFLAG, &msg,
false, -1 );
1088 GetPhysics()->SetLinearVelocity(
idVec3(0, 0, 0) );
1090 GetPhysics()->SetLinearVelocity(
idVec3(0, 0, 20) );
1092 GetPhysics()->SetAngularVelocity(
idVec3(0, 0, 0) );
1096 if ( GetBindMaster() ) {
1097 const idBounds bounds = GetPhysics()->GetBounds();
1098 idVec3 origin = GetBindMaster()->GetPhysics()->GetOrigin() +
idVec3(0, 0, ( bounds[1].
z-bounds[0].
z )*0.6
f );
1102 SetOrigin( origin );
1105 idAngles angle = GetPhysics()->GetAxis().ToAngles();
1108 SetAxis( angle.
ToMat3() );
1113 if ( scriptDropped ) {
1119 SetSkin( skinDefault );
1138 void idItemTeam::Event_FlagReturn(
idPlayer * player ) {
1142 ServerSendEvent( EVENT_FLAGRETURN,
NULL,
false, -1 );
1148 int entitynum = 255;
1162 if ( scriptReturned ) {
1185 void idItemTeam::Event_FlagCapture(
void ) {
1189 ServerSendEvent( EVENT_FLAGCAPTURE,
NULL,
false, -1 );
1197 if ( playerIdx != -1 ) {
1211 if ( scriptCaptured ) {
1235 void idItemTeam::FreeLightDef(
void ) {
1236 if ( itemGlowHandle != -1 ) {
1238 itemGlowHandle = -1;
1247 void idItemTeam::SpawnNugget(
idVec3 pos ) {
1252 velocity *= spawnArgs.GetFloat(
"nugget_velocity",
"1" );
1257 if ( physics && physics->IsType( idPhysics_RigidBody::Type ) ) {
1269 void idItemTeam::WriteToSnapshot(
idBitMsgDelta &msg )
const {
1273 WriteBindToSnapshot( msg );
1284 void idItemTeam::ReadFromSnapshot(
const idBitMsgDelta &msg ) {
1288 ReadBindFromSnapshot( msg );
1294 if ( carried ==
true )
1295 SetSkin( skinCarried );
1297 SetSkin( skinDefault );
1310 void idItemTeam::UpdateGuis(
void ) {
1334 void idItemTeam::Present(
void ) {
1336 if ( carried && GetBindMaster() ) {
1410 const char *camName;
1426 if (
gameLocal.portalSkyEnt.GetEntity() && g_enablePortalSky.GetBool() ) {
1428 portalView.
vieworg =
gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin();
1432 int vidWidth, vidHeight;
1441 for (temp = 1 ; temp <
w ; temp<<=1) {
1444 shiftScale.
x = (
float)w / pot;
1447 for (temp = 1 ; temp < h ; temp<<=1) {
1450 shiftScale.
y = (
float)h / pot;
1482 if ( player && player->
hud ) {
1532 if ( v.
Length() > 64.0f ) {
1567 if ( player && str.
Length() ) {
1590 const char *str = spawnArgs.GetString(
"pda_name" );
1592 player->GivePDA( str, &spawnArgs );
1623 repeatSmoke =
false;
1651 savefile->
WriteInt( nextSoundTime );
1669 savefile->
ReadInt( nextSoundTime );
1680 float density, friction, bouncyness, tsize;
1681 idStr clipModelName;
1684 SetTimeState ts( timeGroup );
1695 if ( !clipModelName[0] ) {
1701 gameLocal.
Error(
"idMoveableItem '%s': cannot load collision model %s",
name.c_str(), clipModelName.
c_str() );
1736 if ( *smokeName !=
'\0' ) {
1764 if ( !repeatSmoke ) {
1789 v = -( velocity * collision.
c.
normal );
1826 args.
Set(
"classname", classname );
1827 args.
Set(
"dropped",
"1" );
1830 args.
Set(
"nodrop",
"1" );
1832 if ( activateDelay ) {
1833 args.
SetBool(
"triggerFirst",
true );
1843 if ( activateDelay ) {
1846 if ( !removeDelay ) {
1847 removeDelay = 5 * 60 * 1000;
1875 const char *skinName, *
c, *jointName;
1910 axis = angles.
ToMat3() * axis;
1915 if ( list && item ) {
1925 if ( skinName[0] ) {
1960 if ( *smokeName !=
'\0' ) {
1983 Gib(
idVec3( 0, 0, 1 ), damageDefName );
2003 const char *str = spawnArgs.GetString(
"pda_name" );
2005 player->GivePDA( str, &spawnArgs );
2048 if ( activator->
IsType( idPlayer::Type ) ) {
2049 RemoveItem( static_cast<idPlayer *>(activator) );
2118 if ( player->
hud ) {
2157 if ( v.
Length() > 64.0f ) {
virtual const idVec3 & GetOrigin(int id=0) const =0
idPlayer * GetLocalPlayer() const
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
renderEntity_t renderEntity
void Save(idSaveGame *savefile) const
float GetFloat(const char *key, const char *defaultString="0") const
virtual bool TrmFromModel(const char *modelName, idTraceModel &trm)=0
bool EmitSmoke(const idDeclParticle *smoke, const int startTime, const float diversity, const idVec3 &origin, const idMat3 &axis, int timeGroup)
int GetInt(const char *key, const char *defaultString="0") const
idStr & SetFileExtension(const char *extension)
bool PostEventSec(const idEventDef *ev, float time)
void ReadParticle(const idDeclParticle *&particle)
idCVarSystem * cvarSystem
virtual void FreeLightDef(qhandle_t lightHandle)=0
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
void RemoveItem(idPlayer *player)
virtual void SetContents(int contents, int id=-1)=0
void ReadMaterial(const idMaterial *&material)
void CallFunction(const function_t *func, bool clearStack)
virtual void SetStateString(const char *varName, const char *value)=0
void SetContents(int newContents)
struct idEntity::entityFlags_s fl
void DelayedStart(int delay)
const int MAX_EVENT_PARAM_SIZE
idSmokeParticles * smokeParticles
bool GiveItem(idItem *item)
const idStr & GetKey(void) const
const idEventDef EV_Activate("activate","e")
const idEventDef EV_DropToFloor("<dropToFloor>")
idEntity * GetBindMaster(void) const
virtual qhandle_t AddEntityDef(const renderEntity_t *re)=0
const idEventDef EV_RespawnFx("<respawnFx>")
GLenum GLenum GLenum GLenum GLenum scale
void void void void void Error(const char *fmt,...) const id_attribute((format(printf
idAngles GetAngles(const char *key, const char *defaultString=NULL) const
bool IsType(const idTypeInfo &c) const
void SetAngles(const idAngles &ang)
idEntity * FindEntity(const char *name) const
idRenderSystem * renderSystem
const idKeyValue * MatchPrefix(const char *prefix, const idKeyValue *lastMatch=NULL) const
static void DropItems(idAnimatedEntity *ent, const char *type, idList< idEntity * > *list)
const idEventDef EV_Gib("gib","s")
const idDeclParticle * smoke
void WriteBits(int value, int numBits)
void PrintMessageEvent(int to, msg_evt_t evt, int parm1=-1, int parm2=-1)
idPhysics_RigidBody physicsObj
static float ClampFloat(float min, float max, float value)
jointHandle_t GetJointHandle(const char *name) const
void Event_Trigger(idEntity *activator)
void ReadBool(bool &value)
void WriteStaticObject(const idClass &obj)
static float Sqrt(float x)
virtual void GetGLSettings(int &width, int &height)=0
virtual void HandleNamedEvent(const char *eventName)=0
const char * Left(int len, idStr &result) const
virtual void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)=0
GLuint GLuint GLsizei GLenum type
void Event_RespawnFx(void)
virtual void SetStateInt(const char *varName, const int value)=0
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
void ReadFromSnapshot(const idBitMsgDelta &msg)
void SetSoundVolume(float volume)
void Set(const char *key, const char *value)
int ReadBits(int numBits) const
void WriteClipModel(const class idClipModel *clipModel)
void Event_HideObjective(idEntity *e)
deferredEntityCallback_t callback
void WriteVec3(const idVec3 &vec)
bool HasChanged(void) const
idMultiplayerGame::gameState_t GetGameState(void) const
const idMaterial * customShader
void Event_DropToFloor(void)
int Icmp(const char *text) const
void WriteMaterial(const idMaterial *material)
#define EVENT(event, function)
void RemoveInventoryItem(idDict *item)
void Init(byte *data, int length)
const char * GetMapName(void) const
virtual bool Pickup(idPlayer *player)
void WriteBool(const bool value)
virtual renderView_t * GetRenderView()
bool IsHidden(void) const
const idEventDef EV_HideObjective("<hideobjective>","e")
void void void Warning(const char *fmt,...) const id_attribute((format(printf
virtual bool GiveToPlayer(idPlayer *player)
void Save(idSaveGame *savefile) const
bool GivePowerUp(int powerup, int time)
void SetSelf(idEntity *e)
void Event_Trigger(idEntity *activator)
virtual void FreeEntityDef(qhandle_t entityHandle)=0
idCVar g_dropItemRotation("g_dropItemRotation","", CVAR_GAME,"")
virtual bool GiveToPlayer(idPlayer *player)
virtual void CaptureRenderToFile(const char *fileName, bool fixAlpha=false)=0
idPhysics * GetPhysics(void) const
void SetSkin(const idDeclSkin *skin)
const char * GetString(const char *key, const char *defaultString="") const
virtual void CaptureRenderToImage(const char *imageName)=0
GLubyte GLubyte GLubyte GLubyte w
bool SpawnEntityDef(const idDict &args, idEntity **ent=NULL, bool setDefaults=true)
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
idStr & StripFileExtension(void)
bool StartSound(const char *soundName, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
void GiveVideo(const char *videoName, idDict *item)
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
void SetPhysics(idPhysics *phys)
void WriteToSnapshot(idBitMsgDelta &msg) const
void Gib(const idVec3 &dir, const char *damageDefName)
bool GetBool(const char *key, const char *defaultString="0") const
void Restore(idRestoreGame *savefile)
bool UpdateRenderEntity(renderEntity_s *renderEntity, const renderView_t *renderView) const
void Event_Trigger(idEntity *activator)
void void DPrintf(const char *fmt,...) const id_attribute((format(printf
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
void Event_GetPlayerPos()
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
void Event_DropToFloor(void)
void ServerSendEvent(int eventId, const idBitMsg *msg, bool saveEvent, int excludeClient) const
static bool ModelCallback(renderEntity_s *renderEntity, const renderView_t *renderView)
virtual void SetOrigin(const idVec3 &newOrigin, int id=-1)=0
void CancelEvents(const idEventDef *ev)
const idVec3 & GetGravity(void) const
const idStr & GetValue(void) const
void Save(idSaveGame *savefile) const
float shaderParms[MAX_GLOBAL_SHADER_PARMS]
virtual const idMat3 & GetAxis(int id=0) const =0
void Event_Trigger(idEntity *activator)
virtual idAnimator * GetAnimator(void)
virtual void UpdateEntityDef(qhandle_t entityHandle, const renderEntity_t *re)=0
void SetFriction(const float linear, const float angular, const float contact)
const char * Right(int len, idStr &result) const
void Save(idSaveGame *savefile) const
virtual bool Pickup(idPlayer *player)
void SetBool(const char *key, bool val)
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
bool GiveInventoryItem(idDict *item)
void SetAxis(const idMat3 &newAxis, int id=-1)
virtual idClipModel * GetClipModel(int id=0) const =0
void WriteInt(const int value)
virtual void Present(void)
static idEntity * DropItem(const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay)
void Restore(idRestoreGame *savefile)
idDeclManager * declManager
idEntity * entities[MAX_GENTITIES]
void Shrink(const float m)
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
const char * GetString(void) const
void SetContents(int contents, int id=-1)
void ReadStaticObject(idClass &obj)
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
void ReadClipModel(idClipModel *&clipModel)
int Append(const type &obj)
virtual ~idMoveableItem()
bool TraceBounds(trace_t &results, const idVec3 &start, const idVec3 &end, const idBounds &bounds, int contentMask, const idEntity *passEntity)
virtual void ClientPredictionThink(void)
const idEventDef EV_CamShot("<camshot>")
void SetClipMask(int mask, int id=-1)
bool LoadModel(const char *name)
bool IsGametypeFlagBased(void)
void GetAttributes(idDict &attributes)
idMat3 ToMat3(void) const
idCVar pm_thirdPerson("pm_thirdPerson","0", CVAR_GAME|CVAR_NETWORKSYNC|CVAR_BOOL,"enables third person view")
bool GetJointWorldTransform(jointHandle_t jointHandle, int currentTime, idVec3 &offset, idMat3 &axis)
void Save(idSaveGame *savefile) const
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
void Restore(idRestoreGame *savefile)
void Event_Gib(const char *damageDefName)
void ReadVec3(idVec3 &vec)
const char * c_str(void) const
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
virtual void RenderScene(const renderView_t *renderView)=0
void RestorePhysics(idPhysics *phys)
void BecomeActive(int flags)
void Event_HideObjective(idEntity *e)
virtual bool GetCVarBool(const char *name) const =0
const idKeyValue * GetKeyVal(int index) const
const idEventDef EV_Remove("<immediateremove>", NULL)
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
void Restore(idRestoreGame *savefile)
function_t * FindFunction(const char *name) const
const idEventDef EV_GetPlayerPos("<getplayerpos>")
virtual const idDeclSkin * FindSkin(const char *name, bool makeDefault=true)=0
virtual void CropRenderSize(int width, int height, bool makePowerOfTwo=false, bool forceDimensions=false)=0
void SetGravity(const idVec3 &newGravity)
void Restore(idRestoreGame *savefile)
void Event_GetPlayerPos()
idRenderWorld * gameRenderWorld
virtual bool GiveToPlayer(idPlayer *player)
char * va(const char *fmt,...)
void Event_Touch(idEntity *other, trace_t *trace)
static idEntityFx * StartFx(const char *fx, const idVec3 *useOrigin, const idMat3 *useAxis, idEntity *ent, bool bind)
void WriteBits(int value, int numBits)
bool PostEventMS(const idEventDef *ev, int time)
void SetOrigin(const idVec3 &org)
void CompleteObjective(const char *title)
const idEventDef EV_Touch("<touch>","et")
void WriteParticle(const idDeclParticle *particle)
void SetBouncyness(const float b)
int GetNumKeyVals(void) const
float shaderParms[MAX_ENTITY_SHADER_PARMS]
void GiveObjective(const char *title, const char *text, const char *screenshot)
void BecomeInactive(int flags)
int ReadBits(int numBits) const
const idEventDef EV_RespawnItem("respawn")
idCollisionModelManager * collisionModelManager
void ActivateTargets(idEntity *activator) const
const idMaterial * shellMaterial
void SetOrigin(const idVec3 &newOrigin, int id=-1)
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
virtual void SetAxis(const idMat3 &newAxis, int id=-1)=0