From 3578b8d596b1d20b44e9529c1e151ae4c41c6621 Mon Sep 17 00:00:00 2001 From: Paradox Date: Wed, 3 Jun 2009 19:43:46 -0400 Subject: Backported from TC2 - More correctly calculate auction deposit. --HG-- branch : trunk --- src/game/AuctionHouseMgr.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 1554013af99..2619d589ec7 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -66,9 +66,41 @@ AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap( uint32 factionTemplateId ) uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem) { - uint32 deposit = pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME ); - - return uint32(deposit * entry->depositPercent * 3 * sWorld.getRate(RATE_AUCTION_DEPOSIT) / 100.0f ); + uint32 MSV = pItem->GetProto()->SellPrice; + double deposit; + double faction_pct; + if (MSV > 0) + { + if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + faction_pct = (0.75 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); + else + { + FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(entry->houseId); + if(!u_entry) + faction_pct = (0.75 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); + else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) + faction_pct = (0.15 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); + else if(u_entry->ourMask & FACTION_MASK_HORDE) + faction_pct = (0.15 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); + else + faction_pct = (0.75 * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT)); + } + deposit = ((double)MSV * faction_pct * (double)pItem->GetCount()) * (double)(time / MIN_AUCTION_TIME ); + } + else + { + faction_pct = 0.0f; + deposit = 0.0f; + } + //sLog.outString("SellPrice:\t\t%u", MSV); + //sLog.outString("Deposit Percent:\t%f", faction_pct); + //sLog.outString("Min Auction Time:\t%u", (time / MIN_AUCTION_TIME )); + //sLog.outString("Count:\t\t\t%u", pItem->GetCount()); + //sLog.outString("Deposit:\t\t%f", deposit); + if (deposit > 0) + return (uint32)deposit; + else + return 0; } //does not clear ram -- cgit v1.2.3 From 85b68d886aa5ebc92dbd28ad83f710c0fd655579 Mon Sep 17 00:00:00 2001 From: krz Date: Fri, 5 Jun 2009 01:21:11 +0200 Subject: Send interrupt message at spell cast end if target is not visible for caster. --HG-- branch : trunk --- src/game/Spell.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 82756ad118f..d8cf24c2933 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2238,6 +2238,11 @@ void Spell::cancel() void Spell::cast(bool skipCheck) { + if(m_targets.getUnitTarget() && !m_targets.getUnitTarget()->isVisibleForOrDetect(m_caster, true)) + { + cancel(); + return; + } SetExecutedCurrently(true); uint8 castResult = 0; -- cgit v1.2.3 From 65598fe2333472adb9a9eaa80ff4d5d3f62cce10 Mon Sep 17 00:00:00 2001 From: krz Date: Fri, 5 Jun 2009 02:02:50 +0200 Subject: Backported from TC2: allow Water Elemental to cast Freeze while casting Water Bolt --HG-- branch : trunk --- src/game/PetHandler.cpp | 5 ++++- src/game/Spell.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 350c390d86c..8ffe2529227 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -632,7 +632,10 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) } if (caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->GetGlobalCooldown() > 0) + { + caster->SendPetCastFail(spellid, SPELL_FAILED_NOT_READY); return; + } SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid); if(!spellInfo) @@ -651,7 +654,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) caster->clearUnitState(UNIT_STAT_FOLLOW); - Spell *spell = new Spell(caster, spellInfo, false); + Spell *spell = new Spell(caster, spellInfo, spellid == 33395); // water elemental can cast freeze as triggered spell->m_targets = targets; int16 result = spell->PetCanCast(NULL); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index d8cf24c2933..88bee994820 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4269,7 +4269,7 @@ int16 Spell::PetCanCast(Unit* target) if(!m_caster->isAlive()) return SPELL_FAILED_CASTER_DEAD; - if(m_caster->IsNonMeleeSpellCasted(false)) //prevent spellcast interruption by another spellcast + if(m_caster->IsNonMeleeSpellCasted(false) && !m_IsTriggeredSpell) //prevent spellcast interruption by another spellcast return SPELL_FAILED_SPELL_IN_PROGRESS; if(m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo)) return SPELL_FAILED_AFFECTING_COMBAT; -- cgit v1.2.3 From a319125b4f49109cf008b5f055cf56cd30a7ed7f Mon Sep 17 00:00:00 2001 From: krz Date: Fri, 5 Jun 2009 02:07:05 +0200 Subject: Change in SpellEntry structure to allow EffectBaseDice[] to store negative values - patch by thenecromancer. --HG-- branch : trunk --- src/shared/Database/DBCStructure.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index 95703f9b778..8e8aa8bfba8 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -605,7 +605,7 @@ struct SpellEntry int32 EquippedItemInventoryTypeMask; // 64 (mask) uint32 Effect[3]; // 65-67 int32 EffectDieSides[3]; // 68-70 - uint32 EffectBaseDice[3]; // 71-73 + int32 EffectBaseDice[3]; // 71-73 float EffectDicePerLevel[3]; // 74-76 float EffectRealPointsPerLevel[3]; // 77-79 int32 EffectBasePoints[3]; // 80-82 (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints) -- cgit v1.2.3 From 715f410fb7fdebe1c22401cb749ad57eae637040 Mon Sep 17 00:00:00 2001 From: Chaz Brown Date: Fri, 5 Jun 2009 21:12:12 -0400 Subject: Fix AHBot to calculate the deposit for auctions so it can be used to check the code for figuring deposit amount on a wide range of items. Fix ahbotoptions command so it works from the server console again. change commented out lines in GetAuctionDeposit so they display in debug loglevel. Min/Max Time settings replaced with a function that selects 12 24 and 48 randomly as the auction times. Backport from TC2 --HG-- branch : trunk --- sql/characters.sql | 2 -- sql/updates/1556_characters_ahbot.sql | 3 ++ src/game/AuctionHouseBot.cpp | 56 ++++++++++++++++++++++++----------- src/game/AuctionHouseBot.h | 23 -------------- src/game/AuctionHouseMgr.cpp | 12 ++++---- src/game/Level3.cpp | 12 ++++++-- 6 files changed, 58 insertions(+), 50 deletions(-) create mode 100644 sql/updates/1556_characters_ahbot.sql (limited to 'src') diff --git a/sql/characters.sql b/sql/characters.sql index c2233b7e282..bcb2b449c0f 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -132,8 +132,6 @@ CREATE TABLE `auctionhousebot` ( `name` char(25) default NULL COMMENT 'Text name of the auctionhouse.', `minitems` int(11) default '0' COMMENT 'This is the minimum number of items you want to keep in the auction house. a 0 here will make it the same as the maximum.', `maxitems` int(11) default '0' COMMENT 'This is the number of items you want to keep in the auction house.', - `mintime` int(11) default '8' COMMENT 'Sets the minimum number of hours for an auction.', - `maxtime` int(11) default '24' COMMENT 'Sets the maximum number of hours for an auction.', `percentgreytradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items', `percentwhitetradegoods` int(11) default '27' COMMENT 'Sets the percentage of the White Trade Goods auction items', `percentgreentradegoods` int(11) default '12' COMMENT 'Sets the percentage of the Green Trade Goods auction items', diff --git a/sql/updates/1556_characters_ahbot.sql b/sql/updates/1556_characters_ahbot.sql new file mode 100644 index 00000000000..85c0b14bac4 --- /dev/null +++ b/sql/updates/1556_characters_ahbot.sql @@ -0,0 +1,3 @@ +ALTER TABLE `auctionhousebot` + DROP COLUMN `minTime`, + DROP COLUMN `maxTime`; diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp index b139358b74a..1c1fdd57384 100644 --- a/src/game/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot.cpp @@ -450,6 +450,40 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) break; } + if(auctionmgr.GetAItem(GUID_LOPART(item->GetGUID()))) + { + sLog.outError("Item %u not found", item->GetEntry()); + break; + } + if(!item->CanBeTraded()) + { + sLog.outError("Item %u can't be traded", item->GetEntry()); + break; + } + + if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION)) + { + sLog.outError("Item %u is conjured or has a duration", item->GetEntry()); + break; + } + uint32 etime = urand(1,3); + switch(etime) + { + case 1: + etime = 43200; + break; + case 2: + etime = 86400; + break; + case 3: + etime = 172800; + break; + default: + etime = 86400; + break; + } + uint32 dep = auctionmgr.GetAuctionDeposit( ahEntry, etime, item ); + item->SetCount(stackCount); AuctionEntry* auctionEntry = new AuctionEntry; @@ -462,8 +496,8 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config) auctionEntry->buyout = buyoutPrice; auctionEntry->bidder = 0; auctionEntry->bid = 0; - auctionEntry->deposit = 0; - auctionEntry->expire_time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL)); + auctionEntry->deposit = dep; + auctionEntry->expire_time = (time_t) etime + time(NULL); auctionEntry->auctionHouseEntry = ahEntry; item->SaveToDB(); item->RemoveFromUpdateQueueOf(AHBplayer); @@ -1117,19 +1151,11 @@ void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* a CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID); config->SetMaxItems(maxItems); }break; - case 3: //min time + case 3: //min time Deprecated (Place holder for future commands) { - char * param1 = strtok(args, " "); - uint32 minTime = (uint32) strtoul(param1, NULL, 0); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime, ahMapID); - config->SetMinTime(minTime); }break; - case 4: //max time + case 4: //max time Deprecated (Place holder for future commands) { - char * param1 = strtok(args, " "); - uint32 maxTime = (uint32) strtoul(param1, NULL, 0); - CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime, ahMapID); - config->SetMaxTime(maxTime); }break; case 5: //percentages { @@ -1250,12 +1276,6 @@ void AuctionHouseBotLoadValues(AHBConfig *config) if(debug_Out) {sLog.outError("minItems = %u", config->GetMinItems()); sLog.outError("maxItems = %u", config->GetMaxItems());} - //load min and max auction times - config->SetMinTime(CharacterDatabase.PQuery("SELECT mintime FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); - config->SetMaxTime(CharacterDatabase.PQuery("SELECT maxtime FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32()); - if(debug_Out) - {sLog.outError("minTime = %u", config->GetMinTime()); - sLog.outError("maxTime = %u", config->GetMaxTime());} //load percentages uint32 greytg = CharacterDatabase.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); uint32 whitetg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32(); diff --git a/src/game/AuctionHouseBot.h b/src/game/AuctionHouseBot.h index 8d5c067a354..f1d4ba86ec9 100644 --- a/src/game/AuctionHouseBot.h +++ b/src/game/AuctionHouseBot.h @@ -37,8 +37,6 @@ class AHBConfig uint32 AHFID; uint32 minItems; uint32 maxItems; - uint32 minTime; - uint32 maxTime; uint32 percentGreyTradeGoods; uint32 percentWhiteTradeGoods; uint32 percentGreenTradeGoods; @@ -166,27 +164,6 @@ class AHBConfig { return maxItems; } - void SetMinTime(uint32 value) - { - minTime = value; - } - uint32 GetMinTime() - { - if (minTime < 1) - return 1; - else if ((maxTime) && (minTime > maxTime)) - return maxTime; - else - return minTime; - } - void SetMaxTime(uint32 value) - { - maxTime = value; - } - uint32 GetMaxTime() - { - return maxTime; - } void SetPercentages(uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg, uint32 greyi, uint32 whitei, uint32 greeni, uint32 bluei, uint32 purplei, uint32 orangei, uint32 yellowi) { uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi; diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 2619d589ec7..adb4a4a2787 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -92,11 +92,13 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 faction_pct = 0.0f; deposit = 0.0f; } - //sLog.outString("SellPrice:\t\t%u", MSV); - //sLog.outString("Deposit Percent:\t%f", faction_pct); - //sLog.outString("Min Auction Time:\t%u", (time / MIN_AUCTION_TIME )); - //sLog.outString("Count:\t\t\t%u", pItem->GetCount()); - //sLog.outString("Deposit:\t\t%f", deposit); + sLog.outDebug("SellPrice:\t\t%u", MSV); + sLog.outDebug("Deposit Percent:\t%f", faction_pct); + sLog.outDebug("Auction Time1:\t\t%u", time); + sLog.outDebug("Auction Time2:\t\t%u", MIN_AUCTION_TIME); + sLog.outDebug("Auction Time3:\t\t%u", (time / MIN_AUCTION_TIME )); + sLog.outDebug("Count:\t\t\t%u", pItem->GetCount()); + sLog.outDebug("Deposit:\t\t%f", deposit); if (deposit > 0) return (uint32)deposit; else diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 128971f0153..b0cb3c5fc9f 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -78,8 +78,8 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) PSendSysMessage("ahexpire"); PSendSysMessage("minitems"); PSendSysMessage("maxitems"); - PSendSysMessage("mintime"); - PSendSysMessage("maxtime"); + //PSendSysMessage(""); + //PSendSysMessage(""); PSendSysMessage("percentages"); PSendSysMessage("minprice"); PSendSysMessage("maxprice"); @@ -112,6 +112,9 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) } else if (strncmp(opt,"maxitems",l) == 0) { + PSendSysMessage("ahbotoptions mintime has been deprecated"); + return false; + /* char * param1 = strtok(NULL, " "); if ((!ahMapIdStr) || (!param1)) { @@ -119,9 +122,13 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) return false; } AuctionHouseBotCommands(2, ahMapID, NULL, param1); + */ } else if (strncmp(opt,"mintime",l) == 0) { + PSendSysMessage("ahbotoptions maxtime has been deprecated"); + return false; + /* char * param1 = strtok(NULL, " "); if ((!ahMapIdStr) || (!param1)) { @@ -129,6 +136,7 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) return false; } AuctionHouseBotCommands(3, ahMapID, NULL, param1); + */ } else if (strncmp(opt,"maxtime",l) == 0) { -- cgit v1.2.3 From 2e4fae75a4f4f24dc2c97b8bde4870974c073aa9 Mon Sep 17 00:00:00 2001 From: krz Date: Sun, 7 Jun 2009 02:02:00 +0200 Subject: Fix the bug that players couldn't talk with Spirit Healer --HG-- branch : trunk --- src/game/Spell.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 88bee994820..cb67391dcbf 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2238,13 +2238,13 @@ void Spell::cancel() void Spell::cast(bool skipCheck) { - if(m_targets.getUnitTarget() && !m_targets.getUnitTarget()->isVisibleForOrDetect(m_caster, true)) + if(m_targets.getUnitTarget() && m_targets.getUnitTarget()->isAlive() && !m_targets.getUnitTarget()->isVisibleForOrDetect(m_caster, true)) { cancel(); return; } - SetExecutedCurrently(true); + SetExecutedCurrently(true); uint8 castResult = 0; // update pointers base at GUIDs to prevent access to non-existed already object -- cgit v1.2.3