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!

Wood Elementals

Wood Elementals

i Made a Wood elemental system but im having a problem with it loading in the Lumberjacking.cs

this is the error im getting:
Code:
Errors:
 + Engines/Harvest/Lumberjacking.cs:
    CS0103: Line 212: The name 'm_log' does not exist in the current contex
    CS0103: Line 237: The name 'm_log' does not exist in the current contex

this is my lumberjacking.cs, the edits i made are in red:

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

namespace Server.Engines.Harvest
{
  public class Lumberjacking : HarvestSystem
  {
    private static Lumberjacking m_System;

    public static Lumberjacking System
    {
      get
      {
        if ( m_System == null )
          m_System = new Lumberjacking();

        return m_System;
      }
    }

    private HarvestDefinition m_Definition;

    public HarvestDefinition Definition
    {
      get{ return m_Definition; }
    }

    private Lumberjacking()
    {
      HarvestResource[] res;
      HarvestVein[] veins;

      #region Lumberjacking
      HarvestDefinition lumber = new HarvestDefinition();

      // Resource banks are every 4x3 tiles
      lumber.BankWidth = 4;
      lumber.BankHeight = 3;

      // Every bank holds from 20 to 45 logs
      lumber.MinTotal = 20;
      lumber.MaxTotal = 45;

      // A resource bank will respawn its content every 20 to 30 minutes
      lumber.MinRespawn = TimeSpan.FromMinutes( 20.0 );
      lumber.MaxRespawn = TimeSpan.FromMinutes( 30.0 );

      // Skill checking is done on the Lumberjacking skill
      lumber.Skill = SkillName.Lumberjacking;

      // Set the list of harvestable tiles
      lumber.Tiles = m_TreeTiles;

      // Players must be within 2 tiles to harvest
      lumber.MaxRange = 2;

      // Ten logs per harvest action
      lumber.ConsumedPerHarvest = 10;
      lumber.ConsumedPerFeluccaHarvest = 20;

      // The chopping effect
      lumber.EffectActions = new int[]{ 13 };
      lumber.EffectSounds = new int[]{ 0x13E };
      lumber.EffectCounts = new int[]{ 1, 2, 2, 2, 3 };
      lumber.EffectDelay = TimeSpan.FromSeconds( 1.6 );
      lumber.EffectSoundDelay = TimeSpan.FromSeconds( 0.9 );

      lumber.NoResourcesMessage = 500493; // There's not enough wood here to harvest.
      lumber.FailMessage = 500495; // You hack at the tree for a while, but fail to produce any useable wood.
      lumber.OutOfRangeMessage = 500446; // That is too far away.
      lumber.PackFullMessage = 500497; // You can't place any wood into your backpack!
      lumber.ToolBrokeMessage = 500499; // You broke your axe.

      res = new HarvestResource[]
        {
          new HarvestResource( 00.0, 00.0, 100.0, 1072540, typeof( Log ) ),

          #region Mondain's Legacy
          new HarvestResource( 65.0, 50.0, 105.0, 1072541, typeof( OakLog ), typeof( OakElemental ) ),
          new HarvestResource( 80.0, 60.0, 110.0, 1072542, typeof( AshLog ), typeof( AshElemental ) ),
          new HarvestResource( 95.0, 70.0, 115.0, 1072543, typeof( YewLog ), typeof( YewElemental ) ),
          new HarvestResource( 100.0, 80.0, 120.0, 1072544, typeof( HeartwoodLog ), typeof( HeartwoodElemental ) ),
          new HarvestResource( 100.0, 90.0, 125.0, 1072545, typeof( BloodwoodLog ), typeof( BloodwoodElemental ) ),
          new HarvestResource( 100.0, 100.0, 130.0, 1072546, typeof( FrostwoodLog ), typeof( FrostwoodElemental ) )
          #endregion
        };

      veins = new HarvestVein[]
        {
          new HarvestVein( 60.0, 0.0, res[0], null ),

          #region Mondain's Legacy
          new HarvestVein( 30.0, 0.0, res[1], res[0] ),
          new HarvestVein( 10.0, 0.5, res[2], res[0] ),
          new HarvestVein( 1.0, 0.5, res[3], res[0] ),
          new HarvestVein( 0.5, 0.5, res[4], res[0] ),
          new HarvestVein( 0.1, 0.5, res[5], res[0] ),
          new HarvestVein( 0.05, 0.5, res[6], res[0] )
          #endregion
        };

      lumber.Resources = res;
      lumber.Veins = veins;

      lumber.RaceBonus = Core.ML;

      m_Definition = lumber;
      Definitions.Add( lumber );
      #endregion
    }

