actor Plantman_W : BaseMM8BDMWep_CBM
{
tag "$TAGC_6E"
dropitem "PlantTrapperWep"
weapon.ammouse 1
Weapon.AmmoGive 28
Weapon.AmmoUse2 1
Obituary "$OB_PLANTBARRIER"
Inventory.Pickupmessage "Power up! Plant Vines?!"
weapon.ammotype "BioticFieldAmmo"
weapon.ammotype2 "PsychedelicAmmo"
+WEAPON.NOAUTOAIM
States
{
Spawn:
C_06 E 1
loop

Deselect:
PBUS A 0 A_GiveInventory("Plantman_DrainDisable_P")
PBUS A 0 A_TakeInventory("ShieldCheck")
goto DeselectSwap
Select:
PBUS A 0
goto SelectSwap

Ready:
PBUS A 0 ACS_NamedExecuteWithResult("core_weaponcolor",DYE_PLANTMAN)
PBUS A 0 A_GunFlash("Flash",1)
Ready2:
PBUS A 0 //A_ClearRefire
PBUS A 3 A_WeaponReady
PBUS A 0 A_GiveInventory("PsychedelicAmmo",1)
Goto Ready2+1

Fire:
PBUS A 0 A_JumpIfInventory("ShieldCheck",1,"ShieldThrow")
PBUS A 0 A_PlaySoundEx("weapon/mbuster","Weapon")
PBUS A 0 A_FireCustomMissile("PlantShot",random(-5,5),0,8,0)
PBUS CB 2
PBUS A 0 A_Refire
goto Ready2
AltFire:
PBUS A 0 A_JumpIfInventory("ShieldCheck",1,"ShieldThrow")
PBUS A 0 A_PlaySoundEx("weapon/blizzboss","Weapon")
PBUS A 0 A_GiveInventory("ShieldCheck",1)
PBUS A 0 A_Refire(1)
PBUS A 1 offset(2,38)
goto ShieldActive
ShieldActive:
PBUS A 0 A_SpawnItemEx("PlantmanShieldWarper",0,0,28,0,0,0,0,1,0)
PBUS A 2 offset(5,57)
PBUS A 2 offset(11,88)
PBUS D 2 offset(-10,72)
PBUS D 2 offset(-2,54)

PBUS D 0 A_GiveInventory("PlantM_DrainRune",1)
PBUS D 0 ACS_NamedExecuteWithResult("core_runeplayer",0,1,RUNE_DRAIN)

PBUS D 0 A_JumpIfNoAmmo("ShieldThrow")
PBUS E 0 A_WeaponReady
Goto Shield
Shield:
PBUS E 0 A_SpawnItemEx("PlantMDrainer",0,0,32)
PBUS E 8 A_WeaponReady
PBUS E 0 A_SpawnItemEx("PlantMDrainer",0,0,32)
PBUS E 8 A_WeaponReady

PBUS E 0 A_TakeInventory("PsychedelicAmmo",3)
PBUS E 0 A_JumpIfNoAmmo("ShieldThrow")

PBUS E 0 A_SpawnItemEx("PlantMDrainer",0,0,32)
PBUS E 8 A_WeaponReady
PBUS E 0 A_SpawnItemEx("PlantMDrainer",0,0,32)
PBUS E 8 A_WeaponReady

PBUS E 0 A_TakeInventory("PsychedelicAmmo",3,1)
PBUS E 0 A_JumpIfNoAmmo("ShieldThrow")
loop

ShieldThrow:
PBUS E 0 A_TakeInventory("ShieldCheck")
PBUS E 0 A_TakeInventory("PsychedelicAmmo",3,1)
PBUS E 2 A_FireCustomMissile("PlantShield",0,0,0,0)

PBUS D 2 offset(1,48)
PBUS D 2 offset(-3,64)
PBUS D 2 offset(-6,80)
PBUS D 2 offset(-9,96)
TNT1 A 2 offset(16,116)
PBUS A 2 offset(12,98)
PBUS A 2 offset(9,82)
PBUS A 2 offset(6,68)
PBUS A 2 offset(4,56)
PBUS A 2 offset(2,46)
PBUS A 2 offset(1,38)

PBUS A 5 A_WeaponReady(12)
PBUS A 0 A_GiveInventory("Plantman_DrainDisable_P")
goto Ready2

Flash:
TNT1 A 8
TNT1 A 50 A_GiveInventory("BioticFieldAmmo",1)
loop
}
}


actor PlantM_DrainRune : Inventory{}


actor PsychedelicAmmo : Ammo
{
inventory.amount 1
inventory.maxamount 28
+INVENTORY.IGNORESKILL
}

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

actor Plantman_DrainDisable_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIfInventory("PlantM_DrainRune",1,1)
stop
TNT1 A 0 A_TakeInventory("PlantM_DrainRune")
TNT1 A 0 ACS_NamedExecuteWithResult("core_runeplayer",0,0,RUNE_DRAIN)
stop
}
}

