-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsLaststandPro.py
146 lines (134 loc) · 5.49 KB
/
bsLaststandPro.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
# -*- coding: UTF-8 -*-
import bs;
from bsTheLastStand import *;
import random;
def onbe(self):
self._isSlowMotion = False
bs.CoopGameActivity.onBegin(self)
# spit out a few powerups and start dropping more shortly
self._dropPowerups(standardPoints=True)
bs.gameTimer(2000,bs.WeakCall(self._startPowerupDrops))
bs.gameTimer(1,bs.WeakCall(self._startBotUpdates))
self.setupLowLifeWarningSound()
self._updateScores()
self._bots = bs.BotSet()
self._dingSound = bs.getSound('dingSmall')
self._dingSoundHigh = bs.getSound('dingSmallHigh')
# our TNT spawner (if applicable)
self._tntSpawner = bs.TNTSpawner(position=self._tntSpawnPosition,respawnTime=10000)
def _bot(self):
self._botUpdateInterval = 3300 - 300*(len(self.players))
self._updateBots()
self._updateBots()
self._updateBots()
self._updateBots()
self._updateBots()
self._updateBots()
if len(self.players) > 2:
self._updateBots()
if len(self.players) > 3:
self._updateBots()
self._botUpdateTimer = bs.Timer(
int(self._botUpdateInterval),
bs.WeakCall(self._updateBots))
def _botup(self):
self._botSpawnTypes = {
bs.BomberBot: [0.1, 0.7, 0.2],
bs.BomberBotPro: [0.1, 0.05, 0.001],
bs.BomberBotProShielded: [0.02, 0.02, 0.002],
bs.ToughGuyBot: [0.2, 0.0, 0.0],
bs.ToughGuyBotPro: [0.2, 0.05, 0.1],
bs.ToughGuyBotProShielded: [0.03, 0.02, 0.04],
bs.ChickBot: [0.3, 0.0, 0.0],
bs.ChickBotPro: [0.2, 0.05, 0.001],
bs.ChickBotProShielded: [0.01, 0.02, 0.002],
bs.NinjaBot: [0.1, 0.05, 0.0],
bs.MelBot: [0.1, 0.6, 0.3],
bs.PirateBot: [0.3, 0.2, 0.1],
bs.NinjaBotProShielded: [0.01, 0.01, 0.02]
}
self._excludePowerups = ['tripleBombs','iceBombs','impactBombs','landMines','stickyBombs','curse'];
self._botUpdateInterval = max(random.randint(1000,2000), 1000)
self._botUpdateTimer = bs.Timer(
int(self._botUpdateInterval),
bs.WeakCall(self._updateBots))
botSpawnPoints = [[-5, 5.5, -4.14], [0, 5.5, -4.14], [5, 5.5, -4.14]]
dists = [0, 0, 0]
playerPts = []
for player in self.players:
try:
if player.isAlive():
playerPts.append(player.actor.node.position)
except Exception as e:
print 'EXC in _updateBots', e
for i in range(3):
for p in playerPts:
dists[i] += abs(p[0]-botSpawnPoints[i][0])
# little random variation
dists[i] += random.random() * 5.0
if dists[0] > dists[1] and dists[0] > dists[2]:
pt = botSpawnPoints[0]
elif dists[1] > dists[2]:
pt = botSpawnPoints[1]
else:
pt = botSpawnPoints[2]
pt = (pt[0]+3.0*(random.random()-0.5),
pt[1], 2.0*(random.random()-0.5)+pt[2])
# normalize our bot type total and find a random number within that
total = 0.0
for t in self._botSpawnTypes.items():
total += t[1][0]
r = random.random()*total
# now go back through and see where this value falls
total = 0
for t in self._botSpawnTypes.items():
total += t[1][0]
if r <= total:
spazType = t[0]
break
spawnTime = 1000
count = 1
while(count < random.randint(2,5)):
spazType = t[0]
spawnTime += 500
pt = (pt[0]+1.2*(random.random()-0.3),pt[1], 1.5*(random.random()-0.3)+pt[2])
self._bots.spawnBot(spazType, pos=pt, spawnTime=spawnTime)
count += 1
for t in self._botSpawnTypes.items():
total += t[1][0]
r = random.random()*total
# now go back through and see where this value falls
total = 0
for t in self._botSpawnTypes.items():
total += t[1][0]
if r <= total:
spazType = t[0]
break
# after every spawn we adjust our ratios slightly to get more
# difficult..
for t in self._botSpawnTypes.items():
t[1][0] += t[1][1] # increase spawn rate
t[1][1] += t[1][2] # increase spawn rate increase rate
def spawnPlayers(self, player):
pos = (
self._spawnCenter[0] + random.uniform(-1.5, 1.5),
self._spawnCenter[1],
self._spawnCenter[2] + random.uniform(-1.5, 1.5))
spaz = self.spawnPlayerSpaz(player, position=pos)
spaz.connectControlsToPlayer(enableBomb=False)
def end(self, outcome):
if outcome == 'defeat':
self.fadeToRed()
bs.screenMessage("游戏结束,您的分数将被除5后再结算.")
self.end(
delay=2000,
results={'outcome': outcome, 'score': self._score.get()/5,
'playerInfo': self.initialPlayerInfo})
#TheLastStandGame.onBegin = onbe;
bs.PirateBot.startCursed = False
bs.BomberBotProShielded.defaultBombType = 'ice'
bs.BomberBotPro.defaultBombType = 'tnt'
bs.BomberBot.defaultBombType = 'tnt'
TheLastStandGame._updateBots = _botup;
TheLastStandGame.spawnPlayer = spawnPlayers;
TheLastStandGame.doEnd = end;