    public override bool CheckHarvest( Mobile from, Item tool )
    {
      if ( !base.CheckHarvest( from, tool ) )
        return false;

      if ( tool.Parent != from )
      {
        from.SendLocalizedMessage( 500487 ); // The axe must be equipped for any serious wood chopping.
        return false;
      }

      return true;
    }

    public override bool CheckHarvest( Mobile from, Item tool, HarvestDefinition def, object toHarvest )
    {
      if ( !base.CheckHarvest( from, tool, def, toHarvest ) )
        return false;

      if ( tool.Parent != from )
      {
        from.SendLocalizedMessage( 500487 ); // The axe must be equipped for any serious wood chopping.
        return false;
      }

      return true;
    }

    #region Mondain's Legacy
    public override bool Give( Mobile m, Item item, bool placeAtFeet )
    {
      if ( m.Skills.Lumberjacking.Value >= 100 )
      {
        if ( Utility.RandomDouble() < 0.15 )
        {
          Item sitem = null;
          int message = 0;
          double chance = Utility.RandomDouble();

          if ( chance < 0.0025 ) // not completely sure
          {
            sitem = new BrilliantAmber();
            message = 1072551; // You found a brilliant amber!
          }
          else if ( chance < 0.05 )
          {
            sitem = new ParasiticPlant();
            message = 1072549; // You found a parasitic plant!
          }
          else if ( chance < 0.35 )
          {
            if ( Utility.RandomBool() )
            {
              sitem = new Switch();
              message = 1072547; // You found a switch!
            }
            else
            {
              sitem = new LuminescentFungi();
              message = 1072550; // You found a luminescent fungi!
            }
          }
          else
          {
            sitem = new BarkFragment();
            message = 1072548; // You found a bark fragment!
          }

          if ( sitem != null && !m.PlaceInBackpack( sitem ) && placeAtFeet )
          {
            ArrayList atFeet = new ArrayList();

            foreach ( Item obj in m.GetItemsInRange( 0 ) )
              atFeet.Add( obj );

            for ( int i = 0; i < atFeet.Count; ++i )
            {
              Item check = (Item)atFeet[i];

              if ( check.StackWith( m, sitem, false ) )
                return base.Give( m, item, placeAtFeet );
            }

            sitem.MoveToWorld( m.Location, m.Map );
          }

          m.SendLocalizedMessage( message );
        }
      }

      return base.Give( m, item, placeAtFeet );
    }
    #endregion

    [COLOR="Red"]//beginaxe[/COLOR]
    public override HarvestVein MutateVein( Mobile from, Item tool, HarvestDefinition def, HarvestBank bank, object toHarvest, HarvestVein vein )
    {
      if ( tool is GargoylesWoodaxe && def == m_log )
      {
        int veinIndex = Array.IndexOf( def.Veins, vein );

        if ( veinIndex >= 0 && veinIndex < (def.Veins.Length - 1) )
          return def.Veins[veinIndex + 1];
      }

      return base.MutateVein( from, tool, def, bank, toHarvest, vein );
    }

    private static int[] m_Offsets = new int[]
      {
        -1, -1,
        -1,  0,
        -1,  1,
         0, -1,
         0,  1,
         1, -1,
         1,  0,
         1,  1
      };

