So here is the code:
[Statedef 850]
type = S
physics = S
movetype= I
anim = 850 ;Roll anim
ctrl = 0
velset = 0,0
[State 850, fx]
type = Playsnd ;sfx
trigger1 = AnimElem = 2
value = 0, ifelse (Random <= 500, 0, 1)
channel = 1
[State 850, Velocity]
type = VelSet
trigger1 = AnimElemTime(2) >= 0 && AnimElemTime(5) <= 0 ;whatever you want here
x = ifelse (AnimElemTime(5) = 0, 0, 11) ;whatever you want here
[State 850, dust]
type = Explod ;fx
trigger1 = Time % 3=0
sprpriority = 7
anim = 9185
postype = P1
pos = ifelse(random<500,15,20),ifelse(random<500,5,3)
accel = ifelse(random<500,.09,.05),0
random = 8,60
removeongethit = 1
facing = -1
ownpal = 1
supermovetime = 9999
pausemovetime = 9999
scale = .5,.5
[State 850, HitBy]
type = HitBy ;not throw invul
trigger1 = 1
value = SCA, NT,ST,HT
[State 850, Push]
type = PlayerPush ;no push
trigger1 = AnimElemTime(2) > 0 ;whatever you want here
value = 0
[State 850, AfterImage]
type = Afterimage
trigger1 = AnimElem = 2
time = 14
length = 8
FrameGap = 3
PalBright = 1,1,1
PalContrast = 128,128,128
PalAdd = 0,0,0
PalMul = 1,1,1
trans = add1
[State 850, Ctrl]
type = CtrlSet
trigger1 = AnimElemTime(6) = 0
value = 1
[State 850, StateChange]
type = Changestate
trigger1 = AnimTime = 0
value = 11
;ctrl = 1