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