Player Effects

The effects cannot be stacked, and doesn't get queued up, only 1 effect can be applied to the player at one time.

Once a effect is ran, onEffectStart(pl, type) and onEffectEnd(pl, type) is called in player.js scriptclass.

Example, scriptnpc

This example will trigger when a player says either effect slow or any of the other effects listed below.

function onPlayerSays(pl) {
    switch (pl.chat) {
        case "effect slow": {
            // set the player speed to 0.5 times their
            // weapon speed in the duration of 10 seconds
            pl.seteffect(10, "speed", { factor: 0.5 });
            break;
        }
        case "effect fast": {
            pl.seteffect(10, "speed", { factor: 2 });
            break;
        }
        case "effect hurt": {
            // hurts the player with -1 hp during 10 seconds
            pl.seteffect(10, "hurt", { hp: 1 });
            break;
        }
        case "effect heal": {
            // heals the player with +1 hp for 10 seconds
            pl.seteffect(10, "heal", { hp: 1 });
            break;
        }
        case "effect damage": {
            // makes player weapon stronger 
            pl.seteffect(30, "damage", { hp: 10 });
            break;
        }
        case "effect shield": {
            // shields from damage
            pl.seteffect(30, "shield", { hp: 10 });
            break;
        }
        case "effect inverse": {
            // makes the players movement controls reversed
            pl.seteffect(30, "inverse");
            break;
        }
    }
}

Example, player.js

This example will clear the aniarg1 from an additional visual effect bani file, when a effect ends, if anything is set on player.aniargs1. It will also output a message when a effect starts and ends.

function onEffectStart(pl, type) {
    echo("effect starts: " + pl.name + " -> " + type );
}

function onEffectEnd(pl, type) {
    echo("effect ends: " + pl.name + " -> " + type );
    if (pl.aniarg1 && pl.aniarg1.startsWith("effect")) pl.aniarg1 = null;
}

Example, item.effect

Besides calling seteffect, an effect can be applied by configuring the effect in the weapon item and then using the item on a player or NPC. Add in /Config/items/weapon/morningstart.js (or other weapons):

    "effect": {
        "delay": 10,
        "type": "hurt",
        "params": {
            "hp": 20
        }
    }