]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/t_quake3.qc
Merge branch 'master' into samual/weapons
[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_cells();          }
27
28 // BFG -> Crylink
29 void spawnfunc_weapon_bfg()          { spawnfunc_weapon_crylink();      }
30 void spawnfunc_ammo_bfg()            { spawnfunc_item_cells();          }
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()       /* not supported */
117 //void spawnfunc_item_haste()        /* not supported */
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()        /* not supported */
123 //void spawnfunc_item_regen()        /* not supported */
124
125 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
126
127 void spawnfunc_item_flight()         { spawnfunc_item_jetpack();       }
128
129 .float notteam;
130 .float notsingle;
131 .float notfree;
132 .float notq3a;
133 .float notta;
134 .string gametype;
135 float DoesQ3ARemoveThisEntity()
136 {
137         // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
138
139         if(self.notq3a)
140                 if(!teamplay || g_tdm || g_ctf)
141                         return 1;
142
143         if(self.notta)
144                 if (!(!teamplay || g_tdm || g_ctf))
145                         return 1;
146
147         if(self.notsingle)
148                 if(maxclients == 1)
149                         return 1;
150
151         if(self.notteam)
152                 if(teamplay)
153                         return 1;
154
155         if(self.notfree)
156                 if(!teamplay)
157                         return 1;
158
159         if(self.gametype)
160         {
161                 string gametypename;
162                 // static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"}
163                 gametypename = "ffa";
164                 if(teamplay)
165                         gametypename = "team";
166                 if(g_ctf)
167                         gametypename = "ctf";
168                 if(maxclients == 1)
169                         gametypename = "single";
170                 // we do not have the other types (oneflag, obelisk, harvester, teamtournament)
171                 if(strstrofs(self.gametype, gametypename, 0) < 0)
172                         return 1;
173         }
174
175         return 0;
176 }