RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Hue of throwing weapons

zerodowned

Sorceror
I noticed that the animation of thrown weapons default to the base hue of the item when thrown.
But the actual held weapon will keep whatever hue the player has changed it to.

Has anyone already found a fix for this?

BaseThrown:

Code:
using System;
using Server.Items;
using Server.Network;
using Server.Spells;
using Server.Mobiles;

namespace Server.Items
{

    public abstract class BaseThrown : BaseRanged
    {
        public abstract int MinThrowRange{ get; }
        public virtual int MaxThrowRange{ get{ return MinThrowRange + 4; } }
        private Mobile m_Thrower;
        private Mobile m_Target;
        private Point3D m_KillSave;

        public override int DefMaxRange
        {
            get
            {
                if ( Parent is PlayerMobile )
                {
                    int range = ((PlayerMobile)Parent).Str / 10;

                    return Math.Min( range, 10 );
                }

                return 10;
            }
        }

        public override int EffectID{ get{ return ItemID; } }
        public override Type AmmoType{ get{ return null; } }
        public override Item Ammo{ get{ return null; } }

        public override int DefHitSound{ get{ return 0x5D3; } }
        public override int DefMissSound{ get{ return 0x5D4; } }

        public override SkillName DefSkill{ get{ return SkillName.Throwing; } }
        //public override WeaponType DefType{ get{ return WeaponType.Ranged; } }
        public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.Slash1H; } }

        public override SkillName AccuracySkill{ get{ return SkillName.Throwing; } }

        public BaseThrown( int itemID ) : base( itemID )
        {
            EnhancementCap = 10; 
        }

        public BaseThrown( Serial serial ) : base( serial )
        {
        }

        public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
        {
            TimeSpan ts = base.OnSwing( attacker, defender );

            // time it takes to throw it around including mystic arc
            if ( ts < TimeSpan.FromMilliseconds( 1000 ) )
                ts = TimeSpan.FromMilliseconds( 1000 );

            return ts;
        }

        public override bool OnFired( Mobile attacker, Mobile defender )
        {
            m_Thrower = attacker;

            if ( !attacker.InRange( defender, 1 ) )
            {
                //Internalize();
                Visible = false;
                attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
            }

            return true;
        }

        public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
        {
            m_Target = defender;
            m_KillSave = defender.Location;

            if ( !(WeaponAbility.GetCurrentAbility( attacker ) is MysticArc) )
                Timer.DelayCall( TimeSpan.FromMilliseconds( 333.0 ), new TimerCallback( ThrowBack ) );

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

        public override void OnMiss( Mobile attacker, Mobile defender )
        {
            m_Target = defender;

            if ( !(WeaponAbility.GetCurrentAbility( attacker ) is MysticArc) )
                Timer.DelayCall( TimeSpan.FromMilliseconds( 333.0 ), new TimerCallback( ThrowBack ) );

            base.OnMiss( attacker, defender );
        }

        public virtual void ThrowBack()
        {
            if ( m_Target != null )
                m_Target.MovingEffect( m_Thrower, EffectID, 18, 1, false, false );
            else if ( m_Thrower != null )
                Effects.SendMovingParticles( new Entity( Serial.Zero, m_KillSave, m_Thrower.Map ), m_Thrower, ItemID, 18, 0, false, false, Hue, 0, 9502, 1, 0, (EffectLayer)255, 0x100 );

            Timer.DelayCall( TimeSpan.FromMilliseconds( 333.0 ), new TimerCallback( UnHide ) );
        }

        public virtual void UnHide()
        {
            if ( this != null )
                Visible = true;

            //if ( m_Thrower != null )
                //if ( !m_Thrower.EquipItem( this ) )
                    //MoveToWorld( m_Thrower.Location, m_Thrower.Map );
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
            writer.Write( (int) 0 ); // version
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
            int version = reader.ReadInt();
            Visible = true;
        }
    }
}
 

ThatDudeJBob

Sorceror
I haven't really looked into or even used throwing weapons since they came out.

I'll do some testing a little later if someone else hasn't come up with a solution by then.
 

zerodowned

Sorceror
got it

in Server/Effects.cs star4ting line 287
C#:
public static void SendMovingEffect( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes )
        {
            SendMovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, 0, 0 );
        }

        public static void SendMovingEffect( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode )
        {
            if ( from is Mobile )
                ((Mobile)from).ProcessDelta();

            if ( to is Mobile )
                ((Mobile)to).ProcessDelta();

            SendPacket( from.Location, from.Map, new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );
        }

