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