3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
5 #include <server/items/items.qh>
6 #include <server/items/spawning.qh>
7 #include <server/resources.qh>
8 #include <common/gamemodes/_mod.qh>
9 #include <common/gamemodes/gamemode/ctf/sv_ctf.qh>
10 #include <common/mapobjects/triggers.qh>
11 #include <common/mapobjects/trigger/counter.qh>
12 #include <common/mutators/mutator/buffs/buffs.qh>
13 #include <common/notifications/all.qh>
14 #include <common/weapons/_all.qh>
16 /***********************
17 * QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
18 ***********************
20 * Map entities NOT handled in this file:
21 holdable_invulnerability Q3TA currently unsupported
22 holdable_kamikaze Q3TA currently unsupported
23 item_ammoregen Q3TA handled by buffs mutator
24 item_doubler Q3TA handled by buffs mutator
25 item_guard Q3TA handled by buffs mutator
26 item_scout Q3TA handled by buffs mutator
27 item_armor_jacket CPMA handled in quake2.qc
28 item_flight Q3A handled by buffs mutator
29 item_haste Q3A handled by buffs mutator
30 item_health Q3A handled in quake.qc
31 item_health_large Q3A handled in items.qc
32 item_health_small Q3A handled in health.qh
33 item_health_mega Q3A handled in health.qh
34 item_invis Q3A handled by buffs mutator
35 item_quad Q3A handled in items.qc
36 item_regen Q3A handled by buffs mutator
37 CTF spawnfuncs handled in sv_ctf.qc
39 NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
43 SPAWNFUNC_ITEM_COND(ammo_shells, (q3compat & BIT(0)), ITEM_Bullets, ITEM_Shells)
44 SPAWNFUNC_WEAPON_COND(weapon_shotgun, (q3compat & BIT(0)), WEP_MACHINEGUN, WEP_SHOTGUN)
47 SPAWNFUNC_ITEM_COND(ammo_bullets, (q3compat & BIT(0)), ITEM_Shells, ITEM_Bullets)
50 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
52 // Team Arena Proximity Launcher -> Mine Layer
53 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
54 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
56 // Team Arena Chaingun -> HLAC
57 SPAWNFUNC_WEAPON(weapon_chaingun, WEP_HLAC)
58 SPAWNFUNC_ITEM(ammo_belt, ITEM_Cells)
60 // Team Arena Nailgun -> Crylink || Quake Nailgun -> Electro
61 SPAWNFUNC_WEAPON_COND(weapon_nailgun, cvar("sv_mapformat_is_quake3"), WEP_CRYLINK, WEP_ELECTRO)
62 SPAWNFUNC_ITEM(ammo_nails, ITEM_Cells)
65 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
66 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
69 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
70 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
73 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
74 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
76 // BFG -> Crylink || Fireball
77 SPAWNFUNC_WEAPON_COND(weapon_bfg, cvar_string("g_mod_balance") == "XDF", WEP_CRYLINK, WEP_FIREBALL)
78 SPAWNFUNC_ITEM_COND(ammo_bfg, cvar_string("g_mod_balance") == "XDF", ITEM_Cells, ITEM_Rockets)
80 // grappling hook -> hook
81 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
84 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
87 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
88 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
89 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
90 SPAWNFUNC_ITEM(item_armor_green, ITEM_ArmorMedium) // CCTF
93 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
95 // medkit -> armor (we have no holdables)
96 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
101 // weapon remove ent from df
102 void target_init_verify(entity this)
104 entity trigger, targ;
105 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
106 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
107 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
114 //setsize(targ, trigger.mins, trigger.maxs);
115 //setorigin(targ, trigger.origin);
120 void target_init_use(entity this, entity actor, entity trigger)
122 if (!(this.spawnflags & 1))
124 SetResource(actor, RES_ARMOR, start_armorvalue);
125 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
128 if (!(this.spawnflags & 2))
130 SetResource(actor, RES_HEALTH, start_health);
131 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
132 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
135 if (!(this.spawnflags & 4))
137 if(this.spawnflags & 32) // spawn with only melee
139 SetResource(actor, RES_SHELLS, 0);
140 SetResource(actor, RES_BULLETS, 0);
141 SetResource(actor, RES_ROCKETS, 0);
142 SetResource(actor, RES_CELLS, 0);
143 SetResource(actor, RES_PLASMA, 0);
144 SetResource(actor, RES_FUEL, 0);
146 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
150 SetResource(actor, RES_SHELLS, start_ammo_shells);
151 SetResource(actor, RES_BULLETS, start_ammo_nails);
152 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
153 SetResource(actor, RES_CELLS, start_ammo_cells);
154 SetResource(actor, RES_PLASMA, start_ammo_plasma);
155 SetResource(actor, RES_FUEL, start_ammo_fuel);
157 STAT(WEAPONS, actor) = start_weapons;
161 if (!(this.spawnflags & 8))
163 STAT(STRENGTH_FINISHED, actor) = 0;
164 STAT(INVINCIBLE_FINISHED, actor) = 0;
165 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
167 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
168 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
169 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
170 if(!IS_INDEPENDENT_PLAYER(actor))
171 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
172 STAT(BUFFS, actor) = 0;
173 STAT(BUFF_TIME, actor) = 0;
177 if (!(this.spawnflags & 16))
179 // We don't have holdables.
182 SUB_UseTargets(this, actor, trigger);
185 spawnfunc(target_init)
187 this.use = target_init_use;
188 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
191 // weapon give ent from defrag
192 void target_give_init(entity this)
194 IL_EACH(g_items, it.targetname == this.target,
196 if (it.classname == "weapon_devastator") {
197 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
198 this.netname = cons(this.netname, "devastator");
200 else if (it.classname == "weapon_vortex") {
201 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
202 this.netname = cons(this.netname, "vortex");
204 else if (it.classname == "weapon_electro") {
205 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
206 this.netname = cons(this.netname, "electro");
208 else if (it.classname == "weapon_hagar") {
209 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
210 this.netname = cons(this.netname, "hagar");
212 else if (it.classname == "weapon_crylink") {
213 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
214 this.netname = cons(this.netname, "crylink");
216 else if (it.classname == "weapon_mortar") {
217 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
218 this.netname = cons(this.netname, "mortar");
220 else if (it.classname == "weapon_shotgun") {
221 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
222 this.netname = cons(this.netname, "shotgun");
224 else if (it.classname == "item_armor_mega")
225 SetResourceExplicit(this, RES_ARMOR, 100);
226 else if (it.classname == "item_health_mega")
227 SetResourceExplicit(this, RES_HEALTH, 200);
228 else if (it.classname == "item_buff") {
229 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
230 this.netname = cons(this.netname, buff.netname);
231 STAT(BUFF_TIME, this) = it.count;
234 //remove(it); // removing ents in init functions causes havoc, workaround:
235 setthink(it, SUB_Remove);
239 this.spawnfunc_checked = true;
240 spawnfunc_target_items(this);
241 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
244 spawnfunc(target_give)
246 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
249 void score_use(entity this, entity actor, entity trigger)
251 if(!IS_PLAYER(actor))
253 actor.fragsfilter_cnt += this.count;
255 spawnfunc(target_score)
257 if(!g_cts) { delete(this); return; }
261 this.use = score_use;
264 void fragsfilter_use(entity this, entity actor, entity trigger)
266 if(!IS_PLAYER(actor))
268 if(actor.fragsfilter_cnt >= this.frags)
269 SUB_UseTargets(this, actor, trigger);
271 spawnfunc(target_fragsFilter)
273 if(!g_cts) { delete(this); return; }
277 this.use = fragsfilter_use;
287 bool DoesQ3ARemoveThisEntity(entity this)
289 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
291 // DeFRaG mappers use "notcpm" or "notvq3" to disable an entity in CPM or VQ3 physics
292 // Xonotic is usually played with a CPM-based physics so we default to CPM mode
293 if(cvar_string("g_mod_physics") == "Q3")
301 // Q3 mappers use "notq3a" or "notta" to disable an entity in Q3A or Q3TA
302 // Xonotic has ~equivalent features to Team Arena
321 // From ioq3 g_spawn.c: static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester"};
322 gametypename = "ffa";
324 gametypename = "team";
326 gametypename = "ctf";
327 if(g_ctf && ctf_oneflag)
328 gametypename = "oneflag";
330 gametypename = "tournament";
332 gametypename = "single";
333 // we do not have the other types (obelisk, harvester)
334 if(strstrofs(this.gametype, gametypename, 0) < 0)