| Author: | Julian Hubbard |
| Author Website: | n/a |
| Script Name: | Reputation and Persuasion Adjusted Merchants |
| Description: | Opens a shop with prices adjusted by PCs reputation with the shopkeeper's faction and a contested persuade test. |
| Instructions on Use: | Set the shop tag to m_ plus the shopkeeper's tag, for example if the
shopkeeper had a tag of "sellerocrap" the shop tag would be set to "m_sellerocrap"
in order for the script to find it. Place this script as the "action taken"
script for the conversation node you want to open the shop. When a PC shops at a store running this script it will get their reputation with the store owner/shopkeeper and set a base markup bonus. It will then do a contested persuade test between the shopkeeper and the PC and adjust the markup bonus in favor of the winner. It will then open the store with the markup and markdown it has computed. I considered adding a penalty for being of a different race but decided that was already taken into account if you have a robust faction system since it already takes charisma modifier into account. |
Script 1:
| //:://///////////////////////////////////////////// //:: FileName factionshopping //::////////////////////////////////////////////// //::////////////////////////////////////////////// //:: Created By: Julian Hubbard //:: Created On: 7/19/2002 12:52:47 PM //::////////////////////////////////////////////// //:: Place in the "action taken" script for //:: conversation node which you want to open shop //:://///////////////////////////////////////////// // Either open the store with that tag or let the user know that no store exists. 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 } |