]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/server/gamec/w_laser.c
Redone campaign mode for better integration with the menu code.
[divverent/nexuiz.git] / 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         vector org2;
36
37         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
38         {
39                 remove(self);
40                 return;
41         }
42
43         if (other == self.owner)
44                 return;
45
46         dir = normalize (self.owner.origin - self.origin);
47         org2 = findbetterlocation (self.origin, 8);
48
49         /*
50         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
51         WriteByte (MSG_BROADCAST, TE_FLAMEJET);
52         WriteCoord (MSG_BROADCAST, self.origin_x);
53         WriteCoord (MSG_BROADCAST, self.origin_y);
54         WriteCoord (MSG_BROADCAST, self.origin_z);
55         WriteCoord (MSG_BROADCAST, 0);          // SeienAbunae: groan... Useless clutter
56         WriteCoord (MSG_BROADCAST, 0);
57         WriteCoord (MSG_BROADCAST, 0);
58         WriteByte (MSG_BROADCAST, 155);
59
60         te_customflash(self.origin, 160, 0.2, '1 0 0');
61         */
62
63         te_knightspike(org2);
64
65
66         self.event_damage = SUB_Null;
67         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);
68         sound (self, CHAN_BODY, "weapons/laserimpact.ogg", 1, ATTN_NORM);
69
70         remove (self);
71 }
72
73 void W_Laser_Attack (void)
74 {
75         local entity missile;
76         local vector org;
77
78         local vector trueaim;
79         trueaim = W_TrueAim();
80
81         sound (self, CHAN_WEAPON, "weapons/lasergun_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         self.punchangle_x = -3;
86
87         org = W_MuzzleOrigin (self, '24 9 -9');
88         //te_customflash(org, 160, 0.2, '1 0 0');
89
90         missile = spawn ();
91         missile.owner = self;
92         missile.classname = "laserbolt";
93
94         missile.movetype = MOVETYPE_FLY;
95         missile.solid = SOLID_BBOX;
96
97         setmodel (missile, "models/laser.mdl");
98         setsize (missile, '0 0 0', '0 0 0');
99         setorigin (missile, org);
100
101         missile.velocity = normalize(trueaim - org) * cvar("g_balance_laser_speed");
102         missile.angles = vectoangles (missile.velocity);
103         //missile.glow_color = 250; // 244, 250
104         //missile.glow_size = 120;
105         missile.touch = W_Laser_Touch;
106         missile.think = SUB_Remove;
107         missile.nextthink = time + cvar("g_balance_laser_lifetime");
108
109         missile.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_FULLBRIGHT | EF_LOWPRECISION;
110         missile.flags = FL_PROJECTILE;
111 }
112
113 // weapon frames
114
115 void()  laser_ready_01 =
116 {
117         weapon_thinkf(WFRAME_IDLE, 0.1, laser_ready_01);
118         self.weaponentity.state = WS_READY;
119 };
120 void()  laser_select_01 =
121 {
122         weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready);
123         weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');
124 };
125 void()  laser_deselect_01 =
126 {
127         weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear);
128         weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);
129 };
130 void()  laser_fire1_01 =
131 {
132         weapon_doattack(laser_check, laser_check, W_Laser_Attack);
133         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_animtime"), laser_ready_01);
134 };