////////////////////////////////////////
// WCS - Warcraft:Source              //
// ---------------------------------- //
//  by kRypT0n!Te                     //
//      http://wcs.despo-clan.de      //
// ---------------------------------- //
// Content of this subscript          //
// - ultimate, ability                //
// - death handling and skill exec    //
////////////////////////////////////////
// say commands:
// ability
//
// admin commands:
// wcs_deathhandle2 <userid>
// wcs_checkskills <userid> <skilltype>
// wcs_skillcheck <userid>
//
////////////////////////////////////////

block load
{
  es_xexists wcs_exists command ability
  es_xregclientcmd ultimate wcs/WCSfunctions/WCSskills/wcs_ultimate "Executes an ultimate skill"
  es_xregclientcmd ability wcs/WCSfunctions/WCSskills/wcs_ability "Command for special abilities"
  es es_xif (server_var(wcs_exists) = 0) then es_xregsaycmd ability wcs/WCSfunctions/WCSskills/wcs_ability "Command for special abilities"
  es_xexists wcs_exists command wcs_deathhandle2
  es es_xif (server_var(wcs_exists) = 0) then es_xregcmd wcs_deathhandle2 wcs/WCSfunctions/WCSskills/wcs_deathhandle2 "Cleanup events"
  es_xexists wcs_exists command wcs_checkskills
  es es_xif (server_var(wcs_exists) = 0) then es_xregcmd wcs_checkskills wcs/WCSfunctions/WCSskills/wcs_checkskills "wcs_checkskills - usage: wcs_checkskills <userid> <type>"
  es_xexists wcs_exists command wcs_skillcheck
  es es_xif (server_var(wcs_exists) = 0) then es_xregcmd wcs_skillcheck wcs/WCSfunctions/WCSskills/wcs_skillcheck "wcs_skillcheck - usage: wcs_skillcheck <userid>"
  es_xexists wcs_exists command +ggun
  es_xregclientcmd +ggun wcs/WCSfunctions/WCSskills/wcs_+ggun "pics up a prop"
  es es_xif (server_var(wcs_exists) = 0) then es_xregsaycmd +ggun wcs/WCSfunctions/WCSskills/wcs_+ggun "pics up a prop"
  es_xexists wcs_exists command -ggun
  es_xregclientcmd -ggun wcs/WCSfunctions/WCSskills/wcs_-ggun "throws a prop"
  es es_xif (server_var(wcs_exists) = 0) then es_xregsaycmd -ggun wcs/WCSfunctions/WCSskills/wcs_-ggun "throws a prop"
  es_xexists wcs_exists command +fly
  es_xregclientcmd +fly wcs/WCSfunctions/WCSskills/wcs_+fly "Turns on Jetpack"
  es es_xif (server_var(wcs_exists) = 0) then es_xregsaycmd +fly wcs/WCSfunctions/WCSskills/wcs_+fly "Turns on Jetpack"
  es_xexists wcs_exists command -fly
  es_xregclientcmd -fly wcs/WCSfunctions/WCSskills/wcs_-fly "Turns off Jetpack"
  es es_xif (server_var(wcs_exists) = 0) then es_xregsaycmd -fly wcs/WCSfunctions/WCSskills/wcs_-fly "Turns off Jetpack"
  es_xregclientcmd +laser wcs/WCSfunctions/WCSskills/wcs_+laser "Turns on laser"
  es es_xif (server_var(wcs_exists) = 0) then es_xregsaycmd +laser wcs/WCSfunctions/WCSskills/wcs_+laser "Turns on laser"
  es_xregclientcmd -laser wcs/WCSfunctions/WCSskills/wcs_-laser "Turns on laser"
  es es_xif (server_var(wcs_exists) = 0) then es_xregsaycmd -laser wcs/WCSfunctions/WCSskills/wcs_-laser "Turns on laser"

  
  es_xkeygroupcreate "WCSpha"
  es_xkeygroupcreate "WCSphv"
  es_xkeygroupcreate "WCSpd"
  es_xkeygroupcreate "WCSps"
  es_xkeygroupcreate "WCSpsay"
}

block unload
{
  es_xkeygroupdelete "WCSpha"
  es_xkeygroupdelete "WCSphv"
  es_xkeygroupdelete "WCSpd"
  es_xkeygroupdelete "WCSps"
  es_xkeygroupdelete "WCSpsay"
}

