PDA

View Full Version : Weapon acting unusually...


Smoke39
16th Dec 2001, 04:35 PM
Why I didn't put my DynamicLoadObject question here is beyond me... Anyway, here's my new question.
This thing fires twice, one after the other, for every time you press fire.

function TraceFire(float accuracy)
{
local vector HitLocation, HitNormal, StartTrace, EndTrace, X, Y, Z;
local actor Other;

Owner.MakeNoise(Pawn(Owner).SoundDampening);
GetAxes(Pawn(owner).ViewRotation, X, Y, Z);
StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.Y * Y + FireOffset.Z * Z;
AdjustedAim = pawn(owner).AdjustAim(1000000, StartTrace, AimError, False, False);
EndTrace = StartTrace + 120.0 * vector(AdjustedAim);
Other = Pawn(Owner).TraceShot(HitLocation, HitNormal, EndTrace, StartTrace);
ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim), Y, Z);
}

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local int HitHeight, HitAngle;

if (Other == Level)
{
Spawn(class'SmallSpark2',,, HitLocation+HitNormal, Rotator(HitNormal));
}
else if (Other.IsA('Pawn'))
{
HitHeight = HitLocation.Z - Other.Location.Z;
HitAngle = (Other.Rotation.Yaw - rotator(HitLocation - Other.Location).Yaw) & 65535;

if (HitHeight > 0.72 * Other.CollisionHeight)
{
Other.TakeDamage(150, Pawn(Owner), HitLocation, 35000.0*X, 'Decapitated');
}
else if (HitHeight <= 0.72 * Other.CollisionHeight && HitHeight > 0.36 * Other.CollisionHeight)
{
Other.TakeDamage(40, Pawn(Owner), HitLocation, 32500.0*X, 'shot');
}
else if (HitHeight < 0.10 * Other.CollisionHeight)
{
Other.TakeDamage(10, Pawn(Owner), HitLocation, 27500.0*X, 'shot');
}
else
{
Other.TakeDamage(30, Pawn(Owner), HitLocation, 30000.0*X, 'shot');
}
}
else
Other.TakeDamage(35, Pawn(Owner), HitLocation, 30000.0*X, 'shot');
}

function Fire( float Value )
{
if (Mode=="Blades")
{
GoToState('BladesFire');
}
else
{
GotoState('NormalFire');

if ( PlayerPawn(Owner) != None )
PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);

bPointing=True;
// PlayFiring();
if ( !bRapidFire && (FiringSpeed > 0) )
Pawn(Owner).PlayRecoil(FiringSpeed);

ProjectileFire(ProjectileClass, ProjectileSpeed, bWarnTarget);

if ( Owner.bHidden )
CheckVisibility();
}
}

state BladesFire
{
ignores Fire, AltFire;

Begin:
FinishAnim();
CheckVisibility();
bPointing=True;
PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);
PlayAnim( Anim, AnimRate, 0.1);

Owner.MakeNoise(2.0 * Pawn(Owner).SoundDampening);
Owner.PlaySound(FireSound, SLOT_None,Pawn(Owner).SoundDampening*3);
TraceFire(0);
Finish();
}

Anyone know why?

Magus
18th Dec 2001, 10:03 AM
In function fire(...) you call ProjectileFire(...) and in state BladesFire you use Trace(0)

ProjectileFire + Trace = 2 Fires

That could be your problem.

Smoke39
18th Dec 2001, 08:38 PM
No, It checks the mode. It only goes to BladesFire if the mode is Blades and it only calls Projectile when the mode is not Blades.

Magus
18th Dec 2001, 09:32 PM
I got lost in all the parentheses. Still trying to find my way out into the real world.

Smoke39
19th Dec 2001, 09:31 PM
Quite understandable.

Wormbo
25th Dec 2001, 04:52 PM
What does the 'NormalFire' state look like? Maybe there is the problem.

/me spots CheckVisibility() in Fire() function
Do you extend from Weapon or TournamentWeapon?

Smoke39
26th Dec 2001, 01:53 AM
What's in NormalFire is irrelevent. It doesn't go to it when you're using the blades, the only mode that has the problem.

Wormbo
26th Dec 2001, 05:57 AM
I can't see a real problem in that code so I'm just guessing now.
Try inserting FinishAnim(); between TraceFire() and Finish().

Smoke39
26th Dec 2001, 10:32 PM
Yay. It worked.