zerodowned

Moderator
Working on implementing some extended features to my Spellbar[hotbar] code.
Using the ClearCurrentAbility in WeaponAbility.cs seems to be the only option to register if a player has executed/cancelled/changed weaponabilites (certain Bushido and Ninjitsu spells are weapon abilities)

I've worked out some previous problems but stuck on how to reference an item in a static method.

C#:
public static void ClearCurrentAbility(Mobile m)
  {
  m_Table.Remove(m);

  if (Core.AOS && m.NetState != null)
  m.Send(ClearWeaponAbility.Instance);
     
       SpecialMove.ClearCurrentMove(m);
     
       if ( m.HasGump(typeof (SpellBarGump.SpellBar_BarGump)) )
       {
         int dbx = 0; int dbxa = 0; int dby = 0; int dbya = 0; int xselect_var = 0;
               
         m.CloseGump( typeof( SpellBarGump.SpellBar_BarGump ) );
       
         m.SendGump(new SpellBarGump.SpellBar_BarGump(m, dbx, dbxa, dby, dbya, xselect_var, m_Scroll ));
       }
     
  }

Items/Weapons/Abilities/WeaponAbility.cs:
CS0120: Line 471: An object reference is required for the non-static field,
method, or property 'Server.Items.WeaponAbility.m_Scroll'

looking at:
http://www.runuo.com/community/threads/accessing-nonstatic-members.19619/ and
http://www.runuo.com/community/thre...uses-when-wearing-the-whole-set.100909/page-2

I've tried m_Scroll(item) and multiple other trial/errors that didn't work.

mirror post: Check if SpecialMove has been executed or cancelled/changed
I'll post here if I get the answer somewhere else.

Thanks
 
Where do you declare what m_Scroll is? Looking at your code you are passing an override into your gump but without declaring what it is the variable is either null (gives strange data/ crashes) or will not compile.

you need some kind of line as follows:

Item m_Scroll = <whatever item the gump needs>;

This needs to happen before you call the gump. Note my server is running RunUO 2.4 and I am not sure if the Item declarations line is the same for ServUO but I would be it is.
 
_Epila_ on runuo pointed me in the right direction

got it to work going outside that static method and doing this in HonorableExecution.cs

C#:
public override void OnHit(Mobile attacker, Mobile defender, int damage)
  {
  if (!this.Validate(attacker) || !this.CheckMana(attacker, true))
  return;

  ClearCurrentMove(attacker);
     
/// added ///
  Item scroll = (Item)(attacker.Backpack.FindItemByType(typeof(SpellBarScroll)));

  SpellBarScroll m_Scroll = (SpellBarScroll) scroll ;
     

         if ( attacker.HasGump(typeof (SpellBarGump.SpellBar_BarGump)) )
         {
           attacker.CloseGump( typeof( SpellBarGump.SpellBar_BarGump ) );
         
           int dbx = 0; int dbxa = 0; int dby = 0; int dbya = 0; int xselect_var = 0;
         
           attacker.SendGump(new SpellBarGump.SpellBar_BarGump(attacker, dbx, dbxa, dby, dbya, xselect_var, m_Scroll ));
         }
/// end added ///  

  HonorableExecutionInfo info = m_Table[attacker] as HonorableExecutionInfo;

  if (info != null)
  {
  info.Clear();

  if (info.m_Timer != null)
  info.m_Timer.Stop();
  }

  if (!defender.Alive)
  {
  attacker.FixedParticles(0x373A, 1, 17, 0x7E2, EffectLayer.Waist);

  double bushido = attacker.Skills[SkillName.Bushido].Value;

  attacker.Hits += 20 + (int)((bushido * bushido) / 480.0);

  int swingBonus = Math.Max(1, (int)((bushido * bushido) / 720.0));

  info = new HonorableExecutionInfo(attacker, swingBonus);
  info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(20.0), new TimerStateCallback(EndEffect), info);

  m_Table[attacker] = info;
  }
  else
  {
  ArrayList mods = new ArrayList();

  mods.Add(new ResistanceMod(ResistanceType.Physical, -40));
  mods.Add(new ResistanceMod(ResistanceType.Fire, -40));
  mods.Add(new ResistanceMod(ResistanceType.Cold, -40));
  mods.Add(new ResistanceMod(ResistanceType.Poison, -40));
  mods.Add(new ResistanceMod(ResistanceType.Energy, -40));

  double resSpells = attacker.Skills[SkillName.MagicResist].Value;

  if (resSpells > 0.0)
  mods.Add(new DefaultSkillMod(SkillName.MagicResist, true, -resSpells));

  info = new HonorableExecutionInfo(attacker, mods);
  info.m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(7.0), new TimerStateCallback(EndEffect), info);

  m_Table[attacker] = info;
  }

  this.CheckGain(attacker);
  }

and

C#:
namespace Server.Spells.Bushido
{
  public class HonorableExecution : SamuraiMove
  {
 
/// added ///
     public SpellBarScroll m_Scroll;
/// end added ///
   
  private static readonly Hashtable m_Table = new Hashtable();
  public HonorableExecution()
  {
  }

That will resend the gump any time the ability HonorableExecution is executed. I'll have to figure out what to do about abilities being changed or cancelled.
 
never mind i think i got this now

Code:
if ( !(SpecialMove.GetCurrentMove( from ) is HonorableExecution) & SpecialMove.GetCurrentMove( from ) != null  )
            {
              from.CloseGump( typeof( SpellBarGump.SpellBar_BarGump ) );
        
              //int dbx = 0; int dbxa = 0; int dby = 0; int dbya = 0; int xselect_var = 0;
        
              from.SendGump(new SpellBarGump.SpellBar_BarGump(from, dbx, dbxa, dby, dbya, xselect_var, m_Scroll ));
          
            }
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back