Tripwire Interactive Forums

Go Back   Tripwire Interactive Forums > Killing Floor Forums > Killing Floor Modifications > Coding

Reply
 
Thread Tools Display Modes
  #41  
Old 05-14-2011, 03:00 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Right now i've probably tested this, it's not going how I wanted it to go...For some reason it still will give players health even when the level is above 4 (5 and above).

Code:
class RegenMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(1, true);
}
function Timer()
{
  local KFHumanPawn Player;
      local KFPlayerReplicationInfo KFPRI;
  
 if (KFPRI.ClientVeteranSkillLevel <=4)
   foreach DynamicActors(class 'KFHumanPawn', Player)
   {
    if (Player.Health + 2 <= Player.HealthMax)
    
    (Player).Health += 2;
    
    else 
    
     Player.Health = Player.HealthMax;
     }
 else return;
}
defaultproperties
{
    GroupName="KFRegenMutator"
    FriendlyName="KF Health Regeneration"
    Description="Mutator that regenerates health depending on perk level."
}
How can I make it so it only regenerates the health of players under level 5?
Reply With Quote
  #42  
Old 05-14-2011, 03:25 PM
Benjamin Benjamin is offline
Senior Member
 
Join Date: May 2009
Location: France
Posts: 3,419
Default

Quote:
Originally Posted by FluX View Post
Right now i've probably tested this, it's not going how I wanted it to go...For some reason it still will give players health even when the level is above 4 (5 and above).

Code:
class RegenMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(1, true);
}
function Timer()
{
  local KFHumanPawn Player;
      local KFPlayerReplicationInfo KFPRI;
  
 if (KFPRI.ClientVeteranSkillLevel <=4)
   foreach DynamicActors(class 'KFHumanPawn', Player)
   {
    if (Player.Health + 2 <= Player.HealthMax)
    
    (Player).Health += 2;
    
    else 
    
     Player.Health = Player.HealthMax;
     }
 else return;
}
defaultproperties
{
    GroupName="KFRegenMutator"
    FriendlyName="KF Health Regeneration"
    Description="Mutator that regenerates health depending on perk level."
}
How can I make it so it only regenerates the health of players under level 5?
It doesn't work because you're not pointing KFPRI to anything, it's just an empty reference. You need to set it something like this:

Code:
KFPRI = KFPlayerReplicationInfo(Player.PlayerReplicationInfo);
And of course put the IF condition inside the loop.
Reply With Quote
  #43  
Old 05-14-2011, 04:23 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Sorry as you can tell im rather new to this all.

Code:
class RegenMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(1, true);
}
function Timer()
{
  local KFHumanPawn Player;
      local KFPlayerReplicationInfo KFPRI;
  
  foreach DynamicActors(class 'KFHumanPawn', Player)
  {
    KFPRI = KFPlayerReplicationInfo(Player.PlayerReplicationInfo);
   if (Player.Health + 2 <= Player.HealthMax && KFPRI.ClientVeteranSkillLevel <=4)
    
   Player.Health += 2;
    
   else 
    
    Player.Health = Player.HealthMax;
   }
}
defaultproperties
{
    GroupName="KFRegenMutator"
    FriendlyName="KF Health Regeneration"
    Description="Mutator that regenerates health depending on perk level."
}
Not sure if I did what you said to do correctly but this seems to give me max health when I get damaged.
Reply With Quote
  #44  
Old 05-14-2011, 05:07 PM
Benjamin Benjamin is offline
Senior Member
 
Join Date: May 2009
Location: France
Posts: 3,419
Default

You need a seperate IF statement which first determines the level of the player, like this:

Code:
class RegenMut extends Mutator;

function PostBeginPlay()
{
	SetTimer(1, true);
}

function Timer()
{
	local KFHumanPawn Player;
	local KFPlayerReplicationInfo KFPRI;

	foreach DynamicActors(class 'KFHumanPawn', Player)
	{
		KFPRI = KFPlayerReplicationInfo(Player.PlayerReplicationInfo);
		if (KFPRI.ClientVeteranSkillLevel <= 4)
		{
			if (Player.Health + 2 <= Player.HealthMax)
				Player.Health += 2;
			else
				Player.Health = Player.HealthMax;
		}
	}
}

defaultproperties
{
	GroupName="KFRegenMutator"
	FriendlyName="KF Health Regeneration"
	Description="Mutator that regenerates health depending on perk level."
}
Reply With Quote
  #45  
Old 05-14-2011, 05:37 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Thanks a lot, works perfectly. Would be better if I spaced my code out more.
Reply With Quote
  #46  
