29 #include "../idlib/precompiled.h"
56 static
const float BOUNCE_SOUND_MIN_VELOCITY = 80.0
f;
57 static
const float BOUNCE_SOUND_MAX_VELOCITY = 200.0f;
65 minDamageVelocity = 100.0f;
66 maxDamageVelocity = 200.0f;
67 nextCollideFxTime = 0;
73 unbindOnDeath =
false;
98 float density, friction, bouncyness, mass;
104 if ( !clipModelName[0] ) {
115 if ( clipShrink != 0 ) {
225 int initialSplineTime;
231 savefile->
ReadObject( reinterpret_cast<idClass *&>( attacker ) );
243 savefile->
ReadInt( initialSplineTime );
246 if ( initialSplineTime != -1 ) {
288 v = -( velocity * collision.
c.
normal );
290 f = v > BOUNCE_SOUND_MAX_VELOCITY ? 1.0f :
idMath::Sqrt( v - BOUNCE_SOUND_MIN_VELOCITY ) * ( 1.0f /
idMath::Sqrt( BOUNCE_SOUND_MAX_VELOCITY - BOUNCE_SOUND_MIN_VELOCITY ) );
302 bool hasMonsterDamage = monsterDamage.Length() > 0;
304 if ( hasDamage || hasMonsterDamage ) {
310 if ( ent->
IsType( idAI::Type ) && hasMonsterDamage ) {
321 }
else if ( hasDamage ) {
345 if ( this->
IsType( idExplodingBarrel::Type ) ) {
348 if ( !ebarrel->IsStable() ) {
435 int initialSplineTime;
542 void idMoveable::SetAttacker(
idEntity *ent ) {
554 idVec3 init_velocity, init_avelocity;
568 if ( delay == 0.0
f ) {
575 if ( delay == 0.0
f ) {
642 additionalRotation = 0.0f;
643 additionalAxis.Identity();
644 fl.networkSync =
true;
681 bool wasAtRest, onGround;
682 float movedDistance, rotatedDistance, angle;
683 idVec3 curOrigin, gravityNormal, dir;
704 dir -= gravityNormal * dir * gravityNormal;
712 dir *= 1.0f / movedDistance;
713 movedDistance = ( 1.0f -
idMath::Fabs( dir * curAxis[barrelAxis] ) ) * movedDistance;
716 angle =
lastAxis[(barrelAxis+1)%3] * curAxis[(barrelAxis+1)%3];
719 rotatedDistance = angle *
radius;
722 if ( movedDistance > rotatedDistance ) {
726 angle = 180.0f * (movedDistance - rotatedDistance) / (radius *
idMath::PI);
727 if ( gravityNormal.Cross( curAxis[barrelAxis] ) * dir < 0.0f ) {
782 radius = ( bounds[1][0] - bounds[0][0] ) * 0.5
f;
837 particleModelDefHandle = -1;
839 memset( &particleRenderEntity, 0,
sizeof( particleRenderEntity ) );
840 memset( &light, 0,
sizeof( light ) );
908 if ( lightDefHandle != -1 ) {
911 if ( particleModelDefHandle != -1 ) {
990 void idExplodingBarrel::SetStability(
bool stability ) {
991 isStable = stability;
999 bool idExplodingBarrel::IsStable(
void ) {
1008 void idExplodingBarrel::StartBurning(
void ) {
1018 void idExplodingBarrel::StopBurning(
void ) {
1037 if ( name && *name ) {
1039 int explicitTimeGroup = timeGroup;
1040 SetTimeState explicitTS( explicitTimeGroup );
1051 float rgb = ( burn ) ? 0.0
f : 1.0
f;
1110 if ( *temp !=
'\0' ) {
1116 if ( *temp !=
'\0' ) {
1121 if ( *temp !=
'\0' ) {
1126 if ( *temp !=
'\0' ) {
1155 msg.
Init( msgBuf,
sizeof( msgBuf ) );
1166 if ( splash && *splash ) {
1177 if ( debris_args ) {
1192 if ( !ent || !ent->
IsType( idDebris::Type ) ) {
1196 debris =
static_cast<idDebris *
>(ent);
1228 const char *damageDefName,
const float damageScale,
const int location ) {
1237 idEntity::Damage( inflictor, attacker, dir, damageDefName, damageScale, location );
1270 if ( minRespawnDist ) {
1278 if ( minDist < 0 || dist < minDist ) {
1282 if ( minDist < minRespawnDist ) {
1288 if ( temp && *temp ) {
virtual const idVec3 & GetOrigin(int id=0) const =0
void SetAngularVelocity(const idVec3 &newAngularVelocity, int id=0)
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
renderEntity_t renderEntity
float GetFloat(const char *key, const char *defaultString="0") const
void InitInitialSpline(int startTime)
idMat3 ToMat3(void) const
virtual bool TrmFromModel(const char *modelName, idTraceModel &trm)=0
const idEventDef EV_SetOwner("setOwner","e")
void WriteString(const char *string)
const idEventDef EV_EnableDamage("enableDamage","f")
int GetInt(const char *key, const char *defaultString="0") const
void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)
bool PostEventSec(const idEventDef *ev, float time)
const idDict * FindEntityDefDict(const char *name, bool makeDefault=true) const
virtual const idVec3 & GetGravityNormal(void) const =0
const int SHADERPARM_DIVERSITY
const idEventDef EV_Respawn("<respawn>")
virtual void FreeLightDef(qhandle_t lightHandle)=0
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
void WriteObject(const idClass *obj)
idVec3 GetCenter(void) const
struct idEntity::entityFlags_s fl
const int MAX_EVENT_PARAM_SIZE
static float ACos16(float a)
const idEventDef EV_Activate("activate","e")
void Event_SetOwnerFromSpawnArgs(void)
idEntity * GetBindMaster(void) const
virtual qhandle_t AddEntityDef(const renderEntity_t *re)=0
idRenderModel * ModelHandle(void) const
void Event_Activate(idEntity *activator)
idMat3 Transpose(void) const
void void void void void Error(const char *fmt,...) const id_attribute((format(printf
bool IsType(const idTypeInfo &c) const
idEntity * FindEntity(const char *name) const
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
const idKeyValue * MatchPrefix(const char *prefix, const idKeyValue *lastMatch=NULL) const
bool ProcessEvent(const idEventDef *ev)
void WriteBits(int value, int numBits)
const idMaterial * shader
void RadiusDamage(const idVec3 &origin, idEntity *inflictor, idEntity *attacker, idEntity *ignoreDamage, idEntity *ignorePush, const char *damageDefName, float dmgPower=1.0f)
static float ClampFloat(float min, float max, float value)
void Restore(idRestoreGame *savefile)
const idEventDef EV_SetAngularVelocity("setAngularVelocity","v")
void ReadBool(bool &value)
void WriteStaticObject(const idClass &obj)
static float Sqrt(float x)
const idVec3 & GetOrigin(int id=0) const
const int SHADERPARM_GREEN
bool FollowInitialSplinePath(void)
renderEntity_t particleRenderEntity
void ExplodingEffects(void)
virtual qhandle_t AddLightDef(const renderLight_t *rlight)=0
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
void ReadFromSnapshot(const idBitMsgDelta &msg)
void SetSoundVolume(float volume)
idVec3 Cross(const idVec3 &a) const
int ReadBits(int numBits) const
void ShiftTime(const float deltaTime)
bool AllowStep(void) const
void WriteVec3(const idVec3 &vec)
bool HasChanged(void) const
void ReadRenderEntity(renderEntity_t &renderEntity)
idPhysics_RigidBody physicsObj
virtual void SetModel(const char *modelname)
const idMaterial * customShader
const int SHADERPARM_ALPHA
virtual bool IsAtRest(void) const
#define EVENT(event, function)
const idEventDef EV_Explode("<explode>", NULL)
void Init(byte *data, int length)
const idEventDef EV_SetLinearVelocity("setLinearVelocity","v")
void WriteBool(const bool value)
float shaderParms[MAX_ENTITY_SHADER_PARMS]
bool IsHidden(void) const
virtual void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
idCurve_Spline< idVec3 > * GetSpline(void) const
const idEventDef EV_SetOwnerFromSpawnArgs("<setOwnerFromSpawnArgs>")
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
virtual const idBounds & GetBounds(int id=-1) const =0
const int SHADERPARM_BLUE
void Save(idSaveGame *savefile) const
void Restore(idRestoreGame *savefile)
void SetSelf(idEntity *e)
virtual void FreeEntityDef(qhandle_t entityHandle)=0
idPhysics * GetPhysics(void) const
const char * GetString(const char *key, const char *defaultString="") const
bool SpawnEntityDef(const idDict &args, idEntity **ent=NULL, bool setDefaults=true)
void ReadFloat(float &value)
bool StartSound(const char *soundName, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
void ReadRenderLight(renderLight_t &renderLight)
virtual renderEntity_t * GetRenderEntity(void)
void SetPhysics(idPhysics *phys)
void WriteToSnapshot(idBitMsgDelta &msg) const
virtual type GetCurrentValue(const float time) const
void WriteFloat(const float value)
static float Fabs(float f)
virtual float GetMass(int id=-1) const =0
bool GetBool(const char *key, const char *defaultString="0") const
void Save(idSaveGame *savefile) const
const idBounds & GetAbsBounds(int id=-1) const
virtual idRenderModel * FindModel(const char *modelName)=0
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
bool IsAtRest(void) const
const int SHADERPARM_TIME_OF_DEATH
void ServerSendEvent(int eventId, const idBitMsg *msg, bool saveEvent, int excludeClient) const
virtual void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
virtual const modelSurface_t * Surface(int surfaceNum) const =0
void CancelEvents(const idEventDef *ev)
const idEventDef EV_TriggerTargets("<triggertargets>")
const idVec3 & GetGravity(void) const
void SetMaterial(const idMaterial *m)
virtual bool GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis)
const idStr & GetValue(void) const
virtual const idMat3 & GetAxis(int id=0) const =0
virtual void UpdateEntityDef(qhandle_t entityHandle, const renderEntity_t *re)=0
void SetFriction(const float linear, const float angular, const float contact)
float NormalizeFast(void)
virtual bool HasGroundContacts(void) const =0
void Save(idSaveGame *savefile) const
virtual type GetCurrentFirstDerivative(const float time) const
float LengthSqr(void) const
const int SHADERPARM_TIMEOFFSET
void Event_IsAtRest(void)
void WriteRenderEntity(const renderEntity_t &renderEntity)
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
const idKeyValue * FindKey(const char *key) const
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
virtual void UpdateLightDef(qhandle_t lightHandle, const renderLight_t *rlight)=0
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
void SetAxis(const idMat3 &newAxis, int id=-1)
const char * ToString(int precision=2) const
void WriteInt(const int value)
virtual void Present(void)
float GetTime(const int index) const
idDeclManager * declManager
void WriteMat3(const idMat3 &mat)
void Event_Activate(idEntity *activator)
void ReadMat3(idMat3 &mat)
idEntity * entities[MAX_GENTITIES]
void Shrink(const float m)
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
void SetContents(int contents, int id=-1)
void ReadStaticObject(idClass &obj)
void Event_TriggerTargets()
idRenderModelManager * renderModelManager
qhandle_t particleModelDefHandle
void SetClipMask(int mask, int id=-1)
const idMaterial * GetRenderModelMaterial(void) const
void Event_BecomeNonSolid(void)
void ProjectDecal(const idVec3 &origin, const idVec3 &dir, float depth, bool parallel, float size, const char *material, float angle=0)
const idMat3 & ToMat3(void) const
virtual void ClientPredictionThink(void)
void Create(idEntity *owner, const idVec3 &start, const idMat3 &axis)
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
void BecomeNonSolid(void)
void ReadVec3(idVec3 &vec)
class idUserInterface * gui[MAX_RENDERENTITY_GUI]
const char * c_str(void) const
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
void RestorePhysics(idPhysics *phys)
const idEventDef EV_IsAtRest("isAtRest", NULL, 'd')
idCurve_Spline< idVec3 > * initialSpline
void BecomeActive(int flags)
void MakeUniform(const float totalTime)
const idEventDef EV_Remove("<immediateremove>", NULL)
virtual int GetContents(int id=-1) const =0
virtual idRenderModel * CheckModel(const char *modelName)=0
void SetGravity(const idVec3 &newGravity)
void Event_EnableDamage(float enable)
idRenderWorld * gameRenderWorld
int GetNumValues(void) const
static float ACos(float a)
static idEntityFx * StartFx(const char *fx, const idVec3 *useOrigin, const idMat3 *useAxis, idEntity *ent, bool bind)
void AddParticles(const char *name, bool burn)
bool PostEventMS(const idEventDef *ev, int time)
void AddLight(const char *name, bool burn)
const idMaterial * shader
void EnableDamage(bool enable, float duration)
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
void Restore(idRestoreGame *savefile)
void SetBouncyness(const float b)
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
float shaderParms[MAX_ENTITY_SHADER_PARMS]
void ReadString(idStr &string)
void BecomeInactive(int flags)
void WriteRenderLight(const renderLight_t &renderLight)
static void ReturnInt(int value)
const idMat3 & GetAxis(int id=0) const
idClipModel * GetClipModel(int id=0) const
idCollisionModelManager * collisionModelManager
void ActivateTargets(idEntity *activator) const
void ReadObject(idClass *&obj)
void SetOrigin(const idVec3 &newOrigin, int id=-1)
const idEventDef EV_BecomeNonSolid("becomeNonSolid")
void SetMass(float mass, int id=-1)
virtual int NumSurfaces() const =0