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!

Food with (Hidden) Attributes

Crab Man

Traveler
I really hate to ask but I am in need of a little help!I have been messing with different ways to give food attributes...

I do not want to show the attributes on the item itself just have it actually enable these attributes.

This is what I have tried and actually got it to Compile with

Code:
using System;
using Server;
using Server.Mobiles;
 
namespace Server.Items
{
        public class WrathGrapes : BaseMagicalFood
        {
                public override MagicalFood FoodID{ get{ return MagicalFood.WrathGrapes; } }
                public override TimeSpan Cooldown{ get{ return TimeSpan.FromMinutes( 2 ); } }
                public override TimeSpan Duration{ get{ return TimeSpan.FromSeconds( 20 ); } }
                public override int EatMessage{ get{ return 1074847; } } // The grapes of wrath invigorate you for a short time, allowing you to deal extra damage.
     
                [Constructable]
                public WrathGrapes() : base( 0x2FD7 )
                {
                        Weight = 1.0;
                        Hue = 0x482;
                }
     
                public WrathGrapes( Serial serial ) : base( serial )
                {
                }
               
                public override bool Eat( Mobile from )
                {
                        if ( base.Eat( from ) )
                        {
                                from.PlaySound( 0x1EA );
                                from.FixedParticles( 0x373A, 10, 15, 5018, EffectLayer.Waist );
                               
                                int DamageBonus = AosAttributes.GetValue( from, AosAttribute.WeaponDamage );
                                int SpellDamageBonus = AosAttributes.GetValue( from, AosAttribute.SpellDamage );
                               
                                DamageBonus += 35;
                                SpellDamageBonus += 15;
                                   
                                   
                                return true;
                        }
                       
                    return false;
                }
             
                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();
                }
        }
}

When the person eats it should give them the Spell Damage Bonus as well as the Damage Increase Bonus!

Thanks for your help!
 

daat99

Moderator
Staff member
IIRC you need to add those attributes to PlayerMobile.cs and then account for them in the methods that deals with damage dealt.
You can't do this on the food item alone.
 

Crab Man

Traveler
IIRC you need to add those attributes to PlayerMobile.cs and then account for them in the methods that deals with damage dealt.
You can't do this on the food item alone.

Darn, I knew that was going to happen. Thanks I am sure I can figure it out.
 

m309

Squire
Don't forget to also add some sort of timer, or way to remove the damage bonuses. Otherwise players can just chow down on countless pieces of food and keep adding bonuses until they hit the hard cap.
 

Crab Man

Traveler
Don't forget to also add some sort of timer, or way to remove the damage bonuses. Otherwise players can just chow down on countless pieces of food and keep adding bonuses until they hit the hard cap.


Yeah I did it! :) Its up at the top of the script as Cooldown :)

Code:
                public override TimeSpan Cooldown{ get{ return TimeSpan.FromMinutes( 2 ); } }
                public override TimeSpan Duration{ get{ return TimeSpan.FromSeconds( 20 ); } }
 

Crab Man

Traveler
Top