zoneserver.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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. #ifndef ZONESERVER_H
  17. #define ZONESERVER_H
  18. #include "../common/linked_list.h"
  19. #include "../common/timer.h"
  20. #include "../common/queue.h"
  21. #include "../common/servertalk.h"
  22. #include "../common/TCPConnection.h"
  23. #include "WorldTCPConnection.h"
  24. #include "../common/Mutex.h"
  25. #include "../common/DataBuffer.h"
  26. #include "net.h"
  27. #include "Player.h"
  28. #include "Combat.h"
  29. #include <list>
  30. #include <map>
  31. #include <set>
  32. #include "MutexList.h"
  33. #include "MutexMap.h"
  34. #include "MutexVector.h"
  35. #include "NPC.h"
  36. #include "Widget.h"
  37. #include "Object.h"
  38. #include "GroundSpawn.h"
  39. #include "Sign.h"
  40. #include "Zone/map.h"
  41. #include "Zone/pathfinder_interface.h"
  42. #include "Zone/mob_movement_manager.h"
  43. #include "Zone/region_map.h"
  44. extern NetConnection net; // needs to be here or compile errors in commands.cpp
  45. class SpellProcess;
  46. class TradeskillMgr;
  47. class Bot;
  48. #define EXPANSION_UNKNOWN 1
  49. #define EXPANSION_UNKNOWN2 64
  50. #define EXPANSION_UNKNOWN3 128
  51. #define EXPANSION_UNKNOWN4 256
  52. #define EXPANSION_UNKNOWN5 512
  53. #define EXPANSION_DOF 1024
  54. #define EXPANSION_KOS 2048
  55. #define EXPANSION_EOF 4096
  56. #define EXPANSION_ROK 8192
  57. #define EXPANSION_TSO 16384
  58. #define EXPANSION_DOV 65536 // This enables DoV and CoE AA tree's lower values disable both trees
  59. // Can't verify these 3 values
  60. // 32768 - SF
  61. // 131072 - AoD
  62. #define SPAWN_SCRIPT_SPAWN 0
  63. #define SPAWN_SCRIPT_RESPAWN 1
  64. #define SPAWN_SCRIPT_ATTACKED 2
  65. #define SPAWN_SCRIPT_TARGETED 3
  66. #define SPAWN_SCRIPT_HAILED 4
  67. #define SPAWN_SCRIPT_DEATH 5
  68. #define SPAWN_SCRIPT_KILLED 6
  69. #define SPAWN_SCRIPT_AGGRO 7
  70. #define SPAWN_SCRIPT_HEALTHCHANGED 8
  71. #define SPAWN_SCRIPT_RANDOMCHAT 9
  72. #define SPAWN_SCRIPT_CONVERSATION 10
  73. #define SPAWN_SCRIPT_TIMER 11
  74. #define SPAWN_SCRIPT_CUSTOM 12
  75. #define SPAWN_SCRIPT_HAILED_BUSY 13
  76. #define SPAWN_SCRIPT_CASTED_ON 14
  77. #define SPAWN_SCRIPT_AUTO_ATTACK_TICK 15
  78. #define SPAWN_SCRIPT_COMBAT_RESET 16
  79. #define SPAWN_SCRIPT_GROUP_DEAD 17
  80. #define SPAWN_SCRIPT_HEAR_SAY 18
  81. #define SPAWN_SCRIPT_PRESPAWN 19
  82. #define SPAWN_SCRIPT_USEDOOR 20
  83. #define SPAWN_CONDITIONAL_NONE 0
  84. #define SPAWN_CONDITIONAL_DAY 1
  85. #define SPAWN_CONDITIONAL_NIGHT 2
  86. #define SPAWN_CONDITIONAL_NOT_RAINING 4
  87. #define SPAWN_CONDITIONAL_RAINING 8
  88. #define MAX_REVIVEPOINT_DISTANCE 1000
  89. /* JA: TODO Turn into R_World Rules */
  90. #define SEND_SPAWN_DISTANCE 250 /* when spawns appear visually to the client */
  91. #define HEAR_SPAWN_DISTANCE 30 /* max distance a client can be from a spawn to 'hear' it */
  92. #define MAX_CHASE_DISTANCE 80
  93. #define REMOVE_SPAWN_DISTANCE 300 // increased distance between send/remove is ideal, this makes sure there is no overlap if a 'fast' client (AKA GM warp speed)
  94. #define TRACKING_STOP 0
  95. #define TRACKING_START 1
  96. #define TRACKING_UPDATE 2
  97. #define TRACKING_CLOSE_WINDOW 3
  98. #define TRACKING_TYPE_ENTITIES 1
  99. #define TRACKING_TYPE_HARVESTABLES 2
  100. #define TRACKING_SPAWN_TYPE_PC 0
  101. #define TRACKING_SPAWN_TYPE_NPC 1
  102. #define WAYPOINT_CATEGORY_GROUP 0
  103. #define WAYPOINT_CATEGORY_QUESTS 1
  104. #define WAYPOINT_CATEGORY_PEOPLE 2
  105. #define WAYPOINT_CATEGORY_PLACES 3
  106. #define WAYPOINT_CATEGORY_USER 4
  107. #define WAYPOINT_CATEGORY_DIRECTIONS 5
  108. #define WAYPOINT_CATEGORY_TRACKING 6
  109. #define WAYPOINT_CATEGORY_HOUSES 7
  110. #define WAYPOINT_CATEGORY_MAP 8
  111. struct PlayerProximity{
  112. float distance;
  113. string in_range_lua_function;
  114. string leaving_range_lua_function;
  115. map<Client*, bool> clients_in_proximity;
  116. };
  117. struct LocationProximity {
  118. float x;
  119. float y;
  120. float z;
  121. float max_variation;
  122. string in_range_lua_function;
  123. string leaving_range_lua_function;
  124. map<Client*, bool> clients_in_proximity;
  125. };
  126. struct LocationGrid {
  127. int32 id;
  128. int32 grid_id;
  129. string name;
  130. bool include_y;
  131. bool discovery;
  132. MutexList<Location*> locations;
  133. MutexMap<Player*, bool> players;
  134. };
  135. struct TrackedSpawn {
  136. Spawn* spawn;
  137. float distance;
  138. };
  139. struct HouseItem {
  140. int32 spawn_id;
  141. int32 item_id;
  142. int32 unique_id;
  143. Item* item;
  144. };
  145. class Widget;
  146. class Client;
  147. class Sign;
  148. class Object;
  149. class GroundSpawn;
  150. struct GroundSpawnEntry;
  151. struct GroundSpawnEntryItem;
  152. struct LootTable;
  153. struct LootDrop;
  154. struct GlobalLoot;
  155. struct TransportDestination;
  156. struct LocationTransportDestination;
  157. #ifdef WIN32
  158. void ZoneLoop(void *tmp);
  159. void SpawnLoop(void *tmp);
  160. void SendInitialSpawns(void *tmp);
  161. void SendLevelChangedSpawns(void*tmp);
  162. #else
  163. void *ZoneLoop(void *tmp);
  164. void *SpawnLoop(void *tmp);
  165. void *SendInitialSpawns(void *tmp);
  166. void *SendLevelChangedSpawns(void *tmp);
  167. #endif
  168. using namespace std;
  169. struct RevivePoint{
  170. int32 id;
  171. int32 zone_id; //usually this zone, but not always
  172. string location_name;
  173. float x;
  174. float y;
  175. float z;
  176. float heading;
  177. };
  178. struct SpawnScriptTimer {
  179. int32 timer;
  180. int32 spawn;
  181. int32 player;
  182. string function;
  183. int32 current_count;
  184. int32 max_count;
  185. };
  186. enum Instance_Type {
  187. NONE,
  188. GROUP_LOCKOUT_INSTANCE,
  189. GROUP_PERSIST_INSTANCE,
  190. RAID_LOCKOUT_INSTANCE,
  191. RAID_PERSIST_INSTANCE,
  192. SOLO_LOCKOUT_INSTANCE,
  193. SOLO_PERSIST_INSTANCE,
  194. TRADESKILL_INSTANCE, // allows anyone to enter, server searches for the first instance that is available
  195. PUBLIC_INSTANCE, // same as tradeskill, except dead spawns are tracked
  196. PERSONAL_HOUSE_INSTANCE,
  197. GUILD_HOUSE_INSTANCE,
  198. QUEST_INSTANCE
  199. };
  200. struct FlightPathInfo {
  201. float speed;
  202. bool flying;
  203. bool dismount;
  204. };
  205. struct FlightPathLocation {
  206. float X;
  207. float Y;
  208. float Z;
  209. };
  210. struct ZoneInfoSlideStructInfo {
  211. float unknown1[2];
  212. int32 unknown2[2];
  213. int32 unknown3;
  214. int32 unknown4;
  215. char slide[128];
  216. char voiceover[128];
  217. int32 key1;
  218. int32 key2;
  219. };
  220. struct ZoneInfoSlideStructTransitionInfo {
  221. int32 transition_x;
  222. int32 transition_y;
  223. float transition_zoom;
  224. float transition_time;
  225. };
  226. struct ZoneInfoSlideStruct {
  227. ZoneInfoSlideStructInfo* info;
  228. vector<ZoneInfoSlideStructTransitionInfo*> slide_transition_info;
  229. };
  230. class SPGrid;
  231. // need to attempt to clean this up and add xml comments, remove unused code, find a logical way to sort the functions maybe by get/set/process/add etc...
  232. class ZoneServer {
  233. public:
  234. ZoneServer(const char* file);
  235. ~ZoneServer();
  236. void Init();
  237. bool Process();
  238. bool SpawnProcess();
  239. ZoneInfoSlideStruct* GenerateSlideStruct(float unknown1a, float unknown1b, int32 unknown2a, int32 unknown2b, int32 unknown3, int32 unknown4, const char* slide, const char* voiceover, int32 key1, int32 key2);
  240. void AddZoneInfoSlideStructTransitionInfo(ZoneInfoSlideStruct* info, int32 x, int32 y, float zoom, float transition_time);
  241. vector<ZoneInfoSlideStruct*>* GenerateTutorialSlides();
  242. void LoadRevivePoints(vector<RevivePoint*>* revive_points);
  243. vector<RevivePoint*>* GetRevivePoints(Client* client);
  244. RevivePoint* GetRevivePoint(int32 id);
  245. void AddClient(Client* client);
  246. void SimpleMessage(int8 type, const char* message, Spawn* from, float distance, bool send_to_sender = true);
  247. void HandleChatMessage(Spawn* from, const char* to, int16 channel, const char* message, float distance = 0, const char* channel_name = 0, bool show_bubble = true, int32 language = 0);
  248. void HandleChatMessage(Client* client, Spawn* from, const char* to, int16 channel, const char* message, float distance = 0, const char* channel_name = 0, bool show_bubble = true, int32 language = 0);
  249. void HandleBroadcast(const char* message);
  250. void HandleAnnouncement(const char* message);
  251. int16 SetSpawnTargetable(Spawn* spawn, float distance);
  252. int16 SetSpawnTargetable(int32 spawn_id);
  253. void ApplySetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value);
  254. void SetSpawnCommand(Spawn* spawn, int8 type, char* value, Client* client = 0);
  255. void SetSpawnCommand(int32 spawn_id, int8 type, char* value, Client* client = 0);
  256. void AddLoot(NPC* npc);
  257. NPC* AddNPCSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  258. Object* AddObjectSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  259. GroundSpawn* AddGroundSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  260. Widget* AddWidgetSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  261. Sign* AddSignSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  262. void AddSpawn(Spawn* spawn);
  263. void RemoveDeadEnemyList(Spawn* spawn);
  264. void RemoveDeadSpawn(Spawn* spawn);
  265. void AddSpawnGroupLocation(int32 group_id, int32 location_id, int32 spawn_location_id);
  266. void AddSpawnGroupAssociation(int32 group_id1, int32 group_id2);
  267. void AddSpawnGroupChance(int32 group_id, float percent);
  268. void RemoveSpawn(Spawn* spawn, bool delete_spawn = true, bool respawn = true, bool lock = true, bool erase_from_spawn_list = true);
  269. void ProcessSpawnLocations();
  270. void SendQuestUpdates(Client* client, Spawn* spawn = 0);
  271. EQ2Packet* GetZoneInfoPacket(Client* client);
  272. Spawn* FindSpawn(Player* searcher, const char* name);
  273. bool CallSpawnScript(Spawn* npc, int8 type, Spawn* spawn = 0, const char* message = 0, bool is_door_open = false);
  274. void SendSpawnVisualState(Spawn* spawn, int16 type);
  275. void SendSpellFailedPacket(Client* client, int16 error);
  276. void SendInterruptPacket(Spawn* interrupted, LuaSpell* spell);
  277. void HandleEmote(Client* originator, string name);
  278. Client* GetClientBySpawn(Spawn* spawn);
  279. Spawn* GetSpawnByDatabaseID(int32 id);
  280. Spawn* GetSpawnByID(int32 id, bool spawnListLocked=false);
  281. void PlaySoundFile(Client* client, const char* name, float origin_x, float origin_y, float origin_z);
  282. void SendZoneSpawns(Client* client);
  283. void StartZoneInitialSpawnThread(Client* client);
  284. void SendSpawnChanges();
  285. void SendSpawnChanges(Spawn* spawn);
  286. void SendSpawnChanges(Spawn* spawn, Client* client, bool override_changes = false, bool override_vis_changes = false);
  287. void SendSpawnChangesByDBID(int32 spawn_id, Client* client, bool override_changes = false, bool override_vis_changes = false);
  288. void SendPlayerPositionChanges(Player* player);
  289. void UpdateVitality(float amount);
  290. vector<Entity*> GetPlayers();
  291. void KillSpawn(bool spawnListLocked, Spawn* dead, Spawn* killer, bool send_packet = true, int8 damage_type = 0, int16 kill_blow_type = 0);
  292. void SendDamagePacket(Spawn* attacker, Spawn* victim, int8 type1, int8 type2, int8 damage_type, int16 damage, const char* spell_name);
  293. void SendHealPacket(Spawn* caster, Spawn* target, int16 type, int32 heal_amt, const char* spell_name);
  294. void SendCastSpellPacket(LuaSpell* spell, Entity* caster);
  295. void SendCastSpellPacket(int32 spell_visual, Spawn* target, Spawn* caster = 0);
  296. void SendCastEntityCommandPacket(EntityCommand* entity_command, int32 spawn_id, int32 target_id);
  297. void TriggerCharSheetTimer();
  298. /// <summary>Sends the game time packet to all connected clients</summary>
  299. void SendTimeUpdateToAllClients();
  300. void AddWidgetTimer(Spawn* widget, float time);
  301. bool HasWidgetTimer(Spawn* widget);
  302. void AddHeadingTimer(Spawn* spawn);
  303. void Despawn(Spawn* spawn, int32 timer);
  304. void RepopSpawns(Client* client, Spawn* spawn);
  305. bool AddCloseSpawnsToSpawnGroup(Spawn* spawn, float radius);
  306. void Depop(bool respawns = false, bool repop = false);
  307. Spawn* GetSpawnGroup(int32 id);
  308. void AddEnemyList(NPC* npc);
  309. void ReloadClientQuests();
  310. void SendAllSpawnsForLevelChange(Client* client);
  311. void SendAllSpawnsForSeeInvisChange(Client* client);
  312. void SendAllSpawnsForVisChange(Client* client, bool limitToEntities=true);
  313. void AddLocationGrid(LocationGrid* grid);
  314. void RemoveLocationGrids();
  315. void DeleteTransporters();
  316. void CheckTransporters(Client* client);
  317. void WritePlayerStatistics();
  318. bool SendRadiusSpawnInfo(Client* client, float radius);
  319. void FindSpawn(Client* client, char* regSearchStr);
  320. volatile bool spawnthread_active;
  321. volatile bool combatthread_active;
  322. volatile int8 initial_spawn_threads_active;
  323. volatile bool client_thread_active;
  324. void AddChangedSpawn(Spawn* spawn);
  325. void AddDamagedSpawn(Spawn* spawn);
  326. void AddDrowningVictim(Player* player);
  327. void RemoveDrowningVictim(Player* player);
  328. Client* GetDrowningVictim(Player* player);
  329. void DeleteSpellProcess();
  330. void LoadSpellProcess();
  331. void LockAllSpells(Player* player);
  332. void UnlockAllSpells(Player* player);
  333. void RemoveSpellTimersFromSpawn(Spawn* spawn, bool remove_all, bool delete_recast = true);
  334. void Interrupted(Entity* caster, Spawn* interruptor, int16 error_code, bool cancel = false, bool from_movement = false);
  335. Spell* GetSpell(Entity* caster);
  336. void ProcessSpell(Spell* spell, Entity* caster, Spawn* target = 0, bool lock = true, bool harvest_spell = false, LuaSpell* customSpell = 0, int16 custom_cast_time = 0, bool in_heroic_opp = false);
  337. void ProcessEntityCommand(EntityCommand* entity_command, Entity* caster, Spawn* target, bool lock = true);
  338. void AddPlayerTracking(Player* player);
  339. void RemovePlayerTracking(Player* player, int8 mode);
  340. void SendUpdateTitles(Client *client, Title *suffix = 0, Title *prefix = 0);
  341. void SendUpdateTitles(Spawn *spawn, Title *suffix = 0, Title *prefix = 0);
  342. void RemoveTargetFromSpell(LuaSpell* spell, Spawn* target);
  343. /// <summary>Set the rain levl in the zone</summary>
  344. /// <param name='val'>Level of rain in the zone 0.0 - 1.1 (rain starts at 0.76)</param>
  345. void SetRain(float val);
  346. /// <summary>Sets the wind direction</summary>
  347. /// <param name='val'>Direction in degrees to set the wind</param>
  348. void SetWind(float val);
  349. /// <summary>Handles zone-wide weather changes</summary>
  350. void ProcessWeather();
  351. Spawn* GetClosestTransportSpawn(float x, float y, float z);
  352. void ResurrectSpawn(Spawn* spawn, Client* client);
  353. void HidePrivateSpawn(Spawn* spawn);
  354. Client* GetClientByName(char* name);
  355. /// <summary>Gets spawns for a true AoE spell</summary>
  356. vector<Spawn*> GetAttackableSpawnsByDistance(Spawn* spawn, float distance);
  357. void StartZoneSpawnsForLevelThread(Client* client);
  358. void SendDispellPacket(Entity* caster, Spawn* target, string dispell_name, string spell_name, int8 dispell_type);
  359. void SetupInstance(int32 createdInstanceID=0);
  360. void SendUpdateDefaultCommand(Spawn* spawn, const char* command, float distance, Spawn* toplayer = NULL);
  361. map<int32, int32>* GetSpawnLocationsByGroup(int32 group_id);
  362. IPathfinder* pathing;
  363. MobMovementManager* movementMgr;
  364. /****************************************************
  365. Following functions are only used for LUA commands
  366. ****************************************************/
  367. int32 GetClosestLocation(Spawn* spawn);
  368. Spawn* GetClosestSpawn(Spawn* spawn, int32 spawn_id);
  369. SpawnLocation* GetSpawnLocation(int32 id);
  370. void PlayFlavor(Client* client, Spawn* spawn, const char* mp3, const char* text, const char* emote, int32 key1, int32 key2, int8 language);
  371. void PlayVoice(Client* client, Spawn* spawn, const char* mp3, int32 key1, int32 key2);
  372. void PlayFlavor(Spawn* spawn, const char* mp3, const char* text, const char* emote, int32 key1, int32 key2, int8 language);
  373. void PlayVoice(Spawn* spawn, const char* mp3, int32 key1, int32 key2);
  374. void SendThreatPacket(Spawn* caster, Spawn* target, int32 threat_amt, const char* spell_name);
  375. void KillSpawnByDistance(Spawn* spawn, float max_distance, bool include_players = false, bool send_packet = false);
  376. void SpawnSetByDistance(Spawn* spawn, float max_distance, string field, string value);
  377. void AddSpawnScriptTimer(SpawnScriptTimer* timer);
  378. Spawn* GetSpawnByLocationID(int32 location_id);
  379. void AddMovementNPC(Spawn* spawn);
  380. void AddPlayerProximity(Spawn* spawn, float distance, string in_range_function, string leaving_range_function);
  381. void AddLocationProximity(float x, float y, float z, float max_variation, string in_range_function, string leaving_range_function);
  382. void PlayAnimation(Spawn* spawn, int32 visual_state, Spawn* spawn2 = 0, int8 type = 1);
  383. void AddTransportSpawn(Spawn* spawn);
  384. vector<Spawn*> GetSpawnsByID(int32 id);
  385. bool IsDusk() { return isDusk; } // never used, probably meant for lua though
  386. /****************************************************
  387. Following functions are all contained in the header
  388. ****************************************************/
  389. inline const char* GetZoneName() { return zone_name; }
  390. void SetZoneName(char* new_zone) {
  391. if( strlen(new_zone) >= sizeof zone_name )
  392. return;
  393. strcpy(zone_name, new_zone);
  394. }
  395. inline const char* GetZoneFile() { return zone_file; }
  396. void SetZoneFile(char* zone) {
  397. if (strlen(zone) >= sizeof zone_file)
  398. return;
  399. strcpy(zone_file, zone);
  400. }
  401. inline const char* GetZoneSkyFile() { return zonesky_file; }
  402. void SetZoneSkyFile(char* zone) {
  403. if (strlen(zone) >= sizeof zonesky_file)
  404. return;
  405. strcpy(zonesky_file, zone);
  406. }
  407. inline const char* GetZoneDescription() { return zone_description; }
  408. void SetZoneDescription(char* desc) {
  409. if( strlen(desc) >= sizeof zone_description )
  410. return;
  411. strcpy(zone_description, desc);
  412. }
  413. void SetUnderWorld(float under){ underworld = under; }
  414. inline int32 GetZoneID() { return zoneID; }
  415. void SetZoneID(int32 new_id){ zoneID = new_id; }
  416. inline bool IsCityZone() { return cityzone; }
  417. inline bool AlwaysLoaded() { return always_loaded; }
  418. void SetCityZone(bool val) { cityzone = val; }
  419. void SetAlwaysLoaded(bool val) { always_loaded = val; }
  420. inline int32& NumPlayers() { return pNumPlayers; }
  421. void SetMinimumStatus(sint16 minStatus) { minimumStatus = minStatus; }
  422. sint16 GetMinimumStatus() { return minimumStatus; }
  423. void SetMinimumLevel(int16 minLevel) { minimumLevel = minLevel; }
  424. void SetMaximumLevel(int16 maxLevel) { maximumLevel = maxLevel; }
  425. void SetMinimumVersion(int16 minVersion) { minimumVersion = minVersion; }
  426. int16 GetMinimumLevel() { return minimumLevel; }
  427. int16 GetMaximumLevel() { return maximumLevel; }
  428. int16 GetMinimumVersion() { return minimumVersion; }
  429. inline bool GetZoneLockState() { return locked; } // JA: /zone lock|unlock
  430. void SetZoneLockState(bool lock_state) { locked = lock_state; } // JA: /zone lock|unlock
  431. int32 GetInstanceID() { return instanceID; }
  432. bool IsInstanceZone() { return isInstance; }
  433. void SetShutdownTimer(int val){
  434. shutdownTimer.SetTimer(val*1000);
  435. }
  436. void AddSpawnLocation(int32 id, SpawnLocation* spawnlocation) {
  437. MSpawnLocationList.writelock(__FUNCTION__, __LINE__);
  438. if (spawn_location_list.count(id) > 0)
  439. safe_delete(spawn_location_list[id]);
  440. spawn_location_list[id] = spawnlocation;
  441. MSpawnLocationList.releasewritelock(__FUNCTION__, __LINE__);
  442. }
  443. void SetInstanceType(int16 type) { InstanceType = (Instance_Type)type; if(type>0)isInstance=true; else isInstance=false; }
  444. Instance_Type GetInstanceType() { return InstanceType; }
  445. float GetSafeX(){ return safe_x; }
  446. float GetSafeY(){ return safe_y; }
  447. float GetSafeZ(){ return safe_z; }
  448. float GetSafeHeading() { return safe_heading; }
  449. void SetSafeX(float val){ safe_x = val; }
  450. void SetSafeY(float val){ safe_y = val; }
  451. void SetSafeZ(float val){ safe_z = val; }
  452. void SetSafeHeading(float val) { safe_heading = val; }
  453. float GetXPModifier() { return xp_mod; }
  454. void SetXPModifier(float val) { xp_mod = val; }
  455. void SetZoneMOTD(string z_motd) { zone_motd = z_motd; }
  456. string GetZoneMOTD() { return zone_motd; }
  457. bool isZoneShuttingDown ( ) { return zoneShuttingDown; }
  458. void Shutdown(){ zoneShuttingDown = true; }
  459. int32 GetClientCount(){ return clients.size(); }
  460. int32 GetDefaultLockoutTime() { return def_lockout_time; }
  461. int32 GetDefaultReenterTime() { return def_reenter_time; }
  462. int32 GetDefaultResetTime() { return def_reset_time; }
  463. int8 GetForceGroupZoneOption() { return group_zone_option; }
  464. void SetDefaultLockoutTime(int32 val) { def_lockout_time = val; }
  465. void SetDefaultReenterTime(int32 val) { def_reenter_time = val; }
  466. void SetDefaultResetTime(int32 val) { def_reset_time = val; }
  467. void SetForceGroupZoneOption(int8 val) { group_zone_option = val; }
  468. SpellProcess* GetSpellProcess() {return spellProcess;}
  469. bool FinishedDepop(){ return finished_depop; }
  470. /// <summary>Returns the Tradeskill Manager for this zone</summary>
  471. TradeskillMgr* GetTradeskillMgr() { return tradeskillMgr; }
  472. // had to add these to access weather from Commands
  473. bool isWeatherEnabled() { return weather_enabled; }
  474. void SetWeatherEnabled(bool val) { weather_enabled = val; }
  475. bool isWeatherAllowed() { return weather_allowed; }
  476. void SetWeatherAllowed(bool val) { weather_allowed = val; }
  477. int8 GetWeatherType() { return weather_type; }
  478. void SetWeatherType(int8 val) { weather_type = val; }
  479. int32 GetWeatherFrequency() { return weather_frequency; }
  480. void SetWeatherFrequency(int32 val) { weather_frequency = val; }
  481. float GetWeatherMinSeverity() { return weather_min_severity; }
  482. void SetWeatherMinSeverity(float val) { weather_min_severity = val; }
  483. float GetWeatherMaxSeverity() { return weather_max_severity; }
  484. void SetWeatherMaxSeverity(float val) { weather_max_severity = val; }
  485. float GetWeatherChangeAmount() { return weather_change_amount; }
  486. void SetWeatherChangeAmount(float val) { weather_change_amount = val; }
  487. float GetWeatherDynamicOffset() { return weather_dynamic_offset; }
  488. void SetWeatherDynamicOffset(float val) { weather_dynamic_offset = val; }
  489. int8 GetWeatherChance() { return weather_change_chance; }
  490. void SetWeatherChance(int8 val) { weather_change_chance = val; }
  491. float GetCurrentWeather() { return weather_current_severity; }
  492. void SetCurrentWeather(float val) { weather_current_severity = val; }
  493. int8 GetWeatherPattern() { return weather_pattern; }
  494. void SetWeatherPattern(int8 val) { weather_pattern = val; }
  495. void SetWeatherLastChangedTime(int32 val) { weather_last_changed_time = val; }
  496. int32 GetExpansionFlag() { return expansion_flag; }
  497. void SetExpansionFlag(int32 val) { expansion_flag = val; }
  498. int32 GetHolidayFlag() { return holiday_flag; }
  499. void SetHolidayFlag(int32 val) { holiday_flag = val; }
  500. void RemoveClientImmediately(Client* client);
  501. void ClearHate(Entity* entity);
  502. /****************************************************
  503. Following functions are pending deletion, left in for
  504. now just to make sure one won't be of future use.
  505. ****************************************************/
  506. //void RemoveFromRangeMap(Client* client); // never used?
  507. //void AddSpawnAssociatedGroup(vector<int32>* ret, int32 group_id); // never used, not even any code for it
  508. //inline const char* GetCAddress() { return clientaddress; } // never used?
  509. //inline int16 GetCPort() { return clientport; } // never used?
  510. //inline bool IsBootingUp() { return BootingUp; } // never used?
  511. //int32 GetShutdownTimer() {return shutdownTimer.GetTimerTime();} // never used
  512. //float GetUnderWorld(){ return underworld; } // function never used but variable is
  513. // Following were private
  514. //char clientaddress[250]; // never used
  515. //int16 clientport; // never used
  516. //bool BootingUp; // never used
  517. //bool authenticated; // never used?
  518. //int16 next_index; // never used
  519. void AddFlightPath(int32 id, FlightPathInfo* info);
  520. void AddFlightPathLocation(int32 id, FlightPathLocation* location);
  521. void DeleteFlightPaths();
  522. void SendFlightPathsPackets(Client* client);
  523. int32 GetFlightPathIndex(int32 id);
  524. float GetFlightPathSpeed(int32 id);
  525. void SendSpawn(Spawn* spawn, Client* client); // moved from private to public for bots
  526. void ProcessSpawnConditional(int8 condition);
  527. void SetSpawnStructs(Client* client);
  528. void AddSpawnProximities(Spawn* spawn);
  529. void RemoveSpawnProximities(Spawn* spawn);
  530. void SetSpawnScript(SpawnEntry* entry, Spawn* spawn);
  531. bool IsLoading() {
  532. return LoadingData;
  533. }
  534. vector<HouseItem> GetHouseItems(Client* client);
  535. Spawn* GetSpawnFromUniqueItemID(int32 unique_id);
  536. void SendHouseItems(Client* client);
  537. MutexMap<int32, int32> house_object_database_lookup; // 1st int32 = model type, 2nd int32 = spawn id
  538. int32 GetWatchdogTime() { return watchdogTimestamp; }
  539. void SetWatchdogTime(int32 time) { watchdogTimestamp = time; }
  540. void CancelThreads();
  541. void AddPendingSpawnRemove(int32 id);
  542. void ProcessSpawnRemovals();
  543. bool SendRemoveSpawn(Client* client, Spawn* spawn, PacketStruct* packet = 0, bool delete_spawn = false);
  544. void AddSpawnToGroup(Spawn* spawn, int32 group_id);
  545. private:
  546. #ifndef WIN32
  547. pthread_t ZoneThread;
  548. pthread_t SpawnThread;
  549. #endif
  550. /* Private Functions */
  551. void AddTransporter(LocationTransportDestination* loc);
  552. void CheckDeadSpawnRemoval();
  553. void DeleteData(bool boot_clients = true);
  554. void DeleteFactionLists();
  555. void ProcessDepop(bool respawns_allowed = false, bool repop = false);
  556. /*
  557. Following functions were public but never used outside the zone server so moved them to private
  558. */
  559. void ClientProcess(); // never used outside zone server
  560. void RemoveClient(Client* client); // never used outside zone server
  561. void DeterminePosition(SpawnLocation* spawnlocation, Spawn* spawn); // never used outside zone server
  562. void AddDeadSpawn(Spawn* spawn, int32 timer = 0xFFFFFFFF); // never used outside zone server
  563. int32 CalculateSpawnGroup(SpawnLocation* spawnlocation, bool respawn = false); // never used outside zone server
  564. float GetSpawnGroupChance(int32 group_id); // never used outside zone server
  565. vector<int32>* GetAssociatedLocations(set<int32>* groups); // never used outside zone server
  566. set<int32>* GetAssociatedGroups(int32 group_id); // never used outside zone server
  567. list<int32>* GetSpawnGroupsByLocation(int32 location_id); // never used outside zone server
  568. void ProcessSpawnLocation(int32 location_id, bool respawn = false); // never used outside zone server
  569. Spawn* ProcessSpawnLocation(SpawnLocation* spawnlocation, bool respawn = false); // never used outside zone server
  570. Spawn* ProcessInstanceSpawnLocation(SpawnLocation* spawnlocation, map<int32,int32>* instNPCs, map<int32,int32>* instGroundSpawns, map<int32,int32>* instObjSpawns, map<int32,int32>* instWidgetSpawns, map<int32,int32>* instSignSpawns, bool respawn = false); // never used outside zone server
  571. void SendCharSheetChanges(); // never used outside zone server
  572. void SendCharSheetChanges(Client* client); // never used outside zone server
  573. void SaveClients(); // never used outside zone server
  574. void CheckSendSpawnToClient(); // never used outside zone server
  575. void CheckSendSpawnToClient(Client* client, bool initial_login = false); // never used outside zone server
  576. void CheckRemoveSpawnFromClient(Spawn* spawn); // never used outside zone server
  577. void SaveClient(Client* client); // never used outside zone server
  578. void ProcessFaction(Spawn* spawn, Client* client); // never used outside zone server
  579. void RegenUpdate(); // never used outside zone server
  580. void SendCalculatedXP(Player* player, Spawn* victim); // never used outside zone server, might not be used at all any more
  581. void SendTimeUpdate(Client* client); // never used outside zone server
  582. void CheckWidgetTimers(); // never used outside zone server
  583. void CheckRespawns(); // never used outside zone server
  584. void CheckSpawnExpireTimers(); // never used outside zone server
  585. void AddSpawnExpireTimer(Spawn* spawn, int32 expire_time, int32 expire_offset = 0); // never used outside zone server
  586. void CheckSpawnRange(Client* client, Spawn* spawn, bool initial_login = false); // never used outside zone server
  587. void CheckSpawnRange(Spawn* spawn); // never used outside zone server
  588. void DeleteSpawnScriptTimers(Spawn* spawn, bool all = false); // never used outside zone server
  589. void DeleteSpawnScriptTimers(); // never used outside zone server
  590. void CheckSpawnScriptTimers(); // never used outside zone server
  591. void CheckHeadingTimers(); // never used outside zone server
  592. void RemoveHeadingTimer(Spawn* spawn); // never used outside zone server
  593. void PrepareSpawnID(Player* player, Spawn* spawn); // never used outside zone server
  594. void RemoveMovementNPC(Spawn* spawn); // never used outside zone server
  595. bool CheckNPCAttacks(NPC* npc, Spawn* victim, Client* client = 0); // never used outside zone server
  596. bool AggroVictim(NPC* npc, Spawn* victim, Client* client = 0); // never used outside zone server
  597. bool CheckEnemyList(NPC* npc); // never used outside zone server
  598. void RemovePlayerProximity(Spawn* spawn, bool all = false); // never used outside zone server
  599. void RemovePlayerProximity(Client* client); // never used outside zone server
  600. void CheckPlayerProximity(Spawn* spawn, Client* client); // never used outside zone server
  601. void RemoveLocationProximities(); // never used outside zone server
  602. void CheckLocationProximity(); // never used outside zone server
  603. void CheckLocationGrids(); // never used outside zone server
  604. void RemoveSpawnSupportFunctions(Spawn* spawn); // never used outside zone server
  605. void ReloadTransporters(); // never used outside zone server
  606. void DeleteSpawns(bool delete_all); // never used outside zone server
  607. void AddPendingDelete(Spawn* spawn); // never used outside zone server
  608. void RemovePendingDelete(Spawn* spawn); // never used outside zone server
  609. void ClearDeadSpawns(); // never used outside zone server
  610. void RemoveChangedSpawn(Spawn* spawn); // never used outside zone server
  611. void ProcessDrowning(); // never used outside zone server
  612. void RemoveDamagedSpawn(Spawn* spawn); // never used outside zone server
  613. void ProcessTracking(); // never used outside zone server
  614. void ProcessTracking(Client* client); // never used outside zone server
  615. void SendEpicMobDeathToGuild(Player* killer, Spawn* victim); // never used outside zone server
  616. void ProcessAggroChecks(Spawn* spawn); // never used outside zone server
  617. /// <summary>Checks to see if it is time to remove a spawn and removes it</summary>
  618. /// <param name='force_delete_all'>Forces all spawns scheduled to be removed regardless of time</param>
  619. bool CombatProcess(Spawn* spawn); // never used outside zone server
  620. void InitWeather(); // never used outside zone server
  621. ///<summary>Dismiss all pets in the zone, useful when the spell process needs to be reloaded</summary>
  622. void DismissAllPets(); // never used outside zone server
  623. /* Mutex Lists */
  624. MutexList<int32> changed_spawns; // int32 = spawn id
  625. vector<Client*> clients;
  626. MutexList<Client*> connected_clients; // probably remove this list so we are not maintaining 2 client lists
  627. MutexList<int32> damaged_spawns; // int32 = spawn id
  628. MutexList<LocationProximity*> location_proximities;
  629. MutexList<LocationGrid*> location_grids;
  630. MutexList<int32> remove_movement_spawns; // int32 = spawn id
  631. set<SpawnScriptTimer*> spawn_script_timers;
  632. Mutex MSpawnScriptTimers;
  633. set<SpawnScriptTimer*> remove_spawn_script_timers_list;
  634. Mutex MRemoveSpawnScriptTimersList;
  635. list<LocationTransportDestination*> transporter_locations;
  636. /* Mutex Maps */
  637. MutexMap<Spawn*, Client*> client_spawn_map; // ok
  638. MutexMap<Client*, int32> drowning_victims;
  639. MutexMap<Spawn*, int32> heading_timers;
  640. MutexMap<int32, int32> movement_spawns; // 1st int32 = spawn id
  641. MutexMap<int32, PlayerProximity*> player_proximities; // 1st int32 = spawn id
  642. MutexMap<int32, Player*> players_tracking;
  643. MutexMap<int32, int32> quick_database_id_lookup; // 1st int32 = database id, 2nd int32 = spawn id
  644. MutexMap<int32, int32> respawn_timers;
  645. map<Spawn*, int32> spawn_delete_list;
  646. MutexMap<int32, int32> spawn_expire_timers; // 1st int32 = spawn id
  647. map<int32, set<int32>* > spawn_group_associations;
  648. map<int32, float> spawn_group_chances;
  649. map<int32, map<int32, int32>* > spawn_group_locations;
  650. MutexMap<int32, MutexList<int32> > spawn_group_map; // MutexList<int32> is a list of spawn id's
  651. map<int32, list<int32>* > spawn_location_groups;
  652. map<int32, SpawnLocation*> spawn_location_list;
  653. MutexMap<Client*, MutexMap<int32, float >* > spawn_range_map; // int32 in the MutexMap<int32, float>* = spawn id, float = distance
  654. Mutex MWidgetTimers;
  655. map<int32, int32> widget_timers; // 1st int32 = spawn id
  656. /* Mutexs */
  657. Mutex m_enemy_faction_list;
  658. Mutex m_npc_faction_list;
  659. Mutex m_reverse_enemy_faction_list;
  660. Mutex MDeadSpawns;
  661. CriticalSection* MMasterZoneLock; //This needs to be a recursive lock to fix a possible /reload spells crash with multiple zones loaded - Foof
  662. Mutex MMasterSpawnLock;
  663. Mutex MPendingSpawnListAdd;
  664. Mutex MSpawnList;
  665. Mutex MTransportSpawns;
  666. Mutex MSpawnGroupAssociation;
  667. Mutex MSpawnGroupLocations;
  668. Mutex MSpawnLocationGroups;
  669. Mutex MSpawnGroupChances;
  670. Mutex MTransportLocations;
  671. Mutex MSpawnLocationList;
  672. Mutex MSpawnDeleteList;
  673. Mutex MClientList;
  674. /* Maps */
  675. map<int32, int32> dead_spawns;
  676. map<int32, vector<int32>* > enemy_faction_list;
  677. map<int32, vector<int32>* > npc_faction_list;
  678. map<int32, vector<int32>* > reverse_enemy_faction_list;
  679. map<int32, Spawn*> spawn_list;
  680. map<int32, FlightPathInfo*> m_flightPaths;
  681. map<int32, vector<FlightPathLocation*> > m_flightPathRoutes;
  682. /* Lists */
  683. list<Spawn*> pending_spawn_list_add;
  684. /* Vectors */
  685. vector<RevivePoint*>* revive_points;
  686. vector<int32> transport_spawns;
  687. /* Classes */
  688. SpellProcess* spellProcess;
  689. TradeskillMgr* tradeskillMgr;
  690. /* Timers */
  691. Timer aggro_timer;
  692. Timer charsheet_changes;
  693. Timer client_save;
  694. Timer location_prox_timer;
  695. Timer location_grid_timer;
  696. Timer movement_timer;
  697. Timer regenTimer;
  698. Timer respawn_timer;
  699. Timer shutdownTimer;
  700. Timer spawn_check_add;
  701. Timer spawn_check_remove;
  702. Timer spawn_expire_timer;
  703. Timer spawn_range;
  704. Timer spawn_update;
  705. Timer sync_game_time_timer;
  706. Timer tracking_timer;
  707. Timer weatherTimer;
  708. Timer widget_timer;
  709. /* Enums */
  710. Instance_Type InstanceType;
  711. /* Variables */
  712. volatile bool finished_depop;
  713. volatile bool depop_zone;
  714. volatile bool repop_zone;
  715. volatile bool respawns_allowed;
  716. volatile bool LoadingData;
  717. bool reloading_spellprocess;
  718. bool zoneShuttingDown;
  719. bool cityzone;
  720. bool always_loaded;
  721. bool isInstance;
  722. int32 pNumPlayers;
  723. sint16 minimumStatus;
  724. int16 minimumLevel;
  725. int16 maximumLevel;
  726. int16 minimumVersion;
  727. char zone_name[64];
  728. char zonesky_file[64];
  729. char zone_file[64];
  730. char zone_description[255];
  731. float underworld;
  732. float safe_x;
  733. float safe_y;
  734. float safe_z;
  735. float safe_heading;
  736. float xp_mod;
  737. volatile int32 zoneID;
  738. bool locked; // JA: implementing /zone lock|unlock commands
  739. int32 instanceID;
  740. string zone_motd;
  741. int32 def_reenter_time;
  742. int32 def_reset_time;
  743. int32 def_lockout_time;
  744. int8 group_zone_option;
  745. float rain;
  746. bool isDusk;
  747. int dusk_hour;
  748. int dawn_hour;
  749. int dusk_minute;
  750. int dawn_minute;
  751. int32 spawn_delete_timer;
  752. int32 expansion_flag;
  753. int32 holiday_flag;
  754. map<int16, PacketStruct*> versioned_pos_structs;
  755. map<int16, PacketStruct*> versioned_info_structs;
  756. map<int16, PacketStruct*> versioned_vis_structs;
  757. /* Weather Stuff */
  758. bool weather_enabled; // false = disabled, true = enabled
  759. int8 weather_type; // 0 = normal, 1 = dynamic, 2 = random, 3 = chaotic
  760. int32 weather_frequency; // how often weather changes
  761. float weather_min_severity; // minimum weather severity in a zone
  762. float weather_max_severity; // maximum weather severity in a zone
  763. float weather_change_amount; // how much does the weather change each interval (normal weather conditions)
  764. float weather_dynamic_offset; // max amount the weather change each interval (dynamic weather conditions)
  765. int8 weather_change_chance; // percentage chance the weather will change
  766. int8 weather_pattern; // 0 = decreasing severity, 1 = increasing severity, 2 = random severity
  767. int32 weather_last_changed_time; // last time weather changed (used with weather_frequency)
  768. float weather_current_severity; // current weather conditions in a zone
  769. bool weather_allowed; // from zones.weather_allowed field in database
  770. bool weather_signaled; // whether or not we told the client "it begins to rain"
  771. bool reloading;
  772. map<int32, vector<EntityCommand*>* > entity_command_list;
  773. map<int32, map<int32, int8> > npc_spell_list;
  774. map<int32, map<int32, int16> > npc_skill_list;
  775. map<int32, vector<int32> > npc_equipment_list;
  776. map<int32, NPC*> npc_list;
  777. map<int32,Object*> object_list;
  778. map<int32,Sign*> sign_list;
  779. map<int32,Widget*> widget_list;
  780. map<int32, vector<GroundSpawnEntry*> > groundspawn_entries;
  781. map<int32, vector<GroundSpawnEntryItem*> > groundspawn_items;
  782. Mutex MGroundSpawnItems;
  783. map<int32,GroundSpawn*> groundspawn_list;
  784. map<int32,LootTable*> loot_tables;
  785. map<int32, vector<LootDrop*> > loot_drops;
  786. map<int32, vector<int32> > spawn_loot_list;
  787. vector<GlobalLoot*> level_loot_list;
  788. map<int16, vector<GlobalLoot*> > racial_loot_list;
  789. map<int32, vector<GlobalLoot*> > zone_loot_list;
  790. map<int32, vector<TransportDestination*> > transporters;
  791. map<int32, MutexList<LocationTransportDestination*>* > location_transporters;
  792. Mutex MTransporters;
  793. Mutex MTransportMaps;
  794. // Map <transport if, map name>
  795. map<int32, string> m_transportMaps;
  796. int32 watchdogTimestamp;
  797. vector<int32> m_pendingSpawnRemove;
  798. Mutex MPendingSpawnRemoval;
  799. public:
  800. Spawn* GetSpawn(int32 id);
  801. /* Entity Commands */
  802. map<int32, vector<EntityCommand*>*>* GetEntityCommandListAll() {return &entity_command_list;}
  803. vector<EntityCommand*>* GetEntityCommandList(int32 id);
  804. void SetEntityCommandList(int32 id, EntityCommand* command);
  805. void ClearEntityCommands();
  806. EntityCommand* GetEntityCommand(int32 id, string name);
  807. /* NPC's */
  808. void AddNPC(int32 id, NPC* npc);
  809. NPC* GetNPC(int32 id, bool override_loading = false) {
  810. if((!reloading || override_loading) && npc_list.count(id) > 0)
  811. return npc_list[id];
  812. else
  813. return 0;
  814. }
  815. NPC* GetNewNPC(int32 id) {
  816. if(!reloading && npc_list.count(id) > 0)
  817. return new NPC(npc_list[id]);
  818. else
  819. return 0;
  820. }
  821. /* NPC Spells */
  822. void AddNPCSpell(int32 list_id, int32 spell_id, int8 tier);
  823. vector<Spell*>* GetNPCSpells(int32 primary_list, int32 secondary_list);
  824. /* NPC Skills */
  825. void AddNPCSkill(int32 list_id, int32 skill_id, int16 value);
  826. map<string, Skill*>* GetNPCSkills(int32 primary_list, int32 secondary_list);
  827. /* NPC Equipment */
  828. void AddNPCEquipment(int32 list_id, int32 item_id);
  829. void SetNPCEquipment(NPC* npc);
  830. /* Objects */
  831. void AddObject(int32 id, Object* object){ object_list[id] = object; }
  832. Object* GetObject(int32 id, bool override_loading = false) {
  833. if((!reloading || override_loading) && object_list.count(id) > 0)
  834. return object_list[id];
  835. else
  836. return 0;
  837. }
  838. Object* GetNewObject(int32 id) {
  839. if(!reloading && object_list.count(id) > 0)
  840. return object_list[id]->Copy();
  841. else
  842. return 0;
  843. }
  844. /* Signs */
  845. void AddSign(int32 id, Sign* sign){ sign_list[id] = sign; }
  846. Sign* GetSign(int32 id, bool override_loading = false) {
  847. if((!reloading || override_loading) && sign_list.count(id) > 0)
  848. return sign_list[id];
  849. else
  850. return 0;
  851. }
  852. Sign* GetNewSign(int32 id) {
  853. if(!reloading && sign_list.count(id) > 0)
  854. return sign_list[id]->Copy();
  855. else
  856. return 0;
  857. }
  858. /* Widgets */
  859. void AddWidget(int32 id, Widget* widget);
  860. Widget* GetWidget(int32 id, bool override_loading = false);
  861. Widget* GetNewWidget(int32 id);
  862. /* Groundspawns */
  863. // JA: groundspawn revamp
  864. void AddGroundSpawnEntry(int32 groundspawn_id, int16 min_skill_level, int16 min_adventure_level, int8 bonus_table, float harvest1, float harvest3, float harvest5, float harvest_imbue, float harvest_rare, float harvest10, int32 harvest_coin);
  865. void AddGroundSpawnItem(int32 groundspawn_id, int32 item_id, int8 is_rare, int32 grid_id);
  866. vector<GroundSpawnEntry*>* GetGroundSpawnEntries(int32 id);
  867. vector<GroundSpawnEntryItem*>* GetGroundSpawnEntryItems(int32 id);
  868. void LoadGroundSpawnEntries();
  869. void LoadGroundSpawnItems();
  870. //
  871. void DeleteGroundSpawnItems();
  872. void AddGroundSpawn(int32 id, GroundSpawn* spawn);
  873. GroundSpawn* GetGroundSpawn(int32 id, bool override_loading = false);
  874. GroundSpawn* GetNewGroundSpawn(int32 id);
  875. /* Pet names */
  876. vector<string> pet_names;
  877. /* Loot */
  878. void AddLootTable(int32 id, LootTable* table);
  879. void AddLootDrop(int32 id, LootDrop* drop);
  880. void AddSpawnLootList(int32 spawn_id, int32 id);
  881. void ClearSpawnLootList(int32 spawn_id);
  882. void AddLevelLootList(GlobalLoot* loot);
  883. void AddRacialLootList(int16 racial_id, GlobalLoot* loot);
  884. void AddZoneLootList(int32 zone, GlobalLoot* loot);
  885. void ClearLootTables();
  886. vector<int32> GetSpawnLootList(int32 spawn_id, int32 zone_id, int8 spawn_level, int16 racial_id);
  887. vector<LootDrop*>* GetLootDrops(int32 table_id);
  888. LootTable* GetLootTable(int32 table_id);
  889. /* Transporters */
  890. void AddLocationTransporter(int32 zone_id, string message, float trigger_x, float trigger_y, float trigger_z, float trigger_radius, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading, int32 cost, int32 unique_id);
  891. void AddTransporter(int32 transport_id, int8 type, string name, string message, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading,
  892. int32 cost, int32 unique_id, int8 min_level, int8 max_level, int32 quest_req, int16 quest_step_req, int32 quest_complete, int32 map_x, int32 map_y, int32 expansion_flag, int32 holiday_flag, int32 min_client_version,
  893. int32 max_client_version, int32 flight_path_id, int16 mount_id, int8 mount_red_color, int8 mount_green_color, int8 mount_blue_color);
  894. void GetTransporters(vector<TransportDestination*>* returnList, Client* client, int32 transport_id);
  895. MutexList<LocationTransportDestination*>* GetLocationTransporters(int32 zone_id);
  896. void DeleteGlobalTransporters();
  897. ///<summary></summary>
  898. ///<param name='id'>The transport id</param>
  899. ///<param name='name'>Name of the map</param>
  900. void AddTransportMap(int32 id, string name);
  901. ///<summary>Checks to see if the transport has a map</summary>
  902. ///<param name='id'>The transport id we want to check</param>
  903. ///<returns>True if the transport id has a map</returns>
  904. bool TransportHasMap(int32 id);
  905. ///<summary>Gets the map name for the given transport id</summary>
  906. ///<param name='id'>The transport id that we want a map for</param>
  907. ///<returns>Map name</returns>
  908. string GetTransportMap(int32 id);
  909. ///<summary>Clears the list of transporter maps</summary>
  910. void DeleteTransporterMaps();
  911. void DeleteGlobalSpawns();
  912. void ReloadSpawns();
  913. void SendStateCommand(Spawn* spawn, int32 state);
  914. };
  915. #endif