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!

PowerScroll help plz

Malaperth;642995 said:
Well, I don't think you need to change that class any as long as you aren't trying to add it into the PowerScroll list. Unless, of course, you discover that it doesn't work :)

i have four or more differt classes so i will have to change all of them to a single class

public class ShieldAttackChanceTarget

public class WeaponAttackChanceTarget

public class ArmorBonusHitRegenTarget
 

Malaperth

Wanderer
That should be fine. Make a List or Array that contains each one and have the method return an Item type (which all of those should inherit from) and it should function as you want.
 
Malaperth;642998 said:
That should be fine. Make a List or Array that contains each one and have the method return an Item type (which all of those should inherit from) and it should function as you want.


Wow what a mod didnt think it would be that big of a mod to base champ lol
 

Malaperth

Wanderer
Well, there may be an easier way, as I've been told that my coding style is bloated and unnecessary, but that is what I thought of to do, and that's all I can offer is my thoughts :)
 
Malaperth;643003 said:
Well, there may be an easier way, as I've been told that my coding style is bloated and unnecessary, but that is what I thought of to do, and that's all I can offer is my thoughts :)

Ya but there not to bad i see that you are very good at what you do even if its a little bulky lol

hey would like an example of Array that you might use im really no good with array's so with your help ill get it no prob
 

Malaperth

Wanderer
Well, maybe an Array isn't the right object. Try to do it similar to how the powerscrolls are done. Instead of PowerScroll as the type, though, I think it will have to be Item.
 
Malaperth;643014 said:
Well, maybe an Array isn't the right object. Try to do it similar to how the powerscrolls are done. Instead of PowerScroll as the type, though, I think it will have to be Item.

so instead of
Code:
SkillName.Blacksmith,
ItemName.ArmorBonusHitRegenModDeed
 

Malaperth

Wanderer
nope. try an array instead.

Code:
ArrayList deedList = new ArrayList( new Deed1(),
                                                new Deed2(),
                                                new Deed3(),
                                               )

now it seems I'm not thinking very well right now, cuz that looks like crap, as you shouldn't create a list with real objects in them like that, but I'm sure someone will be along shortly to point out a better way of doing it after seeing the crap I just posted.
 
Malaperth;643020 said:
nope. try an array instead.

Code:
ArrayList deedList = new ArrayList( new Deed1(),
                                                new Deed2(),
                                                new Deed3(),
                                               )

now it seems I'm not thinking very well right now, cuz that looks like crap, as you shouldn't create a list with real objects in them like that, but I'm sure someone will be along shortly to point out a better way of doing it after seeing the crap I just posted.

like this this way had no errors visual c#

Code:
public void GivePowerScrolls()
		{
			/*if ( Map != Map.Felucca )
				return;*/
            ArrayList deedList = new ArrayList(new Deed1());
                                                new Deed2();
                                                new Deed3();

			ArrayList toGive = new ArrayList();
			List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );

			for ( int i = rights.Count - 1; i >= 0; --i )
			{
				DamageStore ds = rights[i];

				if ( ds.m_HasRight )
					toGive.Add( ds.m_Mobile );
			}
 

Malaperth

Wanderer
Try adding this method:

Code:
        public static Item CreateRandomMyDeed()
        {
            Item item = null;
            switch (Utility.Random(3))
            {
                case 0: 
                    {
                        item = new MyDeed1();
                        break;
                    }
                case 1: 
                    {
                        item = new MyDeed2();
                        return;
                    }
                case 2: 
                    {
                        item = new MyDeed3();
                        break;
                    }
                case 3: 
                    {
                        item = new MyDeed4();
                        break;
                    }
            }
            return item;
        }

and changing this:

Code:
if ( !Core.SE || m.Alive )
{					
   if(Utility.RandomDouble() <= 0.20)
       m.AddToBackpack(new MyDeed());
   else
       m.AddToBackpack( ps );
}

to this:

Code:
if ( !Core.SE || m.Alive )
{					
   if(Utility.RandomDouble() <= 0.20)
       m.AddToBackpack(CreateRandomMyDeed());
   else
       m.AddToBackpack( ps );
}

You will have to modify the method some to reflect what your classes are really instead of MyDeed(), but I think this will get you going.
 
