1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Pet auto guard first when you attack.

Discussion in 'Script Support' started by Opywang, Jan 17, 2017.

  1. Opywang
    Offline

    Opywang New Member

    Joined:
    Jan 16, 2017
    Messages:
    28
    Likes Received:
    1
    When you have pet on guard, and if you attack first pet does nothing. On Demise they seem to have figure it out, and pet guard at everything that attack you no matter what if anybody know the AI script for that I would appreciate it very much!
     
  2. Hammerhand
    Offline

    Hammerhand Active Member

    Joined:
    Mar 26, 2013
    Messages:
    803
    Likes Received:
    77
    If you are attacked, the pet will guard you & attack the attacker. If YOU attack a mob, it will only defend you from other attackers. It defends against an aggressor, but not a mob you attack. And if you have more than 1 pet out & guarding, only the 1st one you pulled from the stables will defend against an aggressor, any others need to "hear" the kill command. To change that would most likely require modifications to BaseAI.cs itself.
     
  3. Vorspire
    Offline

    Vorspire Vita-Nex: Core
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    883
    Likes Received:
    163
    You could override PlayerMobile.OnCombatantChange() and loop through the player's follower's list, fetching pets that are in Guard mode, then setting their Combatant to the player's current Combatant.

    Code (C#):
    1.  
    2. // Required (top of script):
    3. // using System.Linq;
    4.  
    5. public override void OnCombatantChange()
    6. {
    7.     base.OnCombatantChange();
    8.  
    9.     if (Combatant != null)
    10.     {
    11.         foreach (var pet in AllFollowers.OfType<BaseCreature>())
    12.         {
    13.             if (pet.Combatant != null && pet.Combatant != Combatant && pet.ControlOrder == OrderType.Guard)
    14.             {
    15.                 pet.Attack(Combatant);
    16.             }
    17.         }
    18.     }
    19. }
    20.  
     
Similar Threads: Pet auto
Forum Title Date
Archived Bug Reports Bonded pets don`t autostable last svn Aug 27, 2016
Archived Bug Reports All pets - AUTO summon on logout login. Aug 24, 2016
Script Support Stabling Pets Deeds? Sep 29, 2017
General Discussion pet leveling deed? Aug 22, 2017
Archived Bug Reports PetBraningIron Aug 18, 2017
Archived Bug Reports Summons and pets gaining justice, not the owner. Aug 13, 2017
Archived Bug Reports VvV member tamers cannot heal their pets if they leave guild Aug 7, 2017