void Character::CalculateStats() { ECF_Data *ecf = world->ecf->Get(this->clas); short buffstr = 0, buffint = 0, buffwis = 0, buffagi = 0, buffcon = 0, buffcha = 0; UTIL_FOREACH(this->statbuffs, buff) { buffstr += buff->str; buffint += buff->intl; buffwis += buff->wis; buffagi += buff->agi; buffcon += buff->con; buffcha += buff->cha; } this->adj_str = this->str + ecf->str + buffstr; this->adj_intl = this->intl + ecf->intl + buffint; this->adj_wis = this->wis + ecf->wis + buffwis; this->adj_agi = this->agi + ecf->agi + buffagi; this->adj_con = this->con + ecf->con + buffcon; this->adj_cha = this->cha + ecf->cha + buffcha; this->maxweight = 70; this->weight = 0; this->maxhp = 0; this->maxtp = 0; this->mindam = 0; this->maxdam = 0; this->accuracy = 0; this->evade = 0; this->armor = 0; this->maxsp = 0; UTIL_FOREACH(this->inventory, item) { this->weight += this->world->eif->Get(item.id)->weight * item.amount; if (this->weight >= 250) { break; } } UTIL_FOREACH(this->paperdoll, i) { if (i) { EIF_Data *item = this->world->eif->Get(i); this->weight += item->weight; this->maxhp += item->hp; this->maxtp += item->tp; this->mindam += item->mindam; this->maxdam += item->maxdam; this->accuracy += item->accuracy; this->evade += item->evade; this->armor += item->armor; this->adj_str += item->str; this->adj_intl += item->intl; this->adj_wis += item->wis; this->adj_agi += item->agi; this->adj_con += item->con; this->adj_cha += item->cha; } } if (this->weight < 0 || this->weight > 250) { this->weight = 250; } std::unordered_map<std::string, double> formula_vars; this->FormulaVars(formula_vars); this->maxhp += rpn_eval(rpn_parse(this->world->formulas_config["hp"]), formula_vars); this->maxtp += rpn_eval(rpn_parse(this->world->formulas_config["tp"]), formula_vars); this->maxsp += rpn_eval(rpn_parse(this->world->formulas_config["sp"]), formula_vars); this->maxweight = rpn_eval(rpn_parse(this->world->formulas_config["weight"]), formula_vars); if (this->maxweight < 70 || this->maxweight > 250) { this->maxweight = 250; } if (this->world->config["UseClassFormulas"]) { auto dam = rpn_eval(rpn_parse(this->world->formulas_config["class." + util::to_string(ecf->type) + ".damage"]), formula_vars); this->mindam += dam; this->maxdam += dam; this->armor += rpn_eval(rpn_parse(this->world->formulas_config["class." + util::to_string(ecf->type) + ".defence"]), formula_vars); this->accuracy += rpn_eval(rpn_parse(this->world->formulas_config["class." + util::to_string(ecf->type) + ".accuracy"]), formula_vars); this->evade += rpn_eval(rpn_parse(this->world->formulas_config["class." + util::to_string(ecf->type) + ".evade"]), formula_vars); } else { this->mindam += this->adj_str / 2; this->maxdam += this->adj_str / 2; this->accuracy += this->adj_agi / 2; this->evade += this->adj_agi / 2; this->armor += this->adj_con / 2; } if (this->mindam == 0 || !this->world->config["BaseDamageAtZero"]) this->mindam += int(this->world->config["BaseMinDamage"]); if (this->maxdam == 0 || !this->world->config["BaseDamageAtZero"]) this->maxdam += int(this->world->config["BaseMaxDamage"]); if (this->party) { this->party->UpdateHP(this); } }