Dropped item that give healing

Hello,

I would like to add healing to a dropped item. The item is dropped from an enemy who has been killed.

My code:



class Medop extends UTInventory;

var int HealingAmount;
var bool bSuperHeal;

event bool HealDamage(int Amount, Controller Healer, class<DamageType> DamageType);

function SpawnCopyFor( Pawn Recipient )
{
	Recipient.Health += HealAmount(Recipient);

}

function int HealAmount(Pawn Recipient)
{
	local UTPawn UTP;

	if (bSuperHeal)
	{
		UTP = UTPawn(Recipient);
		if (UTP != None)
		{
			return FClamp(UTP.SuperHealthMax - Recipient.Health, 0, HealingAmount);
		}
	}
	return FClamp(Recipient.HealthMax - Recipient.Health, 0, HealingAmount);
}

  simulated function PostBeginPlay()
{
  super.PostbeginPlay();
}

function bool DenyPickupQuery(class<Inventory> ItemClass, Actor Pickup)
{
	if (ItemClass == Class)
	{
		if ( PickupFactory(Pickup) != None )
		{
			PickupFactory(Pickup).PickedUpBy(Instigator);
		}
		else if ( DroppedPickup(Pickup) != None )
		{
			DroppedPickup(Pickup).PickedUpBy(Instigator);
		}
		AnnouncePickup(Instigator);
		return true;
	}

	return false;
}

defaultproperties
{
	Begin Object Class=StaticMeshComponent Name=MeshComponentA
		StaticMesh=StaticMesh'PJS_Res03.pjs03_redcross'
		Materials(0)=none
		AlwaysLoadOnClient=true
		AlwaysLoadOnServer=true
		CastShadow=false
		bForceDirectLightMap=true
		bCastDynamicShadow=false
		bAcceptsLights=true
		CollideActors=false
		BlockRigidBody=false
		Scale3D=(X=0.7,Y=0.7,Z=0.7)
		MaxDrawDistance=8000
		Translation=(X=0.0,Y=0.0,Z=+5.0)
	End Object
	DroppedPickupMesh=MeshComponentA
	PickupFactoryMesh=MeshComponentA
	
	PickupSound=SoundCue'PJS_sounds.Objects.pickup_redcross'
	
	bDropOnDeath=true
  
  HealingAmount=10
  bSuperHeal=true
}


The problem is when you get the item nothing happen. No healing.
I tried a lot of things but i think it’s the best i got.

Thanks.

It’s ‘touch and use’ or the health item is added to the player inventory for later use - which?

At a glance using UnCodeX, UTHealthPickupFactory extends UTPickupFactory rather than UTInventory as you have it. But if you want the Health Pickup to be an Inventory Item that can be used later at will by the player that makes it more complicated and something I’d have to think about for a while before I understood the process to offer you any help.

But if the health pickup is only ‘touch and use’ I’d copy pasta all the UTHealthPickup stuff until I got it working… because obviously the UTHealthPickupFactory works ok.
You’ve successfully managed to get the dead to drop health, and another player to pick up the health so other than activate the health you’re pretty much there.

Thanks for your answer Snipe34 but I finally found another solution.

Script:


class Medop_01 extends UTInventory;

function bool DenyPickupQuery(class<Inventory> ItemClass, Actor Pickup)
{
	if (ItemClass == Class)
	{
		if ( PickupFactory(Pickup) != None )
		{
			PickupFactory(Pickup).PickedUpBy(Instigator);
		}
		else if ( DroppedPickup(Pickup) != None )
		{
			DroppedPickup(Pickup).PickedUpBy(Instigator);
		}
		AnnouncePickup(Instigator);
		return true;
	}
	return false;
}

defaultproperties
{
	Begin Object Class=StaticMeshComponent Name=MeshComponentA
		StaticMesh=StaticMesh'PJS_Res03.pjs03_medop'
		AlwaysLoadOnClient=true
		AlwaysLoadOnServer=true
		CastShadow=false
		bForceDirectLightMap=true
		bCastDynamicShadow=false
		bAcceptsLights=true
		CollideActors=false
		BlockRigidBody=false
		Scale3D=(X=0.3,Y=0.3,Z=0.3)
		MaxDrawDistance=8000
		Translation=(X=0.0,Y=0.0,Z=+0.0)
	End Object
	DroppedPickupMesh=MeshComponentA
	
	PickupSound=SoundCue'PJS_sounds.Objects.pickup_medop'
	
	bDropOnDeath=false

}

There is a little problem, you have to create a script for each bot which drop the item.

And the Kismet part:

Thanks for replying ddzev

There has to be another way. I’m working on loot which is similar - bot dies drops; player picks up. At a glance AdjustPawn(…) from UTJumpBoots? Later, I’m doing other stuff now but I’ll get back later.

you could do it all in the pawn.

ie


event Touch (Actor Other, PrimitiveComponent OtherComp, Object.Vector HitLocation, Object.Vector HitNormal)
{
       local actor otheractor;

       otheractor = Other;

              if (Medop(Other) != None)
            {
                   ///your stuff here/////
                   otheractor.destroy();
            }
}


event Touch (Actor Other, PrimitiveComponent OtherComp, Object.Vector HitLocation, Object.Vector HitNormal)
{
       local actor otheractor;

       otheractor = Other;

              if (Medop(Other) != None)
            {
                   if(health<=maxhealth)
                      {
                          health=health+otheractor.healingamount;
                       }
                   otheractor.destroy();
            }
}

couldn’t edit my other post.

I’m working on Loot and noticed this post:

UDK Forums Update - UDK Content Creation and Design - Epic Developer Community Forums!

His problem:
"However, My overridden functions of GiveTo and SpawnCopyFor are never being called. I am obviously missing something. I double checked, and my pickupfactory is on the map instead of the generic one. "

Last post his solution: “the problem that I encountered is that I was overriding the incorrect chain of functions. GiveTo(P) and SpawnCopyFor(P) are only called when the pawn does not currently possess the weapon they are trying to pickup. Otherwise a function in UTWeapon called DenyPickupQuery(…) is called. So a simple override of that to use my AddAmmo function worked out.”