RyokuHasu Posted March 9, 2012 Author Share Posted March 9, 2012 Anyone else notice that when you have more than 1 player while a pet is out the game get a little unstable? You cant leave map with a pet then go back to the same map, you cant log onto a map with a pet on it, ect. Its a simple error with the Cache that can be fixed in a few easy steps.The pet system was tested on several games and the results always pointed to the Cache as the problem, this uses a simplified cache to store pets. However it will limit the pets per map to only 10.Lightning's Pet System. All credit for the original base Goes to Lightning.PreRequired: http://www.touchofdeathforums.com/smf/index.php/topic,69521.0/topicseen.htmlCredit for The new cache is mine, but you don't have to include me in your creds. (Unless you used my items summoning, then cred me)**Client Side**In modHandleDataIn Private Sub HandleNPCCachecomment out or delete```SaveMap (MapNum)```**ServerSide**in modTypesIn Public Type PetRecat the bottom add```CNum As Long```In modGameLogicin Sub PetDisbandFrom```'Cache the Pets for players logging on [Remove Number from array]```to```'re-warp the players on the map```replace with```PetMapCache(mapNum).Pet(Player(index).Pet.CNum) = 0 Call ClearSingleMapNpc(TempPlayer(index).TempPetSlot, mapNum) Map(GetPlayerMap(index)).NPC(TempPlayer(index).TempPetSlot) = 0 TempPlayer(index).TempPetSlot = 0```In Sub SpawnPetfrom```'Cache the Pets for players logging on [Add new Number to array]```to just before```Select Case GetPlayerDir(index)```replace with```For i = 1 To 10 If PetMapCache(PlayerMap).Pet(i) = 0 Then PetMapCache(PlayerMap).Pet(i) = PetSlot Player(index).Pet.CNum = i Exit For End If Next For i = 1 To 10 If PetMapCache(PlayerMap).Pet(i) > 0 Then Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i)) End If Next```In modPlayerIn Sub PlayerWarpFrom```'If 'refreshing' map```to just above```' send player's equipment to new map```Replace with```'If 'refreshing' map If (OldMap <> mapNum) And TempPlayer(index).TempPetSlot > 0 Then 'switch maps PetDisband index, OldMap SpawnPet index, mapNum, Trim$(Player(index).Pet.SpriteNum) PetFollowOwner index End If 'View Current Pets on Map For i = 1 To 10 If PetMapCache(Player(index).Map).Pet(i) > 0 Then Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i)) End If Next```**DONE** Link to comment Share on other sites More sharing options...
Wing Posted March 9, 2012 Share Posted March 9, 2012 Nice tutorial! The issues mentioned beforehand would be extremely troublesome. Glad your sharing your fix with everyone! Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 9, 2012 Author Share Posted March 9, 2012 Fixed A small error In player warp where I accidentally left in part of the .upperbound Cache. It has been removed to ensure smooth use of the pet system. Link to comment Share on other sites More sharing options...
Dzastin Posted March 11, 2012 Share Posted March 11, 2012 In SpawnPet Sub:PetMapCache(PlayerMap).Pet(i) = PetSlotWhen this is not:'PetMapCache(PlayerMap).Pet(i) = PetSlotMy Game Client closing. Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 11, 2012 Author Share Posted March 11, 2012 what? Link to comment Share on other sites More sharing options...
Dzastin Posted March 11, 2012 Share Posted March 11, 2012 Your Tutorial:> In Sub SpawnPet> > from> Code: [Select]> > 'Cache the Pets for players logging on [Add new Number to array]> > to just before> Code: [Select]> > Select Case GetPlayerDir(index)> > replace with> Code: [Select]> > For i = 1 To 10> If PetMapCache(PlayerMap).Pet(i) = 0 Then> PetMapCache(PlayerMap).Pet(i) = PetSlot> Player(index).Pet.CNum = i> Exit For> End If> Next> For i = 1 To 10> If PetMapCache(PlayerMap).Pet(i) > 0 Then> Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(i))> End If> NextNow, when i add this, and use item to summon pet, my client is closing.PetMapCache(PlayerMap).Pet(i) = PetSlot - this line closing my client, but when this is " ' ", this is work. Link to comment Share on other sites More sharing options...
RyokuHasu Posted March 11, 2012 Author Share Posted March 11, 2012 you did something wrong in either the original tutorial or mine and Im not quite what. Link to comment Share on other sites More sharing options...
bunny123 Posted June 13, 2012 Share Posted June 13, 2012 Server side:@Microsoft:> If (OldMap <> MapNum) And TempPlayer(Index).TempPetSlot > 0 Then> 'switch maps> PetDisband Index, OldMap> SpawnPet Index, MapNum, Trim$(Player(Index).Pet.SpriteNum)> PetFollowOwner Index> End If@Error:> Compile error:> > Wrong number of arguments or invalid property assignment Link to comment Share on other sites More sharing options...
bunny123 Posted June 13, 2012 Share Posted June 13, 2012 I found the problem.You put the following into that code:```SpawnPet Index, MapNum, Trim$(Player(Index).Pet.SpriteNum)```The options for SpawnPet are:```SpawnPet(ByVal Index As Long, ByVal MapNum As Long)```You put three options in your code but the SpawnPet sub has only two options.So in modPlayer (Server side) change```SpawnPet Index, MapNum, Trim$(Player(Index).Pet.SpriteNum)```to```SpawnPet Index, MapNum``` Link to comment Share on other sites More sharing options...
Justn Posted June 13, 2012 Share Posted June 13, 2012 I thought lightning was gonna release an actual fix for this :( maybe he forgot Link to comment Share on other sites More sharing options...
Ariel Posted June 17, 2012 Share Posted June 17, 2012 ~~Lol i cant still go back to the map i was with my pet :Z Help?and sometimes when i use the item to summon the pet its not spawning but if i change map after i used the pet show up at the next map, weird…and i did everything right :O~~Edit: didnt saw its outdated :D Link to comment Share on other sites More sharing options...
Whackeddie99 Posted July 16, 2012 Share Posted July 16, 2012 Even if this is outdated, it didn't work in the first place. Pets have super buggy movement after adding, and when I removed it went back to normal so I know for sure it was this tutorial. 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