void CGameObject::net_Load (IReader &ireader) { load (ireader); // Script Binder Load --------------------------------------- #ifdef DEBUG if (psAI_Flags.test(aiSerialize)) { Msg(">> **** Load script object [%s] *****", *cName()); Msg(">> Before load :: reader position = [%i]", ireader.tell()); } #endif CScriptBinder::load (ireader); #ifdef DEBUG if (psAI_Flags.test(aiSerialize)) { Msg(">> After load :: reader position = [%i]", ireader.tell()); } #endif // ---------------------------------------------------------- #ifdef DEBUG if(ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject)&&stricmp(PH_DBG_ObjectTrackName(),*cName())==0) { Msg("CGameObject::net_Load obj %s (loaded) %f,%f,%f",PH_DBG_ObjectTrackName(),Position().x,Position().y,Position().z); } #endif }
void CPhysicsShellHolder::correct_spawn_pos() { VERIFY (PPhysicsShell()); if( H_Parent() ) { CPhysicsShellHolder * P = smart_cast<CPhysicsShellHolder*>(H_Parent()); if( P && P->has_shell_collision_place(this) ) return; } Fvector size; Fvector c; get_box (PPhysicsShell(),XFORM(),size,c); R_ASSERT2( _valid( c ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) ); R_ASSERT2( _valid( size ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) ); R_ASSERT2( _valid( XFORM() ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) ); CPHActivationShape activation_shape; activation_shape.Create (c,size,this); activation_shape.set_rotation (XFORM()); PPhysicsShell()->DisableCollision (); activation_shape.Activate (size,1,1.f,M_PI/8.f); //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); // if (!valid_pos(activation_shape.Position(),phBoundaries)) { // CPHActivationShape activation_shape; // activation_shape.Create (c,size,this); // activation_shape.set_rotation (XFORM()); // activation_shape.Activate (size,1,1.f,M_PI/8.f); //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); // } PPhysicsShell()->EnableCollision (); Fvector ap = activation_shape.Position(); #ifdef DEBUG if (!valid_pos(ap,phBoundaries)) { Msg("not valid position %f,%f,%f",ap.x,ap.y,ap.z); Msg("size %f,%f,%f",size.x,size.y,size.z); Msg("Object: %s",Name()); Msg("Visual: %s",*(cNameVisual())); Msg("Object pos %f,%f,%f",Position().x,Position().y,Position().z); } #endif // DEBUG VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); Fmatrix trans; trans.identity (); trans.c.sub (ap,c); PPhysicsShell()->TransformPosition (trans); PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); activation_shape.Destroy (); }
void CWeaponAmmo::UpdateCL() { VERIFY2 (_valid(renderable.xform),*cName()); inherited::UpdateCL (); VERIFY2 (_valid(renderable.xform),*cName()); if(!IsGameTypeSingle()) make_Interpolation (); VERIFY2 (_valid(renderable.xform),*cName()); }
void CGameObject::net_Save (NET_Packet &net_packet) { u32 position; net_packet.w_chunk_open16 (position); save (net_packet); // Script Binder Save --------------------------------------- #ifdef DEBUG if (psAI_Flags.test(aiSerialize)) { Msg(">> **** Save script object [%s] *****", *cName()); Msg(">> Before save :: packet position = [%u]", net_packet.w_tell()); } #endif CScriptBinder::save (net_packet); #ifdef DEBUG if (psAI_Flags.test(aiSerialize)) { Msg(">> After save :: packet position = [%u]", net_packet.w_tell()); } #endif // ---------------------------------------------------------- net_packet.w_chunk_close16 (position); }
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 ; }
nsAString* os2PrintQ::PrinterTitle() { if (mPrinterTitle.IsEmpty()) { nsAutoCString cName(mpPQI3->pszComment); if (cName.IsEmpty()) cName.Assign(mpPQI3->pszName); cName.ReplaceChar('\r', ' '); cName.StripChars("\n"); if (cName.Length() > 64) cName.Truncate(64); nsAutoChar16Buffer uName; int32_t uNameLength = 123; MultiByteToWideChar(0, cName.get(), cName.Length(), uName, uNameLength); mPrinterTitle.Assign(nsDependentString(uName.Elements())); // store printer description in prefs for the print dialog nsresult rv; nsCOMPtr<nsIPrefBranch> pPrefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { char desc[DRIV_DEVICENAME_SIZE + DRIV_NAME_SIZE + 8]; char pref[128]; sprintf(desc, "%s (%s)", DriverData()->szDeviceName, mDriverName); sprintf(pref, "print.printer_%s.printer_description", cName.get()); pPrefs->SetCharPref(pref, desc); } } return &mPrinterTitle; }
void CWeaponMagazined::switch2_Fire() { CInventoryOwner* io = smart_cast<CInventoryOwner*>(H_Parent()); CInventoryItem* ii = smart_cast<CInventoryItem*>(this); #ifdef DEBUG VERIFY2(io, make_string("no inventory owner, item %s", *cName())); if (ii != io->inventory().ActiveItem()) Msg("! not an active item, item %s, owner %s, active item %s", *cName(), *H_Parent()->cName(), io->inventory().ActiveItem() ? *io->inventory().ActiveItem()->object().cName() : "no_active_item"); if (!(io && (ii == io->inventory().ActiveItem()))) { CAI_Stalker *stalker = smart_cast<CAI_Stalker*>(H_Parent()); if (stalker) { stalker->planner().show(); stalker->planner().show_current_world_state(); stalker->planner().show_target_world_state(); } } #else if (!io) return; #endif // DEBUG // // VERIFY2( // io && (ii == io->inventory().ActiveItem()), // make_string( // "item[%s], parent[%s]", // *cName(), // H_Parent() ? *H_Parent()->cName() : "no_parent" // ) // ); m_bStopedAfterQueueFired = false; m_bFireSingleShot = true; m_iShotNum = 0; if ((OnClient() || Level().IsDemoPlay()) && !IsWorking()) FireStart(); /* if(SingleShotMode()) { m_bFireSingleShot = true; bWorking = false; }*/ }
void CAI_Stalker::on_restrictions_change () { inherited::on_restrictions_change (); m_best_cover_actual = false; #ifdef _DEBUG Msg ("* [%6d][%s] on_restrictions_change",Device.dwTimeGlobal,*cName()); #endif }
// Get the field ID by name // GetFieldIndexByName() works, but is case sensitive int CODBCRecordset::GetFieldID( LPCTSTR szName ) { void* idx = (void*)-1; CString cName( szName ); cName.MakeUpper(); if( ! m_mapNameIdx.Lookup( cName, idx ) ) return -1; return (int)idx; }
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; }
void CPhysicObject::play_bones_sound() { if(!bones_snd_player) { Msg( "! no sound loaded for obj: %s, model :%s - can not play", cName().c_str(), cNameVisual().c_str() ); return; } if( is_active( bones_snd_player ) ) return; //processing_activate(); bones_snd_player->play( *this ); }
void CAI_Stalker::on_best_cover_changed (const CCoverPoint *new_cover, const CCoverPoint *old_cover) { #if 0 if (new_cover) { if (!new_cover->m_is_smart_cover) Msg ("[%6d][%s], now it is cover", Device.dwTimeGlobal, cName().c_str()); else Msg ( "[%6d][%s], now it is smart cover %s", Device.dwTimeGlobal, cName().c_str(), static_cast<smart_cover::cover const *>(new_cover)->object().cName().c_str() ); } #endif cover_delegates::const_iterator I = m_cover_delegates.begin(); cover_delegates::const_iterator E = m_cover_delegates.end(); for ( ; I != E; ++I) (*I) (new_cover,old_cover); }
int SslSocket::listen(const SocketAddress& sa, int backlog) const { //get certificate and key (is this the correct way?) std::string cName( (certname == "") ? "localhost.localdomain" : certname); CERTCertificate *cert = PK11_FindCertFromNickname(const_cast<char*>(cName.c_str()), 0); if (!cert) throw Exception(QPID_MSG("Failed to load certificate '" << cName << "'")); SECKEYPrivateKey *key = PK11_FindKeyByAnyCert(cert, 0); if (!key) throw Exception(QPID_MSG("Failed to retrieve private key from certificate")); NSS_CHECK(SSL_ConfigSecureServer(prototype, cert, key, NSS_FindCertKEAType(cert))); SECKEY_DestroyPrivateKey(key); CERT_DestroyCertificate(cert); return BSDSocket::listen(sa, backlog); }
void CEntity::OnEvent (NET_Packet& P, u16 type) { inherited::OnEvent (P,type); switch (type) { case GE_DIE: { u16 id; u32 cl; P.r_u16 (id); P.r_u32 (cl); CObject *who = Level().Objects.net_Find (id); if (who && !IsGameTypeSingle()) { if (this!=who) /*if(bDebug) */ Msg( "%s killed by %s ...", cName().c_str(), who->cName().c_str() ); else /*if(bDebug) */ Msg( "%s dies himself ...", cName().c_str() ); } Die (who); } break; } }
/** * Get a top collection from a file * * @param fileName Name of file * @param results Wheter it's the results collection or not * * @return Collection or null */ static TCollection* GetTop(const TString& fileName, Bool_t results=false) { TFile* file = TFile::Open(fileName, "READ"); if (!file) { Error("GetTop", "Failed to open %s", fileName.Data()); return 0; } TCollection* ret = 0; TString cName(Form("ForwardMult%s", results ? "Results" : "Sums")); file->GetObject(cName, ret); if (!ret) Error("GetTop", "Failed to get collection %s from %s", cName.Data(), fileName.Data()); file->Close(); return ret; }
void CGameObject::net_Destroy () { #ifdef DEBUG if (psAI_Flags.test(aiDestroy)) Msg ("Destroying client object [%d][%s][%x]",ID(),*cName(),this); #endif VERIFY (m_spawned); if( m_anim_mov_ctrl ) destroy_anim_mov_ctrl (); xr_delete (m_ini_file); m_script_clsid = -1; if (Visual() && smart_cast<IKinematics*>(Visual())) smart_cast<IKinematics*>(Visual())->Callback (0,0); inherited::net_Destroy (); setReady (FALSE); if (Level().IsDemoPlayStarted() && ID() == u16(-1)) { Msg("Destroying demo_spectator object"); } else { g_pGameLevel->Objects.net_Unregister (this); } if (this == Level().CurrentEntity()) { if (!Level().IsDemoPlayStarted()) { Level().SetControlEntity (0); } Level().SetEntity (0); // do not switch !!! } Level().RemoveObject_From_4CrPr(this); //. Parent = 0; CScriptBinder::net_Destroy (); xr_delete (m_lua_game_object); m_spawned = false; }
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); }
// Updates void CObject::UpdateCL () { // consistency check #ifdef DEBUG VERIFY2 (_valid(renderable.xform),*cName()); if (Device.dwFrame==dbg_update_cl) Debug.fatal (DEBUG_INFO,"'UpdateCL' called twice per frame for %s",*cName()); dbg_update_cl = Device.dwFrame; if (Parent && spatial.node_ptr) Debug.fatal (DEBUG_INFO,"Object %s has parent but is still registered inside spatial DB",*cName()); if ((0==collidable.model)&&(spatial.type&STYPE_COLLIDEABLE)) Debug.fatal (DEBUG_INFO,"Object %s registered as 'collidable' but has no collidable model",*cName()); #endif spatial_update (base_spu_epsP*5,base_spu_epsR*5); // crow if (Parent == g_pGameLevel->CurrentViewEntity()) MakeMeCrow (); else if (AlwaysTheCrow()) MakeMeCrow (); else if (Device.vCameraPosition.distance_to_sqr(Position()) < CROW_RADIUS*CROW_RADIUS) MakeMeCrow (); }
shared_ptr<NavigationElement> NavigationTable::BuildNavigationPoint(xmlNodePtr liNode) { auto elementPtr = std::dynamic_pointer_cast<NavigationElement>(shared_from_this()); xmlNodePtr liChild = liNode->children; if(liChild == nullptr) { return nullptr; } auto point = std::make_shared<NavigationPoint>(elementPtr); for ( ; liChild != nullptr; liChild = liChild->next ) { if ( liChild->type != XML_ELEMENT_NODE ) continue; std::string cName(reinterpret_cast<const char*>(liChild->name)); if ( cName == "a" ) { point->SetTitle(reinterpret_cast<const char*>(xmlNodeGetContent(liChild))); point->SetContent(_getProp(liChild, "href")); } else if( cName == "span" ) { point->SetTitle(xmlNodeGetContent(liChild)); } else if( cName == "ol" ) { LoadChildElements(point, liChild); break; } } return point; }
NavigationElement* NavigationTable::BuildNavigationPoint(xmlNodePtr liNode) { xmlNodePtr liChild = liNode->children; if(liChild == nullptr) { return nullptr; } NavigationPoint* point = new NavigationPoint(); for ( ; liChild != nullptr; liChild = liChild->next ) { if ( liChild->type != XML_ELEMENT_NODE ) continue; std::string cName(reinterpret_cast<const char*>(liChild->name)); if ( cName == "a" ) { point->SetTitle(reinterpret_cast<const char*>(xmlNodeGetContent(liChild))); point->SetSourceHref(_getProp(liChild, "href")); } else if( cName == "span" ) { point->SetTitle(xmlNodeGetContent(liChild)); } else if( cName == "ol" ) { LoadChildElements(point, liChild); break; } } return point; }
BOOL CHangingLamp::net_Spawn(CSE_Abstract* DC) { CSE_Abstract *e = (CSE_Abstract*)(DC); CSE_ALifeObjectHangingLamp *lamp = smart_cast<CSE_ALifeObjectHangingLamp*>(e); R_ASSERT (lamp); inherited::net_Spawn (DC); Fcolor clr; // set bone id // CInifile* pUserData = K->LL_UserData(); // R_ASSERT3 (pUserData,"Empty HangingLamp user data!",lamp->get_visual()); xr_delete(collidable.model); if (Visual()){ CKinematics* K = smart_cast<CKinematics*>(Visual()); R_ASSERT (Visual()&&smart_cast<CKinematics*>(Visual())); light_bone = K->LL_BoneID (*lamp->light_main_bone); VERIFY(light_bone!=BI_NONE); ambient_bone = K->LL_BoneID (*lamp->light_ambient_bone);VERIFY(ambient_bone!=BI_NONE); collidable.model = xr_new<CCF_Skeleton> (this); // alpet: загрузка иммунитетов из спавн-конфига CInifile* ini=K->LL_UserData(); if(ini && ini->section_exist("immunities")) CHitImmunity::LoadImmunities("immunities",ini); } fBrightness = lamp->brightness; clr.set (lamp->color); clr.a = 1.f; clr.mul_rgb (fBrightness); light_render = ::Render->light_create(); light_render->set_shadow(!!lamp->flags.is(CSE_ALifeObjectHangingLamp::flCastShadow)); light_render->set_type (lamp->flags.is(CSE_ALifeObjectHangingLamp::flTypeSpot)?IRender_Light::SPOT:IRender_Light::POINT); light_render->set_range (lamp->range); light_render->set_color (clr); light_render->set_cone (lamp->spot_cone_angle); light_render->set_texture(*lamp->light_texture); light_render->set_virtual_size(lamp->m_virtual_size); if (lamp->glow_texture.size()) { glow_render = ::Render->glow_create(); glow_render->set_texture(*lamp->glow_texture); glow_render->set_color (clr); glow_render->set_radius (lamp->glow_radius); } if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPointAmbient)){ ambient_power = lamp->m_ambient_power; light_ambient = ::Render->light_create(); light_ambient->set_type (IRender_Light::POINT); light_ambient->set_shadow(false); clr.mul_rgb (ambient_power); light_ambient->set_range(lamp->m_ambient_radius); light_ambient->set_color(clr); light_ambient->set_texture(*lamp->m_ambient_texture); light_ambient->set_virtual_size(lamp->m_virtual_size); } fHealth = lamp->m_health; lanim = LALib.FindItem(*lamp->color_animator); CPHSkeleton::Spawn(e); if (smart_cast<CKinematicsAnimated*>(Visual())) smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle("idle"); if (smart_cast<CKinematics*>(Visual())){ smart_cast<CKinematics*> (Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*> (Visual())->CalculateBones(); //.intepolate_pos } if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPhysic)&&!Visual()) Msg("! WARNING: lamp, obj name [%s],flag physics set, but has no visual",*cName()); //. if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPhysic)&&Visual()&&!guid_physic_bone) fHealth=0.f; if (Alive()) TurnOn (); else{ processing_activate (); // temporal enable TurnOff (); // -> and here is disable :) } setVisible ((BOOL)!!Visual()); setEnabled ((BOOL)!!collidable.model); return (TRUE); }
void CCustomZone::Load(LPCSTR section) { inherited::Load(section); m_iDisableHitTime = pSettings->r_s32(section, "disable_time"); m_iDisableHitTimeSmall = pSettings->r_s32(section, "disable_time_small"); m_iDisableIdleTime = pSettings->r_s32(section, "disable_idle_time"); m_fHitImpulseScale = pSettings->r_float(section, "hit_impulse_scale"); m_fEffectiveRadius = pSettings->r_float(section, "effective_radius"); m_eHitTypeBlowout = ALife::g_tfString2HitType(pSettings->r_string(section, "hit_type")); m_zone_flags.set(eIgnoreNonAlive, pSettings->r_bool(section, "ignore_nonalive")); m_zone_flags.set(eIgnoreSmall, pSettings->r_bool(section, "ignore_small")); m_zone_flags.set(eIgnoreArtefact, pSettings->r_bool(section, "ignore_artefacts")); m_zone_flags.set(eVisibleByDetector,pSettings->r_bool(section, "visible_by_detector")); //загрузить времена для зоны m_StateTime[eZoneStateIdle] = -1; m_StateTime[eZoneStateAwaking] = pSettings->r_s32(section, "awaking_time"); m_StateTime[eZoneStateBlowout] = pSettings->r_s32(section, "blowout_time"); m_StateTime[eZoneStateAccumulate] = pSettings->r_s32(section, "accamulate_time"); ////////////////////////////////////////////////////////////////////////// ISpatial* self = smart_cast<ISpatial*> (this); if (self) self->spatial.type |= (STYPE_COLLIDEABLE|STYPE_SHAPE); ////////////////////////////////////////////////////////////////////////// LPCSTR sound_str = NULL; if(pSettings->line_exist(section,"idle_sound")) { sound_str = pSettings->r_string(section,"idle_sound"); m_idle_sound.create(sound_str, st_Effect,sg_SourceType); } if(pSettings->line_exist(section,"accum_sound")) { sound_str = pSettings->r_string(section,"accum_sound"); m_accum_sound.create(sound_str, st_Effect,sg_SourceType); } if(pSettings->line_exist(section,"awake_sound")) { sound_str = pSettings->r_string(section,"awake_sound"); m_awaking_sound.create(sound_str, st_Effect,sg_SourceType); } if(pSettings->line_exist(section,"blowout_sound")) { sound_str = pSettings->r_string(section,"blowout_sound"); m_blowout_sound.create(sound_str, st_Effect,sg_SourceType); } if(pSettings->line_exist(section,"hit_sound")) { sound_str = pSettings->r_string(section,"hit_sound"); m_hit_sound.create(sound_str, st_Effect,sg_SourceType); } if(pSettings->line_exist(section,"entrance_sound")) { sound_str = pSettings->r_string(section,"entrance_sound"); m_entrance_sound.create(sound_str, st_Effect,sg_SourceType); } if(pSettings->line_exist(section,"idle_particles")) m_sIdleParticles = pSettings->r_string(section,"idle_particles"); if(pSettings->line_exist(section,"blowout_particles")) m_sBlowoutParticles = pSettings->r_string(section,"blowout_particles"); if(pSettings->line_exist(section,"accum_particles")) m_sAccumParticles = pSettings->r_string(section,"accum_particles"); if(pSettings->line_exist(section,"awake_particles")) m_sAwakingParticles = pSettings->r_string(section,"awake_particles"); if(pSettings->line_exist(section,"entrance_small_particles")) m_sEntranceParticlesSmall = pSettings->r_string(section,"entrance_small_particles"); if(pSettings->line_exist(section,"entrance_big_particles")) m_sEntranceParticlesBig = pSettings->r_string(section,"entrance_big_particles"); if(pSettings->line_exist(section,"hit_small_particles")) m_sHitParticlesSmall = pSettings->r_string(section,"hit_small_particles"); if(pSettings->line_exist(section,"hit_big_particles")) m_sHitParticlesBig = pSettings->r_string(section,"hit_big_particles"); if(pSettings->line_exist(section,"idle_small_particles")) m_sIdleObjectParticlesBig = pSettings->r_string(section,"idle_big_particles"); if(pSettings->line_exist(section,"idle_big_particles")) m_sIdleObjectParticlesSmall = pSettings->r_string(section,"idle_small_particles"); if(pSettings->line_exist(section,"idle_particles_dont_stop")) m_bIdleObjectParticlesDontStop=pSettings->r_bool(section,"idle_particles_dont_stop"); if(pSettings->line_exist(section,"postprocess")) { m_effector = xr_new<CZoneEffector>(); m_effector->Load (pSettings->r_string(section,"postprocess")); }; if(pSettings->line_exist(section,"blowout_particles_time")) { m_dwBlowoutParticlesTime = pSettings->r_u32(section,"blowout_particles_time"); if (s32(m_dwBlowoutParticlesTime)>m_StateTime[eZoneStateBlowout]) { m_dwBlowoutParticlesTime=m_StateTime[eZoneStateBlowout]; Msg("! ERROR: invalid 'blowout_particles_time' in '%s'",section); } } else m_dwBlowoutParticlesTime = 0; if(pSettings->line_exist(section,"blowout_light_time")) { m_dwBlowoutLightTime = pSettings->r_u32(section,"blowout_light_time"); if (s32(m_dwBlowoutLightTime)>m_StateTime[eZoneStateBlowout]) { m_dwBlowoutLightTime=m_StateTime[eZoneStateBlowout]; Msg("! ERROR: invalid 'blowout_light_time' in '%s'",section); } } else m_dwBlowoutLightTime = 0; if(pSettings->line_exist(section,"blowout_sound_time")) { m_dwBlowoutSoundTime = pSettings->r_u32(section,"blowout_sound_time"); if (s32(m_dwBlowoutSoundTime)>m_StateTime[eZoneStateBlowout]) { m_dwBlowoutSoundTime=m_StateTime[eZoneStateBlowout]; Msg("! ERROR: invalid 'blowout_sound_time' in '%s'",section); } } else m_dwBlowoutSoundTime = 0; if(pSettings->line_exist(section,"blowout_explosion_time")) { m_dwBlowoutExplosionTime = pSettings->r_u32(section,"blowout_explosion_time"); if (s32(m_dwBlowoutExplosionTime)>m_StateTime[eZoneStateBlowout]) { m_dwBlowoutExplosionTime=m_StateTime[eZoneStateBlowout]; Msg("! ERROR: invalid 'blowout_explosion_time' in '%s'",section); } } else m_dwBlowoutExplosionTime = 0; m_zone_flags.set(eBlowoutWind, pSettings->r_bool(section,"blowout_wind")); if( m_zone_flags.test(eBlowoutWind) ){ m_dwBlowoutWindTimeStart = pSettings->r_u32(section,"blowout_wind_time_start"); m_dwBlowoutWindTimePeak = pSettings->r_u32(section,"blowout_wind_time_peak"); m_dwBlowoutWindTimeEnd = pSettings->r_u32(section,"blowout_wind_time_end"); R_ASSERT(m_dwBlowoutWindTimeStart < m_dwBlowoutWindTimePeak); R_ASSERT(m_dwBlowoutWindTimePeak < m_dwBlowoutWindTimeEnd); if((s32)m_dwBlowoutWindTimeEnd < m_StateTime[eZoneStateBlowout]){ m_dwBlowoutWindTimeEnd =u32( m_StateTime[eZoneStateBlowout]-1); Msg("! ERROR: invalid 'blowout_wind_time_end' in '%s'",section); } m_fBlowoutWindPowerMax = pSettings->r_float(section,"blowout_wind_power"); } //загрузить параметры световой вспышки от взрыва m_zone_flags.set(eBlowoutLight, pSettings->r_bool (section, "blowout_light")); if(m_zone_flags.test(eBlowoutLight) ){ sscanf(pSettings->r_string(section,"light_color"), "%f,%f,%f", &m_LightColor.r, &m_LightColor.g, &m_LightColor.b); m_fLightRange = pSettings->r_float(section,"light_range"); m_fLightTime = pSettings->r_float(section,"light_time"); m_fLightTimeLeft = 0; m_fLightHeight = pSettings->r_float(section,"light_height"); } //загрузить параметры idle подсветки m_zone_flags.set(eIdleLight, pSettings->r_bool (section, "idle_light")); if( m_zone_flags.test(eIdleLight) ) { m_fIdleLightRange = pSettings->r_float(section,"idle_light_range"); m_fIdleLightRangeDelta = pSettings->r_float(section,"idle_light_range_delta"); LPCSTR light_anim = pSettings->r_string(section,"idle_light_anim"); m_pIdleLAnim = LALib.FindItem(light_anim); m_fIdleLightHeight = pSettings->r_float(section,"idle_light_height"); } //загрузить параметры для разбрасывания артефактов m_zone_flags.set(eSpawnBlowoutArtefacts, pSettings->r_bool(section,"spawn_blowout_artefacts")); if( m_zone_flags.test(eSpawnBlowoutArtefacts) ) { m_fArtefactSpawnProbability = pSettings->r_float (section,"artefact_spawn_probability"); if(pSettings->line_exist(section,"artefact_spawn_particles")) m_sArtefactSpawnParticles = pSettings->r_string(section,"artefact_spawn_particles"); else m_sArtefactSpawnParticles = NULL; if(pSettings->line_exist(section,"artefact_born_sound")) { sound_str = pSettings->r_string(section,"artefact_born_sound"); m_ArtefactBornSound.create(sound_str, st_Effect,sg_SourceType); } m_fThrowOutPower = pSettings->r_float (section, "throw_out_power"); m_fArtefactSpawnHeight = pSettings->r_float (section, "artefact_spawn_height"); LPCSTR l_caParameters = pSettings->r_string(section, "artefacts"); u16 m_wItemCount = (u16)_GetItemCount(l_caParameters); R_ASSERT2 (!(m_wItemCount & 1),"Invalid number of parameters in string 'artefacts' in the 'system.ltx'!"); m_wItemCount >>= 1; m_ArtefactSpawn.clear(); string512 l_caBuffer; float total_probability = 0.f; m_ArtefactSpawn.resize(m_wItemCount); for (u16 i=0; i<m_wItemCount; ++i) { ARTEFACT_SPAWN& artefact_spawn = m_ArtefactSpawn[i]; artefact_spawn.section = _GetItem(l_caParameters,i << 1,l_caBuffer); artefact_spawn.probability = (float)atof(_GetItem(l_caParameters,(i << 1) | 1,l_caBuffer)); total_probability += artefact_spawn.probability; } R_ASSERT3(!fis_zero(total_probability), "The probability of artefact spawn is zero!",*cName()); //нормализировать вероятности for(i=0; i<m_ArtefactSpawn.size(); ++i) { m_ArtefactSpawn[i].probability = m_ArtefactSpawn[i].probability/total_probability; } }
const Fbox& CObject::BoundingBox () const { VERIFY2(renderable.visual,*cName()); return renderable.visual->vis.box; }
float CObject::Radius () const { VERIFY2(renderable.visual,*cName()); return renderable.visual->vis.sphere.R; }
void CObject::Center (Fvector& C) const { VERIFY2(renderable.visual,*cName()); renderable.xform.transform_tiny(C,renderable.visual->vis.sphere.P); }
void CObject::processing_deactivate () { VERIFY3 (0 != Props.bActiveCounter, "Invalid sequence of processing enable/disable calls: underflow",*cName()); Props.bActiveCounter --; if (0==Props.bActiveCounter) g_pGameLevel->Objects.o_sleep (this); }
// flagging void CObject::processing_activate () { VERIFY3 (255!= Props.bActiveCounter, "Invalid sequence of processing enable/disable calls: overflow",*cName()); Props.bActiveCounter ++; if (0==(Props.bActiveCounter-1)) g_pGameLevel->Objects.o_activate (this); }
void CActor::UpdateCL () { if(m_feel_touch_characters>0) { for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++) { CPhysicsShellHolder *sh = smart_cast<CPhysicsShellHolder*>(*it); if(sh&&sh->character_physics_support()) { sh->character_physics_support()->movement()->UpdateObjectBox(character_physics_support()->movement()->PHCharacter()); } } } if(m_holder) m_holder->UpdateEx( currentFOV() ); m_snd_noise -= 0.3f*Device.fTimeDelta; VERIFY2 (_valid(renderable.xform),*cName()); inherited::UpdateCL(); VERIFY2 (_valid(renderable.xform),*cName()); m_pPhysics_support->in_UpdateCL (); VERIFY2 (_valid(renderable.xform),*cName()); if (g_Alive()) PickupModeUpdate (); PickupModeUpdate_COD(); m_bZoomAimingMode = false; CWeapon* pWeapon = smart_cast<CWeapon*>(inventory().ActiveItem()); Device.Statistic->TEST1.Begin (); cam_Update(float(Device.dwTimeDelta)/1000.0f, currentFOV()); Device.Statistic->TEST1.End (); if(Level().CurrentEntity() && this->ID()==Level().CurrentEntity()->ID() ) { psHUD_Flags.set( HUD_CROSSHAIR_RT2, true ); psHUD_Flags.set( HUD_DRAW_RT, true ); } if(pWeapon ) { if(pWeapon->IsZoomed()) { float full_fire_disp = pWeapon->GetFireDispersion(true); CEffectorZoomInertion* S = smart_cast<CEffectorZoomInertion*> (Cameras().GetCamEffector(eCEZoom)); if(S) S->SetParams(full_fire_disp); m_bZoomAimingMode = true; } if(Level().CurrentEntity() && this->ID()==Level().CurrentEntity()->ID() ) { float fire_disp_full = pWeapon->GetFireDispersion(true); HUD().SetCrosshairDisp(fire_disp_full, 0.02f); HUD().ShowCrosshair(pWeapon->use_crosshair()); psHUD_Flags.set( HUD_CROSSHAIR_RT2, pWeapon->show_crosshair() ); psHUD_Flags.set( HUD_DRAW_RT, pWeapon->show_indicators() ); } } else { if(Level().CurrentEntity() && this->ID()==Level().CurrentEntity()->ID() ) { HUD().SetCrosshairDisp(0.f); HUD().ShowCrosshair(false); } } UpdateDefferedMessages(); if (g_Alive()) CStepManager::update(); spatial.type |=STYPE_REACTTOSOUND; if(m_sndShockEffector) { if (this == Level().CurrentViewEntity()) { m_sndShockEffector->Update(); if(!m_sndShockEffector->InWork()) xr_delete(m_sndShockEffector); } else xr_delete(m_sndShockEffector); } }
void CActor::Load (LPCSTR section ) { // Msg ("Loading actor: %s",section); inherited::Load (section); material().Load (section); CInventoryOwner::Load (section); memory().Load (section); m_location_manager->Load (section); if (GameID() == GAME_SINGLE) OnDifficultyChanged (); ////////////////////////////////////////////////////////////////////////// ISpatial* self = smart_cast<ISpatial*> (this); if (self) { self->spatial.type |= STYPE_VISIBLEFORAI; self->spatial.type &= ~STYPE_REACTTOSOUND; } ////////////////////////////////////////////////////////////////////////// // m_PhysicMovementControl: General //m_PhysicMovementControl->SetParent (this); Fbox bb;Fvector vBOX_center,vBOX_size; // m_PhysicMovementControl: BOX vBOX_center= pSettings->r_fvector3 (section,"ph_box2_center" ); vBOX_size = pSettings->r_fvector3 (section,"ph_box2_size" ); bb.set (vBOX_center,vBOX_center); bb.grow(vBOX_size); character_physics_support()->movement()->SetBox (2,bb); // m_PhysicMovementControl: BOX vBOX_center= pSettings->r_fvector3 (section,"ph_box1_center" ); vBOX_size = pSettings->r_fvector3 (section,"ph_box1_size" ); bb.set (vBOX_center,vBOX_center); bb.grow(vBOX_size); character_physics_support()->movement()->SetBox (1,bb); // m_PhysicMovementControl: BOX vBOX_center= pSettings->r_fvector3 (section,"ph_box0_center" ); vBOX_size = pSettings->r_fvector3 (section,"ph_box0_size" ); bb.set (vBOX_center,vBOX_center); bb.grow(vBOX_size); character_physics_support()->movement()->SetBox (0,bb); //// m_PhysicMovementControl: Foots //Fvector vFOOT_center= pSettings->r_fvector3 (section,"ph_foot_center" ); //Fvector vFOOT_size = pSettings->r_fvector3 (section,"ph_foot_size" ); //bb.set (vFOOT_center,vFOOT_center); bb.grow(vFOOT_size); ////m_PhysicMovementControl->SetFoots (vFOOT_center,vFOOT_size); // m_PhysicMovementControl: Crash speed and mass float cs_min = pSettings->r_float (section,"ph_crash_speed_min" ); float cs_max = pSettings->r_float (section,"ph_crash_speed_max" ); float mass = pSettings->r_float (section,"ph_mass" ); character_physics_support()->movement()->SetCrashSpeeds (cs_min,cs_max); character_physics_support()->movement()->SetMass (mass); if(pSettings->line_exist(section,"stalker_restrictor_radius")) character_physics_support()->movement()->SetActorRestrictorRadius(CPHCharacter::rtStalker,pSettings->r_float(section,"stalker_restrictor_radius")); if(pSettings->line_exist(section,"stalker_small_restrictor_radius")) character_physics_support()->movement()->SetActorRestrictorRadius(CPHCharacter::rtStalkerSmall,pSettings->r_float(section,"stalker_small_restrictor_radius")); if(pSettings->line_exist(section,"medium_monster_restrictor_radius")) character_physics_support()->movement()->SetActorRestrictorRadius(CPHCharacter::rtMonsterMedium,pSettings->r_float(section,"medium_monster_restrictor_radius")); character_physics_support()->movement()->Load(section); m_fWalkAccel = pSettings->r_float(section,"walk_accel"); m_fJumpSpeed = pSettings->r_float(section,"jump_speed"); m_fRunFactor = pSettings->r_float(section,"run_coef"); m_fRunBackFactor = pSettings->r_float(section,"run_back_coef"); m_fWalkBackFactor = pSettings->r_float(section,"walk_back_coef"); m_fCrouchFactor = pSettings->r_float(section,"crouch_coef"); m_fClimbFactor = pSettings->r_float(section,"climb_coef"); m_fSprintFactor = pSettings->r_float(section,"sprint_koef"); m_fWalk_StrafeFactor = READ_IF_EXISTS(pSettings, r_float, section, "walk_strafe_coef", 1.0f); m_fRun_StrafeFactor = READ_IF_EXISTS(pSettings, r_float, section, "run_strafe_coef", 1.0f); m_fCamHeightFactor = pSettings->r_float(section,"camera_height_factor"); character_physics_support()->movement() ->SetJumpUpVelocity(m_fJumpSpeed); float AirControlParam = pSettings->r_float (section,"air_control_param" ); character_physics_support()->movement() ->SetAirControlParam(AirControlParam); m_fPickupInfoRadius = pSettings->r_float(section,"pickup_info_radius"); m_fSleepTimeFactor = pSettings->r_float(section,"sleep_time_factor"); character_physics_support()->in_Load (section); //загрузить параметры эффектора // LoadShootingEffector ("shooting_effector"); LoadSleepEffector ("sleep_effector"); //загрузить параметры смещения firepoint m_vMissileOffset = pSettings->r_fvector3(section,"missile_throw_offset"); //Weapons = xr_new<CWeaponList> (this); if(!g_pGamePersistent->bDedicatedServer) { LPCSTR hit_snd_sect = pSettings->r_string(section,"hit_sounds"); for(int hit_type=0; hit_type<(int)ALife::eHitTypeMax; ++hit_type) { LPCSTR hit_name = ALife::g_cafHitType2String((ALife::EHitType)hit_type); LPCSTR hit_snds = pSettings->r_string(hit_snd_sect, hit_name); int cnt = _GetItemCount(hit_snds); string128 tmp; VERIFY (cnt!=0); for(int i=0; i<cnt;++i) { sndHit[hit_type].push_back (ref_sound()); sndHit[hit_type].back().create (_GetItem(hit_snds,i,tmp),st_Effect,sg_SourceType); } char buf[256]; ::Sound->create (sndDie[0], strconcat(buf,*cName(),"\\die0"), st_Effect,SOUND_TYPE_MONSTER_DYING); ::Sound->create (sndDie[1], strconcat(buf,*cName(),"\\die1"), st_Effect,SOUND_TYPE_MONSTER_DYING); ::Sound->create (sndDie[2], strconcat(buf,*cName(),"\\die2"), st_Effect,SOUND_TYPE_MONSTER_DYING); ::Sound->create (sndDie[3], strconcat(buf,*cName(),"\\die3"), st_Effect,SOUND_TYPE_MONSTER_DYING); m_HeavyBreathSnd.create (pSettings->r_string(section,"heavy_breath_snd"), st_Effect,SOUND_TYPE_MONSTER_INJURING); m_BloodSnd.create (pSettings->r_string(section,"heavy_blood_snd"), st_Effect,SOUND_TYPE_MONSTER_INJURING); } } if( psActorFlags.test(AF_PSP) ) cam_Set (eacLookAt); else cam_Set (eacFirstEye); // sheduler shedule.t_min = shedule.t_max = 1; // настройки дисперсии стрельбы m_fDispBase = pSettings->r_float (section,"disp_base" ); m_fDispBase = deg2rad(m_fDispBase); m_fDispAim = pSettings->r_float (section,"disp_aim" ); m_fDispAim = deg2rad(m_fDispAim); m_fDispVelFactor = pSettings->r_float (section,"disp_vel_factor" ); m_fDispAccelFactor = pSettings->r_float (section,"disp_accel_factor" ); m_fDispCrouchFactor = pSettings->r_float (section,"disp_crouch_factor"); m_fDispCrouchNoAccelFactor = pSettings->r_float (section,"disp_crouch_no_acc_factor"); LPCSTR default_outfit = READ_IF_EXISTS(pSettings,r_string,section,"default_outfit",0); SetDefaultVisualOutfit (default_outfit); invincibility_fire_shield_1st = READ_IF_EXISTS(pSettings,r_string,section,"Invincibility_Shield_1st",0); invincibility_fire_shield_3rd = READ_IF_EXISTS(pSettings,r_string,section,"Invincibility_Shield_3rd",0); //----------------------------------------- m_AutoPickUp_AABB = READ_IF_EXISTS(pSettings,r_fvector3,section,"AutoPickUp_AABB",Fvector().set(0.02f, 0.02f, 0.02f)); m_AutoPickUp_AABB_Offset = READ_IF_EXISTS(pSettings,r_fvector3,section,"AutoPickUp_AABB_offs",Fvector().set(0, 0, 0)); CStringTable string_table; m_sCharacterUseAction = "character_use"; m_sDeadCharacterUseAction = "dead_character_use"; m_sDeadCharacterUseOrDragAction = "dead_character_use_or_drag"; m_sCarCharacterUseAction = "car_character_use"; m_sInventoryItemUseAction = "inventory_item_use"; m_sInventoryBoxUseAction = "inventory_box_use"; //--------------------------------------------------------------------- m_sHeadShotParticle = READ_IF_EXISTS(pSettings,r_string,section,"HeadShotParticle",0); }
CBaseMonster::SDebugInfo CBaseMonster::show_debug_info() { if (!g_Alive()) return SDebugInfo(); if (m_show_debug_info == 0 ) { DBG().text(this).clear(); return SDebugInfo(); } float y = 200; float x = (m_show_debug_info == 1) ? 40.f : float(::Render->getTarget()->get_width() / 2) + 40.f; const float delta_y = 12; string256 text; u32 color = D3DCOLOR_XRGB(0,255,0); u32 delimiter_color = D3DCOLOR_XRGB(0,0,255); DBG().text(this).clear (); DBG().text(this).add_item("---------------------------------------", x, y+=delta_y, delimiter_color); sprintf_s(text, "-- Monster : [%s] Current Time = [%u]", *cName(), Device.dwTimeGlobal); DBG().text(this).add_item(text, x, y+=delta_y, color); DBG().text(this).add_item("----------- PROPERTIES ------------", x, y+=delta_y, delimiter_color); sprintf_s(text, "Health = [%f]", conditions().GetHealth()); DBG().text(this).add_item(text, x, y+=delta_y, color); sprintf_s(text, "Morale = [%f]", Morale.get_morale()); DBG().text(this).add_item(text, x, y+=delta_y, color); DBG().text(this).add_item("----------- MEMORY ----------------", x, y+=delta_y, delimiter_color); if (EnemyMan.get_enemy()) { sprintf_s(text, "Current Enemy = [%s]", *EnemyMan.get_enemy()->cName()); } else sprintf_s(text, "Current Enemy = [NONE]"); DBG().text(this).add_item(text, x, y+=delta_y, color); if (EnemyMan.get_enemy()) { sprintf_s(text, "SeeEnemy[%u] EnemySeeMe[%u] TimeLastSeen[%u]", EnemyMan.see_enemy_now(),EnemyMan.enemy_see_me_now(),EnemyMan.get_enemy_time_last_seen()); DBG().text(this).add_item(text, x, y+=delta_y, color); } if (CorpseMan.get_corpse()) { sprintf_s(text, "Current Corpse = [%s] Satiety = [%.2f]", *CorpseMan.get_corpse()->cName(), GetSatiety()); } else sprintf_s(text, "Current Corpse = [NONE] Satiety = [%.2f]", GetSatiety()); DBG().text(this).add_item(text, x, y+=delta_y, color); // Sound if (SoundMemory.IsRememberSound()) { SoundElem sound_elem; bool dangerous_sound; SoundMemory.GetSound(sound_elem, dangerous_sound); string128 s_type; switch(sound_elem.type){ case WEAPON_SHOOTING: strcpy_s(s_type,"WEAPON_SHOOTING"); break; case MONSTER_ATTACKING: strcpy_s(s_type,"MONSTER_ATTACKING"); break; case WEAPON_BULLET_RICOCHET: strcpy_s(s_type,"WEAPON_BULLET_RICOCHET"); break; case WEAPON_RECHARGING: strcpy_s(s_type,"WEAPON_RECHARGING"); break; case WEAPON_TAKING: strcpy_s(s_type,"WEAPON_TAKING"); break; case WEAPON_HIDING: strcpy_s(s_type,"WEAPON_HIDING"); break; case WEAPON_CHANGING: strcpy_s(s_type,"WEAPON_CHANGING"); break; case WEAPON_EMPTY_CLICKING: strcpy_s(s_type,"WEAPON_EMPTY_CLICKING"); break; case MONSTER_DYING: strcpy_s(s_type,"MONSTER_DYING"); break; case MONSTER_INJURING: strcpy_s(s_type,"MONSTER_INJURING"); break; case MONSTER_WALKING: strcpy_s(s_type,"MONSTER_WALKING"); break; case MONSTER_JUMPING: strcpy_s(s_type,"MONSTER_JUMPING"); break; case MONSTER_FALLING: strcpy_s(s_type,"MONSTER_FALLING"); break; case MONSTER_TALKING: strcpy_s(s_type,"MONSTER_TALKING"); break; case DOOR_OPENING: strcpy_s(s_type,"DOOR_OPENING"); break; case DOOR_CLOSING: strcpy_s(s_type,"DOOR_CLOSING"); break; case OBJECT_BREAKING: strcpy_s(s_type,"OBJECT_BREAKING"); break; case OBJECT_FALLING: strcpy_s(s_type,"OBJECT_FALLING"); break; case NONE_DANGEROUS_SOUND: strcpy_s(s_type,"NONE_DANGEROUS_SOUND"); break; } if (sound_elem.who) sprintf_s(text,"Sound: type[%s] time[%u] power[%.3f] val[%i] src[+]", s_type, sound_elem.time, sound_elem.power, sound_elem.value); else sprintf_s(text,"Sound: type[%s] time[%u] power[%.3f] val[%i] src[?]", s_type, sound_elem.time, sound_elem.power, sound_elem.value); } else sprintf_s(text, "Sound: NONE"); DBG().text(this).add_item(text, x, y+=delta_y, color); // Hit if (HitMemory.is_hit()) { if (HitMemory.get_last_hit_object()) { sprintf_s(text,"Hit Info: object=[%s] time=[%u]", *(HitMemory.get_last_hit_object()->cName()), HitMemory.get_last_hit_time()); } else { sprintf_s(text,"Hit Info: object=[NONE] time=[%u]", HitMemory.get_last_hit_time()); } } else sprintf_s(text, "Hit Info: NONE"); DBG().text(this).add_item(text, x, y+=delta_y, color); DBG().text(this).add_item("----------- MOVEMENT ------------", x, y+=delta_y, delimiter_color); sprintf_s(text, "Actual = [%u] Enabled = [%u]", control().path_builder().actual(), control().path_builder().enabled()); DBG().text(this).add_item(text, x, y+=delta_y, color); sprintf_s(text, "Speed: Linear = [%.3f] Angular = [%.3f]", control().movement().velocity_current(), 0.f); DBG().text(this).add_item(text, x, y+=delta_y, color); DBG().text(this).add_item("------- Attack Distances -------------", x, y+=delta_y, delimiter_color); sprintf_s(text, "MinDist[%.3f] MaxDist[%.3f] As_Step[%.3f] As_MinDist[%.3f]", MeleeChecker.get_min_distance(), MeleeChecker.get_max_distance(), MeleeChecker.dbg_as_step(), MeleeChecker.dbg_as_min_dist() ); DBG().text(this).add_item(text, x, y+=delta_y, color); if (EnemyMan.get_enemy()) { sprintf_s(text, "Current Enemy = [%s]", *EnemyMan.get_enemy()->cName()); } else sprintf_s(text, "Current Enemy = [NONE]"); DBG().text(this).add_item(text, x, y+=delta_y, color); return SDebugInfo(x, y, delta_y, color, delimiter_color); }