[ci] auto-format

This commit is contained in:
Loup-Garou911XD 2022-11-03 17:29:43 +00:00 committed by github-actions[bot]
parent d513809ad3
commit c052a1d7c1
6 changed files with 883 additions and 824 deletions

View file

@ -6,7 +6,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import ba, _ba
import ba
import _ba
from bastd.actor.playerspaz import PlayerSpaz
from bastd.actor.scoreboard import Scoreboard
from bastd.actor.powerupbox import PowerupBoxFactory
@ -19,6 +20,7 @@ if TYPE_CHECKING:
bsuSpaz = None
def getlanguage(text, sub: str = ''):
lang = _ba.app.lang.language
translate = {
@ -44,17 +46,20 @@ def getlanguage(text, sub: str = ''):
"Portuguese": "Ativar velocidade"},
}
languages = ['Spanish','Portuguese','English']
if lang not in languages: lang = 'English'
languages = ['Spanish', 'Portuguese', 'English']
if lang not in languages:
lang = 'English'
if text not in translate:
return text
return translate[text][lang]
class BallDiedMessage:
def __init__(self, ball: Ball):
self.ball = ball
class Ball(ba.Actor):
def __init__(self, position: Sequence[float] = (0.0, 1.0, 0.0)):
super().__init__()
@ -132,12 +137,16 @@ class Team(ba.Team[Player]):
def __init__(self) -> None:
self.score = 0
class Points:
postes = dict()
postes['pal_0'] = (10.64702320098877, 0.0000000000000000, 0.0000000000000000) #10.736066818237305, 0.3002409040927887, 0.5281256437301636
# 10.736066818237305, 0.3002409040927887, 0.5281256437301636
postes['pal_0'] = (10.64702320098877, 0.0000000000000000, 0.0000000000000000)
postes['pal_1'] = (-10.64702320098877, 0.0000000000000000, 0.0000000000000000)
# ba_meta export game
class BasketGame(ba.TeamGameActivity[Player, Team]):
name = getlanguage('Name')
@ -336,7 +345,7 @@ class BasketGame(ba.TeamGameActivity[Player, Team]):
if team.score >= self._score_to_win:
self.end_game()
#ba.playsound(self._foghorn_sound)
# ba.playsound(self._foghorn_sound)
ba.playsound(self._cheer_sound)
self._ball.scored = True
@ -366,7 +375,7 @@ class BasketGame(ba.TeamGameActivity[Player, Team]):
winscore = self._score_to_win
for id, team in enumerate(self.teams):
self._scoreboard.set_team_value(team, team.score, winscore)
#self.postes(id)
# self.postes(id)
def spawn_player(self, player: Player) -> ba.Actor:
if bsuSpaz is None:
@ -414,6 +423,7 @@ class BasketGame(ba.TeamGameActivity[Player, Team]):
assert self._ball_spawn_pos is not None
self._ball = Ball(position=self._ball_spawn_pos)
class Aro(ba.Actor):
def __init__(self, team: int = 0,
position: Sequence[float] = (0.0, 1.0, 0.0)):
@ -486,7 +496,8 @@ class Aro(ba.Actor):
try:
id = 0 if team == 1 else 1
color = act.teams[id].color
except: color = (1,1,1)
except:
color = (1, 1, 1)
while locs_count > 1:
scale = (1.5 * 0.1 * locs_count) + 0.8
@ -523,6 +534,7 @@ class Aro(ba.Actor):
else:
super().handlemessage(msg)
class Cuadro(ba.Actor):
def __init__(self, team: int = 0,
position: Sequence[float] = (0.0, 1.0, 0.0)):
@ -557,11 +569,12 @@ class Cuadro(ba.Actor):
try:
id = 0 if team == 1 else 1
color = act.teams[id].color
except: color = (1,1,1)
except:
color = (1, 1, 1)
while(count_y != 1):
while (count_y != 1):
while(count != 1):
while (count != 1):
pos[2] += 0.19
self.locs.append(
@ -576,7 +589,6 @@ class Cuadro(ba.Actor):
'additive': False}))
count -= 1
count = old_count
pos[1] += 0.2
pos[2] = oldpos[2]
@ -589,6 +601,7 @@ class Cuadro(ba.Actor):
else:
super().handlemessage(msg)
class Palos(ba.Actor):
def __init__(self, team: int = 0,
position: Sequence[float] = (0.0, 1.0, 0.0)):
@ -636,7 +649,7 @@ class Palos(ba.Actor):
owner=self.node,
attrs={'shape': 'circle',
'position': position,
'color': (1,1,0),
'color': (1, 1, 0),
'opacity': 1.0,
'draw_beauty': False,
'additive': True})
@ -656,7 +669,8 @@ class Palos(ba.Actor):
position = self._pos
if team == 0:
pos = (position[0]-0.8, position[1] + 2.0 + _y, position[2])
else: pos = (position[0]+0.8, position[1] + 2.0 + _y, position[2])
else:
pos = (position[0]+0.8, position[1] + 2.0 + _y, position[2])
if self.aro is None:
self.aro = Aro(team, pos).autoretain()
@ -672,6 +686,7 @@ class Palos(ba.Actor):
else:
super().handlemessage(msg)
class BasketMap(maps.FootballStadium):
name = 'BasketBall Stadium'
@ -691,6 +706,7 @@ class BasketMap(maps.FootballStadium):
gnode.vr_camera_offset = (0, -0.8, -1.1)
gnode.vr_near_clip = 0.5
class BasketMapV2(maps.HockeyStadium):
name = 'BasketBall Stadium V2'
@ -750,5 +766,6 @@ class BasketMapV2(maps.HockeyStadium):
'materials': [self.collision]}),
]
ba._map.register_map(BasketMap)
ba._map.register_map(BasketMapV2)

