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