]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator_riflearena.qc
Use a bad trick to allow nades only in mutators which disallow throwing
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_riflearena.qc
1 void ra_SetCvars()
2 {
3         cvar_settemp("g_balance_rifle_secondary_spread", ftos(cvar("g_riflearena_rifle_secondary_spread")));
4         cvar_settemp("g_balance_rifle_secondary_shots", ftos(cvar("g_riflearena_rifle_secondary_shots")));
5         cvar_settemp("g_balance_rifle_secondary_animtime", ftos(cvar("g_riflearena_rifle_secondary_animtime")));
6         cvar_settemp("g_balance_rifle_secondary_refire", ftos(cvar("g_riflearena_rifle_secondary_refire")));
7         cvar_settemp("g_balance_rifle_secondary_damage", ftos(cvar("g_riflearena_rifle_secondary_damage")));
8 }
9
10 MUTATOR_HOOKFUNCTION(ra_PlayerDamage)
11 {
12         if(IS_PLAYER(frag_attacker))
13         if(IS_PLAYER(frag_target))
14         {
15                 if (DEATH_ISWEAPON(frag_deathtype, WEP_LASER))
16                 {
17                         if(frag_attacker == frag_target)
18                                 frag_damage = 5;
19                         else
20                                 frag_damage = 0;
21                         if (frag_target != frag_attacker)
22                         {
23                                 if (frag_target.health >= 1 && IS_PLAYER(frag_target))
24                                         centerprint(frag_attacker, "Laser inflicts no damage!");
25                                 frag_force = '0 0 0';
26                         }
27                 }
28         }
29                 
30         return FALSE;
31 }
32
33 MUTATOR_HOOKFUNCTION(ra_PlayerSpawn)
34 {
35         WEPSET_CLEAR_E(self);
36         WEPSET_OR_EW(self, WEP_RIFLE);
37         WEPSET_OR_EW(self, WEP_LASER);
38         
39         return FALSE;
40 }
41
42 MUTATOR_HOOKFUNCTION(ra_FilterItem)
43 {
44         switch (self.items)
45         {
46                 case IT_5HP:
47                 case IT_ARMOR_SHARD:
48                         return FALSE;
49         }
50                 
51         return TRUE;
52 }
53
54 MUTATOR_HOOKFUNCTION(ra_StartItems)
55 {
56         start_items |= IT_UNLIMITED_AMMO;
57         start_ammo_nails = 100;
58         
59         g_grappling_hook = 0;
60
61         return FALSE;
62 }
63
64 MUTATOR_HOOKFUNCTION(ra_ForbidThrowCurrentWeapon)
65 {
66         nades_CheckThrow();
67         return TRUE;
68 }
69
70 MUTATOR_HOOKFUNCTION(ra_BuildMutatorsString)
71 {
72         ret_string = strcat(ret_string, ":RA");
73         return FALSE;
74 }
75
76 MUTATOR_HOOKFUNCTION(ra_BuildMutatorsPrettyString)
77 {
78         ret_string = strcat(ret_string, ", Rifle Arena");
79         return FALSE;
80 }
81
82 MUTATOR_HOOKFUNCTION(ra_SetModname)
83 {
84         modname = "Rifle Arena";
85         return TRUE;
86 }
87
88 MUTATOR_DEFINITION(mutator_riflearena)
89 {
90         MUTATOR_HOOK(PlayerDamage_Calculate, ra_PlayerDamage, CBC_ORDER_ANY);
91         MUTATOR_HOOK(PlayerSpawn, ra_PlayerSpawn, CBC_ORDER_ANY);
92         MUTATOR_HOOK(FilterItem, ra_FilterItem, CBC_ORDER_ANY);
93         MUTATOR_HOOK(SetStartItems, ra_StartItems, CBC_ORDER_ANY);
94         MUTATOR_HOOK(ForbidThrowCurrentWeapon, ra_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
95         MUTATOR_HOOK(BuildMutatorsString, ra_BuildMutatorsString, CBC_ORDER_ANY);
96         MUTATOR_HOOK(BuildMutatorsPrettyString, ra_BuildMutatorsPrettyString, CBC_ORDER_ANY);
97         
98         MUTATOR_ONADD
99         {
100                 ra_SetCvars();
101                 
102                 weapon_action(WEP_LASER, WR_PRECACHE);
103                 weapon_action(WEP_RIFLE, WR_PRECACHE);
104                 
105                 get_weaponinfo(WEP_HOOK).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
106         }
107         
108         MUTATOR_ONROLLBACK_OR_REMOVE
109         {
110                 get_weaponinfo(WEP_HOOK).spawnflags &~= WEP_FLAG_MUTATORBLOCKED;
111         }
112         
113         MUTATOR_ONREMOVE
114         {
115                 print("This cannot be removed at runtime\n");
116                 return -1;
117         }
118
119         return FALSE;
120 }