View file

@ -185,8 +185,8 @@ class BoxingGame(DeathMatchGame):
PowerupBox(
position=self.map.powerup_spawn_points[index],
poweruptype=PowerupBoxFactory.get().get_random_powerup_type(
excludetypes=['triple_bombs','ice_bombs','impact_bombs',
'land_mines','sticky_bombs','punch']
excludetypes=['triple_bombs', 'ice_bombs', 'impact_bombs',
'land_mines', 'sticky_bombs', 'punch']
),
expire=expire,
).autoretain()

View file

@ -277,13 +277,13 @@ class MeteorShowerv2Game(ba.TeamGameActivity[Player, Team]):
self, position: Sequence[float], velocity: Sequence[float]
) -> None:
if self._bomb_type == 'tnt':
bomb_type = random.choice(['tnt','tnt','tnt','tnt','impact'])
bomb_type = random.choice(['tnt', 'tnt', 'tnt', 'tnt', 'impact'])
elif self._bomb_type == 'land_mine':
bomb_type = random.choice([
'land_mine','land_mine','land_mine','land_mine','impact'])
'land_mine', 'land_mine', 'land_mine', 'land_mine', 'impact'])
elif self._bomb_type == 'random':
bomb_type = random.choice([
'normal','ice','sticky','impact','land_mine','tnt'])
'normal', 'ice', 'sticky', 'impact', 'land_mine', 'tnt'])
else:
bomb_type = self._bomb_type
Bomb(position=position,

View file

@ -1,4 +1,4 @@
#SimonSays
# SimonSays
# you had really better do what Simon says...
# ba_meta require api 7
from __future__ import annotations
@ -12,6 +12,7 @@ from ba import _gameutils
import ba
import random
class CustomText(ba.Actor):
"""Text that pops up above a position to denote something special.
@ -39,7 +40,7 @@ class CustomText(ba.Actor):
'in_world': True,
'shadow': 1.0,
'flatness': 1.0,
'h_align': 'center'},delegate=self)
'h_align': 'center'}, delegate=self)
lifespan = duration
ba.animate(
self.node, 'scale', {
@ -83,6 +84,7 @@ class CustomText(ba.Actor):
self._combine.connectattr('output', self.node, 'color')
self._die_timer = ba.Timer(
lifespan, ba.WeakCall(self.handlemessage, ba.DieMessage()))
def handlemessage(self, msg: Any) -> Any:
assert not self.expired
if isinstance(msg, ba.DieMessage):
@ -91,11 +93,14 @@ class CustomText(ba.Actor):
else:
super().handlemessage(msg)
class Player(ba.Player['Team']):
"""Our player type for this game."""
def __init__(self) -> None:
self.score = 0
class Team(ba.Team[Player]):
"""Our team type for this game."""
@ -103,9 +108,12 @@ class Team(ba.Team[Player]):
self.score = 0
# ba_meta export game
class SimonSays(ba.TeamGameActivity[Player, Team]):
name = "Simon Says"
description = "You have to better do what Simon says!"
@classmethod
def get_available_settings(cls, sessiontype: Type[ba.Session]) -> List[ba.Setting]:
settings = [
@ -149,42 +157,43 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
self.counter_loop = None
self.time = 5000
self._r1 = 2
self.ct_text = ba.newnode('text',attrs={
self.ct_text = ba.newnode('text', attrs={
'in_world': True,
'text':'......',
'text': '......',
'shadow': 1.0,
'color': (1.0,1.0,1.0),
'color': (1.0, 1.0, 1.0),
'flatness': 0.5,
'position': (-5.627144702, 3.3275475, -9.572879116),
'scale': 0.05})
self.n1 = ba.newnode('locator',attrs={'shape':'circle','position':(-4,0,-6),
'color':(1,0,0),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n2 = ba.newnode('locator',attrs={'shape':'circle','position':(0,0,-6),
'color':(0,1,0),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n3 = ba.newnode('locator',attrs={'shape':'circle','position':(4,0,-6),
'color':(0,0,1),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n4 = ba.newnode('locator',attrs={'shape':'circle','position':(-4,0,-2),
'color':(1,1,0),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n5 = ba.newnode('locator',attrs={'shape':'circle','position':(0,0,-2),
'color':(0,1,1),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n6 = ba.newnode('locator',attrs={'shape':'circle','position':(4,0,-2),
'color':(1,0,1),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n7 = ba.newnode('locator',attrs={'shape':'circle','position':(-4,0,2),
'color':(.5,.5,.5),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n8 = ba.newnode('locator',attrs={'shape':'circle','position':(0,0,2),
'color':(.5,.325,0),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.n9 = ba.newnode('locator',attrs={'shape':'circle','position':(4,0,2),
'color':(1,1,1),'opacity':0.5,
'draw_beauty':True,'additive':True})
self.options = ["red", "green", "blue", "yellow", "teal", "purple", "gray", "orange", "white", "top", "bottom", "middle row", "left", "right", "center column", "outside"]
self.n1 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (-4, 0, -6),
'color': (1, 0, 0), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n2 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (0, 0, -6),
'color': (0, 1, 0), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n3 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (4, 0, -6),
'color': (0, 0, 1), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n4 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (-4, 0, -2),
'color': (1, 1, 0), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n5 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (0, 0, -2),
'color': (0, 1, 1), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n6 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (4, 0, -2),
'color': (1, 0, 1), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n7 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (-4, 0, 2),
'color': (.5, .5, .5), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n8 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (0, 0, 2),
'color': (.5, .325, 0), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.n9 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (4, 0, 2),
'color': (1, 1, 1), 'opacity': 0.5,
'draw_beauty': True, 'additive': True})
self.options = ["red", "green", "blue", "yellow", "teal", "purple", "gray", "orange",
"white", "top", "bottom", "middle row", "left", "right", "center column", "outside"]
self.default_music = ba.MusicType.FLAG_CATCHER
def get_instance_description(self) -> str:
@ -193,8 +202,8 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
def on_player_join(self, player: Player) -> None:
if self.has_begun():
ba.screenmessage(
ba.Lstr(resource = 'playerDelayedJoinText',
subs = [('${PLAYER}', player.getname(full=True))]),
ba.Lstr(resource='playerDelayedJoinText',
subs=[('${PLAYER}', player.getname(full=True))]),
color=(0, 1, 0),)
return
else:
@ -203,55 +212,63 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
def on_begin(self) -> None:
super().on_begin()
s = self.settings
_gameutils.animate_array(self.n1,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n2,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n3,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n4,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n5,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n6,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n7,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n8,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n9,'size',1,{0:[0.0],0.2:[self._r1*2.0]})
_gameutils.animate_array(self.n1, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n2, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n3, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n4, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n5, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n6, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n7, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n8, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
_gameutils.animate_array(self.n9, 'size', 1, {0: [0.0], 0.2: [self._r1*2.0]})
for team in self.teams:
team.score = 0
for player in self.players:
player.score = 0
# check for immediate end if theres only 1 player
if len(self.players) == 1:
ba.timer(4000, lambda: self.check_end(),timeformat=ba.TimeFormat.MILLISECONDS)
ba.timer(4000, lambda: self.check_end(), timeformat=ba.TimeFormat.MILLISECONDS)
else:
ba.timer(6000, self.call_round, timeformat=ba.TimeFormat.MILLISECONDS)
def spawn_player(self, player: PlayerType) -> ba.Actor:
assert player
spaz = self.spawn_player_spaz(player, position=(0 + random.uniform(-3.6, 3.6), 2.9, -2 + random.uniform(-3.6, 3.6)))
spaz = self.spawn_player_spaz(player, position=(
0 + random.uniform(-3.6, 3.6), 2.9, -2 + random.uniform(-3.6, 3.6)))
assert spaz.node
spaz.connect_controls_to_player(
enable_bomb=False,
enable_run = True,
enable_punch = self.settings["Enable Punching"],
enable_pickup = self.settings["Enable Picking Up"],
enable_jump = self.settings["Enable Jumping"])
enable_run=True,
enable_punch=self.settings["Enable Punching"],
enable_pickup=self.settings["Enable Picking Up"],
enable_jump=self.settings["Enable Jumping"])
def call_round(self) -> None:
if self.ended: return
if self.ended:
return
self.round_num += 1
self.num = random.randint(0, 15)
self.numa = self.num
self.simon = random.choice([True, False])
false_prefix = random.choices(['Simon say r', 'Simon said r', 'Simon r', 'Simons says r', 'Simons r', 'R'], weights=[35,45,45,39,49,100])[0]
false_prefix = random.choices(['Simon say r', 'Simon said r', 'Simon r',
'Simons says r', 'Simons r', 'R'], weights=[35, 45, 45, 39, 49, 100])[0]
if self.numa < 9:
if not self.simon: line = false_prefix + "un to the " + self.options[self.numa] + " circle!"
else: line = "Run to the " + self.options[self.numa] + " circle!"
if not self.simon:
line = false_prefix + "un to the " + self.options[self.numa] + " circle!"
else:
line = "Run to the " + self.options[self.numa] + " circle!"
elif self.numa < 15:
if not self.simon: line = false_prefix + "un to the " + self.options[self.numa] + "!"
else: line = "Run to the " + self.options[self.numa] + "!"
if not self.simon:
line = false_prefix + "un to the " + self.options[self.numa] + "!"
else:
line = "Run to the " + self.options[self.numa] + "!"
else:
if not self.simon: line = false_prefix + "un outside of the circles!"
else: line = "Run outside of the circles!"
if not self.simon:
line = false_prefix + "un outside of the circles!"
else:
line = "Run outside of the circles!"
if self.simon:
line = "Simon says " + line[0].lower() + line[1:]
@ -263,9 +280,11 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
duration=self.lifespan,
scale=2.0).autoretain()
self.now = 6
def dummy_check():
self.string = "...."
self.check_round()
def set_counter():
self.now = self.now - 1
if self.now == 0:
@ -276,39 +295,57 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
else:
self.ct_text.text = str(self.now)
ba.playsound(ba.getsound('tick'))
self.counter_loop = ba.Timer(self.speed, set_counter ,timeformat=ba.TimeFormat.MILLISECONDS,repeat=True)
self.counter_loop = ba.Timer(self.speed, set_counter,
timeformat=ba.TimeFormat.MILLISECONDS, repeat=True)
def check_round(self) -> None:
if self.ended: return
if self.ended:
return
for player in self.players:
if player.is_alive():
safe = True if self.options[self.numa] in self.in_circle(player.actor.node.position_center) else False
safe = True if self.options[self.numa] in self.in_circle(
player.actor.node.position_center) else False
if ((self.simon and safe == False) or ((not self.simon) and safe == True)):
player.team.score = self.round_num
player.actor.handlemessage(ba.DieMessage())
ba.timer(1633, self.call_round, timeformat=ba.TimeFormat.MILLISECONDS)
def in_circle(self, pos) -> None:
circles = []
x = pos[0]
z = pos[2]
if (x + 4) ** 2 + (z + 6) ** 2 < 4: circles.append("red")
elif (x) ** 2 + (z + 6) ** 2 < 4: circles.append("green")
elif (x - 4) ** 2 + (z + 6) ** 2 < 4: circles.append("blue")
elif (x + 4) ** 2 + (z + 2) ** 2 < 4: circles.append("yellow")
elif (x) ** 2 + (z + 2) ** 2 < 4: circles.append("teal")
elif (x - 4) ** 2 + (z + 2) ** 2 < 4: circles.append("purple")
elif (x + 4) ** 2 + (z - 2) ** 2 < 4: circles.append("gray")
elif (x) ** 2 + (z - 2) ** 2 < 4: circles.append("orange")
elif (x - 4) ** 2 + (z - 2) ** 2 < 4: circles.append("white")
else: circles.append("outside")
if x < -2: circles.append("left")
if x > 2: circles.append("right")
if x > -2 and x < 2: circles.append("center column")
if z > 0: circles.append("bottom")
if z < -4: circles.append("top")
if z < 0 and z > -4: circles.append("middle row")
if (x + 4) ** 2 + (z + 6) ** 2 < 4:
circles.append("red")
elif (x) ** 2 + (z + 6) ** 2 < 4:
circles.append("green")
elif (x - 4) ** 2 + (z + 6) ** 2 < 4:
circles.append("blue")
elif (x + 4) ** 2 + (z + 2) ** 2 < 4:
circles.append("yellow")
elif (x) ** 2 + (z + 2) ** 2 < 4:
circles.append("teal")
elif (x - 4) ** 2 + (z + 2) ** 2 < 4:
circles.append("purple")
elif (x + 4) ** 2 + (z - 2) ** 2 < 4:
circles.append("gray")
elif (x) ** 2 + (z - 2) ** 2 < 4:
circles.append("orange")
elif (x - 4) ** 2 + (z - 2) ** 2 < 4:
circles.append("white")
else:
circles.append("outside")
if x < -2:
circles.append("left")
if x > 2:
circles.append("right")
if x > -2 and x < 2:
circles.append("center column")
if z > 0:
circles.append("bottom")
if z < -4:
circles.append("top")
if z < 0 and z > -4:
circles.append("middle row")
return circles
def handlemessage(self, msg) -> None:
@ -329,5 +366,5 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
for player in self.players:
if player.is_alive():
i += 1
if i <= 2 :
if i <= 2:
ba.timer(0.6, lambda: self.end_game())

View file

@ -30,6 +30,7 @@ class NewBlast(Blast):
else:
return super().handlemessage(msg)
@dataclass
class RaceMine:
"""Holds info about a mine on the track."""
@ -552,7 +553,7 @@ class SquidRaceGame(ba.TeamGameActivity[Player, Team]):
'color': (1.0, 0.0, 0.0),
'attach': 'topCenter',
'position': (-220, -38),
'scale':(155, 65),
'scale': (155, 65),
'texture': ba.gettexture('uiAtlas'),
'model_transparent': ba.getmodel('meterTransparent')})
self._sgcountdown_text = ba.newnode(
@ -615,9 +616,9 @@ class SquidRaceGame(ba.TeamGameActivity[Player, Team]):
self._tick_timer = ba.timer(1.0, do_ticks, repeat=True)
def _start_squid_game(self) -> None:
easy = [4.5,5,5.5,6]
normal = [4,4.5,5]
hard = [3,3.5,4]
easy = [4.5, 5, 5.5, 6]
normal = [4, 4.5, 5]
hard = [3, 3.5, 4]
random_number = random.choice(
hard if self._sq_mode == 'Hard' else
normal if self._sq_mode == 'Normal' else easy)
@ -665,18 +666,18 @@ class SquidRaceGame(ba.TeamGameActivity[Player, Team]):
posy = float("%.1f" % player.customdata['position'][2])
posx_list = [
round(posx,1),round(posx+0.1,1),round(posx+0.2,1),
round(posx-0.1,1),round(posx-0.2,1)]
round(posx, 1), round(posx+0.1, 1), round(posx+0.2, 1),
round(posx-0.1, 1), round(posx-0.2, 1)]
current_posx = float("%.1f" % player.actor.node.position[0])
posz_list = [
round(posz,1),round(posz+0.1,1),round(posz+0.2,1),
round(posz-0.1,1),round(posz-0.2,1)]
round(posz, 1), round(posz+0.1, 1), round(posz+0.2, 1),
round(posz-0.1, 1), round(posz-0.2, 1)]
current_posz = float("%.1f" % player.actor.node.position[1])
posy_list = [
round(posy,1),round(posy+0.1,1),round(posy+0.2,1),
round(posy-0.1,1),round(posy-0.2,1)]
round(posy, 1), round(posy+0.1, 1), round(posy+0.2, 1),
round(posy-0.1, 1), round(posy-0.2, 1)]
current_posy = float("%.1f" % player.actor.node.position[2])
if not (current_posx in posx_list) or not (

View file

@ -82,6 +82,7 @@ class PlayerSpaz_Zom(PlayerSpaz):
return super().handlemessage(m)
return None
class PlayerZombie(PlayerSpaz):
def handlemessage(self, m: Any) -> Any:
if isinstance(m, ba.HitMessage):
@ -101,6 +102,7 @@ class PlayerZombie(PlayerSpaz):
else:
super().handlemessage(m)
class zBotSet(SpazBotSet):
def start_moving(self) -> None:
"""Start processing bot AI updates so they start doing their thing."""
@ -139,6 +141,7 @@ class zBotSet(SpazBotSet):
bot.set_player_points(player_pts)
bot.update_ai()
class Team(ba.Team[Player]):
"""Our team type for this game."""
@ -242,8 +245,8 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
activity = ba.getactivity()
my_factory = SpazFactory.get()
appears = ['Kronk','Zoe','Pixel','Agent Johnson',
'Bones','Frosty','Kronk2']
appears = ['Kronk', 'Zoe', 'Pixel', 'Agent Johnson',
'Bones', 'Frosty', 'Kronk2']
myAppear = copy.copy(ba.app.spaz_appearances['Kronk'])
myAppear.name = 'Kronk2'
ba.app.spaz_appearances['Kronk2'] = myAppear
@ -252,7 +255,7 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
med = my_factory.spaz_media
med['Kronk2']['head_model'] = med['Zoe']['head_model']
med['Kronk2']['color_texture'] = med['Agent Johnson']['color_texture']
med['Kronk2']['color_mask_texture']=med['Pixel']['color_mask_texture']
med['Kronk2']['color_mask_texture'] = med['Pixel']['color_mask_texture']
med['Kronk2']['torso_model'] = med['Bones']['torso_model']
med['Kronk2']['pelvis_model'] = med['Pixel']['pelvis_model']
med['Kronk2']['upper_arm_model'] = med['Frosty']['upper_arm_model']
@ -351,9 +354,9 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
self._bots = zBotSet()
#Set colors and character for ToughGuyBot to be zombie
setattr(BrawlerBot, 'color', (0.4,0.1,0.05))
setattr(BrawlerBot, 'highlight', (0.2,0.4,0.3))
# Set colors and character for ToughGuyBot to be zombie
setattr(BrawlerBot, 'color', (0.4, 0.1, 0.05))
setattr(BrawlerBot, 'highlight', (0.2, 0.4, 0.3))
setattr(BrawlerBot, 'character', 'Kronk2')
# start some timers to spawn bots
thePt = self.map.get_ffa_start_position(self.players)
@ -434,7 +437,6 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
icon.update_for_lives()
xval += x_offs
def _get_spawn_point(self, player: Player) -> ba.Vec3 | None:
del player # Unused.
@ -612,7 +614,7 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
try:
pos = player.actor.node.position
except Exception as e:
print('EXC getting player pos in bsElim',e)
print('EXC getting player pos in bsElim', e)
return
if player.lives > 0:
popuptext.PopupText('x' + str(player.lives - 1),
@ -692,7 +694,8 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
elif isinstance(msg, SpazBotDiedMessage):
self._onSpazBotDied(msg)
super().handlemessage(msg)#bs.PopupText("died",position=self._position,color=popupColor,scale=popupScale).autoRetain()
# bs.PopupText("died",position=self._position,color=popupColor,scale=popupScale).autoRetain()
super().handlemessage(msg)
else:
super().handlemessage(msg)
@ -734,15 +737,15 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
self._round_end_timer = ba.Timer(0.5, self.end_game)
def spawn_zombie(self) -> None:
#We need a Z height...
# We need a Z height...
thePt = list(self.get_random_point_in_play())
thePt2 = self.map.get_ffa_start_position(self.players)
thePt[1] = thePt2[1]
ba.timer(0.1, ba.Call(
self._bots.spawn_bot, BrawlerBot, pos=thePt, spawn_time=1.0))
def _onSpazBotDied(self,DeathMsg) -> None:
#Just in case we are over max...
def _onSpazBotDied(self, DeathMsg) -> None:
# Just in case we are over max...
if len(self._bots.get_living_bots()) < self._max_zombies:
self.zombieQ += 1
@ -762,37 +765,38 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
myMap = self.map.getname()
if myMap == 'Doom Shroom':
while True:
x = random.uniform(-1.0,1.0)
y = random.uniform(-1.0,1.0)
if x*x+y*y < 1.0: break
return ((8.0*x,8.0,-3.5+5.0*y))
x = random.uniform(-1.0, 1.0)
y = random.uniform(-1.0, 1.0)
if x*x+y*y < 1.0:
break
return ((8.0*x, 8.0, -3.5+5.0*y))
elif myMap == 'Rampage':
x = random.uniform(-6.0,7.0)
y = random.uniform(-6.0,-2.5)
x = random.uniform(-6.0, 7.0)
y = random.uniform(-6.0, -2.5)
return ((x, 8.0, y))
elif myMap == 'Hockey Stadium':
x = random.uniform(-11.5,11.5)
y = random.uniform(-4.5,4.5)
x = random.uniform(-11.5, 11.5)
y = random.uniform(-4.5, 4.5)
return ((x, 5.0, y))
elif myMap == 'Courtyard':
x = random.uniform(-4.3,4.3)
y = random.uniform(-4.4,0.3)
x = random.uniform(-4.3, 4.3)
y = random.uniform(-4.4, 0.3)
return ((x, 8.0, y))
elif myMap == 'Crag Castle':
x = random.uniform(-6.7,8.0)
y = random.uniform(-6.0,0.0)
x = random.uniform(-6.7, 8.0)
y = random.uniform(-6.0, 0.0)
return ((x, 12.0, y))
elif myMap == 'Big G':
x = random.uniform(-8.7,8.0)
y = random.uniform(-7.5,6.5)
x = random.uniform(-8.7, 8.0)
y = random.uniform(-7.5, 6.5)
return ((x, 8.0, y))
elif myMap == 'Football Stadium':
x = random.uniform(-12.5,12.5)
y = random.uniform(-5.0,5.5)
x = random.uniform(-12.5, 12.5)
y = random.uniform(-5.0, 5.5)
return ((x, 8.0, y))
else:
x = random.uniform(-5.0,5.0)
y = random.uniform(-6.0,0.0)
x = random.uniform(-5.0, 5.0)
y = random.uniform(-6.0, 0.0)
return ((x, 8.0, y))
def _update_scoreboard(self) -> None: