]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/t_quake3.qc
Buffs: move definitions alongside buff mutator
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_quake3.qc
1
2 #include "../common/weapons/all.qh"
3
4 spawnfunc(weapon_crylink);
5 spawnfunc(weapon_electro);
6 spawnfunc(weapon_hagar);
7 spawnfunc(weapon_machinegun);
8 spawnfunc(weapon_vortex);
9
10 spawnfunc(target_items);
11
12 spawnfunc(item_bullets);
13 spawnfunc(item_cells);
14 spawnfunc(item_rockets);
15 spawnfunc(item_shells);
16
17 spawnfunc(item_jetpack);
18
19 spawnfunc(item_armor_big);
20 spawnfunc(item_armor_large);
21 spawnfunc(item_armor_small);
22
23 spawnfunc(item_health_medium);
24 spawnfunc(item_health_mega);
25
26 //***********************
27 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
28 //***********************
29
30 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
31
32 // SG -> SG
33 spawnfunc(ammo_shells)         { spawnfunc_item_shells(this);         }
34
35 // MG -> MG
36 spawnfunc(ammo_bullets)        { spawnfunc_item_bullets(this);        }
37
38 // GL -> Mortar
39 spawnfunc(ammo_grenades)       { spawnfunc_item_rockets(this);        }
40
41 // LG -> Lightning
42 spawnfunc(weapon_lightning)    { spawnfunc_weapon_electro(this);      }
43 spawnfunc(ammo_lightning)      { spawnfunc_item_cells(this);          }
44
45 // Plasma -> Hagar
46 spawnfunc(weapon_plasmagun)    { spawnfunc_weapon_hagar(this);        }
47 spawnfunc(ammo_cells)          { spawnfunc_item_rockets(this);        }
48
49 // Rail -> Vortex
50 spawnfunc(weapon_railgun)      { spawnfunc_weapon_vortex(this);          }
51 spawnfunc(ammo_slugs)          { spawnfunc_item_cells(this);          }
52
53 // BFG -> Crylink
54 spawnfunc(weapon_bfg)          { spawnfunc_weapon_crylink(this);      }
55 spawnfunc(ammo_bfg)            { spawnfunc_item_cells(this);          }
56
57 // RL -> RL
58 spawnfunc(ammo_rockets)        { spawnfunc_item_rockets(this);        }
59
60 // Armor
61 spawnfunc(item_armor_body)     { spawnfunc_item_armor_large(this);    }
62 spawnfunc(item_armor_combat)   { spawnfunc_item_armor_big(this);      }
63 spawnfunc(item_armor_shard)    { spawnfunc_item_armor_small(this);    }
64 spawnfunc(item_enviro)         { spawnfunc_item_invincible(this);     }
65
66 .float wait;
67 .float delay;
68
69 // weapon remove ent from df
70 void target_init_verify()
71 {
72         entity trigger, targ;
73         for(trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); )
74                 for(targ = world; (targ = find(targ, targetname, trigger.target)); )
75                         if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
76                         {
77                                 trigger.wait = 0;
78                                 trigger.delay = 0;
79                                 targ.wait = 0;
80                                 targ.delay = 0;
81
82                                 //setsize(targ, trigger.mins, trigger.maxs);
83                                 //setorigin(targ, trigger.origin);
84                                 //remove(trigger);
85                         }
86 }
87
88 spawnfunc(target_init)
89 {
90         self.spawnflags = 0; // remove all weapons except the ones listed below
91         self.netname = "shotgun"; // keep these weapons through the remove trigger
92         spawnfunc_target_items(this);
93         InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
94 }
95
96 // weapon give ent from defrag
97 void target_give_init()
98 {SELFPARAM();
99         entity targ;
100         for (targ = world; (targ = find(targ, targetname, self.target)); ) {
101                 if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") {
102                         self.ammo_rockets += targ.count * WEP_CVAR(devastator, ammo);
103                         self.netname = "devastator";
104                 }
105                 else if (targ.classname == "weapon_plasmagun") {
106                         self.ammo_rockets += targ.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
107                         if(self.netname == "")
108                                 self.netname = "hagar";
109                         else
110                                 self.netname = strcat(self.netname, " hagar");
111                 }
112                 else if (targ.classname == "weapon_bfg") {
113                         self.ammo_cells += targ.count * WEP_CVAR_PRI(crylink, ammo);
114                         if(self.netname == "")
115                                 self.netname = "crylink";
116                         else
117                                 self.netname = strcat(self.netname, " crylink");
118                 }
119                 else if (targ.classname == "weapon_grenadelauncher" || targ.classname == "weapon_mortar") {
120                         self.ammo_rockets += targ.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
121                         if(self.netname == "")
122                                 self.netname = "mortar";
123                         else
124                                 self.netname = strcat(self.netname, " mortar");
125                 }
126                 else if (targ.classname == "item_armor_body")
127                         self.armorvalue = 100;
128                 else if (targ.classname == "item_health_mega")
129                         self.health = 200;
130                 //remove(targ); // removing ents in init functions causes havoc, workaround:
131         targ.think = SUB_Remove;
132         targ.nextthink = time;
133         }
134         self.spawnflags = 2;
135         spawnfunc_target_items(this);
136         InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
137 }
138
139 spawnfunc(target_give)
140 {
141         InitializeEntity(self, target_give_init, INITPRIO_FINDTARGET);
142 }
143
144 //spawnfunc(item_flight)       /* handled by buffs mutator or jetpack */
145 //spawnfunc(item_haste)        /* handled by buffs mutator */
146 //spawnfunc(item_health)       /* handled in t_quake.qc */
147 //spawnfunc(item_health_large) /* handled in t_items.qc */
148 //spawnfunc(item_health_small) /* handled in t_items.qc */
149 //spawnfunc(item_health_mega)  /* handled in t_items.qc */
150 //spawnfunc(item_invis)        /* handled by buffs mutator */
151 //spawnfunc(item_regen)        /* handled by buffs mutator */
152
153 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
154
155 spawnfunc(item_flight)
156 {
157         spawnfunc_item_jetpack(this);
158 }
159
160 .float notteam;
161 .float notsingle;
162 .float notfree;
163 .float notq3a;
164 .float notta;
165 .string gametype;
166 float DoesQ3ARemoveThisEntity()
167 {SELFPARAM();
168         // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
169
170         if(self.notq3a)
171                 if(!teamplay || g_tdm || g_ctf)
172                         return 1;
173
174         if(self.notta)
175                 if (!(!teamplay || g_tdm || g_ctf))
176                         return 1;
177
178         if(self.notsingle)
179                 if(maxclients == 1)
180                         return 1;
181
182         if(self.notteam)
183                 if(teamplay)
184                         return 1;
185
186         if(self.notfree)
187                 if(!teamplay)
188                         return 1;
189
190         if(self.gametype)
191         {
192                 string gametypename;
193                 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
194                 gametypename = "ffa";
195                 if(teamplay)
196                         gametypename = "team";
197                 if(g_ctf)
198                         gametypename = "ctf";
199                 if(maxclients == 1)
200                         gametypename = "single";
201                 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
202                 if(strstrofs(self.gametype, gametypename, 0) < 0)
203                         return 1;
204         }
205
206         return 0;
207 }