3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
5 #include <server/items/items.qh>
6 #include <server/items/spawning.qh>
7 #include <server/resources.qh>
8 #include <common/gamemodes/_mod.qh>
9 #include <common/gamemodes/gamemode/ctf/sv_ctf.qh>
10 #include <common/mapobjects/triggers.qh>
11 #include <common/mapobjects/trigger/counter.qh>
12 #include <common/mutators/mutator/buffs/buffs.qh>
13 #include <common/notifications/all.qh>
14 #include <common/weapons/_all.qh>
16 //***********************
17 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
18 //***********************
20 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
23 SPAWNFUNC_ITEM(ammo_shells, ITEM_Shells)
26 SPAWNFUNC_ITEM(ammo_bullets, ITEM_Bullets)
29 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
32 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
33 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
36 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
37 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
40 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
41 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
44 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
45 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
48 SPAWNFUNC_WEAPON(weapon_bfg, WEP_CRYLINK)
49 SPAWNFUNC_ITEM(ammo_bfg, ITEM_Cells)
51 // grappling hook -> hook
52 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
55 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
58 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
59 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
60 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
61 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
63 // medkit -> armor (we have no holdables)
64 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorBig)
69 // weapon remove ent from df
70 void target_init_verify(entity this)
73 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
74 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
75 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
82 //setsize(targ, trigger.mins, trigger.maxs);
83 //setorigin(targ, trigger.origin);
88 void target_init_use(entity this, entity actor, entity trigger)
90 if (!(this.spawnflags & 1))
92 SetResource(actor, RES_ARMOR, start_armorvalue);
93 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
96 if (!(this.spawnflags & 2))
98 SetResource(actor, RES_HEALTH, start_health);
99 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
100 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
103 if (!(this.spawnflags & 4))
105 if(this.spawnflags & 32) // spawn with only melee
107 SetResource(actor, RES_SHELLS, 0);
108 SetResource(actor, RES_BULLETS, 0);
109 SetResource(actor, RES_ROCKETS, 0);
110 SetResource(actor, RES_CELLS, 0);
111 SetResource(actor, RES_PLASMA, 0);
112 SetResource(actor, RES_FUEL, 0);
114 STAT(WEAPONS, actor) = WEPSET(SHOTGUN);
118 SetResource(actor, RES_SHELLS, start_ammo_shells);
119 SetResource(actor, RES_BULLETS, start_ammo_nails);
120 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
121 SetResource(actor, RES_CELLS, start_ammo_cells);
122 SetResource(actor, RES_PLASMA, start_ammo_plasma);
123 SetResource(actor, RES_FUEL, start_ammo_fuel);
125 STAT(WEAPONS, actor) = start_weapons;
129 if (!(this.spawnflags & 8))
131 STAT(STRENGTH_FINISHED, actor) = 0;
132 STAT(INVINCIBLE_FINISHED, actor) = 0;
133 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
135 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
136 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
137 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
138 if(!IS_INDEPENDENT_PLAYER(actor))
139 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
140 STAT(BUFFS, actor) = 0;
141 STAT(BUFF_TIME, actor) = 0;
145 if (!(this.spawnflags & 16))
147 // We don't have holdables.
150 SUB_UseTargets(this, actor, trigger);
153 spawnfunc(target_init)
155 this.use = target_init_use;
156 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
159 // weapon give ent from defrag
160 void target_give_init(entity this)
162 IL_EACH(g_items, it.targetname == this.target,
164 if (it.classname == "weapon_devastator") {
165 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
166 this.netname = cons(this.netname, "devastator");
168 else if (it.classname == "weapon_vortex") {
169 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
170 this.netname = cons(this.netname, "vortex");
172 else if (it.classname == "weapon_electro") {
173 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
174 this.netname = cons(this.netname, "electro");
176 else if (it.classname == "weapon_hagar") {
177 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
178 this.netname = cons(this.netname, "hagar");
180 else if (it.classname == "weapon_crylink") {
181 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
182 this.netname = cons(this.netname, "crylink");
184 else if (it.classname == "weapon_mortar") {
185 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
186 this.netname = cons(this.netname, "mortar");
188 else if (it.classname == "weapon_shotgun") {
189 SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
190 this.netname = cons(this.netname, "shotgun");
192 else if (it.classname == "item_armor_mega")
193 SetResourceExplicit(this, RES_ARMOR, 100);
194 else if (it.classname == "item_health_mega")
195 SetResourceExplicit(this, RES_HEALTH, 200);
196 else if (it.classname == "item_buff") {
197 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
198 this.netname = cons(this.netname, buff.netname);
199 STAT(BUFF_TIME, this) = it.count;
202 //remove(it); // removing ents in init functions causes havoc, workaround:
203 setthink(it, SUB_Remove);
207 this.spawnfunc_checked = true;
208 spawnfunc_target_items(this);
209 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
212 spawnfunc(target_give)
214 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
217 void score_use(entity this, entity actor, entity trigger)
219 if(!IS_PLAYER(actor))
221 actor.fragsfilter_cnt += this.count;
223 spawnfunc(target_score)
225 if(!g_cts) { delete(this); return; }
229 this.use = score_use;
232 void fragsfilter_use(entity this, entity actor, entity trigger)
234 if(!IS_PLAYER(actor))
236 if(actor.fragsfilter_cnt >= this.frags)
237 SUB_UseTargets(this, actor, trigger);
239 spawnfunc(target_fragsFilter)
241 if(!g_cts) { delete(this); return; }
245 this.use = fragsfilter_use;
248 //spawnfunc(item_flight) /* handled by buffs mutator */
249 //spawnfunc(item_doubler) /* handled by buffs mutator */
250 //spawnfunc(item_haste) /* handled by buffs mutator */
251 //spawnfunc(item_health) /* handled in t_quake.qc */
252 //spawnfunc(item_health_large) /* handled in items.qc */
253 //spawnfunc(item_health_small) /* handled in items.qc */
254 //spawnfunc(item_health_mega) /* handled in items.qc */
255 //spawnfunc(item_invis) /* handled by buffs mutator */
256 //spawnfunc(item_regen) /* handled by buffs mutator */
258 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
266 bool DoesQ3ARemoveThisEntity(entity this)
268 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
271 if(!teamplay || g_tdm || g_ctf)
275 if (!(!teamplay || g_tdm || g_ctf))
293 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
294 gametypename = "ffa";
296 gametypename = "team";
298 gametypename = "ctf";
299 if(g_ctf && ctf_oneflag)
300 gametypename = "oneflag";
302 gametypename = "tournament";
304 gametypename = "single";
305 // we do not have the other types (obelisk, harvester, teamtournament)
306 if(strstrofs(this.gametype, gametypename, 0) < 0)