Jump to content
  • 0

Add StatsGiven[] to Vital amount (add for HP and MP)????


mem981
 Share

Question

8 answers to this question

Recommended Posts

  • 1
18 minutes ago, mem981 said:

do i need to add StatsGiven[] in this line???

location (intersect.Server/Database/Item.cs)

 public virtual void Set(Item item)
        {
            ItemId = item.ItemId;
            Quantity = item.Quantity;
            BagId = item.BagId;
            Bag = item.Bag;
            for (var i = 0; i < (int) Stats.StatCount; i++)
            {
                StatBuffs[i] = item.StatBuffs[i];
            }           

            //My line----------------------------------

            for (var i = 0; i < (int) Stats.StatCount; i++)
            {
                StatsGiven[i] = item.StatsGiven[i];
            }  

            ///---------------------------
        }

 

no! don't do it

this way is work!

Spoiler

for (var i = 0; i < Options.EquipmentSlots.Count; i++)
            {
                var equipment = Equipment[i];
                if (Equipment[i] >= 0 && Equipment[i] < Options.MaxInvItems && Equipment[i] < Items.Count)
                {
                    if (Items[Equipment[i]].ItemId != Guid.Empty)
                    {
                        var itemx = Items[equipment];
                        var item = ItemBase.Get(Items[Equipment[i]].ItemId);
                        var descriptor = ItemBase.Get(itemx.ItemId);
                        if (item != null)
                        {                                    
                            classVital += 
                                item.VitalsGiven[vital] + 
                                (vital == (int)Vitals.Health ? 
                                (descriptor.StatsGiven[23] + Items[Equipment[i]].StatBuffs[23]) : 
                                (descriptor.StatsGiven[24] + Items[Equipment[i]].StatBuffs[24]))
                                + item.PercentageVitalsGiven[vital] * baseVital / 100;
                        }
                    }
                }
            }

 

Link to comment
Share on other sites

  • 0

The problem is happening because you are adding the stat just after the measure involving the baseVital.

Cut and replicate the whole formula inside the IFs, so you just need to add the item.StatsGiven/StatBuffs after item.VitalsGiven. Remember to keep VitalsPercentage at last.

Hope it helps

Link to comment
Share on other sites

  • 0
45 minutes ago, boasfesta said:

The problem is happening because you are adding the stat just after the measure involving the baseVital.

Cut and replicate the whole formula inside the IFs, so you just need to add the item.StatsGiven/StatBuffs after item.VitalsGiven. Remember to keep VitalsPercentage at last.

Hope it helps

thank u! it's work but how to know [vital] is Health or Mana, i want add StatsGiven[23] for Health and SG[24] for Mana

Spoiler

for (var i = 0; i < Options.EquipmentSlots.Count; i++)
            {
                if (Equipment[i] >= 0 && Equipment[i] < Options.MaxInvItems && Equipment[i] < Items.Count)
                {
                    if (Items[Equipment[i]].ItemId != Guid.Empty)
                    {
                        var item = ItemBase.Get(Items[Equipment[i]].ItemId);
                        if (item != null)
                        {                          
                            classVital += item.VitalsGiven[vital] + Items[Equipment[i]].StatBuffs[23] + item.PercentageVitalsGiven[vital] * baseVital / 100;
                            
                        }
                    }
                }
            }

 

Link to comment
Share on other sites

  • 0
6 minutes ago, mem981 said:

thank u! it's work but how to know [vital] is Health or Mana, i want add StatsGiven[23] for Health and SG[24] for Mana

  Hide contents

for (var i = 0; i < Options.EquipmentSlots.Count; i++)
            {
                if (Equipment[i] >= 0 && Equipment[i] < Options.MaxInvItems && Equipment[i] < Items.Count)
                {
                    if (Items[Equipment[i]].ItemId != Guid.Empty)
                    {
                        var item = ItemBase.Get(Items[Equipment[i]].ItemId);
                        if (item != null)
                        {                          
                            classVital += item.VitalsGiven[vital] + Items[Equipment[i]].StatBuffs[23] + item.PercentageVitalsGiven[vital] * baseVital / 100;
                            
                        }
                    }
                }
            }

 

 

You can just keep the two IFs as you did :)

Not the right way, the best you can do is to create two variables for fixed and percentage values and do the measure at the end, but it would cost more lines.

For an easy way you can use inline conditionals just like that:

classVital += item.VitalsGiven[vital] + (vital == (int)Vitals.Health ? Items[Equipment[i]].StatBuffs[23] : Items[Equipment[i]].StatBuffs[24]) + item.PercentageVitalsGiven[vital] * baseVital / 100;

The conditional (vital == (int)Vitals.Health ? Items[Equipment[i]].StatBuffs[23] : Items[Equipment[i]].StatBuffs[24]) decide which stat use for Health/Mana

Link to comment
Share on other sites

  • 0
10 hours ago, boasfesta said:

 

You can just keep the two IFs as you did :)

Not the right way, the best you can do is to create two variables for fixed and percentage values and do the measure at the end, but it would cost more lines.

For an easy way you can use inline conditionals just like that:

classVital += item.VitalsGiven[vital] + (vital == (int)Vitals.Health ? Items[Equipment[i]].StatBuffs[23] : Items[Equipment[i]].StatBuffs[24]) + item.PercentageVitalsGiven[vital] * baseVital / 100;

The conditional (vital == (int)Vitals.Health ? Items[Equipment[i]].StatBuffs[23] : Items[Equipment[i]].StatBuffs[24]) decide which stat use for Health/Mana

I just realized that Stats Given[23] = 0, but Stats Buff[23] has a value

in inter.sever/database/item.cs I have set

Spoiler

descriptor.StatsGiven[23] += 5000;
descriptor.StatsGiven[24] += 8000;

but StatBuff[23] and [24] has value

Link to comment
Share on other sites

  • 0
18 minutes ago, mem981 said:

I just realized that Stats Given[23] = 0, but Stats Buff[23] has a value

in inter.sever/database/item.cs I have set

  Hide contents

descriptor.StatsGiven[23] += 5000;
descriptor.StatsGiven[24] += 8000;

but StatBuff[23] and [24] has value

 

Maybe its been overwritten by the database i guess? Its hard to know. You need to specify how your system work and what do you expect to do with it.

But, why dont you use VitalsGiven/VitalsPercentage for items by default?

Link to comment
Share on other sites

  • 0
15 minutes ago, boasfesta said:

 

Maybe its been overwritten by the database i guess? Its hard to know. You need to specify how your system work and what do you expect to do with it.

But, why dont you use VitalsGiven/VitalsPercentage for items by default?

i don't know how to make VitalBuff[] and i'm also afraid it will cause error!

Link to comment
Share on other sites

  • 0
5 hours ago, boasfesta said:

 

Maybe its been overwritten by the database i guess? Its hard to know. You need to specify how your system work and what do you expect to do with it.

But, why dont you use VitalsGiven/VitalsPercentage for items by default?

do i need to add StatsGiven[] in this line???

location (intersect.Server/Database/Item.cs)

 public virtual void Set(Item item)
        {
            ItemId = item.ItemId;
            Quantity = item.Quantity;
            BagId = item.BagId;
            Bag = item.Bag;
            for (var i = 0; i < (int) Stats.StatCount; i++)
            {
                StatBuffs[i] = item.StatBuffs[i];
            }           

            //My line----------------------------------

            for (var i = 0; i < (int) Stats.StatCount; i++)
            {
                StatsGiven[i] = item.StatsGiven[i];
            }  

            ///---------------------------
        }

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...