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