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