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

[EO] Lightning's Pet System [Completely Bug-Free!]


Yxxe
 Share

Recommended Posts

@RyokuHasu:

> well using just this system and none of my mods for it, just click call pet…
>
> If your using Summoning with items make the pet on the same number as the summoning item.
>
> (and if your using my taming system, you should be aressted for hacking my computer lol JK)

I have no pet yet, but i want to make a pet, but how?
Link to comment
Share on other sites

  • Replies 304
  • Created
  • Last Reply

Top Posters In This Topic

Quote from: BugSICK on June 14, 2011, 02:43:26 PM

    light i have this problem. client and server runs good with pet installed. but when i logout and log-in again i get this error.

    did i miss something???

i've tried multiple times and still this error appeared. did you test it?? at first it runs smooth every command are ok, but when i exit client(i mean really close the client not going back to the menu when the X"close" button click) and relogin then i get the error, i need to refresh/shutdown the server and runs it again to run the client back to normal.

I get the same error, no fix for it?
Link to comment
Share on other sites

Ouch, that was me being stupid. >_< I've gone over it again and saw I was setting TempPetSlot to zero before removing the Pet from the server-side cache.

Server-side:

Change "Sub PetDisband" to this:

```
'Clear the npc from the map
Sub PetDisband(ByVal index As Long, ByVal MapNum As Long)
    Dim i As Long
    Dim j As Long

    If TempPlayer(index).TempPetSlot < 1 Then Exit Sub

    'Cache the Pets for players logging on [Remove Number from array]
    'THIS IS KINDA SLOW (EVEN WITHOUT TESTING, LOL), MAY HAVE TO CONVERT TO LINKED LIST FOR SPEED
    For i = 1 To PetMapCache(MapNum).UpperBound
        If PetMapCache(MapNum).Pet(i) = TempPlayer(index).TempPetSlot Then
            If PetMapCache(MapNum).UpperBound > 1 Then
                For j = PetMapCache(MapNum).UpperBound To i Step -1
                    PetMapCache(MapNum).Pet(j - 1) = PetMapCache(MapNum).Pet(j)
                Next
            Else
                PetMapCache(MapNum).Pet(1) = 0
            End If

            PetMapCache(MapNum).UpperBound = PetMapCache(MapNum).UpperBound - 1
            Exit For
        End If
    Next

    Call ClearSingleMapNpc(TempPlayer(index).TempPetSlot, MapNum)
    Map(GetPlayerMap(index)).Npc(TempPlayer(index).TempPetSlot) = 0
    TempPlayer(index).TempPetSlot = 0

    're-warp the players on the map
    For i = 1 To Player_HighIndex
        If IsPlaying(i) Then
            If GetPlayerMap(i) = GetPlayerMap(index) Then
                Call PlayerWarp(i, GetPlayerMap(i), GetPlayerX(i), GetPlayerY(i))
                SendPlayerData index
            End If
        End If
    Next
End Sub
```
Client-side:

Change "Sub HandleNPCCache" back to this:

```
Private Sub HandleNPCCache(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer
    Dim PIndex As Long
    Dim MapNum As Long
    Dim npcNum As Long

    Dim i As Long

    Set Buffer = New clsBuffer

    Buffer.WriteBytes Data()

    MapNum = Buffer.ReadLong
    npcNum = Buffer.ReadLong

    Map.Npc(npcNum) = Buffer.ReadLong
    MapNpc(npcNum).num = Buffer.ReadLong

    SaveMap (MapNum)

    Set Buffer = Nothing

End Sub
```
Link to comment
Share on other sites

Sorry, i spoke to soon, i noticed another bug, the pet goes very odd if it is healed, however that might be an error due to the changes ive made to healing… might be worth you testing

is there a way to prevent it respawning too, because otherwise summoners are pretty imba
Link to comment
Share on other sites

@Fragment:

> Sorry, i spoke to soon, i noticed another bug, the pet goes very odd if it is healed, however that might be an error due to the changes ive made to healing… might be worth you testing

I never coded anything for healing of pets in the first place, so it's nothing to do with me. ;]
Link to comment
Share on other sites

@Fragment:

> yea i know but have you tried healing your pet? just cause a pet is still an npc, so if you use a heal spell on it, it will be healed then it goes into ghost mode

I've never tried it. In my game, I use Pet Food instead of healing spells. You could do the same as what I did, which just stops the healing if they are a Pet.
Link to comment
Share on other sites

@Fragment:

> Ok will do, how did u go about preventing them from respawning though?

Once they die, "PetDisband" is called, which removes the NPC from the map. It also changes the Pet cache for new players logging on and sends an NPC update to the existing players logged on.
Link to comment
Share on other sites

surely this should stop them respawning?

      ElseIf MapNpc(MapNum).Npc(Victim).IsPet = YES Then
            'Get the pet owners' index
            PetOwner = MapNpc(MapNum).Npc(Victim).PetData.Owner
            'Set the NPC's target on the owner now
            MapNpc(MapNum).Npc(Attacker).targetType = 1 'player
            MapNpc(MapNum).Npc(Attacker).target = PetOwner
            'Disband the pet
            PetDisband PetOwner, GetPlayerMap(PetOwner)
        End If
Link to comment
Share on other sites

I do appreciate everything you done in this tutorial but i think [Completely Bug-Free!]
was a bad title to give it

This is the fix for those interested, in server add this to PlayerAttackNpc
    Dim PetOwner As Long

and

above this
```
    Else
        ' NPC not dead, just do the damage
```

add this

```
        If MapNpc(MapNum).Npc(mapNpcNum).IsPet = YES Then
            'Get the pet owners' index
            PetOwner = MapNpc(MapNum).Npc(mapNpcNum).PetData.Owner
            'Disband the pet
            PetDisband PetOwner, GetPlayerMap(PetOwner)
        End If
```
Link to comment
Share on other sites

@Fragment:

> I do appreciate everything you done in this tutorial but i think [Completely Bug-Free!]
> was a bad title to give it

It was completely bug free, but as I forgot to add a few things (which I must make clear were already in my source code) a few "errors" were chucked out. In regards to the Player attacking an NPC, here is the fix:

```
'Checks if NPC was a pet
        If MapNpc(MapNum).Npc(mapNpcNum).IsPet = YES Then
            Call PetDisband(MapNpc(MapNum).Npc(mapNpcNum).PetData.Owner, MapNum) 'The pet was killed         
        End If

```
Just add this in "Sub PlayerAttackNpc" underneath

```
MapNpc(MapNum).Npc(mapNpcNum).Vital(Vitals.HP) = 0
```
It's now bug-free. Be jolly and whatnot.
Link to comment
Share on other sites

Would you mind sharing some light on how your pet food works?  just because i couldnt for the life of me figure out why the hell they turn to ghosts (they are there and move around/can be controlled) if they get healed even once?
Link to comment
Share on other sites

@Fragment:

> Ok np, im not attacking you its just i know you are a very reputable member, so when i seen the topic i didnt expect to need to add any fixes and when i did i just assumed you overlooked them.

When I implemented the new Pet Caching, I just ripped it from my own game's source code. I guess I was just being lazy and assumed it all worked from the outset. Like I explained previously, it was all in the source code in the first place, I just forgot to add it into the tutorial. ;]

@Fragment:

> Would you mind sharing some light on how your pet food works?  just because i couldnt for the life of me figure out why the hell they turn to ghosts (they are there and move around/can be controlled) if they get healed even once?

I think I've given you enough, you can figure it out. :]
Link to comment
Share on other sites

Im sorry to say but even with all the patching and fixes on the forums, this is too buggy to use, anytime you edit the map it will store peoples pets and any time the server closes down, the pets remain stuck to the map.
Link to comment
Share on other sites

@Fragment:

> Im sorry to say but even with all the patching and fixes on the forums, this is too buggy to use, anytime you edit the map it will store peoples pets and any time the server closes down, the pets remain stuck to the map.

Editing maps shouldn't occur in a live game, only on a development server. I did make it very clear early on that you shouldn't edit maps while a pet is out. By all means, go and fix it for yourself. Go and find Ryokus tutorial on pet erasing for server crashes.

I'm beginning to feel how ungrateful some people are in this community.
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...