EOSERV Forum > EOSERV > Trainer reset, stats reallocation issue.
Page: << 1 >>
Trainer reset, stats reallocation issue.
Author Message
Post #203061 Trainer reset, stats reallocation issue.

Hi all,

I'm having an issue whereby when I use the Trainer type NPC to reset my characters stats, it is not reallocating stats that have been assigned via quest scripts.

For example, I have a quest script that allows a player to increase a chosen stat type each day, the problem then being that if they choose to reset their allocated stat points, these points disappear.

I guess the reset uses the characters level + stats per level setting and determines the correct amount of stats due per level?

Is there a way to make it instead calculate the total stats a player has allocated, and return this amount to the player to reallocate?

---
Host of a blacklisted server...
7 years, 4 weeks ago
Post #203062 Re: Trainer reset, stats reallocation issue.

Resets use a points = x * level method to compute. The easiest fix is to add a new character attribute for extra stat points and have the quest dump points there. Likewise the Reset formula will be points = (x * level) + extra stats. Also, make sure to save this new character attribute in your database. 

7 years, 4 weeks ago
Post #203064 Re: Trainer reset, stats reallocation issue.

This should just add up all the stats the player has and reset the stats to 0;

void Character::Reset()

{

    int tsp = 0; //total stat points;

    int tss = 0; //total spell stats;


    tsp += this->str;

    tsp += this->intl;

    tsp += this->wis;

    tsp += this->agi;

    tsp += this->con;

    tsp += this->cha;


    this->spells.clear();

    this->CancelSpell();

    UTIL_FOREACH(this->spells, spell)

    {

        tss+= spell.level;

spell.level = 0;

    }

this->str = 0;

this->intl = 0;

this->wis = 0;

this->agi = 0;

this->con = 0;

this->cha = 0;

    this->statpoints = tsp;

    this->skillpoints = tss;

   this->CalculateStats();

}

Haven't tested this tho so might need changing^^

7 years, 4 weeks ago
Post #203065 Re: Trainer reset, stats reallocation issue.

Great, thank you both for the solutions!


On compile, throwing an error here -

spell.level = 0;

error: assignment of member 'Character_Spell::level' in read-only object

---
Host of a blacklisted server...
7 years, 4 weeks ago
Post #203066 Re: Trainer reset, stats reallocation issue.

Callum's method does not take into account you may want to alter stats per level someday and players could reset for a stat adjustment. Furthermore, it is probably best to fix the stats at level up to adjust without reset should you really screw around with stats during the course of your server's life. I posted a feature request in the bug tracker which will probably never get added officially, but it is an easy fix.

7 years, 4 weeks ago
Post #203067 Re: Trainer reset, stats reallocation issue.
sob posted: (29th Mar 2017, 05:45 pm)

Great, thank you both for the solutions!


On compile, throwing an error here -

spell.level = 0;

error: assignment of member 'Character_Spell::level' in read-only object


Here you go mate, just change the UTIL_FOREACH loop to this:

UTIL_IFOREACH(this->spells, spell)

    {

        tss+= spell->level;

        spell->level = 0;

    }


Probably might be a good idea to store a separate value counting any extra stats gained though.

7 years, 4 weeks ago
Post #203070 Re: Trainer reset, stats reallocation issue.
callum posted: (30th Mar 2017, 12:03 am)

sob posted: (29th Mar 2017, 05:45 pm)

Great, thank you both for the solutions!


On compile, throwing an error here -

spell.level = 0;

error: assignment of member 'Character_Spell::level' in read-only object


Here you go mate, just change the UTIL_FOREACH loop to this:

UTIL_IFOREACH(this->spells, spell)

    {

        tss+= spell->level;

        spell->level = 0;

    }


Probably might be a good idea to store a separate value counting any extra stats gained though.


Great, thank you very much, again.
---
Host of a blacklisted server...
7 years, 4 weeks ago
Page: << 1 >>

EOSERV Forum > EOSERV > Trainer reset, stats reallocation issue.