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