Skill Changer

Post your example zscripts/ACS scripts/etc here.

Skill Changer

Postby Hey Doomer » Sat Nov 20, 2021 5:17 am

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.

CVars:
Code: Select allExpand view
// 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;


ACS:
Code: Select allExpand view
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);

    while(true)
    {
        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)
            {
                skill--;
                ChangeSkill(skill);
                Print(s:"Next game skill lowered to ", d:skill);
                skilltime = sk_interval;
            }
            if (mean > sk_himean && skill < sk_high && skilltime < 1)
            {
                skill++;
                ChangeSkill(skill);
                Print(s:"Next game skill raised to ", d:skill);
                skilltime = sk_interval;
            }
            skilltime--;
        }
        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
Spoiler:
You do not have the required permissions to view the files attached to this post.
Hey Doomer
 
Joined: 25 Sep 2021
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests