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