Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // DWHealthPack
- // A nonrespawnable Health Pickup that decreases in size as its internal
- // Health capacity lowers. It also prevents the griefers from steeling all
- // health since they can't take more than what their character can handle.
- // Author: DW>Ant
- // Date: July 12, 2010
- //=============================================================================
- class DWHealthPack extends TournamentHealth
- placeable;
- //Note: HealAmount variable is useless for this actor
- var() float TotalHealthAmount; //Health amount (only used for initializing)
- var() bool bResizePack; //Want the pack to shrink as more health is drained from it?
- var() bool bCantTakeAllAtOnce; //if true, the player will have to walk over the pickup multiple times to get it all
- var() float HealthPerTouch; //How much Health player will get per touch
- var float HealthRemaining; //Used for the PercentUse property
- var float PercentUsed; //Health pickedup/HealthAmount %
- var float InitialDrawScale; //Keep track the original scale
- var float CollisionDrawScaleRatio; //What's the ratio of collision / drawscale
- var float CollisionDrawScaleRatioHeight; //Same thing, but for the height
- event PostBeginPlay()
- {
- if (TotalHealthAmount <= 0)
- TotalHealthAmount = 1; //Just in case
- HealthRemaining = TotalHealthAmount;
- InitialDrawScale = DrawScale;
- CollisionDrawScaleRatio = default.DrawScale/default.CollisionRadius;
- CollisionDrawScaleRatioHeight = default.DrawScale/default.CollisionHeight;
- SetCollisionSize(DrawScale/CollisionDrawScaleRatio, DrawScale/CollisionDrawScaleRatioHeight );
- }
- auto state Pickup
- {
- function Touch( actor Other )
- {
- local Pawn P;
- local float HealthPickUp, MaxPotentialHealth;
- if ( ValidTouch(Other))
- {
- P = Pawn(Other);
- if (P.Health >= P.SuperHealthMax)
- return; //Pawn already full, don't pickup
- else if (P.Health >= P.HealthMax && !bSuperHeal)
- return; //Pawn already full, don't pickup
- if (bCantTakeAllAtOnce)
- {
- if (HealthRemaining <= MaxPotentialHealth)
- MaxPotentialHealth = HealthRemaining;
- else
- MaxPotentialHealth = HealthPerTouch;
- if (MaxPotentialHealth <= (P.HealthMax-P.Health) )
- HealthPickUp = MaxPotentialHealth;
- else if (bSuperHeal && ( MaxPotentialHealth <= (P.SuperHealthMax - P.Health) ) )
- HealthPickUp = MaxPotentialHealth;
- else if (bSuperHeal)
- HealthPickup = P.SuperHealthMax - P.Health;
- else
- HealthPickup = P.HealthMax - P.Health;
- }
- else
- {
- if (bSuperHeal)
- {
- if (HealthRemaining <= (P.SuperHealthMax - P.Health) )
- HealthPickup = HealthRemaining; //Take what's left
- else //Health > Player Max Super Health
- HealthPickup = P.SuperHealthMax - P.Health;
- }
- else
- {
- if (HealthRemaining <= (P.HealthMax - P.Health) )
- HealthPickUp = HealthRemaining; //Take what's left
- else //Health > Player Max Health
- HealthPickUp = P.HealthMax - P.Health;
- }
- }
- HealthRemaining -= HealthPickup;
- //Resize the pack
- if (bResizePack && Role == ROLE_Authority)
- ResizePill();
- if (bSuperHeal)
- P.GiveHealth(HealthPickup, P.SuperHealthMax);
- else
- P.GiveHealth(HealthPickup, P.HealthMax);
- AnnouncePickup(P);
- if (HealthRemaining <= 0)
- Destroy(); //Remove the Health if it's out
- }
- }
- function ResizePill()
- {
- PercentUsed = InitialDrawScale * (HealthRemaining/TotalHealthAmount);
- SetDrawScale( PercentUsed ); //Resize the pack
- if (CollisionRadius <= 10) //Prevent Collision from being impossibly small
- SetCollisionSize(DrawScale/CollisionDrawScaleRatio, DrawScale/CollisionDrawScaleRatioHeight ); //Redo the collision
- }
- }
- defaultproperties
- {
- HealthPerTouch=25
- bResizePack=True
- bSuperHeal=True
- CollisionRadius=24
- CollisionHeight=23
- DrawScale=0.400000
- TotalHealthAmount=200
- RemoteRole=ROLE_SimulatedProxy
- PickupSound=sound'PickupSounds.HealthPack'
- PickupForce="HealthPack"
- DrawType=DT_StaticMesh
- StaticMesh=StaticMesh'E_Pickups.MidHealth'
- Style=STY_AlphaZ
- ScaleGlow=0.6
- TransientSoundVolume=0.35
- CullDistance=+6500.0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement