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:
    724
    Likes Received:
    72
    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
    Online

    Vorspire Vita-Nex: Core Creator
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    747
    Likes Received:
    150
    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 Pets and stats gain Saturday at 5:38 PM
ServUO Discussion New pet training system on real UO publish 97. Apr 15, 2017
ServUO Discussion Pets logout Apr 10, 2017
Script Support Allow un-shrinking of pets only when near animal trainer NPC Apr 6, 2017
ServUO Discussion Pet AoE damage Apr 2, 2017