MH2 :Prevent player who don't play to get bonus

Discussions about Coding and Scripting
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

MH2 :Prevent player who don't play to get bonus

Post by Letylove49 »

I would like to ensure that players who are inactive no longer get bonuses at the expense of players who play.

Here the function for Bonus
PRand = GetRandomPlayer();
if (PRand != None)
if(score<=5000) return None; // if player have less than 5000 point = no bonus

{
if (kakuCount < DeemerSpawnTime) kakuCount++;
if (HealthCount < HealthAwardTime) HealthCount++;
if (DeemerSpawnTime - kakuCount < 5 && DeemerSpawnTime - kakuCount > 0)
{
BroadcastLocalizedMessage(class 'MH2RandomDeemerMsg', DeemerSpawnTime - kakuCount, PRand.PlayerReplicationInfo);
}
if (HealthAwardTime - HealthCount < 5 && HealthAwardTime - HealthCount > 0)
{
BroadcastLocalizedMessage(class 'MH2RandomHealthMsg', HealthAwardTime - HealthCount, PRand.PlayerReplicationInfo);
}
if (kakuCount >= DeemerSpawnTime)
{
kakuCount = 0;
PRand = GetRandomPlayer();
if (PRand != None && PRand.bIsPlayer)
{
BroadcastLocalizedMessage(class 'MH2RandomDeemerMsg', kakuCount, PRand.PlayerReplicationInfo);
if (Use2k4Deemer)
GiveRedeemer(PRand);
else
GiveOldRedeemer(PRand);
}
}
if (HealthCount >= HealthAwardTime)
{
HealthCount = 0;
PRand = GetRandomPlayer();
if (PRand != None && PRand.bIsPlayer)
{
BroadcastLocalizedMessage(class 'MH2RandomHealthMsg', HealthCount, PRand.PlayerReplicationInfo);
GiveHealth(PRand);
}
}
}
}
}
}
i have try use a function if like : if(score<=5000) return None;

but i got this Log: Compiling MH2Base
Error: D:\UT coding\UnrealTournament\MonsterHunt2GoldUKv5\Classes\MH2Base.uc(1054) : Error, Bad or missing expression in 'If'
Image



Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 2808
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: MH2 :Prevent player who don't play to get bonus

Post by Barbie »

Letylove49 wrote: Sat Jan 27, 2024 3:17 pmi have try use a function if like : if(score<=5000) return None;

but i got this Log: Compiling MH2Base
Error: D:\UT coding\UnrealTournament\MonsterHunt2GoldUKv5\Classes\MH2Base.uc(1054) : Error, Bad or missing expression in 'If'
Try if(PRand.score<=5000) return None;
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: MH2 :Prevent player who don't play to get bonus

Post by Letylove49 »

Barbie wrote: Sat Jan 27, 2024 5:58 pm
Letylove49 wrote: Sat Jan 27, 2024 3:17 pmi have try use a function if like : if(score<=5000) return None;

but i got this Log: Compiling MH2Base
Error: D:\UT coding\UnrealTournament\MonsterHunt2GoldUKv5\Classes\MH2Base.uc(1054) : Error, Bad or missing expression in 'If'
Try if(PRand.score<=5000) return None;
thanks
i got this now : Error in MH2Base.uc (1054): Unrecognized member 'score' in class 'Pawn'
Must i creat a new class MH2Pawn to solve that ? or remplace score by Frags ?   
Auto merged new post submitted 21 minutes later
if(PRand.KillCount<=5000) return None;

get this : Missing ; before None.

i have try to add i but i got the same error.
Image



Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 2808
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: MH2 :Prevent player who don't play to get bonus

Post by Barbie »

Take a deep look into the Actor tree:

Code: Select all

class Pawn extends Actor
[...]
// Player game statistics.
var int			DieCount, ItemCount, KillCount, SecretCount, Spree;
Letylove49 wrote: Sat Jan 27, 2024 7:20 pm if(PRand.KillCount<=5000) return None;

get this : Missing ; before None.
THAT indeed should have worked.

Code: Select all

