actor JewelSatelliteWepSH : BaseMM8BDMWep
{
+INVENTORY.RESTRICTABSOLUTELY Inventory.RestrictedTo megamans
//$Category MM8BDM-Weapons
//$Title Jewel Satellite
Weapon.Ammouse 28
Weapon.AmmoGive 0
Weapon.SlotNumber 7
Obituary "$OB_JEWELSATELLITE"
Tag "$TAG_JEWELSATELLITE"
Inventory.Pickupmessage "$PU_JEWELSATELLITE"
weapon.ammotype "JewelSatelliteAmmo"
inventory.icon "XR9DICON"
States
{
SpawnLoop:
X_R9 D 1
loop
Ready:
JEWE J 0 A_JumpIfInventory("EquippedJewelOnce",1,"Ready2")
JEWE J 0 A_GiveInventory("JewelSatelliteAmmo",28)
JEWE J 0 A_GiveInventory("EquippedJewelOnce",1)
Ready2:
JEWE J 0 ACS_ExecuteAlways(998,0,190)
JEWE J 1 A_WeaponReady
Goto Ready2+1
Deselect:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Lower
JEWE J 1 A_Lower
loop
Select:
TNT1 AAAAAAAAAAAAAAAAAAAAAA 0 A_Raise
JEWE K 1 A_Raise
Loop
Fire:
JEWE J 0 A_JumpIfInventory("JewelEncaserTime",1,"NoAmmo")
JEWE J 0 A_JumpIfNoAmmo("NoAmmo")
JEWE J 0 A_TakeInventory("JewelSatelliteAmmo",28)
JEWE A 0 A_GiveInventory("JewelEncasePower",1)
JEWE M 0 A_GiveInventory("JewelEncaserTime", 525)
JEWE M 0 A_PlaySoundEx("weapon/jewelsatellite", "Weapon")
JEWE M 0 A_SpawnItemEx("JewelEncaserShield",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
JEWE M 0 A_SpawnItemEx("JewelEncaserShield2",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
JEWE M 0 A_GiveInventory("JewelEncaserSpawner",1)
JEWE KLMNOP 2
JEWE J 8
JEWE J 1 
goto Ready2+1
NoAmmo:
JEWE J 1 ACS_Execute(979,0)
goto Ready2+1
}
}
actor JewelEncaserWepSH : JewelSatelliteWepSH {+INVENTORY.RESTRICTABSOLUTELY Inventory.RestrictedTo megamans}
actor EquippedJewelOnce : OnceC {}

actor JewelEncaserTime : Inventory
{
inventory.amount 1
inventory.maxamount 525 //25 seconds.
}

actor JewelEncasePower : PowerProtection
{
Powerup.duration -5
damagefactor "Normal", 0.0
damagefactor "Crush", 1
damagefactor "Falling", 1
damagefactor "Fire", 1
damagefactor "Drowning", 1
damagefactor "Slime", 1
damagefactor "Ice", 1
damagefactor "Spiney", 1
}

actor JewelEncaserSpawner : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_SpawnItemEx("JewelEncaserWatcher")
stop
}
}

actor JewelEncaserWatcher
{
PROJECTILE
+NOINTERACTION
+DONTBLAST
states
{
Spawn:
TNT1 A 0
LoopingTime:
TNT1 A 0 A_SpawnItemEx("DuoChargeLight",8,-8,8)
TNT1 A 1 A_Warp(AAPTR_TARGET, 0, 0, 0, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
TNT1 A 0 A_JumpIfInTargetInventory("IsDead", 1, "Death")
TNT1 A 0 A_TakeFromTarget("JewelEncaserTime", 1)
TNT1 A 0 A_JumpIfInTargetInventory("JewelEncaserTime", 1, "LoopingTime")
Death:
TNT1 A 0 A_TakeInventory("JewelEncasePower",1)
stop}}


actor JewelEncaserShield
{
-COUNTKILL
Scale 2.25
Speed 0
Height 64
Radius 64
Health 275
painchance 256
painsound "misc/devilpain"
+MISSILE
+NOGRAVITY
+DONTSPLASH
+FLOORCLIP
+invulnerable
+GHOST
+DONTBLAST
+FORCEXYBILLBOARD
+NOCLIP
+NOBLOOD
+NOBLOODDECALS
+BRIGHT
+THRUGHOST
renderstyle "add"
Species "Survivor" +THRUSPECIES +MTHRUSPECIES

painchance 256
States
{
Spawn:
TNT1 A 0
TNT1 A 0 //A_GiveInventory("HealthScaled",1)
goto Warping
Warping:
JEWS S 0 A_GiveInventory("JewelEncasePower",1,AAPTR_TARGET)
JEWS ABCDEFGHIJKLMNOP 1 A_Warp(AAPTR_TARGET, 0, 0, -4, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
JEWS P 0 A_JumpIfInventory("JewelEncaserTime",1,"Warping",AAPTR_TARGET)
goto Death

Death:
TNT1 A 0
TNT1 A 5
TNT1 A 0 A_TakeInventory("JewelEncasePower",1,AAPTR_TARGET)
TNT1 A 0 A_TakeInventory("JewelEncaserTime",999,AAPTR_TARGET)
TNT1 A 0 A_PlaySoundEx("weapon/centaurflash","Weapon",0)
TNT1 A 0 A_Warp(AAPTR_TARGET, 0, 0, -4, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("TimeStopGFX", 0, 0, 32, 20, 0, random(-20, 20), random(0, 359))
TNT1 A 1
stop
Terminate:
TNT1 A 0
stop
}
}

actor JewelEncaserShield2 : JewelEncaserShield 
{
States
{
Spawn:
TNT1 A 0
TNT1 A 0 //A_GiveInventory("HealthScaled",1)
TNT1 A 0//ACS_NamedExecuteAlways("SH_enemypain",0)
goto Warping
Warping: 
JEWS S 0 A_GiveInventory("JewelEncasePower",1,AAPTR_TARGET) 
JEWS IJKLMNOPABCDEFGH 1 A_Warp(AAPTR_TARGET, 0, 0, -4, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION) 
JEWS P 0 A_JumpIfInventory("JewelEncaserTime",1,"Warping",AAPTR_TARGET)
goto Death
}
}