supernova72611;643074 said:
ok have it put together now ill put it through a run and see what happens brb

OK got it up now i have this Error think i missed something

Code:
Errors:
 + Mobiles/Special/BaseChampion.cs:
    CS0126: Line 52: An object of a type convertible to 'Server.Item' is require
d

Base champ
Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Engines.CannedEvil;
using System.Collections.Generic;

namespace Server.Mobiles
{
	public abstract class BaseChampion : BaseCreature
	{
		public BaseChampion( AIType aiType ) : this( aiType, FightMode.Closest )
		{
		}

		public BaseChampion( AIType aiType, FightMode mode ) : base( aiType, mode, 18, 1, 0.1, 0.2 )
		{
		}

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

		public abstract ChampionSkullType SkullType{ get; }

		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();
		}
        public static Item CreateRandomDeed()
        {
            Item item = null;
            switch (Utility.Random(4))
            {
                case 0:
                    {
                        item = new ArmorBonusHitRegenModDeed();
                        break;
                    }
                case 1:
                    {
                        item = new ArmorBonusStamRegenModDeed();
                        return;
                    }
                case 2:
                    {
                        item = new ArmorEnergyResistModDeed();
                        break;
                    }
                case 3:
                    {
                        item = new ArmorSelfRepairModDeed();
                        break;
                    }
            }
            return item;
        }
		private PowerScroll CreateRandomPowerScroll()
		{
			int level;
			double random = Utility.RandomDouble();

			if ( 0.1 >= random )
				level = 20;
			else if ( 0.4 >= random )
				level = 15;
			else
				level = 10;

			return PowerScroll.CreateRandomNoCraft( level, level );
		}

		public void GivePowerScrolls()
		{
			/*if ( Map != Map.Felucca )
				return;*/

			ArrayList toGive = new ArrayList();
			List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );
           
                                               
			for ( int i = rights.Count - 1; i >= 0; --i )
			{
				DamageStore ds = rights[i];

				if ( ds.m_HasRight )
					toGive.Add( ds.m_Mobile );
			}

			if ( toGive.Count == 0 )
				return;

			for( int i = 0; i < toGive.Count; i++ )
			{
				Mobile m = (Mobile)toGive[i];

				if( !(m is PlayerMobile) )
					continue;

				bool gainedPath = false;

				int pointsToGain = 800;

				if( VirtueHelper.Award( m, VirtueName.Valor, pointsToGain, ref gainedPath ) )
				{
					if( gainedPath )
						m.SendLocalizedMessage( 1054032 ); // You have gained a path in Valor!
					else
						m.SendLocalizedMessage( 1054030 ); // You have gained in Valor!

					//No delay on Valor gains
				}
			}

			// Randomize
			for ( int i = 0; i < toGive.Count; ++i )
			{
				int rand = Utility.Random( toGive.Count );
				object hold = toGive[i];
				toGive[i] = toGive[rand];
				toGive[rand] = hold;
			}

