forked from roguelike2d/TekkenBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BotPunisher.py
60 lines (43 loc) · 2.07 KB
/
BotPunisher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
A simple bot that presses buttons when emerging from block or hit stun.
"""
from Bot import Bot
from TekkenGameState import TekkenGameState
from TekkenEncyclopedia import TekkenEncyclopedia
from BotData import BotBehaviors
from CharacterData import *
class BotPunisher(Bot):
def __init__(self, botCommands):
super().__init__(botCommands)
self.gameplan = None
self.enemyCyclopedia = TekkenEncyclopedia(False)
def Update(self, gameState: TekkenGameState):
self.enemyCyclopedia.Update(gameState)
if gameState.WasFightReset():
self.botCommands.ClearCommands()
self.gameplan = None
if self.gameplan == None :
char_id = gameState.GetBotCharId()
if char_id != None:
self.gameplan = GetGameplan(char_id)
if self.gameplan != None:
BotBehaviors.Basic(gameState, self.botCommands)
if self.botCommands.IsAvailable():
BotBehaviors.BlockAllAttacks(gameState, self.botCommands)
frameAdvantage = None
if gameState.IsBotBlocking():
frameAdvantage = self.enemyCyclopedia.GetFrameAdvantage(gameState.GetOppMoveId())
elif gameState.IsBotGettingHit():
frameAdvantage = self.enemyCyclopedia.GetFrameAdvantage(gameState.GetOppMoveId(), isOnBlock=False)
try:
frameAdvantage = int(frameAdvantage) * -1
except:
frameAdvantage = None
if frameAdvantage != None:
if frameAdvantage >= 10:
if gameState.IsBotWhileStanding():
punish = self.gameplan.GetMoveByFrame(ResponseTypes.ws_punishes, frameAdvantage)
else:
punish = self.gameplan.GetMoveByFrame(ResponseTypes.st_punishes, frameAdvantage)
if punish != None:
self.botCommands.AddCommand(punish)