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.

Can I make the bots wander around the map?

Share questions and tutorials related to the map editor. Share you maps in the Superfighters Deluxe Custom Maps section.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Ol1vver
Fighter
Fighter
Posts: 41
Joined: Mon Nov 19, 2018 4:55 pm
SFD Alias: Ol1vver
Started SFD: PreAlpha 1.6
Gender:

Can I make the bots wander around the map?

Post by Ol1vver » Fri Aug 23, 2019 10:55 pm

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
Why are you reading my signature?

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 495
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 21

Post by JakSparro98 » Sat Aug 24, 2019 11:37 am

Ol1vver wrote:
Fri Aug 23, 2019 10:55 pm
I am making a map, and I need to make the bots wander around the map randomly without doing anything else. Is that possible?
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

User avatar
Ol1vver
Fighter
Fighter
Posts: 41
Joined: Mon Nov 19, 2018 4:55 pm
SFD Alias: Ol1vver
Started SFD: PreAlpha 1.6
Gender:

Post by Ol1vver » Sat Aug 24, 2019 4:14 pm

JakSparro98 wrote:
Sat Aug 24, 2019 11:37 am
Ol1vver wrote:
Fri Aug 23, 2019 10:55 pm
I am making a map, and I need to make the bots wander around the map randomly without doing anything else. Is that possible?
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.
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.)
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());
		}
	}
}
Here's the real problem I am experiencing: in the main map I am making, the bots would just not even try to get to their path, which is really annoying. I am currently trying to figure out how to fix that.
0 x
Why are you reading my signature?

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1676
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 29

Post by Gurt » Sat Aug 24, 2019 7:25 pm

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

Post Reply