			for ( int i = 0; i < 6; ++i )
			{
				Mobile m = (Mobile)toGive[i % toGive.Count];

				PowerScroll ps = CreateRandomPowerScroll();

				m.SendLocalizedMessage( 1049524 ); // You have received a scroll of power!

                if (!Core.SE || m.Alive)
            //////////////////////////////////////////////////
                    if (Utility.RandomDouble() <= 0.20)
                        m.AddToBackpack(CreateRandomDeed());
                    else
           ///////////////////////////////////////////////////
                        m.AddToBackpack(ps);
                else
                {
					if ( m.Corpse != null && !m.Corpse.Deleted )
						((Container)m.Corpse).DropItem( ps );
					else
						m.AddToBackpack( ps );
				}

				if ( m is PlayerMobile )
				{
					PlayerMobile pm = (PlayerMobile)m;

					for ( int j = 0; j < pm.JusticeProtectors.Count; ++j )
					{
						Mobile prot = (Mobile)pm.JusticeProtectors[j];

						if ( prot.Map != m.Map || prot.Kills >= 5 || prot.Criminal || !JusticeVirtue.CheckMapRegion( m, prot ) )
							continue;

						int chance = 0;

						switch ( VirtueHelper.GetLevel( prot, VirtueName.Justice ) )
						{
							case VirtueLevel.Seeker: chance = 60; break;
							case VirtueLevel.Follower: chance = 80; break;
							case VirtueLevel.Knight: chance = 100; break;
						}

						if ( chance > Utility.Random( 100 ) )
						{
							ps = CreateRandomPowerScroll();

							prot.SendLocalizedMessage( 1049368 ); // You have been rewarded for your dedication to Justice!

							if ( !Core.SE || prot.Alive )
								prot.AddToBackpack( ps );
							else
							{
								if ( prot.Corpse != null && !prot.Corpse.Deleted )
									((Container)prot.Corpse).DropItem( ps );
								else
									prot.AddToBackpack( ps );
							}
						}
					}
				}
			}
		}

		public override bool OnBeforeDeath()
		{
			if ( !NoKillAwards )
			{
				GivePowerScrolls();

				Map map = this.Map;

				if ( map != null )
				{
					for ( int x = -12; x <= 12; ++x )
					{
						for ( int y = -12; y <= 12; ++y )
						{
							double dist = Math.Sqrt(x*x+y*y);

							if ( dist <= 12 )
								new GoodiesTimer( map, X + x, Y + y ).Start();
						}
					}
				}
			}

			return base.OnBeforeDeath();
		}

		public override void OnDeath( Container c )
		{
			//if ( Map == Map.Felucca )
			{
				//TODO: Confirm SE change or AoS one too?
				List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );
				List<Mobile> toGive = new List<Mobile>();

				for ( int i = rights.Count - 1; i >= 0; --i )
				{
					DamageStore ds = rights[i];

					if ( ds.m_HasRight )
						toGive.Add( ds.m_Mobile );
				}

				if ( toGive.Count > 0 )
					toGive[Utility.Random( toGive.Count )].AddToBackpack( new ChampionSkull( SkullType ) );
				else
					c.DropItem( new ChampionSkull( SkullType ) );
			}

			base.OnDeath( c );
		}

		private class GoodiesTimer : Timer
		{
			private Map m_Map;
			private int m_X, m_Y;

			public GoodiesTimer( Map map, int x, int y ) : base( TimeSpan.FromSeconds( Utility.RandomDouble() * 10.0 ) )
			{
				m_Map = map;
				m_X = x;
				m_Y = y;
			}

			protected override void OnTick()
			{
				int z = m_Map.GetAverageZ( m_X, m_Y );
				bool canFit = m_Map.CanFit( m_X, m_Y, z, 6, false, false );

				for ( int i = -3; !canFit && i <= 3; ++i )
				{
					canFit = m_Map.CanFit( m_X, m_Y, z + i, 6, false, false );

					if ( canFit )
						z += i;
				}

				if ( !canFit )
					return;

				Gold g = new Gold( 500, 1000 );
				
				g.MoveToWorld( new Point3D( m_X, m_Y, z ), m_Map );

				if ( 0.5 >= Utility.RandomDouble() )
				{
					switch ( Utility.Random( 3 ) )
					{
						case 0: // Fire column
						{
							Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x3709, 10, 30, 5052 );
							Effects.PlaySound( g, g.Map, 0x208 );

							break;
						}
						case 1: // Explosion
						{
							Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x36BD, 20, 10, 5044 );
							Effects.PlaySound( g, g.Map, 0x307 );

							break;
						}
						case 2: // Ball of fire
						{
							Effects.SendLocationParticles( EffectItem.Create( g.Location, g.Map, EffectItem.DefaultDuration ), 0x36FE, 10, 10, 5052 );

							break;
						}
					}
				}
			}
		}
	}
}

Found spot mess up there was a return where break should have been lol
 

Malaperth

Wanderer
Make sure that the class on line 52 you refer to inherits from the Item class. I don't see why it would compile if it didn't, but I'd check that first.
 
Malaperth;643091 said:
Make sure that the class on line 52 you refer to inherits from the Item class. I don't see why it would compile if it didn't, but I'd check that first.

its just i was not payin att. was that return; was in your code and i missed it when i change it around a bit to fit my needs so put in break then it compiled no prob i'll test real quick and if all goes well will post it up
 
Top