Purpose: Allow shops to have dynamic pricing based upon reputation and
persuasion skill
Usage: Place on the conversation node you want to activate your shop in the
Action Taken tab. Set the merchant tag to m_shopkeepertag, meaning if the
shopkeeper has the tag sellerocrap the merchant would then be tagged
m_sellerocrap. Dats it, if you have robust custom faction in place it works
great, if you pretty much ignoring faction I wouldn't reccomend use of it.
Notes: A#, C, E#
//:://///////
//:: FileName factionshopping
//::///////
//::///////
//:: Created By: Julian Hubbard
//:: Created On: 7/19/2002 12:52:47 PM
//::///////
int GetFactionMarkup(object oPC, object oShopkeeper)
{
int iFaction = GetReputation(oShopkeeper, oPC);
//SendMessageToPC(oPC, ("Faction: " + (IntToString(iFaction)))); //Debug
int iBonusMarkUp = 0;
if (iFaction >= 0 && iFaction < 11)
{
iBonusMarkUp = 500;
}
else if (iFaction >= 11 && iFaction <= 20)
{
iBonusMarkUp = 150;
}
else if (iFaction >= 21 && iFaction <= 30)
{
iBonusMarkUp = 120;
}
else if (iFaction >= 31 && iFaction <= 40)
{
iBonusMarkUp = 90;
}
else if (iFaction >= 41 && iFaction <= 50)
{
iBonusMarkUp = 70;
}
else if (iFaction >= 51 && iFaction <= 60)
{
iBonusMarkUp = 50;
}
else if (iFaction >= 61 && iFaction <= 70)
{
iBonusMarkUp = 35;
}
else if (iFaction >= 71 && iFaction <= 80)
{
iBonusMarkUp = 25;
}
else if (iFaction >= 81 && iFaction <= 90)
{
iBonusMarkUp = 15;
}
else if (iFaction >= 91 && iFaction <= 100)
{
iBonusMarkUp = 10;
}
else
{
iBonusMarkUp = 1000;
}
//SendMessageToPC(oPC, ("Faction Markup in function: " + (IntToString(iBonusMarkUp))));
//Debug
return iBonusMarkUp;
}
int GetHaggleBonus(object oPC, object oShopkeeper)
{
int iHaggleSkill = GetSkillRank(SKILL_PERSUADE, oPC);
int iHaggleBonus = GetAbilityModifier(ABILITY_CHARISMA, oPC);
int iMerchantSkill = GetSkillRank(SKILL_PERSUADE, oShopkeeper);
int iMerchantBonus = GetAbilityModifier(ABILITY_CHARISMA, oShopkeeper);
int iPCTest = iHaggleSkill + iHaggleBonus + d20(1);
float fPCTest = IntToFloat(iPCTest);
int iNPCTest = iMerchantSkill + iMerchantBonus + d20(1);
float fNPCTest = IntToFloat(iNPCTest);
float fTestResults = (fNPCTest - fPCTest)/2;
int iTestResults = FloatToInt(fTestResults);
return iTestResults;
}
void main()
{
object oPC = GetPCSpeaker();
object oShopkeeper = OBJECT_SELF;
string sShopkeeperTag = GetTag(oShopkeeper);
//SendMessageToPC(oPC, ("Shopkeeper Tag: " + sShopkeeperTag)); //Debug
string sWhichShop = ("m_" + sShopkeeperTag);
object oWhichStore = GetObjectByTag(sWhichShop);
//SendMessageToPC(oPC, ("Shop: " + sWhichShop)); //Debug
int iFactionMarkup = GetFactionMarkup(oPC, oShopkeeper);
//SendMessageToPC(oPC, ("Faction Markup in main: " + (IntToString(iFactionMarkup))));
//Debug
int iHaggleBonus = GetHaggleBonus(oPC, oShopkeeper);
//SendMessageToPC(oPC, ("Haggle Markup: " + (IntToString(iHaggleBonus))));
//Debug
int iBonusMarkup = iFactionMarkup + iHaggleBonus;
//SendMessageToPC(oPC, ("Computed Markup: " + (IntToString(iBonusMarkup))));
//Debug
if(iBonusMarkup < 5)
{
iBonusMarkup = 5;
}
//SendMessageToPC(oPC, ("Final Markup: " + (IntToString(iBonusMarkup))));
//Debug
OpenStore(oWhichStore, oPC, iBonusMarkup, iBonusMarkup); //Real version
//OpenStore(oWhichStore, oPC); //Debug version
}