3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
5 #include <server/items.qh>
6 #include <server/resources.qh>
7 #include <common/t_items.qh>
8 #include <common/gamemodes/gamemode/ctf/sv_ctf.qh>
9 #include <common/mapobjects/triggers.qh>
10 #include <common/mapobjects/trigger/counter.qh>
11 #include <common/mutators/mutator/buffs/buffs.qh>
12 #include <common/notifications/all.qh>
13 #include <common/weapons/_all.qh>
15 /***********************
16 * QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
17 ***********************
19 * Map entities NOT handled in this file:
20 holdable_invulnerability Q3TA currently unsupported
21 holdable_kamikaze Q3TA currently unsupported
22 item_ammoregen Q3TA handled by buffs mutator
23 item_doubler Q3TA handled by buffs mutator
24 item_guard Q3TA handled by buffs mutator
25 item_scout Q3TA handled by buffs mutator
26 item_armor_jacket CPMA handled in quake2.qc
27 item_flight Q3A handled by buffs mutator
28 item_haste Q3A handled by buffs mutator
29 item_health Q3A handled in quake.qc
30 item_health_large Q3A handled in items.qc
31 item_health_small Q3A handled in health.qh
32 item_health_mega Q3A handled in health.qh
33 item_invis Q3A handled by buffs mutator
34 item_quad Q3A handled in items.qc
35 item_regen Q3A handled by buffs mutator
36 CTF spawnfuncs handled in sv_ctf.qc
38 NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
42 SPAWNFUNC_ITEM_COND(ammo_shells, (q3compat & BIT(0)), ITEM_Bullets, ITEM_Shells)
43 SPAWNFUNC_WEAPON_COND(weapon_shotgun, (q3compat & BIT(0)), WEP_MACHINEGUN, WEP_SHOTGUN)
46 SPAWNFUNC_ITEM_COND(ammo_bullets, (q3compat & BIT(0)), ITEM_Shells, ITEM_Bullets)
49 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
51 // Team Arena Proximity Launcher -> Mine Layer
52 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
53 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
55 // Team Arena Chaingun -> HLAC
56 SPAWNFUNC_WEAPON(weapon_chaingun, WEP_HLAC)
57 SPAWNFUNC_ITEM(ammo_belt, ITEM_Cells)
59 // Team Arena Nailgun -> Crylink || Quake Nailgun -> Electro
60 SPAWNFUNC_WEAPON_COND(weapon_nailgun, cvar("sv_mapformat_is_quake3"), WEP_CRYLINK, WEP_ELECTRO)
61 SPAWNFUNC_ITEM(ammo_nails, ITEM_Cells)
64 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
65 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
68 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
69 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
72 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
73 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
75 // BFG -> Crylink || Fireball
76 SPAWNFUNC_WEAPON_COND(weapon_bfg, cvar_string("g_mod_balance") == "XDF", WEP_CRYLINK, WEP_FIREBALL)
77 SPAWNFUNC_ITEM_COND(ammo_bfg, cvar_string("g_mod_balance") == "XDF", ITEM_Cells, ITEM_Rockets)
79 // grappling hook -> hook
80 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
83 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
86 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
87 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
88 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
89 SPAWNFUNC_ITEM(item_armor_green, ITEM_ArmorMedium) // CCTF
92 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
94 // medkit -> armor (we have no holdables)
95 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
100 // weapon remove ent from df
101 void target_init_verify(entity this)
103 entity trigger, targ;
104 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
105 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
106 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
113 //setsize(targ, trigger.mins, trigger.maxs);
114 //setorigin(targ, trigger.origin);
119 void target_init_use(entity this, entity actor, entity trigger)
121 if (!(this.spawnflags & 1))
123 SetResource(actor, RES_ARMOR, start_armorvalue);
124 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
127 if (!(this.spawnflags & 2))
129 SetResource(actor, RES_HEALTH, start_health);
130 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
131 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
134 if (!(this.spawnflags & 4))
136 if(this.spawnflags & 32) // spawn with only melee
138 SetResource(actor, RES_SHELLS, 0);
139 SetResource(actor, RES_BULLETS, 0);
140 SetResource(actor, RES_ROCKETS, 0);
141 SetResource(actor, RES_CELLS, 0);
142 SetResource(actor, RES_PLASMA, 0);
143 SetResource(actor, RES_FUEL, 0);
145 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
149 SetResource(actor, RES_SHELLS, start_ammo_shells);
150 SetResource(actor, RES_BULLETS, start_ammo_nails);
151 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
152 SetResource(actor, RES_CELLS, start_ammo_cells);
153 SetResource(actor, RES_PLASMA, start_ammo_plasma);
154 SetResource(actor, RES_FUEL, start_ammo_fuel);
156 STAT(WEAPONS, actor) = start_weapons;
160 if (!(this.spawnflags & 8))
162 STAT(STRENGTH_FINISHED, actor) = 0;
163 STAT(INVINCIBLE_FINISHED, actor) = 0;
164 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
166 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
167 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
168 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
169 if(!IS_INDEPENDENT_PLAYER(actor))
170 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
171 STAT(BUFFS, actor) = 0;
172 STAT(BUFF_TIME, actor) = 0;
176 if (!(this.spawnflags & 16))
178 // We don't have holdables.
181 SUB_UseTargets(this, actor, trigger);
184 spawnfunc(target_init)
186 this.use = target_init_use;
187 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
190 // weapon give ent from defrag
191 void target_give_init(entity this)
193 IL_EACH(g_items, it.targetname == this.target,
195 if (it.classname == "weapon_devastator") {
196 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
197 this.netname = cons(this.netname, "devastator");
199 else if (it.classname == "weapon_vortex") {
200 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
201 this.netname = cons(this.netname, "vortex");
203 else if (it.classname == "weapon_electro") {
204 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
205 this.netname = cons(this.netname, "electro");
207 else if (it.classname == "weapon_hagar") {
208 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
209 this.netname = cons(this.netname, "hagar");
211 else if (it.classname == "weapon_crylink") {
212 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
213 this.netname = cons(this.netname, "crylink");
215 else if (it.classname == "weapon_mortar") {
216 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
217 this.netname = cons(this.netname, "mortar");
219 else if (it.classname == "weapon_shotgun") {
220 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
221 this.netname = cons(this.netname, "shotgun");
223 else if (it.classname == "item_armor_mega")
224 SetResourceExplicit(this, RES_ARMOR, 100);
225 else if (it.classname == "item_health_mega")
226 SetResourceExplicit(this, RES_HEALTH, 200);
227 else if (it.classname == "item_buff") {
228 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
229 this.netname = cons(this.netname, buff.netname);
230 STAT(BUFF_TIME, this) = it.count;
233 //remove(it); // removing ents in init functions causes havoc, workaround:
234 setthink(it, SUB_Remove);
238 this.spawnfunc_checked = true;
239 spawnfunc_target_items(this);
240 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
243 spawnfunc(target_give)
245 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
248 void score_use(entity this, entity actor, entity trigger)
250 if(!IS_PLAYER(actor))
252 actor.fragsfilter_cnt += this.count;
254 spawnfunc(target_score)
256 if(!g_cts) { delete(this); return; }
260 this.use = score_use;
263 void fragsfilter_use(entity this, entity actor, entity trigger)
265 if(!IS_PLAYER(actor))
267 if(actor.fragsfilter_cnt >= this.frags)
268 SUB_UseTargets(this, actor, trigger);
270 spawnfunc(target_fragsFilter)
272 if(!g_cts) { delete(this); return; }
276 this.use = fragsfilter_use;
286 bool DoesQ3ARemoveThisEntity(entity this)
288 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
290 // DeFRaG mappers use "notcpm" or "notvq3" to disable an entity in CPM or VQ3 physics
291 // Xonotic is usually played with a CPM-based physics so we default to CPM mode
292 if(cvar_string("g_mod_physics") == "Q3")
300 // Q3 mappers use "notq3a" or "notta" to disable an entity in Q3A or Q3TA
301 // Xonotic has ~equivalent features to Team Arena
320 // From ioq3 g_spawn.c: static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester"};
321 gametypename = "ffa";
323 gametypename = "team";
325 gametypename = "ctf";
326 if(g_ctf && ctf_oneflag)
327 gametypename = "oneflag";
329 gametypename = "tournament";
331 gametypename = "single";
332 // we do not have the other types (obelisk, harvester)
333 if(strstrofs(this.gametype, gametypename, 0) < 0)