Skip to content

Commit

Permalink
Merge branch 'feature/scoring'
Browse files Browse the repository at this point in the history
  • Loading branch information
wallabra committed Nov 30, 2023
2 parents 7ca11b3 + 53a910a commit 2fbc3a0
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 24 deletions.
85 changes: 71 additions & 14 deletions Classes/MushMatch.uc
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ var(MushMatch_Custom) config bool bOffsetScoreMinusOne; // may fix weird scori
var(MushMatch_Game) config float MushScarceRatio;
var(MushMatch_Game) config float InfectionScoreMultiplier;
var(MushMatch_Game) config bool bPenalizeSameTeamKill, bPenalizeSuicide;
var(MushMatch_Game) config int ScoreReward_Infect, ScoreReward_Kill, ScorePenalty_TeamKill, ScorePenalty_Suicide;
var(MushMatch_Game) config int ScoreReward_Infect, ScoreReward_Kill, ScorePenalty_TeamKill, ScorePenalty_Suicide, ScoreReward_SpottedMush;
var(MushMatch_Game) config float ScoreSuspectorPropag, ScorePenalty_SuspectedFactor;
var(MushMatch_Game) config class<Spectator> SpectatorClass;
var(MushMatch_Game) config bool bInfectionScoreCountNegative;
var(MushMatch_Game) config bool bBeaconCanSpotMush;
var(MushMatch_Game) config bool bBeaconCanSpotMush;

var(MushMatch_Game) config float // firerates
SporifierFirerate,
Expand Down Expand Up @@ -242,9 +243,14 @@ event playerpawn Login
return NewPlayer;
}

function ScoreKill(Pawn Killer, Pawn Other)
function MushMatchScoreKill(Pawn Killer, Pawn Other, float factor)
{
local MushMatchPRL KPRL, OPRL;
local MushMatchPRL KPRL, OPRL, SPRL;
local float localFactor;

if (factor == 0.0) {
factor = 1.0;
}

KPRL = FindPawnPRL(Killer);
OPRL = FindPawnPRL(Other);
Expand All @@ -268,7 +274,7 @@ function ScoreKill(Pawn Killer, Pawn Other)

else {
if (bPenalizeSuicide) {
Killer.PlayerReplicationInfo.Score -= ScorePenalty_Suicide;
Killer.PlayerReplicationInfo.Score -= ScorePenalty_Suicide * factor;
}
}
}
Expand All @@ -277,22 +283,67 @@ function ScoreKill(Pawn Killer, Pawn Other)
Killer.KillCount++;

// Check for team kill and penalize accordingly.
if (KPRL != None && OPRL != None && KPRL.bMush == OPRL.bMush) {
if (OPRL != None && KPRL.bMush == OPRL.bMush) {
if (bPenalizeSameTeamKill) {
Killer.PlayerReplicationInfo.Score -= ScorePenalty_TeamKill;
localFactor = factor;

if (OPRL.bIsSuspected && OPRL.SuspectedBy != KPRL) {
//Log("Decreasing penalty on"@Killer.PlayerReplicationInfo.PlayerName@"for killing suspected person"@Other.PlayerReplicationInfo.PlayerName);
localFactor *= ScorePenalty_SuspectedFactor;
}

else if (OPRL.bIsSuspected) {
//Log("Not decreasing penalty on"@Killer.PlayerReplicationInfo.PlayerName@"for killing suspected person"@Other.PlayerReplicationInfo.PlayerName@"as they themselves are the suspector!");
}

Killer.PlayerReplicationInfo.Score -= ScorePenalty_TeamKill * localFactor;
}
}

// Reward for kill.
else if (OPRL != None) {
Killer.PlayerReplicationInfo.Score += ScoreReward_Kill;
Killer.PlayerReplicationInfo.Score += ScoreReward_Kill * factor;
}
}

// Propagate score to suspector, if applicable.
if (ScoreSuspectorPropag > 0 && OPRL.SuspectedBy != None && OPRL.SuspectedBy != None) {
SPRL = MushMatchPRL(OPRL.SuspectedBy);

if (SPRL == None) {
Warn("SuspectedBy is"@OPRL.SuspectedBy@"when it should be a MushMatchPRL!");
}

else if (SPRL.Owner == None || SPRL.Owner.Owner == None) {
if (SPRL.Owner == None)
Warn(SPRL@"has no PlayerReplicationInfo owner!");
else
Warn(SPRL$"'s owner"@SPRL.Owner@"has no Pawn owner!");
}

else if (SPRL == KPRL) {
//Log("Did not propagate kill of"@Other.PlayerReplicationInfo.Name@"by"@Killer.PlayerReplicationInfo.Name@" as [SPRL == KPRL] - suspector:"@PlayerReplicationInfo(SPRL.Owner).PlayerName);
}

else {
//Log("Propagating suspicion of kill ("$Killer.PlayerReplicationInfo.Name@"killed"@Other.PlayerReplicationInfo.Name$") to suspector ("$PlayerReplicationInfo(SPRL.Owner).Name$")");
MushMatchScoreKill(Pawn(SPRL.Owner.Owner), Other, factor * ScoreSuspectorPropag);
}
}

