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!

cant be repair

egemen

Wanderer
cant be repair

i want that cold blood cant be repaired and my code is:
Code:
using System;
using Server;
using Server.Mobiles;
using Server.Targeting;
using Server.Items;

namespace Server.Engines.Craft
{
	public class Repair
	{
		public Repair()
		{
		}

		public static void Do( Mobile from, CraftSystem craftSystem, BaseTool tool )
		{
			from.Target = new InternalTarget( craftSystem, tool );
			from.SendLocalizedMessage( 1044276 ); // Target an item to repair.
		}

		private class InternalTarget : Target
		{
			private CraftSystem m_CraftSystem;
			private BaseTool m_Tool;

			public InternalTarget( CraftSystem craftSystem, BaseTool tool ) :  base ( 2, false, TargetFlags.None )
			{
				m_CraftSystem = craftSystem;
				m_Tool = tool;
			}

			private static void EndGolemRepair( object state )
			{
				((Mobile)state).EndAction( typeof( Golem ) );
			}

			private bool IsSpecialWeapon( BaseWeapon weapon )
			{
				// Weapons repairable but not craftable

				if ( m_CraftSystem is DefTinkering )
				{
					return ( weapon is Cleaver )
						|| ( weapon is Hatchet )
						|| ( weapon is Pickaxe )
						|| ( weapon is ButcherKnife )
						|| ( weapon is SkinningKnife );
				}
				else if ( m_CraftSystem is DefCarpentry )
				{
					return ( weapon is Club )
						|| ( weapon is BlackStaff )
						|| ( weapon is MagicWand );
				}
				else if ( m_CraftSystem is DefBlacksmithy )
				{
					return ( weapon is Pitchfork );
				}

				return false;
}

