Skill Changer

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Skill Changer

Post by Hey Doomer »

Skills are hard coded in MAPINFO. As suggested on the Wiki, a skill level can be changed for the next level, but what if that used a running health mean instead of a spot check at the end? It's probably already been done, but this is my take.


Code: Select all

// skill parameters
user int sk_low = 0;
user int sk_high = 8;
user int sk_sample = 25;
user int sk_lowmean = 30;
user int sk_himean = 85;
user int sk_interval = 10;
user int sk_freq = 3;

// debug
user bool sk_debug = false;

Code: Select all

script "skills" ENTER
    // cvars
    int sk_low = GetCVar("sk_low");
    int sk_high = GetCVar("sk_high");
    int sk_sample = GetCVar("sk_sample");
    int sk_lowmean = GetCVar("sk_lowmean");
    int sk_himean = GetCVar("sk_himean");
    int sk_interval = GetCVar("sk_interval");
    int sk_freq = GetCVar("sk_freq");

    int health = GetActorProperty(0, APROP_Health);
    int basehealth = health;
    int lasthealth = health;
    int mean = health;
    int skill = GameSkill();
    int skilltime = sk_interval;
    int n = 1;

    Print(s:"Game skill is ", d:skill);

        lasthealth = health;
        health = GetActorProperty(0, APROP_Health);

        if (health <= 0)
            break; // you are dead
        if (health < basehealth)
            health = GetActorProperty(0, APROP_Health);
            mean = (mean * n + health) / ++n;
            Log(s:"Your mean health is: ", d:mean);
            if (n == sk_sample)
                n = 1;
            skill = GameSkill();
            if (mean < sk_lowmean && skill > sk_low && skilltime < 1)
                Print(s:"Next game skill lowered to ", d:skill);
                skilltime = sk_interval;
            if (mean > sk_himean && skill < sk_high && skilltime < 1)
                Print(s:"Next game skill raised to ", d:skill);
                skilltime = sk_interval;
        delay(35 * sk_freq);
This only takes into account health as a running mean that changes according to sample size. Nothing fancy, but it means the levels aren't constantly jumping up and down. I've included extra skill levels in MAPINFO, also nothing fancy. I don't see number of skill levels exposed in ACS or ZScript, so this should crash if sk_high is too high. Default settings work OK for me but can be tweaked to make the mean more or less volatile. Unfortunately skill level only changes for the next level. Ah well. It's connected to actor placement, so I get that.

Originally I combined this for myself with concepts in "Speed," which provides some balance. This gives some granular control over skill levels and should be universal.

Update 11/24/21

Return to “Script Library”