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