summaryrefslogtreecommitdiff
path: root/modLoader/mods.gsc
blob: f6f8b58fd73f3d8e3fe930f84697948f9f7dfe97 (plain)
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
/*
 * Function that update zombie perk limit
 */
setPerkLimit(l, numberOfPerks)
{
	l.perk_purchase_limit = numberOfPerks;
}

/*
 * Function that draws a zombie counter
 */
zombieCounter(p, l, x, y)
{
	p.zombiecounter = drawCounter(p.zombiecounter, x, y, "Objective", 1.7);

	while(1)
	{
		p.zombiecounter.alpha = checkAfterlife(p);

		zombies = l.zombie_total + get_current_zombie_count();
		if ( zombies > 0 )
		{
			p.zombiecounter.label = &"Zombies: ^1";
		}
		else
		{
			p.zombiecounter.label = &"Zombies: ^6";
		}

		p.zombiecounter setvalue(zombies);
		wait 0.05;
	}
}

/*
 * Function that draws a health counter
 */
healthCounter(p, x, y)
{
	p.healthcounter = drawCounter(p.healthcounter, x, y, "Objective", 1.7);

	while(1)
	{
		p.healthcounter.alpha = checkAfterlife(p);

		// Setting Counter Colors
		health = p.health;
		if( health <= 15 )
		{
			p.healthcounter.label = &"Health: ^1";
		}
		else if ( health <= 50 )
		{
			p.healthcounter.label = &"Health: ^3";
		}
		else
		{
			p.healthcounter.label = &"Health: ^2";
		}

		p.healthcounter setValue(health);
		wait 0.05;
	}
}

/*
 * Function that activates solo tombstone perk
 */
activateTombstone(l)
{
	if (isDefined(l.zombiemode_using_tombstone_perk) && l.zombiemode_using_tombstone_perk)
	{
		l thread perk_machine_spawn_init();
		thread solo_tombstone_removal();
		thread turn_tombstone_on();
	}
}

/*
 * Function that activates all the perks to the player at the beginning of the first round
 */
perkaholic(p, l, animation)
{
	if (l.round_number == 1)
	{
		l waittill("start_of_round");
		giveAllPerks(p, l, animation);
	}
}

/*
 * Function that sets a custom box price
 */
setBoxPrice(l, price)
{
	for (i = 0; i < l.chests.size; i++)
	{
		level.chests[ i ].zombie_cost = price;
		level.chests[ i ].old_cost = price;
	}
}

/*
 * Function that sets the player initial points
 */
setPlayerPoints(p, points)
{
	p.score = points;
}

/*
 * Function that sets the player initial count of afterlife lives
 */
catHas9Lifes(p, lifes)
{
	if(isDefined(p.afterlife))
	{
		p.lives = lifes;
	}
}

/*
 * Function that sets the player camera to third person
 */
playThirdPerson(p, crosshair)
{
	p setClientThirdPerson(1);
	
	if (crosshair)
	{
		thread useCrosshairs(p);
	}
}

/*
 * Function that toggles god mode on
 */
godMode(p)
{
	p enableInvulnerability();
}

/*
 * Function that toggles unlimited ammo on
 */
unlimitedAmmo(p)
{
	for(;;)
	{
		wait 0.05;
		
		currentWeapon = p getcurrentweapon();
		if ( currentWeapon != "none" )
		{
			p setweaponammoclip( currentWeapon, weaponclipsize(currentWeapon) );
			p givemaxammo( currentWeapon );
		}

		currentoffhand = p getcurrentoffhand();
		if ( currentoffhand != "none" )
			p givemaxammo( currentoffhand );
    }
}

// Aux Functions
/*
 * Draws the counter in desired position
 */
drawCounter(counterVar, x, y, font, size)
{
	counterVar = createfontstring( font, size );
	counterVar setpoint( "CENTER", "CENTER", x, y);
	counterVar.alpha = 1;
	counterVar.hidewheninmenu = 1;
	counterVar.hidewhendead = 1;
	return counterVar;
}

/*
 * Checks if the player has entered afterlife
 */
checkAfterlife(p)
{
	if(isdefined(p.afterlife) && p.afterlife)
	{
		return 0.2;
	}
	return 1;
}

/*
 * Initializes perk machine spawn and location
 */
perk_machine_spawn_init()
{
	match_string = "";
	location = level.scr_zm_map_start_location;
	if ( location != "default" && location == "" && isDefined( level.default_start_location ) )
	{
		location = level.default_start_location;
	}
	match_string = ( level.scr_zm_ui_gametype + "_perks_" ) + location;
	pos = [];
	if ( isDefined( level.override_perk_targetname ) )
	{
		structs = getstructarray( level.override_perk_targetname, "targetname" );
	}
	else
	{
		structs = getstructarray( "zm_perk_machine", "targetname" );
	}
	_a3578 = structs;
	_k3578 = getFirstArrayKey( _a3578 );
	while ( isDefined( _k3578 ) )
	{
		struct = _a3578[ _k3578 ];
		if ( isDefined( struct.script_string ) )
		{
			tokens = strtok( struct.script_string, " " );
			_a3583 = tokens;
			_k3583 = getFirstArrayKey( _a3583 );
			while ( isDefined( _k3583 ) )
			{
				token = _a3583[ _k3583 ];
				if ( token == match_string )
				{
					pos[ pos.size ] = struct;
				}
				_k3583 = getNextArrayKey( _a3583, _k3583 );
			}
		}
		else pos[ pos.size ] = struct;
		_k3578 = getNextArrayKey( _a3578, _k3578 );
	}
	if ( !isDefined( pos ) || pos.size == 0 )
	{
		return;
	}
	precachemodel( "zm_collision_perks1" );
	i = 0;
	while ( i < pos.size )
	{
		perk = pos[ i ].script_noteworthy;
		if ( isDefined( perk ) && isDefined( pos[ i ].model ) )
		{
			use_trigger = spawn( "trigger_radius_use", pos[ i ].origin + vectorScale( ( 0, -1, 0 ), 30 ), 0, 40, 70 );
			use_trigger.targetname = "zombie_vending";
			use_trigger.script_noteworthy = perk;
			use_trigger triggerignoreteam();
			perk_machine = spawn( "script_model", pos[ i ].origin );
			perk_machine.angles = pos[ i ].angles;
			perk_machine setmodel( pos[ i ].model );
			if ( isDefined( level._no_vending_machine_bump_trigs ) && level._no_vending_machine_bump_trigs )
			{
				bump_trigger = undefined;
			}
			else
			{
				bump_trigger = spawn( "trigger_radius", pos[ i ].origin, 0, 35, 64 );
				bump_trigger.script_activated = 1;
				bump_trigger.script_sound = "zmb_perks_bump_bottle";
				bump_trigger.targetname = "audio_bump_trigger";
				if ( perk != "specialty_weapupgrade" )
				{
					bump_trigger thread thread_bump_trigger();
				}
			}
			collision = spawn( "script_model", pos[ i ].origin, 1 );
			collision.angles = pos[ i ].angles;
			collision setmodel( "zm_collision_perks1" );
			collision.script_noteworthy = "clip";
			collision disconnectpaths();
			use_trigger.clip = collision;
			use_trigger.machine = perk_machine;
			use_trigger.bump = bump_trigger;
			if ( isDefined( pos[ i ].blocker_model ) )
			{
				use_trigger.blocker_model = pos[ i ].blocker_model;
			}
			if ( isDefined( pos[ i ].script_int ) )
			{
				perk_machine.script_int = pos[ i ].script_int;
			}
			if ( isDefined( pos[ i ].turn_on_notify ) )
			{
				perk_machine.turn_on_notify = pos[ i ].turn_on_notify;
			}
			if ( perk == "specialty_scavenger" || perk == "specialty_scavenger_upgrade" )
			{
				use_trigger.script_sound = "mus_perks_tombstone_jingle";
				use_trigger.script_string = "tombstone_perk";
				use_trigger.script_label = "mus_perks_tombstone_sting";
				use_trigger.target = "vending_tombstone";
				perk_machine.script_string = "tombstone_perk";
				perk_machine.targetname = "vending_tombstone";
				if ( isDefined( bump_trigger ) )
				{
					bump_trigger.script_string = "tombstone_perk";
				}
			}
			if ( isDefined( level._custom_perks[ perk ] ) && isDefined( level._custom_perks[ perk ].perk_machine_set_kvps ) )
			{
				[[ level._custom_perks[ perk ].perk_machine_set_kvps ]]( use_trigger, perk_machine, bump_trigger, collision );
			}
		}
		i++;
	}
}

/*
 * Allows notifies of solo tombstone
 */
solo_tombstone_removal()
{
	notify( "tombstone_on" );
}

/*
 * Turns tombstone on
 */
