Merge branch 'marauder_fame'

feature/prepare-cross-merge
Nuno 4 years ago committed by kaetemi
parent 9b5a4d94cf
commit 08393ea94d
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -5131,10 +5131,10 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", "<user id> <web_app_url
if (command_args.size() == 4 || (command_args.size () == 5 && command_args[4] != "0"))
{
// Make sure fame values are properly capped.
CFameManager::getInstance().enforceFameCaps(c->getId(), c->getAllegiance());
CFameManager::getInstance().enforceFameCaps(c->getId(), c->getOrganization(), c->getAllegiance());
// set tribe fame threshold and clamp fame if necessary
CFameManager::getInstance().setAndEnforceTribeFameCap(c->getId(), c->getAllegiance());
CFameManager::getInstance().setAndEnforceTribeFameCap(c->getId(), c->getOrganization(), c->getAllegiance());
}
}

@ -412,6 +412,7 @@ void CFameManager::savePlayerFame(const NLMISC::CEntityId &playerId, EGSPD::CFam
if( entry == NULL )
entry = fameContainer.addToEntries( id );
EGS_PD_AST(entry);
nlinfo("%d : %d", it->second->Fames[i]);
entry->setFame( it->second->Fames[i] );
entry->setLastFameChangeTrend( fow->LastFameChangeTrends[i] );
}
@ -901,7 +902,7 @@ void CFameManager::addFameIndexed(const CEntityId &entityId, uint32 faction, sin
if ( c )
{
// Bound the fame based on current allegiance.
sint32 maxFame = getMaxFameByFactionIndex(c->getAllegiance(), faction);
sint32 maxFame = getMaxFameByFactionIndex(c->getAllegiance(), c->getOrganization(), faction);
clamp(fame,FameAbsoluteMin,maxFame);
// Check to make sure player still qualifies to be in declared allegiances.
c->verifyClanAllegiance(PVP_CLAN::getClanFromIndex(faction), sint32(fame));
@ -932,7 +933,7 @@ void CFameManager::addFameIndexed(const CEntityId &entityId, uint32 faction, sin
if ( g )
{
// Bound the fame based on current allegiance.
sint32 maxFame = getMaxFameByFactionIndex(g->getAllegiance(), faction);
sint32 maxFame = getMaxFameByFactionIndex(g->getAllegiance(), 0, faction);
clamp(fame,FameAbsoluteMin,maxFame);
g->verifyClanAllegiance(PVP_CLAN::getClanFromIndex(faction), sint32(fame));
g->setFameValueGuild(faction, sint32(fame), maxFame, fow.LastFameChangeTrends[faction]);
@ -1238,7 +1239,7 @@ void CFameManager::setEntityFame(const NLMISC::CEntityId & entityId, uint32 fact
{
nldebug("FAME: set fame for character %s as P:%d", entityId.toString().c_str(), fame);
sint32 maxFame = getMaxFameByFactionIndex(ch->getAllegiance(), faction);
sint32 maxFame = getMaxFameByFactionIndex(ch->getAllegiance(), ch->getOrganization(), faction);
ch->setFameValuePlayer(faction, fame, maxFame, fow.LastFameChangeTrends[faction]);
/*
@ -1255,7 +1256,7 @@ void CFameManager::setEntityFame(const NLMISC::CEntityId & entityId, uint32 fact
}
else if(gu)
{
sint32 maxFame = getMaxFameByFactionIndex(gu->getAllegiance(), faction);
sint32 maxFame = getMaxFameByFactionIndex(gu->getAllegiance(), 0, faction);
gu->setFameValueGuild(faction, fame, maxFame, fow.LastFameChangeTrends[faction]);
}
else
@ -1279,8 +1280,20 @@ sint32 CFameManager::getStartFame(PVP_CLAN::TPVPClan playerClan, PVP_CLAN::TPVPC
}
// - getMaxFameByClan: playerClan must be Neutral or the same type (Cult or Clan) as targetClan, targetClan must be any non-neutral clan.
sint32 CFameManager::getMaxFameByClan(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> playerClans, PVP_CLAN::TPVPClan targetClan)
sint32 CFameManager::getMaxFameByClan(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> playerClans, uint32 organization, PVP_CLAN::TPVPClan targetClan)
{
if (targetClan == PVP_CLAN::Marauder)
{
if (organization == 5)
return 100*kFameMultipler;
return 30*kFameMultipler;
}
if (organization == 5) // marauder
{
return -30*kFameMultipler;
}
// Local variables for the lookup values.
int playerLookup, targetLookup;
@ -1337,18 +1350,19 @@ sint32 CFameManager::getMaxFameByClan(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TP
}
}
// Wasn't caught above, probably a tribe. Return a default value.
return FameMaxDefault;
}
sint32 CFameManager::getMaxFameByFactionIndex(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance, uint32 factionIndex)
sint32 CFameManager::getMaxFameByFactionIndex(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance, uint32 organization, uint32 factionIndex)
{
PVP_CLAN::TPVPClan pvpClan;
// try first with a clan
pvpClan= PVP_CLAN::getClanFromIndex(factionIndex);
if(pvpClan != PVP_CLAN::Unknown)
return getMaxFameByClan(allegiance, pvpClan);
return getMaxFameByClan(allegiance, organization, pvpClan);
// search for tribe
else
{
@ -1373,6 +1387,14 @@ sint32 CFameManager::getMaxFameByFactionIndex(std::pair<PVP_CLAN::TPVPClan, PVP_
// get the
const CStaticFames::CTribeCultThreshold * tc = 0;
if (organization == 5) // marauder
{
tc = &tribeThres[ttIndex].Marauder;
return tc->getMarauder();
}
else
{
switch( allegiance.second )
{
case PVP_CLAN::Matis:
@ -1413,6 +1435,7 @@ sint32 CFameManager::getMaxFameByFactionIndex(std::pair<PVP_CLAN::TPVPClan, PVP_
}
}
}
}
void CFameManager::doInitTribeThresholdIndex()
{
@ -1433,7 +1456,7 @@ void CFameManager::doInitTribeThresholdIndex()
}
void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance)
void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, uint32 organization, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance)
{
const TDataSetRow rowId = TheFameDataset.getDataSetRow(entityId);
TFameContainer::iterator it = _FamesOwners.find(rowId);
@ -1464,6 +1487,51 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
sint32 fame;
sint32 maxFame;
if (organization == 5) // marauder
{
for (int looper = PVP_CLAN::BeginCults; looper <= PVP_CLAN::EndCults; looper++)
{
theFactionIndex = PVP_CLAN::getFactionIndex((PVP_CLAN::TPVPClan)looper);
fame = fow.Fames[theFactionIndex];
maxFame = -30*kFameMultipler;
if( fame != NO_FAME)
{
clamp(fame,FameAbsoluteMin, maxFame);
fow.Fames[theFactionIndex] = fame;
}
if (ch)
{
ch->setFameValuePlayer(theFactionIndex, fame, maxFame, fow.LastFameChangeTrends[theFactionIndex]);
}
if (gu)
{
gu->setFameValueGuild(theFactionIndex, fame, maxFame, fow.LastFameChangeTrends[theFactionIndex]);
}
}
for (int looper = PVP_CLAN::BeginCivs; looper <= PVP_CLAN::EndCivs; looper++)
{
theFactionIndex = PVP_CLAN::getFactionIndex((PVP_CLAN::TPVPClan)looper);
fame = fow.Fames[theFactionIndex];
maxFame = -30*kFameMultipler;
if( fame != NO_FAME)
{
clamp(fame,FameAbsoluteMin,maxFame);
fow.Fames[theFactionIndex] = fame;
}
if (ch)
{
ch->setFameValuePlayer(theFactionIndex, fame, maxFame, fow.LastFameChangeTrends[theFactionIndex]);
}
if (gu)
{
gu->setFameValueGuild(theFactionIndex, fame, maxFame, fow.LastFameChangeTrends[theFactionIndex]);
}
}
return;
}
// Check cults, first member of allegiance
PVP_CLAN::TPVPClan theCult = allegiance.first;
if (theCult != PVP_CLAN::None)
@ -1472,7 +1540,7 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
{
theFactionIndex = PVP_CLAN::getFactionIndex((PVP_CLAN::TPVPClan)looper);
fame = fow.Fames[theFactionIndex];
maxFame = getMaxFameByClan(allegiance,(PVP_CLAN::TPVPClan)looper);
maxFame = getMaxFameByClan(allegiance, organization, (PVP_CLAN::TPVPClan)looper);
if( fame != NO_FAME)
{
clamp(fame,FameAbsoluteMin,maxFame);
@ -1496,7 +1564,7 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
{
theFactionIndex = PVP_CLAN::getFactionIndex((PVP_CLAN::TPVPClan)looper);
fame = fow.Fames[theFactionIndex];
maxFame = getMaxFameByClan(allegiance,(PVP_CLAN::TPVPClan)looper);
maxFame = getMaxFameByClan(allegiance, organization, (PVP_CLAN::TPVPClan)looper);
if( fame != NO_FAME)
{
clamp(fame,FameAbsoluteMin,maxFame);
@ -1514,7 +1582,7 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
}
}
void CFameManager::setAndEnforceTribeFameCap(const NLMISC::CEntityId &entityId, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance)
void CFameManager::setAndEnforceTribeFameCap(const NLMISC::CEntityId &entityId, uint32 organization, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance)
{
const TDataSetRow rowId = TheFameDataset.getDataSetRow(entityId);
TFameContainer::iterator it = _FamesOwners.find(rowId);
@ -1551,6 +1619,13 @@ void CFameManager::setAndEnforceTribeFameCap(const NLMISC::CEntityId &entityId,
{
theFactionIndex = (*it).FameIndex;
if (organization == 5) // marauder
{
tc = &(*it).Marauder;
threshold = tc->getMarauder();
}
else
{
switch( allegiance.second )
{
case PVP_CLAN::Matis:
@ -1588,6 +1663,7 @@ void CFameManager::setAndEnforceTribeFameCap(const NLMISC::CEntityId &entityId,
nlwarning("Character %s have bad cult allegiance...'%d/%s' !", entityId.toString().c_str(), allegiance.first, PVP_CLAN::toString(allegiance.first).c_str());
return;
}
}
fame = fow.Fames[theFactionIndex];
if( fame != NO_FAME )
@ -2251,7 +2327,7 @@ NLMISC_COMMAND (testit, "testit", "")
}
//int retval = CFameManager::getInstance().getStartFame(pCiv,tClan);
int retval = CFameManager::getInstance().getMaxFameByClan(std::make_pair(pCult,pCiv),tClan);
int retval = CFameManager::getInstance().getMaxFameByClan(std::make_pair(pCult,pCiv),0,tClan);
log.displayNL("Fame value = %d.", retval);
return true;

@ -147,14 +147,14 @@ public:
sint32 getStartFame(PVP_CLAN::TPVPClan playerClan, PVP_CLAN::TPVPClan targetClan);
// - getMaxFameByClan: playerClan must be Neutral or the same type (Cult or Clan) as targetClan,
// targetClan must be any non-neutral clan.
sint32 getMaxFameByClan(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> playerClans, PVP_CLAN::TPVPClan targetClan);
sint32 getMaxFameByFactionIndex(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> playerClans, uint32 factionIndex);
sint32 getMaxFameByClan(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> playerClans, uint32 organization, PVP_CLAN::TPVPClan targetClan);
sint32 getMaxFameByFactionIndex(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> playerClans, uint32 organization, uint32 factionIndex);
// Ensures that the fame values are properly capped based on allegiance.
void enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance);
void enforceFameCaps(const NLMISC::CEntityId &entityId, uint32 organization, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance);
// Set tribe fame cap and ensures fame values are properly capped, based on allegiance
void setAndEnforceTribeFameCap(const NLMISC::CEntityId &entityId, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance);
void setAndEnforceTribeFameCap(const NLMISC::CEntityId &entityId, uint32 organization, std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> allegiance);
// Callback function for when one of the threshold CVariables are changed.
static void thresholdChanged(NLMISC::IVariable &var);

@ -2071,7 +2071,7 @@ bool CGuild::setDeclaredCult(PVP_CLAN::TPVPClan newClan, bool noCheck)
//character->sendEventForMissionAvailabilityCheck();
}
_DeclaredCult = newClan;
CFameManager::getInstance().enforceFameCaps(getEId(), getAllegiance());
CFameManager::getInstance().enforceFameCaps(getEId(), 0, getAllegiance());
// Go through membership list, change anyone who doesn't fit in guild to "None".
verifyGuildmembersAllegiance();
@ -2105,7 +2105,7 @@ bool CGuild::setDeclaredCiv(PVP_CLAN::TPVPClan newClan, bool noCheck)
//character->sendEventForMissionAvailabilityCheck();
}
_DeclaredCiv = newClan;
CFameManager::getInstance().enforceFameCaps(getEId(), getAllegiance());
CFameManager::getInstance().enforceFameCaps(getEId(), 0, getAllegiance());
// Go through membership list, change anyone who doesn't fit in guild to "None".
verifyGuildmembersAllegiance();
@ -2232,7 +2232,7 @@ void CGuild::resetFameDatabase()
{
// update player fame info
sint32 fame = fi.getFameIndexed(getEId(), i);
sint32 maxFame = CFameManager::getInstance().getMaxFameByFactionIndex(getAllegiance(), i);
sint32 maxFame = CFameManager::getInstance().getMaxFameByFactionIndex(getAllegiance(), 0, i);
setFameValueGuild(i, fame, maxFame, 0);
}
}
@ -2265,7 +2265,7 @@ void CGuild::setStartFameAndAllegiance( const CEntityId& guildCreator )
CFameManager::getInstance().setEntityFame(getEId(), i, 0);
}
}
CFameManager::getInstance().enforceFameCaps( getEId(), allegiance );
CFameManager::getInstance().enforceFameCaps( getEId(), 0, allegiance );
}

@ -11880,9 +11880,21 @@ void CCharacter::setOrganization(uint32 org)
CBankAccessor_PLR::getUSER().getRRPS_LEVELS(1).setVALUE(_PropertyDatabase, _Organization);
CBankAccessor_PLR::getUSER().getRRPS_LEVELS(2).setVALUE(_PropertyDatabase, _OrganizationStatus);
CBankAccessor_PLR::getUSER().getRRPS_LEVELS(3).setVALUE(_PropertyDatabase, _OrganizationPoints);
CPVPManager2::getInstance()->updateFactionChannel(this);
if (org != 0)
{
setDeclaredCult(PVP_CLAN::Neutral);
setDeclaredCiv(PVP_CLAN::Neutral);
}
CPVPManager2::getInstance()->updateFactionChannel(this);
updateJewelsTags(false);
// Make sure fame values are properly capped.
CFameManager::getInstance().enforceFameCaps(getId(), org, getAllegiance());
// set tribe fame threshold and clamp fame if necessary
CFameManager::getInstance().setAndEnforceTribeFameCap(getId(), org, getAllegiance());
}
//-----------------------------------------------------------------------------
@ -16541,7 +16553,7 @@ void CCharacter::setFameValuePlayer(uint32 factionIndex, sint32 playerFame, sint
sint32 marauderFame = CFameInterface::getInstance().getFameIndexed(_Id, marauderIdx);
if (factionIndex != marauderIdx)
{
sint32 maxOtherfame = -100*6000;
sint32 maxOtherfame = -100*kFameMultipler;
for (uint8 fameIdx = 0; fameIdx < 7; fameIdx++)
{
if (fameIdx == marauderIdx)
@ -16553,11 +16565,16 @@ void CCharacter::setFameValuePlayer(uint32 factionIndex, sint32 playerFame, sint
maxOtherfame = fame;
}
// Marauder fame is when player have negative fame in other clans
maxOtherfame = -maxOtherfame;
if (marauderFame < 50 * 6000 || maxOtherfame < 50 * 6000) {
CFameManager::getInstance().setEntityFame(_Id, marauderIdx, maxOtherfame, false);
if (marauderFame < 50*kFameMultipler)
{
if (maxOtherfame < -50*kFameMultipler) // Cap to 50
maxOtherfame = -50*kFameMultipler;
CFameManager::getInstance().setEntityFame(_Id, marauderIdx, -maxOtherfame, false);
}
else
{
if (maxOtherfame > -40*kFameMultipler)
CFameManager::getInstance().setEntityFame(_Id, marauderIdx, -maxOtherfame, false);
}
}
@ -16642,15 +16659,15 @@ void CCharacter::resetFameDatabase()
// Check fames and fix bad values
if (!haveAnyPrivilege())
{
CFameManager::getInstance().enforceFameCaps(getId(), getAllegiance());
CFameManager::getInstance().setAndEnforceTribeFameCap(getId(), getAllegiance());
CFameManager::getInstance().enforceFameCaps(getId(), getOrganization(), getAllegiance());
CFameManager::getInstance().setAndEnforceTribeFameCap(getId(), getOrganization(), getAllegiance());
}
for (uint i = 0; i < CStaticFames::getInstance().getNbFame(); ++i)
{
// update player fame info
sint32 fame = fi.getFameIndexed(_Id, i, false, true);
sint32 maxFame = CFameManager::getInstance().getMaxFameByFactionIndex(getAllegiance(), i);
sint32 maxFame = CFameManager::getInstance().getMaxFameByFactionIndex(getAllegiance(), getOrganization(), i);
setFameValuePlayer(i, fame, maxFame, 0);
}
}
@ -20297,9 +20314,9 @@ bool CCharacter::setDeclaredCult(PVP_CLAN::TPVPClan newClan)
{
// No problems, let the change happen.
// Make sure fame values are properly capped.
CFameManager::getInstance().enforceFameCaps(this->getId(), this->getAllegiance());
CFameManager::getInstance().enforceFameCaps(this->getId(), this->getOrganization(), this->getAllegiance());
// set tribe fame threshold and clamp fame if necessary
CFameManager::getInstance().setAndEnforceTribeFameCap(this->getId(), this->getAllegiance());
CFameManager::getInstance().setAndEnforceTribeFameCap(this->getId(), this->getOrganization(), this->getAllegiance());
// handle with faction channel
CPVPManager2::getInstance()->updateFactionChannel(this);
// write new allegiance in database
@ -20358,9 +20375,9 @@ bool CCharacter::setDeclaredCiv(PVP_CLAN::TPVPClan newClan)
{
// No problems, let the change happen.
// Make sure fame values are properly capped.
CFameManager::getInstance().enforceFameCaps(this->getId(), this->getAllegiance());
CFameManager::getInstance().enforceFameCaps(this->getId(), this->getOrganization(), this->getAllegiance());
// set tribe fame threshold and clamp fame if necessary
CFameManager::getInstance().setAndEnforceTribeFameCap(this->getId(), this->getAllegiance());
CFameManager::getInstance().setAndEnforceTribeFameCap(this->getId(), this->getOrganization(), this->getAllegiance());
// handle with faction channel
CPVPManager2::getInstance()->updateFactionChannel(this);
// write new allegiance in database

@ -3331,6 +3331,11 @@ void CCharacter::useItem(uint32 slot)
fx.Aura = MAGICFX::NoAura;
}
}
else if (getOrganization() == 5 && CFameInterface::getInstance().getFameIndexed(_Id, PVP_CLAN::getFactionIndex(PVP_CLAN::Marauder)))
>= 600000)
{
fx.Aura = MAGICFX::MarauderKami;
}
else
{
fx.Aura = MAGICFX::NoAura;

Loading…
Cancel
Save