summaryrefslogtreecommitdiff
path: root/mods/perks/perkaholic.gsc
blob: 13434764dfcd047bc4914eba30df807f1f8604ff (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
#include common_scripts/utility;
#include maps/mp/zombies/_zm_utility;
#include maps/mp/zombies/_zm_perks;

init()
{
	level thread onPlayerConnect();
}

onPlayerConnect()
{
	while(1)
	{
		level waittill("connected", player);
		player thread onPlayerSpawned();
	}
}

onPlayerSpawned()
{
	self endon("disconnect");
	level endon("game_ended");
	while(1)
	{
		self waittill("spawned_player");

		// Waits for the black preload screen to pass so it can load the mods
		flag_wait( "initial_blackscreen_passed" );

		// Gives all the perks available in the map to the player
		perkaholic(self, level);
	}
}

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

/*
 * Displays animation while giving perk
 */
doGivePerk(perk)
{
	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");
	}
}