]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_laser.c
added many g_balance cvars and renamed cl_weapon_ cvars to use the g_viewweapon_...
[divverent/nexuiz.git] / qcsrc / gamec / w_laser.c
1 void() laser_ready_01;
2 void() laser_fire1_01;
3 void() laser_deselect_01;
4 void() laser_select_01;
5
6 float() laser_check = {return TRUE;};
7
8 void(float req) w_laser =
9 {
10         if (req == WR_IDLE)
11                 laser_ready_01();
12         else if (req == WR_FIRE1)
13                 weapon_prepareattack(laser_check, laser_check, laser_fire1_01, cvar("g_balance_laser_refire"));
14         else if (req == WR_RAISE)
15                 laser_select_01();
16         else if (req == WR_UPDATECOUNTS)
17                 self.currentammo = 1;
18         else if (req == WR_DROP)
19                 laser_deselect_01();
20         else if (req == WR_SETUP)
21                 weapon_setup(WEP_LASER, "w_laser.zym", 0);
22         else if (req == WR_CHECKAMMO)
23                 weapon_hasammo = laser_check();
24 };
25
26 void W_Laser_Touch (void)
27 {
28         vector  dir;
29
30         if (other == self.owner)
31                 return;
32         else if (pointcontents (self.origin) == CONTENT_SKY)
33         {
34                 remove (self);
35                 return;
36         }
37
38         dir = normalize (self.owner.origin - self.origin);
39
40         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
41         WriteByte (MSG_BROADCAST, TE_FLAMEJET);
42         WriteCoord (MSG_BROADCAST, self.origin_x);
43         WriteCoord (MSG_BROADCAST, self.origin_y);
44         WriteCoord (MSG_BROADCAST, self.origin_z);
45         WriteCoord (MSG_BROADCAST, 0);          // SeienAbunae: groan... Useless clutter
46         WriteCoord (MSG_BROADCAST, 0);
47         WriteCoord (MSG_BROADCAST, 0);
48         WriteByte (MSG_BROADCAST, 155);
49
50
51
52         self.event_damage = nullfunction;
53         RadiusDamage (self, self.owner, cvar("g_balance_laser_damage"), cvar("g_balance_laser_edgedamage"), cvar("g_balance_laser_radius"), world, cvar("g_balance_laser_force"), IT_LASER);
54         sound (self, CHAN_IMPACT, "weapons/laserimpact.wav", 1, ATTN_NORM);
55
56         remove (self);
57 }
58
59 void W_Laser_Attack (void)
60 {
61         entity  missile;
62
63         makevectors(self.v_angle);
64
65         sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", 1, ATTN_NORM);
66
67         missile = spawn ();
68         missile.owner = self;
69         missile.classname = "spike";
70
71         missile.movetype = MOVETYPE_FLY;
72         missile.solid = SOLID_BBOX;
73
74         setmodel (missile, "models/laser.mdl");
75         setsize (missile, '0 0 0', '0 0 0');
76         setorigin (missile, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -12);
77
78         missile.velocity = v_forward * cvar("g_balance_laser_speed");
79         missile.angles = vectoangles (missile.velocity);
80         missile.glow_color = 250; // 244, 250
81         missile.glow_size = 30;
82         missile.touch = W_Laser_Touch;
83         missile.think = SUB_Remove;
84         missile.nextthink = time + 9;
85
86         missile.effects = missile.effects | EF_ADDITIVE;
87 }
88
89 // weapon frames
90
91 void()  laser_ready_01 =        {weapon_thinkf(WFRAME_IDLE, 0.1, laser_ready_01); self.weaponentity.state = WS_READY;};
92 void()  laser_select_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
93 void()  laser_deselect_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
94 void()  laser_fire1_01 =
95 {
96         weapon_doattack(laser_check, laser_check, W_Laser_Attack);
97         weapon_thinkf(WFRAME_FIRE1, 0.3, laser_ready_01);
98 };
99