]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
Merge branch 'master' into terencehill/welcome_dialog_translatable
[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;
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
34         strcpy(weaponarenastring_cvar, s);
35
36         n = tokenize_console(s);
37         s = "";
38         for(int j = 0; j < n; ++j)
39         {
40                 Weapon wep = Weapon_from_name(argv(j));
41                 if(wep != WEP_Null)
42                 {
43                         s = cons_mid(s, " & ", wep.m_name);
44                 }
45         }
46         s = sprintf(_("%s Arena"), s);
47
48         strcpy(weaponarenastring, s);
49
50         return weaponarenastring;
51 }
52
53 string XonoticMutatorsDialog_toString(entity me)
54 {
55         string s = build_mutator_list("");
56         if(cvar_string("g_weaponarena") != "0")
57                 s = cons_mid(s, ", ", WeaponArenaString());
58         if(s == "")
59                 return ZCTX(_("MUT^None"));
60         else
61                 return s;
62 }
63
64 float checkCompatibility_pinata(entity me)
65 {
66         if(cvar("g_instagib"))
67                 return 0;
68         if(cvar("g_nix"))
69                 return 0;
70         if(cvar("g_overkill"))
71                 return 0;
72         if(cvar("g_melee_only"))
73                 return 0;
74         if(cvar_string("g_weaponarena") != "0")
75                 return 0;
76         return 1;
77 }
78 float checkCompatibility_weaponstay(entity me)
79 {
80         return checkCompatibility_pinata(me);
81 }
82 float checkCompatibility_newtoys(entity me)
83 {
84         if(cvar("g_instagib"))
85                 return 0;
86         if(cvar_string("g_weaponarena") == "most")
87                 return 1;
88         if(cvar_string("g_weaponarena") == "all" || cvar_string("g_weaponarena") == "1")
89                 return 1;
90         if(cvar_string("g_weaponarena") != "0")
91                 return 0;
92         return 1;
93 }
94 float checkCompatibility_weaponarena_weapon(entity me)
95 {
96         if(cvar("g_instagib"))
97                 return 0;
98         if(cvar_string("g_weaponarena") == "most")
99                 return 0;
100         if(cvar_string("g_weaponarena") == "all" || cvar_string("g_weaponarena") == "1")
101                 return 0;
102         if(cvar_string("g_weaponarena") == "0")
103                 return 0;
104         if(cvar_string("g_balance_blaster_weaponstartoverride") == "0")
105                 return 0;
106         return 1;
107 }
108
109 void XonoticMutatorsDialog_fill(entity me)
110 {
111         entity e, s, w;
112         float i, j;
113         me.TR(me);
114                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Gameplay mutators:")));
115         me.TR(me);
116                 me.TDempty(me, 0.2);
117                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_dodging", _("Dodging"),
118                         _("Enable dodging (quick acceleration in a given direction). Double-tap a directional key to dodge")));
119         me.TR(me);
120                 me.TDempty(me, 0.2);
121                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_touchexplode", _("Touch explode"),
122                         _("An explosion occurs when two players collide")));
123         me.TR(me);
124                 me.TDempty(me, 0.2);
125                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_cloaked", _("Cloaked"),
126                         _("All players are almost invisible")));
127         me.TR(me);
128                 me.TDempty(me, 0.2);
129                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_buffs", _("Buffs"),
130                         _("Enable buff pickups (random bonuses like Medic, Invisible, etc.) on the maps that support it")));
131                         e.cvarOffValue = "-1"; // TODO: make this a radio button?
132         me.TR(me);
133                 me.TDempty(me, 0.2);
134                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_midair", _("Midair"),
135                         _("Only possible to inflict damage on your enemy while they're airborne")));
136         me.TR(me);
137                 me.TDempty(me, 0.2);
138                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_vampire", _("Vampire"),
139                         _("Damage done to your enemy gets added to your own health")));
140                         setDependent(e, "g_instagib", 0, 0);
141         me.TR(me);
142                 me.TDempty(me, 0.2);
143                 s = makeXonoticSlider_T(10, 50, 1, "g_bloodloss",
144                         _("Amount of health below which players start bleeding out (health rots and they can't jump)"));
145                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(0, 1, s, _("Blood loss")));
146                         setDependent(e, "g_instagib", 0, 0);
147         me.TR(me);
148                 me.TDempty(me, 0.4);
149                 me.TD(me, 1, 1.6, s);
150         me.TR(me);
151                 me.TDempty(me, 0.2);
152                 s = makeXonoticSlider_T(80, 400, 8, "sv_gravity",
153                         _("Make things fall to the ground slower (percentage of normal gravity)"));
154                         s.valueDigits = 0;
155                         s.valueDisplayMultiplier = 0.125; // show gravity in percent
156                 me.TD(me, 1, 1.8, e = makeXonoticSliderCheckBox(800, 1, s, _("Low gravity")));
157                         e.savedValue = 200; // good on silvercity
158         me.TR(me);
159                 me.TDempty(me, 0.4);
160                 me.TD(me, 1, 1.6, s);
161         me.TR(me);
162                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Weapon & item mutators:")));
163         me.TR(me);
164                 me.TDempty(me, 0.2);
165                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_grappling_hook", _("Grappling Hook"),
166                         _("Players spawn with the grappling hook. Press the 'hook' key to use it")));
167         me.TR(me);
168                 me.TDempty(me, 0.2);
169                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_jetpack", _("Jetpack"),
170                         _("Players spawn with the jetpack. Double-tap 'jump' or press the 'jetpack' key to use it")));
171         me.TR(me);
172                 me.TDempty(me, 0.2);
173                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_invincible_projectiles", _("Invincible Projectiles"),
174                         _("Projectiles can't be destroyed. However, you can still explode Electro orbs with the Electro primary fire")));
175                         setDependent(e, "g_instagib", 0, 0);
176         me.TR(me);
177                 me.TDempty(me, 0.2);
178                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_new_toys", _("New Toys"),
179                         _("Some weapon spawns will be randomly replaced with new weapons: Heavy Laser Assault Cannon, Mine Layer, Rifle, T.A.G. Seeker")));
180                         setDependentWeird(e, checkCompatibility_newtoys);
181         me.TR(me);
182                 me.TDempty(me, 0.2);
183                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_rocket_flying", _("Rocket Flying"),
184                         _("Devastator rockets can be detonated instantly (otherwise, there's a short delay). This allows players to fire and detonate a Devastator rocket while in the air for a strong mid-air boost even while moving fast")));
185                         setDependent(e, "g_instagib", 0, 0);
186         me.TR(me);
187                 me.TDempty(me, 0.2);
188                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_pinata", _("PiƱata"),
189                         _("Players will drop all weapons they possessed when they are killed")));
190                         setDependentWeird(e, checkCompatibility_pinata);
191         me.TR(me);
192                 me.TDempty(me, 0.2);
193                 me.TD(me, 1, 1.8, e = makeXonoticCheckBox_T(0, "g_weapon_stay", _("Weapons stay"),
194                         _("Weapons stay after they are picked up")));
195                         setDependentWeird(e, checkCompatibility_weaponstay);
196         me.TR(me);
197
198         me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
199                 me.TD(me, 1, 2, e = makeXonoticRadioButton(1, string_null, string_null, _("Regular (no arena)")));
200         string weaponarena_tooltip = strzone(_("Players will be given a set of weapons at spawn as well as unlimited ammo, without weapon pickups"));
201         me.TR(me);
202                 me.TD(me, 1, 2, makeXonoticTextLabel(0, _("Weapon arenas:")));
203         me.TR(me);
204                 me.TDempty(me, 0.2);
205                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "menu_weaponarena", _("Custom weapons"), weaponarena_tooltip));
206                         e.cvarValueIsAnotherCvar = true;
207                         e.cvarOffValue = "0";
208
209                 me.TDempty(me, 0.1); // fix initial position
210         for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
211         {
212                 w = REGISTRY_GET(Weapons, i);
213                 if (w.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK))
214                         continue;
215                 if ((j % 3) == 0)
216                 {
217                         me.TR(me);
218                         me.TDempty(me, 0.4);
219                 }
220                 me.TD(me, 1, 1.2, e = makeXonoticWeaponarenaCheckBox(strzone(w.netname), strzone(w.m_name)));
221                         setDependentWeird(e, checkCompatibility_weaponarena_weapon);
222                 ++j;
223         }
224
225         me.TR(me);
226                 me.TDempty(me, 0.2);
227                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "most", _("Most weapons"), weaponarena_tooltip));
228                         e.cvarOffValue = "0";
229         me.TR(me);
230                 me.TDempty(me, 0.2);
231                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_weaponarena", "all", _("All weapons"), weaponarena_tooltip));
232                         e.cvarOffValue = "0";
233         me.TR(me);
234                 me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Special arenas:")));
235         me.TR(me);
236                 me.TDempty(me, 0.2);
237                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_instagib", "1", _("InstaGib"),
238                         _("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.")));
239                         e.cvarOffValue = "0";
240         me.TR(me);
241                 me.TDempty(me, 0.2);
242                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_nix", "1", _("NIX"),
243                         _("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.")));
244                         e.cvarOffValue = "0";
245         me.TR(me);
246                 me.TDempty(me, 0.4);
247                 me.TD(me, 1, 1.6, e = makeXonoticCheckBox_T(0, "g_nix_with_blaster", _("with blaster"),
248                         _("Always carry the blaster as an additional weapon in Nix")));
249                         setDependent(e, "g_nix", 1, 1);
250         me.TR(me);
251                 me.TDempty(me, 0.2);
252                 me.TD(me, 1, 1.8, e = makeXonoticRadioButton_T(1, "g_balance_blaster_weaponstartoverride", "0", _("No start weapons"), "-"));
253                         e.cvarOffValue = "-1";
254                         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");
255
256         me.gotoRC(me, me.rows - 1, 0);
257                 me.TD(me, 1, me.columns, e = makeXonoticButton(_("OK"), '0 0 0'));
258                         e.onClick = Dialog_Close;
259                         e.onClickEntity = me;
260 }
261
262 .void(entity) refilter;
263
264 void XonoticMutatorsDialog_close(entity me)
265 {
266         if(me.refilterEntity)
267                 me.refilterEntity.refilter(me.refilterEntity);
268         SUPER(XonoticMutatorsDialog).close(me);
269 }