• Advertisement
Sign in to follow this  

Rules of Combat

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm currently adding AI support to my game, and altough everything is working fine, i would like a more accurate way to deal at the rules i give the bots to fire at the player. Bots have a timing to fire at the player, this timing i have it done like this : if(Bot.shoot_time >= 30) { AI_Shoot(&Bot,PlayerPos); Bot.shoot_time = 0; } else Bot.shoot_time += 1*Frame.speedfactor; And to make sure, bots don't allways hit the player when they shoot , i do this : int do_i_hit = rand()%100; if(Bot.position == SHOOT_DUCK) dice = 40; if(Bot.position == SHOOT_STAND) dice = 60; if(Bot.position == SHOOT_WALK) dice = 70; if(do_i_hit >=dice) { hit=1; } Has expected this system doens't work very well. Has anyone implemented something like this ? I would love to see some other ideias, i'm pretty sure this way sucks. thanks, Bruno

Share this post


Link to post
Share on other sites
Advertisement
What kind of game is it?

The code you've posted will work but it will be very regular and not very 'AI' if you know what I mean! I guess this is the problem - but without knowing more about the game itself it's hard to answer the question...

Oh, and a little hint - you don't need to multiply the 'Frame.speedfactor' variable by 1, because anything multiplied by 1 will simply return itself. In other words, it's a redundant multiplication, I'm not sure if the compiler would pick that up though... so it's probably best to remove it yourself!

Here are some suggestions for improving the shooting (although this is a general list really...):

1. Implement some kind of line of site for your bots. In other words, if they don't see you, they don't shoot.

2. Have the *weapons* timed, rather than the bots themselves. In other words, a rocket launcher may only be able to be fired once every couple of seconds, whereas a machine gun will fire 20 rounds a sec.

3. If a bot is being fired upon, have it react. How you do this is up to you - simplest is either fire or run. If the health of the bot is below a certain level, it could run, otherwise it fires back.

I don't know if any of this will help, but it might at least get you started... good luck!

Share this post


Link to post
Share on other sites
It's a tactical fps shooter.,

I already have line of sight working, if they spot us while in their patrol root they either duck, or shoot, if we hide while they are shooting they come and check for us in the last position they saw us, etc , it's just this shooting that i don't like.

point 2 is a good tip :)

thanks m8

Share this post


Link to post
Share on other sites
If it's tactical, why not consider giving weapons a range as well as a time to reload. In other words, the enemy bot might see you from a distance, but maybe he is using a pistol and needs to close the gap first (get him to use cover). If there is no cover, maybe he could call for backup from a unit which has a better ranged weapon.

It also works the other way - the bots wouldn't throw a grenade if they're standing right next to you, or fire a rocket either for that matter!

Hope this helps...

Share this post


Link to post
Share on other sites
A bit like what PhatDom said, have almost everything data driven. This way, it will be easier for you to tweak your gameplay.

You should consider having min/max distances for each of your weapon, optionnaly you could have an optimal min/max distance to help your bot pick the best weapon to handle a situation where he meets an enemy. Say, if a shotgun can fire from 0 to 20 meters, it would still be more optimal to use it from 0 to 5 meters...

We also assign our bots an accuracy from 0 to 1, and each weapon also contains a min/max accuracy from 0 to 1 and a bonus factor when the bot aims. With a spreading angle (stored in the weapon), you can "randomize" (using the accuracy calculed from the bot's accuracy and the weapon's accuracy) the firing vector.

I'm not sure if your game is 2D or not, but still, our "hit detection" is done by a ray intersect check from the weapon, using the firing vector and a balistic mesh on the target. This way you'll get some pretty realistic results.

As PhatDom said, it is very important to store in your weapon the firing rate, reload time (this can be controlled by an animation), weapon damage, and the other parameters I mentionned earlier...

To get more realistic results you should add reation time to your bots, but that might be also managed by your "stimulis" system.

I hope this helps :)

Cheers

Eric

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement