Damage from weapon persists after Player death

Discussions about Coding and Scripting
User avatar
OjitroC
Godlike
Posts: 3086
Joined: Sat Sep 12, 2015 8:46 pm

Damage from weapon persists after Player death

Post by OjitroC » Sun Nov 20, 2022 10:18 pm

When hit by 'projectiles' from the addweap.hkg11, my movement (running speed) slows down considerably and this effect persists even after I am killed and respawn - my normal movement speed doesn't return until I start and play a new map (playing off-line in 469c Release - as an aside, I don't remember this happening in 451 but haven't tested that - a few tests in 436 suggest that it doesn't happen in that version so possibly 'something' introduced by 469c?).

This is the code for the weapon firing - can anyone indicate if there is anything in this code that would account for this significant loss of movement speed?

Code: Select all

function TraceFire( float Accuracy )
{
	local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z, AimDir;
	local actor Other;
        local Pawn PawnOwner;

	PawnOwner = Pawn(Owner);
    
	Owner.MakeNoise(PawnOwner.SoundDampening);
	GetAxes(PawnOwner.ViewRotation,X,Y,Z);
	StartTrace = Owner.Location + PawnOwner.Eyeheight * Z; 
	AdjustedAim = PawnOwner.AdjustAim(1000000, StartTrace, 2*AimError, False, False);	
	X = vector(AdjustedAim);
	 
	AdjustAccuracy(owner,ShotAccuracyBase,ShotAccuracy);

	 EndTrace = StartTrace + ShotAccuracy * (FRand() - 0.5 )* Y * 1000
		+ ShotAccuracy * (FRand() - 0.5 ) * Z * 1000;
	 AimDir = vector(AdjustedAim);
	 EndTrace += (10000 * AimDir); 
	
	Other = PawnOwner.TraceShot(HitLocation,HitNormal,EndTrace,StartTrace);
      	
	//recoil
	Pawn(Owner).ViewRotation.Pitch += (shotc * 8);
        shotc++;

	// visible tracing
        Count++;
	if ( Count == 3 ) 
	{
		Count = 0;
		if ( VSize(HitLocation - StartTrace) > 250 ) Spawn(class'MTracerXM',,, StartTrace + 96 * AimDir,rotator(EndTrace - StartTrace));
	}

	 ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
        
}

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
	if (Other == Level) Spawn(class'UT_HeavyWallHitEffect',,, HitLocation+HitNormal, Rotator(HitNormal));
	else if ( (Other != self) && (Other != Owner) && (Other != None) ) 
	{
		if ( Other.bIsPawn )
		{
		        ProcessHitLocation(owner,Other,HitLocation,X,HeadDamage,ArmorDamage,LegDamage);
			Other.PlaySound(Sound 'ChunkHit',, 4.0,,100);
		}

		if ( !Other.bIsPawn && !Other.IsA('Carcass') )
			spawn(class'UT_SpriteSmokePuff',,,HitLocation+HitNormal*9);	
	}
}

function Fire( float Value )
{
	Enable('Tick');
	if ( AmmoType == None )
	{
		// ammocheck
		GiveAmmo(Pawn(Owner));
	}
	if ( AmmoType.UseAmmo(1) )
	{
		If (AClipCount> 0)  		
		{
		AclipCount--;
		SoundVolume = 255;//*Pawn(Owner).SoundDampening;
		Pawn(Owner).PlayRecoil(FiringSpeed);
		bCanClientFire = true;
		bPointing=True;
		ClientFire(value);
		GotoState('NormalFire');
		}

		else 
		{
				
		GotoState('NewClip');
		}
	

	}
	else GoToState('Idle');
}

This is the complete .uc for the weapon should anyone wish to look at all of it
hkg11.ScriptText.zip
You do not have the required permissions to view the files attached to this post.

User avatar
Barbie
Godlike
Posts: 2479
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Damage from weapon persists after Player death

Post by Barbie » Sun Nov 20, 2022 11:39 pm

