Recent changes Random page
GAMING
Gaming
 
WoWWiki
Halopedia
FFXIclopedia
Age of Conan
Warhammer Online
Grand Theft Wiki
See more...

Pseudo-Normally distributed ability scores

From NWNWiki

Jump to: navigation, search

[edit] Pseudo-Normally Distributed Ability Scores

[edit] What it does

I was implementing the script Rolled Attributes for Creatures by The Great Slayer of Gelatinous Cubes and cleaned it up for my world. Here is the cleaned up version, which is placed in nw_c2_default9 (the default spawn script). It generates pseudo-normally distributed ability scores ranging from 50% to 150% of the base ability score. I may add a wrapper around this code to check the tag of the spawned creature for a specific switch to bypass rolling random ability scores.

[edit] The Script

/*  based on Rolled Attributes for Creatures by The Great Slayer of Gelatinous Cubes
    ::generates pseudo-normally distributed ability scores ranging from 50% to
    150% of the base ability score.
*/
    int iAbility, iAbilityScore, iModifier; effect eModifier;
    for (iAbility=0; iAbility<6; iAbility++) {
        iAbilityScore = GetAbilityScore(OBJECT_SELF, iAbility);
        if (iAbilityScore > 3) {
            iModifier = FloatToInt(IntToFloat(iAbilityScore) * IntToFloat(d20(5) + 45) / 100.0f) + 1 - iAbilityScore; // normal bell curve from 50%-145%
            if (iModifier >= 0) { eModifier = EffectAbilityIncrease(iAbility, iModifier); }
            else { eModifier = EffectAbilityDecrease(iAbility, abs(iModifier)); }
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, eModifier, OBJECT_SELF);
        }
    }
Rate this article:
Share this article: