actor WireAdaptor : BaseMM8BDMUseItem 11147
{
//$Category MM8BDM-Assists
//$Title Wire Adaptor
//$Sprite WADPA0
Inventory.RespawnTics 245
inventory.amount 2
inventory.maxamount 2
inventory.pickupmessage "$PU_WIREADAPTOR"
inventory.icon "WIRE"
Tag "$TAG_WIREADAPTOR"
Inventory.PickupSound "item/1up"
scale 2.0
+COUNTITEM
+INVBAR
states
{
SpawnLoop:
WADP A -1
loop
Use:
TNT1 A 0 A_JumpIfInventory("WireHookShotDelay",1,"TooSoon")
TNT1 A 0 A_GiveInventory("WireHookShotDelay",1)
TNT1 A 0 A_PlaySoundEx("weapon/WireAdp","Item")
TNT1 A 0 A_SpawnItemEx("WireAdaptorHook",-2,0,32,cos(-pitch)*1,0,sin(-pitch)*1,0,0)
fail
TooSoon:
TNT1 A 0
fail
}
}

actor InfiniteWireAdaptor : WireAdaptor
{
inventory.icon "WIREG"
inventory.amount 1
inventory.maxamount 1
states
{
SpawnLoop:
WADP I -1
loop
Use:
TNT1 A 0 A_JumpIfInventory("WireHookShotDelay",1,"TooSoon")
TNT1 A 0 A_GiveInventory("WireHookShotDelay",1)
TNT1 A 0 A_PlaySoundEx("weapon/WireAdp","Item")
TNT1 A 0 A_SpawnItemEx("WireAdaptorHookLong",-2,0,32,cos(-pitch)*1,0,sin(-pitch)*1,0,0)
fail
TooSoon:
TNT1 A 0
fail
}
}


ACTOR WireFlag : Powerup
{
Powerup.Duration 35
}

actor WireHookShotDelay : Powerup
{
Powerup.Duration 20
}

actor WireAdaptorDelay : Powerup//This is how long you are pulled for.
{
Powerup.Duration -3
}

actor WireAdaptorHook
{
Translation "199:199=193:193"
var int user_PTID;
var int user_CountDown;
PROJECTILE
obituary "%o was grappled by %k's Wire Adaptor."
damagetype "WireAdaptor"
+DONTBLAST
+DONTREFLECT
//+PAINLESS
//+SKYEXPLODE
+THRUGHOST
+NOTIMEFREEZE
+HITTRACER
ReactionTime 1
Damage (10)
Radius 8
Height 8
Speed 1
scale 2.5
states
{
Spawn:
WADP B 0
WADP B 0 A_SetUserVar("user_CountDown",reactiontime)
WADP B 0 A_SetUserVar(user_PTID, ACS_NamedExecuteWithResult("core_gettarget"))
WADP B 0 A_GiveInventory("WeaponCharge",1)
WADP B 0 A_ScaleVelocity(44)//Speed of projectile.
goto Spawn2

Spawn2:
WADP B 0 ACS_NamedExecuteAlways("core_drawhookshot", 0, user_PTID, 18)
WADP B 0 A_GiveToTarget("WireHookShotDelay",1)
WAD1 ABABAB 1 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists")==0,"SuperDeath")
WADP B 0 A_GiveToTarget("WireHookShotDelay",1)
WAD1 ABABAB 1 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists")==0,"SuperDeath")
WireLoop:
WADP B 0 A_GiveToTarget("WireHookShotDelay",1)
WAD1 ABABAB 1 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists")==0,"SuperDeath")
WADP B 0 A_SetUserVar("user_CountDown",user_CountDown - 1)
WAD1 A 0 A_CountDown
loop

Death:
WADP B 0 A_JumpIfCloser(64, "SuperDeath")
XDeath:
Crash:
WADP B 0 A_JumpIf(user_CountDown == 0, "SuperDeath")
WADP B 0 A_JumpIfInventory("WeaponCharge",2,"SuperDeath")
WADP B 0 A_JumpIfInventory("WeaponCharge",1,1)
goto SuperDeathPoof//Kill hook early if it never got through the Spawn state.
WADP B 0 A_PlaySoundEx("weapon/crashland","Weapon")
WADP B 0 A_JumpIfInventory("NoHookshot",1,"Death1",AAPTR_TRACER)
WADP B 0 A_CheckFlag("SHOOTABLE","Death2",AAPTR_TRACER)
goto Death1
Death1://Tracer isn't shootable (probably can't move)
WADP B 0 ACS_NamedExecuteAlways("core_hookshot",0,user_PTID,30,0)
WAD1 B 3
goto DeathLoop1
Death2://Tracer IS shootable (probably CAN move)
WADP B 0 ACS_NamedExecuteAlways("core_hookshot",0,user_PTID,30,1)
WAD1 B 3//Needs at least 3 tics of delay.
goto DeathLoop2
DeathLoop1:
WADP B 0 A_JumpIfCloser(64,"SuperDeathPoof")
WADP B 0 A_GiveToTarget("WireHookShotDelay",1)
WAD1 B 1 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists")==0,"SuperDeath")
loop
DeathLoop2:
WADP B 0 A_JumpIfCloser(64,"SuperDeathPoof")
WADP B 0 A_Warp(AAPTR_TRACER,-4,0,28)
WADP B 0 A_GiveToTarget("WireHookShotDelay",1)
WAD1 B 0 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists")==0,"SuperDeath")
WAD1 B 1 A_JumpIf(ACS_NamedExecuteWithResult("core_targetexists",1)==0,"DeathLoop1")
loop
SuperDeathPoof:
WADP B 0 A_PlaySoundEx("weapon/adapterreturn","Weapon")
WADP B 0 A_TakeFromTarget("WireAdaptorDelay",1)
WADP B 0 A_ChangeFlag("NOINTERACTION",1)
WAD1 B 6 A_Stop
stop
SuperDeath:
WAD1 B 0
stop
}
}

