Files
TrinityCore/src/server/game/Scripting/ScriptSystem.h
XTZGZoReX 946adf469c *** New core <-> script library interface - complete rewrite of the old one.
* Removed the misdesigned on_events script/hooks.
* Lots of related cleanups and assertions.
* The interface is now fully object-oriented.
** Scripts no longer use function pointers.
** Scripts no longer use the general-purpose Script struct for everything.
** Script types are split into separate classes which must be inherited depending on what functionality is desired.
* Several script types have been added to allow extending functionality in a code-only manner (some script types require
  assignment in the recently added ScriptName columns in the database, though).
** SpellHandlerScript: Wrapper around spell scripts (returns new SpellScript objects (`spell_script_names`.`ScriptName`)).
** ServerScript: Allows scripting events that occur in the network layer.
** WorldScript: Allows scripting certain world-global events.
** FormulaScript: Allows hooking and interfering with core formulas.
** *MapScript: Allows hooking different map types (including world, instance, and battleground maps (`instance_template`.`ScriptName`)).
** ItemScript: Allows scripting of items (like the old interface (`item_template`.`ScriptName`)).
** CreatureScript: Allows scripting of creatures/AI (like the old interface (`creature_template`.`ScriptName`)).
** GameObjectScript: Allows scripting of gameobjects (like the old interface (`gameobject_template`.`ScriptName`)).
** AreaTriggerScript: Allows scripting triggered area triggers (like the old interface (`areatrigger_scripts`.`ScriptName`)).
** OutdoorPvPScript: Script which should return OutdoorPvP objects for use by OutdoorPvPMgr (`outdoorpvp_template`.`ScriptName`).
** CommandScript: Allows extending the in-core command table.
** WeatherScript: Allows scripting of weather changes (`game_weather`.`ScriptName`).
** AuctionHouseScript: Allows scripting of auction events.
** ConditionScript: Allows scripting of conditions (`conditions`.`ScriptName`).
** DynamicObjectScript: Allows scripting of dynamicobjects.
** TransportScript: Allows scripting of transport events (`transports`.`ScriptName`).
* OutdoorPvP objects are now created through scripts. This effectively means that they'll need to be moved to scripts
  before the they're functional again.
* The whole idea with this new interface is to allow expanding core functionality without touching core code. If further
  hooks are needed to expand functionality of the core, let us know; we'll add them, if we agree that it is appropriate
  to do so.
*** NOTE: The scripts project will _not_ build before it has been adapted to the new interface.
*** Thanks to everyone who helped out with related preparations and suggestions!

--HG--
branch : trunk
2010-08-06 19:23:43 +02:00

103 lines
2.7 KiB
C++

/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
* This program is free software licensed under GPL version 2
* Please see the included DOCS/LICENSE.TXT for more information */
#ifndef SC_SYSTEM_H
#define SC_SYSTEM_H
#define TEXT_SOURCE_RANGE -1000000 //the amount of entries each text source has available
//TODO: find better namings and definitions.
//N=Neutral, A=Alliance, H=Horde.
//NEUTRAL or FRIEND = Hostility to player surroundings (not a good definition)
//ACTIVE or PASSIVE = Hostility to environment surroundings.
enum eEscortFaction
{
FACTION_ESCORT_A_NEUTRAL_PASSIVE = 10,
FACTION_ESCORT_H_NEUTRAL_PASSIVE = 33,
FACTION_ESCORT_N_NEUTRAL_PASSIVE = 113,
FACTION_ESCORT_A_NEUTRAL_ACTIVE = 231,
FACTION_ESCORT_H_NEUTRAL_ACTIVE = 232,
FACTION_ESCORT_N_NEUTRAL_ACTIVE = 250,
FACTION_ESCORT_N_FRIEND_PASSIVE = 290,
FACTION_ESCORT_N_FRIEND_ACTIVE = 495,
FACTION_ESCORT_A_PASSIVE = 774,
FACTION_ESCORT_H_PASSIVE = 775,
FACTION_ESCORT_N_ACTIVE = 1986,
FACTION_ESCORT_H_ACTIVE = 2046
};
struct ScriptPointMove
{
uint32 uiCreatureEntry;
uint32 uiPointId;
float fX;
float fY;
float fZ;
uint32 uiWaitTime;
};
struct StringTextData
{
uint32 uiSoundId;
uint8 uiType;
uint32 uiLanguage;
uint32 uiEmote;
};
class SystemMgr
{
public:
SystemMgr();
~SystemMgr() {}
static SystemMgr& Instance();
//Maps and lists
typedef UNORDERED_MAP<int32, StringTextData> TextDataMap;
typedef UNORDERED_MAP<uint32, std::vector<ScriptPointMove> > PointMoveMap;
//Database
void LoadVersion();
void LoadScriptTexts();
void LoadScriptTextsCustom();
void LoadScriptWaypoints();
//Retrive from storage
StringTextData const* GetTextData(int32 uiTextId) const
{
TextDataMap::const_iterator itr = m_mTextDataMap.find(uiTextId);
if (itr == m_mTextDataMap.end())
return NULL;
return &itr->second;
}
std::vector<ScriptPointMove> const &GetPointMoveList(uint32 uiCreatureEntry) const
{
static std::vector<ScriptPointMove> vEmpty;
PointMoveMap::const_iterator itr = m_mPointMoveMap.find(uiCreatureEntry);
if (itr == m_mPointMoveMap.end())
return vEmpty;
return itr->second;
}
protected:
TextDataMap m_mTextDataMap; //additional data for text strings
PointMoveMap m_mPointMoveMap; //coordinates for waypoints
};
#define sScriptSystemMgr SystemMgr::Instance()
#endif