Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 05-04-2008, 11:57 AM   #1 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default Name extraction - how to get item names?

I've been trying to make a deed called Heavenly Creation Deed for my Heavenly Item system, but have encountered a problem...
The deed is supposed to, among other things, change the name of the item from "[name]" to "Heavenly [name]". The problem is many items don't have their names shown the 'normal' way (item.Name == null).
My question is:
How to check the items' names in such cases?

edited:
Oh... and by the way... is there any way to make existing items artifacts?
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.

Last edited by i_am_neo; 05-04-2008 at 12:04 PM.
i_am_neo is offline   Reply With Quote
Old 05-04-2008, 12:18 PM   #2 (permalink)
Forum Master
 
Lord_Greywolf's Avatar
 
Join Date: Dec 2005
Posts: 6,777
Send a message via Yahoo to Lord_Greywolf
Default

for the name problem
add this section into your code:

string name = this.Name;
if ( name == null ) name = String.Format( "#{0}", LabelNumber );

that will get the name for you if none has been assigned
then you can just add hevenaly, etc to it

as for making stuff artifacts that are not in game
Nope - can only via script overwrites upon creation
not with out a lot of hassle
have to modify base weapon & armor in a few spots
and when i had done this correctly, it still gave problems down the line

what you are better off doing is to just add in a whole new variable into them
and set that variable
and on the "property display" if true - display "artifact" or "heavenly Modified", etc
but they will not be considered artifacts for quick references
__________________
http://www.AoAUO.com

:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :)
Lord_Greywolf is offline   Reply With Quote
Old 05-04-2008, 01:02 PM   #3 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

Quote:
Originally Posted by Lord_Greywolf View Post
for the name problem
add this section into your code:

string name = this.Name;
if ( name == null ) name = String.Format( "#{0}", LabelNumber );

that will get the name for you if none has been assigned
then you can just add hevenaly, etc to it

as for making stuff artifacts that are not in game
Nope - can only via script overwrites upon creation
not with out a lot of hassle
have to modify base weapon & armor in a few spots
and when i had done this correctly, it still gave problems down the line

what you are better off doing is to just add in a whole new variable into them
and set that variable
and on the "property display" if true - display "artifact" or "heavenly Modified", etc
but they will not be considered artifacts for quick references

Humm... That doesn't seem to work...
I put this:
Code:

string name = item.Name;
if (name == null) name = String.Format("#{0}", item.LabelNumber);
item.Name = "Heavenly " + name;
and after changing a Cloak I got this as a name:
Heavenly #1025397

__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-04-2008, 04:49 PM   #4 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

Here's an example of what I got when I used the deed on a katana:

Guess what I'm looking for is a way to change the label number to text (probably some cliloc stuff).
Attached Images
File Type: jpg Heavenly Number.JPG (44.4 KB, 49 views)
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-04-2008, 05:02 PM   #5 (permalink)
Forum Master
 
Lord_Greywolf's Avatar
 
Join Date: Dec 2005
Posts: 6,777
Send a message via Yahoo to Lord_Greywolf
Default

remove the # from in there that i showed and try it
just the # itself, nothing else
__________________
http://www.AoAUO.com

:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :)
Lord_Greywolf is offline   Reply With Quote
Old 05-04-2008, 05:35 PM   #6 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

Now it shows just the number...

I guess the problem is it doesn't see it as a string, just as a number...
All it does is just write the number...
I'm not an expert, but it sees to be so...

So guess the problem will be for it to see the number as a string (find the string in the cliloc?)...

The question wold be... How?
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-04-2008, 06:00 PM   #7 (permalink)
Forum Master
 
Lord_Greywolf's Avatar
 
Join Date: Dec 2005
Posts: 6,777
Send a message via Yahoo to Lord_Greywolf
Default

i got this working before - just forget how now - let me try to find it

this is taken straight from basearmor:

if ( name == null ) name = String.Format( "#{0}", LabelNumber );

make sure you are using the correct CaPs in there andf the rightr {}(), etc
__________________
http://www.AoAUO.com

:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :)
Lord_Greywolf is offline   Reply With Quote
Old 05-04-2008, 06:12 PM   #8 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

Quote:
Originally Posted by Lord_Greywolf View Post
i got this working before - just forget how now - let me try to find it

this is taken straight from basearmor:

if ( name == null ) name = String.Format( "#{0}", LabelNumber );

