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:
    1
    Likes Received:
    0
    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:
    691
    Likes Received:
    70
    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 Creator
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    730
    Likes Received:
    147
    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
General Discussion Shrink a pet or make a shrink potion Saturday at 5:32 AM
ServUO Discussion New real UO pet revamp is now LIVE! 3/16/2017 Mar 16, 2017
Script Support Pets and followers movement block Mar 4, 2017
Archived Bug Reports Pet Loyalty = 0 but still under controll Mar 3, 2017
Script Support Party Member Pets - My first script! (Kinda) Feb 20, 2017