RyokuHasu Posted March 12, 2011 Author Share Posted March 12, 2011 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 modConstantsFind: ' Item constantsAdd Public Const ITEM_TYPE_SUMMON As Byte = # (the next number on the list)example```' Item constantsPublic Const ITEM_TYPE_NONE As Byte = 0Public Const ITEM_TYPE_WEAPON As Byte = 1Public Const ITEM_TYPE_ARMOR As Byte = 2Public Const ITEM_TYPE_HELMET As Byte = 3Public Const ITEM_TYPE_SHIELD As Byte = 4Public Const ITEM_TYPE_CONSUME As Byte = 5Public Const ITEM_TYPE_KEY As Byte = 6Public Const ITEM_TYPE_CURRENCY As Byte = 7Public Const ITEM_TYPE_SPELL As Byte = 8Public 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 thingsBecause these wont fit the new spawn pet parameters sadly they must go, if it calls spawn pet, we have to kill itin modHandleData and look for "Public Sub InitMessages()".Delete:```HandleDataSub(CSpawnPet) = GetAddress(AddressOf HandleSpawnPet)```and in the same mod find Public Sub HandleSpawnPetand 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 mapsFind:```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 modGameLogicFind 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  NextEnd 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.oBUT! we have to do the Visual thingsOpen the frmEditor_Itemclick 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 editorNextOpen up frmMainFind 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!!!! =Dyou now have Pet summoning with items!!!! Complete with ability to set requirements for the summonsHow 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 itemNow 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  NextEnd Sub```and in modPlayerfind Case ITEM_TYPE_SUMMON and erase```Call TakeInvItem(index, itemnum, 0)```at the bottom Link to comment Share on other sites More sharing options...
iSKweek Posted March 12, 2011 Share Posted March 12, 2011 I like this :D Great work! Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 12, 2011 Author Share Posted March 12, 2011 EDITED: Added AboveAdded, a pet checker for the new modeGives 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 More sharing options...
Yxxe Posted March 12, 2011 Share Posted March 12, 2011 Good work, a nice start. Thanks for linking back to my tutorial. ;-) I'll add you to the mods list when I get home from work. :-P Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 12, 2011 Author Share Posted March 12, 2011 thank you =DI was looking for a way to make yours useful and pratical for game creation ^_^ i think this covers that, thank you so much for creating the base i used! Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 12, 2011 Author Share Posted March 12, 2011 O.o is it just me or are there errors when you either change mapes with pets or just try and compile my code?…. Creating a more stable version now.... Link to comment Share on other sites More sharing options...
Helladen Posted March 12, 2011 Share Posted March 12, 2011 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 More sharing options...
Yxxe Posted March 12, 2011 Share Posted March 12, 2011 @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. ;PEDIT 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 More sharing options...
RyokuHasu Posted March 12, 2011 Author Share Posted March 12, 2011 @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 More sharing options...
MrKris Posted March 12, 2011 Share Posted March 12, 2011 really nice job! Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 12, 2011 Author Share Posted March 12, 2011 @Kris:> really nice job!Thank you ^_^ Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 14, 2011 Author Share Posted March 14, 2011 **IMPORTANT EDIT**I ADDED back in the ability to take pets with you when you change mapsAdded:``` 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 More sharing options...
EclipseCommunity Posted March 15, 2011 Share Posted March 15, 2011 What's going on with the SpawnPet sub? You've got an End If without an If, and a Next in completely the wrong place.It's a great tutorial otherwise, just need to fix that sub. Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 15, 2011 Author Share Posted March 15, 2011 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 More sharing options...
EclipseCommunity Posted March 16, 2011 Share Posted March 16, 2011 Ahh, good times. thanks. Link to comment Share on other sites More sharing options...
The New World Posted March 16, 2011 Share Posted March 16, 2011 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 More sharing options...
peekay Posted March 16, 2011 Share Posted March 16, 2011 why does everything remind me of runescape…. some little things in the engine does that as well Link to comment Share on other sites More sharing options...
The New World Posted March 16, 2011 Share Posted March 16, 2011 Because runescape has a lot of basic gameplay that every game has for it's F2P content. Remember Origins is to supplement you with the basics any game should have, the rest of the creation is up to you. Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 17, 2011 Author Share Posted March 17, 2011 @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 More sharing options...
RyokuHasu Posted March 17, 2011 Author Share Posted March 17, 2011 oops lol, I just realised one of the picture is The wrong thing circled =P no big deal, I'll edit it when I get home.(i circled the Item data and not list)Ok I added the Correct Picture, lol It was such a simple mistake, it's all better. Link to comment Share on other sites More sharing options...
EclipseCommunity Posted March 18, 2011 Share Posted March 18, 2011 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 More sharing options...
RyokuHasu Posted March 18, 2011 Author Share Posted March 18, 2011 Thanks ^_^ But this really goes in Lightning's Tut, mine dosn't mod the combat =P Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 15, 2011 Author Share Posted April 15, 2011 **ADDED**by popular demand (and a few FAILED attempts by others) I have added an Optional mod to KEEP the item the is used to summon the Pet, it WILL NOT be treated as consumable any more if used. Link to comment Share on other sites More sharing options...
Yxxe Posted April 15, 2011 Share Posted April 15, 2011 I hope you only removed the 2 lines necessary and didn't in through a load of rubbish like you did in the other thread. ;-) Link to comment Share on other sites More sharing options...
RyokuHasu Posted April 15, 2011 Author Share Posted April 15, 2011 yes XD lol that was a psudo way of getting the item to come back after disband… but the index for loging out isnt the same so its a dead end with out a little more work =3 this is way better and simpler =D Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now