This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk
Forum rules
Forum rules
Can I make the bots wander around the map?
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
- Ol1vver
- Superfighter

- Posts: 69
- Joined: Mon Nov 19, 2018 4:55 pm
- SFD Account: olv
- SFD Alias: olv
- Started SFD: PreAlpha 1.6.4
- Gender:
Can I make the bots wander around the map?
I am making a map, and I need to make the bots wander around the map randomly without doing anything else. Is that possible?
0 x
- JakSparro98
- Superfighter

- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 27
An idea could be to randomly select a nodepath and make it the bot's guard target, he will run towards the node and after some time the action repeats again.
0 x
- Ol1vver
- Superfighter

- Posts: 69
- Joined: Mon Nov 19, 2018 4:55 pm
- SFD Account: olv
- SFD Alias: olv
- Started SFD: PreAlpha 1.6.4
- Gender:
So what I did is, OnStartup foreach() all of the PathNodes and put them in a list. After that, get the player I want and do "player.SetGuardTarget(PathNodeList[new Random().Next(PathNodeList.Count)]);". It didn't work like I wanted it to. The bot would sometimes stop halfway through, follow the player for a bit or look at the player. (I realized that's normal because I am working with GuardTarget.)JakSparro98 wrote: ↑Sat Aug 24, 2019 11:37 amAn idea could be to randomly select a nodepath and make it the bot's guard target, he will run towards the node and after some time the action repeats again.
The bot's Predefined AI is BotA, and it's input is enabled.
Here's the code in my test map:
Code: Select all
List<IObjectPathNode> PathNodeList = new List<IObjectPathNode>();
public void OnStartup()
{
foreach(IObjectPathNode PathNode in Game.GetObjectsByName("PathNode"))
{
PathNodeList.Add(PathNode);
}
}
public void NewRoute(TriggerArgs a)
{
foreach(IPlayer player in Game.GetPlayers())
{
if(player.IsBot)
{
BotBehaviorSet Passive = new BotBehaviorSet();
Passive.SearchForItems = false;
Passive.EliminateEnemies = false;
player.SetBotBehaviorSet(Passive);
player.SetGuardTarget(PathNodeList[new Random().Next(PathNodeList.Count)]);
if(Game.GetSingleObjectByCustomID("tempdraw")!=null){Game.GetSingleObjectByCustomID("tempdraw").Remove();}
IObject o=Game.CreateObject("BgWall00B");
o.CustomID="tempdraw";
o.SetWorldPosition(player.GetGuardTarget().GetWorldPosition());
}
}
}
0 x
- Gurt
- Lead Programmer

- Posts: 1887
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 36
You also want to set the GuardRange and ChaseRange to something like 24 (as long as it's not 0) to allow the bot to walk to the guard target or I think they will ignore it as they don't have a range.
0 x
Gurt