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