nwnxee / unified

Binaries available under the Releases tab on Github
https://nwnxee.github.io/unified
GNU General Public License v3.0
131 stars 92 forks source link

Missing Get, Set and Modify SavingThrowBonus #120

Closed ELadner closed 6 years ago

ELadner commented 6 years ago

Currently in nwnx_funcs. Get and Set are first class functions.

ModifySavingThrowBonus is NSS based.

/* Gets the base saving throw bonus for nSave for nCreature. */
int GetSavingThrowBonus (object oCreature, int nSave);

/* Sets the base saving throw bonus for nSave to nValue for oCreature. */
int SetSavingThrowBonus (object oCreature, int nSave, int nValue);

/* Modifies oCreature's base saving throw bonus for nSave by nValue. */
int ModifySavingThrowBonus (object oCreature, int nSave, int nValue);

int ModifySavingThrowBonus (object oCreature, int nSave, int nValue) {
    if (nSave < 1 || nSave > 3)
        return -1;

    int nBonus = GetSavingThrowBonus(oCreature, nSave) + nValue;

    if (nBonus < 0)
        nBonus = 0;
    else if (nBonus > 127)
        nBonus = 127;

    return SetSavingThrowBonus(oCreature, nSave, nBonus);
}
mtijanic commented 6 years ago

This can be closed now

mtijanic commented 6 years ago

bugscrub: This is all done and can be closed.