GL - fixing with explosivecrate and massdriver

This commit is contained in:
Erik Persson 2014-02-21 15:02:42 +01:00
parent 4360519be7
commit ed3152057c
7 changed files with 42 additions and 39 deletions

View File

@ -56,19 +56,14 @@ void AttatchmentMassDriver::Update(float dt)
//update position of heldObject if there is an object being held //update position of heldObject if there is an object being held
if(hasObject) if(hasObject)
{ {
//Oyster::Physics::ICustomBody::State state;
//state = heldObject->GetState();
Oyster::Math::Float3 ownerPos = owner->GetPosition(); Oyster::Math::Float3 ownerPos = owner->GetPosition();
Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState(); Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState();
Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2]; Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2];
up *= -0.3f; up *= -0.3f;
Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*5); Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*2);
//state.centerPos = pos;
heldObject->SetPosition(pos); heldObject->SetPosition(pos);
heldObject->SetLinearVelocity(Oyster::Math::Float3::null); heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
//heldObject->SetState(state);
} }
} }
@ -149,7 +144,7 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
{ {
Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*5; Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*2;
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10); Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10);
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp);

View File

@ -108,13 +108,31 @@ using namespace GameLogic;
obj.SetPosition(target); obj.SetPosition(target);
} }
void ExplosiveCrate::ExplosiveCrateCollision(Oyster::Physics::ICustomBody *rigidBodyCrate, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) void ExplosiveCrate::ExplosiveCrateCollision(Oyster::Physics::ICustomBody *objA, Oyster::Physics::ICustomBody *objB, Oyster::Math::Float kineticEnergyLoss)
{ {
int forceThreashHold = 200000; //how much force for the box to explode of the impact
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed? Object *realObjA = ((Object*)(objA->GetCustomTag()));
Object *realObjB = (Object*)objB->GetCustomTag(); //needs to be changed?
ExplosiveCrate* crate;
switch (realObj->GetObjectType()) if(!realObjA)
return;
if(!realObjB)
return;
//check who is player and who is the object
if(realObjA->GetObjectType() == ObjectSpecialType::ObjectSpecialType_RedExplosiveBox)
{
crate = (ExplosiveCrate*)realObjA;
}
else
{
crate = (ExplosiveCrate*)realObjB;
realObjB = realObjA;
}
switch (realObjB->GetObjectType())
{ {
case ObjectSpecialType::ObjectSpecialType_Generic: case ObjectSpecialType::ObjectSpecialType_Generic:
break; break;
@ -122,29 +140,15 @@ using namespace GameLogic;
break; break;
case ObjectSpecialType::ObjectSpecialType_Player: case ObjectSpecialType::ObjectSpecialType_Player:
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag()); if(crate->hasExploaded) return;
Oyster::Math::Float3 pos = crate->GetRigidBody()->GetState().centerPos;
Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos;
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius); Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius);
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode); Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
crate->hasExploaded = true;
delete hitSphere; delete hitSphere;
break; break;
} }
/*if(kineticEnergyLoss > forceThreashHold)
{
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos;
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius);
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
delete hitSphere;
}*/
} }
void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args) void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args)
@ -155,16 +159,17 @@ using namespace GameLogic;
Oyster::Math::Float3 explosionCenterPos = ExplosionSource->GetPosition(); Oyster::Math::Float3 explosionCenterPos = ExplosionSource->GetPosition();
Oyster::Math::Float3 hitObjectPos = obj->GetState().centerPos; Oyster::Math::Float3 hitObjectPos = obj->GetState().centerPos;
Oyster::Math::Float3 force = (((hitObjectPos- explosionCenterPos).GetNormalized()) * ExplosionSource->pushForceMagnitude); Oyster::Math::Float3 force = (((hitObjectPos- explosionCenterPos).GetNormalized()) * ExplosionSource->pushForceMagnitude);
if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player) if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player)
{ {
Player *hitPlayer = (Player*)realObj; Player *hitPlayer = (Player*)realObj;
//hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision()); //hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
hitPlayer->GetRigidBody()->ApplyImpulse(force);
//do shredding damage //do shredding damage
} }
realObj->GetRigidBody()->ApplyImpulse(force);
} }
@ -181,11 +186,11 @@ using namespace GameLogic;
Oyster::Math::Float angularFactor = deltaPos.GetNormalized().Dot( (objPrevVel - playerPrevVel).GetNormalized()); Oyster::Math::Float angularFactor = deltaPos.GetNormalized().Dot( (objPrevVel - playerPrevVel).GetNormalized());
Oyster::Math::Float impactPower = deltaSpeed * angularFactor; Oyster::Math::Float impactPower = deltaSpeed * angularFactor;
Oyster::Math::Float damageFactor = 0.1f; Oyster::Math::Float damageFactor = 0.01f;
int damageDone = 0; int damageDone = 0;
int forceThreashHold = 100; //FIX: balance this int forceThreashHold = 30; //FIX: balance this
if(impactPower > forceThreashHold) //should only take damage if the force is high enough if(impactPower > forceThreashHold) //should only take damage if the force is high enough
{ {
@ -198,7 +203,7 @@ using namespace GameLogic;
damageDone = (impactPower * obj.GetRigidBody()->GetState().mass)* damageFactor; damageDone = (impactPower * obj.GetRigidBody()->GetState().mass)* damageFactor;
} }
//player.DamageLife(damageDone); player.DamageLife(damageDone);
} }
} }

