SEN:P-AI/SEN:API
One of the original intents for SEN:P-AI was for it to load and play music automatically, but some time before I actually had the means to create it some guy had a similar idea and created Rigdio.
Unfortunately, SEN:P-AI and Rigdio are written in completely different languages and completely different frameworks, rendering direct integration impossible.
Thus, an Inter-Process Communication (IPC) interface was developed that would allow Rigdio and potentially other programs to access and query information gathered by SEN:P-AI.
Connecting
The SEN:P-AI IPC link is established using Windows's Named Pipes
With SEN:P-AI acting as the server, the pipe is created with the following parameters:
- Name (unescaped):
"\\.\pipe\SEN_P-AI"
- OpenMode:
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED
- PipeMode:
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT
- DefaultTimeOut:
3000
(ms)
Connecting applications must ensure their parameters are compatible with the above for anything to work correctly.
Messages
All messages (must) begin with a 32-bit (4 byte) unsigned length value, little-endian.
All messages are/must be encoded as JSON.
Unrecognized messages, objects, object members, and recognized members with unrecognized types or values are/must be ignored.
This allows API to be extendable without breaking compatability.
Do not take this as permission to send nonsensical garbage.
SEN:P-AI reserves the right to terminate the pipe connection at any time, for any or no reason, and without notice.
Client Requests
(Work In Progress)
Server Responses
The concept of "inheritance" is used here to reduce redundancy. An object that "inherits" another "base" object contains all the members of the base object in addition to its own. (If you did not already understand this, I have no idea why you're even on this page but okay)
Common Substructures
Event
- "type":
"Event"
- "event":
<string>
Name of the event e.g. "Goal" - "timestamp":
<number>
time when the event was processed, as milliseconds since Unix Epoch
Included in every type of event message
Match Event
Inherits Event
- "gameMinute":
<number>
Minute on the PES game clock, stopped during injury time, fractional portion may be inaccurate-1
SEN:P-AI knows that this event happened but not when (unknown time)-2
Event occurred during BENULDIES
- "injuryMinute":
<number (>= 0)>
Minutes into injury time, starting at 0, may be inaccurate<number (< 0)> <Null> <Undefined>
event did not occurr in injury time
Included in every event that occurs during a match
Player Object
- "name":
<string>
name of the player, as written in EDIT0 - "playerId":
<number>
ID of the player, as written in EDIT0
Team Object
- "name":
<string>
the team name, as it was written in EDIT0 - "id":
<number>
the team ID, as written in EDIT0 - "players":
<array of Player object>
each player on the roster of this team
Game State Events
Shit that happens behind the scenes
Teams Changed
Inherits Event
- "event":
"Teams Changed"
- "home":
<Team object>
- "away":
<Team object>
Emitted when:
- the game transitions from Team Select to the Pre-Match Setup menu
- SEN:P-AI is started while the game is already in or pre match
- An application connects to SEN:P-AI after either of the above has happened
- NOT emitted if both teams are the same as before
- A false Teams Changed event with names set to "" may be emitted when exiting to Top Menu
Stats Found
Inherits Match Event
- "event":
"Stats Found"
- "homeScore":
<number>
score of the home team - "awayScore":
<number>
score of the away team
Emitted when:
- SEN:P-AI is first able to locate the player stats table
- Right before the first touch (at the end of anthems)
- when the brute force search is activated, if the regular search method failed
- immediately after SEN:P-AI (re)starts. Events and stat changes that already occurred in the match are unable to be accurately detected.
- An application connects to SEN:P-AI after the above has happened
Stats Lost
Inherits Match Event
- "event":
"Stats Lost"
Emitted when the stats table is deallocated from memory, this happens when exiting to Team Select or to Top Menu, or when the game closes/crashes.
Clock Stopped
Inherits Match Event
- "event":
"Clock Stopped"
- "reason":
<string>
Possible Values:"Unknown"
The stop reason could not be reliably detected.
Possible undetectable reasons include: manual pausing, end of half, a throw in, instances of "Goal/Corner kick" that do not result directly from a shot."Goal"
,"Own Goal"
,"Foul"
,"Offside"
,"Goal kick"
,"Corner kick"
Emitted when SEN:P-AI first reads the same match time two updates in a row. Which means any event that corresponds to the stop reason will have been emitted in the previous update cycle.
NOTE: Since the end of half is currently undetectable, there is no way to know if the match has ended before leaving the post-match results screen. Even if end of half could be detected, there's still no way to detect if Extra Time or Penalties are on until they start or the match is exited.
Clock Started
Inherits Match Event
- "event":
"Clock Started"
Emitted when SEN:P-AI detects a change to the game clock after previously determining that it had stopped.
Important Caveat: If the streamer manages to pause the game after a goal replay and before kickoff, a Clock Started event will not occur until they unpause.
Clock Updated
Inherits Match Event
- "event":
"Clock Updated"
Emitted when SEN:P-AI detects a change to the game clock minute or injury minute.
Match Events
Shit that PES will tell you happened with fancy graphics and animations and shit
Goal
Inherits Match Event
- "event":
"Goal"
- "team": either
"Home"
or"Away"
- "scorer":
<Player object>
- "assister":
<Player object>
<Null> <Undefined>
If the goal was unassisted
Emitted immediately when a goal is scored. It would be wise to delay any automatic playing of music after this is emitted.
Card
Inherits Match Event
- "event":
"Card"
- "team": either
"Home"
or"Away"
- "card": either
"Yellow"
or"Red"
- "player":
<Player object>
Emitted whenever a player recieves a card. For some reason the exact time this happens varies depending on which card cutscene is played.
Player Sub
Inherits Match Event
- "event":
"Player Sub"
- "team": either
"Home"
or"Away"
- "playerIn":
<Player object>
- "playerOut":
<Player object>
NOTE: Currently unimplemented, actual value will be<Undefined>
Emitted when a player's playing time goes from -1 to 0 or up, this occurs just before the Clock Start when they are subbed