    public override void OnHarvestFinished( Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested )
    {
      if ( tool is GargoylesWoodaxe && def == m_log && 0.1 > Utility.RandomDouble() )
      {
        HarvestResource res = vein.PrimaryResource;

        if ( res == resource && res.Types.Length >= 3 )
        {
          try
          {
            Map map = from.Map;

            if ( map == null )
              return;

            BaseCreature spawned = Activator.CreateInstance( res.Types[2], new object[]{ 25 } ) as BaseCreature;

            if ( spawned != null )
            {
              int offset = Utility.Random( 8 ) * 2;

              for ( int i = 0; i < m_Offsets.Length; i += 2 )
              {
                int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length];
                int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];

                if ( map.CanSpawnMobile( x, y, from.Z ) )
                {
                  spawned.MoveToWorld( new Point3D( x, y, from.Z ), map );
                  spawned.Combatant = from;
                  return;
                }
                else
                {
                  int z = map.GetAverageZ( x, y );

                  if ( map.CanSpawnMobile( x, y, z ) )
                  {
                    spawned.MoveToWorld( new Point3D( x, y, z ), map );
                    spawned.Combatant = from;
                    return;
                  }
                }
              }

              spawned.MoveToWorld( from.Location, from.Map );
              spawned.Combatant = from;
            }
          }
          catch
          {
          }
        }
      }
    }
    [COLOR="Red"]//endaxe[/COLOR]

    public override void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
    {
      from.SendLocalizedMessage( 500489 ); // You can't use an axe on that.
    }

    public static void Initialize()
    {
      Array.Sort( m_TreeTiles );
    }

    #region Tile lists
    private static int[] m_TreeTiles = new int[]
      {
        0x4CCA, 0x4CCB, 0x4CCC, 0x4CCD, 0x4CD0, 0x4CD3, 0x4CD6, 0x4CD8,
        0x4CDA, 0x4CDD, 0x4CE0, 0x4CE3, 0x4CE6, 0x4CF8, 0x4CFB, 0x4CFE,
        0x4D01, 0x4D41, 0x4D42, 0x4D43, 0x4D44, 0x4D57, 0x4D58, 0x4D59,
        0x4D5A, 0x4D5B, 0x4D6E, 0x4D6F, 0x4D70, 0x4D71, 0x4D72, 0x4D84,
        0x4D85, 0x4D86, 0x52B5, 0x52B6, 0x52B7, 0x52B8, 0x52B9, 0x52BA,
        0x52BB, 0x52BC, 0x52BD,

        0x4CCE, 0x4CCF, 0x4CD1, 0x4CD2, 0x4CD4, 0x4CD5, 0x4CD7, 0x4CD9,
        0x4CDB, 0x4CDC, 0x4CDE, 0x4CDF, 0x4CE1, 0x4CE2, 0x4CE4, 0x4CE5,
        0x4CE7, 0x4CE8, 0x4CF9, 0x4CFA, 0x4CFC, 0x4CFD, 0x4CFF, 0x4D00,
        0x4D02, 0x4D03, 0x4D45, 0x4D46, 0x4D47, 0x4D48, 0x4D49, 0x4D4A,
        0x4D4B, 0x4D4C, 0x4D4D, 0x4D4E, 0x4D4F, 0x4D50, 0x4D51, 0x4D52,
        0x4D53, 0x4D5C, 0x4D5D, 0x4D5E, 0x4D5F, 0x4D60, 0x4D61, 0x4D62,
        0x4D63, 0x4D64, 0x4D65, 0x4D66, 0x4D67, 0x4D68, 0x4D69, 0x4D73,
        0x4D74, 0x4D75, 0x4D76, 0x4D77, 0x4D78, 0x4D79, 0x4D7A, 0x4D7B,
        0x4D7C, 0x4D7D, 0x4D7E, 0x4D7F, 0x4D87, 0x4D88, 0x4D89, 0x4D8A,
        0x4D8B, 0x4D8C, 0x4D8D, 0x4D8E, 0x4D8F, 0x4D90, 0x4D95, 0x4D96,
        0x4D97, 0x4D99, 0x4D9A, 0x4D9B, 0x4D9D, 0x4D9E, 0x4D9F, 0x4DA1,
        0x4DA2, 0x4DA3, 0x4DA5, 0x4DA6, 0x4DA7, 0x4DA9, 0x4DAA, 0x4DAB,
        0x52BE, 0x52BF, 0x52C0, 0x52C1, 0x52C2, 0x52C3, 0x52C4, 0x52C5,
        0x52C6, 0x52C7
      };
    #endregion
  }
}

