• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Help : Vamprisim Mutator

kf2cool

Active member
Oct 22, 2011
29
1
Hi all expert coders,

Please guide a noob to complete this mission. I had face problems in compiling the mutator at first. But i had rectify it. However, when i run the mutator ingame. Its not working. Please see the three uc scripts below.

Main one.

Code:
class MutVamprisim extends Mutator;
var array<VamprisimMarker> VamprisimMarkers;
static final function MutVamprisim GetVamprisimMutator(GameInfo G)
{
 local Mutator M;
 local MutVamprisim VamprisimMut;
 for (M = G.BaseMutator; M != None && VamprisimMut == None; M = M.NextMutator)
 {
  VamprisimMut = MutVamprisim(M);
 }
 return VamprisimMut;
}
simulated function PostBeginPlay()
{
 Log("PostBeginPlay() was called");
}
defaultproperties
{
     bAddToServerPackages=True
     GroupName="KFVamprisimV1"
     FriendlyName="Vamprisim Mutator for Killing Floor"
     Description="This should enable Vamprisim Effect for Killing Floor."
     bAlwaysRelevant=True
     RemoteRole=ROLE_SimulatedProxy
}

The function

Code:
class Vamprisim extends VamprisimMarker
 abstract;
static function VamprisimMarker GetMarkerFor(Controller Player, MutVamprisim VamprisimMut)
{
 local int i;
 for (i = 0; i < VamprisimMut.VamprisimMarkers.length; i++)
 {
  if (VamprisimMut.VamprisimMarkers[i] == None)
  {
   VamprisimMut.VamprisimMarkers.Remove(i, 1);
   i--;
  }
  else if (VamprisimMut.VamprisimMarkers[i].PC == Player)
  {
   return VamprisimMut.VamprisimMarkers[i];
  }
 }
 return None;
}
static function HandleDamage(int Damage, Pawn Injured, Pawn Instigator, out vector Momentum, class<DamageType> DamageType, bool bOwnedByInstigator)
{
 local int Health;
 local VamprisimMarker Marker;
 local KFHumanPawn Player;
 if (!bOwnedByInstigator || DamageType == class'KFWeaponDamageType' || Injured == Instigator || Instigator == None)
  return;
 Player.Health = int(float(Damage) * 0.05);
 if (Player.Health == 0 && Damage > 0)
 {
  Player.Health = 1;
 }
 if (KFPlayerController(Instigator.Controller) != None)
 {
  Marker = GetMarkerFor(KFPlayerController(Instigator.Controller), class'MutVamprisim'.static.GetVamprisimMutator(Instigator.Level.Game));
  if (Marker == None)
  {
   Warn("Failed to find VamprisimMarker for" @ Instigator.Controller.GetHumanReadableName());
  }
 }
 if (Marker != None)
 {
  // give the pawn the health outright and let the marker cap it in its Tick()
  Instigator.Health += Health;
  Marker.HealthRestored += Health;
 }
 else
 {
  // fall back to old way
  Player.GiveHealth(Health, Player.HealthMax + 50);
 }
}
defaultproperties
{
}

And the Marker

Code:
/* this actor item is associated with players that use the Vamprisim effect.
*/
class VamprisimMarker extends Actor;
var KFPlayerController PC;
var int HealthRestored;
function Tick(float DeltaTime)
{
 if (PC == None)
 {
  Destroy();
 }
 else if (HealthRestored > 0)
 {
  if (PC.Pawn != None && PC.Pawn.Health > PC.Pawn.HealthMax + 50)
  {
   PC.Pawn.Health -= Min(PC.Pawn.Health - PC.Pawn.HealthMax - 50, HealthRestored);
  }
  HealthRestored = 0;
 }
}
defaultproperties
{
     bHidden=True
     RemoteRole=ROLE_None
}

I am trying to call for an actor to let KFWeaponDamage give Player health based on the WeaponDamage.

:(

Thanks.