DarkDino Posted June 21, 2013 Author Share Posted June 21, 2013 Hello! designers D:! i have a problem in the Pet System!. When i call a PET a error appear```Select Case GetPlayerDir(index)Case DIR_UPCall SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)Case DIR_DOWNCall SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) + 1)Case DIR_LEFTCall SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) + 1, GetPlayerY(index))Case DIR_RIGHTCall SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)End Select ```In this "Call SpawnNpc"Wrong number of arguments or invalid property assignmentPlease help D:!. Link to comment Share on other sites More sharing options...
Sigait Posted June 21, 2013 Share Posted June 21, 2013 uhmm I think you should check the implementation of the spawnNpc method,maybe it takes more arguments or different arguments.Also the last one I think should be : Case DIR_RIGHTCall SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) - 1, GetPlayerY(index) ).This surely isn't gonna resolve your error problem but I think it'll resolve another one.Regards,Relative Null. Link to comment Share on other sites More sharing options...
DarkDino Posted June 21, 2013 Author Share Posted June 21, 2013 Doen't work :/ have the same error. Link to comment Share on other sites More sharing options...
Sigait Posted June 21, 2013 Share Posted June 21, 2013 As I recall I told you it would'nt resolve the error but another one.What I think is your problem is that you are calling the spawnNpc method with more,less or the wrong arguments.To resolve your problem check the spawnNpc implementation and see what arguments it gets. Link to comment Share on other sites More sharing options...
DarkDino Posted June 21, 2013 Author Share Posted June 21, 2013 Yes D: ```Public Sub SpawnNpc(ByVal MapNpcNum As Long, ByVal mapnum As Long, Optional ForcedSpawn As Boolean = False) Dim buffer As clsBuffer Dim NPCNum As Long Dim I As Long Dim x As Long Dim y As Long Dim Spawned As Boolean Dim HPRndNum As Long ' Check for subscript out of range If MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or mapnum <= 0 Or mapnum > MAX_MAPS Then Exit Sub NPCNum = Map(mapnum).NPC(MapNpcNum) If ForcedSpawn = False And Map(mapnum).NpcSpawnType(MapNpcNum) = 1 Then NPCNum = 0 If NPCNum > 0 Then MapNpc(mapnum).NPC(MapNpcNum).num = NPCNum MapNpc(mapnum).NPC(MapNpcNum).target = 0 MapNpc(mapnum).NPC(MapNpcNum).targetType = 0 ' clear If NPC(MapNpcNum).RandHP = 0 Then MapNpc(mapnum).NPC(MapNpcNum).HPSetTo = GetNpcMaxVital(NPCNum, Vitals.HP) MapNpc(mapnum).NPC(MapNpcNum).Vital(Vitals.HP) = MapNpc(mapnum).NPC(MapNpcNum).HPSetTo Else HPRndNum = rand(NPC(NPCNum).HPMin, NPC(NPCNum).HP) MapNpc(mapnum).NPC(MapNpcNum).HPSetTo = HPRndNum MapNpc(mapnum).NPC(MapNpcNum).Vital(Vitals.HP) = HPRndNum End If MapNpc(mapnum).NPC(MapNpcNum).Dir = Int(Rnd * 4) 'Check if theres a spawn tile for the specific npc For x = 0 To Map(mapnum).MaxX For y = 0 To Map(mapnum).MaxY If Map(mapnum).Tile(x, y).Type = TILE_TYPE_NPCSPAWN Then If Map(mapnum).Tile(x, y).Data1 = MapNpcNum Then MapNpc(mapnum).NPC(MapNpcNum).x = x MapNpc(mapnum).NPC(MapNpcNum).y = y MapNpc(mapnum).NPC(MapNpcNum).Dir = Map(mapnum).Tile(x, y).Data2 Spawned = True Exit For End If End If Next y Next x If Not Spawned Then ' Well try 100 times to randomly place the sprite For I = 1 To 100 x = Random(0, Map(mapnum).MaxX) y = Random(0, Map(mapnum).MaxY) If x > Map(mapnum).MaxX Then x = Map(mapnum).MaxX If y > Map(mapnum).MaxY Then y = Map(mapnum).MaxY ' Check if the tile is walkable If NpcTileIsOpen(mapnum, x, y) Then MapNpc(mapnum).NPC(MapNpcNum).x = x MapNpc(mapnum).NPC(MapNpcNum).y = y Spawned = True Exit For End If Next End If ' Didn't spawn, so now we'll just try to find a free tile If Not Spawned Then For x = 0 To Map(mapnum).MaxX For y = 0 To Map(mapnum).MaxY If NpcTileIsOpen(mapnum, x, y) Then MapNpc(mapnum).NPC(MapNpcNum).x = x MapNpc(mapnum).NPC(MapNpcNum).y = y Spawned = True End If Next Next End If ' If we suceeded in spawning then send it to everyone If Spawned Then Set buffer = New clsBuffer buffer.WriteLong SSpawnNpc buffer.WriteLong MapNpcNum buffer.WriteLong MapNpc(mapnum).NPC(MapNpcNum).num buffer.WriteLong MapNpc(mapnum).NPC(MapNpcNum).x buffer.WriteLong MapNpc(mapnum).NPC(MapNpcNum).y buffer.WriteLong MapNpc(mapnum).NPC(MapNpcNum).Dir buffer.WriteLong MapNpc(mapnum).NPC(MapNpcNum).HPSetTo buffer.WriteByte MapNpc(mapnum).NPC(MapNpcNum).IsPet buffer.WriteString MapNpc(mapnum).NPC(MapNpcNum).PetData.Name buffer.WriteLong MapNpc(mapnum).NPC(MapNpcNum).PetData.Owner SendDataToMap mapnum, buffer.ToArray() Set buffer = Nothing UpdateMapBlock mapnum, MapNpc(mapnum).NPC(MapNpcNum).x, MapNpc(mapnum).NPC(MapNpcNum).y, True End If SendMapNpcVitals mapnum, MapNpcNum Else MapNpc(mapnum).NPC(MapNpcNum).num = 0 MapNpc(mapnum).NPC(MapNpcNum).target = 0 MapNpc(mapnum).NPC(MapNpcNum).targetType = 0 ' clear ' send death to the map Set buffer = New clsBuffer buffer.WriteLong SNpcDead buffer.WriteLong MapNpcNum SendDataToMap mapnum, buffer.ToArray() Set buffer = Nothing End IfEnd Sub```i dont understand the error :S, are working!, when i use a Summon Pet have this error. Link to comment Share on other sites More sharing options...
Stein Posted June 21, 2013 Share Posted June 21, 2013 You don't understand? SpawnNPC takes THREE arguments, you're supplying FOUR.```Public Sub SpawnNpc(ByVal MapNpcNum As Long, ByVal mapnum As Long, Optional ForcedSpawn As Boolean = False)``````Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1)```The pet spawning you have there simply isn't going to work in this version for various reasons. None of it matches up to eachother. Link to comment Share on other sites More sharing options...
abhi2011 Posted June 21, 2013 Share Posted June 21, 2013 Lets simplify stuff, cause I am pretty sure OP won't understand what Stein said. (And I am criticizing OP no Stein.)SpawnNPC sub takes in three arguments. The Map number, the MapNPCNum for the Map number and should the NPC be force spawned. The X and Y are taken from the MapNpcRec x,y.You are supplying four arguments. The X coord, the Y coord and the PetSlot. (Not sure what PetSlot is intended for.)You will have to make a new sub that will handle Spawning NPCs not there in the MapNpcRec. Link to comment Share on other sites More sharing options...
lel Posted June 21, 2013 Share Posted June 21, 2013 O.O Learning….... *pulls out food* "Munch Munch"O.O "Munch Munch"O.O Actually this is huge strides in help compared to what I've seen in the past. Link to comment Share on other sites More sharing options...
DarkDino Posted June 22, 2013 Author Share Posted June 22, 2013 Well i solved but have a problem with NPC SPAWNS, the Pets :S spawn in D: random X,Y Map help me pleaseThis is my SPawnNPC Code```Public Sub SpawnNpc(ByVal mapNpcNum As Long, ByVal MapNum As Long, Optional PetX As Long, Optional PetY As Long) Dim Buffer As clsBuffer Dim npcNum As Long Dim i As Long Dim x As Long Dim y As Long Dim Spawned As Boolean ' Check for subscript out of range If mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or MapNum <= 0 Or MapNum > MAX_MAPS Then Exit Sub npcNum = Map(MapNum).Npc(mapNpcNum) If npcNum > 0 Then MapNpc(MapNum).Npc(mapNpcNum).Num = npcNum MapNpc(MapNum).Npc(mapNpcNum).target = 0 MapNpc(MapNum).Npc(mapNpcNum).targetType = 0 ' clear MapNpc(MapNum).Npc(mapNpcNum).Vital(Vitals.HP) = GetNpcMaxVital(npcNum, Vitals.HP) MapNpc(MapNum).Npc(mapNpcNum).Vital(Vitals.MP) = GetNpcMaxVital(npcNum, Vitals.MP) MapNpc(MapNum).Npc(mapNpcNum).Dir = Int(Rnd * 4) 'Check if theres a spawn tile for the specific npc For x = 0 To Map(MapNum).MaxX For y = 0 To Map(MapNum).MaxY If Map(MapNum).Tile(x, y).Type = TILE_TYPE_NPCSPAWN Then If Map(MapNum).Tile(x, y).Data1 = mapNpcNum Then MapNpc(MapNum).Npc(mapNpcNum).x = x MapNpc(MapNum).Npc(mapNpcNum).y = y MapNpc(MapNum).Npc(mapNpcNum).Dir = Map(MapNum).Tile(x, y).Data2 Spawned = True Exit For End If End If Next y Next x If Npc(npcNum).Behaviour = NPC_BEHAVIOUR_PET Then If PetX > 0 And PetY > 0 Then MapNpc(MapNum).Npc(mapNpcNum).x = PetX MapNpc(MapNum).Npc(mapNpcNum).y = PetY Spawned = True End If End If If Not Spawned Then ' Well try 100 times to randomly place the sprite For i = 1 To 100 x = Random(0, Map(MapNum).MaxX) y = Random(0, Map(MapNum).MaxY) If x > Map(MapNum).MaxX Then x = Map(MapNum).MaxX If y > Map(MapNum).MaxY Then y = Map(MapNum).MaxY ' Check if the tile is walkable If NpcTileIsOpen(MapNum, x, y) Then MapNpc(MapNum).Npc(mapNpcNum).x = x MapNpc(MapNum).Npc(mapNpcNum).y = y Spawned = True Exit For End If Next End If ' Didn't spawn, so now we'll just try to find a free tile If Not Spawned Then For x = 0 To Map(MapNum).MaxX For y = 0 To Map(MapNum).MaxY If NpcTileIsOpen(MapNum, x, y) Then MapNpc(MapNum).Npc(mapNpcNum).x = x MapNpc(MapNum).Npc(mapNpcNum).y = y Spawned = True End If Next Next End If ' If we suceeded in spawning then send it to everyone If Spawned Then Set Buffer = New clsBuffer Buffer.WriteLong SSpawnNpc Buffer.WriteLong mapNpcNum Buffer.WriteLong MapNpc(MapNum).Npc(mapNpcNum).Num Buffer.WriteLong MapNpc(MapNum).Npc(mapNpcNum).x Buffer.WriteLong MapNpc(MapNum).Npc(mapNpcNum).y Buffer.WriteLong MapNpc(MapNum).Npc(mapNpcNum).Dir SendDataToMap MapNum, Buffer.ToArray() Set Buffer = Nothing End If SendMapNpcVitals MapNum, mapNpcNum End IfEnd Sub```This is my SpawnPET```Sub SpawnPet(ByVal index As Long, ByVal MapNum As Long, Optional spellnum As Long)'Lightning's Pet System 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 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 If spellnum > 0 Then Player(index).Pet.PetNum = spellnum Map(PlayerMap).Npc(PetSlot) = Player(index).Pet.PetNum MapNpc(PlayerMap).Npc(PetSlot).Num = Player(index).Pet.PetNum 'set its Pet Data MapNpc(PlayerMap).Npc(PetSlot).IsPet = YES MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = Trim(Npc(Player(index).Pet.PetNum).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 <> Npc(Player(index).Pet.PetNum).Sprite Then Player(index).Pet.SpriteNum = Npc(Player(index).Pet.PetNum).Sprite Player(index).Pet.Name = Trim(Npc(Player(index).Pet.PetNum).Name) End If End If If Player(index).Pet.PetLevel(Player(index).Pet.PetNum) < 1 Then Player(index).Pet.PetDamage(Player(index).Pet.PetNum) = Npc(Player(index).Pet.PetNum).Damage + RAND(1, 3) Player(index).Pet.PetExp(Player(index).Pet.PetNum) = 0 Player(index).Pet.PetLevel(Player(index).Pet.PetNum) = 1 Player(index).Pet.PetHP(Player(index).Pet.PetNum) = GetPetVital(index, HP) Player(index).Pet.PetMaxHP(Player(index).Pet.PetNum) = Npc(Player(index).Pet.PetNum).HP + (GetPetLevel(index) + RAND(5, 20)) End If Player(index).Pet.Name = Trim(Npc(Player(index).Pet.PetNum).Name) If GetPetVital(index, HP) <= 0 Then SetPetVital index, HP, GetPetMaxVital(index, HP) End If TempPlayer(index).TempPetSlot = PetSlot 'cache the map for sending 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 If GetPlayerX(index) <= 0 Or GetPlayerY(index) <= 0 Then If NpcTileIsOpen(MapNum, GetPlayerX(index), GetPlayerY(index) + 1) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) + 1) ElseIf NpcTileIsOpen(MapNum, GetPlayerX(index) + 1, GetPlayerY(index)) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) + 1, GetPlayerY(index)) ElseIf NpcTileIsOpen(MapNum, GetPlayerX(index), GetPlayerY(index) - 1) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1) ElseIf NpcTileIsOpen(MapNum, GetPlayerX(index) - 1, GetPlayerY(index)) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) - 1, GetPlayerY(index)) Else Call SpawnNpc(PetSlot, PlayerMap) End If Else If NpcTileIsOpen(MapNum, GetPlayerX(index), GetPlayerY(index) - 1) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) - 1) ElseIf NpcTileIsOpen(MapNum, GetPlayerX(index), GetPlayerY(index) + 1) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index), GetPlayerY(index) + 1) ElseIf NpcTileIsOpen(MapNum, GetPlayerX(index) + 1, GetPlayerY(index)) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) + 1, GetPlayerY(index)) ElseIf NpcTileIsOpen(MapNum, GetPlayerX(index) - 1, GetPlayerY(index)) Then Call SpawnNpc(PetSlot, PlayerMap, GetPlayerX(index) - 1, GetPlayerY(index)) Else Call SpawnNpc(PetSlot, PlayerMap) End If End If '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, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)) End If End If Next Player(index).Pet.IsOut = True PetFollowOwner index PetWindow indexEnd Sub``` Link to comment Share on other sites More sharing options...
abhi2011 Posted June 22, 2013 Share Posted June 22, 2013 In your main code, replace SpawnNPC with SpawnPet Link to comment Share on other sites More sharing options...
DarkDino Posted June 22, 2013 Author Share Posted June 22, 2013 Thanks, but dont work D:, I decided to delete the system pets for other bugs in map!, thanks all. 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