]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/compat/quake3.qc
Mark [[eraseable]] most of the common functions in the lib directory. Since many...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / compat / quake3.qc
1 #include "quake3.qh"
2
3 #include <common/weapons/_all.qh>
4
5 spawnfunc(weapon_crylink);
6 spawnfunc(weapon_electro);
7 spawnfunc(weapon_hagar);
8 spawnfunc(weapon_machinegun);
9 spawnfunc(weapon_vortex);
10 spawnfunc(weapon_minelayer);
11
12 spawnfunc(target_items);
13
14 spawnfunc(item_bullets);
15 spawnfunc(item_cells);
16 spawnfunc(item_rockets);
17 spawnfunc(item_shells);
18
19 spawnfunc(item_strength);
20
21 spawnfunc(item_armor_big);
22 spawnfunc(item_armor_mega);
23 spawnfunc(item_armor_small);
24
25 spawnfunc(item_health_medium);
26 spawnfunc(item_health_mega);
27
28 //***********************
29 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
30 //***********************
31
32 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
33
34 // SG -> SG
35 spawnfunc(ammo_shells)         { spawnfunc_item_shells(this);         }
36
37 // MG -> MG
38 spawnfunc(ammo_bullets)        { spawnfunc_item_bullets(this);        }
39
40 // GL -> Mortar
41 spawnfunc(ammo_grenades)       { spawnfunc_item_rockets(this);        }
42
43 // Mines -> Rockets
44 spawnfunc(weapon_prox_launcher) { spawnfunc_weapon_minelayer(this);   }
45 spawnfunc(ammo_mines)           { spawnfunc_item_rockets(this);       }
46
47 // LG -> Lightning
48 spawnfunc(weapon_lightning)    { spawnfunc_weapon_electro(this);      }
49 spawnfunc(ammo_lightning)      { spawnfunc_item_cells(this);          }
50
51 // Plasma -> Hagar
52 spawnfunc(weapon_plasmagun)    { spawnfunc_weapon_hagar(this);        }
53 spawnfunc(ammo_cells)          { spawnfunc_item_rockets(this);        }
54
55 // Rail -> Vortex
56 spawnfunc(weapon_railgun)      { spawnfunc_weapon_vortex(this);       }
57 spawnfunc(ammo_slugs)          { spawnfunc_item_cells(this);          }
58
59 // BFG -> Crylink
60 spawnfunc(weapon_bfg)          { spawnfunc_weapon_crylink(this);      }
61 spawnfunc(ammo_bfg)            { spawnfunc_item_cells(this);          }
62
63 // RL -> RL
64 spawnfunc(ammo_rockets)        { spawnfunc_item_rockets(this);        }
65
66 // Armor
67 spawnfunc(item_armor_body)     { spawnfunc_item_armor_mega(this);     }
68 spawnfunc(item_armor_combat)   { spawnfunc_item_armor_big(this);      }
69 spawnfunc(item_armor_shard)    { spawnfunc_item_armor_small(this);    }
70 spawnfunc(item_enviro)         { spawnfunc_item_invincible(this);     }
71
72 // medkit -> armor (we have no holdables)
73 spawnfunc(holdable_medkit)         { spawnfunc_item_armor_mega(this);     }
74
75 // doubler -> strength
76 spawnfunc(item_doubler)        { spawnfunc_item_strength(this); }
77
78 .float wait;
79 .float delay;
80
81 // weapon remove ent from df
82 void target_init_verify(entity this)
83 {
84         entity trigger, targ;
85         for(trigger = NULL; (trigger = find(trigger, classname, "trigger_multiple")); )
86                 for(targ = NULL; (targ = find(targ, targetname, trigger.target)); )
87                         if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
88                         {
89                                 trigger.wait = 0;
90                                 trigger.delay = 0;
91                                 targ.wait = 0;
92                                 targ.delay = 0;
93
94                                 //setsize(targ, trigger.mins, trigger.maxs);
95                                 //setorigin(targ, trigger.origin);
96                                 //remove(trigger);
97                         }
98 }
99
100 spawnfunc(target_init)
101 {
102         this.spawnflags = 0; // remove all weapons except the ones listed below
103         this.netname = "shotgun"; // keep these weapons through the remove trigger
104         spawnfunc_target_items(this);
105         InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
106 }
107
108 // weapon give ent from defrag
109 void target_give_init(entity this)
110 {
111         IL_EACH(g_items, it.targetname == this.target,
112         {
113                 if (it.classname == "weapon_rocketlauncher" || it.classname == "weapon_devastator") {
114                         this.ammo_rockets += it.count * WEP_CVAR(devastator, ammo);
115                         this.netname = "devastator";
116                 }
117                 else if (it.classname == "weapon_lightning") {
118                         this.ammo_cells += it.count * WEP_CVAR_PRI(electro, ammo); // WEAPONTODO
119                         if(this.netname == "")
120                                 this.netname = "electro";
121                         else
122                                 this.netname = strcat(this.netname, " electro");
123                 }
124                 else if (it.classname == "weapon_plasmagun") {
125                         this.ammo_rockets += it.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
126                         if(this.netname == "")
127                                 this.netname = "hagar";
128                         else
129                                 this.netname = strcat(this.netname, " hagar");
130                 }
131                 else if (it.classname == "weapon_bfg") {
132                         this.ammo_cells += it.count * WEP_CVAR_PRI(crylink, ammo);
133                         if(this.netname == "")
134                                 this.netname = "crylink";
135                         else
136                                 this.netname = strcat(this.netname, " crylink");
137                 }
138                 else if (it.classname == "weapon_grenadelauncher" || it.classname == "weapon_mortar") {
139                         this.ammo_rockets += it.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
140                         if(this.netname == "")
141                                 this.netname = "mortar";
142                         else
143                                 this.netname = strcat(this.netname, " mortar");
144                 }
145                 else if (it.classname == "item_armor_body")
146                         this.armorvalue = 100;
147                 else if (it.classname == "item_health_mega")
148                         this.health = 200;
149                 //remove(it); // removing ents in init functions causes havoc, workaround:
150         setthink(it, SUB_Remove);
151         it.nextthink = time;
152         });
153         this.spawnflags = 2;
154         this.spawnfunc_checked = true;
155         spawnfunc_target_items(this);
156         InitializeEntity(this, target_init_verify, INITPRIO_FINDTARGET);
157 }
158
159 spawnfunc(target_give)
160 {
161         InitializeEntity(this, target_give_init, INITPRIO_FINDTARGET);
162 }
163
164 //spawnfunc(item_flight)       /* handled by buffs mutator */
165 //spawnfunc(item_haste)        /* handled by buffs mutator */
166 //spawnfunc(item_health)       /* handled in t_quake.qc */
167 //spawnfunc(item_health_large) /* handled in t_items.qc */
168 //spawnfunc(item_health_small) /* handled in t_items.qc */
169 //spawnfunc(item_health_mega)  /* handled in t_items.qc */
170 //spawnfunc(item_invis)        /* handled by buffs mutator */
171 //spawnfunc(item_regen)        /* handled by buffs mutator */
172
173 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
174
175 .float notteam;
176 .float notsingle;
177 .float notfree;
178 .float notq3a;
179 .float notta;
180 .string gametype;
181 bool DoesQ3ARemoveThisEntity(entity this)
182 {
183         // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
184
185         if(this.notq3a)
186                 if(!teamplay || g_tdm || g_ctf)
187                         return true;
188
189         if(this.notta)
190                 if (!(!teamplay || g_tdm || g_ctf))
191                         return true;
192
193         if(this.notsingle)
194                 if(maxclients == 1)
195                         return true;
196
197         if(this.notteam)
198                 if(teamplay)
199                         return true;
200
201         if(this.notfree)
202                 if(!teamplay)
203                         return true;
204
205         if(this.gametype)
206         {
207                 string gametypename;
208                 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
209                 gametypename = "ffa";
210                 if(teamplay)
211                         gametypename = "team";
212                 if(g_ctf)
213                         gametypename = "ctf";
214                 if(maxclients == 1)
215                         gametypename = "single";
216                 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
217                 if(strstrofs(this.gametype, gametypename, 0) < 0)
218                         return true;
219         }
220
221         return false;
222 }