void game_cl_Deathmatch::SendPickUpEvent(u16 ID_who, u16 ID_what) { NET_Packet P; u_EventGen (P, GE_OWNERSHIP_TAKE_MP_FORCED, ID_who); P.w_u16 (ID_what); u_EventSend (P); };
void CHelicopter::startRocket(u16 idx) { if((getRocketCount()>=1)&&m_use_rocket_on_attack) { CExplosiveRocket* pGrenade = smart_cast<CExplosiveRocket*>(getCurrentRocket()); VERIFY(pGrenade); pGrenade->SetInitiator(this->ID()); Fmatrix rocketXFORM; (idx==1)?rocketXFORM=m_left_rocket_bone_xform:rocketXFORM=m_right_rocket_bone_xform; Fvector vel; Fvector dir; dir.sub(m_enemy.destEnemyPos, rocketXFORM.c ).normalize_safe(); vel.mul(dir,CRocketLauncher::m_fLaunchSpeed); Fmatrix xform; xform.identity(); xform.k.set(dir); Fvector::generate_orthonormal_basis(xform.k,xform.j,xform.i); xform.c = rocketXFORM.c; VERIFY2(_valid(xform),"CHelicopter::startRocket. Invalid xform"); LaunchRocket(xform, vel, zero_vel); NET_Packet P; u_EventGen(P,GE_LAUNCH_ROCKET,ID()); P.w_u16(u16( getCurrentRocket()->ID())); u_EventSend(P); dropCurrentRocket(); m_last_launched_rocket = idx; HUD_SOUND_ITEM::PlaySound(m_sndShotRocket, xform.c, this, false); } }
void CActor::PickupModeUpdate() { if(!m_bPickupMode) return; if (GameID() != GAME_SINGLE) return; //подбирание объекта if(inventory().m_pTarget && inventory().m_pTarget->Useful() && m_pUsableObject && m_pUsableObject->nonscript_usable() && !Level().m_feel_deny.is_object_denied(smart_cast<CGameObject*>(inventory().m_pTarget)) ) { NET_Packet P; u_EventGen(P, GE_OWNERSHIP_TAKE, ID()); P.w_u16(inventory().m_pTarget->object().ID()); u_EventSend(P); } //. ????? GetNearest ????? feel_touch_update (Position(), /*inventory().GetTakeDist()*/m_fPickupInfoRadius); CFrustum frustum; frustum.CreateFromMatrix(Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR); //. slow (ray-query test) for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++) if (CanPickItem(frustum,Device.vCameraPosition,*it)) PickupInfoDraw(*it); }
void CArtefact::OnAnimationEnd(u32 state) { switch (state) { case eHiding: { SwitchState(eHidden); }break; case eShowing: { SwitchState(eIdle); }break; case eActivating: { if(Local()) { SwitchState (eHiding); NET_Packet P; u_EventGen (P, GEG_PLAYER_ACTIVATEARTEFACT, H_Parent()->ID()); P.w_u16 (ID()); u_EventSend (P); } }break; }; }
void CEntity::KillEntity(u16 whoID) { if (whoID != ID()) { #ifdef DEBUG if (m_killer_id != ALife::_OBJECT_ID(-1)) { Msg ("! Entity [%s][%s] already has killer with id %d, but new killer id arrived - %d",*cNameSect(),*cName(),m_killer_id,whoID); CObject *old_killer = Level().Objects.net_Find(m_killer_id); Msg ("! Old killer is %s",old_killer ? *old_killer->cName() : "unknown"); CObject *new_killer = Level().Objects.net_Find(whoID); Msg ("! New killer is %s",new_killer ? *new_killer->cName() : "unknown"); VERIFY (m_killer_id == ALife::_OBJECT_ID(-1)); } #endif } else { if (m_killer_id != ALife::_OBJECT_ID(-1)) return; } m_killer_id = whoID; set_death_time (); if (!getDestroy()){ NET_Packet P; u_EventGen (P,GE_DIE,ID()); P.w_u16 (u16(whoID)); P.w_u32 (0); if (OnServer()) u_EventSend (P, net_flags(TRUE, TRUE, FALSE, TRUE)); } };
void game_cl_GameState::SendPickUpEvent (u16 ID_who, u16 ID_what) { NET_Packet P; u_EventGen(P,GE_OWNERSHIP_TAKE, ID_who); P.w_u16(ID_what); u_EventSend(P); };
void CArtefact::OnAnimationEnd (u32 state) { switch (state) { case eHiding: { SwitchState(eHidden); //. if(m_pInventory->GetNextActiveSlot()!=NO_ACTIVE_SLOT) //. m_pInventory->Activate(m_pInventory->GetPrevActiveSlot()); }break; case eShowing: { SwitchState(eIdle); }break; case eActivating: { if(Local()){ SwitchState (eHiding); NET_Packet P; u_EventGen (P, GEG_PLAYER_ACTIVATEARTEFACT, H_Parent()->ID()); P.w_u16 (ID()); u_EventSend (P); } }break; }; }
void game_cl_CaptureTheArtefact::OnBuyMenu_Ok() { #ifdef DEBUG Msg("* CTA: Buy menu OK..."); #endif // #ifdef DEBUG typedef CUIGameCTA::BuyMenuItemsCollection TBuyCol; VERIFY2(m_game_ui, "game ui not initialized"); CUIGameCTA::BuyMenuItemsCollection toBuyItemsCollection; s32 moneyDif = 0; m_game_ui->GetPurchaseItems(toBuyItemsCollection, moneyDif); R_ASSERT(local_player); if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) { if (InWarmUp()) { buy_amount = 0; } else { buy_amount = moneyDif; } UpdateMoneyIndicator(); } CGameObject* pPlayer = smart_cast<CGameObject*>(Level().CurrentEntity()); VERIFY(pPlayer); NET_Packet P; pPlayer->u_EventGen(P, GE_GAME_EVENT, pPlayer->ID()); P.w_u16(GAME_EVENT_PLAYER_BUY_FINISHED); if (InWarmUp()) { P.w_s32(0); } else { P.w_s32(moneyDif); } P.w_u16(static_cast<u16>(toBuyItemsCollection.size())); TBuyCol::const_iterator bie = toBuyItemsCollection.end(); for (TBuyCol::const_iterator toBuyIter = toBuyItemsCollection.begin(); toBuyIter != bie; ++toBuyIter) { P.w_u8(toBuyIter->first); P.w_u8(toBuyIter->second); } pPlayer->u_EventSend(P); if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) { u_EventGen(P, GE_GAME_EVENT, local_player->GameID); P.w_u16(GAME_EVENT_PLAYER_BUYMENU_CLOSE); u_EventSend(P); } set_buy_menu_not_ready(); }
void CCustomZone::GoEnabledState() { //switch to idle NET_Packet P; u_EventGen (P,GE_ZONE_STATE_CHANGE,ID()); P.w_u8 (u8(eZoneStateIdle)); u_EventSend (P); }
void CWeaponRPG7::switch2_Fire() { m_iShotNum = 0; m_bFireSingleShot = true; bWorking = false; if(GetState()==eFire && getRocketCount()) { Fvector p1, d1, p; Fvector p2, d2, d; p1.set (get_LastFP()); d1.set (get_LastFD()); p = p1; d = d1; CEntity* E = smart_cast<CEntity*> (H_Parent()); if(E) { E->g_fireParams (this, p2,d2); p = p2; d = d2; if(IsHudModeNow()) { Fvector p0; float dist = HUD().GetCurrentRayQuery().range; p0.mul (d2,dist); p0.add (p1); p = p1; d.sub (p0,p1); d.normalize_safe(); } } Fmatrix launch_matrix; launch_matrix.identity (); launch_matrix.k.set (d); Fvector::generate_orthonormal_basis(launch_matrix.k, launch_matrix.j, launch_matrix.i); launch_matrix.c.set (p); d.normalize (); d.mul (m_fLaunchSpeed); CRocketLauncher::LaunchRocket (launch_matrix, d, zero_vel); CExplosiveRocket* pGrenade = smart_cast<CExplosiveRocket*>(getCurrentRocket()); VERIFY (pGrenade); pGrenade->SetInitiator (H_Parent()->ID()); if (OnServer()) { NET_Packet P; u_EventGen (P,GE_LAUNCH_ROCKET,ID()); P.w_u16 (u16(getCurrentRocket()->ID())); u_EventSend (P); } } }
void game_sv_TeamDeathmatch::OnPlayerChangeTeam(ClientID id_who, s16 team) { game_PlayerState* ps_who = get_id (id_who); if (!ps_who) return; if (!team) { if (!ps_who->team) team = AutoTeam(); else if (TeamSizeEqual()) { team = ps_who->team; } else { team = AutoTeam(); } }; //----------------------------------------------------- NET_Packet Px; GenerateGameMessage(Px); Px.w_u32(GAME_EVENT_PLAYER_GAME_MENU_RESPOND); Px.w_u8(PLAYER_CHANGE_TEAM); Px.w_s16(team); m_server->SendTo(id_who,Px,net_flags(TRUE,TRUE)); //----------------------------------------------------- if (ps_who->team == team) return; //----------------------------------------------------- KillPlayer(id_who, ps_who->GameID); //----------------------------------------------------- ps_who->setFlag(GAME_PLAYER_FLAG_SPECTATOR); //----------------------------------------------------- s16 OldTeam = ps_who->team; ps_who->team = u8(team & 0x00ff); TeamStruct* pTS = GetTeamData(team); if (pTS) { if ((ps_who->money_for_round < pTS->m_iM_Start) || (OldTeam == 0)) Money_SetStart(id_who); } ///////////////////////////////////////////////////////// //Send Switch team message NET_Packet P; // P.w_begin (M_GAMEMESSAGE); GenerateGameMessage (P); P.w_u32 (PLAYER_CHANGE_TEAM); P.w_u16 (ps_who->GameID); P.w_u16 (ps_who->team); P.w_u16 (team); u_EventSend(P); ///////////////////////////////////////////////////////// SetPlayersDefItems(ps_who); }
void game_cl_CaptureTheArtefact::OnBuyMenuOpen() { if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) { NET_Packet P; u_EventGen(P, GE_GAME_EVENT, local_player->GameID); P.w_u16(GAME_EVENT_PLAYER_BUYMENU_OPEN); u_EventSend(P); } }
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 CTeamBaseZone::feel_touch_delete (CObject *tpObject) { if(OnServer() && tpObject->CLS_ID == CLSID_OBJECT_ACTOR) { NET_Packet P_; u_EventGen (P_,GE_GAME_EVENT,ID() ); P_.w_u16 (GAME_EVENT_PLAYER_LEAVE_TEAM_BASE ); P_.w_u16 ( tpObject->ID() ); P_.w_u8 ( GetZoneTeam() ); u_EventSend (P_,net_flags(TRUE,TRUE)); }; }
void CCustomZone::SwitchZoneState(EZoneState new_state) { if (OnServer()) { // !!! Just single entry for given state !!! NET_Packet P; u_EventGen (P,GE_ZONE_STATE_CHANGE,ID()); P.w_u8 (u8(new_state)); u_EventSend (P); }; m_iPreviousStateTime = m_iStateTime = 0; }
void CEntity::shedule_Update (u32 dt) { inherited::shedule_Update (dt); if (!getDestroy() && !g_Alive() && (m_killer_id != u16(-1))) { if (Device.dwTimeGlobal > m_level_death_time + FORGET_KILLER_TIME) { m_killer_id = u16(-1); NET_Packet P; u_EventGen (P,GE_ASSIGN_KILLER,ID()); P.w_u16 (u16(-1)); if (IsGameTypeSingle()) u_EventSend (P); } } }
void CGameObject::DestroyObject() { if(m_bObjectRemoved) return; m_bObjectRemoved = true; if (getDestroy()) return; if (Local()) { NET_Packet P; u_EventGen (P,GE_DESTROY,ID()); u_EventSend (P); } }
void CBottleItem::Hit (SHit* pHDS) { inherited::Hit(pHDS); if(pHDS->damage()>BREAK_POWER) { //Generate Expode event if (Local()) { NET_Packet P; u_EventGen (P,GE_GRENADE_EXPLODE,ID()); u_EventSend (P); }; } }
void CBaseMonster::Hit_Wound(CObject *object, float value, const Fvector &dir, float impulse) { NET_Packet P; SHit HS; HS.GenHeader(GE_HIT, object->ID()); // u_EventGen (P,GE_HIT, object->ID()); HS.whoID = (ID()); // P.w_u16 (ID()); HS.weaponID = (ID()); // P.w_u16 (ID()); HS.dir = (dir); // P.w_dir (dir); HS.power = (value); // P.w_float (value); HS.boneID = (smart_cast<IKinematics*>(object->Visual())->LL_GetBoneRoot()); // P.w_s16 (smart_cast<IKinematics*>(object->Visual())->LL_GetBoneRoot()); HS.p_in_bone_space = (Fvector().set(0.f,0.f,0.f)); // P.w_vec3 (Fvector().set(0.f,0.f,0.f)); HS.impulse = (impulse); // P.w_float (impulse); HS.hit_type = (ALife::eHitTypeWound); // P.w_u16 (u16(ALife::eHitTypeWound)); HS.Write_Packet(P); u_EventSend (P); }
void CBaseMonster::Hit_Psy(CObject *object, float value) { NET_Packet P; SHit HS; HS.GenHeader (GE_HIT, object->ID()); // // u_EventGen (P,GE_HIT, object->ID()); // HS.whoID = (ID()); // own // P.w_u16 (ID()); // own HS.weaponID = (ID()); // own // P.w_u16 (ID()); // own HS.dir = (Fvector().set(0.f,1.f,0.f)); // direction // P.w_dir (Fvector().set(0.f,1.f,0.f)); // direction HS.power = (value); // hit value // P.w_float (value); // hit value HS.boneID = (BI_NONE); // bone // P.w_s16 (BI_NONE); // bone HS.p_in_bone_space = (Fvector().set(0.f,0.f,0.f)); // P.w_vec3 (Fvector().set(0.f,0.f,0.f)); HS.impulse = (0.f); // P.w_float (0.f); HS.hit_type = (ALife::eHitTypeTelepatic); // P.w_u16 (u16(ALife::eHitTypeTelepatic)); HS.Write_Packet (P); u_EventSend (P); }
void CActor::g_Physics (Fvector& _accel, float jump, float dt) { // Correct accel Fvector accel; accel.set (_accel); hit_slowmo -= dt; if (hit_slowmo<0) hit_slowmo = 0.f; accel.mul (1.f-hit_slowmo); if(g_Alive()) { if(mstate_real&mcClimb&&!cameras[eacFirstEye]->bClampYaw)accel.set(0.f,0.f,0.f); character_physics_support()->movement()->Calculate (accel,cameras[cam_active]->vDirection,0,jump,dt,false); bool new_border_state=character_physics_support()->movement()->isOutBorder(); if(m_bOutBorder!=new_border_state && Level().CurrentControlEntity() == this) { SwitchOutBorder(new_border_state); } character_physics_support()->movement()->GetPosition (Position()); character_physics_support()->movement()->bSleep =false; } if (Local() && g_Alive()) { if (character_physics_support()->movement()->gcontact_Was) Cameras().AddCamEffector (xr_new<CEffectorFall> (character_physics_support()->movement()->gcontact_Power)); if (!fis_zero(character_physics_support()->movement()->gcontact_HealthLost)) { const ICollisionDamageInfo* di=character_physics_support()->movement()->CollisionDamageInfo(); Fvector hdir;di->HitDir(hdir); SetHitInfo(this, NULL, 0, Fvector().set(0, 0, 0), hdir); // Hit (m_PhysicMovementControl->gcontact_HealthLost,hdir,di->DamageInitiator(),m_PhysicMovementControl->ContactBone(),di->HitPos(),0.f,ALife::eHitTypeStrike);//s16(6 + 2*::Random.randI(0,2)) if (Level().CurrentControlEntity() == this) { SHit HDS = SHit(character_physics_support()->movement()->gcontact_HealthLost,hdir,di->DamageInitiator(),character_physics_support()->movement()->ContactBone(),di->HitPos(),0.f,di->HitType()); // Hit(&HDS); NET_Packet l_P; HDS.GenHeader(GE_HIT, ID()); HDS.whoID = di->DamageInitiator()->ID(); HDS.weaponID = di->DamageInitiator()->ID(); HDS.Write_Packet(l_P); u_EventSend (l_P); } } } }
void CCustomZone::GoDisabledState() { //switch to disable NET_Packet P; u_EventGen (P,GE_ZONE_STATE_CHANGE,ID()); P.w_u8 (u8(eZoneStateDisabled)); u_EventSend (P); OBJECT_INFO_VEC_IT it = m_ObjectInfoMap.begin(); OBJECT_INFO_VEC_IT it_e = m_ObjectInfoMap.end(); for(;it!=it_e;++it) exit_Zone(*it); m_ObjectInfoMap.clear (); feel_touch.clear (); }
void CCar::OnEvent(NET_Packet& P, u16 type) { inherited::OnEvent (P,type); CExplosive::OnEvent (P,type); //обработка сообщений, нужных для работы с багажником машины u16 id; switch (type) { case GE_OWNERSHIP_TAKE: { P.r_u16 (id); CObject* O = Level().Objects.net_Find (id); if( GetInventory()->CanTakeItem(smart_cast<CInventoryItem*>(O)) ) { O->H_SetParent(this); GetInventory()->Take(smart_cast<CGameObject*>(O), false, false); } else { if (!O || !O->H_Parent() || (this != O->H_Parent())) return; NET_Packet P; u_EventGen(P,GE_OWNERSHIP_REJECT,ID()); P.w_u16(u16(O->ID())); u_EventSend(P); } }break; case GE_OWNERSHIP_REJECT: { P.r_u16 (id); CObject* O = Level().Objects.net_Find (id); bool just_before_destroy = !P.r_eof() && P.r_u8(); O->SetTmpPreDestroy (just_before_destroy); GetInventory()->DropItem(smart_cast<CGameObject*>(O), just_before_destroy, just_before_destroy); //if(GetInventory()->DropItem(smart_cast<CGameObject*>(O), just_before_destroy)) //{ // O->H_SetParent(0, just_before_destroy); //} //moved to DropItem }break; } }
void CBreakableObject::ProcessDamage() { NET_Packet P; SHit HS; HS.GenHeader (GE_HIT, ID()); HS.whoID = (ID()); HS.weaponID = (ID()); HS.dir = (m_contact_damage_dir); HS.power = (m_max_frame_damage); HS.boneID = (PKinematics(Visual())->LL_GetBoneRoot()); HS.p_in_bone_space = (m_contact_damage_pos); HS.impulse = (0.f); HS.hit_type = (ALife::eHitTypeStrike); HS.Write_Packet (P); u_EventSend (P); m_max_frame_damage = 0.f; b_resived_damage =false; }
void CInfoDocument::OnH_A_Chield() { inherited::OnH_A_Chield (); //передать информацию содержащуюся в документе //объекту, который поднял документ CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(H_Parent()); if(!pInvOwner) return; //создать и отправить пакет о получении новой информации if(m_Info.size()) { NET_Packet P; u_EventGen (P,GE_INFO_TRANSFER, H_Parent()->ID()); P.w_u16 (ID()); //отправитель P.w_stringZ (m_Info); //сообщение P.w_u8 (1); //добавление сообщения u_EventSend (P); } }
void CAI_Stalker::remove_personal_only_ammo (const CInventoryItem *item) { const CWeapon *weapon = smart_cast<const CWeapon*>(item); VERIFY (weapon); xr_vector<shared_str>::const_iterator I = weapon->m_ammoTypes.begin(); xr_vector<shared_str>::const_iterator E = weapon->m_ammoTypes.end(); for ( ; I != E; ++I) { bool found = false; TIItemContainer::const_iterator i = inventory().m_all.begin(); TIItemContainer::const_iterator e = inventory().m_all.end(); for ( ; i != e; ++i) { if ((*i)->object().ID() == weapon->ID()) continue; const CWeapon *temp = smart_cast<const CWeapon*>(*i); if (!temp) continue; if (std::find(temp->m_ammoTypes.begin(),temp->m_ammoTypes.end(),*I) == temp->m_ammoTypes.end()) continue; found = true; break; } if (found) continue; for (i = inventory().m_all.begin(); i != e; ++i) { if (xr_strcmp(*I,(*i)->object().cNameSect())) continue; NET_Packet packet; u_EventGen (packet,GE_DESTROY,(*i)->object().ID()); u_EventSend (packet); } } }
void game_sv_TeamDeathmatch::OnPlayerConnectFinished (ClientID id_who) { inherited::OnPlayerConnectFinished(id_who); xrClientData* xrCData = m_server->ID_to_client(id_who); // Send Message About Client join Team if (xrCData) { NET_Packet P; // P.w_begin (M_GAMEMESSAGE); GenerateGameMessage (P); P.w_u32 (GAME_EVENT_PLAYER_JOIN_TEAM); P.w_stringZ ( xrCData->name.c_str() ); P.w_u16 (xrCData->ps->team); u_EventSend(P); }; if (xrCData) { if (xrCData->ps) xrCData->ps->m_iTeamKills = 0; } };
void CCustomZone::CreateHit ( u16 id_to, u16 id_from, const Fvector& hit_dir, float hit_power, s16 bone_id, const Fvector& pos_in_bone, float hit_impulse, ALife::EHitType hit_type) { if (OnServer()) { if(m_owner_id != u32(-1) ) id_from = (u16)m_owner_id; NET_Packet l_P; Fvector hdir = hit_dir; SHit Hit = SHit(hit_power, hdir, this, bone_id, pos_in_bone, hit_impulse, hit_type, 0.0f, false); Hit.GenHeader (GE_HIT, id_to); Hit.whoID = id_from; Hit.weaponID = this->ID(); Hit.Write_Packet (l_P); u_EventSend (l_P); }; }
void CBaseMonster::HitEntity(const CEntity *pEntity, float fDamage, float impulse, Fvector &dir, ALife::EHitType hit_type, bool draw_hit_marks) { if (!g_Alive()) return; if (!pEntity || pEntity->getDestroy()) return; if (!EnemyMan.get_enemy()) return; if (EnemyMan.get_enemy() == pEntity) { Fvector position_in_bone_space; position_in_bone_space.set(0.f,0.f,0.f); // перевод из локальных координат в мировые вектора направления импульса Fvector hit_dir; XFORM().transform_dir (hit_dir,dir); hit_dir.normalize (); CEntity *pEntityNC = const_cast<CEntity*>(pEntity); VERIFY (pEntityNC); NET_Packet l_P; SHit HS; HS.GenHeader(GE_HIT, pEntityNC->ID()); // u_EventGen (l_P,GE_HIT, pEntityNC->ID()); HS.whoID = (ID()); // l_P.w_u16 (ID()); HS.weaponID = (ID()); // l_P.w_u16 (ID()); HS.dir = (hit_dir); // l_P.w_dir (hit_dir); HS.power = (fDamage); // l_P.w_float (fDamage); HS.boneID = (smart_cast<IKinematics*>(pEntityNC->Visual())->LL_GetBoneRoot());// l_P.w_s16 (smart_cast<IKinematics*>(pEntityNC->Visual())->LL_GetBoneRoot()); HS.p_in_bone_space = (position_in_bone_space); // l_P.w_vec3 (position_in_bone_space); HS.impulse = (impulse); // l_P.w_float (impulse); HS.hit_type = hit_type; // l_P.w_u16 ( u16(ALife::eHitTypeWound) ); HS.Write_Packet(l_P); u_EventSend (l_P); if (pEntityNC == Actor() && draw_hit_marks) { START_PROFILE("BaseMonster/Animation/HitEntity"); SDrawStaticStruct* s = CurrentGameUI()->AddCustomStatic("monster_claws", false); float h1,p1; Device.vCameraDirection.getHP (h1,p1); Fvector hd = hit_dir; hd.mul (-1); float d = -h1 + hd.getH (); s->wnd()->SetHeading (d); Fvector2 wnd_pos = s->wnd()->GetWndPos(); wnd_pos.y += 400.0f*_cos(d); wnd_pos.x += 500.0f*_sin(d); s->wnd()->SetWndPos(wnd_pos); STOP_PROFILE; //SetAttackEffector (); float time_to_lock = fDamage * MAX_LOCK_TIME; clamp (time_to_lock, 0.f, MAX_LOCK_TIME); Actor()->lock_accel_for (int(time_to_lock * 1000)); ////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////// CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effBigMonsterHit); if(!ce) { const shared_str& eff_sect = pSettings->r_string(cNameSect(), "actor_hit_effect"); if(eff_sect.c_str()) { int id = -1; Fvector cam_pos,cam_dir,cam_norm; Actor()->cam_Active()->Get (cam_pos,cam_dir,cam_norm); cam_dir.normalize_safe (); dir.normalize_safe (); float ang_diff = angle_difference (cam_dir.getH(), dir.getH()); Fvector cp; cp.crossproduct (cam_dir,dir); bool bUp =(cp.y>0.0f); Fvector cross; cross.crossproduct (cam_dir, dir); VERIFY (ang_diff>=0.0f && ang_diff<=PI); float _s1 = PI_DIV_8; float _s2 = _s1+PI_DIV_4; float _s3 = _s2+PI_DIV_4; float _s4 = _s3+PI_DIV_4; if(ang_diff<=_s1){ id = 2; }else { if(ang_diff>_s1 && ang_diff<=_s2){ id = (bUp)?5:7; }else if(ang_diff>_s2 && ang_diff<=_s3){ id = (bUp)?3:1; }else if(ang_diff>_s3 && ang_diff<=_s4){ id = (bUp)?4:6; }else if(ang_diff>_s4){ id = 0; }else{ VERIFY(0); } } string64 sect_name; xr_sprintf (sect_name,"%s_%d",eff_sect.c_str(), id); AddEffector (Actor(), effBigMonsterHit, sect_name, fDamage); } } ////////////////////////////////////////////////////////////////////////// } Morale.on_attack_success(); m_time_last_attack_success = Device.dwTimeGlobal; } }
void CActor::IR_OnKeyboardPress(int cmd) { if(hud_adj_mode && pInput->iGetAsyncKeyState(DIK_LSHIFT)) return; if (Remote()) return; if (IsTalking()) return; if (m_input_external_handler && !m_input_external_handler->authorized(cmd)) return; switch (cmd) { case kWPN_FIRE: { /* XEM #95 */ //if( (mstate_wishful & mcLookout) && !IsGameTypeSingle() ) return; u16 slot = inventory().GetActiveSlot(); if(inventory().ActiveItem() && (slot==INV_SLOT_3 || slot==INV_SLOT_2) ) mstate_wishful &=~mcSprint; //----------------------------- if (OnServer()) { NET_Packet P; P.w_begin(M_PLAYER_FIRE); P.w_u16(ID()); u_EventSend(P); } }break; default: { }break; } if (!g_Alive()) return; if(m_holder && kUSE != cmd) { m_holder->OnKeyboardPress (cmd); if(m_holder->allowWeapon() && inventory().Action((u16)cmd, CMD_START)) return; return; }else if(inventory().Action((u16)cmd, CMD_START)) return; #ifdef DEBUG if(psActorFlags.test(AF_NO_CLIP)) { NoClipFly(cmd); return; } #endif //DEBUG switch(cmd) { case kJUMP: { mstate_wishful |= mcJump; }break; case kSPRINT_TOGGLE: { mstate_wishful ^= mcSprint; }break; case kCROUCH: { if( psActorFlags.test(AF_CROUCH_TOGGLE) ) mstate_wishful ^= mcCrouch; }break; case kCAM_1: cam_Set (eacFirstEye); break; case kCAM_2: cam_Set (eacLookAt); break; case kCAM_3: cam_Set (eacFreeLook); break; case kNIGHT_VISION: { SwitchNightVision(); break; } case kTORCH: { SwitchTorch(); break; } case kDETECTOR: { PIItem det_active = inventory().ItemFromSlot(DETECTOR_SLOT); if(det_active) { CCustomDetector* det = smart_cast<CCustomDetector*>(det_active); det->ToggleDetector (g_player_hud->attached_item(0)!=NULL); return; } }break; /* case kFLARE:{ PIItem fl_active = inventory().ItemFromSlot(FLARE_SLOT); if(fl_active) { CFlare* fl = smart_cast<CFlare*>(fl_active); fl->DropFlare (); return ; } PIItem fli = inventory().Get(CLSID_DEVICE_FLARE, true); if(!fli) return; CFlare* fl = smart_cast<CFlare*>(fli); if(inventory().Slot(fl)) fl->ActivateFlare (); }break; */ case kUSE: ActorUse(); break; case kDROP: b_DropActivated = TRUE; f_DropPower = 0; break; case kNEXT_SLOT: { OnNextWeaponSlot(); }break; case kPREV_SLOT: { OnPrevWeaponSlot(); }break; case kQUICK_USE_1: case kQUICK_USE_2: case kQUICK_USE_3: case kQUICK_USE_4: { const shared_str& item_name = g_quick_use_slots[cmd-kQUICK_USE_1]; if(item_name.size()) { PIItem itm = inventory().GetAny(item_name.c_str()); if(itm) { if (IsGameTypeSingle()) { inventory().Eat (itm); } else { inventory().ClientEat (itm); } StaticDrawableWrapper* _s = CurrentGameUI()->AddCustomStatic("item_used", true); string1024 str; strconcat (sizeof(str),str,*CStringTable().translate("st_item_used"),": ", itm->NameItem()); _s->wnd()->TextItemControl()->SetText(str); CurrentGameUI()->GetActorMenu().m_pQuickSlot->ReloadReferences(this); } } }break; } }