thank you guys...again
 
ok got a new question got that part of it working, but now i get no ele's spawning i belive i am missing somehting in the ele script but do not know what here is one of the scripts:


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

namespace Server.Mobiles
{
  [CorpseName( "an ash elemental corpse" )]
  public class AshElemental : BaseCreature
  {
    public override WeaponAbility GetWeaponAbility()
    {
      return WeaponAbility.Dismount;
    }

    [Constructable]
    public AshElemental() : base( AIType.AI_Melee, FightMode.Evil, 10, 1, 0.2, 0.4 )
    {
      Name = "an Ash Elemental";
      Body = 301;
      Hue = 1191;

      SetStr( 226, 255 );
      SetDex( 126, 155 );
      SetInt( 66, 90 );

      SetHits( 136, 152 );

      SetDamage( 12, 16 );

      SetDamageType( ResistanceType.Physical, 30 );
      SetDamageType( ResistanceType.Fire, 70 );

      SetResistance( ResistanceType.Physical, 30, 45 );
      SetResistance( ResistanceType.Cold, 30, 40 );
      SetResistance( ResistanceType.Poison, 20, 35 );
      SetResistance( ResistanceType.Energy, 20, 30 );

      SetSkill( SkillName.MagicResist, 50.1, 95.0 );
      SetSkill( SkillName.Tactics, 65.1, 100.0 );
      SetSkill( SkillName.Wrestling, 65.1, 105.0 );

      Fame = 5500;
      Karma = -5500;

      VirtualArmor = 29;
      PackItem( new AshLog( Utility.RandomMinMax( 23, 34 ) ) );
    }

    public override OppositionGroup OppositionGroup
    {
      get{ return OppositionGroup.FeyAndUndead; }
    }

    public override int GetIdleSound()
    {
      return 443;
    }

    public override int GetDeathSound()
    {
      return 31;
    }

    public override int GetAttackSound()
    {
      return 672;
    }

    public override bool BleedImmune{ get{ return true; } }
    public override bool AutoDispel{ get{ return true; } }
    public override int TreasureMapLevel{ get{ return 1; } }

    public override void GenerateLoot()
    {
      AddLoot( LootPack.Average );
      AddLoot( LootPack.Gems, 2 );
    }

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

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

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

      if ( BaseSoundID == 442 )
        BaseSoundID = -1;
    }
  }
}


any ideas?...sorry for being a pain
 

Bujinsho

Page
Nope ... the problem is in Lumberjacking still ...

Try this ...

Code:
        HarvestResource res = vein.PrimaryResource;

        if ( res == resource && res.Types.Length >=[COLOR="Red"]2[/COLOR] )
        {
          try
          {
            Map map = from.Map;

            if ( map == null )
              return;

            BaseCreature spawned = Activator.CreateInstance( res.Types[[COLOR="Red"]1[/COLOR][COLOR="red"][/COLOR]], new object[]{ 25 } ) as BaseCreature;

            if ( spawned != null )
 
actualy your problem is you have a number being passed to the elemental (it is used in ore ones for number of ore)
but your ele does not have a number to be pased to it

so change (25) to just ()

or modify
Code:
    [Constructable]
    public AshElemental() : base( AIType.AI_Melee, FightMode.Evil, 10, 1, 0.2, 0.4 )

like this:

Code:
    [Constructable]
    public AshElemental() : this(25) {}

    [Constructable]
    public AshElemental(int logamount) : base( AIType.AI_Melee, FightMode.Evil, 10, 1, 0.2, 0.4 )

and where it has the logs to give out change it to be logamount instead of a fixed number
 
Top