Old 05-14-2011, 05:41 PM
Benjamin Benjamin is offline
Senior Member
 
Join Date: May 2009
Location: France
Posts: 3,419
Default

Quote:
Originally Posted by FluX View Post
Thanks a lot, works perfectly. Would be better if I spaced my code out more.
It does help readability if you space out sections properly and add good indentation and comments where necessary. Not just for you but others that read it.
Reply With Quote
  #47  
Old 05-24-2011, 12:51 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Right im trying to make a ammo mutator that gives you an ammo box every 5 minutes BUT i've come to a halt due to an error.

Code:
class AmmoMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(300, true);
}
function Timer()
{
    local Pawn P;
 
 {
  P.GiveWeapon("KFMod.KFAmmoPickup");
  Pawn.ClientMessage ("You have been given an ammo box!");
  Log("Ammo Given!");
  return;
 }
}
defaultproperties
{
 GroupName="KFAmmoMutator"
 FriendlyName="KF Timed Ammo Giver Mutator"
 Description="Mutator after every 5 minutes, gives you an ammo box."
}
It wont compile with the error:
Code:
{13} : Error, '{': Bad command or expression
I've tried to use my last mutator (health regeneration) to help figure out what is the problem but I can't see it. Also how would I check to see what wave the current wave is on to make it activate as I can not find a mutator or anything that checks the current wave number.
Reply With Quote
  #48  
Old 05-24-2011, 02:05 PM
Trololololololololololo Trololololololololololo is offline
Senior Member
 
Join Date: May 2010
Posts: 110
Default

Quote:
Originally Posted by FluX View Post
Right im trying to make a ammo mutator that gives you an ammo box every 5 minutes BUT i've come to a halt due to an error.

Code:
class AmmoMut extends Mutator;
function PostBeginPlay()
(and maybe there should a empty line here spacing)
{
 SetTimer(300, true);
}
function Timer()
{
    local Pawn P;
 
 { (mayb it should be } or shouldnt be here either one)
  P.GiveWeapon("KFMod.KFAmmoPickup");
  Pawn.ClientMessage ("You have been given an ammo box!");
  Log("Ammo Given!");
  return;
 }
}
defaultproperties
{
 GroupName="KFAmmoMutator"
 FriendlyName="KF Timed Ammo Giver Mutator"
 Description="Mutator after every 5 minutes, gives you an ammo box."
}
It wont compile with the error:
Code:
{13} : Error, '{': Bad command or expression
I've tried to use my last mutator (health regeneration) to help figure out what is the problem but I can't see it. Also how would I check to see what wave the current wave is on to make it activate as I can not find a mutator or anything that checks the current wave number.
I dont know anything yet due to retardation but that two would be my two guess.

Last edited by Trololololololololololo; 05-24-2011 at 02:09 PM.
Reply With Quote
  #49  
Old 05-24-2011, 03:03 PM
Excalibolg's Avatar
Excalibolg Excalibolg is offline
Senior Member
 
Join Date: May 2009
Location: KF-BioticsLab
Posts: 142
Default

What are you doing in that timer?

PHP Code:
function Timer()
{
    
local Pawn P;
 
  !!!!!!!!!{!!!!!!!!
  
P.GiveWeapon("KFMod.KFAmmoPickup");
  
Pawn.ClientMessage ("You have been given an ammo box!");
  
Log("Ammo Given!");
  return;
  !!!!!!!!!!}!!!!!!

Remove the brackets.

Also giving ammo boxes is kind of band.
Rather get a weapons MagCapacity and increase its ammo by that.


Edit: And I just now actually read the code and noticed that this will not work at all. I hope you know what's missing though :>
__________________
Quote:
Originally Posted by KFWeaponPickup.uc
Description="I AM A DEFAULT DESCRIPTION! KILL ME NOW!"
ItemName="DULL ITEMNAME!!!! KILL KILL KILL!!!!"
AmmoItemName="SHOOT THE DEVS! LAZY SODS DESERVE TO DIE!!!!!"

Last edited by Excalibolg; 05-24-2011 at 03:10 PM.
Reply With Quote
  #50  
Old 05-24-2011, 03:23 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Change it to:
Code:
class AmmoMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(300, true);
}
function Timer()
{
    local Pawn P;
 
  P.GiveWeapon("KFMod.KFAmmoPickup");
  P.ClientMessage ("You have been given an ammo box!");
  Log("Ammo Given!");
  return;
}
defaultproperties
{
 GroupName="KFAmmoMutator"
 FriendlyName="KF Timed Ammo Giver Mutator"
 Description="Mutator after every 5 minutes, gives you an ammo box."
}
But it wont work. It's because i've used "GiveItem". Can't figure it out but doesn't help i've used the AdminPlus mutator to try get this to work.

