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