// very important stuff
ACTOR ActionFragGrenade : inventory { }
ACTOR ActionFlashbang : inventory { }
actor ActionRemoteC4 : inventory { }
ACTOR ActionReload : inventory { }
ACTOR ActionMeleeAttack : inventory { }
ACTOR SelectAnimation : inventory { }
ACTOR UseAnimation : inventory { }
// xindage  can i have a place here too?
ACTOR Hasgrenadeon : inventory { }
// ============================================================================
// Base class for weapons
actor AOWWeapon : Weapon {
	//$Category Weapons
	+NO_AUTO_SWITCH
	+NOAUTOAIM
	Weapon.Kickback 50
	weapon.selectionorder 9999
	states {
	DeselectDie:
		TNT1 A 0 A_Lower
		TNT1 A 1 A_Lower
		loop
	Flash:
		TNT1 A 2 A_Light1
		TNT1 A 2 A_Light2
		TNT1 A 0 A_Light0
		stop
	LightDone:
		TNT1 A 0 A_Light0
		Stop
	UseFragGrenade:
		TNT1 A 0 A_TakeInventory ("StealthFire", 1)
		TNT1 A 0 ACS_ExecuteAlways (SC_STEALTH, 0, STEALTH_FORCEOFF)
		FRAG BCD 1
		FRAG EFG 2
		FRAG H 2 A_PlaySound ("frag/pinpull", CHAN_WEAPON)
		FRAG I 2
		FRAG J 2 A_GiveInventory ("Hasgrenadeon", 1)
		FRAG KLMNOPQR 1
		TNT1 A 3 	
		TNT1 A 7
		FSH1 A 1
		TNT1 A 0 A_GiveInventory ("UseAnimation", 1)
		FSH1 A 0 A_PlaySound ("frag/throw", CHAN_WEAPON)
		FSH1 A 0 A_FireCustomMissile ("FragGrenadeThrown5",-1,0,10,5)
		TNT1 A 0 A_TakeInventory("FragGrenadeAmmo",1)
		TNT1 A 0 A_TakeInventory("Hasgrenadeon",1)
        FSH2 BCDEFGH 1
		TNT1 A 0 A_TakeInventory("ActionFragGrenade",1)
		FSH2 I 1 A_JumpIfInventory("FragGrenadeAmmo",1,2)
		TNT1 A 0 A_TakeInventory("FragGrenade")
		TNT1 A 0
		goto SelectAnim
	UseFlashbang:
		TNT1 A 0 A_TakeInventory ("StealthFire", 1)
		TNT1 A 0 ACS_ExecuteAlways (SC_STEALTH, 0, STEALTH_FORCEOFF)
        FLSH BCDEFGHIJKLMN 1
		FLSH OPQR 1
		FSH1 A 1
		TNT1 A 0 A_GiveInventory ("UseAnimation", 1)
        TNT1 A 0 A_PlaySound("flash/flashthrow", CHAN_WEAPON)		
		TNT1 A 0 A_FireCustomMissile("FlashbangThrown5",-1,0,10,5)		
        TNT1 A 0 A_TakeInventory("FlashbangAmmo",1)
        FSH2 BCDEFGH 1
		TNT1 A 0 A_TakeInventory("ActionFlashbang",1)
		FSH2 I 1 A_JumpIfInventory("FlashbangAmmo",1,2)
		TNT1 A 0 A_TakeInventory("Flashbang")
		TNT1 A 0
		goto SelectAnim
	UseRemoteC4:
		TNT1 A 0 A_TakeInventory ("StealthFire", 1)
		TNT1 A 0 ACS_ExecuteAlways (SC_STEALTH, 0, STEALTH_FORCEOFF)
		RC4A ABCDEFGH 1
		RC4A I 2
		TNT1 A 0 A_GiveInventory ("UseAnimation", 1)
		RC4A J 2 A_PlaySound ("c4/remote2", CHAN_WEAPON)
		RC4A I 4 A_GiveInventory ("C4DetonateCheck", 1)
		RC4A H 6 A_TakeInventory("ActionRemoteC4",1)
		RC4A G 1 A_TakeInventory ("C4DetonateCheck", 666)
		RC4A FEDCB 1
		RC4A A 1 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		goto SelectAnim
	UseMeleeAttack:
		TNT1 A 0 A_TakeInventory ("StealthFire", 1)
		TNT1 A 0 ACS_ExecuteAlways (SC_STEALTH, 0, STEALTH_FORCEOFF)
		TNT1 A 0 A_JumpIfInventory ("Lightsaber",1,"UseLightsaberAttack")
		TNT1 A 0 A_JumpIfInventory ("Knife",1,"UseKnifeAttack")
		PUN2 ABC 1
		TNT1 A 0 A_GiveInventory ("UseAnimation", 1)
        TNT1 A 0 A_PlaySound("weapons/gswing")
		TNT1 A 0 A_CustomPunch(60,1,0,"FistPuff",96)
		PUN2 DEF 1 A_SetAngle(angle-1)
		PUN2 GHI 1 A_SetAngle(angle+1)
		PUN2 JK 1
		TNT1 A 0 A_TakeInventory("ActionMeleeAttack",1)
		goto SelectAnim
	UseKnifeAttack:	
		KNIF B 1 offset (-16, 52)
		KNIF B 1 offset (-40, 40)
		KNIF B 1 offset (-64, 30)
		KNIF B 1 offset (-88, 22)
		KNIF B 1 offset (-112, 16)
		KNIF B 1 offset (-136, 12)
		KNIF C 1 offset (-232, -2)
		KNIF C 1 offset (-224, -4)
		KNIF C 1 offset (-256, -6)
		KNIF C 1 offset (-262, -7)
		KNIF C 1 offset (-268, -8)
        TNT1 A 0 A_GiveInventory ("UseAnimation", 1)
		KNIF C 0 A_PlayWeaponSound("Weapons/KnifeSwing")
		KNIF C 0 A_CustomPunch (8, 1, 0, "KnifePuff",100)
		KNIF C 1 offset (-180, -14)
		KNIF C 0 A_CustomPunch (16, 1, 0, "KnifePuff",100)
		KNIF C 1 offset (-92, -18)
		KNIF C 0 A_CustomPunch (24, 1, 0, "KnifePuff",100)
		KNIF C 1 offset (-4, -14)
		KNIF C 0 A_CustomPunch (32, 1, 0, "KnifePuff",100)
		KNIF C 1 offset (84, -10)
		KNIF C 0 A_CustomPunch (40, 1, 0, "KnifePuff",100)
		KNIF C 1 offset (116, -6)
		KNIF C 1 offset (148, -2)
		KNIF C 1 offset (164, 2)
		KNIF C 1 offset (172, 6)
		KNIF C 1 offset (176, 8)
		KNIF C 1 offset (178, 12)
		KNIF C 1 offset (176, 16)
		KNIF C 1 offset (168, 20)
		KNIF C 1 offset (160, 24)
		KNIF C 1 offset (144, 28)
		KNIF C 1 offset (128, 32)
		TNT1 A 0 offset (0,0)
		TNT1 A 0 A_TakeInventory("ActionMeleeAttack",1)
		goto SelectAnim
	UseLightsaberAttack:
	    TNT1 A 0 A_JumpIfInventory("IsBlue",1,"UseLightsaberAttack.Blue")
		ZSRR A 1 Bright
		ZSAR AB 1 Bright
		TNT1 A 0 A_GiveInventory ("UseAnimation", 1)
		TNT1 A 0 A_Playsound("weapons/sattack3", CHAN_WEAPON, 1) 
		TNT1 A 0 A_CustomPunch(111,1,0,"SaberSlashPuff",128)	
		ZSAR CDE 1 Bright
		TNT1 A 0 A_CustomPunch(111,1,0,"SaberSlashPuff",128)
		ZSAR FGH 1 Bright
		TNT1 A 0 A_CustomPunch(111,1,0,"SaberSlashPuff",128)
		ZSAR IJ 1 Bright
		TNT1 A 10 A_TakeInventory("ActionMeleeAttack",1)
		goto SelectAnim
	UseLightsaberAttack.Blue:
		ZSRB A 1 Bright
		ZSAB AB 1 Bright
		TNT1 A 0 A_GiveInventory ("UseAnimation", 1)
		TNT1 A 0 A_Playsound("weapons/sattack3", CHAN_WEAPON, 1) 
		TNT1 A 0 A_CustomPunch(111,1,0,"SaberSlashPuffBlue",128)
		ZSAB CDE 1 Bright
		TNT1 A 0 A_CustomPunch(111,1,0,"SaberSlashPuffBlue",128)
		ZSAB FGH 1 Bright
		TNT1 A 0 A_CustomPunch(111,1,0,"SaberSlashPuffBlue",128)
		ZSAB IJ 1 Bright
		TNT1 A 10 A_TakeInventory("ActionMeleeAttack",1)
		goto SelectAnim
	SelectAnim:
	    TNT1 A 0 A_GiveInventory ("SelectAnimation", 1)
		TNT1 A 0 A_Raise
		Loop
	}
}