event player_disconnect
{
  es es_xexists wcs_exists key WCSpha event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSpha event_var(userid)
  es es_xexists wcs_exists key WCSphv event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSphv event_var(userid)
  es es_xexists wcs_exists key WCSpd event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSpd event_var(userid)
  es es_xexists wcs_exists key WCSps event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSps event_var(userid)
  es es_xexists wcs_exists key WCSpsay event_var(userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSpsay event_var(userid)
}

event player_activate
{
  es es_xkeycreate WCSpha event_var(userid)
  es es_xkeycreate WCSphv event_var(userid)
  es es_xkeycreate WCSpd event_var(userid)
  es es_xkeycreate WCSps event_var(userid)
  es es_xkeycreate WCSpsay event_var(userid)
}

event server
{
  es_xkeygroupdelete "WCSpha"
  es_xkeygroupdelete "WCSphv"
  es_xkeygroupdelete "WCSpd"
  es_xkeygroupdelete "WCSps"
  es_xkeygroupdelete "WCSpsay"

  es_xkeygroupcreate "WCSpha"
  es_xkeygroupcreate "WCSphv"
  es_xkeygroupcreate "WCSpd"
  es_xkeygroupcreate "WCSps"
  es_xkeygroupcreate "WCSpsay"
}

block wcs_ultimate
{
es es_xif (server_var(wcs_debug) = 1) then profile begin ultimate
  // its a command
  es_xgetcmduserid wcs_userid
  es es_xexists wcs_exists userid server_var(wcs_userid)
  es_xsetinfo wcs_time 0
  es_xsetinfo wcs_curtime 0
  // prevent spectator running ultimate
  es_xsetinfo wcs_dead "0"
  es es_xgetplayerprop wcs_dead server_var(wcs_userid) "CCSPlayer.baseclass.pl.deadflag"
  es es_xif (server_var(wcs_dead) = "1") then es_xsetinfo wcs_exists 0
  es_xcopy wcs_ulti_allow wcs_gamestarted
  //es es_xif (server_var(wcs_game) != server_var(wcs_game_css)) then es_xsetinfo wcs_ulti_allow 1
  // check if its valid
  es es_xif (server_var(wcs_exists) = "1") do
  {
  	// check teams (T=2, CT=3), and ultimate protection in 30feet range
  	es es_xgetplayerteam wcs_team server_var(wcs_userid)
    es es_xif (server_var(wcs_team) = 2) then es_xsetinfo wcs_team_targetn "#c!d"
    es es_xif (server_var(wcs_team) = 3) then es_xsetinfo wcs_team_targetn "#t!d"
    es est_PlayerCount wcs_tmp server_var(wcs_team_targetn)
  	es es_xif (server_var(wcs_tmp) > 0) then est_Near wcs_uid server_var(wcs_team_targetn) 300 server_var(wcs_userid) "es_xsetinfo wcs_tmp 0;es es_xkeygetvalue wcs_tmp WCSuserdata server_var(wcs_uid) ulti_immunity;es es_xif (server_var(wcs_tmp) = 1) then es_xsetinfo wcs_ulti_allow 0"
    es es_xif (server_var(wcs_ulti_allow) = 1) do
    {
      // get a time
      es est_uptime wcs_curtime
      es_xsetinfo wcs_ulti 0
      es es_xkeygetvalue wcs_ulti WCSuserdata server_var(wcs_userid) "ultimate"
      es es_xif (server_var(wcs_ulti) = 0) do
      {
        es es_xkeysetvalue "WCSuserdata" server_var(wcs_userid) "ultimate" server_var(wcs_curtime)
        es es_xsetinfo wcs_ulti server_var(wcs_time)
      }
      es es_xmath wcs_time + server_var(wcs_curtime)
      es es_xmath wcs_time - server_var(wcs_ulti)
      es_xsetinfo wcs_ultidelay 0
      es_xsetinfo wcs_race 0
      es es_xkeygetvalue wcs_race "WCSuserdata" server_var(wcs_userid) "race"
      es es_xkeygetvalue wcs_ultidelay "WCSraces" server_var(wcs_race) "ultimate_cooldown"
      es est_IsNumeric wcs_numeric server_var(wcs_ultidelay)
      es es_xif (server_var(wcs_numeric) = "0") do
      {
      	es es_xkeygetvalue wcs_level "WCSuserdata" server_var(wcs_userid) "ultilevel"
        es es_xtoken wcs_ultidelay server_var(wcs_ultidelay) server_var(wcs_level) "|"
      }
      es es_xif (server_var(wcs_time) >= server_var(wcs_ultidelay)) do
      {
        es_xsetinfo wcs_ultinotexec 0
        // exec the skill
        es wcs_checkskills server_var(wcs_userid) "player_ultimate"
        // check if ultimate fails
        es es_xif (server_var(wcs_ultinotexec) = 0) then es_xkeysetvalue "WCSuserdata" server_var(wcs_userid) "ultimate" server_var(wcs_curtime)
      }
      es_xelse do
      {
        es es_xsetinfo wcs_diff server_var(wcs_ultidelay)
        es es_xmath wcs_diff - server_var(wcs_time)
        wcs_getlanguage "wcs_lng" "wcs_lng_cooldown"
        es es_xformat wcs_text server_var(wcs_lng) server_var(wcs_ultidelay) server_var(wcs_diff)
        es es_xtell server_var(wcs_userid) #multi server_var(wcs_text)
      }
    }
    es_xelse do
    {
    	wcs_getlanguage "wcs_lng" "wcs_lng_ultinotnow"
      es es_xtell server_var(wcs_userid) #multi server_var(wcs_lng)
    }
  }
es es_xif (server_var(wcs_debug) = 1) then profile end ultimate
}

block wcs_ability
{
es es_xif (server_var(wcs_debug) = 1) then profile begin ability
  // first, is it a custom command ?
  es_xsetinfo wcs_userid 0
  es_xgetargv wcs_userid 1
  es es_xexists wcs_exists userid server_var(wcs_userid)
  es es_xif (server_var(wcs_exists) = 0) do
  {
    // or a say command
    es_xgetcmduserid wcs_userid
    es es_xexists wcs_exists userid server_var(wcs_userid)
  }
  es es_xgetplayerprop wcs_dead server_var(wcs_userid) "CCSPlayer.baseclass.pl.deadflag"
  es es_xif (server_var(wcs_dead) = "1") then es_xsetinfo wcs_exists 0
  es_xcopy wcs_ulti_allow wcs_gamestarted
  //es es_xif (server_var(wcs_game) != server_var(wcs_game_css)) then es_xsetinfo wcs_ulti_allow 1
  es es_xif (server_var(wcs_ulti_allow) != "1") then es_xsetinfo wcs_exists 0
  es es_xif (server_var(wcs_exists) = 1) do
  {
    es es_xexists wcs_exists key WCSuserdata server_var(wcs_userid)
    es es_xif (server_var(wcs_exists) = 1) do
    {
      es es_xkeygetvalue wcs_tmp WCSuserdata server_var(wcs_userid) "ability"
      es es_xif (server_var(wcs_tmp) in "warden") do
      {
        es_xsetinfo wcs_ability_count 0
        es es_xkeygetvalue wcs_ability_count WCSuserdata server_var(wcs_userid) ability_count
        es es_xif (server_var(wcs_ability_count) > 0) do
        {
          es es_xif (server_var(wcs_tmp) = "warden") do
          {
            es_xsetinfo wcs_params 0
            es es_xkeygetvalue wcs_params WCSuserdata server_var(wcs_userid) "ability_parameter"
          	es es_xif (server_var(wcs_params) != "0") do
	          {
	          	es es_xgetplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid)
	          	es_xsetinfo wcs_duration 0
					    es es_xtoken wcs_duration server_var(wcs_params) 1 "_"
	          	es es_xif (server_var(wcs_graphicfx) = 1) do
	          	{
	          		es_xcopy wcs_x2 wcs_x1
					      es_xcopy wcs_y2 wcs_y1
					      es_xcopy wcs_z2 wcs_z1
					      es_xmath wcs_z1 + 120
				      	es est_Effect 11 #a 0 "sprites/purpleglow1.vmt" server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_duration) 2 50
				      	es est_Effect 3 #a 0 "sprites/lgtning.vmt" server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_x2) server_var(wcs_y2) server_var(wcs_z2) server_var(wcs_duration) 20 20 10 0 255 70
					      es_xmath wcs_z1 - 120
					    }
					    es es_xgetplayerteam wcs_team server_var(wcs_userid)
				      // check teams (T=2, CT=3)
	            es es_xif (server_var(wcs_team) = 2) do
	  					{
					    	es_xsetinfo wcs_team_target 3
					    	es_xsetinfo wcs_team_targetn "#ct"
					  	}
					  	es es_xif (server_var(wcs_team) = 3) do
					  	{
						    es_xsetinfo wcs_team_target 2
					    	es_xsetinfo wcs_team_targetn "#t"
					  	}
					  	es es_xtoken wcs_dmg server_var(wcs_params) 2 "_"
		          es es_xtoken wcs_radius server_var(wcs_params) 3 "_"
	          	es wcs_warden server_var(wcs_userid) server_var(wcs_duration) server_var(wcs_dmg) server_var(wcs_radius) server_var(wcs_team_target) server_var(wcs_team_targetn) server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_roundcounter)
	          	wcs_getlanguage "wcs_lng" "wcs_lng_wardencreated"
	          	es es_xtell server_var(wcs_userid) #multi server_var(wcs_lng)
	          }
          }
          es_xmath wcs_ability_count - 1
          es es_xkeysetvalue WCSuserdata server_var(wcs_userid) ability_count server_var(wcs_ability_count)
        }
        es_xelse do
        {
        	wcs_getlanguage "wcs_lng" "wcs_lng_noability"
        	es es_xtell server_var(wcs_userid) #multi server_var(wcs_lng)
        }
      }
    }
  }
  es es_xif (server_var(wcs_tmp) in "strider") do
  {
  es_xsetinfo wcs_ability_count 0
  es es_xkeygetvalue wcs_ability_count WCSuserdata server_var(wcs_userid) ability_count
  es es_xif (server_var(wcs_ability_count) > 0) do
  {
   es es_xif (server_var(wcs_tmp) = "strider") do
   {
 es_xsetinfo wcs_params 0
   es es_xkeygetvalue wcs_params WCSuserdata server_var(wcs_userid) "ability_parameter"
     es es_xif (server_var(wcs_params) != "0") do
	    {
	         es es_xgetplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid)
	            es_xsetinfo wcs_duration 0
			           es es_xtoken wcs_duration server_var(wcs_params) 1 "_"
	                 es es_xif (server_var(wcs_graphicfx) = 1) do
	                    {
	          		        es_xcopy wcs_x2 wcs_x1
					                es_xcopy wcs_y2 wcs_y1
					                 es_xcopy wcs_z2 wcs_z1
                             es est_Effect 10 #a 0 "effects/strider_bulge_dudv_dx60.vmt" server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_radius) 5 server_var(wcs_duration) 5 5 1 255 250 70 10 10
                            es_xmath wcs_z1 + 80
                          es est_Effect 3 #a 0 "sprites/lgtning.vmt" server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_x2) server_var(wcs_y2) server_var(wcs_z2) server_var(wcs_duration) 20 20 10 50 255 170
				               	es est_Effect 11 #a 0 "effects/strider_bulge_dudv_dx60.vmt" server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_duration) 1 50
					             }
					            es es_xgetplayerteam wcs_team server_var(wcs_userid)
	                   es es_xif (server_var(wcs_team) = 2) do
	  			       		{
					      	es_xsetinfo wcs_team_target 3
					    	es_xsetinfo wcs_team_targetn "#ct"
					  	}
					  	es es_xif (server_var(wcs_team) = 3) do
					  	{
						    es_xsetinfo wcs_team_target 2
					    	es_xsetinfo wcs_team_targetn "#t"
					  	}
					  	es es_xtoken wcs_dmg server_var(wcs_params) 2 "_"
		          es es_xtoken wcs_radius server_var(wcs_params) 3 "_"
	          	es wcs_strider server_var(wcs_userid) server_var(wcs_duration) server_var(wcs_dmg) server_var(wcs_radius) server_var(wcs_team_target) server_var(wcs_team_targetn) server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_roundcounter)
	          	es es_xtell server_var(wcs_userid) #multi #greenYou have practiced the art of Kayakujutsu
	          }
          }
          es_xmath wcs_ability_count - 1
          es es_xkeysetvalue WCSuserdata server_var(wcs_userid) ability_count server_var(wcs_ability_count)
        }
        es_xelse do
        {
        	wcs_getlanguage "wcs_lng" "wcs_lng_noability"
        	es es_xtell server_var(wcs_userid) #multi server_var(wcs_lng)
        }
      }
    }
  }
}
es es_xif (server_var(wcs_debug) = 1) then profile end ability
}

