Let's talk about Karma & Fame

Let's talk about Karma & Fame

Postby Batlin on Mon Dec 06, 2010 10:44 am

10 karma/fame commands exist:
    getKarma, setKarma, getKarmaLevel, getAdjKarma, changeKarma
    getFame, setFame, getFameLevel, getAdjFame, changeFame

The gainFame and lossFame commands seem to be related to the notoriety system. Refer to the repconvert script to see how repuration may have been converted from notoriety to karma/fame.


The setKarma and setFame commands will ensure that the provided value is between -20000 (for karma) or 0 (for fame) and +20000 (for both karma and fame). The value is adjusted to be within these limits. getKarma and getFame can be used to obtain the actual karma/fame of a player.

getAdjKarma will return the same value as getKarma for non-murderers. For murderers this function will return the same value as getKarma if their karma is negative, otherwise it will return 0! getAdjFame returns the same value as getFame. NOTE: a player is marked as murderer if he/she has a "murderCount" variable attached with a value greater or equal than 5.

getKarmaLevel will return a value based upon the getAdjKarma value using this formula:
Code: Select all
  AdjValue = this->GetAdjKarma();
  if(AdjValue < 0)
  {
    IsPositive = 0
    AdjValue = -this->GetKarma();
  }
  else
    IsPositive = 1
  LevelValue = 10000;
  for ( Level = 5; Level > 0; Level -- )
  {
    if ( Level <= 0)
      return 0;
    if ( AdjValue >= LevelValue )
      break;
    LevelValue /= 2;
  }
  if( ! IsPositive )
    LevelValue = -LevelValue;
  return LevelValue;

getFameLevel will return a value based upon the getAdjFame value using this formula:
Code: Select all
  AdjValue = GetAdjFame(this);
  LevelValue = 10000;
  for ( Level = 4; Level > 0; Level -- )
  {
    if ( AdjValue >= LevelValue )
      return Level;
    LevelValue /= 2;
  }
  return 0;

See also this table : http://uo.stratics.com/content/reputation/titles.shtml.

Now, let's talk about changeKarma and changeFame. What's interesting about those 2 script functions/commands is that they include usage of randomizer. Here are the 2 functions:
Code: Select all
void MOBILE::ChangeKarma(int KarmaChange)
{
  if( this->GetKarma() >= 0 )
  {
    if( KarmaChange >= 0 )
    {
      if( KarmaChange <= this->GetKarma() )
      {
        return;
      }
    }
  }
  else
  {
    if( KarmaChange <= 0)
    {
      if( KarmaChange >= this->GetKarma() )
      {
        return;
      }     
    }
  }

  KarmaChange = KarmaChange - this->GetKarma();
  int KarmaToAdd = KarmaChange / 100:
  int NewKarma = this->GetKarma() + KarmaToAdd;
  if( GetRandom(100) < KarmaChange % 100 )
    NewKarma += 1;

  this->SendKarmaFameChangeMessage(this->GetKarma(), NewKarma, "karma");
  this->SetKarma(NewKarma);
  ExecuteEvent(this, EVENT_KarmaChanged);
}

void MOBILE::ChangeFame(int FameChange)
{
  int NewFame;

  if( FameChange < 0)
  {
    // USELESS
    if(FameChange >= -100)
      NewFame = 0;

    NewFame = this->GetFame() + ( int(this->GetFame() * FameChange) / 100 );
  }
  else
  {
    FameChange = FameChange - this->GetFame();
    if( FameChange <= 0 )
    {
      return;
    }

    int FameToAdd = FameChange / 100:
    NewFame = this->GetFame() + FameToAdd;
    if( GetRandom(100) < FameChange % 100 )
      NewFame += 1;
  }

  this->SendKarmaFameChangeMessage(this->GetFame(), NewFame, "fame");
  this->SetFame(NewFame);
  ExecuteEvent(this, EVENT_FameChanged);
}


