.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Hi, thanks and help! (http://forums.bots-united.com/showthread.php?t=4167)

mfrx 30-06-2005 20:49

Hi, thanks and help!
 
First hi all!

Im attempting to make a bot for DMC so thanks to everyone bc ive got a bot in the game that moves and shoots :D

Now for the help bit ;)

I need to find out when a weapon is actually fired. Im pretty sure that Im doing something n00b bc Im catching the gFunctionTable.pfnGetWeaponData function which fires np so i know which player it is but the values in the weapon_data_s struct are always 0.

Im using the sdk from this site with metamod.

Am I on the right track? Any suggestions?

O and thx to Rick - I had a look through the RCBot code but couldnt find anything :(

Cheers

The Storm 30-06-2005 21:31

Re: Hi, thanks and help!
 
I can't understand what do you mean... Maybe you try to say that you don't know how ammo remain in the weapon ? If is that you need to export a message. In EPB I use this one
Code:

// This message is sent whenever ammo ammounts are adjusted (up or down).
// NOTE: Logging reveals that CS uses it very unreliable !
void BotClient_CS_AmmoX(void *p, int bot_index)
{
  static int index;
  static int ammount;
  int ammo_index;

  bot_t *pBot = &bots[bot_index];

  if (state == 0) {
          index = *(int *) p;          // ammo index (for type of ammo)
  } else if (state == 1) {
          ammount = *(int *) p;        // the ammount of ammo currently available

          pBot->m_rgAmmo[index] = ammount;  // store it away
          if (pBot->current_weapon.iId > CS_WEAPON_INSWITCH) {
                ammo_index = pBot->current_weapon.iId;

#ifdef _DEBUG
                report_log(LOG_MESSAGE, "BotClient_CS_AmmoX",
                                    "Botname=%s iId=%d Amount=%d", pBot->name, ammo_index,
                                        ammount);
#endif

                // update the ammo counts for this weapon...
                pBot->current_weapon.iAmmo1 =
                        pBot->m_rgAmmo[weapon_defs[ammo_index].iAmmo1];
                pBot->current_weapon.iAmmo2 =
                        pBot->m_rgAmmo[weapon_defs[ammo_index].iAmmo2];
          }

  }
  state++;
}

I hope that I help. :)

mfrx 30-06-2005 22:05

Re: Hi, thanks and help!
 
Sorry, I should have been clearer.

First; the reason I need this is because I am trying to make the bots rocket jump (look down, jump and fire a rocket).

The problem is that a player may only fire a rocket once every 0.8 seconds (approx) so if I need to call the rocket jump function just before it is possible to fire again otherwise the bot may end up looking at the ground for 0.79 seconds ;)

So I need to store the time that they last fired a weapon.

I have tried:
Code:


int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
{
char msg[200];
sprintf(msg, "ID: %d, Idle: %.2f, State: %d, Clip: %d", info->m_iId, info->m_flTimeWeaponIdle, info->m_iWeaponState, info->m_iClip);
clsUtil.WriteToConsole(msg);
}

and assigned that function to gFunctionTable.pfnGetWeaponData but all of the members are 0.

I hope that makes sense ;)

1 of the game modes (Rocket Arena) has infinite ammo so the amount does not go down :(

Thanks again

The Storm 30-06-2005 22:11

Re: Hi, thanks and help!
 
Maybe you don't need all that stuff.
Try to change the fire delay in bot_fire_delay_t if you are using HPB bot teamplate.

mfrx 30-06-2005 22:30

Re: Hi, thanks and help!
 
Wow ure quick :D

No im not using any template - I was feeling brave and wanted to do it all myself ;)

So although I have my own weapon class and I know the delays - I still need to hook into the engine somehow :(

btw I know the delays because I tried using the pEdict->v.weaponanim to determine firing times but that is somewhat unreliable :(

I will keep looking :)

The Storm 30-06-2005 23:14

Re: Hi, thanks and help!
 
Man in this way it will be very hard for you. Download HPB bot source code and look there how to fix the things. And too read the botman readme file. :D

mfrx 30-06-2005 23:32

Re: Hi, thanks and help!
 
Yeah should have said, ive already played around for the HPB Bot code for the last month or so :) and my coding is already ok ;) but I dont know the engine well enough :(

The bots are already fighting, dodging rockets, predicting enemy movement etc its just this 1 thing (for now hehe)

So thanks anyway :)

Pierre-Marie Baty 01-07-2005 00:31

Re: Hi, thanks and help!
 
You can also keep track of the last time the bot shooted if you compare pEdict->v.button and pEdict->v.oldbutton and see if in the former case IN_ATTACK was set and not in the latter.

Or else, you can try to hook at the gun animation... I don't recall which function that was, but I remember DrEvil did that for FoxBot.

Akz 01-07-2005 10:30

Re: Hi, thanks and help!
 
Comparing pEdict->v.button and pEdict->v.oldbutton could be used to detect when the attack button was pressed, but it doesn't quarantee that the weapon was fired. Checking the weapon animation should be ok for that purpose though. The variable you're looking for is pEdict->v.weaponanim.

In DMC, the value should be either 0 (idle) or 1 (shooting), because AFAIK there are only 2 animations for each weapon.

mfrx 02-07-2005 01:01

Re: Hi, thanks and help!
 
Sleep followed by lots of coffee is good ;)

I found v.weaponanim to be unrealiable (prehaps due to timing differences between the bot.dll and the engine?)

So I re-read botman's readme a few more times and now it makes sense :D

I've hooked the pfnSetModel func and then check to see what type of model is assigned, then wait until that edict has an owner, then see if it is a bot - thus I can update its time-till-fire.

This may not be the best way to do things but it does work :D

Thanks again

EDIT: Now everything is working unless the previous weapon was a shotgun or super-shotgun because no model seems to be assigned :( Does anyone know how bullets are dealt with by the engine - or can you point me to how/where I can find out?


All times are GMT +2. The time now is 12:25.

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