Changeset 18 for trunk/src/game
- Timestamp:
- 11/19/08 13:23:29 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 23 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Chat.cpp
r9 r18 34 34 35 35 bool ChatHandler::load_command_table = true; 36 37 LanguageDesc lang_description[LANGUAGES_COUNT] =38 {39 { LANG_ADDON, 0, 0 },40 { LANG_UNIVERSAL, 0, 0 },41 { LANG_ORCISH, 669, SKILL_LANG_ORCISH },42 { LANG_DARNASSIAN, 671, SKILL_LANG_DARNASSIAN },43 { LANG_TAURAHE, 670, SKILL_LANG_TAURAHE },44 { LANG_DWARVISH, 672, SKILL_LANG_DWARVEN },45 { LANG_COMMON, 668, SKILL_LANG_COMMON },46 { LANG_DEMONIC, 815, SKILL_LANG_DEMON_TONGUE },47 { LANG_TITAN, 816, SKILL_LANG_TITAN },48 { LANG_THALASSIAN, 813, SKILL_LANG_THALASSIAN },49 { LANG_DRACONIC, 814, SKILL_LANG_DRACONIC },50 { LANG_KALIMAG, 817, SKILL_LANG_OLD_TONGUE },51 { LANG_GNOMISH, 7340, SKILL_LANG_GNOMISH },52 { LANG_TROLL, 7341, SKILL_LANG_TROLL },53 { LANG_GUTTERSPEAK, 17737, SKILL_LANG_GUTTERSPEAK },54 { LANG_DRAENEI, 29932, SKILL_LANG_DRAENEI },55 { LANG_ZOMBIE, 0, 0 },56 { LANG_GNOMISH_BINARY, 0, 0 },57 { LANG_GOBLIN_BINARY, 0, 0 }58 };59 60 LanguageDesc const* GetLanguageDescByID(uint32 lang)61 {62 for(int i = 0; i < LANGUAGES_COUNT; ++i)63 {64 if(uint32(lang_description[i].lang_id) == lang)65 return &lang_description[i];66 }67 68 return NULL;69 }70 71 LanguageDesc const* GetLanguageDescBySpell(uint32 spell_id)72 {73 for(int i = 0; i < LANGUAGES_COUNT; ++i)74 {75 if(lang_description[i].spell_id == spell_id)76 return &lang_description[i];77 }78 79 return NULL;80 }81 82 LanguageDesc const* GetLanguageDescBySkill(uint32 skill_id)83 {84 for(int i = 0; i < LANGUAGES_COUNT; ++i)85 {86 if(lang_description[i].skill_id == skill_id)87 return &lang_description[i];88 }89 90 return NULL;91 }92 36 93 37 ChatCommand * ChatHandler::getCommandTable() -
trunk/src/game/Chat.h
r9 r18 28 28 class Unit; 29 29 struct GameTele; 30 31 struct LanguageDesc32 {33 Language lang_id;34 uint32 spell_id;35 uint32 skill_id;36 };37 38 extern LanguageDesc lang_description[LANGUAGES_COUNT];39 40 LanguageDesc const* GetLanguageDescByID(uint32 lang);41 LanguageDesc const* GetLanguageDescBySpell(uint32 spell_id);42 LanguageDesc const* GetLanguageDescBySkill(uint32 skill_id);43 30 44 31 class ChatCommand -
trunk/src/game/Creature.cpp
r14 r18 63 63 } 64 64 65 bool VendorItemData::RemoveItem( uint32 item_id ) 66 { 67 for(VendorItemList::iterator i = m_items.begin(); i != m_items.end(); ++i ) 68 { 69 if((*i)->item==item_id) 70 { 71 m_items.erase(i); 72 return true; 73 } 74 } 75 return false; 76 } 77 78 VendorItem const* VendorItemData::FindItem(uint32 item_id) const 79 { 80 for(VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i ) 81 if((*i)->item==item_id) 82 return *i; 83 return NULL; 84 } 85 65 86 Creature::Creature() : 66 87 Unit(), i_AI(NULL), 67 88 lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), 68 m_ itemsLoaded(false), m_lootMoney(0), m_lootRecipient(0),89 m_lootMoney(0), m_lootRecipient(0), 69 90 m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), 70 91 m_gossipOptionLoaded(false),m_emoteState(0), m_isPet(false), m_isTotem(false), 71 92 m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), 72 93 m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), 73 m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL) 94 m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTableGuid(0) 74 95 { 75 96 m_valuesCount = UNIT_END; … … 88 109 CleanupsBeforeDelete(); 89 110 90 m_vendor _items.clear();111 m_vendorItemCounts.clear(); 91 112 92 113 delete i_AI; … … 504 525 break; 505 526 } 527 LoadCreaturesAddon(); 506 528 } 507 529 … … 674 696 break; 675 697 case GOSSIP_OPTION_VENDOR: 676 // load vendor items if not yet 677 LoadGoods(); 678 679 if(!GetItemCount()) 698 { 699 VendorItemData const* vItems = GetVendorItems(); 700 if(!vItems || vItems->Empty()) 680 701 { 681 702 sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_VENDOR but have empty trading item list.", … … 684 705 } 685 706 break; 707 } 686 708 case GOSSIP_OPTION_TRAINER: 687 709 if(!isCanTrainingOf(pPlayer,false)) … … 935 957 uint32 Creature::GetNpcTextId() 936 958 { 959 if (!m_DBTableGuid) 960 return DEFAULT_GOSSIP_MESSAGE; 961 937 962 if(uint32 pos = objmgr.GetNpcGossip(m_DBTableGuid)) 938 963 return pos; … … 1047 1072 { 1048 1073 // update in loaded data 1074 if (!m_DBTableGuid) 1075 m_DBTableGuid = GetGUIDLow(); 1049 1076 CreatureData& data = objmgr.NewOrExistCreatureData(m_DBTableGuid); 1050 1077 … … 1238 1265 Object::_Create(guidlow, Entry, HIGHGUID_UNIT); 1239 1266 1240 m_DBTableGuid = guidlow;1241 1267 if(!UpdateEntry(Entry, team, data)) 1242 1268 return false; … … 1264 1290 } 1265 1291 1266 uint32 stored_guid = guid;1292 m_DBTableGuid = guid; 1267 1293 if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT); 1268 1294 … … 1278 1304 return false; 1279 1305 } 1280 1281 m_DBTableGuid = stored_guid;1282 LoadCreaturesAddon();1283 1306 1284 1307 m_respawnradius = data->spawndist; … … 1347 1370 } 1348 1371 1349 void Creature::LoadGoods()1350 {1351 // already loaded;1352 if(m_itemsLoaded)1353 return;1354 1355 m_vendor_items.clear();1356 1357 VendorItemList const* vList = objmgr.GetNpcVendorItemList(GetEntry());1358 if(!vList)1359 return;1360 1361 for (VendorItemList::const_iterator _item_iter = vList->begin(); _item_iter != vList->end(); ++_item_iter)1362 AddItem( (*_item_iter)->item, (*_item_iter)->maxcount, (*_item_iter)->incrtime, (*_item_iter)->ExtendedCost);1363 1364 m_itemsLoaded = true;1365 }1366 1367 1372 bool Creature::hasQuest(uint32 quest_id) const 1368 1373 { … … 1389 1394 void Creature::DeleteFromDB() 1390 1395 { 1396 if (!m_DBTableGuid) 1397 { 1398 sLog.outDebug("Trying to delete not saved creature!"); 1399 return; 1400 } 1401 1391 1402 objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); 1392 1403 objmgr.DeleteCreatureData(m_DBTableGuid); … … 1495 1506 if(getDeathState()==DEAD) 1496 1507 { 1497 objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); 1508 if (m_DBTableGuid) 1509 objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); 1498 1510 m_respawnTime = time(NULL); // respawn at next tick 1499 1511 } … … 1717 1729 void Creature::SaveRespawnTime() 1718 1730 { 1719 if(isPet() )1731 if(isPet() || !m_DBTableGuid) 1720 1732 return; 1721 1733 … … 1753 1765 CreatureDataAddon const* Creature::GetCreatureAddon() const 1754 1766 { 1755 if(CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(m_DBTableGuid)) 1756 return addon; 1767 if (m_DBTableGuid) 1768 { 1769 if(CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(m_DBTableGuid)) 1770 return addon; 1771 } 1757 1772 1758 1773 // dependent from heroic mode entry … … 1957 1972 } 1958 1973 1974 1975 VendorItemData const* Creature::GetVendorItems() const 1976 { 1977 return objmgr.GetNpcVendorItemList(GetEntry()); 1978 } 1979 1980 uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) 1981 { 1982 if(!vItem->maxcount) 1983 return vItem->maxcount; 1984 1985 VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); 1986 for(; itr != m_vendorItemCounts.end(); ++itr) 1987 if(itr->itemId==vItem->item) 1988 break; 1989 1990 if(itr == m_vendorItemCounts.end()) 1991 return vItem->maxcount; 1992 1993 VendorItemCount* vCount = &*itr; 1994 1995 time_t ptime = time(NULL); 1996 1997 if( vCount->lastIncrementTime + vItem->incrtime <= ptime ) 1998 { 1999 ItemPrototype const* pProto = objmgr.GetItemPrototype(vItem->item); 2000 2001 uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); 2002 if((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount ) 2003 { 2004 m_vendorItemCounts.erase(itr); 2005 return vItem->maxcount; 2006 } 2007 2008 vCount->count += diff * pProto->BuyCount; 2009 vCount->lastIncrementTime = ptime; 2010 } 2011 2012 return vCount->count; 2013 } 2014 2015 uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count) 2016 { 2017 if(!vItem->maxcount) 2018 return 0; 2019 2020 VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); 2021 for(; itr != m_vendorItemCounts.end(); ++itr) 2022 if(itr->itemId==vItem->item) 2023 break; 2024 2025 if(itr == m_vendorItemCounts.end()) 2026 { 2027 uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0; 2028 m_vendorItemCounts.push_back(VendorItemCount(vItem->item,new_count)); 2029 return new_count; 2030 } 2031 2032 VendorItemCount* vCount = &*itr; 2033 2034 time_t ptime = time(NULL); 2035 2036 if( vCount->lastIncrementTime + vItem->incrtime <= ptime ) 2037 { 2038 ItemPrototype const* pProto = objmgr.GetItemPrototype(vItem->item); 2039 2040 uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); 2041 if((vCount->count + diff * pProto->BuyCount) < vItem->maxcount ) 2042 vCount->count += diff * pProto->BuyCount; 2043 else 2044 vCount->count = vItem->maxcount; 2045 } 2046 2047 vCount->count = vCount->count > used_count ? vCount->count-used_count : 0; 2048 vCount->lastIncrementTime = ptime; 2049 return vCount->count; 2050 } 2051 1959 2052 TrainerSpellData const* Creature::GetTrainerSpells() const 1960 2053 { -
trunk/src/game/Creature.h
r14 r18 111 111 uint32 Action; 112 112 std::string Option; 113 };114 115 struct CreatureItem116 {117 CreatureItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost)118 : id(_item), count(_maxcount), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost), lastincr((uint32)time(NULL)) {}119 120 uint32 id;121 uint32 count;122 uint32 maxcount;123 uint32 incrtime;124 uint32 lastincr;125 uint32 ExtendedCost;126 113 }; 127 114 … … 292 279 #endif 293 280 281 // Vendors 282 struct VendorItem 283 { 284 VendorItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) 285 : item(_item), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost) {} 286 287 uint32 item; 288 uint32 maxcount; // 0 for infinity item amount 289 uint32 incrtime; // time for restore items amount if maxcount != 0 290 uint32 ExtendedCost; 291 }; 292 typedef std::vector<VendorItem*> VendorItemList; 293 294 struct VendorItemData 295 { 296 VendorItemList m_items; 297 298 VendorItem* GetItem(uint32 slot) const 299 { 300 if(slot>=m_items.size()) return NULL; 301 return m_items[slot]; 302 } 303 bool Empty() const { return m_items.empty(); } 304 uint8 GetItemCount() const { return m_items.size(); } 305 void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) 306 { 307 m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost)); 308 } 309 bool RemoveItem( uint32 item_id ); 310 VendorItem const* FindItem(uint32 item_id) const; 311 312 void Clear() 313 { 314 for (VendorItemList::iterator itr = m_items.begin(); itr != m_items.end(); ++itr) 315 delete (*itr); 316 } 317 }; 318 319 struct VendorItemCount 320 { 321 explicit VendorItemCount(uint32 _item, uint32 _count) 322 : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {} 323 324 uint32 itemId; 325 uint32 count; 326 time_t lastIncrementTime; 327 }; 328 329 typedef std::list<VendorItemCount> VendorItemCounts; 330 294 331 struct TrainerSpell 295 332 { … … 419 456 float GetSpellDamageMod(int32 Rank); 420 457 421 /*********************************************************/ 422 /*** VENDOR SYSTEM ***/ 423 /*********************************************************/ 424 void LoadGoods(); // must be called before access to vendor items, lazy loading at first call 425 void ReloadGoods() { m_itemsLoaded = false; LoadGoods(); } 426 427 CreatureItem* GetItem(uint32 slot) 428 { 429 if(slot>=m_vendor_items.size()) return NULL; 430 return &m_vendor_items[slot]; 431 } 432 uint8 GetItemCount() const { return m_vendor_items.size(); } 433 void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) 434 { 435 m_vendor_items.push_back(CreatureItem(item, maxcount, ptime, ExtendedCost)); 436 } 437 bool RemoveItem( uint32 item_id ) 438 { 439 for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) 440 { 441 if(i->id==item_id) 442 { 443 m_vendor_items.erase(i); 444 return true; 445 } 446 } 447 return false; 448 } 449 CreatureItem* FindItem(uint32 item_id) 450 { 451 for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) 452 if(i->id==item_id) 453 return &*i; 454 return NULL; 455 } 458 VendorItemData const* GetVendorItems() const; 459 uint32 GetVendorItemCurrentCount(VendorItem const* vItem); 460 uint32 UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count); 456 461 457 462 TrainerSpellData const* GetTrainerSpells() const; … … 563 568 564 569 // vendor items 565 typedef std::vector<CreatureItem> CreatureItems; 566 CreatureItems m_vendor_items; 567 bool m_itemsLoaded; // vendor items loading state 570 VendorItemCounts m_vendorItemCounts; 568 571 569 572 void _RealtimeSetCreatureInfo(); … … 593 596 MovementGeneratorType m_defaultMovementType; 594 597 Cell m_currentCell; // store current cell where creature listed 595 uint32 m_DBTableGuid; 598 uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid 596 599 uint32 m_equipmentId; 597 600 -
trunk/src/game/GameObject.cpp
r2 r18 55 55 m_cooldownTime = 0; 56 56 m_goInfo = NULL; 57 58 m_DBTableGuid = 0; 57 59 } 58 60 … … 109 111 Object::_Create(guidlow, goinfo->id, HIGHGUID_GAMEOBJECT); 110 112 111 m_DBTableGuid = guidlow;112 113 m_goInfo = goinfo; 113 114 … … 479 480 void GameObject::SaveToDB() 480 481 { 481 // this should only be used when the creaturehas already been loaded482 // this should only be used when the gameobject has already been loaded 482 483 // perferably after adding to map, because mapid may not be valid otherwise 483 484 GameObjectData const *data = objmgr.GetGOData(m_DBTableGuid); … … 497 498 if (!goI) 498 499 return; 499 500 501 if (!m_DBTableGuid) 502 m_DBTableGuid = GetGUIDLow(); 500 503 // update in loaded data (changing data only in this place) 501 504 GameObjectData& data = objmgr.NewGOData(m_DBTableGuid); … … 567 570 uint32 go_state = data->go_state; 568 571 569 uint32 stored_guid = guid;572 m_DBTableGuid = guid; 570 573 if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); 571 574 572 575 if (!Create(guid,entry, map, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state) ) 573 576 return false; 574 575 m_DBTableGuid = stored_guid;576 577 577 578 switch(GetGOInfo()->type) … … 590 591 m_spawnedByDefault = true; 591 592 m_respawnDelayTime = data->spawntimesecs; 592 m_respawnTime = objmgr.GetGORespawnTime( stored_guid, map->GetInstanceId());593 m_respawnTime = objmgr.GetGORespawnTime(m_DBTableGuid, map->GetInstanceId()); 593 594 594 595 // ready to respawn … … 1159 1160 Player* player = (Player*)user; 1160 1161 1161 if( player->InBattleGround() && // in battleground 1162 !player->IsMounted() && // not mounted 1163 !player->HasStealthAura() && // not stealthed 1164 !player->HasInvisibilityAura() && // not invisible 1165 player->isAlive()) // live player 1166 { 1162 if( player->isAllowUseBattleGroundObject() ) 1163 { 1164 // in battleground check 1167 1165 BattleGround *bg = player->GetBattleGround(); 1168 1166 if(!bg) … … 1187 1185 Player* player = (Player*)user; 1188 1186 1189 if( player->InBattleGround() && // in battleground 1190 !player->IsMounted() && // not mounted 1191 !player->HasStealthAura() && // not stealthed 1192 !player->HasInvisibilityAura() && // not invisible 1193 !player->HasAura(SPELL_RECENTLY_DROPPED_FLAG, 0) && // can't pickup 1194 player->isAlive()) // live player 1195 { 1187 if( player->isAllowUseBattleGroundObject() ) 1188 { 1189 // in battleground check 1196 1190 BattleGround *bg = player->GetBattleGround(); 1197 1191 if(!bg) -
trunk/src/game/GameObject.h
r2 r18 583 583 uint32 m_usetimes; 584 584 585 uint32 m_DBTableGuid; 585 uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid 586 586 GameObjectInfo const* m_goInfo; 587 587 private: -
trunk/src/game/GossipDef.cpp
r6 r18 392 392 393 393 pSession->SendPacket( &data ); 394 //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u",GUID_LOPART(npcGUID),questStatus);394 sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u",GUID_LOPART(npcGUID),questStatus); 395 395 } 396 396 … … 478 478 pSession->SendPacket( &data ); 479 479 480 //sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId());480 sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId()); 481 481 } 482 482 … … 516 516 517 517 data << uint32(pQuest->GetQuestId()); 518 data << uint32(pQuest->Get MinLevel()); // not MinLevel. Accepted values: 0, 1 or 2 Possible theory for future dev: 0==cannot in quest log, 1==can in quest log session only(removed on log out), 2==can in quest log always (save to db)518 data << uint32(pQuest->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details) 519 519 data << uint32(pQuest->GetQuestLevel()); // may be 0 520 520 data << uint32(pQuest->GetZoneOrSort()); // zone or sort to display in quest log … … 598 598 599 599 pSession->SendPacket( &data ); 600 //sLog.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u",pQuest->GetQuestId() );600 sLog.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u",pQuest->GetQuestId() ); 601 601 } 602 602 … … 680 680 data << uint32(0); // Honor points reward, not implemented 681 681 pSession->SendPacket( &data ); 682 //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() );682 sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() ); 683 683 } 684 684 … … 759 759 760 760 pSession->SendPacket( &data ); 761 //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() );762 } 761 sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() ); 762 } -
trunk/src/game/ItemHandler.cpp
r2 r18 681 681 // Stop the npc if moving 682 682 pCreature->StopMoving(); 683 // load vendor items if not yet 684 pCreature->LoadGoods(); 685 686 uint8 numitems = pCreature->GetItemCount(); 683 684 VendorItemData const* vItems = pCreature->GetVendorItems(); 685 if(!vItems) 686 { 687 _player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0); 688 return; 689 } 690 691 uint8 numitems = vItems->GetItemCount(); 687 692 uint8 count = 0; 688 uint32 ptime = time(NULL);689 uint32 diff;690 693 691 694 WorldPacket data( SMSG_LIST_INVENTORY, (8+1+numitems*8*4) ); … … 695 698 float discountMod = _player->GetReputationPriceDiscount(pCreature); 696 699 697 ItemPrototype const *pProto;698 700 for(int i = 0; i < numitems; i++ ) 699 701 { 700 CreatureItem* crItem = pCreature->GetItem(i); 701 if( crItem ) 702 { 703 pProto = objmgr.GetItemPrototype(crItem->id); 704 if( pProto ) 702 if(VendorItem const* crItem = vItems->GetItem(i)) 703 { 704 if(ItemPrototype const *pProto = objmgr.GetItemPrototype(crItem->item)) 705 705 { 706 706 if((pProto->AllowableClass & _player->getClassMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster()) 707 707 continue; 708 708 709 ++count; 709 if( crItem->incrtime != 0 && (crItem->lastincr + crItem->incrtime <= ptime) ) 710 { 711 diff = uint32((ptime - crItem->lastincr)/crItem->incrtime); 712 if( (crItem->count + diff * pProto->BuyCount) <= crItem->maxcount ) 713 crItem->count += diff * pProto->BuyCount; 714 else 715 crItem->count = crItem->maxcount; 716 crItem->lastincr = ptime; 717 } 710 711 // reputation discount 712 uint32 price = uint32(floor(pProto->BuyPrice * discountMod)); 713 718 714 data << uint32(count); 719 data << uint32(crItem->i d);715 data << uint32(crItem->item); 720 716 data << uint32(pProto->DisplayInfoID); 721 data << uint32(crItem->maxcount <= 0 ? 0xFFFFFFFF : crItem->count); 722 723 uint32 price = pProto->BuyPrice; 724 725 // reputation discount 726 price = uint32(floor(pProto->BuyPrice * discountMod)); 727 717 data << uint32(crItem->maxcount <= 0 ? 0xFFFFFFFF : pCreature->GetVendorItemCurrentCount(crItem)); 728 718 data << uint32(price); 729 719 data << uint32(pProto->MaxDurability); -
trunk/src/game/Language.h
r9 r18 304 304 LANG_LOOKUP_PLAYER_CHARACTER = 329, 305 305 LANG_NO_PLAYERS_FOUND = 330, 306 LANG_EXTENDED_COST_NOT_EXIST = 331, 306 307 307 308 // Room for more level 2 -
trunk/src/game/Level2.cpp
r6 r18 1238 1238 return false; 1239 1239 1240 Creature* vendor = getSelectedCreature();1241 if (!vendor || !vendor->isVendor())1242 {1243 SendSysMessage(LANG_COMMAND_VENDORSELECTION);1244 SetSentErrorMessage(true);1245 return false;1246 }1247 1248 1240 char* pitem = extractKeyFromLink((char*)args,"Hitem"); 1249 1241 if (!pitem) … … 1253 1245 return false; 1254 1246 } 1247 1255 1248 uint32 itemId = atol(pitem); 1256 1249 … … 1268 1261 uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0; 1269 1262 1270 ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); 1271 if(!pProto) 1272 { 1273 PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId); 1274 SetSentErrorMessage(true); 1275 return false; 1276 } 1277 1278 if(extendedcost && !sItemExtendedCostStore.LookupEntry(extendedcost)) 1279 { 1280 PSendSysMessage(LANG_BAD_VALUE, extendedcost); 1281 SetSentErrorMessage(true); 1282 return false; 1283 } 1284 1285 // load vendor items if not yet 1286 vendor->LoadGoods(); 1287 1288 if(vendor->FindItem(itemId)) 1289 { 1290 PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST,itemId); 1291 SetSentErrorMessage(true); 1292 return false; 1293 } 1294 1295 if (vendor->GetItemCount() >= MAX_VENDOR_ITEMS) 1296 { 1297 SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); 1298 SetSentErrorMessage(true); 1299 return false; 1300 } 1301 1302 // add to DB and to current ingame vendor 1303 WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",vendor->GetEntry(), itemId, maxcount,incrtime,extendedcost); 1304 vendor->AddItem(itemId,maxcount,incrtime,extendedcost); 1263 Creature* vendor = getSelectedCreature(); 1264 1265 uint32 vendor_entry = vendor ? vendor->GetEntry() : 0; 1266 1267 if(!objmgr.IsVendorItemValid(vendor_entry,itemId,maxcount,incrtime,extendedcost,m_session->GetPlayer())) 1268 { 1269 SetSentErrorMessage(true); 1270 return false; 1271 } 1272 1273 objmgr.AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost); 1274 1275 ItemPrototype const* pProto = objmgr.GetItemPrototype(itemId); 1276 1305 1277 PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); 1306 1278 return true; … … 1330 1302 uint32 itemId = atol(pitem); 1331 1303 1332 ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); 1333 if(!pProto) 1334 { 1335 PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId); 1336 SetSentErrorMessage(true); 1337 return false; 1338 } 1339 1340 // load vendor items if not yet 1341 vendor->LoadGoods(); 1342 1343 if (!vendor->RemoveItem(itemId)) 1304 1305 if(!objmgr.RemoveVendorItem(vendor->GetEntry(),itemId)) 1344 1306 { 1345 1307 PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId); … … 1348 1310 } 1349 1311 1350 WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'",vendor->GetEntry(), itemId); 1312 ItemPrototype const* pProto = objmgr.GetItemPrototype(itemId); 1313 1351 1314 PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); 1352 1315 return true; -
trunk/src/game/ObjectMgr.cpp
r6 r18 71 71 } 72 72 73 LanguageDesc lang_description[LANGUAGES_COUNT] = 74 { 75 { LANG_ADDON, 0, 0 }, 76 { LANG_UNIVERSAL, 0, 0 }, 77 { LANG_ORCISH, 669, SKILL_LANG_ORCISH }, 78 { LANG_DARNASSIAN, 671, SKILL_LANG_DARNASSIAN }, 79 { LANG_TAURAHE, 670, SKILL_LANG_TAURAHE }, 80 { LANG_DWARVISH, 672, SKILL_LANG_DWARVEN }, 81 { LANG_COMMON, 668, SKILL_LANG_COMMON }, 82 { LANG_DEMONIC, 815, SKILL_LANG_DEMON_TONGUE }, 83 { LANG_TITAN, 816, SKILL_LANG_TITAN }, 84 { LANG_THALASSIAN, 813, SKILL_LANG_THALASSIAN }, 85 { LANG_DRACONIC, 814, SKILL_LANG_DRACONIC }, 86 { LANG_KALIMAG, 817, SKILL_LANG_OLD_TONGUE }, 87 { LANG_GNOMISH, 7340, SKILL_LANG_GNOMISH }, 88 { LANG_TROLL, 7341, SKILL_LANG_TROLL }, 89 { LANG_GUTTERSPEAK, 17737, SKILL_LANG_GUTTERSPEAK }, 90 { LANG_DRAENEI, 29932, SKILL_LANG_DRAENEI }, 91 { LANG_ZOMBIE, 0, 0 }, 92 { LANG_GNOMISH_BINARY, 0, 0 }, 93 { LANG_GOBLIN_BINARY, 0, 0 } 94 }; 95 96 LanguageDesc const* GetLanguageDescByID(uint32 lang) 97 { 98 for(int i = 0; i < LANGUAGES_COUNT; ++i) 99 { 100 if(uint32(lang_description[i].lang_id) == lang) 101 return &lang_description[i]; 102 } 103 104 return NULL; 105 } 106 73 107 ObjectMgr::ObjectMgr() 74 108 { … … 135 169 136 170 for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 137 for (VendorItemList::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) 138 delete (*itr2); 171 itr->second.Clear(); 139 172 140 173 for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) … … 2698 2731 mExclusiveQuestGroups.clear(); 2699 2732 2700 // 0 1 2 3 4 5 6 72701 QueryResult *result = WorldDatabase.Query("SELECT entry, ZoneOrSort, SkillOrClass, MinLevel, QuestLevel, Type, RequiredRaces, RequiredSkillValue,"2702 // 8 9 10 11 12 13 14 152733 // 0 1 2 3 4 5 6 7 8 2734 QueryResult *result = WorldDatabase.Query("SELECT entry, Method, ZoneOrSort, SkillOrClass, MinLevel, QuestLevel, Type, RequiredRaces, RequiredSkillValue," 2735 // 9 10 11 12 13 14 15 16 2703 2736 "RepObjectiveFaction, RepObjectiveValue, RequiredMinRepFaction, RequiredMinRepValue, RequiredMaxRepFaction, RequiredMaxRepValue, SuggestedPlayers, LimitTime," 2704 // 1 6 17 18 19 20 21 22 23 24 252737 // 17 18 19 20 21 22 23 24 25 26 2705 2738 "QuestFlags, SpecialFlags, CharTitleId, PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestInChain, SrcItemId, SrcItemCount, SrcSpell," 2706 // 2 6 27 28 29 30 31 32 33 34 352739 // 27 28 29 30 31 32 33 34 35 36 2707 2740 "Title, Details, Objectives, OfferRewardText, RequestItemsText, EndText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4," 2708 // 3 6 37 38 39 40 41 42 432741 // 37 38 39 40 41 42 43 44 2709 2742 "ReqItemId1, ReqItemId2, ReqItemId3, ReqItemId4, ReqItemCount1, ReqItemCount2, ReqItemCount3, ReqItemCount4," 2710 // 4 4 45 46 47 48 49 50 51 52 5354 552743 // 45 46 47 48 49 50 51 52 53 54 54 55 2711 2744 "ReqSourceId1, ReqSourceId2, ReqSourceId3, ReqSourceId4, ReqSourceCount1, ReqSourceCount2, ReqSourceCount3, ReqSourceCount4, ReqSourceRef1, ReqSourceRef2, ReqSourceRef3, ReqSourceRef4," 2712 // 5 6 57 58 59 60 61 62 632745 // 57 58 59 60 61 62 63 64 2713 2746 "ReqCreatureOrGOId1, ReqCreatureOrGOId2, ReqCreatureOrGOId3, ReqCreatureOrGOId4, ReqCreatureOrGOCount1, ReqCreatureOrGOCount2, ReqCreatureOrGOCount3, ReqCreatureOrGOCount4," 2714 // 6 4 65 66 672747 // 65 66 67 68 2715 2748 "ReqSpellCast1, ReqSpellCast2, ReqSpellCast3, ReqSpellCast4," 2716 // 6 8 69 70 71 72 732749 // 69 70 71 72 73 74 2717 2750 "RewChoiceItemId1, RewChoiceItemId2, RewChoiceItemId3, RewChoiceItemId4, RewChoiceItemId5, RewChoiceItemId6," 2718 // 7 4 75 76 77 78 792751 // 75 76 77 78 79 80 2719 2752 "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6," 2720 // 8 0 81 82 83 84 85 86 872753 // 81 82 83 84 85 86 87 88 2721 2754 "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4," 2722 // 8 8 89 90 91 92 93 94 95 96 972755 // 89 90 91 92 93 94 95 96 97 98 2723 2756 "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," 2724 // 9 8 99 100 101 102 103 104 105 106 1072757 // 99 100 101 102 103 104 105 106 107 108 2725 2758 "RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," 2726 // 10 8 109 110 111 112 113 114 115 116 1172759 // 109 110 111 112 113 114 115 116 117 118 2727 2760 "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4,IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," 2728 // 11 8 1192761 // 119 120 2729 2762 "StartScript, CompleteScript" 2730 2763 " FROM quest_template"); … … 2761 2794 2762 2795 // additional quest integrity checks (GO, creature_template and item_template must be loaded already) 2796 2797 if( qinfo->GetQuestMethod() >= 3 ) 2798 { 2799 sLog.outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.",qinfo->GetQuestId(),qinfo->GetQuestMethod()); 2800 } 2763 2801 2764 2802 if (qinfo->QuestFlags & ~QUEST_MANGOS_FLAGS_DB_ALLOWED) … … 6149 6187 if(entry==0) 6150 6188 { 6151 sLog.out String("Table `%s` contain reserved entry 0, ignored.",table);6189 sLog.outErrorDb("Table `%s` contain reserved entry 0, ignored.",table); 6152 6190 continue; 6153 6191 } … … 6156 6194 int32 start = min_value > 0 ? min_value : max_value; 6157 6195 int32 end = min_value > 0 ? max_value : min_value; 6158 sLog.out String("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,start,end);6196 sLog.outErrorDb("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,start,end); 6159 6197 continue; 6160 6198 } … … 6164 6202 if(data.Content.size() > 0) 6165 6203 { 6166 sLog.out String("Table `%s` contain data for already loaded entry %i (from another table?), ignored.",table,entry);6204 sLog.outErrorDb("Table `%s` contain data for already loaded entry %i (from another table?), ignored.",table,entry); 6167 6205 continue; 6168 6206 } … … 6657 6695 barGoLink bar( result->GetRowCount() ); 6658 6696 6659 uint32 count = 0 ,entry,spell;6697 uint32 count = 0; 6660 6698 do 6661 6699 { … … 6664 6702 Field* fields = result->Fetch(); 6665 6703 6666 entry = fields[0].GetUInt32(); 6667 spell = fields[1].GetUInt32(); 6668 6669 if(!GetCreatureTemplate(entry)) 6704 uint32 entry = fields[0].GetUInt32(); 6705 uint32 spell = fields[1].GetUInt32(); 6706 6707 CreatureInfo const* cInfo = GetCreatureTemplate(entry); 6708 6709 if(!cInfo) 6670 6710 { 6671 6711 sLog.outErrorDb("Table `npc_trainer` have entry for not existed creature template (Entry: %u), ignore", entry); 6712 continue; 6713 } 6714 6715 if(!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER)) 6716 { 6717 sLog.outErrorDb("Table `npc_trainer` have data for not creature template (Entry: %u) without trainer flag, ignore", entry); 6672 6718 continue; 6673 6719 } … … 6716 6762 // For reload case 6717 6763 for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 6718 { 6719 for (VendorItemList::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) 6720 delete (*itr2); 6721 } 6764 itr->second.Clear(); 6722 6765 m_mCacheVendorItemMap.clear(); 6723 6766 … … 6737 6780 6738 6781 uint32 count = 0; 6739 uint32 entry, item_id, ExtendedCost;6740 6782 do 6741 6783 { … … 6743 6785 Field* fields = result->Fetch(); 6744 6786 6745 entry = fields[0].GetUInt32(); 6746 if(!GetCreatureTemplate(entry)) 6747 { 6748 sLog.outErrorDb("Table `npc_vendor` have data for not existed creature template (Entry: %u), ignore", entry); 6787 uint32 entry = fields[0].GetUInt32(); 6788 uint32 item_id = fields[1].GetUInt32(); 6789 uint32 maxcount = fields[2].GetUInt32(); 6790 uint32 incrtime = fields[3].GetUInt32(); 6791 uint32 ExtendedCost = fields[4].GetUInt32(); 6792 6793 if(!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost)) 6749 6794 continue; 6750 } 6751 6752 item_id = fields[1].GetUInt32(); 6753 if(!GetItemPrototype(item_id)) 6754 { 6755 sLog.outErrorDb("Table `npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore",entry,item_id); 6756 continue; 6757 } 6758 6759 ExtendedCost = fields[4].GetUInt32(); 6760 if(ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) 6761 { 6762 sLog.outErrorDb("Table `npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,ExtendedCost,entry); 6763 continue; 6764 } 6765 6766 VendorItemList& vList = m_mCacheVendorItemMap[entry]; 6767 6768 if(vList.size() >= MAX_VENDOR_ITEMS) 6769 { 6770 sLog.outErrorDb( "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vList.size(), MAX_VENDOR_ITEMS, entry); 6771 continue; 6772 } 6773 6774 VendorItem* pVendorItem = new VendorItem(); 6775 pVendorItem->item = item_id; 6776 pVendorItem->maxcount = fields[2].GetUInt32(); 6777 pVendorItem->incrtime = fields[3].GetUInt32(); 6778 pVendorItem->ExtendedCost = ExtendedCost; 6779 6780 vList.push_back(pVendorItem); 6795 6796 VendorItemData& vList = m_mCacheVendorItemMap[entry]; 6797 6798 vList.AddItem(item_id,maxcount,incrtime,ExtendedCost); 6781 6799 ++count; 6782 6800 … … 6839 6857 } 6840 6858 6859 void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost ) 6860 { 6861 VendorItemData& vList = m_mCacheVendorItemMap[entry]; 6862 vList.AddItem(item,maxcount,incrtime,extendedcost); 6863 6864 WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",entry, item, maxcount,incrtime,extendedcost); 6865 } 6866 6867 bool ObjectMgr::RemoveVendorItem( uint32 entry,uint32 item ) 6868 { 6869 CacheVendorItemMap::iterator iter = m_mCacheVendorItemMap.find(entry); 6870 if(iter == m_mCacheVendorItemMap.end()) 6871 return false; 6872 6873 if(!iter->second.FindItem(item)) 6874 return false; 6875 6876 iter->second.RemoveItem(item); 6877 WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'",entry, item); 6878 return true; 6879 } 6880 6881 bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl ) const 6882 { 6883 CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry); 6884 if(!cInfo) 6885 { 6886 if(pl) 6887 ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); 6888 else 6889 sLog.outErrorDb("Table `npc_vendor` have data for not existed creature template (Entry: %u), ignore", vendor_entry); 6890 return false; 6891 } 6892 6893 if(!(cInfo->npcflag & UNIT_NPC_FLAG_VENDOR)) 6894 { 6895 if(pl) 6896 ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); 6897 else 6898 sLog.outErrorDb("Table `npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry); 6899 return false; 6900 } 6901 6902 if(!GetItemPrototype(item_id)) 6903 { 6904 if(pl) 6905 ChatHandler(pl).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id); 6906 else 6907 sLog.outErrorDb("Table `npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore",vendor_entry,item_id); 6908 return false; 6909 } 6910 6911 if(ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) 6912 { 6913 if(pl) 6914 ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,ExtendedCost); 6915 else 6916 sLog.outErrorDb("Table `npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,ExtendedCost,vendor_entry); 6917 return false; 6918 } 6919 6920 if(maxcount > 0 && incrtime == 0) 6921 { 6922 if(pl) 6923 ChatHandler(pl).PSendSysMessage("MaxCount!=0 (%u) but IncrTime==0", maxcount); 6924 else 6925 sLog.outErrorDb( "Table `npc_vendor` has `maxcount` (%u) for item %u of vendor (Entry: %u) but `incrtime`=0, ignore", maxcount, item_id, vendor_entry); 6926 return false; 6927 } 6928 else if(maxcount==0 && incrtime > 0) 6929 { 6930 if(pl) 6931 ChatHandler(pl).PSendSysMessage("MaxCount==0 but IncrTime<>=0"); 6932 else 6933 sLog.outErrorDb( "Table `npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignore", item_id, vendor_entry); 6934 return false; 6935 } 6936 6937 VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry); 6938 if(!vItems) 6939 return true; // later checks for non-empty lists 6940 6941 if(vItems->FindItem(item_id)) 6942 { 6943 if(pl) 6944 ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST,item_id); 6945 else 6946 sLog.outErrorDb( "Table `npc_vendor` has duplicate items %u for vendor (Entry: %u), ignore", item_id, vendor_entry); 6947 return false; 6948 } 6949 6950 if(vItems->GetItemCount() >= MAX_VENDOR_ITEMS) 6951 { 6952 if(pl) 6953 ChatHandler(pl).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); 6954 else 6955 sLog.outErrorDb( "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vItems->GetItemCount(), MAX_VENDOR_ITEMS, vendor_entry); 6956 return false; 6957 } 6958 6959 return true; 6960 } 6961 6841 6962 // Functions for scripting access 6842 6963 const char* GetAreaTriggerScriptNameById(uint32 id) … … 6849 6970 if(start_value >= 0 || start_value <= end_value) // start/end reversed for negative values 6850 6971 { 6851 sLog.outError ("Table '%s' attempt loaded with invalid range (%d - %d), use (%d - %d) instead.",table,start_value,end_value,-1,std::numeric_limits<int32>::min());6972 sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), use (%d - %d) instead.",table,start_value,end_value,-1,std::numeric_limits<int32>::min()); 6852 6973 start_value = -1; 6853 6974 end_value = std::numeric_limits<int32>::min(); -
trunk/src/game/ObjectMgr.h
r9 r18 229 229 typedef HM_NAMESPACE::hash_map<uint32, uint32> CacheNpcTextIdMap; 230 230 231 // Vendors 232 struct VendorItem 233 { 234 uint32 item; 235 uint32 maxcount; 236 uint32 incrtime; 237 uint32 ExtendedCost; 238 }; 239 typedef std::vector<VendorItem*> VendorItemList; 240 241 typedef HM_NAMESPACE::hash_map<uint32, VendorItemList> CacheVendorItemMap; 242 231 232 typedef HM_NAMESPACE::hash_map<uint32, VendorItemData> CacheVendorItemMap; 243 233 typedef HM_NAMESPACE::hash_map<uint32, TrainerSpellData> CacheTrainerSpellMap; 244 234 … … 258 248 259 249 bool normalizePlayerName(std::string& name); 250 251 struct MANGOS_DLL_SPEC LanguageDesc 252 { 253 Language lang_id; 254 uint32 spell_id; 255 uint32 skill_id; 256 }; 257 258 extern LanguageDesc lang_description[LANGUAGES_COUNT]; 259 MANGOS_DLL_SPEC LanguageDesc const* GetLanguageDescByID(uint32 lang); 260 260 261 261 class PlayerDumpReader; … … 733 733 } 734 734 735 VendorItem Listconst* GetNpcVendorItemList(uint32 entry) const735 VendorItemData const* GetNpcVendorItemList(uint32 entry) const 736 736 { 737 737 CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); … … 741 741 return &iter->second; 742 742 } 743 void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost); 744 bool RemoveVendorItem(uint32 entry,uint32 item); 745 bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL ) const; 743 746 protected: 744 747 uint32 m_auctionid; -
trunk/src/game/Pet.cpp
r2 r18 1743 1743 if(auraId == 35696) // Demonic Knowledge 1744 1744 { 1745 int32 basePoints = aura->GetDamage() * (GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT)) / 100;1745 int32 basePoints = int32(aura->GetDamage() * (GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT)) / 100); 1746 1746 CastCustomSpell(this,auraId,&basePoints, NULL, NULL, true ); 1747 1747 } -
trunk/src/game/Player.cpp
r12 r18 5795 5795 return; 5796 5796 5797 ReputationOnKillEntry const* Rep = objmgr.GetReputationOnKilEntry( pVictim->GetEntry());5797 ReputationOnKillEntry const* Rep = objmgr.GetReputationOnKilEntry(((Creature*)pVictim)->GetCreatureInfo()->Entry); 5798 5798 5799 5799 if(!Rep) … … 16381 16381 } 16382 16382 16383 // load vendor items if not yet 16384 pCreature->LoadGoods(); 16385 16386 CreatureItem* crItem = pCreature->FindItem(item); 16387 if(!crItem) 16383 VendorItemData const* vItems = pCreature->GetVendorItems(); 16384 if(!vItems || vItems->Empty()) 16388 16385 { 16389 16386 SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); … … 16391 16388 } 16392 16389 16393 if( crItem->maxcount != 0 && crItem->count < count ) 16394 { 16395 SendBuyError( BUY_ERR_ITEM_ALREADY_SOLD, pCreature, item, 0); 16390 VendorItem const* crItem = vItems->FindItem(item); 16391 if(!crItem) 16392 { 16393 SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); 16396 16394 return false; 16395 } 16396 16397 // check current item amount if it limited 16398 if( crItem->maxcount != 0 ) 16399 { 16400 if(pCreature->GetVendorItemCurrentCount(crItem) < pProto->BuyCount * count ) 16401 { 16402 SendBuyError( BUY_ERR_ITEM_ALREADY_SOLD, pCreature, item, 0); 16403 return false; 16404 } 16397 16405 } 16398 16406 … … 16509 16517 if(Item *it = StoreNewItem( dest, item, true )) 16510 16518 { 16511 if( crItem->maxcount != 0 ) 16512 crItem->count -= pProto->BuyCount * count; 16519 uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count); 16513 16520 16514 16521 WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); 16515 16522 data << pCreature->GetGUID(); 16516 data << (uint32)crItem->i d; // entry16517 data << (uint32) crItem->count;16523 data << (uint32)crItem->item; 16524 data << (uint32)(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); 16518 16525 data << (uint32)count; 16519 16526 GetSession()->SendPacket(&data); 16520 16527 16521 SendNewItem(it, count, true, false, false);16528 SendNewItem(it, pProto->BuyCount*count, true, false, false); 16522 16529 } 16523 16530 } … … 16549 16556 if(Item *it = EquipNewItem( dest, item, pProto->BuyCount * count, true )) 16550 16557 { 16551 if( crItem->maxcount != 0 ) 16552 crItem->count -= pProto->BuyCount * count; 16558 uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count); 16553 16559 16554 16560 WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); 16555 16561 data << pCreature->GetGUID(); 16556 data << (uint32)crItem->i d; // entry16557 data << (uint32) crItem->count;16562 data << (uint32)crItem->item; 16563 data << (uint32)(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); 16558 16564 data << (uint32)count; 16559 16565 GetSession()->SendPacket(&data); 16560 16566 16561 SendNewItem(it, count, true, false, false);16567 SendNewItem(it, pProto->BuyCount*count, true, false, false); 16562 16568 16563 16569 AutoUnequipOffhandIfNeed(); … … 16570 16576 } 16571 16577 16572 return crItem->maxcount!=0 ?true:false;16578 return crItem->maxcount!=0; 16573 16579 } 16574 16580 … … 17175 17181 // set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment 17176 17182 if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || isInFlight()) 17177 SetUnitMovementFlags(GetUnitMovementFlags() |MOVEMENTFLAG_FLYING2);17183 AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 17178 17184 } 17179 17185 … … 18168 18174 return false; 18169 18175 } 18176 18177 bool Player::isAllowUseBattleGroundObject() 18178 { 18179 return ( //InBattleGround() && // in battleground - not need, check in other cases 18180 !IsMounted() && // not mounted 18181 !HasStealthAura() && // not stealthed 18182 !HasInvisibilityAura() && // not invisible 18183 !HasAura(SPELL_RECENTLY_DROPPED_FLAG, 0) && // can't pickup 18184 isAlive() // live player 18185 ); 18186 } -
trunk/src/game/Player.h
r12 r18 1899 1899 1900 1900 bool GetBGAccessByLevel(uint32 bgTypeId) const; 1901 bool isAllowUseBattleGroundObject(); 1901 1902 1902 1903 /*********************************************************/ -
trunk/src/game/PointMovementGenerator.cpp
r2 r18 31 31 Traveller<T> traveller(unit); 32 32 i_destinationHolder.SetDestination(traveller,i_x,i_y,i_z); 33 34 if (unit.GetTypeId() == TYPEID_UNIT && ((Creature*)&unit)->canFly()) 35 unit.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 33 36 } 34 37 -
trunk/src/game/QuestDef.cpp
r2 r18 24 24 { 25 25 QuestId = questRecord[0].GetUInt32(); 26 ZoneOrSort = questRecord[1].GetInt32(); 27 SkillOrClass = questRecord[2].GetInt32(); 28 MinLevel = questRecord[3].GetUInt32(); 29 QuestLevel = questRecord[4].GetUInt32(); 30 Type = questRecord[5].GetUInt32(); 31 RequiredRaces = questRecord[6].GetUInt32(); 32 RequiredSkillValue = questRecord[7].GetUInt32(); 33 RepObjectiveFaction = questRecord[8].GetUInt32(); 34 RepObjectiveValue = questRecord[9].GetInt32(); 35 RequiredMinRepFaction = questRecord[10].GetUInt32(); 36 RequiredMinRepValue = questRecord[11].GetInt32(); 37 RequiredMaxRepFaction = questRecord[12].GetUInt32(); 38 RequiredMaxRepValue = questRecord[13].GetInt32(); 39 SuggestedPlayers = questRecord[14].GetUInt32(); 40 LimitTime = questRecord[15].GetUInt32(); 41 QuestFlags = questRecord[16].GetUInt16(); 42 uint32 SpecialFlags = questRecord[17].GetUInt16(); 43 CharTitleId = questRecord[18].GetUInt32(); 44 PrevQuestId = questRecord[19].GetInt32(); 45 NextQuestId = questRecord[20].GetInt32(); 46 ExclusiveGroup = questRecord[21].GetInt32(); 47 NextQuestInChain = questRecord[22].GetUInt32(); 48 SrcItemId = questRecord[23].GetUInt32(); 49 SrcItemCount = questRecord[24].GetUInt32(); 50 SrcSpell = questRecord[25].GetUInt32(); 51 Title = questRecord[26].GetCppString(); 52 Details = questRecord[27].GetCppString(); 53 Objectives = questRecord[28].GetCppString(); 54 OfferRewardText = questRecord[29].GetCppString(); 55 RequestItemsText = questRecord[30].GetCppString(); 56 EndText = questRecord[31].GetCppString(); 57 58 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 59 ObjectiveText[i] = questRecord[32+i].GetCppString(); 60 61 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 62 ReqItemId[i] = questRecord[36+i].GetUInt32(); 63 64 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 65 ReqItemCount[i] = questRecord[40+i].GetUInt32(); 26 QuestMethod = questRecord[1].GetUInt32(); 27 ZoneOrSort = questRecord[2].GetInt32(); 28 SkillOrClass = questRecord[3].GetInt32(); 29 MinLevel = questRecord[4].GetUInt32(); 30 QuestLevel = questRecord[5].GetUInt32(); 31 Type = questRecord[6].GetUInt32(); 32 RequiredRaces = questRecord[7].GetUInt32(); 33 RequiredSkillValue = questRecord[8].GetUInt32(); 34 RepObjectiveFaction = questRecord[9].GetUInt32(); 35 RepObjectiveValue = questRecord[10].GetInt32(); 36 RequiredMinRepFaction = questRecord[11].GetUInt32(); 37 RequiredMinRepValue = questRecord[12].GetInt32(); 38 RequiredMaxRepFaction = questRecord[13].GetUInt32(); 39 RequiredMaxRepValue = questRecord[14].GetInt32(); 40 SuggestedPlayers = questRecord[15].GetUInt32(); 41 LimitTime = questRecord[16].GetUInt32(); 42 QuestFlags = questRecord[17].GetUInt16(); 43 uint32 SpecialFlags = questRecord[18].GetUInt16(); 44 CharTitleId = questRecord[19].GetUInt32(); 45 PrevQuestId = questRecord[20].GetInt32(); 46 NextQuestId = questRecord[21].GetInt32(); 47 ExclusiveGroup = questRecord[22].GetInt32(); 48 NextQuestInChain = questRecord[23].GetUInt32(); 49 SrcItemId = questRecord[24].GetUInt32(); 50 SrcItemCount = questRecord[25].GetUInt32(); 51 SrcSpell = questRecord[26].GetUInt32(); 52 Title = questRecord[27].GetCppString(); 53 Details = questRecord[28].GetCppString(); 54 Objectives = questRecord[29].GetCppString(); 55 OfferRewardText = questRecord[30].GetCppString(); 56 RequestItemsText = questRecord[31].GetCppString(); 57 EndText = questRecord[32].GetCppString(); 58 59 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 60 ObjectiveText[i] = questRecord[33+i].GetCppString(); 61 62 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 63 ReqItemId[i] = questRecord[37+i].GetUInt32(); 64 65 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 66 ReqItemCount[i] = questRecord[41+i].GetUInt32(); 66 67 67 68 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) 68 ReqSourceId[i] = questRecord[4 4+i].GetUInt32();69 ReqSourceId[i] = questRecord[45+i].GetUInt32(); 69 70 70 71 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) 71 ReqSourceCount[i] = questRecord[4 8+i].GetUInt32();72 ReqSourceCount[i] = questRecord[49+i].GetUInt32(); 72 73 73 74 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) 74 ReqSourceRef[i] = questRecord[5 2+i].GetUInt32();75 76 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 77 ReqCreatureOrGOId[i] = questRecord[5 6+i].GetInt32();78 79 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 80 ReqCreatureOrGOCount[i] = questRecord[6 0+i].GetUInt32();81 82 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 83 ReqSpell[i] = questRecord[6 4+i].GetUInt32();75 ReqSourceRef[i] = questRecord[53+i].GetUInt32(); 76 77 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 78 ReqCreatureOrGOId[i] = questRecord[57+i].GetInt32(); 79 80 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 81 ReqCreatureOrGOCount[i] = questRecord[61+i].GetUInt32(); 82 83 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) 84 ReqSpell[i] = questRecord[65+i].GetUInt32(); 84 85 85 86 for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) 86 RewChoiceItemId[i] = questRecord[6 8+i].GetUInt32();87 RewChoiceItemId[i] = questRecord[69+i].GetUInt32(); 87 88 88 89 for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) 89 RewChoiceItemCount[i] = questRecord[7 4+i].GetUInt32();90 RewChoiceItemCount[i] = questRecord[75+i].GetUInt32(); 90 91 91 92 for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) 92 RewItemId[i] = questRecord[8 0+i].GetUInt32();93 RewItemId[i] = questRecord[81+i].GetUInt32(); 93 94 94 95 for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) 95 RewItemCount[i] = questRecord[8 4+i].GetUInt32();96 RewItemCount[i] = questRecord[85+i].GetUInt32(); 96 97 97 98 for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) 98 RewRepFaction[i] = questRecord[8 8+i].GetUInt32();99 RewRepFaction[i] = questRecord[89+i].GetUInt32(); 99 100 100 101 for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) 101 RewRepValue[i] = questRecord[9 3+i].GetInt32();102 103 RewOrReqMoney = questRecord[9 8].GetInt32();104 RewMoneyMaxLevel = questRecord[ 99].GetUInt32();105 RewSpell = questRecord[10 0].GetUInt32();106 RewSpellCast = questRecord[10 1].GetUInt32();107 RewMailTemplateId = questRecord[10 2].GetUInt32();108 RewMailDelaySecs = questRecord[10 3].GetUInt32();109 PointMapId = questRecord[10 4].GetUInt32();110 PointX = questRecord[10 5].GetFloat();111 PointY = questRecord[10 6].GetFloat();112 PointOpt = questRecord[10 7].GetUInt32();102 RewRepValue[i] = questRecord[94+i].GetInt32(); 103 104 RewOrReqMoney = questRecord[99].GetInt32(); 105 RewMoneyMaxLevel = questRecord[100].GetUInt32(); 106 RewSpell = questRecord[101].GetUInt32(); 107 RewSpellCast = questRecord[102].GetUInt32(); 108 RewMailTemplateId = questRecord[103].GetUInt32(); 109 RewMailDelaySecs = questRecord[104].GetUInt32(); 110 PointMapId = questRecord[105].GetUInt32(); 111 PointX = questRecord[106].GetFloat(); 112 PointY = questRecord[107].GetFloat(); 113 PointOpt = questRecord[108].GetUInt32(); 113 114 114 115 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) 115 DetailsEmote[i] = questRecord[10 8+i].GetUInt32();116 117 IncompleteEmote = questRecord[11 2].GetUInt32();118 CompleteEmote = questRecord[11 3].GetUInt32();116 DetailsEmote[i] = questRecord[109+i].GetUInt32(); 117 118 IncompleteEmote = questRecord[113].GetUInt32(); 119 CompleteEmote = questRecord[114].GetUInt32(); 119 120 120 121 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) 121 OfferRewardEmote[i] = questRecord[11 4+i].GetInt32();122 123 QuestStartScript = questRecord[11 8].GetUInt32();124 QuestCompleteScript = questRecord[1 19].GetUInt32();122 OfferRewardEmote[i] = questRecord[115+i].GetInt32(); 123 124 QuestStartScript = questRecord[119].GetUInt32(); 125 QuestCompleteScript = questRecord[120].GetUInt32(); 125 126 126 127 QuestFlags |= SpecialFlags << 16; -
trunk/src/game/QuestDef.h
r2 r18 115 115 // Flags used at server and sended to client 116 116 QUEST_FLAGS_STAY_ALIVE = 1, // Not used currently 117 QUEST_FLAGS_ EVENT = 2, // Not used currently117 QUEST_FLAGS_PARTY_ACCEPT = 2, // Not used currently. If player in party, all players that can accept this quest will receive confirmation box to accept quest CMSG_QUEST_CONFIRM_ACCEPT/SMSG_QUEST_CONFIRM_ACCEPT 118 118 QUEST_FLAGS_EXPLORATION = 4, // Not used currently 119 119 QUEST_FLAGS_SHARABLE = 8, // Can be shared: Player::CanShareQuest() … … 168 168 // table data accessors: 169 169 uint32 GetQuestId() const { return QuestId; } 170 uint32 GetQuestMethod() const { return QuestMethod; } 170 171 int32 GetZoneOrSort() const { return ZoneOrSort; } 171 172 int32 GetSkillOrClass() const { return SkillOrClass; } … … 213 214 uint32 GetQuestCompleteScript() const { return QuestCompleteScript; } 214 215 bool IsRepeatable() const { return QuestFlags & QUEST_MANGOS_FLAGS_REPEATABLE; } 215 bool IsAutoComplete() const { return Objectives.empty(); }216 bool IsAutoComplete() const { return QuestMethod ? false : true; } 216 217 uint32 GetFlags() const { return QuestFlags; } 217 218 bool IsDaily() const { return QuestFlags & QUEST_FLAGS_DAILY; } … … 256 257 protected: 257 258 uint32 QuestId; 259 uint32 QuestMethod; 258 260 int32 ZoneOrSort; 259 261 int32 SkillOrClass; -
trunk/src/game/RandomMovementGenerator.cpp
r2 r18 32 32 float X,Y,Z,z,nx,ny,nz,wander_distance,ori,dist; 33 33 34 creature.GetRespawnCoord(X, Y, Z);35 34 creature.GetRespawnCoord(X, Y, Z, &ori, &wander_distance); 36 35 … … 51 50 nx = X + distanceX; 52 51 ny = Y + distanceY; 52 53 // prevent invalid coordinates generation 54 MaNGOS::NormalizeMapCoord(nx); 55 MaNGOS::NormalizeMapCoord(ny); 56 53 57 dist = distanceX*distanceX + distanceY*distanceY; 54 58 … … 88 92 { 89 93 i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); 90 creature. SetUnitMovementFlags(MOVEMENTFLAG_FLYING2);94 creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 91 95 } 92 96 //else if (is_water_ok) // Swimming mode to be done with more than this check … … 106 110 107 111 if (creature.canFly()) 108 creature. SetUnitMovementFlags(MOVEMENTFLAG_FLYING2);112 creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 109 113 else 110 114 creature.SetUnitMovementFlags(irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MOVEMENTFLAG_WALK_MODE : MOVEMENTFLAG_NONE ); … … 145 149 { 146 150 if (creature.canFly()) 147 creature. SetUnitMovementFlags(MOVEMENTFLAG_FLYING2);151 creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 148 152 else 149 153 creature.SetUnitMovementFlags(irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MOVEMENTFLAG_WALK_MODE : MOVEMENTFLAG_NONE); -
trunk/src/game/Spell.cpp
r15 r18 3682 3682 return SPELL_FAILED_BAD_TARGETS; 3683 3683 3684 // In BattleGround players can use only flags and banners 3685 if( ((Player*)m_caster)->InBattleGround() && 3686 !((Player*)m_caster)->isAllowUseBattleGroundObject() ) 3687 return SPELL_FAILED_TRY_AGAIN; 3688 3684 3689 // get the lock entry 3685 3690 LockEntry const *lockInfo = NULL; -
trunk/src/game/SpellEffects.cpp
r9 r18 53 53 #include "SocialMgr.h" 54 54 #include "Util.h" 55 #include "TemporarySummon.h" 56 55 57 56 58 pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= … … 1007 1009 return; 1008 1010 } 1011 case 37573: //Temporal Phase Modulator 1012 { 1013 if(!unitTarget) 1014 return; 1015 1016 TemporarySummon* tempSummon = dynamic_cast<TemporarySummon*>(unitTarget); 1017 if(!tempSummon) 1018 return; 1019 1020 uint32 health = tempSummon->GetHealth(); 1021 const uint32 entry_list[6] = {21821, 21820, 21817}; 1022 1023 float x = tempSummon->GetPositionX(); 1024 float y = tempSummon->GetPositionY(); 1025 float z = tempSummon->GetPositionZ(); 1026 float o = tempSummon->GetOrientation(); 1027 1028 tempSummon->UnSummon(); 1029 1030 Creature* pCreature = m_caster->SummonCreature(entry_list[urand(0, 2)], x, y, z, o,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,180000); 1031 if (!pCreature) 1032 return; 1033 1034 pCreature->SetHealth(health); 1035 1036 if(pCreature->AI()) 1037 pCreature->AI()->AttackStart(m_caster); 1038 1039 return; 1040 } 1041 case 34665: //Administer Antidote 1042 { 1043 if(!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER ) 1044 return; 1045 1046 if(!unitTarget) 1047 return; 1048 1049 TemporarySummon* tempSummon = dynamic_cast<TemporarySummon*>(unitTarget); 1050 if(!tempSummon) 1051 return; 1052 1053 uint32 health = tempSummon->GetHealth(); 1054 1055 float x = tempSummon->GetPositionX(); 1056 float y = tempSummon->GetPositionY(); 1057 float z = tempSummon->GetPositionZ(); 1058 float o = tempSummon->GetOrientation(); 1059 tempSummon->UnSummon(); 1060 1061 Creature* pCreature = m_caster->SummonCreature(16992, x, y, z, o,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,180000); 1062 if (!pCreature) 1063 return; 1064 1065 pCreature->SetHealth(health); 1066 ((Player*)m_caster)->KilledMonster(16992,pCreature->GetGUID()); 1067 1068 if (pCreature->AI()) 1069 pCreature->AI()->AttackStart(m_caster); 1070 1071 return; 1072 } 1073 case 44997: // Converting Sentry 1074 { 1075 //Converted Sentry Credit 1076 m_caster->CastSpell(m_caster, 45009, true); 1077 return; 1078 } 1009 1079 case 45030: // Impale Emissary 1010 1080 { 1011 1081 // Emissary of Hate Credit 1012 m_caster->CastSpell(m_caster, 45088,true);1082 m_caster->CastSpell(m_caster, 45088, true); 1013 1083 return; 1014 1084 } … … 1100 1170 ((Player*)m_caster)->GetSession()->SendPacket(&data); 1101 1171 } 1172 } 1173 return; 1174 } 1175 case 32826: 1176 { 1177 if ( unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT ) 1178 { 1179 //Polymorph Cast Visual Rank 1 1180 const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820}; 1181 unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 1102 1182 } 1103 1183 return; … … 2761 2841 goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK ) 2762 2842 { 2763 if(BattleGround *bg = player->GetBattleGround())// in battleground 2764 { 2765 if( !player->IsMounted() && // not mounted 2766 !player->HasStealthAura() && // not stealthed 2767 !player->HasInvisibilityAura() && // not invisible 2768 player->isAlive() ) // live player 2769 { 2770 // check if it's correct bg 2771 if(bg && bg->GetTypeID() == BATTLEGROUND_AB) 2772 bg->EventPlayerClickedOnFlag(player, gameObjTarget); 2773 2774 return; 2775 } 2843 //isAllowUseBattleGroundObject() already called in CanCast() 2844 // in battleground check 2845 if(BattleGround *bg = player->GetBattleGround()) 2846 { 2847 // check if it's correct bg 2848 if(bg && bg->GetTypeID() == BATTLEGROUND_AB) 2849 bg->EventPlayerClickedOnFlag(player, gameObjTarget); 2850 return; 2776 2851 } 2777 2852 } 2778 2853 else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND) 2779 2854 { 2855 //isAllowUseBattleGroundObject() already called in CanCast() 2856 // in battleground check 2780 2857 if(BattleGround *bg = player->GetBattleGround()) 2858 { 2781 2859 if(bg->GetTypeID() == BATTLEGROUND_EY) 2782 2860 bg->EventPlayerClickedOnFlag(player, gameObjTarget); 2783 return; 2861 return; 2862 } 2784 2863 } 2785 2864 lockId = gameObjTarget->GetLockId(); … … 4752 4831 break; 4753 4832 } 4833 //5,000 Gold 4834 case 46642: 4835 { 4836 if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) 4837 return; 4838 4839 ((Player*)unitTarget)->ModifyMoney(50000000); 4840 4841 break; 4842 } 4754 4843 } 4755 4844 -
trunk/src/game/TargetedMovementGenerator.cpp
r2 r18 86 86 i_destinationHolder.SetDestination(traveller, x, y, z); 87 87 owner.addUnitState(UNIT_STAT_CHASE); 88 if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly()) 89 owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 88 90 } 89 91 … … 95 97 return; 96 98 owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); 99 100 if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly()) 101 owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 102 97 103 _setTargetLocation(owner); 98 104 } … … 144 150 { 145 151 owner.addUnitState(UNIT_STAT_CHASE); 152 if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly()) 153 owner.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 154 146 155 i_destinationHolder.StartTravel(traveller); 147 156 return true; -
trunk/src/game/WaypointMovementGenerator.cpp
r6 r18 113 113 creature.addUnitState(UNIT_STAT_ROAMING); 114 114 if (creature.canFly()) 115 creature. SetUnitMovementFlags(MOVEMENTFLAG_FLYING2);115 creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 116 116 const WaypointNode &node = i_path->at(i_currentNode); 117 117 i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); … … 177 177 creature.addUnitState(UNIT_STAT_ROAMING); 178 178 if (creature.canFly()) 179 creature. SetUnitMovementFlags(MOVEMENTFLAG_FLYING2);179 creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); 180 180 const WaypointNode &node = i_path->at(i_currentNode); 181 181 i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z);