BOOL CObject::net_Spawn (CSE_Abstract* data) { PositionStack.clear (); VERIFY (_valid(renderable.xform)); if (0==Visual() && pSettings->line_exist( cNameSect(), "visual" ) ) cNameVisual_set (pSettings->r_string( cNameSect(), "visual" ) ); if (0==collidable.model) { if (pSettings->line_exist(cNameSect(),"cform")) { //LPCSTR cf = pSettings->r_string (*cNameSect(), "cform"); VERIFY3 (*NameVisual, "Model isn't assigned for object, but cform requisted",*cName()); collidable.model = xr_new<CCF_Skeleton> (this); } } R_ASSERT(spatial.space); spatial_register(); if (register_schedule()) shedule_register (); // reinitialize flags //. Props.bActiveCounter = 0; processing_activate (); setDestroy (false); MakeMeCrow (); return TRUE ; }
void CGrenade::GetBriefInfo(xr_string& str_name, xr_string& icon_sect_name, xr_string& str_count) { str_name = NameShort(); u32 ThisGrenadeCount = m_pCurrentInventory->dwfGetSameItemCount(*cNameSect(), true); string16 stmp; sprintf_s (stmp, "%d", ThisGrenadeCount); str_count = stmp; icon_sect_name = *cNameSect(); }
void CHelicopter::UseFireTrail(bool val) { m_enemy.bUseFireTrail = val; if(val){ fireDispersionBase = pSettings->r_float (*cNameSect(),"fire_dispersion_null"); fireDispersionBase = deg2rad (fireDispersionBase); }else{ fireDispersionBase = pSettings->r_float (*cNameSect(),"fire_dispersion_base"); fireDispersionBase = deg2rad (fireDispersionBase); } }
void CHelicopter::MGunUpdateFire() { fShotTimeCounter -= Device.fTimeDelta; if (delta_t < 0){ delta_t = Device.fTimeGlobal; flag_by_fire = 0; } float time_f = Device.fTimeGlobal - delta_t; float fire_time; if(pSettings->line_exist(*cNameSect(),"fire_time")) fire_time = pSettings->r_float(*cNameSect(),"fire_time"); else fire_time = -1; float no_fire_time; if(pSettings->line_exist(*cNameSect(),"no_fire_time")) no_fire_time = pSettings->r_float(*cNameSect(),"no_fire_time"); else no_fire_time = -1; CShootingObject::UpdateFlameParticles(); CShootingObject::UpdateLight(); if(!IsWorking()) { clamp(fShotTimeCounter,0.0f, flt_max); return; } if(no_fire_time > 0 && fire_time > 0) { if (flag_by_fire==1 && time_f > fire_time){ delta_t = Device.fTimeGlobal; time_f = Device.fTimeGlobal - delta_t; flag_by_fire = 0; } if (time_f > no_fire_time && flag_by_fire ==0){ delta_t = Device.fTimeGlobal; time_f = Device.fTimeGlobal - delta_t; flag_by_fire = 1; } if(flag_by_fire ==0 && time_f < no_fire_time) return; } if(fShotTimeCounter<=0) { OnShot(); fShotTimeCounter += fOneShotTime; } }
bool CGrenade::GetBriefInfo( II_BriefInfo& info ) { VERIFY( m_pInventory ); info.clear(); info.name._set( m_nameShort ); info.icon._set( cNameSect() ); u32 ThisGrenadeCount = m_pInventory->dwfGetSameItemCount( cNameSect().c_str(), true ); string16 stmp; xr_sprintf( stmp, "%d", ThisGrenadeCount ); info.cur_ammo._set( stmp ); return true; }
bool CGrenade::Action(s32 cmd, u32 flags) { if(inherited::Action(cmd, flags)) return true; switch(cmd) { //переключение типа гранаты case kWPN_NEXT: { if(flags&CMD_START) { if(m_pCurrentInventory) { TIItemContainer::iterator it = m_pCurrentInventory->m_ruck.begin(); TIItemContainer::iterator it_e = m_pCurrentInventory->m_ruck.end(); for(;it!=it_e;++it) { CGrenade *pGrenade = smart_cast<CGrenade*>(*it); if(pGrenade && xr_strcmp(pGrenade->cNameSect(), cNameSect())) { m_pCurrentInventory->Ruck(this); m_pCurrentInventory->SetActiveSlot(NO_ACTIVE_SLOT); m_pCurrentInventory->Slot(pGrenade); return true; } } return true; } } return true; }; } return false; }
void CPseudoGigant::reinit() { inherited::reinit(); m_time_next_threaten = 0; if(CCustomMonster::use_simplified_visual()) return; move().load_velocity(*cNameSect(), "Velocity_JumpPrepare",MonsterMovement::eGiantVelocityParameterJumpPrepare); move().load_velocity(*cNameSect(), "Velocity_JumpGround",MonsterMovement::eGiantVelocityParameterJumpGround); //com_man().load_jump_data(0,"jump_attack_0", "jump_attack_1", "jump_attack_2", MonsterMovement::eGiantVelocityParameterJumpPrepare, MonsterMovement::eGiantVelocityParameterJumpGround,0); com_man().add_rotation_jump_data("1","2","3","4", PI_DIV_2); com_man().set_threaten_data ("stand_kick_0", 0.43f); }
void CWeapon::SwitchState(u32 S) { if (OnClient()) return; #ifndef MASTER_GOLD if ( bDebug ) { Msg("---Server is going to send GE_WPN_STATE_CHANGE to [%d], weapon_section[%s], parent[%s]", S, cNameSect().c_str(), H_Parent() ? H_Parent()->cName().c_str() : "NULL Parent"); } #endif // #ifndef MASTER_GOLD SetNextState ( S ); if (CHudItem::object().Local() && !CHudItem::object().getDestroy() && m_pInventory && OnServer()) { // !!! Just single entry for given state !!! NET_Packet P; CHudItem::object().u_EventGen (P,GE_WPN_STATE_CHANGE,CHudItem::object().ID()); P.w_u8 (u8(S)); P.w_u8 (u8(m_sub_state)); P.w_u8 (m_ammoType); P.w_u8 (u8(iAmmoElapsed & 0xff)); P.w_u8 (m_set_next_ammoType_on_reload); CHudItem::object().u_EventSend (P, net_flags(TRUE, TRUE, FALSE, TRUE)); } }
void CCustomOutfit::ApplySkinModel(CActor* pActor, bool bDress, bool bHUDOnly) { if(bDress) { if(!bHUDOnly && m_ActorVisual.size()) { shared_str NewVisual = NULL; char* TeamSection = Game().getTeamSection(pActor->g_Team()); if (TeamSection) { if (pSettings->line_exist(TeamSection, *cNameSect())) { NewVisual = pSettings->r_string(TeamSection, *cNameSect()); string256 SkinName; xr_strcpy(SkinName, pSettings->r_string("mp_skins_path", "skin_path")); xr_strcat(SkinName, *NewVisual); xr_strcat(SkinName, ".ogf"); NewVisual._set(SkinName); } } if (!NewVisual.size()) NewVisual = m_ActorVisual; pActor->ChangeVisual(NewVisual); } if (pActor == Level().CurrentViewEntity()) g_player_hud->load(pSettings->r_string(cNameSect(),"player_hud_section")); }else { if (!bHUDOnly && m_ActorVisual.size()) { shared_str DefVisual = pActor->GetDefaultVisualOutfit(); if (DefVisual.size()) { pActor->ChangeVisual(DefVisual); }; } if (pActor == Level().CurrentViewEntity()) g_player_hud->load_default(); } }
void CWeaponMagazined::state_Fire(float dt) { VERIFY(fTimeToFire > 0.f); Fvector p1, d; p1.set(get_LastFP()); d.set(get_LastFD()); if (!H_Parent()) return; CInventoryOwner* io = smart_cast<CInventoryOwner*>(H_Parent()); if (NULL == io->inventory().ActiveItem()) { Log("current_state", GetState()); Log("next_state", GetNextState()); Log("state_time", m_dwStateTime); Log("item_sect", cNameSect().c_str()); Log("H_Parent", H_Parent()->cNameSect().c_str()); } smart_cast<CEntity*> (H_Parent())->g_fireParams(this, p1, d); if (m_iShotNum == 0) { m_vStartPos = p1; m_vStartDir = d; }; VERIFY(!m_magazine.empty()); // Msg("%d && %d && (%d || %d) && (%d || %d)", !m_magazine.empty(), fTime<=0, IsWorking(), m_bFireSingleShot, m_iQueueSize < 0, m_iShotNum < m_iQueueSize); while (!m_magazine.empty() && fTime <= 0 && (IsWorking() || m_bFireSingleShot) && (m_iQueueSize < 0 || m_iShotNum < m_iQueueSize)) { m_bFireSingleShot = false; VERIFY(fTimeToFire > 0.f); fTime += fTimeToFire; ++m_iShotNum; OnShot(); static int i = 0; if (i || m_iShotNum > m_iShootEffectorStart) { // Do Weapon Callback. (Cribbledirge) StateSwitchCallback(GameObject::eOnActorWeaponFire, GameObject::eOnNPCWeaponFire); FireTrace(p1, d); } else { FireTrace(m_vStartPos, m_vStartDir); } } if (m_iShotNum == m_iQueueSize) m_bStopedAfterQueueFired = true; UpdateSounds(); }
void CPhysicObject:: run_anim_back () { if( !check_blend( m_anim_blend, cName().c_str(), cNameSect().c_str(), cNameVisual().c_str() ) ) return; m_anim_blend->playing = TRUE; m_anim_blend->stop_at_end_callback = TRUE; if(m_anim_blend->speed > 0.f) m_anim_blend->speed = -m_anim_blend->speed; }
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::OnShot () { Fvector fire_pos,fire_dir; fire_pos = get_CurrentFirePoint(); fire_dir = m_fire_dir; float fire_trail_speed = 15.0f; clamp (fire_trail_speed,GetCurrVelocity(),300.0f); if(m_enemy.bUseFireTrail){ Fvector enemy_pos = m_enemy.destEnemyPos; float dt = Device.fTimeGlobal - m_enemy.fStartFireTime; VERIFY(dt>=0); float dist = m_enemy.fire_trail_length_curr - dt*fire_trail_speed; if(dist<0) { MGunFireEnd (); return ; } Fvector fp = fire_pos; fp.y = enemy_pos.y; Fvector fd; fd.sub(enemy_pos,fp).normalize_safe(); if(dist > (m_enemy.fire_trail_length_curr/2.0f) ){ fd.mul(-1.0f); dist = dist - (m_enemy.fire_trail_length_curr/2.0f); }else{ dist = (m_enemy.fire_trail_length_curr/2.0f) - dist; } static float fire_trace_width = pSettings->r_float(*cNameSect(),"fire_trace_width"); enemy_pos.mad(fd,dist); Fvector disp_dir; disp_dir.random_point(fire_trace_width); enemy_pos.add(disp_dir); fire_dir.sub(enemy_pos,fire_pos).normalize_safe(); }; FireBullet(fire_pos, fire_dir, fireDispersionBase, m_CurrentAmmo, ID(), ID(), OnServer()); StartShotParticles (); if(m_bLightShotEnabled) Light_Start (); StartFlameParticles (); StartSmokeParticles (fire_pos, zero_vel); OnShellDrop (fire_pos, zero_vel); HUD_SOUND_ITEM::PlaySound (m_sndShot, fire_pos, this, false); }
void CActor::OnDifficultyChanged () { // immunities VERIFY(g_SingleGameDifficulty>=egdNovice && g_SingleGameDifficulty<=egdMaster); LPCSTR diff_name = get_token_name(difficulty_type_token, g_SingleGameDifficulty); string128 tmp; strconcat (tmp,"actor_immunities_",diff_name); conditions().LoadImmunities (tmp,pSettings); // hit probability strconcat (tmp,"hit_probability_",diff_name); hit_probability = pSettings->r_float(*cNameSect(),tmp); }
void CSnork::reinit() { inherited::reinit (); if(CCustomMonster::use_simplified_visual() ) return; move().load_velocity(*cNameSect(), "Velocity_JumpGround",MonsterMovement::eSnorkVelocityParameterJumpGround); com_man().load_jump_data("stand_attack_2_0",0, "stand_attack_2_1", "stand_somersault_0", u32(-1), MonsterMovement::eSnorkVelocityParameterJumpGround,0); start_threaten = false; com_man().set_threaten_data ("stand_threaten_0", 0.63f); // TODO: remove this m_target_node = 0; }
void CCustomMonster::reinit () { CScriptEntity::reinit (); CEntityAlive::reinit (); if (character_physics_support()) material().reinit (); movement().reinit (); sound().reinit (); m_client_update_delta = 0; m_last_client_update_time = Device.dwTimeGlobal; eye_pp_stage = 0; m_dwLastUpdateTime = 0xffffffff; m_tEyeShift.set (0,0,0); m_fEyeShiftYaw = 0.f; NET_WasExtrapolating = FALSE; ////////////////////////////////////////////////////////////////////////// // Critical Wounds ////////////////////////////////////////////////////////////////////////// m_critical_wound_type = u32(-1); m_last_hit_time = 0; m_critical_wound_accumulator = 0.f; m_critical_wound_threshold = pSettings->r_float(cNameSect(),"critical_wound_threshold"); m_critical_wound_decrease_quant = pSettings->r_float(cNameSect(),"critical_wound_decrease_quant"); if (m_critical_wound_threshold >= 0) load_critical_wound_bones (); ////////////////////////////////////////////////////////////////////////// m_update_rotation_on_frame = true; m_movement_enabled_before_animation_controller = true; }
void CCustomOutfit::OnMoveToSlot () { if (m_pInventory) { CActor* pActor = smart_cast<CActor*> (m_pInventory->GetOwner()); if (pActor) { if (m_ActorVisual.size()) { shared_str NewVisual = NULL; char* TeamSection = Game().getTeamSection(pActor->g_Team()); if (TeamSection) { if (pSettings->line_exist(TeamSection, *cNameSect())) { NewVisual = pSettings->r_string(TeamSection, *cNameSect()); string256 SkinName; std::strcpy(SkinName, pSettings->r_string("mp_skins_path", "skin_path")); strcat(SkinName, *NewVisual); strcat(SkinName, ".ogf"); NewVisual._set(SkinName); } } if (!NewVisual.size()) NewVisual = m_ActorVisual; pActor->ChangeVisual(NewVisual); } if(pSettings->line_exist(cNameSect(),"bones_koeff_protection")){ m_boneProtection->reload( pSettings->r_string(cNameSect(),"bones_koeff_protection"), smart_cast<CKinematics*>(pActor->Visual()) ); }; } } };
void CHelicopter::DieHelicopter() { if ( state() == CHelicopter::eDead ) return; CEntity::Die(NULL); m_engineSound.stop (); m_brokenSound.create (pSettings->r_string(*cNameSect(), "broken_snd"),st_Effect,sg_SourceType); m_brokenSound.play_at_pos (0,XFORM().c,sm_Looped); CKinematics* K = smart_cast<CKinematics*>(Visual()); if(true /*!PPhysicsShell()*/){ string256 I; LPCSTR bone; u16 bone_id; for (u32 i=0, n=_GetItemCount(*m_death_bones_to_hide); i<n; ++i){ bone = _GetItem(*m_death_bones_to_hide,i,I); bone_id = K->LL_BoneID (bone); K->LL_SetBoneVisible(bone_id,FALSE,TRUE); } ///PPhysicsShell()=P_build_Shell (this,false); PPhysicsShell()->EnabledCallbacks(TRUE); PPhysicsShell()->set_ObjectContactCallback(CollisionCallbackDead); PPhysicsShell()->set_ContactCallback(ContactShotMark); } Fvector lin_vel; Fvector prev_pos = PositionStack.front().vPosition; lin_vel.sub (XFORM().c,prev_pos); if(Device.dwTimeGlobal != PositionStack.front().dwTime) lin_vel.div((Device.dwTimeGlobal-PositionStack.front().dwTime)/1000.0f); lin_vel.mul (m_death_lin_vel_k); PPhysicsShell()->set_LinearVel (lin_vel); PPhysicsShell()->set_AngularVel (m_death_ang_vel); PPhysicsShell()->Enable (); K->CalculateBones_Invalidate (); K->CalculateBones (); setState (CHelicopter::eDead); m_engineSound.stop (); processing_deactivate (); m_dead = true; }
void CArtefact::StartLights() { VERIFY(!physics_world()->Processing()); if(!m_bLightsEnabled) return; VERIFY (m_pTrailLight == NULL); m_pTrailLight = ::Render->light_create(); bool const b_light_shadow = !!pSettings->r_bool(cNameSect(), "idle_light_shadow"); m_pTrailLight->set_shadow (b_light_shadow); m_pTrailLight->set_color (m_TrailLightColor); m_pTrailLight->set_range (m_fTrailLightRange); m_pTrailLight->set_position (Position()); m_pTrailLight->set_active (true); }
void CPhysicObject:: anim_time_set ( float time ) { if( !check_blend( m_anim_blend, cName().c_str(), cNameSect().c_str(), cNameVisual().c_str() ) ) return ; if( time < 0.f || time > m_anim_blend->timeTotal ) { #ifdef DEBUG Msg( " ! can not set blend time %f - it must be in range 0 - %f(timeTotal) obj: %s, model: %s, anim: %s", time, m_anim_blend->timeTotal, cName().c_str(), cNameVisual().c_str(), smart_cast<IKinematicsAnimated*>( PPhysicsShell()->PKinematics() )->LL_MotionDefName_dbg( m_anim_blend->motionID ).first ); #endif return; } m_anim_blend->timeCurrent = time; IKinematics *K = smart_cast<IKinematics*>(Visual()); VERIFY( K ); K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); }
void CAI_Stalker::on_after_take (const CGameObject *object) { if (!g_Alive()) return; if (!READ_IF_EXISTS(pSettings,r_bool,cNameSect(),"use_single_item_rule",true)) return; const CWeapon *new_weapon = smart_cast<const CWeapon*>(object); if (!new_weapon) return; TIItemContainer::iterator I = inventory().m_all.begin(); TIItemContainer::iterator E = inventory().m_all.end(); for ( ; I != E; ++I) update_conflicted (*I,new_weapon); }
void CBaseMonster::fill_bones_body_parts (LPCSTR body_part, CriticalWoundType wound_type) { LPCSTR body_parts_section = pSettings->r_string(cNameSect(),body_part); IKinematics *kinematics = smart_cast<IKinematics*>(Visual()); VERIFY (kinematics); CInifile::Sect &body_part_section = pSettings->r_section(body_parts_section); CInifile::SectCIt I = body_part_section.Data.begin(); CInifile::SectCIt E = body_part_section.Data.end(); for ( ; I != E; ++I) m_bones_body_parts.insert ( std::make_pair( kinematics->LL_BoneID((*I).first), u32(wound_type) ) ); }
BOOL CArtefact::net_Spawn(CSE_Abstract* DC) { if(pSettings->r_bool(cNameSect(),"can_be_controlled") ) m_detectorObj = xr_new<SArtefactDetectorsSupport>(this); BOOL result = inherited::net_Spawn(DC); SwitchAfParticles (true); StartLights(); m_CarringBoneID = u16(-1); IKinematicsAnimated *K = smart_cast<IKinematicsAnimated*>(Visual()); if(K) K->PlayCycle("idle"); o_fastmode = FALSE; // start initially with fast-mode enabled o_render_frame = 0; SetState (eHidden); return result; }
/* s32 CWeaponAmmo::Sort(PIItem pIItem) { // Если нужно разместить IItem после this - вернуть 1, если // перед - -1. Если пофиг то 0. CWeaponAmmo *l_pA = smart_cast<CWeaponAmmo*>(pIItem); if(!l_pA) return 0; if(xr_strcmp(cNameSect(), l_pA->cNameSect())) return 0; if(m_boxCurr <= l_pA->m_boxCurr) return 1; else return -1; } */ bool CWeaponAmmo::Get(CCartridge &cartridge) { if(!m_boxCurr) return false; cartridge.m_ammoSect = cNameSect(); cartridge.m_kDist = m_kDist; cartridge.m_kDisp = m_kDisp; cartridge.m_kHit = m_kHit; cartridge.m_kImpulse = m_kImpulse; cartridge.m_kPierce = m_kPierce; cartridge.m_kAP = m_kAP; cartridge.m_kAirRes = m_kAirRes; cartridge.m_u8ColorID = m_u8ColorID; cartridge.m_flags.set(CCartridge::cfTracer ,m_tracer); cartridge.m_buckShot = m_buckShot; cartridge.m_impair = m_impair; cartridge.fWallmarkSize = fWallmarkSize; cartridge.bullet_material_idx = GMLib.GetMaterialIdx(WEAPON_MATERIAL_NAME); cartridge.m_InvShortName = NameShort(); --m_boxCurr; if(m_pInventory)m_pInventory->InvalidateState(); return true; }
void CBaseMonster::load_critical_wound_bones() { // animation does not exist - no bones loaded if (pSettings->line_exist(cNameSect(),"critical_wound_anim_head")) { fill_bones_body_parts ("critical_wound_bones_head", critical_wound_type_head); m_critical_wound_anim_head = pSettings->r_string(cNameSect(),"critical_wound_anim_head"); } if (pSettings->line_exist(cNameSect(),"critical_wound_anim_torso")) { fill_bones_body_parts ("critical_wound_bones_torso", critical_wound_type_torso); m_critical_wound_anim_torso = pSettings->r_string(cNameSect(),"critical_wound_anim_torso"); } if (pSettings->line_exist(cNameSect(),"critical_wound_anim_legs")) { fill_bones_body_parts ("critical_wound_bones_legs", critical_wound_type_legs); m_critical_wound_anim_legs = pSettings->r_string(cNameSect(),"critical_wound_anim_legs"); } }
void CWeapon::Load (LPCSTR section) { inherited::Load (section); CShootingObject::Load (section); if(pSettings->line_exist(section, "flame_particles_2")) m_sFlameParticles2 = pSettings->r_string(section, "flame_particles_2"); // load ammo classes m_ammoTypes.clear (); LPCSTR S = pSettings->r_string(section,"ammo_class"); if (S && S[0]) { string128 _ammoItem; int count = _GetItemCount (S); for (int it=0; it<count; ++it) { _GetItem (S,it,_ammoItem); m_ammoTypes.push_back (_ammoItem); } } iAmmoElapsed = pSettings->r_s32 (section,"ammo_elapsed" ); iMagazineSize = pSettings->r_s32 (section,"ammo_mag_size" ); //////////////////////////////////////////////////// // дисперсия стрельбы //подбрасывание камеры во время отдачи u8 rm = READ_IF_EXISTS( pSettings, r_u8, section, "cam_return", 1 ); cam_recoil.ReturnMode = (rm == 1); rm = READ_IF_EXISTS( pSettings, r_u8, section, "cam_return_stop", 0 ); cam_recoil.StopReturn = (rm == 1); float temp_f = 0.0f; temp_f = pSettings->r_float( section,"cam_relax_speed" ); cam_recoil.RelaxSpeed = _abs( deg2rad( temp_f ) ); VERIFY( !fis_zero(cam_recoil.RelaxSpeed) ); if ( fis_zero(cam_recoil.RelaxSpeed) ) { cam_recoil.RelaxSpeed = EPS_L; } cam_recoil.RelaxSpeed_AI = cam_recoil.RelaxSpeed; if ( pSettings->line_exist( section, "cam_relax_speed_ai" ) ) { temp_f = pSettings->r_float( section, "cam_relax_speed_ai" ); cam_recoil.RelaxSpeed_AI = _abs( deg2rad( temp_f ) ); VERIFY( !fis_zero(cam_recoil.RelaxSpeed_AI) ); if ( fis_zero(cam_recoil.RelaxSpeed_AI) ) { cam_recoil.RelaxSpeed_AI = EPS_L; } } temp_f = pSettings->r_float( section, "cam_max_angle" ); cam_recoil.MaxAngleVert = _abs( deg2rad( temp_f ) ); VERIFY( !fis_zero(cam_recoil.MaxAngleVert) ); if ( fis_zero(cam_recoil.MaxAngleVert) ) { cam_recoil.MaxAngleVert = EPS; } temp_f = pSettings->r_float( section, "cam_max_angle_horz" ); cam_recoil.MaxAngleHorz = _abs( deg2rad( temp_f ) ); VERIFY( !fis_zero(cam_recoil.MaxAngleHorz) ); if ( fis_zero(cam_recoil.MaxAngleHorz) ) { cam_recoil.MaxAngleHorz = EPS; } temp_f = pSettings->r_float( section, "cam_step_angle_horz" ); cam_recoil.StepAngleHorz = deg2rad( temp_f ); cam_recoil.DispersionFrac = _abs( READ_IF_EXISTS( pSettings, r_float, section, "cam_dispersion_frac", 0.7f ) ); //подбрасывание камеры во время отдачи в режиме zoom ==> ironsight or scope //zoom_cam_recoil.Clone( cam_recoil ); ==== нельзя !!!!!!!!!! zoom_cam_recoil.RelaxSpeed = cam_recoil.RelaxSpeed; zoom_cam_recoil.RelaxSpeed_AI = cam_recoil.RelaxSpeed_AI; zoom_cam_recoil.DispersionFrac = cam_recoil.DispersionFrac; zoom_cam_recoil.MaxAngleVert = cam_recoil.MaxAngleVert; zoom_cam_recoil.MaxAngleHorz = cam_recoil.MaxAngleHorz; zoom_cam_recoil.StepAngleHorz = cam_recoil.StepAngleHorz; zoom_cam_recoil.ReturnMode = cam_recoil.ReturnMode; zoom_cam_recoil.StopReturn = cam_recoil.StopReturn; if ( pSettings->line_exist( section, "zoom_cam_relax_speed" ) ) { zoom_cam_recoil.RelaxSpeed = _abs( deg2rad( pSettings->r_float( section, "zoom_cam_relax_speed" ) ) ); VERIFY( !fis_zero(zoom_cam_recoil.RelaxSpeed) ); if ( fis_zero(zoom_cam_recoil.RelaxSpeed) ) { zoom_cam_recoil.RelaxSpeed = EPS_L; } } if ( pSettings->line_exist( section, "zoom_cam_relax_speed_ai" ) ) { zoom_cam_recoil.RelaxSpeed_AI = _abs( deg2rad( pSettings->r_float( section,"zoom_cam_relax_speed_ai" ) ) ); VERIFY( !fis_zero(zoom_cam_recoil.RelaxSpeed_AI) ); if ( fis_zero(zoom_cam_recoil.RelaxSpeed_AI) ) { zoom_cam_recoil.RelaxSpeed_AI = EPS_L; } } if ( pSettings->line_exist( section, "zoom_cam_max_angle" ) ) { zoom_cam_recoil.MaxAngleVert = _abs( deg2rad( pSettings->r_float( section, "zoom_cam_max_angle" ) ) ); VERIFY( !fis_zero(zoom_cam_recoil.MaxAngleVert) ); if ( fis_zero(zoom_cam_recoil.MaxAngleVert) ) { zoom_cam_recoil.MaxAngleVert = EPS; } } if ( pSettings->line_exist( section, "zoom_cam_max_angle_horz" ) ) { zoom_cam_recoil.MaxAngleHorz = _abs( deg2rad( pSettings->r_float( section, "zoom_cam_max_angle_horz" ) ) ); VERIFY( !fis_zero(zoom_cam_recoil.MaxAngleHorz) ); if ( fis_zero(zoom_cam_recoil.MaxAngleHorz) ) { zoom_cam_recoil.MaxAngleHorz = EPS; } } if ( pSettings->line_exist( section, "zoom_cam_step_angle_horz" ) ) { zoom_cam_recoil.StepAngleHorz = deg2rad( pSettings->r_float( section, "zoom_cam_step_angle_horz" ) ); } if ( pSettings->line_exist( section, "zoom_cam_dispersion_frac" ) ) { zoom_cam_recoil.DispersionFrac = _abs( pSettings->r_float( section, "zoom_cam_dispersion_frac" ) ); } m_pdm.m_fPDM_disp_base = pSettings->r_float( section, "PDM_disp_base" ); m_pdm.m_fPDM_disp_vel_factor = pSettings->r_float( section, "PDM_disp_vel_factor" ); m_pdm.m_fPDM_disp_accel_factor = pSettings->r_float( section, "PDM_disp_accel_factor" ); m_pdm.m_fPDM_disp_crouch = pSettings->r_float( section, "PDM_disp_crouch" ); m_pdm.m_fPDM_disp_crouch_no_acc = pSettings->r_float( section, "PDM_disp_crouch_no_acc" ); m_crosshair_inertion = READ_IF_EXISTS(pSettings, r_float, section, "crosshair_inertion", 5.91f); m_first_bullet_controller.load (section); fireDispersionConditionFactor = pSettings->r_float(section,"fire_dispersion_condition_factor"); // modified by Peacemaker [17.10.08] // misfireProbability = pSettings->r_float(section,"misfire_probability"); // misfireConditionK = READ_IF_EXISTS(pSettings, r_float, section, "misfire_condition_k", 1.0f); misfireStartCondition = pSettings->r_float(section, "misfire_start_condition"); misfireEndCondition = READ_IF_EXISTS(pSettings, r_float, section, "misfire_end_condition", 0.f); misfireStartProbability = READ_IF_EXISTS(pSettings, r_float, section, "misfire_start_prob", 0.f); misfireEndProbability = pSettings->r_float(section, "misfire_end_prob"); conditionDecreasePerShot = pSettings->r_float(section,"condition_shot_dec"); conditionDecreasePerQueueShot = READ_IF_EXISTS(pSettings, r_float, section, "condition_queue_shot_dec", conditionDecreasePerShot); vLoadedFirePoint = pSettings->r_fvector3 (section,"fire_point" ); if(pSettings->line_exist(section,"fire_point2")) vLoadedFirePoint2= pSettings->r_fvector3 (section,"fire_point2"); else vLoadedFirePoint2= vLoadedFirePoint; // hands eHandDependence = EHandDependence(pSettings->r_s32(section,"hand_dependence")); m_bIsSingleHanded = true; if (pSettings->line_exist(section, "single_handed")) m_bIsSingleHanded = !!pSettings->r_bool(section, "single_handed"); // m_fMinRadius = pSettings->r_float (section,"min_radius"); m_fMaxRadius = pSettings->r_float (section,"max_radius"); // информация о возможных апгрейдах и их визуализации в инвентаре m_eScopeStatus = (ALife::EWeaponAddonStatus)pSettings->r_s32(section,"scope_status"); m_eSilencerStatus = (ALife::EWeaponAddonStatus)pSettings->r_s32(section,"silencer_status"); m_eGrenadeLauncherStatus = (ALife::EWeaponAddonStatus)pSettings->r_s32(section,"grenade_launcher_status"); m_zoom_params.m_bZoomEnabled = !!pSettings->r_bool(section,"zoom_enabled"); m_zoom_params.m_fZoomRotateTime = pSettings->r_float(section,"zoom_rotate_time"); if ( m_eScopeStatus == ALife::eAddonAttachable ) { if(pSettings->line_exist(section, "scopes_sect")) { LPCSTR str = pSettings->r_string(section, "scopes_sect"); for(int i = 0, count = _GetItemCount(str); i < count; ++i ) { string128 scope_section; _GetItem (str, i, scope_section); m_scopes.push_back (scope_section); } } else { m_scopes.push_back(section); } } else if( m_eScopeStatus == ALife::eAddonPermanent ) { shared_str scope_tex_name = pSettings->r_string(cNameSect(), "scope_texture"); m_zoom_params.m_fScopeZoomFactor = pSettings->r_float( cNameSect(), "scope_zoom_factor"); if ( !g_dedicated_server ) { m_UIScope = xr_new<CUIWindow>(); if(!pWpnScopeXml) { pWpnScopeXml = xr_new<CUIXml>(); pWpnScopeXml->Load (CONFIG_PATH, UI_PATH, "scopes.xml"); } CUIXmlInit::InitWindow (*pWpnScopeXml, scope_tex_name.c_str(), 0, m_UIScope); } } if ( m_eSilencerStatus == ALife::eAddonAttachable ) { m_sSilencerName = pSettings->r_string(section,"silencer_name"); m_iSilencerX = pSettings->r_s32(section,"silencer_x"); m_iSilencerY = pSettings->r_s32(section,"silencer_y"); } if ( m_eGrenadeLauncherStatus == ALife::eAddonAttachable ) { m_sGrenadeLauncherName = pSettings->r_string(section,"grenade_launcher_name"); m_iGrenadeLauncherX = pSettings->r_s32(section,"grenade_launcher_x"); m_iGrenadeLauncherY = pSettings->r_s32(section,"grenade_launcher_y"); } InitAddons(); if(pSettings->line_exist(section,"weapon_remove_time")) m_dwWeaponRemoveTime = pSettings->r_u32(section,"weapon_remove_time"); else m_dwWeaponRemoveTime = WEAPON_REMOVE_TIME; if(pSettings->line_exist(section,"auto_spawn_ammo")) m_bAutoSpawnAmmo = pSettings->r_bool(section,"auto_spawn_ammo"); else m_bAutoSpawnAmmo = TRUE; m_zoom_params.m_bHideCrosshairInZoom = true; if(pSettings->line_exist(hud_sect, "zoom_hide_crosshair")) m_zoom_params.m_bHideCrosshairInZoom = !!pSettings->r_bool(hud_sect, "zoom_hide_crosshair"); Fvector def_dof; def_dof.set (-1,-1,-1); // m_zoom_params.m_ZoomDof = READ_IF_EXISTS(pSettings, r_fvector3, section, "zoom_dof", Fvector().set(-1,-1,-1)); // m_zoom_params.m_bZoomDofEnabled = !def_dof.similar(m_zoom_params.m_ZoomDof); // m_zoom_params.m_ReloadDof = READ_IF_EXISTS(pSettings, r_fvector4, section, "reload_dof", Fvector4().set(-1,-1,-1,-1)); m_bHasTracers = !!READ_IF_EXISTS(pSettings, r_bool, section, "tracers", true); m_u8TracerColorID = READ_IF_EXISTS(pSettings, r_u8, section, "tracers_color_ID", u8(-1)); string256 temp; for (int i=egdNovice; i<egdCount; ++i) { strconcat (sizeof(temp),temp,"hit_probability_",get_token_name(difficulty_type_token,i)); m_hit_probability[i] = READ_IF_EXISTS(pSettings,r_float,section,temp,1.f); } m_zoom_params.m_bUseDynamicZoom = READ_IF_EXISTS(pSettings,r_bool,section,"scope_dynamic_zoom",FALSE); m_zoom_params.m_sUseZoomPostprocess = 0; m_zoom_params.m_sUseBinocularVision = 0; }
float CPhysicObject:: anim_time_get () { if( !check_blend( m_anim_blend, cName().c_str(), cNameSect().c_str(), cNameVisual().c_str() ) ) return 0.f; return m_anim_blend->timeCurrent; }
void CWeaponMagazined::InitAddons() { ////////////////////////////////////////////////////////////////////////// // Прицел m_fIronSightZoomFactor = READ_IF_EXISTS(pSettings, r_float, cNameSect(), "ironsight_zoom_factor", 50.0f); if (IsScopeAttached()) { if (m_eScopeStatus == ALife::eAddonAttachable) { m_sScopeName = pSettings->r_string(cNameSect(), "scope_name"); m_iScopeX = pSettings->r_s32(cNameSect(), "scope_x"); m_iScopeY = pSettings->r_s32(cNameSect(), "scope_y"); shared_str scope_tex_name; scope_tex_name = pSettings->r_string(*m_sScopeName, "scope_texture"); m_fScopeZoomFactor = pSettings->r_float(*m_sScopeName, "scope_zoom_factor"); if (m_UIScope) xr_delete(m_UIScope); m_UIScope = xr_new<CUIStaticItem>(); // m_UIScope->Init(*scope_tex_name, "hud\\default", 0, 0, alNone); m_UIScope->Init(*scope_tex_name, "hud\\scopes", 0, 0, alNone); // KD: special shader that account screen resolution } else if (m_eScopeStatus == ALife::eAddonPermanent) { m_fScopeZoomFactor = pSettings->r_float(cNameSect(), "scope_zoom_factor"); shared_str scope_tex_name; scope_tex_name = pSettings->r_string(cNameSect(), "scope_texture"); if (m_UIScope) xr_delete(m_UIScope); m_UIScope = xr_new<CUIStaticItem>(); // m_UIScope->Init(*scope_tex_name, "hud\\default", 0, 0, alNone); m_UIScope->Init(*scope_tex_name, "hud\\scopes", 0, 0, alNone); // KD: special shader that account screen resolution } } else { if (m_UIScope) xr_delete(m_UIScope); if (IsZoomEnabled()) m_fIronSightZoomFactor = pSettings->r_float(cNameSect(), "scope_zoom_factor"); } if (IsSilencerAttached() && SilencerAttachable()) { m_sFlameParticlesCurrent = m_sSilencerFlameParticles; m_sSmokeParticlesCurrent = m_sSilencerSmokeParticles; m_pSndShotCurrent = &sndSilencerShot; //сила выстрела LoadFireParams(*cNameSect(), ""); //подсветка от выстрела LoadLights(*cNameSect(), "silencer_"); ApplySilencerKoeffs(); } else { m_sFlameParticlesCurrent = m_sFlameParticles; m_sSmokeParticlesCurrent = m_sSmokeParticles; m_pSndShotCurrent = &sndShot; //сила выстрела LoadFireParams(*cNameSect(), ""); //подсветка от выстрела LoadLights(*cNameSect(), ""); } inherited::InitAddons(); }
bool CPhysicObject::is_ai_obstacle () const { return !!( READ_IF_EXISTS(pSettings, r_bool, cNameSect(), "is_ai_obstacle", true ) ); }
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; } }