View Single Post
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#9)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: NEW STEAM: Failure on detecting round, how do YOU do it? - 16-02-2004

FINALLY BU works again.

And i got the fix too, this one is with help from Alfred. Using messages with destination MSG_SPEC...

engine.cpp
Code:
	  // STEFAN
	  else if (msg_dest == MSG_SPEC)
	  {
		 botMsgFunction = NULL;  // no msg function until known otherwise
		 botMsgIndex = -1;	   // index of bot receiving message (none)
		 if (mod_id == CSTRIKE_DLL)
		 {
			 if (msg_type == GET_USER_MSG_ID (PLID, "HLTV", NULL))
				 botMsgFunction = BotClient_CS_HLTV;
		 }
	  }
	  // STEFAN END
botclient.cpp
Code:
// STEFAN
// This message gets sent for HLTV, according to Alfred (Valve) also
// unique for each round-start.
void BotClient_CS_HLTV(void *p, int bot_index)
{
  static int state = 0;  // current state machine state
  static int players = 0;
  /* 
	From e-mail Alfred:
  // reset all players health for HLTV
 MESSAGE_BEGIN( MSG_SPEC, gmsgHLTV );
  WRITE_BYTE( 0 ); // 0 = all players
  WRITE_BYTE( 100 | 128 );
 MESSAGE_END();
 // reset all players FOV for HLTV
 MESSAGE_BEGIN( MSG_SPEC, gmsgHLTV );
  WRITE_BYTE( 0 ); // all players
  WRITE_BYTE( 0 );
 MESSAGE_END();
  */
  if (state == 0)
  {
	  players = *(int *) p; // check the byte
	  state++;
  }
  else if (state == 1)
  {
	  // I check here on purpose. Multiple HLTV messages get sent within the game, 
	  // by checking for the second state i AND the 'all players' flag as above in Alfreds
	  // code i hopefully elminate all faulty 'new round' detections. Testing
	  // has shown me that the state machine MUST be in, else you will get "New Round"
	  // detections on strange occasions!
	  // We could do some cool stuff here, but all i want to know is if the
	  // round has (re)started, so i just set that flag and i am done dude.
	  if (players == 0)
	  {
		  // New round started.
		  Game.SetNewRound(true);
		  Game.SetRoundTime(gpGlobals->time);
	  }
	  state = 0;
  }
}
// STEFAN - END


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote