here is all of it, it is not that long
Dim nExpectCount
Dim nShot0Count
Dim arBtn0Shots(2)
Dim nShot2Count
Dim arBtn2Shots(0)
Dim nShot3Count
Dim arBtn3Shots(1)
Sub Player_OnControllerMove(OldActions, NewActions)
If (Not OldActions) And NewActions And ACTION_BUTTON1 Then DoFireButton0
If (Not OldActions) And NewActions And ACTION_BUTTON3 Then DoFireButton2
If (Not OldActions) And NewActions And ACTION_BUTTON4 Then DoFireButton3
End Sub
Sub RecountShots()
Dim nSIdx, nLIdx
With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
nSIdx = 0
Do While nSIdx < nShot0Count
For nLIdx = 0 to .SpriteCount - 1
If arBtn0Shots(nSIdx) Is .Sprite(nLIdx) Then
Exit For
End If
Next
If nLIdx >= .SpriteCount Then
Set arBtn0Shots(nSIdx) = arBtn0Shots(nShot0Count - 1)
nShot0Count = nShot0Count - 1
Else
nSIdx = nSIdx + 1
End If
Loop
nSIdx = 0
Do While nSIdx < nShot2Count
For nLIdx = 0 to .SpriteCount - 1
If arBtn2Shots(nSIdx) Is .Sprite(nLIdx) Then
Exit For
End If
Next
If nLIdx >= .SpriteCount Then
Set arBtn2Shots(nSIdx) = arBtn2Shots(nShot2Count - 1)
nShot2Count = nShot2Count - 1
Else
nSIdx = nSIdx + 1
End If
Loop
nSIdx = 0
Do While nSIdx < nShot3Count
For nLIdx = 0 to .SpriteCount - 1
If arBtn3Shots(nSIdx) Is .Sprite(nLIdx) Then
Exit For
End If
Next
If nLIdx >= .SpriteCount Then
Set arBtn3Shots(nSIdx) = arBtn3Shots(nShot3Count - 1)
nShot3Count = nShot3Count - 1
Else
nSIdx = nSIdx + 1
End If
Loop
nExpectCount = .SpriteCount
End With
End Sub
Sub RemoveShot(Spr)
Dim nIdx
With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
For nIdx = 0 to .SpriteCount - 1
If .Sprite(nIdx) Is Spr Then .RemoveSprite(nIdx) : Exit Sub
Next
End With
End Sub
Function GetStateDeltas(DX, DY)
With ProjectObj.GamePlayer.PlayerSprite
Select Case .rDef.Template.StateType
Case STATE_SINGLE
If Abs(DX) + Abs(DY) > 1 Then
DX = .DX / (Abs(.DX) + Abs(.DY))
DY = .DY / (Abs(.DX) + Abs(.DY))
Else
If Abs(DX) + Abs(DY) < 1 Then DX = 0 : DY = -1
End If
Case STATE_LEFT_RIGHT
DY = 0
If (.CurState Mod 2) = 0 Then DX = -1 Else DX = 1
Case STATE_8_DIRECTION
Select Case (.CurState Mod

Case 0 : DX = 0 : DY = -1
Case 1 : DX = 1 : DY = -1
Case 2 : DX = 1 : DY = 0
Case 3 : DX = 1 : DY = 1
Case 4 : DX = 0 : DY = 1
Case 5 : DX = -1 : DY = 1
Case 6 : DX = -1 : DY = 0
Case 7 : DX = -1 : DY = -1
End Select
Case Else
DX = Cos((.CurState Mod 36) * 3.14159 / 18)
DY = -Sin((.CurState Mod 36) * 3.14159 / 18)
End Select
End With
End Function
Sub Player_OnAfterMoveSprites
Dim nIdx, VLeft, VTop, VRight, VBottom, VDat
With ProjectObj.GamePlayer
VLeft = .MapScrollX
VTop = .MapScrollY
VRight = VLeft + .rMap.ViewWidth
VBottom = VTop + .rMap.ViewHeight
End With
If nExpectCount <> ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.SpriteCount Then RecountShots
nIdx = 0
Do While nIdx < nShot0Count
With arBtn0Shots(nIdx)
If .X < VLeft Or .X > VRight Or .Y < VTop Or .Y > VBottom Or (.DX = 0 And .DY = 0) Then
RemoveShot arBtn0Shots(nIdx)
Set arBtn0Shots(nIdx) = arBtn0Shots(nShot0Count - 1)
nShot0Count = nShot0Count - 1
nExpectCount = nExpectCount - 1
Else
nIdx = nIdx + 1
End if
End With
Loop
If nExpectCount <> ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.SpriteCount Then RecountShots
nIdx = 0
Do While nIdx < nShot2Count
With arBtn2Shots(nIdx)
If .X < VLeft Or .X > VRight Or .Y < VTop Or .Y > VBottom Or (.DX = 0 And .DY = 0) Then
RemoveShot arBtn2Shots(nIdx)
Set arBtn2Shots(nIdx) = arBtn2Shots(nShot2Count - 1)
nShot2Count = nShot2Count - 1
nExpectCount = nExpectCount - 1
Else
nIdx = nIdx + 1
End if
End With
Loop
If nExpectCount <> ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.SpriteCount Then RecountShots
nIdx = 0
Do While nIdx < nShot3Count
With arBtn3Shots(nIdx)
If .X < VLeft Or .X > VRight Or .Y < VTop Or .Y > VBottom Or (.DX = 0 And .DY = 0) Then
RemoveShot arBtn3Shots(nIdx)
Set arBtn3Shots(nIdx) = arBtn3Shots(nShot3Count - 1)
nShot3Count = nShot3Count - 1
nExpectCount = nExpectCount - 1
Else
nIdx = nIdx + 1
End if
End With
Loop
End Sub
Sub DoFireButton0()
Dim NewSpr, DX, DY
If nShot0Count >= 3 Then Exit Sub
If ProjectObj.GamePlayer.InvQuantityOwned(2) < 2 Then Exit sub
ProjectObj.GamePlayer.InvQuantityOwned(2) = ProjectObj.GamePlayer.InvQuantityOwned(2) - 2
Set NewSpr = ProjectObj.GamePlayer.rMap.SpriteDefs("pulsar_laser").MakeInstance
Set arBtn0Shots(nShot0Count) = NewSpr
nShot0Count = nShot0Count + 1
With ProjectObj.GamePlayer.PlayerSprite
.rDef.rLayer.AddSprite HostObj.AsObject(NewSpr)
nExpectCount = nExpectCount + 1
NewSpr.X = .X + (.Width - NewSpr.Width) / 2
NewSpr.Y = .Y + (.Height - NewSpr.Height) / 2
GetStateDeltas DX, DY
NewSpr.DX = DX * NewSpr.rDef.Template.MoveSpeed
NewSpr.DY = DY * NewSpr.rDef.Template.MoveSpeed
If NewSpr.rDef.Template.StateCount = 36 Then NewSpr.CurState = RectToPolarState(DX, DY)
ProjectObj.MediaMgr.Clip("pulsar").Play
End With
End Sub
Sub DoFireButton2()
Dim NewSpr, DX, DY
If nShot2Count >= 1 Then Exit Sub
If ProjectObj.GamePlayer.InvQuantityOwned(2) < 3 Then Exit sub
If ProjectObj.GamePlayer.InvQuantityOwned(10) < 1 Then Exit sub
ProjectObj.GamePlayer.InvQuantityOwned(2) = ProjectObj.GamePlayer.InvQuantityOwned(2) - 3
Set NewSpr = ProjectObj.GamePlayer.rMap.SpriteDefs("plasma_rifle").MakeInstance
Set arBtn2Shots(nShot2Count) = NewSpr
nShot2Count = nShot2Count + 1
With ProjectObj.GamePlayer.PlayerSprite
.rDef.rLayer.AddSprite HostObj.AsObject(NewSpr)
nExpectCount = nExpectCount + 1
NewSpr.X = .X + (.Width - NewSpr.Width) / 2
NewSpr.Y = .Y + (.Height - NewSpr.Height) / 2
GetStateDeltas DX, DY
NewSpr.DX = DX * NewSpr.rDef.Template.MoveSpeed
NewSpr.DY = DY * NewSpr.rDef.Template.MoveSpeed
If NewSpr.rDef.Template.StateCount = 36 Then NewSpr.CurState = RectToPolarState(DX, DY)
ProjectObj.MediaMgr.Clip("plasma_rifle").Play
End With
End Sub
Sub DoFireButton3()
Dim NewSpr, DX, DY
If nShot3Count >= 2 Then Exit Sub
If ProjectObj.GamePlayer.InvQuantityOwned(2) < 2 Then Exit sub
If ProjectObj.GamePlayer.InvQuantityOwned(4) < 1 Then Exit sub
ProjectObj.GamePlayer.InvQuantityOwned(2) = ProjectObj.GamePlayer.InvQuantityOwned(2) - 2
Set NewSpr = ProjectObj.GamePlayer.rMap.SpriteDefs("freeze_ray").MakeInstance
Set arBtn3Shots(nShot3Count) = NewSpr
nShot3Count = nShot3Count + 1
With ProjectObj.GamePlayer.PlayerSprite
.rDef.rLayer.AddSprite HostObj.AsObject(NewSpr)
nExpectCount = nExpectCount + 1
NewSpr.X = .X + (.Width - NewSpr.Width) / 2
NewSpr.Y = .Y + (.Height - NewSpr.Height) / 2
GetStateDeltas DX, DY
NewSpr.DX = DX * NewSpr.rDef.Template.MoveSpeed
NewSpr.DY = DY * NewSpr.rDef.Template.MoveSpeed
If NewSpr.rDef.Template.StateCount = 36 Then NewSpr.CurState = RectToPolarState(DX, DY)
ProjectObj.MediaMgr.Clip("freeze_ray").Play
End With
End Sub
Function RectToPolarState(X, Y)
Dim Angle, Pi
Pi = 3.14159
If X <> 0 Then
Angle = Atn(-Y / X)
Else
Angle = -(Pi / 2) * Sgn(Y)
End If
If X < 0 Then
Angle = Pi + Angle
ElseIf Y > 0 Then
Angle = Pi * 2 + Angle
End If
RectToPolarState = ((Angle * 18) / Pi) Mod 36
End Function
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16