This is the Maximum Health modifying script for the Stat Points Mutator.
First, you want to make an Inventory subclass. This class will be carried around with the player, making sure that he has the right Maximum Health.
class HealthInv extends Inventory; simulated function CalculateHealth( int StatPoints ) { Instigator.HealthMax = Instigator.default.HealthMax + 20 * StatPoints; Instigator.SuperHealthMax = Instigator.HealthMax + 100; }
It has the function CalculateHealth(), which, when called, will set the Instigator's (player's) Maximum Health to its normal value, plus 20 for each stat point. Also, the Super Health Max of the player will be set 100 above that.
Now, this doesn't do anything right off the bat, so we need to make a Mutator that will control its execution.
class MutHealthModifier extends Mutator; function ModifyPawn( Pawn Other ) { local Inventory Inv; local HealthInv Health_Inv; Super.ModifyPlayer(Other); if ( Other.Controller == None || !Other.Controller.bIsPlayer ) return; Inv = Other.FindInventoryType(class'HealthInv'); if ( Inv == None ) { Health_Inv = Spawn(class'HealthInv'); if ( Health_Inv != None ) Health_Inv.GiveTo(Other, None); Health_Inv.CalculateHealth(2); } }
The above goes through every player, makes sure it is controlled and is a player, sees if it already has a HealthInv, and if not, spawns one and gives the player an automatic 2*20 = 40 extra points to their Maximum Health. If you want a more dynamic modifier, I suggest you start from Legacy:Stat Points System/StatPointDetermination.
Alright, using the above information and what you already know about making Unreal Tournament packages, you should be able to successfully spawn with 140 Starting and Maximum Health.
Comments
Kohan: This was created by me, not the original author. If he or she wishes to change it, be my guest; I'm just trying to expand the tutorial.
lizardman6: Isn't this code part of the UT2004RPG?