void SArtefactActivation::ChangeEffects() { VERIFY(!ph_world->Processing()); SStateDef& state_def = m_activation_states[(int)m_cur_activation_state]; if(m_snd._feedback()) m_snd.stop(); if(state_def.m_snd.size()){ m_snd.create (*state_def.m_snd,st_Effect,sg_SourceType); m_snd.play_at_pos (m_af, m_af->Position()); }; m_light->set_range ( state_def.m_light_range); m_light->set_color ( state_def.m_light_color.r, state_def.m_light_color.g, state_def.m_light_color.b); if(state_def.m_particle.size()){ Fvector dir; dir.set(0,1,0); m_af->CParticlesPlayer::StartParticles( state_def.m_particle, dir, m_af->ID(), iFloor(state_def.m_time*1000) ); }; if(state_def.m_animation.size()){ CKinematicsAnimated *K=smart_cast<CKinematicsAnimated*>(m_af->Visual()); if(K)K->PlayCycle(*state_def.m_animation); } }
void SArtefactActivation::UpdateActivation() { VERIFY(!ph_world->Processing()); m_cur_state_time += Device.fTimeDelta; if(m_cur_state_time >= m_activation_states[int(m_cur_activation_state)].m_time){ m_cur_activation_state = (EActivationStates)(int)(m_cur_activation_state+1); if(m_cur_activation_state == eMax){ m_cur_activation_state = eNone; m_af->processing_deactivate (); m_af->CPHUpdateObject::Deactivate (); m_af->DestroyObject(); } m_cur_state_time = 0.0f; ChangeEffects (); if(m_cur_activation_state==eSpawnZone && OnServer()) SpawnAnomaly (); } UpdateEffects (); }
void SArtefactActivation::UpdateEffects() { VERIFY(!ph_world->Processing()); if(m_snd._feedback()) m_snd.set_position( m_af->Position() ); m_light->set_position(m_af->Position()); }
BOOL CAfList::feel_touch_contact (CObject* O) { CLASS_ID clsid = O->CLS_ID; TypesMapIt it = m_TypesMap.find(clsid); bool res = (it!=m_TypesMap.end()); if(res) { CArtefact* pAf = smart_cast<CArtefact*>(O); if(pAf->GetAfRank()>m_af_rank) res = false; } return res; }
void SArtefactActivation::Start() { VERIFY(!ph_world->Processing()); m_af->StopLights (); m_cur_activation_state = eStarting; m_cur_state_time = 0.0f; m_af->processing_activate(); NET_Packet P; CGameObject::u_EventGen (P,GE_OWNERSHIP_REJECT, m_af->H_Parent()->ID()); P.w_u16 (m_af->ID()); if (OnServer()) CGameObject::u_EventSend (P); m_light->set_active (true); ChangeEffects (); }
float CActor::get_additional_weight() const { float res = 0.0f ; CCustomOutfit* outfit = GetOutfit(); if ( outfit ) { res += outfit->m_additional_weight; } for(TIItemContainer::const_iterator it = inventory().m_belt.begin(); inventory().m_belt.end() != it; ++it) { CArtefact* artefact = smart_cast<CArtefact*>(*it); if(artefact) res += artefact->AdditionalInventoryWeight(); } return res; }
void game_cl_ArtefactHunt::GetMapEntities(xr_vector<SZoneMapEntityData>& dst) { inherited::GetMapEntities(dst); SZoneMapEntityData D; u32 color_enemy_with_artefact = 0xffff0000; u32 color_artefact = 0xffffffff; u32 color_friend_with_artefact = 0xffffff00; s16 local_team = local_player->team; CObject* pObject = Level().Objects.net_Find(artefactID); if(!pObject) return; CArtefact* pArtefact = smart_cast<CArtefact*>(pObject); VERIFY(pArtefact); CObject* pParent = pArtefact->H_Parent(); if(!pParent){// Artefact alone D.color = color_artefact; D.pos = pArtefact->Position(); dst.push_back(D); return; }; if (pParent && pParent->ID() == artefactBearerID && GetPlayerByGameID(artefactBearerID)){ CObject* pBearer = Level().Objects.net_Find(artefactBearerID); VERIFY(pBearer); D.pos = pBearer->Position(); game_PlayerState* ps = GetPlayerByGameID (artefactBearerID); (ps->team==local_team)? D.color=color_friend_with_artefact:D.color=color_enemy_with_artefact; //remove previous record about this actor !!! dst.push_back(D); return; } }
void SArtefactActivation::PhDataUpdate(dReal step) { if (m_cur_activation_state==eFlying) { Fvector dir = {0, -1.f, 0}; if(Level().ObjectSpace.RayTest(m_af->Position(), dir, 1.0f, collide::rqtBoth,NULL,m_af) ){ dir.y = ph_world->Gravity()*1.1f; m_af->m_pPhysicsShell->applyGravityAccel(dir); } } }
void CEliteDetector::UpdateAf() { ui().Clear (); if(m_artefacts.m_ItemInfos.size()==0) return; CAfList::ItemsMapIt it_b = m_artefacts.m_ItemInfos.begin(); CAfList::ItemsMapIt it_e = m_artefacts.m_ItemInfos.end(); CAfList::ItemsMapIt it = it_b; Fvector detector_pos = Position(); for(;it_b!=it_e;++it_b) { CArtefact *pAf = it_b->first; if(pAf->H_Parent()) continue; ui().RegisterItemToDraw (pAf->Position(),"af_sign"); if(pAf->CanBeInvisible()) { float d = detector_pos.distance_to(pAf->Position()); if(d<m_fAfVisRadius) pAf->SwitchVisibility(true); } } }
void SArtefactActivation::Load() { for(int i=0; i<(int)eMax; ++i) m_activation_states.push_back(SStateDef()); LPCSTR activation_seq = pSettings->r_string(*m_af->cNameSect(),"artefact_activation_seq"); m_activation_states[(int)eStarting].Load(activation_seq, "starting"); m_activation_states[(int)eFlying].Load(activation_seq, "flying"); m_activation_states[(int)eBeforeSpawn].Load(activation_seq, "idle_before_spawning"); m_activation_states[(int)eSpawnZone].Load(activation_seq, "spawning"); }
void SArtefactActivation::SpawnAnomaly() { VERIFY(!ph_world->Processing()); string128 tmp; LPCSTR str = pSettings->r_string("artefact_spawn_zones",*m_af->cNameSect()); VERIFY3(3==_GetItemCount(str),"Bad record format in artefact_spawn_zones",str); float zone_radius = (float)atof(_GetItem(str,1,tmp)); float zone_power = (float)atof(_GetItem(str,2,tmp)); LPCSTR zone_sect = _GetItem(str,0,tmp); //must be last call of _GetItem... (LPCSTR !!!) Fvector pos; m_af->Center(pos); CSE_Abstract *object = Level().spawn_item( zone_sect, pos, m_af->ai_location().level_vertex_id(), 0xffff, true ); CSE_ALifeAnomalousZone* AlifeZone = smart_cast<CSE_ALifeAnomalousZone*>(object); VERIFY(AlifeZone); CShapeData::shape_def _shape; _shape.data.sphere.P.set (0.0f,0.0f,0.0f); _shape.data.sphere.R = zone_radius; _shape.type = CShapeData::cfSphere; AlifeZone->assign_shapes (&_shape,1); AlifeZone->m_maxPower = zone_power; AlifeZone->m_owner_id = m_owner_id; AlifeZone->m_space_restrictor_type = RestrictionSpace::eRestrictorTypeNone; NET_Packet P; object->Spawn_Write (P,TRUE); Level().Send (P,net_flags(TRUE)); F_entity_Destroy (object); #ifdef DEBUG Msg("artefact [%s] spawned a zone [%s] at [%f]", *m_af->cName(), zone_sect, Device.fTimeGlobal); #endif }
void CScientificDetector::UpfateWork() { ui().Clear (); CAfList::ItemsMapIt ait_b = m_artefacts.m_ItemInfos.begin(); CAfList::ItemsMapIt ait_e = m_artefacts.m_ItemInfos.end(); CAfList::ItemsMapIt ait = ait_b; Fvector detector_pos = Position(); for(;ait_b!=ait_e;++ait_b) { CArtefact *pAf = ait_b->first; if(pAf->H_Parent()) continue; ui().RegisterItemToDraw (pAf->Position(), pAf->cNameSect()); if(pAf->CanBeInvisible()) { float d = detector_pos.distance_to(pAf->Position()); if(d<m_fAfVisRadius) pAf->SwitchVisibility(true); } } CZoneList::ItemsMapIt zit_b = m_zones.m_ItemInfos.begin(); CZoneList::ItemsMapIt zit_e = m_zones.m_ItemInfos.end(); CZoneList::ItemsMapIt zit = zit_b; for(;zit_b!=zit_e;++zit_b) { CCustomZone* pZone = zit_b->first; ui().RegisterItemToDraw (pZone->Position(),pZone->cNameSect()); } m_ui->update (); }
void CActor::g_SetAnimation( u32 mstate_rl ) { if (!g_Alive()) { if (m_current_legs||m_current_torso){ SActorState* ST = 0; if (mstate_rl&mcCrouch) ST = &m_anims->m_crouch; else ST = &m_anims->m_normal; mstate_real = 0; m_current_legs.invalidate (); m_current_torso.invalidate (); smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle(m_anims->m_dead_stop); } return; } STorsoWpn::eMovingState moving_idx = STorsoWpn::eIdle; SActorState* ST = 0; SAnimState* AS = 0; if (mstate_rl&mcCrouch) ST = &m_anims->m_crouch; else if (mstate_rl&mcClimb) ST = &m_anims->m_climb; else ST = &m_anims->m_normal; bool bAccelerated = isActorAccelerated(mstate_rl, IsZoomAimingMode()); if ( bAccelerated ){ AS = &ST->m_run; }else{ AS = &ST->m_walk; } if(mstate_rl&mcAnyMove){ if( bAccelerated ) moving_idx = STorsoWpn::eRun; else moving_idx = STorsoWpn::eWalk; } // анимации MotionID M_legs; MotionID M_torso; MotionID M_head; //если мы просто стоим на месте bool is_standing = false; // Legs if (mstate_rl&mcLanding) M_legs = ST->landing[0]; else if (mstate_rl&mcLanding2) M_legs = ST->landing[1]; else if ((mstate_rl&mcTurn)&& !(mstate_rl&mcClimb)) M_legs = ST->legs_turn; else if (mstate_rl&mcFall) M_legs = ST->jump_idle; else if (mstate_rl&mcJump) M_legs = ST->jump_begin; else if (mstate_rl&mcFwd) M_legs = AS->legs_fwd; else if (mstate_rl&mcBack) M_legs = AS->legs_back; else if (mstate_rl&mcLStrafe) M_legs = AS->legs_ls; else if (mstate_rl&mcRStrafe) M_legs = AS->legs_rs; else is_standing = true; if(mstate_rl&mcSprint){ g_SetSprintAnimation (mstate_rl,M_head,M_torso,M_legs); moving_idx = STorsoWpn::eSprint; } //--------------------------------------------------------------- if (this == Level().CurrentViewEntity()) { if ((mstate_rl&mcSprint) != (mstate_old&mcSprint)) { CHudItem* pHudItem = smart_cast<CHudItem*>(inventory().ActiveItem()); if (pHudItem) pHudItem->onMovementChanged(mcSprint); }; }; //----------------------------------------------------------------------- // Torso if(mstate_rl&mcClimb) { if (mstate_rl&mcFwd) M_torso = AS->legs_fwd; else if (mstate_rl&mcBack) M_torso = AS->legs_back; else if (mstate_rl&mcLStrafe) M_torso = AS->legs_ls; else if (mstate_rl&mcRStrafe) M_torso = AS->legs_rs; } if(!M_torso) { CInventoryItem* _i = inventory().ActiveItem(); CHudItem *H = smart_cast<CHudItem*>(_i); CWeapon *W = smart_cast<CWeapon*>(_i); CMissile *M = smart_cast<CMissile*>(_i); CArtefact *A = smart_cast<CArtefact*>(_i); if (H) { VERIFY(H->animation_slot() <= _total_anim_slots_); STorsoWpn* TW = &ST->m_torso[H->animation_slot() - 1]; if (!b_DropActivated&&!fis_zero(f_DropPower)){ M_torso = TW->drop; if (!M_torso) { Msg("! drop animation for %s", *(H->object().cName())); M_torso = ST->m_torso_idle; }; m_bAnimTorsoPlayed = TRUE; }else{ if (!m_bAnimTorsoPlayed) { if (W) { bool K =inventory().GetActiveSlot() == KNIFE_SLOT; bool R3 = W->IsTriStateReload(); if(K) { switch (W->GetState()){ case CWeapon::eIdle: M_torso = TW->moving[moving_idx]; break; case CWeapon::eFire: if(is_standing) M_torso = M_legs = M_head = TW->all_attack_0; else M_torso = TW->attack_zoom; break; case CWeapon::eFire2: if(is_standing) M_torso = M_legs = M_head = TW->all_attack_1; else M_torso = TW->fire_idle; break; case CWeapon::eJammed: case CWeapon::eReload: M_torso = TW->reload; break; case CWeapon::eShowing: M_torso = TW->draw; break; case CWeapon::eHiding: M_torso = TW->holster; break; default : M_torso = TW->moving[moving_idx]; break; } } else { switch (W->GetState()){ case CWeapon::eIdle: M_torso = W->IsZoomed()?TW->zoom:TW->moving[moving_idx]; break; case CWeapon::eFire: M_torso = W->IsZoomed()?TW->attack_zoom:TW->attack; break; case CWeapon::eFire2: M_torso = W->IsZoomed()?TW->attack_zoom:TW->attack; break; case CWeapon::eJammed: case CWeapon::eReload: if(!R3) M_torso = TW->reload; else{ CWeapon::EWeaponSubStates sub_st = W->GetReloadState(); switch (sub_st){ case CWeapon::eSubstateReloadBegin: M_torso = TW->reload; break; case CWeapon::eSubstateReloadInProcess: M_torso = TW->reload_1; break; case CWeapon::eSubstateReloadEnd: M_torso = TW->reload_2; break; default: M_torso = TW->reload; break; } }break; case CWeapon::eShowing: M_torso = TW->draw; break; case CWeapon::eHiding: M_torso = TW->holster; break; default : M_torso = TW->moving[moving_idx]; break; } } } else if (M) { if(is_standing) { switch (M->GetState()){ case MS_SHOWING : M_torso = TW->draw; break; case MS_HIDING : M_torso = TW->holster; break; case MS_IDLE_SPRINT: ; case MS_IDLE : M_torso = TW->moving[moving_idx]; break; case MS_EMPTY : M_torso = TW->zoom; break; case MS_THREATEN : M_torso = M_legs = M_head = TW->all_attack_0; break; case MS_READY : M_torso = M_legs = M_head = TW->all_attack_1; break; case MS_THROW : M_torso = M_legs = M_head = TW->all_attack_2; break; case MS_END : M_torso = M_legs = M_head = TW->all_attack_2; break; default : M_torso = TW->draw; break; } } else { switch (M->GetState()){ case MS_SHOWING : M_torso = TW->draw; break; case MS_HIDING : M_torso = TW->holster; break; case MS_IDLE_SPRINT: ; case MS_IDLE : M_torso = TW->moving[moving_idx]; break; case MS_EMPTY : M_torso = TW->moving[moving_idx]; break; case MS_THREATEN : M_torso = TW->attack_zoom; break; case MS_READY : M_torso = TW->fire_idle; break; case MS_THROW : M_torso = TW->fire_end; break; case MS_END : M_torso = TW->fire_end; break; default : M_torso = TW->draw; break; } } } else if (A){ switch(A->GetState()){ case CArtefact::eIdle : M_torso = TW->moving[moving_idx]; break; case CArtefact::eShowing : M_torso = TW->draw; break; case CArtefact::eHiding : M_torso = TW->holster; break; case CArtefact::eActivating : M_torso = TW->zoom; break; default : M_torso = TW->moving[moving_idx]; } } } } } } if (!M_legs) { if((mstate_rl&mcCrouch)&&!isActorAccelerated(mstate_rl, IsZoomAimingMode()))//!(mstate_rl&mcAccel)) { M_legs=smart_cast<CKinematicsAnimated*>(Visual())->ID_Cycle("cr_idle_1"); } else M_legs = ST->legs_idle; } if (!M_head) M_head = ST->m_head_idle; if (!M_torso){ if (m_bAnimTorsoPlayed) M_torso = m_current_torso; else M_torso = ST->m_torso_idle; } // есть анимация для всего - запустим / иначе запустим анимацию по частям if (m_current_torso!=M_torso){ if (m_bAnimTorsoPlayed) m_current_torso_blend = smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle(M_torso,TRUE,AnimTorsoPlayCallBack,this); else /**/m_current_torso_blend = /**/smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle(M_torso); m_current_torso=M_torso; } if(m_current_head!=M_head) { if(M_head)smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle(M_head); m_current_head=M_head; } if (m_current_legs!=M_legs){ float pos = 0.f; VERIFY (!m_current_legs_blend || !fis_zero(m_current_legs_blend->timeTotal)); if ((mstate_real&mcAnyMove)&&(mstate_old&mcAnyMove)&&m_current_legs_blend) pos = fmod(m_current_legs_blend->timeCurrent,m_current_legs_blend->timeTotal)/m_current_legs_blend->timeTotal; m_current_legs_blend = smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle(M_legs,TRUE,legs_play_callback,this); if ((!(mstate_old&mcAnyMove))&&(mstate_real&mcAnyMove)) pos = 0.5f*Random.randI(2); if (m_current_legs_blend) m_current_legs_blend->timeCurrent = m_current_legs_blend->timeTotal*pos; m_current_legs = M_legs; CStepManager::on_animation_start(M_legs, m_current_legs_blend); } #ifdef _DEBUG if(bDebug){ HUD().Font().pFontStat->OutSetI (0,0); HUD().Font().pFontStat->OutNext("[%s]",mov_state[moving_idx]); } #endif #ifdef _DEBUG if ((Level().CurrentControlEntity() == this) && g_ShowAnimationInfo) { string128 buf; strcpy(buf,""); if (isActorAccelerated(mstate_rl, IsZoomAimingMode())) strcat(buf,"Accel "); if (mstate_rl&mcCrouch) strcat(buf,"Crouch "); if (mstate_rl&mcFwd) strcat(buf,"Fwd "); if (mstate_rl&mcBack) strcat(buf,"Back "); if (mstate_rl&mcLStrafe) strcat(buf,"LStrafe "); if (mstate_rl&mcRStrafe) strcat(buf,"RStrafe "); if (mstate_rl&mcJump) strcat(buf,"Jump "); if (mstate_rl&mcFall) strcat(buf,"Fall "); if (mstate_rl&mcTurn) strcat(buf,"Turn "); if (mstate_rl&mcLanding) strcat(buf,"Landing "); if (mstate_rl&mcLLookout) strcat(buf,"LLookout "); if (mstate_rl&mcRLookout) strcat(buf,"RLookout "); if (m_bJumpKeyPressed) strcat(buf,"+Jumping "); HUD().Font().pFontStat->OutNext ("MSTATE: [%s]",buf); /* switch (m_PhysicMovementControl->Environment()) { case CPHMovementControl::peOnGround: strcpy(buf,"ground"); break; case CPHMovementControl::peInAir: strcpy(buf,"air"); break; case CPHMovementControl::peAtWall: strcpy(buf,"wall"); break; } HUD().Font().pFontStat->OutNext (buf); HUD().Font().pFontStat->OutNext ("Accel [%3.2f, %3.2f, %3.2f]",VPUSH(NET_SavedAccel)); HUD().Font().pFontStat->OutNext ("V [%3.2f, %3.2f, %3.2f]",VPUSH(m_PhysicMovementControl->GetVelocity())); HUD().Font().pFontStat->OutNext ("vertex ID %d",ai_location().level_vertex_id()); Game().m_WeaponUsageStatistic->Draw(); */ }; #endif if (!m_current_torso_blend) return; CKinematicsAnimated *skeleton_animated = PKinematicsAnimated(Visual()); CMotionDef *motion0 = skeleton_animated->LL_GetMotionDef(m_current_torso); VERIFY (motion0); if (!(motion0->flags & esmSyncPart)) return; if (!m_current_legs_blend) return; CMotionDef *motion1 = skeleton_animated->LL_GetMotionDef(m_current_legs); VERIFY (motion1); if (!(motion1->flags & esmSyncPart)) return; m_current_torso_blend->timeCurrent = m_current_legs_blend->timeCurrent/m_current_legs_blend->timeTotal*m_current_torso_blend->timeTotal; }
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* O = Level().Objects.net_Find (id); if (!O) { Msg("! Error: No object to take/buy [%d]", id); break; } CGameObject* _GO = smart_cast<CGameObject*>(O); CFoodItem* pFood = smart_cast<CFoodItem*>(O); if(pFood) #if defined(INV_NEW_SLOTS_SYSTEM) if (pFood->m_eItemPlace != eItemPlaceSlot) #endif pFood->m_eItemPlace = eItemPlaceRuck; if( inventory().CanTakeItem(smart_cast<CInventoryItem*>(_GO)) ) { O->H_SetParent(smart_cast<CObject*>(this)); inventory().Take(_GO, false, true); CUIGameSP* pGameSP = NULL; CUI* ui = HUD().GetUI(); if( ui&&ui->UIGame() ) { pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); if (Level().CurrentViewEntity() == this) HUD().GetUI()->UIGame()->ReInitShownUI(); }; //добавить отсоединенный аддон в инвентарь if(pGameSP) { if(pGameSP->MainInputReceiver() == pGameSP->InventoryMenu) { pGameSP->InventoryMenu->AddItemToBag(smart_cast<CInventoryItem*>(O)); } } SelectBestWeapon(O); } else { NET_Packet P; u_EventGen(P,GE_OWNERSHIP_REJECT,ID()); P.w_u16(u16(O->ID())); u_EventSend(P); } } break; case GE_TRADE_SELL: case GE_OWNERSHIP_REJECT: { P.r_u16 (id); CObject* O = Level().Objects.net_Find (id); if (!O) { Msg("! Error: No object to reject/sell [%d]", id); break; } bool just_before_destroy = !P.r_eof() && P.r_u8(); O->SetTmpPreDestroy (just_before_destroy); if (inventory().DropItem(smart_cast<CGameObject*>(O)) && !O->getDestroy()) { O->H_SetParent(0,just_before_destroy); //. feel_touch_deny(O,2000); Level().m_feel_deny.feel_touch_deny(O, 1000); } SelectBestWeapon(O); if (Level().CurrentViewEntity() == this && HUD().GetUI() && HUD().GetUI()->UIGame()) HUD().GetUI()->UIGame()->ReInitShownUI(); } break; case GE_INV_ACTION: { s32 cmd; P.r_s32 (cmd); u32 flags; P.r_u32 (flags); s32 ZoomRndSeed = P.r_s32(); s32 ShotRndSeed = P.r_s32(); 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* O = Level().Objects.net_Find (id); if(!O) break; if (O->getDestroy()) { #ifdef DEBUG Msg("! something to destroyed object - %s[%d]0x%X", *O->cName(), id, smart_cast<CInventoryItem*>(O)); #endif break; } switch (type) { case GEG_PLAYER_ITEM2SLOT: inventory().Slot(smart_cast<CInventoryItem*>(O)); break; case GEG_PLAYER_ITEM2BELT: inventory().Belt(smart_cast<CInventoryItem*>(O)); break; case GEG_PLAYER_ITEM2RUCK: inventory().Ruck(smart_cast<CInventoryItem*>(O)); break; case GEG_PLAYER_ITEM_EAT: inventory().Eat(smart_cast<CInventoryItem*>(O)); break; case GEG_PLAYER_ACTIVATEARTEFACT: { CArtefact* pArtefact = smart_cast<CArtefact*>(O); pArtefact->ActivateArtefact (); }break; } }break; case GEG_PLAYER_ACTIVATE_SLOT: { u32 slot_id; P.r_u32 (slot_id); inventory().Activate (slot_id); }break; case GEG_PLAYER_WEAPON_HIDE_STATE: { u32 State = P.r_u32(); BOOL Set = !!P.r_u8(); inventory().SetSlotsBlocked ((u16)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 GEG_PLAYER_ATTACH_HOLDER: { u32 id = P.r_u32(); 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; u32 id = P.r_u32(); 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 CUIArtefactParams::SetInfo(CGameObject *obj) { CArtefact *art = smart_cast<CArtefact*> (obj); R_ASSERT2(art, "object is not CArtefact"); const shared_str& af_section = art->cNameSect(); CActor *pActor = Actor(); if (!pActor) return; string128 _buff; float _h = 0.0f; DetachAll (); for(u32 i=_item_start; i<_max_item_index; ++i) { CUIStatic* _s = m_info_items[i]; float _val; if(i<_max_item_index1) { #ifdef AF_SHOW_DYNAMIC_PARAMS float _actor_val = pActor->conditions().GetParamByName(af_actor_param_names[i]); float CArtefact::* pRestoreSpeed = af_prop_offsets[i]; _val = (art->*pRestoreSpeed); // alpet: используется указатель на данные класса #else _val = pSettings->r_float (af_section, af_item_sect_names[i]); float _actor_val = pSettings->r_float ("actor_condition", af_actor_param_names[i]); #endif if (fis_zero(_val)) continue; _val = (_val/_actor_val)*100.0f; }else { #ifdef AF_SHOW_DYNAMIC_PARAMS u32 idx = i - _max_item_index1; // absorbation index _val = art->m_ArtefactHitImmunities.immunities()[idx]; // real absorbation values #else shared_str _sect = pSettings->r_string(af_section, "hit_absorbation_sect"); _val = pSettings->r_float(_sect, af_item_sect_names[i]); #endif if (fsimilar(_val, 1.0f)) continue; _val = (1.0f - _val); _val *= 100.0f; } LPCSTR _sn = "%"; if(i==_item_radiation_restore_speed || i==_item_power_restore_speed) { _val /= 100.0f; _sn = ""; } LPCSTR _color = (_val>0)?"%c[green]":"%c[red]"; if(i==_item_bleeding_restore_speed) _val *= -1.0f; if(i==_item_bleeding_restore_speed || i==_item_radiation_restore_speed) _color = (_val>0)?"%c[red]":"%c[green]"; sprintf_s ( _buff, "%s %s %+.0f %s", CStringTable().translate(af_item_param_names[i]).c_str(), _color, _val, _sn); _s->SetText (_buff); _s->SetWndPos (_s->GetWndPos().x, _h); _h += _s->GetWndSize().y; AttachChild (_s); } SetHeight (_h); }
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; } }