Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Pet System script (No Longer Beign Worked On)


Dennys
 Share

Recommended Posts

  • Replies 417
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

~~Idk, some script problems, now there's a problem, "script out of range" when i try to join the game >.>~~

Nevermind everything works perfectly. Good job. Our progress is like 50% done.

EDID: The only bug right now is, when you lauch the client, it gives an error, re-creates config.ini to default IP: 127.0.0.1 and port 4001, so basically people on my server have to put the ip and the port every since time.
Link to comment
Share on other sites

lol my brain is overloaded… been a while since ive had to think so much xD, i remember the first day of this project i spent all night thinkign about it and thoughts changed and by the end of the night i had figured out a plan to remodel my room to have more space xD
Link to comment
Share on other sites

@Bloodmyst:

> Hmm check your config and read me the insides….. Anyways ill fix it via hardcode and send you it but ill give you a temporary Fix
>
> Btw VintihooxD once we get to sadscripting ill call you(PM you)

DONT IGNORE ME :(
Link to comment
Share on other sites

Heres Fix:
Replace THese 2 Subs in ModGeneral:
```
Private Sub LoadConfig()
    Dim FileName As String

    On Error GoTo ErrorHandle

    FileName = App.path & "\config.ini"

    frmMirage.chkBubbleBar.Value = CLng(ReadINI("CONFIG", "SpeechBubbles", FileName))
    frmMirage.chkNpcBar.Value = CLng(ReadINI("CONFIG", "NpcBar", FileName))
    frmMirage.chkPetBar.Value = CLng(ReadINI("PET", "PETBar", FileName))
    frmMirage.chkNpcName.Value = CLng(ReadINI("CONFIG", "NPCName", FileName))
    frmMirage.chkPetName.Value = CLng(ReadINI("PET", "PETName", FileName))
    frmMirage.chkPlayerBar.Value = CLng(ReadINI("CONFIG", "PlayerBar", FileName))
    frmMirage.chkPlayerName.Value = CLng(ReadINI("CONFIG", "PlayerName", FileName))
    frmMirage.chkPlayerDamage.Value = CLng(ReadINI("CONFIG", "NPCDamage", FileName))
    frmMirage.chkNpcDamage.Value = ReadINI("CONFIG", "PlayerDamage", FileName)
  ' frmMirage.chkMusic.Value = CLng(ReadINI("CONFIG", "Music", FileName)) <-- This caused connectivity issues upon disabling music [Devil Of Duce]
    frmMirage.chkSound.Value = CLng(ReadINI("CONFIG", "Sound", FileName))
    frmMirage.chkAutoScroll.Value = CLng(ReadINI("CONFIG", "AutoScroll", FileName))
    AutoLogin = CLng(ReadINI("CONFIG", "Auto", FileName))

    Exit Sub

ErrorHandle:
    Call MsgBox("Error reading from config.ini, re-creating file.")
    Kill "config.ini"
    Call FileCreateConfigINI

End Sub

Private Sub FileCreateConfigINI()
    WriteINI "IPCONFIG", "IP", "127.0.0.1", App.path & "\config.ini"
    WriteINI "IPCONFIG", "PORT", 4001, App.path & "\config.ini"

    WriteINI "CONFIG", "Account", vbNullString, App.path & "\config.ini"
    WriteINI "CONFIG", "Password", vbNullString, App.path & "\config.ini"
    WriteINI "CONFIG", "WebSite", vbNullString, App.path & "\config.ini"
    WriteINI "CONFIG", "SpeechBubbles", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "NpcBar", 1, App.path & "\config.ini"
    WriteINI "PET", "PETBar", 1, App.path & "\config.ini"
    WriteINI "PET", "PETName", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "NPCName", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "NPCDamage", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "PlayerBar", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "PlayerName", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "PlayerDamage", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "MapGrid", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "Music", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "Sound", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "AutoScroll", 1, App.path & "\config.ini"
    WriteINI "CONFIG", "Auto", 0, App.path & "\config.ini"
End Sub
```
Link to comment
Share on other sites

I already added SpawnPet all we need to do is ScriptSpawnPet….. which will go in Clscommands used by sadscripts. Unless we decide not to do any sadscript. And we make some sort of System Purely by coding, But then its hard to Make it Smmon pet from item *BRAIN POPS*
Link to comment
Share on other sites

Not an item ,but SPELL. Did you do this code? :

```
Sub ScriptSpawnNpc(ByVal MapNpcNum As Long, ByVal MapNum As Long, ByVal spawn_X As Long, ByVal spawn_Y As Long, ByVal NPCnum As Long)
    ' NPC_index              map_number          X spawn          Y spawn            NPC_number
    Dim packet As String
    Dim I As Long

    ' Check for subscript out of range
    If MapNpcNum < 0 Or MapNpcNum > MAX_MAP_NPCS Or MapNum <= 0 Or MapNum > MAX_MAPS Then
        Exit Sub
    End If

    If NPCnum = 0 Then
        Map(MapNum).Revision = Map(MapNum).Revision + 1
        MapNPC(MapNum, MapNpcNum).num = 0
        Map(MapNum).NPC(MapNpcNum) = 0
        MapNPC(MapNum, MapNpcNum).Target = 0
        MapNPC(MapNum, MapNpcNum).HP = 0
        MapNPC(MapNum, MapNpcNum).MP = 0
        MapNPC(MapNum, MapNpcNum).SP = 0
        MapNPC(MapNum, MapNpcNum).Dir = 0
        MapNPC(MapNum, MapNpcNum).X = 0
        MapNPC(MapNum, MapNpcNum).Y = 0

        ' Packet = "SPAWNNPC" & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(mapnum, MapNpcNum).num & SEP_CHAR & MapNpc(mapnum, MapNpcNum).X & SEP_CHAR & MapNpc(mapnum, MapNpcNum).Y & SEP_CHAR & MapNpc(mapnum, MapNpcNum).Dir & SEP_CHAR & Npc(MapNpc(mapnum, MapNpcNum).num).Big & END_CHAR
        ' Call SendDataToMap(mapnum, Packet)
        Call SaveMap(MapNum)
    End If

' MapNpc(mapnum, MapNpcNum).num = 0
' MapNpc(mapnum, MapNpcNum).SpawnWait = GetTickCount
' MapNpc(mapnum, MapNpcNum).HP = 0
' Call SendDataToMap(mapnum, "NPCDEAD" & SEP_CHAR & MapNpcNum & END_CHAR)

    Map(MapNum).Revision = Map(MapNum).Revision + 1

    MapNPC(MapNum, MapNpcNum).num = NPCnum
    Map(MapNum).NPC(MapNpcNum) = NPCnum

    MapNPC(MapNum, MapNpcNum).Target = 0

    MapNPC(MapNum, MapNpcNum).HP = GetNpcMaxHP(NPCnum)
    MapNPC(MapNum, MapNpcNum).MP = GetNpcMaxMP(NPCnum)
    MapNPC(MapNum, MapNpcNum).SP = GetNpcMaxSP(NPCnum)

    MapNPC(MapNum, MapNpcNum).Dir = Int(Rnd * 4)

    MapNPC(MapNum, MapNpcNum).X = spawn_X
    MapNPC(MapNum, MapNpcNum).Y = spawn_Y

    packet = "SPAWNNPC" & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNPC(MapNum, MapNpcNum).num & SEP_CHAR & MapNPC(MapNum, MapNpcNum).X & SEP_CHAR & MapNPC(MapNum, MapNpcNum).Y & SEP_CHAR & MapNPC(MapNum, MapNpcNum).Dir & SEP_CHAR & NPC(MapNPC(MapNum, MapNpcNum).num).Big & END_CHAR
    Call SendDataToMap(MapNum, packet)

    Call SaveMap(MapNum)

    For I = 1 To MAX_PLAYERS
        If IsPlaying(I) And GetPlayerMap(I) = MapNum Then
            Call SendDataTo(I, "CHECKFORMAP" & SEP_CHAR & GetPlayerMap(I) & SEP_CHAR & Map(GetPlayerMap(I)).Revision & END_CHAR)
        End If
    Next I

End Sub
```
This is for spawn. And this is how you call it out:

```
Sub ScriptSpawnNpc(ByVal MapNpcNum As Long, ByVal MapNum As Long, ByVal spawn_X As Long, ByVal spawn_Y As Long, ByVal NPCnum As Long
```
EDIT: lol exept change the NPC to Pet and that's it.
Link to comment
Share on other sites

No i did this code which is used by server Not by sadscripting.
```
Sub SpawnPet(ByVal MapPetNum As Long, ByVal MapNum As Long)
    Dim packet As String
    Dim PETnum As Long
    Dim I As Long
    Dim X As Long
    Dim Y As Long
    Dim Spawned As Boolean

    ' Check for subscript out of range
    If MapPetNum < 1 Or MapPetNum > MAX_MAP_PETS Or MapNum < 1 Or MapNum > MAX_MAPS Then
        Exit Sub
    End If

    PETnum = Map(MapNum).PET(MapPetNum)

    If PETnum > 0 Then
        If GameTime = TIME_NIGHT Then
            If PETS(PETnum).SpawnTime = 1 Then
                MapPET(MapNum, MapPetNum).num = 0
                MapPET(MapNum, MapPetNum).SpawnWait = GetTickCount
                MapPET(MapNum, MapPetNum).HP = 0
                Call SendDataToMap(MapNum, "PetDEAD" & SEP_CHAR & MapPetNum & END_CHAR)
                Exit Sub
            End If
        Else
            If PETS(PETnum).SpawnTime = 2 Then
                MapPET(MapNum, MapPetNum).num = 0
                MapPET(MapNum, MapPetNum).SpawnWait = GetTickCount
                MapPET(MapNum, MapPetNum).HP = 0
                Call SendDataToMap(MapNum, "PETDEAD" & SEP_CHAR & MapPetNum & END_CHAR)
                Exit Sub
            End If
        End If

        MapPET(MapNum, MapPetNum).num = PETnum
        MapPET(MapNum, MapPetNum).Target = 0

        MapPET(MapNum, MapPetNum).HP = GetNpcMaxHP(PETnum)
        MapPET(MapNum, MapPetNum).MP = GetNpcMaxMP(PETnum)
        MapPET(MapNum, MapPetNum).SP = GetNpcMaxSP(PETnum)

        MapPET(MapNum, MapPetNum).Dir = Int(Rnd * 4)

        ' This means the admin wants to do a random spawn. [Mellowz]
        If Map(MapNum).SpawnX(MapPetNum) = 0 Or Map(MapNum).SpawnY(MapPetNum) = 0 Then
            For I = 1 To 100
                X = Int(Rnd * MAX_MAPX)
                Y = Int(Rnd * MAX_MAPY)

                If Map(MapNum).Tile(X, Y).Type = TILE_TYPE_WALKABLE Then
                    MapPET(MapNum, MapPetNum).X = X
                    MapPET(MapNum, MapPetNum).Y = Y
                    Spawned = True
                    Exit For
                End If
            Next I

            ' Didn't spawn, so now we'll just try to find a free tile
            If Not Spawned Then
                For Y = 0 To MAX_MAPY
                    For X = 0 To MAX_MAPX
                        If Map(MapNum).Tile(X, Y).Type = TILE_TYPE_WALKABLE Then
                            MapNPC(MapNum, MapPetNum).X = X
                            MapNPC(MapNum, MapPetNum).Y = Y
                            Spawned = True
                        End If
                    Next X
                Next Y
            End If
        Else
            ' We subtract one because Rand is ListIndex 0\. [Mellowz]
            MapPET(MapNum, MapPetNum).X = Map(MapNum).SpawnX(MapPetNum) - 1
            MapPET(MapNum, MapPetNum).Y = Map(MapNum).SpawnY(MapPetNum) - 1
            Spawned = True
        End If

        ' If we suceeded in spawning then send it to everyone
        If Spawned Then
            packet = "SPAWNPET" & SEP_CHAR & MapPetNum & SEP_CHAR & MapPET(MapNum, MapPetNum).num & SEP_CHAR & MapPET(MapNum, MapPetNum).X & SEP_CHAR & MapPET(MapNum, MapPetNum).Y & SEP_CHAR & MapPET(MapNum, MapPetNum).Dir & SEP_CHAR & PETS(MapPET(MapNum, MapPetNum).num).Big & END_CHAR
            Call SendDataToMap(MapNum, packet)
        End If
    End If

    ' Enable this to display HP when monsters spawn.
    ' Call SendDataToMap(MapNum, "npchp" & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNPC(MapNum, MapNpcNum).HP & SEP_CHAR & GetNpcMaxHP(MapNPC(MapNum, MapNpcNum).num) & END_CHAR)
End Sub
```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...