Object.cpp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "World.h"
  17. #include "Object.h"
  18. #include "Spells.h"
  19. extern World world;
  20. extern ConfigReader configReader;
  21. extern MasterSpellList master_spell_list;
  22. Object::Object(){
  23. clickable = false;
  24. zone_name = 0;
  25. packet_num = 0;
  26. appearance.activity_status = 64;
  27. appearance.pos.state = 1;
  28. appearance.encounter_level = 0;
  29. spawn_type = 2;
  30. m_deviceID = 0;
  31. }
  32. Object::~Object(){
  33. }
  34. EQ2Packet* Object::serialize(Player* player, int16 version){
  35. return spawn_serialize(player, version);
  36. }
  37. void Object::HandleUse(Client* client, string command){
  38. vector<TransportDestination*> destinations;
  39. if(GetTransporterID() > 0)
  40. GetZone()->GetTransporters(&destinations, client, GetTransporterID());
  41. if (destinations.size())
  42. {
  43. client->SetTemporaryTransportID(0);
  44. client->ProcessTeleport(this, &destinations, GetTransporterID());
  45. }
  46. else if (client && command.length() > 0 && appearance.show_command_icon == 1 && MeetsSpawnAccessRequirements(client->GetPlayer())){
  47. EntityCommand* entity_command = FindEntityCommand(command);
  48. if (entity_command)
  49. client->GetCurrentZone()->ProcessEntityCommand(entity_command, client->GetPlayer(), client->GetPlayer()->GetTarget());
  50. }
  51. }
  52. Object* Object::Copy(){
  53. Object* new_spawn = new Object();
  54. new_spawn->SetCollector(IsCollector());
  55. new_spawn->SetMerchantID(merchant_id);
  56. new_spawn->SetMerchantType(merchant_type);
  57. new_spawn->SetMerchantLevelRange(GetMerchantMinLevel(), GetMerchantMaxLevel());
  58. if(GetSizeOffset() > 0){
  59. int8 offset = GetSizeOffset()+1;
  60. sint32 tmp_size = size + (rand()%offset - rand()%offset);
  61. if(tmp_size < 0)
  62. tmp_size = 1;
  63. else if(tmp_size >= 0xFFFF)
  64. tmp_size = 0xFFFF;
  65. new_spawn->size = (int16)tmp_size;
  66. }
  67. else
  68. new_spawn->size = size;
  69. new_spawn->SetPrimaryCommands(&primary_command_list);
  70. new_spawn->SetSecondaryCommands(&secondary_command_list);
  71. new_spawn->database_id = database_id;
  72. new_spawn->primary_command_list_id = primary_command_list_id;
  73. new_spawn->secondary_command_list_id = secondary_command_list_id;
  74. memcpy(&new_spawn->appearance, &appearance, sizeof(AppearanceData));
  75. new_spawn->faction_id = faction_id;
  76. new_spawn->target = 0;
  77. new_spawn->SetTotalHP(GetTotalHP());
  78. new_spawn->SetTotalPower(GetTotalPower());
  79. new_spawn->SetHP(GetHP());
  80. new_spawn->SetPower(GetPower());
  81. SetQuestsRequired(new_spawn);
  82. new_spawn->SetTransporterID(GetTransporterID());
  83. new_spawn->SetDeviceID(GetDeviceID());
  84. new_spawn->SetSoundsDisabled(IsSoundsDisabled());
  85. new_spawn->SetOmittedByDBFlag(IsOmittedByDBFlag());
  86. return new_spawn;
  87. }