/*************************************************
 * Decompiled by Serious and Edited by SyndiShanX
 * Script: zm\zm_genesis_wisps.csc
*************************************************/

#using scripts\codescripts\struct;
#using scripts\shared\animation_shared;
#using scripts\shared\array_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\exploder_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\postfx_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
#using scripts\shared\weapons\_bouncingbetty;
#using scripts\zm\_load;
#using scripts\zm\_zm;
#using scripts\zm\_zm_utility;
#using scripts\zm\zm_genesis_util;
#namespace zm_genesis_wisps;

function autoexec __init__sytem__() {
  system::register("zm_genesis_wisps", &__init__, &__main__, undefined);
}

function __init__() {
  clientfield::register("toplayer", "set_funfact_fx", 15000, 3, "int", &set_funfact_fx, 0, 0);
  clientfield::register("scriptmover", "wisp_fx", 15000, 2, "int", &wisp_fx, 0, 0);
}

function __main__() {}

function wisp_fx(localclientnum, oldval, newval, bnewent, binitialsnap, fieldname, bwastimejump) {
  if(newval == 1) {
    playFXOnTag(localclientnum, level._effect["wisp_abcd"], self, "tag_origin");
  }
  if(newval == 2) {
    playFXOnTag(localclientnum, level._effect["wisp_shad"], self, "tag_origin");
  }
}

function set_funfact_fx(localclientnum, oldval, newval, bnewent, binitialsnap, fieldname, bwastimejump) {
  if(newval) {
    if(!isDefined(self.var_ab2ca08f)) {
      var_6aa3898e = array("stub", "s_fx_funfact_demp", "s_fx_funfact_niko", "s_fx_funfact_rich", "s_fx_funfact_take");
      var_43845c37 = var_6aa3898e[newval];
      s_fx = struct::get(var_43845c37, "targetname");
      if(isDefined(s_fx)) {
        self.var_ab2ca08f = util::spawn_model(localclientnum, "tag_origin", s_fx.origin, s_fx.angles);
        if(isDefined(self.var_ab2ca08f)) {
          playFXOnTag(localclientnum, level._effect["wisp_abcd"], self.var_ab2ca08f, "tag_origin");
        }
      }
    }
  } else if(isDefined(self.var_ab2ca08f)) {
    self.var_ab2ca08f delete();
  }
}