ScoreSave mutator

Search, find and discuss about Mutators!

ScoreSave mutator

Postby MrLoathsome » Tue Jun 01, 2010 12:59 am

ScoreSave mutator.

RC_5 added fix to prevent score/deaths values from being lost if player respawned too quickly.
added players current health to list of variables being saved.
added the Pawn stat variables DieCount, ItemCount, KillCount, SecretCount & Spree to save list.
added config variable SSDelay. Controls rate at which the mutator saves current variable data.

RC_4 added fix for spectators. Thanks iloveut99 !
v2.3 added StartTime back to the list of saved variables.
v2.2 update rewritten to use timer.
v2.0 update has minor code change to eliminate possible accessed none warnings.

Server only mutator that will preserve players scores on disconnect.

Had a request last week from one of the regulars on my servers who connects
via dialup. He is way out in rural Northern canada, and the modem disconnects
on him quite often.... He plays extremely well, and I can only imagine how
frustrating it is when you get the score reset from 1st or 2nd place too zero
sometimes several times in a match. Probably my oldest regular player on the
MooCow servers. At least 7-8 years this has been going on.....

2 days ago he asks : "Why cant the server save my score when I get disconnected ?"

"Thats a good question." I responded....

Did a few searches, and asked somebody* who knows about even more UT mutators than
I do, but found no trace of a mutator that would accomplish this.

It rained today so I couldn't go ride my dirtbike as scheduled, so a few hours
ago I decided to see if I could fix this issue.

Not only does this solve that problem, but now I can connect to one of my other
servers to check on things, then go back to the game I was playing without
losing my score. I can also start playing a game on the pc in my kitchen, then
shut it down, and go finish the match on a different pc in the basement or wherever
without losing my score.

Get it here: http://ecoop.ucoz.com/load/ or download attached
Attachments
ScoreSave_RC5.zip
RC5
(4.88 KiB) Downloaded 311 times
Last edited by MrLoathsome on Tue Nov 30, 2010 4:01 am, edited 2 times in total.
blarg
MrLoathsome
Inhuman
 
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Location: MrLoathsome fell out of the world!
Personal rank: I am quite rank.

Re: ScoreSave mutator

Postby Shade » Tue Jun 01, 2010 2:28 am

Wow, THATS a useful mutator! :) Should be a "must have" for every server :P
User avatar
Shade
Site Admin
 
Posts: 1364
Joined: Sun Jan 27, 2008 12:03 pm
Location: Germany
Personal rank: Founder of UT99.org

Re: ScoreSave mutator

Postby Darkness » Tue Jun 01, 2010 2:38 am

That's a great idea, indeed in some situations it might prove useful. Another simple yet great concept, nice job.
Darkness
Experienced
 
Posts: 80
Joined: Mon Mar 01, 2010 10:12 pm
Location: Brazil

Re: ScoreSave mutator

Postby Hook » Wed Jun 02, 2010 7:02 pm

