[ci] auto-format

This commit is contained in:
Loup-Garou911XD 2023-05-15 10:58:00 +00:00 committed by github-actions[bot]
parent 4af785998d
commit 2ac90c8677
10 changed files with 1225 additions and 1214 deletions

View file

@ -4,7 +4,6 @@
# https://discord.gg/ucyaesh
# ba_meta require api 7
from __future__ import annotations
@ -18,7 +17,6 @@ if TYPE_CHECKING:
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
class State:
def __init__(self, bomb=None, grab=False, punch=False, curse=False, required=False, final=False, name=''):
self.bomb = bomb
@ -56,8 +54,10 @@ states = [ State(bomb='normal', name='Basic Bombs'),
State(punch=True, name='Punching only'),
State(curse=True, name='Cursed', final=True)]
class Player(ba.Player['Team']):
"""Our player type for this game."""
def __init__(self):
self.state = None

View file

@ -475,12 +475,12 @@ class CollectorGame(ba.TeamGameActivity[Player, Team]):
count=int(6.4+random.random()*24),
scale=1.2,
spread=2.0,
chunk_type='spark');
chunk_type='spark')
ba.emitfx(
position=capsule.node.position,
velocity=(0, 0, 0),
count=int(4.0+random.random()*6),
emit_type='tendrils');
emit_type='tendrils')
else:
player.capsules += 1
ba.playsound(
@ -514,6 +514,7 @@ class CollectorGame(ba.TeamGameActivity[Player, Team]):
0.0: player.light.intensity,
0.1: intensity
})
def newintensity():
player.light.intensity = intensity
ba.timer(0.1, newintensity)

View file

