void LaserBeam::OnCollision(ICollidable *other) { Entity *entity = (Entity*)other; Damage_t damage; damage.damage = entity->GetHealth(); if (entity->IsPlayer()) { damage.damage = 1; } damage.direction = Vector2D(-1, 0); damage.inflictor = GetOwner(); if (GetOwner() != nullptr) { damage.statsInflictorName = GetOwner()->GetEntityClassName(); damage.statsInflictorClass = GetOwner()->GetEntityResourceClass(); } damage.statsWeaponName = GetEntityClassName(); damage.statsWeaponClass = GetEntityResourceClass(); entity->TakeDamage(damage); Vector2D laserCenter = GetOrigin(); laserCenter.x = entity->GetOrigin().x; GetGameContext()->GetParticleRoot()->CreateParticles("laser_cannon_hit", laserCenter, Vector2D(-1, 0)); }
void hud::DrawESP() { surface->SetFont(ui::font_hud); surface->SetTextColor(0xff, 0xff, 0xff, 0xff); Entity *lp = LocalPlayer(); int maxent = globals->maxclients(); for (int i = 1; i <= ents->GetMaxEntities(); ++i) { Entity *ent = ents->GetEntity(i); if (ent == nullptr || ent == lp) continue; if (ent->IsDormant()) continue; if (1 && i <= maxent) { if (!ent->IsAlive()) continue; int x0, y0, x1, y1; if (!MakeBox(ent, x0, y0, x1, y1)) continue; surface->SetColor(0x00, 0x00, 0x00, 0x7f); surface->DrawOutlinedRect(x0 - 1, y0 - 1, x1 + 1, y1 + 1); surface->DrawOutlinedRect(x0 + 1, y0 + 1, x1 - 1, y1 - 1); if (1) // menu.ESP.health surface->DrawFilledRect(x0 - 4, y0 - 1, x0 - 1, y1 + 1); #if defined(L4D) || defined(L4D2) switch (ent->GetTeam()) { case 2: case 4: surface->SetColor(0x46, 0x78, 0xff, 0xff); break; case 3: surface->SetColor(0x96, 0x00, 0xe1, 0xff); break; } #else switch (ent->GetTeam()) { case TEAM_RED: surface->SetColor(0xff, 0x64, 0x64, 0xff); break; case TEAM_BLU: surface->SetColor(0x46, 0x78, 0xff, 0xff); break; } #endif surface->DrawOutlinedRect(x0, y0, x1, y1); if (1) // menu.ESP.health { if (ent->GetHealth() <= ent->GetMaxHealth()) { if (ent->GetHealth() <= (ent->GetMaxHealth() / 4)) surface->SetColor(0xff, 0x00, 0x00, 0xff); else surface->SetColor(0x00, 0xff, 0x00, 0xff); } surface->DrawFilledRect(x0 - 3, y1 - Min<int>(y1 - y0, (float)(y1 - y0) * ((float)ent->GetHealth() / (float)ent->GetMaxHealth()) + 0.5f), x0 - 1, y1); } if (1) // menu.ESP.name { player_info info; engine->GetPlayerInfo(i, info); int length = 0; const wchar_t *text = tounicode(info.name, length); int tw, th; surface->GetTextSize(ui::font_hud, text, tw, th); surface->SetTextPos((x0 + x1 - tw) / 2, y0 - th); surface->DrawText(text, length, 0); } if (1) // menu.ESP.weapon { Entity *weapon = ent->GetActiveWeapon(); if (weapon) { const char *classname = weapon->GetClass(); #ifndef GMOD if (qstrlen(classname) > 6) { classname += 6; } #endif int length = 0; const wchar_t *text = util::MakeReadable(classname, length); int tw, th; surface->GetTextSize(ui::font_hud, text, tw, th); surface->SetTextPos((x0 + x1 - tw) / 2, y1 + 1); surface->DrawText(text, length, 0); } } continue; } if (1) { #if defined(L4D) || defined(L4D2) if (streq(ent->GetNetworkClass()->name, "Infected")) { if (!ent->NPC_IsAlive()) continue; int x0, y0, x1, y1; if (!MakeBox(ent, x0, y0, x1, y1)) continue; surface->SetColor(0x00, 0x00, 0x00, 0x7f); surface->DrawOutlinedRect(x0 - 1, y0 - 1, x1 + 1, y1 + 1); surface->DrawOutlinedRect(x0 + 1, y0 + 1, x1 - 1, y1 - 1); surface->SetColor(0xc8, 0xff, 0x00, 0xff); surface->DrawOutlinedRect(x0, y0, x1, y1); int tw, th; if (ReadPtr<bool>(ent, m_mobRush)) { surface->GetTextSize(ui::font_hud, L"Mob rush", tw, th); surface->SetTextPos((x0 + x1 - tw) / 2, y1 + 1); surface->DrawText(L"Mob rush", 8, 0); } else { surface->GetTextSize(ui::font_hud, L"Common", tw, th); surface->SetTextPos((x0 + x1 - tw) / 2, y1 + 1); surface->DrawText(L"Common", 6, 0); } continue; } if (streq(ent->GetNetworkClass()->name, "Witch")) { if (!ent->NPC_IsAlive()) continue; int x0, y0, x1, y1; if (!MakeBox(ent, x0, y0, x1, y1)) continue; surface->SetColor(0x00, 0x00, 0x00, 0x7f); surface->DrawOutlinedRect(x0 - 1, y0 - 1, x1 + 1, y1 + 1); surface->DrawOutlinedRect(x0 + 1, y0 + 1, x1 - 1, y1 - 1); surface->SetColor(0x96, 0x00, 0xe1, 0xff); surface->DrawOutlinedRect(x0, y0, x1, y1); int tw, th; surface->GetTextSize(ui::font_hud, L"Witch", tw, th); surface->SetTextPos((x0 + x1 - tw) / 2, y1 + 1); surface->DrawText(L"Witch", 5, 0); continue; } #endif } } }