Example #1
0
//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;
}
Example #2
0
//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;
}
Example #3
0
//o--------------------------------------------------------------
//| Name: GetFactionLevel; rembrant, Dec. 16, 2001
//o--------------------------------------------------------------
//| Notes: Gets the characters faction standing with the
//|        specified NPC.
//|        Will return Indifferent on failure.
//o--------------------------------------------------------------
FactionLevels Client::GetFactionLevel(int32 char_id, int32 npc_id, int32 p_race, int32 p_class, int32 p_deity, int32 pFaction)
{
    sint32 pFacValue;
    sint32 tmpFactionValue;
    FactionMods fmods;
    //First get the NPC's Primary faction
    if (GetFeigned() || GetHide())
        return FACTION_INDIFFERENT;
    if(pFaction != 0)
    {
        //Get the faction data from the database
        if(database.GetFactionData(&fmods, p_class, p_race, p_deity, pFaction))
        {
            //Get the players current faction with pFaction
            tmpFactionValue = this->GetCharacterFactionLevel(pFaction);
            //Return the faction to the client
            return CalculateFaction(&fmods, tmpFactionValue);
        }
    }

    return FACTION_INDIFFERENT;
}
Example #4
0
//o--------------------------------------------------------------
//| Name: GetFactionLevel; rembrant, Dec. 16, 2001
//o--------------------------------------------------------------
//| Notes: Gets the characters faction standing with the
//|        specified NPC.
//|        Will return Indifferent on failure.
//o--------------------------------------------------------------
FACTION_VALUE Client::GetFactionLevel(int32 char_id, int32 npc_id, int32 p_race, int32 p_class, int32 p_deity, sint32 pFaction, Mob* tnpc)
{
	if (pFaction < 0)
		return GetSpecialFactionCon(tnpc);
	FACTION_VALUE fac = FACTION_INDIFFERENT;
	//sint32 pFacValue;  -Trumpcard: commenting. Not currently used.
	sint32 tmpFactionValue;
	FactionMods fmods;

    // neotokyo: few optimizations
    if (GetFeigned())
		return FACTION_INDIFFERENT;
    if (invisible_undead && tnpc && !tnpc->SeeInvisibleUndead())
        return FACTION_INDIFFERENT;
    if (IsInvisible(tnpc))
		return FACTION_INDIFFERENT;
    if (tnpc && tnpc->GetOwnerID() != 0) // neotokyo: pets always con indiff
        return FACTION_INDIFFERENT;
#ifdef GUILDWARS
	if(tnpc && tnpc->IsNPC() && tnpc->CastToNPC()->GetGuildOwner() != 0 && GuildDBID() != 0)
	{
		if(IsAttackAllowed(tnpc))
			return FACTION_SCOWLS;
		else
			return FACTION_ALLY;
	}
#endif

    //First get the NPC's Primary faction
	if(pFaction > 0)
	{
		//Get the faction data from the database
		if(database.GetFactionData(&fmods, p_class, p_race, p_deity, pFaction))
		{
			//Get the players current faction with pFaction
			tmpFactionValue = this->GetCharacterFactionLevel(pFaction);
			//Return the faction to the client
			fac = CalculateFaction(&fmods, tmpFactionValue);
			//Message(0,"Faction: %i %i %i %i",fmods.base,fmods.class_mod,fmods.race_mod,fmods.deity_mod);
			//Message(0,"tmpFactionValue: %i, fac: %i",tmpFactionValue,fac);
		}
	}
	else
    {
        fmods.base = 0;
        fmods.deity_mod = 0;

        if (tnpc && p_class == (int32) tnpc->GetClass()%16)
            fmods.class_mod = 301;
        else if (tnpc && tnpc->IsNPC() && tnpc->CastToNPC()->MerchantType == 0)
            fmods.class_mod = -101;
        else
            fmods.class_mod = 0;

        if (tnpc && IsOfEqualRace(p_race, tnpc->GetRace()) )
            fmods.race_mod = 101;
        else if (tnpc && IsOfIndiffRace(p_race, tnpc->GetRace()) )
            fmods.race_mod = 0;
        else if (tnpc)
            fmods.race_mod = -51;
        else
            fmods.race_mod = 0;
        fac = CalculateFaction(&fmods, 0);
    }

    // merchant fix
    if (tnpc && tnpc->IsNPC() && tnpc->CastToNPC()->MerchantType && (fac == FACTION_THREATENLY || fac == FACTION_SCOWLS))
        fac = FACTION_DUBIOUS;

	if (tnpc != 0 && fac != FACTION_SCOWLS && tnpc->CastToNPC()->CheckAggro(this))
		fac = FACTION_THREATENLY;

	return fac;
}