mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2026-08-15 13:03:08 +00:00
commit
654d99c555
3 changed files with 689 additions and 59 deletions
|
|
@ -328,6 +328,12 @@
|
|||
}
|
||||
],
|
||||
"versions": {
|
||||
"2.0.0": {
|
||||
"api_version": 8,
|
||||
"commit_sha": "f54c993",
|
||||
"released_on": "27-07-2023",
|
||||
"md5sum": "7699483f4c379db809676ac917943d3c"
|
||||
},
|
||||
"1.0.0": {
|
||||
"api_version": 7,
|
||||
"commit_sha": "2aa1e50",
|
||||
|
|
@ -698,6 +704,25 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"super_duel": {
|
||||
"description": "Crush your enemy in a 1v1",
|
||||
"external_url": "https://www.youtube.com/watch?v=hvRtiXR-oC0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "JoseAng3l",
|
||||
"email": "",
|
||||
"discord": "joseang3l"
|
||||
}
|
||||
],
|
||||
"versions": {
|
||||
"1.0.0": {
|
||||
"api_version": 8,
|
||||
"commit_sha": "ab26786",
|
||||
"released_on": "27-07-2023",
|
||||
"md5sum": "d0c9c0472d7b145eadf535957a462fdf"
|
||||
}
|
||||
}
|
||||
},
|
||||
"supersmash": {
|
||||
"description": "Blow up your enemies off the map!",
|
||||
"external_url": "",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
# ba_meta require api 7
|
||||
# ba_meta require api 8
|
||||
"""
|
||||
DemolitionWar - BombFight on wooden floor flying in air.
|
||||
Author: Mr.Smoothy
|
||||
|
|
@ -12,23 +12,26 @@ from __future__ import annotations
|
|||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import ba
|
||||
from bastd.game.elimination import EliminationGame, Player
|
||||
from bastd.gameutils import SharedObjects
|
||||
from bastd.actor.bomb import BombFactory
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
from bascenev1 import _map
|
||||
from bascenev1lib.game.elimination import EliminationGame, Player
|
||||
from bascenev1lib.gameutils import SharedObjects
|
||||
from bascenev1lib.actor.bomb import BombFactory
|
||||
import random
|
||||
from bastd.actor.playerspaz import PlayerSpaz
|
||||
from bascenev1lib.actor.playerspaz import PlayerSpaz
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Sequence
|
||||
|
||||
# ba_meta export game
|
||||
# ba_meta export bascenev1.GameActivity
|
||||
|
||||
|
||||
class DemolitionWar(EliminationGame):
|
||||
name = 'DemolitionWar'
|
||||
description = 'Last remaining alive wins.'
|
||||
scoreconfig = ba.ScoreConfig(
|
||||
label='Survived', scoretype=ba.ScoreType.SECONDS, none_is_winner=True
|
||||
scoreconfig = bs.ScoreConfig(
|
||||
label='Survived', scoretype=bs.ScoreType.SECONDS, none_is_winner=True
|
||||
)
|
||||
# Show messages when players die since it's meaningful here.
|
||||
announce_player_deaths = True
|
||||
|
|
@ -37,17 +40,17 @@ class DemolitionWar(EliminationGame):
|
|||
|
||||
@classmethod
|
||||
def get_available_settings(
|
||||
cls, sessiontype: type[ba.Session]
|
||||
) -> list[ba.Setting]:
|
||||
cls, sessiontype: type[bs.Session]
|
||||
) -> list[babase.Setting]:
|
||||
settings = [
|
||||
ba.IntSetting(
|
||||
bs.IntSetting(
|
||||
'Lives Per Player',
|
||||
default=1,
|
||||
min_value=1,
|
||||
max_value=10,
|
||||
increment=1,
|
||||
),
|
||||
ba.IntChoiceSetting(
|
||||
bs.IntChoiceSetting(
|
||||
'Time Limit',
|
||||
choices=[
|
||||
('None', 0),
|
||||
|
|
@ -59,7 +62,7 @@ class DemolitionWar(EliminationGame):
|
|||
],
|
||||
default=0,
|
||||
),
|
||||
ba.FloatChoiceSetting(
|
||||
bs.FloatChoiceSetting(
|
||||
'Respawn Times',
|
||||
choices=[
|
||||
('Shorter', 0.25),
|
||||
|
|
@ -70,23 +73,23 @@ class DemolitionWar(EliminationGame):
|
|||
],
|
||||
default=1.0,
|
||||
),
|
||||
ba.BoolSetting('Epic Mode', default=False),
|
||||
bs.BoolSetting('Epic Mode', default=False),
|
||||
]
|
||||
if issubclass(sessiontype, ba.DualTeamSession):
|
||||
settings.append(ba.BoolSetting('Solo Mode', default=False))
|
||||
if issubclass(sessiontype, bs.DualTeamSession):
|
||||
settings.append(bs.BoolSetting('Solo Mode', default=False))
|
||||
settings.append(
|
||||
ba.BoolSetting('Balance Total Lives', default=False)
|
||||
bs.BoolSetting('Balance Total Lives', default=False)
|
||||
)
|
||||
return settings
|
||||
|
||||
@classmethod
|
||||
def supports_session_type(cls, sessiontype: type[ba.Session]) -> bool:
|
||||
return issubclass(sessiontype, ba.DualTeamSession) or issubclass(
|
||||
sessiontype, ba.FreeForAllSession
|
||||
def supports_session_type(cls, sessiontype: type[bs.Session]) -> bool:
|
||||
return issubclass(sessiontype, bs.DualTeamSession) or issubclass(
|
||||
sessiontype, bs.FreeForAllSession
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_supported_maps(cls, sessiontype: type[ba.Session]) -> list[str]:
|
||||
def get_supported_maps(cls, sessiontype: type[bs.Session]) -> list[str]:
|
||||
return ['Wooden Floor']
|
||||
|
||||
def __init__(self, settings: dict):
|
||||
|
|
@ -95,7 +98,7 @@ class DemolitionWar(EliminationGame):
|
|||
self._solo_mode = False
|
||||
self._balance_total_lives = False
|
||||
|
||||
def spawn_player(self, player: Player) -> ba.Actor:
|
||||
def spawn_player(self, player: Player) -> bs.Actor:
|
||||
p = [-6, -4.3, -2.6, -0.9, 0.8, 2.5, 4.2, 5.9]
|
||||
q = [-4, -2.3, -0.6, 1.1, 2.8, 4.5]
|
||||
|
||||
|
|
@ -118,23 +121,23 @@ class DemolitionWar(EliminationGame):
|
|||
self.map_extend()
|
||||
|
||||
def on_blast(self):
|
||||
node = ba.getcollision().sourcenode
|
||||
ba.emitfx((node.position[0], 0.9, node.position[2]),
|
||||
node = bs.getcollision().sourcenode
|
||||
bs.emitfx((node.position[0], 0.9, node.position[2]),
|
||||
(0, 2, 0), 30, 1, spread=1, chunk_type='splinter')
|
||||
ba.timer(0.1, ba.Call(node.delete))
|
||||
bs.timer(0.1, babase.Call(node.delete))
|
||||
|
||||
def map_extend(self):
|
||||
# TODO need to improve here , so we can increase size of map easily with settings
|
||||
p = [-6, -4.3, -2.6, -0.9, 0.8, 2.5, 4.2, 5.9]
|
||||
q = [-4, -2.3, -0.6, 1.1, 2.8, 4.5]
|
||||
factory = BombFactory.get()
|
||||
self.ramp_bomb = ba.Material()
|
||||
self.ramp_bomb = bs.Material()
|
||||
self.ramp_bomb.add_actions(
|
||||
conditions=('they_have_material', factory.bomb_material),
|
||||
actions=(
|
||||
('modify_part_collision', 'collide', True),
|
||||
('modify_part_collision', 'physical', True),
|
||||
('call', 'at_connect', ba.Call(self.on_blast))
|
||||
('call', 'at_connect', babase.Call(self.on_blast))
|
||||
))
|
||||
self.ramps = []
|
||||
for i in p:
|
||||
|
|
@ -144,7 +147,7 @@ class DemolitionWar(EliminationGame):
|
|||
def create_ramp(self, x, z):
|
||||
|
||||
shared = SharedObjects.get()
|
||||
self._real_collied_material = ba.Material()
|
||||
self._real_collied_material = bs.Material()
|
||||
|
||||
self._real_collied_material.add_actions(
|
||||
actions=(
|
||||
|
|
@ -152,32 +155,32 @@ class DemolitionWar(EliminationGame):
|
|||
('modify_part_collision', 'physical', True)
|
||||
|
||||
))
|
||||
self.mat = ba.Material()
|
||||
self.mat = bs.Material()
|
||||
self.mat.add_actions(
|
||||
actions=(('modify_part_collision', 'physical', False),
|
||||
('modify_part_collision', 'collide', False))
|
||||
)
|
||||
pos = (x, 0, z)
|
||||
ud_1_r = ba.newnode('region', attrs={'position': pos, 'scale': (1.5, 1, 1.5), 'type': 'box', 'materials': [
|
||||
ud_1_r = bs.newnode('region', attrs={'position': pos, 'scale': (1.5, 1, 1.5), 'type': 'box', 'materials': [
|
||||
shared.footing_material, self._real_collied_material, self.ramp_bomb]})
|
||||
|
||||
node = ba.newnode('prop',
|
||||
node = bs.newnode('prop',
|
||||
owner=ud_1_r,
|
||||
attrs={
|
||||
'model': ba.getmodel('image1x1'),
|
||||
'light_model': ba.getmodel('powerupSimple'),
|
||||
'mesh': bs.getmesh('image1x1'),
|
||||
'light_mesh': bs.getmesh('powerupSimple'),
|
||||
'position': (2, 7, 2),
|
||||
'body': 'puck',
|
||||
'shadow_size': 0.0,
|
||||
'velocity': (0, 0, 0),
|
||||
'color_texture': ba.gettexture('tnt'),
|
||||
'model_scale': 1.5,
|
||||
'color_texture': bs.gettexture('tnt'),
|
||||
'mesh_scale': 1.5,
|
||||
'reflection_scale': [1.5],
|
||||
'materials': [self.mat, shared.object_material, shared.footing_material],
|
||||
'density': 9000000000
|
||||
})
|
||||
node.changerotation(1, 0, 0)
|
||||
mnode = ba.newnode('math',
|
||||
# node.changerotation(1, 0, 0)
|
||||
mnode = bs.newnode('math',
|
||||
owner=ud_1_r,
|
||||
attrs={
|
||||
'input1': (0, 0.6, 0),
|
||||
|
|
@ -218,7 +221,7 @@ class mapdefs:
|
|||
points['tnt1'] = (-0.08421587483, 0.9515026107, -0.7762602271)
|
||||
|
||||
|
||||
class WoodenFloor(ba.Map):
|
||||
class WoodenFloor(bs._map.Map): # ahdunno if this is correct way, change if u find better way
|
||||
"""Stadium map for football games."""
|
||||
defs = mapdefs
|
||||
defs.points['spawn1'] = (-12.03866341, 0.02275111462, 0.0) + (0.5, 1.0, 4.0)
|
||||
|
|
@ -238,15 +241,15 @@ class WoodenFloor(ba.Map):
|
|||
def on_preload(cls) -> Any:
|
||||
data: dict[str, Any] = {
|
||||
|
||||
'model_bg': ba.getmodel('doomShroomBG'),
|
||||
'bg_vr_fill_model': ba.getmodel('natureBackgroundVRFill'),
|
||||
'collide_model': ba.getcollidemodel('bridgitLevelCollide'),
|
||||
'tex': ba.gettexture('bridgitLevelColor'),
|
||||
'model_bg_tex': ba.gettexture('doomShroomBGColor'),
|
||||
'collide_bg': ba.getcollidemodel('natureBackgroundCollide'),
|
||||
'railing_collide_model':
|
||||
(ba.getcollidemodel('bridgitLevelRailingCollide')),
|
||||
'bg_material': ba.Material()
|
||||
'mesh_bg': bs.getmesh('doomShroomBG'),
|
||||
'bg_vr_fill_mesh': bs.getmesh('natureBackgroundVRFill'),
|
||||
'collide_mesh': bs.getcollisionmesh('bridgitLevelCollide'),
|
||||
'tex': bs.gettexture('bridgitLevelColor'),
|
||||
'mesh_bg_tex': bs.gettexture('doomShroomBGColor'),
|
||||
'collide_bg': bs.getcollisionmesh('natureBackgroundCollide'),
|
||||
'railing_collide_mesh':
|
||||
(bs.getcollisionmesh('bridgitLevelRailingCollide')),
|
||||
'bg_material': bs.Material()
|
||||
}
|
||||
data['bg_material'].add_actions(actions=('modify_part_collision',
|
||||
'friction', 10.0))
|
||||
|
|
@ -255,23 +258,23 @@ class WoodenFloor(ba.Map):
|
|||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
shared = SharedObjects.get()
|
||||
self.background = ba.newnode(
|
||||
self.background = bs.newnode(
|
||||
'terrain',
|
||||
attrs={
|
||||
'model': self.preloaddata['model_bg'],
|
||||
'mesh': self.preloaddata['mesh_bg'],
|
||||
'lighting': False,
|
||||
'background': True,
|
||||
'color_texture': self.preloaddata['model_bg_tex']
|
||||
'color_texture': self.preloaddata['mesh_bg_tex']
|
||||
})
|
||||
self.vr = ba.newnode('terrain',
|
||||
self.vr = bs.newnode('terrain',
|
||||
attrs={
|
||||
'model': self.preloaddata['bg_vr_fill_model'],
|
||||
'mesh': self.preloaddata['bg_vr_fill_mesh'],
|
||||
'lighting': False,
|
||||
'vr_only': True,
|
||||
'background': True,
|
||||
'color_texture': self.preloaddata['model_bg_tex']
|
||||
'color_texture': self.preloaddata['mesh_bg_tex']
|
||||
})
|
||||
gnode = ba.getactivity().globalsnode
|
||||
gnode = bs.getactivity().globalsnode
|
||||
gnode.tint = (1.3, 1.2, 1.0)
|
||||
gnode.ambient_color = (1.3, 1.2, 1.0)
|
||||
gnode.vignette_outer = (0.57, 0.57, 0.57)
|
||||
|
|
@ -280,7 +283,7 @@ class WoodenFloor(ba.Map):
|
|||
gnode.vr_near_clip = 0.5
|
||||
|
||||
def is_point_near_edge(self,
|
||||
point: ba.Vec3,
|
||||
point: babase.Vec3,
|
||||
running: bool = False) -> bool:
|
||||
box_position = self.defs.boxes['edge_box'][0:3]
|
||||
box_scale = self.defs.boxes['edge_box'][6:9]
|
||||
|
|
@ -290,15 +293,15 @@ class WoodenFloor(ba.Map):
|
|||
|
||||
def _handle_player_collide(self):
|
||||
try:
|
||||
player = ba.getcollision().opposingnode.getdelegate(
|
||||
player = bs.getcollision().opposingnode.getdelegate(
|
||||
PlayerSpaz, True)
|
||||
except ba.NotFoundError:
|
||||
except bs.NotFoundError:
|
||||
return
|
||||
if player.is_alive():
|
||||
player.shatter(True)
|
||||
|
||||
|
||||
try:
|
||||
ba._map.register_map(WoodenFloor)
|
||||
bs._map.register_map(WoodenFloor)
|
||||
except:
|
||||
pass
|
||||
|
|
|
|||
602
plugins/minigames/super_duel.py
Normal file
602
plugins/minigames/super_duel.py
Normal file
|
|
@ -0,0 +1,602 @@
|
|||
"""New Duel / Created by: byANG3L"""
|
||||
|
||||
# ba_meta require api 8
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
import random
|
||||
from bascenev1lib.actor.playerspaz import PlayerSpaz
|
||||
from bascenev1lib.actor.scoreboard import Scoreboard
|
||||
from bascenev1lib.game.elimination import Icon
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional
|
||||
|
||||
|
||||
class SuperSpaz(PlayerSpaz):
|
||||
|
||||
def __init__(self,
|
||||
player: bs.Player,
|
||||
color: Sequence[float] = (1.0, 1.0, 1.0),
|
||||
highlight: Sequence[float] = (0.5, 0.5, 0.5),
|
||||
character: str = 'Spaz',
|
||||
super_punch: bool = False,
|
||||
powerups_expire: bool = True):
|
||||
super().__init__(player=player,
|
||||
color=color,
|
||||
highlight=highlight,
|
||||
character=character,
|
||||
powerups_expire=powerups_expire)
|
||||
self._super_punch = super_punch
|
||||
|
||||
def handlemessage(self, msg: Any) -> Any:
|
||||
from bascenev1lib.actor.spaz import PunchHitMessage
|
||||
from bascenev1lib.actor.bomb import Blast
|
||||
if isinstance(msg, PunchHitMessage):
|
||||
super().handlemessage(msg)
|
||||
node = bs.getcollision().opposingnode
|
||||
if self._super_punch:
|
||||
if node.getnodetype() == 'spaz':
|
||||
if not node.frozen:
|
||||
node.frozen = True
|
||||
node.handlemessage(babase.FreezeMessage())
|
||||
bs.getsound('freeze').play()
|
||||
bs.getsound('superPunch').play()
|
||||
bs.getsound('punchStrong02').play()
|
||||
Blast(position=node.position,
|
||||
velocity=node.velocity,
|
||||
blast_radius=0.0,
|
||||
blast_type='normal').autoretain()
|
||||
else:
|
||||
return super().handlemessage(msg)
|
||||
return None
|
||||
|
||||
|
||||
class Player(bs.Player['Team']):
|
||||
"""Our player type for this game."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.icons: List[Icon] = []
|
||||
self.in_game: bool = False
|
||||
self.playervs1: bool = False
|
||||
self.playervs2: bool = False
|
||||
self.light: bool = False
|
||||
|
||||
|
||||
class Team(bs.Team[Player]):
|
||||
"""Our team type for this game."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.score = 0
|
||||
|
||||
|
||||
lang = bs.app.lang.language
|
||||
if lang == 'Spanish':
|
||||
enable_powerups = 'Habilitar Potenciadores'
|
||||
night_mode = 'Modo Noche'
|
||||
fight_delay = 'Tiempo entre Pelea'
|
||||
very_fast = 'Muy Rápido'
|
||||
fast = 'Rápido'
|
||||
normal = 'Normal'
|
||||
slow = 'Lento'
|
||||
very_slow = 'Muy Lento'
|
||||
none = 'Ninguno'
|
||||
super_punch = 'Super Golpe'
|
||||
box_mode = 'Modo Caja'
|
||||
boxing_gloves = 'Guantes de Boxeo'
|
||||
else:
|
||||
enable_powerups = 'Enable Powerups'
|
||||
night_mode = 'Night Mode'
|
||||
fight_delay = 'Fight Delay'
|
||||
very_fast = 'Very Fast'
|
||||
fast = 'Fast'
|
||||
normal = 'Normal'
|
||||
slow = 'Slow'
|
||||
very_slow = 'Very Slow'
|
||||
super_punch = 'Super Punch'
|
||||
box_mode = 'Box Mode'
|
||||
boxing_gloves = 'Boxing Gloves'
|
||||
|
||||
# ba_meta export bascenev1.GameActivity
|
||||
|
||||
|
||||
class NewDuelGame(bs.TeamGameActivity[Player, Team]):
|
||||
"""A game type based on acquiring kills."""
|
||||
|
||||
name = 'Duel'
|
||||
description = 'Kill a set number of enemies to win.'
|
||||
|
||||
# Print messages when players die since it matters here.
|
||||
announce_player_deaths = True
|
||||
|
||||
@classmethod
|
||||
def get_available_settings(
|
||||
cls, sessiontype: Type[bs.Session]) -> List[babase.Setting]:
|
||||
settings = [
|
||||
bs.IntSetting(
|
||||
'Kills to Win Per Player',
|
||||
min_value=1,
|
||||
default=5,
|
||||
increment=1,
|
||||
),
|
||||
bs.IntChoiceSetting(
|
||||
'Time Limit',
|
||||
choices=[
|
||||
('None', 0),
|
||||
('1 Minute', 60),
|
||||
('2 Minutes', 120),
|
||||
('5 Minutes', 300),
|
||||
('10 Minutes', 600),
|
||||
('20 Minutes', 1200),
|
||||
],
|
||||
default=0,
|
||||
),
|
||||
bs.BoolSetting(enable_powerups, default=False),
|
||||
bs.BoolSetting(boxing_gloves, default=False),
|
||||
bs.BoolSetting(night_mode, default=False),
|
||||
bs.BoolSetting(super_punch, default=False),
|
||||
bs.BoolSetting(box_mode, default=False),
|
||||
bs.BoolSetting('Epic Mode', default=False),
|
||||
bs.BoolSetting('Allow Negative Scores', default=False),
|
||||
]
|
||||
return settings
|
||||
|
||||
@classmethod
|
||||
def supports_session_type(cls, sessiontype: Type[bs.Session]) -> bool:
|
||||
return (issubclass(sessiontype, bs.FreeForAllSession))
|
||||
|
||||
@classmethod
|
||||
def get_supported_maps(cls, sessiontype: Type[bs.Session]) -> List[str]:
|
||||
return bs.app.classic.getmaps('melee')
|
||||
|
||||
def __init__(self, settings: dict):
|
||||
super().__init__(settings)
|
||||
self._scoreboard = Scoreboard()
|
||||
self._score_to_win: Optional[int] = None
|
||||
self._dingsound = bs.getsound('dingSmall')
|
||||
self._epic_mode = bool(settings['Epic Mode'])
|
||||
self._kills_to_win_per_player = int(
|
||||
settings['Kills to Win Per Player'])
|
||||
self._enable_powerups = bool(settings[enable_powerups])
|
||||
self._night_mode = bool(settings[night_mode])
|
||||
self._fight_delay: float = 0
|
||||
self._time_limit = float(settings['Time Limit'])
|
||||
self._allow_negative_scores = bool(
|
||||
settings.get('Allow Negative Scores', False))
|
||||
self._super_punch = bool(settings[super_punch])
|
||||
self._box_mode = bool(settings[box_mode])
|
||||
self._boxing_gloves = bool(settings[boxing_gloves])
|
||||
self._vs_text: Optional[bs.Actor] = None
|
||||
self.spawn_order: List[Player] = []
|
||||
self._players_vs_1: bool = False
|
||||
self._players_vs_2: bool = False
|
||||
self._first_countdown: bool = True
|
||||
self._count_1 = bs.getsound('announceOne')
|
||||
self._count_2 = bs.getsound('announceTwo')
|
||||
self._count_3 = bs.getsound('announceThree')
|
||||
self._boxing_bell = bs.getsound('boxingBell')
|
||||
|
||||
# Base class overrides.
|
||||
self.slow_motion = self._epic_mode
|
||||
self.default_music = (bs.MusicType.EPIC if self._epic_mode else
|
||||
bs.MusicType.TO_THE_DEATH)
|
||||
|
||||
def get_instance_description(self) -> Union[str, Sequence]:
|
||||
return 'Crush ${ARG1} of your enemies.', self._score_to_win
|
||||
|
||||
def get_instance_description_short(self) -> Union[str, Sequence]:
|
||||
return 'kill ${ARG1} enemies', self._score_to_win
|
||||
|
||||
def on_player_join(self, player: Player) -> None:
|
||||
self.spawn_order.append(player)
|
||||
self._update_order()
|
||||
|
||||
def on_player_leave(self, player: Player) -> None:
|
||||
super().on_player_leave(player)
|
||||
player.icons = []
|
||||
if player.playervs1:
|
||||
player.playervs1 = False
|
||||
self._players_vs_1 = False
|
||||
player.in_game = False
|
||||
elif player.playervs2:
|
||||
player.playervs2 = False
|
||||
self._players_vs_2 = False
|
||||
player.in_game = False
|
||||
if player in self.spawn_order:
|
||||
self.spawn_order.remove(player)
|
||||
bs.timer(0.2, self._update_order)
|
||||
|
||||
def on_transition_in(self) -> None:
|
||||
super().on_transition_in()
|
||||
if self._night_mode:
|
||||
gnode = bs.getactivity().globalsnode
|
||||
gnode.tint = (0.3, 0.3, 0.3)
|
||||
|
||||
def on_team_join(self, team: Team) -> None:
|
||||
if self.has_begun():
|
||||
self._update_scoreboard()
|
||||
|
||||
def on_begin(self) -> None:
|
||||
super().on_begin()
|
||||
self.setup_standard_time_limit(self._time_limit)
|
||||
if self._enable_powerups:
|
||||
self.setup_standard_powerup_drops()
|
||||
self._vs_text = bs.NodeActor(
|
||||
bs.newnode('text',
|
||||
attrs={
|
||||
'position': (0, 105),
|
||||
'h_attach': 'center',
|
||||
'h_align': 'center',
|
||||
'maxwidth': 200,
|
||||
'shadow': 0.5,
|
||||
'vr_depth': 390,
|
||||
'scale': 0.6,
|
||||
'v_attach': 'bottom',
|
||||
'color': (0.8, 0.8, 0.3, 1.0),
|
||||
'text': babase.Lstr(resource='vsText')
|
||||
}))
|
||||
|
||||
# Base kills needed to win on the size of the largest team.
|
||||
self._score_to_win = (self._kills_to_win_per_player *
|
||||
max(1, max(len(t.players) for t in self.teams)))
|
||||
self._update_scoreboard()
|
||||
bs.timer(1.0, self._update, repeat=True)
|
||||
|
||||
def _update(self) -> None:
|
||||
if len(self.players) == 1:
|
||||
'self.end_game()'
|
||||
|
||||
def spawn_player(self, player: PlayerType) -> bs.Actor:
|
||||
# pylint: disable=too-many-locals
|
||||
# pylint: disable=cyclic-import
|
||||
from babase import _math
|
||||
from bascenev1._coopsession import CoopSession
|
||||
from bascenev1lib.actor.spazfactory import SpazFactory
|
||||
factory = SpazFactory.get()
|
||||
name = player.getname()
|
||||
color = player.color
|
||||
highlight = player.highlight
|
||||
|
||||
light_color = _math.normalized_color(color)
|
||||
display_color = babase.safecolor(color, target_intensity=0.75)
|
||||
spaz = SuperSpaz(color=color,
|
||||
highlight=highlight,
|
||||
character=player.character,
|
||||
player=player,
|
||||
super_punch=True if self._super_punch else False)
|
||||
|
||||
player.actor = spaz
|
||||
assert spaz.node
|
||||
|
||||
# If this is co-op and we're on Courtyard or Runaround, add the
|
||||
# material that allows us to collide with the player-walls.
|
||||
# FIXME: Need to generalize this.
|
||||
if isinstance(self.session, CoopSession) and self.map.getname() in [
|
||||
'Courtyard', 'Tower D'
|
||||
]:
|
||||
mat = self.map.preloaddata['collide_with_wall_material']
|
||||
assert isinstance(spaz.node.materials, tuple)
|
||||
assert isinstance(spaz.node.roller_materials, tuple)
|
||||
spaz.node.materials += (mat, )
|
||||
spaz.node.roller_materials += (mat, )
|
||||
|
||||
spaz.node.name = name
|
||||
spaz.node.name_color = display_color
|
||||
spaz.connect_controls_to_player()
|
||||
|
||||
self._spawn_sound.play(1, position=spaz.node.position)
|
||||
light = bs.newnode('light', attrs={'color': light_color})
|
||||
spaz.node.connectattr('position', light, 'position')
|
||||
bs.animate(light, 'intensity', {0: 0, 0.25: 1, 0.5: 0})
|
||||
bs.timer(0.5, light.delete)
|
||||
|
||||
pos1 = [self.map.get_start_position(0), 90]
|
||||
pos2 = [self.map.get_start_position(1), 270]
|
||||
pos3 = []
|
||||
|
||||
for x in self.players:
|
||||
if x.is_alive():
|
||||
if x is player:
|
||||
continue
|
||||
p = x.actor.node.position
|
||||
if 0.0 not in (p[0], p[2]):
|
||||
if p[0] <= 0:
|
||||
pos3.append(pos2[0])
|
||||
else:
|
||||
pos3.append(pos1[0])
|
||||
|
||||
spaz.handlemessage(bs.StandMessage(pos1[0] if player.playervs1 else pos2[0],
|
||||
pos1[1] if player.playervs1 else pos2[1]))
|
||||
|
||||
if any(pos3):
|
||||
spaz.handlemessage(bs.StandMessage(pos3[0]))
|
||||
|
||||
if self._super_punch:
|
||||
spaz._punch_power_scale = factory.punch_power_scale_gloves = 10
|
||||
spaz.equip_boxing_gloves()
|
||||
lfx = bs.newnode(
|
||||
'light',
|
||||
attrs={
|
||||
'color': color,
|
||||
'radius': 0.3,
|
||||
'intensity': 0.3})
|
||||
|
||||
def sp_fx():
|
||||
if not spaz.node:
|
||||
lfx.delete()
|
||||
return
|
||||
bs.emitfx(position=spaz.node.position,
|
||||
velocity=spaz.node.velocity,
|
||||
count=5,
|
||||
scale=0.5,
|
||||
spread=0.5,
|
||||
chunk_type='spark')
|
||||
bs.emitfx(position=spaz.node.position,
|
||||
velocity=spaz.node.velocity,
|
||||
count=2,
|
||||
scale=0.8,
|
||||
spread=0.3,
|
||||
chunk_type='spark')
|
||||
if lfx:
|
||||
spaz.node.connectattr('position', lfx, 'position')
|
||||
bs.timer(0.1, sp_fx, repeat=True)
|
||||
|
||||
if self._box_mode:
|
||||
spaz.node.color_texture = bs.gettexture('tnt')
|
||||
spaz.node.color_mask_texture = bs.gettexture('tnt')
|
||||
spaz.node.color = (1, 1, 1)
|
||||
spaz.node.highlight = (1, 1, 1)
|
||||
spaz.node.head_mesh = None
|
||||
spaz.node.torso_mesh = bs.getmesh('tnt')
|
||||
spaz.node.style = 'cyborg'
|
||||
|
||||
if self._boxing_gloves:
|
||||
spaz.equip_boxing_gloves()
|
||||
|
||||
return spaz
|
||||
|
||||
def _update_spawn(self) -> None:
|
||||
if self._players_vs_1 or self._players_vs_2:
|
||||
for player in self.players:
|
||||
if player.playervs1 or player.playervs2:
|
||||
if not player.is_alive():
|
||||
self.spawn_player(player)
|
||||
# player.actor.disconnect_controls_from_player()
|
||||
|
||||
if self._night_mode:
|
||||
if not player.light:
|
||||
player.light = True
|
||||
light = bs.newnode(
|
||||
'light',
|
||||
owner=player.node,
|
||||
attrs={
|
||||
'radius': 0.3,
|
||||
'intensity': 0.6,
|
||||
'height_attenuated': False,
|
||||
'color': player.color
|
||||
})
|
||||
player.node.connectattr(
|
||||
'position', light, 'position')
|
||||
else:
|
||||
player.actor.disconnect_controls_from_player()
|
||||
|
||||
bs.timer(0.0, self._countdown)
|
||||
# bs.timer(0.1, self._clear_all_objects)
|
||||
|
||||
def _countdown(self) -> None:
|
||||
self._first_countdown = False
|
||||
if self._fight_delay == 0:
|
||||
for player in self.players:
|
||||
if player.playervs1 or player.playervs2:
|
||||
if not player.is_alive():
|
||||
return
|
||||
else:
|
||||
player.actor.connect_controls_to_player()
|
||||
else:
|
||||
bs.timer(self._fight_delay, self.count3)
|
||||
|
||||
def start(self) -> None:
|
||||
self._count_text('FIGHT')
|
||||
self._boxing_bell.play()
|
||||
for player in self.players:
|
||||
if player.playervs1 or player.playervs2:
|
||||
if not player.is_alive():
|
||||
return
|
||||
else:
|
||||
player.actor.connect_controls_to_player()
|
||||
|
||||
def count(self) -> None:
|
||||
self._count_text('1')
|
||||
self._count_1.play()
|
||||
bs.timer(self._fight_delay, self.start)
|
||||
|
||||
def count2(self) -> None:
|
||||
self._count_text('2')
|
||||
self._count_2.play()
|
||||
bs.timer(self._fight_delay, self.count)
|
||||
|
||||
def count3(self) -> None:
|
||||
self._count_text('3')
|
||||
self._count_3.play()
|
||||
bs.timer(self._fight_delay, self.count2)
|
||||
|
||||
def _count_text(self, num: str) -> None:
|
||||
self.node = bs.newnode('text',
|
||||
attrs={
|
||||
'v_attach': 'center',
|
||||
'h_attach': 'center',
|
||||
'h_align': 'center',
|
||||
'color': (1, 1, 0.5, 1),
|
||||
'flatness': 0.5,
|
||||
'shadow': 0.5,
|
||||
'position': (0, 18),
|
||||
'text': num
|
||||
})
|
||||
if self._fight_delay == 0.7:
|
||||
bs.animate(self.node, 'scale',
|
||||
{0: 0, 0.1: 3.9, 0.64: 4.3, 0.68: 0})
|
||||
elif self._fight_delay == 0.4:
|
||||
bs.animate(self.node, 'scale',
|
||||
{0: 0, 0.1: 3.9, 0.34: 4.3, 0.38: 0})
|
||||
else:
|
||||
bs.animate(self.node, 'scale',
|
||||
{0: 0, 0.1: 3.9, 0.92: 4.3, 0.96: 0})
|
||||
cmb = bs.newnode('combine', owner=self.node, attrs={'size': 4})
|
||||
cmb.connectattr('output', self.node, 'color')
|
||||
bs.animate(cmb, 'input0', {0: 1.0, 0.15: 1.0}, loop=True)
|
||||
bs.animate(cmb, 'input1', {0: 1.0, 0.15: 0.5}, loop=True)
|
||||
bs.animate(cmb, 'input2', {0: 0.1, 0.15: 0.0}, loop=True)
|
||||
cmb.input3 = 1.0
|
||||
bs.timer(self._fight_delay, self.node.delete)
|
||||
|
||||
def _update_order(self) -> None:
|
||||
for player in self.spawn_order:
|
||||
assert isinstance(player, Player)
|
||||
if not player.is_alive():
|
||||
if not self._players_vs_1:
|
||||
self._players_vs_1 = True
|
||||
player.playervs1 = True
|
||||
player.in_game = True
|
||||
self.spawn_order.remove(player)
|
||||
self._update_spawn()
|
||||
elif not self._players_vs_2:
|
||||
self._players_vs_2 = True
|
||||
player.playervs2 = True
|
||||
player.in_game = True
|
||||
self.spawn_order.remove(player)
|
||||
self._update_spawn()
|
||||
self._update_icons()
|
||||
|
||||
def _update_icons(self) -> None:
|
||||
# pylint: disable=too-many-branches
|
||||
|
||||
for player in self.players:
|
||||
player.icons = []
|
||||
|
||||
if player.in_game:
|
||||
if player.playervs1:
|
||||
xval = -60
|
||||
x_offs = -78
|
||||
elif player.playervs2:
|
||||
xval = 60
|
||||
x_offs = 78
|
||||
player.icons.append(
|
||||
Icon(player,
|
||||
position=(xval, 40),
|
||||
scale=1.0,
|
||||
name_maxwidth=130,
|
||||
name_scale=0.8,
|
||||
flatness=0.0,
|
||||
shadow=0.5,
|
||||
show_death=True,
|
||||
show_lives=False))
|
||||
else:
|
||||
xval = 125
|
||||
xval2 = -125
|
||||
x_offs = 78
|
||||
for player in self.spawn_order:
|
||||
player.icons.append(
|
||||
Icon(player,
|
||||
position=(xval, 25),
|
||||
scale=0.5,
|
||||
name_maxwidth=75,
|
||||
name_scale=1.0,
|
||||
flatness=1.0,
|
||||
shadow=1.0,
|
||||
show_death=False,
|
||||
show_lives=False))
|
||||
xval += x_offs * 0.56
|
||||
player.icons.append(
|
||||
Icon(player,
|
||||
position=(xval2, 25),
|
||||
scale=0.5,
|
||||
name_maxwidth=75,
|
||||
name_scale=1.0,
|
||||
flatness=1.0,
|
||||
shadow=1.0,
|
||||
show_death=False,
|
||||
show_lives=False))
|
||||
xval2 -= x_offs * 0.56
|
||||
|
||||
def handlemessage(self, msg: Any) -> Any:
|
||||
|
||||
if isinstance(msg, bs.PlayerDiedMessage):
|
||||
|
||||
# Augment standard behavior.
|
||||
super().handlemessage(msg)
|
||||
|
||||
player = msg.getplayer(Player)
|
||||
|
||||
if player.playervs1:
|
||||
player.playervs1 = False
|
||||
self._players_vs_1 = False
|
||||
player.in_game = False
|
||||
self.spawn_order.append(player)
|
||||
elif player.playervs2:
|
||||
player.playervs2 = False
|
||||
self._players_vs_2 = False
|
||||
player.in_game = False
|
||||
self.spawn_order.append(player)
|
||||
bs.timer(0.2, self._update_order)
|
||||
|
||||
killer = msg.getkillerplayer(Player)
|
||||
if killer is None:
|
||||
return None
|
||||
|
||||
# Handle team-kills.
|
||||
if killer.team is player.team:
|
||||
|
||||
# In free-for-all, killing yourself loses you a point.
|
||||
if isinstance(self.session, bs.FreeForAllSession):
|
||||
new_score = player.team.score - 1
|
||||
if not self._allow_negative_scores:
|
||||
new_score = max(0, new_score)
|
||||
player.team.score = new_score
|
||||
|
||||
# In teams-mode it gives a point to the other team.
|
||||
else:
|
||||
self._dingsound.play()
|
||||
for team in self.teams:
|
||||
if team is not killer.team:
|
||||
team.score += 1
|
||||
|
||||
# Killing someone on another team nets a kill.
|
||||
else:
|
||||
killer.team.score += 1
|
||||
self._dingsound.play()
|
||||
|
||||
# In FFA show scores since its hard to find on the scoreboard.
|
||||
if isinstance(killer.actor, PlayerSpaz) and killer.actor:
|
||||
killer.actor.set_score_text(str(killer.team.score) + '/' +
|
||||
str(self._score_to_win),
|
||||
color=killer.team.color,
|
||||
flash=True)
|
||||
|
||||
self._update_scoreboard()
|
||||
|
||||
# If someone has won, set a timer to end shortly.
|
||||
# (allows the dust to clear and draws to occur if deaths are
|
||||
# close enough)
|
||||
assert self._score_to_win is not None
|
||||
if any(team.score >= self._score_to_win for team in self.teams):
|
||||
bs.timer(0.5, self.end_game)
|
||||
else:
|
||||
return super().handlemessage(msg)
|
||||
return None
|
||||
|
||||
def _update_scoreboard(self) -> None:
|
||||
for team in self.teams:
|
||||
self._scoreboard.set_team_value(team, team.score,
|
||||
self._score_to_win)
|
||||
|
||||
def end_game(self) -> None:
|
||||
results = bs.GameResults()
|
||||
for team in self.teams:
|
||||
results.set_team_score(team, team.score)
|
||||
self.end(results=results)
|
||||
Loading…
Add table
Add a link
Reference in a new issue