Skip to content

Commit

Permalink
No changes, just the script classes being organized in their own sour…
Browse files Browse the repository at this point in the history
…ce and header files
  • Loading branch information
kewinrausch committed Aug 16, 2024
1 parent 6296e2e commit 62bb00f
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 164 deletions.
15 changes: 12 additions & 3 deletions src/AuctionHouseBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,29 @@ uint32 AuctionHouseBot::getStackCount(uint32 max)

if (DivisibleStacks)
{
uint32 ret = 0;

if (max % 5 == 0) // 5, 10, 15, 20
{
return urand(1, 4) * 5;
ret = urand(1, 4) * 5;
}

if (max % 4 == 0) // 4, 8, 12, 16
{
return urand(1, 4) * 4;
ret = urand(1, 4) * 4;
}

if (max % 3 == 0) // 3, 6, 9
{
return urand(1, 3) * 3;
ret = urand(1, 3) * 3;
}

if (ret > max)
{
ret = max;
}

return ret;
}

//
Expand Down
4 changes: 2 additions & 2 deletions src/AuctionHouseBot.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include "AuctionHouseBotConfig.h"

struct AuctionEntry;
class Player;
class WorldSession;
class Player;
class WorldSession;

class AuctionHouseBot
{
Expand Down
84 changes: 84 additions & 0 deletions src/AuctionHouseBotAuctionHouseScript.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include "AuctionHouseBot.h"
#include "AuctionHouseBotAuctionHouseScript.h"

AHBot_AuctionHouseScript::AHBot_AuctionHouseScript() : AuctionHouseScript("AHBot_AuctionHouseScript")
{

}

void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(
AuctionHouseMgr*, /*auctionHouseMgr*/
AuctionEntry*, /*auction*/
Player* owner,
uint32&, /*owner_accId*/
uint32&, /*profit*/
bool& sendNotification,
bool& updateAchievementCriteria,
bool& /*sendMail*/)
{
if (owner && owner->GetGUID().GetCounter() == auctionbot->GetAHBplayerGUID())
{
sendNotification = false;
updateAchievementCriteria = false;
}
}

void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrSendAuctionExpiredMail(
AuctionHouseMgr*, /* auctionHouseMgr */
AuctionEntry*, /* auction */
Player* owner,
uint32&, /* owner_accId */
bool& sendNotification,
bool& /* sendMail */)
{
if (owner && owner->GetGUID().GetCounter() == auctionbot->GetAHBplayerGUID())
{
sendNotification = false;
}
}

void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(
AuctionHouseMgr*, /* auctionHouseMgr */
AuctionEntry* auction,
Player* oldBidder,
uint32&, /* oldBidder_accId */
Player* newBidder,
uint32& newPrice,
bool&, /* sendNotification */
bool& /* sendMail */)
{
if (oldBidder && !newBidder)
{
oldBidder->GetSession()->SendAuctionBidderNotification(
auction->GetHouseId(),
auction->Id,
ObjectGuid::Create<HighGuid::Player>(auctionbot->GetAHBplayerGUID()),
newPrice,
auction->GetAuctionOutBid(),
auction->item_template);
}
}

void AHBot_AuctionHouseScript::OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionEntry* auction)
{
//
// Keeps updated the amount of items in the auction
//

auctionbot->IncrementItemCounts(auction);
}

void AHBot_AuctionHouseScript::OnAuctionRemove(AuctionHouseObject* /*ah*/, AuctionEntry* auction)
{
//
// Keeps updated the amount of items in the auction
//

auctionbot->DecrementItemCounts(auction);
}

void AHBot_AuctionHouseScript::OnBeforeAuctionHouseMgrUpdate()
{
auctionbot->Update();
}

30 changes: 30 additions & 0 deletions src/AuctionHouseBotAuctionHouseScript.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
*/

#ifndef AUCTION_HOUSE_BOT_AUCTION_HOUSE_SCRIPT_H
#define AUCTION_HOUSE_BOT_AUCTION_HOUSE_SCRIPT_H

#include "Player.h"
#include "ScriptMgr.h"

// =============================================================================
// Interaction with the auction house core mechanisms
// =============================================================================

class AHBot_AuctionHouseScript : public AuctionHouseScript
{
public:
AHBot_AuctionHouseScript();

void OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, uint32& profit, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail) override;
void OnBeforeAuctionHouseMgrSendAuctionExpiredMail (AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendNotification, bool& sendMail) override;
void OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail (AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* oldBidder, uint32& oldBidder_accId, Player* newBidder, uint32& newPrice, bool& sendNotification, bool& sendMail) override;

void OnAuctionAdd (AuctionHouseObject* ah, AuctionEntry* auction) override;
void OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* auction) override;

void OnBeforeAuctionHouseMgrUpdate() override;
};

#endif /* AUCTION_HOUSE_BOT_AUCTION_HOUSE_SCRIPT_H */
3 changes: 2 additions & 1 deletion src/AuctionHouseBotConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ AHBConfig::AHBConfig(uint32 ahid)
break;

default:
AHFID = 120; // Alliance
AHFID = 120; // Neutral
break;
}
}
Expand Down Expand Up @@ -1044,6 +1044,7 @@ uint32 AHBConfig::GetMaxStack(uint32 color)
return 0;
}
}

void AHBConfig::SetBuyerPrice(uint32 color, uint32 value)
{
switch (color)
Expand Down
32 changes: 32 additions & 0 deletions src/AuctionHouseBotMailScript.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "AuctionHouseBot.h"
#include "AuctionHouseBotMailScript.h"

AHBot_MailScript::AHBot_MailScript() : MailScript("AHBot_MailScript")
{

}

void AHBot_MailScript::OnBeforeMailDraftSendMailTo(
MailDraft*, /* mailDraft */
MailReceiver const& receiver,
MailSender const& sender,
MailCheckMask&, /* checked */
uint32&, /* deliver_delay */
uint32&, /* custom_expiration */
bool& deleteMailItemsFromDB,
bool& sendMail)
{
//
// If the mail is for the bot, then remove it and delete the items bought
//

if (receiver.GetPlayerGUIDLow() == auctionbot->GetAHBplayerGUID())
{
if (sender.GetMailMessageType() == MAIL_AUCTION)
{
deleteMailItemsFromDB = true;
}

sendMail = false;
}
}
23 changes: 23 additions & 0 deletions src/AuctionHouseBotMailScript.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
*/

#ifndef AUCTION_HOUSE_BOT_MAIL_SCRIPT_H
#define AUCTION_HOUSE_BOT_MAIL_SCRIPT_H

#include "ScriptMgr.h"
#include "Mail.h"

// =============================================================================
// Interaction with the mailing systems
// =============================================================================

class AHBot_MailScript : public MailScript
{
public:
AHBot_MailScript();

void OnBeforeMailDraftSendMailTo(MailDraft* mailDraft, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& checked, uint32& deliver_delay, uint32& custom_expiration, bool& deleteMailItemsFromDB, bool& sendMail) override;
};

#endif /* AUCTION_HOUSE_BOT_MAIL_SCRIPT_H */
Loading

0 comments on commit 62bb00f

Please sign in to comment.