the first one is what basethrown is currently using, the second is what it needs to be changed to under both OnFired and ThrowBack. I'm not sure what rendermode is but it's an int so i kept it as 0

C#:
using System;
using Server.Items;
using Server.Network;
using Server.Spells;
using Server.Mobiles;

namespace Server.Items
{

    public abstract class BaseThrown : BaseRanged
    {
        public abstract int MinThrowRange{ get; }
        public virtual int MaxThrowRange{ get{ return MinThrowRange + 4; } }
        private Mobile m_Thrower;
        private Mobile m_Target;
        private Point3D m_KillSave;

        public override int DefMaxRange
        {
            get
            {
                if ( Parent is PlayerMobile )
                {
                    int range = ((PlayerMobile)Parent).Str / 10;

                    return Math.Min( range, 10 );
                }

                return 10;
            }
        }

        public override int EffectID{ get{ return ItemID; } }
        public override Type AmmoType{ get{ return null; } }
        public override Item Ammo{ get{ return null; } }

        public override int DefHitSound{ get{ return 0x5D3; } }
        public override int DefMissSound{ get{ return 0x5D4; } }

        public override SkillName DefSkill{ get{ return SkillName.Throwing; } }
        //public override WeaponType DefType{ get{ return WeaponType.Ranged; } }
        public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.Slash1H; } }

        public override SkillName AccuracySkill{ get{ return SkillName.Throwing; } }

        public BaseThrown( int itemID ) : base( itemID )
        {
            EnhancementCap = 10; 
        }

        public BaseThrown( Serial serial ) : base( serial )
        {
        }

        public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
        {
            TimeSpan ts = base.OnSwing( attacker, defender );

            // time it takes to throw it around including mystic arc
            if ( ts < TimeSpan.FromMilliseconds( 1000 ) )
                ts = TimeSpan.FromMilliseconds( 1000 );

            return ts;
        }

        public override bool OnFired( Mobile attacker, Mobile defender )
        {
            m_Thrower = attacker;

            if ( !attacker.InRange( defender, 1 ) )
            {
                //Internalize();
                Visible = false;
                //public static void SendMovingEffect( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode )
                attacker.MovingEffect( defender, EffectID, 18, 1, false, false, Hue, 0 );
            }

            return true;
        }

        public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
        {
            m_Target = defender;
            m_KillSave = defender.Location;

            if ( !(WeaponAbility.GetCurrentAbility( attacker ) is MysticArc) )
                Timer.DelayCall( TimeSpan.FromMilliseconds( 333.0 ), new TimerCallback( ThrowBack ) );

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

        public override void OnMiss( Mobile attacker, Mobile defender )
        {
            m_Target = defender;

            if ( !(WeaponAbility.GetCurrentAbility( attacker ) is MysticArc) )
                Timer.DelayCall( TimeSpan.FromMilliseconds( 333.0 ), new TimerCallback( ThrowBack ) );

            base.OnMiss( attacker, defender );
        }

        public virtual void ThrowBack()
        {
            if ( m_Target != null )
                m_Target.MovingEffect( m_Thrower, EffectID, 18, 1, false, false, Hue, 0 );
            else if ( m_Thrower != null )
                Effects.SendMovingParticles( new Entity( Serial.Zero, m_KillSave, m_Thrower.Map ), m_Thrower, ItemID, 18, 0, false, false, Hue, 0, 9502, 1, 0, (EffectLayer)255, 0x100 );

            Timer.DelayCall( TimeSpan.FromMilliseconds( 333.0 ), new TimerCallback( UnHide ) );
        }

        public virtual void UnHide()
        {
            if ( this != null )
                Visible = true;

            //if ( m_Thrower != null )
                //if ( !m_Thrower.EquipItem( this ) )
                    //MoveToWorld( m_Thrower.Location, m_Thrower.Map );
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
            writer.Write( (int) 0 ); // version
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
            int version = reader.ReadInt();
            Visible = true;
        }
    }
}
 

zerodowned

Sorceror
after further testing rendermode seems to allow you to change the hue of the animation to be different from that of the item

ie you throw the weapon and it returns bloodied, covered in slime, etc


edit:
keep as 0 [zero] if you want it to stay the color of the weapon
 
Top