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