Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

How to change PlayerModifierInfo using a certain difficulty

Share questions, scripts and tutorials related to the ScriptAPI in SFD.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
dsafxP
Meatbag
Posts: 9
Joined: Fri May 08, 2020 5:16 am
SFD Account: dsafxP
SFD Alias: dsafxP
Started SFD: 2020
Location: Argentina
Gender:

How to change PlayerModifierInfo using a certain difficulty

Post by dsafxP » Fri May 29, 2020 1:25 am

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.
0 x
Who's gonna clean this mess?

User avatar
Odex64
Superfighter
Superfighter
Posts: 173
Joined: Sat Jul 29, 2017 12:39 pm
Title: Content Creator
SFD Account: Odex64
Started SFD: PreAlpha
Location: Italy
Gender:
Age: 22

Post by Odex64 » Fri May 29, 2020 1:15 pm

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.
0 x
Image

Post Reply