3 #include <server/client.qh>
4 #include <common/weapons/_all.qh>
5 #include <common/stats.qh>
6 #include <server/miscfunctions.qh>
7 #include <server/items/items.qh>
8 #include <server/items/spawning.qh>
9 #include <server/resources.qh>
10 #include <server/world.qh>
11 #include <common/gamemodes/_mod.qh>
12 #include <common/gamemodes/gamemode/ctf/sv_ctf.qh>
13 #include <common/mapobjects/triggers.qh>
14 #include <common/mapobjects/trigger/counter.qh>
15 #include <common/mutators/mutator/buffs/buffs.qh>
16 #include <common/notifications/all.qh>
17 #include <common/weapons/_all.qh>
19 //***********************
20 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
21 //***********************
23 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
26 SPAWNFUNC_ITEM(ammo_shells, ITEM_Shells)
29 SPAWNFUNC_ITEM(ammo_bullets, ITEM_Bullets)
32 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
35 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
36 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
39 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
40 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
43 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
44 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
47 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
48 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
51 SPAWNFUNC_WEAPON(weapon_bfg, WEP_CRYLINK)
52 SPAWNFUNC_ITEM(ammo_bfg, ITEM_Cells)
54 // grappling hook -> hook
55 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
58 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
61 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
62 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
63 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
64 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
66 // medkit -> armor (we have no holdables)
67 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
72 // weapon remove ent from df
73 void target_init_verify(entity this)
76 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
77 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
78 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
85 //setsize(targ, trigger.mins, trigger.maxs);
86 //setorigin(targ, trigger.origin);
91 void target_init_use(entity this, entity actor, entity trigger)
93 if (!(this.spawnflags & 1))
95 SetResource(actor, RES_ARMOR, start_armorvalue);
96 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
99 if (!(this.spawnflags & 2))
101 SetResource(actor, RES_HEALTH, start_health);
102 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
103 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
106 if (!(this.spawnflags & 4))
108 if(this.spawnflags & 32) // spawn with only melee
110 SetResource(actor, RES_SHELLS, 0);
111 SetResource(actor, RES_BULLETS, 0);
112 SetResource(actor, RES_ROCKETS, 0);
113 SetResource(actor, RES_CELLS, 0);
114 SetResource(actor, RES_PLASMA, 0);
115 SetResource(actor, RES_FUEL, 0);
117 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
121 SetResource(actor, RES_SHELLS, start_ammo_shells);
122 SetResource(actor, RES_BULLETS, start_ammo_nails);
123 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
124 SetResource(actor, RES_CELLS, start_ammo_cells);
125 SetResource(actor, RES_PLASMA, start_ammo_plasma);
126 SetResource(actor, RES_FUEL, start_ammo_fuel);
128 STAT(WEAPONS, actor) = start_weapons;
132 if (!(this.spawnflags & 8))
134 STAT(STRENGTH_FINISHED, actor) = 0;
135 STAT(INVINCIBLE_FINISHED, actor) = 0;
136 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
138 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
139 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
140 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
141 if(!IS_INDEPENDENT_PLAYER(actor))
142 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
143 STAT(BUFFS, actor) = 0;
144 STAT(BUFF_TIME, actor) = 0;
148 if (!(this.spawnflags & 16))
150 // We don't have holdables.
153 SUB_UseTargets(this, actor, trigger);
156 spawnfunc(target_init)
158 this.use = target_init_use;
159 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
162 // weapon give ent from defrag
163 void target_give_init(entity this)
165 IL_EACH(g_items, it.targetname == this.target,
167 if (it.classname == "weapon_devastator") {
168 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
169 this.netname = cons(this.netname, "devastator");
171 else if (it.classname == "weapon_vortex") {
172 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
173 this.netname = cons(this.netname, "vortex");
175 else if (it.classname == "weapon_electro") {
176 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
177 this.netname = cons(this.netname, "electro");
179 else if (it.classname == "weapon_hagar") {
180 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
181 this.netname = cons(this.netname, "hagar");
183 else if (it.classname == "weapon_crylink") {
184 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
185 this.netname = cons(this.netname, "crylink");
187 else if (it.classname == "weapon_mortar") {
188 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
189 this.netname = cons(this.netname, "mortar");
191 else if (it.classname == "weapon_shotgun") {
192 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
193 this.netname = cons(this.netname, "shotgun");
195 else if (it.classname == "item_armor_mega")
196 SetResourceExplicit(this, RES_ARMOR, 100);
197 else if (it.classname == "item_health_mega")
198 SetResourceExplicit(this, RES_HEALTH, 200);
199 else if (it.classname == "item_buff") {
200 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
201 this.netname = cons(this.netname, buff.netname);
202 STAT(BUFF_TIME, this) = it.count;
205 //remove(it); // removing ents in init functions causes havoc, workaround:
206 setthink(it, SUB_Remove);
210 this.spawnfunc_checked = true;
211 spawnfunc_target_items(this);
212 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
215 spawnfunc(target_give)
217 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
220 void score_use(entity this, entity actor, entity trigger)
222 if(!IS_PLAYER(actor))
224 actor.fragsfilter_cnt += this.count;
226 spawnfunc(target_score)
228 if(!g_cts) { delete(this); return; }
232 this.use = score_use;
235 void fragsfilter_use(entity this, entity actor, entity trigger)
237 if(!IS_PLAYER(actor))
239 if(actor.fragsfilter_cnt >= this.frags)
240 SUB_UseTargets(this, actor, trigger);
242 spawnfunc(target_fragsFilter)
244 if(!g_cts) { delete(this); return; }
248 this.use = fragsfilter_use;
251 //spawnfunc(item_flight) /* handled by buffs mutator */
252 //spawnfunc(item_doubler) /* handled by buffs mutator */
253 //spawnfunc(item_haste) /* handled by buffs mutator */
254 //spawnfunc(item_health) /* handled in t_quake.qc */
255 //spawnfunc(item_health_large) /* handled in items.qc */
256 //spawnfunc(item_health_small) /* handled in items.qc */
257 //spawnfunc(item_health_mega) /* handled in items.qc */
258 //spawnfunc(item_invis) /* handled by buffs mutator */
259 //spawnfunc(item_regen) /* handled by buffs mutator */
261 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
269 bool DoesQ3ARemoveThisEntity(entity this)
271 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
274 if(!teamplay || g_tdm || g_ctf)
278 if (!(!teamplay || g_tdm || g_ctf))
296 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
297 gametypename = "ffa";
299 gametypename = "team";
301 gametypename = "ctf";
302 if(g_ctf && ctf_oneflag)
303 gametypename = "oneflag";
305 gametypename = "tournament";
307 gametypename = "single";
308 // we do not have the other types (obelisk, harvester, teamtournament)
309 if(strstrofs(this.gametype, gametypename, 0) < 0)