static int dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr) { struct dcache_block *db = dcache_hit (dcache, addr); if (db) db->data[XFORM (dcache, addr)] = *ptr; return 1; }
void CLevelChanger::shedule_Update(u32 dt) { inherited::shedule_Update (dt); const Fsphere &s = CFORM()->getSphere(); Fvector P; XFORM().transform_tiny (P,s.P); feel_touch_update (P,s.R); update_actor_invitation (); }
void CBreakableObject::ActivateBroken() { m_pPhysicsShell=m_Shell; IKinematics* K=smart_cast<IKinematics*>(Visual()); m_pPhysicsShell->set_Kinematics(K); m_pPhysicsShell->RunSimulation(); m_pPhysicsShell->SetCallbacks( ); K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); m_pPhysicsShell->GetGlobalTransformDynamic(&XFORM()); }
void CGameObject::create_anim_mov_ctrl ( CBlend *b, Fmatrix *start_pose, bool local_animation ) { if( animation_movement_controlled( ) ) { m_anim_mov_ctrl->NewBlend ( b, start_pose ? *start_pose : XFORM(), local_animation ); } else { // start_pose = &renderable.xform; if( m_anim_mov_ctrl ) destroy_anim_mov_ctrl(); VERIFY2 ( start_pose, make_string( "start pose hasn't been specified for animation [%s][%s]", smart_cast<IKinematicsAnimated&>(*Visual()).LL_MotionDefName_dbg(b->motionID).first, smart_cast<IKinematicsAnimated&>(*Visual()).LL_MotionDefName_dbg(b->motionID).second ) ); VERIFY2 ( !animation_movement(), make_string( "start pose hasn't been specified for animation [%s][%s]", smart_cast<IKinematicsAnimated&>(*Visual()).LL_MotionDefName_dbg(b->motionID).first, smart_cast<IKinematicsAnimated&>(*Visual()).LL_MotionDefName_dbg(b->motionID).second ) ); VERIFY (Visual()); IKinematics *K = Visual( )->dcast_PKinematics( ); VERIFY ( K ); m_anim_mov_ctrl = xr_new<animation_movement_controller>( &XFORM(), *start_pose, K, b ); } }
void CPhysicItem::UpdateCL() { // if (!xr_strcmp("bolt",cName())) // Log ("--- B - CBolt",renderable.xform); if (!H_Parent() && m_pPhysicsShell && m_pPhysicsShell->isActive()) m_pPhysicsShell->InterpolateGlobalTransform(&XFORM()); // if (!xr_strcmp("bolt",cName())) // Log ("--- C - CBolt",renderable.xform); inherited::UpdateCL (); // if (!xr_strcmp("bolt",cName())) // Log ("--- D - CBolt",renderable.xform); }
static int dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr) { struct dcache_block *db = dcache_hit (dcache, addr); if (!db) { db = dcache_alloc (dcache, addr); if (!db) return 0; } if (db->state[XFORM (addr)] == ENTRY_BAD) { if (!dcache_read_line(dcache, db)) return 0; } *ptr = db->data[XFORM (addr)]; return 1; }
float CHelicopter::GetRealAltitude() { collide::rq_result cR; Fvector down_dir; down_dir.set(0.0f, -1.0f, 0.0f); Level().ObjectSpace.RayPick(XFORM().c, down_dir, 1000.0f, collide::rqtStatic, cR, NULL); return cR.range; }
void CGraviArtefact::UpdateCLChild() { VERIFY(!ph_world->Processing()); if (getVisible() && m_pPhysicsShell) { if (m_fJumpHeight) { Fvector dir; dir.set(0, -1.f, 0); collide::rq_result RQ; //проверить высоту артифакта if(Level().ObjectSpace.RayPick(Position(), dir, m_fJumpHeight, collide::rqtBoth, RQ, this)) { dir.y = 1.f; m_pPhysicsShell->applyImpulse(dir, 30.f * Device.fTimeDelta * m_pPhysicsShell->getMass()); } } } else if(H_Parent()) { XFORM().set(H_Parent()->XFORM()); if (GameID() == GAME_ARTEFACTHUNT && m_CarringBoneID != u16(-1)) { CKinematics* K = smart_cast<CKinematics*>(H_Parent()->Visual()); if (K) { K->CalculateBones (); Fmatrix Ruck_MTX = K->LL_GetTransform(m_CarringBoneID); Fvector x; x.set(-0.1f, 0.f, -0.3f); Ruck_MTX.translate_add(x); Ruck_MTX.mulA_43 (XFORM()); XFORM().set(Ruck_MTX); }; }; }; }
void CCar::VisualUpdate(float fov) { m_pPhysicsShell->InterpolateGlobalTransform(&XFORM()); Fvector lin_vel; m_pPhysicsShell->get_LinearVel(lin_vel); // Sound Fvector C,V; Center (C); V.set (lin_vel); m_car_sound->Update(); if(Owner()) { if(m_pPhysicsShell->isEnabled()) { Owner()->XFORM().mul_43 (XFORM(),m_sits_transforms[0]); } // // if(OwnerActor() && OwnerActor()->IsMyCamera()) // { // cam_Update(Device.fTimeDelta, fov); // OwnerActor()->Cameras().Update(Camera()); // OwnerActor()->Cameras().ApplyDevice(); // } // /* if(CurrentGameUI())// { CurrentGameUI()->UIMainIngameWnd->CarPanel().Show(true); CurrentGameUI()->UIMainIngameWnd->CarPanel().SetCarHealth(GetfHealth()); CurrentGameUI()->UIMainIngameWnd->CarPanel().SetSpeed(lin_vel.magnitude()/1000.f*3600.f/100.f); CurrentGameUI()->UIMainIngameWnd->CarPanel().SetRPM(m_current_rpm/m_max_rpm/2.f); } */ } UpdateExhausts (); m_lights.Update (); }
BOOL CPhysicsShellHolder::net_Spawn (CSE_Abstract* DC) { CParticlesPlayer::net_SpawnParticles (); st_enable_state=(u8)stNotDefitnite; b_sheduled = true; BOOL ret=inherited::net_Spawn (DC);//load //create_physic_shell (); if(PPhysicsShell()&&PPhysicsShell()->isFullActive()) { PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); PPhysicsShell()->mXFORM = XFORM(); switch (EEnableState(st_enable_state)) { case stEnable : PPhysicsShell()->Enable() ;break; case stDisable : PPhysicsShell()->Disable() ;break; case stNotDefitnite : ;break; } ApplySpawnIniToPhysicShell(pSettings,PPhysicsShell(),false); st_enable_state=(u8)stNotDefitnite; } return ret; }
bool CHelicopter::isObjectVisible (CObject* O) { Fvector dir_to_object; Fvector to_point; O->Center (to_point); Fvector from_point = XFORM().c; dir_to_object.sub (to_point,from_point).normalize_safe(); float ray_length = from_point.distance_to(to_point); BOOL res = Level().ObjectSpace.RayTest(from_point, dir_to_object, ray_length, collide::rqtStatic, NULL, NULL); return !res; }
void CCustomZone::PlayAwakingParticles() { if(m_sAwakingParticles.size()) { CParticlesObject* pParticles; pParticles = CParticlesObject::Create(*m_sAwakingParticles,TRUE); pParticles->UpdateParent(XFORM(),zero_vel); pParticles->Play(false); } if(m_awaking_sound._handle()) m_awaking_sound.play_at_pos (0, Position()); }
void CHangingLamp::Synchronize() // alpet: сохранение данных в серверный объект { CSE_ALifeObjectHangingLamp *lamp = get_se_lamp(this); if (!lamp) return; lamp->position() = XFORM().c; XFORM().getXYZ(lamp->angle()); lamp->brightness = fBrightness; lamp->spot_cone_angle = light_render->get_cone(); lamp->range = light_render->get_range(); Fcolor clr = light_render->get_color(); if (fBrightness > 0) clr.mul_rgb( 255.f / fBrightness); lamp->color = clr.get(); if (light_ambient) { lamp->m_ambient_radius = light_ambient->get_range(); } if (lanim) lamp->color_animator = lanim->cName; }
void CHelicopter::UpdateHeliParticles () { CKinematics* K = smart_cast<CKinematics*>(Visual()); m_particleXFORM = K->LL_GetTransform(m_smoke_bone); m_particleXFORM.mulA_43(XFORM()); if (m_pParticle){ Fvector vel; Fvector last_pos = PositionStack.back().vPosition; vel.sub(Position(), last_pos); vel.mul(5.0f); m_pParticle->UpdateParent(m_particleXFORM, vel ); } //lighting if(m_light_render->get_active()){ Fmatrix xf; Fmatrix& M = K->LL_GetTransform(u16(m_light_bone)); xf.mul (XFORM(),M); VERIFY(!fis_zero(DET(xf))); m_light_render->set_rotation (xf.k,xf.i); m_light_render->set_position (xf.c); if (m_lanim) { int frame; u32 clr = m_lanim->CalculateBGR(Device.fTimeGlobal,frame); // òþ÷ò¨ð•ðõª ò ¯þ¨üðªõ BGR Fcolor fclr; fclr.set ((float)color_get_B(clr),(float)color_get_G(clr),(float)color_get_R(clr),1.f); fclr.mul_rgb (m_light_brightness/255.f); m_light_render->set_color (fclr); } } }
void CPhysicItem::activate_physic_shell() { CObject *object = smart_cast<CObject*>(H_Parent()); R_ASSERT (object); XFORM().set (object->XFORM()); inherited::activate_physic_shell(); CKinematics* K=smart_cast<CKinematics*>(Visual()); if(K) { K->CalculateBones_Invalidate(); K->CalculateBones(); } ///m_pPhysicsShell->Update (); }
void CPhysicsShellHolder::UpdateXFORM(const Fmatrix &upd) { inherited::UpdateXFORM(upd); static int method = 1 + 4 + 8; // alpet: набор флагов для отладки, можно менять значение во время выполнения из Watches if (PPhysicsShell()) { // m_pPhysicsShell->SetTransform(upd); if (method & 1) { PPhysicsShell()->mXFORM.set(upd); PPhysicsShell()->SetGlTransformDynamic(upd); } if (method & 2) { // стянуто из Car.cpp и как-то не так работает bool enable = PPhysicsShell()->isEnabled(); Fmatrix inv, replace; Fmatrix restored_form; PPhysicsShell()->GetGlobalTransformDynamic(&restored_form); inv.set(restored_form); inv.invert(); replace.mul(upd, inv); PPhysicsShell()->SetTransform (replace); if (enable) PPhysicsShell()->Enable(); else PPhysicsShell()->Disable(); // PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); } // пересчет костей CKinematics *K = PKinematics(Visual()); if (K) { K->CalculateBones_Invalidate(); K->CalculateBones(); } if (method & 4) PPhysicsShell()->Update(); if (method & 8) PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); } }
void CWeaponStatMgun::cam_Update (float dt, float fov) { Fvector P,Da; Da.set (0,0,0); IKinematics* K = smart_cast<IKinematics*>(Visual()); K->CalculateBones_Invalidate (); K->CalculateBones (TRUE); const Fmatrix& C = K->LL_GetTransform(m_camera_bone); XFORM().transform_tiny (P,C.c); Fvector d = C.k; XFORM().transform_dir (d); Fvector2 des_cam_dir; d.getHP(des_cam_dir.x, des_cam_dir.y); des_cam_dir.mul(-1.0f); Camera()->yaw = angle_inertion_var(Camera()->yaw, des_cam_dir.x, 0.5f, 7.5f, PI_DIV_6, Device.fTimeDelta); Camera()->pitch = angle_inertion_var(Camera()->pitch, des_cam_dir.y, 0.5f, 7.5f, PI_DIV_6, Device.fTimeDelta); if(OwnerActor()){ // rotate head OwnerActor()->Orientation().yaw = -Camera()->yaw; OwnerActor()->Orientation().pitch = -Camera()->pitch; } Camera()->Update (P,Da); Level().Cameras().UpdateFromCamera (Camera()); }
BOOL CLevelChanger::net_Spawn (CSE_Abstract* DC) { m_entrance_time = 0; CCF_Shape *l_pShape = xr_new<CCF_Shape>(this); collidable.model = l_pShape; CSE_Abstract *l_tpAbstract = (CSE_Abstract*)(DC); CSE_ALifeLevelChanger *l_tpALifeLevelChanger = smart_cast<CSE_ALifeLevelChanger*>(l_tpAbstract); R_ASSERT (l_tpALifeLevelChanger); m_game_vertex_id = l_tpALifeLevelChanger->m_tNextGraphID; m_level_vertex_id = l_tpALifeLevelChanger->m_dwNextNodeID; m_position = l_tpALifeLevelChanger->m_tNextPosition; m_angles = l_tpALifeLevelChanger->m_tAngles; m_bSilentMode = !!l_tpALifeLevelChanger->m_bSilentMode; if (ai().get_level_graph()) { //. this information should be computed in xrAI ai_location().level_vertex (ai().level_graph().vertex(u32(-1),Position())); ai_location().game_vertex (ai().cross_table().vertex(ai_location().level_vertex_id()).game_vertex_id()); } feel_touch.clear (); for (u32 i=0; i < l_tpALifeLevelChanger->shapes.size(); ++i) { CSE_Shape::shape_def &S = l_tpALifeLevelChanger->shapes[i]; switch (S.type) { case 0 : { l_pShape->add_sphere(S.data.sphere); break; } case 1 : { l_pShape->add_box(S.data.box); break; } } } BOOL bOk = inherited::net_Spawn(DC); if (bOk) { l_pShape->ComputeBounds (); Fvector P; XFORM().transform_tiny (P,CFORM()->getSphere().P); setEnabled (TRUE); } g_lchangers.push_back (this); return (bOk); }
void CRadioactiveZone::Affect(SZoneObjectInfo* O) { float one = 0.1f; float tg = Device.fTimeGlobal; if(!O->object || O->f_time_affected+one > Device.fTimeGlobal) return; clamp (O->f_time_affected, tg-(one*3), tg); Fvector pos; XFORM().transform_tiny (pos,CFORM()->getSphere().P); Fvector dir ={0,0,0}; float power = Power(O->object->Position().distance_to(pos),nearest_shape_radius(O)); float impulse = 0.0f; if(power < EPS) { O->f_time_affected = tg; return; } float send_power = power*one; while(O->f_time_affected+one < tg) { CreateHit ( O->object->ID(), ID(), dir, send_power, BI_NONE, Fvector().set(0.0f,0.0f,0.0f), impulse, m_eHitTypeBlowout); #ifdef DEBUG // if(bDebug) /* Msg ( "Zone[%s]-hit->[%s] Power=%3.3f Frame=%d Time=%3.3f", cName().c_str(), O->object->cName().c_str(), send_power, Device.dwFrame, tg);*/ /// Msg( "Zone hit ___ damage = %.4f Frame=%d ", send_power, Device.dwFrame ); #endif O->f_time_affected += one; }//while }
void CCustomZone::PlayBulletParticles(Fvector& pos) { m_entrance_sound.play_at_pos(0, pos); if(!m_sEntranceParticlesSmall) return; CParticlesObject* pParticles; pParticles = CParticlesObject::Create(*m_sEntranceParticlesSmall,TRUE); Fmatrix M; M = XFORM(); M.c.set(pos); pParticles->UpdateParent(M,zero_vel); pParticles->Play(false); }
//--------------------------------------------------------------------- void CPhantom::UpdatePosition(const Fvector& tgt_pos) { float tgt_h,tgt_p; Fvector tgt_dir,cur_dir; tgt_dir.sub (tgt_pos,Position()); tgt_dir.getHP (tgt_h,tgt_p); angle_lerp (vHP.x,tgt_h,fASpeed,Device.fTimeDelta); angle_lerp (vHP.y,tgt_p,fASpeed,Device.fTimeDelta); cur_dir.setHP (vHP.x,vHP.y); Fvector prev_pos=Position(); XFORM().rotateY (-vHP.x); Position().mad (prev_pos,cur_dir,fSpeed*Device.fTimeDelta); }
void CHelicopter::save(NET_Packet &output_packet) { m_movement.save (output_packet); m_body.save (output_packet); m_enemy.save (output_packet); output_packet.w_vec3(XFORM().c); output_packet.w_float(m_barrel_dir_tolerance); save_data (m_use_rocket_on_attack, output_packet); save_data (m_use_mgun_on_attack, output_packet); save_data (m_min_rocket_dist, output_packet); save_data (m_max_rocket_dist, output_packet); save_data (m_min_mgun_dist, output_packet); save_data (m_max_mgun_dist, output_packet); save_data (m_time_between_rocket_attack, output_packet); save_data (m_syncronize_rocket, output_packet); }
BOOL CPhantom::net_Spawn(CSE_Abstract* DC) { CSE_ALifeCreaturePhantom* OBJ = smart_cast<CSE_ALifeCreaturePhantom*>(DC); VERIFY(OBJ); // select visual at first LPCSTR vis_name = OBJ->get_visual(); if (!(vis_name&&vis_name[0])){ LPCSTR visuals = pSettings->r_string(cNameSect(),"visuals"); u32 cnt = _GetItemCount(visuals); string256 tmp; OBJ->set_visual (_GetItem(visuals,Random.randI(cnt),tmp)); // inform server NET_Packet P; u_EventGen (P, GE_CHANGE_VISUAL, OBJ->ID); P.w_stringZ (tmp); u_EventSend (P); } SwitchToState (stBirth); // initial state (changed on load method in inherited::) // inherited if (!inherited::net_Spawn(DC)) return FALSE; m_enemy = Level().CurrentEntity(); VERIFY (m_enemy); // default init m_fly_particles = 0; SetfHealth (0.001f); // orientate to enemy XFORM().k.sub (m_enemy->Position(),Position()).normalize(); XFORM().j.set (0,1,0); XFORM().i.crossproduct (XFORM().j,XFORM().k); XFORM().k.getHP (vHP.x,vHP.y); // set animation IKinematicsAnimated *K = smart_cast<IKinematicsAnimated*>(Visual()); m_state_data[stBirth].motion = K->ID_Cycle("birth_0"); m_state_data[stFly].motion = K->ID_Cycle("fly_0"); m_state_data[stContact].motion = K->ID_Cycle("contact_0"); m_state_data[stShoot].motion = K->ID_Cycle("shoot_0"); VERIFY(K->LL_GetMotionDef(m_state_data[stBirth].motion)->flags&esmStopAtEnd); VERIFY(K->LL_GetMotionDef(m_state_data[stContact].motion)->flags&esmStopAtEnd); VERIFY(K->LL_GetMotionDef(m_state_data[stShoot].motion)->flags&esmStopAtEnd); // set state SwitchToState_internal(m_TgtState); setVisible (m_CurState>stIdle?TRUE:FALSE); setEnabled (TRUE); return TRUE; }
BOOL CWeaponStatMgun::net_Spawn(CSE_Abstract* DC) { if(!inheritedPH::net_Spawn (DC)) return FALSE; IKinematics* K = smart_cast<IKinematics*>(Visual()); CInifile* pUserData = K->LL_UserData(); R_ASSERT2 (pUserData,"Empty WeaponStatMgun user data!"); m_rotate_x_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_x_bone")); m_rotate_y_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_y_bone")); m_fire_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","fire_bone")); m_camera_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","camera_bone")); U16Vec fixed_bones; fixed_bones.push_back (K->LL_GetBoneRoot()); PPhysicsShell() = P_build_Shell(this,false,fixed_bones); CBoneData& bdX = K->LL_GetData(m_rotate_x_bone); VERIFY(bdX.IK_data.type==jtJoint); m_lim_x_rot.set (bdX.IK_data.limits[0].limit.x,bdX.IK_data.limits[0].limit.y); CBoneData& bdY = K->LL_GetData(m_rotate_y_bone); VERIFY(bdY.IK_data.type==jtJoint); m_lim_y_rot.set (bdY.IK_data.limits[1].limit.x,bdY.IK_data.limits[1].limit.y); xr_vector<Fmatrix> matrices; K->LL_GetBindTransform (matrices); m_i_bind_x_xform.invert (matrices[m_rotate_x_bone]); m_i_bind_y_xform.invert (matrices[m_rotate_y_bone]); m_bind_x_rot = matrices[m_rotate_x_bone].k.getP(); m_bind_y_rot = matrices[m_rotate_y_bone].k.getH(); m_bind_x.set (matrices[m_rotate_x_bone].c); m_bind_y.set (matrices[m_rotate_y_bone].c); m_cur_x_rot = m_bind_x_rot; m_cur_y_rot = m_bind_y_rot; m_destEnemyDir.setHP (m_bind_y_rot,m_bind_x_rot); XFORM().transform_dir (m_destEnemyDir); inheritedShooting::Light_Create(); processing_activate (); setVisible (TRUE); setEnabled (TRUE); return TRUE; }
void CActor::RenderText (LPCSTR Text, Fvector dpos, float* pdup, u32 color) { if (!g_Alive()) return; CBoneInstance& BI = smart_cast<CKinematics*>(Visual())->LL_GetBoneInstance(u16(m_head)); Fmatrix M; smart_cast<CKinematics*>(Visual())->CalculateBones (); M.mul (XFORM(),BI.mTransform); //------------------------------------------------ Fvector v0, v1; v0.set(M.c); v1.set(M.c); Fvector T = Device.vCameraTop; v1.add(T); Fvector v0r, v1r; Device.mFullTransform.transform(v0r,v0); Device.mFullTransform.transform(v1r,v1); float size = v1r.distance_to(v0r); CGameFont* pFont = HUD().Font().pFontArial14; if (!pFont) return; // float OldFontSize = pFont->GetHeight (); float delta_up = 0.0f; if (size < mid_size) delta_up = upsize; else delta_up = upsize*(mid_size/size); dpos.y += delta_up; if (size > mid_size) size = mid_size; // float NewFontSize = size/mid_size * fontsize; //------------------------------------------------ M.c.y += dpos.y; Fvector4 v_res; Device.mFullTransform.transform(v_res,M.c); if (v_res.z < 0 || v_res.w < 0) return; if (v_res.x < -1.f || v_res.x > 1.f || v_res.y<-1.f || v_res.y>1.f) return; float x = (1.f + v_res.x)/2.f * (Device.dwWidth); float y = (1.f - v_res.y)/2.f * (Device.dwHeight); pFont->SetAligment (CGameFont::alCenter); pFont->SetColor (color); // pFont->SetHeight (NewFontSize); pFont->Out (x,y,Text); //------------------------------------------------- // pFont->SetHeight(OldFontSize); *pdup = delta_up; };
void CArtefact::UpdateXForm() { if (Device.dwFrame!=dwXF_Frame) { dwXF_Frame = Device.dwFrame; if (0==H_Parent()) return; // Get access to entity and its visual CEntityAlive* E = smart_cast<CEntityAlive*>(H_Parent()); if(!E) return ; const CInventoryOwner *parent = smart_cast<const CInventoryOwner*>(E); if (parent && parent->use_simplified_visual()) return; VERIFY (E); IKinematics* V = smart_cast<IKinematics*> (E->Visual()); VERIFY (V); if(CAttachableItem::enabled()) return; // Get matrices int boneL = -1, boneR = -1, boneR2 = -1; E->g_WeaponBones (boneL,boneR,boneR2); if (boneR == -1) return; boneL = boneR2; V->CalculateBones (); Fmatrix& mL = V->LL_GetTransform(u16(boneL)); Fmatrix& mR = V->LL_GetTransform(u16(boneR)); // Calculate Fmatrix mRes; Fvector R,D,N; D.sub (mL.c,mR.c); D.normalize_safe(); R.crossproduct (mR.j,D); R.normalize_safe(); N.crossproduct (D,R); N.normalize_safe(); mRes.set (R,N,D,mR.c); mRes.mulA_43 (E->XFORM()); // UpdatePosition (mRes); XFORM().mul (mRes,offset()); } }
void CHelicopter::UpdateWeapons () { if( isOnAttack() ){ UpdateMGunDir(); }else{ m_tgt_rot.set (0.0f,0.0f); }; // lerp angle angle_lerp (m_cur_rot.x, m_tgt_rot.x, PI, Device.fTimeDelta); angle_lerp (m_cur_rot.y, m_tgt_rot.y, PI, Device.fTimeDelta); if( isOnAttack() ){ if(m_allow_fire){ float d = XFORM().c.distance_to_xz(m_enemy.destEnemyPos); if( between(d,m_min_mgun_dist,m_max_mgun_dist) ) MGunFireStart(); if( between(d,m_min_rocket_dist,m_max_rocket_dist) && (Device.dwTimeGlobal-m_last_rocket_attack > m_time_between_rocket_attack) ) { if(m_syncronize_rocket) { startRocket(1); startRocket(2); }else{ if(m_last_launched_rocket==1) startRocket(2); else startRocket(1); } m_last_rocket_attack = Device.dwTimeGlobal; } }else{ MGunFireEnd(); } }else MGunFireEnd(); MGunUpdateFire(); }
void CActor::MoveActor (Fvector NewPos, Fvector NewDir) { Fmatrix M = XFORM(); M.translate(NewPos); r_model_yaw = NewDir.y; r_torso.yaw = NewDir.y; r_torso.pitch = -NewDir.x; unaffected_r_torso.yaw = r_torso.yaw; unaffected_r_torso.pitch= r_torso.pitch; unaffected_r_torso.roll = 0;//r_torso.roll; r_torso_tgt_roll = 0; cam_Active()->Set (-unaffected_r_torso.yaw,unaffected_r_torso.pitch,unaffected_r_torso.roll); ForceTransform(M); m_bInInterpolation = false; }
BOOL CTeamBaseZone::net_Spawn (CSE_Abstract* DC) { CCF_Shape *l_pShape = xr_new<CCF_Shape>(this); collidable.model = l_pShape; CSE_Abstract *l_tpAbstract = (CSE_Abstract*)(DC); CSE_ALifeTeamBaseZone *l_tpALifeScriptZone = smart_cast<CSE_ALifeTeamBaseZone*>(l_tpAbstract); R_ASSERT (l_tpALifeScriptZone); feel_touch.clear (); for (u32 i=0; i < l_tpALifeScriptZone->shapes.size(); ++i) { CSE_Shape::shape_def &S = l_tpALifeScriptZone->shapes[i]; switch (S.type) { case 0 : { l_pShape->add_sphere(S.data.sphere); break; } case 1 : { l_pShape->add_box(S.data.box); break; } } } m_Team = l_tpALifeScriptZone->m_team; BOOL bOk = inherited::net_Spawn(DC); if (bOk) { l_pShape->ComputeBounds (); Fvector P; XFORM().transform_tiny (P,CFORM()->getSphere().P); setEnabled (TRUE); } if (GameID() != GAME_SINGLE && !g_dedicated_server) { char BaseMapLocation[1024]; sprintf_s (BaseMapLocation, "mp_team_base_%d_location", m_Team); (Level().MapManager().AddMapLocation(BaseMapLocation,ID()))->EnablePointer(); }; return (bOk); }
void CMosquitoBald::Affect(SZoneObjectInfo* O) { CPhysicsShellHolder *pGameObject = smart_cast<CPhysicsShellHolder*>(O->object); if(!pGameObject) return; if(O->zone_ignore) return; Fvector P; XFORM().transform_tiny(P,CFORM()->getSphere().P); #ifdef DEBUG char l_pow[255]; sprintf_s(l_pow, "zone hit. %.1f", Power(pGameObject->Position().distance_to(P))); if(bDebug) Msg("%s %s",*pGameObject->cName(), l_pow); #endif Fvector hit_dir; hit_dir.set(::Random.randF(-.5f,.5f), ::Random.randF(.0f,1.f), ::Random.randF(-.5f,.5f)); hit_dir.normalize(); Fvector position_in_bone_space; VERIFY(!pGameObject->getDestroy()); float dist = pGameObject->Position().distance_to(P) - pGameObject->Radius(); float power = Power(dist>0.f?dist:0.f); float impulse = m_fHitImpulseScale*power*pGameObject->GetMass(); //статистика по объекту O->total_damage += power; O->hit_num++; if(power > 0.01f) { m_dwDeltaTime = 0; position_in_bone_space.set(0.f,0.f,0.f); CreateHit(pGameObject->ID(),ID(),hit_dir,power,0,position_in_bone_space,impulse,m_eHitTypeBlowout); PlayHitParticles(pGameObject); } }