]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_hagar.c
add csqc skeleton for Nexuiz
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_hagar.c
1 void() hagar_ready_01;
2 void() hagar_fire1_01;
3 void() hagar_deselect_01;
4 void() hagar_select_01;
5
6 float() hagar_check =
7 {
8         if (self.ammo_rockets >= 1)
9                 return TRUE;
10         return FALSE;
11 };
12
13 void(float req) w_hagar =
14 {
15         if (req == WR_IDLE)
16                 hagar_ready_01();
17         else if (req == WR_FIRE1 || req == WR_FIRE2)
18                 weapon_prepareattack(hagar_check, hagar_check, hagar_fire1_01, cvar("g_balance_hagar_refire"));
19         else if (req == WR_RAISE)
20                 hagar_select_01();
21         else if (req == WR_UPDATECOUNTS)
22                 self.currentammo = self.ammo_rockets;
23         else if (req == WR_DROP)
24                 hagar_deselect_01();
25         else if (req == WR_SETUP)
26                 weapon_setup(WEP_HAGAR, "w_hagar.zym", IT_ROCKETS);
27         else if (req == WR_CHECKAMMO)
28                 weapon_hasammo = hagar_check();
29 };
30
31 void W_Hagar_Explode (void)
32 {
33         vector  org2;
34         float b;
35         org2 = findbetterlocation (self.origin);
36         te_explosion (org2);
37         effect (org2, "models/sprites/hagar.spr", 0, 12, 35);
38         b = crandom();
39         if (b<-0.7)
40                 sound (self, CHAN_BODY, "weapons/hagexp1.ogg", 1, ATTN_NORM);
41         else if (b<0.4)
42                 sound (self, CHAN_BODY, "weapons/hagexp2.ogg", 1, ATTN_NORM);
43         else if (b<1)
44                 sound (self, CHAN_BODY, "weapons/hagexp3.ogg", 1, ATTN_NORM);
45
46         self.event_damage = SUB_Null;
47         RadiusDamage (self, self.owner, cvar("g_balance_hagar_damage"), cvar("g_balance_hagar_edgedamage"), cvar("g_balance_hagar_radius"), world, cvar("g_balance_hagar_force"), IT_HAGAR);
48
49         remove (self);
50 }
51
52 void W_Hagar_Touch (void)
53 {
54         if (other == self.owner)
55                 return;
56         else if (pointcontents (self.origin) == CONTENT_SKY)
57         {
58                 remove (self);
59                 return;
60         }
61
62         W_Hagar_Explode ();
63 }
64
65 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
66 {
67         self.health = self.health - damage;
68         if (self.health <= 0)
69                 W_Hagar_Explode();
70 }
71
72 void W_Hagar_Attack (void)
73 {
74         local entity missile;
75         local vector org;
76
77         local vector trueaim;
78         trueaim = W_TrueAim();
79         
80
81         sound (self, CHAN_WEAPON, "weapons/hagar_fire.ogg", 1, ATTN_NORM);
82         if (self.items & IT_STRENGTH) {
83                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
84         }
85         
86         if (cvar("g_use_ammunition"))
87                 self.ammo_rockets = self.ammo_rockets - 1;
88         self.punchangle_x = -2;
89         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -8;
90
91         missile = spawn ();
92         missile.owner = self;
93         missile.classname = "missile";
94         missile.touch = W_Hagar_Touch;
95         missile.think = W_Hagar_Explode;
96         missile.nextthink = time + 10;
97         missile.solid = SOLID_BBOX;
98         missile.scale = 0.4; // BUG: the model is too big
99         setorigin (missile, org);
100         setmodel (missile, "models/hagarmissile.mdl");
101         setsize (missile, '0 0 0', '0 0 0');
102         //missile.takedamage = DAMAGE_YES;
103         //missile.damageforcescale = 4;
104         //missile.health = 10;
105         //missile.event_damage = W_Hagar_Damage;
106         missile.effects = EF_LOWPRECISION;
107
108         if (self.button3)
109         {
110                 missile.movetype = MOVETYPE_TOSS;
111                 missile.velocity = normalize(trueaim - org) * cvar("g_balance_hagar_speed2") + v_up * cvar("g_balance_hagar_speed2_up");
112                 missile.avelocity = '100 10 10';
113         }
114         else
115         {
116                 missile.movetype = MOVETYPE_FLY;
117                 missile.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_hagar_spread")) * cvar("g_balance_hagar_speed");
118         }
119
120         missile.angles = vectoangles (missile.velocity);
121 }
122
123 // weapon frames
124 void()  hagar_ready_01 =        {weapon_thinkf(WFRAME_IDLE, 0.1, hagar_ready_01); self.weaponentity.state = WS_READY;};
125 void()  hagar_select_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
126 void()  hagar_deselect_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
127 void()  hagar_fire1_01 =
128 {
129         weapon_doattack(hagar_check, hagar_check, W_Hagar_Attack);
130         weapon_thinkf(WFRAME_FIRE1, 0.15, hagar_ready_01);
131 };
132