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/mapobjects/triggers.qh>
9 #include <common/mapobjects/trigger/counter.qh>
10 #include <common/mutators/mutator/buffs/buffs.qh>
11 #include <common/notifications/all.qh>
12 #include <common/weapons/_all.qh>
14 /***********************
15 * QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
16 ***********************
18 * Map entities NOT handled in this file:
19 holdable_invulnerability Q3TA currently unsupported
20 holdable_kamikaze Q3TA currently unsupported
21 item_ammoregen Q3TA handled by buffs mutator
22 item_doubler Q3TA handled by buffs mutator
23 item_guard Q3TA handled by buffs mutator
24 item_scout Q3TA handled by buffs mutator
25 item_armor_jacket CPMA handled in quake2.qc
26 item_flight Q3A handled by buffs mutator
27 item_haste Q3A handled by buffs mutator
28 item_health Q3A handled in quake.qc
29 item_health_large Q3A handled in items.qc
30 item_health_small Q3A handled in health.qh
31 item_health_mega Q3A handled in health.qh
32 item_invis Q3A handled by buffs mutator
33 item_quad Q3A handled in items.qc
34 item_regen Q3A handled by buffs mutator
35 CTF spawnfuncs handled in sv_ctf.qc
37 NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
41 SPAWNFUNC_ITEM_COND(ammo_shells, q3compat & BIT(0), ITEM_Bullets, ITEM_Shells)
42 SPAWNFUNC_WEAPON_COND(weapon_shotgun, q3compat & BIT(0), WEP_MACHINEGUN, WEP_SHOTGUN)
45 SPAWNFUNC_ITEM_COND(ammo_bullets, q3compat & BIT(0), ITEM_Shells, ITEM_Bullets)
48 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
50 // Team Arena Proximity Launcher -> Mine Layer
51 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
52 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
54 // Team Arena Chaingun -> HLAC
55 SPAWNFUNC_WEAPON(weapon_chaingun, WEP_HLAC)
56 SPAWNFUNC_ITEM(ammo_belt, ITEM_Cells)
58 // Team Arena Nailgun -> Crylink || Quake Nailgun -> Electro
59 SPAWNFUNC_WEAPON_COND(weapon_nailgun, cvar_string("sv_mapformat_is_quake3"), WEP_CRYLINK, WEP_ELECTRO)
60 SPAWNFUNC_ITEM(ammo_nails, ITEM_Cells)
63 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
64 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
67 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
68 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
71 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
72 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
74 // BFG -> Crylink || Fireball
75 SPAWNFUNC_WEAPON_COND(weapon_bfg, cvar_string("g_mod_balance") == "XDF", WEP_CRYLINK, WEP_FIREBALL)
76 SPAWNFUNC_ITEM_COND(ammo_bfg, cvar_string("g_mod_balance") == "XDF", ITEM_Cells, ITEM_Rockets)
78 // grappling hook -> hook
79 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
82 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
85 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
86 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
87 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
88 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
90 // medkit -> armor (we have no holdables)
91 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
96 // weapon remove ent from df
97 void target_init_verify(entity this)
100 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
101 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
102 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
109 //setsize(targ, trigger.mins, trigger.maxs);
110 //setorigin(targ, trigger.origin);
115 void target_init_use(entity this, entity actor, entity trigger)
117 if (!(this.spawnflags & 1))
119 SetResource(actor, RES_ARMOR, start_armorvalue);
120 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
123 if (!(this.spawnflags & 2))
125 SetResource(actor, RES_HEALTH, start_health);
126 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
127 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
130 if (!(this.spawnflags & 4))
132 if(this.spawnflags & 32) // spawn with only melee
134 SetResource(actor, RES_SHELLS, 0);
135 SetResource(actor, RES_BULLETS, 0);
136 SetResource(actor, RES_ROCKETS, 0);
137 SetResource(actor, RES_CELLS, 0);
138 SetResource(actor, RES_PLASMA, 0);
139 SetResource(actor, RES_FUEL, 0);
141 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
145 SetResource(actor, RES_SHELLS, start_ammo_shells);
146 SetResource(actor, RES_BULLETS, start_ammo_nails);
147 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
148 SetResource(actor, RES_CELLS, start_ammo_cells);
149 SetResource(actor, RES_PLASMA, start_ammo_plasma);
150 SetResource(actor, RES_FUEL, start_ammo_fuel);
152 STAT(WEAPONS, actor) = start_weapons;
156 if (!(this.spawnflags & 8))
158 STAT(STRENGTH_FINISHED, actor) = 0;
159 STAT(INVINCIBLE_FINISHED, actor) = 0;
160 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
162 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
163 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
164 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
165 if(!IS_INDEPENDENT_PLAYER(actor))
166 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
167 STAT(BUFFS, actor) = 0;
168 STAT(BUFF_TIME, actor) = 0;
172 if (!(this.spawnflags & 16))
174 // We don't have holdables.
177 SUB_UseTargets(this, actor, trigger);
180 spawnfunc(target_init)
182 this.use = target_init_use;
183 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
186 // weapon give ent from defrag
187 void target_give_init(entity this)
189 IL_EACH(g_items, it.targetname == this.target,
191 if (it.classname == "weapon_devastator") {
192 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
193 this.netname = cons(this.netname, "devastator");
195 else if (it.classname == "weapon_vortex") {
196 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
197 this.netname = cons(this.netname, "vortex");
199 else if (it.classname == "weapon_electro") {
200 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
201 this.netname = cons(this.netname, "electro");
203 else if (it.classname == "weapon_hagar") {
204 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
205 this.netname = cons(this.netname, "hagar");
207 else if (it.classname == "weapon_crylink") {
208 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
209 this.netname = cons(this.netname, "crylink");
211 else if (it.classname == "weapon_mortar") {
212 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
213 this.netname = cons(this.netname, "mortar");
215 else if (it.classname == "weapon_shotgun") {
216 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
217 this.netname = cons(this.netname, "shotgun");
219 else if (it.classname == "item_armor_mega")
220 SetResourceExplicit(this, RES_ARMOR, 100);
221 else if (it.classname == "item_health_mega")
222 SetResourceExplicit(this, RES_HEALTH, 200);
223 else if (it.classname == "item_buff") {
224 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
225 this.netname = cons(this.netname, buff.netname);
226 STAT(BUFF_TIME, this) = it.count;
229 //remove(it); // removing ents in init functions causes havoc, workaround:
230 setthink(it, SUB_Remove);
234 this.spawnfunc_checked = true;
235 spawnfunc_target_items(this);
236 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
239 spawnfunc(target_give)
241 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
244 void score_use(entity this, entity actor, entity trigger)
246 if(!IS_PLAYER(actor))
248 actor.fragsfilter_cnt += this.count;
250 spawnfunc(target_score)
252 if(!g_cts) { delete(this); return; }
256 this.use = score_use;
259 void fragsfilter_use(entity this, entity actor, entity trigger)
261 if(!IS_PLAYER(actor))
263 if(actor.fragsfilter_cnt >= this.frags)
264 SUB_UseTargets(this, actor, trigger);
266 spawnfunc(target_fragsFilter)
268 if(!g_cts) { delete(this); return; }
272 this.use = fragsfilter_use;
282 bool DoesQ3ARemoveThisEntity(entity this)
284 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
286 // DeFRaG mappers use "notcpm" or "notvq3" to disable an entity in CPM or VQ3 physics
287 // Xonotic is usually played with a CPM-based physics so we default to CPM mode
288 if(cvar_string("g_mod_physics") == "Q3")
296 // Q3 mappers use "notq3a" or "notta" to disable an entity in Q3A or Q3TA
297 // Xonotic has ~equivalent features to Team Arena
316 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
317 gametypename = "ffa";
319 gametypename = "team";
321 gametypename = "ctf";
323 gametypename = "tournament";
325 gametypename = "single";
326 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
327 if(strstrofs(this.gametype, gametypename, 0) < 0)