PigPen

Member
ServUO Version
Publish Unknown
Ultima Expansion
Mondain's Legacy
On my RunUO v 2.2 shard . . I have been trying to make a special Dragon that is impervious to arrows and bolts. I am probably way off, but the best my brain can think of for this is to use the 'OnDamage' section in the Dragon's script.

My problem is . . my efforts are not working and players using bows still slay the dragon from a distance with their Ranged weapons.

Here is my most recent try:
Code:
        public override void OnDamage( int amount, Mobile from, bool willKill )
        {
            if ( (from == null) || (from.Deleted) || !(from.Alive) || !(from.Map == this.Map) )
            {
                return;
            } 

            if (!Summoned && from != null)
            {
                    var ranged = from.FindItemOnLayer(Layer.TwoHanded);

                      if (ranged != null && ranged is BaseRanged)
                {
                          double reflectmsg = Utility.RandomDouble();

                    if (reflectmsg < 0.25)
                    {
                        from.SendMessage( "The dragon's scales deflect arrows and bolts." );
                    }

                    this.Hits = (this.Hits + amount);
                }
            }

            base.OnDamage( amount, from, willKill );
        }

I know this 'OnDamage' section is being tested because the players are getting the message that arrows and bolts are deflected. However . . the ranged weapons are still killing the Dragon.

Can anyone (please) tell me how I could prevent ranged weapons from damaging this Dragon?

Your time and thoughts are appreciated.
 
BaseRanged.cs, method onhit


C#:
if(attacker is PlayerMobile && defender is BaseCreature && defender is Dragon)
{
attacker.SendAsciiMessage ("You cant slay dragons with a bow!");

  return;
}

try
 
That's a kewl idea. Can that be tied to whether your Dragon is wearing barding or not?

Something like:

if(attacker is [I]PlayerMobile [/I]&& defender is BaseCreature && defender is Dragon &&[I] is wearrng kewl Dragon Barding[/I]) { attacker.SendAsciiMessage ("Ye Silly Sod!! Ye Can't be Slayin A Dragon thats armoured up like that mi' lad!"); return; // ...To whence thy came }
 
Thank you nipa for setting me on the right track. Here is what I found:

1) Your idea works except . . if the bow (weapon) has any properties added for MagicArrow or HitLightning etc then you need to edit BaseWeapon.cs like this example;
Code:
        public virtual void DoMagicArrow(Mobile attacker, Mobile defender)
        {
            if (!attacker.CanBeHarmful(defender, false))
                return;

//Special Creature Message:
            if ( (attacker is SpecialDragon) || (attacker is SpecialDrake) )
            {
            attacker.SendAsciiMessage("Magic Arrow does not work on that");
                return;
            }

            attacker.DoHarmful(defender);

            double damage = GetAosDamage(attacker, 10, 1, 4);

            attacker.MovingParticles(defender, 0x36E4, 5, 0, false, true, 3006, 4006, 0);
            attacker.PlaySound(0x1E5);

            SpellHelper.Damage(TimeSpan.FromSeconds(1.0), defender, attacker, damage, 0, 100, 0, 0, 0);
        }

2) If you have any weapons (bows in my case) where you have added any extra damage in the weapon's specific script for OnHit, then those individual weapon scripts may need their OnHit section edited as well . . like this;
Code:
        public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
        {

            if ( defender is SpecialDragon || (defender is SpecialDrake))
            {
                attacker.SendAsciiMessage("That is a Special Creature");
                return;
            }

            else if (defender != null && defender.Hits >= 100)
            {
                double parachance = Utility.RandomDouble();
                if (parachance < 0.99)
                {
                    defender.Hits = (defender.Hits - 25);
                    Timer.DelayCall( TimeSpan.FromSeconds( 15.0 ), new TimerStateCallback( Recover_Callback ), defender );
                    defender.FixedEffect( 0x376A, 10, 16 );
                    defender.Frozen = true;
                    defender.Combatant = null;
                    attacker.SendMessage( "The bow's power has frozen the creature." );
                }
            }

            else if (defender.Hits <= 15)
            {
                defender.Hits = (defender.Hits - 17);
            }

            base.OnHit( attacker, defender, damageBonus );
        }

* * Anyone looking at this and thinking of trying it . . please remember my examples are from a RunUO V2.2 set up. It is possible there may be some minor changes needed for ServUO specifics.

Again nipa . . many thanks for taking the time to look at my problem and for your very speedy response.

*bows*
 
Last edited:
hey, i remember you from few years ago, im glad you still around, btw i use Runuo 2.2 too lol. im glad my answer was helpful somehow
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back