diff --git a/plugins/minigames/air_soccer.py b/plugins/minigames/air_soccer.py index 83ecd46..a089d95 100644 --- a/plugins/minigames/air_soccer.py +++ b/plugins/minigames/air_soccer.py @@ -9,7 +9,8 @@ from __future__ import annotations from typing import TYPE_CHECKING -import ba,_ba +import ba +import _ba from bastd.actor.playerspaz import PlayerSpaz from bastd.actor.scoreboard import Scoreboard from bastd.actor.powerupbox import PowerupBoxFactory @@ -25,14 +26,17 @@ class PuckDiedMessage: def __init__(self, puck: Puck): self.puck = puck + def create_slope(self): - shared = SharedObjects.get() - x=5 - y=12 - for i in range(0,10): - ba.newnode('region',attrs={'position': (x, y, -5.52),'scale': (0.2,0.1,6),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - x = x+0.3 - y = y+0.1 + shared = SharedObjects.get() + x = 5 + y = 12 + for i in range(0, 10): + ba.newnode('region', attrs={'position': (x, y, -5.52), 'scale': (0.2, 0.1, 6), + 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + x = x+0.3 + y = y+0.1 + class Puck(ba.Actor): """A lovely giant hockey puck.""" @@ -57,7 +61,7 @@ class Puck(ba.Actor): 'body': 'sphere', 'reflection': 'soft', 'reflection_scale': [0.2], - 'gravity_scale':0.3, + 'gravity_scale': 0.3, 'shadow_size': 0.5, 'is_area_of_interest': True, 'position': self._spawn_pos, @@ -190,7 +194,7 @@ class AirSoccerGame(ba.TeamGameActivity[Player, Team]): shared.footing_material), actions=('impact_sound', self._puck_sound, 0.2, 5)) - self._real_wall_material=ba.Material() + self._real_wall_material = ba.Material() self._real_wall_material.add_actions( actions=( @@ -206,7 +210,7 @@ class AirSoccerGame(ba.TeamGameActivity[Player, Team]): ('modify_part_collision', 'physical', True) )) - self._goal_post_material=ba.Material() + self._goal_post_material = ba.Material() self._goal_post_material.add_actions( actions=( @@ -261,7 +265,7 @@ class AirSoccerGame(ba.TeamGameActivity[Player, Team]): self.setup_standard_time_limit(self._time_limit) self.setup_standard_powerup_drops() - self._puck_spawn_pos =(0,16.9,-5.5) + self._puck_spawn_pos = (0, 16.9, -5.5) self._spawn_puck() self.make_map() @@ -272,8 +276,8 @@ class AirSoccerGame(ba.TeamGameActivity[Player, Team]): ba.NodeActor( ba.newnode('region', attrs={ - 'position': (17,14.5,-5.52), - 'scale': (1,3,1), + 'position': (17, 14.5, -5.52), + 'scale': (1, 3, 1), 'type': 'box', 'materials': [self._score_region_material] }))) @@ -281,8 +285,8 @@ class AirSoccerGame(ba.TeamGameActivity[Player, Team]): ba.NodeActor( ba.newnode('region', attrs={ - 'position': (-17,14.5,-5.52), - 'scale': (1,3,1), + 'position': (-17, 14.5, -5.52), + 'scale': (1, 3, 1), 'type': 'box', 'materials': [self._score_region_material] }))) @@ -306,72 +310,80 @@ class AirSoccerGame(ba.TeamGameActivity[Player, Team]): def make_map(self): shared = SharedObjects.get() - _ba.get_foreground_host_activity()._map.leftwall.materials= [shared.footing_material,self._real_wall_material ] - - _ba.get_foreground_host_activity()._map.rightwall.materials=[shared.footing_material,self._real_wall_material ] - - _ba.get_foreground_host_activity()._map.topwall.materials=[shared.footing_material,self._real_wall_material ] - self.floorwall=ba.newnode('region',attrs={'position': (0, 5, -5.52),'scale': (35.4,0.2,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - ba.newnode('locator', attrs={'shape':'box', 'position':(0, 5, -5.52), 'color':(0,0,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(35.4,0.2,2)}) - + _ba.get_foreground_host_activity()._map.leftwall.materials = [ + shared.footing_material, self._real_wall_material] - self.create_goal_post(-16.65,12.69) - self.create_goal_post(-16.65,16.69) - - self.create_goal_post(16.65,12.69) - self.create_goal_post(16.65,16.69) - - self.create_static_step(0,16.29) + _ba.get_foreground_host_activity()._map.rightwall.materials = [ + shared.footing_material, self._real_wall_material] - self.create_static_step(4.35,11.1) - self.create_static_step(-4.35,11.1) + _ba.get_foreground_host_activity()._map.topwall.materials = [ + shared.footing_material, self._real_wall_material] + self.floorwall = ba.newnode('region', attrs={'position': (0, 5, -5.52), 'scale': ( + 35.4, 0.2, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + ba.newnode('locator', attrs={'shape': 'box', 'position': ( + 0, 5, -5.52), 'color': (0, 0, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (35.4, 0.2, 2)}) + + self.create_goal_post(-16.65, 12.69) + self.create_goal_post(-16.65, 16.69) + + self.create_goal_post(16.65, 12.69) + self.create_goal_post(16.65, 16.69) + + self.create_static_step(0, 16.29) + + self.create_static_step(4.35, 11.1) + self.create_static_step(-4.35, 11.1) self.create_vertical(10, 15.6) self.create_vertical(-10, 15.6) - - def create_static_step(self,x,y): - floor="" - for i in range(0,7): - floor+="_ " + + def create_static_step(self, x, y): + floor = "" + for i in range(0, 7): + floor += "_ " shared = SharedObjects.get() - step={} - step["r"]=ba.newnode('region',attrs={'position': (x, y, -5.52),'scale': (3,0.1,6),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - ba.newnode('locator', attrs={'shape':'box', 'position':( x, y, -5.52), 'color':(1,1,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(3,0.1,2)}) - + step = {} + step["r"] = ba.newnode('region', attrs={'position': (x, y, -5.52), 'scale': ( + 3, 0.1, 6), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + ba.newnode('locator', attrs={'shape': 'box', 'position': ( + x, y, -5.52), 'color': (1, 1, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (3, 0.1, 2)}) + return step - def create_goal_post(self,x,y): + + def create_goal_post(self, x, y): shared = SharedObjects.get() if x > 0: - color = (1,0,0) #change to team specific color + color = (1, 0, 0) # change to team specific color else: - color = (0,0,1) - floor="" - for i in range(0,4): - floor+="_ " - ba.newnode('region',attrs={'position': (x-0.2, y, -5.52),'scale': (1.8,0.1,6),'type': 'box','materials': [shared.footing_material,self._goal_post_material]}) - - ba.newnode('locator', attrs={'shape':'box', 'position':( x-0.2, y, -5.52), 'color': color, 'opacity':1,'draw_beauty':True,'additive':False,'size':(1.8,0.1,2)}) - + color = (0, 0, 1) + floor = "" + for i in range(0, 4): + floor += "_ " + ba.newnode('region', attrs={'position': (x-0.2, y, -5.52), 'scale': (1.8, 0.1, 6), + 'type': 'box', 'materials': [shared.footing_material, self._goal_post_material]}) - def create_vertical(self,x,y): + ba.newnode('locator', attrs={'shape': 'box', 'position': ( + x-0.2, y, -5.52), 'color': color, 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (1.8, 0.1, 2)}) + + def create_vertical(self, x, y): shared = SharedObjects.get() floor = "" - for i in range(0,4): - floor +="|\n" - ba.newnode('region',attrs={'position': (x, y, -5.52),'scale': (0.1,2.8,1),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - ba.newnode('locator', attrs={'shape':'box', 'position':( x, y, -5.52), 'color':(1,1,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(0.1,2.8,2)}) - + for i in range(0, 4): + floor += "|\n" + ba.newnode('region', attrs={'position': (x, y, -5.52), 'scale': (0.1, 2.8, 1), + 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + ba.newnode('locator', attrs={'shape': 'box', 'position': ( + x, y, -5.52), 'color': (1, 1, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (0.1, 2.8, 2)}) def spawn_player_spaz(self, player: Player, position: Sequence[float] = None, angle: float = None) -> PlayerSpaz: """Intercept new spazzes and add our team material for them.""" - if player.team.id==0: - position=(-10.75152479, 5.057427485, -5.52) - elif player.team.id==1: - position=(8.75152479, 5.057427485, -5.52) - + if player.team.id == 0: + position = (-10.75152479, 5.057427485, -5.52) + elif player.team.id == 1: + position = (8.75152479, 5.057427485, -5.52) spaz = super().spawn_player_spaz(player, position, angle) return spaz @@ -456,7 +468,7 @@ class AirSoccerGame(ba.TeamGameActivity[Player, Team]): # Respawn dead players if they're still in the game. if isinstance(msg, ba.PlayerDiedMessage): - # Augment standard behavior... + # Augment standard behavior... super().handlemessage(msg) self.respawn_player(msg.getplayer(Player)) @@ -527,6 +539,8 @@ class mapdefs: 0.9516389866, 0.6666414677, 0.08607244075) points['spawn_by_flag4'] = (0.4932087091, 12.74493212, -5.598987003) + ( 0.5245740665, 0.5245740665, 0.01941146064) + + class CreativeThoughts(ba.Map): """Freaking map by smoothy.""" @@ -566,10 +580,11 @@ class CreativeThoughts(ba.Map): def __init__(self) -> None: super().__init__(vr_overlay_offset=(0, -3.7, 2.5)) shared = SharedObjects.get() - self._fake_wall_material=ba.Material() - self._real_wall_material=ba.Material() + self._fake_wall_material = ba.Material() + self._real_wall_material = ba.Material() self._fake_wall_material.add_actions( - conditions=(('they_are_younger_than',9000),'and',('they_have_material', shared.player_material)), + conditions=(('they_are_younger_than', 9000), 'and', + ('they_have_material', shared.player_material)), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', True) @@ -591,12 +606,18 @@ class CreativeThoughts(ba.Map): 'color_texture': ba.gettexture("rampageBGColor") }) - self.leftwall=ba.newnode('region',attrs={'position': (-17.75152479, 13, -5.52),'scale': (0.1,15.5,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - self.rightwall=ba.newnode('region',attrs={'position': (17.75, 13, -5.52),'scale': (0.1,15.5,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - self.topwall=ba.newnode('region',attrs={'position': (0, 21.0, -5.52),'scale': (35.4,0.2,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - ba.newnode('locator', attrs={'shape':'box', 'position':(-17.75152479, 13, -5.52), 'color':(0,0,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(0.1,15.5,2)}) - ba.newnode('locator', attrs={'shape':'box', 'position':(17.75, 13, -5.52), 'color':(0,0,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(0.1,15.5,2)}) - ba.newnode('locator', attrs={'shape':'box', 'position':(0, 21.0, -5.52), 'color':(0,0,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(35.4,0.2,2)}) + self.leftwall = ba.newnode('region', attrs={'position': (-17.75152479, 13, -5.52), 'scale': ( + 0.1, 15.5, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + self.rightwall = ba.newnode('region', attrs={'position': (17.75, 13, -5.52), 'scale': ( + 0.1, 15.5, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + self.topwall = ba.newnode('region', attrs={'position': (0, 21.0, -5.52), 'scale': ( + 35.4, 0.2, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + ba.newnode('locator', attrs={'shape': 'box', 'position': (-17.75152479, 13, -5.52), 'color': ( + 0, 0, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (0.1, 15.5, 2)}) + ba.newnode('locator', attrs={'shape': 'box', 'position': (17.75, 13, -5.52), 'color': ( + 0, 0, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (0.1, 15.5, 2)}) + ba.newnode('locator', attrs={'shape': 'box', 'position': (0, 21.0, -5.52), 'color': ( + 0, 0, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (35.4, 0.2, 2)}) gnode = ba.getactivity().globalsnode gnode.happy_thoughts_mode = True @@ -636,4 +657,4 @@ class CreativeThoughts(ba.Map): try: ba._map.register_map(CreativeThoughts) except: - pass \ No newline at end of file + pass diff --git a/plugins/minigames/shimla.py b/plugins/minigames/shimla.py index 6d19656..da96392 100644 --- a/plugins/minigames/shimla.py +++ b/plugins/minigames/shimla.py @@ -20,6 +20,8 @@ if TYPE_CHECKING: from typing import Any, Sequence, Dict, Type, List, Optional, Union # ba_meta export game + + class ShimlaGame(DeathMatchGame): name = 'Shimla' @@ -71,14 +73,16 @@ class ShimlaGame(DeathMatchGame): def on_begin(self): ba.getactivity().globalsnode.happy_thoughts_mode = False super().on_begin() - + self.make_map() ba.timer(2, self.disable_fly) + def disable_fly(self): activity = _ba.get_foreground_host_activity() for players in activity.players: players.actor.node.fly = False + def spawn_player_spaz( self, player: Player, @@ -87,13 +91,13 @@ class ShimlaGame(DeathMatchGame): ) -> PlayerSpaz: """Intercept new spazzes and add our team material for them.""" spaz = super().spawn_player_spaz(player, position, angle) - + spaz.connect_controls_to_player(enable_punch=True, enable_bomb=True, enable_pickup=True, enable_fly=False, enable_jump=True) - spaz.fly = False + spaz.fly = False return spaz def make_map(self): @@ -106,9 +110,9 @@ class ShimlaGame(DeathMatchGame): _ba.get_foreground_host_activity()._map.topwall.materials = [ shared.footing_material, self._real_wall_material] - - self.floorwall1 = ba.newnode('region', attrs={'position': (-10, 5, -5.52), 'scale': - (15, 0.2, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + + self.floorwall1 = ba.newnode('region', attrs={'position': (-10, 5, -5.52), 'scale': + (15, 0.2, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) self.floorwall2 = ba.newnode('region', attrs={'position': (10, 5, -5.52), 'scale': ( 15, 0.2, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) @@ -144,7 +148,7 @@ class ShimlaGame(DeathMatchGame): self.create_static_step(-5, 10) def create_static_step(self, x, y): - + shared = SharedObjects.get() ba.newnode('region', attrs={'position': (x, y, -5.52), 'scale': (5.5, 0.1, 6), @@ -157,7 +161,7 @@ class ShimlaGame(DeathMatchGame): color = (0.7, 0.6, 0.5) floor = ba.newnode('region', attrs={'position': (x, y, -5.52), 'scale': ( - 1.8, 0.1, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material ,self._lift_material]}) + 1.8, 0.1, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material, self._lift_material]}) cleaner = ba.newnode('region', attrs={'position': (x, y, -5.52), 'scale': ( 2, 0.3, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) @@ -181,13 +185,13 @@ class ShimlaGame(DeathMatchGame): _tcombine.connectattr('output', mnode, 'input2') _cleaner_combine = ba.newnode('combine', - owner=cleaner, - attrs={ - 'input1': 5.6, - 'input2': -5.5, - 'size': 3 - }) - _cleaner_combine.connectattr('output', cleaner, 'position') + owner=cleaner, + attrs={ + 'input1': 5.6, + 'input2': -5.5, + 'size': 3 + }) + _cleaner_combine.connectattr('output', cleaner, 'position') ba.animate(_tcombine, 'input1', { 0: 5.1, }) @@ -197,14 +201,16 @@ class ShimlaGame(DeathMatchGame): _tcombine.connectattr('output', floor, 'position') mnode.connectattr('output', lift, 'position') - self.lifts[floor] = {"state":"origin","lift":_tcombine,"cleaner":_cleaner_combine,'leftLift': x < 0} + self.lifts[floor] = {"state": "origin", "lift": _tcombine, + "cleaner": _cleaner_combine, 'leftLift': x < 0} def _handle_lift(self): region = ba.getcollision().sourcenode lift = self.lifts[region] + def clean(lift): ba.animate(lift["cleaner"], 'input0', { - 0: -19 if lift["leftLift"] else 19 , + 0: -19 if lift["leftLift"] else 19, 2: -16 if lift["leftLift"] else 16, 4.3: -19 if lift["leftLift"] else 19 }) @@ -220,7 +226,6 @@ class ShimlaGame(DeathMatchGame): ba.timer(16, ba.Call(lambda lift: lift.update({'state': 'end'}), lift)) ba.timer(12, ba.Call(clean, lift)) - def _handle_lift_disconnect(self): region = ba.getcollision().sourcenode lift = self.lifts[region] @@ -242,6 +247,7 @@ class ShimlaGame(DeathMatchGame): x = x-0.1 y = y+0.1 + class mapdefs: points = {} # noinspection PyDictCreation @@ -284,6 +290,8 @@ class mapdefs: 0.9516389866, 0.6666414677, 0.08607244075) points['spawn_by_flag4'] = (0.4932087091, 12.74493212, -5.598987003) + ( 0.5245740665, 0.5245740665, 0.01941146064) + + class CreativeThoughts(ba.Map): """Freaking map by smoothy.""" @@ -323,10 +331,11 @@ class CreativeThoughts(ba.Map): def __init__(self) -> None: super().__init__(vr_overlay_offset=(0, -3.7, 2.5)) shared = SharedObjects.get() - self._fake_wall_material=ba.Material() - self._real_wall_material=ba.Material() + self._fake_wall_material = ba.Material() + self._real_wall_material = ba.Material() self._fake_wall_material.add_actions( - conditions=(('they_are_younger_than',9000),'and',('they_have_material', shared.player_material)), + conditions=(('they_are_younger_than', 9000), 'and', + ('they_have_material', shared.player_material)), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', True) @@ -348,12 +357,18 @@ class CreativeThoughts(ba.Map): 'color_texture': ba.gettexture("rampageBGColor") }) - self.leftwall=ba.newnode('region',attrs={'position': (-17.75152479, 13, -5.52),'scale': (0.1,15.5,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - self.rightwall=ba.newnode('region',attrs={'position': (17.75, 13, -5.52),'scale': (0.1,15.5,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - self.topwall=ba.newnode('region',attrs={'position': (0, 21.0, -5.52),'scale': (35.4,0.2,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]}) - ba.newnode('locator', attrs={'shape':'box', 'position':(-17.75152479, 13, -5.52), 'color':(0,0,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(0.1,15.5,2)}) - ba.newnode('locator', attrs={'shape':'box', 'position':(17.75, 13, -5.52), 'color':(0,0,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(0.1,15.5,2)}) - ba.newnode('locator', attrs={'shape':'box', 'position':(0, 21.0, -5.52), 'color':(0,0,0), 'opacity':1,'draw_beauty':True,'additive':False,'size':(35.4,0.2,2)}) + self.leftwall = ba.newnode('region', attrs={'position': (-17.75152479, 13, -5.52), 'scale': ( + 0.1, 15.5, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + self.rightwall = ba.newnode('region', attrs={'position': (17.75, 13, -5.52), 'scale': ( + 0.1, 15.5, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + self.topwall = ba.newnode('region', attrs={'position': (0, 21.0, -5.52), 'scale': ( + 35.4, 0.2, 2), 'type': 'box', 'materials': [shared.footing_material, self._real_wall_material]}) + ba.newnode('locator', attrs={'shape': 'box', 'position': (-17.75152479, 13, -5.52), 'color': ( + 0, 0, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (0.1, 15.5, 2)}) + ba.newnode('locator', attrs={'shape': 'box', 'position': (17.75, 13, -5.52), 'color': ( + 0, 0, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (0.1, 15.5, 2)}) + ba.newnode('locator', attrs={'shape': 'box', 'position': (0, 21.0, -5.52), 'color': ( + 0, 0, 0), 'opacity': 1, 'draw_beauty': True, 'additive': False, 'size': (35.4, 0.2, 2)}) gnode = ba.getactivity().globalsnode gnode.happy_thoughts_mode = True @@ -393,4 +408,4 @@ class CreativeThoughts(ba.Map): try: ba._map.register_map(CreativeThoughts) except: - pass \ No newline at end of file + pass