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/weapons/_all.qh>
12 //***********************
13 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
14 //***********************
16 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
19 SPAWNFUNC_ITEM(ammo_shells, ITEM_Shells)
22 SPAWNFUNC_ITEM(ammo_bullets, ITEM_Bullets)
25 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
28 SPAWNFUNC_WEAPON(weapon_prox_launcher, WEP_MINE_LAYER)
29 SPAWNFUNC_ITEM(ammo_mines, ITEM_Rockets)
32 SPAWNFUNC_WEAPON(weapon_lightning, WEP_ELECTRO)
33 SPAWNFUNC_ITEM(ammo_lightning, ITEM_Cells)
36 SPAWNFUNC_WEAPON(weapon_plasmagun, WEP_HAGAR)
37 SPAWNFUNC_ITEM(ammo_cells, ITEM_Rockets)
40 SPAWNFUNC_WEAPON(weapon_railgun, WEP_VORTEX)
41 SPAWNFUNC_ITEM(ammo_slugs, ITEM_Cells)
44 SPAWNFUNC_WEAPON(weapon_bfg, WEP_CRYLINK)
45 SPAWNFUNC_ITEM(ammo_bfg, ITEM_Cells)
47 // grappling hook -> hook
48 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)
51 SPAWNFUNC_ITEM(ammo_rockets, ITEM_Rockets)
54 SPAWNFUNC_ITEM(item_armor_body, ITEM_ArmorMega)
55 SPAWNFUNC_ITEM(item_armor_combat, ITEM_ArmorBig)
56 SPAWNFUNC_ITEM(item_armor_shard, ITEM_ArmorSmall)
57 SPAWNFUNC_ITEM(item_enviro, ITEM_Shield)
59 // medkit -> armor (we have no holdables)
60 SPAWNFUNC_ITEM(holdable_medkit, ITEM_ArmorMega)
62 // doubler -> strength
63 SPAWNFUNC_ITEM(item_doubler, ITEM_Strength)
68 // weapon remove ent from df
69 void target_init_verify(entity this)
72 for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
73 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
74 if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
81 //setsize(targ, trigger.mins, trigger.maxs);
82 //setorigin(targ, trigger.origin);
87 void target_init_use(entity this, entity actor, entity trigger)
89 if (!(this.spawnflags & 1))
91 SetResource(actor, RES_ARMOR, start_armorvalue);
92 actor.pauserotarmor_finished = time + autocvar_g_balance_pause_armor_rot;
95 if (!(this.spawnflags & 2))
97 SetResource(actor, RES_HEALTH, start_health);
98 actor.pauserothealth_finished = time + autocvar_g_balance_pause_health_rot;
99 actor.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
102 if (!(this.spawnflags & 4))
104 SetResource(actor, RES_SHELLS, start_ammo_shells);
105 SetResource(actor, RES_BULLETS, start_ammo_nails);
106 SetResource(actor, RES_ROCKETS, start_ammo_rockets);
107 SetResource(actor, RES_CELLS, start_ammo_cells);
108 SetResource(actor, RES_PLASMA, start_ammo_plasma);
109 SetResource(actor, RES_FUEL, start_ammo_fuel);
111 STAT(WEAPONS, actor) = start_weapons;
112 if (this.spawnflags & 32)
118 if (!(this.spawnflags & 8))
120 actor.strength_finished = 0;
121 actor.invincible_finished = 0;
122 if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
124 int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
125 Send_Notification(NOTIF_ONE, actor, MSG_MULTI, ITEM_BUFF_DROP, buffid);
126 sound(actor, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM);
127 if(!IS_INDEPENDENT_PLAYER(actor))
128 Send_Notification(NOTIF_ALL_EXCEPT, actor, MSG_INFO, INFO_ITEM_BUFF_LOST, actor.netname, buffid);
129 STAT(BUFFS, actor) = 0;
130 STAT(BUFF_TIME, actor) = 0;
134 if (!(this.spawnflags & 16))
136 // We don't have holdables.
139 SUB_UseTargets(this, actor, trigger);
142 spawnfunc(target_init)
144 this.use = target_init_use;
145 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
148 // weapon give ent from defrag
149 void target_give_init(entity this)
151 IL_EACH(g_items, it.targetname == this.target,
153 if (it.classname == "weapon_devastator") {
154 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
155 this.netname = cons(this.netname, "devastator");
157 else if (it.classname == "weapon_vortex") {
158 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
159 this.netname = cons(this.netname, "vortex");
161 else if (it.classname == "weapon_electro") {
162 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
163 this.netname = cons(this.netname, "electro");
165 else if (it.classname == "weapon_hagar") {
166 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
167 this.netname = cons(this.netname, "hagar");
169 else if (it.classname == "weapon_crylink") {
170 SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
171 this.netname = cons(this.netname, "crylink");
173 else if (it.classname == "weapon_mortar") {
174 SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
175 this.netname = cons(this.netname, "mortar");
177 else if (it.classname == "item_armor_mega")
178 SetResourceExplicit(this, RES_ARMOR, 100);
179 else if (it.classname == "item_health_mega")
180 SetResourceExplicit(this, RES_HEALTH, 200);
181 else if (it.classname == "item_buff") {
182 entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
183 this.netname = cons(this.netname, buff.netname);
184 STAT(BUFF_TIME, this) = it.count;
187 //remove(it); // removing ents in init functions causes havoc, workaround:
188 setthink(it, SUB_Remove);
192 this.spawnfunc_checked = true;
193 spawnfunc_target_items(this);
194 InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
197 spawnfunc(target_give)
199 InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
202 void score_use(entity this, entity actor, entity trigger)
204 if(!IS_PLAYER(actor))
206 actor.fragsfilter_cnt += this.count;
208 spawnfunc(target_score)
210 if(!g_cts) { delete(this); return; }
214 this.use = score_use;
217 void fragsfilter_use(entity this, entity actor, entity trigger)
219 if(!IS_PLAYER(actor))
221 if(actor.fragsfilter_cnt >= this.frags)
222 SUB_UseTargets(this, actor, trigger);
224 spawnfunc(target_fragsFilter)
226 if(!g_cts) { delete(this); return; }
230 this.use = fragsfilter_use;
233 //spawnfunc(item_flight) /* handled by buffs mutator */
234 //spawnfunc(item_haste) /* handled by buffs mutator */
235 //spawnfunc(item_health) /* handled in t_quake.qc */
236 //spawnfunc(item_health_large) /* handled in t_items.qc */
237 //spawnfunc(item_health_small) /* handled in t_items.qc */
238 //spawnfunc(item_health_mega) /* handled in t_items.qc */
239 //spawnfunc(item_invis) /* handled by buffs mutator */
240 //spawnfunc(item_regen) /* handled by buffs mutator */
242 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
250 bool DoesQ3ARemoveThisEntity(entity this)
252 // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
255 if(!teamplay || g_tdm || g_ctf)
259 if (!(!teamplay || g_tdm || g_ctf))
277 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
278 gametypename = "ffa";
280 gametypename = "team";
282 gametypename = "ctf";
284 gametypename = "tournament";
286 gametypename = "single";
287 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
288 if(strstrofs(this.gametype, gametypename, 0) < 0)