- 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);
}
...
- 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: Converted to C this gives:
- Code: Select all
// Per tick...:
if( 0 )
{
this->Fame = this->Fame - this->Fame >> 7;
}