@ -39,15 +39,18 @@ class BallType(Enum):
# increase the next ball speed but less than MEDIUM.
# Ball color is crimson(purple+red = pinky color type).
# this dict decide the ball_type spawning rate like powerup box
ball_type_dict: dict[BallType, int] = {
BallType.EASY: 3,
BallType.MEDIUM: 2,
BallType.HARD: 1,
};
}
class Ball(ba.Actor):
""" Shooting Ball """
def __init__(self,
position: Sequence[float],
velocity: Sequence[float],
@ -56,11 +59,11 @@ class Ball(ba.Actor):
gravity_scale: float = 1.0,
) -> NoReturn:
super().__init__();
super().__init__()
shared = SharedObjects.get();
shared = SharedObjects.get()
ball_material = ba.Material();
ball_material = ba.Material()
ball_material.add_actions(
conditions=(
(
@ -72,7 +75,7 @@ class Ball(ba.Actor):
('they_have_material', shared.object_material),
),
actions=('modify_node_collision', 'collide', False),
);
)
self.node = ba.newnode(
'prop',
@ -89,19 +92,19 @@ class Ball(ba.Actor):
'density': 4.0, # increase density of ball so ball collide with player with heavy force. # ammm very bad grammer
'materials': (ball_material,),
},
);
)
# die the ball manually incase the ball doesn't fall the outside of the map
ba.timer(2.5, ba.WeakCall(self.handlemessage, ba.DieMessage()));
ba.timer(2.5, ba.WeakCall(self.handlemessage, ba.DieMessage()))
# i am not handling anything in this ball Class(except for diemessage).
# all game things and logics going to be in the box class
def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, ba.DieMessage):
self.node.delete();
self.node.delete()
else:
super().handlemessage(msg);
super().handlemessage(msg)
class Box(ba.Actor):
@ -112,11 +115,11 @@ class Box(ba.Actor):
velocity: Sequence[float],
) -> NoReturn:
super().__init__();
super().__init__()
shared = SharedObjects.get();
shared = SharedObjects.get()
# self.ball_jump = 0.0;
no_hit_material = ba.Material();
no_hit_material = ba.Material()
# we don't need that the box was move and collide with objects.
no_hit_material.add_actions(
conditions=(
@ -125,7 +128,7 @@ class Box(ba.Actor):
('they_have_material', shared.attack_material),
),
actions=('modify_part_collision', 'collide', False),
);
)
no_hit_material.add_actions(
conditions=(
@ -137,7 +140,7 @@ class Box(ba.Actor):
('modify_part_collision', 'collide', False),
('modify_part_collision', 'physical', False),
),
);
)
self.node = ba.newnode(
'prop',
@ -155,7 +158,7 @@ class Box(ba.Actor):
'reflection_scale': [1.0],
'materials': (no_hit_material,),
},
);
)
# light
self.light = ba.newnode(
"light",
@ -165,8 +168,8 @@ class Box(ba.Actor):
'intensity': 0.8,
'color': (0.0, 1.0, 0.0),
}
);
self.node.connectattr("position", self.light, "position");
)
self.node.connectattr("position", self.light, "position")
# Drawing circle and circleOutline in radius of 3,
# so player can see that how close he is to the box.
# If player is inside this circle the ball speed will increase.
@ -182,7 +185,7 @@ class Box(ba.Actor):
'additive': True,
},
)
self.node.connectattr("position", circle, "position");
self.node.connectattr("position", circle, "position")
# also adding a outline cause its look nice.
circle_outline = ba.newnode(
"locator",
@ -195,76 +198,76 @@ class Box(ba.Actor):
'draw_beauty': False,
'additive': True,
},
);
self.node.connectattr("position", circle_outline, "position");
)
self.node.connectattr("position", circle_outline, "position")
# all ball attribute that we need.
self.ball_type: BallType = BallType.EASY;
self.shoot_timer: ba.Timer | None = None;
self.shoot_speed: float = 0.0;
self.ball_type: BallType = BallType.EASY
self.shoot_timer: ba.Timer | None = None
self.shoot_speed: float = 0.0
# this force the shoot if player is inside the red circle.
self.force_shoot_speed: float = 0.0;
self.ball_mag = 3000;
self.ball_gravity: float = 1.0;
self.ball_tex: ba.Texture | None = None;
self.force_shoot_speed: float = 0.0
self.ball_mag = 3000
self.ball_gravity: float = 1.0
self.ball_tex: ba.Texture | None = None
# only for Hard ball_type
self.player_facing_direction: list[float, float] = [0.0, 0.0];
self.player_facing_direction: list[float, float] = [0.0, 0.0]
# ball shoot soound.
self.shoot_sound = ba.getsound('laserReverse');
self.shoot_sound = ba.getsound('laserReverse')
# same as "powerupdist"
self.ball_type_dist: list[BallType] = [];
self.ball_type_dist: list[BallType] = []
for ball in ball_type_dict:
for _ in range(ball_type_dict[ball]):
self.ball_type_dist.append(ball);
self.ball_type_dist.append(ball)
# Here main logic of game goes here.
# like shoot balls, shoot speed, anything we want goes here(except for some thing).
def start_shoot(self) -> NoReturn:
# getting all allive players in a list.
alive_players_list = self.activity.get_alive_players();
alive_players_list = self.activity.get_alive_players()
# make sure that list is not Empty.
if len(alive_players_list) > 0:
# choosing a random player from list.
target_player = choice(alive_players_list);
target_player = choice(alive_players_list)
# highlight the target player
self.highlight_target_player(target_player);
self.highlight_target_player(target_player)
# to finding difference between player and box.
# we just need to subtract player pos and ball pos.
# Same logic as eric applied in Target Practice Gamemode.
difference = ba.Vec3(target_player.position) - ba.Vec3(self.node.position);
difference = ba.Vec3(target_player.position) - ba.Vec3(self.node.position)
# discard Y position so ball shoot more straight.
difference[1] = 0.0
# and now, this length method returns distance in float.
# we're gonna use this value for calculating player analog stick
distance = difference.length();
distance = difference.length()
# shoot a random BallType
self.upgrade_ball_type(choice(self.ball_type_dist));
self.upgrade_ball_type(choice(self.ball_type_dist))
# and check the ball_type and upgrade it gravity_scale, texture, next ball speed.
self.check_ball_type(self.ball_type);
self.check_ball_type(self.ball_type)
# For HARD ball i am just focusing on player analog stick facing direction.
# Not very accurate and that's we need.
if self.ball_type == BallType.HARD:
self.calculate_player_analog_stick(target_player, distance);
self.calculate_player_analog_stick(target_player, distance)
else:
self.player_facing_direction = [0.0, 0.0];
self.player_facing_direction = [0.0, 0.0]
pos = self.node.position;
pos = self.node.position
if self.ball_type == BallType.MEDIUM or self.ball_type == BallType.HARD:
# Target head by increasing Y pos.
# How this work? cause ball gravity_scale is ......
pos = (pos[0], pos[1]+.25, pos[2]);
pos = (pos[0], pos[1]+.25, pos[2])
# ball is generating..
ball = Ball(
@ -273,14 +276,14 @@ class Box(ba.Actor):
texture=self.ball_tex,
gravity_scale=self.ball_gravity,
body_scale=1.0,
).autoretain();
).autoretain()
# shoot Animation and sound.
self.shoot_animation();
self.shoot_animation()
# force the shoot speed if player try to go inside the red circle.
if self.force_shoot_speed != 0.0:
self.shoot_speed = self.force_shoot_speed;
self.shoot_speed = self.force_shoot_speed
# push the ball to the player
ball.node.handlemessage(
@ -296,41 +299,41 @@ class Box(ba.Actor):
difference[0] + self.player_facing_direction[0], # force direction X
difference[1], # force direction Y
difference[2] + self.player_facing_direction[1], # force direction Z
);
)
# creating our timer and shoot the ball again.(and we create a loop)
self.shoot_timer = ba.Timer(self.shoot_speed, self.start_shoot);
self.shoot_timer = ba.Timer(self.shoot_speed, self.start_shoot)
def upgrade_ball_type(self, ball_type: BallType) -> NoReturn:
self.ball_type = ball_type;
self.ball_type = ball_type
def check_ball_type(self, ball_type: BallType) -> NoReturn:
if ball_type == BallType.EASY:
self.shoot_speed = 0.8;
self.ball_gravity = 1.0;
self.shoot_speed = 0.8
self.ball_gravity = 1.0
# next ball shoot speed
self.ball_mag = 3000;
self.ball_mag = 3000
# box light color and ball tex
self.light.color = (1.0, 1.0, 0.0);
self.ball_tex = ba.gettexture('egg4');
self.light.color = (1.0, 1.0, 0.0)
self.ball_tex = ba.gettexture('egg4')
elif ball_type == BallType.MEDIUM:
self.ball_mag = 3000;
self.ball_mag = 3000
# decrease the gravity scale so, ball shoot without falling and straight.
self.ball_gravity = 0.0;
self.ball_gravity = 0.0
# next ball shoot speed.
self.shoot_speed = 0.4;
self.shoot_speed = 0.4
# box light color and ball tex.
self.light.color = (1.0, 0.0, 1.0);
self.ball_tex = ba.gettexture('egg3');
self.light.color = (1.0, 0.0, 1.0)
self.ball_tex = ba.gettexture('egg3')
elif ball_type == BallType.HARD:
self.ball_mag = 2500;
self.ball_gravity = 0.0;
self.ball_mag = 2500
self.ball_gravity = 0.0
# next ball shoot speed.
self.shoot_speed = 0.6;
self.shoot_speed = 0.6
# box light color and ball tex.
self.light.color = (1.0, 0.2, 1.0);
self.ball_tex = ba.gettexture('egg1');
self.light.color = (1.0, 0.2, 1.0)
self.ball_tex = ba.gettexture('egg1')
def shoot_animation(self) -> NoReturn:
@ -341,9 +344,9 @@ class Box(ba.Actor):
0.05: 1.7,
0.10: 1.4,
}
);
)
# playing shoot sound.
ba.playsound(self.shoot_sound, position = self.node.position);
ba.playsound(self.shoot_sound, position=self.node.position)
def highlight_target_player(self, player: ba.Player) -> NoReturn:
@ -356,7 +359,7 @@ class Box(ba.Actor):
'intensity': 1.0,
'color': (1.0, 0.0, 0.0),
}
);
)
ba.animate(
light,
"radius", {
@ -369,7 +372,7 @@ class Box(ba.Actor):
0.35: 0.02,
0.40: 0.00,
}
);
)
# And a circle outline with ugly animation.
circle_outline = ba.newnode(
"locator",
@ -381,7 +384,7 @@ class Box(ba.Actor):
'draw_beauty': False,
'additive': True,
},
);
)
ba.animate_array(
circle_outline,
'size',
@ -395,16 +398,16 @@ class Box(ba.Actor):
0.35: [0.6],
0.40: [0.0],
}
);
)
# coonect it and...
player.actor.node.connectattr("position", light, "position");
player.actor.node.connectattr("position", circle_outline, "position");
player.actor.node.connectattr("position", light, "position")
player.actor.node.connectattr("position", circle_outline, "position")
# immediately delete the node after another player has been targeted.
self.shoot_speed = 0.5 if self.shoot_speed == 0.0 else self.shoot_speed;
ba.timer(self.shoot_speed, light.delete);
ba.timer(self.shoot_speed, circle_outline.delete);
self.shoot_speed = 0.5 if self.shoot_speed == 0.0 else self.shoot_speed
ba.timer(self.shoot_speed, light.delete)
ba.timer(self.shoot_speed, circle_outline.delete)
def calculate_player_analog_stick(self, player: ba.Player, distance: float) -> NoReturn:
# at first i was very confused how i can read the player analog stick \
@ -412,14 +415,14 @@ class Box(ba.Actor):
# and i got it how analog stick values are works.
# just need to store analog stick facing direction and need some calculation according how far player pushed analog stick.
# Notice that how vertical direction is inverted, so we need to put a minus infront of veriable.(so ball isn't shoot at wrong direction).
self.player_facing_direction[0] = player.actor.node.move_left_right;
self.player_facing_direction[1] = -player.actor.node.move_up_down;
self.player_facing_direction[0] = player.actor.node.move_left_right
self.player_facing_direction[1] = -player.actor.node.move_up_down
# if player is too close and the player pushing his analog stick fully the ball shoot's too far away to player.
# so, we need to reduce the value of "self.player_facing_direction" to fix this problem.
if distance <= 3:
self.player_facing_direction[0] = 0.4 if self.player_facing_direction[0] > 0 else -0.4;
self.player_facing_direction[1] = 0.4 if self.player_facing_direction[0] > 0 else -0.4;
self.player_facing_direction[0] = 0.4 if self.player_facing_direction[0] > 0 else -0.4
self.player_facing_direction[1] = 0.4 if self.player_facing_direction[0] > 0 else -0.4
# same problem to long distance but in reverse, the ball can't reach to the player,
# its because player analog stick value is between 1 and -1,
# and this value is low to shoot ball forward to Player if player is too far from the box.
@ -428,34 +431,34 @@ class Box(ba.Actor):
# So many calculation according to how analog stick pushed by player.
# Horizontal(left-right) calculation
if self.player_facing_direction[0] > 0.4:
self.player_facing_direction[0] = 1.5;
self.player_facing_direction[0] = 1.5
elif self.player_facing_direction[0] < -0.4:
self.player_facing_direction[0] = -1.5;
self.player_facing_direction[0] = -1.5
else:
if self.player_facing_direction[0] > 0.0:
self.player_facing_direction[0] = 0.2;
self.player_facing_direction[0] = 0.2
elif self.player_facing_direction[0] < 0.0:
self.player_facing_direction[0] = -0.2;
self.player_facing_direction[0] = -0.2
else:
self.player_facing_direction[0] = 0.0;
self.player_facing_direction[0] = 0.0
# Vertical(up-down) calculation.
if self.player_facing_direction[1] > 0.4:
self.player_facing_direction[1] = 1.5;
self.player_facing_direction[1] = 1.5
elif self.player_facing_direction[1] < -0.4:
self.player_facing_direction[1] = -1.5;
self.player_facing_direction[1] = -1.5
else:
if self.player_facing_direction[1] > 0.0:
self.player_facing_direction[1] = 0.2;
self.player_facing_direction[1] = 0.2
elif self.player_facing_direction[1] < 0.0:
self.player_facing_direction[1] = -0.2;
self.player_facing_direction[1] = -0.2
else:
self.player_facing_direction[1] = -0.0;
self.player_facing_direction[1] = -0.0
# if we want stop the ball shootes
def stop_shoot(self) -> NoReturn:
# Kill the timer.
self.shoot_timer = None;
self.shoot_timer = None
class Player(ba.Player['Team']):
@ -470,11 +473,13 @@ class Team(ba.Team[Player]):
# and main thing don't allow player to camp inside of box are going in this class.
# ba_meta export game
class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
# defining name, description and settings..
name = 'Dodge the ball';
description = 'Survive from shooting balls';
name = 'Dodge the ball'
description = 'Survive from shooting balls'
available_settings = [
ba.IntSetting(
@ -487,14 +492,14 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
]
# Don't allow joining after we start.
allow_mid_activity_joins = False;
allow_mid_activity_joins = False
@classmethod
def supports_session_type(cls, sessiontype: type[ba.Session]) -> bool:
# We support team and ffa sessions.
return issubclass(sessiontype, ba.FreeForAllSession) or issubclass(
sessiontype, ba.DualTeamSession,
);
)
@classmethod
def get_supported_maps(cls, sessiontype: type[ba.Session]) -> list[str]:
@ -502,75 +507,75 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
# bombsquad have "Doom Shroom" map.
# Not perfect map for this game mode but its fine for this gamemode.
# the problem is that Doom Shroom is not a perfect circle and not flat also.
return ['Doom Shroom'];
return ['Doom Shroom']
def __init__(self, settings: dict):
super().__init__(settings);
self._epic_mode = bool(settings['Epic Mode']);
self.countdown_time = int(settings['Cooldown']);
super().__init__(settings)
self._epic_mode = bool(settings['Epic Mode'])
self.countdown_time = int(settings['Cooldown'])
self.check_player_pos_timer: ba.Timer | None = None;
self.shield_drop_timer: ba.Timer | None = None;
self.check_player_pos_timer: ba.Timer | None = None
self.shield_drop_timer: ba.Timer | None = None
# cooldown and Box
self._countdown: OnScreenCountdown | None = None;
self.box: Box | None = None;
self._countdown: OnScreenCountdown | None = None
self.box: Box | None = None
# this lists for scoring.
self.joined_player_list: list[ba.Player] = [];
self.dead_player_list: list[ba.Player] = [];
self.joined_player_list: list[ba.Player] = []
self.dead_player_list: list[ba.Player] = []
# normally play RUN AWAY music cause is match with our gamemode at.. my point,
# but in epic switch to EPIC.
self.slow_motion = self._epic_mode;
self.slow_motion = self._epic_mode
self.default_music = (
ba.MusicType.EPIC if self._epic_mode else ba.MusicType.RUN_AWAY
);
)
def get_instance_description(self) -> str | Sequence:
return 'Keep away as possible as you can';
return 'Keep away as possible as you can'
# add a tiny text under our game name.
def get_instance_description_short(self) -> str | Sequence:
return 'Dodge the shooting balls';
return 'Dodge the shooting balls'
def on_begin(self) -> NoReturn:
super().on_begin();
super().on_begin()
# spawn our box at middle of the map
self.box = Box(
position=(0.5, 2.7, -3.9),
velocity=(0.0, 0.0, 0.0),
).autoretain();
).autoretain()
# create our cooldown
self._countdown = OnScreenCountdown(
duration=self.countdown_time,
endcall=self.play_victory_sound_and_end,
);
)
# and starts the cooldown and shootes.
ba.timer(5.0, self._countdown.start);
ba.timer(5.0, self.box.start_shoot);
ba.timer(5.0, self._countdown.start)
ba.timer(5.0, self.box.start_shoot)
# start checking all player pos.
ba.timer(5.0, self.check_player_pos);
ba.timer(5.0, self.check_player_pos)
# drop shield every ten Seconds
# need five seconds delay Because shootes start after 5 seconds.
ba.timer(15.0, self.drop_shield);
ba.timer(15.0, self.drop_shield)
# This function returns all alive players in game.
# i thinck you see this function in Box class.
def get_alive_players(self) -> Sequence[ba.Player]:
alive_players = [];
alive_players = []
for team in self.teams:
for player in team.players:
if player.is_alive():
alive_players.append(player);
alive_players.append(player)
return alive_players;
return alive_players
# let's disallowed camping inside of box by doing a blast and increasing ball shoot speed.
def check_player_pos(self):
@ -578,14 +583,14 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
for player in self.get_alive_players():
# same logic as applied for the ball
difference = ba.Vec3(player.position) - ba.Vec3(self.box.node.position);
difference = ba.Vec3(player.position) - ba.Vec3(self.box.node.position)
distance = difference.length();
distance = difference.length()
if distance < 3:
self.box.force_shoot_speed = 0.2;
self.box.force_shoot_speed = 0.2
else:
self.box.force_shoot_speed = 0.0;
self.box.force_shoot_speed = 0.0
if distance < 0.5:
Blast(
@ -593,7 +598,7 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
velocity=self.box.node.velocity,
blast_type='normal',
blast_radius=1.0,
).autoretain();
).autoretain()
PopupText(
position=self.box.node.position,
@ -601,53 +606,53 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
random_offset=0.0,
scale=2.0,
color=self.box.light.color,
).autoretain();
).autoretain()
# create our timer and start looping it
self.check_player_pos_timer = ba.Timer(0.1, self.check_player_pos);
self.check_player_pos_timer = ba.Timer(0.1, self.check_player_pos)
# drop useless shield's too give player temptation.
def drop_shield(self) -> NoReturn:
pos = self.box.node.position;
pos = self.box.node.position
PowerupBox(
position=(pos[0] + 4.0, pos[1] + 3.0, pos[2]),
poweruptype='shield',
).autoretain();
).autoretain()
PowerupBox(
position=(pos[0] - 4.0, pos[1] + 3.0, pos[2]),
poweruptype='shield',
).autoretain();
).autoretain()
self.shield_drop_timer = ba.Timer(10.0, self.drop_shield);
self.shield_drop_timer = ba.Timer(10.0, self.drop_shield)
# when cooldown time up i don't want that the game end immediately.
def play_victory_sound_and_end(self) -> NoReturn:
# kill timers
self.box.stop_shoot();
self.box.stop_shoot()
self.check_player_pos_timer = None
self.shield_drop_timer = None
ba.timer(2.0, self.end_game);
ba.timer(2.0, self.end_game)
# this function runs when A player spawn in map
def spawn_player(self, player: Player) -> NoReturn:
spaz = self.spawn_player_spaz(player);
spaz = self.spawn_player_spaz(player)
# reconnect this player's controls.
# without bomb, punch and pickup.
spaz.connect_controls_to_player(
enable_punch=False, enable_bomb=False, enable_pickup=False,
);
)
# storing all players for ScorinG.
self.joined_player_list.append(player);
self.joined_player_list.append(player)
# Also lets have them make some noise when they die.
spaz.play_big_death_sound = True;
spaz.play_big_death_sound = True
# very helpful function to check end game when player dead or leav.
def _check_end_game(self) -> bool:
@ -669,10 +674,10 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
# this function called when player leave.
def on_player_leave(self, player: Player) -> NoReturn:
# Augment default behavior.
super().on_player_leave(player);
super().on_player_leave(player)
# checking end game.
self._check_end_game();
self._check_end_game()
# this gamemode needs to handle only one msg "PlayerDiedMessage".
def handlemessage(self, msg: Any) -> Any:
@ -680,13 +685,13 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
if isinstance(msg, ba.PlayerDiedMessage):
# Augment standard behavior.
super().handlemessage(msg);
super().handlemessage(msg)
# and storing the dead player records in our dead_player_list.
self.dead_player_list.append(msg.getplayer(Player));
self.dead_player_list.append(msg.getplayer(Player))
# check the end game.
ba.timer(1.0, self._check_end_game);
ba.timer(1.0, self._check_end_game)
def end_game(self):
# kill timers
@ -758,5 +763,3 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
results.set_team_score(team, int(10 * max_index))
# and end the game
self.end(results=results)

