actor CandyCaneWep_NormalBar : NormalBar{args 87, 41}
actor CandyCaneWep : BaseMM8BDMWep
{
Weapon.AmmoUse 2
Weapon.AmmoGive 27
Weapon.SlotNumber 3
Obituary "$OB_CANDYCANE"
Inventory.Pickupmessage "$PU_CANDYCANE" 
Tag "$TAG_CANDYCANE"
weapon.ammotype "CandyCaneAmmo"
inventory.icon "CCANICON"
Scale 2.0
States
{
SpawnLoop: 
CCAN Z 1
loop
Ready: 
CCAN A 0
CCAN A 0 ACS_NamedExecuteWithResult("core_weaponcolor",COLOR_CANDYCANE) 
CCAN A 1 A_WeaponReady
Goto Ready+2
ReadyC: Goto Ready+2
Deselect: 
CCAN A 0
goto DeselectSwap
Select: 
CCAN A 0
goto SelectSwap
Fire: 
CCAN A 0 A_JumpIfNoAmmo("NoAmmo") 
CCAN A 0 A_PlaySoundEx("misc/fakeshot","Weapon")
CCAN A 0 A_FireCustomMissile("CandyCane",0,1,8,0)
CCAN BC 2
CCAN A 2
CCAN B 0 A_Refire
Goto Ready+2 
NoAmmo: 
CCAN A 1 ACS_NamedExecute("core_noammo",0)
Goto Ready+2
}
}

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

actor CandyCane_90D_Fix : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_JumpIf(pitch>=90,"Recoil")
TNT1 A 0 A_JumpIf(pitch<=-90,"Recoil")
stop
Recoil:
TNT1 A 0 A_Recoil(0.5)
stop
}
}

actor CandyCaneVerticalFlag : Once {}
actor CandyCaneVerticalFlag2 : Once {}

actor CandyCane : BasicFastProjectile
{
+DONTBLAST
species "MovingPlatform" // It creates a platform that is solid
//+THRUSPECIES
+HITTRACER
+CANPASS
Obituary "$OB_CANDYCANE"
PROJECTILE
Damage (CallACS("vile_cbm_damage",13))
damagetype "CandyCane"
speed 50
Scale 2.5
Height 32
Radius 16
States
{
Spawn:
CCAN EE 0 A_Recoil(0.01)
TNT1 A 0 A_JumpIf(momz<=-40, "VerticalCheck")
TNT1 A 0 A_JumpIf(momz>=40, "VerticalCheck2")
CCAN D 2
wait
VerticalCheck:
CCAN H 0 A_GiveInventory("CandyCaneVerticalFlag",1)
CCAN H 2
wait
VerticalCheck2:
CCAN H 0 A_GiveInventory("CandyCaneVerticalFlag2",1)
CCAN H 2
wait
Die:
CCAN D 0
stop

XDeath:
CCAN E 0 A_CheckFlag(SOLID,"XDeathC",AAPTR_TRACER)
XDeath.End:
CCAN E 0 
stop
XDeathC:
CCAN E 0 A_CheckFlag(SHOOTABLE,2,AAPTR_TRACER)
goto Death
CCAN E 0 A_CheckFlag(ISMONSTER,"XDeath.End1",AAPTR_TRACER)
CCAN E 0 A_CheckFlag(MISSILE,"XDeath.End3",AAPTR_TRACER)
CCAN E 0 A_JumpIfInventory("MM8BDMPlayer",1,"XDeath.End4",AAPTR_TRACER)
goto Death
XDeath.End1:
CCAN E 0 
goto XDeath.End
XDeath.End3:
CCAN E 0 
goto XDeath.End
XDeath.End4:
CCAN E 0
goto XDeath.End
Death:
CCAN E 0 A_JumpIfInventory("CandyCaneVerticalFlag2",1,"CeilingCane")
CCAN E 0 A_CheckCeiling("CeilingCane")
CCAN E 0 A_JumpIfInventory("CandyCaneVerticalFlag",1,"FloorCane")
CCAN E 0 A_CheckFloor("FloorCane")
CCAN E 4
CCAN E 0 A_JumpIfCloser(48, "XDeath")
CCAN E 0 A_PlaySoundEx("weapon/candycane","Weapon")
CCAN E 0 A_SpawnItemEx("CandyCaneBlock",0,0,0,0,0,0,0)
stop
FloorCane:
CONC D 0 A_SetAngle(0)
CCAN G 4
CCAN G 0 A_JumpIfCloser(48, "XDeath")
CCAN G 0 A_PlaySoundEx("weapon/candycane","Weapon")
CCAN G 0 A_SpawnItemEx("CandyCaneBlockFloor",0,0,0,0,0,0,0)
TNT1 A 2
stop
CeilingCane:
CONC D 0 A_SetAngle(0)
CCAN G 4
CCAN G 0 A_JumpIfCloser(48, "XDeath")
CCAN G 0 A_PlaySoundEx("weapon/candycane","Weapon")
CCAN G 0 A_SpawnItemEx("CandyCaneBlockFloor",0,0,-8,0,0,0,0)
TNT1 A 2
stop
}
}

actor CandyCaneBlock : ProjSpawnFuncActor
{
height 32
radius 16
scale 2.5
+FORCEYBILLBOARD
+GHOST
+NOGRAVITY
+DONTRIP
+CANTSEEK
+MISSILE
+TOUCHY
+SHOOTABLE
+NOTAUTOAIMED
+NOBLOOD
+DONTBLAST
+DONTDRAIN
species "MovingPlatform"
+THRUSPECIES
Health 9999
Mass 9999
+USEDAMAGEEVENTSCRIPT
var int user_NoOwnerDamage;
States
{
Spawn:
CCAN F 0
CCAN F 0 A_JumpIf(CallACS("core_getPlayersInRadius", 20, PRF_CUBE|PRF_CHECKCOLLISION) > 0, "Death")
CCAN F 1
CCAN F 0 A_ChangeFlag(TOUCHY, false)
CCAN F 0 A_ChangeFlag(MISSILE, false)
CCAN F 0 A_ChangeFlag(SOLID, true)
CCAN F 154
CCAN EFEFEF 2
Goto Death
Death:
CCAN B 0 A_NoBlocking
CCAN E 3 A_SpawnItemEx("ExplosionEffect1")
TNT1 A 2
stop
}
}

actor CandyCaneBlockFloor : CandyCaneBlock
{
States
{
Spawn:
CCAN H 0
CCAN H 0 A_JumpIf(CallACS("core_getPlayersInRadius", 20, PRF_CUBE|PRF_CHECKCOLLISION) > 0, "Death")
CCAN H 1
CCAN H 0 A_ChangeFlag(TOUCHY, false)
CCAN H 0 A_ChangeFlag(MISSILE, false)
CCAN H 0 A_ChangeFlag(SOLID, true)
CCAN H 154
CCAN GHGHGHGHGH 2
Goto Death
Death:
CCAN G 0 A_NoBlocking
CCAN G 3 A_SpawnItemEx("ExplosionEffect1")
TNT1 G 2
stop
}
}

