Merge remote-tracking branch 'origin/GameLogic' into GameClient
This commit is contained in:
commit
4f838bb39e
|
@ -62,6 +62,8 @@ bool LanMenuState::Init( SharedStateContent &shared )
|
|||
this->privData->connectIP->ReserveLines( 1 );
|
||||
this->privData->connectIP->AppendText( L"127.0.0.1" );
|
||||
//this->privData->connectIP->AppendText( L"194.47.150.206" ); // HACK: connecting to Dennis's server
|
||||
//this->privData->connectIP->AppendText( L"194.47.150.189" ); // HACK: connecting to Robins server
|
||||
|
||||
this->privData->connectIP->SetFontHeight( 0.08f );
|
||||
this->privData->connectIP->SetLineSpacing( 0.005f );
|
||||
this->privData->connectIP->SetTopAligned();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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?
|
||||
|
||||
switch (realObj->GetObjectType())
|
||||
Object *realObjA = ((Object*)(objA->GetCustomTag()));
|
||||
Object *realObjB = (Object*)objB->GetCustomTag(); //needs to be changed?
|
||||
ExplosiveCrate* crate;
|
||||
|
||||
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)
|
||||
|
@ -156,15 +160,16 @@ using namespace GameLogic;
|
|||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -173,16 +178,32 @@ using namespace GameLogic;
|
|||
//Collision between a player and a general static or dynamic object
|
||||
//use kinetic energyloss of the collision in order too determin how much damage to take
|
||||
//use as part of the damage algorithm
|
||||
//Oyster::Math::Float3 prevVel = obj.GetRigidBody()->GetState().prev
|
||||
Oyster::Math::Float3 objPrevVel = obj.GetRigidBody()->GetState().previousVelocity;
|
||||
Oyster::Math::Float3 playerPrevVel = player.GetRigidBody()->GetState().previousVelocity;
|
||||
|
||||
Oyster::Math::Float3 deltaPos = (player.GetPosition() - obj.GetPosition());
|
||||
Oyster::Math::Float deltaSpeed = (objPrevVel - playerPrevVel).GetMagnitude();
|
||||
Oyster::Math::Float angularFactor = deltaPos.GetNormalized().Dot( (objPrevVel - playerPrevVel).GetNormalized());
|
||||
|
||||
Oyster::Math::Float impactPower = deltaSpeed * angularFactor;
|
||||
Oyster::Math::Float damageFactor = 0.01f;
|
||||
|
||||
|
||||
int damageDone = 0;
|
||||
int forceThreashHold = 200000;
|
||||
int forceThreashHold = 30; //FIX: balance this
|
||||
|
||||
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
||||
if(impactPower > forceThreashHold) //should only take damage if the force is high enough
|
||||
{
|
||||
damageDone = (int)(kineticEnergyLoss * 0.10f);
|
||||
//player.DamageLife(damageDone);
|
||||
if(obj.GetRigidBody()->GetState().mass == 0)
|
||||
{
|
||||
damageDone = impactPower * damageFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
damageDone = (impactPower * obj.GetRigidBody()->GetState().mass)* damageFactor;
|
||||
}
|
||||
|
||||
player.DamageLife(damageDone);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace GameLogic
|
|||
private:
|
||||
Oyster::Math::Float pushForceMagnitude;
|
||||
Oyster::Math::Float ExplosionRadius;
|
||||
bool hasExploaded;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -90,7 +90,7 @@ using namespace DanBias;
|
|||
{
|
||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||
{
|
||||
if(this->gClients[i] )
|
||||
if(this->gClients[i] && !this->gClients[i]->IsInvalid())
|
||||
{
|
||||
this->gClients[i]->UpdateClient();
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ using namespace DanBias;
|
|||
bool returnValue = false;
|
||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||
{
|
||||
if(this->gClients[i])
|
||||
if(this->gClients[i] && !this->gClients[i]->IsInvalid())
|
||||
{
|
||||
this->gClients[i]->GetClient()->Send(message);
|
||||
returnValue = true;
|
||||
|
@ -115,7 +115,7 @@ using namespace DanBias;
|
|||
{
|
||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||
{
|
||||
if(this->gClients[i] && this->gClients[i]->GetClient()->GetID() == ID)
|
||||
if(this->gClients[i] && !this->gClients[i]->IsInvalid() && this->gClients[i]->GetClient()->GetID() == ID)
|
||||
{
|
||||
this->gClients[i]->GetClient()->Send(protocol);
|
||||
return true;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -288,10 +288,10 @@ void API_Impl::UpdateWorld()
|
|||
{
|
||||
this->customBodies[i]->CallSubscription_Move();
|
||||
}
|
||||
simpleBody->SetPreviousVelocity(simpleBody->GetState().previousVelocity);
|
||||
simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity());
|
||||
}
|
||||
|
||||
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
||||
this->dynamicsWorld->stepSimulation(this->timeStep, 10, this->timeStep);
|
||||
|
||||
ICustomBody::State state;
|
||||
|
||||
|
@ -314,9 +314,34 @@ void API_Impl::UpdateWorld()
|
|||
ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer();
|
||||
ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer();
|
||||
|
||||
|
||||
|
||||
int numContacts = contactManifold->getNumContacts();
|
||||
for (int j=0;j<numContacts;j++)
|
||||
{
|
||||
btManifoldPoint& pt = contactManifold->getContactPoint(j);
|
||||
if (pt.getDistance()<0.f)
|
||||
{
|
||||
if(bodyA->GetState().mass == 40 && bodyB->GetState().centerPos == Float3::null)
|
||||
{
|
||||
const char* breakPoint = "STOP";
|
||||
}
|
||||
if(bodyB->GetState().mass == 40 && bodyA->GetState().centerPos == Float3::null)
|
||||
{
|
||||
const char* breakPoint = "STOP";
|
||||
}
|
||||
|
||||
const btVector3& ptA = pt.getPositionWorldOnA();
|
||||
const btVector3& ptB = pt.getPositionWorldOnB();
|
||||
const btVector3& normalOnB = pt.m_normalWorldOnB;
|
||||
|
||||
bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f);
|
||||
bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ SimpleRigidBody::SimpleRigidBody()
|
|||
this->state.restitutionCoeff = 0.0f;
|
||||
this->state.reach = Float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
this->collisionFlags = 0;
|
||||
|
||||
this->afterCollision = NULL;
|
||||
this->onMovement = NULL;
|
||||
|
||||
|
@ -85,7 +87,7 @@ void SimpleRigidBody::SetMotionState(btDefaultMotionState* motionState)
|
|||
void SimpleRigidBody::SetRigidBody(btRigidBody* rigidBody)
|
||||
{
|
||||
this->rigidBody = rigidBody;
|
||||
|
||||
this->collisionFlags = rigidBody->getCollisionFlags();
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetSubscription(EventAction_AfterCollisionResponse function)
|
||||
|
@ -421,7 +423,7 @@ void SimpleRigidBody::MoveToLimbo()
|
|||
|
||||
void SimpleRigidBody::ReleaseFromLimbo()
|
||||
{
|
||||
this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
|
||||
this->rigidBody->setCollisionFlags(this->collisionFlags);
|
||||
}
|
||||
|
||||
void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity)
|
||||
|
|
|
@ -93,6 +93,8 @@ namespace Oyster
|
|||
btVector3 raySource[2];
|
||||
btVector3 rayTarget[2];
|
||||
btScalar rayLambda[2];
|
||||
|
||||
int collisionFlags;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue