]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator_new_toys.qc
new toys: start coding it, far from done
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_new_toys.qc
1 /*
2
3 CORE    laser   nex     lg      rl      cry     gl      elec    hagar   fireb   hook
4                                                                         minsta  porto
5                                                                         tuba
6
7 NEW             rifle   hlac    minel                           seeker   
8 IDEAS                                   OPEN    flak    OPEN            FUN FUN FUN FUN
9
10
11
12 How this mutator works:
13  =======================
14
15 When a gun tries to spawn, this mutator is called. It will provide alternate
16 default values of weaponreplace lists.
17
18 Entity:
19
20 {
21 "classname" "weapon_nex"
22 "new_toys" "rifle"
23 }
24 -> This will spawn as Rifle in this mutator ONLY, and as Nex otherwise.
25
26 {
27 "classname" "weapon_nex"
28 "new_toys" "nex rifle"
29 }
30 -> This will spawn as either Nex or Rifle in this mutator ONLY, and as Nex otherwise.
31
32 {
33 "classname" "weapon_nex"
34 "new_toys" "nex"
35 }
36 -> This is always a Nex.
37
38 If the map specifies no "new_toys" argument
39
40 There will be two default replacements selectable: "replace all" and "replace random".
41 In "replace all" mode, e.g. Nex will have the default replacement "rifle".
42 In "replace random" mode, Nex will have the default replacement "nex rifle".
43
44 This mutator's replacements run BEFORE regular weaponreplace!
45
46 The New Toys guns do NOT get a spawn function, so they can only ever be spawned
47 when this mutator is active.
48
49 Likewise, warmup, give all, give ALL and impulse 99 will not give them unless
50 this mutator is active.
51
52 Outside this mutator, they still can be spawned by:
53 - setting their start weapon cvar to 1
54 - give weaponname
55 - weaponreplace
56 - weaponarena (but all and most weapons arena again won't include them)
57
58 Also, this mutator performs the default replacements on the DEFAULTS of the
59 start weapon selection.
60
61 Also: these weapons appear in the menu's priority list, BUT get a suffix
62 "(Mutator weapon)".
63
64 Picking up a "new toys" weapon will not play standard weapon pickup sound, but
65 roflsound "New toys, new toys!" sound.
66
67 */
68
69 string i_herd_yo_liek_weaponreplace(string replacement)
70 {
71         string newlist;
72         float n = tokenize_console(replacement);
73         string out = "";
74         for(i = 0; i < n; ++i)
75         {
76                 string s = argv(i);
77                 string r = cvar_string(strcat("g_weaponreplace_", s));
78                 if(r == "")
79                         out = strcat(out, " ", s);
80                 else if(r != "0")
81                         out = strcat(out, " ", r);
82         }
83         return substring(out, 1);
84 }
85
86 MUTATOR_HOOKFUNCTION(nt_SetModname)
87 {
88         modname = "NewToys";
89         return 0;
90 }
91
92 MUTATOR_HOOKFUNCTION(nt_SetStartItems)
93 {
94         // rearrange start_weapon_default
95         // apply those bits that are set by start_weapon_defaultmask
96         // same for warmup
97         // TODO
98         return 0;
99 }
100
101 MUTATOR_DEFINITION(mutator_new_toys)
102 {
103         MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY);
104         MUTATOR_HOOK(SetStartItems, nix_SetStartItems, CBC_ORDER_ANY);
105
106         MUTATOR_ONADD
107         {
108                 if(time > 1) // game loads at time 1
109                         error("This cannot be added at runtime\n");
110         }
111         MUTATOR_ONREMOVE
112         {
113                 error("This cannot be removed at runtime\n");
114         }
115
116         return 0;
117 }