block wcs_skillcheck
{
es es_xif (server_var(wcs_debug) = 1) then profile begin skillcheck
  // usage:    wcs_skillcheck <userid>
  // userid:   give a VALID userid
  es_xsetinfo wcs_scuserid 0
  es_xgetargv wcs_scuserid 1
  es es_xexists wcs_exists userid server_var(wcs_scuserid)
  es es_xif (server_var(wcs_exists) = 1) do
  {
    // reset all to 0
    es es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) player_attacker 0
    es es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) player_victim 0
    es es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) player_death 0
    es es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) player_spawn 0
    es es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) player_say 0
    //ulti_immunity
    es_xsetinfo wcs_counter 1
    es es_xkeygetvalue wcs_race "WCSuserdata" server_var(wcs_scuserid) "race"
    es es_xkeygetvalue wcs_numberofskills "WCSraces" server_var(wcs_race) "numberofskills"
    es es_xif (server_var(wcs_debug) = 1) then profile begin skillcheck_a
    es es_xif (server_var(wcs_numberofskills) != 0) then while "server_var(wcs_counter) <= server_var(wcs_numberofskills)" "es es_xformat wcs_skillnumber skill_%1 server_var(wcs_counter);es es_xkeygetvalue wcs_skill WCSuserdata server_var(wcs_scuserid) server_var(wcs_skillnumber);es es_xkeygetvalue wcs_skilltype WCSraces server_var(wcs_race) skillcfg;es es_xtoken wcs_skilltype server_var(wcs_skilltype) server_var(wcs_counter) |;es es_xkeygetvalue wcs_tmp WCSuserdata server_var(wcs_scuserid) server_var(wcs_skilltype);es es_xif (server_var(wcs_skill) > 0) then es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) server_var(wcs_skilltype) 1;es es_xif (server_var(wcs_skill) = 0) then es_xif (server_var(wcs_tmp) = 0) then es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) server_var(wcs_skilltype) 0;es_xmath wcs_counter + 1"
    es es_xif (server_var(wcs_debug) = 1) then profile end skillcheck_a
    es es_xkeycreate WCSpha event_var(userid)
    es es_xkeycreate WCSphv event_var(userid)
    es es_xkeycreate WCSpd event_var(userid)
    es es_xkeycreate WCSps event_var(userid)
    es es_xkeycreate WCSpsay event_var(userid)
    es_xsetinfo wcs_counter 1
    es_xsetinfo wcs_itemactivate 0
    es es_xif (server_var(wcs_debug) = 1) then profile begin skillcheck_b
    while "server_var(wcs_counter) <= 5" "es_xdoblock wcs/WCSfunctions/WCSskills/wcs_skillcheck_b;es_xmath wcs_counter + 1;es es_xif (server_var(wcs_activate) = 1) then es_xsetinfo wcs_itemactivate 1"
    es es_xkeysetvalue WCSuserdata server_var(wcs_scuserid) "itemactivate" server_var(wcs_itemactivate)
    es es_xif (server_var(wcs_debug) = 1) then profile end skillcheck_b
  }
  es es_xif (server_var(wcs_debug) = 1) then profile end skillcheck
}

