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