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

Can set enemies to do not flee?

Discussion in 'Script Support' started by Lemke, Mar 13, 2018.

  1. Lemke
    Offline

    Lemke New Member

    Joined:
    Sep 26, 2015
    Messages:
    19
    Likes Received:
    0
    Hello guys!
    There is some way to set enemies cant flee when they have 10%hp?
    Thanks in advance,i think the code is in baseAI.cs and all "x"AI.cs?Thank you!!!
     
  2. Juzzver
    Offline

    Juzzver Member

    Joined:
    Sep 17, 2013
    Messages:
    176
    Likes Received:
    17
    BaseAI.cs
    public virtual double TransformMoveDelay(double delay)

    Code (C#):
    1.  
    2.             if (!m_Mobile.IsDeadPet && (m_Mobile.ReduceSpeedWithDamage || m_Mobile.IsSubdued))
    3.             {
    4.                 double offset = (double)m_Mobile.Hits / m_Mobile.HitsMax;
    5.  
    6.                 if (offset < 0.0)
    7.                 {
    8.                     offset = 0.0;
    9.                 }
    10.                 else if (offset > 1.0)
    11.                 {
    12.                     offset = 1.0;
    13.                 }
    14.  
    15.                 offset = 1.0 - offset;
    16.  
    17.                 delay += (offset * speedfactor);
    18.             }
     
  3. Lemke
    Offline

    Lemke New Member

    Joined:
    Sep 26, 2015
    Messages:
    19
    Likes Received:
    0
    Thank you!!!!Working!!!!
     
  4. rhasce
    Offline

    rhasce Member

    Joined:
    Jan 10, 2017
    Messages:
    230
    Likes Received:
    9
    Hi, sorry but I feel like an idiot but what is working?, is there anything to change? Di I missed a secret post? I dont see where I can stop them from fleeing , set the 1.0 to 0(I tried did nothing )? help :)
     
    #4 rhasce, Mar 27, 2018
    Last edited: Mar 27, 2018
  5. NoSkillNewbie
    Offline

    NoSkillNewbie Member

    Joined:
    May 7, 2017
    Messages:
    31
    Likes Received:
    4
    You can always use the override as well.

    public override bool CanFlee { get { return false; } }
     
  6. rhasce
    Offline

    rhasce Member

    Joined:
    Jan 10, 2017
    Messages:
    230
    Likes Received:
    9
    ahhhh where could I place that?:
     
  7. NoSkillNewbie
    Offline

    NoSkillNewbie Member

    Joined:
    May 7, 2017
    Messages:
    31
    Likes Received:
    4
    Maybe this will help explain it some. You could change it for every single creature by editing the base file. There are certain things that are meant to run. So the best thing is to create your own creature. I've made you an NPC wearing dyed plate armor, that won't flee, is immune to bard stuff, auto dispels summons, Poison immune, and always Red. All of those are just overriding the default class for this one creature.

    Code (C#):
    1.  
    2. using System;
    3. using Server.Items;
    4. using System.Collections.Generic;
    5. using Server.Engines.CannedEvil;
    6.  
    7. namespace Server.Mobiles
    8. {
    9.     [CorpseName( "rhasce corpse" )]
    10.     public class Rhasce : BaseCreature
    11.     {
    12.         public override bool CanFlee { get { return false; } }
    13.         public override bool BardImmune{ get{ return true; } } //make it bardimmune: unpeaceable\unprovokable\undiscorded
    14.         public override bool AutoDispel{ get{ return true; } } //make it auto dispel summons
    15.         public override Poison PoisonImmune{ get{ return Poison.Lethal; } } //make it immmune to lethal poison
    16.         public override bool AlwaysMurderer{ get{ return true; } } //make the npc red
    17.        
    18.         public int m_ArmorHUE = 0x54E;
    19.  
    20.         [Constructable]
    21.         public Rhasce() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
    22.         {
    23.             Name = "Rhasce"; //the name players will see
    24.             // Body = 0x25D; //Male Body
    25.             Body = 0x25E; //Female Body
    26.  
    27.             SetStr( 500, 750 ); //set stats
    28.             SetDex( 250, 400 );
    29.             SetInt( 350, 550 );
    30.  
    31.             SetHits( 2000, 2500 ); //set hp
    32.  
    33.             SetDamage( 70, 80 ); //set how much damage ~
    34.  
    35.             SetDamageType( ResistanceType.Physical, 50 ); //which damage type it does
    36.             SetDamageType( ResistanceType.Cold, 50 );
    37.             // SetDamageType( ResistanceType.Fire, 50 );
    38.             // SetDamageType( ResistanceType.Poison, 50 );
    39.             // SetDamageType( ResistanceType.Energy, 50 );
    40.  
    41.             SetResistance( ResistanceType.Physical, 60, 80 ); //what resists it has
    42.             SetResistance( ResistanceType.Fire, 55, 70 );
    43.             SetResistance( ResistanceType.Cold, 55, 70 );
    44.             SetResistance( ResistanceType.Poison, 55, 70 );
    45.             SetResistance( ResistanceType.Energy, 55, 70 );
    46.  
    47.             SetSkill( SkillName.Anatomy, 200.0 );
    48.             SetSkill( SkillName.Tactics, 200.0 );
    49.             SetSkill( SkillName.Macing, 200.0 );
    50.  
    51.             Fame = 30000; //its fame/karma
    52.             Karma = -30000;
    53.            
    54.             VirtualArmor = 50;
    55.  
    56.             PlateChest chest = new PlateChest(); //add its armor and set its hue and not movable so it won't be on loot
    57.             chest.Hue = m_ArmorHUE;
    58.             chest.Movable = false;
    59.             AddItem( chest );
    60.            
    61.             PlateArms arms = new PlateArms();
    62.             arms.Hue = m_ArmorHUE;
    63.             arms.Movable = false;
    64.             AddItem( arms );
    65.            
    66.             PlateGloves gloves = new PlateGloves();
    67.             gloves.Hue = m_ArmorHUE;
    68.             gloves.Movable = false;
    69.             AddItem( gloves );
    70.            
    71.             PlateGorget gorget = new PlateGorget();
    72.             gorget.Hue = m_ArmorHUE;
    73.             gorget.Movable = false;
    74.             AddItem( gorget );
    75.            
    76.             PlateLegs legs = new PlateLegs();
    77.             legs.Hue = m_ArmorHUE;
    78.             legs.Movable = false;
    79.             AddItem( legs );
    80.            
    81.             WarHammer weapon = new WarHammer(); //add its weapon and set its hue and not movable so it won't be on loot
    82.             weapon.Name = "Rhasce's Hammer of Smiting!";
    83.             weapon.Hue = m_ArmorHUE;
    84.             weapon.Movable = false;
    85.             AddItem( weapon );
    86.            
    87.             FurBoots boots = new FurBoots(); //add its boots and set its hue and not movable so it won't be on loot
    88.             boots.Hue = m_ArmorHUE;
    89.             boots.Movable = false;
    90.             AddItem( boots );
    91.  
    92.             Item hair = new Item( 8251 );  //add its hair and set its hue and not movable so it won't be on loot
    93.             hair.Hue = m_ArmorHUE;
    94.             hair.Layer = Layer.Hair;
    95.             hair.Movable = false;
    96.             AddItem( hair );
    97.  
    98.             AddItem( new Gold( 2500, 5000 ));
    99.         }
    100.  
    101.         public override void GenerateLoot() //add normal loot
    102.         {
    103.             AddLoot( LootPack.UltraRich ); // set the loot type to ultra rich
    104.         }
    105.  
    106.         public Rhasce( Serial serial ) : base( serial ) // no idea what this does
    107.         {
    108.         }
    109.  
    110.         public override void Serialize( GenericWriter writer ) // this save the info on the mob so it won't be deleted all the time
    111.         {
    112.             base.Serialize( writer );
    113.             writer.Write( (int) 0 ); // version
    114.         }
    115.  
    116.         public override void Deserialize( GenericReader reader ) // this load the info on the mob so it won't be deleted all the time
    117.         {
    118.             base.Deserialize( reader );
    119.             int version = reader.ReadInt();
    120.         }
    121.     }
    122. }
    123.  
     
    • Like Like x 1
  8. rhasce
    Offline

    rhasce Member

    Joined:
    Jan 10, 2017
    Messages:
    230
    Likes Received:
    9
    Sweet man thanks a lot :)
     
Similar Threads: set enemies
Forum Title Date
Custom Releases Custom full sets (Only full set can be equiped). Saturday at 12:14 PM
Script Support How can I Set Item Ownership to an Account? Nov 17, 2018
Windows Support Trying to setup a clean servuo Oct 25, 2018
Archived Bug Reports Various Armor Sets are only spawning 1 type Sep 30, 2018
General Discussion Skills set to be dropped are not dropping Sep 25, 2018
Archived Bug Reports Missing Epiphany Armor Set Sep 14, 2018
Archived Bug Reports Mini Champ re-set bug... Sep 13, 2018