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