make sure you are using the correct CaPs in there andf the rightr {}(), etc

That would be something similar to what I have...
Maybe it makes a difference, that item means BaseClothing here??
Well.. here's a bigger piece of code:
Code:
/* Non-meaningful here */
 
if ( (target is BaseClothing) && !(target is BaseShoes) )
{
BaseClothing item = (BaseClothing)target;
 
/* Non-meaningful here */
 
string name = item.Name;
if (name == null) name = String.Format("{0}", item.LabelNumber);
item.Name = "Heavenly " + name;
 
/* Non-meaningful here */
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-04-2008, 08:20 PM   #9 (permalink)
Forum Master
 
Lord_Greywolf's Avatar
 
Join Date: Dec 2005
Posts: 6,777
Send a message via Yahoo to Lord_Greywolf
Default

you need the # symbol in there

this is from baseclothing - so putting the item. in front of label would be needed (shown in red and added), but it is how it works there


Code:
		private string GetNameString()
		{
			string name = this.Name;

			if ( name == null )
				name = String.Format( "#{0}", item.LabelNumber );

			return name;
		}
make sure you are copying & pasting exactly, a "space" in the wrong place will goof it up

also what version of runuo are you using?
__________________
http://www.AoAUO.com

:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :)
Lord_Greywolf is offline   Reply With Quote
Old 05-05-2008, 11:21 AM   #10 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

Quote:
Originally Posted by i_am_neo View Post
Humm... That doesn't seem to work...
I put this:
Code:
string name = item.Name;
if (name == null) name = String.Format("#{0}", item.LabelNumber);
item.Name = "Heavenly " + name;
and after changing a Cloak I got this as a name:
Heavenly #1025397

Already tried that...
And I'm running on RC1.
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-05-2008, 11:54 AM   #11 (permalink)
Forum Expert
 
Vorspire's Avatar
 
Join Date: Jan 2005
Location: Newcastle, United Kingdom
Age: 21
Posts: 2,298
Send a message via ICQ to Vorspire Send a message via MSN to Vorspire Send a message via Skype™ to Vorspire
Default

it's lowercase string.Format not uppercase String.Format
__________________

WWW.RPK-UO.COM - The WoW-UO Cross-Over Shard
Vorspire is offline   Reply With Quote
Old 05-05-2008, 12:53 PM   #12 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

That doesn't work either :/

Any other ideas?
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-05-2008, 01:08 PM   #13 (permalink)
Forum Expert
 
Vorspire's Avatar
 
Join Date: Jan 2005
Location: Newcastle, United Kingdom
Age: 21
Posts: 2,298
Send a message via ICQ to Vorspire Send a message via MSN to Vorspire Send a message via Skype™ to Vorspire
Default

Code:
item.Name = PrependName( item, "Heavenly" )

public string PrependName( Item item, string prepend )
{
    if(item.Name==null)
      return (prepend +" "+ string.Format( "#{0}", LabelNumber ) );

    return ( prepend +" "+ item.Name );
}
__________________

WWW.RPK-UO.COM - The WoW-UO Cross-Over Shard
Vorspire is offline   Reply With Quote
Old 05-05-2008, 02:19 PM   #14 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

What the...
Doesn't work either...
So nothing seems to work...
How about base.GetNameProperties( ... ), or something like that?
Could it be used here?
Or maybe something else?
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-05-2008, 02:50 PM   #15 (permalink)
Forum Expert
 
Vorspire's Avatar
 
Join Date: Jan 2005
Location: Newcastle, United Kingdom
Age: 21
Posts: 2,298
Send a message via ICQ to Vorspire Send a message via MSN to Vorspire Send a message via Skype™ to Vorspire
Default

Does it create the item named "Heavenly "?

Please post your current script
__________________

WWW.RPK-UO.COM - The WoW-UO Cross-Over Shard
Vorspire is offline   Reply With Quote
Old 05-05-2008, 02:57 PM   #16 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

It changes the item's name to "Heavenly #xxxxx" (where xxxxx is the item's cliloc number).