What happens on a kill? How is your fame and karma affected?
This is from inside the EXE...
For the killer:
Code: Select all
// in case of a kill :
...
Defender->SetCurHP(DefenderHealth - DamageAmount);
if(Attacker != NULL && Defender != NULL)
{
  int DefenderAdjFame = Defender->GetAdjFame();
  int DefenderAdjKarma = 0;
  if( ! Defender=>IsPlayer() )
    DefenderAdjKarma = -Defender->GetAdjKarma();

  Attacker->ChangeReputation(DefenderAdjFame, DefenderAdjKarma);
}
...
On resurrection:
Code: Select all
...
Resurrected->ChangeFame(-10);
...


ChangeReputation is like this:
Code: Select all
void PLAYER::ChangeReputation(int FameChange, int KarmaChange)
{
  // THIS IS FOR PLAYERS ONLY!!!! MOBILES HAVE DIFFERENT CODE
  this->ChangeFame(FameChange);
  this->ChangeKarma(KarmaChange);
}


The demo also contains disabled fame decay code, this is a screenshot of the documented assembler in action:
Disable Fame Decay.png
Disable Fame Decay.png (13.06 KiB) Viewed 106 times
Converted to C this gives:
Code: Select all
// Per tick...:
if( 0 )
{
  this->Fame = this->Fame - this->Fame >> 7;
}
<Derrick> RunUO AI is kind of a functional prototype, which i have hacked into something resembling OSI behavior, but only by complitcating everything
Batlin
Site Admin
 
Posts: 306
Joined: Wed Apr 08, 2009 6:35 am


Re: Let's talk about Karma & Fame

Postby Bicchus Dicchus on Fri Jan 14, 2011 10:58 pm

Hmm I find it odd that the T2A demo, which came out before UOR, has functions for fame and karma.
These two variables didn't exist in the Notoriety system, which was the standard of the day.

I reckon they had been considering and working on the Reputation system for a while before it was introduced.

Always get nostalgic for the old Noto days though.

-Bicchus Dicchus
Bicchus Dicchus
 
Posts: 3
Joined: Fri Jan 14, 2011 10:07 pm
Location: Sosaria


Re: Let's talk about Karma & Fame

Postby Batlin on Fri Jan 14, 2011 11:56 pm

Hmm I find it odd that the T2A demo, which came out before UOR, has functions for fame and karma.
These two variables didn't exist in the Notoriety system, which was the standard of the day.
The demo contains leftovers from the Notoriety system but it's not active inside the EXE. If you have time, check out the scripts and read them with a correct analysis of the getCompileFlag function : http://uodemo.joinuo.com/index.php?title=GetCompileFlag

Inside the EXE there's also a reference to a "remnoto" script which in my opinion stands for "remove notoriety". The script itself is not included in the DAT file.

Another interesting script is the "repconvert" (reputation convert) script which actually converts notoriety to karma/fame. Pretty cool stuff in there.
<Derrick> RunUO AI is kind of a functional prototype, which i have hacked into something resembling OSI behavior, but only by complitcating everything
Batlin
Site Admin
 
Posts: 306
Joined: Wed Apr 08, 2009 6:35 am


Re: Let's talk about Karma & Fame

Postby Bicchus Dicchus on Sun Jan 16, 2011 6:50 pm

I checked it out, and I find it fascinating. I presume that all leftovers are, for the most part, left in for compatibility's sake, and not due to programming laziness. However, I'm of the opinion that there's been many a programmer working on the client, and perhaps more than one of these fellows were inept in the arts of code documentation. C'est la vie.

I always had a soft spot for the Notoriety system. I like to keep things simple.

-Bicchus Dicchus
Bicchus Dicchus
 
Posts: 3
Joined: Fri Jan 14, 2011 10:07 pm
Location: Sosaria



Return to UO Demo

Who is online

Users browsing this forum: No registered users and 1 guest