Last edited by FluX; 05-25-2011 at 05:01 AM.
Reply With Quote
  #51  
Old 06-13-2011, 12:06 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default How to call function in a function?

He,y right im trying to get this working again but im looking at some of the weapon mutators as a base.

Here's my code:
Code:
class AmmoMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(300, true);
}
function Timer()
{ 
 Want to call my ModifyPlayer function here
 Player.ClientMessage ("You have been given an ammo box!");
 Log("Ammo Given!");
}
function ModifyPlayer(Pawn Player)
{
     Super.ModifyPlayer(Player);
     Player.GiveWeapon("KFMod.KFAmmoPickup");
}
defaultproperties
{
 GroupName="KFAmmoMutator"
 FriendlyName="KF Timed Ammo Giver Mutator"
 Description="Mutator after every 5 minutes, gives you an ammo box."
}
How could I add my function inside the timer? Also at the moment im getting the error:
Error, 'Player': Bad command or expression
Why is this?

Probably a newb question but to learn I rather do then read etc. It actually makes me remember better.
Reply With Quote
  #52  
Old 06-13-2011, 09:50 PM
Excalibolg's Avatar
Excalibolg Excalibolg is offline
Senior Member
 
Join Date: May 2009
Location: KF-BioticsLab
Posts: 142
Default

Player isn't some magic variable that references each player on the map. You actually need to loop through all player actors and call ModifyPlayer on them. Refer to the code examples above in this thread, where this is done. Somehow this was lost in the progress :S
__________________
Quote:
Originally Posted by KFWeaponPickup.uc
Description="I AM A DEFAULT DESCRIPTION! KILL ME NOW!"
ItemName="DULL ITEMNAME!!!! KILL KILL KILL!!!!"
AmmoItemName="SHOOT THE DEVS! LAZY SODS DESERVE TO DIE!!!!!"
Reply With Quote
  #53  
Old 06-14-2011, 02:06 AM
TroyIrving TroyIrving is offline
Junior Member
 
Join Date: Dec 2010
Posts: 23
Default

EDIT(Again):

Just disregard anything I said here. lol.

Last edited by TroyIrving; 06-14-2011 at 08:02 AM.
Reply With Quote
  #54  