				[COLOR="Red"]private bool IsNotSpecialWeapon( BaseWeapon weapon )
			{
		

				if ( m_CraftSystem is DefTinkering )
				{
					return ( weapon is ColdBlood );
				}
				
				return false;
}[/COLOR]			protected override void OnTarget( Mobile from, object targeted )
			{
				int number;

				if ( m_CraftSystem is DefTinkering && targeted is Golem )
				{
					Golem g = (Golem)targeted;
					int damage = g.HitsMax - g.Hits;

					if ( g.IsDeadBondedPet )
					{
						number = 500426; // You can't repair that.
					}
					else if ( damage <= 0 )
					{
						number = 500423; // That is already in full repair.
					}
					else
					{
						double skillValue = from.Skills[SkillName.Tinkering].Value;

						if ( skillValue < 60.0 )
						{
							number = 1044153; // You don't have the required skills to attempt this item.
						}
						else if ( !from.CanBeginAction( typeof( Golem ) ) )
						{
							number = 501789; // You must wait before trying again.
						}
						else
						{
							if ( damage > (int)(skillValue * 0.3) )
								damage = (int)(skillValue * 0.3);

							damage += 30;

							if ( !from.CheckSkill( SkillName.Tinkering, 0.0, 100.0 ) )
								damage /= 2;

							Container pack = from.Backpack;

							if ( pack != null )
							{
								int v = pack.ConsumeUpTo( typeof( IronIngot ), (damage+4)/5 );

								if ( v > 0 )
								{
									g.Hits += v*5;

									number = 1044279; // You repair the item.

									from.BeginAction( typeof( Golem ) );
									Timer.DelayCall( TimeSpan.FromSeconds( 12.0 ), new TimerStateCallback( EndGolemRepair 

), from );
								}
								else
								{
									number = 1044037; // You do not have sufficient metal to make that.
								}
							}
							else
							{
								number = 1044037; // You do not have sufficient metal to make that.
							}
						}
					}
				}
				else if ( targeted is BaseWeapon )
				{
					BaseWeapon weapon = (BaseWeapon)targeted;
					SkillName skill = m_CraftSystem.MainSkill;
					int toWeaken = 0;

					if ( Core.AOS )
					{
						toWeaken = 1;
					}
					else if ( skill != SkillName.Tailoring )
					{
						double skillLevel = from.Skills[skill].Base;

						if ( skillLevel >= 90.0 )
							toWeaken = 1;
						else if ( skillLevel >= 70.0 )
							toWeaken = 2;
						else
							toWeaken = 3;
					}

					if ( m_CraftSystem.CraftItems.SearchForSubclass( weapon.GetType() ) == null && !IsSpecialWeapon( weapon )&& 

[COLOR="red"]IsNotSpecialWeapon( weapon )[/COLOR] )
					{
						number = 1044277; // That item cannot be repaired.
					}
					else if ( !weapon.IsChildOf( from.Backpack ) )
					{
						number = 1044275; // The item must be in your backpack to repair it.
					}
					else if ( weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits )
					{
						number = 1044281; // That item is in full repair
					}
					else if ( weapon.MaxHits <= toWeaken )
					{
						number = 500424; // You destroyed the item.
						m_CraftSystem.PlayCraftEffect( from );
						weapon.Delete();
					}
					else if ( from.CheckSkill( skill, -285.0, 100.0 ) )
					{
						number = 1044279; // You repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						weapon.MaxHits -= toWeaken;
						weapon.Hits = weapon.MaxHits;
					}
					else
					{
						number = 1044280; // You fail to repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						weapon.MaxHits -= toWeaken;

						if ( weapon.Hits - toWeaken < 0 )
							weapon.Hits = 0;
						else
							weapon.Hits -= toWeaken;
					}

					if ( weapon.MaxHits <= toWeaken )
						from.SendLocalizedMessage( 1044278 ); // That item has been repaired many times, and will break if repairs 

are attempted again.
				}
				else if ( targeted is BaseArmor )
				{
					BaseArmor armor = (BaseArmor)targeted;
					SkillName skill = m_CraftSystem.MainSkill;
					int toWeaken = 0;

					if ( Core.AOS )
					{
						toWeaken = 1;
					}
					else if ( skill != SkillName.Tailoring )
					{
						double skillLevel = from.Skills[skill].Base;

						if ( skillLevel >= 90.0 )
							toWeaken = 1;
						else if ( skillLevel >= 70.0 )
							toWeaken = 2;
						else
							toWeaken = 3;
					}

					if ( m_CraftSystem.CraftItems.SearchForSubclass( armor.GetType() ) == null )
					{
						number = 1044277; // That item cannot be repaired.
					}
					else if ( !armor.IsChildOf( from.Backpack ) )
					{
						number = 1044275; // The item must be in your backpack to repair it.
					}
					else if ( armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints )
					{
						number = 1044281; // That item is in full repair
					}
					else if ( armor.MaxHitPoints <= toWeaken )
					{
						number = 500424; // You destroyed the item.
						m_CraftSystem.PlayCraftEffect( from );
						armor.Delete();
					}
					else if ( from.CheckSkill( skill, -285.0, 100.0 ) )
					{
						number = 1044279; // You repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						armor.MaxHitPoints -= toWeaken;
						armor.HitPoints = armor.MaxHitPoints;
					}
					else
					{
						number = 1044280; // You fail to repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						armor.MaxHitPoints -= toWeaken;

						if ( armor.HitPoints - toWeaken < 0 )
							armor.HitPoints = 0;
						else
							armor.HitPoints -= toWeaken;
					}

					if ( armor.MaxHitPoints <= toWeaken )
						from.SendLocalizedMessage( 1044278 ); // That item has been repaired many times, and will break if repairs 

are attempted again.
				}
				else if ( targeted is Item )
				{
					number = 1044277; // That item cannot be repaired.
				}
				else
				{
					number = 500426; // You can't repair that.
				}

				CraftContext context = m_CraftSystem.GetContext( from );

				from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, number ) );
			}
		}
	}
}
i doesnt give any error but still players can repair cold blood :((
 

egemen

Wanderer
i didnt understand what do u mean i only add some functions first catogarize the cold and second is main purpose of the code and still i dont know what is my wrong?
 

David

Moderate
Try
Code:
[COLOR="Red"]return [COLOR="Blue"][B]![/B][/COLOR]( weapon is ColdBlood );[/COLOR]
Or
Code:
[COLOR="Red"][COLOR="Blue"][B]![/B][/COLOR]IsNotSpecialWeapon( weapon )[/COLOR]
(but not both)
The code is confusing, but I think your test is reversed.
 

Phantom

Knight
egemen said:
i didnt understand what do u mean i only add some functions first catogarize the cold and second is main purpose of the code and still i dont know what is my wrong?

Did you add this code to the class

Code:
private bool IsNotSpecialWeapon( BaseWeapon weapon )
			{
		

				if ( m_CraftSystem is DefTinkering )
				{
					return ( weapon is ColdBlood );
				}
				
				return false;
}

Its a simple yes or no answer.
 

X-SirSly-X

Sorceror
If someone asks a question and you know the answer... answer the damn question. Answering the question is the best thing you can do for RunUO and like the person who wrote the quote driving this update said, "...it can also foster the sense of community that is the very lifeblood of..." RunUO.

Its easy to see he added that code in himself.

Besides does it really matter?
No, it doesn't he's working on it, and trying, and thats what matters.


egemen, did Davids post help? If not you could work on adding an array list, which has all the items that can't, be repaired, and then put the list name down here the post David posted. I can help more after class.
 

Phantom

Knight
X-SirSly-X said:
Its easy to see he added that code in himself.

Besides does it really matter?
No, it doesn't he's working on it, and trying, and thats what matters.

I am trying to answer his question, without knowing if he added that code himself, I cannot help him. The method could have existed, and he just removed all the code. In order to help him, I must know if thats a default method. Depending on several factors, the reason his code is not working, could be as simple as he never called the method. I am not going to explain to the user, how to fix his code, unless I know what exactly he did.

Who are you to decide if it matters or not? Like I just said, I am trying to gather the required information in order to help him. I cannot answer, or should I explain to him, why his code is not working till I get that required information. Please take your grudge against me, and bring it up in starbucks or some other website, but do not get in the way of me helping people.

egemen

I still need to know if thats a custom method that you added to the class, perhaps if you explain why you thought to add it, I might be able to explain why its not working.
 

egemen

Wanderer
X-SirSly-X said:
Its easy to see he added that code in himself.

Besides does it really matter?
No, it doesn't he's working on it, and trying, and thats what matters.


egemen, did Davids post help? If not you could work on adding an array list, which has all the items that can't, be repaired, and then put the list name down here the post David posted. I can help more after class.

İ tried davids post but it didn't work too.
İ used İsNotSpecialWeapon to catogorize cold blood
Code:
if ( m_CraftSystem.CraftItems.SearchForSubclass( weapon.GetType() ) == null && !IsSpecialWeapon( weapon ) )
					{
						number = 1044277; // That item cannot be repaired.
					}
for this
 

Phantom

Knight
You should modify the IsSpecialWeapon, and not the method you created, as you never called it.

You still didn't answer my question, which upsets me, so this will be my last reply.
 

egemen

Wanderer
Phantom said:
You should modify the IsSpecialWeapon, and not the method you created, as you never called it.

You still didn't answer my question, which upsets me, so this will be my last reply.
Phantom i have answered ur question 2 times you ask that why did u write NotSpecialWeapon and i said u that to catogorize cold blood that is different than clever ok?
And you said that modify IsSpecialWeapon but there only 2 codes to modify:
David said:
Try
Code:
[COLOR="Red"]return [COLOR="Blue"][B]![/B][/COLOR]( weapon is ColdBlood );[/COLOR]
Or
Code:
[COLOR="Red"][COLOR="Blue"][B]![/B][/COLOR]IsNotSpecialWeapon( weapon )[/COLOR]
(but not both)
The code is confusing, but I think your test is reversed.
They are not working too :(
 

Phantom

Knight
Phantom i have answered ur question 2 times you ask that why did u write NotSpecialWeapon and i said u that to catogorize cold blood that is different than clever ok?

Whatever, the only person that said you wrote that method, was somebody else. Only after several replies, and several hours later, did you answer my question.

You need to modify the following code, and add your weapon to the list of unrepairable objects.

private bool IsSpecialWeapon( BaseWeapon weapon )
{
// Weapons repairable but not craftable

if ( m_CraftSystem is DefTinkering )
{
return ( weapon is Cleaver )
|| ( weapon is Hatchet )
|| ( weapon is Pickaxe )
|| ( weapon is ButcherKnife )
|| ( weapon is SkinningKnife );
}
else if ( m_CraftSystem is DefCarpentry )
{
return ( weapon is Club )
|| ( weapon is BlackStaff )
|| ( weapon is MagicWand );
}
else if ( m_CraftSystem is DefBlacksmithy )
{
return ( weapon is Pitchfork );
}

return false;
}

the exact check you should use is the following:

Code:
return ( weapon is ColdBlood );

If you do my suggestion it will work, if you ignore it, well if you blindly ignore my advice you are on your own. I have attempted to help you, have been attack for doing so, and I feel like my advice isn't being taken.
 

egemen

Wanderer
İ am sorry if i break you i am trying all of your suggustions because i dont know scripting as yours i will try your suggestion now :)
 

egemen

Wanderer
You said this i think but it is giving errors too :(
Code:
private bool IsSpecialWeapon( BaseWeapon weapon )
			{
				// Weapons repairable but not craftable

				if ( m_CraftSystem is DefTinkering )
				{
					return ( weapon is Cleaver )
						|| ( weapon is Hatchet )
						|| ( weapon is Pickaxe )
						|| ( weapon is ButcherKnife )
						|| ( weapon is SkinningKnife );
				}
				else if ( m_CraftSystem is DefCarpentry )
				{
					return ( weapon is Club )
						|| ( weapon is BlackStaff )
						|| ( weapon is MagicWand );
				}
				else if ( m_CraftSystem is DefBlacksmithy )
				{
					return ( weapon is Pitchfork );
				}
				else if ( m_CraftSystem is unrepairable objects )
				{
					return ( weapon is ColdBlood );
				}

				return false;
			}

it gives error that:
Code:
Scripts: Compiling C# scripts...failed (4 errors, 1 warnings)
 - Warning: Scripts\custom\cold repair\tamirkagıdı.cs: CS0168: (line 26, column
9) The variable 'number' is declared but never used
 - Error: Scripts\Engines\Craft\Core\Repair.cs: CS1026: (line 59, column 45) ) e
xpected
 - Error: Scripts\Engines\Craft\Core\Repair.cs: CS1002: (line 59, column 53) ; e
xpected
 - Error: Scripts\Engines\Craft\Core\Repair.cs: CS1525: (line 59, column 53) Inv
alid expression term ')'
 - Error: Scripts\Engines\Craft\Core\Repair.cs: CS1002: (line 59, column 54) ; e
xpected
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.
 

egemen

Wanderer
else if ( m_CraftSystem is DefTinkering && weapon is ColdBlood )
{

number = 500426; // You can't repair that.
}


this?
 

Phantom

Knight
egemen said:
else if ( m_CraftSystem is DefTinkering && weapon is ColdBlood )
{

number = 500426; // You can't repair that.
}


this?

Is that legal code, of course it is, but it won't do what you want.

Infact that code will break the default code thats already there, why you removed the default code, confuses me.
 

egemen

Wanderer
Phantom said:
Is that legal code, of course it is, but it won't do what you want.

Infact that code will break the default code thats already there, why you removed the default code, confuses me.
What is default code?
 

Phantom

Knight
Code:
if ( m_CraftSystem is DefTinkering )
				{
					return ( weapon is Cleaver )
						|| ( weapon is Hatchet )
						|| ( weapon is Pickaxe )
						|| ( weapon is ButcherKnife )
						|| ( weapon is SkinningKnife );
				}
 

egemen

Wanderer
ok i didnt removed this code only add some functions and inspite of your clue i havent understand what i must do because you didnt understand that i am very bad scripter i started new.
you are saying that add cold blood to unrepairable items but can you see any unreapairable catagory on repair.cs
Code:
using System;
using Server;
using Server.Mobiles;
using Server.Targeting;
using Server.Items;

namespace Server.Engines.Craft
{
	public class Repair
	{
		public Repair()
		{
		}

		public static void Do( Mobile from, CraftSystem craftSystem, BaseTool tool )
		{
			from.Target = new InternalTarget( craftSystem, tool );
			from.SendLocalizedMessage( 1044276 ); // Target an item to repair.
		}

		private class InternalTarget : Target
		{
			private CraftSystem m_CraftSystem;
			private BaseTool m_Tool;

			public InternalTarget( CraftSystem craftSystem, BaseTool tool ) :  base ( 2, false, TargetFlags.None )
			{
				m_CraftSystem = craftSystem;
				m_Tool = tool;
			}

			private static void EndGolemRepair( object state )
			{
				((Mobile)state).EndAction( typeof( Golem ) );
			}

			private bool IsSpecialWeapon( BaseWeapon weapon )
			{
				// Weapons repairable but not craftable

				if ( m_CraftSystem is DefTinkering )
				{
					return 
						 ( weapon is Hatchet )
						|| ( weapon is Pickaxe )
						|| ( weapon is ButcherKnife )
						|| ( weapon is SkinningKnife );
				}
				else if ( m_CraftSystem is DefCarpentry )
				{
					return ( weapon is Club )
						|| ( weapon is BlackStaff )
						|| ( weapon is MagicWand );
				}
				else if ( m_CraftSystem is DefBlacksmithy )
				{
					return ( weapon is Pitchfork );
				}
				
				return false;
			}

			protected override void OnTarget( Mobile from, object targeted )
			{
				int number;

				if ( m_CraftSystem is DefTinkering && targeted is Golem )
				{
					Golem g = (Golem)targeted;
					int damage = g.HitsMax - g.Hits;

					if ( g.IsDeadBondedPet )
					{
						number = 500426; // You can't repair that.
					}
					else if ( damage <= 0 )
					{
						number = 500423; // That is already in full repair.
					}
					else
					{
						double skillValue = from.Skills[SkillName.Tinkering].Value;

						if ( skillValue < 60.0 )
						{
							number = 1044153; // You don't have the required skills to attempt this item.
						}
						else if ( !from.CanBeginAction( typeof( Golem ) ) )
						{
							number = 501789; // You must wait before trying again.
						}
						else
						{
							if ( damage > (int)(skillValue * 0.3) )
								damage = (int)(skillValue * 0.3);

							damage += 30;

							if ( !from.CheckSkill( SkillName.Tinkering, 0.0, 100.0 ) )
								damage /= 2;

							Container pack = from.Backpack;

							if ( pack != null )
							{
								int v = pack.ConsumeUpTo( typeof( IronIngot ), (damage+4)/5 );

								if ( v > 0 )
								{
									g.Hits += v*5;

									number = 1044279; // You repair the item.

									from.BeginAction( typeof( Golem ) );
									Timer.DelayCall( TimeSpan.FromSeconds( 12.0 ), new TimerStateCallback( EndGolemRepair 

), from );
								}
								else
								{
									number = 1044037; // You do not have sufficient metal to make that.
								}
							}
							else
							{
								number = 1044037; // You do not have sufficient metal to make that.
							}
						}
					}
				}
				else if ( targeted is BaseWeapon )
				{
					BaseWeapon weapon = (BaseWeapon)targeted;
					SkillName skill = m_CraftSystem.MainSkill;
					int toWeaken = 0;

					if ( Core.AOS )
					{
						toWeaken = 1;
					}
					else if ( skill != SkillName.Tailoring )
					{
						double skillLevel = from.Skills[skill].Base;

						if ( skillLevel >= 90.0 )
							toWeaken = 1;
						else if ( skillLevel >= 70.0 )
							toWeaken = 2;
						else
							toWeaken = 3;
					}

					if ( m_CraftSystem.CraftItems.SearchForSubclass( weapon.GetType() ) == null && !IsSpecialWeapon( weapon ) )
					{
						number = 1044277; // That item cannot be repaired.
					}
					else if ( !weapon.IsChildOf( from.Backpack ) )
					{
						number = 1044275; // The item must be in your backpack to repair it.
					}
					else if ( weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits )
					{
						number = 1044281; // That item is in full repair
					}
					else if ( weapon.MaxHits <= toWeaken )
					{
						number = 500424; // You destroyed the item.
						m_CraftSystem.PlayCraftEffect( from );
						weapon.Delete();
					}
					else if ( from.CheckSkill( skill, -285.0, 100.0 ) )
					{
						number = 1044279; // You repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						weapon.MaxHits -= toWeaken;
						weapon.Hits = weapon.MaxHits;
					}
					else
					{
						number = 1044280; // You fail to repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						weapon.MaxHits -= toWeaken;

						if ( weapon.Hits - toWeaken < 0 )
							weapon.Hits = 0;
						else
							weapon.Hits -= toWeaken;
					}

					if ( weapon.MaxHits <= toWeaken )
						from.SendLocalizedMessage( 1044278 ); // That item has been repaired many times, and will break if repairs 

are attempted again.
				}
				else if ( targeted is BaseArmor )
				{
					BaseArmor armor = (BaseArmor)targeted;
					SkillName skill = m_CraftSystem.MainSkill;
					int toWeaken = 0;

					if ( Core.AOS )
					{
						toWeaken = 1;
					}
					else if ( skill != SkillName.Tailoring )
					{
						double skillLevel = from.Skills[skill].Base;

						if ( skillLevel >= 90.0 )
							toWeaken = 1;
						else if ( skillLevel >= 70.0 )
							toWeaken = 2;
						else
							toWeaken = 3;
					}

					if ( m_CraftSystem.CraftItems.SearchForSubclass( armor.GetType() ) == null )
					{
						number = 1044277; // That item cannot be repaired.
					}
					else if ( !armor.IsChildOf( from.Backpack ) )
					{
						number = 1044275; // The item must be in your backpack to repair it.
					}
					else if ( armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints )
					{
						number = 1044281; // That item is in full repair
					}
					else if ( armor.MaxHitPoints <= toWeaken )
					{
						number = 500424; // You destroyed the item.
						m_CraftSystem.PlayCraftEffect( from );
						armor.Delete();
					}
					else if ( from.CheckSkill( skill, -285.0, 100.0 ) )
					{
						number = 1044279; // You repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						armor.MaxHitPoints -= toWeaken;
						armor.HitPoints = armor.MaxHitPoints;
					}
					else
					{
						number = 1044280; // You fail to repair the item.
						m_CraftSystem.PlayCraftEffect( from );
						armor.MaxHitPoints -= toWeaken;

						if ( armor.HitPoints - toWeaken < 0 )
							armor.HitPoints = 0;
						else
							armor.HitPoints -= toWeaken;
					}

					if ( armor.MaxHitPoints <= toWeaken )
						from.SendLocalizedMessage( 1044278 ); // That item has been repaired many times, and will break if repairs 

are attempted again.
				}
				else if ( targeted is Item )
				{
					number = 1044277; // That item cannot be repaired.
				}
				else
				{
					number = 500426; // You can't repair that.
				}

				CraftContext context = m_CraftSystem.GetContext( from );

				from.SendGump( new CraftGump( from, m_CraftSystem, m_Tool, number ) );
			}
		}
	}
}
 

seltor

Sorceror
Can he not just add this inside the tinkering check? Or will it still return because it is a cleaver?

Code:
!( weapon is ColdBlood );
 
Top