actor DocRobot_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_3I"
dropitem "DocScannerWep"
Weapon.AmmoUse 1
Weapon.AmmoGive 3
Weapon.SlotNumber 1
Obituary "$OB_DOCBUSTER"
Inventory.Pickupmessage "Power up! \ciD\c-iverse \ciO\c-perations \ciC\c-ircuit \ciRobot\c-!"
weapon.ammotype "DocVirusAmmo"
States
{
Spawn:
C_03 I 1
loop

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

Ready:
DOCR A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_DOCROBOT)
Goto Ready2
Ready2:
DOCR A 10 A_WeaponReady
//DOCR A 0 A_GiveInventory("DocVirusAmmo_P")
loop

Fire:
DOCR A 0 A_PlaySoundEx("weapon/pshot",1)
DOCR A 0 A_FireCustomMissile("DocShotB",0,0,8,0)
DOCR BC 4
DOCR A 6
DOCR A 0 A_Refire("Fire")
Goto Ready2

AltFire:
DOCR D 0 A_PlaySound("DocRobot/NullAlt",1,0.6)
AltFireHold:
DOCR D 1 A_RailWait
DOCR A 1
DOCR D 0 A_ReFire("AltFireHold")
Goto Ready2

AltfireOld:
DOCR A 0 A_JumpIfInventory("DocVirusAmmo",56,"AltfireScan")
DOCR A 1
Goto Ready2
AltfireScan:
DOCR A 0 A_PlaySound("Wep/DocScanCheck",4)
DOCR A 0 A_SpawnItemEx("DocRobotScanner",0,0,33,cos(-pitch)*1,0,sin(-pitch)*1,0,1)
DOCR D 1 A_SpawnItemEx("DocScannerLaserFX_H",0,0,43,cos(-pitch)*15,0,sin(-pitch)*15,0,1)
DOCR A 1 A_TakeInventory("DocVirusAmmo",4)
DOCR A 0 A_JumpIfInventory("PlayerPropertyRage",1,5)
DOCR DADADADAD 1
Goto Ready2
NoAmmo:
DOCR A 1
Goto Ready2
}
}

actor DocVirusAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 56
+INVENTORY.IGNORESKILL
}

actor DocRobotItem : BasicClassItem
{
inventory.icon "Doc_Icon"
inventory.pickupmessage "Deck Of Cards Scanner"
Tag "DocRobot Copy Scanner"
states
{
Spawn:
DOCR Z 1
loop
UseCBM:
TNT1 A 0 A_JumpIfInventory("DocRobotIsScanning_F",1,2)
TNT1 A 0 A_JumpIfInventory("DocVirusAmmo",56,"Use2")
TNT1 A 0
fail
Use2:
TNT1 A 0 A_PlaySound("Wep/DocScanCheck",4)
TNT1 A 0 A_GiveInventory("DocRobotIsScanning_F",1)
TNT1 A 0 A_SpawnItemEx("DocRobotScanner_H")
TNT1 A 0 A_SpawnItemEx("DocRobotScanner",0,0,33,cos(-pitch)*1,0,sin(-pitch)*1,0,1)
TNT1 A 0 A_SpawnItemEx("DocScannerLaserFX_H",0,0,43,cos(-pitch)*15,0,sin(-pitch)*15,0,1)
fail
}
}
actor DocRobotIsScanning_F : Inventory{}

actor DocRobotJump_F : Inventory
{
inventory.amount 1
inventory.maxamount 999
}
actor DocRobotSpeed_F : DocRobotJump_F{}

actor DocRobotSpawnStart_P : CustomInventory
{
States
{
Pickup:
//Not so fast, user TID isn't set yet. Same with weapons being defined
//TNT1 A 0 ACS_NamedExecuteWithResult("cbm_CopyWepSetAmmo",2,3)//Cut all ammo in half
//TNT1 A 0 ACS_NamedExecuteWithResult("cbm_DocStatsModifier",1)//Force Stat change
TNT1 A 0 A_SpawnItemEx("DocAmmoGiver")
stop
}
}
actor DocRobotAmmoAdjust_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_CopyWepSetAmmo",2,3)
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_DocStatsModifier",1)
stop
}
}

