Remption Mutator

  • 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/

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
Mutator name: Redemption
Effects: Restores your health and teleports you back to the starting position if your health drops below 10%. This will only work once during the game so use it wisely.
Download: http://www.mediafire.com/?9sd49kv9he618a6

I haven't gotten to chance to test this with other people let me know what you think of this mutator and tell me if it works online or not.

Edit: Note: You should never use this on any mission map of any kind as it will break the game.
 
Last edited:

halbridious

FNG / Fresh Meat
Jan 6, 2011
1,769
211
0
Michigan (USA)
so does this happen automatically or with a button press? I don't wanna waste my "redemption" if theres just a clot left on the level, but it'd come in handy if i was getting FP raged...
 

Phada

FNG / Fresh Meat
Aug 24, 2010
190
62
0
France
phada.2ya.com
This only work if you're under 10hp and above 0, you can still get killed in one blow (example: own grenade).

My suggestions:
1) Use PreventDeath() from a GameRules.
2) Why not make this only effective while carrying a expensive item from trader? Plus this will be easy to check in PreventDeath() without modifying the pawn class.
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
This only work if you're under 10hp and above 0, you can still get killed in one blow (example: own grenade).

My suggestions:
1) Use PreventDeath() from a GameRules.
2) Why not make this only effective while carrying a expensive item from trader? Plus this will be easy to check in PreventDeath() without modifying the pawn class.

Yes GameRules was my first method for this mutator, however I never really got it to work properly, I'll give it another shot and see how it works out.

Edit: I can't seem to get this to work at all for some reason.
 
Last edited:

halbridious

FNG / Fresh Meat
Jan 6, 2011
1,769
211
0
Michigan (USA)
Phada mentioned expensive stuff, could you include a parameter saying something along the lines of if networth < 1000 don't use redemption? That would save some greif i think.
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
I don't know what I'm doing wrong, can somebody take a look at this and help me?

Code:
class RedemptionMessage extends CriticalEventPlus;
var() localized string SwitchMessage[10];
static function string GetString (optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject)
{
 if ( (Switch >= 0) && (Switch <= 9) )
  return Default.SwitchMessage[Switch];
}
defaultproperties
{
     SwitchMessage(0)="You have been Redeemed!"
     DrawColor=(B=0,G=0,R=220)
     StackMode=SM_Down
     PosY=0.800000
}

Code:
//=============================================================================
// RedemptionMutator.
//
// If your health reaches zero or below, you will be fully healed and teleported to a random starting position.
//=============================================================================
class RedemptionMutator extends Mutator;
var KFPlayerReplicationInfo KFPRI;
function ModifyPlayer(Pawn Other)
{
    local NavigationPoint NP;
    local float AmountHealed;
    local KFHumanPawn KFP;
        KFP = KFHumanPawn(Other);
 AmountHealed = (KFP.Health * 1.5) * KFPRI.ClientVeteranSkillLevel;
 if ( KFP != None && KFP.Health <= 10 )
 {
      KFP.Health *= AmountHealed;
      PlayerController(KFP.Controller).ReceiveLocalizedMessage(class'MutRedemption.RedemptionMessage',0);
      for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
      {
       if (NP.IsA('PlayerStart'))
       {
        KFP.SetLocation(NP.Location);
       }
      }
 }
 Super.ModifyPlayer(Other);
}
defaultproperties
{
     GroupName="KF-Redemption"
     FriendlyName="Redemption"
     Description="Gives you a second chance at life."
     bAddToServerPackages=True
     bAlwaysRelevant=True
     RemoteRole=ROLE_SimulatedProxy
}
 

Phada

FNG / Fresh Meat
Aug 24, 2010
190
62
0
France
phada.2ya.com
I don't understand what you're trying to do, ModifyPlayer() is only called on spawn/respawn.
Pawn's health will be always 100 (HealthMax) here.

Also you don't need to change bAlwaysRelevant or RemoteRole for a normal mutator use.
And for the message you only use one, why you put a 10 vars string chain?

Still the same prob anyway, you can still be killed in one blow by checking health.
 
Last edited:

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
I don't understand what you're trying to do, ModifyPlayer() is only called on spawn/respawn.
Pawn's health will be always 100 (HealthMax) here.

Thanks for clearing that up, I now know how to fix this!

Also you don't need to change bAlwaysRelevant or RemoteRole for a normal mutator use.

I've always used them in mutators, I guess I don't really need it here. I shall remove them.

And for the message you only use one, why you put a 10 vars string chain?

I copied it from BullpupSwitchMessage.uc

Still the same prob anyway, you can still be killed in one blow by checking health.

I want them to be killed if there health goes from 11 or more down to 0 though.

Answers are in green and thanks.
 
