-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIX_KatanaFire.uc
154 lines (128 loc) · 4.67 KB
/
FIX_KatanaFire.uc
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
class FIX_KatanaFire extends KatanaFire;
function Timer()
{
ProcessFire(Self);
}
static final function vector GetAimPos( Actor Other )
{
local KFMonster P;
local Coords C;
local bool bAlt;
P = KFMonster(Other);
if( P==None || P.Health<=0 )
return Other.Location;
if( P.HeadBone=='' || SkeletalMesh(P.Mesh)==None )
return P.Location + vect(0,0,0.9)*P.CollisionHeight;
// If we are a dedicated server estimate what animation is most likely playing on the client
if( P.Level.NetMode == NM_DedicatedServer )
{
if( !P.IsAnimating(0) && !P.IsAnimating(1) )
{
if (P.Physics == PHYS_Falling)
P.PlayAnim(P.AirAnims[0], 1.0, 0.0);
else if (P.Physics == PHYS_Walking)
{
if (P.bIsCrouched)
P.PlayAnim(P.IdleCrouchAnim, 1.0, 0.0);
else bAlt=true;
}
else if (P.Physics == PHYS_Swimming)
P.PlayAnim(P.SwimAnims[0], 1.0, 0.0);
P.SetAnimFrame(0.5);
}
}
if( bAlt )
return P.Location + (P.OnlineHeadshotOffset >> P.Rotation);
C = P.GetBoneCoords(P.HeadBone);
return C.Origin + (P.HeadHeight * P.HeadScale * C.XAxis);
}
static final function function ProcessFire( KFMeleeFire F )
{
local Actor HitActor;
local vector StartTrace, EndTrace, HitLocation, HitNormal;
local rotator PointRot;
local int MyDamage;
local bool bBackStabbed;
local Pawn Victims;
local vector dir, lookdir;
local float DiffAngle, VictimDist;
local Pawn Inst;
MyDamage = F.MeleeDamage;
If( F.Weapon!=None && F.Instigator!=None && !KFWeapon(F.Weapon).bNoHit )
{
Inst = F.Instigator;
MyDamage = F.MeleeDamage;
StartTrace = Inst.Location + Inst.EyePosition();
if( Inst.Controller!=None && !Inst.IsHumanControlled() && Inst.Controller.Target!=None )
{
PointRot = rotator(GetAimPos(Inst.Controller.Target)-StartTrace); // Give aimbot for bots.
}
else
{
PointRot = Inst.GetViewRotation();
}
EndTrace = StartTrace + vector(PointRot)*F.weaponRange;
HitActor = Inst.Trace( HitLocation, HitNormal, EndTrace, StartTrace, true);
if (HitActor!=None)
{
F.ImpactShakeView();
if( HitActor.IsA('ExtendedZCollision') && HitActor.Base!=none && HitActor.Base.IsA('KFMonster') )
{
HitActor = HitActor.Base;
}
if ( (HitActor.IsA('KFMonster') || HitActor.IsA('KFHumanPawn')) && KFMeleeGun(F.Weapon).BloodyMaterial!=none )
{
F.Weapon.Skins[KFMeleeGun(F.Weapon).BloodSkinSwitchArray] = KFMeleeGun(F.Weapon).BloodyMaterial;
F.Weapon.texture = F.Weapon.default.Texture;
}
if( F.Level.NetMode==NM_Client )
Return;
if( HitActor.IsA('Pawn') && !HitActor.IsA('Vehicle') && ((HitActor.Location-Inst.Location) dot vector(HitActor.Rotation))>0 ) // Fixed in Balance Round 2
{
bBackStabbed = true;
MyDamage*=2; // Backstab >:P
}
if( (KFMonster(HitActor)!=none) )
{
KFMonster(HitActor).bBackstabbed = bBackStabbed;
HitActor.TakeDamage(MyDamage, Inst, HitLocation, vector(PointRot), F.hitDamageClass);
if(F.MeleeHitSounds.Length > 0)
{
F.Weapon.PlaySound(F.MeleeHitSounds[Rand(F.MeleeHitSounds.length)],SLOT_None,F.MeleeHitVolume,,,,false);
}
if( VSize(Inst.Velocity)>300 && KFMonster(HitActor).Mass<=Inst.Mass )
KFMonster(HitActor).FlipOver();
}
else
{
HitActor.TakeDamage(MyDamage, Inst, HitLocation, vector(PointRot), F.hitDamageClass);
F.Level.Spawn(F.HitEffectClass,,, HitLocation, rotator(HitLocation - StartTrace));
}
}
if( F.Weapon!=None && F.WideDamageMinHitAngle > 0 )
{
foreach F.Weapon.VisibleCollidingActors( class 'Pawn', Victims, (F.weaponRange * 3), StartTrace ) //, RadiusHitLocation
{
if( Victims==HitActor || Victims.Health<=0 || Victims==Inst )
continue;
VictimDist = VSizeSquared(Inst.Location - Victims.Location);
if( VictimDist > (((F.weaponRange * 1.1) * (F.weaponRange * 1.1)) + (Victims.CollisionRadius * Victims.CollisionRadius)) )
continue;
lookdir = Normal(Vector(Inst.GetViewRotation()));
dir = Normal(Victims.Location - Inst.Location);
DiffAngle = lookdir dot dir;
if( DiffAngle > F.WideDamageMinHitAngle )
{
Victims.TakeDamage(MyDamage*DiffAngle, Inst, (Victims.Location + Victims.CollisionHeight * vect(0,0,0.7)), vector(PointRot), F.hitDamageClass);
if( F.Weapon==None )
break;
if( Victims!=None && F.MeleeHitSounds.Length>0 )
Victims.PlaySound(F.MeleeHitSounds[Rand(F.MeleeHitSounds.length)],SLOT_None,F.MeleeHitVolume,,,,false);
}
}
}
}
}
defaultproperties
{
}