actor DocShotB : ProjSpawnFuncActor
{
PROJECTILE
damagetype "DocRobot_Shot"
Obituary "$OB_DOCBUSTER"
+FORCEXYBILLBOARD
+BRIGHT
damage (150)
Radius 10
Height 7
speed 45
scale 2.5
States
{
Spawn:
Q_0D B 1
loop
}
}



actor DocRobotScanner_H : BasicWatcher
{
+SERVERSIDEONLY
+NOTIMEFREEZE
ReactionTime 10
States
{

Spawn:
TNT1 A 0
TNT1 A 1 A_JumpIfInventory("PlayerPropertyRage",1,1,2)
TNT1 A 1 A_CountDown
loop
Death:
TNT1 A 0 A_TakeFromTarget("DocRobotIsScanning_F",1)
stop
}
}

actor DocRobotScanner : DocScanner
{
damagetype "DocRobot_Scan"
damage (30*(CallACS("core_checkrune",RUNE_SPREAD,2)*2+1))
States
{
DeathScan:
TNT1 A 0 A_SpawnItemEx("DocScannerMarkFX_H",-6,0,8,0,0,0,0,1)
TNT1 A 0 A_SpawnItemEx("DocRobotScannerBitFX_H",-6,0,8,0,0,0,0,1+SXF_TRANSFERPOINTERS)
TNT1 A 10 A_TakeFromTarget("DocRobotIsScanning_F",-5)
stop
}
}

actor DocRobotScannerBitFX_H : BasicHelper
{
var int user_TID;
var int user_Tracer;
var int user_ScannerMemory;
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_SetUserVar("user_TID",CallACS("core_gettarget",0))
TNT1 A 0 A_SetUserVar("user_Tracer",CallACS("core_gettracer",0))
TNT1 A 0 A_PlaySoundEx("Wep/DocScanHit","weapon")
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_DocScannerRecordClass",user_Tracer)
TNT1 A 4 //A_GiveToTarget("DocVirusAmmoDelay",1)
goto Spawn1
Spawn1:
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_GiveInventory("WeaponCharge",1)
TNT1 A 0 //A_GiveToTarget("DocVirusAmmoDelay",1)
TNT1 A 8 A_SpawnItemEx("DocScannerBitFX",0,0,-58,0,0,0,0,1)
TNT1 A 0 A_JumpIfInventory("WeaponCharge",4,"SpawnEnd")
goto Spawn2
Spawn2:
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 //A_GiveToTarget("DocVirusAmmoDelay",1)
TNT1 A 10 A_SpawnItemEx("DocScannerBitFX",0,0,6,0,0,0,0,1)
goto Spawn1
SpawnEnd:
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 10 //A_GiveToTarget("DocVirusAmmoDelay",1)
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 //A_GiveToTarget("DocVirusAmmoDelay",1)
TNT1 A 2 A_JumpIf(CallACS("cbm_DocScannerGiveCopy",user_Tracer,user_TID),2)
TNT1 A 10 A_TakeFromTarget("DocRobotIsScanning_F",99)
stop
TNT1 A 2 A_TakeFromTarget("DocVirusAmmo",56,1)
TNT1 A 10 A_TakeFromTarget("DocVirusAmmo",56,1)
TNT1 A 10 A_TakeFromTarget("DocRobotIsScanning_F",99)
stop

}
}





actor DocVirusAmmo_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("DocVirusAmmoDelay",1,2)
TNT1 A 0 A_GiveInventory("DocVirusAmmo",1)
TNT1 A 0
stop
}
}


actor DocVirusAmmoDelay : Powerup
{
Powerup.Duration 20
}

actor DocAmmoGiverCheck_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("CutterFlag",1+CallACS("core_checkrune",RUNE_RAGE,2))
TNT1 A 0 //A_JumpIfInTargetInventory("DocVirusAmmoDelay",1,"No")
TNT1 A 0 A_JumpIfInventory("VivifyDelay10",1,"No")
TNT1 A 0 A_GiveInventory("VivifyDelay10",1)
TNT1 A 0 A_GiveToTarget("DocVirusAmmo",1+CallACS("core_checkrune",RUNE_RAGE,2))
stop
No:
TNT1 A 0
stop
}
}

