-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweapon_paranoia_knife.as
117 lines (97 loc) · 4.22 KB
/
weapon_paranoia_knife.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
class weapon_paranoia_knife : CBaseParanoiaWeapon{
int iSwing;
TraceResult pHitTrace;
weapon_paranoia_knife(){
szVModel = "models/paranoia/v_crowbar.mdl";
szPModel = "models/paranoia/p_crowbar.mdl";
szWModel = "models/paranoia/w_crowbar.mdl";
szHUDModel = "sprites/paranoia/p_hud2.spr";
szAnimation = "crowbar";
flDeploy = 1.0f;
iDefaultGive = 0;
iMaxAmmo1 = -1;
iMaxClip = -1;
iSlot = 1;
iPosition = 7;
iDrawAnimation = 5;
aryFireAnimation = {1, 2, 3, 4};
aryIdleAnimation = {0};
aryFireSound = {"weapons/paranoia/knife_stab.wav"};
aryOtherSound = {"weapons/paranoia/knife_deploy1.wav", };
}
void PrimaryAttack() override{
Swing(1);
}
void SecondaryAttack() override{
Swing(1, false, 0.8);
}
void Smack(){
g_WeaponFuncs.DecalGunshot( pHitTrace, BULLET_PLAYER_CROWBAR );
}
bool Swing( int fFirst , bool bIsPrimary = true, float flNextAttack = 0.5){
bool fDidHit = false;
TraceResult tr;
Math.MakeVectors( pPlayer.pev.v_angle );
Vector vecSrc = pPlayer.GetGunPosition();
Vector vecEnd = vecSrc + g_Engine.v_forward * 32;
g_Utility.TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pPlayer.edict(), tr );
if ( tr.flFraction >= 1.0 ){
g_Utility.TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, pPlayer.edict(), tr );
if ( tr.flFraction < 1.0 ){
CBaseEntity@ pHit = g_EntityFuncs.Instance( tr.pHit );
if ( pHit is null || pHit.IsBSPModel() )
g_Utility.FindHullIntersection( vecSrc, tr, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, pPlayer.edict() );
vecEnd = tr.vecEndPos;
}
}
//写人人都看得懂的工程代码
//不做无脑炫技人
iSwing++;
if(bIsPrimary)
self.SendWeaponAnim( aryFireAnimation[iSwing % 2] );
self.m_flTimeWeaponIdle = self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = g_Engine.time + flNextAttack;
pPlayer.SetAnimation( PLAYER_ATTACK1 );
g_SoundSystem.EmitSoundDyn( pPlayer.edict(), CHAN_WEAPON, aryFireSound[0], 1, ATTN_NORM, 0, 94 + Math.RandomLong( 0,0xF ) );
if ( tr.flFraction >= 1.0 ){
if( fFirst != 0 )
if(!bIsPrimary)
self.SendWeaponAnim(aryFireAnimation[3]);
}
else{
fDidHit = true;
CBaseEntity@ pEntity = g_EntityFuncs.Instance( tr.pHit );
float flDamage = bIsPrimary ? 15 : 45;
g_WeaponFuncs.ClearMultiDamage();
if ( self.m_flNextPrimaryAttack + 1 < g_Engine.time )
pEntity.TraceAttack( pPlayer.pev, flDamage, g_Engine.v_forward, tr, DMG_CLUB );
else
pEntity.TraceAttack( pPlayer.pev, flDamage * 0.5, g_Engine.v_forward, tr, DMG_CLUB );
g_WeaponFuncs.ApplyMultiDamage( pPlayer.pev, pPlayer.pev );
float flVol = 1.0;
bool fHitWorld = true;
if(!bIsPrimary)
self.SendWeaponAnim(aryFireAnimation[2]);
if( pEntity !is null ){
if( pEntity.Classify() != CLASS_NONE && pEntity.Classify() != CLASS_MACHINE && pEntity.BloodColor() != DONT_BLEED ){
if( pEntity.IsPlayer() )
pEntity.pev.velocity = pEntity.pev.velocity + ( self.pev.origin - pEntity.pev.origin ).Normalize() * 120;
pPlayer.m_iWeaponVolume = 128;
if( !pEntity.IsAlive() )
return true;
else
flVol = 0.1;
fHitWorld = false;
}
}
if( fHitWorld ){
float fvolbar = g_SoundSystem.PlayHitSound( tr, vecSrc, vecSrc + ( vecEnd - vecSrc ) * 2, BULLET_PLAYER_CROWBAR );
fvolbar = 1;
}
pHitTrace = tr;
SetThink( ThinkFunction( this.Smack ) );
self.pev.nextthink = g_Engine.time + 0.2;
pPlayer.m_iWeaponVolume = int( flVol * 512 );
}
return fDidHit;
}
}