Last edited:

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
New code (still doesn't work :S):

Code:
//=============================================================================
// RedemptionMutator.
//
// If your health reaches zero or below, you will be fully healed and teleported to a random starting position.
//=============================================================================
class RedemptionMutator extends Mutator;
function Tick( float DeltaTime )
{
 local Actor Other;
 local KFHumanPawn KFP;
 KFP = KFHumanPawn(Other);
 if ( KFP != None && KFP.Health <= 10 )
  RedeemPlayer();
}
function RedeemPlayer() 
{
         local NavigationPoint NP;
  local Actor Other;
  local KFHumanPawn KFP;
  KFP = KFHumanPawn(Other);
  if ( KFP != None )
  {
   KFP.Health = KFP.HealthMax;
   PlayerController(KFP.Controller).ReceiveLocalizedMessage(class'MutRedemption.RedemptionMessage',0);
   for (NP = Level.NavigationPointList; NP != None; NP = NP.NextNavigationPoint)
   {
   if (NP.IsA('PlayerStart'))
   {
    KFP.SetLocation(NP.Location);
   }
   }
  }
}
defaultproperties
{
     GroupName="KF-Redemption"
     FriendlyName="Redemption"
     Description="Gives you a second chance at life."
     bAddToServerPackages=True
}

Code:
class RedemptionMessage extends CriticalEventPlus;
var() localized string RedeemMessage;
static function string GetString (optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject)
{
 return Default.RedeemMessage;
}
defaultproperties
{
     RedeemMessage="You have been Redeemed!"
     DrawColor=(B=0,G=0,R=220)
     StackMode=SM_Down
     PosY=0.800000
}
 

Phada

FNG / Fresh Meat
Aug 24, 2010
190
62
0
France
phada.2ya.com
"Other" refer to nothing :p

If you want to check pawn health here you have to use the ControllerList:
Code:
function Tick( float DeltaTime )
{
    local Controller C;

    for (C=Level.ControllerList; C!=None; C=C.NextController)
        if (C.bIsPlayer && C.Pawn != None && C.Pawn.Health <= 10 && C.Pawn.Health > 0)
            RedeemPlayer(C.Pawn);
}

function RedeemPlayer(Pawn P) {
    P.Health = P.HealthMax;
    [...]
}
But the clean way to check health change with a mutator is with NetDamage() from a GameRules, the function is called every time that a pawn receives damage.

Also you're not relocating the pawn to a random starting point but to every PlayerStart until the last one in the list.
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
"Other" refer to nothing :p

If you want to check pawn health here you have to use the ControllerList:
Code:
function Tick( float DeltaTime )
{
    local Controller C;
 
    for (C=Level.ControllerList; C!=None; C=C.NextController)
        if (C.bIsPlayer && C.Pawn != None && C.Pawn.Health <= 10 && C.Pawn.Health > 0)
            RedeemPlayer(C.Pawn);
}
 
function RedeemPlayer(Pawn P) {
    P.Health = P.HealthMax;
    [...]
}
But the clean way to check health change with a mutator is with NetDamage() from a GameRules, the function is called every time that a pawn receives damage.

Also you're not relocating the pawn to a random starting point but to every PlayerStart until the last one in the list.

Thanks for clearing that up, I understand now. I'm usually pretty good with writing mods, I'm not sure why I had so much trouble with this one in particular.
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
New download links, this should and hopefully will work without any of the reported bug and glitches, see original post download. Thanks to Phada for his assistance! :D


EDIT: JUST NOW I UPDATED THE DOWNLOAD LINK FOR A FINAL TIME, PLEASE DOWNLOAD THE LATEST VERSION AS IT HAS AN IMPORTANT FIX IN IT! This fix will prevent a player from being redeemed more than once in the game, it should work online flawlessly.
 
Last edited:

Phada

FNG / Fresh Meat
Aug 24, 2010
190
62
0
France
phada.2ya.com
New suggestions ^^

If you run the Tick client side (need the simulated prefix, bAlwaysRelevant=True and RemoteRole=ROLE_SimulatedProxy now), maybe you don't have check all controllers in the list, try this:
Code:
local PlayerController PC;

PC = Level.GetLocalPlayerController();
if (PC != None && PC.Pawn != None && PC.Pawn.Health <= 10 && PC.Pawn.Health > 0) {
    RedeemPlayer(PC.Pawn, PC);
    Disable('Tick');
}
You can remove the bool, disable() will just stop the function to run which is enough to do it once.

In the function you forgot to set the rotation:
Code:
if (NP != None) {
    P.SetLocation(NP.Location);
    P.SetRotation(NP.Rotation);
}
 

YoYoBatty

FNG / Fresh Meat
Dec 17, 2009
3,460
2,502
0
Canada
It works with ServerPerks now. The only problem now is its hit or miss. It doesnt always respawn you. It mostly 50/50.

Was your health 10 or below before you died? If its greater than 10 and a hit kills you, you don't respawn.