class PlayerReplicationInfo expands ReplicationInfo
[...]
var float				Score;			// Player's current score.
So try if(PRand.PlayerReplicationInfo != None && PRand.PlayerReplicationInfo.score <= 5000) return None;
(BTW: why float for score?)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH2 :Prevent player who don't play to get bonus

Post by sektor2111 »

It is... whatever. Player can play 3 minutes earning something... Then, he only camps...
And that "score" check should include actor that has variable "score" not just vars thrown for compiling... The rest is to check how goes that "KillCount". If works based on number of kills... then wait player to kill 5000 creatures until will be able to gain some bonus (which honestly I did not use last time...).
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: MH2 :Prevent player who don't play to get bonus

Post by Letylove49 »

sektor2111 wrote: Sun Jan 28, 2024 12:54 pm It is... whatever. Player can play 3 minutes earning something... Then, he only camps...
And that "score" check should include actor that has variable "score" not just vars thrown for compiling... The rest is to check how goes that "KillCount". If works based on number of kills... then wait player to kill 5000 creatures until will be able to gain some bonus (which honestly I did not use last time...).
i want for score not the number of kill.   
Auto merged new post submitted 11 minutes later
Barbie wrote: Sat Jan 27, 2024 11:51 pm Take a deep look into the Actor tree:

Code: Select all

class Pawn extends Actor
[...]
// Player game statistics.
var int			DieCount, ItemCount, KillCount, SecretCount, Spree;
Letylove49 wrote: Sat Jan 27, 2024 7:20 pm if(PRand.KillCount<=5000) return None;

get this : Missing ; before None.
THAT indeed should have worked.

Code: Select all

class PlayerReplicationInfo expands ReplicationInfo
[...]
var float				Score;			// Player's current score.
So try if(PRand.PlayerReplicationInfo != None && PRand.PlayerReplicationInfo.score <= 5000) return None;
(BTW: why float for score?)

Error in MH2Base.uc (1054): Missing ';' before 'None'

PRand = GetRandomPlayer();
if (PRand != None)
if(PRand.PlayerReplicationInfo != None && PRand.PlayerReplicationInfo.score <= 5000) return None;

i don't know if that can help but in class MH2ScoreBoard i have this :
// Draw Score
Canvas.SetPos(Canvas.ClipX * 0.5, YOffset );
Canvas.DrawText("Frags:"@int(PRI.Score), false );






i have finaly fund a solution : insteat to get none if player have less than 5000 point i have set this :
if(PRand.PlayerReplicationInfo != None && PRand.PlayerReplicationInfo.score >= 5000)
and i 'm able to compile but finaly after some test that donn't worlk like expected.

Thanks for your help Barbie and sektor2111
Image



Image
Letylove49 aka Alicia
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: MH2 :Prevent player who don't play to get bonus

Post by Letylove49 »

pehaps i should use a fucntion who dectect inattive player :

var float AFKTime; // Number of seconds the player has been AFK.
var int AFKTimeRemaining; // Time remaining before the player will be ignored for the bonus.

Code: Select all

  // AFK Function
   	if (gInf.gameState == gInf.GS_Playing) {
			if (vSize((oldLocation - player.location) * vect(1, 1, 0)) > maxAFKRadius) {
				oldLocation = player.location;
				AFKTime = -AFKCountDelay;
                                AFKTimeRemaining = -1;
                                lastAFKTimeRemaining = AFKTimeRemaining;
 }
 }
Image



Image
Letylove49 aka Alicia
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH2 :Prevent player who don't play to get bonus

Post by sektor2111 »

Score should be "<=" 5000 for exception, not ">=" as I see above, unless the check must work in reverse.

Solution number two. Look at certain Anti-Camper mod. Go figure a camp time on normal ground. If camp time is excessive it will be needed an exception method by checking whatever campers list and excepting them from being candidates at any bonus.

Solution number three. Damaging things... Player not doing damage for certain time but others hunting hard way, can be excepted from receiving bonuses. Here there are sub-options for chasing damage.

Solution number four. Monster Proximity... Player that is not really facing monsters and is also very far from monsters perhaps is sitting in a safe spot and... resting there - he doesn't need any bonus.
User avatar
Barbie
Godlike
Posts: 2808
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: MH2 :Prevent player who don't play to get bonus

