123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /*
- EQ2Emulator: Everquest II Server Emulator
- Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
- This file is part of EQ2Emulator.
- EQ2Emulator is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- EQ2Emulator is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "Loot.h"
- #include "../client.h"
- #include "../../common/ConfigReader.h"
- #include "../classes.h"
- #include "../../common/debug.h"
- #include "../zoneserver.h"
- #include "../Skills.h"
- #include "../classes.h"
- #include "../World.h"
- #include "../LuaInterface.h"
- #include "../../common/Log.h"
- #include "../Entity.h"
- #include "../Rules/Rules.h"
- extern Classes classes;
- extern ConfigReader configReader;
- extern MasterSkillList master_skill_list;
- extern RuleManager rule_manager;
- // If we want to transfer functions to this file then we should just do it, but for now we don't need all this commented code here
- NPC* Entity::DropChest() {
- // Check to see if treasure chests are disabled in the rules
- if (rule_manager.GetGlobalRule(R_World, TreasureChestDisabled)->GetBool())
- return 0;
- NPC* chest = 0;
- chest = new NPC();
- chest->SetAttackable(0);
- chest->SetShowLevel(0);
- chest->SetShowName(1);
- chest->SetTargetable(1);
- chest->SetLevel(GetLevel());
- chest->SetChestDropTime();
- // Set the brain to a blank brain so it does nothing
- chest->SetBrain(new BlankBrain(chest));
- // Set the x, y, z, heading, location (grid id) to that of the dead spawn
- chest->SetZone(GetZone());
- chest->SetX(GetX());
- chest->SetZ(GetZ()); // need to set X/Z BEFORE setting Y
- chest->SetY(GetY());
- // heading needs to be GetHeading() - 180 so the chest faces the proper way
- chest->SetHeading(GetHeading() - 180);
- chest->SetLocation(GetLocation());
- // Set the primary command to loot and the secondary to disarm
- chest->AddPrimaryEntityCommand("loot", rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat(), "loot", "", 0, 0);
- chest->AddSecondaryEntityCommand("Disarm", rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat(), "Disarm", "", 0, 0);
- // 32 = loot icon for the mouse
- chest->SetIcon(32);
- // 1 = show the right click menu
- chest->SetShowCommandIcon(1);
- int8 highest_tier = 0;
- vector<Item*>::iterator itr;
- for (itr = ((Spawn*)this)->GetLootItems()->begin(); itr != ((Spawn*)this)->GetLootItems()->end(); ) {
- if ((*itr)->details.tier >= ITEM_TAG_UNCOMMON && !(*itr)->IsBodyDrop()) {
- if ((*itr)->details.tier > highest_tier)
- highest_tier = (*itr)->details.tier;
- // Add the item to the chest
- chest->AddLootItem((*itr)->details.item_id, (*itr)->details.count);
- // Remove the item from the corpse
- itr = ((Spawn*)this)->GetLootItems()->erase(itr);
- }
- else
- itr++;
- }
- /*4034 = small chest | 5864 = treasure chest | 5865 = ornate treasure chest | 4015 = exquisite chest*/
- if (highest_tier >= ITEM_TAG_FABLED) {
- chest->SetModelType(4015);
- chest->SetName("Exquisite Chest");
- }
- else if (highest_tier >= ITEM_TAG_LEGENDARY) {
- chest->SetModelType(5865);
- chest->SetName("Ornate Chest");
- }
- else if (highest_tier >= ITEM_TAG_TREASURED) {
- chest->SetModelType(5864);
- chest->SetName("Treasure Chest");
- }
- else if (highest_tier >= ITEM_TAG_UNCOMMON) {
- chest->SetModelType(4034);
- chest->SetName("Small Chest");
- }
- else
- safe_delete(chest);
- if (chest)
- chest->SetShowHandIcon(1);
- return chest;
- }
|