turn_tombstone_on()
{
	while ( 1 )
	{
		machine = getentarray( "vending_tombstone", "targetname" );
		machine_triggers = getentarray( "vending_tombstone", "target" );
		i = 0;
		while ( i < machine.size )
		{
			machine[ i ] setmodel( level.machine_assets[ "tombstone" ].off_model );
			i++;
		}
		level thread do_initial_power_off_callback( machine, "tombstone" );
		array_thread( machine_triggers, ::set_power_on, 0 );
		level waittill( "tombstone_on" );
		i = 0;
		while ( i < machine.size )
		{
			machine[ i ] setmodel( level.machine_assets[ "tombstone" ].on_model );
			machine[ i ] vibrate( vectorScale( ( 0, -1, 0 ), 100 ), 0,3, 0,4, 3 );
			machine[ i ] playsound( "zmb_perks_power_on" );
			machine[ i ] thread perk_fx( "tombstone_light" );
			machine[ i ] thread play_loop_on_machine();
			i++;
		}
		level notify( "specialty_scavenger_power_on" );
		array_thread( machine_triggers, ::set_power_on, 1 );
		if ( isDefined( level.machine_assets[ "tombstone" ].power_on_callback ) )
		{
			array_thread( machine, level.machine_assets[ "tombstone" ].power_on_callback );
		}
		level waittill( "tombstone_off" );
		if ( isDefined( level.machine_assets[ "tombstone" ].power_off_callback ) )
		{
			array_thread( machine, level.machine_assets[ "tombstone" ].power_off_callback );
		}
		array_thread( machine, ::turn_perk_off );
		players = get_players();
		_a1718 = players;
		_k1718 = getFirstArrayKey( _a1718 );
		while ( isDefined( _k1718 ) )
		{
			player = _a1718[ _k1718 ];
			player.hasperkspecialtytombstone = undefined;
			_k1718 = getNextArrayKey( _a1718, _k1718 );
		}
	}
}

/*
 * Function that gives the player all the perks if they are available in the current map
 */
giveAllPerks(p, l, animation)
{
    if (isDefined(l.zombiemode_using_juggernaut_perk) && l.zombiemode_using_juggernaut_perk)
         p doGivePerk("specialty_armorvest", animation);
    if (isDefined(l._custom_perks) && isDefined(l._custom_perks["specialty_nomotionsensor"]))
        p doGivePerk("specialty_nomotionsensor", animation);
    if (isDefined(l.zombiemode_using_doubletap_perk) && l.zombiemode_using_doubletap_perk) 
         p doGivePerk("specialty_rof", animation);
    if (isDefined(l.zombiemode_using_marathon_perk) && l.zombiemode_using_marathon_perk)
        p doGivePerk("specialty_longersprint", animation);
    if (isDefined(l.zombiemode_using_sleightofhand_perk) && l.zombiemode_using_sleightofhand_perk)
        p doGivePerk("specialty_fastreload", animation);
    if(isDefined(l.zombiemode_using_additionalprimaryweapon_perk) && l.zombiemode_using_additionalprimaryweapon_perk)
        p doGivePerk("specialty_additionalprimaryweapon", animation);
    if (isDefined(l.zombiemode_using_revive_perk) && l.zombiemode_using_revive_perk)
       p doGivePerk("specialty_quickrevive", animation);
    if (isDefined(l.zombiemode_using_chugabud_perk) && l.zombiemode_using_chugabud_perk)
        p doGivePerk("specialty_finalstand", animation);
    if (isDefined(l._custom_perks) && isDefined(l._custom_perks["specialty_grenadepulldeath"]))
        p doGivePerk("specialty_grenadepulldeath", animation);
    if (isDefined(l._custom_perks) && isDefined(l._custom_perks["specialty_flakjacket"]) && (l.script != "zm_buried"))
        p doGivePerk("specialty_flakjacket", animation);
    if (isDefined(l.zombiemode_using_deadshot_perk) && l.zombiemode_using_deadshot_perk)
        p doGivePerk("specialty_deadshot", animation);
    if (isDefined(l.zombiemode_using_tombstone_perk) && l.zombiemode_using_tombstone_perk)
        p doGivePerk("specialty_scavenger", animation);
}

/*
 * Displays animation while giving perk
 */
doGivePerk(perk, animation)
{
	if ( animation )
	{
		self endon("perk_abort_drinking");
		if (!(self hasperk(perk) || (self maps/mp/zombies/_zm_perks::has_perk_paused(perk))))
		{
		    gun = self maps/mp/zombies/_zm_perks::perk_give_bottle_begin(perk);
		    evt = self waittill_any_return("fake_death", "death", "player_downed", "weapon_change_complete");
		    if (evt == "weapon_change_complete")
		        self thread maps/mp/zombies/_zm_perks::wait_give_perk(perk, 1);
		    self maps/mp/zombies/_zm_perks::perk_give_bottle_end(gun, perk);
		    if (self maps/mp/zombies/_zm_laststand::player_is_in_laststand() || isDefined(self.intermission) && self.intermission)
		        return;
		    self notify("burp");
		}
    }
    else
    {
    	give_perk(perk);
    }
}

/*
 * Displays crosshair for third person
 */
useCrosshairs(p)
{
	p.dot = drawCounter(p.dot, 0, 0, "default", 1.7);
	p.dot.label = &"+";
}