View file

@ -225,7 +225,6 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
scoring_team.time_remaining = max(
0, scoring_team.time_remaining - 1)
self._update_scoreboard()
# announce numbers we have sounds for
@ -286,7 +285,8 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
self._invicible_one_player = player
if self._invicible_one_is_lazy:
player.actor.connect_controls_to_player(enable_punch = False, enable_pickup = False, enable_bomb = False)
player.actor.connect_controls_to_player(
enable_punch=False, enable_pickup=False, enable_bomb=False)
if player.actor.node.torso_model != None:
player.actor.node.color_mask_texture = None
player.actor.node.color_texture = None
@ -310,7 +310,6 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
player.actor.node.name = ''
def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, ba.PlayerDiedMessage):
# Augment standard behavior.

View file

@ -1,12 +1,16 @@
# ba_meta require api 7
from typing import Sequence
import ba, _ba, random
import ba
import _ba
import random
from bastd.actor.spaz import Spaz
from bastd.actor.scoreboard import Scoreboard
class Player(ba.Player['Team']):
"""Our player type for this game."""
class Team(ba.Team[Player]):
"""Our team type for this game."""
@ -14,14 +18,17 @@ class Team(ba.Team[Player]):
super().__init__()
self.score = 1
class ChooseingSpazHitMessage:
def __init__(self, hitter: Player) -> None:
self.hitter = hitter
class ChooseingSpazDieMessage:
def __init__(self, killer: Player) -> None:
self.killer = killer
class ChooseingSpaz(Spaz):
def __init__(
self,
@ -64,7 +71,6 @@ class ChooseingSpaz(Spaz):
self.activity.handlemessage(ChooseingSpazHitMessage(player))
self.last_player_attacked_by = player
elif isinstance(msg, ba.DieMessage):
player = self.last_player_attacked_by
@ -74,8 +80,6 @@ class ChooseingSpaz(Spaz):
self.loc.delete()
def stand(self, pos=(0, 0, 0), angle=0):
self.handlemessage(ba.StandMessage(pos, angle))
@ -84,6 +88,7 @@ class ChooseingSpaz(Spaz):
self.node.highlight = highlight
self.loc.color = color
class ChooseBilbord(ba.Actor):
def __init__(self, player: Player, delay=0.1) -> None:
super().__init__()
@ -123,7 +128,8 @@ class ChooseBilbord(ba.Actor):
},
)
ba.animate_array(self.node, "scale", keys={0 + delay:[0,0], 0.05 + delay:[self.scale, self.scale]}, size=1)
ba.animate_array(self.node, "scale", keys={
0 + delay: [0, 0], 0.05 + delay: [self.scale, self.scale]}, size=1)
ba.animate(self.name_node, "scale", {0 + delay: 0, 0.07 + delay: 1})
def handlemessage(self, msg):
@ -139,6 +145,8 @@ class ChooseBilbord(ba.Actor):
ba.timer(0.2, __delete)
# ba_meta export game
class LastPunchStand(ba.TeamGameActivity[Player, Team]):
name = "Last Punch Stand"
description = "Last one punchs the choosing spaz wins"
@ -202,7 +210,8 @@ class LastPunchStand(ba.TeamGameActivity[Player, Team]):
def end_game(self) -> None:
results = ba.GameResults()
for team in self.teams:
if self.choosed_player and (team.id == self.choosed_player.team.id): team.score += 100
if self.choosed_player and (team.id == self.choosed_player.team.id):
team.score += 100
results.set_team_score(team, team.score)
self.end(results=results)