block wcs_skillcheck_a
{
	es es_xformat wcs_skillnumber "skill_%1" server_var(wcs_counter)
	es es_xkeygetvalue wcs_skill "WCSuserdata" server_var(wcs_scuserid) server_var(wcs_skillnumber)
	es es_xkeygetvalue wcs_skilltype "WCSraces" server_var(wcs_race) "skillcfg"
	es es_xtoken wcs_skilltype server_var(wcs_skilltype) server_var(wcs_counter) "|"
	es es_xkeygetvalue wcs_tmp "WCSuserdata" server_var(wcs_scuserid) server_var(wcs_skilltype)
	es es_xif (server_var(wcs_skill) > 0) then es_xkeysetvalue "WCSuserdata" server_var(wcs_scuserid) server_var(wcs_skilltype) "1"
	es es_xif (server_var(wcs_skill) = 0) then es_xif (server_var(wcs_tmp) = "0") then es_xkeysetvalue "WCSuserdata" server_var(wcs_scuserid) server_var(wcs_skilltype) "0"
}

block wcs_skillcheck_b
{
  es_xsetinfo wcs_activate 0
  es es_xtoken wcs_shopcat server_var(wcs_eventarray1) server_var(wcs_counter) "|"
  es es_xtoken wcs_eventcat server_var(wcs_eventarray2) server_var(wcs_counter) "|"
  es es_xkeygetvalue wcs_tmp server_var(wcs_shopcat) server_var(wcs_scuserid) "icmd1"
  es es_xstrlen wcs_strlen server_var(wcs_tmp)
  es es_xif (server_var(wcs_strlen) > 1) then es_xsetinfo wcs_activate 1
  es es_xkeygetvalue wcs_tmp server_var(wcs_shopcat) server_var(wcs_scuserid) "icmd2"
  es es_xstrlen wcs_strlen server_var(wcs_tmp)
  es es_xif (server_var(wcs_strlen) > 1) then es_xsetinfo wcs_activate 1
  es es_xkeygetvalue wcs_tmp server_var(wcs_shopcat) server_var(wcs_scuserid) "icmd3"
  es es_xstrlen wcs_strlen server_var(wcs_tmp)
  es es_xif (server_var(wcs_strlen) > 1) then es_xsetinfo wcs_activate 1
  es es_xkeygetvalue wcs_tmp "WCSuserdata" server_var(wcs_scuserid) server_var(wcs_eventcat)
  es es_xif (server_var(wcs_activate) = "1") then es_xkeysetvalue "WCSuserdata" server_var(wcs_scuserid) server_var(wcs_eventcat) "1"
  es es_xif (server_var(wcs_activate) = "0") then es_xif (server_var(wcs_tmp) = "0") then es_xkeysetvalue "WCSuserdata" server_var(wcs_scuserid) server_var(wcs_eventcat) "0"
}