View File

@ -7,6 +7,7 @@ ExplosiveCrate::ExplosiveCrate(void)
{ {
this->pushForceMagnitude = 0; this->pushForceMagnitude = 0;
this->ExplosionRadius = 0; this->ExplosionRadius = 0;
this->hasExploaded = false;
} }
ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float extraDamageOnCollision, Oyster::Math::Float pushForceMagnitude, Oyster::Math::Float ExplosionRadius) ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpecialType type, int objectID,Oyster::Math::Float extraDamageOnCollision, Oyster::Math::Float pushForceMagnitude, Oyster::Math::Float ExplosionRadius)
@ -15,6 +16,7 @@ ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpe
this->extraDamageOnCollision = extraDamageOnCollision; this->extraDamageOnCollision = extraDamageOnCollision;
this->pushForceMagnitude = pushForceMagnitude; this->pushForceMagnitude = pushForceMagnitude;
this->ExplosionRadius = ExplosionRadius; this->ExplosionRadius = ExplosionRadius;
this->hasExploaded = false;
} }
ExplosiveCrate::~ExplosiveCrate(void) ExplosiveCrate::~ExplosiveCrate(void)

View File

@ -18,6 +18,7 @@ namespace GameLogic
private: private:
Oyster::Math::Float pushForceMagnitude; Oyster::Math::Float pushForceMagnitude;
Oyster::Math::Float ExplosionRadius; Oyster::Math::Float ExplosionRadius;
bool hasExploaded;
}; };

View File

@ -70,8 +70,8 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
case ObjectSpecialType_RedExplosiveBox: case ObjectSpecialType_RedExplosiveBox:
{ {
Oyster::Math::Float dmg = 50; Oyster::Math::Float dmg = 50;
Oyster::Math::Float force = 50; Oyster::Math::Float force = 500;
Oyster::Math::Float radie = 50; Oyster::Math::Float radie = 3;
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie); gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
} }
break; break;

View File

@ -36,8 +36,8 @@ GameSession::GameSession()
this->isCreated = false; this->isCreated = false;
this->isRunning = false; this->isRunning = false;
this->gameSession = this; this->gameSession = this;
this->logicFrameTime = DELTA_TIME_20; this->logicFrameTime = DELTA_TIME_60;
this->networkFrameTime = DELTA_TIME_20; this->networkFrameTime = DELTA_TIME_60;
this->networkTimer.reset(); this->networkTimer.reset();
this->logicTimer.reset(); this->logicTimer.reset();

View File

@ -32,7 +32,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
GameServerAPI::GameSetGameMode(L"free-for-all"); GameServerAPI::GameSetGameMode(L"free-for-all");
GameServerAPI::GameSetGameName(L"DebugServer"); GameServerAPI::GameSetGameName(L"DebugServer");
GameServerAPI::GameSetGameTime(15); GameServerAPI::GameSetGameTime(15);
GameServerAPI::GameSetMapName(L"2ofAll.bias"); GameServerAPI::GameSetMapName(L"erik_250.bias");
GameServerAPI::GameSetMaxClients(10); GameServerAPI::GameSetMaxClients(10);
if(GameServerAPI::GameStart(true)) if(GameServerAPI::GameStart(true))