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

[EO] Pet System Cache FIX


RyokuHasu
 Share

Recommended Posts

Anyone else notice that when you have more than 1 player while a pet is out the game get a little unstable? You cant leave map with a pet then go back to the same map, you cant log onto a map with a pet on it, ect. Its a simple error with the Cache that can be fixed in a few easy steps.

The pet system was tested on several games and the results always pointed to the Cache as the problem, this uses a simplified cache to store pets. However it will limit the pets per map to only 10.

Lightning's Pet System. All credit for the original base Goes to Lightning.
PreRequired: http://www.touchofdeathforums.com/smf/index.php/topic,69521.0/topicseen.html

Credit for The new cache is mine, but you don't have to include me in your creds. (Unless you used my items summoning, then cred me)

**Client Side**

In modHandleData

In Private Sub HandleNPCCache

comment out or delete
```
SaveMap (MapNum)
```

**ServerSide**

in modTypes

In Public Type PetRec

at the bottom add
```
CNum As Long
```
In modGameLogic

in Sub PetDisband

From
```
'Cache the Pets for players logging on [Remove Number from array]
```to
```
're-warp the players on the map
```
replace with
```
PetMapCache(mapNum).Pet(Player(index).Pet.CNum) = 0

    Call ClearSingleMapNpc(TempPlayer(index).TempPetSlot, mapNum)
    Map(GetPlayerMap(index)).NPC(TempPlayer(index).TempPetSlot) = 0
    TempPlayer(index).TempPetSlot = 0

```
In Sub SpawnPet

from
```
'Cache the Pets for players logging on [Add new Number to array]
```to just before
```
Select Case GetPlayerDir(index)
```
replace with
```
For i = 1 To 10
        If PetMapCache(PlayerMap).Pet(i) = 0 Then
            PetMapCache(PlayerMap).Pet(i) = PetSlot
            Player(index).Pet.CNum = i
            Exit For
        End If
    Next
    For i = 1 To 10
        If PetMapCache(PlayerMap).Pet(i) > 0 Then
            Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i))
        End If
    Next

```

In modPlayer

In Sub PlayerWarp

From
```
'If 'refreshing' map
```to just above
```
' send player's equipment to new map
```
Replace with
```
'If 'refreshing' map
    If (OldMap <> mapNum) And TempPlayer(index).TempPetSlot > 0 Then
        'switch maps
      PetDisband index, OldMap
        SpawnPet index, mapNum, Trim$(Player(index).Pet.SpriteNum)
        PetFollowOwner index
    End If

    'View Current Pets on Map
    For i = 1 To 10
        If PetMapCache(Player(index).Map).Pet(i) > 0 Then
            Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i))
        End If
    Next

```
**DONE**
Link to comment
Share on other sites

Your Tutorial:

> In Sub SpawnPet
>
> from
> Code: [Select]
>
> 'Cache the Pets for players logging on [Add new Number to array]
>
> to just before
> Code: [Select]
>
> Select Case GetPlayerDir(index)
>
> replace with
> Code: [Select]
>
> For i = 1 To 10
>         If PetMapCache(PlayerMap).Pet(i) = 0 Then
>             PetMapCache(PlayerMap).Pet(i) = PetSlot
>             Player(index).Pet.CNum = i
>             Exit For
>         End If
>     Next
>     For i = 1 To 10
>         If PetMapCache(PlayerMap).Pet(i) > 0 Then
>             Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i))
>         End If
>     Next

Now, when i add this, and use item to summon pet, my client is closing.

PetMapCache(PlayerMap).Pet(i) = PetSlot - this line closing my client, but when this is " ' ", this is work.
Link to comment
Share on other sites

  • 3 months later...
Server side:
@Microsoft:

> If (OldMap <> MapNum) And TempPlayer(Index).TempPetSlot > 0 Then
>         'switch maps
>       PetDisband Index, OldMap
>         SpawnPet Index, MapNum, Trim$(Player(Index).Pet.SpriteNum)
>         PetFollowOwner Index
>     End If

@Error:

> Compile error:
>
> Wrong number of arguments or invalid property assignment
Link to comment
Share on other sites

I found the problem.
You put the following into that code:
```
SpawnPet Index, MapNum, Trim$(Player(Index).Pet.SpriteNum)
```
The options for SpawnPet are:
```
SpawnPet(ByVal Index As Long, ByVal MapNum As Long)
```
You put three options in your code but the SpawnPet sub has only two options.

So in modPlayer (Server side) change
```
SpawnPet Index, MapNum, Trim$(Player(Index).Pet.SpriteNum)
```to
```
SpawnPet Index, MapNum
```
Link to comment
Share on other sites

~~Lol i cant still go back to the map i was with my pet :Z Help?
and sometimes when i use the item to summon the pet its not spawning but if i change map after i used the pet show up at the next map, weird…
and i did everything right :O~~

Edit: didnt saw its outdated :D
Link to comment
Share on other sites

  • 5 weeks later...

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...