BelfortUO

Member
Running ServUO. Just curious, how difficult is it to add % bonuses to a worn item?

I am a total newb trying to figure out how to connect the dots.

Tried a couple different things however just get errors.

using System;
using Server;

namespace Server.Items
{
public class SnowBoots : BaseArmor
{
public override int ArtifactRarity{ get{ return 50; } }
public override int InitMinHits{ get{ return 255; } }
public override int InitMaxHits{ get{ return 255; } }

[Constructable]
public FrostySnowBoots() : base (5899)
{
Name = "Snow Boots";
Hue = 1153;
Weight = 3;

SkillBonuses.SetValues( 0, SkillName.Stealth, 10 );
SkillBonuses.SetValues( 1, SkillName.DetectHidden, 10 );
SkillBonuses.SetValues( 2, SkillName.Stealing, 10 );

LootType = LootType.Regular;


Attributes.BonusStr = 6;
Attributes.BonusDex = 12;
Attributes.BonusStam = 12;
Attributes.DefendChance = 10;
Attributes.AttackChance = 10;
Attributes.ReflectPhysical = 20;
PhysicalBonus = 10;
ColdBonus = 30;
EnergyBonus = 20;
}


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

public override ArmorMaterialType MaterialType
{
get
{
return ArmorMaterialType.Cloth;
}
}
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();
}

}
}
 
The first thing I see is your calling it 'BaseArmor'. I do not think shoes are armor, they are clothing. I changed it to BaseShoes or Boots and it mostly worked.
But... the armor material type I have not seen, and had to remark out that section.
Also, the physical, cold, and energy bonus does not seem to work with shoes. I changed the base to PlateLegs and it loaded. I changed it back to Boots and had to remark out those lines to get it to load. I changed the lines to get resistances to load.

I added
using Server.Items;

And to get the resistances I used
public override int BaseColdResistance { get { return 10; } }
public override int BaseEnergyResistance { get { return 10; } }
public override int BasePhysicalResistance { get { return 10; } }

If you are looking for damage type, I think it needs to be on a weapon like this
WeaponAttributes.HitColdArea = 10;

Or like this
public override void GetDamageTypes(Mobile wielder, out int phys, out int fire, out int cold, out int pois, out int nrgy)
{
phys = 20; //damage type percentages
fire = 20;
cold = 20;
pois = 20;
nrgy = 20;
}

But I do not think either will work on shoes. Here the script and a picture of the boots. (they are yellow because they are highlighted, they are actually white ha ha)

boots.jpg
 

Attachments

  • boot.cs
    1.9 KB · Views: 3
Thanks. Yea I did that on purpose. What I am really looking to do it if equipped give 5% more gold. Or if equipped give 3% more luck to the item.
 
Thanks. Yea I did that on purpose. What I am really looking to do it if equipped give 5% more gold. Or if equipped give 3% more luck to the item.
The gold one wouldn't be possible unless you created a new ability into the game base files. Though you could possibly do the luck one since there is already a ability in that area but that is basically just the luck attribute
 
Maybe the OnEquip method,somehting like that:
C#:
public override bool OnEquip(Mobile from)
        {
           from.Luck = from.Luck + ( from.Luck / 0.03); //3%?

            return base.OnEquip(from);
        }
Related to gold,you need to do some changes in baseCreature,maybe here?
In method public void PackGold(int amount)
Try this:
C#:
public void PackGold(int amount)
{
    if (LastKiller is PlayerMobile)
    {
        if (LastKiller.FindItemOnLayer(Layer.YourLayer) is YourItem && amount > 0)
        {
        amount = amount + (int)(amount * 0.03); //3%?
        PackItem(new Gold(amount));
        }
    }
    else if (amount > 0)
         {
         PackItem(new Gold(amount));
         }
}
Note: Not tested,lets see if it works.
Note 2: you can also add this to your item script to show your players the item has a gold bonus.

C#:
public override void GetProperties(ObjectPropertyList list)
        {
        base.GetProperties(list);
        list.Add("Gold bonus<BASEFONT COLOR=#00FF00> [3%]<BASEFONT COLOR=#FFFFFF>");
        }
 
Last edited:
Sorry,editing 3% of gold,try this:

C#:
public void PackGold(int amount)
{
    int Bonus = ( 3 / amount) * 100; //3%?
   
    if (LastKiller is PlayerMobile)
    {
        if (LastKiller.FindItemOnLayer(Layer.Earrings) is PremiumEarrings && amount > 0)
        {
        amount = amount + Bonus;
        PackItem(new Gold(amount));
        }
    }
    else if (amount > 0)
         {
         PackItem(new Gold(amount));
         }
}
About the luck,getting some problems for now.
 
So it looks like the code works without errors. However after testing on a BaseCreature with an average loot pack, wait for it, the average loot was less with it on vs. with it equipped! lol I did an average of 10 with and 10 kills without. With average loot was 140.4....without...141.8. Maybe I need a bigger sample size. Thoughts?

Looks cool though

1609694062763.png
Another sample, same thing, without 146.3 with 144.4
Post automatically merged:

I think the math needs to be more like (looking at a 5% bonus)
int Bonus = ( amount * .05);
That would give you the bonus amount then it looks like it adds it below however it gives an error when you do that.

CS0266: Line 5256: Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
Post automatically merged:

Changed the Math to the following:

int Bonus = ( amount * (5/100)); //5%?

This should give the % amount to be added to the base amount however still not seeing a bonus when the talisman is worn after doing a round of testing.

:confused:
 
Last edited:
Code:
int Bonus = ( amount * .05);
and
Code:
int Bonus = ( amount * (5/100)); //5%?
is literally the same thing.
only problem could end up being if the bracket is calced as int, wich results in 0

anyways.
Code:
int Bonus = (int)(amount * 0.05);
would work.

Also for testing you could simply increase the gold bonus, so do it times 10 then you will have to notice the difference.
 
It doesn't appear to be giving the bonus. Changed it to be a 50% bonus....still same. So there is something else going on.
 
very few creatures use:
public void PackGold(int amount)

Most use:
C#:
        public int Roll()
        {
            int v = m_Bonus;

            for (int i = 0; i < m_Count; ++i)
            {
                v += Utility.Random(1, m_Sides);
            }

            return v;
        }
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back