Full Version : Property Count
xmlspawner >>Scripting Support >>Property Count
<< Prev | Next >>
Lord Hog Fred- 02-04-2007
How can I call the properties present on an item from within a script.
I don't need to be able to see what properties they are, just how many there are.
For example I have Item X with SSI, DI and LRC I want the script to detect the item has 3 properties on it.
How could I go about this?
Thanks ,
ArteGordon- 02-05-2007
You could modify the GetProperties method in the scripts for the type of objects that you want to track attributes for (e.g. in BaseWeapon.cs) to keep track of the number of attributes on the weapon.
Add a publically accessible variable to keep track of it, and then increment that variable for any attribute you are trying to count, like this

QUOTE
//ARTEGORDONMOD // keep track of number of attributes on a weapon public int Totalattributes = 0; public override void GetProperties( ObjectPropertyList list ) {
base.GetProperties( list );
if ( m_Crafter != null )
list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~
#region Factions
if ( m_FactionState != null )
list.Add( 1041350 ); // faction item
#endregion
if ( m_AosSkillBonuses != null )
m_AosSkillBonuses.GetProperties( list );
if ( m_Quality == WeaponQuality.Exceptional )
list.Add( 1060636 ); // exceptional
if( RequiredRace == Race.Elf )
list.Add( 1075086 ); // Elves Only
if ( ArtifactRarity > 0 )
list.Add( 1061078, ArtifactRarity.ToString() ); // artifact rarity ~1_val~
if ( this is IUsesRemaining && ((IUsesRemaining)this).ShowUsesRemaining )
list.Add( 1060584, ((IUsesRemaining)this).UsesRemaining.ToString() ); // uses remaining: ~1_val~
if ( m_Poison != null && m_PoisonCharges > 0 )
list.Add( 1062412 + m_Poison.Level, m_PoisonCharges.ToString() );
if( m_Slayer != SlayerName.None )
{
SlayerEntry entry = SlayerGroup.GetEntryByName( m_Slayer );
if( entry != null )
list.Add( entry.Title );
}
if( m_Slayer2 != SlayerName.None )
{
SlayerEntry entry = SlayerGroup.GetEntryByName( m_Slayer2 );
if( entry != null )
list.Add( entry.Title );
}
base.AddResistanceProperties( list );
int prop;
// ARTEGORDONMOD
// reset the attribute count
Totalattributes = 0;
if ((prop = m_AosWeaponAttributes.UseBestSkill) != 0)
{
list.Add(1060400); // use best weapon skill
// ARTEGORDONMOD
// increment the attribute count
Totalattributes++;
}
if ((prop = (GetDamageBonus() + m_AosAttributes.WeaponDamage)) != 0)
{
list.Add(1060401, prop.ToString()); // damage increase ~1_val~%
// ARTEGORDONMOD
// increment the attribute count
Totalattributes++;
}

You could also just add your own property that went through the list and counted them, like

CODE
public int TotalAttributes { get { int count = 0;
if (m_AosWeaponAttributes.UseBestSkill != 0)
count++;
if ((GetDamageBonus() + m_AosAttributes.WeaponDamage) != 0)
count++;
return count;
}
}

Lord Hog Fred- 02-05-2007
Ah fantastic.
Thanks a lot, shalll give it a go