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