|
1 |
| -from __future__ import annotations |
| 1 | +import csv |
| 2 | +from random import choice, randint |
2 | 3 |
|
3 | 4 | from rlbot import flat
|
4 | 5 | from rlbot.config import load_player_loadout
|
|
7 | 8 |
|
8 | 9 | class Fashion(Bot):
|
9 | 10 | standard_loadout: flat.PlayerLoadout
|
| 11 | + last_tick = 0 |
| 12 | + items: dict[str, list[int]] = {} |
10 | 13 |
|
11 | 14 | def initialize(self):
|
| 15 | + with open("./items.csv") as f: |
| 16 | + reader = csv.reader(f) |
| 17 | + for row in reader: |
| 18 | + if row[1] not in self.items: |
| 19 | + self.items[row[1]] = [] |
| 20 | + |
| 21 | + self.items[row[1]].append(int(row[0])) |
| 22 | + |
12 | 23 | self.standard_loadout = load_player_loadout("../necto/loadout.toml", self.team)
|
13 | 24 | self.set_loadout(self.standard_loadout)
|
14 | 25 |
|
15 | 26 | def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
|
16 |
| - return flat.ControllerState() |
| 27 | + if packet.match_info.match_phase != flat.MatchPhase.Active: |
| 28 | + return flat.ControllerState() |
| 29 | + |
| 30 | + if packet.match_info.frame_num - self.last_tick >= 2 * 120: |
| 31 | + loadout = flat.PlayerLoadout( |
| 32 | + team_color_id=randint(0, 69), |
| 33 | + custom_color_id=randint(0, 104), |
| 34 | + car_id=choice(self.items["Body"]), |
| 35 | + wheels_id=choice(self.items["Wheels"]), |
| 36 | + decal_id=0, |
| 37 | + boost_id=choice(self.items["Boost"]), |
| 38 | + antenna_id=choice(self.items["Antenna"]), |
| 39 | + hat_id=choice(self.items["Hat"]), |
| 40 | + paint_finish_id=choice(self.items["PaintFinish"]), |
| 41 | + loadout_paint=flat.LoadoutPaint( |
| 42 | + randint(0, 18), |
| 43 | + randint(0, 18), |
| 44 | + randint(0, 18), |
| 45 | + randint(0, 18), |
| 46 | + randint(0, 18), |
| 47 | + randint(0, 18), |
| 48 | + randint(0, 18), |
| 49 | + randint(0, 18), |
| 50 | + ), |
| 51 | + ) |
| 52 | + |
| 53 | + self.logger.info(f"State setting new loadout") |
| 54 | + self.set_loadout(loadout) |
| 55 | + self.last_tick = packet.match_info.frame_num |
| 56 | + |
| 57 | + return flat.ControllerState(throttle=1, steer=1) |
17 | 58 |
|
18 | 59 |
|
19 | 60 | if __name__ == "__main__":
|
|
0 commit comments