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