Events.PlayerKeyInputCallback a_playerKeyInputEvent = null;
Events.PlayerKeyInputCallback b_playerKeyInputEvent = null;
Events.PlayerKeyInputCallback c_playerKeyInputEvent = null;
Events.PlayerKeyInputCallback d_playerKeyInputEvent = null;
Events.PlayerKeyInputCallback e_playerKeyInputEvent = null;
//Events.PlayerKeyInputCallback f_playerKeyInputEvent = null;
Events.PlayerKeyInputCallback h_playerKeyInputEvent = null;
Events.PlayerKeyInputCallback i_playerKeyInputEvent = null;
 
public void OnStartup(){
    a_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput);
    b_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput1);
    c_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput2);
    d_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput3);
    e_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput4);
    //f_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput5);
    h_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput6);
    i_playerKeyInputEvent = Events.PlayerKeyInputCallback.Start(OnPlayerKeyInput7);
 }

public void OnPlayerKeyInput(IPlayer player, VirtualKeyInfo[] keyEvents) {
    for (int i = 0; i < keyEvents.Length; i ++) {

			if(player.IsWalking){
			if (keyEvents[i].Key == VirtualKey.DRAW_MELEE) {
			player.SetInputEnabled(false);
			player.AddCommand(new PlayerCommand(PlayerCommandType.Fall));
			IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			Time.SetIntervalTime(10);
			Time.SetRepeatCount(1);
			Time.SetScriptMethod("Reset");
			Time.Trigger();

				}
        }
    }
}

public void OnPlayerKeyInput1(IPlayer player, VirtualKeyInfo[] keyEvents) {
    for (int i = 0; i < keyEvents.Length; i ++) {

			if(player.IsWalking){
			if (keyEvents[i].Key == VirtualKey.DRAW_SPECIAL) {
			player.SetInputEnabled(false);
			player.AddCommand(new PlayerCommand(PlayerCommandType.DeathKneelInfinite));
			IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			Time.SetIntervalTime(1600);
			Time.SetRepeatCount(1);
			Time.SetScriptMethod("Reset");
			Time.Trigger();

				}
        }
    }
}

 public void OnPlayerKeyInput2(IPlayer player, VirtualKeyInfo[] keyEvents) {
    for (int i = 0; i < keyEvents.Length; i ++) {

			if(player.IsWalking){
			if (keyEvents[i].Key == VirtualKey.DRAW_GRENADE) {
			player.SetInputEnabled(false);
			player.AddCommand(new PlayerCommand(PlayerCommandType.StaggerInfinite));
			IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			Time.SetIntervalTime(10);
			Time.SetRepeatCount(1);
			Time.SetScriptMethod("Reset");
			Time.Trigger();

				}
        }
    }
}

 public void OnPlayerKeyInput3(IPlayer player, VirtualKeyInfo[] keyEvents) {
    for (int i = 0; i < keyEvents.Length; i ++){

			if(player.IsStaggering){
			if (keyEvents[i].Key == VirtualKey.DRAW_MELEE) {
			player.SetInputEnabled(false);
			player.AddCommand(new PlayerCommand(PlayerCommandType.StopStagger));
			IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			Time.SetIntervalTime(1);
			Time.SetRepeatCount(1);
			Time.SetScriptMethod("Reset");
			Time.Trigger();
				}
        }
    }
}

 public void OnPlayerKeyInput4(IPlayer player, VirtualKeyInfo[] keyEvents) {
    for (int i = 0; i < keyEvents.Length; i ++) 
    {
			if(player.IsDeathKneeling){
			if (keyEvents[i].Key == VirtualKey.DRAW_MELEE) {
			player.SetInputEnabled(false);
			player.AddCommand(new PlayerCommand(PlayerCommandType.StopDeathKneel));
			IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			Time.SetIntervalTime(1);
			Time.SetRepeatCount(1);
			Time.SetScriptMethod("Reset");
			Time.Trigger();
				}
        }
    }
}

 //public void OnPlayerKeyInput5(IPlayer player, VirtualKeyInfo[] keyEvents) {
    //for (int i = 0; i < keyEvents.Length; i ++) 
    //{
			//if(player.IsWalking){
			//if (keyEvents[i].Key == VirtualKey.GRAB) {
			//player.SetInputEnabled(false);
			//player.AddCommand(new PlayerCommand(PlayerCommandType.GrabInfinite));
			//IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			//Time.SetIntervalTime(300);
			//Time.SetRepeatCount(1);
			//Time.SetScriptMethod("Reset");
			//Time.Trigger();
				//}
        //}
    //}
//}

 public void OnPlayerKeyInput6(IPlayer player, VirtualKeyInfo[] keyEvents) {
    for (int i = 0; i < keyEvents.Length; i ++) 
    {
		if(player.IsWalking){
		if (keyEvents[i].Key == VirtualKey.BLOCK) {
			float minx = 2f;
			float maxx = 1f;
			if( player.FacingDirection == 1 ) {
				minx = -2f;
				maxx = 1f;
			} else {
				minx = -2f;
				maxx = 1f;
			}
			
			Vector2 plyPos = player.GetWorldPosition();
			Vector2 minPos = plyPos + new Vector2( minx, -2 );
			Vector2 maxPos = plyPos + new Vector2( maxx, 1 );

			foreach( IObject obj in Game.GetObjectsByArea( new Area(minPos, maxPos) ) ) {
				if( obj is IPlayer && player == obj ) continue;

				if( player.IsBlocking && obj.Name.Contains("Wpn")) {
					float mass = 1f;
					if (obj is IPlayer) mass = 1f;

					obj.SetLinearVelocity(obj.GetLinearVelocity() + new Vector2(0,3));
               obj.TrackAsMissile(true); 
					}
				}
			}
		}
	}
}

 public void OnPlayerKeyInput7(IPlayer player, VirtualKeyInfo[] keyEvents) {
    for (int i = 0; i < keyEvents.Length; i ++) 
    {
			if(player.IsDeathKneeling){
			if (keyEvents[i].Key == VirtualKey.DRAW_HANDGUN) {
			player.SetInputEnabled(false);
			player.AddCommand(new PlayerCommand(PlayerCommandType.StopDeathKneel));
			IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			Time.SetIntervalTime(10);
			Time.SetRepeatCount(1);
			Time.SetScriptMethod("Start");
			Time.Trigger();
				}
        }
    }
}

public void Start(TriggerArgs args){
foreach(IPlayer player in Game.GetPlayers()){
player.AddCommand(new PlayerCommand(PlayerCommandType.DeathKneelInfinite));
			IObjectTimerTrigger Time = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
			Time.SetIntervalTime(300);
			Time.SetRepeatCount(1);
			Time.SetScriptMethod("Reset");
			Time.Trigger();
	}
}

public void Reset(TriggerArgs args){
foreach(IPlayer ply in Game.GetPlayers()){
ply.SetInputEnabled(true);
ply.ClearCommandQueue();
(args.Caller as IObject).Remove();
	}
}