mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 16:41:29 +00:00
Merge pull request #351 from noudess/master
Repair Faction System Messaging
This commit is contained in:
commit
6a43fd3b45
@ -0,0 +1,30 @@
|
|||||||
|
DELIMITER $$
|
||||||
|
|
||||||
|
use peqdb
|
||||||
|
|
||||||
|
CREATE DEFINER=`eqemu`@`%` PROCEDURE `MyFaction`(charname text)
|
||||||
|
BEGIN
|
||||||
|
declare class_mod text default "";
|
||||||
|
declare race_mod text default "";
|
||||||
|
declare deity_mod text default "";
|
||||||
|
|
||||||
|
select class into class_mod from character_data where name = charname;
|
||||||
|
select race into race_mod from character_data where name = charname;
|
||||||
|
select deity into deity_mod from character_data where name = charname;
|
||||||
|
select concat("c", class_mod) into class_mod;
|
||||||
|
select concat("r", race_mod) into race_mod;
|
||||||
|
select concat("d", deity_mod) into deity_mod;
|
||||||
|
|
||||||
|
set @class_bump := 0;
|
||||||
|
set @race_bump := 0;
|
||||||
|
set @deity_bump := 0;
|
||||||
|
|
||||||
|
SELECT race_mod as R, class_mod as C, deity_mod as D, f.name as faction, f.id, v.current_value, f.base as "START",
|
||||||
|
@class_bump := IFNULL((select m.mod from faction_list_mod m where faction_id = f.id && class_mod != "" && mod_name = class_mod),0) as class_bump,
|
||||||
|
@race_bump := IFNULL((select m.mod from faction_list_mod m where faction_id = f.id && race_mod != "" && mod_name = race_mod),0) as race_bump,
|
||||||
|
@deity_bump := IFNULL((select m.mod from faction_list_mod m where faction_id = f.id && race_mod != "" && mod_name = deity_mod),0) as deity_bump,
|
||||||
|
v.current_value + f.base + @class_bump + @race_bump + @deity_bump as TOTAL
|
||||||
|
FROM peqdb.faction_values v
|
||||||
|
inner join faction_list f on f.id = v.faction_id
|
||||||
|
where v.char_id = (select id from character_data where name=charname) ;
|
||||||
|
END
|
||||||
159
zone/client.cpp
159
zone/client.cpp
@ -7512,73 +7512,30 @@ void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, ui
|
|||||||
int32 faction_id[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 };
|
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 };
|
uint8 temp[MAX_NPC_FACTIONS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
int32 mod;
|
|
||||||
int32 tmpValue;
|
|
||||||
int32 current_value;
|
int32 current_value;
|
||||||
FactionMods fm;
|
|
||||||
bool change = false;
|
bool change = false;
|
||||||
bool repair = false;
|
|
||||||
|
|
||||||
// Get the npc faction list
|
// 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;
|
return;
|
||||||
for (int i = 0; i < MAX_NPC_FACTIONS; i++)
|
for (int i = 0; i < MAX_NPC_FACTIONS; i++)
|
||||||
{
|
{
|
||||||
|
int32 faction_before_hit;
|
||||||
|
int32 faction_to_use_for_messaging;
|
||||||
|
|
||||||
if (faction_id[i] <= 0)
|
if (faction_id[i] <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Get the faction modifiers
|
// Get the characters current value with that faction
|
||||||
if (database.GetFactionData(&fm, char_class, char_race, char_deity, faction_id[i]))
|
current_value = GetCharacterFactionLevel(faction_id[i]);
|
||||||
{
|
faction_before_hit = current_value;
|
||||||
// Get the characters current value with that faction
|
|
||||||
current_value = GetCharacterFactionLevel(faction_id[i]);
|
|
||||||
|
|
||||||
if (this->itembonuses.HeroicCHA)
|
change = UpdatePersonalFaction(char_id, npc_value[i], faction_id[i], ¤t_value, temp[i]);
|
||||||
|
|
||||||
|
if (change)
|
||||||
{
|
{
|
||||||
int faction_mod = itembonuses.HeroicCHA / 5;
|
SendFactionMessage(npc_value[i], faction_id[i], faction_before_hit, current_value, temp[i]);
|
||||||
// If our result isn't truncated, then just do that
|
|
||||||
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 (zone->random.Int(0, 100) < faction_mod)
|
|
||||||
npc_value[i] *= 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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;
|
|
||||||
|
|
||||||
current_value += npc_value[i];
|
|
||||||
|
|
||||||
if (current_value > MAX_PERSONAL_FACTION)
|
|
||||||
current_value = MAX_PERSONAL_FACTION;
|
|
||||||
else if (current_value < MIN_PERSONAL_FACTION)
|
|
||||||
current_value = MIN_PERSONAL_FACTION;
|
|
||||||
|
|
||||||
if (change || repair)
|
|
||||||
{
|
|
||||||
database.SetCharacterFactionLevel(char_id, faction_id[i], current_value, temp[i], factionvalues);
|
|
||||||
|
|
||||||
if (change)
|
|
||||||
{
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -7586,15 +7543,24 @@ void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, ui
|
|||||||
void Client::SetFactionLevel2(uint32 char_id, int32 faction_id, uint8 char_class, uint8 char_race, uint8 char_deity, int32 value, uint8 temp)
|
void Client::SetFactionLevel2(uint32 char_id, int32 faction_id, uint8 char_class, uint8 char_race, uint8 char_deity, int32 value, uint8 temp)
|
||||||
{
|
{
|
||||||
int32 current_value;
|
int32 current_value;
|
||||||
|
bool change=false;
|
||||||
|
|
||||||
//Get the npc faction list
|
//Get the npc faction list
|
||||||
if(faction_id > 0 && value != 0) {
|
if(faction_id > 0 && value != 0) {
|
||||||
//Get the faction modifiers
|
int32 faction_before_hit;
|
||||||
current_value = GetCharacterFactionLevel(faction_id) + value;
|
|
||||||
if(!(database.SetCharacterFactionLevel(char_id, faction_id, current_value, temp, factionvalues)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
SendFactionMessage(value, faction_id, current_value, temp);
|
//Get the faction modifiers
|
||||||
|
current_value = GetCharacterFactionLevel(faction_id);
|
||||||
|
faction_before_hit = current_value;
|
||||||
|
|
||||||
|
change = UpdatePersonalFaction(char_id, value, faction_id, ¤t_value, temp);
|
||||||
|
|
||||||
|
if (change)
|
||||||
|
{
|
||||||
|
SendFactionMessage(value, faction_id, faction_before_hit, current_value, temp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7609,6 +7575,58 @@ int32 Client::GetCharacterFactionLevel(int32 faction_id)
|
|||||||
return res->second;
|
return res->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Common code to set faction level.
|
||||||
|
// Applies HeroicCHA is it applies
|
||||||
|
// Checks for bottom out and max faction and old faction db entries
|
||||||
|
// Updates the faction if we are not minned, maxed or we need to repair
|
||||||
|
|
||||||
|
bool Client::UpdatePersonalFaction(int32 char_id, int32 npc_value, int32 faction_id, int32 *current_value, int32 temp)
|
||||||
|
{
|
||||||
|
bool repair = false;
|
||||||
|
bool change = false;
|
||||||
|
|
||||||
|
if (this->itembonuses.HeroicCHA)
|
||||||
|
{
|
||||||
|
int faction_mod = itembonuses.HeroicCHA / 5;
|
||||||
|
// If our result isn't truncated, then just do that
|
||||||
|
if (npc_value * faction_mod / 100 != 0)
|
||||||
|
npc_value += npc_value * 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 (zone->random.Int(0, 100) < faction_mod)
|
||||||
|
npc_value *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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 != 0) && ((*current_value != MAX_PERSONAL_FACTION) || (*current_value != MIN_PERSONAL_FACTION)))
|
||||||
|
change = true;
|
||||||
|
|
||||||
|
*current_value += npc_value;
|
||||||
|
|
||||||
|
if (*current_value > MAX_PERSONAL_FACTION)
|
||||||
|
*current_value = MAX_PERSONAL_FACTION;
|
||||||
|
else if (*current_value < MIN_PERSONAL_FACTION)
|
||||||
|
*current_value = MIN_PERSONAL_FACTION;
|
||||||
|
|
||||||
|
if (change || repair)
|
||||||
|
{
|
||||||
|
database.SetCharacterFactionLevel(char_id, faction_id, *current_value, temp, factionvalues);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (repair || change);
|
||||||
|
}
|
||||||
|
|
||||||
// returns the character's faction level, adjusted for racial, class, and deity modifiers
|
// returns the character's faction level, adjusted for racial, class, and deity modifiers
|
||||||
int32 Client::GetModCharacterFactionLevel(int32 faction_id) {
|
int32 Client::GetModCharacterFactionLevel(int32 faction_id) {
|
||||||
int32 Modded = GetCharacterFactionLevel(faction_id);
|
int32 Modded = GetCharacterFactionLevel(faction_id);
|
||||||
@ -7687,9 +7705,24 @@ void Client::MerchantRejectMessage(Mob *merchant, int primaryfaction)
|
|||||||
//o--------------------------------------------------------------
|
//o--------------------------------------------------------------
|
||||||
//| Purpose: Send faction change message to client
|
//| Purpose: Send faction change message to client
|
||||||
//o--------------------------------------------------------------
|
//o--------------------------------------------------------------
|
||||||
void Client::SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 totalvalue, uint8 temp)
|
void Client::SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 faction_before_hit, int32 totalvalue, uint8 temp)
|
||||||
{
|
{
|
||||||
char name[50];
|
char name[50];
|
||||||
|
int32 faction_value;
|
||||||
|
|
||||||
|
// If we're dropping from MAX or raising from MIN, we should
|
||||||
|
// base the message on the new updated value so we don't show
|
||||||
|
// a min MAX message
|
||||||
|
//
|
||||||
|
// If we're changing any other place, we use the value before the
|
||||||
|
// hit. For example, if we go from 1199 to 1200 which is the MAX
|
||||||
|
// we still want to say faction got better this time around.
|
||||||
|
|
||||||
|
if ( (faction_before_hit == MAX_PERSONAL_FACTION) ||
|
||||||
|
(faction_before_hit == MIN_PERSONAL_FACTION))
|
||||||
|
faction_value = totalvalue;
|
||||||
|
else
|
||||||
|
faction_value = faction_before_hit;
|
||||||
|
|
||||||
// default to Faction# if we couldn't get the name from the ID
|
// default to Faction# if we couldn't get the name from the ID
|
||||||
if (database.GetFactionName(faction_id, name, sizeof(name)) == false)
|
if (database.GetFactionName(faction_id, name, sizeof(name)) == false)
|
||||||
@ -7697,13 +7730,13 @@ void Client::SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 totalval
|
|||||||
|
|
||||||
if (tmpvalue == 0 || temp == 1 || temp == 2)
|
if (tmpvalue == 0 || temp == 1 || temp == 2)
|
||||||
return;
|
return;
|
||||||
else if (totalvalue >= MAX_PERSONAL_FACTION)
|
else if (faction_value >= MAX_PERSONAL_FACTION)
|
||||||
Message_StringID(15, FACTION_BEST, name);
|
Message_StringID(15, FACTION_BEST, name);
|
||||||
else if (totalvalue <= MIN_PERSONAL_FACTION)
|
else if (faction_value <= MIN_PERSONAL_FACTION)
|
||||||
Message_StringID(15, FACTION_WORST, name);
|
Message_StringID(15, FACTION_WORST, name);
|
||||||
else if (tmpvalue > 0 && totalvalue < MAX_PERSONAL_FACTION && !RuleB(Client, UseLiveFactionMessage))
|
else if (tmpvalue > 0 && faction_value < MAX_PERSONAL_FACTION && !RuleB(Client, UseLiveFactionMessage))
|
||||||
Message_StringID(15, FACTION_BETTER, name);
|
Message_StringID(15, FACTION_BETTER, name);
|
||||||
else if (tmpvalue < 0 && totalvalue > MIN_PERSONAL_FACTION && !RuleB(Client, UseLiveFactionMessage))
|
else if (tmpvalue < 0 && faction_value > MIN_PERSONAL_FACTION && !RuleB(Client, UseLiveFactionMessage))
|
||||||
Message_StringID(15, FACTION_WORSE, name);
|
Message_StringID(15, FACTION_WORSE, name);
|
||||||
else if (RuleB(Client, UseLiveFactionMessage))
|
else if (RuleB(Client, UseLiveFactionMessage))
|
||||||
Message(15, "Your faction standing with %s has been adjusted by %i.", name, tmpvalue); //New Live faction message (14261)
|
Message(15, "Your faction standing with %s has been adjusted by %i.", name, tmpvalue); //New Live faction message (14261)
|
||||||
|
|||||||
@ -606,8 +606,9 @@ public:
|
|||||||
int32 GetCharacterFactionLevel(int32 faction_id);
|
int32 GetCharacterFactionLevel(int32 faction_id);
|
||||||
int32 GetModCharacterFactionLevel(int32 faction_id);
|
int32 GetModCharacterFactionLevel(int32 faction_id);
|
||||||
void MerchantRejectMessage(Mob *merchant, int primaryfaction);
|
void MerchantRejectMessage(Mob *merchant, int primaryfaction);
|
||||||
void SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 totalvalue, uint8 temp);
|
void SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 faction_before_hit, int32 totalvalue, uint8 temp);
|
||||||
|
|
||||||
|
bool UpdatePersonalFaction(int32 char_id, int32 npc_value, int32 faction_id, int32 *current_value, int32 temp);
|
||||||
void SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity);
|
void SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity);
|
||||||
void SetFactionLevel2(uint32 char_id, int32 faction_id, uint8 char_class, uint8 char_race, uint8 char_deity, int32 value, uint8 temp);
|
void SetFactionLevel2(uint32 char_id, int32 faction_id, uint8 char_class, uint8 char_race, uint8 char_deity, int32 value, uint8 temp);
|
||||||
int32 GetRawItemAC();
|
int32 GetRawItemAC();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user