block wcs_deathhandle2
{
  es_xsetinfo wcs_userid 0
  es_xgetargv wcs_userid 1
	// remove custom item events
	es es_xexists wcs_exists key WCSpha server_var(wcs_userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSpha server_var(wcs_userid)
  es es_xexists wcs_exists key WCSphv server_var(wcs_userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSphv server_var(wcs_userid)
  es es_xexists wcs_exists key WCSpd server_var(wcs_userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSpd server_var(wcs_userid)
  es es_xexists wcs_exists key WCSps server_var(wcs_userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSps server_var(wcs_userid)
  es es_xexists wcs_exists key WCSpsay server_var(wcs_userid)
  es es_xif (server_var(wcs_exists) = 1) then es_xkeydelete WCSpsay server_var(wcs_userid)
	es es_xkeycreate WCSpha server_var(wcs_userid)
  es es_xkeycreate WCSphv server_var(wcs_userid)
  es es_xkeycreate WCSpd server_var(wcs_userid)
  es es_xkeycreate WCSps server_var(wcs_userid)
  es es_xkeycreate WCSpsay server_var(wcs_userid)
  // clear item amount
  es es_xforeachval wcs_val in WCSuserdata server_var(wcs_userid) "es es_xif (item_ in server_var(wcs_val)) then es_xkeysetvalue WCSuserdata server_var(wcs_userid) server_var(wcs_val) 0"
}

block wcs_checkskills
{
es es_xif (server_var(wcs_debug) = 1) then profile begin checkskill
  // custom command
  es_xsetinfo wcs_userid 0
  es_xsetinfo wcs_checkskill 0
  es_xgetargv wcs_userid 1
  es_xgetargv wcs_checkskill 2
  es es_xexists wcs_exists userid server_var(wcs_userid)
  es es_xif (server_var(wcs_exists) = 1) do
  {
    es es_xif (server_var(wcs_checkskill) in "player_death player_attacker player_victim player_spawn player_say player_ultimate") do
    {
      es es_xexists wcs_exists key "WCSuserdata" server_var(wcs_userid)
      es es_xif (server_var(wcs_exists) = 1) do
      {
        es_xsetinfo wcs_race 0
        es es_xkeygetvalue wcs_race "WCSuserdata" server_var(wcs_userid) "race"
        es_xsetinfo wcs_level 0
        es_xsetinfo wcs_skill 0
        es_xsetinfo wcs_skillcfg 0
        es_xsetinfo wcs_skill_setting 0
        es_xsetinfo wcs_skill_cmd 0
        es_xsetinfo wcs_skill_sfx 0
        // new try
        es_xsetinfo wcs_numberofskills 0
        es_xsetinfo wcs_val 0
        es_xsetinfo wcs_skilltype 0
        es_xsetinfo wcs_scounter 1
        es es_xkeygetvalue wcs_numberofskills WCSraces server_var(wcs_race) "numberofskills"
        es es_xif (server_var(wcs_numberofskills) != "0") then while "server_var(wcs_scounter) <= server_var(wcs_numberofskills)" "es es_xformat wcs_val skill_%1 server_var(wcs_scounter);es es_xkeygetvalue wcs_skilltype WCSraces server_var(wcs_race) skillcfg;es es_xtoken wcs_skilltype server_var(wcs_skilltype) server_var(wcs_scounter) |;es es_xif (server_var(wcs_skilltype) = server_var(wcs_checkskill)) then es_xdoblock wcs/WCSfunctions/WCSskills/wcs_execskills;es_xmath wcs_scounter + 1"
      }
    }
  }
es es_xif (server_var(wcs_debug) = 1) then profile end checkskill
}

block wcs_execskills
{
es es_xif (server_var(wcs_debug) = 1) then profile begin execskill
  es es_xexists wcs_exists userid server_var(wcs_userid)
  // no skills while spectator/invalid team
  es_xsetinfo wcs_team 0
  es es_xgetplayerteam wcs_team server_var(wcs_userid)
  es es_xif (server_var(wcs_team) <= 1) then es_xsetinfo wcs_exists "0"
  es es_xif (server_var(wcs_exists) = 1) do
  {
    es es_xif (server_var(wcs_val) != "0") do
    {
      // get skill level
      es_xsetinfo wcs_level 0
      es es_xkeygetvalue wcs_level "WCSuserdata" server_var(wcs_userid) server_var(wcs_val)
      // if level > 0 get the config type
      es es_xif (server_var(wcs_level) > 0) do
      {
        // raceX_skillY -> get Y (skill number)
        //es es_xtoken wcs_skill server_var(wcs_val) 2 "skill"
        es es_xsetinfo wcs_skill server_var(wcs_scounter)
        // check if the config is equal
        es es_xkeygetvalue wcs_skillcfg "WCSraces" server_var(wcs_race) "skillcfg"
        es es_xtoken wcs_skillcfg server_var(wcs_skillcfg) server_var(wcs_skill) "|"
        es es_xif (server_var(wcs_skillcfg) = server_var(wcs_checkskill)) do
        {
es es_xif (server_var(wcs_debug) = "1") then echo running race server_var(wcs_race) -> skill server_var(wcs_skill) 
          // get the settings
          es es_xformat wcs_skill_setting "skill%1_setting" server_var(wcs_skill)
          es es_xformat wcs_skill_cmd "skill%1_cmd" server_var(wcs_skill)
          es es_xformat wcs_skill_sfx "skill%1_sfx" server_var(wcs_skill)
          es es_xkeygetvalue wcs_skill_setting WCSraces server_var(wcs_race) server_var(wcs_skill_setting)
          es es_xtoken wcs_skill_setting server_var(wcs_skill_setting) server_var(wcs_level) "|"
          es es_xkeygetvalue wcs_skill_cmd WCSraces server_var(wcs_race) server_var(wcs_skill_cmd)
          es es_xkeygetvalue wcs_skill_sfx WCSraces server_var(wcs_race) server_var(wcs_skill_sfx)
          // roll the dice
          es_xrand wcs_dice 1 100
es es_xif (server_var(wcs_debug) = "1") then echo WCS : Dice rolled server_var(wcs_dice)
          es es_xstrlen wcs_strlen server_var(wcs_skill_setting)
          // execute the skill
          es es_xif (server_var(wcs_strlen) > 1) do
          {
            es alias wcs_cmd server_var(wcs_skill_setting)
            wcs_cmd
          }
          es es_xstrlen wcs_strlen server_var(wcs_skill_sfx)
          es es_xif (server_var(wcs_strlen) > 1) do
          {
            es es_xif (server_var(wcs_graphicfx) = "1") do
            {
              es_xsetinfo wcs_dead "1"
              es es_xgetplayerprop wcs_dead server_var(wcs_userid) "CCSPlayer.baseclass.pl.deadflag"
              es es_xif (server_var(wcs_dead) = "0") do
              {
                es alias wcs_cmd server_var(wcs_skill_sfx)
                wcs_cmd
              }
            }
          }
          es es_xstrlen wcs_strlen server_var(wcs_skill_cmd)
          es es_xif (server_var(wcs_strlen) > 1) do
          {
            es alias wcs_cmd server_var(wcs_skill_cmd)
            es es_xif (server_var(wcs_graphicfx) = "1") then es_xif (server_var(wcs_cfg_skillflash) = "1") then est_fade server_var(wcs_userid) 0 0.3 0 255 255 255 100
            wcs_cmd
          }
        }
      }
    }
  }
es es_xif (server_var(wcs_debug) = 1) then profile end execskill
}

block wcs_+ggun
    {
     es_getcmduserid wcs_uid
     es_keygetvalue wcs_tmp WCSuserdata server_var(wcs_uid) allow_ggun
     ifx true(wcs_tmp) do
    { 
        es_xset gg_fuse 1
	es_keygroupcreate gravitygun
	es_keygroupcreate gg_objects
        es_xset pu_userid 0
	es_getcmduserid pu_userid 
	es_xset time_hold 0
	es_gettime time_hold
	es_xset pl_x 0
	es_xset pl_y 0
	es_xset pl_z 0
	es_xset player_vector 0
	es_xset player_view 0
	es_xset this_object 0
	es_xset is_player 0	
	es_xset check_prop 0
        es_xset props 0
	es_xset prop_index 0
        es es_keysetvalue gravitygun server_var(pu_userid) timestart server_var(time_hold)
        es es_keycreate gravitygun event_var(userid)
 	es_createentitylist list_of_props prop_physics_multiplayer
	es_foreachkey prop_index in list_of_props "es_doblock wcs/WCSfunctions/WCSskills/wcs_props"
	es_keygroupdelete list_of_props
 	es_createentitylist list_of_props prop_dynamic
	es_foreachkey prop_index in list_of_props "es_doblock wcs/WCSfunctions/WCSskills/wcs_props"
	es_keygroupdelete list_of_props
 	es_createentitylist list_of_props prop_physics
	es_foreachkey prop_index in list_of_props "es_doblock wcs/WCSfunctions/WCSskills/wcs_props"
	es_keygroupdelete list_of_props
	es_xset keygroup_gg_exist 0
	es_exists keygroup_gg_exist keygroup gg_objects
	es_keygroupcreate gg_objects
	es est_GetViewPlayer server_var(pu_userid) is_player
	if (server_var(is_player) = 0) do
	{
		es est_GetViewProp server_var(pu_userid) this_object
		es_formatv check_prop "prop%1s" this_object
		es_xset prop_exists 0
		es_exists prop_exists key gg_objects server_var(check_prop)
             ifx false(prop_exists) do
		         {
             if (server_var(check_prop) in server_var(props)) do
		         {
		         if (server_var(this_object) > 0) do
		         {
			es_getplayerlocation pl_x pl_y pl_z server_var(pu_userid)
      			es_xmath pl_z + 60
      			es_createvectorstring player_vector server_var(pl_x) server_var(pl_y) server_var(pl_z)
      			es playerget viewvector player_view server_var(pu_userid)
      			es_splitvectorstring pl_x pl_y pl_z server_var(player_view)
      			es est_entteleport server_var(this_object) server_var(pl_x) server_var(pl_y) server_var(pl_z)
			es_emitsound entity server_var(this_object) weapons/physcannon/physcannon_charge.wav 1.0 0.3
			es es_keysetvalue gravitygun server_var(pu_userid) current_object server_var(this_object)
			es es_keysetvalue gravitygun server_var(pu_userid) checked_prop server_var(check_prop)
				es_xset model_name 0
				es_format model_name "model_%1" server_var(this_object)
				es est_setentname server_var(this_object) server_var(model_name)
				es_xset model_user 0
				es_xset model_user2 0
				es_xformatv model_user "targetname user%1" pu_userid
				es_xformatv model_user2 "user%1" pu_userid	
				es_xset model_vector 0
				es_xformatv model_vector "SetParentAttachmentMaintainOffset %1" player_view
				es_xstring model_vector replace "," " "
				es_fire server_var(pu_userid) !self addoutput server_var(model_user)
				es_fire server_var(pu_userid) server_var(model_name)  setparent server_var(model_user2)
				es_fire server_var(pu_userid) server_var(model_name)  server_var(model_vector)
				es es_keycreate gg_objects server_var(check_prop)
			      }
                       }
	       }
                else es_tell server_var(pu_userid) #multi #green[GravityGun] #lightgreenObject cannot be picked up
	}
  }
}
block wcs_-ggun
{
 es_getcmduserid wcs_uid
 es_keygetvalue wcs_tmp WCSuserdata server_var(wcs_uid) allow_ggun
 ifx true(wcs_tmp) do
{
 es_xset th_userid 0
 es_getcmduserid th_userid
 es_xset time_hold_end 0
 es_gettime time_hold_end
 es_xset p_time 0
 es es_keygetvalue p_time gravitygun server_var(th_userid) timestart
 es_math time_hold_end - server_var(p_time)
 if (server_var(time_hold_end) <= 1) then es_xset time_hold_end 1
 es_xset gravgun_power 500
 es_math gravgun_power multiply server_var(time_hold_end)	
 if (server_var(gravgun_power) >= 500) then es_xset gravgun_power 500
 es_xset push_x 0
 es_xset push_y 0
 es_xset push_z 0
 es est_GetViewCoord server_var(th_userid) push_x push_y push_z
 es_math push_z + 100
 es_xset p_check 0
 es_xset p_object 0
 es es_keygetvalue p_check gravitygun server_var(th_userid) checked_prop
 es es_keygetvalue p_object gravitygun server_var(th_userid) current_object
 if (server_var(p_check) in server_var(props)) do
 {
 if (server_var(p_object) > 0) do
 {
 es_xset model_owner 0
 es_getplayerhandle model_owner server_var(th_userid)) 
 es es_setindexprop server_var(p_object) CBaseEntity.moveparent 0
 es es_setindexprop server_var(p_object) CBaseEntity.m_hOwnerEntity server_var(model_owner)
 es_getplayerlocation pl_x pl_y pl_z server_var(th_userid)
 es_xmath pl_z + 60
 es est_entteleport server_var(p_object) server_var(pl_x) server_var(pl_y) server_var(pl_z)
 es_xset gg_temp 0
 es est_entPushTo server_var(p_object) server_var(push_x) server_var(push_y) server_var(push_z) server_var(gravgun_power)
 es_emitsound entity server_var(p_object) weapons/physcannon/superphys_launch3.wav 1.0 0.3
 es_format gg_temp "gg%1" server_var(th_userid)
 es est_setentname server_var(p_object) server_var(gg_temp)
 es_fire server_var(th_userid) server_var(gg_temp) addoutput "spawnflags 256"
 es_fire server_var(th_userid) server_var(gg_temp) addoutput "physdamagescale 9999"
 es_fire server_var(th_userid) server_var(gg_temp) addoutput "exploderadius 400"
 es_fire server_var(th_userid) server_var(gg_temp) addoutput "explodedamage 200"
 es_delayed server_var(gg_fuse) es_fire server_var(th_userid) server_var(gg_temp) addoutput "onhealthchanged !self,break"
 es_delayed server_var(gg_fuse) es_fire server_var(th_userid) server_var(gg_temp) addoutput "onhealthchanged !self,kill,,1.0"
}
 }
 es es_keysetvalue gravitygun server_var(th_userid) current_object 0
 es es_keysetvalue gravitygun server_var(th_userid) checked_prop 0
 }
}
block wcs_props
 {
 es_formatv props "%1, prop%2s" props prop_index
 }

block wcs_+fly
{
  es_getcmduserid wcs_uid
  es_keygetvalue wcs_tmp WCSuserdata server_var(wcs_uid) allow_fly
  ifx true(wcs_tmp) do
{       
es est_jetpack server_var(wcs_uid) 1 
es est_speed server_var(wcs_uid) server_var(wcs_fly)
es es_xgetplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_uid)
es_xmath wcs_z1 + 15
es est_effect 11 #a 0 sprites/fire.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 2 server_var(wcs_fire) 255
es_xmath wcs_y1 + 50
es est_effect 11 #a 0 sprites/fire.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 2 server_var(wcs_fire) 255
es est_setplayercolor server_var(wcs_uid) 243 243 43 server_var(wcs_invis) 1
es est_playplayer server_var(wcs_uid) weapons/mortar/mortar_explode3.wav
es est_getprimary wcs_tmp1 server_var(wcs_uid)
es est_getsecondary wcs_tmp2 server_var(wcs_uid)
es es_delayed 0.1 est_removeweapon server_var(wcs_uid) 1
es es_delayed 0.1 est_removeweapon server_var(wcs_uid) 2
 }
}

block wcs_-fly
{
  es_getcmduserid wcs_uid
  es_keygetvalue wcs_tmp WCSuserdata server_var(wcs_uid) allow_fly
  ifx true(wcs_tmp) do
{ 
es est_jetpack server_var(wcs_uid) 0
es est_speed server_var(wcs_uid) 1
es est_setplayercolor server_var(wcs_uid) 255 255 255 255 1
es est_give server_var(wcs_uid) server_var(wcs_tmp1)
es est_give server_var(wcs_uid) server_var(wcs_tmp2)
es est_playplayer server_var(wcs_uid) weapons/mortar/mortar_explode1.wav
es es_xgetplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_uid)
es_xmath wcs_z1 + 15
es est_effect 11 #a 0 sprites/fire.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 1 0.5 255
es_xmath wcs_y1 + 50
es est_effect 11 #a 0 sprites/fire.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) 1 0.5 255
 }
}

block wcs_+laser
{
  es_getcmduserid wcs_uid
  es_keygetvalue wcs_tmp WCSuserdata server_var(wcs_uid) allow_laser
  ifx true(wcs_tmp) do
{
es es_xgetplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid)
es est_GetViewCoord server_var(wcs_userid) wcs_x2 wcs_y2 wcs_z2
es est_effect 3 #a 0 sprites/purplelaser1.vmt server_var(wcs_x1) server_var(wcs_y1) server_var(wcs_z1) server_var(wcs_x2) server_var(wcs_y2) server_var(wcs_z2) 1 0.1 0.1 255 14 41 255
es est_effect 11 #a 3 sprites/glow1.vmt server_var(wcs_x2) server_var(wcs_y2) server_var(wcs_z2) 2 1 255
 }
}
block wcs_-laser
{
  es_getcmduserid wcs_uid
  es_keygetvalue wcs_tmp WCSuserdata server_var(wcs_uid) allow_laser
  ifx true(wcs_tmp) do
{
es es_xgetplayerlocation wcs_x1 wcs_y1 wcs_z1 server_var(wcs_userid)
es est_GetViewCoord server_var(wcs_userid) wcs_x2 wcs_y2 wcs_z2
 }
}
