actor Springman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_7E"
dropitem "WildCoilWep"
Weapon.AmmoUse 20
Weapon.AmmoGive 140
Obituary "$OB_WILDCOIL"
weapon.ammotype "GumAmmo"
States
{
Spawn:
C_07 E 1
loop

Deselect:
SPFI A 0
goto DeselectSwap
Select:
SPFI A 0
goto SelectSwap

Ready:
SPFI A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_SPRINGMAN)
goto Ready1
Ready1:
SPFI A 0 A_JumpIfInventory("GumAmmo",20,"Ready2")
SPFI A 2 A_WeaponReady(4)
SPFI A 0 A_GiveInventory("GumAmmo",2)
loop
Ready2:
SPFI A 2 A_WeaponReady
SPFI A 0 A_GiveInventory("GumAmmo",2)
loop

Fire:
SPFI A 0 A_GiveInventory("SpringmanMain_P",1)
SPFI BC 5
SPFI A 4
SPFI A 3
Goto Ready1
AltFire:
SPFI A 0 A_Jump(256,"AltfirePunch")
Goto Ready1
AltfirePunch:
SPFI A 0 A_GiveInventory("VivifyFlag1",1)
SPFI A 0 A_PlaySound("weapon/springpunch",1)
SPFI A 2 Offset(2,52)
SPFI A 2 Offset(5,72)
SPFI A 1 Offset(9,92)
SPFI A 0 A_ReFire("AltfirePunch1")
goto AltfirePunch2

AltfirePunch1:
SPFI D 0 A_GunFlash("Flash",1)
SPFI D 0 A_TakeInventory("AdapterWaitCount")
SPFI D 0
SPFI D 3 Offset(-16,91)A_TakeInventory("FistFlag")
SPFI D 5 Offset(-10,52)
SPFI E 12 Offset(2,33)A_FireCustomMissile("SpringFist",0,0,-8,0)
goto FistWait1
FistWait1:
SPFI E 1 Offset(2,33)A_JumpIfInventory("FistFlag",1,"FistFinish")
SPFI E 0 A_GiveInventory("AdapterWaitCount",1)
SPFI E 0 A_GiveInventory("GumAmmo",2+CallACS("core_checkrune",RUNE_RAGE)*2)
SPFI E 0 A_JumpIfInventory("AdapterWaitCount",15,"FistFinish")
loop

AltfirePunch2:
SPFI D 0 A_TakeInventory("AdapterWaitCount")
SPFI D 0
SPFI D 3 Offset(-16,91)A_TakeInventory("FistFlag")
SPFI D 5 Offset(-10,52)
SPFI E 12 Offset(2,33)A_FireCustomMissile("SpringFistWeak",0,0,-8,0)
goto FistWait2
FistWait2:
SPFI E 1 Offset(2,33)A_JumpIfInventory("FistFlag",1,"FistFinish")
SPFI E 0 A_GiveInventory("AdapterWaitCount",1)
SPFI E 0 A_JumpIfInventory("AdapterWaitCount",20,"FistFinish")
loop
FistFinish:
SPFI D 0 A_TakeInventory("VivifyFlag1")
SPFI D 0 A_PlaySound("weapon/adapterreturn",1)

SPFI D 2 Offset(2,33)A_GiveInventory("GumAmmo",2)
SPFI D 2 Offset(-11,61)A_GiveInventory("GumAmmo",2)
SPFI D 2 Offset(-20,89)A_GiveInventory("GumAmmo",2)
TNT1 AA 2 A_GiveInventory("GumAmmo",2)
SPFI A 2 Offset(9,80)A_GiveInventory("GumAmmo",2)
SPFI A 2 Offset(5,58)A_GiveInventory("GumAmmo",2)
SPFI A 2 Offset(2,42)A_GiveInventory("GumAmmo",2)

SPFI A 0 A_TakeInventory("FistFlag")
SPFI A 0 A_TakeInventory("AdapterWaitCount")
SPFI A 0
Goto Ready1

