]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
Mutators dialog: fix "No start weapons" checkbox enabling all weapons and "Regular...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_create_mutators.qc
1 #include "dialog_multiplayer_create_mutators.qh"
2 #include <common/weapons/_all.qh>
3
4 #include "weaponarenacheckbox.qh"
5 #include "checkbox.qh"
6 #include "slider.qh"
7 #include "textlabel.qh"
8 #include "checkbox_slider_invalid.qh"
9 #include "radiobutton.qh"
10 #include "button.qh"
11
12 void XonoticMutatorsDialog_showNotify(entity me)
13 {
14         SUPER(XonoticMutatorsDialog).showNotify(me);
15         loadAllCvars(me);
16 }
17
18 string weaponarenastring;
19 string weaponarenastring_cvar;
20 string WeaponArenaString()
21 {
22         string s;
23         float n, i;
24         s = cvar_string("g_weaponarena");
25         if(s == "0")
26                 return "";
27         if(s == "all" || s == "1")
28                 return _("All Weapons Arena");
29         if(s == "most")
30                 return _("Most Weapons Arena");
31         if(s == weaponarenastring_cvar)
32                 return weaponarenastring;
33         if(weaponarenastring)
34                 strunzone(weaponarenastring);
35         if(weaponarenastring_cvar)
36                 strunzone(weaponarenastring_cvar);
37
38         weaponarenastring_cvar = strzone(s);
39
40         n = tokenize_console(s);
41         s = "";
42         for(i = 0; i < n; ++i)
43         {
44                 FOREACH(Weapons, it != WEP_Null, LAMBDA(
45                         if(argv(i) == it.netname)
46                                 s = strcat(s, " & ", it.m_name);
47                 ));
48         }
49         s = sprintf(_("%s Arena"), substring(s, 3, strlen(s) - 3));
50
51         weaponarenastring = strzone(s);
52
53         return weaponarenastring;
54 }
55
56 string XonoticMutatorsDialog_toString(entity me)
57 {
58         string s;
59         s = "";
60         if(cvar("g_dodging"))
61                 s = strcat(s, ", ", _("Dodging"));
62         if(cvar("g_instagib"))
63                 s = strcat(s, ", ", _("InstaGib"));
64         if(cvar("g_new_toys"))
65                 s = strcat(s, ", ", _("New Toys"));
66         if(cvar("g_nix"))
67                 s = strcat(s, ", ", _("NIX"));
68         if(cvar("g_rocket_flying"))
69                 s = strcat(s, ", ", _("Rocket Flying"));
70         if(cvar("g_invincible_projectiles"))
71                 s = strcat(s, ", ", _("Invincible Projectiles"));
72         if(cvar_string("g_weaponarena") != "0")
73                 s = strcat(s, ", ", WeaponArenaString());
74         else if(cvar("g_balance_blaster_weaponstartoverride") == 0)
75                 s = strcat(s, ", ", _("No start weapons"));
76         if(cvar("sv_gravity") < stof(cvar_defstring("sv_gravity")))
77                 s = strcat(s, ", ", _("Low gravity"));
78         if(cvar("g_cloaked"))
79                 s = strcat(s, ", ", _("Cloaked"));
80         if(cvar("g_grappling_hook"))
81                 s = strcat(s, ", ", _("Hook"));
82         if(cvar("g_midair"))
83                 s = strcat(s, ", ", _("Midair"));
84         if(cvar("g_vampire"))
85                 s = strcat(s, ", ", _("Vampire"));
86         if(cvar("g_pinata"))
87                 s = strcat(s, ", ", _("Piñata"));
88         if(cvar("g_weapon_stay"))
89                 s = strcat(s, ", ", _("Weapons stay"));
90         if(cvar("g_bloodloss") > 0)
91                 s = strcat(s, ", ", _("Blood loss"));
92         if(cvar("g_jetpack"))
93                 s = strcat(s, ", ", _("Jet pack"));
94         if(cvar("g_buffs"))
95                 s = strcat(s, ", ", _("Buffs"));
96         if(cvar("g_overkill"))
97                 s = strcat(s, ", ", _("Overkill"));
98         if(cvar("g_powerups") == 0)
99                 s = strcat(s, ", ", _("No powerups"));
100         if(cvar("g_powerups") > 0)
101                 s = strcat(s, ", ", _("Powerups"));
102         if(cvar("g_touchexplode") > 0)
103                 s = strcat(s, ", ", _("Touch explode"));
104         if(s == "")
105                 return ZCTX(_("MUT^None"));
106         else
107                 return substring(s, 2, strlen(s) - 2);
108 }
109
110 float checkCompatibility_pinata(entity me)
111 {
112         if(cvar("g_instagib"))
113                 return 0;
114         if(cvar("g_nix"))
115                 return 0;
116         if(cvar_string("g_weaponarena") != "0")
117                 return 0;
118         return 1;
119 }
120 float checkCompatibility_weaponstay(entity me)
121 {
122         return checkCompatibility_pinata(me);
123 }
124 float checkCompatibility_newtoys(entity me)
125 {
126         if(cvar("g_instagib"))
127                 return 0;
128         if(cvar_string("g_weaponarena") == "most")
129                 return 1;
130         if(cvar_string("g_weaponarena") == "all" || cvar_string("g_weaponarena") == "1")
131                 return 1;
132         if(cvar_string("g_weaponarena") != "0")
133                 return 0;
134         return 1;
135 }
136 float checkCompatibility_weaponarena_weapon(entity me)
137 {
138         if(cvar("g_instagib"))
139                 return 0;
140         if(cvar_string("g_weaponarena") == "most")
141                 return 0;
142         if(cvar_string("g_weaponarena") == "all" || cvar_string("g_weaponarena") == "1")
143                 return 0;
144         if(cvar_string("g_weaponarena") == "0")
145                 return 0;
146         if(cvar_string("g_balance_blaster_weaponstartoverride") == "0")
147                 return 0;
148         return 1;
149 }
150
151 void XonoticMutatorsDialog_fill(entity me)
152 {
153         entity e, s, w;
154         float i, j;
155         me.TR(me);
156                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Gameplay mutators:")));
157         me.TR(me);
158                 me.TDempty(me, 0.2);
159                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_dodging", _("Dodging"),
160                         _("Enable dodging")));
161         me.TR(me);
162                 me.TDempty(me, 0.2);
163                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_touchexplode", _("Touch explode")));
164         me.TR(me);
165                 me.TDempty(me, 0.2);
166                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_cloaked", _("Cloaked"),
167                         _("All players are almost invisible")));
168         me.TR(me);
169                 me.TDempty(me, 0.2);
170                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_buffs", _("Buffs")));
171         me.TR(me);
172                 me.TDempty(me, 0.2);
173                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_midair", _("Midair"),
174                         _("Only possible to inflict damage on your enemy while he's airborne")));
175         me.TR(me);
176                 me.TDempty(me, 0.2);
177                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_vampire", _("Vampire"),
178                         _("Damage done to your enemy gets added to your own health")));
179                         setDependent(e, "g_instagib", 0, 0);
180         me.TR(me);
181                 me.TDempty(me, 0.2);
182                 s = makeXonoticSlider_T(10, 50, 1, "g_bloodloss",
183                         _("Amount of health below which your player gets stunned because of blood loss"));
184                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(0, 1, s, _("Blood loss")));
185                         setDependent(e, "g_instagib", 0, 0);
186         me.TR(me);
187                 me.TDempty(me, 0.4);
188                 me.TD(me, 1, 1.6, s);
189         me.TR(me);
190                 me.TDempty(me, 0.2);
191                 s = makeXonoticSlider_T(80, 400, 8, "sv_gravity",
192                         _("Make things fall to the ground slower, lower value means lower gravity"));
193                         s.valueDigits = 0;
194                         s.valueDisplayMultiplier = 0.125; // show gravity in percent
195                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(800, 1, s, _("Low gravity")));
196                         e.savedValue = 200; // good on silvercity
197         me.TR(me);
198                 me.TDempty(me, 0.4);
199                 me.TD(me, 1, 1.6, s);
200         me.TR(me);
201                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Weapon & item mutators:")));
202         me.TR(me);
203                 me.TDempty(me, 0.2);
204                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_grappling_hook", _("Grappling hook"),
205                         _("Players spawn with the grappling hook")));
206         me.TR(me);
207                 me.TDempty(me, 0.2);
208                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_jetpack", _("Jet pack"),
209                         _("Players spawn with the jetpack")));
210         me.TR(me);
211                 me.TDempty(me, 0.2);
212                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_invincible_projectiles", _("Invincible Projectiles")));
213                         setDependent(e, "g_instagib", 0, 0);
214         me.TR(me);
215                 me.TDempty(me, 0.2);
216                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_new_toys", _("New Toys")));
217                         setDependentWeird(e, checkCompatibility_newtoys);
218         me.TR(me);
219                 me.TDempty(me, 0.2);
220                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox(0, "g_rocket_flying", _("Rocket Flying")));
221                         setDependent(e, "g_instagib", 0, 0);
222         me.TR(me);
223                 me.TDempty(me, 0.2);
224                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_pinata", _("Piñata"),
225                         _("Players will drop all weapons they possessed when they are killed")));
226                         setDependentWeird(e, checkCompatibility_pinata);
227         me.TR(me);
228                 me.TDempty(me, 0.2);
229                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_weapon_stay", _("Weapons stay"),
230                         _("Weapons stay after they are picked up")));
231                         setDependentWeird(e, checkCompatibility_weaponstay);
232         me.TR(me);
233
234         me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
235                 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
236         me.TR(me);
237                 me.TD(me, 1, 2, e = makeXonoticRadioButton_T(1, "g_weaponarena", "menu_weaponarena", _("Weapon arenas:"),
238                         _("Selecting a weapon arena will give all players that weapon at spawn as well as unlimited ammo, and disable all other weapon pickups.")));
239                         e.cvarValueIsAnotherCvar = true;
240                         e.cvarOffValue = "0";
241         for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
242         {
243                 w = Weapons_from(i);
244                 if(w.spawnflags & WEP_FLAG_HIDDEN)
245                         continue;
246                 if((j & 1) == 0)
247                         me.TR(me);
248                 me.TDempty(me, 0.2);
249                 me.TD(me, 1, 1.8, e = makeXonoticWeaponarenaCheckBox(strzone(w.netname), strzone(w.m_name)));
250                         setDependentWeird(e, checkCompatibility_weaponarena_weapon);
251                 ++j;
252         }
253         me.TR(me);
254                 me.TDempty(me, 0.2);
255                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "most", _("Most weapons"),
256                         _("Selecting a weapon arena will give all players that weapon at spawn as well as unlimited ammo, and disable all other weapon pickups.")));
257                         e.cvarOffValue = "0";
258         me.TR(me);
259                 me.TDempty(me, 0.2);
260                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "all", _("All weapons"),
261                         _("Selecting a weapon arena will give all players that weapon at spawn as well as unlimited ammo, and disable all other weapon pickups.")));
262                         e.cvarOffValue = "0";
263         me.TR(me);
264                 me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Special arenas:")));
265         me.TR(me);
266                 me.TDempty(me, 0.2);
267                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_instagib", "1", _("InstaGib"),
268                         _("Players will be given only one weapon, which can instantly kill the opponent with a single shot. If the player runs out of ammo, he will have 10 seconds to find some or if he fails to do so, face death. The secondary fire mode does not inflict any damage but is good for doing trickjumps.")));
269                         e.cvarOffValue = "0";
270         me.TR(me);
271                 me.TDempty(me, 0.2);
272                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_nix", "1", _("NIX"),
273                         _("No items Xonotic - instead of pickup items, everyone plays with the same weapon. After some time, a countdown will start, after which everyone will switch to another weapon.")));
274                         e.cvarOffValue = "0";
275         me.TR(me);
276                 me.TDempty(me, 0.4);
277                 me.TD(me, 1, 1.6, e = makeXonoticCheckBox_T(0, "g_nix_with_blaster", _("with blaster"),
278                         _("Always carry the blaster as an additional weapon in Nix")));
279                         setDependent(e, "g_nix", 1, 1);
280         me.TR(me);
281                 me.TDempty(me, 0.2);
282                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_balance_blaster_weaponstartoverride", "0", _("No start weapons"), "-"));
283                         e.cvarOffValue = "-1";
284                         makeMulti(e, "g_balance_shotgun_weaponstartoverride g_balance_machinegun_weaponstartoverride g_balance_devastator_weaponstartoverride g_balance_minelayer_weaponstartoverride g_balance_electro_weaponstartoverride g_balance_crylink_weaponstartoverride g_balance_hagar_weaponstartoverride g_balance_porto_weaponstartoverride g_balance_vaporizer_weaponstartoverride g_balance_hook_weaponstartoverride g_balance_rifle_weaponstartoverride g_balance_fireball_weaponstartoverride g_balance_seeker_weaponstartoverride g_balance_tuba_weaponstartoverride g_balance_arc_weaponstartoverride g_balance_vortex_weaponstartoverride g_balance_mortar_weaponstartoverride");
285
286         me.gotoRC(me, me.rows - 1, 0);
287                 me.TD(me, 1, me.columns, e = makeXonoticButton(_("OK"), '0 0 0'));
288                         e.onClick = Dialog_Close;
289                         e.onClickEntity = me;
290 }
291
292 .void(entity) refilter;
293
294 void XonoticMutatorsDialog_close(entity me)
295 {
296         if(me.refilterEntity)
297                 me.refilterEntity.refilter(me.refilterEntity);
298         SUPER(XonoticMutatorsDialog).close(me);
299 }