1 // leilei's fancy muzzleflash stuff
3 void() W_Uzi_Flash_Go {
8 self.frame = self.frame + 2;
9 self.alpha = self.alpha - 0.2;
10 self.think = W_Uzi_Flash_Go;
11 self.nextthink = time + 0.02;
14 .float uzi_bulletcounter;
15 void W_Uzi_Attack (void)
17 local entity flash, flash2;
19 if (cvar("g_use_ammunition"))
21 if (self.uzi_bulletcounter == 1)
22 self.ammo_nails = self.ammo_nails - cvar("g_balance_uzi_first_ammo");
24 self.ammo_nails = self.ammo_nails - cvar("g_balance_uzi_sustained_ammo");
26 W_SetupShot (self, '25 5.5 -8', TRUE, 0, "weapons/uzi_fire.wav");
27 //W_SetupShot (self, '25 8 -8', TRUE, 0, "weapons/uzi_fire.wav"); // TODO: move model to the right a little
30 self.punchangle_x = random () - 0.5;
31 self.punchangle_y = random () - 0.5;
34 // this attack_finished just enforces a cooldown at the end of a burst
35 ATTACK_FINISHED(self) = time + cvar("g_balance_uzi_first_refire");
37 if (self.uzi_bulletcounter == 1)
38 fireBullet (w_shotorg, w_shotdir, cvar("g_balance_uzi_first_spread"), cvar("g_balance_uzi_first_damage"), cvar("g_balance_uzi_first_force"), IT_UZI, TRUE);
40 fireBullet (w_shotorg, w_shotdir, cvar("g_balance_uzi_sustained_spread"), cvar("g_balance_uzi_sustained_damage"), cvar("g_balance_uzi_sustained_force"), IT_UZI, (self.uzi_bulletcounter & 3) == 0);
42 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
44 // muzzle flash for 1st person view
46 setorigin(flash, '53 5 0');
47 setmodel(flash, "models/uziflash.md3"); // precision set below
48 setattachment(flash, self.weaponentity, "bone01");
50 flash.viewmodelforclient = self;
51 flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
53 //SUB_SetFade(flash, time + 0.06, 0);
54 flash.think = W_Uzi_Flash_Go;
55 flash.nextthink = time + 0.02;
58 // muzzle flash for 3rd person view
60 setorigin(flash2, '43 1 8');
61 setmodel(flash2, "models/uziflash.md3"); // precision set below
62 setattachment(flash2, self.exteriorweaponentity, "");
63 //SUB_SetFade(flash2, time + 0.06, 0);
64 flash2.think = W_Uzi_Flash_Go;
65 flash2.nextthink = time + 0.02;
68 flash.angles_z = flash2.angles_z = flash.v_angle_z + random() * 180;
69 flash.alpha = flash2.alpha = 1;
70 flash.effects = flash2.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
73 if (cvar("g_casings") >= 2)
74 SpawnCasing (w_shotorg + v_forward * 10, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3);
80 if(self.weapon != self.switchweapon) // abort immediately if switching
87 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
89 self.switchweapon = w_getbestweapon(self);
90 if (self.switchweapon != self.weapon)
91 self.cnt = self.weapon;
95 ATTACK_FINISHED(self) = time + cvar("g_balance_uzi_refire");
96 self.uzi_bulletcounter = self.uzi_bulletcounter + 1;
98 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
101 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
104 float(float req) w_uzi =
107 if(vlen(self.origin-self.enemy.origin)<750)
108 self.button0 = bot_aim(1000000, 0, 0.001, FALSE);
111 self.button3 = bot_aim(1000000, 0, 0.001, FALSE);
113 else if (req == WR_THINK)
116 if (weapon_prepareattack(0, cvar("g_balance_uzi_refire")))
118 self.uzi_bulletcounter = 1;
120 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
123 if (weapon_prepareattack(1, cvar("g_balance_uzi_refire")))
125 self.uzi_bulletcounter = 1;
127 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
130 else if (req == WR_PRECACHE)
132 precache_model ("models/tracer.mdl");
133 precache_model ("models/uziflash.md3");
134 precache_model ("models/weapons/g_uzi.md3");
135 precache_model ("models/weapons/v_uzi.md3");
136 precache_model ("models/weapons/w_uzi.zym");
137 precache_sound ("weapons/ric1.wav");
138 precache_sound ("weapons/ric2.wav");
139 precache_sound ("weapons/ric3.wav");
140 precache_sound ("weapons/tink1.wav");
141 precache_sound ("weapons/uzi_fire.wav");
142 if (cvar("g_casings") >= 2)
143 precache_model ("models/casing_bronze.mdl");
145 else if (req == WR_SETUP)
146 weapon_setup(WEP_UZI, "uzi", IT_NAILS);
147 else if (req == WR_CHECKAMMO1)
148 return self.ammo_nails >= cvar("g_balance_uzi_first_ammo");
149 else if (req == WR_CHECKAMMO2)
150 return self.ammo_nails >= cvar("g_balance_uzi_first_ammo");
151 else if (req == WR_REGISTER)
152 weapon_register(WEP_UZI, cvar("g_balance_uzi_first_ammo"));