-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWarpModule.py
More file actions
163 lines (133 loc) · 6.57 KB
/
WarpModule.py
File metadata and controls
163 lines (133 loc) · 6.57 KB
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
#
# Updated by darkdiplomat
#
# NOTE: REQUIRES COMPATIBLE MAPS TO WORK PROPERLY
#
from . import GEScenario
from .Utils.GEPlayerTracker import GEPlayerTracker
import random
import GEEntity, GEPlayer, GEUtil, GEWeapon, GEMPGameRules, GEGlobal
USING_API = GEGlobal.API_VERSION_1_2_0
class WarpModule(GEScenario):
warpDelay = "DelayForWarp"
charged = "MeterFull"
energy = "MeterPoints"
def __init__(self):
super(WarpModule, self).__init__()
self.pltracker = GEPlayerTracker(self)
def Cleanup(self):
super(WarpModule, self).Cleanup()
self.pltracker = None
def GetPrintName(self):
return "Warp Module"
def GetScenarioHelp(self, help_obj):
help_obj.SetDescription("Press G to travel through dimensions! Occasionally you get stuck, get over it.")
def GetGameDescription(self):
if GEMPGameRules.IsTeamplay():
return "Team Warp Module"
else:
return "Warp Module"
def GetTeamPlay(self):
return GEGlobal.TEAMPLAY_TOGGLE
def OnLoadGamePlay(self):
GEMPGameRules.SetAllowTeamSpawns(False)
self.CreateCVar("wm_teledelay", "12", "Maximum power, in seconds, of the teleport module.")
self.CreateCVar("wm_telecost", "7", "Cost, in seconds, of each teleport.")
GEUtil.PrecacheSound("GEGamePlay.Token_Chime")
GEUtil.PrecacheSound("Buttons.beep_denied")
GEUtil.PrecacheSound("GEGamePlay.Token_Knock")
def OnCVarChanged(self, name, oldvalue, newvalue):
if name == "wm_teledelay":
for i in range(32):
if GEPlayer.IsValidPlayerIndex(i):
player = GEPlayer.GetMPPlayer(i)
GEUtil.RemoveHudProgressBar(player, 0)
GEUtil.InitHudProgressBar(player, 0, "Warp", GEGlobal.HUDPB_SHOWBAR,
int(GEUtil.GetCVarValue("wm_teledelay")), -1, .76, 100, 10,
GEUtil.CColor(220, 220, 220, 220))
GEUtil.UpdateHudProgressBar(player, 0, int(GEUtil.GetCVarValue("wm_teledelay")))
def OnRoundBegin(self):
for i in range(32):
if GEPlayer.IsValidPlayerIndex(i):
player = GEPlayer.GetMPPlayer(i)
GEUtil.RemoveHudProgressBar(player, 0)
GEUtil.InitHudProgressBar(player, 0, "Warp", GEGlobal.HUDPB_SHOWBAR,
int(GEUtil.GetCVarValue("wm_teledelay")), -1, .76, 100, 10,
GEUtil.CColor(220, 220, 220, 220))
self.pltracker.SetValue(player, self.charged, True)
GEUtil.UpdateHudProgressBar(player, 0, int(GEUtil.GetCVarValue("wm_teledelay")))
GEMPGameRules.ResetAllPlayerDeaths()
GEMPGameRules.ResetAllPlayersScores()
def OnPlayerSpawn(self, player):
if player.IsInitialSpawn():
GEUtil.InitHudProgressBar(player, 0, "Warp", GEGlobal.HUDPB_SHOWBAR,
int(GEUtil.GetCVarValue("wm_teledelay")), -1, .76, 100, 10,
GEUtil.CColor(220, 220, 220, 220))
self.pltracker.SetValue(player, self.charged, True)
self.pltracker.SetValue(player, self.warpDelay, 0)
self.pltracker.SetValue(player, self.energy, int(GEUtil.GetCVarValue("wm_teledelay")))
GEUtil.UpdateHudProgressBar(player, 0, int(GEUtil.GetCVarValue("wm_teledelay")))
markSpawn = random.randint(0, 1)
if markSpawn == 1:
player.SetTargetName("Mark1")
else:
player.SetTargetName("Mark2")
def OnPlayerSay(self, player, text):
if text == "!voodoo":
if self.checkenergy(player):
curname = player.GetTargetName()
GEUtil.PlaySoundToPlayer(player, "GEGamePlay.Token_Knock")
self.setwarpdelay(player)
if curname == "Mark1":
player.SetTargetName("Mark2")
else:
player.SetTargetName("Mark1")
else:
GEUtil.PlaySoundToPlayer(player, "Buttons.beep_denied")
return True
def OnThink(self):
maxpower = int(GEUtil.GetCVarValue("wm_teledelay"))
warpcost = int(GEUtil.GetCVarValue("wm_telecost"))
time = int(GEUtil.GetTime())
for i in range(32):
if GEPlayer.IsValidPlayerIndex(i):
player = GEPlayer.GetMPPlayer(i)
if not player.IsDead():
warpdelay = int(self.pltracker.GetValue(player, self.warpDelay))
warpenergy = self.calcenergy(player)
if warpenergy <= maxpower:
if not self.pltracker.GetValue(player, self.charged):
if warpcost <= warpenergy:
GEUtil.PlaySoundToPlayer(player, "GEGamePlay.Token_Chime")
self.pltracker.SetValue(player, self.charged, True)
else:
GEUtil.UpdateHudProgressBar(player, 0, warpenergy)
else:
GEUtil.UpdateHudProgressBar(player, 0, warpenergy)
#########################################
def setwarpdelay(self, player):
maxpower = int(GEUtil.GetCVarValue("wm_teledelay"))
warpcost = int(GEUtil.GetCVarValue("wm_telecost"))
warpenergy = int(self.pltracker.GetValue(player, self.energy)) - warpcost
self.pltracker.SetValue(player, self.energy, warpenergy)
GEUtil.UpdateHudProgressBar(player, 0, warpenergy)
self.pltracker.SetValue(player, self.warpDelay,
GEUtil.GetTime() + (int(GEUtil.GetCVarValue("wm_teledelay")) - warpenergy))
self.checkenergy(player)
return
def checkenergy(self, player):
warpcost = int(GEUtil.GetCVarValue("wm_telecost"))
warpenergy = int(self.pltracker.GetValue(player, self.energy))
if warpenergy < warpcost:
self.pltracker.SetValue(player, self.charged, False)
return False
else:
self.pltracker.SetValue(player, self.charged, True)
return True
def calcenergy(self, player):
warpenergy = int(GEUtil.GetCVarValue("wm_teledelay")) - (
int(self.pltracker.GetValue(player, self.warpDelay)) - int(GEUtil.GetTime()))
if warpenergy > int(GEUtil.GetCVarValue("wm_teledelay")):
warpenergy = int(GEUtil.GetCVarValue("wm_teledelay"))
self.pltracker.SetValue(player, self.energy, warpenergy)
return warpenergy