UE1 - UT Pickup absorb single damage source

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

bumrush

New Member
Aug 23, 2010
1
0
0
I need to make something happen when damage is received.

I made a modification for the UT_Shieldbelt class that disguises the wearer as a player from the opposite team. I want it to absorb the first blast of damage, whether that be falling damage, an IG shot, or a tick from the pulse gun, etc. I figured I would just set the armor high enough to absorb an IG shot and then call the destroyed() method when damage is received.
I'm a complete newbie to uscript, but I managed to make it right up to the finishing touches before encountering this problem and resorting to posting.

Here's my code just in case. I'm not sure if any of this will be relevant to the solution at hand, but if you read it and notice and blatant newbie blunders feel free to point them out.
Code:
class JBondsBelt expands UT_ShieldBelt;

var texture originalSkin[4];	// original skin will be saved here when item picked up
var mesh originalMesh;		// original mesh will be saved here when item picked up

function PickupFunction(Pawn Other)
{
	local Pawn P;
	local Pawn bestPawn;
	
	// Finds the player with the most deaths on the enemy team and prepares to copy their appearance
	for (P=Level.PawnList; P!=None ; P=P.nextPawn)
	{
		if (P.PlayerReplicationInfo.Team != Other.PlayerReplicationInfo.Team)
		{
			if (bestPawn == None)
				bestPawn = P;
			else if (P.DieCount >= bestPawn.DieCount)
				bestPawn = P;
		}
	}
	CopySkin(Other, bestPawn);	
}

// A = pawn that's changing skin
// B = pawn who's skin is to be copied
function CopySkin(Pawn A, Pawn B)
{
	local int i;
	originalMesh = A.Mesh;
	A.Mesh = B.Mesh;
	for(i = 0; i < 4; i++)
	{
		originalSkin[i]=A.MultiSkins[i];
		A.MultiSkins[i]=B.MultiSkins[i];
	}
}

// Sets owner's skin back to whatever it was before picking up the item
function DisguiseEnd()
{
	local int i;
	Owner.Mesh = originalMesh;
	for(i = 0; i < 4; i++)
		Owner.MultiSkins[i]=originalSkin[i];
	Spawn(class'EnergyBurst',,,Location); 
}

function Destroyed()
{
	DisguiseEnd();
	Super(UT_ShieldBelt).Destroyed();
}


I really appreciate this help and all previous posts, the forum is a great resource.
 

.:..:

New Member
Apr 11, 2006
61
0
0
Finland
I believe this is something what you are looking for:
Code:
function int ArmorAbsorbDamage(int Damage, name DamageType, vector HitLocation)
{
	ArmorImpactEffect(HitLocation);
	Destroy();
	return 0;
}
function int ArmorPriority(name DamageType)
{
	return 1000000;
}
As for rest of the code, are you sure you want to just copy from the player with most deaths only or a random player?
Code:
function PickupFunction(Pawn Other)
{
	local Pawn P,Candinates[6];
	local byte Count;
	
	// Finds the player with the most deaths on the enemy team and prepares to copy their appearance
	if( Level.Game.bTeamGame )
	{
		for (P=Level.PawnList; P!=None ; P=P.nextPawn)
		{
			if( P.PlayerReplicationInfo!=None && !P.PlayerReplicationInfo.bIsSpectator && P.PlayerReplicationInfo.Team!=Other.PlayerReplicationInfo.Team )
			{
				if( Count==ArrayCount(Candinates) )
					Candinates[Rand(ArrayCount(Candinates))] = P;
				else Candinates[Count++] = P;
			}
		}
	}
	else // Aswell support for DeathMatch
	{
		for (P=Level.PawnList; P!=None ; P=P.nextPawn)
		{
			if( P.PlayerReplicationInfo!=None && !P.PlayerReplicationInfo.bIsSpectator && P!=Other )
			{
				if( Count==ArrayCount(Candinates) )
					Candinates[Rand(ArrayCount(Candinates))] = P;
				else Candinates[Count++] = P;
			}
		}
	}
	if( Count>0 )
		CopySkin(Other, Candinates[Rand(Count)]);	
}
And finally to be safe (EnergyBurst should be spawned in Owner Location):
Code:
function DisguiseEnd()
{
	local byte i;

	if( Owner!=None && originalMesh!=None )
	{
		Owner.Mesh = originalMesh;
		for(i = 0; i < 4; i++)
			Owner.MultiSkins[i] = originalSkin[i];
		Spawn(class'EnergyBurst',,,Owner.Location);
	}
}