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

[EO] Summoning diffrent pets with items V2.0


RyokuHasu
 Share

Recommended Posts

  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

@Prang123:

> I'm a major Noob at EO Scripting, so I was wondering if you could PM me the source code files? xD
> I don't even know how to get those buttons up =/ (The Call Pet ones from Lightning's Tutorial)

Read my thread next time please. All you need to do is make a label on the game form.

[If you can't for the life of you figure out how to call the procedures, click here.](http://www.touchofdeathforums.com/smf/index.php/topic,69521.msg764273.html#msg764273)
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
O.o im not entirely shure whats wrong with it… maby its just left over pets from last time you were on and loged out of shutdown the server. if thats the case you might need my newest tut.

http://www.touchofdeathforums.com/smf/index.php/topic,72532.0.html

It cleans up any and all pets that shouldnt be there.
Link to comment
Share on other sites

This is my SpawnPet sub:

```
Sub SpawnPet(ByVal index As Long, ByVal MapNum As Long, npcNum As Long)

Dim PlayerMap As Long
Dim i As Integer
Dim PetSlot As Byte

        'Prevent multiple pets for the same owner
            If TempPlayer(index).TempPetSlot > 0 Then
                Call GiveInvItem(index, npcNum, 0)
                Exit Sub
            End If

            PlayerMap = GetPlayerMap(index)
            PetSlot = 0

            For i = 1 To MAX_MAP_NPCS
                  If Map(PlayerMap).Npc(i) = 0 Then
                        PetSlot = i
                        Exit For
                  End If
            Next

            If PetSlot = 0 Then
                Call GiveInvItem(index, npcNum, 0)
                Call PlayerMsg(index, "The map is too crowded for you to call on your pet!", Red)
                Exit Sub
            End If

            'create the pet for the map
                Map(PlayerMap).Npc(PetSlot) = npcNum
                MapNpc(PlayerMap).Npc(PetSlot).Num = npcNum

            'set its Pet Data
                MapNpc(PlayerMap).Npc(PetSlot).IsPet = YES
                MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name
                MapNpc(PlayerMap).Npc(PetSlot).PetData.Owner = index

            'If Pet doesn't exist with player, link it to the player
                If Player(index).Pet.SpriteNum <> npcNum Then
                Player(index).Pet.SpriteNum = npcNum
                Player(index).Pet.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name
                End If
                TempPlayer(index).TempPetSlot = PetSlot
            'cache the map for sending
                Call MapCache_Create(PlayerMap)
            'save the map
                SaveMap (PlayerMap)

            'send the update
                For i = 1 To Player_HighIndex
                    If IsPlaying(i) Then
                    If GetPlayerMap(i) = GetPlayerMap(index) Then
                        SendMap i, PlayerMap
                    End If
                    End If
                Next

                Select Case GetPlayerDir(index)
                    Case DIR_UP
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)
                    Case DIR_DOWN
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) + 1)
                    Case DIR_LEFT
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) + 1, GetPlayerY(index))
                    Case DIR_RIGHT
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)
                End Select

'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, PlayerMap, GetPlayerX(i), GetPlayerY(i))
        End If
    End If
Next
End Sub

```
And yes, i add the optional part for dont remove the items.
Link to comment
Share on other sites

@Sr_Sirius:

> This is my SpawnPet sub:
> ```
> Sub SpawnPet(ByVal index As Long, ByVal MapNum As Long, npcNum As Long)
>
> Dim PlayerMap As Long
> Dim i As Integer
> Dim PetSlot As Byte
>
>         'Prevent multiple pets for the same owner
>             If TempPlayer(index).TempPetSlot > 0 Then
>                 Call GiveInvItem(index, npcNum, 0) ' this was sposed to b removed
>                 Exit Sub
>             End If
>        
>             PlayerMap = GetPlayerMap(index)
>             PetSlot = 0
>
>             For i = 1 To MAX_MAP_NPCS
>                   If Map(PlayerMap).Npc(i) = 0 Then
>                         PetSlot = i
>                         Exit For
>                   End If
>             Next
>
>             If PetSlot = 0 Then
>                 Call GiveInvItem(index, npcNum, 0) ' this was sposed to be removed
>                 Call PlayerMsg(index, "The map is too crowded for you to call on your pet!", Red)
>                 Exit Sub
>             End If
>
>             'create the pet for the map
>                 Map(PlayerMap).Npc(PetSlot) = npcNum
>                 MapNpc(PlayerMap).Npc(PetSlot).Num = npcNum
>                
>             'set its Pet Data
>                 MapNpc(PlayerMap).Npc(PetSlot).IsPet = YES
>                 MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name
>                 MapNpc(PlayerMap).Npc(PetSlot).PetData.Owner = index
>
>             'If Pet doesn't exist with player, link it to the player
>                 If Player(index).Pet.SpriteNum <> npcNum Then
>                 Player(index).Pet.SpriteNum = npcNum
>                 Player(index).Pet.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name
>                 End If
>                 TempPlayer(index).TempPetSlot = PetSlot
>             'cache the map for sending
>                 Call MapCache_Create(PlayerMap)
>             'save the map
>                 SaveMap (PlayerMap)
>
>             'send the update
>                 For i = 1 To Player_HighIndex
>                     If IsPlaying(i) Then
>                     If GetPlayerMap(i) = GetPlayerMap(index) Then
>                         SendMap i, PlayerMap
>                     End If
>                     End If
>                 Next
>
>                 Select Case GetPlayerDir(index)
>                     Case DIR_UP
>                     Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)
>                     Case DIR_DOWN
>                     Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) + 1)
>                     Case DIR_LEFT
>                     Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) + 1, GetPlayerY(index))
>                     Case DIR_RIGHT
>                     Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)
>                 End Select
>
> '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, PlayerMap, GetPlayerX(i), GetPlayerY(i))
>         End If
>     End If
> Next
> End Sub
>
> ```And yes, i add the optional part for dont remove the items.

yes I see, you didnt replace the spawn pet sub a 2nd time. (like it said to)

;3 use this, its the EXACT same as the one in te optional section

```
Sub SpawnPet(ByVal index As Long, ByVal MapNum As Long, npcNum As Long)

Dim PlayerMap As Long
Dim i As Integer
Dim PetSlot As Byte

        'Prevent multiple pets for the same owner
            If TempPlayer(index).TempPetSlot > 0 Then
                Exit Sub
            End If

            PlayerMap = GetPlayerMap(index)
            PetSlot = 0

            For i = 1 To MAX_MAP_NPCS
                  If Map(PlayerMap).Npc(i) = 0 Then
                        PetSlot = i
                        Exit For
                  End If
            Next

            If PetSlot = 0 Then
                Call PlayerMsg(index, "The map is too crowded for you to call on your pet!", Red)
                Exit Sub
            End If

            'create the pet for the map
                Map(PlayerMap).Npc(PetSlot) = npcNum
                MapNpc(PlayerMap).Npc(PetSlot).Num = npcNum

            'set its Pet Data
                MapNpc(PlayerMap).Npc(PetSlot).IsPet = YES
                MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name
                MapNpc(PlayerMap).Npc(PetSlot).PetData.Owner = index

            'If Pet doesn't exist with player, link it to the player
                If Player(index).Pet.SpriteNum <> npcNum Then
                Player(index).Pet.SpriteNum = npcNum
                Player(index).Pet.Name = GetPlayerName(index) & "'s " & Npc(npcNum).Name
                End If
                TempPlayer(index).TempPetSlot = PetSlot
            'cache the map for sending
                Call MapCache_Create(PlayerMap)
            'save the map
                SaveMap (PlayerMap)

            'send the update
                For i = 1 To Player_HighIndex
                    If IsPlaying(i) Then
                    If GetPlayerMap(i) = GetPlayerMap(index) Then
                        SendMap i, PlayerMap
                    End If
                    End If
                Next

                Select Case GetPlayerDir(index)
                    Case DIR_UP
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)
                    Case DIR_DOWN
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) + 1)
                    Case DIR_LEFT
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) + 1, GetPlayerY(index))
                    Case DIR_RIGHT
                    Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)
                End Select

'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, PlayerMap, GetPlayerX(i), GetPlayerY(i))
        End If
    End If
Next
End Sub

```
Enjoy my 1/2 of the pet system XD

PS: ;D I have both types of pet summon items in my game at the same time.
Link to comment
Share on other sites

@RyokuHasu:

> O.o im not entirely shure whats wrong with it… maby its just left over pets from last time you were on and loged out of shutdown the server. if thats the case you might need my newest tut.
>
> http://www.touchofdeathforums.com/smf/index.php/topic,72532.0.html
>
> It cleans up any and all pets that shouldnt be there.

Ok so I don't know why its happening… but i know what is happening when i walk on to a map with my pet it overwrites the NPC in that maps 1st slot... Ive made a few changes but i don't think ive done anything to make it do that... at the moment ive solved the problem by puttin my npcs in the 30th slot going backwards but im concerned about what will happen when i have more then me on the game >.< any ideas why it would be doin something like this... ok if not ill just make pet unsummon when going from map to map lol
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...
  • 1 month later...
  • 5 months 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...