ent.dphitcontentsmask = oldsolid; // restore solid type (generally SOLID_SLIDEBOX)\r
\r
if (!g_norecoil)\r
- ent.punchangle_x = recoil * -1;\r
+ {\r
+ ent.punchangle_x += crandom() * recoil;\r
+ ent.punchangle_y += crandom() * recoil;\r
+ }\r
\r
if (snd != "")\r
{\r
sound (ent, CHAN_WEAPON, snd, VOL_BASE, ATTN_NORM);\r
}\r
\r
- if (ent.items & IT_STRENGTH)\r
- sound (ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);\r
+ if (ent.items & IT_STRENGTH && maxdamage)\r
+ sound (ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);\r
};\r
\r
#define W_SetupShot_ProjectileSize(ent,mi,ma,antilag,recoil,snd,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, v_forward, mi, ma, antilag, recoil, snd, maxdamage)\r
// otherwise, the stomach model the predator is transformed in (see Client_customizeentityforclient) will have a weapon model attached to it\r
if(self.owner.weaponname == "" || self.owner.deadflag != DEAD_NO)\r
return TRUE;\r
- if(other.cvar_chase_active > 0 || other.classname == "observer") // the classname check prevents a bug\r
- {\r
- setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3"));\r
- return TRUE;\r
- }\r
- if(other.spectatee_status)\r
+\r
+ float chase;\r
+ chase = other.cvar_chase_active;\r
+\r
+ if(other.spectatee_status && other.spectatee_status == num_for_edict(other.enemy))\r
other = other.enemy; // also do this for the player we are spectating\r
+\r
+ if not(chase || other.classname == "observer") // the observer check prevents a bug\r
if(other.predator == self.owner)\r
{\r
setmodel(self, "");\r
return TRUE;\r
}\r
- setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3"));\r
+\r
+ if(cvar("g_nodepthtestplayers"))\r
+ self.effects |= EF_NODEPTHTEST;\r
+ else\r
+ self.effects &~= EF_NODEPTHTEST;\r
+ if(cvar("g_fullbrightplayers"))\r
+ self.effects |= EF_FULLBRIGHT;\r
+\r
+ if not(self.owner.stat_eaten)\r
+ setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3"));\r
+ else if(cvar("g_vore_neighborprey_distance") && other.predator == self.owner.predator && !(chase || other.classname == "observer"))\r
+ {\r
+ setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); // allow seeing neighboring prey's weapon model\r
+ self.effects |= EF_NODEPTHTEST; // don't hide behind the stomach's own EF_NODEPTHTEST\r
+ }\r
+ else\r
+ setmodel(self, ""); // hide prey's weapon model\r
return TRUE;\r
}\r
\r
return;\r
}\r
if (self.cnt != self.owner.weapon || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag)\r
+ if (substring(self.owner.model, -4, 4) != ".md3") // not a stomach model\r
{\r
self.cnt = self.owner.weapon;\r
self.dmg = self.owner.modelindex;\r
}\r
else\r
{\r
- setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".dpm")); // precision set below\r
- animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".dpm.animinfo");\r
+ setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".iqm")); // precision set below\r
+ animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".iqm.animinfo");\r
animfile = fopen(animfilename, FILE_READ);\r
// preset some defaults that work great for renamed zym files (which don't need an animinfo)\r
- self.anim_fire1 = '0 1 0.01';\r
- self.anim_fire2 = '1 1 0.01';\r
- self.anim_idle = '2 1 0.01';\r
- self.anim_reload = '3 1 0.01';\r
- if (animfile >= 0)\r
- {\r
- animparseerror = FALSE;\r
- self.anim_fire1 = animparseline(animfile);\r
- self.anim_fire2 = animparseline(animfile);\r
- self.anim_idle = animparseline(animfile);\r
- self.anim_reload = animparseline(animfile);\r
- fclose(animfile);\r
- if (animparseerror)\r
- print("Parse error in ", animfilename, ", some player animations are broken\n");\r
- }\r
+ self.anim_fire1 = animfixfps(self, '0 1 0.01');\r
+ self.anim_fire2 = animfixfps(self, '1 1 0.01');\r
+ self.anim_idle = animfixfps(self, '2 1 0.01');\r
+ self.anim_reload = animfixfps(self, '3 1 0.01');\r
\r
// if we have a "weapon" tag, let's attach the v_ model to it ("invisible hand" style model)\r
// if we don't, this is a "real" animated model\r
self.movedir = '0 0 0';\r
self.spawnorigin = '0 0 0';\r
self.oldorigin = '0 0 0';\r
- self.anim_fire1 = '0 1 0.01';\r
- self.anim_fire2 = '0 1 0.01';\r
- self.anim_idle = '0 1 0.01';\r
- self.anim_reload = '0 1 0.01';\r
+ self.anim_fire1 = animfixfps(self, '0 1 0.01');\r
+ self.anim_fire2 = animfixfps(self, '0 1 0.01');\r
+ self.anim_idle = animfixfps(self, '0 1 0.01');\r
+ self.anim_reload = animfixfps(self, '0 1 0.01');\r
}\r
\r
self.view_ofs = '0 0 0';\r
\r
if(self.owner.alpha == default_player_alpha)\r
self.alpha = default_weapon_alpha;\r
- else if(self.owner.alpha != 0)\r
+ else if(self.owner.alpha != 0 && !self.owner.stat_eaten)\r
self.alpha = self.owner.alpha;\r
else\r
self.alpha = 1;\r
\r
self.colormap = self.owner.colormap;\r
+ self.colormod = self.owner.colormod;\r
+ self.glowmod = self.owner.weaponentity_glowmod;\r
if (self.weaponentity)\r
{\r
self.weaponentity.effects = self.effects;\r
self.weaponentity.alpha = self.alpha;\r
self.weaponentity.colormap = self.colormap;\r
self.weaponentity.colormod = self.owner.colormod; // used by the regurgitating colors\r
+ self.weaponentity.glowmod = self.glowmod;\r
}\r
\r
self.angles = '0 0 0';\r
\r
}\r
\r
- // create or update the lasertarget entity\r
+ // if we are a micro or macro, size the weapon model accordingly\r
+ if(cvar("g_healthsize") && cvar("g_healthsize_weapon_scalefactor"))\r
+ if(self.owner.scale) // prevents some exceptions\r
+ {\r
+ self.scale = pow(1 / self.owner.scale, cvar("g_healthsize_weapon_scalefactor"));\r
+ if(self.scale < 0.1)\r
+ self.scale = 0.1; // stuff breaks if scale is smaller than this\r
+ self.origin_z = (1 - self.scale) * cvar("g_healthsize_weapon_scalefactor_pos");\r
+\r
+ // copy properties to the static weapon entity as well\r
+ if(self.weaponentity != world) // prevents assignment to world\r
+ {\r
+ self.weaponentity.scale = self.scale;\r
+ self.weaponentity.origin = self.origin;\r
+ }\r
+ }\r
};\r
\r
void CL_ExteriorWeaponentity_Think()\r
return;\r
}\r
if (self.cnt != self.owner.weapon || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag)\r
+ if (substring(self.owner.model, -4, 4) != ".md3") // not a stomach model\r
{\r
self.cnt = self.owner.weapon;\r
self.dmg = self.owner.modelindex;\r
self.angles = ang;\r
}\r
\r
+ // if we are a micro or macro, size the weapon model accordingly\r
+ if(self.owner.scale && cvar("g_healthsize_exteriorweapon_scalefactor"))\r
+ if(self.model != "")\r
+ {\r
+ self.scale = 1 / self.owner.scale; // for some reason, the exterior weapon entity copies the player's scale somewhere else, so undo that first\r
+ self.scale = (1 - cvar("g_healthsize_exteriorweapon_scalefactor")) + cvar("g_healthsize_exteriorweapon_scalefactor") * self.scale;\r
+ }\r
+\r
self.colormap = self.owner.colormap;\r
+ self.glowmod = self.owner.weaponentity_glowmod;\r
self.customizeentityforclient = CL_ExteriorWeaponentity_CustomizeEntityForClient;\r
};\r
\r
\r
float client_hasweapon(entity cl, float wpn, float andammo, float complain)\r
{\r
- local float weaponbit, f;\r
- local entity oldself;\r
+ local float weaponbit;\r
+ //local float weaponbit, f;\r
+ //local entity oldself;\r
\r
if(time < self.hasweapon_complain_spam)\r
complain = 0;\r
weaponbit = W_WeaponBit(wpn);\r
if (cl.weapons & weaponbit)\r
{\r
- if (andammo)\r
+ // since we don't have an infinite ammo weapon in vore tournament, allow switching to the grabber even when it has no ammo\r
+ /*if (andammo)\r
{\r
if(cl.items & IT_UNLIMITED_WEAPON_AMMO)\r
{\r
}\r
return FALSE;\r
}\r
- }\r
+ }*/\r
return TRUE;\r
}\r
if (complain)\r
};\r
\r
// perform weapon to attack (weaponstate and attack_finished check is here)\r
-.float race_penalty;\r
-float weapon_prepareattack(float secondary, float attacktime)\r
+void W_SwitchToOtherWeapon(entity pl)\r
{\r
- //if sv_ready_restart_after_countdown is set, don't allow the player to shoot\r
- //if all players readied up and the countdown is running\r
- if(time < game_starttime || time < self.race_penalty) {\r
- return FALSE;\r
- }\r
+ // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)\r
+ float w, ww;\r
+ w = W_WeaponBit(pl.weapon);\r
+ pl.weapons &~= w;\r
+ ww = w_getbestweapon(pl);\r
+ pl.weapons |= w;\r
+ if(ww)\r
+ W_SwitchWeapon_Force(pl, ww);\r
+}\r
\r
+.float prevdryfire;\r
+float weapon_prepareattack_checkammo(float secondary)\r
+{\r
if not(self.items & IT_UNLIMITED_WEAPON_AMMO)\r
if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary))\r
{\r
- // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)\r
- float w, ww;\r
- w = W_WeaponBit(self.weapon);\r
- self.weapons &~= w;\r
- ww = w_getbestweapon(self);\r
- self.weapons |= w;\r
- if(ww)\r
- W_SwitchWeapon_Force(self, ww);\r
+ if(self.weapon == self.switchweapon && time - self.prevdryfire > 1) // only play once BEFORE starting to switch weapons\r
+ {\r
+ sound (self, CHAN_AUTO, "misc/unavailable.wav", VOL_BASE, ATTN_NORM);\r
+ self.prevdryfire = time;\r
+ }\r
+\r
+ // since we don't have an infinite ammo weapon in vore tournament, allow switching to the grabber even when it has no ammo\r
+ //W_SwitchToOtherWeapon(self);\r
+ return FALSE;\r
+ }\r
+ return TRUE;\r
+}\r
+.float race_penalty;\r
+float weapon_prepareattack_check(float secondary, float attacktime)\r
+{\r
+ if(!weapon_prepareattack_checkammo(secondary))\r
+ return FALSE;\r
+\r
+ //if sv_ready_restart_after_countdown is set, don't allow the player to shoot\r
+ //if all players readied up and the countdown is running\r
+ if(time < game_starttime || time < self.race_penalty) {\r
return FALSE;\r
}\r
\r
if (self.weaponentity.state != WS_READY)\r
return FALSE;\r
}\r
+\r
+ return TRUE;\r
+}\r
+float weapon_prepareattack_do(float secondary, float attacktime)\r
+{\r
self.weaponentity.state = WS_INUSE;\r
\r
self.spawnshieldtime = min(self.spawnshieldtime, time); // kill spawn shield when you fire\r
}\r
//dprint("attack finished ", ftos(ATTACK_FINISHED(self)), "\n");\r
return TRUE;\r
-};\r
+}\r
+float weapon_prepareattack(float secondary, float attacktime)\r
+{\r
+ if(weapon_prepareattack_check(secondary, attacktime))\r
+ {\r
+ weapon_prepareattack_do(secondary, attacktime);\r
+ return TRUE;\r
+ }\r
+ else\r
+ return FALSE;\r
+}\r
\r
void weapon_thinkf(float fr, float t, void() func)\r
{\r
if (t)\r
if (!self.crouch) // shoot anim stands up, this looks bad\r
{\r
- local vector anim;\r
- anim = self.anim_shoot;\r
- anim_z = anim_y / (t + sys_frametime);\r
- setanim(self, anim, FALSE, TRUE, TRUE);\r
+ vector anim;\r
+ if(self.weapon == WEP_GRABBER && self.BUTTON_ATCK2)\r
+ {\r
+ // use melee attack animation for grabber alt fire\r
+ anim = self.anim_melee;\r
+ anim_z = anim_y / (t + sys_frametime);\r
+ setanim(self, anim, FALSE, TRUE, TRUE);\r
+ }\r
+ else\r
+ {\r
+ anim = self.anim_shoot;\r
+ anim_z = anim_y / (t + sys_frametime);\r
+ setanim(self, anim, FALSE, TRUE, TRUE);\r
+ }\r
}\r
};\r
\r
\r
#define W_SETUPPROJECTILEVELOCITY_UP(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), cvar(#s "_speed_up"), cvar(#s "_speed_z"), cvar(#s "_spread"))\r
#define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, 0, cvar(#s "_spread"))\r
+\r
+void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload)\r
+{\r
+ if((self.items & IT_UNLIMITED_WEAPON_AMMO) && !ammo_reload)\r
+ return;\r
+\r
+ // if this weapon is reloadable, decrease its load. Else decrease the player's ammo\r
+ if(ammo_reload)\r
+ {\r
+ self.clip_load -= ammo_use;\r
+ self.(weapon_load[self.weapon]) = self.clip_load;\r
+ }\r
+ else\r
+ self.(self.current_ammo) -= ammo_use;\r
+}\r
+\r
+// weapon reloading code\r
+\r
+.float reload_ammo_amount, reload_ammo_min, reload_time;\r
+.float reload_complain;\r
+.string reload_sound;\r
+\r
+void W_ReloadedAndReady()\r
+{\r
+ // if we are inside the stomach, don't allow reloading, and schedule the weapon to reload once when we're out\r
+ if(self.stat_eaten)\r
+ {\r
+ self.clip_load = self.(weapon_load[self.weapon]) = -1;\r
+ w_ready(); // don't keep executing each frame\r
+ return;\r
+ }\r
+\r
+ // finish the reloading process, and do the ammo transfer\r
+\r
+ self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading\r
+\r
+ // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load\r
+ if(!self.reload_ammo_min || self.items & IT_UNLIMITED_WEAPON_AMMO)\r
+ self.clip_load = self.reload_ammo_amount;\r
+ else\r
+ {\r
+ while(self.clip_load < self.reload_ammo_amount && self.(self.current_ammo) >= 1) // make sure we don't add more ammo than we have\r
+ {\r
+ self.clip_load += 1;\r
+ self.(self.current_ammo) -= 1;\r
+ }\r
+ }\r
+ self.(weapon_load[self.weapon]) = self.clip_load;\r
+\r
+ // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,\r
+ // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,\r
+ // so your weapon is disabled for a few seconds without reason\r
+\r
+ //ATTACK_FINISHED(self) -= self.reload_time - 1;\r
+\r
+ w_ready();\r
+}\r
+\r
+void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound)\r
+{\r
+ // if we are inside the stomach, don't allow reloading\r
+ if(self.stat_eaten)\r
+ return;\r
+\r
+ // set global values to work with\r
+ self.reload_ammo_min = sent_ammo_min;\r
+ self.reload_ammo_amount = sent_ammo_amount;\r
+ self.reload_time = sent_time;\r
+ self.reload_sound = sent_sound;\r
+\r
+ // check if we meet the necessary conditions to reload\r
+\r
+ entity e;\r
+ e = get_weaponinfo(self.weapon);\r
+\r
+ // don't reload weapons that don't have the RELOADABLE flag\r
+ if not(e.spawnflags & WEP_FLAG_RELOADABLE)\r
+ {\r
+ dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");\r
+ return;\r
+ }\r
+ // return if reloading is disabled for this weapon\r
+ if(!self.reload_ammo_amount)\r
+ return;\r
+ // our weapon is fully loaded, no need to reload\r
+ if (self.clip_load >= self.reload_ammo_amount)\r
+ return;\r
+ // no ammo, so nothing to load\r
+ if(self.(self.current_ammo) < 1 && self.reload_ammo_min)\r
+ if not(self.items & IT_UNLIMITED_WEAPON_AMMO)\r
+ {\r
+ if(clienttype(self) == CLIENTTYPE_REAL && self.reload_complain < time)\r
+ {\r
+ play2(self, "misc/unavailable.wav");\r
+ sprint(self, strcat("You don't have enough ammo to reload the ^2", W_Name(self.weapon), "\n"));\r
+ self.reload_complain = time + 1;\r
+ }\r
+ // switch away if the amount of ammo is not enough to keep using this weapon\r
+ // disabled since we only have one weapon in VT, so nothing else to switch to if we're out of ammo\r
+ /*if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2))\r
+ {\r
+ self.clip_load = -1; // reload later\r
+ W_SwitchToOtherWeapon(self);\r
+ }*/\r
+ return;\r
+ }\r
+\r
+ if (self.weaponentity)\r
+ {\r
+ if (self.weaponentity.wframe == WFRAME_RELOAD)\r
+ return;\r
+\r
+ // allow switching away while reloading, but this will cause a new reload!\r
+ self.weaponentity.state = WS_READY;\r
+ }\r
+\r
+ // now begin the reloading process\r
+\r
+ // weapon reload effects\r
+ if(self.weapon == WEP_GRABBER && self.clip_load >= 0) // only when we first begin reloading\r
+ {\r
+ vector org;\r
+ org = self.origin + self.view_ofs + self.weaponentity.spawnorigin_x * v_forward - self.weaponentity.spawnorigin_y * v_right + self.weaponentity.spawnorigin_z * v_up;\r
+ SpawnCasing (org, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, self);\r
+ pointparticles(particleeffectnum("grabber_reload"), org, '0 0 0', 1);\r
+ }\r
+ sound (self, CHAN_WEAPON2, self.reload_sound, VOL_BASE, ATTN_NORM);\r
+\r
+ // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,\r
+ // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,\r
+ // so your weapon is disabled for a few seconds without reason\r
+\r
+ //ATTACK_FINISHED(self) = max(time, ATTACK_FINISHED(self)) + self.reload_time + 1;\r
+\r
+ weapon_thinkf(WFRAME_RELOAD, self.reload_time, W_ReloadedAndReady);\r
+\r
+ if(self.clip_load < 0)\r
+ self.clip_load = 0;\r
+ self.old_clip_load = self.clip_load;\r
+ self.clip_load = self.(weapon_load[self.weapon]) = -1;\r
+}\r