else {
//Log("Did not propagate kill of"@Other.PlayerReplicationInfo.PlayerName@"by"@Killer.PlayerReplicationInfo.PlayerName@" as [there is no suspector] - suspector PRL:"@OPRL.SuspectedBy);
}

// Offset score if applicable.
if (bOffsetScoreMinusOne) {
Killer.PlayerReplicationInfo.Score -= 1;
}
}

function ScoreKill(Pawn Killer, Pawn Other)
{
MushMatchScoreKill(Killer, Other, 1.0);

// Call ScoreKill on BaseMutator.
BaseMutator.ScoreKill(Killer, Other);
Expand Down Expand Up @@ -550,7 +601,7 @@ function bool StrapBeacon(Pawn Other, optional Pawn Suspector)
BroadcastSuspected(Suspector.PlayerReplicationInfo, Other.PlayerReplicationInfo);

OtherPRL.bIsSuspected = True;

OtherPRL.SuspectedBy = SuspectorPRL;

if (MushMatchMutator(BaseMutator).BasicWitnessSuspect(Other, Suspector, Other)) {
RegisterHate(Other, Suspector);
Expand Down Expand Up @@ -654,10 +705,6 @@ function MakeMush(Pawn Other, Pawn Instigator) {
Other.PlayerReplicationInfo.Score = 0;
}

if (MushMatch(Level.Game).CheckEnd()) {
return;
}

if (Instigator != None) {
Instigator.PlayerReplicationInfo.Score += ScoreReward_Infect;

Expand All @@ -670,6 +717,10 @@ function MakeMush(Pawn Other, Pawn Instigator) {
// mushmatch(Level.Game).SpotMush(Other, p);
// }
}

if (MushMatch(Level.Game).CheckEnd()) {
return;
}

if (PlayerPawn(Other) != None && !MushMatch(Level.Game).bMatchEnd) {
Other.PlayOwnedSound(sound'Infected');
Expand Down Expand Up @@ -700,7 +751,7 @@ function bool SpotMush(Pawn Other, Pawn Finder)

if (PlayerPawn(Other) != None && DiscoveredMusic != "")
{
Log("Playing discovered music"@ DiscoveredMusic @"for:"@ OtherPRI.PlayerName);
//Log("Playing discovered music"@ DiscoveredMusic @"for:"@ OtherPRI.PlayerName);
Spawn(class'MushMusic', Other);
}

Expand All @@ -713,6 +764,9 @@ function bool SpotMush(Pawn Other, Pawn Finder)
OtherPRL.bKnownHuman = False;
OtherPRL.Instigator = None; // also clear instigator field (which is used only for people with suspicion beacons)

// Reward discovering the mush
FinderPRI.Score += ScoreReward_SpottedMush;

return True;
}

Expand Down Expand Up @@ -1086,4 +1140,7 @@ defaultproperties
SuspicionBeaconFirerate=1.1
bOffsetScoreMinusOne=false
bBeaconCanSpotMush=true
ScoreSuspectorPropag=0.5
ScorePenalty_SuspectedFactor=0.25
ScoreReward_SpottedMush=6
}
1 change: 1 addition & 0 deletions Classes/MushMatchPRL.uc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class MushMatchPRL extends PlayerReplicationList config(MushMatch);

var bool bIsSuspected;
var PlayerReplicationList SuspectedBy;
var bool bMush;
var bool bKnownMush, bKnownHuman;
var bool bDead, bSpectator;
Expand Down
11 changes: 2 additions & 9 deletions Classes/PlayerReplicationList.uc
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,10 @@ simulated function PlayerReplicationList AppendPlayer(PlayerReplicationInfo othe

simulated function PlayerReplicationList FindPlayer(PlayerReplicationInfo other)
{
local PlayerReplicationList prl, prev;
local int i;
prev = None;

i = 0;
local PlayerReplicationList prl;

for ( prl = self; prl != None && prl != prev; prl = prl.Next ) {
if (!(i % 5)) Log((i + 1)@other@prl);
for ( prl = self; prl != None; prl = prl.Next ) {
if ( prl.owner == other ) return prl;
prev = prl;
i++.
}

return None;
Expand Down
2 changes: 1 addition & 1 deletion buildconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
export name="Mush Match"
export package=MushMatch
export version=1.3.3
export build=20230306
export build=20231101
export debug=1
export makeint=1
export incl_readme=1
Expand Down

0 comments on commit 2fbc3a0

Please sign in to comment.