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