Hi you all,
there is a command to refresh the Character Status Panel after a double click on an item (i.e. a Four-Leaf)?
I've added a BaseLuck property to Mobile.cs and it works, but the Character Status LUCK changes only if I move the Four-Leaf inside the backpack after the double click.
When the internal timer ends (25 seconds), I've to move the Four-Leaf again to refresh the LUCK inside the Character Status.

Here is my Four-Leaf code:

Code:
using System;
using System.Collections.Generic;
using Server;
using Server.Misc;
using Server.Network;
using Server.Mobiles;
using Server.Targeting;
using Server.Commands;

namespace Server.Items
{
    public class FourLeaf : BaseReagent
    {       
        private bool m_Herb;
        private int m_Luck;
       
        public int DefaultLuck
        {
            get { return m_Luck; }
            set { m_Luck = value;}
        }
       
        [Constructable]
        public FourLeaf() : this( 1, 0 )
        {
        }

        [Constructable]
        public FourLeaf( int amount ) : this( amount, 0 )
        {
        }
       
        [Constructable]
        public FourLeaf( int amount, int type ) : base( 0x0D3E, amount )
        {
            Name = "Quadrifoglio";
            Weight = 0.1;
            Stackable = true;
           
            m_Herb = false;
            m_Luck = 0;
        }
       
        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.Alive )
            {
                from.SendMessage( "Non puoi farlo adesso." );
                return;
            }
               
            if ( !this.IsChildOf(from.Backpack) )
            {
                from.SendMessage( "Deve essere in borsa per poterlo usare." );
                return;
            }
           
            if ( PerformingAction() )
            {
                from.SendMessage( "Non puoi ancora rifarlo." );
                return;
            }
           
            if ( IsChildOf( from.Backpack ) || from.InRange( this, 2 ) && from.CanSee( this ) )
            {
                this.BeginAction();
                from.Emote( "*strofina un quadrifoglio*" );
                from.SendMessage( "Ti senti positivo." );
                m_Luck = 75;
                from.BaseLuck += 75;
                /* REFRESH THE CHAR STATUS */
                // HOW...
                new InternalLeafTimer( this, from, TimeSpan.FromSeconds( 25.0 ) ).Start();
            }
            else
            {
                from.SendMessage( "E' troppo lontano." );
                return;
            }      
        }

        public FourLeaf( Serial serial ) : base( serial )
        {
            m_Herb = false;
            m_Luck = 0;
        }
       
        public void BeginAction()
        {
            m_Herb = true;
        }
       
        public void EndAction()
        {
            m_Herb = false;
        }
       
        public bool PerformingAction()
        {
            if ( m_Herb )
                return true;
           
            return false;           
        }
       
        private class InternalLeafTimer : Timer
        {
            private FourLeaf m_4leaf;
            private Mobile m_From;

            public InternalLeafTimer ( FourLeaf fourleaf, Mobile from, TimeSpan duration ) : base( duration )
            {
                Priority = TimerPriority.OneSecond;
                m_4leaf = fourleaf;
                m_From = from;
            }

            protected override void OnTick()
            {
                if ( m_From == null || m_4leaf == null )
                    Stop();
                else
                {
                    m_4leaf.DefaultLuck = 0;
                    m_From.BaseLuck -= 75;                   
		 /* REFRESH THE CHAR STATUS */
                    // HOW...	
                    m_4leaf.EndAction();   
                }               
            }
        }

        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();
        }
    }
}
 
I think you could take a look at InvalidateProperties from the Mobile class.
So, from.InvalidateProperties(), it should update the luck values hopefully.
I know that it works with the properties list when hovering over a player or mobile, but i'm unsure how it would react with that.
It's worth a shot though.
 
C#:
from.Delta( MobileDelta.Resistances );

Forcing a Delta update for Resistances will cause it to resend the MobileStatus packet.

You could also try MobileDelta.Gold, MobileDelta.Stat, MobileDelta.Armor and/or MobileDelta.WeaponDamage
 
Thank you all for your replies!
I tried the [from.InvalidateProperties();] suggestion with no... LUCK! XD
The second suggestion [from.Delta( MobileDelta.Resistances);] worked like a charm!

Thank you Voxpire!
 
Back