29 #include "../idlib/precompiled.h"
52 physicsObj.SetSelf(
this );
149 float halfLinkLength = linkLength * 0.5f;
161 org = origin -
idVec3( 0, 0, halfLinkLength );
164 for ( i = 0; i < numLinks; i++ ) {
171 physicsObj.AddBody( body );
174 SetModelForId( physicsObj.GetBodyId( body ), spawnArgs.GetString(
"model" ) );
180 uj->
SetShafts( idVec3( 0, 0, -1 ), idVec3( 0, 0, 1 ) );
186 uj->
SetShafts( idVec3( 0, 0, 1 ), idVec3( 0, 0, -1 ) );
189 uj->
SetAnchor( org + idVec3( 0, 0, halfLinkLength ) );
191 physicsObj.AddConstraint( uj );
196 bsj->
SetAnchor( org + idVec3( 0, 0, halfLinkLength ) );
197 bsj->
SetConeLimit( idVec3( 0, 0, 1 ), 60.0
f, idVec3( 0, 0, 1 ) );
198 physicsObj.AddConstraint( bsj );
202 org[2] -= linkLength;
215 float length, linkLength, linkWidth, density;
224 linkLength = length / numLinks;
233 BuildChain(
"link", origin, linkLength, linkWidth, density, numLinks, !drop );
375 const char *damageDefName,
const float damageScale,
const int location ) {
522 static
const float BOUNCE_SOUND_MIN_VELOCITY = 80.0
f;
523 static
const float BOUNCE_SOUND_MAX_VELOCITY = 200.0f;
532 combatModelContents = 0;
535 spawnAxis.Identity();
602 if ( !
af.
Load(
this, fileName ) ) {
603 gameLocal.
Error(
"idAFEntity_Base::LoadAF: Couldn't load af file '%s' on entity '%s'", fileName.
c_str(),
name.c_str() );
753 v = -( velocity * collision.
c.
normal );
755 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 ) );
894 const char *skinName;
907 if ( newEnt && newEnt->
IsType( idAFEntity_Base::Type ) ) {
960 skeletonModel =
NULL;
961 skeletonModelDefHandle = -1;
1002 savefile->
ReadBool( hasCombatModel );
1009 if ( hasCombatModel ) {
1035 const char *modelName;
1044 if ( modelName[0] !=
'\0' ) {
1053 gameLocal.
Error(
"gib model '%s' has different number of joints than model '%s'",
1103 Gib( dir, damageDefName );
1113 void idAFEntity_Gibbable::SetThrown(
bool isThrown ) {
1118 for ( i=0; i<
num; i++ ) {
1126 wasThrown = isThrown;
1136 if ( !
gibbed && wasThrown ) {
1149 Gib( vel,
"damage_gib" );
1165 idVec3 entityCenter, velocity;
1183 gibNonSolid = damageDef->
GetBool(
"gibNonSolid" );
1184 for ( i = 0; i < list.
Num(); i++ ) {
1185 if ( gibNonSolid ) {
1186 list[
i]->GetPhysics()->SetContents( 0 );
1187 list[
i]->GetPhysics()->SetClipMask( 0 );
1188 list[
i]->GetPhysics()->UnlinkClip();
1189 list[
i]->GetPhysics()->PutToRest();
1192 list[
i]->GetPhysics()->SetContents( 0 );
1197 velocity = list[
i]->GetPhysics()->GetAbsBounds().GetCenter() - entityCenter;
1199 velocity += ( i & 1 ) ? dir : -dir;
1200 list[
i]->GetPhysics()->SetLinearVelocity( velocity * 75.0
f );
1204 list[
i]->noGrab =
true;
1206 list[
i]->GetRenderEntity()->noShadow =
true;
1233 if ( damageDef->
GetBool(
"gibNonSolid" ) ) {
1268 Gib(
idVec3( 0, 0, 1 ), damageDefName );
1289 keepRunningPhysics =
false;
1360 idVec3 init_velocity, init_avelocity;
1371 if ( delay == 0.0
f ) {
1378 if ( delay == 0.0
f ) {
1476 const char *headModel;
1482 if ( headModel[ 0 ] ) {
1491 headEnt->
SetBody(
this, headModel, joint );
1619 Gib(
idVec3( 0, 0, 1 ), damageDefName );
1629 idVec3 init_velocity, init_avelocity;
1640 if ( delay == 0.0
f ) {
1647 if ( delay == 0.0
f ) {
1688 const char *steeringWheelJointName =
spawnArgs.
GetString(
"steeringWheelJoint",
"steeringWheel" );
1698 if ( !eyesJointName[0] ) {
1702 if ( !steeringWheelJointName[0] ) {
1703 gameLocal.
Error(
"idAFEntity_Vehicle '%s' no steering wheel joint specified",
name.c_str() );
1714 if ( *smokeName !=
'\0' ) {
1754 float idealSteerAngle, angleDelta;
1764 steerAngle = idealSteerAngle;
1789 for ( i = 0; i < 4; i++ ) {
1790 suspension[
i] =
NULL;
1810 static const char *wheelJointKeys[] = {
1811 "wheelJointFrontLeft",
1812 "wheelJointFrontRight",
1813 "wheelJointRearLeft",
1814 "wheelJointRearRight"
1816 static idVec3 wheelPoly[4] = {
idVec3( 2, 2, 0 ),
idVec3( 2, -2, 0 ),
idVec3( -2, -2, 0 ),
idVec3( -2, 2, 0 ) };
1827 for ( i = 0; i < 4; i++ ) {
1829 if ( !wheelJointName[0] ) {
1830 gameLocal.
Error(
"idAFEntity_VehicleSimple '%s' no '%s' specified",
name.c_str(), wheelJointKeys[
i] );
1834 gameLocal.
Error(
"idAFEntity_VehicleSimple '%s' can't find wheel joint '%s'",
name.c_str(), wheelJointName );
1862 float force = 0.0f, velocity = 0.0f,
steerAngle = 0.0f;
1873 velocity = -velocity;
1880 for ( i = 0; i < 2; i++ ) {
1883 if ( velocity != 0.0
f ) {
1903 for ( i = 0; i < 4; i++ ) {
1915 for ( i = 0; i < 4; i++ ) {
1924 wheelRotation.
SetVec( 0, -1, 0 );
1929 steerRotation.
SetVec( 0, 0, 1 );
1984 for ( i = 0; i < 4; i++ ) {
1987 wheelAngles[
i] = 0.0f;
2000 static const char *wheelBodyKeys[] = {
2001 "wheelBodyFrontLeft",
2002 "wheelBodyFrontRight",
2003 "wheelBodyRearLeft",
2004 "wheelBodyRearRight"
2006 static const char *wheelJointKeys[] = {
2007 "wheelJointFrontLeft",
2008 "wheelJointFrontRight",
2009 "wheelJointRearLeft",
2010 "wheelJointRearRight"
2012 static const char *steeringHingeKeys[] = {
2013 "steeringHingeFrontLeft",
2014 "steeringHingeFrontRight",
2017 const char *wheelBodyName, *wheelJointName, *steeringHingeName;
2019 for ( i = 0; i < 4; i++ ) {
2021 if ( !wheelBodyName[0] ) {
2022 gameLocal.
Error(
"idAFEntity_VehicleFourWheels '%s' no '%s' specified",
name.c_str(), wheelBodyKeys[
i] );
2026 gameLocal.
Error(
"idAFEntity_VehicleFourWheels '%s' can't find wheel body '%s'",
name.c_str(), wheelBodyName );
2029 if ( !wheelJointName[0] ) {
2030 gameLocal.
Error(
"idAFEntity_VehicleFourWheels '%s' no '%s' specified",
name.c_str(), wheelJointKeys[
i] );
2034 gameLocal.
Error(
"idAFEntity_VehicleFourWheels '%s' can't find wheel joint '%s'",
name.c_str(), wheelJointName );
2038 for ( i = 0; i < 2; i++ ) {
2040 if ( !steeringHingeName[0] ) {
2041 gameLocal.
Error(
"idAFEntity_VehicleFourWheels '%s' no '%s' specified",
name.c_str(), steeringHingeKeys[
i] );
2045 gameLocal.
Error(
"idAFEntity_VehicleFourWheels '%s': can't find steering hinge '%s'",
name.c_str(), steeringHingeName );
2060 float force = 0.0f, velocity = 0.0f,
steerAngle = 0.0f;
2071 velocity = -velocity;
2078 for ( i = 0; i < 2; i++ ) {
2094 for ( i = 0; i < 2; i++ ) {
2100 rotation.
SetVec( axis[2] );
2108 for ( i = 0; i < 4; i++ ) {
2109 if ( force == 0.0
f ) {
2124 for ( i = 0; i < 4; i++ ) {
2126 for (
int j = 0;
j < numContacts;
j++ ) {
2160 for ( i = 0; i < 6; i++ ) {
2163 wheelAngles[
i] = 0.0f;
2178 static const char *wheelBodyKeys[] = {
2179 "wheelBodyFrontLeft",
2180 "wheelBodyFrontRight",
2181 "wheelBodyMiddleLeft",
2182 "wheelBodyMiddleRight",
2183 "wheelBodyRearLeft",
2184 "wheelBodyRearRight"
2186 static const char *wheelJointKeys[] = {
2187 "wheelJointFrontLeft",
2188 "wheelJointFrontRight",
2189 "wheelJointMiddleLeft",
2190 "wheelJointMiddleRight",
2191 "wheelJointRearLeft",
2192 "wheelJointRearRight"
2194 static const char *steeringHingeKeys[] = {
2195 "steeringHingeFrontLeft",
2196 "steeringHingeFrontRight",
2197 "steeringHingeRearLeft",
2198 "steeringHingeRearRight"
2201 const char *wheelBodyName, *wheelJointName, *steeringHingeName;
2203 for ( i = 0; i < 6; i++ ) {
2205 if ( !wheelBodyName[0] ) {
2206 gameLocal.
Error(
"idAFEntity_VehicleSixWheels '%s' no '%s' specified",
name.c_str(), wheelBodyKeys[
i] );
2210 gameLocal.
Error(
"idAFEntity_VehicleSixWheels '%s' can't find wheel body '%s'",
name.c_str(), wheelBodyName );
2213 if ( !wheelJointName[0] ) {
2214 gameLocal.
Error(
"idAFEntity_VehicleSixWheels '%s' no '%s' specified",
name.c_str(), wheelJointKeys[
i] );
2218 gameLocal.
Error(
"idAFEntity_VehicleSixWheels '%s' can't find wheel joint '%s'",
name.c_str(), wheelJointName );
2222 for ( i = 0; i < 4; i++ ) {
2224 if ( !steeringHingeName[0] ) {
2225 gameLocal.
Error(
"idAFEntity_VehicleSixWheels '%s' no '%s' specified",
name.c_str(), steeringHingeKeys[
i] );
2229 gameLocal.
Error(
"idAFEntity_VehicleSixWheels '%s': can't find steering hinge '%s'",
name.c_str(), steeringHingeName );
2245 float force = 0.0f, velocity = 0.0f,
steerAngle = 0.0f;
2257 velocity = -velocity;
2264 for ( i = 0; i < 6; i++ ) {
2271 for ( i = 0; i < 3; i++ ) {
2272 wheels[(i<<1)]->SetContactMotorVelocity( velocity * 0.5
f );
2276 for ( i = 0; i < 3; i++ ) {
2277 wheels[1+(i<<1)]->SetContactMotorVelocity( velocity * 0.5
f );
2286 for ( i = 0; i < 4; i++ ) {
2292 rotation.
SetVec( axis[2] );
2300 for ( i = 0; i < 6; i++ ) {
2301 if ( force == 0.0
f ) {
2316 for ( i = 0; i < 6; i++ ) {
2318 for (
int j = 0;
j < numContacts;
j++ ) {
2340 const idEventDef EV_Vehicle_setVelocity(
"setVelocity",
"f" );
2341 const idEventDef EV_Vehicle_setTorque(
"setTorque",
"f" );
2342 const idEventDef EV_Vehicle_setSteeringSpeed(
"setSteeringSpeed",
"f" );
2343 const idEventDef EV_Vehicle_setWaypoint(
"setWaypoint",
"e" );
2347 EVENT( EV_Vehicle_setVelocity, idAFEntity_VehicleAutomated::Event_SetVelocity )
2348 EVENT( EV_Vehicle_setTorque, idAFEntity_VehicleAutomated::Event_SetTorque )
2349 EVENT( EV_Vehicle_setSteeringSpeed, idAFEntity_VehicleAutomated::Event_SetSteeringSpeed )
2350 EVENT( EV_Vehicle_setWaypoint, idAFEntity_VehicleAutomated::Event_SetWayPoint )
2358 void idAFEntity_VehicleAutomated::Spawn(
void ) {
2360 velocity = force = steerAngle = 0.f;
2361 currentSteering = steeringSpeed = 0.f;
2365 spawnArgs.GetFloat(
"velocity",
"150", velocity );
2366 spawnArgs.GetFloat(
"torque",
"200000", force );
2367 spawnArgs.GetFloat(
"steeringSpeed",
"1", steeringSpeed );
2368 spawnArgs.GetFloat(
"originHeight",
"0", originHeight );
2370 PostEventMS( &EV_PostSpawn, 0 );
2378 void idAFEntity_VehicleAutomated::PostSpawn(
void ) {
2380 if ( targets.Num() ) {
2381 waypoint = targets[0].GetEntity();
2390 void idAFEntity_VehicleAutomated::Event_SetVelocity(
float _velocity ) {
2391 velocity = _velocity;
2399 void idAFEntity_VehicleAutomated::Event_SetTorque(
float _torque ) {
2408 void idAFEntity_VehicleAutomated::Event_SetSteeringSpeed(
float _steeringSpeed ) {
2409 steeringSpeed = _steeringSpeed;
2417 void idAFEntity_VehicleAutomated::Event_SetWayPoint(
idEntity *_waypoint ) {
2418 waypoint = _waypoint;
2426 #define HIT_WAYPOINT_THRESHOLD 80.f
2428 void idAFEntity_VehicleAutomated::Think(
void ) {
2432 velocity = force = steerAngle = 0.f;
2437 idVec3 waypoint_origin, vehicle_origin;
2439 float distance_from_waypoint;
2442 vehicle_origin = GetPhysics()->GetOrigin();
2443 vehicle_origin.
z -= originHeight;
2445 waypoint_origin = waypoint->GetPhysics()->GetOrigin();
2447 travel_vector = waypoint_origin - vehicle_origin;
2448 distance_from_waypoint = travel_vector.
Length();
2451 if ( distance_from_waypoint < HIT_WAYPOINT_THRESHOLD ) {
2458 if ( callfunc.
Length() ) {
2460 if ( func !=
NULL ) {
2467 if ( waypoint->targets.Num() ) {
2468 waypoint = waypoint->targets[0].GetEntity();
2478 idAngles vehicle_angles, travel_angles;
2482 vehicle_angles = this->GetPhysics()->GetAxis().ToAngles().
Normalize360();
2487 delta_yaw = vehicle_angles.
yaw - travel_angles.
yaw;
2489 if ( delta_yaw > 0 ) {
2490 delta_yaw = delta_yaw - 360;
2492 delta_yaw = delta_yaw + 360;
2499 idealSteering = delta_yaw;
2502 if (
idMath::Fabs( (idealSteering - currentSteering) ) > steeringSpeed ) {
2503 if ( idealSteering > currentSteering ) {
2504 currentSteering += steeringSpeed;
2506 currentSteering -= steeringSpeed;
2509 currentSteering = idealSteering;
2513 if ( g_vehicleDebug.GetBool() ) {
2521 steerAngle = currentSteering;
2547 steamUpForce = 0.0f;
2548 steamModelDefHandle = -1;
2549 memset( &steamRenderEntity, 0,
sizeof( steamRenderEntity ) );
2587 const char *steamBodyName;
2625 if ( *temp !=
'\0' ) {
2626 if ( !strstr( temp,
"." ) ) {
2691 static
const char *clawConstraintNames[] = {
2692 "claw1",
"claw2",
"claw3",
"claw4"
2715 for ( i = 0; i < 4; i++ ) {
2728 for ( i = 0; i < 4; i++ ) {
2755 for ( i = 0; i < 4; i++ ) {
2758 gameLocal.
Error(
"idClaw_FourFingers '%s': can't find claw constraint '%s'",
name.c_str(), clawConstraintNames[
i] );
2771 for ( i = 0; i < 4; i++ ) {
2786 for ( i = 0; i < 4; i++ ) {
2825 args.
Set(
"angle",
va(
"%f", yaw + 180 ) );
2828 args.
Set(
"spawnclass",
"idAFEntity_Generic" );
2829 if ( af->
model[0] ) {
2832 args.
Set(
"model", fileName );
2834 if ( af->
skin[0] ) {
2837 args.
Set(
"articulatedFigure", fileName );
2838 args.
Set(
"nodrop",
"1" );
2866 if ( ent->
IsType( idAFEntity_Base::Type ) ) {
2888 for ( i = 0; i <
c; i++ ) {
2899 if ( ent->
IsType( idAFEntity_Base::Type ) ) {
2919 static bool GetJointTransform(
void *model,
const idJointMat *frame,
const char *jointName,
idVec3 &origin,
idMat3 &axis ) {
2941 static const char *GetArgString(
const idDict &args,
const idDict *defArgs,
const char *key ) {
2945 if ( !s[0] && defArgs ) {
2961 idVec3 origin, *bodyOrigin, *newBodyOrigin, *modifiedOrigin;
2962 idMat3 axis, *bodyAxis, *newBodyAxis, *modifiedAxis;
2969 const char *classname, *afName, *modelName;
2983 classname = args.
GetString(
"classname" );
2987 afName = GetArgString( args, defArgs,
"articulatedFigure" );
2994 modelName = GetArgString( args, defArgs,
"model" );
3012 int animNum = modelDef->
GetAnim(
"af_pose" );
3025 memset( &ent, 0,
sizeof( ent ) );
3046 for ( i = 0; i < af->
bodies.
Num(); i++ ) {
3052 axis[2].Normalize();
3053 axis[2].NormalVectors( axis[0], axis[1] );
3060 newBodyAxis[
i] = bodyAxis[
i] = axis;
3066 name.
Strip(
"body " );
3067 for ( i = 0; i < af->
bodies.
Num(); i++ ) {
3069 if ( fb->
name.
Icmp( name ) == 0 ) {
3076 sscanf( arg->
GetValue(),
"%f %f %f %f %f %f", &origin.
x, &origin.
y, &origin.
z, &angles.
pitch, &angles.
yaw, &angles.
roll );
3080 meshOrigin = origin - bodyOrigin[
i] * meshAxis;
3083 newBodyOrigin[
i] = origin;
3084 newBodyAxis[
i] = angles.
ToMat3();
3089 originalJoints = (
idJointMat * )_alloca16( numMD5joints *
sizeof( originalJoints[0] ) );
3090 memcpy( originalJoints, ent.
joints, numMD5joints *
sizeof( originalJoints[0] ) );
3095 modifiedOrigin = (
idVec3 *) _alloca16( numMD5joints *
sizeof(
idVec3 ) );
3096 memset( modifiedOrigin, 0, numMD5joints *
sizeof(
idVec3 ) );
3097 modifiedAxis = (
idMat3 *) _alloca16( numMD5joints *
sizeof(
idMat3 ) );
3098 memset( modifiedAxis, 0, numMD5joints *
sizeof(
idMat3 ) );
3101 for ( i = 0; i < af->
bodies.
Num(); i++ ) {
3108 for ( jointNum = 0; jointNum < numMD5joints; jointNum++ ) {
3109 if ( MD5joints[jointNum].name.
Icmp( fb->
jointName ) == 0 ) {
3114 if ( jointNum >= 0 && jointNum < ent.
numJoints ) {
3115 jointMod[ jointNum ] = fb->
jointMod;
3116 modifiedAxis[ jointNum ] = ( bodyAxis[
i] * originalJoints[jointNum].
ToMat3().
Transpose() ).Transpose() * ( newBodyAxis[
i] * meshAxis.
Transpose() );
3118 modifiedOrigin[ jointNum ] = originalJoints[ jointNum ].
ToVec3();
3123 MD5joint = MD5joints + 1;
3124 for( i = 1; i < numMD5joints; i++, MD5joint++ ) {
3126 parentNum = MD5joint->
parent - MD5joints;
3127 idMat3 parentAxis = originalJoints[ parentNum ].
ToMat3();
3131 switch( jointMod[i] ) {
3167 const idEventDef EV_Harvest_SpawnHarvestTrigger(
"<spawnHarvestTrigger>",
NULL );
3170 EVENT( EV_Harvest_SpawnHarvestTrigger, idHarvestable::Event_SpawnHarvestTrigger )
3174 idHarvestable::idHarvestable() {
3179 idHarvestable::~idHarvestable() {
3186 void idHarvestable::Spawn() {
3190 spawnArgs.GetFloat(
"triggersize",
"120", triggersize );
3191 spawnArgs.GetFloat(
"give_delay",
"3", giveDelay);
3195 removeDelay = spawnArgs.GetFloat(
"remove_delay") * 1000.0f;
3197 fxFollowPlayer = spawnArgs.GetBool(
"fx_follow_player",
"1");
3198 fxOrient = spawnArgs.GetString(
"fx_orient");
3203 void idHarvestable::Init(
idEntity* parent) {
3210 this->Bind(parent,
true);
3219 if(parent->
IsType(idActor::Type)) {
3221 head = withHead->GetHeadEntity();
3223 if(parent->
IsType(idAFEntity_WithAttachedHead::Type)) {
3240 PostEventMS( &EV_Harvest_SpawnHarvestTrigger, 0 );
3243 void idHarvestable::Save(
idSaveGame *savefile )
const {
3250 player.Save( savefile );
3254 fx.Save( savefile );
3257 parentEnt.Save(savefile);
3267 player.Restore( savefile );
3268 savefile->
ReadInt( startTime );
3270 savefile->
ReadBool( fxFollowPlayer );
3271 fx.Restore( savefile );
3274 parentEnt.Restore(savefile);
3277 void idHarvestable::SetParent(
idEntity* parent) {
3281 void idHarvestable::Think() {
3283 idEntity* parent = parentEnt.GetEntity();
3293 if(startTime &&
gameLocal.slow.
time - startTime > giveDelay && ! given) {
3294 idPlayer *thePlayer = player.GetEntity();
3296 thePlayer->
Give(spawnArgs.GetString(
"give_item"), spawnArgs.GetString(
"give_value"));
3297 thePlayer->harvest_lock =
false;
3301 if(startTime &&
gameLocal.slow.
time - startTime > removeDelay) {
3306 if(fxFollowPlayer) {
3311 if(GetFxOrientationAxis(orientAxisLocal)) {
3325 void idHarvestable::Gib() {
3327 idEntity* parent = parentEnt.GetEntity();
3341 void idHarvestable::BeginBurn() {
3343 idEntity* parent = parentEnt.GetEntity();
3348 if(!spawnArgs.GetBool(
"burn")) {
3362 if(parent->
IsType(idActor::Type)) {
3364 head = withHead->GetHeadEntity();
3366 if(parent->
IsType(idAFEntity_WithAttachedHead::Type)) {
3389 void idHarvestable::BeginFX() {
3390 if(strlen(spawnArgs.GetString(
"fx")) <= 0) {
3397 if(GetFxOrientationAxis(orientAxisLocal)) {
3398 orientAxis = &orientAxisLocal;
3408 void idHarvestable::CalcTriggerBounds(
float size,
idBounds &bounds ) {
3410 idEntity* parent = parentEnt.GetEntity();
3422 bool idHarvestable::GetFxOrientationAxis(
idMat3& mat) {
3424 idEntity* parent = parentEnt.GetEntity();
3429 idPlayer *thePlayer = player.GetEntity();
3431 if(!fxOrient.Icmp(
"up")) {
3437 idMat3 temp(left.
x, left.
y, left.
z, up.
x, up.
y, up.
z, grav.
x, grav.
y, grav.
z);
3442 }
else if(!fxOrient.Icmp(
"weapon")) {
3460 idMat3 temp(left.
x, left.
y, left.
z, up.
x, up.
y, up.
z, toPlayer.
x, toPlayer.
y, toPlayer.
z);
3465 }
else if(!fxOrient.Icmp(
"player")) {
3474 left = toPlayer.
Cross(up);
3475 up = left.
Cross(toPlayer);
3480 idMat3 temp(left.
x, left.
y, left.
z, up.
x, up.
y, up.
z, toPlayer.
x, toPlayer.
y, toPlayer.
z);
3496 void idHarvestable::Event_SpawnHarvestTrigger(
void ) {
3499 idEntity* parent = parentEnt.GetEntity();
3504 CalcTriggerBounds( triggersize, bounds );
3521 idEntity* parent = parentEnt.GetEntity();
3525 if(parent->
IsType(idAFEntity_Gibbable::Type)) {
3527 if(gibParent->IsGibbed())
3532 if(!startTime && other && other->
IsType(idPlayer::Type)) {
3535 if(thePlayer->harvest_lock) {
3542 bool okToGive =
true;
3543 idStr requiredWeapons = spawnArgs.GetString(
"required_weapons");
3545 if(requiredWeapons.
Length() > 0) {
3546 idStr playerWeap = thePlayer->GetCurrentWeapon();
3547 if(playerWeap.
Length() == 0 || requiredWeapons.
Find(playerWeap,
false) == -1) {
3553 if(thePlayer->CanGive(spawnArgs.GetString(
"give_item"), spawnArgs.GetString(
"give_value"))) {
3558 thePlayer->harvest_lock =
true;
3580 trigger->SetContents( 0 );
3595 const idEventDef EV_Harvest_SpawnHarvestEntity(
"<spawnHarvestEntity>",
NULL );
3598 EVENT( EV_Harvest_SpawnHarvestEntity, idAFEntity_Harvest::Event_SpawnHarvestEntity )
3606 idAFEntity_Harvest::idAFEntity_Harvest() {
3615 idAFEntity_Harvest::~idAFEntity_Harvest() {
3617 if ( harvestEnt.GetEntity() ) {
3618 harvestEnt.GetEntity()->PostEventMS( &
EV_Remove, 0 );
3628 void idAFEntity_Harvest::Save(
idSaveGame *savefile )
const {
3629 harvestEnt.Save(savefile);
3637 void idAFEntity_Harvest::Restore(
idRestoreGame *savefile ) {
3638 harvestEnt.Restore(savefile);
3649 void idAFEntity_Harvest::Spawn(
void ) {
3651 PostEventMS( &EV_Harvest_SpawnHarvestEntity, 0 );
3659 void idAFEntity_Harvest::Think(
void ) {
3665 void idAFEntity_Harvest::Event_SpawnHarvestEntity(
void ) {
3671 harvestEnt =
static_cast<idHarvestable *
>(temp);
3674 if(harvestEnt.GetEntity()) {
3676 harvestEnt.GetEntity()->Init(
this);
3677 harvestEnt.GetEntity()->BecomeActive(
TH_THINK );
3681 void idAFEntity_Harvest::Gib(
const idVec3 &dir,
const char *damageDefName ) {
3682 if(harvestEnt.GetEntity()) {
3684 harvestEnt.GetEntity()->Gib();
virtual const idVec3 & GetOrigin(int id=0) const =0
idPlayer * GetLocalPlayer() const
void SetupPolygon(const idVec3 *v, const int count)
void SetupPose(idEntity *ent, int time)
int skeletonModelDefHandle
renderEntity_t renderEntity
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
jointHandle_t steeringWheelJoint
void SetSteerAngle(const float degrees)
int GetContents(void) const
float GetFloat(const char *key, const char *defaultString="0") const
virtual void Gib(const idVec3 &dir, const char *damageDefName)
idMat3 ToMat3(void) const
void InitSkeletonModel(void)
bool GetJointTransform(jointHandle_t jointHandle, int currenttime, idVec3 &offset, idMat3 &axis)
void WriteString(const char *string)
bool EmitSmoke(const idDeclParticle *smoke, const int startTime, const float diversity, const idVec3 &origin, const idMat3 &axis, int timeGroup)
idAngles & Normalize360(void)
void SetAnchor(const idVec3 &worldPosition)
int GetInt(const char *key, const char *defaultString="0") const
virtual idRenderModel * InstantiateDynamicModel(const struct renderEntity_s *ent, const struct viewDef_s *view, idRenderModel *cachedModel)=0
void Event_SetConstraintPosition(const char *name, const idVec3 &pos)
bool PostEventSec(const idEventDef *ev, float time)
virtual void InitTool(const toolFlag_t tool, const idDict *dict)=0
virtual void AF_UpdateEntities(const char *fileName)
void SetMotorForce(const float force)
assert(prefInfo.fullscreenBtn)
const idDict * FindEntityDefDict(const char *name, bool makeDefault=true) const
idList< int > modelDefHandles
virtual const idVec3 & GetGravityNormal(void) const =0
idAFConstraint_Hinge * steering[2]
void Restore(idRestoreGame *savefile)
#define CLIPMODEL_ID_TO_JOINT_HANDLE(id)
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
void Restore(idRestoreGame *savefile)
virtual void SetContents(int contents, int id=-1)=0
void SetSteerSpeed(const float speed)
const idEventDef EV_PostSpawn("<postspawn>", NULL)
void WriteObject(const idClass *obj)
void Save(idSaveGame *savefile) const
virtual void DebugArrow(const idVec4 &color, const idVec3 &start, const idVec3 &end, int size, const int lifetime=0)=0
idVec3 GetCenter(void) const
int GetNumBodies(void) const
idAFConstraint * GetConstraint(const char *constraintName) const
void SetComeToRest(bool enable)
void SetContents(int newContents)
virtual void UnlinkCombat(void)
struct idEntity::entityFlags_s fl
idCVar g_vehicleTireFriction("g_vehicleTireFriction","0.8", CVAR_GAME|CVAR_FLOAT,"")
void BindToJoint(idEntity *master, const char *jointname, bool orientated)
type * GetEntity(void) const
virtual void Finish(const getJointTransform_t GetJointTransform, const idJointMat *frame, void *model) const
void DelayedStart(int delay)
virtual void AF_UndoChanges(void)
void SetShaderParm(int parmnum, float value)
void LoadState(const idDict &args)
idSmokeParticles * smokeParticles
float GetFloat(void) const
void SetVec(const idVec3 &rotationVec)
const idStr & GetKey(void) const
bool UpdateAnimation(void)
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
const idEventDef EV_Activate("activate","e")
const idDeclParticle * dustSmoke
virtual qhandle_t AddEntityDef(const renderEntity_t *re)=0
idRenderModel * ModelHandle(void) const
~idAFEntity_SteamPipe(void)
void SetCombatModel(void)
idMat3 Transpose(void) const
void SetAxis(const idMat3 &axis)
void void void void void Error(const char *fmt,...) const id_attribute((format(printf
const int ANIMCHANNEL_ALL
void SetSteerAngle(const float degrees)
void AssureSize(int newSize)
bool IsType(const idTypeInfo &c) const
void Setup(const char *name, idAFBody *body, const idVec3 &origin, const idMat3 &axis, idClipModel *clipModel)
void Set(const float x, const float y, const float z)
void SetForcePushable(const bool enable)
void Event_StopFingers(void)
idAFBody * GetBody(const char *bodyName) const
const idMat3 & GetWorldAxis(void) const
const char * GetAFName(void) const
const idKeyValue * MatchPrefix(const char *prefix, const idKeyValue *lastMatch=NULL) const
idVec3 GetEyePosition(void) const
static void DropItems(idAnimatedEntity *ent, const char *type, idList< idEntity * > *list)
~idAFEntity_Gibbable(void)
int BodyForClipModelId(int id) const
const idEventDef EV_Gib("gib","s")
bool ProcessEvent(const idEventDef *ev)
void SetShafts(const idVec3 &cardanShaft1, const idVec3 &cardanShaft2)
bool CreateFrame(int animtime, bool force)
const idEventDef EV_StopFingers("stopFingers")
void SetCombatModel(void)
static float ClampFloat(float min, float max, float value)
void AddBindConstraints(void)
jointHandle_t GetJointHandle(const char *name) const
const idEventDef EV_SetAngularVelocity("setAngularVelocity","v")
const char * GetName(void) const
void ReadJoint(jointHandle_t &value)
void ReadBool(bool &value)
jointHandle_t wheelJoints[6]
void SetFriction(const float f)
virtual bool GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis)
static float Sqrt(float x)
const idVec3 GetWheelOrigin(void) const
idPhysics_AF * GetPhysics(void)
const int SHADERPARM_GREEN
virtual void FreeModelDef(void)
virtual const char * Name() const =0
virtual void Gib(const idVec3 &dir, const char *damageDefName)
virtual void ShowEditingDialog(void)
GLuint GLuint GLsizei GLenum type
const idDeclSkin * GetSkin(void) const
void SetJointPos(jointHandle_t jointnum, jointModTransform_t transform_type, const idVec3 &pos)
void SetSoundVolume(float volume)
void Set(const char *key, const char *value)
virtual void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
idVec3 Cross(const idVec3 &a) const
void InitSteamRenderEntity(void)
~idAFEntity_WithAttachedHead()
virtual void SpawnGibs(const idVec3 &dir, const char *damageDefName)
void Restore(idRestoreGame *savefile)
void WriteClipModel(const class idClipModel *clipModel)
#define MASK_MONSTERSOLID
virtual void UnlinkCombat(void)
void OrthogonalBasis(idVec3 &left, idVec3 &up) const
jointHandle_t wheelJoints[4]
void SetAnimator(idAnimator *a)
void WriteVec3(const idVec3 &vec)
void SetTranslation(const idVec3 &t)
const idMat3 & GetAxis(int id=0) const
virtual void AddForce(idEntity *ent, int id, const idVec3 &point, const idVec3 &force)
virtual void ANIM_CreateAnimFrame(const idRenderModel *model, const idMD5Anim *anim, int numJoints, idJointMat *frame, int time, const idVec3 &offset, bool remove_origin_offset)
int Icmp(const char *text) const
declAFJointMod_t jointMod
void SetName(const char *name)
void RemoveBindConstraints(void)
bool Give(const char *statname, const char *value)
#define EVENT(event, function)
void Restore(idRestoreGame *savefile)
void Restore(idRestoreGame *savefile)
bool Load(idEntity *ent, const char *fileName)
idClipModel * combatModel
void SetJointAxis(jointHandle_t jointnum, jointModTransform_t transform_type, const idMat3 &mat)
const idEventDef EV_SetLinearVelocity("setLinearVelocity","v")
void WriteJoint(const jointHandle_t value)
void SetSuspension(const float up, const float down, const float k, const float d, const float f)
void SetRotation(const idMat3 &m)
void WriteBool(const bool value)
virtual void FreeModelDef(void)
bool IsHidden(void) const
void SetGibTime(int _time)
void Event_Gib(const char *damageDefName)
idEntity * SpawnEntityType(const idTypeInfo &classdef, const idDict *args=NULL, bool bIsClientReadSnapshot=false)
virtual const idMD5Joint * GetJoints(void) const =0
idAFConstraint_Hinge * fingers[4]
void SetClipMask(const int mask)
const int SHADERPARM_BLUE
void GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis) const
void AddForce(idEntity *ent, int id, const idVec3 &point, const idVec3 &force)
void Restore(idRestoreGame *savefile)
void Translate(const idVec3 &translation)
const idEventDef EV_SetFingerAngle("setFingerAngle","f")
idClipModel * combatModel
void SetSelf(idEntity *e)
virtual void FreeEntityDef(qhandle_t entityHandle)=0
virtual void AddDamageEffect(const trace_t &collision, const idVec3 &velocity, const char *damageDefName)
virtual bool LoadAF(void)
void SetModelForId(int id, const idStr &modelName)
virtual void Restore(idRestoreGame *saveFile)
virtual void AddForce(idEntity *ent, int id, const idVec3 &point, const idVec3 &force)
virtual void Present(void)
void SetOwner(idEntity *newOwner)
idPhysics * GetPhysics(void) const
void KeepRunningPhysics(void)
idCVar g_vehicleVelocity("g_vehicleVelocity","1000", CVAR_GAME|CVAR_FLOAT,"")
void Restore(idRestoreGame *savefile)
void Use(idPlayer *player)
idAngles ToAngles(void) const
const idVec3 & ToVec3(void) const
void SetSkin(const idDeclSkin *skin)
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)
idStr & StripFileExtension(void)
idVec3 ToForward(void) const
idRenderModel * skeletonModel
void SetSelected(idEntity *ent)
void SetContents(int contents, int id=-1)
bool StartSound(const char *soundName, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
idCVar g_bloodEffects("g_bloodEffects","1", CVAR_GAME|CVAR_ARCHIVE|CVAR_BOOL,"show blood splats, sprays and gibs")
void Save(idSaveGame *savefile) const
void SaveState(idDict &args) const
void GetImpactInfo(idEntity *ent, int id, const idVec3 &point, impactInfo_t *info)
virtual renderEntity_t * GetRenderEntity(void)
void SetPhysics(idPhysics *phys)
void SetConstraintPosition(const char *name, const idVec3 &pos)
virtual void GetImpactInfo(idEntity *ent, int id, const idVec3 &point, impactInfo_t *info)
idVec3 ToVec3(void) const
void WriteFloat(const float value)
idPhysics_AF * GetAFPhysics(void)
static float Fabs(float f)
bool GetBool(const char *key, const char *defaultString="0") const
const idMD5Anim * MD5Anim(int num) const
const idMD5Joint * parent
virtual void GetImpactInfo(idEntity *ent, int id, const idVec3 &point, impactInfo_t *info)
idAnimBlend * CurrentAnim(int channelNum)
const idDeclSkin * customSkin
virtual idRenderModel * FindModel(const char *modelName)=0
static void DropAFs(idEntity *ent, const char *type, idList< idEntity * > *list)
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
virtual void GetImpactInfo(idEntity *ent, int id, const idVec3 &point, impactInfo_t *info)
GLsizei GLsizei GLenum GLenum const GLvoid * data
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
void SetContactMotorVelocity(float vel)
~idAFEntity_VehicleSimple(void)
const int SHADERPARM_TIME_OF_DEATH
virtual void ProjectOverlay(const idVec3 &origin, const idVec3 &dir, float size, const char *material)
virtual void AddDamageEffect(const trace_t &collision, const idVec3 &velocity, const char *damageDefName)
virtual void SetOrigin(const idVec3 &newOrigin, int id=-1)=0
const idAnim * GetAnim(int index) const
void CycleAnim(int channelNum, int animnum, int currenttime, int blendtime)
const idVec3 & GetGravity(void) const
idCVar g_vehicleSuspensionUp("g_vehicleSuspensionUp","32", CVAR_GAME|CVAR_FLOAT,"")
const idEventDef EV_SetConstraintPosition("SetConstraintPosition","sv")
void Save(idSaveGame *savefile) const
virtual idRenderModel * AF_CreateMesh(const idDict &args, idVec3 &meshOrigin, idMat3 &meshAxis, bool &poseIsSet)
const idStr & GetValue(void) const
void Save(idSaveGame *savefile) const
virtual const idMat3 & GetAxis(int id=0) const =0
virtual idAnimator * GetAnimator(void)
virtual void UpdateEntityDef(qhandle_t entityHandle, const renderEntity_t *re)=0
float NormalizeFast(void)
const idEventDef EV_Weapon_State("weaponState","sd")
virtual void DrawText(const char *text, const idVec3 &origin, float scale, const idVec4 &color, const idMat3 &viewAxis, const int align=1, const int lifetime=0, bool depthTest=false)=0
int Find(const char c, int start=0, int end=-1) const
jointHandle_t attachJoint
idLinkList< idEntity > spawnNode
void SetBool(const char *key, bool val)
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
void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)
void SetAnchor(const idVec3 &worldPosition)
void Event_Activate(idEntity *activator)
const idVec3 & GetVisualOffset(void) const
void LockWorldConstraints(const bool lock)
idAFConstraint_Suspension * suspension[4]
virtual void LoadModel()=0
virtual idBounds Bounds(const struct renderEntity_s *ent=NULL) const =0
idLinkList< idEntity > spawnedEntities
void SetPosition(idPhysics *physics, int id, const idVec3 &point)
void BindToBody(idEntity *master, int bodyId, bool orientated)
virtual idClipModel * GetClipModel(int id=0) const =0
const char * ToString(int precision=2) const
void WriteInt(const int value)
virtual void Present(void)
void SetCombatContents(bool enable)
virtual void Save(idSaveGame *saveFile) const
idDeclManager * declManager
void WriteMat3(const idMat3 &mat)
void EnableMotor(const bool enable)
int GetBodyId(idAFBody *body) const
void ReadMat3(idMat3 &mat)
idEntity * entities[MAX_GENTITIES]
bool IsLoaded(void) const
idMat3 ToMat3(void) const
virtual int GetNumDecls(declType_t type)=0
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
virtual void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
int BodyForClipModelId(int id) const
void ReadClipModel(idClipModel *&clipModel)
idClipModel * GetCombatModel(void) const
int Append(const type &obj)
void PlayIdleAnim(int blendTime)
virtual void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
idRenderModelManager * renderModelManager
void AddConstraint(idAFConstraint *constraint)
virtual bool IsDefaultModel() const =0
void SetForce(const idVec3 &force)
void SetClipMask(int mask, int id=-1)
void SetConeLimit(const idVec3 &coneAxis, const float coneAngle, const idVec3 &body1Axis)
idList< idDeclAF_Body * > bodies
void LoadState(const idDict &args)
virtual bool IsLoaded()=0
virtual const idDecl * DeclByIndex(declType_t type, int index, bool forceParse=true)=0
idAFEntity_ClawFourFingers(void)
virtual void LinkCombat(void)
void SetContactMotorForce(float force)
idCVar g_vehicleSuspensionKCompress("g_vehicleSuspensionKCompress","200", CVAR_GAME|CVAR_FLOAT,"")
void Restore(idRestoreGame *savefile)
bool LoadModel(const char *name)
const idMat3 & ToMat3(void) const
virtual void AddForce(idEntity *ent, int id, const idVec3 &point, const idVec3 &force)
void BuildChain(const idStr &name, const idVec3 &origin, float linkLength, float linkWidth, float density, int numLinks, bool bindToWorld=true)
idMat3 ToMat3(void) const
void Save(idSaveGame *savefile) const
virtual const idBounds & GetAbsBounds(int id=-1) const =0
virtual bool AF_SpawnEntity(const char *fileName)
idAFConstraint_Hinge * steering[4]
void Save(idSaveGame *savefile) const
virtual ~idAFEntity_Base(void)
jointHandle_t wheelJoints[4]
bool GetJointWorldTransform(jointHandle_t jointHandle, int currentTime, idVec3 &offset, idMat3 &axis)
void Translate(const idVec3 &translation, int id=-1)
virtual void Evaluate(int time)
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
virtual void LinkCombat(void)
GLsizei const GLcharARB const GLint * length
void UpdateAnimation(void)
void Event_SetFingerAngle(float angle)
void Save(idSaveGame *savefile) const
void ReadVec3(idVec3 &vec)
idEntityPtr< idAFAttachment > head
void SetBody(idEntity *bodyEnt, const char *headModel, jointHandle_t attachJoint)
const char * c_str(void) const
void Event_Gib(const char *damageDefName)
idRotation ToRotation(void) const
const idAnim * GetAnim(int index) const
void ApplyImpulse(idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse)
void BecomeActive(int flags)
virtual int NumJoints(void) const =0
void RemoveBindConstraints(void)
const idEventDef EV_Remove("<immediateremove>", NULL)
void Save(idSaveGame *savefile) const
function_t * FindFunction(const char *name) const
~idAFEntity_Generic(void)
void SetFrame(int channelNum, int animnum, int frame, int currenttime, int blendtime)
virtual void Present(void)
const idEventDef EV_Gibbed("<gibbed>")
virtual const idDeclSkin * FindSkin(const char *name, bool makeDefault=true)=0
virtual bool IsAtRest(void) const =0
void AddBindConstraints(void)
bool CheatsOk(bool requirePlayer=true)
void SetAngularVelocity(const idVec3 &newAngularVelocity, int id=0)
idBounds & ExpandSelf(const float d)
void SetGravity(const idVec3 &newGravity)
virtual void DebugBounds(const idVec4 &color, const idBounds &bounds, const idVec3 &org=vec3_origin, const int lifetime=0)=0
idClipModel * GetCombatModel(void) const
idVec3 GetPointVelocity(const idVec3 &point) const
float GetSteerAngle(void)
qhandle_t steamModelDefHandle
idEntity * GetBody(void) const
idRenderWorld * gameRenderWorld
void SaveState(idDict &args) const
char * va(const char *fmt,...)
void Rotate(const idRotation &rotation, int id=-1)
static idEntityFx * StartFx(const char *fx, const idVec3 *useOrigin, const idMat3 *useAxis, idEntity *ent, bool bind)
virtual bool GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis)
renderEntity_t steamRenderEntity
void SetOrigin(const idVec3 &org)
bool PostEventMS(const idEventDef *ev, int time)
virtual void SetModel(const char *modelname)
idCVar g_vehicleForce("g_vehicleForce","50000", CVAR_GAME|CVAR_FLOAT,"")
virtual void ProjectOverlay(const idVec3 &origin, const idVec3 &dir, float size, const char *material)
const idEventDef EV_Touch("<touch>","et")
bool IsActive(void) const
idCVar g_vehicleSuspensionDown("g_vehicleSuspensionDown","20", CVAR_GAME|CVAR_FLOAT,"")
float shaderParms[MAX_ENTITY_SHADER_PARMS]
void ReadString(idStr &string)
void Event_Activate(idEntity *activator)
idList< idRenderModel * > modelHandles
void UpdateDamageEffects(void)
virtual void UnlinkCombat(void)
void SetMotorVelocity(const float vel)
void BecomeInactive(int flags)
idEntityPtr< idWeapon > weapon
#define JOINT_HANDLE_TO_CLIPMODEL_ID(id)
virtual bool UpdateAnimationControllers(void)
virtual ~idAFAttachment(void)
const idVec3 & GetLinearVelocity(void) const
idCVar g_vehicleSuspensionDamping("g_vehicleSuspensionDamping","400", CVAR_GAME|CVAR_FLOAT,"")
void StopSound(const s_channelType channel, bool broadcast)
void Save(idSaveGame *savefile) const
void Restore(idRestoreGame *savefile)
const idVec3 & GetOrigin(int id=0) const
void ReadObject(idClass *&obj)
void SetAngle(const float rotationAngle)
virtual void SetAxis(const idMat3 &newAxis, int id=-1)=0
virtual void LinkCombat(void)
int GetBodyContactConstraints(const int id, idAFConstraint_Contact *contacts[], int maxContacts) const