sahisahi

Member
Using runuo2.2


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

namespace Server.Items
{

public class Anillomana : BaseRing
   {
      InternalTimer m_Timer;

      [Constructable]
      public Anillomana() : base(0x108a)
      {
         Weight = 19.8;
         Hue = 2548;
         Name = "Ring of mana regeneration";
      }
       
      public Anillomana( Serial serial ) : base( serial )
      {
      }         

      public override bool OnEquip( Mobile from )
      { 
         from.SendMessage( "Your mana regeneration has increased!." );
         from.Hidden = false;
         //from.AllowedStealthSteps = 25;
         m_Timer = new InternalTimer( from, this );
         m_Timer.Start();   

         return true;
      }

      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();

         if ( this.Parent is Mobile )
               {
                     Mobile m = (Mobile)this.Parent;

                     m_Timer = new InternalTimer( m, this );
                     m_Timer.Start();
               }

   
      }

      private class InternalTimer : Timer
      {
         private Mobile m_Mobile;
         private int m_Count;
         private Item m_Item;    
        

         public InternalTimer( Mobile from, Item item ) : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) )
         {
            m_Mobile = from;
            m_Item = item;
         }
         protected override void OnTick()
         { 
            //int currentMana = from.Mana;
          // int maxMana = from.ManaMax;
        
           m_Count++;

            if ( !m_Mobile.CheckAlive() )
            {
               Stop();
            }    
            if ( m_Item.Parent != m_Mobile )
               Stop();
            else
            { 
             if (currentMana + Mana > maxMana)
             {
           overMaxMana = (currentMana + Mana) - maxMana;
                if ((overMaxMana / 2) + currentMana > (maxMana + (Mana / 2)))
                    from.Mana = maxMana + (Mana / 2);
                else
                    from.Mana = maxMana + overMaxMana/2;
               
                 from.Mana = maxMana + (int)(0.1 * (currentMana + Mana - maxMana));
            }
            else
                from.Mana += 3;
         }
      }
   }
}
}

---------------------------------------------------------------------------------------
Errors:
+ KUSTOM/anillomana.cs:
CS0103: Line 89: The name 'currentMana' does not exist in the current contex
t
CS0103: Line 89: The name 'Mana' does not exist in the current context
CS0103: Line 89: The name 'maxMana' does not exist in the current context
CS0103: Line 91: The name 'overMaxMana' does not exist in the current contex
t
CS0103: Line 91: The name 'currentMana' does not exist in the current contex
t
CS0103: Line 91: The name 'Mana' does not exist in the current context
CS0103: Line 91: The name 'maxMana' does not exist in the current context
CS0103: Line 92: The name 'overMaxMana' does not exist in the current contex
t
CS0103: Line 92: The name 'currentMana' does not exist in the current contex
t
CS0103: Line 92: The name 'maxMana' does not exist in the current context
CS0103: Line 92: The name 'Mana' does not exist in the current context
CS0103: Line 93: The name 'from' does not exist in the current context
CS0103: Line 93: The name 'maxMana' does not exist in the current context
CS0103: Line 93: The name 'Mana' does not exist in the current context
CS0103: Line 95: The name 'from' does not exist in the current context
CS0103: Line 95: The name 'maxMana' does not exist in the current context
CS0103: Line 95: The name 'overMaxMana' does not exist in the current contex
t
CS0103: Line 97: The name 'from' does not exist in the current context
CS0103: Line 97: The name 'maxMana' does not exist in the current context
CS0103: Line 97: The name 'currentMana' does not exist in the current contex
t
CS0103: Line 97: The name 'Mana' does not exist in the current context
CS0103: Line 97: The name 'maxMana' does not exist in the current context
CS0103: Line 100: The name 'from' does not exist in the current context



Thanks!
 
Instead of doing all of that, take a look at the HelmOfInsight.cs Scripts/Items/Armor/Artifacts. It uses
Code:
Attributes.RegenMana = 2;
and nothing more. The 2 dictates how fast it regens. No timer needed. You could keep the message, but you really don't need a bunch of coding to regen the players mana faster.
 
Instead of doing all of that, take a look at the HelmOfInsight.cs Scripts/Items/Armor/Artifacts. It uses
Code:
Attributes.RegenMana = 2;
and nothing more. The 2 dictates how fast it regens. No timer needed. You could keep the message, but you really don't need a bunch of coding to regen the players mana faster.

I have aos disabled so there are no attritbutes :eek:
 

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back