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:
    647
    Likes Received:
    66
    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:
    682
    Likes Received:
    140
    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 Party Member Pets - My first script! (Kinda) Yesterday at 9:25 PM
Script Support Reapetable Timer Feb 8, 2017
Archived Bug Reports Despise players go grey while healing evil "pets" in trammel Jan 18, 2017
Archived Bug Reports Crystal field teleporter does not transport pets Jan 14, 2017
Archived Bug Reports Players in VvV can not heal their pets Jan 11, 2017