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

=P i know its not the exact same

BUT somtimes code breaks for an instant, its like that. One time while working on Bleach: Bladed's mirror people kept saying that thier kido spells were not calling the animations but still working (this is in a 3d combat MMO i made) I the code for some reason had a 1 in a 1000 chance of skiping the animation sequence, there was nothing i could do, i poured over it for 3 days looking for the problem, and cam back and said sorry, it looks fine.
Link to comment
Share on other sites

  • Replies 304
  • Created
  • Last Reply

Top Posters In This Topic

few other things u need to fix lightning…
- onpetdeath the pets target needs to switch to player
- if the server crashes for some reason and u enter the game again your pet is there uncontrolable... duno if u can fix that tho
Link to comment
Share on other sites

@peekay:

> few other things u need to fix lightning…
> - onpetdeath the pets target needs to switch to player

What do you mean by this, explain more please.

@peekay:

> - if the server crashes for some reason and u enter the game again your pet is there uncontrolable… duno if u can fix that tho

That's because the Pet is still there but doesn't have a pet index. There is obviously no event handler which will despawn all the pets when the server crashes.
Link to comment
Share on other sites

you go in and remove it from the map at this point…. or kill it (if you can)

GO NEWS!!! Coming soon: Pet Stats scaling!!!! based on your level and STR the pet you summon will be stronger too =D

WIP: Pet armor, give your pet paperdoll armor and get it back when it dies or is disbanded.

;D im making your pets better...
Link to comment
Share on other sites

@RyokuHasu:

> you go in and remove it from the map at this point…. or kill it (if you can)
>
> GO NEWS!!! Coming soon: Pet Stats scaling!!!! based on your level and STR the pet you summon will be stronger too =D
>
> WIP: Pet armor, give your pet paperdoll armor and get it back when it dies or is disbanded.
>
> ;D im making your pets better...

You haven't seen what I've done with mine yet… xD
Link to comment
Share on other sites

@RyokuHasu:

> O.o you ever gona share? or do i have to become the leading person for pet modifications? lol

I've given the community everything you need to make something that I am making. And no, my Pet System will be unique to my game. ;)

