GoldenEye: Source Forums

  • March 28, 2024, 08:06:49 am
  • Welcome, Guest
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: [Solved] How To Obtain Match Results During & After Each Match?  (Read 10010 times)

0 Members and 1 Guest are viewing this topic.

Phivex

  • Agent
  • *
  • Posts: 21
  • Reputation Power: 3
  • Phivex has no influence.
  • Offline Offline
[Solved] How To Obtain Match Results During & After Each Match?
« on: September 16, 2016, 11:25:07 pm »

So I'm looking to read log info from each match played. I've looked through the files, but I've yet to see a file that stores match results when the match is over. I'm also interested in the Python script(s) that outputs info to the screen about each kill or event. If it's not already written to a file, then I'd like to change that. Anyone have any insight?
« Last Edit: September 19, 2016, 09:54:30 am by Phivex »
Logged

Phivex

  • Agent
  • *
  • Posts: 21
  • Reputation Power: 3
  • Phivex has no influence.
  • Offline Offline
Re: How To Obtain Match Results During & After Each Match?
« Reply #1 on: September 17, 2016, 12:39:54 am »

So I *might* have found where to put some code. The function onPlayerKilled() in the gesource/python/ges/GamePlay/__init__.py may be what I'm looking for. The issue that I'm hitting now is even though I've added code to create and write to a file, it isn't running. I know how to write to a file in python, so I know it's not a syntax or logic issue. It's almost as if the python code doesn't run and it's pre-compiled and I'd have to recompile it or something. Thoughts?

So I was looking for my file in the gesource path. It actually created it in the "../Steam/steamapps/common/Source SDK 2007/" directory. However, the parameters (self, victim, killer, weapon) passed to the onPlayerKilled() function don't actually seem to have the player's name. When the victim and killer variables are output, they just output "player" as the value instead of the player's name. The weapon variable actually works, though. Example output for that variable: "weapon_d5k_silenced".

Now I just have to figure out how to get the player's name. Maybe the victim and killer variables are actually objects that have a name variable? If not, maybe there's a function that can be called and given the victim and killer variables and returns the name?
« Last Edit: September 17, 2016, 01:04:22 am by Phivex »
Logged

Phivex

  • Agent
  • *
  • Posts: 21
  • Reputation Power: 3
  • Phivex has no influence.
  • Offline Offline
