]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/t_quake3.qc
Make most server includes order insensitive
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_quake3.qc
1 #include "_.qh"
2
3 #include "../common/weapons/weapons.qc"
4
5 //***********************
6 //QUAKE 3 ENTITIES - So people can play quake3 maps with the xonotic weapons
7 //***********************
8
9 // NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
10
11 // SG -> SG
12 void spawnfunc_ammo_shells()         { spawnfunc_item_shells();         }
13
14 // MG -> MG
15 void spawnfunc_ammo_bullets()        { spawnfunc_item_bullets();        }
16
17 // GL -> Mortar
18 void spawnfunc_ammo_grenades()       { spawnfunc_item_rockets();        }
19
20 // LG -> Lightning
21 void spawnfunc_weapon_lightning()    { spawnfunc_weapon_electro();      }
22 void spawnfunc_ammo_lightning()      { spawnfunc_item_cells();          }
23
24 // Plasma -> Hagar
25 void spawnfunc_weapon_plasmagun()    { spawnfunc_weapon_hagar();        }
26 void spawnfunc_ammo_cells()          { spawnfunc_item_rockets();        }
27
28 // Rail -> Vortex
29 void spawnfunc_weapon_railgun()      { spawnfunc_weapon_vortex();          }
30 void spawnfunc_ammo_slugs()          { spawnfunc_item_cells();          }
31
32 // BFG -> Crylink
33 void spawnfunc_weapon_bfg()          { spawnfunc_weapon_crylink();      }
34 void spawnfunc_ammo_bfg()            { spawnfunc_item_cells();          }
35
36 // RL -> RL
37 void spawnfunc_ammo_rockets()        { spawnfunc_item_rockets();        }
38
39 // Armor
40 void spawnfunc_item_armor_body()     { spawnfunc_item_armor_large();    }
41 void spawnfunc_item_armor_combat()   { spawnfunc_item_armor_big();      }
42 void spawnfunc_item_armor_shard()    { spawnfunc_item_armor_small();    }
43 void spawnfunc_item_enviro()         { spawnfunc_item_invincible();     }
44
45 // weapon remove ent from df
46 void target_init_verify()
47 {
48         entity trigger, targ;
49         for(trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); )
50                 for(targ = world; (targ = find(targ, targetname, trigger.target)); )
51                         if (targ.classname == "target_init" || targ.classname == "target_give" || targ.classname == "target_items")
52                         {
53                                 trigger.wait = 0;
54                                 trigger.delay = 0;
55                                 targ.wait = 0;
56                                 targ.delay = 0;
57
58                                 //setsize(targ, trigger.mins, trigger.maxs);
59                                 //setorigin(targ, trigger.origin);
60                                 //remove(trigger);
61                         }
62 }
63
64 void spawnfunc_target_init()
65 {
66         self.spawnflags = 0; // remove all weapons except the ones listed below
67         self.netname = "shotgun"; // keep these weapons through the remove trigger
68         spawnfunc_target_items();
69         InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
70 }
71
72 // weapon give ent from defrag
73 void target_give_init()
74 {
75         entity targ;
76         for (targ = world; (targ = find(targ, targetname, self.target)); ) {
77                 if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") {
78                         self.ammo_rockets += targ.count * WEP_CVAR(devastator, ammo);
79                         self.netname = "devastator";
80                 }
81                 else if (targ.classname == "weapon_plasmagun") {
82                         self.ammo_rockets += targ.count * WEP_CVAR_PRI(hagar, ammo); // WEAPONTODO
83                         if(self.netname == "")
84                                 self.netname = "hagar";
85                         else
86                                 self.netname = strcat(self.netname, " hagar");
87                 }
88                 else if (targ.classname == "weapon_bfg") {
89                         self.ammo_cells += targ.count * WEP_CVAR_PRI(crylink, ammo);
90                         if(self.netname == "")
91                                 self.netname = "crylink";
92                         else
93                                 self.netname = strcat(self.netname, " crylink");
94                 }
95                 else if (targ.classname == "weapon_grenadelauncher" || targ.classname == "weapon_mortar") {
96                         self.ammo_rockets += targ.count * WEP_CVAR_PRI(mortar, ammo); // WEAPONTODO
97                         if(self.netname == "")
98                                 self.netname = "mortar";
99                         else
100                                 self.netname = strcat(self.netname, " mortar");
101                 }
102                 else if (targ.classname == "item_armor_body")
103                         self.armorvalue = 100;
104                 else if (targ.classname == "item_health_mega")
105                         self.health = 200;
106                 //remove(targ); // removing ents in init functions causes havoc, workaround:
107         targ.think = SUB_Remove;
108         targ.nextthink = time;
109         }
110         self.spawnflags = 2;
111         spawnfunc_target_items();
112         InitializeEntity(self, target_init_verify, INITPRIO_FINDTARGET);
113 }
114
115 void spawnfunc_target_give()
116 {
117         InitializeEntity(self, target_give_init, INITPRIO_FINDTARGET);
118 }
119
120 //void spawnfunc_item_flight()       /* handled by buffs mutator or jetpack */
121 //void spawnfunc_item_haste()        /* handled by buffs mutator */
122 //void spawnfunc_item_health()       /* handled in t_quake.qc */
123 //void spawnfunc_item_health_large() /* handled in t_items.qc */
124 //void spawnfunc_item_health_small() /* handled in t_items.qc */
125 //void spawnfunc_item_health_mega()  /* handled in t_items.qc */
126 //void spawnfunc_item_invis()        /* handled by buffs mutator */
127 //void spawnfunc_item_regen()        /* handled by buffs mutator */
128
129 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
130
131 void spawnfunc_item_flight()
132 {
133         if(!cvar("g_buffs") || !cvar("g_buffs_flight"))
134                 spawnfunc_item_jetpack();
135         else
136                 buff_Init_Compat(self, BUFF_FLIGHT);
137 }
138
139 .float notteam;
140 .float notsingle;
141 .float notfree;
142 .float notq3a;
143 .float notta;
144 .string gametype;
145 float DoesQ3ARemoveThisEntity()
146 {
147         // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
148
149         if(self.notq3a)
150                 if(!teamplay || g_tdm || g_ctf)
151                         return 1;
152
153         if(self.notta)
154                 if (!(!teamplay || g_tdm || g_ctf))
155                         return 1;
156
157         if(self.notsingle)
158                 if(maxclients == 1)
159                         return 1;
160
161         if(self.notteam)
162                 if(teamplay)
163                         return 1;
164
165         if(self.notfree)
166                 if(!teamplay)
167                         return 1;
168
169         if(self.gametype)
170         {
171                 string gametypename;
172                 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
173                 gametypename = "ffa";
174                 if(teamplay)
175                         gametypename = "team";
176                 if(g_ctf)
177                         gametypename = "ctf";
178                 if(maxclients == 1)
179                         gametypename = "single";
180                 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
181                 if(strstrofs(self.gametype, gametypename, 0) < 0)
182                         return 1;
183         }
184
185         return 0;
186 }