.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 1 SDK (http://forums.bots-united.com/forumdisplay.php?f=33)
-   -   NEW STEAM: Failure on detecting round, how do YOU do it? (http://forums.bots-united.com/showthread.php?t=748)

stefanhendriks 13-02-2004 15:12

NEW STEAM: Failure on detecting round, how do YOU do it?
 
Here is my sollution, probably many use it as i believe i got this from the forums when i just started RB :D

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?

Pierre-Marie Baty 13-02-2004 16:09

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
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...

stefanhendriks 13-02-2004 16:15

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
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? :D)

Pierre-Marie Baty 13-02-2004 16:26

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
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 ?

stefanhendriks 13-02-2004 16:31

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
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?

Pierre-Marie Baty 13-02-2004 16:53

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
yes... the RoundTime message. What if we tested this one ?

Pierre-Marie Baty 13-02-2004 17:13

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
WORKS!!!!!! :D :D :D

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


botmeister 14-02-2004 04:47

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
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.

stefanhendriks 16-02-2004 12:18

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
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


Pierre-Marie Baty 16-02-2004 12:55

Re: NEW STEAM: Failure on detecting round, how do YOU do it?
 
Nice... but I prefer my method. Less code involved :P

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 ?


All times are GMT +2. The time now is 18:20.

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