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/notifications/all.qh>
9 #include <common/stats.qh>
10 #include <common/weapons/_all.qh>
11 #include <common/weapons/_all.qh>
12 #include <server/client.qh>
13 #include <server/items/items.qh>
14 #include <server/items/spawning.qh>
15 #include <server/resources.qh>
16 #include <server/world.qh>
18 //***********************
19 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
20 //***********************
22 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
25 SPAWNFUNC_ITEM(ammo_shells, ITEM_Shells)
28 SPAWNFUNC_ITEM(ammo_bullets, ITEM_Bullets)
31 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
34 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
35 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
38 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
39 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
42 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
43 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
46 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
47 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
50 SPAWNFUNC_WEAPON(weapon_bfg, WEP_CRYLINK)
51 SPAWNFUNC_ITEM(ammo_bfg, ITEM_Cells)
53 // grappling hook -> hook
54 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
57 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
60 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
61 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
62 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
63 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
65 // medkit -> armor (we have no holdables)
66 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
71 // weapon remove ent from df
72 void target_init_verify(entity this)
75 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
76 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
77 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
84 //setsize(targ, trigger.mins, trigger.maxs);
85 //setorigin(targ, trigger.origin);
90 void target_init_use(entity this, entity actor, entity trigger)
92 if (!(this.spawnflags & 1))
94 SetResource(actor, RES_ARMOR, start_armorvalue);
95 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
98 if (!(this.spawnflags & 2))
100 SetResource(actor, RES_HEALTH, start_health);
101 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
102 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
105 if (!(this.spawnflags & 4))
107 if(this.spawnflags & 32) // spawn with only melee
109 SetResource(actor, RES_SHELLS, 0);
110 SetResource(actor, RES_BULLETS, 0);
111 SetResource(actor, RES_ROCKETS, 0);
112 SetResource(actor, RES_CELLS, 0);
113 SetResource(actor, RES_PLASMA, 0);
114 SetResource(actor, RES_FUEL, 0);
116 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
120 SetResource(actor, RES_SHELLS, start_ammo_shells);
121 SetResource(actor, RES_BULLETS, start_ammo_nails);
122 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
123 SetResource(actor, RES_CELLS, start_ammo_cells);
124 SetResource(actor, RES_PLASMA, start_ammo_plasma);
125 SetResource(actor, RES_FUEL, start_ammo_fuel);
127 STAT(WEAPONS, actor) = start_weapons;
131 if (!(this.spawnflags & 8))
133 STAT(STRENGTH_FINISHED, actor) = 0;
134 STAT(INVINCIBLE_FINISHED, actor) = 0;
135 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
137 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
138 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
139 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
140 if(!IS_INDEPENDENT_PLAYER(actor))
141 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
142 STAT(BUFFS, actor) = 0;
143 STAT(BUFF_TIME, actor) = 0;
147 if (!(this.spawnflags & 16))
149 // We don't have holdables.
152 SUB_UseTargets(this, actor, trigger);
155 spawnfunc(target_init)
157 this.use = target_init_use;
158 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
161 // weapon give ent from defrag
162 void target_give_init(entity this)
164 IL_EACH(g_items, it.targetname == this.target,
166 if (it.classname == "weapon_devastator") {
167 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
168 this.netname = cons(this.netname, "devastator");
170 else if (it.classname == "weapon_vortex") {
171 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
172 this.netname = cons(this.netname, "vortex");
174 else if (it.classname == "weapon_electro") {
175 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
176 this.netname = cons(this.netname, "electro");
178 else if (it.classname == "weapon_hagar") {
179 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
180 this.netname = cons(this.netname, "hagar");
182 else if (it.classname == "weapon_crylink") {
183 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
184 this.netname = cons(this.netname, "crylink");
186 else if (it.classname == "weapon_mortar") {
187 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
188 this.netname = cons(this.netname, "mortar");
190 else if (it.classname == "weapon_shotgun") {
191 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
192 this.netname = cons(this.netname, "shotgun");
194 else if (it.classname == "item_armor_mega")
195 SetResourceExplicit(this, RES_ARMOR, 100);
196 else if (it.classname == "item_health_mega")
197 SetResourceExplicit(this, RES_HEALTH, 200);
198 else if (it.classname == "item_buff") {
199 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
200 this.netname = cons(this.netname, buff.netname);
201 STAT(BUFF_TIME, this) = it.count;
204 //remove(it); // removing ents in init functions causes havoc, workaround:
205 setthink(it, SUB_Remove);
209 this.spawnfunc_checked = true;
210 spawnfunc_target_items(this);
211 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
214 spawnfunc(target_give)
216 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
219 void score_use(entity this, entity actor, entity trigger)
221 if(!IS_PLAYER(actor))
223 actor.fragsfilter_cnt += this.count;
225 spawnfunc(target_score)
227 if(!g_cts) { delete(this); return; }
231 this.use = score_use;
234 void fragsfilter_use(entity this, entity actor, entity trigger)
236 if(!IS_PLAYER(actor))
238 if(actor.fragsfilter_cnt >= this.frags)
239 SUB_UseTargets(this, actor, trigger);
241 spawnfunc(target_fragsFilter)
243 if(!g_cts) { delete(this); return; }
247 this.use = fragsfilter_use;
250 //spawnfunc(item_flight) /* handled by buffs mutator */
251 //spawnfunc(item_doubler) /* handled by buffs mutator */
252 //spawnfunc(item_haste) /* handled by buffs mutator */
253 //spawnfunc(item_health) /* handled in t_quake.qc */
254 //spawnfunc(item_health_large) /* handled in items.qc */
255 //spawnfunc(item_health_small) /* handled in items.qc */
256 //spawnfunc(item_health_mega) /* handled in items.qc */
257 //spawnfunc(item_invis) /* handled by buffs mutator */
258 //spawnfunc(item_regen) /* handled by buffs mutator */
260 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
268 bool DoesQ3ARemoveThisEntity(entity this)
270 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
273 if(!teamplay || g_tdm || g_ctf)
277 if (!(!teamplay || g_tdm || g_ctf))
295 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
296 gametypename = "ffa";
298 gametypename = "team";
300 gametypename = "ctf";
301 if(g_ctf && ctf_oneflag)
302 gametypename = "oneflag";
304 gametypename = "tournament";
306 gametypename = "single";
307 // we do not have the other types (obelisk, harvester, teamtournament)
308 if(strstrofs(this.gametype, gametypename, 0) < 0)