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 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
21 SPAWNFUNC_ITEM(ammo_shells, ITEM_Shells)
24 SPAWNFUNC_ITEM(ammo_bullets, ITEM_Bullets)
27 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
29 // Team Arena Proximity Launcher -> Mine Layer
30 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
31 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
33 // Team Arena Chaingun -> HLAC
34 SPAWNFUNC_WEAPON(weapon_chaingun, WEP_HLAC)
35 SPAWNFUNC_ITEM(ammo_belt, ITEM_Cells)
37 // Team Arena Nailgun -> Crylink || Quake Nailgun -> Electro
38 SPAWNFUNC_WEAPON_COND(weapon_nailgun, autocvar_sv_q3acompat_machineshotgunswap, WEP_CRYLINK, WEP_ELECTRO)
39 SPAWNFUNC_ITEM(ammo_nails, ITEM_Cells)
42 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
43 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
46 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
47 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
50 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
51 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
54 SPAWNFUNC_WEAPON(weapon_bfg, WEP_CRYLINK)
55 SPAWNFUNC_ITEM(ammo_bfg, ITEM_Cells)
57 // grappling hook -> hook
58 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
61 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
64 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
65 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
66 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
67 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
69 // medkit -> armor (we have no holdables)
70 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
75 // weapon remove ent from df
76 void target_init_verify(entity this)
79 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
80 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
81 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
88 //setsize(targ, trigger.mins, trigger.maxs);
89 //setorigin(targ, trigger.origin);
94 void target_init_use(entity this, entity actor, entity trigger)
96 if (!(this.spawnflags & 1))
98 SetResource(actor, RES_ARMOR, start_armorvalue);
99 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
102 if (!(this.spawnflags & 2))
104 SetResource(actor, RES_HEALTH, start_health);
105 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
106 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
109 if (!(this.spawnflags & 4))
111 if(this.spawnflags & 32) // spawn with only melee
113 SetResource(actor, RES_SHELLS, 0);
114 SetResource(actor, RES_BULLETS, 0);
115 SetResource(actor, RES_ROCKETS, 0);
116 SetResource(actor, RES_CELLS, 0);
117 SetResource(actor, RES_PLASMA, 0);
118 SetResource(actor, RES_FUEL, 0);
120 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
124 SetResource(actor, RES_SHELLS, start_ammo_shells);
125 SetResource(actor, RES_BULLETS, start_ammo_nails);
126 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
127 SetResource(actor, RES_CELLS, start_ammo_cells);
128 SetResource(actor, RES_PLASMA, start_ammo_plasma);
129 SetResource(actor, RES_FUEL, start_ammo_fuel);
131 STAT(WEAPONS, actor) = start_weapons;
135 if (!(this.spawnflags & 8))
137 STAT(STRENGTH_FINISHED, actor) = 0;
138 STAT(INVINCIBLE_FINISHED, actor) = 0;
139 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
141 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
142 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
143 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
144 if(!IS_INDEPENDENT_PLAYER(actor))
145 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
146 STAT(BUFFS, actor) = 0;
147 STAT(BUFF_TIME, actor) = 0;
151 if (!(this.spawnflags & 16))
153 // We don't have holdables.
156 SUB_UseTargets(this, actor, trigger);
159 spawnfunc(target_init)
161 this.use = target_init_use;
162 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
165 // weapon give ent from defrag
166 void target_give_init(entity this)
168 IL_EACH(g_items, it.targetname == this.target,
170 if (it.classname == "weapon_devastator") {
171 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
172 this.netname = cons(this.netname, "devastator");
174 else if (it.classname == "weapon_vortex") {
175 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
176 this.netname = cons(this.netname, "vortex");
178 else if (it.classname == "weapon_electro") {
179 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
180 this.netname = cons(this.netname, "electro");
182 else if (it.classname == "weapon_hagar") {
183 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
184 this.netname = cons(this.netname, "hagar");
186 else if (it.classname == "weapon_crylink") {
187 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
188 this.netname = cons(this.netname, "crylink");
190 else if (it.classname == "weapon_mortar") {
191 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
192 this.netname = cons(this.netname, "mortar");
194 else if (it.classname == "weapon_shotgun") {
195 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
196 this.netname = cons(this.netname, "shotgun");
198 else if (it.classname == "item_armor_mega")
199 SetResourceExplicit(this, RES_ARMOR, 100);
200 else if (it.classname == "item_health_mega")
201 SetResourceExplicit(this, RES_HEALTH, 200);
202 else if (it.classname == "item_buff") {
203 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
204 this.netname = cons(this.netname, buff.netname);
205 STAT(BUFF_TIME, this) = it.count;
208 //remove(it); // removing ents in init functions causes havoc, workaround:
209 setthink(it, SUB_Remove);
213 this.spawnfunc_checked = true;
214 spawnfunc_target_items(this);
215 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
218 spawnfunc(target_give)
220 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
223 void score_use(entity this, entity actor, entity trigger)
225 if(!IS_PLAYER(actor))
227 actor.fragsfilter_cnt += this.count;
229 spawnfunc(target_score)
231 if(!g_cts) { delete(this); return; }
235 this.use = score_use;
238 void fragsfilter_use(entity this, entity actor, entity trigger)
240 if(!IS_PLAYER(actor))
242 if(actor.fragsfilter_cnt >= this.frags)
243 SUB_UseTargets(this, actor, trigger);
245 spawnfunc(target_fragsFilter)
247 if(!g_cts) { delete(this); return; }
251 this.use = fragsfilter_use;
254 //spawnfunc(item_flight) /* handled by buffs mutator */
255 //spawnfunc(item_doubler) /* handled by buffs mutator */
256 //spawnfunc(item_haste) /* handled by buffs mutator */
257 //spawnfunc(item_health) /* handled in t_quake.qc */
258 //spawnfunc(item_health_large) /* handled in t_items.qc */
259 //spawnfunc(item_health_small) /* handled in t_items.qc */
260 //spawnfunc(item_health_mega) /* handled in t_items.qc */
261 //spawnfunc(item_invis) /* handled by buffs mutator */
262 //spawnfunc(item_regen) /* handled by buffs mutator */
264 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
273 bool DoesQ3ARemoveThisEntity(entity this)
275 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
277 // DeFRaG mappers use "notcpm" or "notvq3" to disable an entity in CPM or VQ3 physics
278 // Xonotic is usually played with a CPM-based physics so we default to CPM mode
279 if(cvar_string("g_mod_physics") == "Q3") {
280 if(this.notvq3) return true;
282 else if(this.notcpm) return true;
284 // Q3 mappers use "notq3a" or "notta" to disable an entity in Q3A or Q3TA
285 // Xonotic has ~equivalent features to Team Arena
304 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
305 gametypename = "ffa";
307 gametypename = "team";
309 gametypename = "ctf";
311 gametypename = "tournament";
313 gametypename = "single";
314 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
315 if(strstrofs(this.gametype, gametypename, 0) < 0)