-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsDeathBoat.py
194 lines (140 loc) · 5.8 KB
/
bsDeathBoat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# -*- coding: utf-8 -*-
#by wsdx233
#菜猪比赛专用~
import bs
import random
def bsGetAPIVersion():
# see bombsquadgame.com/apichanges
return 4
def bsGetGames():
return [DeathMatchGame]
class PirateBotPro(bs.PirateBot):
curseTime = 9000
defaultShields = False
defaultBoxingGloves = True
class DeathMatchGame(bs.TeamGameActivity):
@classmethod
def getName(cls):
return '选拔船员'
@classmethod
def getDescription(cls, sessionType):
return '嘘!别被选上!'
@classmethod
def supportsSessionType(cls, sessionType):
return True if(
issubclass(sessionType, bs.TeamsSession)
or issubclass(sessionType, bs.FreeForAllSession)) else False
@classmethod
def getSupportedMaps(cls, sessionType):
return bs.getMapsSupportingPlayType("melee")
@classmethod
def getSettings(cls, sessionType):
settings = [
("Time Limit",
{
'choices':
[
('1 Minute', 60),
('2 Minutes', 120),
('5 Minutes', 300),
('10 Minutes', 600),
('20 Minutes', 1200)],
'default': 60}),
("Respawn Times",
{
'choices':
[('Shorter', 0.25),
('Short', 0.5),
('Normal', 1.0),
('Long', 2.0),
('Longer', 4.0)],
'default': 1.0}),
("Epic Mode", {'default': True})]
# In teams mode, a suicide gives a point to the other team, but in
# free-for-all it subtracts from your own score. By default we clamp
# this at zero to benefit new players, but pro players might like to
# be able to go negative. (to avoid a strategy of just
# suiciding until you get a good drop)
return settings
def __init__(self, settings):
bs.TeamGameActivity.__init__(self, settings)
if self.settings['Epic Mode']:
self._isSlowMotion = True
# print messages when players die since it matters here..
self.announcePlayerDeaths = True
self._scoreBoard = bs.ScoreBoard()
def _test(*a):
bs.screenMessage(str(a))
def getInstanceDescription(self):
return ('嘘!别被选上!')
def getInstanceScoreBoardDescription(self):
return ('别被选上!逃!')
def onTransitionIn(self):
bs.TeamGameActivity.onTransitionIn(
self, music='Epic' if self.settings['Epic Mode'] else 'ToTheDeath')
def onTeamJoin(self, team):
team.gameData['score'] = 0
if self.hasBegun():
team.gameData['score'] = -99
self._updateScoreBoard()
def onBegin(self):
bs.TeamGameActivity.onBegin(self)
self.setupStandardTimeLimit(self.settings['Time Limit'])
self.setupStandardPowerupDrops()
self._updateScoreBoard()
self._dingSound = bs.getSound('dingSmall')
# spawn some baddies
self._bots = bs.BotSet()
self._bots.spawnBot(PirateBotPro,pos=(-2,5,0), spawnTime=2000)
def _curs(self, game, bot):
bot.curseTime = 9999
def handleMessage(self, m):
# a spaz-bot has died
if isinstance(m, bs.SpazBotDeathMessage):
self._bots.spawnBot(PirateBotPro,pos=(random.randint(-5,5),5,random.randint(-5,5)), spawnTime=4000, onSpawnCall=self._curs)
if (random.randint(1,100) >= 95 and (len(self._bots.getLivingBots()) < 3)) :
self._bots.spawnBot(PirateBotPro,pos=(random.randint(-5,5),5,random.randint(-5,5)), spawnTime=4000, onSpawnCall=self._curs)
if isinstance(m, bs.PlayerSpazDeathMessage):
bs.TeamGameActivity.handleMessage(
self, m) # augment standard behavior
player = m.spaz.getPlayer()
self.respawnPlayer(player)
killer = m.killerPlayer
if killer is None:
return
# handle team-kills
if True:
# in free-for-all, killing yourself loses you a point
if isinstance(self.getSession(), bs.FreeForAllSession):
newScore = player.getTeam().gameData['score'] - 1
if False:
newScore = max(0, newScore)
player.getTeam().gameData['score'] = newScore
# in teams-mode it gives a point to the other team
else:
bs.playSound(self._dingSound)
for team in self.teams:
if team is killer.getTeam():
team.gameData['score'] -= 1
# killing someone on another team nets a kill
self._updateScoreBoard()
# if someone has won, set a timer to end shortly
# (allows the dust to clear and draws to occur if deaths are
# close enough)
else:
bs.TeamGameActivity.handleMessage(self, m)
def _updateScoreBoard(self):
for team in self.teams:
self._scoreBoard.setTeamValue(
team, team.gameData['score'],
1)
def spawnPlayer(self, player):
spaz = self.spawnPlayerSpaz(player)
# lets reconnect this player's controls to this
# spaz but *without* the ability to attack or pick stuff up
spaz.connectControlsToPlayer(enablePunch=False,enableBomb=False,enablePickUp=True)
def endGame(self):
results = bs.TeamGameResults()
for t in self.teams:
results.setTeamScore(t, t.gameData['score'])
self.end(results=results)