Alright, sorry for taking so long! Here is the script and the changes I thought were necessary, rather I thought the guide line for this meant.
<------------------------------------------------------------------>
Option Explicit
'-----Initialize Sprites-----
Dim Hits(2), i
for i = 0 to 2
set Hits(i) = new Hit
Hits(i).Hit "LevelOne","Evil" & i, 5
next
'-----End Initialization-----
Class Hit
Private hMap
Private hSpriteName
Private hHPs
Public 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, oMap
Dim oNewSpecial
for i = 0 to ubound(Hits)
Set
Set oMap = ProjectObj.Maps(Hits(i).getMap())
oNewSpecial.FuncType = 7 ' SPECIAL_EVENT
oNewSpecial.Flags = 8 ' INTFL_RAISEEVENT
oNewSpecial.Name = "COL_" & Hits(i).getSprite()
oMap.AddSpecial(hostObj.AsObject(oNewSpecial))
Next
End Sub
Sub Player_OnSpecialFunction(SpecialObj)
dim i, layer, idx, spr
for i = 0 to UBound(Hits)
spr = Hits(i).getSprite()
if left(SpecialObj.Name,4 + len(spr)) = "COL_" & spr then
set 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
With ProjectObj.GamePlayer.rMap
for i = 0 to .LayerCount - 1
for j = 0 to .MapLayer(i).SpriteCount() - 1
if .MapLayer(i).Sprite(j).rDef.Name = SpriteName then
set oLayer = .MapLayer(i)
oSprIndex = j
set FindSpriteByDef = oLayer.Sprite(j)
end if
next
next
End with
End Function
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16
<----------------------------------------------------------->
I only changed the "Map1" and "Enemy" text from the code. I thought that by changing the name "Map1" in the script would let the computer know which map I am refering to; I changed the "Enemy" text to the name of one of my sprites(which I thought you could have more) and I assumed that it would recognize the enemy but it seems the the script only crashes. I hope you can make sense of that jibberish, I honestly don't know what I am talking about.
What do you think I am doing wrong?
Also, sorry for the huge post...