Object.cpp 3.2 KB

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