actor NoHookshot : Once {}

Actor WireAdaptorHookFX
{
+CLIENTSIDEONLY
+NOINTERACTION
+NOGRAVITY
+NOTIMEFREEZE
-SOLID
radius 2
height 2
scale 2.5
States
{
Spawn:
WAD1 I 0
WAD1 C 1
stop
}
}

actor WireHookShotEnd : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_TakeInventory("WireAdaptor",1)
TNT1 A 0 A_TakeInventory("WireAdaptorDelay",1)
stop
}
}

actor WireAdaptorHookLong : WireAdaptorHook
{
reactiontime 3
}

actor WireAdaptorHookLongFX : WireAdaptorHookFX {}

// OLD
/*
actor WireAdaptor : CustomInventory 11147
{
//$Category MM8BDM-Assists
//$Title Wire Adaptor
//Inventory.RespawnTics 300
inventory.amount 2
inventory.maxamount 2
inventory.pickupmessage "$PU_WIREADAPTOR"
inventory.icon "WIRE"
Tag "$TAG_WIREADAPTOR"
Inventory.PickupSound "item/1up"
scale 2.0
+COUNTITEM
+INVBAR
states
{
Spawn:
WADP A 1
loop
Use:
WADP A 0 A_JumpIfInventory("WireFlag", 1, "TooSoon")
WADP A 0 A_GiveInventory("WireFlag")
WADP A 0 A_JumpIf(pitch < 305 && pitch >100, "Proj")
WADP A 0 A_SpawnItemEx("WireAdaptorGrapple",8,8,16,15,0,30,0)
fail
Proj:
WADP A 0 A_FireCustomMissile("WireAdaptorGrapple",0,0,8,0)
fail
TooSoon:
WADP A 0
fail
}
}

actor WireAdaptorGrapple
{
PROJECTILE
+RIPPER
+FORCEXYBILLBOARD
+DONTBLAST
+THRUGHOST
+DONTREFLECT
damage (0)
height 8
radius 8
Speed 30
ReactionTime 3
scale 2.5
states
{
Spawn:
WADP B 0
TNT1 A 1 A_PlaySoundEx("weapon/WireAdp", "weapon")
WADP B 1 A_SpawnItemEx("WireAdaptorChain",0,0,-16)
WADP C 1 A_SpawnItemEx("WireAdaptorChain",0,0,-16)
WADP D 1 A_SpawnItemEx("WireAdaptorChain",0,0,-16)
WADP E 1 A_SpawnItemEx("WireAdaptorChain",0,0,-16)
WADP F 1 A_SpawnItemEx("WireAdaptorChain",0,0,-16)
WADP C 1 A_SpawnItemEx("WireAdaptorChain",0,0,-16)
WADP B 0 A_CountDown
Goto Spawn+2
Death:
WADP B 0 
WADP B 0 A_JumpIf(ceilingz-z<20, "Ceiling")
stop
Ceiling:
TCLA C 0 A_GiveToTarget("WireFlag", 1)
TCLA C 0 A_TakeFromTarget("WireAdaptor", 1)
TCLA C 0 A_SpawnItemEx("WireAdaptorPeg")
stop
}
}

actor WireAdaptorChain
{
//+CLIENTSIDEONLY
+NOINTERACTION
+NOGRAVITY
+FORCEYBILLBOARD
Scale 2.5
States
{
Spawn:
WADP HHH 5 
stop
}
}

Actor WireAdaptorPeg
{
+NODAMAGETHRUST
+NOGRAVITY
Mass 99999
Height 16
Radius 16
Speed 0
Scale 2.5
States
{
Spawn:
TNT1 A 0 
TNT1 A 0 ACS_ExecuteAlways(248,0)
WADP BB 10
TNT1 A 10
TNT1 A 1 Thing_ChangeTID(0,0)
stop
}
}
*/
///////////////////////////////////////