[Work Around - Solution in Reply #6]
« Reply #2 on: September 17, 2016, 02:18:20 am »

Okay. I think I figured out what I was trying to do. I'll post the solution so others can view in case they're curious. I imagine since no one else has responded and I've found nothing else similar very quickly, there isn't another way of doing it.

Add the following lines to the end of the function OnPlayerKilled() [line 113] in ../Steam/steamapps/sourcemods/gesource/python/ges/GamePlay/__init__.py

Code: [Select]
fileHandle = open("killLog.log", "a")
fileHandle.write("{},{},{}\n".format(killer.GetPlayerName(), victim.GetPlayerName(), weapon))
fileHandle.close()

The killLog.log file will be in "../Steam/steamapps/common/Source SDK Base 2007/".

For other options available to the killer and victim objects, view the "../gesource/python/stubs/GEPlayer.py" file.

EDIT: Please note this only works for game modes where the scoring focuses on kills.
« Last Edit: September 18, 2016, 06:12:04 pm by Phivex »
Logged

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: [Solved] How To Obtain Match Results During & After Each Match?
« Reply #3 on: September 17, 2016, 03:20:56 pm »

Your better bet is to register an event hook in the __init__ function of GamePlay/__init__.py

This will guarantee that it is called even if the parent class does not call down into the base.

For examples of event hooks look in the utils files: https://github.com/goldeneye-source/ges-python/blob/master/ges/GamePlay/Utils/GEPlayerTracker.py
Logged

Phivex

  • Agent
  • *
  • Posts: 21
  • Reputation Power: 3
  • Phivex has no influence.
  • Offline Offline
Re: [Solved] How To Obtain Match Results During & After Each Match?
« Reply #4 on: September 18, 2016, 01:21:02 pm »

Hmm. Okay. Well hooks have always been a weak point of mine. Not sure why, but they always give me trouble.

So I tried adding the following snippet and it completely broke the scoring system. What am I doing wrong? How do I know what parameters are going to be passed?

Code: [Select]
def __init__(self):
    ....
    parent.RegisterEventHook( EventHooks.GP_PLAYERKILLED, self._Test )   
   
def _Test(self, killer, victim, weapon):
    GEUtil.Msg("----HOOK----")

Logged

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: [Solved-Kinda] How To Obtain Match Results During & After Each Match?
« Reply #5 on: September 18, 2016, 01:33:14 pm »

Snippet is not enough. Is parent defined? Perhaps you should use self.

Self.RegisterEventHook
Logged

Phivex

  • Agent
  • *
  • Posts: 21
  • Reputation Power: 3
  • Phivex has no influence.
  • Offline Offline
[Solution]
« Reply #6 on: September 18, 2016, 02:30:20 pm »

Ah. Yup. Changing "parent" to "self" fixed it and I was able to incorporate my other code. I also had to add "from GEGlobal import EventHooks". I was thinking the regular "import GEGlobal" would've been fine, but it didn't cut it. I was able to port my other code over. Thanks for the help!

Any idea how to get the current map and after match awards (e.g. "Where's the Armor", "Most Frantic", etc.)? I have all the data I want EXCEPT for that. I've been racking my brain trying to find it.

Edit: Integrating an event hook makes this code work for any game mode.
« Last Edit: September 18, 2016, 06:11:44 pm by Phivex »
Logged

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: [Solved-ish] How To Obtain Match Results During & After Each Match?
« Reply #7 on: September 18, 2016, 09:36:37 pm »

I also had to add "from GEGlobal import EventHooks". I was thinking the regular "import GEGlobal" would've been fine, but it didn't cut it.

This is because Python respects namespaces unlike C# (the one thing I hate about C# actually). If you import a module, you have to prepend the module name if you want to use any functions defined in it (i.e., GEGlobal.EventHooks.GP_PLAYERKILLED). You can also import all names into your current namespace (not recommended) by doing from GEGlobal import *.

The awards are not transmitted to python, unfortunately. We never intended python to be used for stat tracking, though its not a bad idea to start doing that!
Logged

Phivex

  • Agent
  • *
  • Posts: 21
  • Reputation Power: 3
  • Phivex has no influence.
  • Offline Offline
Re: [Solved-ish] How To Obtain Match Results During & After Each Match?
« Reply #8 on: September 18, 2016, 10:48:15 pm »

Quote
The awards are not transmitted to python, unfortunately. We never intended python to be used for stat tracking, though its not a bad idea to start doing that!

  • That's what I'm currently attempting to implement, stat tracking. Once I'm done, I'll post the code if you want.
  • Is the current map transmitted to python? I was hoping to use that in the stats too.
  • I'm glad you mentioned implementing an event hook. I was able to create another one that gets the after round results. I noticed there isn't an event hook for a match, though, but there are a couple for round begin and end. Is an event hook for matches something that is on the roadmap?
  • What about event hooks for non-deathmatch game modes like "blue flag grabbed", "blue flag captured", etc. for CTF, "weapon level change" for Arsenal, "golden gun obtained" for MWGG, and others? Are those things that are on the roadmap? If not, maybe there's another way I can easily get that info? I know I can go into each "..\GamePlay\<GameMode>.py" file and make additions there, but I guess now that you have me on the event hooks I'm kinda hooked on them (pardon the pun). Plus, the upkeep and organization of that would look horrible.
Logged

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: [Solved-ish] How To Obtain Match Results During & After Each Match?
« Reply #9 on: September 19, 2016, 01:10:11 am »

Match end triggers OnRoundEnd. You can check that is the match end by using IsGameOver() function. https://github.com/goldeneye-source/ges-python/blob/master/stubs/GEMPGameRules.py#L147

You could implement your own event hooks for each game mode pretty easily, but to make it generic would take a significant effort. A good idea though if we were to implement stats in python.
Logged

Phivex

  • Agent
  • *
  • Posts: 21
  • Reputation Power: 3
  • Phivex has no influence.
  • Offline Offline
Re: [Solved] How To Obtain Match Results During & After Each Match?
« Reply #10 on: September 19, 2016, 11:32:13 am »

How would I go about creating whole new event hooks? It's one thing to just register a new hook, but I have no idea how to create a new hook. I was trying to peruse the code for an example, but again event hooks aren't my strong point. Got an example, tutorial, or reading material I can use? Otherwise, I'm just going to find the functions that are called and add code to the functions like I was originally doing with the OnPlayerKilled() function.
Logged

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: [Solved] How To Obtain Match Results During & After Each Match?
« Reply #11 on: September 20, 2016, 01:54:03 am »

What I meant was add code snippets to each function in the game mode (such as OnTokenGrabbed) to add logging for that stuff. Its event hook cheating.
Logged
Pages: [1]   Go Up