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

Hello, this is my first major tutorial, i decided to make one because i want to get noticed, that and a Tamer class sucks with only one summon, lol. And yes, I am leaving out a few other features i added to my version, got to keep some stuff for my self.

Discription:

Use a summoning item to summon the matching NPC: monsters, quest givers, mercenaries, ANYTHING.

they are also treated as consumables, they disapear after use. (this is now optional to remove)

you CAN  take pets from map to map with you. (edited back in)

**Prerequired Tutorial**http://www.touchofdeathforums.com/smf/index.php/topic,69521.0.html
* Credit to Lightning for the base I used

**Translated In German by EisKeks, Under "Abschnitt 2"**
http://www.touchofdeathforums.com/smf/index.php/topic,71065.new.html

* GERMAN VERSION IS NOT COMPATIBLE WITH THE NEW PET SYSTEM VERSION

* * *

MY TUTORIAL
**BOTH SERVER AND CLIENT**
In modConstants

Find: ' Item constants

Add Public Const ITEM_TYPE_SUMMON As Byte = # (the next number on the list)

example
```
' Item constants
Public Const ITEM_TYPE_NONE As Byte = 0
Public Const ITEM_TYPE_WEAPON As Byte = 1
Public Const ITEM_TYPE_ARMOR As Byte = 2
Public Const ITEM_TYPE_HELMET As Byte = 3
Public Const ITEM_TYPE_SHIELD As Byte = 4
Public Const ITEM_TYPE_CONSUME As Byte = 5
Public Const ITEM_TYPE_KEY As Byte = 6
Public Const ITEM_TYPE_CURRENCY As Byte = 7
Public Const ITEM_TYPE_SPELL As Byte = 8
Public Const ITEM_TYPE_SUMMON As Byte = 9

```
This declairs the new item type

* * *

**SERVER SIDE**

Befor we start we need to delete a  some thing that will conflict with my new way of doing things

Because these wont fit the new spawn pet parameters sadly they must go, if it calls spawn pet, we have to kill it

in modHandleData and look for "Public Sub InitMessages()".
Delete:
```
HandleDataSub(CSpawnPet) = GetAddress(AddressOf HandleSpawnPet)

```
and in the same mod find Public Sub HandleSpawnPet
and delete
```
Public Sub HandleSpawnPet(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
      SpawnPet Index, GetPlayerMap(Index)
End Sub

```

In modPlayer Find: 'switch maps
Find:
```
SpawnPet index, MapNum

```Replace with:
```
SpawnPet index, MapNum, Trim$(Player(index).Pet.SpriteNum)

```

WOOT!!! I got the pet to follow you to diffrent maps!

In modGameLogic

Find the Sub SpawnPet and replace with:

```

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

    PlayerMap = GetPlayerMap(index)
    PetSlot = 0

    For i = 1 To MAX_MAP_NPCS
        'If Map(PlayerMap).Npc(i) = 0 Then
        If MapNpc(PlayerMap).NPC(i).SpawnWait = 0 And MapNpc(PlayerMap).NPC(i).Num = 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)

    'Cache the Pets for players logging on [Add new Number to array]
    PetMapCache(PlayerMap).UpperBound = PetMapCache(PlayerMap).UpperBound + 1
    PetMapCache(PlayerMap).Pet(PetMapCache(PlayerMap).UpperBound) = PetSlot

    If PetMapCache(Player(index).Map).UpperBound > 0 Then
        For i = 1 To PetMapCache(Player(index).Map).UpperBound
            Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i))
        Next
    End If

    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

```
this declares npcNUM as a new parameter and let us summon diffrent pets, how ever the "Call Pet button will no longer work now, DONT NEED IT, we will use items.

In modPlayer find Public Sub UseItem (should be the last one)

In the bottum of the sub, befor End Select, add

```
Case ITEM_TYPE_SUMMON
                ' stat requirements
                For i = 1 To Stats.Stat_Count - 1
                    If GetPlayerRawStat(index, i) < Item(itemnum).Stat_Req(i) Then
                        PlayerMsg index, "You do not meet the stat requirements to use this item.", BrightRed
                        Exit Sub
                    End If
                Next

                ' level requirement
                If GetPlayerLevel(index) < Item(itemnum).LevelReq Then
                    PlayerMsg index, "You do not meet the level requirement to use this item.", BrightRed
                    Exit Sub
                End If

                ' class requirement
                If Item(itemnum).ClassReq > 0 Then
                    If Not GetPlayerClass(index) = Item(itemnum).ClassReq Then
                        PlayerMsg index, "You do not meet the class requirement to use this item.", BrightRed
                        Exit Sub
                    End If
                End If

                ' access requirement
                If Not GetPlayerAccess(index) >= Item(itemnum).AccessReq Then
                    PlayerMsg index, "You do not meet the access requirement to use this item.", BrightRed
                    Exit Sub
                End If
                Call SpawnPet(index, GetPlayerMap(index), itemnum)
                Call TakeInvItem(index, itemnum, 0)

```
this adds the ability to summon using items Item number = Summoned NPC number SIMPLE AND UNLIMITED!!! (close to it)

* * *

**CLIENT SIDE**

NO SCRIPTING!? O.o

BUT! we have to do the Visual things

Open the frmEditor_Item

click on cmbType only once
![](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=69925.0;attach=17268)

over on the properties find the list
![](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=69925.0;attach=17360)

Add Summon at the bottom

![](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=69925.0;attach=17272)