actor PlantmanItem : BasicClassItem
{
inventory.icon "PlntIcon"
inventory.pickupmessage "Biotic Field deployed."
Tag "Plant Biotic Field"
states
{
Spawn:
PBUS Z 1
loop
UseCBM:
TNT1 A 0 A_JumpIfInventory("BioticFieldAmmo",28,"Success")
fail
Success:
TNT1 A 0 A_TakeInventory("BioticFieldAmmo",10)
TNT1 A 0 A_TakeInventory("BioticFieldAmmo",18,1)
TNT1 A 0 A_FireCustomMissile("PlantM_BioFieldSpawner",0,0,-8,0)
fail
}
}

actor PlantM_BioFieldSpawner : BasicHelper
{
ReactionTime 9
Speed 1
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_PlaySoundEx("weapon/blizzboss","Weapon")
TNT1 A 0 A_ScaleVelocity(0.01)
TNT1 A 3 A_SpawnItemEx("PlantM_BioFieldToss",0,0,0,momx*5000,momy*5000,momz*5000+2,0,8+32)
Spawn2:
TNT1 A 0 A_PlaySoundEx("weapon/blizzboss","Weapon")
TNT1 A 3 A_SpawnItemEx("PlantM_BioFieldTossFX",0,0,0,momx*5000,momy*5000,momz*5000+2,0,8+32)
TNT1 A 0 A_CountDown
loop
}
}

actor PlantM_BioFieldToss : ProjSpawnFuncActor
{
Translation "192:192=104:104","198:198=60:60"
PROJECTILE
-NOGRAVITY
+THRUACTORS
+SKYEXPLODE
+BOUNCEONWALLS
+BOUNCEONCEILINGS
+CANBOUNCEWATER
BounceFactor 1.0
WallBounceFactor 1.0
BounceCount 10
gravity 1.65
Damage (0)
Radius 14
Height 14
Speed 50
scale 2.5
States
{
Spawn:
PBUS X 0
PBUS X 0 //ThrustThingZ(0,8,0,1)
PBUS X 1 
wait
Death:
TNT1 A 0 //A_JumpIf(CallACS("core_targetexists")==0,"NoDeath")
TNT1 A 1 A_SpawnItemEx("PlantM_BioticField",0,0,0,0,0,0,0,1)
stop
NoDeath:
TNT1 A 1
stop
}
}

actor PlantM_BioFieldTossFX : PlantM_BioFieldToss
{
//+CLIENTSIDEONLY
States
{
Death:
goto NoDeath
}
}

actor PlantM_BioticField : BasicExplosion//BasicHelper
{
-MISSILE
//RenderStyle Normal
ReactionTime 18//11
Height 56
Scale 2.5
States
{
Spawn:
TNT1 A 0
TNT1 A 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,0,1)
TNT1 A 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,36+12*1,1)
TNT1 A 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,72+12*2,1)
TNT1 A 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,108+12*3,1)
TNT1 A 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,144+12*4,1)
TNT1 A 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,180+12*5,1)
TNT1 A 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,216+12*6,1)
PBUS J 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,252+12*7,1)
PBUS K 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,288+12*8,1)
PBUS L 3 A_SpawnItemEX("PlantM_BioPetalFX",256,0,20,0,0,0,324+12*9,1)
PBUS M 0 A_SpawnItemEX("PlantM_HealFX_H",0,0,0,0,0,0,0,1)
PBUS M 0 A_ChangeFlag("MISSILE",1)
Spawn2:
PBUS MMMMNNNNOOOO 1 A_RadiusGive("PlantM_BioHeal_P",256,2)
//TNT1 AAAAAAAAAAAAAAAAAAAA 1 A_RadiusGive("PlantM_BioHeal_P",256,2)
TNT1 A 0 A_Countdown//20
loop
Death:
PBUS LLL 1 A_RadiusGive("PlantM_BioHeal_P",256,2)
PBUS PPP 1
PBUS QQQ 1
stop
}
}

actor PlantM_BioPetalFX : BasicGraphicEffect
{
States
{
SpawnFrame:
PBUS X 0//angle 4
PBUS X 1 A_Warp(2,256,0,20,4,WARPF_USECALLERANGLE+WARPF_NOCHECKPOSITION+WARPF_INTERPOLATE)//4+8+16
PBUS X 0 A_CheckFlag("NOGRAVITY","SpawnFrame",2)
stop
}
}

actor PlantM_HealFX_H : BasicGraphicEffect
{
RenderStyle None
States
{
SpawnFrame:
TNT1 A 0
TNT1 AAAA 0 A_SpawnItemEx("PlantM_HealFX",random(32,256),0,random(-64,16),0,0,random(4,5),random(0,359),1)
TNT1 A 1
TNT1 A 0 A_CheckFlag("NOGRAVITY","Spawn",2)
stop
}
}