Here's the script:
Code:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
namespace Server.Items
{
publicclass HeavenlyCreationTarget : Target // Create our targeting class (which we derive from the base target class)
{
private HeavenlyCreationDeed m_Deed;
public HeavenlyCreationTarget(HeavenlyCreationDeed deed)
: base(1, false, TargetFlags.None)
{
m_Deed = deed;
}
publicstring PrependName( Item item, string prepend )
{
if(item.Name==null)
return (prepend +" "+ string.Format( "#{0}", item.LabelNumber ) );
return ( prepend +" "+ item.Name );
}
protectedoverridevoid OnTarget( Mobile from, object target ) // Override the protected OnTarget() for our feature
{
if ( m_Deed.Deleted || m_Deed.RootParent != from )
return;
if ( (target is BaseClothing) && !(target is BaseShoes) )
{
BaseClothing item = (BaseClothing)target;
if (item.RootParent != from)
{
from.SendMessage("The item must be in your pack for you to convert it!");
return;
}
from.SendMessage( "You have successfully transferred heavenly powers to the item!" );
/* Adding Item Properties */
item.Weight = 2;
item.Name = PrependName(item, "Heavenly");
item.Hue = 1159;
item.MaxHitPoints = -1;
item.LootType = LootType.Blessed;
item.Resistances.Cold += 15 - Utility.Random(7);
item.Resistances.Energy += 15 - Utility.Random(7);
item.Resistances.Fire += 15 - Utility.Random(7);
item.Resistances.Physical += 15 - Utility.Random(7);
item.Resistances.Poison += 15 - Utility.Random(7);
item.Attributes.BonusDex = 5;
item.Attributes.BonusInt = 5;
item.Attributes.BonusStr = 5;
item.Attributes.BonusHits = 10;
item.Attributes.BonusMana = 10;
item.Attributes.BonusStam = 10;
item.Attributes.WeaponSpeed = 5;
item.Attributes.WeaponDamage = 5;
item.Attributes.SpellDamage = 5;
item.Attributes.LowerManaCost = 5;
item.Attributes.CastRecovery = 2;
item.Attributes.CastSpeed = 2;
item.Attributes.RegenHits = 4;
item.Attributes.RegenMana = 4;
item.Attributes.RegenStam = 4;
item.Attributes.AttackChance = 5;
item.Attributes.DefendChance = 5 + Utility.Random(5);
item.Attributes.NightSight = 1;
item.Attributes.ReflectPhysical = 5 + Utility.Random(5);
item.Attributes.Luck = 300;
 
/* Adding Item Properties */
m_Deed.Delete(); // Delete the deed
 
}
elseif (target is BaseShoes)
{
BaseShoes item = (BaseShoes)target;
if (item.RootParent != from)
{
from.SendMessage("The item must be in your pack for you to convert it!");
return;
}
from.SendMessage("You have successfully transferred heavenly powers to the item!");
/* Adding Item Properties */
item.Weight = 2;
item.Name = PrependName( item, "Heavenly" );
item.Hue = 1159;
item.MaxHitPoints = -1;
item.LootType = LootType.Blessed;
item.Resistances.Cold += 15 - Utility.Random(10);
item.Resistances.Energy += 15 - Utility.Random(10);
item.Resistances.Fire += 15 - Utility.Random(10);
item.Resistances.Physical += 15 - Utility.Random(5);
item.Resistances.Poison += 15 - Utility.Random(10);
item.Attributes.BonusDex = 5;
item.Attributes.BonusInt = 5;
item.Attributes.BonusStr = 5;
item.Attributes.BonusHits = 10;
item.Attributes.BonusMana = 10;
item.Attributes.BonusStam = 10 + Utility.Random(30);
item.Attributes.WeaponSpeed = 5;
item.Attributes.WeaponDamage = 5;
item.Attributes.SpellDamage = 5;
item.Attributes.LowerManaCost = 5;
item.Attributes.CastRecovery = 2;
item.Attributes.CastSpeed = 2;
item.Attributes.RegenHits = 4;
item.Attributes.RegenMana = 4;
item.Attributes.RegenStam = 4 + Utility.Random(6);
item.Attributes.AttackChance = 5;
item.Attributes.DefendChance = 5;
item.Attributes.NightSight = 1;
item.Attributes.ReflectPhysical = 5;
item.Attributes.Luck = 300;
/* Adding Item Properties */
m_Deed.Delete(); // Delete the deed
}
elseif (target is BaseArmor)
{
BaseArmor item = (BaseArmor)target;
if (item.RootParent != from)
{
from.SendMessage("The item must be in your pack for you to convert it!");
return;
}
from.SendMessage("You have successfully transferred heavenly powers to the item!");
/* Adding Item Properties */
item.Weight = 2;
item.Name = PrependName(item, "Heavenly");
item.Hue = 1159;
item.MaxHitPoints = -1;
item.LootType = LootType.Blessed;
item.ColdBonus += 25 - Utility.Random(10);
item.EnergyBonus += 25 - Utility.Random(10);
item.FireBonus += 25 - Utility.Random(10);
item.PhysicalBonus += 25 - Utility.Random(10);
item.PoisonBonus += 25 - Utility.Random(10);
item.Attributes.BonusDex = 10;
item.Attributes.BonusInt = 10;
item.Attributes.BonusStr = 10;
item.Attributes.BonusHits = 15;
item.Attributes.BonusMana = 15;
item.Attributes.BonusStam = 15;
item.Attributes.WeaponSpeed = 5;
item.Attributes.WeaponDamage = 5;
item.Attributes.SpellDamage = 5;
item.Attributes.LowerManaCost = 5;
item.Attributes.CastRecovery = 2;
item.Attributes.CastSpeed = 2;
item.Attributes.RegenHits = 5;
item.Attributes.RegenMana = 5;
item.Attributes.RegenStam = 10;
item.Attributes.AttackChance = 5;
item.Attributes.DefendChance = 5;
item.Attributes.NightSight = 1;
item.Attributes.ReflectPhysical = 5 + Utility.Random(20);
item.ArmorAttributes.MageArmor = 1;
item.Attributes.Luck = 300;
/* Adding Item Properties */
m_Deed.Delete(); // Delete the deed
}
elseif (target is BaseJewel)
{
BaseJewel item = (BaseJewel)target;
if (item.RootParent != from)
{
from.SendMessage("The item must be in your pack for you to convert it!");
return;
}
from.SendMessage("You have successfully transferred heavenly powers to the item!");
/* Adding Item Properties */
item.Weight = 2;
item.Name = PrependName(item, "Heavenly");
item.Hue = 1159;
item.LootType = LootType.Blessed;
item.Resistances.Cold = 4 + (4 - Utility.Random(8));
item.Resistances.Energy = 4 + (4 - Utility.Random(8));
item.Resistances.Fire = 4 + (4 - Utility.Random(8));
item.Resistances.Physical = 4 + (4 - Utility.Random(8));
item.Resistances.Poison = 4 + (4 - Utility.Random(8));
item.Attributes.BonusDex = 8 + Utility.Random(5);
item.Attributes.BonusInt = 8 + Utility.Random(5);
item.Attributes.BonusStr = 8 + Utility.Random(5);
item.Attributes.BonusHits = 15;
item.Attributes.BonusMana = 15;
item.Attributes.BonusStam = 15;
item.Attributes.WeaponSpeed = 5;
item.Attributes.WeaponDamage = 15;
item.Attributes.SpellDamage = 15;
item.Attributes.LowerManaCost = 10;
item.Attributes.CastRecovery = 3 + Utility.Random(5);
item.Attributes.CastSpeed = 3 + Utility.Random(5);
item.Attributes.RegenHits = 5;
item.Attributes.RegenMana = 5;
item.Attributes.RegenStam = 5;
item.Attributes.AttackChance = 5;
item.Attributes.DefendChance = 5;
item.Attributes.Luck = 400; 
/* Adding Item Properties */
m_Deed.Delete(); // Delete the deed
}
elseif (target is BaseWeapon)
{
BaseWeapon item = (BaseWeapon)target;
if (item.RootParent != from)
{
from.SendMessage("The item must be in your pack for you to convert it!");
return;
}
from.SendMessage("You have successfully transferred heavenly powers to the item!");
/* Adding Item Properties */
item.Weight = 2;
item.Name = PrependName(item, "Heavenly");
item.Hue = 1159;
item.MaxHitPoints = -1;
item.LootType = LootType.Blessed;
item.MaxDamage = item.MinDamage = 20 + Utility.Random(15);
item.WeaponAttributes.HitLeechHits = 40 + (5 - Utility.Random(10));
item.WeaponAttributes.HitLeechMana = 40 + (5 - Utility.Random(10));
item.WeaponAttributes.HitLeechStam = 40 + (5 - Utility.Random(10));
item.Attributes.AttackChance = 15;
item.Attributes.DefendChance = 15;
item.Attributes.BonusDex = 8;
item.Attributes.BonusInt = 8;
item.Attributes.BonusStr = 8;
item.Attributes.BonusHits = 15;
item.Attributes.BonusMana = 15;
item.Attributes.BonusStam = 15;
item.Attributes.CastRecovery = 3;
item.Attributes.CastSpeed = 3;
item.Attributes.LowerManaCost = 5;
item.Attributes.RegenHits = 5;
item.Attributes.RegenMana = 5;
item.Attributes.RegenStam = 5;
item.Attributes.SpellChanneling = 1;
item.Attributes.WeaponSpeed = 20;
item.Attributes.Luck = 350;
/* Adding Item Properties */
m_Deed.Delete(); // Delete the deed
} 
// BaseWeapon
else
{
from.SendMessage( "You cannot convert that!" );
}
}
}
publicclass HeavenlyCreationDeed : Item // Create the item class which is derived from the base item class
{
publicoverridestring DefaultName
{
get { return"a heavenly creation deed"; }
}
[Constructable]
public HeavenlyCreationDeed() : base( 0x14F0 )
{
Weight = 1.0;
Hue = 1159;
LootType = LootType.Blessed;
}
public HeavenlyCreationDeed(Serial serial)
: base(serial)
{
}
publicoverridevoid Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
publicoverridevoid Deserialize( GenericReader reader )
{
base.Deserialize( reader );
LootType = LootType.Blessed;
int version = reader.ReadInt();
}
publicoverridebool DisplayLootType{ get{ returnfalse; } }
publicoverridevoid OnDoubleClick( Mobile from ) // Override double click of the deed to call our target
{
if ( !IsChildOf( from.Backpack ) ) // Make sure its in their pack
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
else
{
from.SendMessage( "What would you like to enchant with heavenly powers?" ); // What would you like to bless? (Clothes Only)
from.Target = new HeavenlyCreationTarget(this); // Call our target
}
} 
}
}
I also attach the script here:
Attached Files
File Type: cs Heavenly Creation Deed.cs (12.8 KB, 1 views)
__________________
|Heavenly Item System|Neo's Level System|
If anyone knows, how to put links here, please msg me.
i_am_neo is offline   Reply With Quote
Old 05-05-2008, 04:38 PM   #17 (permalink)
Forum Master
 
