Object.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. {
  44. client->SetTemporaryTransportID(0);
  45. client->ProcessTeleport(this, &destinations, GetTransporterID());
  46. }
  47. else if (client && command.length() > 0 && appearance.show_command_icon == 1 && MeetsSpawnAccessRequirements(client->GetPlayer())){
  48. EntityCommand* entity_command = FindEntityCommand(command);
  49. if (entity_command)
  50. client->GetCurrentZone()->ProcessEntityCommand(entity_command, client->GetPlayer(), client->GetPlayer()->GetTarget());
  51. }
  52. }
  53. Object* Object::Copy(){
  54. Object* new_spawn = new Object();
  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. new_spawn->SetQuestsRequired(GetQuestsRequired());
  82. new_spawn->SetTransporterID(GetTransporterID());
  83. new_spawn->SetDeviceID(GetDeviceID());
  84. new_spawn->SetSoundsDisabled(IsSoundsDisabled());
  85. return new_spawn;
  86. }