also, i just put the first section in to replace
Dim Hits(16)
Dim i
for i = 0 to 3
set Hits(i) = new Hit
Hits(i) "5-0TheMoon","MJW" & i + 1,2
next
for i = 4 to 16
set Hits(i) = new Hit
Hits(i) "5-0TheMoon","MS" & i - 3,3
next
so now i have this
Option Explicit
Class Hit
Private hMap
Private hSpriteName
Private hHPs
Public Default Sub Hit(Map, SpriteName, HPs)
hMap = Map
hSpriteName = SpriteName
hHPs = HPs
End Sub
public function getMap()
getMap = hMap
End function
public function getSprite()
getSprite = hSpriteName
End function
public function getHPs()
getHPs = hHPs
end function
End Class
Sub Player_OnPlayInit()
Dim i
Dim oNewSpecial
Set oNewSpecial = NewSpecialFunction
for i = 0 to ubound(Hits)
oMap = ProjectObj.Maps(Hits(i).getMap())
oNewSpecial.FuncType = 7 ' SPECIAL_EVENT
oNewSpecial.Name = "COL_" & Hits(i).getSprite()
oMap.AddSpecial(hostObj.AsObject(oNewSpecial))
Next
End Sub
Sub Player_OnSpecialFunction(SpecialObj)
dim i, layer, idx
for i = 0 to UBound(Hits)
spr = Hits(i).getSprite()
if left(Special.Name,4 + len(spr)) = "COL_" & spr then
spr = FindSpriteByDef(spr,layer,idx)
if spr.UserData > Hits(i).getHPs() or spr.UserData < 0 then spr.UserData = 0
spr.UserData = spr.UserData + 1
if spr.UserData = Hits(i).getHPs() then
layer.RemoveSprite(idx)
end if
end if
next
End Sub
Function FindSpriteByDef(SpriteName, byref oLayer, byref oSprIndex)
dim i, j
oMap = ProjectObj.GamePlayer.rMap
for i = 0 to rMap.LayerCount
for j = 0 to rMap.MapLayer(i).SpriteCount()
if rMap.MapLayer(i).Sprite(j).SpriteDef.Name = SpriteName then
set oLayer = rMap.MapLayer(i)
oSprIndex = j
set FindSpriteByDef = oLayer.Sprite(j)
end if
next
next
End Function
'-----Initialize Sprites-----
Dim NewHit, MyHit(1)
Set NewHit = New Hit
NewHit "5-0TheMoon","MJW1-4",2
Set MyHit(0) = NewHit
Set NewHit = New Hit
NewHit "5-0TheMoon","MS1-13",3
Set MyHit(1) = NewHit
'-----End initialization-----
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16