Old 06-14-2011, 03:16 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Quote:
Originally Posted by Excalibolg View Post
Player isn't some magic variable that references each player on the map. You actually need to loop through all player actors and call ModifyPlayer on them. Refer to the code examples above in this thread, where this is done. Somehow this was lost in the progress :S
you mean by adding this section:
Code:
	local KFHumanPawn Player;
	local KFPlayerReplicationInfo KFPRI;

	foreach DynamicActors(class 'KFHumanPawn', Player)
	{
		KFPRI = KFPlayerReplicationInfo(Player.PlayerReplicationInfo);
Would I have to keep the ModifyPlayer as a seperate function, if so how I make it do the function?
Reply With Quote
  #55  
Old 06-16-2011, 04:08 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Right I have now got it to be able to compile by having this:
Code:
class AmmoMut extends Mutator;
function PostBeginPlay()
{
 SetTimer(300, true);
}
function Timer()
{
 local KFHumanPawn Player;
 foreach DynamicActors(class 'KFHumanPawn', Player)
 {
  Player.GiveWeapon("KFMod.KFAmmoPickup");
  Player.ClientMessage ("You have been given an ammo box!");
  Log("Ammo Given!");
 }
}
defaultproperties
{
 GroupName="KFAmmoMutator"
 FriendlyName="KF Timed Ammo Giver Mutator"
 Description="Mutator after every 5 minutes, gives you an ammo box."
}
The only problem I have now is that it wont actually give the players the ammo box. I know this is atleast working through the rest of the code cause the player gets the client message.

I have noticed I get this message spamming my log:
Code:
Warning: KFGameType KF-FluXiDefence.KFGameType (Function KFmod.KFGameType.MatchInProgress.SetupPickups:023F) Accessed None 'AmmoPickups'
Error: KFGameType KF-FluXiDefence.KFGameType (Function KFmod.KFGameType.MatchInProgress.SetupPickups:023F) Accessed array 'AmmoPickups' out of bounds (0/0)
and after that I get the
Code:
ScriptLog: Ammo Given!
ScriptLog: Ammo Given!
ScriptLog: Ammo Given!
ScriptLog: Ammo Given!
Can someone help me please?
Reply With Quote
  #56  
Old 06-18-2011, 03:08 PM
Excalibolg's Avatar
Excalibolg Excalibolg is offline
Senior Member
 
Join Date: May 2009
Location: KF-BioticsLab
Posts: 142
Default

Does that message only appear with your mut on? Try disabling it and then check your log. Some maps get that if they don't have ammo spawns I think. Then we can safely say if it's an error with your mut or the map

also I'd suggest not giving the players the ammo boxes and instead just running the KFAmmoPickup.uc code in your mut
__________________
Quote:
Originally Posted by KFWeaponPickup.uc
Description="I AM A DEFAULT DESCRIPTION! KILL ME NOW!"
ItemName="DULL ITEMNAME!!!! KILL KILL KILL!!!!"
AmmoItemName="SHOOT THE DEVS! LAZY SODS DESERVE TO DIE!!!!!"

Last edited by Excalibolg; 06-18-2011 at 04:10 PM.
Reply With Quote
  #57  
Old 06-18-2011, 06:54 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Quote:
Originally Posted by Excalibolg View Post
Does that message only appear with your mut on? Try disabling it and then check your log. Some maps get that if they don't have ammo spawns I think. Then we can safely say if it's an error with your mut or the map

also I'd suggest not giving the players the ammo boxes and instead just running the KFAmmoPickup.uc code in your mut
For some reason im getting an error:
AmmoMut.uc(50) : Error, Bad or missing expression in 'If'

Code:
function Timer()
{
 local KFHumanPawn Player;
 
 foreach DynamicActors(class 'KFHumanPawn', Player)
 {
  if (WaveNum >= 6) && (NumPlayers >= 8)
  {
   GiveAmmo(Player);
   Player.ClientMessage ("You have been given an ammo box!");
   Player.PlaySound( Sound'KF_InventorySnd.Ammo_GenericPickup',,1.0,,600.f);
  }
  else return;
 }
}
Tried many things but all saying same error.
Reply With Quote
  #58  
Old 06-27-2011, 06:56 AM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

*Bump*

Can someone help me with this please? This isn't my full code but this is the section that is playing up.
Reply With Quote
  #59  
Old 06-27-2011, 07:59 AM
braindead's Avatar
braindead braindead is offline
Senior Member
 
Join Date: Aug 2009
Location: Merry Ol' England
Posts: 911
Default

Code:
class AmmoMut extends Mutator;

var  KFGameReplicationInfo   KFGRI;

function PostBeginPlay() 
{  
SetTimer(300, true); 
} 

function Timer()
{
 local KFHumanPawn Player;
 
 foreach DynamicActors(class 'KFHumanPawn', Player)
 {
  if (KFGRI.WaveNum >= 6) && (Level.game.NumPlayers >= 8)
  {
   GiveAmmo(Player);
   Player.ClientMessage ("You have been given an ammo box!");
   Player.PlaySound( Sound'KF_InventorySnd.Ammo_GenericPickup',,1.0,,600.f);
  }
  else return;
 }
}

however without testing I am not sure whether the KFGRI should be local or var? try both


hope it helps
__________________

Last edited by braindead; 06-27-2011 at 08:03 AM.
Reply With Quote
  #60  
Old 06-27-2011, 12:00 PM
FluX FluX is offline
Senior Member
 
Join Date: Oct 2010
Posts: 3,729
Default

Quote:
Originally Posted by braindead View Post
Code:
class AmmoMut extends Mutator;
 
var  KFGameReplicationInfo   KFGRI;
 
function PostBeginPlay() 
{  
SetTimer(300, true); 
} 
 
function Timer()
{
 local KFHumanPawn Player;
 
 foreach DynamicActors(class 'KFHumanPawn', Player)
 {
  if (KFGRI.WaveNum >= 6) && (Level.game.NumPlayers >= 8)
  {
   GiveAmmo(Player);
   Player.ClientMessage ("You have been given an ammo box!");
   Player.PlaySound( Sound'KF_InventorySnd.Ammo_GenericPickup',,1.0,,600.f);
  }
  else return;
 }
}

however without testing I am not sure whether the KFGRI should be local or var? try both


hope it helps
Both version show an error of:
Code:
Unrecognized member 'WaveNum' in class 'KFGameReplicationInfo'
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2005 - 2013, Tripwire Interactive, LLC