This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
iw4xsniper.gsc
249 lines (222 loc) · 4.87 KB
/
iw4xsniper.gsc
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
* _ __ ___ __ ____ _____
* | '_ ` _ \\ \/ /\ \ / / _ \
* | | | | | |> < \ V / __/
* |_| |_| |_/_/\_\ \_/ \___|
*
* _ _ _ _
* (_)_ _| || |__ __ ___ _ __ (_)_ __ ___ _ __
* | \ \ /\ / / || |\ \/ / / __| '_ \| | '_ \ / _ \ '__|
* | |\ V V /|__ _> < \__ \ | | | | |_) | __/ |
* |_| \_/\_/ |_|/_/\_\ |___/_| |_|_| .__/ \___|_|
* |_|
*
* Based on Sunbae's iw4xSniper
* https://github.com/eztso/iw4xSniper
*
*/
#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
/*
* init()
* Script entry point
*/
init()
{
level thread onPlayerConnect();
level thread hudLoop();
}
/*
* onPlayerConnect()
*
* Main Thread that starts a thread for each player once they are connected
*/
onPlayerConnect()
{
while (true)
{
level waittill("connected", player);
if(!isDefined(player.message_shown))
{
player.message_shown = 0;
}
if(!isDefined(player.cur_bright))
{
player.cur_bright = 0;
}
player thread onPlayerSpawned();
}
}
/*
* onPlayerSpawned()
*
* Player thread started by onPlayerConnect
* Alive until player disconnects
*/
onPlayerSpawned()
{
self endon("disconnect");
while (true)
{
self waittill("spawned_player");
self thread applyGameMode();
self thread ammoLoop();
}
}
/*
* restrictWeapons()
*
* Restrict weapons and offhand, replace if disallowed encountered
*/
restrictWeapons()
{
// Remove nades
self takeWeapon("frag_grenade_mp");
self takeWeapon("semtex_mp");
self takeWeapon("specialty_tacticalinsertion");
self takeWeapon("specialty_blastshield");
self takeWeapon("claymore_mp");
self takeWeapon("c4_mp");
self takeWeapon("flash_grenade_mp");
self takeWeapon("concussion_grenade_mp");
self takeWeapon("smoke_grenade_mp");
weapon = self getCurrentWeapon();
// Check for weapon attachments and allowed weapons
if (
weapon != self.secondaryWeapon &&
(
isSubStr(weapon, "thermal") ||
isSubStr(weapon, "heartbeat") ||
isSubStr(weapon, "acog") ||
isSubStr(weapon, "silencer") ||
isSubStr(weapon, "riotshield") ||
!(
isSubStr(weapon, "cheytac") ||
isSubStr(weapon, "m40a3") ||
isSubStr(weapon, "throwingknife")
)
)
)
{
self takeWeapon(weapon);
self giveWeapon("cheytac_mp");
// wait .1 second as switchToWeapon doesn't seem to work when called directly after giveWeapon
wait(.1);
self switchToWeapon("cheytac_mp");
// Give Sleight of Hand Pro
self maps\mp\perks\_perks::givePerk("specialty_fastreload");
self maps\mp\perks\_perks::givePerk("specialty_quickdraw");
}
}
/*
* takeAmmo(slot)
* slot (string):
* primary
* secondary
*/
takeAmmo(slot)
{
if (slot == "primary")
{
self setWeaponAmmoClip(self.primaryWeapon, 0);
self setWeaponAmmoStock(self.primaryWeapon, 0);
}
else if (slot == "secondary")
{
// Check for akimbo and take ammo of both akimbo weapons if encountered
if (isSubstr(self.secondaryWeapon, "akimbo"))
{
self setWeaponAmmoClip(self.secondaryWeapon, 0, "left");
self setWeaponAmmoClip(self.secondaryWeapon, 0, "right");
} else {
self setWeaponAmmoClip(self.secondaryWeapon, 0);
}
self setWeaponAmmoStock(self.secondaryWeapon, 0);
}
}
/*
* dvars()
*
* Set required dvars
*/
dvars()
{
/*
* Disable melee
* WONTFIX:
* Can't break windows with knife
* Fixing this would require hooking into the damage function and
* settings damage on player hit to 0 for the knife
*/
setDvar("player_meleeRange", 0);
/*
* /weather clear
* r_fog
* removes main dust on rust
* fx_enable
* removes particles etc
* also fixed black boxes with fullbright on mp_nuked
* additonally this seems to change the kill points color to gray?
*/
self setClientDvar("r_fog", 0);
self setClientDvar("fx_enable", 0);
}
/*
* applyGameMode()
*
* Apply game mode on player spawn
* Restrict weapons during class selection grace period
*/
applyGameMode()
{
self dvars();
for (count=0;count<15;count++)
{
self restrictWeapons();
self takeAmmo("secondary");
wait(3);
}
}
/*
* ammoLoop()
*
* Restock ammo on shot fired
* Excluding secondary weapon
*/
ammoLoop()
{
while (true)
{
self waittill("weapon_fired");
ammoWeapon = self getCurrentWeapon();
if (ammoWeapon != self.secondaryWeapon)
{
self giveMaxAmmo(ammoWeapon);
}
}
}
/*
* hudLoop()
*
* Draw watermark and cycle text
*/
hudLoop()
{
info = level createServerFontString("objective", 0.95);
info setPoint("CENTER", "BOTTOM", 0, -10);
info.glowalpha = .6;
info.hideWhenInMenu = true;
while (true)
{
info.glowcolor = ( .7, .3, 1 );
info setText("mxve's Sniper Rotation");
wait 20;
info.glowcolor = ( 0, 1, 0 );
info setText("iw4x.mxve.de");
wait 14;
info.glowcolor = ( 1, 0, 0 );
info setText("github.com/mxve/iw4x-sniper");
wait 8;
}
}