]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_laser.c
- fixed playercount in lms
[divverent/nexuiz.git] / data / qcsrc / server / 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_FIRE2)
15                 self.switchweapon = self.cnt;
16         else if (req == WR_RAISE)
17                 laser_select_01();
18         else if (req == WR_UPDATECOUNTS)
19                 self.currentammo = 1;
20         else if (req == WR_DROP)
21                 laser_deselect_01();
22         else if (req == WR_SETUP)
23                 weapon_setup(WEP_LASER, "w_laser.zym", 0);
24         else if (req == WR_CHECKAMMO)
25                 weapon_hasammo = laser_check();
26 };
27
28 void W_Laser_Touch (void)
29 {
30         vector  dir;
31
32         if (other == self.owner)
33                 return;
34         else if (pointcontents (self.origin) == CONTENT_SKY)
35         {
36                 remove (self);
37                 return;
38         }
39
40         dir = normalize (self.owner.origin - self.origin);
41
42         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
43         WriteByte (MSG_BROADCAST, TE_FLAMEJET);
44         WriteCoord (MSG_BROADCAST, self.origin_x);
45         WriteCoord (MSG_BROADCAST, self.origin_y);
46         WriteCoord (MSG_BROADCAST, self.origin_z);
47         WriteCoord (MSG_BROADCAST, 0);          // SeienAbunae: groan... Useless clutter
48         WriteCoord (MSG_BROADCAST, 0);
49         WriteCoord (MSG_BROADCAST, 0);
50         WriteByte (MSG_BROADCAST, 155);
51
52         te_customflash(self.origin, 160, 0.2, '1 0 0');
53
54
55         self.event_damage = SUB_Null;
56         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);
57         sound (self, CHAN_BODY, "weapons/laserimpact.ogg", 1, ATTN_NORM);
58
59         remove (self);
60 }
61
62 void W_Laser_Attack (void)
63 {
64         local entity missile;
65         local vector org;
66
67         local vector trueaim;
68         trueaim = W_TrueAim();
69
70         sound (self, CHAN_WEAPON, "weapons/lasergun_fire.ogg", 1, ATTN_NORM);
71         if (self.items & IT_STRENGTH) {
72                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
73         }
74         
75         org = self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -12;
76         //te_customflash(org, 160, 0.2, '1 0 0');
77
78         missile = spawn ();
79         missile.owner = self;
80         missile.classname = "laserbolt";
81
82         missile.movetype = MOVETYPE_FLY;
83         missile.solid = SOLID_BBOX;
84
85         setmodel (missile, "models/laser.mdl");
86         setsize (missile, '0 0 0', '0 0 0');
87         setorigin (missile, org);
88
89         missile.velocity = normalize(trueaim - org) * cvar("g_balance_laser_speed");
90         missile.angles = vectoangles (missile.velocity);
91         //missile.glow_color = 250; // 244, 250
92         //missile.glow_size = 120;
93         missile.touch = W_Laser_Touch;
94         missile.think = SUB_Remove;
95         missile.nextthink = time + 9;
96
97         missile.effects = EF_FULLBRIGHT | EF_FULLBRIGHT | EF_LOWPRECISION;
98 }
99
100 // weapon frames
101
102 void()  laser_ready_01 =
103 {
104         weapon_thinkf(WFRAME_IDLE, 0.1, laser_ready_01);
105         self.weaponentity.state = WS_READY;
106 };
107 void()  laser_select_01 =       
108 {
109         weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready);
110         weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');
111 };
112 void()  laser_deselect_01 =
113 {
114         weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear);
115         weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);
116 };
117 void()  laser_fire1_01 =
118 {
119         weapon_doattack(laser_check, laser_check, W_Laser_Attack);
120         weapon_thinkf(WFRAME_FIRE1, 0.3, laser_ready_01);
121 };