.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Suicidal tendencies of the Botmanīs BOT#1o (http://forums.bots-united.com/showthread.php?t=9934)

MIFUNE 23-03-2014 12:25

Suicidal tendencies of the Botmanīs BOT#1o
 
Hi. First of all I know that this BOT is almost 10 years old, but it works perfectly for my MOD...

http://www.moddb.com/mods/zion-warcry

...except for the fact that they have a serious and stupid suicidal tendencies. I have tried to use the code in the BOTīs source which is used to find walls, but with no luck.

Code:

BOOL CBot::BotChecFloor( void )
{
  Vector v_src, v_up;
  TraceResult tr;

  UTIL_MakeVectors( pev->v_angle );

  // do a trace down...

  v_src = pev->origin;
  v_left = v_src + gpGlobals->v_up * -40;  // 40 units down

  UTIL_TraceLine( v_src, v_left, dont_ignore_monsters, ENT(pev), &tr);

  // check if the trace hit something...
  if (tr.flFraction < 1.0)
  {
      if (f_wall_down = 1)
        f_wall_down = gpGlobals->time;

      return TRUE;
  }

  return FALSE;
}

Itīs the best approach I have found. In the first version BOTs get stuck (2007 version), and now (2014) I have made them walk on the bridges, buuuuuuut... even if they aparently check that thereīs no floor beneath them (they stop and start walking in other direction), they finally return to the void and fall to death.

What should I do?. Any help will be added to the credits. :thumbup:

Thanks in anticipation.

Cheeseh 26-03-2014 15:46

Re: Suicidal tendencies of the Botmanīs BOT#1o
 
Quote:

Originally Posted by MIFUNE (Post 65957)
Hi. First of all I know that this BOT is almost 10 years old, but it works perfectly for my MOD...

http://www.moddb.com/mods/zion-warcry

...except for the fact that they have a serious and stupid suicidal tendencies. I have tried to use the code in the BOTīs source which is used to find walls, but with no luck.

Code:

BOOL CBot::BotChecFloor( void )
{
  Vector v_src, v_up;
  TraceResult tr;

  UTIL_MakeVectors( pev->v_angle );

  // do a trace down...

  v_src = pev->origin;
  v_left = v_src + gpGlobals->v_up * -40;  // 40 units down

  UTIL_TraceLine( v_src, v_left, dont_ignore_monsters, ENT(pev), &tr);

  // check if the trace hit something...
  if (tr.flFraction < 1.0)
  {
      if (f_wall_down = 1)
        f_wall_down = gpGlobals->time;

      return TRUE;
  }

  return FALSE;
}

Itīs the best approach I have found. In the first version BOTs get stuck (2007 version), and now (2014) I have made them walk on the bridges, buuuuuuut... even if they aparently check that thereīs no floor beneath them (they stop and start walking in other direction), they finally return to the void and fall to death.

What should I do?. Any help will be added to the credits. :thumbup:

Thanks in anticipation.

Are you using waypoints? You shouldn't need this is you have waypoints.
This code is either for waypointless navigation or for another reason.

What is done after and before this function is called? How does a bot know when to stop or move forward?

Better waypointless navigation can be foound in RACC bot source or try old RCBot1 source for ideas.

MIFUNE 26-03-2014 17:04

Re: Suicidal tendencies of the Botmanīs BOT#1o
 
Hi!. No, I donīt use waypoints. Bot#10 uses a navigation system without nodes or waypoints. This function is called inside BotThink function, where itīs used to check if thereīs a wall or, in this case, floor with which interact.

In theory, the bot stops its movement if it find a wall in a certain degree based on its line of sight. For the floor, as you can see, Iīm quite lost.:confused:

Aniway, would it be a better approach to make it avoid a dangerous func_x like a trigger_hurt?, I am now studying how to code it (Iīm totally noob at this :sweatdrop: ), but any help will be much appreciated :helpsmilie:

Thanks for replying!!

Cheeseh 01-04-2014 16:21

Re: Suicidal tendencies of the Botmanīs BOT#1o
 
as far as I'm aware botman never implemented any non-waypoint navigation code except for very basic waypointless navigation, unless I'm mistaken.

What PMB and I did for RACC bot and RCBot respectively was to take several tracelines across the bots field of view and choose to go down the path which had the longest distance to any wall. It's a basic technique used in carpet cleaning bots and in webots for example.

From my own understanding, this function that you've shown, doesn't do anything useful for bots to avoid falling.

Imagine this scenario
BotChecFloor() = true : okay move forward
BotChecFloor() = true : okay move forward
BotChecFloor() = true : okay move forward
BotChecFloor() = true : okay move forward
(bot has already fallen off floor now)
BotChecFloor() = false: okay turn or stop
(bot is falling and can't turn or stop)
(bot dies)

as you can see BotChecFloor will return true even if the bot is eventually going to fall, so it's not a useful function for this. you need to check the floor in front of the bot not directly below the bot.

example
Code:

BOOL CBot::BotChecFloor( void )
{
  Vector v_src, v_fwd;
  TraceResult tr;

  v_src = pev->origin;
  v_fwd = pev->velocity;

  v_fwd.z = v_fwd.z - 50.0f;

  UTIL_TraceLine( v_src, v_fwd, dont_ignore_monsters, ENT(pev), &tr);

  // check if the trace hit something...
  if (tr.flFraction < 1.0)
  {
      if (f_wall_down = 1)
        f_wall_down = gpGlobals->time;

      return TRUE;
  }

  return FALSE;
}

this code will do this:

Code:

  O -.
 /|\  `.
  /\      `.______

the previous code did this

Code:

  O
 /|\ 
  /\     
  .
  .
  .
____


MIFUNE 02-04-2014 00:07

Re: Suicidal tendencies of the Botmanīs BOT#1o
 
OMG!, I repeat that I was quite lost in coding, 7 years are much for an already noob to left C++ books on a shelf...:blushing:
Trying to avoid my bots from killing themselves I created a better way to make them die...0_o

Iīl l put your function on my code, and put here the results!! :)

If it works, man, youīll be on the v2.0 credits!! :thumbsup:

EDIT: Tested... unfortunately, they still throw themselves to the void.. Iīll keep trying poking a bit with your code !! :)

Cheeseh 02-04-2014 03:39

Re: Suicidal tendencies of the Botmanīs BOT#1o
 
Sorry there's a bug in the code


Try

Code:

BOOL CBot::BotChecFloor( void )
{
  Vector v_src, v_fwd;
  TraceResult tr;

  v_src = pev->origin;
  v_fwd = pev->velocity;

  v_fwd.z = v_fwd.z - 50.0f;

  UTIL_TraceLine( v_src, v_src + v_fwd, dont_ignore_monsters, ENT(pev), &tr);

  // check if the trace hit something...
  if (tr.flFraction < 1.0)
  {
      if (f_wall_down = 1)
        f_wall_down = gpGlobals->time;

      return TRUE;
  }

  return FALSE;
}

Note it should be v_src + v_fwd in UTIL_TraceLine

Ps:You'll need to show me the decision the bot takes after you call this function

MIFUNE 03-04-2014 21:25

Re: Suicidal tendencies of the Botmanīs BOT#1o
 
Ok!, I have tested and tested yesterday and I finished thinking that I was an absolute moron for not making it work...

The actions that the Bot will do after this function is called are:

1st. Turn (randomly) 45-60 degrees (randomly) to its right or left side
2nd. Pause 1 second
3rd. Start walking again.

If it is engaged in combat it wonīt walk, unless its armor or health (engine) is low, so it will search for a func_reloader (wall mounted health charger. In my mod Iīve gave it a model and some other capabilities). You can see it under the central tower (so I want the bots wonīt fall to the void when they start walking towards the reloaders from the external circle of the dock).

http://media.moddb.com/images/mods/1/7/6540/67216.jpg

Actually Iīm starting from scratch using the old source (bot.cpp and bot_combat.cpp ) all (c) Botman, modified to fit ZWC, because for one reason I cannot understand, the bots make the game crash again (I have probably touched something relative to one pointer or similar :unsure: )

Also Iīm curious on how to make the Bot search team mates and make groups of three, but this is, by now, something impossible to me :blushing:, Iīm now studying HPBpt source and also PODBot source to see how I should do it. :helpsmilie:

Thanks again, Iīll post the testing results as soon as I re-compile the zwc source :thumbsup:


All times are GMT +2. The time now is 17:39.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.