actor PlantM_HealFX : BasicGraphicEffect
{
Speed 20
States
{
SpawnFrame:
TNT1 A 0
TNT1 A 0 A_Jump(64,"Spawn3")
TNT1 A 0 A_Jump(128,"Spawn2")
goto Spawn1
Spawn1:
X_0C AAABBB 1 A_FadeOut(0.05)
loop
Spawn2:
X_0C CCCDDD 1 A_FadeOut(0.05)
loop
Spawn3:
X_0C EEEFFF 1 A_FadeOut(0.05)
loop
}
}

actor PlantM_BioHealDelay : Powerup
{
powerup.duration 10
}

actor PlantM_BioHeal_P : CustomInventory
{
States
{
Pickup:
Pickup2:
TNT1 A 0 A_JumpIfInventory("PlantM_BioHealDelay",1,"No")
TNT1 A 0 A_GiveInventory("PlantM_BioHealDelay",1)
TNT1 A 0 A_GiveInventory("CBM_HealThing10_P")
stop
No:
TNT1 A 0
stop
}
}

actor PlantmanShieldWarper : ShieldWarper_CBM
{
+NOTIMEFREEZE
States
{
Shield:
PLAB A 0 A_JumpIfInTargetInventory("PlayerPropertyRage",1,"ShieldR1")
PLAB ABCDEFGH 1 A_Warp(AAPTR_TARGET,0,0,28,0,WARPF_NOCHECKPOSITION+WARPF_INTERPOLATE)//8+16
PLAB I 0 A_JumpIfInTargetInventory("PlayerPropertyRage",1,"ShieldR2")
PLAB IJKLMNOP 1 A_Warp(2,0,0,28,0,8+16)
PLAB Q 0 A_JumpIfInTargetInventory("PlayerPropertyRage",1,"ShieldR3")
PLAB QRSTUVWX 1 A_Warp(2,0,0,28,0,8+16)
PLAB Y 0 A_JumpIfInTargetInventory("PlayerPropertyRage",1,"ShieldR4")
PLAB YZ 1 A_Warp(2,0,0,28,0,8+16)
PBUS RSTUVW 1 A_Warp(2,0,0,28,0,8+16)
loop
ShieldR1:
PLAB ACEG 1 A_Warp(2,0,0,28,0,8+16)
goto Shield+9
ShieldR2:
PLAB IKMO 1 A_Warp(2,0,0,28,0,8+16)
goto Shield+18
ShieldR3:
PLAB QSUW 1 A_Warp(2,0,0,28,0,8+16)
goto Shield+27
ShieldR4:
PLAB Y 1 A_Warp(2,0,0,28,0,8+16)
PBUS RTV 1 A_Warp(2,0,0,28,0,8+16)
goto Shield
}
}

actor PlantShield : ProjSpawnFuncActor
{
PROJECTILE
Obituary "$OB_PLANTBARRIER"
Damagetype "PlantM_Toss"
Damage (200)
Speed 20
Radius 16
Height 16
scale 2.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Jump(256,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32)
SpawnL:
PLAB ABCDEFGHIJKLMNOPQRSTUVWXYZ 1
PBUS RSTUVW 1
loop
}
}

actor PlantShot : ProjSpawnFuncActor
{
PROJECTILE
-NOGRAVITY
+HITTRACER
damagetype "PlantM_Shot"
Obituary "$OB_PLANTBUSTER"
Speed 43
Damage (50)
radius 10
height 5
scale 2.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_ChangeVelocity(0,0,2)
Q_0D E 1
wait
XDeath:
Crash:
Q_0D E 0 A_JumpIf(CallACS("cbm_istracerenemy")==1,"Give")
Goto Death
Give:
Q_0D E 0 A_GiveToTarget("PlantM_ShotHeal_P")
Goto Death
Death:
Q_0D E 1
stop
}
}

actor PlantM_ShotHeal_P : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_GiveInventory("CBM_HealThing10_P")
stop
}
}

actor PlantMDrainer : BasicImplosion
{
Damagetype "PlantM_Barrier"
Obituary "$OB_PLANTDRAIN"
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_Explode(40+CallACS("core_checkrune",RUNE_SPREAD,2)*80,160,0,0,96)
TNT1 A 2 A_Explode(70+CallACS("core_checkrune",RUNE_SPREAD,2)*140,160,0,0,20)
stop
}
}

actor PlantRadiusHeal : BasicHelper
{
States
{
Spawn:
TNT1 A 0
TNT1 A 2
stop
}
}


actor Plantman_W_NormalBar : NormalBar {Args 4,39}
actor Plantman_W_SecondBar : SecondBar {Args 104,60}