]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_hagar.qc
Merge branch 'master' into fruitiex/newpanelhud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_hagar.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", "Hagar");
3 #else
4 #ifdef SVQC
5 // NO bounce protection, as bounces are limited!
6 void W_Hagar_Explode (void)
7 {
8         self.event_damage = SUB_Null;
9         RadiusDamage (self, self.realowner, cvar("g_balance_hagar_primary_damage"), cvar("g_balance_hagar_primary_edgedamage"), cvar("g_balance_hagar_primary_radius"), world, cvar("g_balance_hagar_primary_force"), self.projectiledeathtype, other);
10
11         remove (self);
12 }
13
14 void W_Hagar_Explode2 (void)
15 {
16         self.event_damage = SUB_Null;
17         RadiusDamage (self, self.realowner, cvar("g_balance_hagar_secondary_damage"), cvar("g_balance_hagar_secondary_edgedamage"), cvar("g_balance_hagar_secondary_radius"), world, cvar("g_balance_hagar_secondary_force"), self.projectiledeathtype, other);
18
19         remove (self);
20 }
21
22 void W_Hagar_Touch (void)
23 {
24         PROJECTILE_TOUCH;
25         self.use ();
26 }
27
28 void W_Hagar_Touch2 (void)
29 {
30         PROJECTILE_TOUCH;
31
32         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
33                 self.use();
34         } else {
35                 self.cnt++;
36                 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
37                 self.angles = vectoangles (self.velocity);
38                 self.owner = world;
39                 self.projectiledeathtype |= HITTYPE_BOUNCE;
40         }
41 }
42
43 void W_Hagar_Attack (void)
44 {
45         local entity missile;
46
47         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
48                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_primary_ammo");
49         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", cvar("g_balance_hagar_primary_damage"));
50
51         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
52
53         missile = spawn ();
54         missile.owner = missile.realowner = self;
55         missile.classname = "missile";
56         missile.bot_dodge = TRUE;
57         missile.bot_dodgerating = cvar("g_balance_hagar_primary_damage");
58         missile.touch = W_Hagar_Touch;
59         missile.use = W_Hagar_Explode;
60         missile.think = adaptor_think2use_hittype_splash;
61         missile.nextthink = time + cvar("g_balance_hagar_primary_lifetime");
62         PROJECTILE_MAKETRIGGER(missile);
63         missile.projectiledeathtype = WEP_HAGAR;
64         setorigin (missile, w_shotorg);
65         setsize(missile, '0 0 0', '0 0 0');
66
67         missile.movetype = MOVETYPE_FLY;
68         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
69
70         missile.angles = vectoangles (missile.velocity);
71         missile.flags = FL_PROJECTILE;
72
73         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
74 }
75
76 void W_Hagar_Attack2 (void)
77 {
78         local entity missile;
79
80         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
81                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_secondary_ammo");
82         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", cvar("g_balance_hagar_secondary_damage"));
83         //W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav"); // TODO: move model a little to the right
84
85         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
86
87         missile = spawn ();
88         missile.owner = missile.realowner = self;
89         missile.classname = "missile";
90         missile.bot_dodge = TRUE;
91         missile.bot_dodgerating = cvar("g_balance_hagar_secondary_damage");
92         missile.touch = W_Hagar_Touch2;
93         missile.cnt = 0;
94         missile.use = W_Hagar_Explode2;
95         missile.think = adaptor_think2use_hittype_splash;
96         missile.nextthink = time + cvar("g_balance_hagar_secondary_lifetime_min") + random() * cvar("g_balance_hagar_secondary_lifetime_rand");
97         PROJECTILE_MAKETRIGGER(missile);
98         missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
99         setorigin (missile, w_shotorg);
100         setsize(missile, '0 0 0', '0 0 0');
101
102         missile.movetype = MOVETYPE_BOUNCEMISSILE;
103         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
104
105         missile.angles = vectoangles (missile.velocity);
106         missile.flags = FL_PROJECTILE;
107
108         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
109 }
110
111 void spawnfunc_weapon_hagar (void)
112 {
113         weapon_defaultspawnfunc(WEP_HAGAR);
114 }
115
116 float w_hagar(float req)
117 {
118         if (req == WR_AIM)
119                 if (random()>0.15)
120                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
121                 else
122                 {
123                         // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
124                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
125                 }
126         else if (req == WR_THINK)
127         {
128                 if (self.BUTTON_ATCK)
129                 if (weapon_prepareattack(0, cvar("g_balance_hagar_primary_refire")))
130                 {
131                         W_Hagar_Attack();
132                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_primary_refire"), w_ready);
133                 }
134                 if (self.BUTTON_ATCK2 && cvar("g_balance_hagar_secondary"))
135                 if (weapon_prepareattack(1, cvar("g_balance_hagar_secondary_refire")))
136                 {
137                         W_Hagar_Attack2();
138                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_hagar_secondary_refire"), w_ready);
139                 }
140         }
141         else if (req == WR_PRECACHE)
142         {
143                 precache_model ("models/weapons/g_hagar.md3");
144                 precache_model ("models/weapons/v_hagar.md3");
145                 precache_model ("models/weapons/h_hagar.iqm");
146                 precache_sound ("weapons/hagar_fire.wav");
147         }
148         else if (req == WR_SETUP)
149                 weapon_setup(WEP_HAGAR);
150         else if (req == WR_CHECKAMMO1)
151                 return self.ammo_rockets >= cvar("g_balance_hagar_primary_ammo");
152         else if (req == WR_CHECKAMMO2)
153                 return self.ammo_rockets >= cvar("g_balance_hagar_secondary_ammo");
154         return TRUE;
155 };
156 #endif
157 #ifdef CSQC
158 float w_hagar(float req)
159 {
160         if(req == WR_IMPACTEFFECT)
161         {
162                 vector org2;
163                 org2 = w_org + w_backoff * 6;
164                 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
165                 if(!w_issilent)
166                 {
167                         if (w_random<0.15)
168                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
169                         else if (w_random<0.7)
170                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
171                         else
172                                 sound(self, CHAN_PROJECTILE, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
173                 }
174         }
175         else if(req == WR_PRECACHE)
176         {
177                 precache_sound("weapons/hagexp1.wav");
178                 precache_sound("weapons/hagexp2.wav");
179                 precache_sound("weapons/hagexp3.wav");
180         }
181         else if (req == WR_SUICIDEMESSAGE)
182                 w_deathtypestring = "played with tiny rockets";
183         else if (req == WR_KILLMESSAGE)
184         {
185                 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
186                         w_deathtypestring = "hoped #'s missiles wouldn't bounce";
187                 else // unchecked: SPLASH, SECONDARY
188                         w_deathtypestring = "was pummeled by";
189         }
190         return TRUE;
191 }
192 #endif
193 #endif