Page 1 of 1

How to change PlayerModifierInfo using a certain difficulty

Posted: Fri May 29, 2020 1:25 am
by dsafxP
So, I'm doing a campaign and i'm trying to do a script that changes a PlayerModifierInfo when you use a certain difficulty, is there any guides to do this? there are many and i'm not able to find a guide that explains how to do this. Thanks in advance.

Re: How to change PlayerModifierInfo using a certain difficulty

Posted: Fri May 29, 2020 1:15 pm
by Odex64
It's pretty easy changing Bots' modifiers depending on the campaign difficulty. Here's the script:

Code: Select all

public void SetModifiers(string id, string modifier)
{
    foreach(IObjectPlayerSpawnTrigger bot in Game.GetObjectsByCustomId(id))
    	bot.SetModifierInfo((IObjectPlayerModifierInfo) Game.GetSingleObjectByCustomId(modifier));
}

public void OnStartup()
{
    switch (Game.CurrentDifficulty.ToString())
    {
        case "0,25": //EASY
            SetModifiers("thebot", "easy");
            break;

        case "0,5": //NORMAL
            SetModifiers("thebot", "normal");
            break;

        case "0,75": //HARD
            SetModifiers("thebot", "hard");
            break;

        case "1": //EXPERT
            SetModifiers("thebot", "expert");
            break;
    }
}
As you can see each number represents the campaign difficulty. You just have to paste this script in your map and assign each Bot/ModifierInfo a customID (remember to use different IDs for bots & modifiers); Then you have to write SetModifiers(); and type inside the brackets the Bot's CustomID and the Modifier's ID.

You can also add extra IDs for Special bots, ex:

Code: Select all

case "1": //EXPERT
    SetModifiers("thebot", "expert");
    SetModifiers("Boss", "specialExpert");
    break;
I think that's all. Good luck with your map.