]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/t_quake3.qc
Merge branch 'master' into terencehill/physics_panel_updates
[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 -> Rifle
26 void spawnfunc_weapon_railgun()      { spawnfunc_weapon_rifle();  }
27 void spawnfunc_ammo_slugs()          { spawnfunc_item_bullets();        }
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 void spawnfunc_team_CTF_redflag()    { spawnfunc_item_flag_team1();    }
126 void spawnfunc_team_CTF_blueflag()   { spawnfunc_item_flag_team2();    }
127 void spawnfunc_team_CTF_redplayer()  { spawnfunc_info_player_team1();  }
128 void spawnfunc_team_CTF_blueplayer() { spawnfunc_info_player_team2();  }
129 void spawnfunc_team_CTF_redspawn()   { spawnfunc_info_player_team1();  }
130 void spawnfunc_team_CTF_bluespawn()  { spawnfunc_info_player_team2();  }
131
132 void spawnfunc_item_flight()         { spawnfunc_item_jetpack();       }
133
134 .float notteam;
135 .float notsingle;
136 .float notfree;
137 .float notq3a;
138 .float notta;
139 .string gametype;
140 float DoesQ3ARemoveThisEntity()
141 {
142         // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
143
144         if(self.notq3a)
145                 if(!teamplay || g_tdm || g_ctf)
146                         return 1;
147
148         if(self.notta)
149                 if not(!teamplay || g_tdm || g_ctf)
150                         return 1;
151
152         if(self.notsingle)
153                 if(maxclients == 1)
154                         return 1;
155
156         if(self.notteam)
157                 if(teamplay)
158                         return 1;
159
160         if(self.notfree)
161                 if(!teamplay)
162                         return 1;
163
164         if(self.gametype)
165         {
166                 string gametypename;
167                 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
168                 gametypename = "ffa";
169                 if(teamplay)
170                         gametypename = "team";
171                 if(g_arena)
172                         gametypename = "tournament";
173                 if(g_ctf)
174                         gametypename = "ctf";
175                 if(maxclients == 1)
176                         gametypename = "single";
177                 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
178                 if(strstrofs(self.gametype, gametypename, 0) < 0)
179                         return 1;
180         }
181
182         return 0;
183 }