[Origin - The Legend Reborn Pet Handling Life Skill](http://www.touchofdeathforums.com/smf/index.php/topic,69956.0.html)
In the next few days I will be releasing more info about it. ^^
Link to comment
Share on other sites

umm bout that thing i said above lightning

when a pet dies from attacking a npc the npc its attacking should switch targets to the player, otherwise people can just send in pets after pets and never be attacked by a npc xD
Link to comment
Share on other sites

@peekay:

> umm bout that thing i said above lightning
>
> when a pet dies from attacking a npc the npc its attacking should switch targets to the player, otherwise people can just send in pets after pets and never be attacked by a npc xD

Added, all it is is 2 lines of code, lol.

Change sub NpcAttackNpc to this:

```
Sub NpcAttackNpc(ByVal MapNum As Long, ByVal Attacker As Long, ByVal Victim As Long, ByVal Damage As Long)
    Dim i As Long
    Dim Buffer As clsBuffer
    Dim aNpcNum As Long
    Dim vNpcNum As Long
    Dim n As Long
    Dim PetOwner As Long

    If Attacker <= 0 Or Attacker > MAX_MAP_NPCS Then Exit Sub
    If Victim <= 0 Or Victim > MAX_MAP_NPCS Then Exit Sub

    If Damage <= 0 Then Exit Sub

    aNpcNum = MapNpc(MapNum).Npc(Attacker).Num
    vNpcNum = MapNpc(MapNum).Npc(Victim).Num

    If aNpcNum <= 0 Then Exit Sub
    If vNpcNum <= 0 Then Exit Sub

    'set the victim's target to the pet attacking it
    MapNpc(MapNum).Npc(Victim).targetType = 2 'Npc
    MapNpc(MapNum).Npc(Victim).target = Attacker

    ' Send this packet so they can see the person attacking
    Set Buffer = New clsBuffer
    Buffer.WriteLong SNpcAttack
    Buffer.WriteLong Attacker
    SendDataToMap MapNum, Buffer.ToArray()
    Set Buffer = Nothing

    If Damage >= MapNpc(MapNum).Npc(Victim).Vital(Vitals.HP) Then
        SendActionMsg MapNum, "-" & Damage, BrightRed, 1, (MapNpc(MapNum).Npc(Victim).x * 32), (MapNpc(MapNum).Npc(Victim).y * 32)
        SendBlood MapNum, MapNpc(MapNum).Npc(Victim).x, MapNpc(MapNum).Npc(Victim).y

        ' npc is dead.
        'Call GlobalMsg(CheckGrammar(Trim$(Npc(vNpcNum).Name), 1) & " has been killed by " & CheckGrammar(Trim$(Npc(aNpcNum).Name)) & "!", BrightRed)

        ' Set NPC target to 0
        MapNpc(MapNum).Npc(Attacker).target = 0
        MapNpc(MapNum).Npc(Attacker).targetType = 0
        'reset the targetter for the player

        If MapNpc(MapNum).Npc(Attacker).IsPet = YES Then
            TempPlayer(MapNpc(MapNum).Npc(Attacker).PetData.Owner).target = 0
            TempPlayer(MapNpc(MapNum).Npc(Attacker).PetData.Owner).targetType = TARGET_TYPE_NONE

            PetOwner = MapNpc(MapNum).Npc(Attacker).PetData.Owner

            SendTarget PetOwner

            'Give the player the pet owner some experience from the kill
            Call SetPlayerExp(PetOwner, GetPlayerExp(PetOwner) + Npc(MapNpc(MapNum).Npc(Victim).Num).Exp)
            CheckPlayerLevelUp PetOwner
            SendActionMsg MapNum, "+" & Npc(MapNpc(MapNum).Npc(Victim).Num).Exp & "Exp", White, 1, GetPlayerX(PetOwner) * 32, GetPlayerY(PetOwner) * 32
            SendEXP PetOwner

        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

        ' Drop the goods if they get it
        'For n = 1 To MAX_NPC_DROPS
        If Npc(vNpcNum).DropItem <> 0 Then
            If Rnd <= Npc(vNpcNum).DropChance Then
                Call SpawnItem(Npc(vNpcNum).DropItem, Npc(vNpcNum).DropItemValue, MapNum, MapNpc(MapNum).Npc(Victim).x, MapNpc(MapNum).Npc(Victim).y)
            End If
        End If
        'Next

        ' Reset victim's stuff so it dies in loop
        MapNpc(MapNum).Npc(Victim).Num = 0
        MapNpc(MapNum).Npc(Victim).SpawnWait = GetTickCount
        MapNpc(MapNum).Npc(Victim).Vital(Vitals.HP) = 0

        ' send npc death packet to map
        Set Buffer = New clsBuffer
        Buffer.WriteLong SNpcDead
        Buffer.WriteLong Victim
        SendDataToMap MapNum, Buffer.ToArray()
        Set Buffer = Nothing

        If PetOwner > 0 Then
            PetFollowOwner PetOwner
        End If
    Else
        ' npc not dead, just do the damage
        MapNpc(MapNum).Npc(Victim).Vital(Vitals.HP) = MapNpc(MapNum).Npc(Victim).Vital(Vitals.HP) - Damage

        ' Say damage
        SendActionMsg MapNum, "-" & Damage, BrightRed, 1, (MapNpc(MapNum).Npc(Victim).x * 32), (MapNpc(MapNum).Npc(Victim).y * 32)
        SendBlood MapNum, MapNpc(MapNum).Npc(Victim).x, MapNpc(MapNum).Npc(Victim).y
    End If

    'Send both Npc's Vitals to the client
    SendMapNpcVitals MapNum, Attacker
    SendMapNpcVitals MapNum, Victim

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

@peekay:

> i got pet spells sorta workin but they dont stop for the cast time… do u think i need to add spellbuffer to mapnpcrec?

You could add another spell buffer to TempPlayerRec, and make a new spell type. Then you could go ahead with adding a few checks which would fill the other buffer with the Pets' spell, leaving you able to cast one yourself. I haven't really thought about it much, but I would probably go down that kinda route.
Link to comment
Share on other sites

i think theres a possible bug when ur pet attacks a npc and the npcs target is the player..
getting a division by 0 errornum 11
unless its somethin i did (EDIT: its to do with my new spell attacking subs dw bout this but if u can help me figure it out xD)

also if u disband your pet the npcs target is set to 0 it needs to be set to 1 to attack player
thats all i can think of atm
Link to comment
Share on other sites

@Xlithan:

> For anybody who has added Multiple Item Drops and Percentiles, Find:
>
> ```
> ' Drop the goods if they get it
> ```in NPCAttackNPC sub, and change to this:
>
> ```
>         ' Drop the goods if they get it
>         For n = 1 To MAX_NPC_DROPS
>             If Npc(Victim).DropItem(n) = 0 Then Exit For
>             If Rnd <= Npc(Victim).DropChance(n) Then
>                 Call SpawnItem(Npc(Victim).DropItem(n), Npc(Victim).DropItemValue(n), MapNum, MapNpc(MapNum).Npc(Victim).x, MapNpc(MapNum).Npc(Victim).y)
>             End If
>         Next
> ```

=D this goes In your tut more than mine ^_^
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...