centerprints now are managed independently per line
[divverent/nexuiz.git] / data / qcsrc / server / w_hagar.qc
1 void W_Hagar_Explode (void)
2 {
3         vector  org2;
4         float b;
5         org2 = findbetterlocation (self.origin, 12);
6         te_explosion (org2);
7         //effect (org2, "models/sprites/hagar.spr", 0, 12, 35);
8         b = crandom();
9         if (b<-0.7)
10                 sound (self, CHAN_BODY, "weapons/hagexp1.ogg", 1, ATTN_NORM);
11         else if (b<0.4)
12                 sound (self, CHAN_BODY, "weapons/hagexp2.ogg", 1, ATTN_NORM);
13         else if (b<1)
14                 sound (self, CHAN_BODY, "weapons/hagexp3.ogg", 1, ATTN_NORM);
15
16         self.event_damage = SUB_Null;
17         RadiusDamage (self, self.owner, 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"), IT_HAGAR);
18
19         remove (self);
20 }
21
22 void W_Hagar_Explode2 (void)
23 {
24         vector  org2;
25         float b;
26         org2 = findbetterlocation (self.origin, 12);
27         te_explosion (org2);
28         //effect (org2, "models/sprites/hagar.spr", 0, 12, 35);
29         b = crandom();
30         if (b<-0.7)
31                 sound (self, CHAN_BODY, "weapons/hagexp1.ogg", 1, ATTN_NORM);
32         else if (b<0.4)
33                 sound (self, CHAN_BODY, "weapons/hagexp2.ogg", 1, ATTN_NORM);
34         else if (b<1)
35                 sound (self, CHAN_BODY, "weapons/hagexp3.ogg", 1, ATTN_NORM);
36
37         self.event_damage = SUB_Null;
38         RadiusDamage (self, self.owner, 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"), IT_HAGAR);
39
40         remove (self);
41 }
42
43 void W_Hagar_Touch (void)
44 {
45         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
46         {
47                 remove(self);
48                 return;
49         }
50         if (other == self.owner)
51                 return;
52
53         self.think ();
54 }
55
56 void W_Hagar_Touch2 (void)
57 {
58         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
59         {
60                 remove(self);
61                 return;
62         }
63
64         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
65                 self.think();
66         } else {
67                 self.cnt++;
68         }
69 }
70
71 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
72 {
73         self.health = self.health - damage;
74         if (self.health <= 0)
75                 self.think ();
76 }
77
78 void W_Hagar_Attack (void)
79 {
80         local entity missile;
81
82         if (cvar("g_use_ammunition"))
83                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_primary_ammo");
84         W_SetupShot (self, '15 5 -8', FALSE, 2, "weapons/hagar_fire.ogg");
85
86         missile = spawn ();
87         missile.owner = self;
88         missile.classname = "missile";
89         missile.bot_dodge = TRUE;
90         missile.bot_dodgerating = cvar("g_balance_hagar_primary_damage");
91         missile.touch = W_Hagar_Touch;
92         missile.think = W_Hagar_Explode;
93         missile.nextthink = time + cvar("g_balance_hagar_primary_lifetime");
94         missile.solid = SOLID_BBOX;
95         missile.scale = 0.4; // BUG: the model is too big
96         setorigin (missile, w_shotorg);
97         setmodel (missile, "models/hagarmissile.mdl");
98         setsize (missile, '0 0 0', '0 0 0');
99         //missile.takedamage = DAMAGE_YES;
100         //missile.damageforcescale = 4;
101         //missile.health = 10;
102         //missile.event_damage = W_Hagar_Damage;
103         missile.effects = EF_LOWPRECISION | EF_NOSHADOW | EF_FULLBRIGHT;
104
105         missile.movetype = MOVETYPE_FLY;
106         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_primary_spread")) * cvar("g_balance_hagar_primary_speed");
107
108         missile.angles = vectoangles (missile.velocity);
109         missile.flags = FL_PROJECTILE;
110 }
111
112 void W_Hagar_Attack2 (void)
113 {
114         local entity missile;
115
116         if (cvar("g_use_ammunition"))
117                 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_hagar_secondary_ammo");
118         W_SetupShot (self, '15 5 -8', FALSE, 2, "weapons/hagar_fire.ogg");
119
120         missile = spawn ();
121         missile.owner = self;
122         missile.classname = "missile";
123         missile.bot_dodge = TRUE;
124         missile.bot_dodgerating = cvar("g_balance_hagar_secondary_damage");
125         missile.touch = W_Hagar_Touch2;
126         missile.cnt = 0;
127         missile.think = W_Hagar_Explode;
128         missile.nextthink = time + cvar("g_balance_hagar_secondary_lifetime");
129         missile.solid = SOLID_BBOX;
130         missile.scale = 0.4; // BUG: the model is too big
131         setorigin (missile, w_shotorg);
132         setmodel (missile, "models/hagarmissile.mdl");
133         setsize (missile, '0 0 0', '0 0 0');
134         //missile.takedamage = DAMAGE_YES;
135         //missile.damageforcescale = 4;
136         //missile.health = 10;
137         //missile.event_damage = W_Hagar_Damage;
138         missile.effects = EF_LOWPRECISION | EF_NOSHADOW | EF_FULLBRIGHT;
139
140         missile.movetype = MOVETYPE_BOUNCEMISSILE;
141         missile.velocity = (w_shotdir + randomvec() * cvar("g_balance_hagar_secondary_spread")) * cvar("g_balance_hagar_secondary_speed");
142         missile.avelocity = '100 10 10';
143
144         missile.angles = vectoangles (missile.velocity);
145         missile.flags = FL_PROJECTILE;
146 }
147
148 float(float req) w_hagar =
149 {
150         if (req == WR_AIM)
151                 self.button0 = bot_aim(cvar("g_balance_hagar_primary_speed"), 0, cvar("g_balance_hagar_primary_lifetime"), FALSE);
152         else if (req == WR_THINK)
153         {
154                 if (self.button0)
155                 if (weapon_prepareattack(0, cvar("g_balance_hagar_primary_refire")))
156                 {
157                         W_Hagar_Attack();
158                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_primary_refire"), w_ready);
159                 }
160                 if (self.button3)
161                 if (weapon_prepareattack(1, cvar("g_balance_hagar_secondary_refire")))
162                 {
163                         W_Hagar_Attack2();
164                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hagar_secondary_refire"), w_ready);
165                 }
166         }
167         else if (req == WR_SETUP)
168                 weapon_setup(WEP_HAGAR, "hagar", IT_ROCKETS);
169         else if (req == WR_CHECKAMMO1)
170                 return self.ammo_rockets >= cvar("g_balance_hagar_primary_ammo");
171         else if (req == WR_CHECKAMMO2)
172                 return self.ammo_rockets >= cvar("g_balance_hagar_secondary_ammo");
173         return TRUE;
174 };