mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
[ci] auto-format
This commit is contained in:
parent
4af785998d
commit
2ac90c8677
10 changed files with 1225 additions and 1214 deletions
|
|
@ -1,10 +1,9 @@
|
||||||
#Ported by: Freaku / @[Just] Freak#4999
|
# Ported by: Freaku / @[Just] Freak#4999
|
||||||
|
|
||||||
#Join BCS:
|
# Join BCS:
|
||||||
# https://discord.gg/ucyaesh
|
# https://discord.gg/ucyaesh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ba_meta require api 7
|
# ba_meta require api 7
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
@ -18,7 +17,6 @@ if TYPE_CHECKING:
|
||||||
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
|
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
def __init__(self, bomb=None, grab=False, punch=False, curse=False, required=False, final=False, name=''):
|
def __init__(self, bomb=None, grab=False, punch=False, curse=False, required=False, final=False, name=''):
|
||||||
self.bomb = bomb
|
self.bomb = bomb
|
||||||
|
|
@ -35,8 +33,8 @@ class State:
|
||||||
def apply(self, spaz):
|
def apply(self, spaz):
|
||||||
spaz.disconnect_controls_from_player()
|
spaz.disconnect_controls_from_player()
|
||||||
spaz.connect_controls_to_player(enable_punch=self.punch,
|
spaz.connect_controls_to_player(enable_punch=self.punch,
|
||||||
enable_bomb=self.bomb,
|
enable_bomb=self.bomb,
|
||||||
enable_pickup=self.grab)
|
enable_pickup=self.grab)
|
||||||
if self.curse:
|
if self.curse:
|
||||||
spaz.curse_time = -1
|
spaz.curse_time = -1
|
||||||
spaz.curse()
|
spaz.curse()
|
||||||
|
|
@ -48,16 +46,18 @@ class State:
|
||||||
return (self.name)
|
return (self.name)
|
||||||
|
|
||||||
|
|
||||||
states = [ State(bomb='normal', name='Basic Bombs'),
|
states = [State(bomb='normal', name='Basic Bombs'),
|
||||||
State(bomb='ice', name='Frozen Bombs'),
|
State(bomb='ice', name='Frozen Bombs'),
|
||||||
State(bomb='sticky', name='Sticky Bombs'),
|
State(bomb='sticky', name='Sticky Bombs'),
|
||||||
State(bomb='impact', name='Impact Bombs'),
|
State(bomb='impact', name='Impact Bombs'),
|
||||||
State(grab=True, name='Grabbing only'),
|
State(grab=True, name='Grabbing only'),
|
||||||
State(punch=True, name='Punching only'),
|
State(punch=True, name='Punching only'),
|
||||||
State(curse=True, name='Cursed', final=True) ]
|
State(curse=True, name='Cursed', final=True)]
|
||||||
|
|
||||||
|
|
||||||
class Player(ba.Player['Team']):
|
class Player(ba.Player['Team']):
|
||||||
"""Our player type for this game."""
|
"""Our player type for this game."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.state = None
|
self.state = None
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -39,28 +39,31 @@ class BallType(Enum):
|
||||||
# increase the next ball speed but less than MEDIUM.
|
# increase the next ball speed but less than MEDIUM.
|
||||||
# Ball color is crimson(purple+red = pinky color type).
|
# Ball color is crimson(purple+red = pinky color type).
|
||||||
|
|
||||||
|
|
||||||
# this dict decide the ball_type spawning rate like powerup box
|
# this dict decide the ball_type spawning rate like powerup box
|
||||||
ball_type_dict: dict[BallType, int] = {
|
ball_type_dict: dict[BallType, int] = {
|
||||||
BallType.EASY: 3,
|
BallType.EASY: 3,
|
||||||
BallType.MEDIUM: 2,
|
BallType.MEDIUM: 2,
|
||||||
BallType.HARD: 1,
|
BallType.HARD: 1,
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
class Ball(ba.Actor):
|
class Ball(ba.Actor):
|
||||||
""" Shooting Ball """
|
""" Shooting Ball """
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
position: Sequence[float],
|
position: Sequence[float],
|
||||||
velocity: Sequence[float],
|
velocity: Sequence[float],
|
||||||
texture: ba.Texture,
|
texture: ba.Texture,
|
||||||
body_scale: float = 1.0,
|
body_scale: float = 1.0,
|
||||||
gravity_scale: float = 1.0,
|
gravity_scale: float = 1.0,
|
||||||
) -> NoReturn:
|
) -> NoReturn:
|
||||||
|
|
||||||
super().__init__();
|
super().__init__()
|
||||||
|
|
||||||
shared = SharedObjects.get();
|
shared = SharedObjects.get()
|
||||||
|
|
||||||
ball_material = ba.Material();
|
ball_material = ba.Material()
|
||||||
ball_material.add_actions(
|
ball_material.add_actions(
|
||||||
conditions=(
|
conditions=(
|
||||||
(
|
(
|
||||||
|
|
@ -72,7 +75,7 @@ class Ball(ba.Actor):
|
||||||
('they_have_material', shared.object_material),
|
('they_have_material', shared.object_material),
|
||||||
),
|
),
|
||||||
actions=('modify_node_collision', 'collide', False),
|
actions=('modify_node_collision', 'collide', False),
|
||||||
);
|
)
|
||||||
|
|
||||||
self.node = ba.newnode(
|
self.node = ba.newnode(
|
||||||
'prop',
|
'prop',
|
||||||
|
|
@ -86,37 +89,37 @@ class Ball(ba.Actor):
|
||||||
'model_scale': body_scale,
|
'model_scale': body_scale,
|
||||||
'color_texture': texture,
|
'color_texture': texture,
|
||||||
'gravity_scale': gravity_scale,
|
'gravity_scale': gravity_scale,
|
||||||
'density': 4.0, # increase density of ball so ball collide with player with heavy force. # ammm very bad grammer
|
'density': 4.0, # increase density of ball so ball collide with player with heavy force. # ammm very bad grammer
|
||||||
'materials': (ball_material,),
|
'materials': (ball_material,),
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
|
|
||||||
# die the ball manually incase the ball doesn't fall the outside of the map
|
# 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).
|
# i am not handling anything in this ball Class(except for diemessage).
|
||||||
# all game things and logics going to be in the box class
|
# all game things and logics going to be in the box class
|
||||||
def handlemessage(self, msg: Any) -> Any:
|
def handlemessage(self, msg: Any) -> Any:
|
||||||
|
|
||||||
if isinstance(msg, ba.DieMessage):
|
if isinstance(msg, ba.DieMessage):
|
||||||
self.node.delete();
|
self.node.delete()
|
||||||
else:
|
else:
|
||||||
super().handlemessage(msg);
|
super().handlemessage(msg)
|
||||||
|
|
||||||
|
|
||||||
class Box(ba.Actor):
|
class Box(ba.Actor):
|
||||||
""" A box that spawn midle of map as a decoration perpose """
|
""" A box that spawn midle of map as a decoration perpose """
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
position: Sequence[float],
|
position: Sequence[float],
|
||||||
velocity: Sequence[float],
|
velocity: Sequence[float],
|
||||||
) -> NoReturn:
|
) -> NoReturn:
|
||||||
|
|
||||||
super().__init__();
|
super().__init__()
|
||||||
|
|
||||||
shared = SharedObjects.get();
|
shared = SharedObjects.get()
|
||||||
# self.ball_jump = 0.0;
|
# 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.
|
# we don't need that the box was move and collide with objects.
|
||||||
no_hit_material.add_actions(
|
no_hit_material.add_actions(
|
||||||
conditions=(
|
conditions=(
|
||||||
|
|
@ -125,7 +128,7 @@ class Box(ba.Actor):
|
||||||
('they_have_material', shared.attack_material),
|
('they_have_material', shared.attack_material),
|
||||||
),
|
),
|
||||||
actions=('modify_part_collision', 'collide', False),
|
actions=('modify_part_collision', 'collide', False),
|
||||||
);
|
)
|
||||||
|
|
||||||
no_hit_material.add_actions(
|
no_hit_material.add_actions(
|
||||||
conditions=(
|
conditions=(
|
||||||
|
|
@ -137,7 +140,7 @@ class Box(ba.Actor):
|
||||||
('modify_part_collision', 'collide', False),
|
('modify_part_collision', 'collide', False),
|
||||||
('modify_part_collision', 'physical', False),
|
('modify_part_collision', 'physical', False),
|
||||||
),
|
),
|
||||||
);
|
)
|
||||||
|
|
||||||
self.node = ba.newnode(
|
self.node = ba.newnode(
|
||||||
'prop',
|
'prop',
|
||||||
|
|
@ -154,26 +157,26 @@ class Box(ba.Actor):
|
||||||
'reflection': 'powerup',
|
'reflection': 'powerup',
|
||||||
'reflection_scale': [1.0],
|
'reflection_scale': [1.0],
|
||||||
'materials': (no_hit_material,),
|
'materials': (no_hit_material,),
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
# light
|
# light
|
||||||
self.light = ba.newnode(
|
self.light = ba.newnode(
|
||||||
"light",
|
"light",
|
||||||
owner = self.node,
|
owner=self.node,
|
||||||
attrs={
|
attrs={
|
||||||
'radius' : 0.2,
|
'radius': 0.2,
|
||||||
'intensity' : 0.8,
|
'intensity': 0.8,
|
||||||
'color': (0.0, 1.0, 0.0),
|
'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,
|
# Drawing circle and circleOutline in radius of 3,
|
||||||
# so player can see that how close he is to the box.
|
# so player can see that how close he is to the box.
|
||||||
# If player is inside this circle the ball speed will increase.
|
# If player is inside this circle the ball speed will increase.
|
||||||
circle = ba.newnode(
|
circle = ba.newnode(
|
||||||
"locator",
|
"locator",
|
||||||
owner = self.node,
|
owner=self.node,
|
||||||
attrs = {
|
attrs={
|
||||||
'shape': 'circle',
|
'shape': 'circle',
|
||||||
'color': (1.0, 0.0, 0.0),
|
'color': (1.0, 0.0, 0.0),
|
||||||
'opacity': 0.1,
|
'opacity': 0.1,
|
||||||
|
|
@ -182,12 +185,12 @@ class Box(ba.Actor):
|
||||||
'additive': True,
|
'additive': True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.node.connectattr("position", circle, "position");
|
self.node.connectattr("position", circle, "position")
|
||||||
# also adding a outline cause its look nice.
|
# also adding a outline cause its look nice.
|
||||||
circle_outline = ba.newnode(
|
circle_outline = ba.newnode(
|
||||||
"locator",
|
"locator",
|
||||||
owner = self.node,
|
owner=self.node,
|
||||||
attrs = {
|
attrs={
|
||||||
'shape': 'circleOutline',
|
'shape': 'circleOutline',
|
||||||
'color': (1.0, 1.0, 0.0),
|
'color': (1.0, 1.0, 0.0),
|
||||||
'opacity': 0.1,
|
'opacity': 0.1,
|
||||||
|
|
@ -195,92 +198,92 @@ class Box(ba.Actor):
|
||||||
'draw_beauty': False,
|
'draw_beauty': False,
|
||||||
'additive': True,
|
'additive': True,
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
self.node.connectattr("position", circle_outline, "position");
|
self.node.connectattr("position", circle_outline, "position")
|
||||||
|
|
||||||
# all ball attribute that we need.
|
# all ball attribute that we need.
|
||||||
self.ball_type: BallType = BallType.EASY;
|
self.ball_type: BallType = BallType.EASY
|
||||||
self.shoot_timer: ba.Timer | None = None;
|
self.shoot_timer: ba.Timer | None = None
|
||||||
self.shoot_speed: float = 0.0;
|
self.shoot_speed: float = 0.0
|
||||||
# this force the shoot if player is inside the red circle.
|
# this force the shoot if player is inside the red circle.
|
||||||
self.force_shoot_speed: float = 0.0;
|
self.force_shoot_speed: float = 0.0
|
||||||
self.ball_mag = 3000;
|
self.ball_mag = 3000
|
||||||
self.ball_gravity: float = 1.0;
|
self.ball_gravity: float = 1.0
|
||||||
self.ball_tex: ba.Texture | None = None;
|
self.ball_tex: ba.Texture | None = None
|
||||||
# only for Hard ball_type
|
# 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.
|
# ball shoot soound.
|
||||||
self.shoot_sound = ba.getsound('laserReverse');
|
self.shoot_sound = ba.getsound('laserReverse')
|
||||||
|
|
||||||
# same as "powerupdist"
|
# same as "powerupdist"
|
||||||
self.ball_type_dist: list[BallType] = [];
|
self.ball_type_dist: list[BallType] = []
|
||||||
|
|
||||||
for ball in ball_type_dict:
|
for ball in ball_type_dict:
|
||||||
for _ in range(ball_type_dict[ball]):
|
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.
|
# Here main logic of game goes here.
|
||||||
# like shoot balls, shoot speed, anything we want goes here(except for some thing).
|
# like shoot balls, shoot speed, anything we want goes here(except for some thing).
|
||||||
def start_shoot(self) -> NoReturn:
|
def start_shoot(self) -> NoReturn:
|
||||||
|
|
||||||
# getting all allive players in a list.
|
# 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.
|
# make sure that list is not Empty.
|
||||||
if len(alive_players_list) > 0:
|
if len(alive_players_list) > 0:
|
||||||
|
|
||||||
# choosing a random player from list.
|
# choosing a random player from list.
|
||||||
target_player = choice(alive_players_list);
|
target_player = choice(alive_players_list)
|
||||||
# highlight the target player
|
# highlight the target player
|
||||||
self.highlight_target_player(target_player);
|
self.highlight_target_player(target_player)
|
||||||
|
|
||||||
# to finding difference between player and box.
|
# to finding difference between player and box.
|
||||||
# we just need to subtract player pos and ball pos.
|
# we just need to subtract player pos and ball pos.
|
||||||
# Same logic as eric applied in Target Practice Gamemode.
|
# 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.
|
# discard Y position so ball shoot more straight.
|
||||||
difference[1] = 0.0
|
difference[1] = 0.0
|
||||||
|
|
||||||
# and now, this length method returns distance in float.
|
# and now, this length method returns distance in float.
|
||||||
# we're gonna use this value for calculating player analog stick
|
# we're gonna use this value for calculating player analog stick
|
||||||
distance = difference.length();
|
distance = difference.length()
|
||||||
|
|
||||||
# shoot a random BallType
|
# 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.
|
# 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.
|
# For HARD ball i am just focusing on player analog stick facing direction.
|
||||||
# Not very accurate and that's we need.
|
# Not very accurate and that's we need.
|
||||||
if self.ball_type == BallType.HARD:
|
if self.ball_type == BallType.HARD:
|
||||||
self.calculate_player_analog_stick(target_player, distance);
|
self.calculate_player_analog_stick(target_player, distance)
|
||||||
else:
|
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:
|
if self.ball_type == BallType.MEDIUM or self.ball_type == BallType.HARD:
|
||||||
# Target head by increasing Y pos.
|
# Target head by increasing Y pos.
|
||||||
# How this work? cause ball gravity_scale is ......
|
# 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 is generating..
|
||||||
ball = Ball(
|
ball = Ball(
|
||||||
position = pos,
|
position=pos,
|
||||||
velocity = (0.0, 0.0, 0.0),
|
velocity=(0.0, 0.0, 0.0),
|
||||||
texture = self.ball_tex,
|
texture=self.ball_tex,
|
||||||
gravity_scale = self.ball_gravity,
|
gravity_scale=self.ball_gravity,
|
||||||
body_scale = 1.0,
|
body_scale=1.0,
|
||||||
).autoretain();
|
).autoretain()
|
||||||
|
|
||||||
# shoot Animation and sound.
|
# shoot Animation and sound.
|
||||||
self.shoot_animation();
|
self.shoot_animation()
|
||||||
|
|
||||||
# force the shoot speed if player try to go inside the red circle.
|
# force the shoot speed if player try to go inside the red circle.
|
||||||
if self.force_shoot_speed != 0.0:
|
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
|
# push the ball to the player
|
||||||
ball.node.handlemessage(
|
ball.node.handlemessage(
|
||||||
|
|
@ -293,87 +296,87 @@ class Box(ba.Actor):
|
||||||
0.000, # magnetude velocity
|
0.000, # magnetude velocity
|
||||||
0.000, # radius
|
0.000, # radius
|
||||||
0.000, # idk
|
0.000, # idk
|
||||||
difference[0] + self.player_facing_direction[0], # force direction X
|
difference[0] + self.player_facing_direction[0], # force direction X
|
||||||
difference[1] , # force direction Y
|
difference[1], # force direction Y
|
||||||
difference[2] + self.player_facing_direction[1], # force direction Z
|
difference[2] + self.player_facing_direction[1], # force direction Z
|
||||||
);
|
)
|
||||||
# creating our timer and shoot the ball again.(and we create a loop)
|
# 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:
|
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:
|
def check_ball_type(self, ball_type: BallType) -> NoReturn:
|
||||||
|
|
||||||
if ball_type == BallType.EASY:
|
if ball_type == BallType.EASY:
|
||||||
self.shoot_speed = 0.8;
|
self.shoot_speed = 0.8
|
||||||
self.ball_gravity = 1.0;
|
self.ball_gravity = 1.0
|
||||||
# next ball shoot speed
|
# next ball shoot speed
|
||||||
self.ball_mag = 3000;
|
self.ball_mag = 3000
|
||||||
# box light color and ball tex
|
# box light color and ball tex
|
||||||
self.light.color = (1.0, 1.0, 0.0);
|
self.light.color = (1.0, 1.0, 0.0)
|
||||||
self.ball_tex = ba.gettexture('egg4');
|
self.ball_tex = ba.gettexture('egg4')
|
||||||
elif ball_type == BallType.MEDIUM:
|
elif ball_type == BallType.MEDIUM:
|
||||||
self.ball_mag = 3000;
|
self.ball_mag = 3000
|
||||||
# decrease the gravity scale so, ball shoot without falling and straight.
|
# 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.
|
# next ball shoot speed.
|
||||||
self.shoot_speed = 0.4;
|
self.shoot_speed = 0.4
|
||||||
# box light color and ball tex.
|
# box light color and ball tex.
|
||||||
self.light.color = (1.0, 0.0, 1.0);
|
self.light.color = (1.0, 0.0, 1.0)
|
||||||
self.ball_tex = ba.gettexture('egg3');
|
self.ball_tex = ba.gettexture('egg3')
|
||||||
elif ball_type == BallType.HARD:
|
elif ball_type == BallType.HARD:
|
||||||
self.ball_mag = 2500;
|
self.ball_mag = 2500
|
||||||
self.ball_gravity = 0.0;
|
self.ball_gravity = 0.0
|
||||||
# next ball shoot speed.
|
# next ball shoot speed.
|
||||||
self.shoot_speed = 0.6;
|
self.shoot_speed = 0.6
|
||||||
# box light color and ball tex.
|
# box light color and ball tex.
|
||||||
self.light.color = (1.0, 0.2, 1.0);
|
self.light.color = (1.0, 0.2, 1.0)
|
||||||
self.ball_tex = ba.gettexture('egg1');
|
self.ball_tex = ba.gettexture('egg1')
|
||||||
|
|
||||||
def shoot_animation(self) -> NoReturn:
|
def shoot_animation(self) -> NoReturn:
|
||||||
|
|
||||||
ba.animate(
|
ba.animate(
|
||||||
self.node,
|
self.node,
|
||||||
"model_scale",{
|
"model_scale", {
|
||||||
0.00: 1.4,
|
0.00: 1.4,
|
||||||
0.05: 1.7,
|
0.05: 1.7,
|
||||||
0.10: 1.4,
|
0.10: 1.4,
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
# playing shoot sound.
|
# 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:
|
def highlight_target_player(self, player: ba.Player) -> NoReturn:
|
||||||
|
|
||||||
# adding light
|
# adding light
|
||||||
light = ba.newnode(
|
light = ba.newnode(
|
||||||
"light",
|
"light",
|
||||||
owner = self.node,
|
owner=self.node,
|
||||||
attrs={
|
attrs={
|
||||||
'radius':0.0,
|
'radius': 0.0,
|
||||||
'intensity':1.0,
|
'intensity': 1.0,
|
||||||
'color': (1.0, 0.0, 0.0),
|
'color': (1.0, 0.0, 0.0),
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
ba.animate(
|
ba.animate(
|
||||||
light,
|
light,
|
||||||
"radius",{
|
"radius", {
|
||||||
0.05: 0.02,
|
0.05: 0.02,
|
||||||
0.10: 0.07,
|
0.10: 0.07,
|
||||||
0.15: 0.15,
|
0.15: 0.15,
|
||||||
0.20: 0.13,
|
0.20: 0.13,
|
||||||
0.25: 0.10,
|
0.25: 0.10,
|
||||||
0.30: 0.05,
|
0.30: 0.05,
|
||||||
0.35: 0.02,
|
0.35: 0.02,
|
||||||
0.40: 0.00,
|
0.40: 0.00,
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
# And a circle outline with ugly animation.
|
# And a circle outline with ugly animation.
|
||||||
circle_outline = ba.newnode(
|
circle_outline = ba.newnode(
|
||||||
"locator",
|
"locator",
|
||||||
owner = player.actor.node,
|
owner=player.actor.node,
|
||||||
attrs={
|
attrs={
|
||||||
'shape': 'circleOutline',
|
'shape': 'circleOutline',
|
||||||
'color': (1.0, 0.0, 0.0),
|
'color': (1.0, 0.0, 0.0),
|
||||||
|
|
@ -381,45 +384,45 @@ class Box(ba.Actor):
|
||||||
'draw_beauty': False,
|
'draw_beauty': False,
|
||||||
'additive': True,
|
'additive': True,
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
ba.animate_array(
|
ba.animate_array(
|
||||||
circle_outline,
|
circle_outline,
|
||||||
'size',
|
'size',
|
||||||
1, {
|
1, {
|
||||||
0.05: [0.5],
|
0.05: [0.5],
|
||||||
0.10: [0.8],
|
0.10: [0.8],
|
||||||
0.15: [1.5],
|
0.15: [1.5],
|
||||||
0.20: [2.0],
|
0.20: [2.0],
|
||||||
0.25: [1.8],
|
0.25: [1.8],
|
||||||
0.30: [1.3],
|
0.30: [1.3],
|
||||||
0.35: [0.6],
|
0.35: [0.6],
|
||||||
0.40: [0.0],
|
0.40: [0.0],
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
# coonect it and...
|
# coonect it and...
|
||||||
player.actor.node.connectattr("position", light, "position");
|
player.actor.node.connectattr("position", light, "position")
|
||||||
player.actor.node.connectattr("position", circle_outline, "position");
|
player.actor.node.connectattr("position", circle_outline, "position")
|
||||||
|
|
||||||
# immediately delete the node after another player has been targeted.
|
# 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;
|
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, light.delete)
|
||||||
ba.timer(self.shoot_speed, circle_outline.delete);
|
ba.timer(self.shoot_speed, circle_outline.delete)
|
||||||
|
|
||||||
def calculate_player_analog_stick(self, player:ba.Player, distance: float) -> NoReturn:
|
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 \
|
# at first i was very confused how i can read the player analog stick \
|
||||||
# then i saw TheMikirog#1984 autorun plugin code.
|
# then i saw TheMikirog#1984 autorun plugin code.
|
||||||
# and i got it how analog stick values are works.
|
# 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.
|
# 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).
|
# 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[0] = player.actor.node.move_left_right
|
||||||
self.player_facing_direction[1] = -player.actor.node.move_up_down;
|
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.
|
# 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.
|
# so, we need to reduce the value of "self.player_facing_direction" to fix this problem.
|
||||||
if distance <= 3:
|
if distance <= 3:
|
||||||
self.player_facing_direction[0] = 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;
|
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,
|
# 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,
|
# 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.
|
# 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.
|
# So many calculation according to how analog stick pushed by player.
|
||||||
# Horizontal(left-right) calculation
|
# Horizontal(left-right) calculation
|
||||||
if self.player_facing_direction[0] > 0.4:
|
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:
|
elif self.player_facing_direction[0] < -0.4:
|
||||||
self.player_facing_direction[0] = -1.5;
|
self.player_facing_direction[0] = -1.5
|
||||||
else:
|
else:
|
||||||
if self.player_facing_direction[0] > 0.0:
|
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:
|
elif self.player_facing_direction[0] < 0.0:
|
||||||
self.player_facing_direction[0] = -0.2;
|
self.player_facing_direction[0] = -0.2
|
||||||
else:
|
else:
|
||||||
self.player_facing_direction[0] = 0.0;
|
self.player_facing_direction[0] = 0.0
|
||||||
|
|
||||||
# Vertical(up-down) calculation.
|
# Vertical(up-down) calculation.
|
||||||
if self.player_facing_direction[1] > 0.4:
|
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:
|
elif self.player_facing_direction[1] < -0.4:
|
||||||
self.player_facing_direction[1] = -1.5;
|
self.player_facing_direction[1] = -1.5
|
||||||
else:
|
else:
|
||||||
if self.player_facing_direction[1] > 0.0:
|
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:
|
elif self.player_facing_direction[1] < 0.0:
|
||||||
self.player_facing_direction[1] = -0.2;
|
self.player_facing_direction[1] = -0.2
|
||||||
else:
|
else:
|
||||||
self.player_facing_direction[1] = -0.0;
|
self.player_facing_direction[1] = -0.0
|
||||||
|
|
||||||
# if we want stop the ball shootes
|
# if we want stop the ball shootes
|
||||||
def stop_shoot(self) -> NoReturn:
|
def stop_shoot(self) -> NoReturn:
|
||||||
# Kill the timer.
|
# Kill the timer.
|
||||||
self.shoot_timer = None;
|
self.shoot_timer = None
|
||||||
|
|
||||||
|
|
||||||
class Player(ba.Player['Team']):
|
class Player(ba.Player['Team']):
|
||||||
|
|
@ -470,31 +473,33 @@ class Team(ba.Team[Player]):
|
||||||
# and main thing don't allow player to camp inside of box are going in this class.
|
# and main thing don't allow player to camp inside of box are going in this class.
|
||||||
|
|
||||||
# ba_meta export game
|
# ba_meta export game
|
||||||
|
|
||||||
|
|
||||||
class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
|
class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
|
||||||
|
|
||||||
# defining name, description and settings..
|
# defining name, description and settings..
|
||||||
name = 'Dodge the ball';
|
name = 'Dodge the ball'
|
||||||
description = 'Survive from shooting balls';
|
description = 'Survive from shooting balls'
|
||||||
|
|
||||||
available_settings = [
|
available_settings = [
|
||||||
ba.IntSetting(
|
ba.IntSetting(
|
||||||
'Cooldown',
|
'Cooldown',
|
||||||
min_value = 20,
|
min_value=20,
|
||||||
default = 45,
|
default=45,
|
||||||
increment = 5,
|
increment=5,
|
||||||
),
|
),
|
||||||
ba.BoolSetting('Epic Mode', default=False)
|
ba.BoolSetting('Epic Mode', default=False)
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't allow joining after we start.
|
# Don't allow joining after we start.
|
||||||
allow_mid_activity_joins = False;
|
allow_mid_activity_joins = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def supports_session_type(cls, sessiontype: type[ba.Session]) -> bool:
|
def supports_session_type(cls, sessiontype: type[ba.Session]) -> bool:
|
||||||
# We support team and ffa sessions.
|
# We support team and ffa sessions.
|
||||||
return issubclass(sessiontype, ba.FreeForAllSession) or issubclass(
|
return issubclass(sessiontype, ba.FreeForAllSession) or issubclass(
|
||||||
sessiontype, ba.DualTeamSession,
|
sessiontype, ba.DualTeamSession,
|
||||||
);
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_supported_maps(cls, sessiontype: type[ba.Session]) -> list[str]:
|
def get_supported_maps(cls, sessiontype: type[ba.Session]) -> list[str]:
|
||||||
|
|
@ -502,152 +507,152 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
|
||||||
# bombsquad have "Doom Shroom" map.
|
# bombsquad have "Doom Shroom" map.
|
||||||
# Not perfect map for this game mode but its fine for this gamemode.
|
# 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.
|
# 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):
|
def __init__(self, settings: dict):
|
||||||
super().__init__(settings);
|
super().__init__(settings)
|
||||||
self._epic_mode = bool(settings['Epic Mode']);
|
self._epic_mode = bool(settings['Epic Mode'])
|
||||||
self.countdown_time = int(settings['Cooldown']);
|
self.countdown_time = int(settings['Cooldown'])
|
||||||
|
|
||||||
self.check_player_pos_timer: ba.Timer | None = None;
|
self.check_player_pos_timer: ba.Timer | None = None
|
||||||
self.shield_drop_timer: ba.Timer | None = None;
|
self.shield_drop_timer: ba.Timer | None = None
|
||||||
# cooldown and Box
|
# cooldown and Box
|
||||||
self._countdown: OnScreenCountdown | None = None;
|
self._countdown: OnScreenCountdown | None = None
|
||||||
self.box: Box | None = None;
|
self.box: Box | None = None
|
||||||
|
|
||||||
# this lists for scoring.
|
# this lists for scoring.
|
||||||
self.joined_player_list: list[ba.Player] = [];
|
self.joined_player_list: list[ba.Player] = []
|
||||||
self.dead_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,
|
# normally play RUN AWAY music cause is match with our gamemode at.. my point,
|
||||||
# but in epic switch to EPIC.
|
# but in epic switch to EPIC.
|
||||||
self.slow_motion = self._epic_mode;
|
self.slow_motion = self._epic_mode
|
||||||
self.default_music = (
|
self.default_music = (
|
||||||
ba.MusicType.EPIC if self._epic_mode else ba.MusicType.RUN_AWAY
|
ba.MusicType.EPIC if self._epic_mode else ba.MusicType.RUN_AWAY
|
||||||
);
|
)
|
||||||
|
|
||||||
def get_instance_description(self) -> str | Sequence:
|
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.
|
# add a tiny text under our game name.
|
||||||
def get_instance_description_short(self) -> str | Sequence:
|
def get_instance_description_short(self) -> str | Sequence:
|
||||||
return 'Dodge the shooting balls';
|
return 'Dodge the shooting balls'
|
||||||
|
|
||||||
def on_begin(self) -> NoReturn:
|
def on_begin(self) -> NoReturn:
|
||||||
super().on_begin();
|
super().on_begin()
|
||||||
|
|
||||||
# spawn our box at middle of the map
|
# spawn our box at middle of the map
|
||||||
self.box = Box(
|
self.box = Box(
|
||||||
position=(0.5, 2.7, -3.9),
|
position=(0.5, 2.7, -3.9),
|
||||||
velocity=(0.0, 0.0, 0.0),
|
velocity=(0.0, 0.0, 0.0),
|
||||||
).autoretain();
|
).autoretain()
|
||||||
|
|
||||||
# create our cooldown
|
# create our cooldown
|
||||||
self._countdown = OnScreenCountdown(
|
self._countdown = OnScreenCountdown(
|
||||||
duration = self.countdown_time,
|
duration=self.countdown_time,
|
||||||
endcall = self.play_victory_sound_and_end,
|
endcall=self.play_victory_sound_and_end,
|
||||||
);
|
)
|
||||||
|
|
||||||
# and starts the cooldown and shootes.
|
# and starts the cooldown and shootes.
|
||||||
ba.timer(5.0, self._countdown.start);
|
ba.timer(5.0, self._countdown.start)
|
||||||
ba.timer(5.0, self.box.start_shoot);
|
ba.timer(5.0, self.box.start_shoot)
|
||||||
|
|
||||||
# start checking all player pos.
|
# 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
|
# drop shield every ten Seconds
|
||||||
# need five seconds delay Because shootes start after 5 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.
|
# This function returns all alive players in game.
|
||||||
# i thinck you see this function in Box class.
|
# i thinck you see this function in Box class.
|
||||||
def get_alive_players(self) -> Sequence[ba.Player]:
|
def get_alive_players(self) -> Sequence[ba.Player]:
|
||||||
|
|
||||||
alive_players = [];
|
alive_players = []
|
||||||
|
|
||||||
for team in self.teams:
|
for team in self.teams:
|
||||||
for player in team.players:
|
for player in team.players:
|
||||||
if player.is_alive():
|
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.
|
# let's disallowed camping inside of box by doing a blast and increasing ball shoot speed.
|
||||||
def check_player_pos(self):
|
def check_player_pos(self):
|
||||||
|
|
||||||
for player in self.get_alive_players():
|
for player in self.get_alive_players():
|
||||||
|
|
||||||
# same logic as applied for the ball
|
# 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:
|
if distance < 3:
|
||||||
self.box.force_shoot_speed = 0.2;
|
self.box.force_shoot_speed = 0.2
|
||||||
else:
|
else:
|
||||||
self.box.force_shoot_speed = 0.0;
|
self.box.force_shoot_speed = 0.0
|
||||||
|
|
||||||
if distance < 0.5:
|
if distance < 0.5:
|
||||||
Blast(
|
Blast(
|
||||||
position = self.box.node.position,
|
position=self.box.node.position,
|
||||||
velocity = self.box.node.velocity,
|
velocity=self.box.node.velocity,
|
||||||
blast_type = 'normal',
|
blast_type='normal',
|
||||||
blast_radius = 1.0,
|
blast_radius=1.0,
|
||||||
).autoretain();
|
).autoretain()
|
||||||
|
|
||||||
PopupText(
|
PopupText(
|
||||||
position = self.box.node.position,
|
position=self.box.node.position,
|
||||||
text = 'Keep away from me',
|
text='Keep away from me',
|
||||||
random_offset = 0.0,
|
random_offset=0.0,
|
||||||
scale = 2.0,
|
scale=2.0,
|
||||||
color = self.box.light.color,
|
color=self.box.light.color,
|
||||||
).autoretain();
|
).autoretain()
|
||||||
|
|
||||||
# create our timer and start looping it
|
# 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.
|
# drop useless shield's too give player temptation.
|
||||||
def drop_shield(self) -> NoReturn:
|
def drop_shield(self) -> NoReturn:
|
||||||
|
|
||||||
pos = self.box.node.position;
|
pos = self.box.node.position
|
||||||
|
|
||||||
PowerupBox(
|
PowerupBox(
|
||||||
position = (pos[0] + 4.0, pos[1] + 3.0, pos[2]),
|
position=(pos[0] + 4.0, pos[1] + 3.0, pos[2]),
|
||||||
poweruptype = 'shield',
|
poweruptype='shield',
|
||||||
).autoretain();
|
).autoretain()
|
||||||
|
|
||||||
PowerupBox(
|
PowerupBox(
|
||||||
position = (pos[0] - 4.0, pos[1] + 3.0, pos[2]),
|
position=(pos[0] - 4.0, pos[1] + 3.0, pos[2]),
|
||||||
poweruptype = 'shield',
|
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.
|
# when cooldown time up i don't want that the game end immediately.
|
||||||
def play_victory_sound_and_end(self) -> NoReturn:
|
def play_victory_sound_and_end(self) -> NoReturn:
|
||||||
|
|
||||||
# kill timers
|
# kill timers
|
||||||
self.box.stop_shoot();
|
self.box.stop_shoot()
|
||||||
self.check_player_pos_timer = None
|
self.check_player_pos_timer = None
|
||||||
self.shield_drop_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
|
# this function runs when A player spawn in map
|
||||||
def spawn_player(self, player: Player) -> NoReturn:
|
def spawn_player(self, player: Player) -> NoReturn:
|
||||||
spaz = self.spawn_player_spaz(player);
|
spaz = self.spawn_player_spaz(player)
|
||||||
|
|
||||||
# reconnect this player's controls.
|
# reconnect this player's controls.
|
||||||
# without bomb, punch and pickup.
|
# without bomb, punch and pickup.
|
||||||
spaz.connect_controls_to_player(
|
spaz.connect_controls_to_player(
|
||||||
enable_punch=False, enable_bomb=False, enable_pickup=False,
|
enable_punch=False, enable_bomb=False, enable_pickup=False,
|
||||||
);
|
)
|
||||||
|
|
||||||
# storing all players for ScorinG.
|
# 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.
|
# 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.
|
# very helpful function to check end game when player dead or leav.
|
||||||
def _check_end_game(self) -> bool:
|
def _check_end_game(self) -> bool:
|
||||||
|
|
@ -669,10 +674,10 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
|
||||||
# this function called when player leave.
|
# this function called when player leave.
|
||||||
def on_player_leave(self, player: Player) -> NoReturn:
|
def on_player_leave(self, player: Player) -> NoReturn:
|
||||||
# Augment default behavior.
|
# Augment default behavior.
|
||||||
super().on_player_leave(player);
|
super().on_player_leave(player)
|
||||||
|
|
||||||
# checking end game.
|
# checking end game.
|
||||||
self._check_end_game();
|
self._check_end_game()
|
||||||
|
|
||||||
# this gamemode needs to handle only one msg "PlayerDiedMessage".
|
# this gamemode needs to handle only one msg "PlayerDiedMessage".
|
||||||
def handlemessage(self, msg: Any) -> Any:
|
def handlemessage(self, msg: Any) -> Any:
|
||||||
|
|
@ -680,13 +685,13 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
|
||||||
if isinstance(msg, ba.PlayerDiedMessage):
|
if isinstance(msg, ba.PlayerDiedMessage):
|
||||||
|
|
||||||
# Augment standard behavior.
|
# Augment standard behavior.
|
||||||
super().handlemessage(msg);
|
super().handlemessage(msg)
|
||||||
|
|
||||||
# and storing the dead player records in our dead_player_list.
|
# 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.
|
# check the end game.
|
||||||
ba.timer(1.0, self._check_end_game);
|
ba.timer(1.0, self._check_end_game)
|
||||||
|
|
||||||
def end_game(self):
|
def end_game(self):
|
||||||
# kill timers
|
# kill timers
|
||||||
|
|
@ -741,22 +746,20 @@ class DodgeTheBall(ba.TeamGameActivity[Player, Team]):
|
||||||
|
|
||||||
max_index = 0
|
max_index = 0
|
||||||
for player in team.players:
|
for player in team.players:
|
||||||
# for the team, we choose only one player who survived longest.
|
# for the team, we choose only one player who survived longest.
|
||||||
# same logic..
|
# same logic..
|
||||||
if len(self.dead_player_list) > 0:
|
if len(self.dead_player_list) > 0:
|
||||||
for index, dead_player in enumerate(self.dead_player_list):
|
for index, dead_player in enumerate(self.dead_player_list):
|
||||||
if player == dead_player:
|
if player == dead_player:
|
||||||
index += 1
|
index += 1
|
||||||
break
|
break
|
||||||
elif index == len(self.dead_player_list) - 1:
|
elif index == len(self.dead_player_list) - 1:
|
||||||
index = len(self.joined_player_list)
|
index = len(self.joined_player_list)
|
||||||
else:
|
else:
|
||||||
index = len(self.joined_player_list)
|
index = len(self.joined_player_list)
|
||||||
|
|
||||||
max_index = max(max_index, index)
|
max_index = max(max_index, index)
|
||||||
# set the team score
|
# set the team score
|
||||||
results.set_team_score(team, int(10 * max_index))
|
results.set_team_score(team, int(10 * max_index))
|
||||||
# and end the game
|
# and end the game
|
||||||
self.end(results=results)
|
self.end(results=results)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -225,7 +225,6 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
||||||
scoring_team.time_remaining = max(
|
scoring_team.time_remaining = max(
|
||||||
0, scoring_team.time_remaining - 1)
|
0, scoring_team.time_remaining - 1)
|
||||||
|
|
||||||
|
|
||||||
self._update_scoreboard()
|
self._update_scoreboard()
|
||||||
|
|
||||||
# announce numbers we have sounds for
|
# announce numbers we have sounds for
|
||||||
|
|
@ -286,7 +285,8 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
||||||
self._invicible_one_player = player
|
self._invicible_one_player = player
|
||||||
|
|
||||||
if self._invicible_one_is_lazy:
|
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:
|
if player.actor.node.torso_model != None:
|
||||||
player.actor.node.color_mask_texture = None
|
player.actor.node.color_mask_texture = None
|
||||||
player.actor.node.color_texture = None
|
player.actor.node.color_texture = None
|
||||||
|
|
@ -310,7 +310,6 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
||||||
|
|
||||||
player.actor.node.name = ''
|
player.actor.node.name = ''
|
||||||
|
|
||||||
|
|
||||||
def handlemessage(self, msg: Any) -> Any:
|
def handlemessage(self, msg: Any) -> Any:
|
||||||
if isinstance(msg, ba.PlayerDiedMessage):
|
if isinstance(msg, ba.PlayerDiedMessage):
|
||||||
# Augment standard behavior.
|
# Augment standard behavior.
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,45 @@
|
||||||
# ba_meta require api 7
|
# ba_meta require api 7
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
import ba, _ba, random
|
import ba
|
||||||
|
import _ba
|
||||||
|
import random
|
||||||
from bastd.actor.spaz import Spaz
|
from bastd.actor.spaz import Spaz
|
||||||
from bastd.actor.scoreboard import Scoreboard
|
from bastd.actor.scoreboard import Scoreboard
|
||||||
|
|
||||||
|
|
||||||
class Player(ba.Player['Team']):
|
class Player(ba.Player['Team']):
|
||||||
"""Our player type for this game."""
|
"""Our player type for this game."""
|
||||||
|
|
||||||
|
|
||||||
class Team(ba.Team[Player]):
|
class Team(ba.Team[Player]):
|
||||||
"""Our team type for this game."""
|
"""Our team type for this game."""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.score = 1
|
||||||
|
|
||||||
def __init__(self) -> None:
|
|
||||||
super().__init__()
|
|
||||||
self.score = 1
|
|
||||||
|
|
||||||
class ChooseingSpazHitMessage:
|
class ChooseingSpazHitMessage:
|
||||||
def __init__(self, hitter:Player) -> None:
|
def __init__(self, hitter: Player) -> None:
|
||||||
self.hitter = hitter
|
self.hitter = hitter
|
||||||
|
|
||||||
|
|
||||||
class ChooseingSpazDieMessage:
|
class ChooseingSpazDieMessage:
|
||||||
def __init__(self, killer:Player) -> None:
|
def __init__(self, killer: Player) -> None:
|
||||||
self.killer = killer
|
self.killer = killer
|
||||||
|
|
||||||
|
|
||||||
class ChooseingSpaz(Spaz):
|
class ChooseingSpaz(Spaz):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
pos:Sequence[float],
|
pos: Sequence[float],
|
||||||
color: Sequence[float] = (1.0, 1.0, 1.0),
|
color: Sequence[float] = (1.0, 1.0, 1.0),
|
||||||
highlight: Sequence[float] = (0.5, 0.5, 0.5),
|
highlight: Sequence[float] = (0.5, 0.5, 0.5),
|
||||||
):
|
):
|
||||||
super().__init__(color, highlight, "Spaz", None, True, True, False, False)
|
super().__init__(color, highlight, "Spaz", None, True, True, False, False)
|
||||||
self.last_player_attacked_by = None
|
self.last_player_attacked_by = None
|
||||||
self.stand(pos)
|
self.stand(pos)
|
||||||
self.loc = ba.newnode(
|
self.loc = ba.newnode(
|
||||||
'locator',
|
'locator',
|
||||||
attrs={
|
attrs={
|
||||||
'shape': 'circleOutline',
|
'shape': 'circleOutline',
|
||||||
|
|
@ -43,221 +50,223 @@ class ChooseingSpaz(Spaz):
|
||||||
'additive': True,
|
'additive': True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.node.connectattr("position", self.loc, "position")
|
self.node.connectattr("position", self.loc, "position")
|
||||||
ba.animate_array(self.loc, "size", 1, keys={0:[0.5,], 1:[2,], 1.5:[0.5]}, loop=True)
|
ba.animate_array(self.loc, "size", 1, keys={0: [0.5,], 1: [2,], 1.5: [0.5]}, loop=True)
|
||||||
|
|
||||||
def handlemessage(self, msg):
|
def handlemessage(self, msg):
|
||||||
if isinstance(msg, ba.FreezeMessage):
|
if isinstance(msg, ba.FreezeMessage):
|
||||||
return
|
return
|
||||||
|
|
||||||
if isinstance(msg, ba.PowerupMessage):
|
if isinstance(msg, ba.PowerupMessage):
|
||||||
if not(msg.poweruptype == "health"):
|
if not (msg.poweruptype == "health"):
|
||||||
return
|
return
|
||||||
|
|
||||||
super().handlemessage(msg)
|
super().handlemessage(msg)
|
||||||
|
|
||||||
if isinstance(msg, ba.HitMessage):
|
if isinstance(msg, ba.HitMessage):
|
||||||
self.handlemessage(ba.PowerupMessage("health"))
|
self.handlemessage(ba.PowerupMessage("health"))
|
||||||
|
|
||||||
player = msg.get_source_player(Player)
|
player = msg.get_source_player(Player)
|
||||||
if self.is_alive():
|
if self.is_alive():
|
||||||
self.activity.handlemessage(ChooseingSpazHitMessage(player))
|
self.activity.handlemessage(ChooseingSpazHitMessage(player))
|
||||||
self.last_player_attacked_by = player
|
self.last_player_attacked_by = player
|
||||||
|
|
||||||
|
elif isinstance(msg, ba.DieMessage):
|
||||||
|
player = self.last_player_attacked_by
|
||||||
|
|
||||||
elif isinstance(msg, ba.DieMessage):
|
if msg.how.value != ba.DeathType.GENERIC.value:
|
||||||
player = self.last_player_attacked_by
|
self._dead = True
|
||||||
|
self.activity.handlemessage(ChooseingSpazDieMessage(player))
|
||||||
|
|
||||||
if msg.how.value != ba.DeathType.GENERIC.value:
|
self.loc.delete()
|
||||||
self._dead = True
|
|
||||||
self.activity.handlemessage(ChooseingSpazDieMessage(player))
|
|
||||||
|
|
||||||
self.loc.delete()
|
def stand(self, pos=(0, 0, 0), angle=0):
|
||||||
|
self.handlemessage(ba.StandMessage(pos, angle))
|
||||||
|
|
||||||
|
def recolor(self, color, highlight=(1, 1, 1)):
|
||||||
|
self.node.color = color
|
||||||
|
self.node.highlight = highlight
|
||||||
|
self.loc.color = color
|
||||||
|
|
||||||
|
|
||||||
def stand(self, pos = (0,0,0), angle = 0):
|
|
||||||
self.handlemessage(ba.StandMessage(pos,angle))
|
|
||||||
|
|
||||||
def recolor(self, color, highlight = (1,1,1)):
|
|
||||||
self.node.color = color
|
|
||||||
self.node.highlight = highlight
|
|
||||||
self.loc.color = color
|
|
||||||
|
|
||||||
class ChooseBilbord(ba.Actor):
|
class ChooseBilbord(ba.Actor):
|
||||||
def __init__(self, player:Player, delay = 0.1) -> None:
|
def __init__(self, player: Player, delay=0.1) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
icon = player.get_icon()
|
icon = player.get_icon()
|
||||||
self.scale = 100
|
self.scale = 100
|
||||||
|
|
||||||
self.node = ba.newnode(
|
self.node = ba.newnode(
|
||||||
'image',
|
'image',
|
||||||
delegate=self,
|
delegate=self,
|
||||||
attrs={
|
attrs={
|
||||||
"position":(60,-125),
|
"position": (60, -125),
|
||||||
'texture': icon['texture'],
|
'texture': icon['texture'],
|
||||||
'tint_texture': icon['tint_texture'],
|
'tint_texture': icon['tint_texture'],
|
||||||
'tint_color': icon['tint_color'],
|
'tint_color': icon['tint_color'],
|
||||||
'tint2_color': icon['tint2_color'],
|
'tint2_color': icon['tint2_color'],
|
||||||
'opacity': 1.0,
|
'opacity': 1.0,
|
||||||
'absolute_scale': True,
|
'absolute_scale': True,
|
||||||
'attach': "topLeft"
|
'attach': "topLeft"
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name_node = ba.newnode(
|
self.name_node = ba.newnode(
|
||||||
'text',
|
'text',
|
||||||
owner=self.node,
|
owner=self.node,
|
||||||
attrs={
|
attrs={
|
||||||
'position': (60,-185),
|
'position': (60, -185),
|
||||||
'text': ba.Lstr(value=player.getname()),
|
'text': ba.Lstr(value=player.getname()),
|
||||||
'color': ba.safecolor(player.team.color),
|
'color': ba.safecolor(player.team.color),
|
||||||
'h_align': 'center',
|
'h_align': 'center',
|
||||||
'v_align': 'center',
|
'v_align': 'center',
|
||||||
'vr_depth': 410,
|
'vr_depth': 410,
|
||||||
'flatness': 1.0,
|
'flatness': 1.0,
|
||||||
'h_attach': 'left',
|
'h_attach': 'left',
|
||||||
'v_attach': 'top',
|
'v_attach': 'top',
|
||||||
'maxwidth':self.scale
|
'maxwidth': self.scale
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
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={
|
||||||
ba.animate(self.name_node, "scale", {0 + delay:0, 0.07 + delay:1})
|
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):
|
def handlemessage(self, msg):
|
||||||
super().handlemessage(msg)
|
super().handlemessage(msg)
|
||||||
if isinstance(msg, ba.DieMessage):
|
if isinstance(msg, ba.DieMessage):
|
||||||
ba.animate_array(self.node, "scale", keys={0:self.node.scale, 0.05:[0,0]}, size=1)
|
ba.animate_array(self.node, "scale", keys={0: self.node.scale, 0.05: [0, 0]}, size=1)
|
||||||
ba.animate(self.name_node, "scale", {0:self.name_node.scale, 0.07:0})
|
ba.animate(self.name_node, "scale", {0: self.name_node.scale, 0.07: 0})
|
||||||
|
|
||||||
def __delete():
|
def __delete():
|
||||||
self.node.delete()
|
self.node.delete()
|
||||||
self.name_node.delete()
|
self.name_node.delete()
|
||||||
|
|
||||||
ba.timer(0.2, __delete)
|
ba.timer(0.2, __delete)
|
||||||
|
|
||||||
# ba_meta export game
|
# ba_meta export game
|
||||||
|
|
||||||
|
|
||||||
class LastPunchStand(ba.TeamGameActivity[Player, Team]):
|
class LastPunchStand(ba.TeamGameActivity[Player, Team]):
|
||||||
name = "Last Punch Stand"
|
name = "Last Punch Stand"
|
||||||
description = "Last one punchs the choosing spaz wins"
|
description = "Last one punchs the choosing spaz wins"
|
||||||
tips = [
|
tips = [
|
||||||
'keep punching the choosing spaz to be last punched player at times up!',
|
'keep punching the choosing spaz to be last punched player at times up!',
|
||||||
'you can not frezz the choosing spaz',
|
'you can not frezz the choosing spaz',
|
||||||
"evry time you punch the choosing spaz, you will get one point",
|
"evry time you punch the choosing spaz, you will get one point",
|
||||||
]
|
]
|
||||||
|
|
||||||
default_music = ba.MusicType.TO_THE_DEATH
|
default_music = ba.MusicType.TO_THE_DEATH
|
||||||
|
|
||||||
available_settings = [
|
available_settings = [
|
||||||
ba.FloatSetting("min time limit (in seconds)", 50.0, min_value=30.0),
|
ba.FloatSetting("min time limit (in seconds)", 50.0, min_value=30.0),
|
||||||
ba.FloatSetting("max time limit (in seconds)", 160.0, 60),
|
ba.FloatSetting("max time limit (in seconds)", 160.0, 60),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, settings: dict):
|
def __init__(self, settings: dict):
|
||||||
super().__init__(settings)
|
super().__init__(settings)
|
||||||
self._min_timelimit = settings["min time limit (in seconds)"]
|
self._min_timelimit = settings["min time limit (in seconds)"]
|
||||||
self._max_timelimit = settings["max time limit (in seconds)"]
|
self._max_timelimit = settings["max time limit (in seconds)"]
|
||||||
if (self._min_timelimit > self._max_timelimit):
|
if (self._min_timelimit > self._max_timelimit):
|
||||||
self._max_timelimit = self._min_timelimit
|
self._max_timelimit = self._min_timelimit
|
||||||
|
|
||||||
self._choosing_spaz_defcolor = (0.5,0.5,0.5)
|
self._choosing_spaz_defcolor = (0.5, 0.5, 0.5)
|
||||||
self.choosing_spaz = None
|
self.choosing_spaz = None
|
||||||
self.choosed_player = None
|
self.choosed_player = None
|
||||||
self.times_uped = False
|
self.times_uped = False
|
||||||
self.scoreboard = Scoreboard()
|
self.scoreboard = Scoreboard()
|
||||||
|
|
||||||
def times_up(self):
|
def times_up(self):
|
||||||
self.times_uped = True
|
self.times_uped = True
|
||||||
|
|
||||||
for player in self.players:
|
for player in self.players:
|
||||||
if self.choosed_player and (player.team.id != self.choosed_player.team.id):
|
if self.choosed_player and (player.team.id != self.choosed_player.team.id):
|
||||||
player.actor._cursed = True
|
player.actor._cursed = True
|
||||||
player.actor.curse_explode()
|
player.actor.curse_explode()
|
||||||
|
|
||||||
self.end_game()
|
self.end_game()
|
||||||
|
|
||||||
def __get_spaz_bot_spawn_point(self):
|
def __get_spaz_bot_spawn_point(self):
|
||||||
if len(self.map.tnt_points) > 0:
|
if len(self.map.tnt_points) > 0:
|
||||||
return self.map.tnt_points[random.randint(0, len(self.map.tnt_points)-1)]
|
return self.map.tnt_points[random.randint(0, len(self.map.tnt_points)-1)]
|
||||||
else:
|
else:
|
||||||
return (0, 6, 0)
|
return (0, 6, 0)
|
||||||
|
|
||||||
def spaw_bot(self):
|
def spaw_bot(self):
|
||||||
"spawns a choosing bot"
|
"spawns a choosing bot"
|
||||||
|
|
||||||
self.choosing_spaz = ChooseingSpaz(self.__get_spaz_bot_spawn_point())
|
self.choosing_spaz = ChooseingSpaz(self.__get_spaz_bot_spawn_point())
|
||||||
self.choose_bilbord = None
|
self.choose_bilbord = None
|
||||||
|
|
||||||
def on_begin(self) -> None:
|
def on_begin(self) -> None:
|
||||||
super().on_begin()
|
super().on_begin()
|
||||||
time_limit = random.randint(self._min_timelimit, self._max_timelimit)
|
time_limit = random.randint(self._min_timelimit, self._max_timelimit)
|
||||||
self.spaw_bot()
|
self.spaw_bot()
|
||||||
ba.timer(time_limit, self.times_up)
|
ba.timer(time_limit, self.times_up)
|
||||||
|
|
||||||
self.setup_standard_powerup_drops(False)
|
self.setup_standard_powerup_drops(False)
|
||||||
|
|
||||||
def end_game(self) -> None:
|
def end_game(self) -> None:
|
||||||
results = ba.GameResults()
|
results = ba.GameResults()
|
||||||
for team in self.teams:
|
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):
|
||||||
results.set_team_score(team, team.score)
|
team.score += 100
|
||||||
self.end(results=results)
|
results.set_team_score(team, team.score)
|
||||||
|
self.end(results=results)
|
||||||
|
|
||||||
def change_choosed_player(self, hitter:Player):
|
def change_choosed_player(self, hitter: Player):
|
||||||
if hitter:
|
if hitter:
|
||||||
self.choosing_spaz.recolor(hitter.color, hitter.highlight)
|
self.choosing_spaz.recolor(hitter.color, hitter.highlight)
|
||||||
self.choosed_player = hitter
|
self.choosed_player = hitter
|
||||||
hitter.team.score += 1
|
hitter.team.score += 1
|
||||||
self.choose_bilbord = ChooseBilbord(hitter)
|
self.choose_bilbord = ChooseBilbord(hitter)
|
||||||
self.hide_score_board()
|
self.hide_score_board()
|
||||||
else:
|
else:
|
||||||
self.choosing_spaz.recolor(self._choosing_spaz_defcolor)
|
self.choosing_spaz.recolor(self._choosing_spaz_defcolor)
|
||||||
self.choosed_player = None
|
self.choosed_player = None
|
||||||
self.choose_bilbord = None
|
self.choose_bilbord = None
|
||||||
self.show_score_board()
|
self.show_score_board()
|
||||||
|
|
||||||
def show_score_board(self):
|
def show_score_board(self):
|
||||||
self.scoreboard = Scoreboard()
|
self.scoreboard = Scoreboard()
|
||||||
for team in self.teams:
|
for team in self.teams:
|
||||||
self.scoreboard.set_team_value(team, team.score)
|
self.scoreboard.set_team_value(team, team.score)
|
||||||
|
|
||||||
def hide_score_board(self):
|
def hide_score_board(self):
|
||||||
self.scoreboard = None
|
self.scoreboard = None
|
||||||
|
|
||||||
def _watch_dog_(self):
|
def _watch_dog_(self):
|
||||||
"checks if choosing spaz exists"
|
"checks if choosing spaz exists"
|
||||||
#choosing spaz wont respawn if death type if generic
|
# choosing spaz wont respawn if death type if generic
|
||||||
#this becuse we dont want to keep respawn him when he dies because of losing referce
|
# this becuse we dont want to keep respawn him when he dies because of losing referce
|
||||||
#but sometimes "choosing spaz" dies naturaly and his death type is generic! so it wont respawn back again
|
# but sometimes "choosing spaz" dies naturaly and his death type is generic! so it wont respawn back again
|
||||||
#thats why we have this function; to check if spaz exits in the case that he didnt respawned
|
# thats why we have this function; to check if spaz exits in the case that he didnt respawned
|
||||||
|
|
||||||
if self.choosing_spaz:
|
if self.choosing_spaz:
|
||||||
if self.choosing_spaz._dead:
|
if self.choosing_spaz._dead:
|
||||||
self.spaw_bot()
|
self.spaw_bot()
|
||||||
else:
|
else:
|
||||||
self.spaw_bot()
|
self.spaw_bot()
|
||||||
|
|
||||||
def handlemessage(self, msg):
|
def handlemessage(self, msg):
|
||||||
super().handlemessage(msg)
|
super().handlemessage(msg)
|
||||||
|
|
||||||
if isinstance(msg, ChooseingSpazHitMessage):
|
if isinstance(msg, ChooseingSpazHitMessage):
|
||||||
hitter = msg.hitter
|
hitter = msg.hitter
|
||||||
if self.choosing_spaz.node and hitter:
|
if self.choosing_spaz.node and hitter:
|
||||||
self.change_choosed_player(hitter)
|
self.change_choosed_player(hitter)
|
||||||
|
|
||||||
elif isinstance(msg, ChooseingSpazDieMessage):
|
elif isinstance(msg, ChooseingSpazDieMessage):
|
||||||
self.spaw_bot()
|
self.spaw_bot()
|
||||||
self.change_choosed_player(None)
|
self.change_choosed_player(None)
|
||||||
|
|
||||||
elif isinstance(msg, ba.PlayerDiedMessage):
|
elif isinstance(msg, ba.PlayerDiedMessage):
|
||||||
player = msg.getplayer(Player)
|
player = msg.getplayer(Player)
|
||||||
if not (self.has_ended() or self.times_uped):
|
if not (self.has_ended() or self.times_uped):
|
||||||
self.respawn_player(player, 0)
|
self.respawn_player(player, 0)
|
||||||
|
|
||||||
if self.choosed_player and (player.getname(True) == self.choosed_player.getname(True)):
|
if self.choosed_player and (player.getname(True) == self.choosed_player.getname(True)):
|
||||||
self.change_choosed_player(None)
|
self.change_choosed_player(None)
|
||||||
|
|
||||||
self._watch_dog_()
|
self._watch_dog_()
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,17 @@ from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import enum
|
import enum
|
||||||
import ba, _ba
|
import ba
|
||||||
|
import _ba
|
||||||
|
|
||||||
from bastd.actor.scoreboard import Scoreboard
|
from bastd.actor.scoreboard import Scoreboard
|
||||||
from bastd.actor.powerupbox import PowerupBox
|
from bastd.actor.powerupbox import PowerupBox
|
||||||
from bastd.gameutils import SharedObjects
|
from bastd.gameutils import SharedObjects
|
||||||
|
|
||||||
#from rocket
|
# from rocket
|
||||||
from bastd.actor.bomb import Blast
|
from bastd.actor.bomb import Blast
|
||||||
|
|
||||||
#from railgun
|
# from railgun
|
||||||
from bastd.actor.playerspaz import PlayerSpaz
|
from bastd.actor.playerspaz import PlayerSpaz
|
||||||
from bastd.actor.spaz import Spaz
|
from bastd.actor.spaz import Spaz
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ if TYPE_CHECKING:
|
||||||
STORAGE_ATTR_NAME = f'_shared_{__name__}_factory'
|
STORAGE_ATTR_NAME = f'_shared_{__name__}_factory'
|
||||||
|
|
||||||
|
|
||||||
#+++++++++++++++++++Rocket++++++++++++++++++++++++
|
# +++++++++++++++++++Rocket++++++++++++++++++++++++
|
||||||
class RocketFactory:
|
class RocketFactory:
|
||||||
"""Quake Rocket factory"""
|
"""Quake Rocket factory"""
|
||||||
|
|
||||||
|
|
@ -182,10 +183,10 @@ class Rocket(ba.Actor):
|
||||||
elif isinstance(msg, ba.OutOfBoundsMessage):
|
elif isinstance(msg, ba.OutOfBoundsMessage):
|
||||||
self.handlemessage(ba.DieMessage())
|
self.handlemessage(ba.DieMessage())
|
||||||
|
|
||||||
#-------------------Rocket--------------------------
|
# -------------------Rocket--------------------------
|
||||||
|
|
||||||
|
|
||||||
#++++++++++++++++++Railgun++++++++++++++++++++++++++
|
# ++++++++++++++++++Railgun++++++++++++++++++++++++++
|
||||||
class Railgun:
|
class Railgun:
|
||||||
"""Very dangerous weapon"""
|
"""Very dangerous weapon"""
|
||||||
|
|
||||||
|
|
@ -298,7 +299,8 @@ class RailBullet(ba.Actor):
|
||||||
elif isinstance(msg, ba.OutOfBoundsMessage):
|
elif isinstance(msg, ba.OutOfBoundsMessage):
|
||||||
self.handlemessage(ba.DieMessage())
|
self.handlemessage(ba.DieMessage())
|
||||||
|
|
||||||
#------------------Railgun-------------------------
|
# ------------------Railgun-------------------------
|
||||||
|
|
||||||
|
|
||||||
class Player(ba.Player['Team']):
|
class Player(ba.Player['Team']):
|
||||||
"""Our player"""
|
"""Our player"""
|
||||||
|
|
@ -306,6 +308,7 @@ class Player(ba.Player['Team']):
|
||||||
|
|
||||||
class Team(ba.Team[Player]):
|
class Team(ba.Team[Player]):
|
||||||
"""Our team"""
|
"""Our team"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.score = 0
|
self.score = 0
|
||||||
|
|
||||||
|
|
@ -618,10 +621,10 @@ class Obstacle(ba.Actor):
|
||||||
'color_texture':
|
'color_texture':
|
||||||
ba.gettexture('bunnyColor'),
|
ba.gettexture('bunnyColor'),
|
||||||
'materials': [SharedObjects.get().footing_material]
|
'materials': [SharedObjects.get().footing_material]
|
||||||
if mirror else [
|
if mirror else [
|
||||||
SharedObjects.get().object_material,
|
SharedObjects.get().object_material,
|
||||||
SharedObjects.get().footing_material
|
SharedObjects.get().footing_material
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
def handlemessage(self, msg: Any) -> Any:
|
def handlemessage(self, msg: Any) -> Any:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Released under the MIT License. See LICENSE for details.
|
# Released under the MIT License. See LICENSE for details.
|
||||||
# y me (: itsre3
|
# y me (: itsre3
|
||||||
# =>2<=
|
# =>2<=
|
||||||
#BCS RULES
|
# BCS RULES
|
||||||
#
|
#
|
||||||
"""Defines Race mini-game."""
|
"""Defines Race mini-game."""
|
||||||
|
|
||||||
|
|
@ -14,7 +14,8 @@ import random
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
import ba, _ba
|
import ba
|
||||||
|
import _ba
|
||||||
from bastd.actor.bomb import Bomb
|
from bastd.actor.bomb import Bomb
|
||||||
from bastd.actor.playerspaz import PlayerSpaz
|
from bastd.actor.playerspaz import PlayerSpaz
|
||||||
from bastd.actor.scoreboard import Scoreboard
|
from bastd.actor.scoreboard import Scoreboard
|
||||||
|
|
@ -215,7 +216,7 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
|
||||||
('modify_part_collision', 'physical', False),
|
('modify_part_collision', 'physical', False),
|
||||||
('call', 'at_connect',
|
('call', 'at_connect',
|
||||||
self._handle_race_point_collide),
|
self._handle_race_point_collide),
|
||||||
))
|
))
|
||||||
for rpt in pts:
|
for rpt in pts:
|
||||||
self._regions.append(RaceRegion(rpt, len(self._regions)))
|
self._regions.append(RaceRegion(rpt, len(self._regions)))
|
||||||
|
|
||||||
|
|
@ -263,7 +264,7 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
|
||||||
translate=('statements', 'Killing ${NAME} for'
|
translate=('statements', 'Killing ${NAME} for'
|
||||||
' skipping part of the track!'),
|
' skipping part of the track!'),
|
||||||
subs=[('${NAME}', player.getname(full=True))]),
|
subs=[('${NAME}', player.getname(full=True))]),
|
||||||
color=(1, 0, 0))
|
color=(1, 0, 0))
|
||||||
else:
|
else:
|
||||||
# If this player is in first, note that this is the
|
# If this player is in first, note that this is the
|
||||||
# front-most race-point.
|
# front-most race-point.
|
||||||
|
|
@ -378,7 +379,7 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
|
||||||
'${TEAM} is disqualified because ${PLAYER} left'),
|
'${TEAM} is disqualified because ${PLAYER} left'),
|
||||||
subs=[('${TEAM}', player.team.name),
|
subs=[('${TEAM}', player.team.name),
|
||||||
('${PLAYER}', player.getname(full=True))]),
|
('${PLAYER}', player.getname(full=True))]),
|
||||||
color=(1, 1, 0))
|
color=(1, 1, 0))
|
||||||
player.team.finished = True
|
player.team.finished = True
|
||||||
player.team.time = None
|
player.team.time = None
|
||||||
player.team.lap = 0
|
player.team.lap = 0
|
||||||
|
|
@ -435,7 +436,6 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
|
||||||
'text': 'By itsre3'
|
'text': 'By itsre3'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
# Throw a timer up on-screen.
|
# Throw a timer up on-screen.
|
||||||
self._time_text = ba.NodeActor(
|
self._time_text = ba.NodeActor(
|
||||||
ba.newnode('text',
|
ba.newnode('text',
|
||||||
|
|
@ -543,35 +543,34 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
|
||||||
self._spawn_bomb,
|
self._spawn_bomb,
|
||||||
repeat=True)
|
repeat=True)
|
||||||
|
|
||||||
|
|
||||||
def knock_players():
|
def knock_players():
|
||||||
activity = _ba.get_foreground_host_activity()
|
activity = _ba.get_foreground_host_activity()
|
||||||
gnode = ba.getactivity().globalsnode
|
gnode = ba.getactivity().globalsnode
|
||||||
for players in activity.players:
|
for players in activity.players:
|
||||||
gnode.tint = (0.5,0.5,0.5)
|
gnode.tint = (0.5, 0.5, 0.5)
|
||||||
node = players.actor.node
|
node = players.actor.node
|
||||||
node.handlemessage('knockout', 600.0)
|
node.handlemessage('knockout', 600.0)
|
||||||
self.text_offset = ba.newnode('math',
|
self.text_offset = ba.newnode('math',
|
||||||
owner=node,
|
owner=node,
|
||||||
attrs={'input1': (-0.5, 0.5, 0.25),
|
attrs={'input1': (-0.5, 0.5, 0.25),
|
||||||
'operation': 'add'})
|
'operation': 'add'})
|
||||||
node.connectattr(
|
node.connectattr(
|
||||||
'torso_position',
|
'torso_position',
|
||||||
self.text_offset,
|
self.text_offset,
|
||||||
'input2')
|
'input2')
|
||||||
self.text = ba.newnode('text',
|
self.text = ba.newnode('text',
|
||||||
owner=node,
|
owner=node,
|
||||||
attrs={
|
attrs={
|
||||||
'h_align': 'right',
|
'h_align': 'right',
|
||||||
'color': (1.0, 1.0, 1.0),
|
'color': (1.0, 1.0, 1.0),
|
||||||
'shadow': 1.0,
|
'shadow': 1.0,
|
||||||
'text': 'z z',
|
'text': 'z z',
|
||||||
'scale': 0.01,
|
'scale': 0.01,
|
||||||
'in_world': True})
|
'in_world': True})
|
||||||
self.text_offset.connectattr(
|
self.text_offset.connectattr(
|
||||||
'output',
|
'output',
|
||||||
self.text,
|
self.text,
|
||||||
'position')
|
'position')
|
||||||
ba.animate(self.text, 'scale', {0: 0.0, 1.0: 0.01})
|
ba.animate(self.text, 'scale', {0: 0.0, 1.0: 0.01})
|
||||||
ba.timer(2, self.text.delete)
|
ba.timer(2, self.text.delete)
|
||||||
|
|
||||||
|
|
@ -583,7 +582,6 @@ class SleepRaceGame(ba.TeamGameActivity[Player, Team]):
|
||||||
|
|
||||||
self._race_started = True
|
self._race_started = True
|
||||||
|
|
||||||
|
|
||||||
def _update_player_order(self) -> None:
|
def _update_player_order(self) -> None:
|
||||||
|
|
||||||
# Calc all player distances.
|
# Calc all player distances.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#snake
|
# snake
|
||||||
# Released under the MIT License. See LICENSE for details.
|
# Released under the MIT License. See LICENSE for details.
|
||||||
#
|
#
|
||||||
"""Snake game by SEBASTIAN2059"""
|
"""Snake game by SEBASTIAN2059"""
|
||||||
|
|
@ -18,27 +18,33 @@ from bastd.actor import bomb as stdbomb
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
|
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
|
||||||
|
|
||||||
|
|
||||||
class ScoreMessage:
|
class ScoreMessage:
|
||||||
"""It will help us with the scores."""
|
"""It will help us with the scores."""
|
||||||
def __init__(self,player: Player):
|
|
||||||
|
def __init__(self, player: Player):
|
||||||
self.player = player
|
self.player = player
|
||||||
|
|
||||||
def getplayer(self):
|
def getplayer(self):
|
||||||
return self.player
|
return self.player
|
||||||
|
|
||||||
|
|
||||||
class Player(ba.Player['Team']):
|
class Player(ba.Player['Team']):
|
||||||
"""Our player type for this game."""
|
"""Our player type for this game."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
|
||||||
self.mines = []
|
self.mines = []
|
||||||
self.actived = None
|
self.actived = None
|
||||||
|
|
||||||
|
|
||||||
class Team(ba.Team[Player]):
|
class Team(ba.Team[Player]):
|
||||||
"""Our team type for this game."""
|
"""Our team type for this game."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.score = 0
|
self.score = 0
|
||||||
|
|
||||||
|
|
||||||
lang = ba.app.lang.language
|
lang = ba.app.lang.language
|
||||||
if lang == 'Spanish':
|
if lang == 'Spanish':
|
||||||
description = 'Sobrevive a un número determinado de minas para ganar.'
|
description = 'Sobrevive a un número determinado de minas para ganar.'
|
||||||
|
|
@ -50,18 +56,23 @@ else:
|
||||||
join_description = "Run and don't get killed."
|
join_description = "Run and don't get killed."
|
||||||
view_description = 'survive ${ARG1} mines'
|
view_description = 'survive ${ARG1} mines'
|
||||||
|
|
||||||
|
|
||||||
class Custom_Mine(stdbomb.Bomb):
|
class Custom_Mine(stdbomb.Bomb):
|
||||||
"""Custom a mine :)"""
|
"""Custom a mine :)"""
|
||||||
def __init__(self,position,source_player):
|
|
||||||
stdbomb.Bomb.__init__(self,position=position,bomb_type='land_mine',source_player=source_player)
|
|
||||||
|
|
||||||
def handlemessage(self,msg: Any) -> Any:
|
def __init__(self, position, 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):
|
if isinstance(msg, ba.HitMessage):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
super().handlemessage(msg)
|
super().handlemessage(msg)
|
||||||
|
|
||||||
# ba_meta export game
|
# ba_meta export game
|
||||||
|
|
||||||
|
|
||||||
class SnakeGame(ba.TeamGameActivity[Player, Team]):
|
class SnakeGame(ba.TeamGameActivity[Player, Team]):
|
||||||
"""A game type based on acquiring kills."""
|
"""A game type based on acquiring kills."""
|
||||||
|
|
||||||
|
|
@ -151,14 +162,13 @@ class SnakeGame(ba.TeamGameActivity[Player, Team]):
|
||||||
def on_begin(self) -> None:
|
def on_begin(self) -> None:
|
||||||
super().on_begin()
|
super().on_begin()
|
||||||
self.setup_standard_time_limit(self._time_limit)
|
self.setup_standard_time_limit(self._time_limit)
|
||||||
#self.setup_standard_powerup_drops()
|
# self.setup_standard_powerup_drops()
|
||||||
|
|
||||||
# Base kills needed to win on the size of the largest team.
|
# Base kills needed to win on the size of the largest team.
|
||||||
self._score_to_win = (self._kills_to_win_per_player *
|
self._score_to_win = (self._kills_to_win_per_player *
|
||||||
max(1, max(len(t.players) for t in self.teams)))
|
max(1, max(len(t.players) for t in self.teams)))
|
||||||
self._update_scoreboard()
|
self._update_scoreboard()
|
||||||
|
|
||||||
|
|
||||||
if self.slow_motion:
|
if self.slow_motion:
|
||||||
t_scale = 0.4
|
t_scale = 0.4
|
||||||
light_y = 50
|
light_y = 50
|
||||||
|
|
@ -240,31 +250,28 @@ class SnakeGame(ba.TeamGameActivity[Player, Team]):
|
||||||
self.generate_mines(player)
|
self.generate_mines(player)
|
||||||
return spaz
|
return spaz
|
||||||
|
|
||||||
|
def generate_mines(self, player: Player):
|
||||||
def generate_mines(self,player: Player):
|
|
||||||
try:
|
try:
|
||||||
player.actived = ba.Timer(0.5,ba.Call(self.spawn_mine, player),repeat=True)
|
player.actived = ba.Timer(0.5, ba.Call(self.spawn_mine, player), repeat=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Exception -> '+ str(e))
|
print('Exception -> ' + str(e))
|
||||||
|
|
||||||
|
def spawn_mine(self, player: Player):
|
||||||
|
|
||||||
def spawn_mine(self,player: Player):
|
|
||||||
if player.team.score >= self._score_to_win:
|
if player.team.score >= self._score_to_win:
|
||||||
return
|
return
|
||||||
pos = player.actor.node.position
|
pos = player.actor.node.position
|
||||||
# mine = stdbomb.Bomb(position=(pos[0], pos[1] + 2.0, pos[2]),
|
# mine = stdbomb.Bomb(position=(pos[0], pos[1] + 2.0, pos[2]),
|
||||||
# velocity=(0, 0, 0),
|
# velocity=(0, 0, 0),
|
||||||
# bomb_type='land_mine',
|
# bomb_type='land_mine',
|
||||||
# #blast_radius=,
|
# #blast_radius=,
|
||||||
# source_player=player.actor.source_player,
|
# source_player=player.actor.source_player,
|
||||||
# owner=player.actor.node).autoretain()
|
# owner=player.actor.node).autoretain()
|
||||||
mine = Custom_Mine(position=(pos[0], pos[1] + 2.0, pos[2]),
|
mine = Custom_Mine(position=(pos[0], pos[1] + 2.0, pos[2]),
|
||||||
source_player=player.actor.source_player)
|
source_player=player.actor.source_player)
|
||||||
|
|
||||||
def arm():
|
def arm():
|
||||||
mine.arm()
|
mine.arm()
|
||||||
ba.timer(0.5,arm)
|
ba.timer(0.5, arm)
|
||||||
|
|
||||||
player.mines.append(mine)
|
player.mines.append(mine)
|
||||||
if len(player.mines) > 15:
|
if len(player.mines) > 15:
|
||||||
|
|
@ -297,7 +304,7 @@ class SnakeGame(ba.TeamGameActivity[Player, Team]):
|
||||||
|
|
||||||
assert self._score_to_win is not None
|
assert self._score_to_win is not None
|
||||||
if any(team.score >= self._score_to_win for team in self.teams):
|
if any(team.score >= self._score_to_win for team in self.teams):
|
||||||
self.end_game() #ba.timer(0.5, self.end_game)
|
self.end_game() # ba.timer(0.5, self.end_game)
|
||||||
else:
|
else:
|
||||||
return super().handlemessage(msg)
|
return super().handlemessage(msg)
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
import random
|
import random
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
import ba, _ba
|
import ba
|
||||||
|
import _ba
|
||||||
from bastd.actor.playerspaz import PlayerSpaz
|
from bastd.actor.playerspaz import PlayerSpaz
|
||||||
from bastd.actor.spaz import Spaz
|
from bastd.actor.spaz import Spaz
|
||||||
from bastd.actor.bomb import Blast, Bomb
|
from bastd.actor.bomb import Blast, Bomb
|
||||||
|
|
@ -56,8 +57,6 @@ class RoboBot(StickyBot):
|
||||||
highlight = (3, 3, 3)
|
highlight = (3, 3, 3)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UFO(ba.Actor):
|
class UFO(ba.Actor):
|
||||||
"""
|
"""
|
||||||
New AI for Boss
|
New AI for Boss
|
||||||
|
|
@ -252,8 +251,8 @@ class UFO(ba.Actor):
|
||||||
1.0 + i,
|
1.0 + i,
|
||||||
lambda: self._bots.spawn_bot(
|
lambda: self._bots.spawn_bot(
|
||||||
RoboBot, pos=(self.node.position[0],
|
RoboBot, pos=(self.node.position[0],
|
||||||
self.node.position[1] - 1,
|
self.node.position[1] - 1,
|
||||||
self.node.position[2]), spawn_time=0.0
|
self.node.position[2]), spawn_time=0.0
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
@ -299,7 +298,6 @@ class UFO(ba.Actor):
|
||||||
node.position[2], 0, 5, 0, 3, 10, 0,
|
node.position[2], 0, 5, 0, 3, 10, 0,
|
||||||
0, 0, 5, 0)
|
0, 0, 5, 0)
|
||||||
|
|
||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -314,7 +312,6 @@ class UFO(ba.Actor):
|
||||||
if not self.node:
|
if not self.node:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
damage = abs(msg.magnitude)
|
damage = abs(msg.magnitude)
|
||||||
if msg.hit_type == 'explosion':
|
if msg.hit_type == 'explosion':
|
||||||
damage /= 20
|
damage /= 20
|
||||||
|
|
@ -326,7 +323,7 @@ class UFO(ba.Actor):
|
||||||
self.handlemessage(ba.DieMessage())
|
self.handlemessage(ba.DieMessage())
|
||||||
|
|
||||||
def _get_target_player_pt(self) -> tuple[
|
def _get_target_player_pt(self) -> tuple[
|
||||||
ba.Vec3 | None, ba.Vec3 | None]:
|
ba.Vec3 | None, ba.Vec3 | None]:
|
||||||
"""Returns the position and velocity of our target.
|
"""Returns the position and velocity of our target.
|
||||||
|
|
||||||
Both values will be None in the case of no target.
|
Both values will be None in the case of no target.
|
||||||
|
|
@ -519,7 +516,6 @@ class UFO(ba.Actor):
|
||||||
{0: self.shield_deco.color, 0.2: (5, 0.2, 0.2)})
|
{0: self.shield_deco.color, 0.2: (5, 0.2, 0.2)})
|
||||||
self.bot_count = 6
|
self.bot_count = 6
|
||||||
|
|
||||||
|
|
||||||
def update_ai(self) -> None:
|
def update_ai(self) -> None:
|
||||||
"""Should be called periodically to update the spaz' AI."""
|
"""Should be called periodically to update the spaz' AI."""
|
||||||
# pylint: disable=too-many-branches
|
# pylint: disable=too-many-branches
|
||||||
|
|
@ -572,9 +568,9 @@ class UFO(ba.Actor):
|
||||||
self.to_target.y,
|
self.to_target.y,
|
||||||
self.to_target.z * self.xz_pos))
|
self.to_target.z * self.xz_pos))
|
||||||
setattr(self.node, 'extra_acceleration',
|
setattr(self.node, 'extra_acceleration',
|
||||||
(self.to_target.x * self.xz_pos ,
|
(self.to_target.x * self.xz_pos,
|
||||||
self.to_target.y * 80 + 70,
|
self.to_target.y * 80 + 70,
|
||||||
self.to_target.z * self.xz_pos))
|
self.to_target.z * self.xz_pos))
|
||||||
|
|
||||||
def on_expire(self) -> None:
|
def on_expire(self) -> None:
|
||||||
super().on_expire()
|
super().on_expire()
|
||||||
|
|
@ -656,7 +652,6 @@ class UFO(ba.Actor):
|
||||||
self.xz_pos = 0.01
|
self.xz_pos = 0.01
|
||||||
self.node.reflection_scale = [2]
|
self.node.reflection_scale = [2]
|
||||||
|
|
||||||
|
|
||||||
def unfrozen():
|
def unfrozen():
|
||||||
self.frozen = False
|
self.frozen = False
|
||||||
if self.bot_dur_froze:
|
if self.bot_dur_froze:
|
||||||
|
|
@ -666,7 +661,6 @@ class UFO(ba.Actor):
|
||||||
self.xz_pos = 1
|
self.xz_pos = 1
|
||||||
self.node.reflection_scale = [0.25]
|
self.node.reflection_scale = [0.25]
|
||||||
|
|
||||||
|
|
||||||
ba.timer(5.0, unfrozen)
|
ba.timer(5.0, unfrozen)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
@ -710,8 +704,8 @@ class UFOSet:
|
||||||
+ str(self._ufo_bot_lists[self._ufo_bot_update_list])
|
+ str(self._ufo_bot_lists[self._ufo_bot_update_list])
|
||||||
)
|
)
|
||||||
self._bot_update_list = (
|
self._bot_update_list = (
|
||||||
self._ufo_bot_update_list + 1
|
self._ufo_bot_update_list + 1
|
||||||
) % self._ufo_bot_list_count
|
) % self._ufo_bot_list_count
|
||||||
|
|
||||||
# Update our list of player points for the bots to use.
|
# Update our list of player points for the bots to use.
|
||||||
player_pts = []
|
player_pts = []
|
||||||
|
|
@ -784,7 +778,7 @@ class UFOSet:
|
||||||
"""Add a ba.SpazBot instance to the set."""
|
"""Add a ba.SpazBot instance to the set."""
|
||||||
self._ufo_bot_lists[self._ufo_bot_add_list].append(bot)
|
self._ufo_bot_lists[self._ufo_bot_add_list].append(bot)
|
||||||
self._ufo_bot_add_list = (
|
self._ufo_bot_add_list = (
|
||||||
self._ufo_bot_add_list + 1) % self._ufo_bot_list_count
|
self._ufo_bot_add_list + 1) % self._ufo_bot_list_count
|
||||||
|
|
||||||
def have_living_bots(self) -> bool:
|
def have_living_bots(self) -> bool:
|
||||||
"""Return whether any bots in the set are alive or spawning."""
|
"""Return whether any bots in the set are alive or spawning."""
|
||||||
|
|
@ -859,18 +853,16 @@ class UFOightGame(ba.TeamGameActivity[Player, Team]):
|
||||||
self._bots = UFOSet()
|
self._bots = UFOSet()
|
||||||
self._preset = str(settings['preset'])
|
self._preset = str(settings['preset'])
|
||||||
self._credit = ba.newnode('text',
|
self._credit = ba.newnode('text',
|
||||||
attrs={
|
attrs={
|
||||||
'v_attach': 'bottom',
|
'v_attach': 'bottom',
|
||||||
'h_align': 'center',
|
'h_align': 'center',
|
||||||
'color': (0.4, 0.4, 0.4),
|
'color': (0.4, 0.4, 0.4),
|
||||||
'flatness': 0.5,
|
'flatness': 0.5,
|
||||||
'shadow': 0.5,
|
'shadow': 0.5,
|
||||||
'position': (0, 20),
|
'position': (0, 20),
|
||||||
'scale': 0.7,
|
'scale': 0.7,
|
||||||
'text': 'By Cross Joy'
|
'text': 'By Cross Joy'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_transition_in(self) -> None:
|
def on_transition_in(self) -> None:
|
||||||
super().on_transition_in()
|
super().on_transition_in()
|
||||||
|
|
@ -882,8 +874,6 @@ class UFOightGame(ba.TeamGameActivity[Player, Team]):
|
||||||
super().on_begin()
|
super().on_begin()
|
||||||
self.setup_standard_powerup_drops()
|
self.setup_standard_powerup_drops()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# In pro mode there's no powerups.
|
# In pro mode there's no powerups.
|
||||||
|
|
||||||
# Make our on-screen timer and start it roughly when our bots appear.
|
# 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',
|
preview_texture_name='footballStadiumPreview',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#Made by your friend: @[Just] Freak#4999
|
# Made by your friend: @[Just] Freak#4999
|
||||||
|
|
||||||
# ba_meta require api 7
|
# ba_meta require api 7
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
@ -116,26 +116,28 @@ class BoxingGame(ba.TeamGameActivity[Player, Team]):
|
||||||
def on_team_join(self, team: Team) -> None:
|
def on_team_join(self, team: Team) -> None:
|
||||||
if self.has_begun():
|
if self.has_begun():
|
||||||
self._update_scoreboard()
|
self._update_scoreboard()
|
||||||
|
|
||||||
def getRandomPowerupPoint(self) -> None:
|
def getRandomPowerupPoint(self) -> None:
|
||||||
myMap = self.map.getname()
|
myMap = self.map.getname()
|
||||||
if myMap == 'Doom Shroom':
|
if myMap == 'Doom Shroom':
|
||||||
while True:
|
while True:
|
||||||
x = random.uniform(-1.0,1.0)
|
x = random.uniform(-1.0, 1.0)
|
||||||
y = 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:
|
||||||
return ((8.0*x,2.5,-3.5+5.0*y))
|
break
|
||||||
|
return ((8.0*x, 2.5, -3.5+5.0*y))
|
||||||
elif myMap == 'Rampage':
|
elif myMap == 'Rampage':
|
||||||
x = random.uniform(-6.0,7.0)
|
x = random.uniform(-6.0, 7.0)
|
||||||
y = random.uniform(-6.0,-2.5)
|
y = random.uniform(-6.0, -2.5)
|
||||||
return ((x, 5.2, y))
|
return ((x, 5.2, y))
|
||||||
else:
|
else:
|
||||||
x = random.uniform(-5.0,5.0)
|
x = random.uniform(-5.0, 5.0)
|
||||||
y = random.uniform(-6.0,0.0)
|
y = random.uniform(-6.0, 0.0)
|
||||||
return ((x, 8.0, y))
|
return ((x, 8.0, y))
|
||||||
|
|
||||||
def on_begin(self) -> None:
|
def on_begin(self) -> None:
|
||||||
super().on_begin()
|
super().on_begin()
|
||||||
ba.screenmessage("start Yeeting",color = (0.2,1,1))
|
ba.screenmessage("start Yeeting", color=(0.2, 1, 1))
|
||||||
self.setup_standard_time_limit(self._time_limit)
|
self.setup_standard_time_limit(self._time_limit)
|
||||||
# Base kills needed to win on the size of the largest team.
|
# Base kills needed to win on the size of the largest team.
|
||||||
self._score_to_win = (self._kills_to_win_per_player *
|
self._score_to_win = (self._kills_to_win_per_player *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue