Advertisement
S1L1R

Untitled

Jul 3rd, 2020
2,406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.02 KB | None | 0 0
  1. void c_eventlistener::FireGameEvent(IGameEvent* e) {
  2.     if (!e)
  3.         return;
  4.  
  5.     auto event_name = std::string(e->GetName());
  6.     auto localplayer = g_game->interfaces->engine->get_local_player();
  7.     auto cfg = c_config::get();
  8.  
  9.     if (event_name == _("bullet_impact")) {
  10.         auto x = e->get_float(_("x"));
  11.         auto y = e->get_float(_("y"));
  12.         auto z = e->get_float(_("z"));
  13.         auto userid = e->get_int(_("userid"));
  14.  
  15.         if (cfg->b[_("vis_bulletimpacts")])
  16.             g_game->interfaces->overlay->add_box_overlay(Vector(x, y, z), Vector(-2, -2, -2), Vector(2, 2, 2), Vector(0, 0, 0), 0, 0, 255, 127, 4);
  17.  
  18.         last_bullet_impact = Vector(x, y, z);
  19.  
  20.         auto entid = g_game->interfaces->engine->get_player_for_userid(userid);
  21.         auto uent = g_game->interfaces->entities->from_num(entid);
  22.         if (uent) {
  23.             auto ent = uent->get_base_entity();
  24.             auto eyes = ent->m_vecOrigin() + ent->m_vecViewOffset();
  25.  
  26.             if (ent->entindex() == g_globals->local_player->entindex() && (cfg->b[_("vis_local_tracer")] || cfg->b[_("vis_team_tracer")])) {
  27.                 Ray_t raycast;
  28.                 raycast.init(eyes, Vector(x, y, z));
  29.  
  30.                 CTraceFilter filter;
  31.                 filter.skip = g_globals->local_player;
  32.  
  33.                 trace_t tr;
  34.                 g_game->interfaces->trace->trace_ray(raycast, MASK_SHOT | CONTENTS_GRATE, &filter, &tr);
  35.  
  36.                 if (tr.ent && cfg->b[_("vis_team_tracer")])
  37.                     c_tracers::get()->add(
  38.                         Vector(eyes.x, eyes.y, eyes.z - 2.f),
  39.                         Vector(x, y, z),
  40.                         cfg->imcolor_to_ccolor(cfg->c[_("vis_team_tracer_color")]));
  41.                 else if (!tr.ent && cfg->b[_("vis_local_tracer")])
  42.                     c_tracers::get()->add(
  43.                         Vector(eyes.x, eyes.y, eyes.z - 2.f),
  44.                         Vector(x, y, z),
  45.                         cfg->imcolor_to_ccolor(cfg->c[_("vis_local_tracer_color")]));
  46.             }
  47.             else {
  48.                 if (ent->m_iTeamNum() != g_globals->local_player->m_iTeamNum() && cfg->b[_("vis_enemy_tracer")])
  49.                     c_tracers::get()->add(
  50.                         Vector(eyes.x, eyes.y, eyes.z - 2.f),
  51.                         Vector(x, y, z),
  52.                         cfg->imcolor_to_ccolor(cfg->c[_("vis_enemy_tracer_color")]));
  53.             }
  54.         }
  55.     }
  56.  
  57.     if (event_name == _("player_hurt")) {
  58.         auto userid = e->get_int(_("userid"));
  59.         auto attacker = e->get_int(_("attacker"));
  60.         auto health = e->get_int(_("health"));
  61.         auto armor = e->get_int(_("armor"));
  62.         auto weapon = e->get_string(_("weapon"));
  63.         auto dmg_health = e->get_int(_("dmg_health"));
  64.         auto dmg_armor = e->get_int(_("dmg_armor"));
  65.         auto hitgroup = e->get_int(_("hitgroup"));
  66.  
  67.         auto ent_hurted = g_game->interfaces->engine->get_player_for_userid(userid);
  68.         auto ent_attacker = g_game->interfaces->engine->get_player_for_userid(attacker);
  69.  
  70.         if (ent_hurted != ent_attacker) {
  71.             player_info_t p_hurted, p_attacker;
  72.             g_game->interfaces->engine->get_player_info(ent_hurted, &p_hurted);
  73.             g_game->interfaces->engine->get_player_info(ent_attacker, &p_attacker);
  74.  
  75.             if (ent_hurted == localplayer && cfg->b[_("misc_logevents")] && cfg->b[_("misc_showdamage")])
  76.                 c_utils::get()->log(_("      -%ihp in the %s by %s (%s)"), dmg_health, hitgroup_to_string(hitgroup).c_str(), p_attacker.name, weapon);
  77.             if (ent_attacker == localplayer) {
  78.                 if (cfg->b[_("misc_logevents")] && cfg->b[_("misc_showdamage")])
  79.                 //  c_utils::get()->log(_("Hit %s in the %s for %ihp (%ihp left)"), p_hurted.name, hitgroup_to_string(hitgroup).c_str(), dmg_health, health);
  80.                     c_utils::get()->log(_("-%ihp in %s to %s (%ihp left)"), dmg_health, hitgroup_to_string(hitgroup).c_str(), p_hurted.name, health);
  81.                 if (cfg->i[_("vis_hitsound")]) {
  82.                     if (cfg->i[_("vis_hitsound")] == 1)
  83.                         g_game->interfaces->engine->client_cmd_unrestricted(_("play weapons/auto_semiauto_switch"));
  84.                     if (cfg->i[_("vis_hitsound")] == 2)
  85.                         g_game->interfaces->engine->client_cmd_unrestricted(_("play buttons/arena_switch_press_02"));
  86.                 }
  87.                 if (cfg->m[_("vis_hitmarker")][0])
  88.                     c_hitmarker::get()->add_screen_marker();
  89.                 if (cfg->m[_("vis_hitmarker")][1])
  90.                     c_hitmarker::get()->add_positional_marker(last_bullet_impact);
  91.                 if (health <= 0 && cfg->i[_("vis_killeffect")] == 1)
  92.                     g_globals->killeffect_alpha = (int)(cfg->c[_("vis_killeffect_color")][3] * 255.f);
  93.                 if (health <= 0 && cfg->i[_("vis_killeffect")] == 2)
  94.                     g_globals->local_player->m_flHealthShotBoostExpirationTime() = g_game->interfaces->globals->curtime + cfg->f[_("vis_killeffect_length")];
  95.             }
  96.         }
  97.     }
  98.  
  99.     if (event_name == _("player_blind")) {
  100.         auto attacker = e->get_int(_("attacker"));
  101.         auto userid = e->get_int(_("userid"));
  102.  
  103.         auto ent_attacker = g_game->interfaces->engine->get_player_for_userid(attacker);
  104.         auto ent_userid = g_game->interfaces->engine->get_player_for_userid(userid);\
  105.  
  106.         if (ent_attacker == localplayer) {
  107.             if (cfg->i[_("vis_hitsound")]) {
  108.                 if (cfg->i[_("vis_hitsound")] == 1)
  109.                     g_game->interfaces->engine->client_cmd_unrestricted(_("play weapons/auto_semiauto_switch"));
  110.                 if (cfg->i[_("vis_hitsound")] == 2)
  111.                     g_game->interfaces->engine->client_cmd_unrestricted(_("play buttons/arena_switch_press_02"));
  112.             }
  113.         }
  114.     }
  115.  
  116.     if (event_name == _("game_newmap")) {
  117.         g_globals->reset_smoke = true;
  118.         g_globals->reset_alpha = true;
  119.         g_globals->reset_sky = true;
  120.         g_globals->reset_impacts = true;
  121.     }
  122.  
  123.     if (event_name == _("player_footstep")) {
  124.         if (cfg->b[_("vis_soundesp")]) {
  125.             auto uid = e->get_int(_("userid"));
  126.             auto ent = (C_BaseEntity*)g_game->interfaces->entities->from_num(g_game->interfaces->engine->get_player_for_userid(uid));
  127.  
  128.             if (ent) {
  129.                 if (ent->entindex() != g_globals->local_player->entindex() && ent->m_iTeamNum() != g_globals->local_player->m_iTeamNum()) {
  130.                     auto col = cfg->c[_("vis_soundesp_color")];
  131.                     g_game->interfaces->overlay->add_text_rgb(ent->m_vecOrigin(), 0, 1.5f, col[0], col[1], col[2], col[3], _("STEP"));
  132.                 }
  133.             }
  134.         }
  135.     }  
  136.  
  137.     if (event_name == _("round_start")) {
  138.         for (int i = 1; i < g_game->interfaces->globals->maxclients; i++) {
  139.             auto ent = (C_BaseEntity*)g_game->interfaces->entities->from_num(i);
  140.             if (ent)
  141.                 ent->m_hObserverTarget() = CBaseHandle();
  142.         }
  143.  
  144.         for (auto& p : c_esp::get()->players) {
  145.             p.second.alpha = 0;
  146.             p.second.alpha_anim = 0;
  147.         }
  148.     }
  149.  
  150.     if (event_name == "player_death") {
  151.         auto userid = e->get_int("userid");
  152.         auto ent = (C_BaseEntity*)g_game->interfaces->entities->from_num(g_game->interfaces->engine->get_player_for_userid(userid));
  153.         if (ent) {
  154.             ent->m_iHealth() = 0;
  155.  
  156.             c_esp::get()->players[ent->entindex()].alpha = 0;
  157.             c_esp::get()->players[ent->entindex()].alpha_anim = 0;
  158.         }
  159.  
  160.         auto attacker = g_game->interfaces->entities->from_num(g_game->interfaces->engine->get_player_for_userid(e->get_int("attacker")));
  161.         auto group = _("lb_grp_") + std::to_string(c_legitbot::get()->group_id) + _("_");
  162.  
  163.         if (attacker && g_globals->local_player && attacker->entindex() == g_globals->local_player->entindex() &&
  164.             cfg->i[group + _("switchdelay")] != 0 && cfg->b[group + _("aimbot")] && c_keyhandler::get()->auto_check(group + _("aimbot_key"))) {
  165.             c_legitbot::get()->shot_delay += g_globals->local_player->m_flSimulationTime() + cfg->i[group + _("switchdelay")] * 0.001f;
  166.         }
  167.     }
  168.  
  169.     if (c_config::get()->b[_("lua_devmode")])
  170.         c_utils::get()->log(event_name.c_str());
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement