]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_hagar.c
more control over starting weapons/ammo/pickups
[divverent/nexuiz.git] / qcsrc / 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         effect (org2, "models/sprites/hagarexplosion.spr32", 0, 19, 30);
37         b = crandom();
38         if (b<-0.7)
39                 sound (self, CHAN_BODY, "weapons/hagexp1.wav", 1, ATTN_NORM);
40         else if (b<0.4)
41                 sound (self, CHAN_BODY, "weapons/hagexp2.wav", 1, ATTN_NORM);
42         else if (b<1)
43                 sound (self, CHAN_BODY, "weapons/hagexp3.wav", 1, ATTN_NORM);
44
45         self.event_damage = SUB_Null;
46         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);
47
48         remove (self);
49 }
50
51 void W_Hagar_Touch (void)
52 {
53         if (other == self.owner)
54                 return;
55         else if (pointcontents (self.origin) == CONTENT_SKY)
56         {
57                 remove (self);
58                 return;
59         }
60
61         W_Hagar_Explode ();
62 }
63
64 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
65 {
66         self.health = self.health - damage;
67         if (self.health <= 0)
68                 W_Hagar_Explode();
69 }
70
71 void W_Hagar_Attack (void)
72 {
73         local entity missile;
74         local vector org;
75
76         sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
77         if (cvar("g_use_ammunition"))
78                 self.ammo_rockets = self.ammo_rockets - 1;
79         self.punchangle_x = -2;
80         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -8;
81
82         missile = spawn ();
83         missile.owner = self;
84         missile.classname = "missile";
85         missile.touch = W_Hagar_Touch;
86         missile.think = W_Hagar_Explode;
87         missile.nextthink = time + 10;
88         missile.solid = SOLID_BBOX;
89         missile.scale = 0.4; // BUG: the model is too big
90         setorigin (missile, org);
91         setmodel (missile, "models/hagarmissile.mdl");
92         setsize (missile, '0 0 0', '0 0 0');
93         //missile.takedamage = DAMAGE_YES;
94         //missile.damageforcescale = 4;
95         //missile.health = 10;
96         //missile.event_damage = W_Hagar_Damage;
97         missile.effects = EF_LOWPRECISION;
98
99         if (self.button3)
100         {
101                 missile.movetype = MOVETYPE_TOSS;
102                 missile.velocity = v_forward * cvar("g_balance_hagar_speed2") + v_up * cvar("g_balance_hagar_speed2_up");
103                 missile.avelocity = '100 10 10';
104         }
105         else
106         {
107                 missile.movetype = MOVETYPE_FLY;
108                 missile.velocity = (v_forward + randomvec() * cvar("g_balance_hagar_spread")) * cvar("g_balance_hagar_speed");
109         }
110
111         missile.angles = vectoangles (missile.velocity);
112 }
113
114 // weapon frames
115 void()  hagar_ready_01 =        {weapon_thinkf(WFRAME_IDLE, 0.1, hagar_ready_01); self.weaponentity.state = WS_READY;};
116 void()  hagar_select_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
117 void()  hagar_deselect_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
118 void()  hagar_fire1_01 =
119 {
120         weapon_doattack(hagar_check, hagar_check, W_Hagar_Attack);
121         weapon_thinkf(WFRAME_FIRE1, 0.15, hagar_ready_01);
122 };
123