Post by Barbie »

Letylove49 wrote: Sat Feb 03, 2024 3:05 pm pehaps i should use a fucntion who dectect inattive player :
Your function only takes movement into account - what about players standing still but shooting continuously? (Needed for some health oversized monsters.)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: MH2 :Prevent player who don't play to get bonus

Post by Letylove49 »

ok i have test to put >5000 but that don't work like expeted.
The funtion ged rabdin player

Code: Select all

 
         PRand = GetRandomPlayer();
         if (PRand != None)
        [b]  if(PRand.PlayerReplicationInfo != None && PRand.PlayerReplicationInfo.score <= 5000)[/b]

         {
            if (kakuCount < DeemerSpawnTime) kakuCount++;
            if (HealthCount < HealthAwardTime) HealthCount++;
            if (DeemerSpawnTime - kakuCount < 5 && DeemerSpawnTime - kakuCount > 0)
            {  
               BroadcastLocalizedMessage(class 'MH2RandomDeemerMsg', DeemerSpawnTime - kakuCount, PRand.PlayerReplicationInfo);
            }
            if (HealthAwardTime - HealthCount < 5 && HealthAwardTime - HealthCount > 0)
            {
               BroadcastLocalizedMessage(class 'MH2RandomHealthMsg', HealthAwardTime - HealthCount, PRand.PlayerReplicationInfo);
            }
            if (kakuCount >= DeemerSpawnTime)
            {
               kakuCount = 0;
               PRand = GetRandomPlayer();
               if (PRand != None && PRand.bIsPlayer)
               {
                  BroadcastLocalizedMessage(class 'MH2RandomDeemerMsg', kakuCount, PRand.PlayerReplicationInfo);
                  if (Use2k4Deemer)
                     GiveRedeemer(PRand);
                  else
                     GiveOldRedeemer(PRand);
               }
            }
            if (HealthCount >= HealthAwardTime)
            {
               HealthCount = 0;
               PRand = GetRandomPlayer();
               if (PRand != None && PRand.bIsPlayer)
               {
                  BroadcastLocalizedMessage(class 'MH2RandomHealthMsg', HealthCount, PRand.PlayerReplicationInfo);
                  GiveHealth(PRand);
               }
            }
         }
      }
   }
}





For reedemer :

Code: Select all

 
function GiveRedeemer(Pawn PlayerPawn)
{
   local MH2WarheadLauncher  rede;
   local bool NoNeed;





   rede= spawn(class'MH2WarheadLauncher');
   if( rede!= None )
   {  
      if (PlayerPawn.FindInventoryType(class'MH2WarheadLauncher') != None)
         NoNeed = true;

      rede.RespawnTime = 0.0;
      rede.GiveTo(PlayerPawn);
      rede.SetSwitchPriority(PlayerPawn);
      PlayerPawn.AddInventory(rede);
      rede.PickupAmmoCount = 1;
      rede.GiveAmmo(PlayerPawn);
      if (NoNeed)
         rede.Destroy();
   }
}

function GiveOldRedeemer(Pawn PlayerPawn)
{
   local Warheadlauncher  redeA;
   local bool NoNeed;

   redeA= spawn(class'Warheadlauncher');
   if( redeA!= None )
   {  
      if (PlayerPawn.FindInventoryType(class'Warheadlauncher') != None)
         NoNeed = true;

      redeA.RespawnTime = 0.0;
      redeA.GiveTo(PlayerPawn);
      redeA.SetSwitchPriority(PlayerPawn);
      PlayerPawn.AddInventory(redeA);
      redeA.PickupAmmoCount = 1;
      redeA.GiveAmmo(PlayerPawn);
      if (NoNeed)
         redeA.Destroy();
   }
}
For Health

Code: Select all

function GiveHealth(Pawn PlayerPawn)
{

   PlayerPawn.Health+=500;
}

function Pawn GetRandomPlayer()

