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 Member

    Joined:
    Jan 16, 2017
    Messages:
    65
    Likes Received:
    2
    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:
    827
    Likes Received:
    80
    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:
    920
    Likes Received:
    164
    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.  
     
  4. Tasanar
    Offline

    Tasanar Well-Known Member

    Joined:
    Oct 16, 2014
    Messages:
    2,607
    Likes Received:
    78
    Has anyone here applied Vorspires code? Does it produce any unexpected unintended consequences?
     
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
Bug Reports Pets detect hidden ability - probably bug Wednesday at 4:25 AM
ServUO Discussion Pet Breeding System for latest ServUO Dec 7, 2017
Bug Reports Exploit - rare stuff drop and bonded pets Dec 7, 2017
Bug Reports Pet Training - Publish 97 Nov 30, 2017
Script Support Rogue Pet Oct 30, 2017