void AimLegit::GetBestTarget() { float maxDistance = 8192.f; float nearest; int index = -1; float fov = g_Options.legit_fov; int firedShots = g_LocalPlayer->m_iShotsFired(); for (int i = 1; i < g_GlobalVars->maxClients; i++) { auto player = C_BasePlayer::GetPlayerByIndex(i); if (!CheckTarget(player)) continue; QAngle viewangles = usercmd->viewangles; Vector targetpos; if (firedShots > g_Options.legit_aftershots) targetpos = player->GetBonePos(realAimSpot[g_Options.legit_afteraim]); else if (firedShots < g_Options.legit_aftershots) targetpos = player->GetBonePos(realAimSpot[g_Options.legit_preaim]); nearest = Math::GetFov(viewangles, Math::CalcAngle(g_LocalPlayer->GetEyePos(), targetpos)); if (nearest > fov) continue; float distance = Math::GetDistance(g_LocalPlayer->m_vecOrigin(), player->m_vecOrigin()); if (fabsf(fov - nearest) < 5) { if (distance < maxDistance) { fov = nearest; maxDistance = distance; index = i; } } else if (nearest < fov) { fov = nearest; maxDistance = distance; index = i; } } SetTarget(index); }
void CParticlesPlayer::StartParticles(const shared_str& particles_name, u16 bone_num, const Fmatrix& xform, u16 sender_id, int life_time, bool auto_stop) { VERIFY(fis_zero(xform.c.magnitude())); R_ASSERT(*particles_name); CObject* object = m_self_object; VERIFY(object); SBoneInfo* pBoneInfo = get_nearest_bone_info(smart_cast<CKinematics*>(object->Visual()),bone_num); if(!pBoneInfo) return; SParticlesInfo &particles_info =*pBoneInfo->AppendParticles(object,particles_name); particles_info.sender_id = sender_id; particles_info.life_time=auto_stop ? life_time : u32(-1); xform.getHPB(particles_info.angles); Fmatrix m; m.setHPB(particles_info.angles.x,particles_info.angles.y,particles_info.angles.z); GetBonePos(object,pBoneInfo->index,pBoneInfo->offset,m.c); particles_info.ps->UpdateParent(m,zero_vel); if(!particles_info.ps->IsPlaying()) particles_info.ps->Play (); m_bActiveBones = true; }
void AimLegit::TargetRegion() { auto player = C_BasePlayer::GetPlayerByIndex(m_iTarget); int firedShots = g_LocalPlayer->m_iShotsFired(); QAngle aimPunchAngle = g_LocalPlayer->m_aimPunchAngle(); std::random_device r3nd0m; std::mt19937 r3nd0mGen(r3nd0m()); std::uniform_real<float> r3nd0mXAngle(1.7f, 1.9f); std::uniform_real<float> r3nd0mYAngle(1.7f, 1.9f); aimPunchAngle.pitch *= r3nd0mXAngle(r3nd0mGen); aimPunchAngle.yaw *= r3nd0mYAngle(r3nd0mGen); aimPunchAngle.roll = 0.0f; Math::NormalizeAngles(aimPunchAngle); QAngle viewangles = usercmd->viewangles; Vector targetpos; if (firedShots > g_Options.legit_aftershots) targetpos = player->GetBonePos(realAimSpot[g_Options.legit_afteraim]); else if (firedShots < g_Options.legit_aftershots) targetpos = player->GetBonePos(realAimSpot[g_Options.legit_preaim]); QAngle angle = Math::CalcAngle(g_LocalPlayer->GetEyePos(), targetpos); angle.pitch -= aimPunchAngle.pitch; angle.yaw -= aimPunchAngle.yaw; Math::SmoothAngle(viewangles, angle, g_Options.legit_smooth_factor); Math::NormalizeAngles(angle); usercmd->viewangles = angle; }
void CParticlesPlayer::UpdateParticles() { if (!m_bActiveBones) return; m_bActiveBones = false; CObject* object = m_self_object; VERIFY (object); for(BoneInfoVecIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) { SBoneInfo& b_info = *b_it; for (ParticlesInfoListIt p_it=b_info.particles.begin(); p_it!=b_info.particles.end(); p_it++) { SParticlesInfo& p_info = *p_it; if(!p_info.ps) continue; //обновить позицию партиклов Fmatrix xform; xform.setHPB(p_info.angles.x,p_info.angles.y,p_info.angles.z); GetBonePos(object,b_info.index,b_info.offset,xform.c); p_info.ps->UpdateParent(xform, parent_vel); //обновить время существования if(p_info.life_time!=u32(-1)) { if(p_info.life_time>Device.dwTimeDelta) p_info.life_time-=Device.dwTimeDelta; else { p_info.ps->Stop(); p_info.life_time=u32(-1); } } if(!p_info.ps->IsPlaying()) { CParticlesObject::Destroy(p_info.ps); } else m_bActiveBones = true; } ParticlesInfoListIt RI=std::remove_if(b_info.particles.begin(),b_info.particles.end(),SRP()); b_info.particles.erase(RI,b_info.particles.end()); } }
void CParticlesPlayer::StartParticles(const shared_str& ps_name, const Fmatrix& xform, u16 sender_id, int life_time, bool auto_stop) { CObject* object = m_self_object; VERIFY(object); for(BoneInfoVecIt it = m_Bones.begin(); it!=m_Bones.end(); it++) { SParticlesInfo &particles_info =*it->AppendParticles(object,ps_name); particles_info.sender_id = sender_id; particles_info.life_time=auto_stop ? life_time : u32(-1); xform.getHPB(particles_info.angles); //начать играть партиклы Fmatrix m; m.set(xform); GetBonePos(object,it->index,it->offset,m.c); particles_info.ps->UpdateParent(m,zero_vel); if(!particles_info.ps->IsPlaying()) particles_info.ps->Play (); } m_bActiveBones = true; }
void CParticlesPlayer::MakeXFORM (CObject* pObject, u16 bone_id, const Fvector& dir, const Fvector& offset, Fmatrix& result) { generate_orthonormal_basis(dir,result); GetBonePos(pObject, bone_id, offset, result.c); }