From ed3152057c27d9e862d104bbdcb4a11203316536 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 21 Feb 2014 15:02:42 +0100 Subject: [PATCH] GL - fixing with explosivecrate and massdriver --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 9 +-- Code/Game/GameLogic/CollisionManager.cpp | 59 ++++++++++--------- Code/Game/GameLogic/ExplosiveCrate.cpp | 2 + Code/Game/GameLogic/ExplosiveCrate.h | 1 + Code/Game/GameLogic/Level.cpp | 4 +- .../Implementation/GameSession_General.cpp | 4 +- .../GameServerDebugEnvironment/Source.cpp | 2 +- 7 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index a092c81e..b988451f 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -56,19 +56,14 @@ void AttatchmentMassDriver::Update(float dt) //update position of heldObject if there is an object being held if(hasObject) { - //Oyster::Physics::ICustomBody::State state; - //state = heldObject->GetState(); Oyster::Math::Float3 ownerPos = owner->GetPosition(); Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState(); Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2]; up *= -0.3f; - Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*5); - - //state.centerPos = pos; + Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*2); heldObject->SetPosition(pos); 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) { - 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::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 3e042765..1ab9afbd 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -108,13 +108,31 @@ using namespace GameLogic; 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: break; @@ -122,29 +140,15 @@ using namespace GameLogic; break; case ObjectSpecialType::ObjectSpecialType_Player: - ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag()); - - - Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos; + if(crate->hasExploaded) return; + Oyster::Math::Float3 pos = crate->GetRigidBody()->GetState().centerPos; Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius); Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode); - + crate->hasExploaded = true; delete hitSphere; 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) @@ -155,16 +159,17 @@ using namespace GameLogic; Oyster::Math::Float3 explosionCenterPos = ExplosionSource->GetPosition(); Oyster::Math::Float3 hitObjectPos = obj->GetState().centerPos; Oyster::Math::Float3 force = (((hitObjectPos- explosionCenterPos).GetNormalized()) * ExplosionSource->pushForceMagnitude); - + + if(realObj->GetObjectType() == ObjectSpecialType::ObjectSpecialType_Player) { Player *hitPlayer = (Player*)realObj; - //hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision()); + hitPlayer->GetRigidBody()->ApplyImpulse(force); //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 impactPower = deltaSpeed * angularFactor; - Oyster::Math::Float damageFactor = 0.1f; + Oyster::Math::Float damageFactor = 0.01f; 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 { @@ -198,7 +203,7 @@ using namespace GameLogic; damageDone = (impactPower * obj.GetRigidBody()->GetState().mass)* damageFactor; } - //player.DamageLife(damageDone); + player.DamageLife(damageDone); } } diff --git a/Code/Game/GameLogic/ExplosiveCrate.cpp b/Code/Game/GameLogic/ExplosiveCrate.cpp index d236d400..cf011ce4 100644 --- a/Code/Game/GameLogic/ExplosiveCrate.cpp +++ b/Code/Game/GameLogic/ExplosiveCrate.cpp @@ -7,6 +7,7 @@ ExplosiveCrate::ExplosiveCrate(void) { this->pushForceMagnitude = 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) @@ -15,6 +16,7 @@ ExplosiveCrate::ExplosiveCrate(Oyster::Physics::ICustomBody *rigidBody,ObjectSpe this->extraDamageOnCollision = extraDamageOnCollision; this->pushForceMagnitude = pushForceMagnitude; this->ExplosionRadius = ExplosionRadius; + this->hasExploaded = false; } ExplosiveCrate::~ExplosiveCrate(void) diff --git a/Code/Game/GameLogic/ExplosiveCrate.h b/Code/Game/GameLogic/ExplosiveCrate.h index 75afdc4a..b6054266 100644 --- a/Code/Game/GameLogic/ExplosiveCrate.h +++ b/Code/Game/GameLogic/ExplosiveCrate.h @@ -18,6 +18,7 @@ namespace GameLogic private: Oyster::Math::Float pushForceMagnitude; Oyster::Math::Float ExplosionRadius; + bool hasExploaded; }; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index c9938dbd..ca5ccf32 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -70,8 +70,8 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody) case ObjectSpecialType_RedExplosiveBox: { Oyster::Math::Float dmg = 50; - Oyster::Math::Float force = 50; - Oyster::Math::Float radie = 50; + Oyster::Math::Float force = 500; + Oyster::Math::Float radie = 3; gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie); } break; diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index fb4c9246..11e80a9f 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -36,8 +36,8 @@ GameSession::GameSession() this->isCreated = false; this->isRunning = false; this->gameSession = this; - this->logicFrameTime = DELTA_TIME_20; - this->networkFrameTime = DELTA_TIME_20; + this->logicFrameTime = DELTA_TIME_60; + this->networkFrameTime = DELTA_TIME_60; this->networkTimer.reset(); this->logicTimer.reset(); diff --git a/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp b/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp index 62332541..3357f52c 100644 --- a/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp +++ b/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp @@ -32,7 +32,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh GameServerAPI::GameSetGameMode(L"free-for-all"); GameServerAPI::GameSetGameName(L"DebugServer"); GameServerAPI::GameSetGameTime(15); - GameServerAPI::GameSetMapName(L"2ofAll.bias"); + GameServerAPI::GameSetMapName(L"erik_250.bias"); GameServerAPI::GameSetMaxClients(10); if(GameServerAPI::GameStart(true))