Manual merge of new faction system (#256).

Clean up some personal signatures.
This commit is contained in:
JJ
2014-11-01 23:27:23 -04:00
parent acab4dd443
commit 43e906e3c8
12 changed files with 80 additions and 101 deletions
+54 -76
View File
@@ -7460,7 +7460,7 @@ FACTION_VALUE Client::GetReverseFactionCon(Mob* iOther) {
}
//o--------------------------------------------------------------
//| Name: GetFactionLevel; rembrant, Dec. 16, 2001
//| Name: GetFactionLevel; Dec. 16, 2001
//o--------------------------------------------------------------
//| Notes: Gets the characters faction standing with the specified NPC.
//| Will return Indifferent on failure.
@@ -7473,7 +7473,7 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra
int32 tmpFactionValue;
FactionMods fmods;
// neotokyo: few optimizations
// few optimizations
if (GetFeigned())
return FACTION_INDIFFERENT;
if (invisible_undead && tnpc && !tnpc->SeeInvisibleUndead())
@@ -7496,7 +7496,7 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra
{
//Get the players current faction with pFaction
tmpFactionValue = GetCharacterFactionLevel(pFaction);
// Everhood - tack on any bonuses from Alliance type spell effects
//Tack on any bonuses from Alliance type spell effects
tmpFactionValue += GetFactionBonus(pFaction);
tmpFactionValue += GetItemFactionBonus(pFaction);
//Return the faction to the client
@@ -7518,97 +7518,77 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra
return fac;
}
//o--------------------------------------------------------------
//| Name: SetFactionLevel; rembrant, Dec. 20, 2001
//o--------------------------------------------------------------
//| Notes: Sets the characters faction standing with the specified NPC.
//o--------------------------------------------------------------
//Sets the characters faction standing with the specified NPC.
void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity)
{
int32 faction_id[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 };
int32 npc_value[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 };
uint8 temp[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 };
int32 faction_id[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int32 npc_value[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint8 temp[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int32 mod;
int32 t;
int32 tmpValue;
int32 current_value;
FactionMods fm;
bool change = false;
bool repair = false;
// Get the npc faction list
if(!database.GetNPCFactionList(npc_id, faction_id, npc_value, temp))
if (!database.GetNPCFactionList(npc_id, faction_id, npc_value, temp))
return;
for(int i = 0;i<MAX_NPC_FACTIONS;i++)
for (int i = 0; i < MAX_NPC_FACTIONS; i++)
{
if(faction_id[i] <= 0)
if (faction_id[i] <= 0)
continue;
// Get the faction modifiers
if(database.GetFactionData(&fm,char_class,char_race,char_deity,faction_id[i]))
if (database.GetFactionData(&fm, char_class, char_race, char_deity, faction_id[i]))
{
// Get the characters current value with that faction
current_value = GetCharacterFactionLevel(faction_id[i]);
if(this->itembonuses.HeroicCHA) {
if (this->itembonuses.HeroicCHA)
{
int faction_mod = itembonuses.HeroicCHA / 5;
// If our result isn't truncated, then just do that
if(npc_value[i] * faction_mod / 100 != 0)
if (npc_value[i] * faction_mod / 100 != 0)
npc_value[i] += npc_value[i] * faction_mod / 100;
// If our result is truncated, then double a mob's value every once and a while to equal what they would have got
else {
if(MakeRandomInt(0, 100) < faction_mod)
else
{
if (MakeRandomInt(0, 100) < faction_mod)
npc_value[i] *= 2;
}
}
//figure out their modifier
mod = fm.base + fm.class_mod + fm.race_mod + fm.deity_mod;
if(mod > MAX_FACTION)
mod = MAX_FACTION;
else if(mod < MIN_FACTION)
mod = MIN_FACTION;
// Set flag when to update db
if (current_value > MAX_PERSONAL_FACTION)
{
current_value = MAX_PERSONAL_FACTION;
repair = true;
}
else if (current_value < MIN_PERSONAL_FACTION)
{
current_value = MIN_PERSONAL_FACTION;
repair = true;
}
else if ((m_pp.gm != 1) && (npc_value[i] != 0) && ((current_value != MAX_PERSONAL_FACTION) || (current_value != MIN_PERSONAL_FACTION)))
change = true;
// Calculate the faction
if(npc_value[i] != 0) {
tmpValue = current_value + mod + npc_value[i];
current_value += npc_value[i];
int16 FactionModPct = spellbonuses.FactionModPct + itembonuses.FactionModPct + aabonuses.FactionModPct;
tmpValue += (tmpValue * FactionModPct) / 100;
if (current_value > MAX_PERSONAL_FACTION)
current_value = MAX_PERSONAL_FACTION;
else if (current_value < MIN_PERSONAL_FACTION)
current_value = MIN_PERSONAL_FACTION;
// Make sure faction hits don't go to GMs...
if (m_pp.gm==1 && (tmpValue < current_value)) {
tmpValue = current_value;
}
if (change || repair)
{
database.SetCharacterFactionLevel(char_id, faction_id[i], current_value, temp[i], factionvalues);
// Make sure we dont go over the min/max faction limits
if(tmpValue >= MAX_FACTION)
if (change)
{
t = MAX_FACTION - mod;
if(current_value == t) {
//do nothing, it is already maxed out
} else if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], t, temp[i], factionvalues)))
{
return;
}
mod = fm.base + fm.class_mod + fm.race_mod + fm.deity_mod;
tmpValue = current_value + mod + npc_value[i];
SendFactionMessage(npc_value[i], faction_id[i], tmpValue, temp[i]);
}
else if(tmpValue <= MIN_FACTION)
{
t = MIN_FACTION - mod;
if(current_value == t) {
//do nothing, it is already maxed out
} else if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], t, temp[i], factionvalues)))
{
return;
}
}
else
{
if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], current_value + npc_value[i], temp[i], factionvalues)))
{
return;
}
}
if(tmpValue <= MIN_FACTION)
tmpValue = MIN_FACTION;
SendFactionMessage(npc_value[i], faction_id[i], tmpValue, temp[i]);
}
}
}
@@ -7636,19 +7616,17 @@ int32 Client::GetCharacterFactionLevel(int32 faction_id)
return 0;
faction_map::iterator res;
res = factionvalues.find(faction_id);
if(res == factionvalues.end())
return(0);
return(res->second);
if (res == factionvalues.end())
return 0;
return res->second;
}
// returns the character's faction level, adjusted for racial, class, and deity modifiers
int32 Client::GetModCharacterFactionLevel(int32 faction_id) {
int32 Modded = GetCharacterFactionLevel(faction_id);
FactionMods fm;
if(database.GetFactionData(&fm,GetClass(),GetRace(),GetDeity(),faction_id))
if (database.GetFactionData(&fm, GetClass(), GetRace(), GetDeity(), faction_id))
Modded += fm.base + fm.class_mod + fm.race_mod + fm.deity_mod;
if (Modded > MAX_FACTION)
Modded = MAX_FACTION;
return Modded;
}
@@ -7727,17 +7705,17 @@ void Client::SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 totalval
// default to Faction# if we couldn't get the name from the ID
if (database.GetFactionName(faction_id, name, sizeof(name)) == false)
snprintf(name, sizeof(name),"Faction%i",faction_id);
snprintf(name, sizeof(name), "Faction%i", faction_id);
if (tmpvalue == 0 || temp == 1 || temp == 2)
return;
else if (totalvalue >= MAX_FACTION)
else if (totalvalue >= MAX_PERSONAL_FACTION)
Message_StringID(0, FACTION_BEST, name);
else if (tmpvalue > 0 && totalvalue < MAX_FACTION)
else if (tmpvalue > 0 && totalvalue < MAX_PERSONAL_FACTION)
Message_StringID(0, FACTION_BETTER, name);
else if (tmpvalue < 0 && totalvalue > MIN_FACTION)
else if (tmpvalue < 0 && totalvalue > MIN_PERSONAL_FACTION)
Message_StringID(0, FACTION_WORSE, name);
else if (totalvalue <= MIN_FACTION)
else if (totalvalue <= MIN_PERSONAL_FACTION)
Message_StringID(0, FACTION_WORST, name);
return;