//обновление состояния float CEntity::CalcCondition(float hit) { // If Local() - perform some logic if (Local() && g_Alive()) { SetfHealth (GetfHealth()-hit); SetfHealth ((GetfHealth()<-1000)?-1000:GetfHealth()); } return hit; }
void CCustomMonster::net_Import(NET_Packet& P) { R_ASSERT (Remote()); net_update N; u8 flags; float health; P.r_float (health); SetfHealth (health); P.r_u32 (N.dwTimeStamp); P.r_u8 (flags); P.r_vec3 (N.p_pos); P.r_float /*r_angle8*/ (N.o_model); P.r_float /*r_angle8*/ (N.o_torso.yaw); P.r_float /*r_angle8*/ (N.o_torso.pitch); P.r_float /*r_angle8*/ (N.o_torso.roll ); id_Team = P.r_u8(); id_Squad = P.r_u8(); id_Group = P.r_u8(); if (NET.empty() || (NET.back().dwTimeStamp<N.dwTimeStamp)) { NET.push_back (N); NET_WasInterpolating = TRUE; } setVisible (TRUE); setEnabled (TRUE); }
void CPhantom::net_Import (NET_Packet& P) { // import R_ASSERT (Remote()); u8 flags; float health; P.r_float (health); SetfHealth (health); float fDummy; u32 dwDummy; P.r_float (fDummy); P.r_u32 (dwDummy); P.r_u32 (dwDummy); P.r_u32 (dwDummy); P.r_u8 (flags); float yaw, pitch, bank = 0, roll = 0; P.r_float /*r_angle8*/ (yaw); P.r_float /*r_angle8*/ (yaw); P.r_float /*r_angle8*/ (pitch); P.r_float /*r_angle8*/ (roll); id_Team = P.r_u8(); id_Squad = P.r_u8(); id_Group = P.r_u8(); XFORM().setHPB (yaw,pitch,bank); }
//--------------------------------------------------------------------- //void CPhantom::Hit (float P, Fvector &dir, CObject* who, s16 element,Fvector p_in_object_space, float impulse, ALife::EHitType hit_type) void CPhantom::Hit (SHit* pHDS) { if (m_TgtState==stFly) SwitchToState(stShoot); if (g_Alive()){ SetfHealth (-1.f); // inherited::Hit (P,dir,who,element,p_in_object_space,impulse/100.f, hit_type); inherited::Hit (pHDS); } }
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; }
void CHelicopter::Hit (SHit* pHDS) { // inherited::Hit(pHDS); if(GetfHealth()<0.005f) return; if(state() == CHelicopter::eDead ) return; if(pHDS->who==this) return; bonesIt It = m_hitBones.find(pHDS->bone()); if(It != m_hitBones.end() && pHDS->hit_type==ALife::eHitTypeFireWound) { float curHealth = GetfHealth(); curHealth -= pHDS->damage()*It->second*1000.0f; SetfHealth(curHealth); #ifdef DEBUG if (bDebug) Log("----Helicopter::PilotHit(). health=",curHealth); #endif }else { float hit_power = pHDS->damage(); hit_power *= m_HitTypeK[pHDS->hit_type]; SetfHealth(GetfHealth()-hit_power); #ifdef DEBUG if (bDebug) Log("----Helicopter::Hit(). health=",GetfHealth()); #endif }; if (pHDS->who&& ( pHDS->who->CLS_ID==CLSID_OBJECT_ACTOR || smart_cast<CAI_Stalker*>(pHDS->who) || smart_cast<CCustomZone*>(pHDS->who) ) ){ callback(GameObject::eHelicopterOnHit)(pHDS->damage(),pHDS->impulse,pHDS->hit_type,pHDS->who->ID()); } CPHDestroyable::SetFatalHit(*pHDS); }
//--------------------------------------------------------------------- void CAI_Crow::HitSignal (float /**HitAmount/**/, Fvector& /**local_dir/**/, CObject* who, s16 /**element/**/) { //bool first_time = !!g_Alive(); // bool first_time = !PPhysicsShell(); SetfHealth (0); //set_death_time () ; if (eDeathDead!=st_current) { // if (first_time) Die (who); st_target = eDeathFall; } else smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle(m_Anims.m_death_dead.GetRandom()); }
void CEntity::Die(CObject* who) { if (!AlreadyDie()) set_death_time(); set_ready_to_save (); SetfHealth (-1.f); if(IsGameTypeSingle()) { VERIFY (m_registered_member); } m_registered_member = false; if (IsGameTypeSingle()) Level().seniority_holder().team(g_Team()).squad(g_Squad()).group(g_Group()).unregister_member(this); }
void CBaseMonster::net_Import(NET_Packet& P) { R_ASSERT (Remote()); net_update N; u8 flags; float health; P.r_float (health); SetfHealth (health); P.r_u32 (N.dwTimeStamp); P.r_u8 (flags); P.r_vec3 (N.p_pos); P.r_float /*r_angle8*/ (N.o_model); P.r_float /*r_angle8*/ (N.o_torso.yaw); P.r_float /*r_angle8*/ (N.o_torso.pitch); P.r_float /*r_angle8*/ (N.o_torso.roll ); id_Team = P.r_u8(); id_Squad = P.r_u8(); id_Group = P.r_u8(); GameGraph::_GRAPH_ID l_game_vertex_id = ai_location().game_vertex_id(); P.r (&l_game_vertex_id, sizeof(l_game_vertex_id)); P.r (&l_game_vertex_id, sizeof(l_game_vertex_id)); if (NET.empty() || (NET.back().dwTimeStamp<N.dwTimeStamp)) { NET.push_back (N); NET_WasInterpolating = TRUE; } // P.r (&m_fGoingSpeed, sizeof(m_fGoingSpeed)); // P.r (&m_fGoingSpeed, sizeof(m_fGoingSpeed)); float f1 = 0; if (ai().game_graph().valid_vertex_id(l_game_vertex_id)) { f1 = Position().distance_to (ai().game_graph().vertex(l_game_vertex_id)->level_point()); P.r (&f1, sizeof(f1)); f1 = Position().distance_to (ai().game_graph().vertex(l_game_vertex_id)->level_point()); P.r (&f1, sizeof(f1)); } else { P.r (&f1, sizeof(f1)); P.r (&f1, sizeof(f1)); } setVisible (TRUE); setEnabled (TRUE); }
void CHelicopter::init() { m_cur_rot.set (0.0f,0.0f); m_tgt_rot.set (0.0f,0.0f); m_bind_rot.set (0.0f,0.0f); m_allow_fire = FALSE; m_use_rocket_on_attack = TRUE; m_use_mgun_on_attack = TRUE; m_syncronize_rocket = TRUE; m_min_rocket_dist = 20.0f; m_max_rocket_dist = 200.0f; m_time_between_rocket_attack = 0; m_last_rocket_attack = Device.dwTimeGlobal; SetfHealth (1.0f); }
BOOL CCar::net_Spawn (CSE_Abstract* DC) { #ifdef DEBUG InitDebug(); #endif CSE_Abstract *e = (CSE_Abstract*)(DC); CSE_ALifeCar *co=smart_cast<CSE_ALifeCar*>(e); BOOL R = inherited::net_Spawn(DC); PKinematics(Visual())->CalculateBones_Invalidate(); PKinematics(Visual())->CalculateBones(TRUE); CPHSkeleton::Spawn(e); setEnabled (TRUE); setVisible (TRUE); PKinematics(Visual())->CalculateBones_Invalidate(); PKinematics(Visual())->CalculateBones(TRUE); m_fSaveMaxRPM = m_max_rpm; SetfHealth (co->health); if(!g_Alive()) b_exploded=true; else b_exploded=false; CDamagableItem::RestoreEffect(); CInifile* pUserData = PKinematics(Visual())->LL_UserData(); if(pUserData->section_exist("destroyed")) CPHDestroyable::Load(pUserData,"destroyed"); if(pUserData->section_exist("mounted_weapon_definition")) m_car_weapon = xr_new<CCarWeapon>(this); if(pUserData->section_exist("visual_memory_definition")) { m_memory = xr_new<car_memory>(this); m_memory->reload (pUserData->r_string("visual_memory_definition", "section")); } return (CScriptEntity::net_Spawn(DC) && R); }
void CActorMP::net_Import ( NET_Packet &P) { net_update N; m_state_holder.read (P); R_ASSERT2(valid_pos(m_state_holder.state().position), "imported bad position"); /*if (m_i_am_dead) return;*/ if (OnClient()) { /*#ifdef DEBUG if (GetfHealth() != m_state_holder.state().health) Msg("net_Import: [%d][%s], is going to set health to %2.04f", this->ID(), Name(), m_state_holder.state().health); #endif*/ game_PlayerState* ps = Game().GetPlayerByGameID(this->object_id()); float new_health = m_state_holder.state().health; if (GetfHealth() < new_health) { SetfHealth(new_health); } else { if (!ps || !ps->testFlag(GAME_PLAYER_FLAG_INVINCIBLE)) { SetfHealth(new_health); } } } if (PPhysicsShell() != NULL) { return; } if (OnClient()) SetfRadiation (m_state_holder.state().radiation*100.0f); u16 ActiveSlot = m_state_holder.state().inventory_active_slot; if (OnClient() && (inventory().GetActiveSlot()!=ActiveSlot) ) { #ifdef DEBUG Msg("Client-SetActiveSlot[%d][%d]",ActiveSlot, Device.dwFrame); #endif // #ifdef DEBUG inventory().SetActiveSlot(ActiveSlot); } N.mstate = m_state_holder.state().body_state_flags; N.dwTimeStamp = m_state_holder.state().time; N.p_pos = m_state_holder.state().position; N.o_model = m_state_holder.state().model_yaw; N.o_torso.yaw = m_state_holder.state().camera_yaw; N.o_torso.pitch = m_state_holder.state().camera_pitch; N.o_torso.roll = m_state_holder.state().camera_roll; if (N.o_torso.roll > PI) N.o_torso.roll -= PI_MUL_2; { if (Level().IsDemoPlay() || OnServer() || Remote()) { unaffected_r_torso.yaw = N.o_torso.yaw; unaffected_r_torso.pitch = N.o_torso.pitch; unaffected_r_torso.roll = N.o_torso.roll; cam_Active()->yaw = -N.o_torso.yaw; cam_Active()->pitch = N.o_torso.pitch; }; }; //CSE_ALifeCreatureActor N.p_accel = m_state_holder.state().logic_acceleration; process_packet (N); net_update_A N_A; m_States.clear (); N_A.State.enabled = m_state_holder.state().physics_state_enabled; N_A.State.angular_vel = m_state_holder.state().physics_angular_velocity; N_A.State.linear_vel = m_state_holder.state().physics_linear_velocity; N_A.State.force = m_state_holder.state().physics_force; N_A.State.torque = m_state_holder.state().physics_torque; N_A.State.position = m_state_holder.state().physics_position; N_A.State.quaternion = m_state_holder.state().physics_quaternion; // interpolcation postprocess_packet (N_A); }
BOOL CHelicopter::net_Spawn(CSE_Abstract* DC) { SetfHealth(100.0f); setState(CHelicopter::eAlive); m_flame_started =false; m_light_started =false; m_exploded =false; m_ready_explode =false; m_dead =false; if (!inherited::net_Spawn(DC)) return (FALSE); CPHSkeleton::Spawn((CSE_Abstract*)(DC)); for(u32 i=0; i<4; ++i) CRocketLauncher::SpawnRocket(*m_sRocketSection, smart_cast<CGameObject*>(this)); // assigning m_animator here CSE_Abstract *abstract =(CSE_Abstract*)(DC); CSE_ALifeHelicopter *heli = smart_cast<CSE_ALifeHelicopter*>(abstract); VERIFY (heli); R_ASSERT (Visual()&&smart_cast<IKinematics*>(Visual())); IKinematics* K = smart_cast<IKinematics*>(Visual()); CInifile* pUserData = K->LL_UserData(); m_rotate_x_bone = K->LL_BoneID (pUserData->r_string("helicopter_definition","wpn_rotate_x_bone")); m_rotate_y_bone = K->LL_BoneID (pUserData->r_string("helicopter_definition","wpn_rotate_y_bone")); m_fire_bone = K->LL_BoneID (pUserData->r_string("helicopter_definition","wpn_fire_bone")); m_death_bones_to_hide = pUserData->r_string("on_death_mode","scale_bone"); m_left_rocket_bone = K->LL_BoneID (pUserData->r_string("helicopter_definition","left_rocket_bone")); m_right_rocket_bone = K->LL_BoneID (pUserData->r_string("helicopter_definition","right_rocket_bone")); m_smoke_bone = K->LL_BoneID (pUserData->r_string("helicopter_definition","smoke_bone")); m_light_bone = K->LL_BoneID (pUserData->r_string("helicopter_definition","light_bone")); CExplosive::Load (pUserData,"explosion"); CExplosive::SetInitiator(ID()); LPCSTR s = pUserData->r_string("helicopter_definition","hit_section"); if( pUserData->section_exist(s) ) { int lc = pUserData->line_count(s); LPCSTR name; LPCSTR value; s16 boneID; for (int i=0 ; i<lc; ++i) { pUserData->r_line( s, i, &name, &value); boneID =K->LL_BoneID(name); m_hitBones.insert( std::make_pair(boneID, (float)atof(value)) ); } } CBoneInstance& biX = smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_x_bone); biX.set_callback (bctCustom,BoneMGunCallbackX,this); CBoneInstance& biY = smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_y_bone); biY.set_callback (bctCustom,BoneMGunCallbackY,this); 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_rot.x = matrices[m_rotate_x_bone].k.getP(); m_bind_rot.y = 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); IKinematicsAnimated *A = smart_cast<IKinematicsAnimated*>(Visual()); if (A) { A->PlayCycle (*heli->startup_animation); K->CalculateBones (TRUE); } m_engineSound.create (*heli->engine_sound,st_Effect,sg_SourceType); m_engineSound.play_at_pos (0,XFORM().c,sm_Looped); CShootingObject::Light_Create (); setVisible (TRUE); setEnabled (TRUE); m_stepRemains = 0.0f; //lighting m_light_render = ::Render->light_create(); m_light_render->set_shadow (false); m_light_render->set_type (IRender_Light::POINT); m_light_render->set_range (m_light_range); m_light_render->set_color (m_light_color); if(g_Alive())processing_activate (); TurnEngineSound(false); if(pUserData->section_exist("destroyed")) CPHDestroyable::Load(pUserData,"destroyed"); #ifdef DEBUG Device.seqRender.Add(this,REG_PRIORITY_LOW-1); #endif return TRUE; }
void CActor::OnEvent(NET_Packet& P, u16 type) { inherited::OnEvent (P,type); CInventoryOwner::OnEvent (P,type); u16 id; switch (type) { case GE_TRADE_BUY: case GE_OWNERSHIP_TAKE: { P.r_u16 (id); CObject* Obj = Level().Objects.net_Find (id); // R_ASSERT2( Obj, make_string("GE_OWNERSHIP_TAKE: Object not found. object_id = [%d]", id).c_str() ); VERIFY2 ( Obj, make_string("GE_OWNERSHIP_TAKE: Object not found. object_id = [%d]", id).c_str() ); if ( !Obj ) { Msg ( "! GE_OWNERSHIP_TAKE: Object not found. object_id = [%d]", id ); break; } CGameObject* _GO = smart_cast<CGameObject*>(Obj); if (!IsGameTypeSingle() && !g_Alive()) { Msg("! WARNING: dead player [%d][%s] can't take items [%d][%s]", ID(), Name(), _GO->ID(), _GO->cNameSect().c_str()); break; } if( inventory().CanTakeItem(smart_cast<CInventoryItem*>(_GO)) ) { Obj->H_SetParent (smart_cast<CObject*>(this)); #ifdef MP_LOGGING string64 act; xr_strcpy( act, (type == GE_TRADE_BUY)? "buys" : "takes" ); Msg("--- Actor [%d][%s] %s [%d][%s]", ID(), Name(), act, _GO->ID(), _GO->cNameSect().c_str()); #endif // MP_LOGGING inventory().Take (_GO, false, true); SelectBestWeapon(Obj); } else { if (IsGameTypeSingle()) { NET_Packet P; u_EventGen (P,GE_OWNERSHIP_REJECT,ID()); P.w_u16 (u16(Obj->ID())); u_EventSend (P); } else { Msg("! ERROR: Actor [%d][%s] tries to drop on take [%d][%s]", ID(), Name(), _GO->ID(), _GO->cNameSect().c_str()); } } } break; case GE_TRADE_SELL: case GE_OWNERSHIP_REJECT: { P.r_u16 (id); CObject* Obj = Level().Objects.net_Find (id); // R_ASSERT2( Obj, make_string("GE_OWNERSHIP_REJECT: Object not found, id = %d", id).c_str() ); VERIFY2 ( Obj, make_string("GE_OWNERSHIP_REJECT: Object not found, id = %d", id).c_str() ); if ( !Obj ) { Msg ( "! GE_OWNERSHIP_REJECT: Object not found, id = %d", id ); break; } bool just_before_destroy = !P.r_eof() && P.r_u8(); bool dont_create_shell = (type==GE_TRADE_SELL) || just_before_destroy; Obj->SetTmpPreDestroy (just_before_destroy); CGameObject * GO = smart_cast<CGameObject*>(Obj); #ifdef MP_LOGGING string64 act; xr_strcpy( act, (type == GE_TRADE_SELL)? "sells" : "rejects" ); Msg("--- Actor [%d][%s] %s [%d][%s]", ID(), Name(), act, GO->ID(), GO->cNameSect().c_str()); #endif // MP_LOGGING VERIFY( GO->H_Parent() ); if ( !GO->H_Parent() ) { Msg("! ERROR: Actor [%d][%s] tries to reject item [%d][%s] that has no parent", ID(), Name(), GO->ID(), GO->cNameSect().c_str()); break; } VERIFY2( GO->H_Parent()->ID() == ID(), make_string("actor [%d][%s] tries to drop not own object [%d][%s]", ID(), Name(), GO->ID(), GO->cNameSect().c_str() ).c_str() ); if ( GO->H_Parent()->ID() != ID() ) { CActor* real_parent = smart_cast<CActor*>(GO->H_Parent()); Msg("! ERROR: Actor [%d][%s] tries to drop not own item [%d][%s], his parent is [%d][%s]", ID(), Name(), GO->ID(), GO->cNameSect().c_str(), real_parent->ID(), real_parent->Name()); break; } if (!Obj->getDestroy() && inventory().DropItem(GO, just_before_destroy, dont_create_shell)) { //O->H_SetParent(0,just_before_destroy);//moved to DropItem //feel_touch_deny(O,2000); Level().m_feel_deny.feel_touch_deny(Obj, 1000); // [12.11.07] Alexander Maniluk: extended GE_OWNERSHIP_REJECT packet for drop item to selected position Fvector dropPosition; if (!P.r_eof()) { P.r_vec3(dropPosition); GO->MoveTo(dropPosition); //Other variant :) /*NET_Packet MovePacket; MovePacket.w_begin(M_MOVE_ARTEFACTS); MovePacket.w_u8(1); MovePacket.w_u16(id); MovePacket.w_vec3(dropPosition); u_EventSend(MovePacket);*/ } } if (!just_before_destroy) SelectBestWeapon(Obj); } break; case GE_INV_ACTION: { u16 cmd; P.r_u16 (cmd); u32 flags; P.r_u32 (flags); s32 ZoomRndSeed = P.r_s32(); s32 ShotRndSeed = P.r_s32(); if (!IsGameTypeSingle() && !g_Alive()) { // Msg("! WARNING: dead player tries to rize inventory action"); break; } if (flags & CMD_START) { if (cmd == kWPN_ZOOM) SetZoomRndSeed(ZoomRndSeed); if (cmd == kWPN_FIRE) SetShotRndSeed(ShotRndSeed); IR_OnKeyboardPress(cmd); } else IR_OnKeyboardRelease(cmd); } break; case GEG_PLAYER_ITEM2SLOT: case GEG_PLAYER_ITEM2BELT: case GEG_PLAYER_ITEM2RUCK: case GEG_PLAYER_ITEM_EAT: case GEG_PLAYER_ACTIVATEARTEFACT: { P.r_u16 (id); CObject* Obj = Level().Objects.net_Find (id); // R_ASSERT2( Obj, make_string("GEG_PLAYER_ITEM_EAT(use): Object not found. object_id = [%d]", id).c_str() ); VERIFY2 ( Obj, make_string("GEG_PLAYER_ITEM_EAT(use): Object not found. object_id = [%d]", id).c_str() ); if ( !Obj ) { // Msg ( "! GEG_PLAYER_ITEM_EAT(use): Object not found. object_id = [%d]", id ); break; } // R_ASSERT2( !Obj->getDestroy(), make_string("GEG_PLAYER_ITEM_EAT(use): Object is destroying. object_id = [%d]", id).c_str() ); VERIFY2 ( !Obj->getDestroy(), make_string("GEG_PLAYER_ITEM_EAT(use): Object is destroying. object_id = [%d]", id).c_str() ); if ( Obj->getDestroy() ) { // Msg ( "! GEG_PLAYER_ITEM_EAT(use): Object is destroying. object_id = [%d]", id ); break; } if (!IsGameTypeSingle() && !g_Alive()) { Msg("! WARNING: dead player [%d][%s] can't use items [%d][%s]", ID(), Name(), Obj->ID(), Obj->cNameSect().c_str()); break; } if ( type == GEG_PLAYER_ACTIVATEARTEFACT ) { CArtefact* pArtefact = smart_cast<CArtefact*>(Obj); // R_ASSERT2( pArtefact, make_string("GEG_PLAYER_ACTIVATEARTEFACT: Artefact not found. artefact_id = [%d]", id).c_str() ); VERIFY2 ( pArtefact, make_string("GEG_PLAYER_ACTIVATEARTEFACT: Artefact not found. artefact_id = [%d]", id).c_str() ); if ( !pArtefact ) { Msg ( "! GEG_PLAYER_ACTIVATEARTEFACT: Artefact not found. artefact_id = [%d]", id ); break;//1 } pArtefact->ActivateArtefact (); break;//1 } PIItem iitem = smart_cast<CInventoryItem*>(Obj); R_ASSERT( iitem ); switch (type) { case GEG_PLAYER_ITEM2SLOT: { u16 slot_id = P.r_u16(); inventory().Slot(slot_id, iitem ); }break;//2 case GEG_PLAYER_ITEM2BELT: inventory().Belt( iitem ); break;//2 case GEG_PLAYER_ITEM2RUCK: inventory().Ruck( iitem ); break;//2 case GEG_PLAYER_ITEM_EAT: inventory().Eat( iitem ); break;//2 }//switch }break;//1 case GEG_PLAYER_ACTIVATE_SLOT: { u16 slot_id; P.r_u16 (slot_id); inventory().Activate (slot_id); }break; case GEG_PLAYER_DISABLE_SPRINT: { s8 cmd = P.r_s8(); m_block_sprint_counter = m_block_sprint_counter+cmd; Msg("m_block_sprint_counter=%d",m_block_sprint_counter); if(m_block_sprint_counter>0) { mstate_wishful &=~mcSprint; } }break; case GEG_PLAYER_WEAPON_HIDE_STATE: { u16 State = P.r_u16(); BOOL Set = !!P.r_u8(); inventory().SetSlotsBlocked (State, !!Set); }break; case GE_MOVE_ACTOR: { Fvector NewPos, NewRot; P.r_vec3(NewPos); P.r_vec3(NewRot); MoveActor(NewPos, NewRot); }break; case GE_ACTOR_MAX_POWER: { conditions().MaxPower(); conditions().ClearWounds(); ClearBloodWounds(); }break; case GE_ACTOR_MAX_HEALTH: { SetfHealth(GetMaxHealth()); }break; case GEG_PLAYER_ATTACH_HOLDER: { u16 id = P.r_u16(); CObject* O = Level().Objects.net_Find (id); if (!O){ Msg("! Error: No object to attach holder [%d]", id); break; } VERIFY(m_holder==NULL); CHolderCustom* holder = smart_cast<CHolderCustom*>(O); if(!holder->Engaged()) use_Holder (holder); }break; case GEG_PLAYER_DETACH_HOLDER: { if (!m_holder) break; u16 id = P.r_u16(); CGameObject* GO = smart_cast<CGameObject*>(m_holder); VERIFY (id==GO->ID()); use_Holder (NULL); }break; case GEG_PLAYER_PLAY_HEADSHOT_PARTICLE: { OnPlayHeadShotParticle(P); }break; case GE_ACTOR_JUMPING: { /* Fvector dir; P.r_dir(dir); float jump = P.r_float(); NET_SavedAccel = dir; extern float NET_Jump; NET_Jump = jump; m_bInInterpolation = false; mstate_real |= mcJump; */ }break; } }
void CBaseMonster::Load(LPCSTR section) { m_section = section; // load parameters from ".ltx" file inherited::Load (section); m_head_bone_name = READ_IF_EXISTS(pSettings,r_string,section, "bone_head", "bip01_head"); m_left_eye_bone_name = READ_IF_EXISTS(pSettings,r_string,section, "bone_eye_left", 0); m_right_eye_bone_name = READ_IF_EXISTS(pSettings,r_string,section, "bone_eye_right", 0); m_corpse_cover_evaluator = xr_new<CMonsterCorpseCoverEvaluator> (&movement().restrictions()); m_enemy_cover_evaluator = xr_new<CCoverEvaluatorFarFromEnemy> (&movement().restrictions()); m_cover_evaluator_close_point = xr_new<CCoverEvaluatorCloseToEnemy> (&movement().restrictions()); MeleeChecker.load (section); Morale.load (section); m_pPhysics_support ->in_Load(section); SetfHealth ( (float)pSettings->r_u32 (section,"Health")); m_controlled = smart_cast<CControlledEntityBase*>(this); settings_load (section); control().load (section); m_anomaly_detector->load (section); CoverMan->load (); m_rank = (pSettings->line_exist(section,"rank")) ? int(pSettings->r_u32(section,"rank")) : 0; // if (pSettings->line_exist(section,"Spawn_Inventory_Item_Section")) { // m_item_section = pSettings->r_string(section,"Spawn_Inventory_Item_Section"); // m_spawn_probability = pSettings->r_float(section,"Spawn_Inventory_Item_Probability"); // } else m_spawn_probability = 0.f; m_melee_rotation_factor = READ_IF_EXISTS(pSettings,r_float,section,"Melee_Rotation_Factor", 1.5f); berserk_always = !!READ_IF_EXISTS(pSettings,r_bool,section,"berserk_always", false); m_feel_enemy_who_just_hit_max_distance = READ_IF_EXISTS(pSettings, r_float, section, "feel_enemy_who_just_hit_max_distance", detail::base_monster::feel_enemy_who_just_hit_max_distance); m_feel_enemy_max_distance = READ_IF_EXISTS(pSettings, r_float, section, "feel_enemy_max_distance", detail::base_monster::feel_enemy_max_distance); m_feel_enemy_who_made_sound_max_distance = READ_IF_EXISTS(pSettings, r_float, section, "feel_enemy_who_made_sound_max_distance", detail::base_monster::feel_enemy_who_made_sound_max_distance); //------------------------------------ // Steering Behaviour //------------------------------------ float separate_factor = READ_IF_EXISTS(pSettings, r_float, section, "separate_factor", 0.f); float separate_range = READ_IF_EXISTS(pSettings, r_float, section, "separate_range" , 0.f); if ( (separate_factor > 0.0001f) && (separate_range > 0.01f) ) { m_steer_manager = xr_new<steering_behaviour::manager>(); m_grouping_behaviour = xr_new<squad_grouping_behaviour> (this, Fvector3().set(0.f, 0.f, 0.f), Fvector3().set(0.f, separate_factor, 0.f), separate_range); get_steer_manager()->add ( xr_new<steering_behaviour::grouping>(m_grouping_behaviour) ); } //------------------------------------ // Auras //------------------------------------ m_psy_aura.load_from_ini (pSettings, section); m_radiation_aura.load_from_ini (pSettings, section, true); m_fire_aura.load_from_ini (pSettings, section); m_base_aura.load_from_ini (pSettings, section); //------------------------------------ // Protections //------------------------------------ m_fSkinArmor = 0.f; m_fHitFracMonster = 0.1f; if(pSettings->line_exist(section, "protections_sect")) { LPCSTR protections_sect = pSettings->r_string(section, "protections_sect"); m_fSkinArmor = READ_IF_EXISTS(pSettings,r_float,protections_sect,"skin_armor", 0.f); m_fHitFracMonster = READ_IF_EXISTS(pSettings,r_float,protections_sect,"hit_fraction_monster", 0.1f); } m_force_anti_aim = false; }
BOOL CEntity::net_Spawn (CSE_Abstract* DC) { m_level_death_time = 0; m_game_death_time = 0; m_killer_id = ALife::_OBJECT_ID(-1); CSE_Abstract *e = (CSE_Abstract*)(DC); CSE_ALifeCreatureAbstract *E = smart_cast<CSE_ALifeCreatureAbstract*>(e); // Initialize variables if (E) { SetfHealth (E->get_health()); R_ASSERT2(!((E->get_killer_id() != ALife::_OBJECT_ID(-1)) && g_Alive()), make_string("server entity [%s][%d] has an killer [%d] and not dead", E->name_replace(), E->ID, E->get_killer_id()).c_str()); m_killer_id = E->get_killer_id(); if (m_killer_id == ID()) m_killer_id = ALife::_OBJECT_ID(-1); } else SetfHealth (1.0f); // load damage params if (!E) { // Car or trader only!!!! CSE_ALifeCar *C = smart_cast<CSE_ALifeCar*>(e); CSE_ALifeTrader *T = smart_cast<CSE_ALifeTrader*>(e); CSE_ALifeHelicopter *H = smart_cast<CSE_ALifeHelicopter*>(e); R_ASSERT2 (C||T||H,"Invalid entity (no inheritance from CSE_CreatureAbstract, CSE_ALifeItemCar and CSE_ALifeTrader and CSE_ALifeHelicopter)!"); id_Team = id_Squad = id_Group = 0; } else { id_Team = E->g_team(); id_Squad = E->g_squad(); id_Group = E->g_group(); CSE_ALifeMonsterBase *monster = smart_cast<CSE_ALifeMonsterBase*>(E); if (monster) { MONSTER_COMMUNITY monster_community; monster_community.set (pSettings->r_string(*cNameSect(), "species")); if(monster_community.team() != 255) id_Team = monster_community.team(); } } if (g_Alive() && IsGameTypeSingle()) { m_registered_member = true; Level().seniority_holder().team(g_Team()).squad(g_Squad()).group(g_Group()).register_member(this); ++Level().seniority_holder().team(g_Team()).squad(g_Squad()).group(g_Group()).m_dwAliveCount; } if(!g_Alive()) { m_level_death_time = Device.dwTimeGlobal; m_game_death_time = E->m_game_death_time;; } if (!inherited::net_Spawn(DC)) return (FALSE); // SetfHealth (E->fHealth); IKinematics* pKinematics=smart_cast<IKinematics*>(Visual()); CInifile* ini = NULL; if(pKinematics) ini = pKinematics->LL_UserData(); if (ini) { if (ini->section_exist("damage_section") && !use_simplified_visual()) CDamageManager::reload(pSettings->r_string("damage_section","damage"),ini); CParticlesPlayer::LoadParticles(pKinematics); } return TRUE; }