本文整理汇总了C++中Database::GetNPCFactionList方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::GetNPCFactionList方法的具体用法?C++ Database::GetNPCFactionList怎么用?C++ Database::GetNPCFactionList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::GetNPCFactionList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFactionLevel
//o--------------------------------------------------------------
//| Name: SetFactionLevel; rembrant, Dec. 20, 2001
//o--------------------------------------------------------------
//| Notes: Sets the characters faction standing with the
//| specified NPC.
//o--------------------------------------------------------------
void Client::SetFactionLevel(int32 char_id, int32 npc_id, int8 char_class, int8 char_race, int8 char_deity)
{
sint32 faction_id[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 };
sint32 npc_value[MAX_NPC_FACTIONS]={ 0,0,0,0,0,0,0,0,0,0 };
sint32 tmpValue;
sint32 current_value;
FactionMods fm;
//Get the npc faction list
if(database.GetNPCFactionList(npc_id, faction_id, npc_value))
{
for(int i = 0;i<MAX_NPC_FACTIONS;i++)
{
if(faction_id[i] > 0)
{
//Get the faction modifiers
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]) + npc_value[i];
//Calculate the faction
tmpValue = current_value + fm.base + fm.class_mod + fm.race_mod + fm.deity_mod;
//Make sure faction hits don't go to GMs...
//if(pp.gm==1 && (tmpValue < current_value)) {
// tmpValue=current_value;
//}
//Make sure we dont go over the min/max faction limits
if(tmpValue >= MAX_FACTION)
{
if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], MAX_FACTION,&factionvalue_list)))
{
return;
}
}
else if(tmpValue <= MIN_FACTION)
{
if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], MIN_FACTION,&factionvalue_list)))
{
return;
}
}
else
{
if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], current_value,&factionvalue_list)))
{
return;
}
}
if(tmpValue <= MIN_FACTION) tmpValue = MIN_FACTION;
//ChannelMessageSend(0,0,7,0,BuildFactionMessage(npc_value[i], faction_id[i]));
char* msg = BuildFactionMessage(npc_value[i],faction_id[i],tmpValue);
if (msg != 0)
Message(0, msg);
safe_delete(msg);
}
}
}
}
return;
}
示例2: SetFactionLevel
//o--------------------------------------------------------------
//| Name: SetFactionLevel; rembrant, Dec. 20, 2001
//o--------------------------------------------------------------
//| Notes: Sets the characters faction standing with the
//| specified NPC.
//o--------------------------------------------------------------
void Client::SetFactionLevel(int32 char_id, int32 npc_id, int8 char_class, int8 char_race, int8 char_deity)
{
int32 faction_id[]= { 0,0,0,0,0,0,0,0,0,0 };
sint32 npc_value[]= { 0,0,0,0,0,0,0,0,0,0 };
sint32 tmpValue;
sint32 current_value;
FactionMods fm;
//Get the npc faction list
if(database.GetNPCFactionList(npc_id, faction_id, npc_value))
{
for(int i = 0; i<=9; i++)
{
if(faction_id[i] != 0)
{
//Get the faction modifiers
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]) + npc_value[i];
//Calculate the faction
tmpValue = current_value + fm.base + fm.class_mod + fm.race_mod + fm.deity_mod;
//Make sure we dont go over the min/max faction limits
if(tmpValue >= MAX_FACTION)
{
tmpValue = MAX_FACTION;
}
if(tmpValue < MAX_FACTION && tmpValue > MIN_FACTION)
{
if(!(database.SetCharacterFactionLevel(char_id, faction_id[i], current_value,&factionvalue_list)))
{
return;
}
}
if(tmpValue <= MIN_FACTION)
{
tmpValue = MIN_FACTION;
}
//ChannelMessageSend(0,0,7,0,BuildFactionMessage(npc_value[i], faction_id[i]));
Message(0,BuildFactionMessage(npc_value[i],faction_id[i]));
}
}
}
}
return;
}
示例3: GetNPCFactionList
//o--------------------------------------------------------------
//| Name: GetNPCFactionList; rembrant, Dec. 16, 2001
//o--------------------------------------------------------------
//| Purpose: Gets a list of faction_id's and values bound to
//| the npc_id.
//| Returns false on failure.
//o--------------------------------------------------------------
bool Database::GetNPCFactionList(int32 npcfaction_id, sint32* faction_id, sint32* value, sint32* primary_faction) {
if (npcfaction_id <= 0) {
if (primary_faction)
*primary_faction = npcfaction_id;
return true;
}
const NPCFactionList* nfl = database.GetNPCFactionList(npcfaction_id);
if (!nfl)
return false;
if (primary_faction)
*primary_faction = nfl->primaryfaction;
for (int i=0; i<MAX_NPC_FACTIONS; i++) {
faction_id[i] = nfl->factionid[i];
value[i] = nfl->factionvalue[i];
}
return true;
/* char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
int i = 0;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT faction_id, value FROM npc_faction WHERE npc_id = %i", npc_id), errbuf, &result)) {
delete[] query;
while ((row = mysql_fetch_row(result)))
{
faction_id[i] = atoi(row[0]);
value[i] = atoi(row[1]);
i++;
if (i >= MAX_NPC_FACTIONS) {
cerr << "Error in GetNPCFactionList: More than MAX_NPC_FACTIONS factions returned" << endl;
break;
}
}
mysql_free_result(result);
return true;
}
else
{
cerr << "Error in GetNPCFactionList query '" << query << "' " << errbuf << endl;
delete[] query;
}
return false;
*/
}