def __init__(self, settings: dict): super().__init__(settings) shared = SharedObjects.get() self._scoreboard = Scoreboard() self._cheer_sound = ba.getsound('cheer') self._chant_sound = ba.getsound('crowdChant') self._foghorn_sound = ba.getsound('foghorn') self._swipsound = ba.getsound('swip') self._whistle_sound = ba.getsound('refWhistle') self.puck_model = ba.getmodel('puck') self.puck_tex = ba.gettexture('puckColor') self._puck_sound = ba.getsound('metalHit') self.puck_material = ba.Material() self.puck_material.add_actions(actions=(('modify_part_collision', 'friction', 0.5))) self.puck_material.add_actions(conditions=('they_have_material', shared.pickup_material), actions=('modify_part_collision', 'collide', False)) self.puck_material.add_actions( conditions=( ('we_are_younger_than', 100), 'and', ('they_have_material', shared.object_material), ), actions=('modify_node_collision', 'collide', False), ) self.puck_material.add_actions(conditions=('they_have_material', shared.footing_material), actions=('impact_sound', self._puck_sound, 0.2, 5)) # Keep track of which player last touched the puck self.puck_material.add_actions( conditions=('they_have_material', shared.player_material), actions=(('call', 'at_connect', self._handle_puck_player_collide), )) # We want the puck to kill powerups; not get stopped by them self.puck_material.add_actions( conditions=('they_have_material', PowerupBoxFactory.get().powerup_material), actions=(('modify_part_collision', 'physical', False), ('message', 'their_node', 'at_connect', ba.DieMessage()))) self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=('they_have_material', self.puck_material), actions=(('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._handle_score))) self._puck_spawn_pos: Optional[Sequence[float]] = None self._score_regions: Optional[List[ba.NodeActor]] = None self._puck: Optional[Puck] = None self._score_to_win = int(settings['Score to Win']) self._time_limit = float(settings['Time Limit'])
def __init__(self) -> None: """Instantiate a PowerupBoxFactory. You shouldn't need to do this; call ba.Powerup.get_factory() to get a shared instance. """ from ba.internal import get_default_powerup_distribution shared = SharedObjects.get() self._lastpoweruptype: Optional[str] = None self.model = ba.getmodel('powerup') self.model_simple = ba.getmodel('powerupSimple') self.tex_bomb = ba.gettexture('powerupBomb') self.tex_punch = ba.gettexture('powerupPunch') self.tex_ice_bombs = ba.gettexture('powerupIceBombs') self.tex_sticky_bombs = ba.gettexture('powerupStickyBombs') self.tex_shield = ba.gettexture('powerupShield') self.tex_impact_bombs = ba.gettexture('powerupImpactBombs') self.tex_health = ba.gettexture('powerupHealth') self.tex_land_mines = ba.gettexture('powerupLandMines') self.tex_curse = ba.gettexture('powerupCurse') self.health_powerup_sound = ba.getsound('healthPowerup') self.powerup_sound = ba.getsound('powerup01') self.powerdown_sound = ba.getsound('powerdown01') self.drop_sound = ba.getsound('boxDrop') # Material for powerups. self.powerup_material = ba.Material() # Material for anyone wanting to accept powerups. self.powerup_accept_material = ba.Material() # Pass a powerup-touched message to applicable stuff. self.powerup_material.add_actions( conditions=('they_have_material', self.powerup_accept_material), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('message', 'our_node', 'at_connect', _TouchedMessage()), )) # We don't wanna be picked up. self.powerup_material.add_actions( conditions=('they_have_material', shared.pickup_material), actions=('modify_part_collision', 'collide', False), ) self.powerup_material.add_actions( conditions=('they_have_material', shared.footing_material), actions=('impact_sound', self.drop_sound, 0.5, 0.1), ) self._powerupdist: List[str] = [] for powerup, freq in get_default_powerup_distribution(): for _i in range(int(freq)): self._powerupdist.append(powerup)
def __init__(self) -> None: """Instantiate a PowerupBoxFactory. You shouldn't need to do this; call ba.Powerup.get_factory() to get a shared instance. """ from ba.internal import get_default_powerup_distribution self._lastpoweruptype: Optional[str] = None self.model = ba.getmodel("powerup") self.model_simple = ba.getmodel("powerupSimple") self.tex_bomb = ba.gettexture("powerupBomb") self.tex_punch = ba.gettexture("powerupPunch") self.tex_ice_bombs = ba.gettexture("powerupIceBombs") self.tex_sticky_bombs = ba.gettexture("powerupStickyBombs") self.tex_shield = ba.gettexture("powerupShield") self.tex_impact_bombs = ba.gettexture("powerupImpactBombs") self.tex_health = ba.gettexture("powerupHealth") self.tex_land_mines = ba.gettexture("powerupLandMines") self.tex_curse = ba.gettexture("powerupCurse") self.health_powerup_sound = ba.getsound("healthPowerup") self.powerup_sound = ba.getsound("powerup01") self.powerdown_sound = ba.getsound("powerdown01") self.drop_sound = ba.getsound("boxDrop") # Material for powerups. self.powerup_material = ba.Material() # Material for anyone wanting to accept powerups. self.powerup_accept_material = ba.Material() # Pass a powerup-touched message to applicable stuff. self.powerup_material.add_actions( conditions=("they_have_material", self.powerup_accept_material), actions=(("modify_part_collision", "collide", True), ("modify_part_collision", "physical", False), ("message", "our_node", "at_connect", _TouchedMessage()))) # We don't wanna be picked up. self.powerup_material.add_actions( conditions=("they_have_material", ba.sharedobj('pickup_material')), actions=("modify_part_collision", "collide", False)) self.powerup_material.add_actions( conditions=("they_have_material", ba.sharedobj('footing_material')), actions=("impact_sound", self.drop_sound, 0.5, 0.1)) self._powerupdist: List[str] = [] for powerup, freq in get_default_powerup_distribution(): for _i in range(int(freq)): self._powerupdist.append(powerup)
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard from bastd.actor import powerupbox super().__init__(settings) self._scoreboard = Scoreboard() self._cheer_sound = ba.getsound("cheer") self._chant_sound = ba.getsound("crowdChant") self._foghorn_sound = ba.getsound("foghorn") self._swipsound = ba.getsound("swip") self._whistle_sound = ba.getsound("refWhistle") self.puck_model = ba.getmodel("puck") self.puck_tex = ba.gettexture("puckColor") self._puck_sound = ba.getsound("metalHit") self.puck_material = ba.Material() self.puck_material.add_actions(actions=(("modify_part_collision", "friction", 0.5))) self.puck_material.add_actions( conditions=("they_have_material", ba.sharedobj('pickup_material')), actions=("modify_part_collision", "collide", False)) self.puck_material.add_actions( conditions=(("we_are_younger_than", 100), 'and', ("they_have_material", ba.sharedobj('object_material'))), actions=("modify_node_collision", "collide", False)) self.puck_material.add_actions( conditions=("they_have_material", ba.sharedobj('footing_material')), actions=("impact_sound", self._puck_sound, 0.2, 5)) # Keep track of which player last touched the puck self.puck_material.add_actions( conditions=("they_have_material", ba.sharedobj('player_material')), actions=(("call", "at_connect", self._handle_puck_player_collide), )) # We want the puck to kill powerups; not get stopped by them self.puck_material.add_actions( conditions=("they_have_material", powerupbox.get_factory().powerup_material), actions=(("modify_part_collision", "physical", False), ("message", "their_node", "at_connect", ba.DieMessage()))) self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=("they_have_material", self.puck_material), actions=(("modify_part_collision", "collide", True), ("modify_part_collision", "physical", False), ("call", "at_connect", self._handle_score))) self._puck_spawn_pos: Optional[Sequence[float]] = None self._score_regions: Optional[List[ba.NodeActor]] = None self._puck: Optional[Puck] = None
def __init__(self, settings: dict): super().__init__(settings) self._scoreboard: Optional[Scoreboard] = Scoreboard() # Load some media we need. self._cheer_sound = ba.getsound('cheer') self._chant_sound = ba.getsound('crowdChant') self._score_sound = ba.getsound('score') self._swipsound = ba.getsound('swip') self._whistle_sound = ba.getsound('refWhistle') self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=('they_have_material', FlagFactory.get().flagmaterial), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._handle_score), )) self._flag_spawn_pos: Optional[Sequence[float]] = None self._score_regions: List[ba.NodeActor] = [] self._flag: Optional[FootballFlag] = None self._flag_respawn_timer: Optional[ba.Timer] = None self._flag_respawn_light: Optional[ba.NodeActor] = None self._score_to_win = int(settings['Score to Win']) self._time_limit = float(settings['Time Limit'])
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard super().__init__(settings) self._scoreboard = Scoreboard() self._swipsound = ba.getsound('swip') self._tick_sound = ba.getsound('tick') self._countdownsounds = { 10: ba.getsound('announceTen'), 9: ba.getsound('announceNine'), 8: ba.getsound('announceEight'), 7: ba.getsound('announceSeven'), 6: ba.getsound('announceSix'), 5: ba.getsound('announceFive'), 4: ba.getsound('announceFour'), 3: ba.getsound('announceThree'), 2: ba.getsound('announceTwo'), 1: ba.getsound('announceOne') } self._flag_pos: Optional[Sequence[float]] = None self._flag_state: Optional[int] = None self._flag: Optional[stdflag.Flag] = None self._flag_light: Optional[ba.Node] = None self._scoring_team: Optional[ReferenceType[ba.Team]] = None self._flag_region_material = ba.Material() self._flag_region_material.add_actions( conditions=('they_have_material', ba.sharedobj('player_material')), actions=(('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', ba.Call(self._handle_player_flag_region_collide, True)), ('call', 'at_disconnect', ba.Call(self._handle_player_flag_region_collide, False))))
def on_begin(self) -> None: super().on_begin() shared = SharedObjects.get() self.setup_standard_time_limit(self._time_limit) self.setup_standard_powerup_drops() self._flag_spawn_pos = self.map.get_flag_position(None) Flag.project_stand(self._flag_spawn_pos) self._set_chosen_one_player(None) pos = self._flag_spawn_pos ba.timer(1.0, call=self._tick, repeat=True) mat = self._reset_region_material = ba.Material() mat.add_actions( conditions=( 'they_have_material', shared.player_material, ), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', ba.WeakCall(self._handle_reset_collide)), ), ) self._reset_region = ba.newnode('region', attrs={ 'position': (pos[0], pos[1] + 0.75, pos[2]), 'scale': (0.5, 0.5, 0.5), 'type': 'sphere', 'materials': [mat] })
def __init__(self, item: ba.Node, owner: ba.Node): self.item = item self.owner = owner self.node: ba.Node self.target: Optional[ba.Node] = None self.aim_zone: ba.Material = ba.Material() shared = SharedObjects.get() self.aim_zone.add_actions( conditions=(('they_have_material', shared.player_material)), actions=(('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._touch_handler))) # raise the item a little self.item.extra_acceleration = (0, 20, 0) # if the item exists, then take its position, # else "turn the bench" if self.item.exists(): position = self.item.position else: return self.node = ba.newnode('region', attrs={ 'type': 'sphere', 'position': position, 'materials': [self.aim_zone]}) # aiming effect ba.animate_array(self.node, 'scale', 3, {0: (0.1, 0.1, 0.1), 1: (60, 60, 60)})
def __init__(self, m, random_col): super().__init__() shared = SharedObjects.get() if random_col: col = (random.uniform(0, 1.2), random.uniform(0, 1.2), random.uniform(0, 1.2)) else: col = (0.9, 0.7, 0.0) self.mat = ba.Material() self.mat.add_actions(actions=( ('modify_part_collision', 'collide', False), ('modify_part_collision', 'physical', False), )) self.node = ba.newnode('prop', delegate=self, attrs={ 'model': ba.getmodel('bomb'), 'position': (2, 4, 2), 'body': 'capsule', 'shadow_size': 0.0, 'color_texture': ba.gettexture('coin'), 'reflection': 'soft', 'reflection_scale': [1.5], 'materials': [shared.object_material, self.mat] }) ba.animate(self.node, 'model_scale', { 0: 0, 1: 0.19, 5: 0.10, 10: 0.0 }, loop=True) ba.animate_array(self.node, 'position', 3, self.generateKeys(m), loop=True) self.light = ba.newnode('light', owner=self.node, attrs={ 'intensity': 0.6, 'height_attenuated': True, 'radius': 0.2, 'color': col }) ba.animate(self.light, 'radius', { 0: 0.0, 20: 0.4, 70: 0.1, 100: 0.3, 150: 0 }, loop=True) self.node.connectattr('position', self.light, 'position')
def __init__(self, settings: dict): settings['map'] = 'Tower D' super().__init__(settings) shared = SharedObjects.get() self._preset = Preset(settings.get('preset', 'pro')) self._player_death_sound = ba.getsound('playerDeath') self._new_wave_sound = ba.getsound('scoreHit01') self._winsound = ba.getsound('score') self._cashregistersound = ba.getsound('cashRegister') self._bad_guy_score_sound = ba.getsound('shieldDown') self._heart_tex = ba.gettexture('heart') self._heart_model_opaque = ba.getmodel('heartOpaque') self._heart_model_transparent = ba.getmodel('heartTransparent') self._a_player_has_been_killed = False self._spawn_center = self._map_type.defs.points['spawn1'][0:3] self._tntspawnpos = self._map_type.defs.points['tnt_loc'][0:3] self._powerup_center = self._map_type.defs.boxes['powerup_region'][0:3] self._powerup_spread = ( self._map_type.defs.boxes['powerup_region'][6] * 0.5, self._map_type.defs.boxes['powerup_region'][8] * 0.5) self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=('they_have_material', shared.player_material), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._handle_reached_end), )) self._last_wave_end_time = ba.time() self._player_has_picked_up_powerup = False self._scoreboard: Optional[Scoreboard] = None self._game_over = False self._wavenum = 0 self._can_end_wave = True self._score = 0 self._time_bonus = 0 self._score_region: Optional[ba.Actor] = None self._dingsound = ba.getsound('dingSmall') self._dingsoundhigh = ba.getsound('dingSmallHigh') self._exclude_powerups: Optional[List[str]] = None self._have_tnt: Optional[bool] = None self._waves: Optional[List[Wave]] = None self._bots = SpazBotSet() self._tntspawner: Optional[TNTSpawner] = None self._lives_bg: Optional[ba.NodeActor] = None self._start_lives = 10 self._lives = self._start_lives self._lives_text: Optional[ba.NodeActor] = None self._flawless = True self._time_bonus_timer: Optional[ba.Timer] = None self._time_bonus_text: Optional[ba.NodeActor] = None self._time_bonus_mult: Optional[float] = None self._wave_text: Optional[ba.NodeActor] = None self._flawless_bonus: Optional[int] = None self._wave_update_timer: Optional[ba.Timer] = None
def region_material(self) -> ba.Material: """A ba.Material used for non-physical collision shapes (regions); collisions can generally be allowed with this material even when initially overlapping since it is not physical. """ if self._region_material is None: self._region_material = ba.Material() return self._region_material
def __init__(self) -> None: """Instantiate a FlagFactory. You shouldn't need to do this; call bastd.actor.flag.get_factory() to get a shared instance. """ self.flagmaterial = ba.Material() self.flagmaterial.add_actions( conditions=(('we_are_younger_than', 100), 'and', ('they_have_material', ba.sharedobj('object_material'))), actions=('modify_node_collision', 'collide', False)) self.flagmaterial.add_actions( conditions=('they_have_material', ba.sharedobj('footing_material')), actions=(('message', 'our_node', 'at_connect', 'footing', 1), ('message', 'our_node', 'at_disconnect', 'footing', -1))) self.impact_sound = ba.getsound('metalHit') self.skid_sound = ba.getsound('metalSkid') self.flagmaterial.add_actions( conditions=('they_have_material', ba.sharedobj('footing_material')), actions=(('impact_sound', self.impact_sound, 2, 5), ('skid_sound', self.skid_sound, 2, 5))) self.no_hit_material = ba.Material() self.no_hit_material.add_actions( conditions=(('they_have_material', ba.sharedobj('pickup_material')), 'or', ('they_have_material', ba.sharedobj('attack_material'))), actions=('modify_part_collision', 'collide', False)) # We also don't want anything moving it. self.no_hit_material.add_actions( conditions=(('they_have_material', ba.sharedobj('object_material')), 'or', ('they_dont_have_material', ba.sharedobj('footing_material'))), actions=(('modify_part_collision', 'collide', False), ('modify_part_collision', 'physical', False))) self.flag_texture = ba.gettexture('flagColor')
def attack_material(self) -> ba.Material: """A ba.Material applied to explosion shapes, punch shapes, etc. An object not wanting to receive impulse/etc messages can disable collisions against this material. """ if self._attack_material is None: self._attack_material = ba.Material() return self._attack_material
def player_material(self) -> ba.Material: """a ba.Material to be applied to player parts. Generally, materials related to the process of scoring when reaching a goal, etc will look for the presence of this material on things that hit them. """ if self._player_material is None: self._player_material = ba.Material() return self._player_material
def footing_material(self) -> ba.Material: """Anything that can be 'walked on' should have this ba.Material applied; generally just terrain and whatnot. A character will snap upright whenever touching something with this material so it should not be applied to props, etc. """ if self._footing_material is None: self._footing_material = ba.Material() return self._footing_material
def pickup_material(self) -> ba.Material: """A ba.Material; collision shapes used for picking things up will have this material applied. To prevent an object from being picked up, you can add a material that disables collisions against things containing this material. """ if self._pickup_material is None: self._pickup_material = ba.Material() return self._pickup_material
def death_material(self) -> ba.Material: """A ba.Material that sends a ba.DieMessage() to anything that touches it; handy for terrain below a cliff, etc. """ if self._death_material is None: mat = self._death_material = ba.Material() mat.add_actions( ('message', 'their_node', 'at_connect', ba.DieMessage())) return self._death_material
def object_material(self) -> ba.Material: """A ba.Material that should be applied to any small, normal, physical objects such as bombs, boxes, players, etc. Other materials often check for the presence of this material as a prerequisite for performing certain actions (such as disabling collisions between initially-overlapping objects) """ if self._object_material is None: self._object_material = ba.Material() return self._object_material
def on_transition_in(self) -> None: super().on_transition_in() pts = self.map.get_def_points('race_point') mat = self.race_region_material = ba.Material() mat.add_actions(conditions=('they_have_material', ba.sharedobj('player_material')), actions=(('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._handle_race_point_collide))) for rpt in pts: self._regions.append(RaceRegion(rpt, len(self._regions)))
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard super().__init__(settings) self._scoreboard = Scoreboard() if self.settings_raw['Epic Mode']: self.slow_motion = True self._alarmsound = ba.getsound('alarm') self._ticking_sound = ba.getsound('ticking') self._last_score_time = 0 self._score_sound = ba.getsound('score') self._swipsound = ba.getsound('swip') self._all_bases_material = ba.Material() self._last_home_flag_notice_print_time = 0.0
def __init__(self): bomb_factory = stdbomb.BombFactory.get() shared = SharedObjects.get() self.sticky_gift_material = ba.Material() self.sticky_gift_material.add_actions( conditions=(('we_are_older_than', 200), 'and', ('they_are_older_than', 200), 'and', ('eval_colliding', ), 'and', (('they_dont_have_material', bomb_factory.land_mine_no_explode_material), 'and', (('they_have_material', shared.object_material), 'or', ('they_have_material', shared.player_material)))), actions=(('message', 'our_node', 'at_connect', SetStickyMessage()))) self.sticky_gift_texture = ba.gettexture('bg') self.sticky_gift_model = bomb_factory.sticky_bomb_model
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard super().__init__(settings) if self.settings_raw['Epic Mode']: self.slow_motion = True self._scoreboard = Scoreboard() self._score_sound = ba.getsound('score') self._swipsound = ba.getsound('swip') self._extraflagmat = ba.Material() self._flags: List[ConquestFlag] = [] # We want flags to tell us they've been hit but not react physically. self._extraflagmat.add_actions( conditions=('they_have_material', ba.sharedobj('player_material')), actions=(('modify_part_collision', 'collide', True), ('call', 'at_connect', self._handle_flag_player_collide)))
def on_begin(self) -> None: from bastd.actor.flag import Flag super().on_begin() self.setup_standard_time_limit(self.settings_raw['Time Limit']) self.setup_standard_powerup_drops() for team in self.teams: mat = self._base_region_materials[team.get_id()] = ba.Material() mat.add_actions(conditions=('they_have_material', ba.sharedobj('player_material')), actions=(('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', ba.Call(self._handle_base_collide, team)))) # Create a score region and flag for each team. for team in self.teams: team.gamedata['base_pos'] = self.map.get_flag_position( team.get_id()) ba.newnode('light', attrs={ 'position': team.gamedata['base_pos'], 'intensity': 0.6, 'height_attenuated': False, 'volume_intensity_scale': 0.1, 'radius': 0.1, 'color': team.color }) self.project_flag_stand(team.gamedata['base_pos']) team.gamedata['flag'] = Flag(touchable=False, position=team.gamedata['base_pos'], color=team.color) basepos = team.gamedata['base_pos'] ba.newnode('region', owner=team.gamedata['flag'].node, attrs={ 'position': (basepos[0], basepos[1] + 0.75, basepos[2]), 'scale': (0.5, 0.5, 0.5), 'type': 'sphere', 'materials': [self._base_region_materials[team.get_id()]] })
def __init__(self, settings: dict): settings['map'] = 'Football Stadium' super().__init__(settings) self._preset = settings.get('preset', 'rookie') # Load some media we need. self._cheer_sound = ba.getsound('cheer') self._boo_sound = ba.getsound('boo') self._chant_sound = ba.getsound('crowdChant') self._score_sound = ba.getsound('score') self._swipsound = ba.getsound('swip') self._whistle_sound = ba.getsound('refWhistle') self._score_to_win = 21 self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=('they_have_material', FlagFactory.get().flagmaterial), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._handle_score), )) self._powerup_center = (0, 2, 0) self._powerup_spread = (10, 5.5) self._player_has_dropped_bomb = False self._player_has_punched = False self._scoreboard: Optional[Scoreboard] = None self._flag_spawn_pos: Optional[Sequence[float]] = None self._score_regions: List[ba.NodeActor] = [] self._exclude_powerups: List[str] = [] self._have_tnt = False self._bot_types_initial: Optional[List[Type[SpazBot]]] = None self._bot_types_7: Optional[List[Type[SpazBot]]] = None self._bot_types_14: Optional[List[Type[SpazBot]]] = None self._bot_team: Optional[Team] = None self._starttime_ms: Optional[int] = None self._time_text: Optional[ba.NodeActor] = None self._time_text_input: Optional[ba.NodeActor] = None self._tntspawner: Optional[TNTSpawner] = None self._bots = SpazBotSet() self._bot_spawn_timer: Optional[ba.Timer] = None self._powerup_drop_timer: Optional[ba.Timer] = None self._scoring_team: Optional[Team] = None self._final_time_ms: Optional[int] = None self._time_text_timer: Optional[ba.Timer] = None self._flag_respawn_light: Optional[ba.Actor] = None self._flag: Optional[FootballFlag] = None
def __init__(self, settings: Dict[str, Any]): settings['map'] = 'Football Stadium' super().__init__(settings) self._preset = self.settings.get('preset', 'rookie') # Load some media we need. self._cheer_sound = ba.getsound("cheer") self._boo_sound = ba.getsound("boo") self._chant_sound = ba.getsound("crowdChant") self._score_sound = ba.getsound("score") self._swipsound = ba.getsound("swip") self._whistle_sound = ba.getsound("refWhistle") self._score_to_win = 21 self._score_region_material = ba.Material() self._score_region_material.add_actions( conditions=("they_have_material", stdflag.get_factory().flagmaterial), actions=(("modify_part_collision", "collide", True), ("modify_part_collision", "physical", False), ("call", "at_connect", self._handle_score))) self._powerup_center = (0, 2, 0) self._powerup_spread = (10, 5.5) self._player_has_dropped_bomb = False self._player_has_punched = False self._scoreboard: Optional[Scoreboard] = None self._flag_spawn_pos: Optional[Sequence[float]] = None self.score_regions: List[ba.NodeActor] = [] self._exclude_powerups: List[str] = [] self._have_tnt = False self._bot_types_initial: Optional[List[Type[spazbot.SpazBot]]] = None self._bot_types_7: Optional[List[Type[spazbot.SpazBot]]] = None self._bot_types_14: Optional[List[Type[spazbot.SpazBot]]] = None self._bot_team: Optional[ba.Team] = None self._starttime_ms: Optional[int] = None self._time_text: Optional[ba.NodeActor] = None self._time_text_input: Optional[ba.NodeActor] = None self._tntspawner: Optional[stdbomb.TNTSpawner] = None self._bots = spazbot.BotSet() self._bot_spawn_timer: Optional[ba.Timer] = None self._powerup_drop_timer: Optional[ba.Timer] = None self.scoring_team: Optional[ba.Team] = None self._final_time_ms: Optional[int] = None self._time_text_timer: Optional[ba.Timer] = None self._flag_respawn_light: Optional[ba.Actor] = None self._flag: Optional[FootballFlag] = None
def railing_material(self) -> ba.Material: """A ba.Material with a very low friction/stiffness/etc that can be applied to invisible 'railings' useful for gently keeping characters from falling off of cliffs. """ if self._railing_material is None: mat = self._railing_material = ba.Material() mat.add_actions(('modify_part_collision', 'collide', False)) mat.add_actions(('modify_part_collision', 'stiffness', 0.003)) mat.add_actions(('modify_part_collision', 'damping', 0.00001)) mat.add_actions( conditions=('they_have_material', self.player_material), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'friction', 0.0), ), ) return self._railing_material
def __init__(self, position: Sequence[float] = (0, 1, 0), lifetime: float = 0.5, highlight: bool = True): super().__init__() # array of nodes that received health kit self.cured_nodes: List[ba.Node] = [] self.area_material: ba.Material = ba.Material() shared = SharedObjects.get() self.area_material.add_actions( conditions=(('they_have_material', shared.player_material)), actions=(('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', self._touch_handler))) # the area itself... self.node: ba.Node = ba.newnode('region', attrs={ 'type': 'sphere', 'scale': (2, 2, 2), 'position': position, 'materials': [self.area_material] }) ba.timer(lifetime, self.node.delete) # highlight the treatment area if highlight: self.area_highlight: ba.Node = ba.newnode( 'light', attrs={ 'color': (1, 1, 1), 'radius': 0.25, 'position': position, 'volume_intensity_scale': 1.0 }) # a little beautiful animation ba.animate(self.area_highlight, 'intensity', { 0: 0, lifetime / 2: 1.0, lifetime: 0 })
def __init__(self): self.bonesTex = ba.gettexture("powerupCurse") self.bonesModel = ba.getmodel("bonesHead") self.bearTex = ba.gettexture("bearColor") self.bearModel = ba.getmodel("bearHead") self.aliTex = ba.gettexture("aliColor") self.aliModel = ba.getmodel("aliHead") self.b9000Tex = ba.gettexture("cyborgColor") self.b9000Model = ba.getmodel("cyborgHead") self.frostyTex = ba.gettexture("frostyColor") self.frostyModel = ba.getmodel("frostyHead") self.cubeTex = ba.gettexture("crossOutMask") self.cubeModel = ba.getmodel("powerup") try: self.mikuModel = ba.getmodel("operaSingerHead") self.mikuTex = ba.gettexture("operaSingerColor") except:ba.print_exception() self.ballMaterial = ba.Material() self.impactSound = ba.getsound("impactMedium") self.ballMaterial.add_actions(actions=("modify_node_collision", "collide", False))
def __init__(self, settings: Dict[str, Any]): from bastd.actor.scoreboard import Scoreboard super().__init__(settings) self._last_player_death_time = None self._scoreboard = Scoreboard() self.egg_model = ba.getmodel('egg') self.egg_tex_1 = ba.gettexture('eggTex1') self.egg_tex_2 = ba.gettexture('eggTex2') self.egg_tex_3 = ba.gettexture('eggTex3') self._collect_sound = ba.getsound('powerup01') self._pro_mode = settings.get('Pro Mode', False) self._max_eggs = 1.0 self.egg_material = ba.Material() self.egg_material.add_actions( conditions=("they_have_material", ba.sharedobj('player_material')), actions=(("call", "at_connect", self._on_egg_player_collide), )) self._eggs: List[Egg] = [] self._update_timer: Optional[ba.Timer] = None self._countdown: Optional[OnScreenCountdown] = None self._bots: Optional[spazbot.BotSet] = None
def create_team(self, sessionteam: ba.SessionTeam) -> Team: shared = SharedObjects.get() base_pos = self.map.get_flag_position(sessionteam.id) ba.newnode('light', attrs={ 'position': base_pos, 'intensity': 0.6, 'height_attenuated': False, 'volume_intensity_scale': 0.1, 'radius': 0.1, 'color': sessionteam.color }) Flag.project_stand(base_pos) flag = Flag(touchable=False, position=base_pos, color=sessionteam.color) team = Team(base_pos=base_pos, flag=flag) mat = self._base_region_materials[sessionteam.id] = ba.Material() mat.add_actions( conditions=('they_have_material', shared.player_material), actions=( ('modify_part_collision', 'collide', True), ('modify_part_collision', 'physical', False), ('call', 'at_connect', ba.Call(self._handle_base_collide, team)), ), ) ba.newnode('region', owner=flag.node, attrs={ 'position': (base_pos[0], base_pos[1] + 0.75, base_pos[2]), 'scale': (0.5, 0.5, 0.5), 'type': 'sphere', 'materials': [self._base_region_materials[sessionteam.id]] }) return team