Looks like code of class'hkg11' is not enough - it extends class'addweapons'. Need to look there also. Best is to put a link to the complete package.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
OjitroC
Godlike
Posts: 3086
Joined: Sat Sep 12, 2015 8:46 pm

Re: Damage from weapon persists after Player death

Post by OjitroC » Mon Nov 21, 2022 1:01 am

This is the package
combat.zip
It's actually the mod Combat Zone.

One thing I have noticed is that the persistent speed reduction occurs in Low Gravity (using the default LG mutator) in 469c but does not occur in normal Gravity, nor does it happen in Low Gravity (using the default LG mutator) in 436. So something to do with Low Gravity in 469c?

User avatar
Barbie
Godlike
Posts: 2479
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Damage from weapon persists after Player death

Post by Barbie » Mon Nov 21, 2022 11:58 am

OMG!
(Firefox 102.4.0.esr says: "risk because the connection is not encrypted" - I feel like in a Kindergarden :pfff: )
OMG_The_end_is_near.jpg

Automatically merged

You can find the GroundSpeed reduction in class'addweapons' (expanding class'TournamentWeapon') in

Code: Select all

Function ProcessHitLocation(..., int LegDamage) {
	HitHeight = HitLocation.Z - Other.Location.Z;
...
	if (HitHeight < 0.75 * Other.CollisionHeight - Other.CollisionHeight ) {  
		Other.TakeDamage(LegDamage, Pawn(Owner), HitLocation, 25000 * X, MyDamageType);
		ReducedGroundspeed = Pawn(other).GroundSpeed - ReduceGroundSpeedRatio;
		If ( ReducedGroundSpeed <= MinGroundSpeed ) ReducedGroundSpeed=MinGroundSpeed;
		Pawn(other).GroundSpeed = ReducedGroundspeed;
		return;
	}
Because the condition is true for some negative values of HitHeight I assume that the victim was shot into the legs and therefore gets some damage and speed reduction.

You should also find an info in the HUD:

Code: Select all

Canvas.DrawText("Legs :status:  "$Int(legstatus)$" %");
You do not have the required permissions to view the files attached to this post.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
OjitroC
Godlike
Posts: 3086
Joined: Sat Sep 12, 2015 8:46 pm

Re: Damage from weapon persists after Player death

Post by OjitroC » Mon Nov 21, 2022 12:27 pm

Thanks for that.

So that explains the speed reduction but is there anything in the code that explains why that speed reduction persists after the victim is killed and respawned?

The difference in behaviour between LG and normal gravity (and between UT versions) is difficult to test as you have now shown that the speed reduction depends on the hit location and accuracy of hit location can only be achieved by testing with human players which I am not doing.

User avatar
Barbie
Godlike
Posts: 2479
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Damage from weapon persists after Player death

Post by Barbie » Mon Nov 21, 2022 1:25 pm

There is nothing in the code that resets the speed reduction. Maybe make a small mutator that catches the event when a player respawns and set his default GroundSpeed then.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
EvilGrins
Godlike
Posts: 8956
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA

Re: Damage from weapon persists after Player death

Post by EvilGrins » Mon Nov 21, 2022 7:00 pm

While I can't speak to this specific thing, there are a number of mutators that offer weapons or things that ultimately result in players not being able to move as fast. Like the Quake Weapons, played under the mutator and not directly edited onto a map, of Frag'n'Brag offered some new Relics on his more recent map edits and one was for super speed... but when it wore off you weren't back to normal speed.

It was like your switched from playing in Turbo back down to Hardcore.

Most of these slow downs would stick with you until play on that particular map ended and a new map loaded... and yes, this is all from before the new patch; which I can easily confirm as I still don't have the new patch.
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758

User avatar
OjitroC
Godlike
Posts: 3086
Joined: Sat Sep 12, 2015 8:46 pm

Re: Damage from weapon persists after Player death

Post by OjitroC » Mon Nov 21, 2022 10:19 pm

Barbie wrote:
Mon Nov 21, 2022 1:25 pm
There is nothing in the code that resets the speed reduction. Maybe make a small mutator that catches the event when a player respawns and set his default GroundSpeed then.
That clears that up nicely - thanks for the info.