sahisahi

Member
Hello not sure if im going to get runuo support here, im using 2.2

Im trying to make dragons deals half of the damage to players if they are carring an antidragonshield

any help?

the only thing i know is that ihave to play with the alterdamage method


Well.... thanks
 
Assuming "player" is the Mobile being targeted, your code might look something like this:

AntiDragonShield shield = (AntiDragonShield)player.FindItemOnLayer(Layer.Shield);

if (shield != null) damage /= 2;
 
public override void AlterMeleeDamageTo( Mobile to, ref int damage )
{
if ( to is PlayerMobile )
AntiDragonShield shield = (AntiDragonShield)player.FindItemOnLayer(Layer.Shield);
if (shield != null) damage /= 2;

}

Im getting error:
-------EDIT--------
I changed player.FindItemOnLayer to PlayerMobile.FindItemOnLayer

Im getting the next error

''Server.Layer does not contain a definition for Shield''

Remember that im using run uo 2.2
 

Attachments

  • error.png
    error.png
    2.7 KB · Views: 4
CS0120: Line 115: An object reference is required for the non-static field,
method, or property 'Server.Mobile.FindItemOnLayer(Server.Layer)'
 
Change "player" to "to". So:

AntiDragonShield shield = (AntiDragonShield)to.FindItemOnLayer(Layer.Shield);
 
It compiles, but server crashed :D



Exception:
System.InvalidCastException: Unable to cast object of type 'Server.Items.HeaterShield' to type 'Server.Items.AntiDragonShield'.
at Server.Mobiles.Dragon.AlterMeleeDamageTo(Mobile to, Int32& damage)
at Server.Items.BaseWeapon.OnHit(Mobile attacker, Mobile defender, Double damageBonus)
at Server.Timer.Slice()
at Server.Core.Main(String[] args)


It is due the type of shield right? maybe should i change it to a heater one?

-----------edit---------------


Another crash, it crash everytime i switch weapon while gettting hit :( hmmmm weird!


Exception:
System.InvalidCastException: Unable to cast object of type 'Server.Items.Bastondetamer' to type 'Server.Items.AntiDragonShield'.
at Server.Mobiles.Dragon.AlterMeleeDamageTo(Mobile to, Int32& damage)
at Server.Items.BaseWeapon.OnHit(Mobile attacker, Mobile defender, Double damageBonus)
at Server.Timer.Slice()
at Server.Core.Main(String[] args)
 
It compiles, but server crashed :D



Exception:
System.InvalidCastException: Unable to cast object of type 'Server.Items.HeaterShield' to type 'Server.Items.AntiDragonShield'.
at Server.Mobiles.Dragon.AlterMeleeDamageTo(Mobile to, Int32& damage)
at Server.Items.BaseWeapon.OnHit(Mobile attacker, Mobile defender, Double damageBonus)
at Server.Timer.Slice()
at Server.Core.Main(String[] args)


It is due the type of shield right? maybe should i change it to a heater one?

No, the error is correct. Let's try this:

Code:
public override void AlterMeleeDamageTo( Mobile to, ref int damage )
{
   if ( to is PlayerMobile )
   {
     Item shield = (Item)to.FindItemOnLayer(Layer.TwoHanded);
     if (shield != null && shield is AntiDragonShield) damage /= 2;
   }

}
 
Ah, ninja edit, let me try, btw thanks for your help, im using your Lokai skills script i love it :)



------------------

doesnt seems to crash anymore, how can i change the damage part?

-50% seems to be a lot, would be more balanced -30% or so

i tried damage =/1.7; but it dont let me
 
Last edited:
Or, let's say you want it to absorb between 30 and 50% of the damage randomly. You could do this:

Code:
public override void AlterMeleeDamageTo( Mobile to, ref int damage )
{
    if ( to is PlayerMobile )
    {
        Item shield = (Item)to.FindItemOnLayer(Layer.TwoHanded);
        if (shield != null && shield is AntiDragonShield)
        {
            int negfactor = Utility.Random(20);
            damage = (int)(damage * ((50 + negfactor)/100));
        }
    }

}
 

Active Shards

Donations

Total amount
$0.00
Goal
$500.00
Back