/*************************************************
 * Decompiled by Serious and Edited by SyndiShanX
 * Script: zm\_zm_hackables_packapunch.gsc
*************************************************/

#using scripts\codescripts\struct;
#using scripts\shared\array_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\util_shared;
#using scripts\zm\_zm_equip_hacker;
#namespace zm_hackables_packapunch;

function hack_packapunch() {
  vending_weapon_upgrade_trigger = getEntArray("pack_a_punch", "script_noteworthy");
  perk = getent(vending_weapon_upgrade_trigger[0].target, "targetname");
  if(isDefined(perk)) {
    struct = spawnStruct();
    struct.origin = (perk.origin + (anglestoright(perk.angles) * 26)) + vectorscale((0, 0, 1), 48);
    struct.radius = 48;
    struct.height = 48;
    struct.script_float = 5;
    struct.script_int = -1000;
    level._pack_hack_struct = struct;
    zm_equip_hacker::register_pooled_hackable_struct(level._pack_hack_struct, &packapunch_hack);
    level._pack_hack_struct pack_trigger_think();
  }
}

function pack_trigger_think() {
  if(!level flag::exists("enter_nml")) {
    return;
  }
  while(true) {
    level flag::wait_till("enter_nml");
    self.script_int = -1000;
    while(level flag::get("enter_nml")) {
      wait(1);
    }
  }
}

function packapunch_hack(hacker) {
  zm_equip_hacker::deregister_hackable_struct(level._pack_hack_struct);
  level._pack_hack_struct.script_int = 0;
  level notify("packapunch_hacked");
}