WEAPON_SNIPER: Basic implementation
This commit is contained in:
parent
dd918f106c
commit
6adad7195e
1 changed files with 106 additions and 12 deletions
|
@ -14,26 +14,37 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
SNIPER_IDLE,
|
||||
SNIPER_AIM,
|
||||
SNIPER_FIRE,
|
||||
SNIPER_DRAW,
|
||||
SNIPER_HOLSTER,
|
||||
SNIPER_AUTOIDLE,
|
||||
SNIPER_AUTOFIRE,
|
||||
SNIPER_AUTODRAW,
|
||||
SNIPER_AUTOHOLSTER,
|
||||
};
|
||||
|
||||
void
|
||||
w_sniper_precache(void)
|
||||
{
|
||||
precache_model("models/v_tfc_sniper.mdl");
|
||||
precache_model("models/w_sniper.mdl");
|
||||
precache_model("models/p_sniper.mdl");
|
||||
Sound_Precache("weapon_sniper.fire");
|
||||
}
|
||||
|
||||
void
|
||||
w_sniper_updateammo(player pl)
|
||||
{
|
||||
#ifdef SERVER
|
||||
Weapons_UpdateAmmo(pl, __NULL__, __NULL__, __NULL__);
|
||||
#endif
|
||||
Weapons_UpdateAmmo(pl, __NULL__, pl.m_iAmmoShells, __NULL__);
|
||||
}
|
||||
|
||||
string
|
||||
w_sniper_wmodel(void)
|
||||
{
|
||||
return "models/w_sniper.mdl";
|
||||
return;
|
||||
}
|
||||
string
|
||||
w_sniper_pmodel(player pl)
|
||||
|
@ -47,11 +58,17 @@ w_sniper_deathmsg(void)
|
|||
return "%s was assaulted by %s's Assault Cannon.";
|
||||
}
|
||||
|
||||
void
|
||||
w_sniper_release(player pl)
|
||||
{
|
||||
Weapons_ViewAnimation(pl, SNIPER_IDLE);
|
||||
}
|
||||
|
||||
void
|
||||
w_sniper_draw(player pl)
|
||||
{
|
||||
Weapons_SetModel("models/v_tfc_sniper.mdl");
|
||||
Weapons_ViewAnimation(pl, 0);
|
||||
Weapons_ViewAnimation(pl, SNIPER_IDLE);
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -60,6 +77,83 @@ w_sniper_aimanim(player pl)
|
|||
return self.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR;
|
||||
}
|
||||
|
||||
void
|
||||
w_sniper_primary(player pl)
|
||||
{
|
||||
|
||||
//pl.mode_still = 1 - pl.mode_still;
|
||||
|
||||
// TODO
|
||||
// Below should be in the release, we need to detect whether we are still and then create the "dot"
|
||||
|
||||
if (pl.w_attack_next > 0.0)
|
||||
return;
|
||||
|
||||
w_baseauto_fire(pl, player::m_iAmmoShells, 8, [0,0]);
|
||||
Weapons_ViewAnimation(pl, SNIPER_FIRE);
|
||||
#ifdef CLIENT
|
||||
View_SetMuzzleflash(MUZZLE_WEIRD);
|
||||
#endif
|
||||
Weapons_Sound(pl, CHAN_WEAPON, "weapon_sniper.fire");
|
||||
pl.w_attack_next = 2.0f;
|
||||
|
||||
pl.w_idle_next = 1.5f;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
w_sniper_secondary(player pl)
|
||||
{
|
||||
if (pl.w_attack_next) {
|
||||
return;
|
||||
}
|
||||
/* Simple toggle of fovs */
|
||||
if (pl.viewzoom == 1.0f) {
|
||||
pl.viewzoom = 0.2f;
|
||||
} else {
|
||||
pl.viewzoom = 1.0f;
|
||||
}
|
||||
pl.w_attack_next = 0.5f;
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
w_sniper_release(player pl)
|
||||
{
|
||||
if (pl.w_attack_next > 0.0)
|
||||
return;
|
||||
|
||||
// Can't fire if moving
|
||||
//if (pl.mode_still == 1) {
|
||||
w_baseauto_fire(pl, player::m_iAmmoShells, 8, [0,0]);
|
||||
Weapons_ViewAnimation(pl, SNIPER_FIRE);
|
||||
#ifdef CLIENT
|
||||
View_SetMuzzleflash(MUZZLE_WEIRD);
|
||||
#else
|
||||
Sound_Play(pl, CHAN_WEAPON, "weapon_sniper.fire");
|
||||
#endif
|
||||
pl.w_attack_next = 2.0f;
|
||||
//}
|
||||
pl.w_idle_next = 1.5f;
|
||||
}
|
||||
*/
|
||||
void
|
||||
w_sniper_postdraw(player pl)
|
||||
{
|
||||
#ifdef CLIENT
|
||||
// crosshair
|
||||
if (pl.viewzoom == 1) {
|
||||
Cross_DrawSub(g_cross_spr, [24,24], [72/128,0], [0.1875, 0.1875]);
|
||||
} else {
|
||||
Cross_DrawSub(g_cross_spr, [104,16], [24/128,96/128], [104/128, 16/128]);
|
||||
}
|
||||
// ammo counter
|
||||
HUD_DrawAmmo2();
|
||||
vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];
|
||||
drawsubpic(aicon_pos, [24,24], "sprites/640hud7.spr_0.tga", [72/256,72/128], [24/256, 24/128], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
w_sniper_hudpic(player pl, int selected, vector pos, float a)
|
||||
{
|
||||
|
@ -69,7 +163,7 @@ w_sniper_hudpic(player pl, int selected, vector pos, float a)
|
|||
pos,
|
||||
[170,45],
|
||||
"sprites/tfchud02.spr_0.tga",
|
||||
[0,45/256],
|
||||
[0,0],
|
||||
[170/256,45/256],
|
||||
g_hud_color,
|
||||
a,
|
||||
|
@ -80,7 +174,7 @@ w_sniper_hudpic(player pl, int selected, vector pos, float a)
|
|||
pos,
|
||||
[170,45],
|
||||
"sprites/tfchud01.spr_0.tga",
|
||||
[0,45/256],
|
||||
[0,0],
|
||||
[170/256,45/256],
|
||||
g_hud_color,
|
||||
a,
|
||||
|
@ -98,15 +192,15 @@ weapon_t w_sniper =
|
|||
.slot_pos = 1,
|
||||
.draw = w_sniper_draw,
|
||||
.holster = __NULL__,
|
||||
.primary = __NULL__,
|
||||
.secondary = __NULL__,
|
||||
.primary = w_sniper_primary,
|
||||
.secondary = w_sniper_secondary,
|
||||
.reload = __NULL__,
|
||||
.release = __NULL__,
|
||||
.postdraw = __NULL__,
|
||||
.postdraw = w_sniper_postdraw,
|
||||
.precache = w_sniper_precache,
|
||||
.pickup = __NULL__,
|
||||
.updateammo = w_sniper_updateammo,
|
||||
.wmodel = w_sniper_wmodel,
|
||||
.wmodel = __NULL__,
|
||||
.pmodel = w_sniper_pmodel,
|
||||
.deathmsg = w_sniper_deathmsg,
|
||||
.aimanim = w_sniper_aimanim,
|
||||
|
|
Loading…
Reference in a new issue