Flash:
TNT1 A 0 A_JumpIfInventory("PlayerPropertyGrounded",1,2)
TNT1 A 0 A_Stop
TNT1 A 1 A_RailWait
TNT1 A 0 A_JumpIfInventory("VivifyFlag1",1,"Flash")
stop

}
}

actor GumAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 140
+INVENTORY.IGNORESKILL
}

actor SpringmanMain_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_PlaySoundEx("SpringM/Fire","Weapon")
TNT1 A 0 A_CheckFloor(2)
TNT1 A 0 A_FireCustomMissile("WilderCoil",0,1,8,0)
stop
TNT1 A 0 A_FireCustomMissile("WilderCoil1",0,1,8,0,0,(pitch>89 && pitch<90))
stop
}
}

actor WilderCoil : ProjSpawnFuncActor
{
PROJECTILE
damagetype "SpringM_Coil"
Obituary "$OB_WILDCOIL"
-NOGRAVITY
+SKYEXPLODE
+USEBOUNCESTATE
+BOUNCEONWALLS
+BOUNCEONFLOORS
+BOUNCEONCEILINGS
+CANBOUNCEWATER
bouncecount 5
bouncefactor 0.65
wallbouncefactor 0.65
ReactionTime 1
Damage (150)
height 16
radius 12
speed 34
scale 2.5
States
{
Spawn:
SPFI K 0
SPFI K 0 A_ChangeVelocity(0,0,1.5)
Goto Bouncing
Bouncing:
SPFI KLMKLM 5
loop
Bounce:
TNT1 A 0 A_ChangeFlag("USEBOUNCESTATE",0)
TNT1 A 0 A_PlaySoundEx("weapon/SpringBounce2","Weapon")
TNT1 A 0 A_SpawnItemEx("WilderCoil2",0,0,0,sqrt(momx*momx+momy*momy),0,momz,15)
TNT1 A 0 A_SpawnItemEx("WilderCoil2",0,0,0,sqrt(momx*momx+momy*momy),0,momz,-15)
TNT1 A 1 A_CountDown
wait
Death:
Crash:
XDeath:
TNT1 A 0 A_PlaySoundEx("weapon/SpringDed","Weapon")
TNT1 A 1 A_SpawnItemEx("WilderCoilDeathFX",0,0,25,0,0,0,0,1)
stop
}
}

actor WilderCoilDeathFX : BasicGraphicEffect
{
States
{
SpawnFrame:
NMFX ABCD 2
stop
}
}

actor WilderCoil1 : WilderCoil
{
States
{
Spawn:
SPFI K 0
SPFI K 0 A_ChangeVelocity(0,0,1.5)
SPFI K 5 A_GiveInventory("Once",1)
Goto Bouncing+1
Bounce.Floor:
TNT1 A 0 A_JumpIfInventory("Once",1,"Bounce")
TNT1 A 0 A_ChangeFlag("USEBOUNCESTATE",0)
TNT1 A 0 A_PlaySoundEx("weapon/SpringBounce2","Weapon")
TNT1 A 0 A_SpawnItemEx("WilderCoil2",0,0,8,18,0,8.5,90,1)
TNT1 A 0 A_SpawnItemEx("WilderCoil2",0,0,8,18,0,8.5,-90,1)
TNT1 A 1 A_CountDown
wait
}
}

actor WilderCoil2 : WilderCoil
{
-USEBOUNCESTATE
bouncecount 5
bouncefactor 1.0
wallbouncefactor 1.0
BounceSound "weapon/SpringBounce2"
Damage (100)
States
{
Spawn:
SPFI K 0
SPFI K 0
Goto Bouncing
}
}


