Object.cpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 = 0;
  40. if(GetTransporterID() > 0)
  41. destinations = GetZone()->GetTransporters(GetTransporterID());
  42. if(destinations)
  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. if(GetSizeOffset() > 0){
  55. int8 offset = GetSizeOffset()+1;
  56. sint32 tmp_size = size + (rand()%offset - rand()%offset);
  57. if(tmp_size < 0)
  58. tmp_size = 1;
  59. else if(tmp_size >= 0xFFFF)
  60. tmp_size = 0xFFFF;
  61. new_spawn->size = (int16)tmp_size;
  62. }
  63. else
  64. new_spawn->size = size;
  65. new_spawn->SetPrimaryCommands(&primary_command_list);
  66. new_spawn->SetSecondaryCommands(&secondary_command_list);
  67. new_spawn->database_id = database_id;
  68. new_spawn->primary_command_list_id = primary_command_list_id;
  69. new_spawn->secondary_command_list_id = secondary_command_list_id;
  70. memcpy(&new_spawn->appearance, &appearance, sizeof(AppearanceData));
  71. new_spawn->faction_id = faction_id;
  72. new_spawn->target = 0;
  73. new_spawn->SetTotalHP(GetTotalHP());
  74. new_spawn->SetTotalPower(GetTotalPower());
  75. new_spawn->SetHP(GetHP());
  76. new_spawn->SetPower(GetPower());
  77. new_spawn->SetQuestsRequired(GetQuestsRequired());
  78. new_spawn->SetTransporterID(GetTransporterID());
  79. new_spawn->SetDeviceID(GetDeviceID());
  80. return new_spawn;
  81. }