Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MS4
#34
I browsed through the spawnnpc sub and could not find anything wrong?

Code:
Sub SpawnNpc(ByVal MapNpcNum As Long, ByVal MapNum As Long)
Dim Packet As String
Dim NpcNum As Long
Dim i As Long
Dim x As Long
Dim y As Long
Dim Spawned As Boolean
Dim Buffer As clsBuffer

    ' Check for subscript out of range
    If MapNpcNum  MAX_MAP_NPCS Or MapNum  MAX_MAPS Then
        Exit Sub
    End If
    
    NpcNum = Map(MapNum).Npc(MapNpcNum)
    If NpcNum > 0 Then
        MapNpc(MapNum).Npc(MapNpcNum).Num = NpcNum
        MapNpc(MapNum).Npc(MapNpcNum).Target = 0
        
        MapNpc(MapNum).Npc(MapNpcNum).Vital(Vitals.HP) = GetNpcMaxVital(NpcNum, Vitals.HP)
        MapNpc(MapNum).Npc(MapNpcNum).Vital(Vitals.MP) = GetNpcMaxVital(NpcNum, Vitals.MP)
        MapNpc(MapNum).Npc(MapNpcNum).Vital(Vitals.SP) = GetNpcMaxVital(NpcNum, Vitals.SP)
                
        MapNpc(MapNum).Npc(MapNpcNum).Dir = Int(Rnd * 4)
        
        ' Well try 100 times to randomly place the sprite
        For i = 1 To 100
            x = Int(Rnd * Map(MapNum).MaxX)
            y = Int(Rnd * Map(MapNum).MaxY)
            
            ' Check if the tile is walkable
            If Map(MapNum).Tile(x, y).Type = TILE_TYPE_WALKABLE Then
                MapNpc(MapNum).Npc(MapNpcNum).x = x
                MapNpc(MapNum).Npc(MapNpcNum).y = y
                Spawned = True
                Exit For
            End If
        Next
        
        ' Didn't spawn, so now we'll just try to find a free tile
        If Not Spawned Then
            For x = 0 To Map(MapNum).MaxX
                For y = 0 To Map(MapNum).MaxY
                    If Map(MapNum).Tile(x, y).Type = TILE_TYPE_WALKABLE Then
                        MapNpc(MapNum).Npc(MapNpcNum).x = x
                        MapNpc(MapNum).Npc(MapNpcNum).y = y
                        Spawned = True
                    End If
                Next
            Next
        End If
            
        ' If we suceeded in spawning then send it to everyone
        If Spawned Then
        
            Set Buffer = New clsBuffer
            
            Buffer.WriteLong SSpawnNpc
            Buffer.WriteLong MapNpcNum
            Buffer.WriteLong MapNpc(MapNum).Npc(MapNpcNum).Num
            Buffer.WriteLong MapNpc(MapNum).Npc(MapNpcNum).x
            Buffer.WriteLong MapNpc(MapNum).Npc(MapNpcNum).y
            Buffer.WriteLong MapNpc(MapNum).Npc(MapNpcNum).Dir
            
            SendDataToMap MapNum, Buffer.ToArray()
            
            Set Buffer = Nothing
        End If
    End If
End Sub


On top of that whenever you cast a spell with the required mp you get an RTE9 highlighting.
Code:
MPReq = Spell(SpellNum).MPReq

I personally think that the problem is DX orientated because the npcs do exist just the sprites don't blt,

I dont know very much Dx so im not sure where to continue with it but any help would be great Smile
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)