actor DocAmmoGiver : BasicHelper
{
+NOTIMEFREEZE
+SERVERSIDEONLY
States
{
Spawn:
TNT1 A 0
TNT1 AA 1
//Wait 2 tics for owner to change TID
//Along with waiting for all the weapons to be defined in ACS
TNT1 A 0 A_GiveToTarget("DocRobotAmmoAdjust_P",1)
TNT1 AA 1
goto Spawn1
Spawn1:
TNT1 A 0
TNT1 A 1
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_JumpIfInTargetInventory("DocRobot_W",1,1)
goto Death
TNT1 A 0 A_GiveInventory("DocAmmoGiverCheck_P")
TNT1 A 0 A_JumpIfInventory("CutterFlag",53,"DocAmmo2")
loop

DocAmmo2:
TNT1 A 0 A_GiveToTarget("DocAmmo22",1)
TNT1 A 0 //A_JumpIfInTargetInventory("EnergyBalancerActive",1,2)
TNT1 A 0 A_TakeInventory("CutterFlag",999)
goto Spawn1
TNT1 A 0 A_TakeInventory("CutterFlag",27)
goto Spawn1

}
}

actor DocAmmoGiverOld : BasicHelper
{
States
{
Spawn:
TNT1 A 0
TNT1 A 1
TNT1 A 0 A_JumpIf(!CallACS("cbm_PointerExists",AAPTR_TARGET),"Death")
TNT1 A 0 A_JumpIfInTargetInventory("DocRobot_W",1,1)
goto Death
TNT1 A 0 A_GiveInventory("CutterFlag",1)
TNT1 A 0 A_JumpIfInventory("CutterFlag",127,2)
TNT1 A 0 A_JumpIfInventory("CutterFlag",126,"DocAmmo2")
TNT1 A 0 A_JumpIfInventory("CutterFlag",169,2)
TNT1 A 0 A_JumpIfInventory("CutterFlag",168,"DocAmmo1p5")
TNT1 A 0 A_JumpIfInventory("CutterFlag",253,2)
TNT1 A 0 A_JumpIfInventory("CutterFlag",252,"DocAmmo0and2")
TNT1 A 0 A_JumpIfInventory("CutterFlag",337,2)
TNT1 A 0 A_JumpIfInventory("CutterFlag",336,"DocAmmo1p5")
TNT1 A 0 A_JumpIfInventory("CutterFlag",379,2)
TNT1 A 0 A_JumpIfInventory("CutterFlag",378,"DocAmmo2")
TNT1 A 0 A_JumpIfInventory("CutterFlag",504,"DocAmmo0and1p5and2")
goto Spawn+1
DocAmmo0and2:
TNT1 A 0 A_GiveToTarget("DocAmmo0",1)
TNT1 A 0 A_GiveToTarget("DocAmmo2",1)
goto Spawn+1
DocAmmo1p5:
TNT1 A 0 A_GiveToTarget("DocAmmo1p5",1)
goto Spawn+1
DocAmmo2:
TNT1 A 0 A_GiveToTarget("DocAmmo2",1)
goto Spawn+1
DocAmmo0and1p5and2:
TNT1 A 0 A_GiveToTarget("DocAmmo0",1)
TNT1 A 0 A_GiveToTarget("DocAmmo1p5",1)
TNT1 A 0 A_GiveToTarget("DocAmmo2",1)
TNT1 A 0 A_TakeInventory("CutterFlag",999)
goto Spawn+1
Death:
TNT1 A 0
stop
}
}


actor DocAmmo0 : CustomInventory
{
States
{
Pickup:
EBAL E 0 ACS_NamedExecuteWithResult("cbm_CopyWepAmmoRatioGive",2)
stop
}
}

actor DocAmmo1p5 : CustomInventory
{
States
{
Pickup:
EBAL E 0 ACS_NamedExecuteWithResult("cbm_CopyWepAmmoRatioGive",3/* *0.5 */)
stop
}
}

actor DocAmmo2 : CustomInventory
{
States
{
Pickup:
EBAL E 0 ACS_NamedExecuteWithResult("cbm_CopyWepAmmoRatioGive",4 /* *0.5 */)
stop
}
}

actor DocAmmo22 : CustomInventory
{
States
{
Pickup:
TNT1 A 0 //A_PlaySound("item/energyup",3,1.0)
TNT1 A 0 ACS_NamedExecuteWithResult("cbm_CopyWepAmmoRatioGive",8)
stop
}
}

actor DocRobot_W_NormalBar : NormalBar {Args 217,174}