3 #include <common/gamemodes/_mod.qh>
4 #include <common/gamemodes/gamemode/ctf/sv_ctf.qh>
5 #include <common/mapobjects/trigger/counter.qh>
6 #include <common/mapobjects/triggers.qh>
7 #include <common/mutators/mutator/buffs/buffs.qh>
8 #include <common/mutators/mutator/buffs/sv_buffs.qh>
9 #include <common/mutators/mutator/status_effects/_mod.qh>
10 #include <common/notifications/all.qh>
11 #include <common/stats.qh>
12 #include <common/weapons/_all.qh>
13 #include <common/weapons/_all.qh>
14 #include <server/client.qh>
15 #include <server/items/items.qh>
16 #include <server/items/spawning.qh>
17 #include <server/resources.qh>
18 #include <server/world.qh>
20 //***********************
21 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
22 //***********************
24 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
27 SPAWNFUNC_ITEM(ammo_shells, ITEM_Shells)
30 SPAWNFUNC_ITEM(ammo_bullets, ITEM_Bullets)
33 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
36 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
37 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
40 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
41 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
44 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
45 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
48 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
49 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
52 SPAWNFUNC_WEAPON(weapon_bfg, WEP_CRYLINK)
53 SPAWNFUNC_ITEM(ammo_bfg, ITEM_Cells)
55 // grappling hook -> hook
56 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
59 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
62 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
63 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
64 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
65 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
67 // medkit -> armor (we have no holdables)
68 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
73 // weapon remove ent from df
74 void target_init_verify(entity this)
77 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
78 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
79 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
86 //setsize(targ, trigger.mins, trigger.maxs);
87 //setorigin(targ, trigger.origin);
92 void target_init_use(entity this, entity actor, entity trigger)
94 if (!(this.spawnflags & 1))
96 SetResource(actor, RES_ARMOR, start_armorvalue);
97 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
100 if (!(this.spawnflags & 2))
102 SetResource(actor, RES_HEALTH, start_health);
103 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
104 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
107 if (!(this.spawnflags & 4))
109 if(this.spawnflags & 32) // spawn with only melee
111 SetResource(actor, RES_SHELLS, 0);
112 SetResource(actor, RES_BULLETS, 0);
113 SetResource(actor, RES_ROCKETS, 0);
114 SetResource(actor, RES_CELLS, 0);
115 SetResource(actor, RES_PLASMA, 0);
116 SetResource(actor, RES_FUEL, 0);
118 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
122 SetResource(actor, RES_SHELLS, start_ammo_shells);
123 SetResource(actor, RES_BULLETS, start_ammo_nails);
124 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
125 SetResource(actor, RES_CELLS, start_ammo_cells);
126 SetResource(actor, RES_PLASMA, start_ammo_plasma);
127 SetResource(actor, RES_FUEL, start_ammo_fuel);
129 STAT(WEAPONS, actor) = start_weapons;
133 if (!(this.spawnflags & 8))
135 StatusEffects_remove(STATUSEFFECT_Strength, actor, STATUSEFFECT_REMOVE_NORMAL);
136 StatusEffects_remove(STATUSEFFECT_Shield, actor, STATUSEFFECT_REMOVE_NORMAL);
137 entity heldbuff = buff_FirstFromFlags(actor);
138 if(heldbuff) // TODO: make a dropbuffs function to handle this
140 int buffid = heldbuff.m_id;
141 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
142 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
143 if(!IS_INDEPENDENT_PLAYER(actor))
144 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
145 buff_RemoveAll(actor, STATUSEFFECT_REMOVE_NORMAL);
149 if (!(this.spawnflags & 16))
151 // We don't have holdables.
154 SUB_UseTargets(this, actor, trigger);
157 spawnfunc(target_init)
159 this.use = target_init_use;
160 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
163 // weapon give ent from defrag
164 void target_give_init(entity this)
166 IL_EACH(g_items, it.targetname == this.target,
168 if (it.classname == "weapon_devastator") {
169 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
170 this.netname = cons(this.netname, "devastator");
172 else if (it.classname == "weapon_vortex") {
173 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
174 this.netname = cons(this.netname, "vortex");
176 else if (it.classname == "weapon_electro") {
177 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
178 this.netname = cons(this.netname, "electro");
180 else if (it.classname == "weapon_hagar") {
181 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
182 this.netname = cons(this.netname, "hagar");
184 else if (it.classname == "weapon_crylink") {
185 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
186 this.netname = cons(this.netname, "crylink");
188 else if (it.classname == "weapon_mortar") {
189 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
190 this.netname = cons(this.netname, "mortar");
192 else if (it.classname == "weapon_shotgun") {
193 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
194 this.netname = cons(this.netname, "shotgun");
196 else if (it.classname == "item_armor_mega")
197 SetResourceExplicit(this, RES_ARMOR, 100);
198 else if (it.classname == "item_health_mega")
199 SetResourceExplicit(this, RES_HEALTH, 200);
200 else if (it.classname == "item_buff") {
201 entity buff = it.buffdef;
202 this.netname = cons(this.netname, buff.netname);
203 this.buffs_finished = it.count;
206 //remove(it); // removing ents in init functions causes havoc, workaround:
207 setthink(it, SUB_Remove);
211 this.spawnfunc_checked = true;
212 spawnfunc_target_items(this);
213 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
216 spawnfunc(target_give)
218 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
221 void score_use(entity this, entity actor, entity trigger)
223 if(!IS_PLAYER(actor))
225 actor.fragsfilter_cnt += this.count;
227 spawnfunc(target_score)
229 if(!g_cts) { delete(this); return; }
233 this.use = score_use;
236 void fragsfilter_use(entity this, entity actor, entity trigger)
238 if(!IS_PLAYER(actor))
240 if(actor.fragsfilter_cnt >= this.frags)
241 SUB_UseTargets(this, actor, trigger);
243 spawnfunc(target_fragsFilter)
245 if(!g_cts) { delete(this); return; }
249 this.use = fragsfilter_use;
252 //spawnfunc(item_flight) /* handled by buffs mutator */
253 //spawnfunc(item_doubler) /* handled by buffs mutator */
254 //spawnfunc(item_haste) /* handled by buffs mutator */
255 //spawnfunc(item_health) /* handled in t_quake.qc */
256 //spawnfunc(item_health_large) /* handled in items.qc */
257 //spawnfunc(item_health_small) /* handled in items.qc */
258 //spawnfunc(item_health_mega) /* handled in items.qc */
259 //spawnfunc(item_invis) /* handled by buffs mutator */
260 //spawnfunc(item_regen) /* handled by buffs mutator */
262 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
270 bool DoesQ3ARemoveThisEntity(entity this)
272 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
275 if(!teamplay || g_tdm || g_ctf)
279 if (!(!teamplay || g_tdm || g_ctf))
297 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
298 gametypename = "ffa";
300 gametypename = "team";
302 gametypename = "ctf";
303 if(g_ctf && ctf_oneflag)
304 gametypename = "oneflag";
306 gametypename = "tournament";
308 gametypename = "single";
309 // we do not have the other types (obelisk, harvester, teamtournament)
310 if(strstrofs(this.gametype, gametypename, 0) < 0)