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!

Can anyone fix the lifespan on the training cow?

bazspeed

Sorceror
The lifespan on the training cow does not work correctly.

Can anyone work out why?

http://www.runuo.com/community/threads/runuo-2-0-2-1-2-2-svn-personal-training-cow.518020/

Code:
using System;
using System.Collections;
using Server.Items;
using Server.Targeting;
 
namespace Server.Mobiles
{
    [CorpseName( "a training cow corpse" )]
    public class TrainingCow : BaseCreature
    {
        private int m_Lifespan;
       
        [CommandProperty( AccessLevel.GameMaster )]
        public int TimeLeft
        {
      get{ return m_Lifespan; }
            set{ m_Lifespan = value; InvalidateProperties(); }
        }
     
    [Constructable]
        public TrainingCow() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
        {
            Name = "a training cow";
            Body = Utility.RandomList( 0xD8, 0xE7 );
            Hue = 1153;
            BaseSoundID = 0x78;
            m_Lifespan = Utility.RandomMinMax( 3000, 4500 );
 
          SetStr( 1000, 1000 );
            SetDex( 1000 );
            SetInt( 1000 );
 
            SetHits( 300000 , 300000 );
 
            SetDamage( 1, 1 );
 
            SetDamageType( ResistanceType.Physical, 1 );
 
            SetResistance( ResistanceType.Physical, 1 );
            SetResistance( ResistanceType.Fire, 1 );
            SetResistance( ResistanceType.Cold, 1 );
            SetResistance( ResistanceType.Poison, 1 );
            SetResistance( ResistanceType.Energy, 1 );
 
            SetSkill( SkillName.Tactics, 1.0, 1.0 );
            SetSkill( SkillName.Wrestling, 1.0, 1.0 );
            SetSkill( SkillName.Anatomy, 1.0, 1.0 );
 
            Fame = 2500;
            Karma = -2500;
      CantWalk = true;
            VirtualArmor = 200;
      Timer.DelayCall( TimeSpan.FromMinutes( m_Lifespan ), TimeSpan.FromSeconds( 10 ), new TimerCallback( Expire ) );
           
        }
 
        public override int Meat{ get{ return 12; } }
        public override int Hides{ get{ return 8; } }
   
        public override void GetProperties( ObjectPropertyList list )
        {
          base.AddNameProperties( list );
            list.Add( 1060658, "Lifespan \t{0}", m_Lifespan.ToString() );
        }
       
    private void Expire()
        {
          m_Lifespan -= 10;   
          InvalidateProperties();
           
      if ( Deleted )
                return;
 
            Delete();
            Effects.SendLocationParticles( EffectItem.Create( Location, Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
            Effects.PlaySound( Location, Map, 0x201 );           
        }
 
        public TrainingCow( Serial serial ) : base( serial )
        {
        }
 
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
            writer.Write( (int) 0 );
            writer.Write( (int) m_Lifespan );
           
        }
 
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
            int version = reader.ReadInt();
            m_Lifespan = reader.ReadInt();
        }
        public override void OnGotMeleeAttack( Mobile attacker )
        {
        SetHits( 300000, 300000 );
        }
   
   
  }
}
 

Arvoreen

Sorceror
The lifespan on the training cow does not work correctly.

How should it behave, and what is it doing exactly that is not correct? And on a side note, this would probably have been best posted in the thread for the script itself :) Just sayin!
 
Top