Rune_PRC8/_module/nss/b2_hbs_auction.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

446 lines
16 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name(B2) Auction Heart Beat Script
//:: FileName
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
this is the heartbeat script that controlls the auction.
*/
//:://////////////////////////////////////////////
//:: Created By: Donny Wilbanks
//:: Created On: 10/10/02
//:://////////////////////////////////////////////
// *********************
// ***
// *** Starting Percentage
// ***
// *** Defualt is 0.35 or 35% of the items true value in gold. Increasing or
// *** decrease this amount as suited to your campaign.
// ***
float start_per = 0.35;
void B2_BASICWANT(object oPlayer)
{
int vWantsItem = d100();
int iBidsLeft = d10();
SetLocalInt(oPlayer,"B2_AuctionWantsItem",vWantsItem);
SetLocalInt(oPlayer,"B2_AuctionBidsLeft",iBidsLeft);
SetLocalInt(oPlayer,"B2_AuctionDidIBid",FALSE);
}
void B2_BID(object oPlayer)
{
int vBidRoll = d100();
int iBidsLeft = GetLocalInt(oPlayer,"B2_AuctionBidsLeft");
int vWantsItem = GetLocalInt(oPlayer,"B2_AuctionWantsItem");
object oLastBidder = GetLocalObject(OBJECT_SELF,"B2_LASTBIDDER");
if (vBidRoll<vWantsItem && iBidsLeft>0 && oLastBidder!=oPlayer)
{
SetLocalInt(oPlayer,"B2_AuctionDidIBid",TRUE);
SetLocalObject(OBJECT_SELF,"B2_LASTBIDDER",oPlayer);
int vWantsItem = GetLocalInt(oPlayer,"B2_AuctionWantsItem");
SetLocalInt(oPlayer,"B2_AuctionWantsItem",vWantsItem);
iBidsLeft--;
SetLocalInt(oPlayer,"B2_AuctionBidsLeft",iBidsLeft);
}
int vRound = GetLocalInt(OBJECT_SELF,"B2_AuctionRound");
string sTag = GetTag(oPlayer);
if (sTag == "ASGBUYER_03" && vRound==2)
{
// Wolf Family Specail to make sure there is a last bidder.
if (vRound==2)
{
SetLocalInt(oPlayer,"B2_AuctionDidIBid",TRUE);
SetLocalObject(OBJECT_SELF,"B2_LASTBIDDER",oPlayer);
}
}
}
int B2_BIDDERSLEFT(object oPlayer)
{
int iResult = FALSE;
int vDidIBid = GetLocalInt(oPlayer,"B2_AuctionDidIBid");
if (vDidIBid == TRUE)
{
iResult = TRUE;
}
return iResult;
}
void B2_BIDANIMATION (object oPlayer)
{
int vAnin = ANIMATION_FIREFORGET_VICTORY1;
int vVoice = VOICE_CHAT_YES;
switch(d3())
{
case(1): vAnin = ANIMATION_FIREFORGET_VICTORY1; break;
case(2): vAnin = ANIMATION_FIREFORGET_VICTORY2; break;
case(3): vAnin = ANIMATION_FIREFORGET_VICTORY3; break;
}
AssignCommand(oPlayer,ActionSpeakString("BID!"));
DelayCommand(3.0,AssignCommand(oPlayer,PlayAnimation(vAnin,1.0,3.0)));
switch(d3())
{
case(1): vVoice = VOICE_CHAT_THANKS; break;
case(2): vVoice = VOICE_CHAT_CANDO; break;
case(3): vVoice = VOICE_CHAT_GOODIDEA; break;
}
PlayVoiceChat(vVoice,oPlayer);
}
void B2_RESETBIDDERS(object oPlayer)
{
SetLocalInt(oPlayer,"B2_AuctionDidIBid",FALSE);
}
void B2_AUCTION()
{
int vRound = GetLocalInt(OBJECT_SELF,"B2_AuctionRound");
object oAuctioneer = GetNearestObjectByTag("DMrGAuctioneer");
object oA1 = GetNearestObjectByTag("ASGBUYER_01");
object oA2 = GetNearestObjectByTag("ASGBUYER_02");
object oA3 = GetNearestObjectByTag("ASGBUYER_03");
object oA4 = GetNearestObjectByTag("ASGBUYER_04");
object oA5 = GetNearestObjectByTag("ASGBUYER_05");
object oA6 = GetNearestObjectByTag("ASGBUYER_06");
object oA7 = GetNearestObjectByTag("ASGBUYER_07");
object oA8 = GetNearestObjectByTag("ASGBUYER_08");
object oA9 = GetNearestObjectByTag("ASGBUYER_09");
if (vRound<1)
{
object oCChest = GetNearestObjectByTag("ASG_CCHEST");
object oItem = GetFirstItemInInventory(oCChest);
if (GetIsObjectValid(oItem))
{
SetIdentified(oItem,TRUE);
B2_BASICWANT(oA1);
B2_BASICWANT(oA2);
B2_BASICWANT(oA3);
B2_BASICWANT(oA4);
B2_BASICWANT(oA5);
string sName = GetName(oItem);
int vGPValue = GetGoldPieceValue(oItem);
float fBid = start_per;
SetLocalFloat(OBJECT_SELF,"B2_AuctionBidPerc",fBid);
float fBidValue = IntToFloat(vGPValue);
fBidValue=fBidValue*fBid;
int vBid = FloatToInt(fBidValue);
SetLocalInt(OBJECT_SELF,"B2_AuctionBid",vBid);
vRound++;
SetLocalInt(OBJECT_SELF,"B2_AuctionRound",vRound);
}
else
{
AssignCommand(oAuctioneer,ActionSpeakString("This Auction is Over."));
}
}
if (vRound==1)
{
vRound++;
SetLocalInt(OBJECT_SELF,"B2_AuctionRound",vRound);
object oCChest = GetNearestObjectByTag("ASG_CCHEST");
object oItem = GetFirstItemInInventory(oCChest);
object oOwner = GetLocalObject(oItem,"B2_AuctionOwner");
if (GetIsObjectValid(oOwner)==FALSE)
{
SetLocalObject(oItem,"B2_AuctionOwner",oAuctioneer);
}
int vBid = GetLocalInt(OBJECT_SELF,"B2_AuctionBid");
string sSellersName = GetName(oOwner);
string sLine;
string sItemName= GetName(oItem);
switch(d4())
{
case(1):
{
sLine = "Well, "+sSellersName+" has brought us this fine "+sItemName+", Let's start he bidding at "+IntToString(vBid)+" gold.";
}
break;
case(2):
{
sLine = "Now this custom "+sItemName+" is part of the "+sSellersName+" Collection. The bidding starts at "+IntToString(vBid)+" gold.";
}
break;
case(3):
{
sLine = "Ahh, this once in a life time "+sItemName+" was brought to us by "+sSellersName+". The bidding starts at he battle is "+IntToString(vBid)+" gold.";
}
case(4):
{
sLine = sSellersName+" knows you want this prise "+sItemName+", it could be yours for only "+IntToString(vBid)+" gold.";
}
break;
}
AssignCommand(oAuctioneer,ActionSpeakString(sLine));
}
if (vRound>0)
{
int vCount = 0;
object oCChest = GetNearestObjectByTag("ASG_CCHEST");
object oItem = GetFirstItemInInventory(oCChest);
int vBid = GetLocalInt(OBJECT_SELF,"B2_AuctionBid");
string sItemName = GetName(oItem);
/*
int iIBid = FALSE;
B2_BID(oA1);int vBidder = B2_BIDDERSLEFT(oA1);
if (vBidder == TRUE)
{
vCount++;iIBid=TRUE;
} else if (iBid==FALSE)
{
B2_BID(oA2);vBidder = B2_BIDDERSLEFT(oA2);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
} else if (iBid==FALSE)
{
B2_BID(oA3);vBidder = B2_BIDDERSLEFT(oA3);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
} else if (iBid==FALSE)
{
B2_BID(oA4);vBidder = B2_BIDDERSLEFT(oA4);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
} else if (iBid==FALSE)
{
B2_BID(oA5);vBidder = B2_BIDDERSLEFT(oA5);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
}else if (iBid==FALSE)
{
B2_BID(oA6);vBidder = B2_BIDDERSLEFT(oA6);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
} else if (iBid==FALSE)
{
B2_BID(oA7);vBidder = B2_BIDDERSLEFT(oA7);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
} else if (iBid==FALSE)
{
B2_BID(oA8);vBidder = B2_BIDDERSLEFT(oA8);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
} else if (iBid==FALSE)
{
B2_BID(oA9);vBidder = B2_BIDDERSLEFT(oA9);
if (vBidder == TRUE)
{
vCount++; iBid=TRUE;
}
}
*/
B2_BID(oA1);
B2_BID(oA2);
B2_BID(oA3);
B2_BID(oA4);
B2_BID(oA5);
B2_BID(oA6);
B2_BID(oA7);
B2_BID(oA8);
B2_BID(oA9);
// Is there more than one Bidder left?
int vBidder = B2_BIDDERSLEFT(oA1);
if (vBidder == TRUE) vCount++;
vBidder = B2_BIDDERSLEFT(oA3);
if (vBidder == TRUE) vCount++;
vBidder = B2_BIDDERSLEFT(oA4);
if (vBidder == TRUE) vCount++;
vBidder = B2_BIDDERSLEFT(oA5);
if (vBidder == TRUE) vCount++;
vBidder = B2_BIDDERSLEFT(oA6);
if (vBidder == TRUE) vCount++;
vBidder = B2_BIDDERSLEFT(oA7);
if (vBidder == TRUE) vCount++;
vBidder = B2_BIDDERSLEFT(oA8);
if (vBidder == TRUE) vCount++;
vBidder = B2_BIDDERSLEFT(oA9);
if (vBidder == TRUE) vCount++;
// Play Animations & for Bidders.
{
int vBidder = B2_BIDDERSLEFT(oA1);
if (vBidder == TRUE) DelayCommand(3.0,B2_BIDANIMATION(oA1));
vBidder = B2_BIDDERSLEFT(oA2);
if (vBidder == TRUE) DelayCommand(3.0,B2_BIDANIMATION(oA2));
vBidder = B2_BIDDERSLEFT(oA3);
if (vBidder == TRUE) DelayCommand(3.0,B2_BIDANIMATION(oA3));
vBidder = B2_BIDDERSLEFT(oA4);
if (vBidder == TRUE) DelayCommand(3.0,B2_BIDANIMATION(oA4));
vBidder = B2_BIDDERSLEFT(oA5);
if (vBidder == TRUE) DelayCommand(3.0,B2_BIDANIMATION(oA5));
}
if (vCount==0)
{
int iGoing = GetLocalInt(OBJECT_SELF,"b2_Going");iGoing++;
SetLocalInt(OBJECT_SELF,"b2_Going",iGoing);
string sText;
object oLastBidder = GetLocalObject(OBJECT_SELF,"B2_LASTBIDDER");
switch (iGoing)
{
case(1): sText= "Going Once to "+GetName(oLastBidder)+"!";break;
case(2): sText= "Going Twice to "+GetName(oLastBidder)+"!";break;
case(3): sText= "Going Three Times to "+GetName(oLastBidder)+"!";break;
}
if (iGoing>3)
{
object oOwner = GetLocalObject(oItem,"B2_AuctionOwner");
object oLastBidder = GetLocalObject(OBJECT_SELF,"B2_LASTBIDDER");
int iStartOver=FALSE;
object oPlayer = oLastBidder;
if (GetIsPC(oLastBidder))
{
vBid = GetLocalInt(OBJECT_SELF,"B2_LastAuctionBid");
int vGold = GetGold(oPlayer);
if (vGold >= vBid)
{
int vFinalPrice = vBid - (FloatToInt(vBid*0.10));
TakeGoldFromCreature(vBid,oPlayer,TRUE);
string sTag = GetTag(oItem);
string sBluePrint = GetResRef(oItem);
SendMessageToPC(oPlayer,"**** $$$$$$$$$$$$ ******");
SendMessageToPC(oPlayer,"You have won the Bid!");
SendMessageToPC(oPlayer,"**** $$$$$$$$$$$$ ******");
int vNum = GetNumStackedItems(oItem);
if (vNum<1) vNum = 1;
object oNewItem = CreateItemOnObject(sBluePrint,oPlayer,1);
SetIdentified(oNewItem,TRUE);
if (oOwner!=oLastBidder) TakeGoldFromCreature(vFinalPrice,oPlayer,FALSE);
}
else
{
SendMessageToPC(oPlayer,"!!! You don't have enough money !!!");
iStartOver=TRUE;
}
}
if (iStartOver==FALSE)
{
string sName = GetName(oLastBidder);
string sItemName = GetName(oItem);
DelayCommand(3.0,AssignCommand(oAuctioneer,ActionSpeakString("*$* Sold "+GetName(oOwner)+"'s "+sItemName+" to "+sName+" for "+IntToString(vBid)+" gp. *$*")));
object oOwner = GetLocalObject(oItem,"B2_AuctionOwner");
int vFinalPrice = vBid - (FloatToInt(vBid*0.10));
if (oOwner != oLastBidder)
{
GiveGoldToCreature(oOwner,vFinalPrice);
SendMessageToPC(oOwner,"**** $$$$$$$$$$$$ ******");
SendMessageToPC(oOwner,GetName(oItem)+" Sold! SBTC taking 10%.");
SendMessageToPC(oOwner,"**** $$$$$$$$$$$$ ******");
}
else
{
if (GetIsPC(oLastBidder) && oOwner == oLastBidder)
{
string sBluePrint = GetResRef(oItem);
SendMessageToPC(oPlayer,"!!! The item was yours, SBTC still takes 10%.");
GiveGoldToCreature(oOwner,vFinalPrice);
}
}
DelayCommand(3.25,DestroyObject(oItem));
SetLocalInt(OBJECT_SELF,"B2_AuctionRound",0);
SetLocalInt(OBJECT_SELF,"b2_Going",0);
}
else
{
SetLocalInt(OBJECT_SELF,"B2_AuctionRound",0);
SetLocalInt(OBJECT_SELF,"b2_Going",0);
}
}
else
{
AssignCommand(oAuctioneer,ActionSpeakString(sText));
vRound++;
SetLocalInt(OBJECT_SELF,"B2_AuctionRound",vRound);
B2_RESETBIDDERS(oA1);
B2_RESETBIDDERS(oA2);
B2_RESETBIDDERS(oA3);
B2_RESETBIDDERS(oA4);
B2_RESETBIDDERS(oA5);
B2_RESETBIDDERS(oA6);
B2_RESETBIDDERS(oA7);
B2_RESETBIDDERS(oA8);
B2_RESETBIDDERS(oA9);
}
}
else
{
int vGPValue = GetGoldPieceValue(oItem);
float fBid = GetLocalFloat(OBJECT_SELF,"B2_AuctionBidPerc");
int vIncrease = d10();
float fIncrease = IntToFloat(vIncrease)*0.01;
fBid=fBid+fIncrease;
SetLocalInt(OBJECT_SELF,"B2_LastAuctionBid",GetLocalInt(OBJECT_SELF,"B2_AuctionBid"));
SetLocalFloat(OBJECT_SELF,"B2_AuctionBidPerc",fBid);
float fBidValue = IntToFloat(vGPValue);
fBidValue=fBidValue*fBid;
int vBid = FloatToInt(fBidValue);
SetLocalInt(OBJECT_SELF,"B2_AuctionBid",vBid);
vRound++;
SetLocalInt(OBJECT_SELF,"B2_AuctionRound",vRound);
SetLocalInt(OBJECT_SELF,"b2_Going",0);
DelayCommand(5.0,AssignCommand(oAuctioneer,ActionSpeakString("Do I here "+IntToString(vBid)+" gold.")));
B2_RESETBIDDERS(oA1);
B2_RESETBIDDERS(oA2);
B2_RESETBIDDERS(oA3);
B2_RESETBIDDERS(oA4);
B2_RESETBIDDERS(oA5);
B2_RESETBIDDERS(oA6);
B2_RESETBIDDERS(oA7);
B2_RESETBIDDERS(oA8);
B2_RESETBIDDERS(oA9);
}
}
}
void main()
{
object oAuctioneer = GetNearestObjectByTag("DMrGAuctioneer");
if(GetIsObjectValid(oAuctioneer))
{
int vAStarted = GetLocalInt(oAuctioneer,"B2_AUCTIONSTATUS");
if (vAStarted == TRUE)
{
object oCChest = GetNearestObjectByTag("ASG_CCHEST");
if (GetIsObjectValid(oCChest))
{
object oItem = GetFirstItemInInventory(oCChest);
if (GetIsObjectValid(oItem))
{
B2_AUCTION();
}
else
{
AssignCommand(oAuctioneer,ActionSpeakString("This auction is over. All items have been sold."));
SetLocalInt(oAuctioneer,"B2_AUCTIONSTATUS",FALSE);
}
}
// Set up Acutioneers
}
}
}
// New Bidding Routine