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