SHARE
TWEET

MosquitoBald.cpp

CUgopEntity Jan 23rd, 2019 10 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include "mosquitobald.h"
  3. #include "hudmanager.h"
  4.  
  5. static
  6. f32 g_pp_fade = 2000.f;
  7.  
  8. CMosquitoBald::CMosquitoBald(void) {
  9.     m_time = 0;
  10.     m_pp_time = 0;
  11.     m_hitImpulseScale = 1.f;
  12. }
  13.  
  14. CMosquitoBald::~CMosquitoBald(void) {}
  15.  
  16. void CMosquitoBald::Load(LPCSTR section) {
  17.     inherited::Load(section);
  18.     m_hitImpulseScale = pSettings->ReadFLOAT(section,"hit_impulse_scale");
  19.  
  20.     LPCSTR l_PP = pSettings->ReadSTRING(section,"postprocess");
  21.     m_pp.duality_h = pSettings->ReadFLOAT(l_PP,"duality_h");
  22.     m_pp.duality_v = pSettings->ReadFLOAT(l_PP,"duality_v");
  23.     m_pp.gray = pSettings->ReadFLOAT(l_PP,"gray");
  24.     m_pp.blur = pSettings->ReadFLOAT(l_PP,"blur");
  25.     m_pp.gray = pSettings->ReadFLOAT(l_PP,"gray");
  26.     m_pp.noise = pSettings->ReadFLOAT(l_PP,"noise");
  27.     m_pp.noise_scale = pSettings->ReadFLOAT(l_PP,"noise_scale");
  28.     sscanf(pSettings->ReadSTRING(l_PP,"noise_color"), "%d,%d,%d,%d", &m_pp.r, &m_pp.g, &m_pp.b, &m_pp.a);
  29. }
  30.  
  31. void CMosquitoBald::Affect(CObject* O) {
  32.     CGameObject *l_pO = dynamic_cast<CGameObject*>(O);
  33.     if(l_pO) {
  34.         Fvector P; clXFORM().transform_tiny(P,cfModel->getSphere().P);
  35.         char l_pow[255]; sprintf(l_pow, "zone hit. %.1f", Power(l_pO->Position().distance_to(P)));
  36.         if(bDebug) Level().HUD()->outMessage(0xffffffff,l_pO->cName(), l_pow);
  37.         Fvector l_dir; l_dir.set(::Random.randF(-.5f,.5f), ::Random.randF(.0f,1.f), ::Random.randF(-.5f,.5f)); l_dir.normalize();
  38.         //l_pO->ph_Movement.ApplyImpulse(l_dir, 50.f*Power(l_pO->Position().distance_to(P)));
  39.         Fvector position_in_bone_space;
  40.         float power = Power(l_pO->Position().distance_to(P)), impulse = m_hitImpulseScale*power;
  41.         if(power > 0.01f) {
  42.             m_time = 0;
  43.             position_in_bone_space.set(0.f,0.f,0.f);
  44.             NET_Packet      l_P;
  45.             l_pO->u_EventGen        (l_P,GE_HIT,l_pO->ID());
  46.             l_P.w_u16           (u16(l_pO->ID()));
  47.             l_P.w_dir           (l_dir);
  48.             l_P.w_float         (power);
  49.             l_P.w_s16           ((s16)0);
  50.             l_P.w_vec3          (position_in_bone_space);
  51.             l_P.w_float         (impulse);
  52.             l_pO->u_EventSend       (l_P);
  53.         }
  54.     }
  55. }
  56.  
  57. //void CMosquitoBald::Update(u32 dt) {
  58. void CMosquitoBald::UpdateCL() {
  59.     u32 dt = Device.dwTimeDelta;
  60.     m_time += dt;
  61.     if(m_time > m_period) {
  62.         m_time = m_period;
  63.         //while(m_time > m_period) m_time -= m_period;
  64.         m_ready = true;
  65.     }
  66.     if(m_pLocalActor && m_pLocalActor->g_Alive()) {
  67.         CRender_target*     T   = ::Render->getTarget();
  68.         f32 l_h = m_pp_time < g_pp_fade ? m_pp.duality_h * ((f32)m_pp_time / g_pp_fade) : m_pp.duality_h;
  69.         f32 l_v = m_pp_time < g_pp_fade ? m_pp.duality_v * ((f32)m_pp_time / g_pp_fade) : m_pp.duality_v;
  70.         T->set_duality_h        (l_h*sinf(1.f*Device.fTimeGlobal));
  71.         T->set_duality_v        (l_v*cosf(1.1f*Device.fTimeGlobal));
  72.         //T->set_duality_h      (.0f);
  73.         //T->set_duality_v      (.0f);
  74.         T->set_blur             (m_pp_time < g_pp_fade ? m_pp.blur * ((f32)m_pp_time / g_pp_fade) : m_pp.blur);
  75.         //T->set_blur               (1.f);
  76.         T->set_gray             (m_pp_time < g_pp_fade ? m_pp.gray * ((f32)m_pp_time / g_pp_fade) : m_pp.gray);
  77.         T->set_noise            (m_pp_time < g_pp_fade ? m_pp.noise * ((f32)m_pp_time / g_pp_fade) : m_pp.noise);
  78.         //T->set_noise          (m_pp.noise);
  79.         T->set_noise_scale      (m_pp.noise_scale);
  80.         T->set_noise_color      (color_rgba(m_pp.r,m_pp.g,m_pp.b,m_pp.a));
  81.         T->set_noise_fps        (10.f);
  82.         m_pp_time += dt;
  83.     } else if(m_pp_time>0) {
  84.         if(m_pp_time > g_pp_fade) m_pp_time = (u32)g_pp_fade;
  85.         m_pp_time = m_pp_time < dt ? 0 : m_pp_time - dt;
  86.         CRender_target*     T   = ::Render->getTarget();
  87.         f32 l_h = m_pp_time < g_pp_fade ? m_pp.duality_h * ((f32)m_pp_time / g_pp_fade) : m_pp.duality_h;
  88.         f32 l_v = m_pp_time < g_pp_fade ? m_pp.duality_v * ((f32)m_pp_time / g_pp_fade) : m_pp.duality_v;
  89.         T->set_duality_h        (l_h*sinf(1.f*Device.fTimeGlobal));
  90.         T->set_duality_v        (l_v*cosf(1.1f*Device.fTimeGlobal));
  91.         T->set_blur             (m_pp_time < g_pp_fade ? m_pp.blur * ((f32)m_pp_time / g_pp_fade) : m_pp.blur);
  92.         T->set_gray             (m_pp_time < g_pp_fade ? m_pp.gray * ((f32)m_pp_time / g_pp_fade) : m_pp.gray);
  93.         T->set_noise            (m_pp_time < g_pp_fade ? m_pp.noise * ((f32)m_pp_time / g_pp_fade) : m_pp.noise);
  94.         //T->set_noise          (m_pp.noise);
  95.         T->set_noise_scale      (m_pp.noise_scale);
  96.         T->set_noise_color      (color_rgba(m_pp.r,m_pp.g,m_pp.b,m_pp.a));
  97.         T->set_noise_fps        (10.f);
  98.     }
  99.     inherited::UpdateCL();
  100.     //inherited::Update(dt);
  101. }
  102.  
  103. void CMosquitoBald::Postprocess(f32 val) {
  104. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top