I would like to change some values of a player's stats through food.
I tried with the Apple.cs script attached and it gives me the error: Cannot assign a value to the 'Server.Mobile.HitsMax' property because it is read-only, while the Hidden state changes regularly.
Could anyone help me?
Thanks
 

Attachments

  • Apple.cs
    1 KB · Views: 8
TY GoldDraco13 but sorry I didn't understand how to use your suggestion and in any case I wish to use the method for both the stat and the player's skills or resistance
I would like to make the cooking activity more interesting
 
Strength is the primary determinant of hit points, but they are not assigned on a one-for-one basis. The formula for calculating hit points is (Strength/2) + 50.

Going by your Apple.cs in order to get a 1000 hitpoints you'd need to set the strength to 475 if ServUO uses the calculation quoted above!

ie:

from.RawStr = 475;
 
Hi GoldDrake13 sorry for my english i trasleate with google
I don't want to change only the player or pet str but I wish I could change all the stats and skills
 
I would do something like this... Not tested, these are just from my own code snippets but this might be useful.

Resistance :
C#:
TimeSpan duration = TimeSpan.FromSeconds( 120 ); //or any calculs

int amount = 10; //or any calculs

ResistanceMod mod1 = new ResistanceMod( ResistanceType.Energy, + amount );

from.SendMessage("Miam Miam!")

from.AddResistanceMod( mod1 );
new ExpireTimer( from, mod1, duration ).Start();

//Removing the mod via timer
private class ExpireTimer : Timer
        {
            private Mobile m_Mobile;
            private ResistanceMod m_Mods;

            public ExpireTimer( Mobile m, ResistanceMod mod, TimeSpan delay ) : base( delay )
            {
                m_Mobile = m;
                m_Mods = mod;
            }

            public void DoExpire()
            {
                m_Mobile.RemoveResistanceMod( m_Mods );

                Stop();
            }

            protected override void OnTick()
            {
                if ( m_Mobile != null )
                {
                    m_Mobile.SendMessage( "The apple magical effect fades away." );
                    DoExpire();
                }
            }

Skills or Stats :
C#:
object[] mods = new object[]
{
new StatMod( StatType.Dex, "AppleDex", 10, TimeSpan.Zero ), //or any timespan you want
new StatMod( StatType.Str, "AppleStr", -10, TimeSpan.Zero ), //or any timespawn you want
new DefaultSkillMod( SkillName.Hiding, true, 10 ), //or any value
new DefaultSkillMod( SkillName.Stealth, true, 10 ), //or any value
};

 m_Table[from] = mods;
from.AddStatMod((StatMod)mods[0]); //str
from.AddStatMod((StatMod)mods[1]); //dex
from.AddSkillMod((SkillMod)mods[2]); //hiding
from.AddSkillMod((SkillMod)mods[3]); //stealth

//Remove
if (m_Table.ContainsKey(m))
{
    object[] mods = m_Table[m];

    if (mods != null)
    {
        m.RemoveStatMod(((StatMod)mods[0]).Name);
        m.RemoveStatMod(((StatMod)mods[1]).Name);
        m.RemoveSkillMod((SkillMod)mods[2]);
        m.RemoveSkillMod((SkillMod)mods[3]);

    }

        m_Table.Remove(m);
 
Hi GoldDrake13
i have do that in attach but don't known value EXP at line 114
can help me?
TYVM
 

Attachments

  • Apple.cs
    6 KB · Views: 2
Try this for line 114, you forgot to point to EXP int carried in by the apple(deed)

Code:
switch (m_Deed.EXP)                      //  here don't known value EXP why??????
Post automatically merged:

I was thinking about this some more and see another problem due to the way you scripted these using other scripts, you never changed things like deed.
-Just mentioning this as it causes issues if you don't rename things to make them make sense!

But the issue is the base Item doesn't have EXP but Apple does and since you only pass the item, the target will not see the EXP from Apple.

Code:
Apple apple = m_Deed as Apple;

switch (apple.EXP)
 
Last edited by a moderator:
Back