generated from Jaysyn/ModuleTemplate
Initial upload
Initial upload.
This commit is contained in:
29
_module/nss/calcmodvalue2.nss
Normal file
29
_module/nss/calcmodvalue2.nss
Normal file
@@ -0,0 +1,29 @@
|
||||
void main()
|
||||
{
|
||||
object oPC = GetPCSpeaker();
|
||||
object oItem = GetLocalObject(oPC, "MODIFY_ITEM");
|
||||
object oCopy = GetLocalObject(oPC, "MODIFY_COPY");
|
||||
SetCustomToken(102, IntToString(GetGold(oPC)));
|
||||
|
||||
//Get values of original item and modified copy, then destroy copy
|
||||
int iCurrentValue = GetGoldPieceValue(oItem);
|
||||
int iNewValue = GetGoldPieceValue(oCopy);
|
||||
DestroyObject(oCopy);
|
||||
|
||||
//Either amount to pay, refund or no change
|
||||
int iValue = 0;
|
||||
int iDiff = 0;
|
||||
if (iNewValue > iCurrentValue)
|
||||
{
|
||||
iValue = iNewValue - iCurrentValue;
|
||||
iDiff = 1; //iValue is amount to pay
|
||||
}
|
||||
else if (iNewValue < iCurrentValue)
|
||||
{
|
||||
iValue = iCurrentValue - iNewValue;
|
||||
iDiff = -1; //iValue is refund
|
||||
};
|
||||
SetLocalInt(oPC, "MODIFY_VALUE", iValue);
|
||||
SetLocalInt(oPC, "MODIFY_DIFF", iDiff);
|
||||
SetCustomToken(101, IntToString(iValue));
|
||||
}
|
||||
Reference in New Issue
Block a user