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!

XML Food System

datguy

Sorceror
Food System, XmlSpawner Required

Finding the cooking section quite boring and if the server required eating, players would still only
buy fruits or cakes & not work on their cooking skills I decided to give them incentive to become a great chef.

When players buy foods they get full & that is all, when they craft foods, they get a small bonus to either a particular skill or a stat or both, depending on what they are eating, the more difficult the item is to craft the better the boost to the foods.

Added a Speciality Section in the craft area, all of these require a recipe, there is a series of Quests that will give out these recipes However there is only a small chance the player will get the recipe each time they do the quest, they will however get a sample of the food they are trying to learn.

Once they do get the recipe the food itself is not hard to make skillwise, so this then would be their specialty. You can opt to give out the recipes some other way but you'd be missing out imo. Quests created by Ednyved mostly (used by permission)


internally what it does

-Modified the foods to have properties, each food can have of
1 skill boost, int/dex/str, 1 or 2 or 3 stat boosts
-each boost will last as long as the foods fillfactor, which is set for 15 minutes, so if the food has
a fillfactor of 4, the boost lasts 1 hour and so does the food till your at that hunger level again.
-The time can also be specified manually in the scripts per item but if nothing is specified it is
same as fillfactor
-each of the boosts are easily adjusted in the food scripts
Statboost time & skill boost time can be adjusted globaly in food.cs to be less than fillfactor, note:

If it is set longer than Fillfactor it does Not stack but just doesn't add the boost if you eat again (checks if there's already a boost applied)so the first Boost may run out before you can eat again because your full.
-

Only crafted foods have these boosts applied to them and the default is that nothing is applied so existing

foods that need no boost properties specified do not need to be altered in any way.

ANY purchasable foods have no boosts on them

example of a crafted food;
Code:
		[Constructable]
public DriedPeachSlice( int amount ) : base( amount, 0x172A )
		{
            Name = "Dried Peach Slice";
            Stackable = true;
            Hue = 435;
            this.Weight = 0.2;
            this.FillFactor = 1;//1 fillfactor = 15 minutes of time

            this.IntBoost = 2;
            this.DexBoost = 1;
            //this.StrBoost = 2;
            //this.StatBoostTime = 5;//can set it's time in MINUTES --default is fillfactor

            this.Skill = "Lumberjacking";
            this.SkillBoost = 2;
            //this.SkillBoostTime = 10;//can set this time in MINUTES independantly from StatBoostTime --default is fillfactor

		}
example of non-crafted food
Code:
        [Constructable]
        public Peach( int amount ) : base( amount, 0x9D2 )
        {
            this.Weight = 1.0;
            this.FillFactor = 1;
        }
Hopefully I got all the code out of my custom server correctly and hopefully I've made things clear enough to understand ;) install info inside



*EDIT* Feb26
Added Jerky item/quest to give you idea's of what is possible, I'm sure you'll come up with many other idea once you get started. Lets not stick to just scripted foods, we can make them in xmlquests

Edit Feb 27
error in Food.cs that if you specify StatBoost duration instead of relying on Fillfactor the timer would break. Either redownload FoodSystem & use the new Food.cs or look a few posts down to see how to fix it.
Thanks Nockar
 

Attachments

  • XmlChefQuest.rar
    63.6 KB · Views: 59
  • Jerky.rar
    2 KB · Views: 49
  • Food System.rar
    52.8 KB · Views: 85

datguy

Sorceror
base foods that need to be added to world - found in Fooditems.cs & Vegetables.cs

put these into the world somehow, either forsale somewhere or a plant system or as loot off of a plant creature
Needed for base ingredients.


Carrot
//Cabbage ----- not nessessary for any recipe but is there might as well use it
Onion
Lettuce
Pumpkin
//SmallPumpkin--- not nessessary for any recipe but is there might as well use it
Peanut
Corn
GarlicBulb
Potato
Spinach
Broccoli
BlackPepperHarvest
WormSilk //add to a worm type creature?

fruit from fruit.cs
peach
Banana
Lemon
Pear
Apple

the rest are not nessessary for any recipe but is there might as well sell it
 

datguy

Sorceror
found another slight error, there are 2 possible quests to use skarachef.npc & skarachef1.npc depending in you have quivers or not, when I made one ask for bows instead for easier distribution I neglected to change line #5 to
Oh, {GETONTRIGMOB,name}! Have you brought the bows?</Text>
here's a replacement , just rename skarachef.npc or fix file yourself :) Main post fixed as well.
 

Attachments

  • skarachef.npc.txt
    7.3 KB · Views: 8

Nockar

Sorceror
Where are these files??????

newfile -\Scripts\Custom\Hunger System\Foods\Items\WormSilk.cs

new file \Custom\Hunger System\HungerCommand.cs

new file \Custom\Hunger System\SkillFood.cs
new file \Custom\Hunger System\StatFood.cs

And where are the new meat types located?
 

Nockar

Sorceror
Well, I got it to compile.

When I eat a food with the +stats they get added but the stats never go away. Tried manually setting the this.StatBoostTime = XX; to a low number since its using second. The stats just end up being permanently added.

Not sure if I missed something in the install or if a file is missing in the RAR.

Any idea?
 

datguy

Sorceror
the stats/skills boost will drop after time has expired as soon as you use any skill, that's just the way xmlspawner attachment works
You can do a [getatt & see the attachments

I guess some documentation is wrong, I'll have to change that :)
wormsilk is in fooditem.cs
Skillfood & Statfood I didn't include (I'll go over them & add them this weekend)
Hunger Command is in my AutoEat&Drink link in my Sig.

Raw meat types are in Cookablefood
Cooked meats in CustomFood
 

datguy

Sorceror
Skillfood & Statfood I didn't include (I'll go over them & add them this weekend)

Lies, Didn't add because i didn't need to, lol. However I did show you a way to make custom foods on the fly on first post with Jerky.rar A quest giver want's you to get some krozar ears & he'll make you some jerky. Kill some renamed mongbats, some of them have their ear as loot (a ruby renamed, diff id# ) collect some & get reward, (apple, renamed, diff id#, hued to look different than raw ears) and because it's a food, it has properties from foodsystem where i can add int, dex, str, skill boosts, all from the questbook
 

Nockar

Sorceror
the stats/skills boost will drop after time has expired as soon as you use any skill, that's just the way xmlspawner attachment works
You can do a [getatt & see the attachments

I guess some documentation is wrong, I'll have to change that :)
wormsilk is in fooditem.cs
Skillfood & Statfood I didn't include (I'll go over them & add them this weekend)
Hunger Command is in my AutoEat&Drink link in my Sig.

Raw meat types are in Cookablefood
Cooked meats in CustomFood

Oh ya, I see that now!

[getatt is showing the timer as have a 15 minuet count down. the code should be set to 15 seconds. Any idea why?

I just waited 15 mins. The xml attachments do go away. However stats still stay at +. They are not seaming to be removed back to original. I tried using various skill and what not. But they still show up as being there.

public class Muffins : Food
{
[Constructable]
public Muffins() : base( 0x9eb )
{
this.Weight = 1.0;
this.FillFactor = 4;
this.IntBoost = 4;
//this.DexBoost = 5;
this.StrBoost = 4;
this.StatBoostTime = 15;
}
 

datguy

Sorceror
Oh crumb, there is an error in the scripts, seems when you set the clock in statboost duration yourself another variable isn't set.so m_StatBoostDataTime remains 0 meaning no timer :/
Not to worry, on loggoff & login stats & skills will reset to reality even though in [getatt it shows being there (might have to reset it there) because that is only a data tag so the stats/skills won't stack

in food.cs Line# 148
change
Code:
                if (m_StatBoostTime < 1)
                {
                    m_StatBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor time Stats are based on seconds
                    m_StatBoostDataTime = (m_StatBoostTime / 15) * 900;//converting seconds to minutes for same timeframe as m_StatBoostTime
                }

                    if (m_SkillBoostTime < 1)
                    m_SkillBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor timeSkill is based in Minutes in XmlSpawner

to
Code:
                if (m_StatBoostTime < .01)
                {
                    m_StatBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor time Stats are based on seconds
                }
                    m_StatBoostDataTime = (m_StatBoostTime / 15) * 900;//The Data tag timer is based in Minutes but the Stat it's controlling is based in Seconds

                    if (m_SkillBoostTime < .01)
                    m_SkillBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor time XmlSkill is based in Minutes in XmlSpawner
//The Data tag timer is based in Minutes

Now this.StatBoostTime = 15;
should really be
this.StatBoostTime = .25;

Both StatBoost & SkillBoost Timers are be based on Minutes ...
 

Nockar

Sorceror
Oh crumb, there is an error in the scripts, seems when you set the clock in statboost duration yourself another variable isn't set.so m_StatBoostDataTime remains 0 meaning no timer :/
Not to worry, on loggoff & login stats & skills will reset to reality even though in [getatt it shows being there (might have to reset it there) because that is only a data tag so the stats/skills won't stack

Now this.StatBoostTime = 15;
should really be
this.StatBoostTime = .25;

Both StatBoost & SkillBoost Timers are be based on Minutes ...

Made thos changes. Its still setting it to 15 mins.

So in order to make the +stats go away the player has to logoff? Well, i think technically, the +stats are not there, but they show up as being there in the charact stats gump
Do you know of any way to make it auto update?

Thanks for the help!!!

Code:
//XML Boost Mod START
//Boost Checks by Datguy / Morpheus Added Start
//                if (m_StatBoostTime < 1)
//                {
//                    m_StatBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor time Stats are based on seconds
//                    //m_StatBoostDataTime = (m_StatBoostTime / 15) * 900;//converting seconds to minutes for same timeframe as m_StatBoostTime
//                }
//
//                if (m_SkillBoostTime < 1)
//                    m_SkillBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor timeSkill is based in Minutes in XmlSpawner

                if (m_StatBoostTime < .01)
                {
                    m_StatBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor time Stats are based on seconds
                }
                m_StatBoostDataTime = (m_StatBoostTime / 15) * 900;//The Data tag timer is based in Minutes but the Stat it's controlling is based in Seconds

                if (m_SkillBoostTime < .01)
                    m_SkillBoostTime = m_FillFactor * 15;//15 minutes, same as fillfactor time XmlSkill is based in Minutes in XmlSpawner
                            //The Data tag timer is based in Minutes

                if (m_Skill != null)
                {
                    if (XmlAttach.FindAttachment(from, typeof(XmlData), m_Skill) == null)
                    {
                        XmlAttach.AttachTo(from, new XmlData(m_Skill, m_Skill, m_SkillBoostTime));//Set Data to look for next time, XmlData is by minute
                        XmlAttach.AttachTo(from, new XmlSkill(m_Skill, m_Skill, m_SkillBoost, m_SkillBoostTime));//+ Skill, XmlSkill is by the MINUTE

                        from.FixedEffect(0x376A, 9, 32);
                        from.PlaySound(0x1F2);
                    }
                    else
                    {
                        from.SendMessage(521, "You are already under a {0} effect.", m_Skill);
                    }
                }
 

datguy

Sorceror
it's setting it to 15 minutes because
this.StatBoostTime = 15;
is 15 minutes, did you try
this.StatBoostTime = .25;

I just tested & works fine


[Constructable]
public Muffins() : base( 0x9eb )
{
Stackable = false;
this.Weight = 1.0;
this.FillFactor = 4;
this.IntBoost = 4;
//this.DexBoost = 5;
this.StrBoost = 4;
this.StatBoostTime = .25;//in Minutes - Default is long as FillFactor

}

the Stats don't drop on loggoff/on as I thought, however they do on server restart because the Attachments never get saved, or i didn't wait long enough between logon/off
 
Top