.:: 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 > SDK Programming discussions > Half-Life 1 SDK
Half-Life 1 SDK For developments focused around Half-Life (and its mods) Half-Life

Reply
 
Thread Tools
NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#1)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default NEW STEAM: Failure on detecting round, how do YOU do it? - 13-02-2004

Here is my sollution, probably many use it as i believe i got this from the forums when i just started RB

Code:
edict_t* pfnFindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue)
{
 // Counter-Strike - New Round Started
 if (strcmp(pszValue,"info_map_parameters") == 0) {
		
  // New round started.
  Game.SetNewRound(true);
		Game.SetRoundTime(gpGlobals->time);  
 }
   RETURN_META_VALUE (MRES_IGNORED, NULL);
}
I think the 'new optimized shit code from cs dll' does not do this anymore at round start.

Perhaps an engine message gets sent ALL THE TIME (also on dedicated server) so we can use that as a sollution?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#2)
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: NEW STEAM: Failure on detecting round, how do YOU do it? - 13-02-2004

Ah. Here's the pitfall.

I believe it's eLiTe who figured out this code. Anyhow... I always suspected this was not a clean way to detect round start.

I will run some tests using my o-so-handy PMtools plugin. Perhaps I can find a network message that is sent at round start and only then. Back in 2 minutes...



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#3)
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? - 13-02-2004

I admit this is method is probably not the most clean one, but it worked all the time, and as long as it works, don't fix things that are not broken (yet? )


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#4)
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: NEW STEAM: Failure on detecting round, how do YOU do it? - 13-02-2004

HOLY SHIT!

Here's what is sent as soon as I toggle sv_restartround to 1:
Code:
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 76 ("TextMsg") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 76 ("TextMsg") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 117 ("BombPickup") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 87 ("TeamScore") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 87 ("TeamScore") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 85 ("ScoreInfo") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 85 ("ScoreInfo") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 85 ("ScoreInfo") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 111 ("NVGToggle") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 78 ("ResetHUD") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 102 ("Money") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 107 ("StatusIcon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 101 ("RoundTime") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 87 ("TeamScore") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 87 ("TeamScore") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 94 ("HideWeapon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 95 ("SetFOV") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 72 ("Battery") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 71 ("Damage") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 69 ("FlashBat") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 73 ("Train") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 99 ("AmmoX") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 107 ("StatusIcon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 66 ("CurWeapon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 92 ("WeapPickup") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 92 ("WeapPickup") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 91 ("AmmoPickup") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 86 ("TeamInfo") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 85 ("ScoreInfo") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 98 ("ScreenFade") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 101 ("RoundTime") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 99 ("AmmoX") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 66 ("CurWeapon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 66 ("CurWeapon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 74 ("HudText") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 69 ("FlashBat") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 107 ("StatusIcon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (PMB) SENDS MESSAGE type 67 ("Geiger") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 65 ("ReqState") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 76 ("TextMsg") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): Entity #1 (player) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (player) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #3 (player) SENDS MESSAGE type 84 ("ScoreAttrib") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (player) SENDS MESSAGE type 99 ("AmmoX") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): Entity #2 (player) SENDS MESSAGE type 66 ("CurWeapon") in 1 ("MSG_ONE") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 76 ("TextMsg") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 76 ("TextMsg") in 2 ("MSG_ALL") from NULL
PMTOOLS (HUD): NULLENT [= Game] SENDS MESSAGE type 100 ("SendAudio") in 0 ("MSG_BROADCAST") from NULL
ReqState messages are discardable, they are sent every second in the game and are part of the network pack... that's all I can say. Which one to trust, according to you ? Are messages like TeamScore sent only at map change ?



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#5)
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? - 13-02-2004

I don't know about teamscore, i thought i have seen it changed directly after the bomb exploded or hostages have been rescued. So i am not sure about that.

I did see a roundtimer got set too?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#6)
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: NEW STEAM: Failure on detecting round, how do YOU do it? - 13-02-2004

yes... the RoundTime message. What if we tested this one ?



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: NEW STEAM: Failure on detecting round, how do YOU do 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: NEW STEAM: Failure on detecting round, how do YOU do it? - 13-02-2004

WORKS!!!!!!

this message is sent ONLY when the round restarts ! it is NOT sent when you change the mp_roundtime CVAR !

Here's the fix, guys !

in pfnMessageBegin():
Code:
		 else if (msg_type == GetUserMsgId ("RoundTime"))
			mission.finished = TRUE; // the round has restarted



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#8)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: NEW STEAM: Failure on detecting round, how do YOU do it? - 14-02-2004

PMB I looked at your plugin solution. It seems that you won't detect the very first round start because "round_end" is set to true only after the round ends. To start off, round_end should be initialized to true, that way on the first start frame the first round start will be detected.

Your code may be fine if the intention is to detect only the end of a round, but I did not dig into it that far.

*edit*

I see another problem. What about a map change before a round ends? For example, if you issue a changelevel command in the middle of a round, will the roundend message be sent? Even if the roundend message is sent, several frames may go by before the map starts to load up, and your plugin will not be aware of exactly when the first round of the new map started. It will instead think the round started before the map even started to load up.

Tosolve this, you will have to also add the round_end detection in pfnChangeLevel, in PMB's case, set the bool
Code:
round_end = true
in there. After the pfnChangeLevel function call, the next frame should be the first frame of the newly loaded map, which hopefully will also be the first frame of the round start (or close enough).

I have not yet tested any of this with the new CS 1.6 update (I am coding the changes now as I type), so don't assume I know what I'm talking about. I'll post updates once I have my updates coded and tested.

*edit*

I am assuming that the roundtime message is sent directly after a round ends, not when a round begins.


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

Last edited by botmeister; 14-02-2004 at 05:16..
  
Reply With Quote
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
Re: NEW STEAM: Failure on detecting round, how do YOU do it?
Old
  (#10)
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: NEW STEAM: Failure on detecting round, how do YOU do it? - 16-02-2004

Nice... but I prefer my method. Less code involved

and my method always works since any map change / map start / server start calls ServerActivate(), which resets all the round and mission parameters and sets mission.finished to TRUE automatically.

*edit*
in CS 1.5 at least, RoundTime is sent for the first round too, so it DOES indeed catch every round START. I don't know for CS 1.6. Can one of you confirm ?



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; 16-02-2004 at 13:07..
  
Reply With Quote
Reply


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

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