.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
The f____ shield. How to get bots to deal with it?
Old
  (#1)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default The f____ shield. How to get bots to deal with it? - 20-01-2004

I've been trying to get bots to successfully attack a player with a shield. I've used the animation sequence to detect if a player has the shield active or inactive, this seems to work fine:

Code:
if ( ptrTarget->v.weaponanim == 5 || ptrTarget->v.weaponanim == 6 ) 
{
	 // shield is active
}
else
{
	 // shield is not active
}
Now what I need is to detect if a bot can hit the player behind an activated shield or not. For example, if the bot is behind the target player, then it can hit the player even when the players shield is active. The same can be done from the side, or various angles from above and below (but let's forget about the 3rd dimension for now).

I've thought of some methods to decide if a bot can hit the player or not, but none of them are as good as I want. The best solution is probably to somehow calculate if the target player is facing an angle relative to the targeting bot that leaves the target exposed. I've almost completely forgotten my linear algebra so I have no idea how to calculate this, although it should be a simple calculation.

Imagine we look at the origin of targeting bot (B) and the target player with shield (T).

In two dimensional space (x,y) we can draw a line (L1) between origin B and origin T. We can also draw a line (L2) from where the bot is facing to some point forward of the bot (just imagine a short line pointing forward out from where the bot is facing). Now we can draw another line (L3) from origin B to the end point of line L2. This will form a closed triangle and we're interested in computing the angle inside the triangle located at origin T. If the angle is 0 (degrees) then the target cannot be hit (directly facing B), if the angle is 90 then the target's side is exposed, and if the the angle is 180 then the target's back is fully exposed and can be hit.

So anyone know of how I can compute this?


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#2)
Onno Kreuzinger
aka: memed / Server Admin
 
Onno Kreuzinger's Avatar
 
Status: Offline
Posts: 705
Join Date: Jan 2004
Location: germany
Default Re: The f____ shield. How to get bots to deal with it? - 20-01-2004

Hi,

well just a thought, but wouldn't it be more human like if the bot would first fire some shots (hitting if not in front) and then a slow sequence of shots aimed well, with some longer pauses pretending reload (this is how i deal with shields). Also some of the advantage of shields gets lost if bots would behave too perfect.

/edit
uhm the advantage: it sounds like less computing
edit/

Cheers Memed

Last edited by Onno Kreuzinger; 20-01-2004 at 22:00..
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#3)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: The f____ shield. How to get bots to deal with it? - 20-01-2004

maybe if you can detect somehow that the shield is not blocking a body part and have the bot shoot at that spot?
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#4)
Bert
Member
 
Status: Offline
Posts: 11
Join Date: Jan 2004
Default Re: The f____ shield. How to get bots to deal with it? - 20-01-2004

You could solve this with the cosine rule (or whatever it's called in english (translating from dutch here)).


if you got the following situation:


then:

L2²=L1²+L3²-2*L1*L2*cos(a)

You can get cos(a) from that, so use arccos(L2²-etc. etc.) to get a.
[edit]

You could probably keep some sort of cosine table, so you can do rough estimates instead of calculating that arccos everytime

[/edit]

Last edited by Bert; 20-01-2004 at 22:40..
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: The f____ shield. How to get bots to deal with it? - 20-01-2004

why so complicated, guys ?
Code:
// is enemy looking at more than 90° aside of the bot's forward direction ?
if (fabs (WrapAngle (pEnemyEdict->v.v_angle.y - pBotEdict->v.v_angle.y)) > 90)
{
   // yes, it is (meaning, bot sees the back of its enemy)
}
else
{
   // no, it is not (enemy is facing the bot)
}



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 20-01-2004 at 22:49..
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#6)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: The f____ shield. How to get bots to deal with it? - 21-01-2004

Quote:
Originally Posted by Pierre-Marie Baty
why so complicated, guys ?
Code:
// is enemy looking at more than 90° aside of the bot's forward direction ?
if (fabs (WrapAngle (pEnemyEdict->v.v_angle.y - pBotEdict->v.v_angle.y)) > 90)
{
// yes, it is (meaning, bot sees the back of its enemy)
}
else
{
// no, it is not (enemy is facing the bot)
}
Why so complicated? Well, in my case I simply don't know what some of the the v.(whatever) values represent.

For the above example, what does v.v_angle.y represent?

v_angle; // Viewing angle (player only)

Is this the vector describing the direction a player is looking? That's my guess based on the comment. Is there a document somewhere describing what these values are?

I'm not completely clueless. I did take (and pass) a linear algerbra course which covered everything about vectors, but that was years ago, and I've forgotten almost all of it, fortunately I saved the book and I've dusted it off as my reference. I think I just need a few pointers to get me going in the right direction.


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#7)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: The f____ shield. How to get bots to deal with it? - 21-01-2004

Everything that has "angles" in its name is a variable which describes NOT a location, but an angle. The Vector type mostly serves as a placeholder. The X Y and Z parts are used this way :

X : stores the PITCH (vertical looking angle) of a model
Y : stores the YAW (horizontal looking angle) of a model
Z : stores the ROLL (i.e, how much the model is "bent" relatively to the vertical axis - DO NOT USE THIS)

Player and monster models distinguish the BODY angles (pEdict->v.angles) and the VIEW angles (pEdict->v.v_angle). The body angles determine where the model's body is facing, while the view angles determine where the model's head is LOOKING. A player's view point is ALWAYS relative to his v_angle (view angle). By knowing the origin, eye position and view angle of a player you can tell EXACTLY what is the player's point of view in the game at some instant t.

[edit] I thought you already used the angles a lot when you implemented the bot aiming thingy in the mEAn mod ? Anyway, if you are curious to see what the pEdict->v. things are for, make an entvars dump of an entity in the game using my PMTools plugin and look at the results. I *always* have this plugin runnning, I can't develop anything without. Or make your own similar plugin, at your choice...



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 21-01-2004 at 01:33..
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#8)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: The f____ shield. How to get bots to deal with it? - 21-01-2004

Thanks again PMB for the help I'll give you pmtools plugin a try, it should help a lot.

Quote:
I thought you already used the angles a lot when you implemented the bot aiming thingy in the mEAn mod ?
Well I know some of what's going on, just not all of it. I managed to make up a bot aiming system by looking at examples from the SDK, botmans template and your botaim plugin. Even without a deep understanding of everything I still managed to get it to work quite well. As I gain more understanding I'll be able to do a whole lot more.


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#9)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: The f____ shield. How to get bots to deal with it? - 21-01-2004

but they don't have to be 90 degrees to be able to hit the person sometimes you can hit the person even when he has shield up and is facing slightly towards you
  
Reply With Quote
Re: The f____ shield. How to get bots to deal with it?
Old
  (#10)
A$$A$$IN
Guest
 
Status:
Posts: n/a
Default Re: The f____ shield. How to get bots to deal with it? - 21-01-2004

Quote:
Originally Posted by Pierre-Marie Baty
why so complicated, guys ?
Code:
// is enemy looking at more than 90° aside of the bot's forward direction ?
if (fabs (WrapAngle (pEnemyEdict->v.v_angle.y - pBotEdict->v.v_angle.y)) > 90)
{
// yes, it is (meaning, bot sees the back of its enemy)
}
else
{
// no, it is not (enemy is facing the bot)
}
2 minor bugs with this approach:

1. The shield protection yaw angle is closer to 120 degrees than 180 so you would probably get better results using 60 instead of 90 in the code above.

2. If the enemy with the shield is not crouched, you can shoot at his feet and take him out that way. So a better algorithm would be something like this:

If enemy is facing within 60 degrees of directly at you then
CircleBehindEnemy

If EnemyIsNotCrouched then
ShootAtEnemy'sFeetWhileCirclingBehindHim
EndIf

Else

BlastTheBastardsFaceOff

EndIf
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com