here's the pet sub: ``` Public Sub Pet() Dim I As Long, X As Long, Y As Long, n As Long, x1 As Long, y1 As Long, TickCount As Long Dim Damage As Long, DistanceX As Long, DistanceY As Long, PETnum As Long, Target As Long Dim DidWalk As Boolean, Pet(1 To 20) As Integer Dim index On Error Resume Next ' ///////////////////////////////////////// ' // This is used for ATTACKING ON SIGHT // ' ///////////////////////////////////////// ' Make sure theres a PET with the map If Map(Y).Pet(X) > 0 Then If MapPETS(Y, X).num > 0 Then ' If the pet is a attack on sight, search for a player on the map If Pet(PETnum).Behavior = PET_BEHAVIOR_ATTACKONSIGHT Or Pet(PETnum).Behavior = PET_BEHAVIOR_RELAXED Then For I = 1 To MAX_PLAYERS If IsPlaying(I) Then If GetPlayerMap(I) = Y Then If MapPET(Y, X).Target = 0 Then If GetPlayerAccess(I) GetPlayerX(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_LEFT) Then Call PETMove(Y, X, DIR_LEFT, MOVING_WALKING) DidWalk = True End If End If End If ' Down If MapPET(Y, X).Y < GetPlayerY(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_DOWN) Then Call PETMove(Y, X, DIR_DOWN, MOVING_WALKING) DidWalk = True End If End If End If ' Up If MapPET(Y, X).Y > GetPlayerY(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_UP) Then Call PETMove(Y, X, DIR_UP, MOVING_WALKING) DidWalk = True End If End If End If Case 2 ' Down If MapPET(Y, X).Y < GetPlayerY(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_DOWN) Then Call PETMove(Y, X, DIR_DOWN, MOVING_WALKING) DidWalk = True End If End If End If ' Up If MapPET(Y, X).Y > GetPlayerY(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_UP) Then Call PETMove(Y, X, DIR_UP, MOVING_WALKING) DidWalk = True End If End If End If ' Right If MapPET(Y, X).X < GetPlayerX(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_RIGHT) Then Call PETMove(Y, X, DIR_RIGHT, MOVING_WALKING) DidWalk = True End If End If End If ' Left If MapPET(Y, X).X > GetPlayerX(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_LEFT) Then Call PETMove(Y, X, DIR_LEFT, MOVING_WALKING) DidWalk = True End If End If End If Case 3 ' Left If MapPET(Y, X).X > GetPlayerX(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_LEFT) Then Call PETMove(Y, X, DIR_LEFT, MOVING_WALKING) DidWalk = True End If End If End If ' Right If MapPET(Y, X).X < GetPlayerX(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_RIGHT) Then Call PETMove(Y, X, DIR_RIGHT, MOVING_WALKING) DidWalk = True End If End If End If ' Up If MapPET(Y, X).Y > GetPlayerY(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_UP) Then Call PETMove(Y, X, DIR_UP, MOVING_WALKING) DidWalk = True End If End If End If ' Down If MapPET(Y, X).Y < GetPlayerY(index) Then If DidWalk = False Then If CanPETMove(Y, X, DIR_DOWN) Then Call PETMove(Y, X, DIR_DOWN, MOVING_WALKING) DidWalk = True End If End If End If End Select ' Check if we can't move and if player is behind something and if we can just switch dirs If Not DidWalk Then If MapPET(Y, X).X - 1 = GetPlayerX(index) Then If MapPET(Y, X).Y = GetPlayerY(index) Then If MapPET(Y, X).Dir DIR_LEFT Then Call PETDir(Y, X, DIR_LEFT) End If End If DidWalk = True End If If MapPET(Y, X).X + 1 = GetPlayerX(index) Then If MapPET(Y, X).Y = GetPlayerY(index) Then If MapPET(Y, X).Dir DIR_RIGHT Then Call PETDir(Y, X, DIR_RIGHT) End If End If DidWalk = True End If If MapPET(Y, X).X = GetPlayerX(index) Then If MapPET(Y, X).Y - 1 = GetPlayerY(index) Then If MapNPET(Y, X).Dir DIR_UP Then Call PETDir(Y, X, DIR_UP) End If End If DidWalk = True End If If MapPET(Y, X).X = GetPlayerX(index) Then If MapPET(Y, X).Y + 1 = GetPlayerY(index) Then If MapPET(Y, X).Dir DIR_DOWN Then Call PETDir(Y, X, DIR_DOWN) End If End If DidWalk = True End If ' We could not move so player must be behind something, walk randomly. If Not DidWalk Then I = Int(Rnd * 2) If I = 1 Then I = Int(Rnd * 4) If CanPETMove(Y, X, I) Then Call PETMove(Y, X, I, MOVING_WALKING) End If End If End If End If Else MapPET(Y, X).index = 0 End If End If Else I = Int(Rnd * 4) If I = 1 Then I = Int(Rnd * 4) If CanPETMove(Y, X, I) Then Call PETMove(Y, X, I, MOVING_WALKING) End If End If End If End If End If End If ' ///////////////////////////////////////////// ' // This is used for pet to attack players // ' ///////////////////////////////////////////// ' Make sure theres a PET with the map If Map(Y).Pet(X) > 0 Then If MapPET(Y, X).num > 0 Then Target = MapPET(Y, X).Target ' Check if the PET can attack the targeted player player If Target > 0 Then ' Is the target playing and on the same map? If IsPlaying(Target) And GetPlayerMap(Target) = Y Then ' Can the pet attack the player? If CanPETAttackPlayer(X, Target) Then If Not CanPlayerBlockHit(Target) Then Damage = Pet(PETnum).STR - GetPlayerProtection(Target) If Damage > 0 Then If SCRIPTING = 1 Then MyScript.ExecuteStatement "Scripts\Main.txt", "PlayerHitPet " & Target & "," & X & "," & Damage Else Call PETAttackPlayer(X, Target, Damage) End If Else Call BattleMsg(Target, "The " & Trim(Pet(PETnum).Name) & " couldn't hurt you!", BRIGHTBLUE, 1) 'Call PlayerMsg(Target, "The " & Trim(PET(PETNum).Name) & "'s hit didn't even phase you!", BrightBlue) End If Else Call BattleMsg(Target, "You blocked the " & Trim(Pet(PETnum).Name) & "'s hit!", BRIGHTCYAN, 1) 'Call PlayerMsg(Target, "Your " & Trim(Item(GetPlayerInvItemNum(Target, GetPlayerShieldSlot(Target))).Name) & " blocks the " & Trim(PET(PETNum).Name) & "'s hit!", BrightCyan) End If End If Else ' Player left map or game, set target to 0 MapPET(Y, X).Target = 0 End If End If End If End If ' //////////////////////////////////////////// ' // This is used for regenerating PET's HP // ' //////////////////////////////////////////// ' Check to see if we want to regen some of the PET's hp If MapPET(Y, X).num > 0 Then If TickCount > GivePETHPTimer + 10000 Then If MapPET(Y, X).HP > 0 Then MapPET(Y, X).HP = MapPET(Y, X).HP + GetPETHPRegen(PETnum) ' Check if they have more then they should and if so just set it to max If MapPET(Y, X).HP > GetPETMaxHP(PETnum) Then MapPET(Y, X).HP = GetPETMaxHP(PETnum) End If End If End If End If ' ////////////////////////////////////// ' // This is used for spawning an PET // ' ////////////////////////////////////// ' Check if we are supposed to spawn an PET or not If MapPET(Y, X).num = 0 Then If Map(Y).Pet(X) > 0 Then If TickCount > MapPET(Y, X).SpawnWait + (Pet(Map(Y).Pet(X)).SpawnSecs * 1000) Then Call SpawnPET(X, Y) End If End If End If Next X End If Next Y ' Make sure we reset the timer for PET hp regeneration If GetTickCount > GivePETHPTimer + 10000 Then GivePETHPTimer = GetTickCount End If ' Make sure we reset the timer for door closing If GetTickCount > KeyTimer + 15000 Then KeyTimer = GetTickCount End If ```