Mirage Source
MS4 - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+----- Thread: MS4 (/showthread.php?tid=3065)

Pages: 1 2


Re: MS4 - Xlithan - 08-09-2009

Did you get chance to check it out?


Re: MS4 - Matt - 08-09-2009

Xlithan Wrote:Did you get chance to check it out?

Not yet. Still getting adjusted to having a new baby in the house and I've been doin' work on the basement as well. I'll try to get around to it tonight though.


Re: MS4 - xp79 - 09-09-2009

Congrats on the new baby.

Any news about the npc error or what may of caused it?


Re: MS4 - Matt - 09-09-2009

xp79 Wrote:Congrats on the new baby.

Any news about the npc error or what may of caused it?

Pretty sure I fixed it and updated the download.. Lol.


Re: MS4 - xp79 - 10-09-2009

Whenever I reload a map the npc disappears,
In some cases the npc stays there but the sprite doesnt blt.
I did a simple drawtext over them to check where they are and that blts successfully,


Re: MS4 - Matt - 10-09-2009

If I'm not mistaken, it was a packet issue with the spawn npc system. Run through that if you want and if you're using a large map, remember they'll spawn all over the map.


Re: MS4 - xp79 - 10-09-2009

Matt Wrote:If I'm not mistaken, it was a packet issue with the spawn npc system. Run through that if you want and if you're using a large map, remember they'll spawn all over the map.

When you say it "was" il take it you fixed it recently because im using the latest source and im still having the problem,
And dont worry I took that into account Tongue

And thanks il look into it and post my results Smile


Re: MS4 - Matt - 10-09-2009

xp79 Wrote:
Matt Wrote:If I'm not mistaken, it was a packet issue with the spawn npc system. Run through that if you want and if you're using a large map, remember they'll spawn all over the map.

When you say it "was" il take it you fixed it recently because im using the latest source and im still having the problem,
And dont worry I took that into account Tongue

And thanks il look into it and post my results Smile

I'm pretty sure I fixed it, but I don't really remember. I may have fixed it in my game's source, which is based off this source. I'll take a look later. I need to get some sleep for a change.


Re: MS4 - xp79 - 12-09-2009

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


Re: MS4 - Matt - 12-09-2009

I don't exactly remember the problem. I have time today to look at it and I will get it all handled. When it's fixed, I'll update the source download as well as post the fix so that people can fix it in the source they're developing their game with, if someone is doing that. Lol.


Re: MS4 - xp79 - 12-09-2009

I am hopefully planning on using your source Smile
I love the speed of the byte arrays Tongue Plus im not experianced enough to convert it myself Smile

Thanks for getting round to it mate and hope your little'un is well Smile!


Re: MS4 - Robin - 25-09-2009

Editing an item crashes the server. As in, breaks VB6.

EDIT: Dies on the first READ STRING, so I'm guessing it's a problem with the CopyMemory stuff.


Re: MS4 - Robin - 25-09-2009

It was using copymemory for the client, but wasn't reading it like it should server-side.

Anyway, it's all in HandleSaveItem.

Add at top:
Code:
Dim ItemSize As Long
Dim ItemData() As Byte

Replace:
Code:
Item(n).Name = Buffer.ReadString
Item(n).Pic = Buffer.ReadLong
Item(n).Type = Buffer.ReadLong
Item(n).Data1 = Buffer.ReadLong
Item(n).Data2 = Buffer.ReadLong
Item(n).Data3 = Buffer.ReadLong

With:
Code:
ItemSize = LenB(Item(n))
ReDim ItemData(ItemSize - 1)
ItemData = Buffer.ReadBytes(ItemSize)
CopyMemory ByVal VarPtr(Item(n)), ByVal VarPtr(ItemData(0)), ItemSize



Re: MS4 - Matt - 25-09-2009

I posted the fix for NPCs. This is needed for shops and spells too if I recall.


Re: MS4 - Robin - 25-09-2009

Matt Wrote:I posted the fix for NPCs. This is needed for shops and spells too if I recall.

NPCs need a fix? I got this code from the NPC part of the project, and just changed it for Items.


Re: MS4 - Matt - 25-09-2009

Robin Wrote:
Matt Wrote:I posted the fix for NPCs. This is needed for shops and spells too if I recall.

NPCs need a fix? I got this code from the NPC part of the project, and just changed it for Items.

I thought npcs were the only problem the first time I updated it with the fix. I fixed everything before, guess I forgot to upload it. I don't have it anymore though..


Re: MS4 - Matt - 25-09-2009

Matt Wrote:Server side find:

Code:
Sub HandleSaveNPC

Replace the whole sub with:

Code:
Private Sub HandleSaveNpc(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim NpcNum As Long
Dim Buffer As clsBuffer
Dim NpcSize As Long
Dim NpcData() As Byte

    ' Prevent hacking
    If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
        Call HackingAttempt(Index, "Admin Cloning")
        Exit Sub
    End If
    
    Set Buffer = New clsBuffer

    Buffer.WriteBytes Data()
    
    NpcNum = Buffer.ReadLong
    
    ' Prevent hacking
    If NpcNum < 0 Or NpcNum > MAX_NpcS Then
        Call HackingAttempt(Index, "Invalid Npc Index")
        Exit Sub
    End If
    
    NpcSize = LenB(Npc(NpcNum))
    ReDim NpcData(NpcSize - 1)
    NpcData = Buffer.ReadBytes(NpcSize)
    CopyMemory ByVal VarPtr(Npc(NpcNum)), ByVal VarPtr(NpcData(0)), NpcSize
    
    ' Save it
    Call SendUpdateNpcToAll(NpcNum)
    Call SaveNpc(NpcNum)
    Call AddLog(GetPlayerName(Index) & " saved Npc #" & NpcNum & ".", ADMIN_LOG)
End Sub

I have also already updated the source download.

That's the fix for NPCs that I posted on the first page.


Re: MS4 - Robin - 25-09-2009

Oh, that was in the source I downloaded anyway.

Just copying the stuff across to the other subs works fine.


Re: MS4 - Matt - 25-09-2009

Robin Wrote:Oh, that was in the source I downloaded anyway.

Just copying the stuff across to the other subs works fine.

Yeah, I know. Like I said, I updated the download when I found the NPC editor issue, but I thought that was the only one so I didn't fix the others until later and I forgot to upload the fixed source. Lol.

Thanks for the help.