-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOfflineCrowdControl.py
170 lines (125 loc) · 4.76 KB
/
OfflineCrowdControl.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
# Can't use real Crowd Control? Get a taste of the experience with this!
import socket
import time
import random
def genMsg(code,param):
msg = '{"id":1,"viewer":"Python","code":"'+code+'","type":1'
if param:
msg+=',"parameters":['
paramstr = ""
for p in param:
print(p)
if isinstance(p,int):
paramstr+=str(p)
elif isinstance(p,str):
paramstr+='"'+p+'"'
paramstr+=","
paramstr = paramstr[:-1]
print(paramstr)
msg+=paramstr
msg+=']'
msg+=',"duration":'
msg+= str(random.randint(10,80)*1000)
msg+='}\0'
return msg
def randomAmmo():
ammo = []
ammo.append('FlakAmmo') #Flak Cannon
ammo.append('BioAmmo') #Bio Rifle
ammo.append('WarHeadAmmo') #Redeemer
ammo.append('PAmmo') #Pulse Gun
ammo.append('ShockCore') #Shock Rifle
ammo.append('BladeHopper') #Ripper
ammo.append('RocketPack') #Rocket
ammo.append('BulletBox') #Sniper
ammo.append('MiniAmmo') #Enforcer and minigun both use these???
return random.choice(ammo).lower()
def randomWeapon():
weapon = []
weapon.append('Translocator')
weapon.append('Ripper')
weapon.append('WarHeadLauncher')
weapon.append('BioRifle')
weapon.append('FlakCannon')
weapon.append('SniperRifle')
weapon.append('ShockRifle')
weapon.append('PulseGun')
weapon.append('MiniGun')
weapon.append('SuperShockRifle')
weapon.append('RocketLauncher')
return random.choice(weapon).lower()
def pickEffect():
effects = []
#return ("force_weapon_use",[randomWeapon()]) #For testing a specific effect
#return ("spawn_a_bot_attack",None) #For testing a specific effect
#effects.append(("last_place_shield",None))
#effects.append(("last_place_bonus_dmg",None))
#effects.append(("first_place_slow",None))
#return random.choice(effects) #For testing a small selection of effects
effects.append(None)
effects.append(None)
effects.append(None)
effects.append(("sudden_death",None))
effects.append(("full_heal",None))
effects.append(("full_heal",None))
effects.append(("drop_selected_item",None))
effects.append(("give_health",[str(random.randint(10,100))]))
effects.append(("give_health",[str(random.randint(10,100))]))
effects.append(("give_health",[str(random.randint(10,100))]))
effects.append(("full_armour",None))
#effects.append(("disable_jump",None))
effects.append(("gotta_go_fast",None))
effects.append(("gotta_go_slow",None))
effects.append(("ice_physics",None))
effects.append(("third_person",None))
effects.append(("bonus_dmg",None))
effects.append(("thanos",None))
effects.append(("full_fat",None))
effects.append(("skin_and_bones",None))
effects.append(("no_ammo",None))
effects.append(("give_weapon",[randomWeapon()]))
effects.append(("force_weapon_use",[randomWeapon()]))
effects.append(("give_ammo",[randomAmmo(),str(random.randint(1,3))]))
effects.append(("nudge",None))
effects.append(("swap_player_position",None))
effects.append(("low_grav",None))
effects.append(("flood",None))
effects.append(("melee_only",None))
effects.append(("last_place_shield",None))
effects.append(("last_place_bonus_dmg",None))
effects.append(("blue_redeemer_shell",None))
effects.append(("first_place_slow",None))
effects.append(("vampire_mode",None))
effects.append(("spawn_a_bot_attack",None))
effects.append(("spawn_a_bot_defend",None))
effects.append(("give_ammo",[randomAmmo(),random.randint(1,2)]))
effects.append(("reset_domination_control_points",None))
effects.append(("reset_domination_control_points",None))
effects.append(("return_ctf_flags",None))
effects.append(("return_ctf_flags",None))
effects.append(("thorns",None))
effects.append(("jump_boot_madness",None))
effects.append(("massive_momentum",None))
effects.append(("bouncy_castle",None))
effects.append(("red_light_green_light",None))
effects.append(("random_weapon_swap",None))
return random.choice(effects)
s=socket.create_server(("localhost",43384))
while True:
print("Connecting...")
conn,addr = s.accept()
with conn:
print("Connected to ",addr)
while True:
#conn.send(x)
time.sleep(random.randint(5,10))
effect = pickEffect()
if effect!=None:
msg = genMsg(effect[0],effect[1])
print("Sending "+msg)
try:
conn.send(msg.encode('utf-8'))
except:
break
print("Sent")
#time.sleep(random.randint(60,75))