Is this something different? :P
I mean there is Pheonix and also Resurrector.
They both preserve scores when you temporarily disconnect form a server. :|
=Hook=(Member# 626)
Forums: http://hooksutplace.freeforums.net
UT99 Server -> CROSSBONES Missile Madness {CMM}

* Newest Versions of: PRO-Redeemers | PRO-SNIPER-Redeemers | PRO-SEEKER-Redeemers <-(the Original)
and Now with FOOD FIGHT and Frying Pan arena !!!
IP: 68.232.181.236:7777
User avatar
Hook
Masterful
 
Posts: 683
Joined: Tue Apr 22, 2008 11:21 pm
Location: Minnesota USA
Personal rank: UT99 Promoter/Admin

Re: ScoreSave mutator

Postby gopostal » Thu Jun 03, 2010 2:27 am

Loath, be very, very careful with this. The UT native code saves stuff anyway and mods like phoenix can cause a bunch of unintended consequences. You can mistakenly get the server to save other settings, even from game to game, causing mods to malfunction, things to get "weird", and even crashes.

If this is something you plan on pursuing as a developed mod, drop me a line and I'll tell you where my working with phoenix got and the problems I saw with it. I'll warn you up front there are quite a few unanswered questions about "why" a score saving mod can trigger such server behavior but I can reference you a bunch of admins who have seen it first-hand.
gopostal
 

Re: ScoreSave mutator

Postby MrLoathsome » Thu Jun 03, 2010 2:48 pm

Hook wrote:Is this something different? :P
I mean there is Pheonix and also Resurrector.
They both preserve scores when you temporarily disconnect form a server. :|


I never heard of either of them, and I probably spent more time searching for a mutator that would
do that than I did writing this one....

After reading gopostals message about Pheonix, I am now afraid to download those or look at the source code. :confused2:
blarg
MrLoathsome
Inhuman
 
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Location: MrLoathsome fell out of the world!
Personal rank: I am quite rank.

Re: ScoreSave mutator

Postby MrLoathsome » Thu Jun 03, 2010 2:53 pm

gopostal wrote:Loath, be very, very careful with this. The UT native code saves stuff anyway and mods like phoenix can cause a bunch of unintended consequences. You can mistakenly get the server to save other settings, even from game to game, causing mods to malfunction, things to get "weird", and even crashes.

:idea:

So far I haven't seen my version do anything out of the ordinary. I kept it as short and simple as I could.
It is so short I will post the entire source here now, and you can take a look and tell me what is wrong with it.

Code: Select all
class ScoreSave extends Mutator;

var int      NumPlyrs;
var string   PlyrList[128];
var int      PlyrScore[128];
var int      PlyrDeaths[128];
var bool Initialized;

function PostBeginPlay()
{
   local int i;

   if (Initialized)
      return;
   Initialized = True;
   for (i=0; i < 128; i++)
   {
      PlyrList[i] = "";
      PlyrScore[i] = 0;
      PlyrDeaths[i] = 0;
      NumPlyrs = Level.Game.NumPlayers;
   }
   Level.Game.RegisterDamageMutator( Self );
}

function ScoreKill(Pawn Killer, Pawn Other)
{
   local int i;

   if ( NextMutator != None )
      NextMutator.ScoreKill(Killer, Other);

   if ((Killer.isA('PlayerPawn') && !Killer.isA('Bot')))
   {
      for( i=0; i < NumPlyrs; i++ )
      {
         if ( Killer.PlayerReplicationInfo.PlayerName == PlyrList[i] )
            {
               PlyrScore[i] = Killer.PlayerReplicationInfo.Score;
               PlyrDeaths[i] = Killer.PlayerReplicationInfo.Deaths;
               break;
            }
      }
   }
   if ((Other.isA('PlayerPawn') && !Other.isA('Bot')))
   {
      for( i=0; i < NumPlyrs; i++ )
      {
         if ( Other.PlayerReplicationInfo.PlayerName == PlyrList[i] )
            {
               PlyrScore[i] = Other.PlayerReplicationInfo.Score;
               PlyrDeaths[i] = Other.PlayerReplicationInfo.Deaths;
               break;
            }
      }
   }
}


function ModifyPlayer(Pawn Other)
{
   local playerpawn NewPlayer;
   local int i;
   local string PName;

   if (!Initialized)
   {
      Initialized = True;
   }
   NewPlayer = playerpawn(Other);
   if ( (Other == None) || (Other.IsA('Bot')) || (Other.PlayerReplicationInfo.Score != 0) || (Other.PlayerReplicationInfo.Deaths != 0) )
   {
      Super.ModifyPlayer(Other);
      return;
   }
   PName = NewPlayer.PlayerReplicationInfo.PlayerName;
   for( i=0; i < NumPlyrs; i++ )
      {
         if ( PName == PlyrList[i] )
            {
               Other.PlayerReplicationInfo.Score = PlyrScore[i];
               Other.PlayerReplicationInfo.Deaths = PlyrDeaths[i];
               break;
            }
      }
      if (i >= NumPlyrs)
      {
         NumPlyrs++;
         PlyrList[i] = PName;
      }
   Super.ModifyPlayer(Other);
}

defaultproperties
{
}
blarg
MrLoathsome
Inhuman
 
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Location: MrLoathsome fell out of the world!
Personal rank: I am quite rank.

Re: ScoreSave mutator

Postby Hook » Thu Jun 03, 2010 7:08 pm

I have never Heard of any problems with either Pheonix or Resurrector, but Gopo probably has some reasons and cases of something going wrong with Pheonix anyway.
I don't know about Resurrector...
Resurrector is "Pheonix Re-Written" according to its author, but I am not sure WHY it was re-written or what was changed exactly.

I have been using Pheonix for quit a while now (many months) on 2 of my servers without any problems that I know of.
A few other server admins I know also use Pheonix. - One of them alternates between Pheonix and Resurrector - don't know why he does this - been meaning to ask him. :roll:

That is all I know about these two (2).
=Hook=(Member# 626)
Forums: http://hooksutplace.freeforums.net
UT99 Server -> CROSSBONES Missile Madness {CMM}

* Newest Versions of: PRO-Redeemers | PRO-SNIPER-Redeemers | PRO-SEEKER-Redeemers <-(the Original)
and Now with FOOD FIGHT and Frying Pan arena !!!
IP: 68.232.181.236:7777
User avatar
Hook
Masterful
 
Posts: 683
Joined: Tue Apr 22, 2008 11:21 pm
Location: Minnesota USA
Personal rank: UT99 Promoter/Admin

Re: ScoreSave mutator

Postby gopostal » Thu Jun 03, 2010 11:47 pm

I'm sorry to be non-specific but I can't really help you because I don't know the problem. In messing around with the phoenix code I saw problems crop up that went away as soon as the code was removed. It was my intention to include score save into MH2 but I finally gave up. For some reason the storage of playerreplicationinfo into an array that remains on the server if you leave triggers things in the native code to be saved, even across games. I frequently had to hard reboot to clear the server.

Some of the things I remember happening was:
gametype switch sometimes didn't work. You'd get the monsterhunt controller loading into Jailbreak and DM matches
players occasionally started the next game with odd inventory, sometimes carried over, sometimes "random"
Gravity (if it was full map settings) sometimes crept into the next map
I even remember map names (the one you see in the server browser not the "True" one) sometimes carried over from the last map

There were some others too but you get the idea. I had intentions of making an ini and saving the last so-many players on it to remove the saved info from the server buffers *but*, now get this part: MH2 *will* save your score if you leave and return and it has no code to do that. Somehow in the compile that code got in and is active and has not removed. Ghosts in the machine, I guess.

In the end this whole thing has baffled me. I swear I'd pay Epic to explain to me why on these issues.

BTW, I'm a fan of your work. Clean, well-written code and you continue to improve your stuff. Where the hell were you 10 years ago?
gopostal
 

Re: ScoreSave mutator

Postby MrLoathsome » Sat Jun 05, 2010 2:58 am

Does that other mutator attempt to save inventory and other PRI stuff across level changes ?
I can see where that might cause issues, as it becomes a non-trivial task.
What other functions does it perform ?

My mutator has a life-span of 1 game/match, and resets everything when a new match starts.
It saves nothing but the Score and Deaths during 1 game. Gametype etc is pretty much irrelevant
for it. I tried to make it as simple and universal as possible.

Just got done testing it on the 2 live servers I have installed it on. No glitches yet.....

Thanks for the bit about my code. I certainly keep it clean from any unneeded comments. :mrgreen:
Learned to program on a Ti99 4/a and programmed on Atari 8-bit computers for years. 800xl, 130xe etc..
You didn't waste any space with comments back then....

10 years ago I had just gotten laid off from a Network Admin & IBM midrange programming position.
After I solved the Y2K problem and saved the company and planet, they decided they didn't need me anymore. :loool:
Wrote stuff in RPG for old System 36 and AS400 boxes for about 10 years.
blarg
MrLoathsome
Inhuman
 
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Location: MrLoathsome fell out of the world!
Personal rank: I am quite rank.

Re: ScoreSave mutator

Postby MrLoathsome » Sun Jun 06, 2010 6:07 am

Minor update on this.

It was pointed out to me that under certain conditions, the killer or killed could be none...

This update I just changed the lines using this method:

Code: Select all
   if ((Killer.isA('PlayerPawn') && !Killer.isA('Bot')))


to

Code: Select all
   if ((PlayerPawn(Killer) != None) && (Bot(Killer) == None))


This should solve that problem and execute faster also.
:rock:
blarg
MrLoathsome
Inhuman
 
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Location: MrLoathsome fell out of the world!
Personal rank: I am quite rank.

Re: ScoreSave mutator

Postby gopostal » Sun Jun 06, 2010 2:08 pm

You might change your class sheet too. I can promise you that has gotten copy/pasted into several mods already in development.

I hope you have solved this problem, +1 for a stellar effort. I was thinking about the issue yesterday at work and I might have something approaching an answer. Don't know if you play MH but the skaarj sniper class(es) can use the weaponry that players use. The problem is that the code is incomplete and any weapon they hold has no ammo. Not zero, its completely null. This makes buggy weapons that get dropped and result in players picking up a weapon that messes up their HUD, but has infinite ammo. I fixed it in MH2, but only my removing the ability for the Skaarj to toss the weapon. The value for the weapon's ammo is still null.
Anyhow I think the scoresave mod was messed up trying to get the replication value for weapons with null value. I didn't see errors in the log for that but it could very well be returning something that makes it get all weird but doesn't consider "wrong". I should have simplified it just like you did, but like always I overthink things.

Very good job. BTW, is your stuff usable with credits to you?
gopostal
 

Re: ScoreSave mutator

Postby MrLoathsome » Sun Jun 06, 2010 4:50 pm

I am pretty sure this thing is now done. It wasn't creating any quantity of accessed nones, but the
possibility existed that a few might occur, and I do not allow my code to produce accessed none errors. 8)

Anybody can use my code as long as they send me $10,000.

Or if they don't want to pay me $10,000 they can use it for free. :mrgreen: :lol2: :omfg:

I put this little section at the bottom of most of my Readme.txt files for my mutators so far:
Code: Select all
// ============================================================
//  (c) 2010 Mr.Loathsome aka Scott Armitage
//
// You MAY modify this code without written permission from
// the author. You are free to use and distribute this code,
// as long as there is no money charged for it.
// ============================================================


Now here is a question that will demonstrate my UnrealScripting noobness.

What exactly do you mean by "Class Sheet" ?

But seriously, send me $10,000 anyway. :loool:
blarg
MrLoathsome
Inhuman
 
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Location: MrLoathsome fell out of the world!
Personal rank: I am quite rank.

Re: ScoreSave mutator

Postby gopostal » Sun Jun 06, 2010 5:16 pm

Maybe something like this:
Image

You just know serious man hours were lost at Verizon while the techs tried to solve the equation.

Sheet is an old term. Back in the early days of BASIC you printed your code onto the old sheet-fed printers. We had "copy sheets" not copy paper (and man were they loud when printing). Once you peeled the perforated sides off you had a decent sheet of paper to read and use. I got so used to the term I automatically think of uc files as "unreal class sheets".

"Unreal class text file" just seems so much less romantic. :noidea
gopostal
 

Re: ScoreSave mutator

Postby iloveut99 » Mon Aug 16, 2010 11:36 pm

Works awesome.

Thanks.
iloveut99
Skilled
 
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Next

Return to Mutators

Who is online

Users browsing this forum: makemeunreal and 2 guests