View file

@ -6,7 +6,8 @@ from typing import TYPE_CHECKING
import random
import enum
import ba, _ba
import ba
import _ba
from bastd.actor.scoreboard import Scoreboard
from bastd.actor.powerupbox import PowerupBox
@ -300,12 +301,14 @@ class RailBullet(ba.Actor):
# ------------------Railgun-------------------------
class Player(ba.Player['Team']):
"""Our player"""
class Team(ba.Team[Player]):
"""Our team"""
def __init__(self) -> None:
self.score = 0

View file

@ -14,7 +14,8 @@ import random
from typing import TYPE_CHECKING
from dataclasses import dataclass
import ba, _ba
import ba
import _ba
from bastd.actor.bomb import Bomb
from bastd.actor.playerspaz import PlayerSpaz
from bastd.actor.scoreboard import Scoreboard
@ -435,7 +436,6 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
'text': 'By itsre3'
}))
# Throw a timer up on-screen.
self._time_text = ba.NodeActor(
ba.newnode('text',
@ -543,7 +543,6 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
self._spawn_bomb,
repeat=True)
def knock_players():
activity = _ba.get_foreground_host_activity()
gnode = ba.getactivity().globalsnode
@ -583,7 +582,6 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
self._race_started = True
def _update_player_order(self) -> None:
# Calc all player distances.

View file

@ -18,27 +18,33 @@ from bastd.actor import bomb as stdbomb
if TYPE_CHECKING:
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
class ScoreMessage:
"""It will help us with the scores."""
def __init__(self, player: Player):
self.player = player
def getplayer(self):
return self.player
class Player(ba.Player['Team']):
"""Our player type for this game."""
def __init__(self) -> None:
self.mines = []
self.actived = None
class Team(ba.Team[Player]):
"""Our team type for this game."""
def __init__(self) -> None:
self.score = 0
lang = ba.app.lang.language
if lang == 'Spanish':
description = 'Sobrevive a un número determinado de minas para ganar.'
@ -50,10 +56,13 @@ else:
join_description = "Run and don't get killed."
view_description = 'survive ${ARG1} mines'
class Custom_Mine(stdbomb.Bomb):
"""Custom a mine :)"""
def __init__(self, position, source_player):
stdbomb.Bomb.__init__(self,position=position,bomb_type='land_mine',source_player=source_player)
stdbomb.Bomb.__init__(self, position=position, bomb_type='land_mine',
source_player=source_player)
def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, ba.HitMessage):
@ -62,6 +71,8 @@ class Custom_Mine(stdbomb.Bomb):
super().handlemessage(msg)
# ba_meta export game
class SnakeGame(ba.TeamGameActivity[Player, Team]):
"""A game type based on acquiring kills."""
@ -158,7 +169,6 @@ class SnakeGame(ba.TeamGameActivity[Player, Team]):
max(1, max(len(t.players) for t in self.teams)))
self._update_scoreboard()
if self.slow_motion:
t_scale = 0.4
light_y = 50
@ -240,15 +250,12 @@ class SnakeGame(ba.TeamGameActivity[Player, Team]):
self.generate_mines(player)
return spaz
def generate_mines(self, player: Player):
try:
player.actived = ba.Timer(0.5, ba.Call(self.spawn_mine, player), repeat=True)
except Exception as e:
print('Exception -> ' + str(e))
def spawn_mine(self, player: Player):
if player.team.score >= self._score_to_win:
return

