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