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

Special Abilities 2014-06-13

Custom Abilities for creatures

  1. Omni
    Ok, examples...

    So... you want dragons in your shard to do five firebreaths at once ocasionally.

    Code (C#):
    1. Code (text):
    2. using System;
    3. using Server;
    4. using Server.Items;
    5.  
    6. namespace Server.Mobiles
    7. {
    8.     [CorpseName( "a dragon corpse" )]
    9.     public class Dragon : BaseCreature
    10.     {
    11.         [Constructable]
    12.         public Dragon () : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4 )
    13.         {
    14.             Name = "a dragon";
    15.             Body = Utility.RandomList( 12, 59 );
    16.             BaseSoundID = 362;
    17.  
    18.             SetStr( 796, 825 );
    19.             SetDex( 86, 105 );
    20.             SetInt( 436, 475 );
    21.  
    22.             SetHits( 478, 495 );
    23.  
    24.             SetDamage( 16, 22 );
    25.  
    26.             SetDamageType( ResistanceType.Physical, 100 );
    27.  
    28.             SetResistance( ResistanceType.Physical, 55, 65 );
    29.             SetResistance( ResistanceType.Fire, 60, 70 );
    30.             SetResistance( ResistanceType.Cold, 30, 40 );
    31.             SetResistance( ResistanceType.Poison, 25, 35 );
    32.             SetResistance( ResistanceType.Energy, 35, 45 );
    33.  
    34.             SetSkill( SkillName.EvalInt, 30.1, 40.0 );
    35.             SetSkill( SkillName.Magery, 30.1, 40.0 );
    36.             SetSkill( SkillName.MagicResist, 99.1, 100.0 );
    37.             SetSkill( SkillName.Tactics, 97.6, 100.0 );
    38.             SetSkill( SkillName.Wrestling, 90.1, 92.5 );
    39.  
    40.             Fame = 15000;
    41.             Karma = -15000;
    42.  
    43.             VirtualArmor = 60;
    44.  
    45.             Tamable = true;
    46.             ControlSlots = 3;
    47.             MinTameSkill = 93.9;
    48.         }
    49.  
    50.         public override void GenerateLoot()
    51.         {
    52.             AddLoot( LootPack.FilthyRich, 2 );
    53.             AddLoot( LootPack.Gems, 8 );
    54.         }
    55.  
    56.         public override bool ReacquireOnMovement{ get{ return !Controlled; } }
    57.         public override bool HasBreath{ get{ return true; } } // fire breath enabled
    58.         public override bool AutoDispel{ get{ return !Controlled; } }
    59.         public override int TreasureMapLevel{ get{ return 4; } }
    60.         public override int Meat{ get{ return 19; } }
    61.         public override int Hides{ get{ return 20; } }
    62.         public override HideType HideType{ get{ return HideType.Barbed; } }
    63.         public override int Scales{ get{ return 7; } }
    64.         public override ScaleType ScaleType{ get{ return ( Body == 12 ? ScaleType.Yellow : ScaleType.Red ); } }
    65.         public override FoodType FavoriteFood{ get{ return FoodType.Meat; } }
    66.         public override bool CanAngerOnTame { get { return true; } }
    67.  
    68.         public Dragon( Serial serial ) : base( serial )
    69.         {
    70.         }
    71.  
    72.         public override void Serialize( GenericWriter writer )
    73.         {
    74.             base.Serialize( writer );
    75.             writer.Write( (int) 0 );
    76.         }
    77.  
    78.         public override void Deserialize( GenericReader reader )
    79.         {
    80.             base.Deserialize( reader );
    81.             int version = reader.ReadInt();
    82.         }
    83.     }
    84. }
    That is the distro code for a Dragon.

    Code (C#):
    1.  
    2. using System;
    3. using Server;
    4. using Server.Items;
    5.  
    6. namespace Server.Mobiles
    7. {
    8.     [CorpseName( "a dragon corpse" )]
    9.     public class Dragon : [color=green]BaseSpecialCreature[/color]
    10.     {[color=green]
    11.             public override bool DoesMultiFirebreathing { get { return true; } }
    12.             public override double MultiFirebreathingChance { get { return 0.4; } }
    13.             public override int BreathDamagePercent { get { return 80; } }
    14.             public override int BreathMaxTargets { get { return 5; } }
    15.             public override int BreathMaxRange { get { return 5; } }
    16. [/color]
    17.         [Constructable]
    18.         public Dragon () : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4 )
    19.         {
    20.             Name = "a dragon";
    21.             Body = Utility.RandomList( 12, 59 );
    22.             BaseSoundID = 362;
    23.  
    24.             SetStr( 796, 825 );
    25.             SetDex( 86, 105 );
    26.             SetInt( 436, 475 );
    27.  
    28.             SetHits( 478, 495 );
    29.  
    30.             SetDamage( 16, 22 );
    31.  
    32.             SetDamageType( ResistanceType.Physical, 100 );
    33.  
    34.             SetResistance( ResistanceType.Physical, 55, 65 );
    35.             SetResistance( ResistanceType.Fire, 60, 70 );
    36.             SetResistance( ResistanceType.Cold, 30, 40 );
    37.             SetResistance( ResistanceType.Poison, 25, 35 );
    38.             SetResistance( ResistanceType.Energy, 35, 45 );
    39.  
    40.             SetSkill( SkillName.EvalInt, 30.1, 40.0 );
    41.             SetSkill( SkillName.Magery, 30.1, 40.0 );
    42.             SetSkill( SkillName.MagicResist, 99.1, 100.0 );
    43.             SetSkill( SkillName.Tactics, 97.6, 100.0 );
    44.             SetSkill( SkillName.Wrestling, 90.1, 92.5 );
    45.  
    46.             Fame = 15000;
    47.             Karma = -15000;
    48.  
    49.             VirtualArmor = 60;
    50.  
    51.             Tamable = true;
    52.             ControlSlots = 3;
    53.             MinTameSkill = 93.9;
    54.         }
    55.  
    56.         public override void GenerateLoot()
    57.         {
    58.             AddLoot( LootPack.FilthyRich, 2 );
    59.             AddLoot( LootPack.Gems, 8 );
    60.         }
    61.  
    62.         public override bool ReacquireOnMovement{ get{ return !Controlled; } }
    63.         [color=green]//[/color]public override bool HasBreath{ get{ return true; } } // fire breath enabled
    64.         public override bool AutoDispel{ get{ return !Controlled; } }
    65.         public override int TreasureMapLevel{ get{ return 4; } }
    66.         public override int Meat{ get{ return 19; } }
    67.         public override int Hides{ get{ return 20; } }
    68.         public override HideType HideType{ get{ return HideType.Barbed; } }
    69.         public override int Scales{ get{ return 7; } }
    70.         public override ScaleType ScaleType{ get{ return ( Body == 12 ? ScaleType.Yellow : ScaleType.Red ); } }
    71.         public override FoodType FavoriteFood{ get{ return FoodType.Meat; } }
    72.         public override bool CanAngerOnTame { get { return true; } }
    73.  
    74.         public Dragon( Serial serial ) : base( serial )
    75.         {
    76.         }
    77.  
    78.         public override void Serialize( GenericWriter writer )
    79.         {
    80.             base.Serialize( writer );
    81.             writer.Write( (int) 0 );
    82.         }
    83.  
    84.         public override void Deserialize( GenericReader reader )
    85.         {
    86.             base.Deserialize( reader );
    87.             int version = reader.ReadInt();
    88.         }
    89.     }
    90. }
    91.  
    This is after configuring it for multiple firebreathing.
    What does each thing mean?
    Code (C#):
    1.  
    2. public class Dragon : [color=green]BaseSpecialCreature[/color]
    3. This will allow you to use the special abilities I've developed, and packed them into a single class, you will still be able to use BaseCreature (90% of NPC Mobiles inherit from this class) as normal, because BaseSpecialCreature inherits from it.
    4.  
    public override bool DoesMultiFirebreathing { get { return true; } }
    This will enable the multiple firebreathing ability.

    public override double MultiFirebreathingChance { get { return 0.4; } }
    This will set a chance of 40% to use multiple firebreaths (if the chance is not hit, then the normal firebreathing style will be used).

    public override int BreathDamagePercent { get { return 80; } }
    This basically works as a scalar. The more you reduce it, the less damage a firebreath does, I added this considering that multiple firebreaths will be thougher

    public override int BreathMaxTargets { get { return 5; } }
    This will determine how many targets we will hit with our multiple firebreath

    public override int BreathMaxRange { get { return 5; } }
    This will determine the max tile range to check for hitting with firebreaths.

    //public override bool HasBreath{ get{ return true; } } // fire breath enabled
    Actually you could just leave this on, but I wanted to add that if you don't have it, it will work anyways, because baseclass defaults HasBreath to 'DoesMultiFirebreathing'.

    Note that firebreaths won't hit a single target twice.

    This was a old script that was given to me i don't take credit for this..