View file

@ -15,7 +15,8 @@ from __future__ import annotations
import random
from typing import TYPE_CHECKING
import ba, _ba
import ba
import _ba
from bastd.actor.playerspaz import PlayerSpaz
from bastd.actor.spaz import Spaz
from bastd.actor.bomb import Blast, Bomb
@ -56,8 +57,6 @@ class RoboBot(StickyBot):
highlight = (3, 3, 3)
class UFO(ba.Actor):
"""
New AI for Boss
@ -299,7 +298,6 @@ class UFO(ba.Actor):
node.position[2], 0, 5, 0, 3, 10, 0,
0, 0, 5, 0)
except:
pass
@ -314,7 +312,6 @@ class UFO(ba.Actor):
if not self.node:
return None
damage = abs(msg.magnitude)
if msg.hit_type == 'explosion':
damage /= 20
@ -519,7 +516,6 @@ class UFO(ba.Actor):
{0: self.shield_deco.color, 0.2: (5, 0.2, 0.2)})
self.bot_count = 6
def update_ai(self) -> None:
"""Should be called periodically to update the spaz' AI."""
# pylint: disable=too-many-branches
@ -656,7 +652,6 @@ class UFO(ba.Actor):
self.xz_pos = 0.01
self.node.reflection_scale = [2]
def unfrozen():
self.frozen = False
if self.bot_dur_froze:
@ -666,7 +661,6 @@ class UFO(ba.Actor):
self.xz_pos = 1
self.node.reflection_scale = [0.25]
ba.timer(5.0, unfrozen)
else:
@ -870,8 +864,6 @@ class UFOightGame(ba.TeamGameActivity[Player, Team]):
'text': 'By Cross Joy'
})
def on_transition_in(self) -> None:
super().on_transition_in()
gnode = ba.getactivity().globalsnode
@ -882,8 +874,6 @@ class UFOightGame(ba.TeamGameActivity[Player, Team]):
super().on_begin()
self.setup_standard_powerup_drops()
# In pro mode there's no powerups.
# Make our on-screen timer and start it roughly when our bots appear.
@ -991,4 +981,3 @@ class MyUFOFightLevel(ba.Plugin):
preview_texture_name='footballStadiumPreview',
)
)

View file

@ -116,13 +116,15 @@ class BoxingGame(ba.TeamGameActivity[Player, Team]):
def on_team_join(self, team: Team) -> None:
if self.has_begun():
self._update_scoreboard()
def getRandomPowerupPoint(self) -> None:
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
if x*x+y*y < 1.0:
break
return ((8.0*x, 2.5, -3.5+5.0*y))
elif myMap == 'Rampage':
x = random.uniform(-6.0, 7.0)