Lord_Greywolf's Avatar
 
Join Date: Dec 2005
Posts: 6,777
Send a message via Yahoo to Lord_Greywolf
Default

this may be a deal with it being 1.0 instead of 2.0

look in baseclothing, like i did for how they gat the name that way
and use the same procedure

apparently 1.0 does not convert the cliloc numbers over the same way
__________________
http://www.AoAUO.com

:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :)
Lord_Greywolf is offline   Reply With Quote
Old 05-05-2008, 05:06 PM   #18 (permalink)
Newbie
 
i_am_neo's Avatar
 
Join Date: Jan 2008
Location: Warsaw, Poland
Age: 22
Posts: 97
Send a message via MSN to i_am_neo
Default

So then my RunUO lies:

Code:
RunUO - [www.runuo.com] Version 2.0, Build 2357.32527


I'm pretty sure it's 2.0 RC1

And It's a funny thing...

I've also got the same thing in BaseClothing.cs...

Here's the BaseClothing.cs thing:
Code:

privatestring GetNameString()
{
string name = this.Name;
if ( name == null )
name = String.Format( "#{0}", LabelNumber );
return name;
}
And in publicoverridevoid AddNameProperty( ObjectPropertyList list ):
Code:

if ( oreType != 0 )
list.Add( 1053099, "#{0}\t{1}", oreType, GetNameString() ); // ~1_oretype~ ~2_armortype~
elseif ( Name == null )
list.Add( LabelNumber );
else
list.Add( Name );


And what I have is:
Code:
// (...)
 
publicstring PrependName( Item item, string prepend )
{
    if(item.Name==null)
        return (prepend +" "+ string.Format( "#{0}", item.LabelNumber ) );
    return ( prepend +" "+ item.Name );
}
protectedoverridevoid OnTarget( Mobile from, object target ) // Override the protected OnTarget() for our feature
{
    if ( m_Deed.Deleted || m_Deed.RootParent != from )
        return;
    if ( (target is BaseClothing) && !(target