Without having to use an unrelated BaseClass like MagicalFood.cs or Spells.cs….
Below I have assigned the buffs I need for each item at random on doubleclick. What I would like is the ability to have those buffs reverted to their original state on the player who used the item after a duration. I know very little about how timers work and so I was wondering if someone could help me out here if possible.

Double Click An Item And Gain A Stat Buff:
            else if (pm is PlayerMobile)
            {             
                switch (Utility.Random(4))
                {
                    case 3:
                        {
                            int strBonus4 = (int)((double)pm.Str * 1.00);
                            pm.Str = pm.Str + strBonus4;
        
                            int dexBonus4 = (int)((double)pm.Dex * 0.25);
                            pm.Dex = pm.Dex + dexBonus4;
        
                            break;
                        }
                    case 2:
                        {
                            int strBonus3 = (int)((double)pm.Str * 0.75);
                            pm.Str = pm.Str + strBonus3;
        
                            break;
                        }
                    case 1:
                        {
                            int strBonus2 = (int)((double)pm.Str * 0.50);
                            pm.Str = pm.Str + strBonus2;
        
                            break;
                        }
                    case 0:
                        {
                            int strBonus1 = (int)((double)pm.Str * 0.25);
                            pm.Str = pm.Str + strBonus1;
        
                            break;
                        }
                }
 
Thanks Voxpire...
I just figured out how to utilize the AddStatMod(….)

So I have this code now:

3:
Timer.DelayCall(TimeSpan.FromSeconds(0), delegate
{
     pm.AddStatMod(new StatMod(StatType.Str, "str", (int)((double)pm.Str * (0.20)), timerHasExpired));
});

I have been researching Cliloc and looking for examples without any luck, I was wondering if anyone knows how we can use custom strings in place of the clilocs within this line:

C#:
 BuffInfo.AddBuff(pm, new BuffInfo(BuffIcon.Strength, 1027996, 1027996, TimeSpan.FromSeconds(6.5), pm)); // 1027996 = Strength

As you can see I found the cliloc for strength, but it really doesn't fit what I think should be there. Any ideas? Maybe an example of how to?

The line in question uses this code in BuffIcons.cs:

C#:
        public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m)
            : this(iconID, titleCliloc, secondaryCliloc)
        {
            m_TimeLength = length;
            m_TimeStart = DateTime.UtcNow;

            m_Timer = Timer.DelayCall(length, new TimerCallback(
                delegate
                {
                    PlayerMobile pm = m as PlayerMobile;

                    if (pm == null)
                        return;

                    pm.RemoveBuff(this);
                }));
        }
 
You don't need to "remove" stat buffs. They naturally go away at the end of the timer. Have you looked at how bless handles it?

Yes I noticed, actually the "no love comment" had to do with my second question which was how can I replace the clilocs with strings. I keep running into: cannot implicitly convert int to string. Which is driving me nutty by the way LOL.

I wanted to do this so that I can manually type in descriptions for the buffs.
 
It will take some doing but if you can change the variable type being used for the buff's cliloc entry to TextDefinition it should have the results you're looking for.

The magic of that variable type is that it will accept cliloc numbers or a text string automatically, meaning that scripts you don't want to change can stay as they are.
 
Are you just trying to write new descriptions for an otherwise stock strength buff?

Because of the way buffs and buff icons work, you will need to use different buff icons if you intend to make buffs that are just iterations of stock stuff.

Say you put your custom str buff on a rock players can click. A mage comes long and casts Strength on that player, but the mage has only like... 20 skill. Their low duration Strength will override the buff icon and description. It will also not stack, due to the way stat buffs work, the greatest buff takes priority.

You can create stacking stat buffs by using AoS properties. But you still run into a wall against the buff icons.
 
@Anon the Felon

The buff icons were just an added bonus on what I have done with the project I am working on.

I am wanting to get rid of the description because it is default for something else. I wanted to use the strength bufficon, but it says the bonus is higher than it really is and this shouldn’t read like that.

My idea was to get it to read a more accurate description. As for stacking - I wasn’t aware either way and this is something I am going to have to look into once I have this script done.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back