Object.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. opcode = EQOpcodeManager[GetOpcodeVersion(version)]->EmuToEQ(OP_EqCreateGhostCmd);
  36. return spawn_serialize(player, version);
  37. }
  38. void Object::HandleUse(Client* client, string command){
  39. vector<TransportDestination*> destinations;
  40. if(GetTransporterID() > 0)
  41. GetZone()->GetTransporters(&destinations, client, GetTransporterID());
  42. if(destinations.size())
  43. client->ProcessTeleport(this, &destinations, GetTransporterID());
  44. else if (client && command.length() > 0 && appearance.show_command_icon == 1 && MeetsSpawnAccessRequirements(client->GetPlayer())){
  45. EntityCommand* entity_command = FindEntityCommand(command);
  46. if (entity_command)
  47. client->GetCurrentZone()->ProcessEntityCommand(entity_command, client->GetPlayer(), client->GetPlayer()->GetTarget());
  48. }
  49. }
  50. Object* Object::Copy(){
  51. Object* new_spawn = new Object();
  52. new_spawn->SetMerchantID(merchant_id);
  53. new_spawn->SetMerchantType(merchant_type);
  54. new_spawn->SetMerchantLevelRange(GetMerchantMinLevel(), GetMerchantMaxLevel());
  55. if(GetSizeOffset() > 0){
  56. int8 offset = GetSizeOffset()+1;
  57. sint32 tmp_size = size + (rand()%offset - rand()%offset);
  58. if(tmp_size < 0)
  59. tmp_size = 1;
  60. else if(tmp_size >= 0xFFFF)
  61. tmp_size = 0xFFFF;
  62. new_spawn->size = (int16)tmp_size;
  63. }
  64. else
  65. new_spawn->size = size;
  66. new_spawn->SetPrimaryCommands(&primary_command_list);
  67. new_spawn->SetSecondaryCommands(&secondary_command_list);
  68. new_spawn->database_id = database_id;
  69. new_spawn->primary_command_list_id = primary_command_list_id;
  70. new_spawn->secondary_command_list_id = secondary_command_list_id;
  71. memcpy(&new_spawn->appearance, &appearance, sizeof(AppearanceData));
  72. new_spawn->faction_id = faction_id;
  73. new_spawn->target = 0;
  74. new_spawn->SetTotalHP(GetTotalHP());
  75. new_spawn->SetTotalPower(GetTotalPower());
  76. new_spawn->SetHP(GetHP());
  77. new_spawn->SetPower(GetPower());
  78. new_spawn->SetQuestsRequired(GetQuestsRequired());
  79. new_spawn->SetTransporterID(GetTransporterID());
  80. new_spawn->SetDeviceID(GetDeviceID());
  81. new_spawn->SetSoundsDisabled(IsSoundsDisabled());
  82. return new_spawn;
  83. }