This enables the new type of item to be created, want the edit parameters? they ARE the NPC editor

Next

Open up frmMain

Find your pet menu find your "call pet" button, double click it

![](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=69925.0;attach=17274)

ERASE
```
Private Sub Label3_Click()
Call SpawnPet(MyIndex)
End Sub

```
This prevents an error for what we are about to do…

NOW DELETE YOUR CALL PET BUTTON!!!! you use items for that now, no cheating, go BUY a summon.

AND TADA!!!! =D

you now have Pet summoning with items!!!! Complete with ability to set requirements for the summons

How to use:

Make a summon item, set your requirements, and SAVE! Now remember what number that item is.

Next, make a NPC *ON THE SAME NUMBER* as the summon item

Now summon, and the rest of the controls are the same.

you now have an advanced summoning system, and ability to make an entire Tamer Class.

[hr/]
**Optional**
To make the item stay after summoning, for those who want to do so.

In game logic change sub SpawnPet to (YES, you do this AGAIN, someone didnt and it messed up)

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

    PlayerMap = GetPlayerMap(index)
    PetSlot = 0

    For i = 1 To MAX_MAP_NPCS
        'If Map(PlayerMap).Npc(i) = 0 Then
        If MapNpc(PlayerMap).NPC(i).SpawnWait = 0 And MapNpc(PlayerMap).NPC(i).Num = 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)

    'Cache the Pets for players logging on [Add new Number to array]
    PetMapCache(PlayerMap).UpperBound = PetMapCache(PlayerMap).UpperBound + 1
    PetMapCache(PlayerMap).Pet(PetMapCache(PlayerMap).UpperBound) = PetSlot

    If PetMapCache(Player(index).Map).UpperBound > 0 Then
        For i = 1 To PetMapCache(Player(index).Map).UpperBound
            Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i))
        Next
    End If

    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 in modPlayer

find Case ITEM_TYPE_SUMMON and erase

```
Call TakeInvItem(index, itemnum, 0)

```at the bottom
Link to comment
Share on other sites

  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

EDITED: Added Above

Added, a pet checker for the new mode

Gives your summoning item back if you cant summon or already have a summon out.

REDO

@RyokuHasu:

> In modGameLogic
>
> Find the Sub SpawnPet and replace with:
>
> ```
>
> 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(index, PlayerMap, GetPlayerX(index), GetPlayerY(index))
>                     End If
>                     End If
>                 Next
> End Sub
>
> ```
Link to comment
Share on other sites

You should set the values in player(index).pet then call it, rather than just spawning it. The way you did it just plain sucks, to be honest. And someone needs to rewrite the way the pets are handled, saving them to the map is bad design flaw written all over it.
Link to comment
Share on other sites

@Helladen:

> You should set the values in player(index).pet then call it, rather than just spawning it. The way you did it just plain sucks, to be honest. And someone needs to rewrite the way the pets are handled, saving them to the map is bad design flaw written all over it.

Just saw that, lol. Removing the "SaveMap" line makes no difference. xD *Goes to change tutorial*
It may be easier to add a separate array to hold the Pets. Will probably end up doing that tomorrow and adding it to the tutorial. ;P

EDIT 2: ARGHGHGH too tired to tell whether the SaveMap line will do anything for when another player logs in. *sleeps*
Link to comment
Share on other sites

@Helladen:

> You should set the values in player(index).pet then call it, rather than just spawning it. The way you did it just plain sucks, to be honest. And someone needs to rewrite the way the pets are handled, saving them to the map is bad design flaw written all over it.

For the way the pets are handled is not my design…

As for how the pet is summoned i just rerouted the trigger, not HOW it was summoned >.>

Realy read into the things i changed, i just chaned where it was called from, the only diffrence is i added options to it on the client side.

don't complain to me.... Im just changing triggers and debugging errors

"Don't complain about the car's engine if the guy only changed the tires"

EDITED: Was forced to remove the ability to take pets from map to map, im not that good enough yet to reroute those triggers too.
Link to comment
Share on other sites

**IMPORTANT EDIT**

I ADDED back in the ability to take pets with you when you change maps

Added:

```
SpawnPet index, MapNum, Trim$(Player(index).Pet.SpriteNum)

```
Find "  'switch maps" In modPlayer Add it under

```
PetDisband index, OldMap

```
if you already completed this tutorial before

(yes it was as simple as using Trim$…. if only i figued that out 2 days ago when this was released >.<)
Link to comment
Share on other sites

If your talking about…

```
'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

```
Read it closely… I just tabed it wrong, it spose to look like...

```
'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

```
ummm….  Is that what you where talking about?

other than that, there are dubble ifs... =P but i will re-tab the part in question... sorry for the confusion, if you have changed this, please revert it back to normal.
Link to comment
Share on other sites

You could change the "Disband Pet" option to give back the item used to spawn the pet.

And if you want this system to be different compared to all the other pet and summon modifications, you could do what I did and add in a handler for when you right-click a pet npc, it renders the pet menu at the mouse click. :)
Link to comment
Share on other sites

@Yukiyo:

> You could change the "Disband Pet" option to give back the item used to spawn the pet.
>
> And if you want this system to be different compared to all the other pet and summon modifications, you could do what I did and add in a handler for when you right-click a pet npc, it renders the pet menu at the mouse click. :)

SHUSSSHHH XD dont tell them that lol the point is one time use scrolls or items im not gona share re-useables… They can make thier own. lol
Link to comment
Share on other sites

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
```
Link to comment
Share on other sites

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