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