{
   local Pawn N;
   local PlayerPawn Dest;
   local Pawn Candidate[32];
   local int num;
   


   for (N=Level.PawnList; N!=None; N=N.NextPawn)
   {
      Dest=PlayerPawn(N);
      if (Dest!=None && Dest.bIsPlayer && !Dest.PlayerReplicationInfo.bIsSpectator)
      {
         if (num<32) Candidate[num] = Dest;
         else if (Rand(num) < 32) Candidate[Rand(32)] = Dest;
         num++;
      }
   }
   if(num==0) return None;
   return Candidate[Rand(Min(32,num))];
}
 
i will look on anti-camp mode
Image



Image
Letylove49 aka Alicia
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH2 :Prevent player who don't play to get bonus

Post by sektor2111 »

You forgot the root of sorting not the "timer".

Code: Select all

PRand = GetRandomPlayer();
HERE is your condition not elsewhere.
Actually "GetRandomPlayer()" it's just sorting a random player - excepting only spectators.
function Pawn GetRandomPlayer()

{
local Pawn N;
local PlayerPawn Dest;
local Pawn Candidate[32];
local int num;



for (N=Level.PawnList; N!=None; N=N.NextPawn)
{
Dest=PlayerPawn(N);
if (Dest!=None && Dest.bIsPlayer && !Dest.PlayerReplicationInfo.bIsSpectator)
{
if (num<32) Candidate[num] = Dest;
else if (Rand(num) < 32) Candidate[Rand(32)] = Dest;
num++;
}
}
if(num==0) return None;
return Candidate[Rand(Min(32,num))];
}
To mention that I rewrote this one...
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: MH2 :Prevent player who don't play to get bonus

Post by Letylove49 »

Code: Select all


function Pawn GetRandomPlayer()

{
   local Pawn N;
   local PlayerPawn Dest;
   local Pawn Candidate[32];
   local int num;
   


   for (N=Level.PawnList; N!=None; N=N.NextPawn)
   {
      Dest=PlayerPawn(N);
      if (Dest!=None && Dest.bIsPlayer && !Dest.PlayerReplicationInfo.bIsSpectator[b][color=#FF0000] && Dest.PlayerReplicationInfo.score >= 5000)[/color][/b]
      {
         if (num<32) Candidate[num] = Dest;
         else if (Rand(num) < 32) Candidate[Rand(32)] = Dest;
         num++;
      }
   }
   if(num==0) return None;
   return Candidate[Rand(Min(32,num))];
}

i have added this && Dest.PlayerReplicationInfo.score >= 5000)a nd that work only player who have 5000 point or more get the bonus

and i have removed this who is usless : if(PRand.PlayerReplicationInfo != None && PRand.PlayerReplicationInfo.score <= 5000)
Image



Image
Letylove49 aka Alicia
User avatar
sektor2111
Godlike
Posts: 6413
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: MH2 :Prevent player who don't play to get bonus

Post by sektor2111 »

Letylove49 wrote: Tue Feb 06, 2024 12:14 am only player who have 5000 point or more get the bonus
Exactly... Sorting only players with some score not all players.

For Amplifier by example you can walk through Players and except those with low score - checking reversal method... or simply giving amplifier at those with high score using the same score check.
Letylove49
Adept
Posts: 277
Joined: Tue Feb 28, 2012 7:47 pm
Location: suisse
Contact:

Re: MH2 :Prevent player who don't play to get bonus

Post by Letylove49 »

My goal was really to prevent players who connect but who do not play to get redeemers instead of players who play with what I did I also get that with health. if one day I want to do the same with the amplifier I will look at it but it is not my intention for the moment
Image



Image
Letylove49 aka Alicia
User avatar
Barbie
Godlike
Posts: 2808
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: MH2 :Prevent player who don't play to get bonus

Post by Barbie »

Letylove49 wrote: Tue Feb 06, 2024 12:14 am and i have removed this who is usless : if(PRand.PlayerReplicationInfo != None && PRand.PlayerReplicationInfo.score <= 5000)
Not really useless: PRand (or Dest in your alternative code) don't have a PlayerReplicationInfo in seldom cases¹ and so your new code accesses NONE if you don't check it.

(1) E.g. when SkaarjTrooper pick a weapon.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Post Reply