]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_laser.qc
now all projectile hit effects are clientside
[divverent/nexuiz.git] / data / qcsrc / server / w_laser.qc
1 void(float imp) W_SwitchWeapon;
2
3 void W_Laser_Touch (void)
4 {
5         vector  dir;
6         vector org2;
7         vector normal;
8
9         PROJECTILE_TOUCH;
10
11         normal = trace_plane_normal;
12         dir = normalize (self.owner.origin - self.origin);
13
14         self.event_damage = SUB_Null;
15         if (self.dmg)
16                 RadiusDamage (self, self.owner, cvar("g_balance_laser_secondary_damage"), cvar("g_balance_laser_secondary_edgedamage"), cvar("g_balance_laser_secondary_radius"), world, cvar("g_balance_laser_secondary_force"), self.projectiledeathtype, other);
17         else
18                 RadiusDamage (self, self.owner, cvar("g_balance_laser_primary_damage"), cvar("g_balance_laser_primary_edgedamage"), cvar("g_balance_laser_primary_radius"), world, cvar("g_balance_laser_primary_force"), self.projectiledeathtype, other);
19
20         remove (self);
21 }
22
23 void W_Laser_Attack (float issecondary)
24 {
25         local entity missile;
26
27         W_SetupShot (self, '25 8 -8', FALSE, 3, "weapons/lasergun_fire.wav");
28         pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
29
30         missile = spawn ();
31         missile.owner = self;
32         missile.classname = "laserbolt";
33         missile.dmg = issecondary;
34         missile.bot_dodge = TRUE;
35         if (issecondary)
36                 missile.bot_dodgerating = cvar("g_balance_laser_secondary_damage");
37         else
38                 missile.bot_dodgerating = cvar("g_balance_laser_primary_damage");
39
40         missile.movetype = MOVETYPE_FLY;
41         missile.solid = SOLID_BBOX;
42         missile.projectiledeathtype = WEP_LASER;
43         if(issecondary)
44                 missile.projectiledeathtype |= HITTYPE_SECONDARY;
45
46         setmodel (missile, "models/laser.mdl"); // precision set below
47         setsize (missile, '0 0 0', '0 0 0');
48         setorigin (missile, w_shotorg);
49
50         if (issecondary)
51                 missile.velocity = w_shotdir * cvar("g_balance_laser_secondary_speed");
52         else
53                 missile.velocity = w_shotdir * cvar("g_balance_laser_primary_speed");
54         W_SetupProjectileVelocity(missile);
55         missile.angles = vectoangles (missile.velocity);
56         //missile.glow_color = 250; // 244, 250
57         //missile.glow_size = 120;
58         missile.touch = W_Laser_Touch;
59         missile.think = SUB_Remove;
60         if (issecondary)
61                 missile.nextthink = time + cvar("g_balance_laser_secondary_lifetime");
62         else
63                 missile.nextthink = time + cvar("g_balance_laser_primary_lifetime");
64
65         missile.effects = EF_LOWPRECISION;
66         missile.flags = FL_PROJECTILE;
67
68         CSQCProjectile(missile, TRUE, PROJECTILE_LASER);
69 }
70
71 float w_laser(float req)
72 {
73         local float r1;
74         local float r2;
75         if (req == WR_AIM)
76         {
77                 if(cvar("g_balance_laser_secondary"))
78                 {
79                         r1 = cvar("g_balance_laser_primary_damage");
80                         r2 = cvar("g_balance_laser_secondary_damage");
81                         if (random() * (r2 + r1) > r1)
82                                 self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_laser_secondary_speed"), 0, cvar("g_balance_laser_secondary_lifetime"), FALSE);
83                         else
84                                 self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
85                 }
86                 else
87                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
88         }
89         else if (req == WR_THINK)
90         {
91                 if (self.BUTTON_ATCK)
92                 if (weapon_prepareattack(0, cvar("g_balance_laser_primary_refire")))
93                 {
94                         W_Laser_Attack(FALSE);
95                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_primary_animtime"), w_ready);
96                 }
97                 if (self.BUTTON_ATCK2)
98                 {
99                         if(cvar("g_balance_laser_secondary"))
100                         {
101                                 if (weapon_prepareattack(0, cvar("g_balance_laser_secondary_refire")))
102                                 {
103                                         W_Laser_Attack(TRUE);
104                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_secondary_animtime"), w_ready);
105                                 }
106                         }
107                         else
108                         {
109                                 if(self.switchweapon == WEP_LASER) // don't do this if already switching
110                                         W_SwitchWeapon (self.cnt);
111                         }
112                 }
113         }
114         else if (req == WR_PRECACHE)
115         {
116                 precache_model ("models/laser.mdl");
117                 precache_model ("models/weapons/v_laser.md3");
118                 precache_model ("models/weapons/w_laser.zym");
119                 precache_sound ("weapons/lasergun_fire.wav");
120                 precache_sound ("weapons/laserimpact.wav");
121         }
122         else if (req == WR_SETUP)
123                 weapon_setup(WEP_LASER);
124         else if (req == WR_CHECKAMMO1)
125                 return TRUE;
126         else if (req == WR_CHECKAMMO2)
127                 return TRUE;
128         else if (req == WR_SUICIDEMESSAGE)
129                 w_deathtypestring = "lasered himself to hell";
130         else if (req == WR_KILLMESSAGE)
131         {
132                 w_deathtypestring = "was lasered to death by"; // unchecked: SPLASH
133         }
134         return TRUE;
135 };