// =============================================================================
// Base class for morphs
actor AOWMorph : PowerMorph {
	PowerMorph.MorphStyle (MRF_FULLHEALTH|MRF_ADDSTAMINA|MRF_NEWTIDBEHAVIOUR|MRF_WHENINVULNERABLE)
}

// =============================================================================
// Base class for powerups
actor PermanentPowerup : PowerupGiver {
	+AUTOACTIVATE
	Inventory.MaxAmount 0
	Powerup.Type "Null"
	Powerup.Duration 0x7FFFFFFF
	states {
	Spawn:
		TNT1 A 0
		stop
	}
}

// =============================================================================
// Base class for inventory items, providing a few extra states and +INVBAR
actor InventoryItem : CustomInventory {
	+INVBAR
	Inventory.MaxAmount 1
	States {
	Spawn:
		TNT1 A 0
		stop
	Use.Mech:
		TNT1 A 0 ACS_ExecuteAlways (697, 0)
		fail
	Failure:
		TNT1 A 0
		fail
	Destealth:
		TNT1 A 0 ACS_ExecuteAlways (SC_STEALTH, 0, STEALTH_FORCEOFF)
		fail
	}
}

// ============================================================================
actor Cooldown : PowerProtection {
	Powerup.Duration 1
	DamageFactor "normal", 1
}
