void army::MoveTo(int hexIdx) { if(this->creature.creature_flags & FLYER) { this->targetHex = hexIdx; if(ValidFlight(this->targetHex, 0)) FlyTo(this->targetHex); } else { WalkTo(hexIdx); } }
void CCharacterPhysicsSupport:: EndActivateFreeShell ( CObject* who, const Fvector& inital_entity_position, const Fvector& dp, const Fvector & velocity ) { VERIFY ( m_pPhysicsShell ); VERIFY( m_eState==esDead ); #ifdef DEBUG if( dbg_draw_ragdoll_spawn ) { DBG_OpenCashedDraw(); m_pPhysicsShell->dbg_draw_geometry( 0.2f, D3DCOLOR_XRGB( 255, 100, 0 ) ); DBG_ClosedCashedDraw( 50000 ); } #endif CollisionCorrectObjPos( dp ); m_pPhysicsShell->SetGlTransformDynamic(mXFORM); #ifdef DEBUG if( dbg_draw_ragdoll_spawn ) { DBG_OpenCashedDraw(); m_pPhysicsShell->dbg_draw_geometry( 0.2f, D3DCOLOR_XRGB( 255, 0, 100 ) ); DBG_ClosedCashedDraw( 50000 ); } #endif //fly back after correction FlyTo(Fvector().sub(inital_entity_position,m_EntityAlife.Position())); #ifdef DEBUG if( dbg_draw_ragdoll_spawn ) { DBG_OpenCashedDraw(); m_pPhysicsShell->dbg_draw_geometry( 0.2f, D3DCOLOR_XRGB( 100, 255, 100 ) ); DBG_ClosedCashedDraw( 50000 ); } #endif Fvector v = velocity; m_character_shell_control.apply_start_velocity_factor( who, v ); #ifdef DEBUG if( death_anim_debug ) { Msg( "death anim: ragdoll velocity picked from char controller =(%f,%f,%f), velocity applied to ragdoll =(%f,%f,%f) ", velocity.x, velocity.y, velocity.z, v.x, v.y, v.z ); } #endif m_pPhysicsShell->set_LinearVel( v ); //actualize m_pPhysicsShell->GetGlobalTransformDynamic(&mXFORM); m_pPhysicsShell->mXFORM.set(mXFORM); //if( false && anim_mov_ctrl && anim_mov_blend && anim_mov_blend->blend != CBlend::eFREE_SLOT && anim_mov_blend->timeCurrent + Device.fTimeDelta*anim_mov_blend->speed < anim_mov_blend->timeTotal-SAMPLE_SPF-EPS)//. //{ // const Fmatrix sv_xform = mXFORM; // mXFORM.set( start_xform ); // //anim_mov_blend->blendPower = 1; // anim_mov_blend->timeCurrent += Device.fTimeDelta * anim_mov_blend->speed; // m_pPhysicsShell->AnimToVelocityState( Device.fTimeDelta, 2 * default_l_limit, 10.f * default_w_limit ); // mXFORM.set( sv_xform ); //} IKinematics* K=smart_cast<IKinematics*>( m_EntityAlife.Visual( ) ); K->CalculateBones_Invalidate(); K->CalculateBones (TRUE); }
void CCharacterPhysicsSupport::ActivateShell (CObject* who) { DestroyIKController(); if(!m_physics_skeleton)CreateSkeleton(m_physics_skeleton); if(m_eType==etActor) { CActor* A=smart_cast<CActor*>(&m_EntityAlife); R_ASSERT2(A,"not an actor has actor type"); if(A->Holder()) return; if(m_eState==esRemoved)return; } CKinematics* K=smart_cast<CKinematics*>(m_EntityAlife.Visual()); //////////////////////this needs to evaluate object box////////////////////////////////////////////////////// for(u16 I=K->LL_BoneCount()-1;I!=u16(-1);--I)K->LL_GetBoneInstance(I).reset_callback(); K->CalculateBones_Invalidate(); K->CalculateBones (); //////////////////////////////////////////////////////////////////////////// if(m_pPhysicsShell) return; Fvector velocity; m_PhysicMovementControl->GetCharacterVelocity (velocity); velocity.mul(1.3f); Fvector dp,start;start.set(m_EntityAlife.Position()); if(!m_PhysicMovementControl->CharacterExist()) dp.set(m_EntityAlife.Position()); else m_PhysicMovementControl->GetDeathPosition(dp); m_PhysicMovementControl->DestroyCharacter(); CollisionCorrectObjPos(dp); R_ASSERT2(m_physics_skeleton,"No skeleton created!!"); m_pPhysicsShell=m_physics_skeleton; m_physics_skeleton=NULL; m_pPhysicsShell->set_Kinematics(K); m_pPhysicsShell->RunSimulation(); m_pPhysicsShell->mXFORM.set(mXFORM); m_pPhysicsShell->SetCallbacks(m_pPhysicsShell->GetBonesCallback()); if(!smart_cast<CCustomZone*>(who)) { velocity.mul(1.25f*m_after_death_velocity_factor); } if(!DoCharacterShellCollide()) { m_pPhysicsShell->DisableCharacterCollision(); } m_pPhysicsShell->set_LinearVel(velocity); K->CalculateBones_Invalidate(); K->CalculateBones (); m_flags.set(fl_death_anim_on,FALSE); m_eState=esDead; m_flags.set(fl_skeleton_in_shell,TRUE); if(IsGameTypeSingle()) { m_pPhysicsShell->SetPrefereExactIntegration ();//use exact integration for ragdolls in single m_pPhysicsShell->SetRemoveCharacterCollLADisable(); } else { m_pPhysicsShell->SetIgnoreDynamic(); } m_pPhysicsShell->SetIgnoreSmall(); FlyTo(Fvector().sub(start,m_EntityAlife.Position())); m_pPhysicsShell->GetGlobalTransformDynamic(&mXFORM); m_pPhysicsShell->add_ObjectContactCallback(OnCharacterContactInDeath); m_pPhysicsShell->set_CallbackData((void*)this); }