actor SpringFist : ProjSpawnFuncActor
{
PROJECTILE
damagetype "SpringM_Fist"
Obituary "$OB_SPRINGFIST"
+SKYEXPLODE
+EXPLODEONWATER
+DONTBLAST
+NOTARGETSWITCH
+DONTREFLECT
+SEEKERMISSILE
reactiontime 20
damage (0)
Radius 10
Height 10
speed 54
scale 2.5
Args 54
States
{
Spawn:
SPFI P 1
SPFI P 0 ACS_NamedExecuteWithResult("core_drawhookshot",CallACS("core_gettarget"),Args[0],-8,DHS_MAXDIST+2058)
//SPFI P 0 A_SpawnItemEx("SpringmanFistCoilFX",-1,-8,-8,0,0,0,0,1)
SPFI P 1 A_CountDown
wait
Death:
SPFI R 0
SPFI R 0 A_PlaySoundEX("weapon/hardquakeland","Weapon")
SPFI R 0 A_Explode(350,96,0,0,32)
SPFI R 0 A_SpawnItemEx("SpringFistHitFX",0,0,8,0,0,0,0,1)
SPFI R 0 A_TakeFromTarget("AdapterWaitCount",20)
SPFI R 0 A_RearrangePointers(AAPTR_DEFAULT,AAPTR_DEFAULT,AAPTR_TARGET)
SPFI R 4 A_FaceTarget
SPFI R 1 A_ChangeFlag("NOINTERACTION",1)
goto Death2
Death2:
SPFI R 0 A_TakeFromTarget("AdapterWaitCount",20)
SPFI R 0 A_JumpIfCloser(60,"Return")
SPFI RR 0 A_SeekerMissile(90,90,SMF_PRECISE)
SPFI R 1 A_GiveInventory("CutterFlag",1)
SPFI R 0 A_JumpIfInventory("CutterFlag",105,"DeathEnd")
SPFI R 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"DeathEnd")
loop
Return:
TNT1 A 1 A_GiveToTarget("FistFlag",1)
stop
DeathEnd:
TNT1 A 1 A_GiveToTarget("FistFlag",1)
stop
}
}

actor SpringFistHitFX : BasicGraphicEffect
{
+FORCEXYBILLBOARD
Scale 3.0
States
{
SpawnFrame:
SPFI STUVWX 2
stop
}
}


actor SpringFistWeak : SpringFist
{
reactiontime 15
speed 48
Args 48
States
{
Death:
SPFI R 0
SPFI R 0 A_PlaySoundEX("weapon/hardquakeland","Weapon")
SPFI R 0 A_Explode(250,80,0,0,24)
SPFI R 0 A_SpawnItemEx("SpringFistWeakHitFX",0,0,8,0,0,0,0,1)
goto Super::Death+4
}
}

actor SpringFistWeakHitFX : SpringFistHitFX
{
Scale 2.25
}



actor SpringFistFX : BasicGraphicEffect
{
+NOTIMEFREEZE
Speed 0
States
{
Spawn:
SPFI Q 0
SPFI Q 1
stop
}
}
actor SpringFistWeakFX : SpringFistFX{}

actor SpringmanFistCoilFX : BasicGraphicEffect
{
+NOTARGETSWITCH
+SEEKERMISSILE
+FORCEXYBILLBOARD
reactiontime 70
speed 50
States
{
SpawnFrame:
TNT1 A 1
SPFI Q 0 A_RearrangePointers(AAPTR_DEFAULT,AAPTR_DEFAULT,AAPTR_TARGET)
SPFI Q 0 A_FaceTarget
goto Spawn3
Spawn3:
SPFI Q 1
SPFI Q 0 A_CountDown
SPFI Q 0 //A_JumpIfInTargetInventory("FistReturning",1,"Return")
SPFI Q 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
loop
Return:
SPFI Q 0 A_JumpIfCloser(60,"Death")
SPFI Q 0 A_SeekerMissile(90,90,SMF_PRECISE)
goto Spawn3+3
Death:
TNT1 A 1
stop
}
}


actor Springman_W_NormalBar : NormalBar {Args 109,238}