/* EQ2Emulator: Everquest II Server Emulator Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net) This file is part of EQ2Emulator. EQ2Emulator is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. EQ2Emulator is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with EQ2Emulator. If not, see . */ #ifndef __EQ2_TRADESKILLS__ #define __EQ2_TRADESKILLS__ #include "../../common/types.h" #include "../../common/Mutex.h" #include "../Items/Items.h" #include class Player; class Spawn; class Recipe; class Client; struct TradeskillEvent { char Name[250]; int16 Icon; int32 Technique; int16 SuccessProgress; int16 SuccessDurability; int16 SuccessHP; int16 SuccessPower; int32 SuccessSpellID; int32 SuccessItemID; sint16 FailProgress; sint16 FailDurability; sint16 FailHP; sint16 FailPower; }; struct Tradeskill { Player* player; Spawn* table; Recipe* recipe; int32 currentProgress; int32 currentDurability; int32 nextUpdateTime; vector> usedComponents; TradeskillEvent* CurrentEvent; bool eventChecked; bool eventCountered; }; class TradeskillMgr { public: TradeskillMgr(); ~TradeskillMgr(); /// Determines if an update is needed if so send one and stop crafting if finished void Process(); /// Starts the actual crafting process /// Client that is crafting /// List of items the player is using to craft void BeginCrafting(Client* client, vector> components); /// Stops the crafting process /// Client that stopped crafting /// Does the list need a mutex lock? default = true void StopCrafting(Client* client, bool lock = true); /// Checks to see if the given client is crafting /// The client to check /// True if the client is crafting bool IsClientCrafting(Client* client); /// Get the tradeskill struct for the given client /// The client to get the tradeskill struct for /// Pointer to the clients tradeskill struct, or 0 if they don't have one Tradeskill* GetTradeskill(Client* client); /// Check to see if we countered the tradeskill event /// The client to check for /// The icon of the spell we casted void CheckTradeskillEvent(Client* client, int16 icon); /// Lock the tradeskill list for reading, should never need to write to the tradeskill list outside of the TradeskillMgr class /// Function name that called this lock /// Line number this lock was called from void ReadLock(const char* function = (const char*)0, int32 line = 0) { m_tradeskills.readlock(function, line); } /// Releases the red lock on the tradeskill list /// Function name that is releasing the lock /// Line number that is releasing the lock void ReleaseReadLock(const char* function = (const char*)0, int32 line = 0) { m_tradeskills.releasereadlock(function, line); } int32 GetTechniqueSuccessAnim(int16 version, int32 technique); int32 GetTechniqueFailureAnim(int16 version, int32 technique); int32 GetTechniqueIdleAnim(int16 version, int32 technique); int32 GetMissTargetAnim(int16 version); int32 GetKillMissTargetAnim(int16 version); void SetClientIdleVisualState(Client* client, Tradeskill* ts); private: /// Sends the creation window /// Client to send the window to /// The recipe being crafted void SendItemCreationUI(Client* client, Recipe* recipe); map tradeskillList; Mutex m_tradeskills; float m_critFail; float m_critSuccess; float m_fail; float m_success; float m_eventChance; }; class MasterTradeskillEventsList { public: MasterTradeskillEventsList(); ~MasterTradeskillEventsList(); /// Adds a tradeskill event to the master list /// The event to add void AddEvent(TradeskillEvent* tradeskillEvent); /// Gets a list of tradeskill events for the given technique /// The skill id of the technique /// Vector of TradeskillEvent* for the given technique vector* GetEventByTechnique(int32 technique); /// Get the size of the event list /// int32 containing the size of the list int32 Size(); private: Mutex m_eventList; map > eventList; }; #endif