83e1cf0821965e51242cb6ae23d2d3a06c011f6e
[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         else if (req == WR_SUICIDEMESSAGE)
155                 w_deathtypestring = "played with tiny rockets";
156         else if (req == WR_KILLMESSAGE)
157         {
158                 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
159                         w_deathtypestring = "hoped #'s missiles wouldn't bounce";
160                 else // unchecked: SPLASH, SECONDARY
161                         w_deathtypestring = "was pummeled by";
162         }
163         return TRUE;
164 };
165 #endif
166 #ifdef CSQC
167 float w_hagar(float req)
168 {
169         return TRUE;
170 }
171 #endif
172 #endif