新开魔兽世界服务端版数据库配置传送师代码

来源: 作者: 点击:
TeleNPCwithdestinationsintheDatabase

diff-rf771d2852d2aREADME.NPCTELEPORT
---/dev/nullThuJan0100:00:001970+0000
+++b/README.NPCTELEPORTThuApr0903:20:002009+0200
@@-00+114@@
+NPCTeleportforTrinity
+
+Originalauthor:Wilibald09
+
+AllowsyoutoaddacustomNPCforteleportingusing.npcadd100000.
+ThedefaultNPCisentry100000.
+
+AllsettingsarelocatedintheDBsoyoucancustomizeandadddestinations
+setlevelrestrictionsandalsochargetheplayerforteleporting.
+
+Installation:
+
+Runthequerysetup_npc_teleport.sqllocatedinthetrinitysqldirectoryon
+yourworldDB.ThiswillsetuptheDBandyoucancustomizefromthere.
diff-re4a831c8ab22sql/setup_npc_teleport.sql
diff-rf771d2852d2asql/setup_npc_teleport.sql
---/dev/nullThuJan0100:00:001970+0000
+++b/sql/setup_npc_teleport.sqlThuApr0903:20:002009+0200
@@-00+1119@@
+DROPTABLEIFEXISTS`custom_npc_tele_category`;
+CREATETABLE`custom_npc_tele_category`(
+`id`int(6)unsignedNOTNULLdefault'0'
+`name`varchar(255)NOTNULLdefault''
+`flag`tinyint(3)unsignedNOTNULLdefault'0'
+`data0`bigint(20)unsignedNOTNULLdefault'0'
+`data1`int(6)unsignedNOTNULLdefault'0'
+PRIMARYKEY(`id`)
+)ENGINE=MyISAMDEFAULTCHARSET=utf8;
+
+DROPTABLEIFEXISTS`custom_npc_tele_destination`;
+CREATETABLE`custom_npc_tele_destination`(
+`id`int(6)unsignedNOTNULLauto_increment
+`name`char(100)NOTNULLdefault''
+`pos_X`floatNOTNULLdefault'0'
+`pos_Y`floatNOTNULLdefault'0'
+`pos_Z`floatNOTNULLdefault'0'
+`map`smallint(5)unsignedNOTNULLdefault'0'
+`orientation`floatNOTNULLdefault'0'
+`level`tinyint(3)unsignedNOTNULLdefault'0'
+`cost`int(10)unsignedNOTNULLdefault'0'
+PRIMARYKEY(`id`)
+)ENGINE=MyISAMAUTO_INCREMENT=1DEFAULTCHARSET=utf8;
+
+DROPTABLEIFEXISTS`custom_npc_tele_association`;
+CREATETABLE`custom_npc_tele_association`(
+`cat_id`int(6)unsignedNOTNULLdefault'0'
+`dest_id`int(6)unsignedNOTNULLdefault'0'
+PRIMARYKEY(`cat_id``dest_id`)
+)ENGINE=MyISAMDEFAULTCHARSET=utf8;
+
+TRUNCATE`custom_npc_tele_category`;
+INSERTINTO`custom_npc_tele_category`
+(`id``name``flag``data0``data1`)
+VALUES
+(1'Cities'010)
+(2'Cities'020)
+(3'Battlegrounds'010)
+(4'Battlegrounds'020)
+(5'Arenas'000)
+(6'[InstancesLvl1-60]'000)
+(7'[InstancesLvl60+]'5600)
+(8'[InstancesLvl70+]'5700)
+(9'DestinationsMJ'300);
+
+TRUNCATE`custom_npc_tele_destination`;
+INSERTINTO`custom_npc_tele_destination`
+(`id``name``pos_X``pos_Y``pos_Z``map``orientation``level``cost`)
+VALUES
+(1'AlteracValley'883.187-489.37596.7618303.0693200)
+(2'AlteracValley'-818.155-623.04354.0884302.100)
+(3'ArathiBasin'686.053683.165-12.91495290.1800)
+(4'ArathiBasin'1308.681306.03-9.01075293.9128500)
+(5'BlackTemple'-3610.72324.98837.45303.2829800)
+(6'BlackfathomDeeps'4254.58664.74-29.0411.9700)
+(7'BlackrockDepths'-7301.03-913.19165.3700.0800)
+(8'BlackrockSpire'-7535.43-1212.04285.4505.2900)
+(9'BlackwingLair'-7665.55-1102.49400.679469000)
+(10'CavernsofTime'-8173.66-4746.3633.842314.9398900)
+(11'CircleofBlood'2839.445930.1711.10025303.1628400)
+(12'CoilfangReservoir'517.2886976.2832.0072530000)
+(13'Darnassus'9947.522482.731316.211000)
+(14'DireMaul'-3982.471127.79161.0210.0500)
+(15'Exodar'-4073.03-12020.4-1.47530000)
+(16'EyeoftheStorm'2487.721609.121224.645663.3567100)
+(17'EyeoftheStorm'1843.731529.771224.435660.29757900)
+(18'Goldshire'-946462560000)
+(19'Gruul'sLair'3539.015082.361.69107530000)
+(20'Gurubashi'-13261.3168.29435.079201.0068800)
+(21'HellfireCitadel'-305.8163056.4-2.473185302.0100)
+(22'Ironforge'-4924.07-951.95501.5505.400)
+(23'IsleOfQuel'Danas'12947.4-6893.315.683985303.0915400)
+(24'Karazhan'-11118.8-2010.8447.08070000)
+(25'Maraudon'-1433.332955.3496.2114.8200)
+(26'MoltenCore'1121.45-454.317-101.332303.500)
+(27'Naxxramas'3125.18-3748.02136.0490000)
+(28'Onyxia'sLair'-4707.44-3726.8254.672313.800)
+(29'Orgrimmar'1552.5-4420.668.948021000)
+(30'RazorHill'315.721-4743.410.48671000)
+(31'RazorfenDowns'-4645.08-2470.8585.5314.3900)
+(32'RazorfenKraul'-4484.04-1739.486.4711.2300)
+(33'RingofTrials'-1999.946581.7111.325302.300)
+(34'RuinsofAhn'Qiraj'-8409.031498.8327.361512.4975700)
+(35'Scholomance'1219.01-2604.6685.6100.500)
+(36'ShadowfangKeep'-254.471524.6876.8901.5600)
+(37'ShattrathCity'-1850.215435.82-10.96145303.4039100)
+(38'Silvermoon'9338.74-7277.2713.7895530000)
+(39'Stormwind'-8960.14516.26696.35680000)
+(40'Stratholme'3263.54-3379.46143.590000)
+(41'TempestKeep'3089.581399.05187.6535304.7940700)
+(42'TempleofAhn'Qiraj'-8245.841983.74129.07210.93619500)
+(43'TheDeadmines'-112121658.5825.6701.4500)
+(44'TheMaul'-3761.491133.43132.08314.5725900)
+(45'TheScarletMonastery'2843.89-693.74139.3205.1100)
+(46'TheSunkenTemple'-10346.9-3851.9-43.4106.0900)
+(47'TheWailingCaverns'-722.53-2226.316.9412.7100)
+(48'ThunderBluff'-1290147.034129.68214.91900)
+(49'Uldaman'-6119.7-2957.3204.1100.0300)
+(50'Undercity'1819.71238.7960.53210000)
+(51'WarsongGulch'930.8511431.57345.5374890.01570400)
+(52'WarsongGulch'1525.951481.66352.0014893.2075600)
+(53'Zul'Aman'6846.95-7954.5170.0285304.6150100)
+(54'Zul'Farrak'-6839.39-2911.038.8710.4100)
+(55'Zul'Gurub'-11916.7-1212.8292.286804.609500)
+(56'IledesMJ'1625416276.914.508211.7026900);
+
+TRUNCATE`custom_npc_tele_association`;
+INSERTINTO`custom_npc_tele_association`
+(`cat_id``dest_id`)
+VALUES
+(113)(115)(118)(122)(123)(137)(139)(223)(229)(230)(237)(238)(248)(250)(31)(34)(316)(352)(42)(43)(417)(451)(511)(520)(533)(544)(66)(67)(68)(614)(625)(631)(632)(635)(636)(640)(643)(645)(646)(647)(649)(654)(79)(726)(727)(728)(734)(742)(755)(85)(810)(812)(819)(821)(824)(841)(853)(956);
+
+--`npc_text`
+REPLACEINTO`npc_text`(`ID``text0_0`)VALUES
+(100000'ChooseyourCategory.')
+(100001'ChooseyourDestination.');
+
+--`creature_template`
+REPLACEINTO`creature_template`(`entry``heroic_entry``modelid_A``modelid_A2``modelid_H``modelid_H2``name``subname``IconName``minlevel``maxlevel``minhealth``maxhealth``minmana``maxmana``armor``faction_A``faction_H``npcflag``speed``scale``rank``mindmg``maxdmg``dmgschool``attackpower``baseattacktime``rangeattacktime``unit_flags``dynamicflags``family``trainer_type``trainer_spell``class``race``minrangedmg``maxrangedmg``rangedattackpower``type``type_flags``lootid``pickpocketloot``skinloot``resistance1``resistance2``resistance3``resistance4``resistance5``resistance6``spell1``spell2``spell3``spell4``PetSpellDataId``mingold``maxgold``AIName``MovementType``InhabitType``RacialLeader``RegenHealth``equipment_id``mechanic_immune_mask``flags_extra``ScriptName`)VALUES(1000000160420160420'SparcT�l�portServices''NPCTeleport'''70707500750000035351111250025000100150000000000000700000000000000000''0301000'npc_teleport');
diff-re4a831c8ab22src/bindings/scripts/CMakeLists.txt
diff-rf771d2852d2asrc/bindings/scripts/CMakeLists.txt
---a/src/bindings/scripts/CMakeLists.txt2009-08-1611:43:09.000000000+0200
+++b/src/bindings/scripts/CMakeLists.txt2009-08-1611:44:46.000000000+0200
@@-166+169@@
include/sc_creature.h
include/sc_gossip.h
include/sc_instance.h
+include/sc_npc_teleport.cpp
+include/sc_npc_teleport.h
+scripts/custom/npc_teleport.cpp
scripts/eastern_kingdoms/blackrock_depths/blackrock_depths.cpp
scripts/eastern_kingdoms/blackrock_depths/boss_ambassador_flamelash.cpp
scripts/eastern_kingdoms/blackrock_depths/boss_anubshiah.cpp
diff-rf771d2852d2asrc/bindings/scripts/ScriptMgr.cpp
---a/src/bindings/scripts/ScriptMgr.cppWedApr0816:43:592009-0500
+++b/src/bindings/scripts/ScriptMgr.cppThuApr0903:20:002009+0200
@@-96+97@@
#include"ObjectMgr.h"
#include"rogressBar.h"
#include"../system/ScriptLoader.h"
+#include"sc_npc_teleport.h"

#define_FULLVERSION"TrinityScript"

@@-856+869@@
//DropExistingTextMaponlydoneonceandwearereadytoadddatafrommultiplesources.
TextMap.clear();

+//LoadTeleNPC2
+LoadNpcTele(result);
+
//LoadScriptText
outstring_log("TSCR:LoadingScriptTexts...");
LoadTrinityStrings(TScriptDB"script_texts"TEXT_SOURCE_RANGE1+(TEXT_SOURCE_RANGE*2));
---/dev/nullThuJan0100:00:001970+0000
+++b/src/bindings/scripts/include/sc_npc_teleport.cppThuApr0903:20:002009+0200
@@-00+1377@@
+/**
+*
+*@File:sc_npc_teleport.cpp
+*
+*@Authors:Wilibald09
+*
+*@Date:28/08/2008
+*
+*@Version:1.2
+*
+**/
+
+
+#include"precompiled.h"
+#include"sc_npc_teleport.h"
+#include"rogressBar.h"
+
+#defineTELEnsNpcTel::CatDest
+#definePAGEnsNpcTel:age
+#definePAGEIPAGE::Instance
+
+
+nsNpcTel::VCatDestnsNpcTel::TabCatDest;
+
+
+constuint32PAGE:perator[](Player*constplayer)const
+{
+for(VInst_ti(0);i<m_TabInstance.size();++i)
+{
+if(m_TabInstance.GetPlayer()==player)
+returnm_TabInstance.GetPageId();
+}
+return0;
+}
+
+PAGE::Instance&PAGE:perator()(Player*constplayer)
+{
+for(VInst_ti(0);i<m_TabInstance.size();++i)
+{
+if(m_TabInstance.GetPlayer()==player)
+returnm_TabInstance;
+}
+m_TabInstance.push_back(Instance(player));
+returnm_TabInstance.back();
+}
+
+PAGE::Instance&PAGEI:perator=(constuint32&id)
+{
+m_PageId=id;
+return*this;
+}
+
+PAGE::Instance&PAGEI:perator++(void)
+{
+++m_PageId;
+return*this;
+}
+
+PAGE::InstancePAGEI:perator++(int32)
+{
+Instancetmp(*this);
+++m_PageId;
+returntmp;
+}
+
+PAGE::Instance&PAGEI:perator--(void)
+{
+--m_PageId;
+return*this;
+}
+
+PAGE::InstancePAGEI:perator--(int32)
+{
+Instancetmp(*this);
+--m_PageId;
+returntmp;
+}
+
+TELE::CatDest(constuint32&idconststd::string&name
+constFlag&flagconstuint64&data0constuint32&data1)
+:m_id(id)m_name(name)m_flag(flag)m_data0(data0)m_data1(data1)
+{
+m_TabDest.clear();
+}
+
+std::stringTELE::GetName(constboolIsGM/*=false*/)const
+{
+if(!IsGM||m_flag!=FLAG_TEAM)
+returnm_name;
+
+switch(m_data0)
+{
+caseTEAM_HORDE:returnstd::string(m_name+"(H)");
+caseTEAM_ALLIANCE:returnstd::string(m_name+"(A)");
+}
+returnm_name;
+}
+
+boolTELE::IsAllowedToTeleport(Player*constplayer)const
+{
+if(player->isGameMaster())
+{
+if(m_flag==FLAG_GMLEVEL)
+returnplayer->GetSession()->GetSecurity()>=m_data0;
+returntrue;
+}
+
+switch(m_flag)
+{
+caseFLAG_TEAM:
+switch(m_data0)
+{
+caseTEAM_HORDE:returnplayer->GetTeam()==HORDE;
+caseTEAM_ALLIANCE:returnplayer->GetTeam()==ALLIANCE;
+caseTEAM_ALL:returntrue;
+}
+
+caseFLAG_GUILD:
+returnplayer->GetGuildId()==m_data0;
+
+caseFLAG_GMLEVEL:
+returnplayer->GetSession()->GetSecurity()>=m_data0;
+
+caseFLAG_ISGM:
+returnplayer->isGameMaster();
+
+caseFLAG_ACCOUNT:
+returnplayer->GetSession()->GetAccountId()==m_data0;
+
+caseFLAG_LEVEL:
+returnplayer->getLevel()>=m_data0;
+
+caseFLAG_ITEM:
+returnplayer->HasItemCount(m_data0m_data1true);
+
+caseFLAG_QUEST:
+if(m_data1<MAX_QUEST_STATUS)
+returnplayer->GetQuestStatus(m_data0)==m_data1;
+returnplayer->GetQuestRewardStatus(m_data0);
+
+caseFLAG_GENDER:
+returnplayer->getGender()==m_data0;
+
+caseFLAG_RACE:
+returnplayer->getRace()==m_data0;
+
+caseFLAG_CLASS:
+returnplayer->getClass()==m_data0;
+
+caseFLAG_REPUTATION:
+returnplayer->GetReputationRank(m_data0)>=m_data1;
+
+caseFLAG_PLAYER:
+returnplayer->GetGUID()==m_data0;
+}
+
+error_log("Invalidflag(category:%u).Importantproblem..."GetCatID());
+returnfalse;
+}
+
+uint32TELE::CountOfCategoryAllowedBy(Player*constplayer)
+{
+uint32count(0);
+for(VCatDest_ti(0);i<TabCatDest.size();++i)
+{
+if(TabCatDest.IsAllowedToTeleport(player))
+++count;
+}
+returncount;
+}
+
+boolnsNpcTel::IsValidData(constuint32&catconstFlag&flag
+constuint64&data0constuint32&data1)
+{
+switch(flag)
+{
+caseFLAG_TEAM:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(data0<MAX_FLAG_TEAM)
+returntrue;
+error_log("Invaliddata0(Team)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_GUILD:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(data0)
+returntrue;
+error_log("Invaliddata0(GuildID)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_GMLEVEL:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(0<data0&&data0<256)
+returntrue;
+error_log("Invaliddata0(GmLevel)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_ISGM:
+if(data0)
+error_log("Invaliddata0(category:%u)."cat);
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+returntrue;
+
+caseFLAG_ACCOUNT:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(data0)
+returntrue;
+error_log("Invaliddata0(AccountID)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_LEVEL:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(0<data0&&data0<256)
+returntrue;
+error_log("Invaliddata0(Level)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_ITEM:
+if(!data0)
+{
+error_log("Invaliddata0(ItemID)(category:%u)."cat);
+returnfalse;
+}
+if(data1)
+returntrue;
+error_log("Invaliddata1(ItemCount)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_QUEST:
+if(!data0)
+{
+error_log("Invaliddata0(QuestID)(category:%u)."cat);
+returnfalse;
+}
+if(data1<MAX_QUEST_STATUS+1)
+returntrue;
+error_log("Invaliddata1(QuestStatus)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_GENDER:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(data0<GENDER_NONE)
+returntrue;
+error_log("Invaliddata0(Gender)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_RACE:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(0<data0&&data0<MAX_RACES)
+returntrue;
+error_log("Invaliddata0(Race)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_CLASS:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(0<data0&&data0<MAX_CLASSES)
+returntrue;
+error_log("Invaliddata0(Class)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_REPUTATION:
+if(!data0)
+{
+error_log("Invaliddata0(Faction/Reputation)(category:%u)."cat);
+returnfalse;
+}
+if(data1<=REP_EXALTED)
+returntrue;
+error_log("Invaliddata1(Faction/Reputation)(category:%u)."cat);
+returnfalse;
+
+caseFLAG_PLAYER:
+if(data1)
+error_log("Invaliddata1(category:%u)."cat);
+if(data0)
+returntrue;
+error_log("Invaliddata0(PlayerGuid)(category:%u)."cat);
+returnfalse;
+}
+
+error_log("Invalidflag(category:%u)."cat);
+returnfalse;
+}
+
+voidLoadNpcTele(QueryResult*result)
+{
+constchar*Table[]=
+{
+"custom_npc_tele_category"
+"custom_npc_tele_destination"
+"custom_npc_tele_association"
+};
+
+
+result=TScriptDB.PQuery(
+"SELECT`flag``data0``data1``cat_id`C.`name``namecat`D.`name``namedest`"
+//012345
+"`pos_X``pos_Y``pos_Z``orientation``map``level``cost`"
+//6789101112
+"FROM`%s`C`%s`D`%s`A"
+"WHEREC.`id`=`cat_id`ANDD.`id`=`dest_id`"
+"ORDERBY`namecat``cat_id``namedest`"Table[0]Table[1]Table[2]);
+
+nsNpcTel::TabCatDest.clear();
+
+if(result)
+{
+outstring_log("TSCR:Loading%s%sand%s..."Table[0]Table[1]Table[2]);
+barGoLinkbar(result->GetRowCount());
+
+uint32catid=0;
+uint32nbDest=0;
+boolIsValidCat=true;
+boolFirstTime=true;
+
+do
+{
+bar.step();
+Field*fields=result->Fetch();
+
+if(!IsValidCat&&catid==fields[3].GetUInt32()&&!FirstTime)
+continue;
+
+IsValidCat=true;
+FirstTime=false;
+
+if(!nsNpcTel::IsValidData(fields[3].GetUInt32()(nsNpcTel::Flag)fields[0].GetUInt8()
+fields[1].GetUInt64()fields[2].GetUInt32()))
+{
+IsValidCat=false;
+catid=fields[3].GetUInt32();
+continue;
+}
+
+if(catid!=fields[3].GetUInt32())
+{
+catid=fields[3].GetUInt32();
+nsNpcTel::CatDestcategorie(catidfields[4].GetCppString()(nsNpcTel::Flag)fields[0].GetUInt8()
+fields[1].GetUInt64()fields[2].GetUInt32());
+nsNpcTel::TabCatDest.push_back(categorie);
+}
+
+nsNpcTel:estitem=
+{
+fields[5].GetCppString()//Name
+fields[6].GetFloat()//X
+fields[7].GetFloat()//Y
+fields[8].GetFloat()//Z
+fields[9].GetFloat()//Orientation
+fields[10].GetUInt16()//Map
+fields[11].GetUInt8()//Level
+fields[12].GetUInt32()//Cost
+};
+
+nsNpcTel::TabCatDest.back().AddDest(item);
+++nbDest;
+}while(result->NextRow());
+
+deleteresult;
+outstring_log("");
+outstring_log("TSCR:>>Loaded%unpc_teleport."nbDest);
+}elseoutstring_log("TSCR:WARNING>>Loaded0npc_teleport.");
+}
+
+
+#undefTELE
+#undefPAGE
+#undefPAGEI
diff-rf771d2852d2asrc/bindings/scripts/include/sc_npc_teleport.h
---/dev/nullThuJan0100:00:001970+0000
+++b/src/bindings/scripts/include/sc_npc_teleport.hThuApr0903:20:002009+0200
@@-00+1151@@
+/**
+*
+*@File:sc_npc_teleport.h
+*
+*@Authors:Wilibald09
+*
+*@Date:19/08/2008
+*
+*@Version:1.2
+*
+**/
+
+
+#ifndefSC_NPC_TELEPORT_H
+#defineSC_NPC_TELEPORT_H
+
+#include<vector>
+
+
+namespacensNpcTel
+{
+//Differenttypesofpermissions
+enumFlag
+{
+FLAG_TEAM=0
+FLAG_GUILD=1
+FLAG_GMLEVEL=2
+FLAG_ISGM=3
+FLAG_ACCOUNT=4
+FLAG_LEVEL=5
+FLAG_ITEM=6
+FLAG_QUEST=7
+FLAG_GENDER=8
+FLAG_RACE=9
+FLAG_CLASS=10
+FLAG_REPUTATION=11
+FLAG_PLAYER=12
+MAX_FLAG
+};
+
+//DifferentparametersofFLAG_TEAM
+enum
+{
+TEAM_ALL=0
+TEAM_ALLIANCE=1
+TEAM_HORDE=2
+MAX_FLAG_TEAM
+};
+
+//Structurerepresentingthedestinations
+structDest
+{
+std::stringm_name;
+floatm_Xm_Ym_Zm_orient;
+uint16m_map;
+uint8m_level;
+uint32m_cost;
+};
+
+//Classrepresentingthecategoriesofdestinations
+classCatDest
+{
+public:
+
+typedefstd::vector<Dest>VDest;
+typedefVDest::size_typeVDest_t;
+
+CatDest(constuint32&idconststd::string&name
+constFlag&flagconstuint64&data0constuint32&data1);
+
+voidAddDest(constDest&item){m_TabDest.push_back(item);}
+DestGetDest(constuint32&id)const{returnm_TabDest[id];}
+uint32GetCatID(void)const{returnm_id;}
+uint32size(void)const{returnm_TabDest.size();}
+
+std::stringGetName(constboolIsGM=false)const;
+boolIsAllowedToTeleport(Player*constplayer)const;
+
+staticuint32CountOfCategoryAllowedBy(Player*constplayer);
+
+private:
+
+uint32m_id;
+std::stringm_name;
+Flagm_flag;
+uint64m_data0;
+uint32m_data1;
+VDestm_TabDest;
+};
+
+//Classpageforcurrentplayer
+classPage
+{
+protected:
+
+//Classinstanceforcurrentplayer
+classInstance
+{
+public:
+
+Instance(Player*constplayerconstuint32&ageId=0)
+:m_player(player)m_PageId(PageId){}
+
+Instance&operator=(constuint32&id);
+Instance&operator++(void);
+Instanceoperator++(int32);
+Instance&operator--(void);
+Instanceoperator--(int32);
+
+uint32GetPageId(void)const{returnm_PageId;}
+Player*GetPlayer(void)const{returnm_player;}
+
+private:
+
+Player*m_player;
+uint32m_PageId;
+};
+
+
+public:
+
+typedefstd::vector<Instance>VInst;
+typedefVInst::size_typeVInst_t;
+
+Page(void){m_TabInstance.clear();}
+
+Instance&operator()(Player*constplayer);
+constuint32operator[](Player*constplayer)const;
+
+
+private:
+
+VInstm_TabInstance;
+};
+
+typedefstd::vector<CatDest>VCatDest;
+typedefVCatDest::size_typeVCatDest_t;
+
+//Verificationofdataintegrity
+boolIsValidData(constuint32&catconstFlag&flag
+constuint64&data0constuint32&data1);
+
+externVCatDestTabCatDest;
+}
+
+//Loadingcontentsofdatabase
+voidLoadNpcTele(QueryResult*);
+
+externDatabaseTypeTScriptDB;
+
+#endif
diff-rf771d2852d2asrc/bindings/scripts/scripts/custom/npc_teleport.cpp
---/dev/nullThuJan0100:00:001970+0000
+++b/src/bindings/scripts/scripts/custom/npc_teleport.cppThuApr0903:20:002009+0200
@@-00+1220@@
+/**
+*
+*@File:npc_teleport.cpp
+*
+*@Authors:Wilibald09
+*
+*@Date:19/08/2008
+*
+*@Version:1.2
+*
+**/
+
+
+#include"precompiled.h"
+#include"sc_npc_teleport.h"
+#include<sstream>
+
+
+#defineGOSSIP_SHOW_DEST1000
+#defineGOSSIP_TELEPORT1001
+#defineGOSSIP_NEXT_PAGEC1002
+#defineGOSSIP_PREV_PAGEC1003
+#defineGOSSIP_NEXT_PAGED1004
+#defineGOSSIP_PREV_PAGED1005
+#defineGOSSIP_MAIN_MENU1006
+
+#defineSPELL_VISUAL_TELEPORT35517
+
+#defineNB_ITEM_PAGE10
+#defineMSG_CAT100000
+#defineMSG_DEST100001
+
+#defineNEXT_PAGE"->[NextPage]"
+#definePREV_PAGE"<-[PreviousPage]"
+#defineMAIN_MENU"<=[MainMenu]"
+
+
+usingnamespacensNpcTel;
+
+
+namespace
+{
+PagePageCPageD;
+PageCat;
+
+//Conversionfunctionint->string
+std::stringConvertStr(constint64&val)
+{
+std:stringstreamostr;
+ostr<<val;
+returnostr.str();
+}
+
+//ConversionfunctionintMoney->stringMoney
+std::stringConvertMoney(constuint32&Money)
+{
+std::stringStr(ConvertStr(Money));
+uint32SizeStr=Str.length();
+
+if(SizeStr>4)
+Str=Str.insert(Str.length()-4"po");
+if(SizeStr>2)
+Str=Str.insert(Str.length()-2"pa");
+Str+="pc";
+
+returnStr;
+}
+
+//TeleportPlayer
+voidTeleport(Player*constplayerconstuint16&map
+constfloat&Xconstfloat&Yconstfloat&Zconstfloat&orient)
+{
+player->CastSpell(playerSPELL_VISUAL_TELEPORTtrue);
+player->TeleportTo(mapXYZorient);
+}
+
+//Displaycategories
+voidAffichCat(Player*constplayerCreature*constcreature)
+{
+if(PageC[player]>0)
+player->ADD_GOSSIP_ITEM(7PREV_PAGEGOSSIP_PREV_PAGEC0);
+
+VCatDest_ti(PageC[player]*NB_ITEM_PAGE);
+for(;i<TabCatDest.size()&&i<(NB_ITEM_PAGE*(PageC[player]+1));++i)
+{
+if(TabCatDest.IsAllowedToTeleport(player))
+player->ADD_GOSSIP_ITEM(7TabCatDest.GetName(player->isGameMaster()).c_str()GOSSIP_SHOW_DESTi);
+}
+
+if(i<TabCatDest.size())
+player->ADD_GOSSIP_ITEM(7NEXT_PAGEGOSSIP_NEXT_PAGEC0);
+
+player->SEND_GOSSIP_MENU(MSG_CATcreature->GetGUID());
+}
+
+//Displaydestinationcategories
+voidAffichDest(Player*constplayerCreature*constcreature)
+{
+if(PageD[player]>0)
+player->ADD_GOSSIP_ITEM(7PREV_PAGEGOSSIP_PREV_PAGED0);
+
+CatDest::VDest_ti(PageD[player]*NB_ITEM_PAGE);
+for(;i<TabCatDest[Cat[player]].size()&&i<(NB_ITEM_PAGE*(PageD[player]+1));++i)
+{
+player->ADD_GOSSIP_ITEM(5TabCatDest[Cat[player]].GetDest(i).m_name.c_str()GOSSIP_TELEPORTi);
+}
+
+if(i<TabCatDest[Cat[player]].size())
+player->ADD_GOSSIP_ITEM(7NEXT_PAGEGOSSIP_NEXT_PAGED0);
+
+if(CatDest::CountOfCategoryAllowedBy(player)>1)
+player->ADD_GOSSIP_ITEM(7MAIN_MENUGOSSIP_MAIN_MENU0);
+
+player->SEND_GOSSIP_MENU(MSG_DESTcreature->GetGUID());
+}
+
+//Verificationbeforeteleportation
+voidActionTeleport(Player*constplayerCreature*constcreatureconstuint32&id)
+{
+Destdest(TabCatDest[Cat[player]].GetDest(id));
+
+if(player->getLevel()<dest.m_level&&!player->isGameMaster())
+{
+std::stringmsg("Youdonothavetherequiredlevel.Thisdestinationrequireslevel"+ConvertStr(dest.m_level)+".");
+creature->MonsterWhisper(msg.c_str()player->GetGUID());
+return;
+}
+
+if(player->GetMoney()<dest.m_cost&&!player->isGameMaster())
+{
+std::stringmsg("Youdonothaveenoughmoney.Thepriceforteleportationis"+ConvertMoney(dest.m_cost)+".");
+creature->MonsterWhisper(msg.c_str()player->GetGUID());
+return;
+}
+
+if(!player->isGameMaster()&&dest.m_cost)
+player->ModifyMoney(-1*dest.m_cost);
+
+Teleport(playerdest.m_mapdest.m_Xdest.m_Ydest.m_Zdest.m_orient);
+}
+}
+
+boolGossipHello_npc_teleport(Player*playerCreature*creature)
+{
+PageC(player)=PageD(player)=Cat(player)=0;
+
+if(player->isInCombat())
+{
+player->CLOSE_GOSSIP_MENU();
+creature->MonsterWhisper("Youareincombat.Comebacklater"player->GetGUID());
+returntrue;
+}
+AffichCat(playercreature);
+returntrue;
+}
+
+boolGossipSelect_npc_teleport(Player*playerCreature*creatureuint32senderuint32param)
+{
+switch(sender)
+{
+//Displaydestinations
+caseGOSSIP_SHOW_DEST:
+Cat(player)=param;
+AffichDest(playercreature);
+break;
+
+//Previouscategoriespage
+caseGOSSIP_PREV_PAGEC:
+--PageC(player);
+AffichCat(playercreature);
+break;
+
+//Nextpagecategories
+caseGOSSIP_NEXT_PAGEC:
+++PageC(player);
+AffichCat(playercreature);
+break;
+
+//Previousdestinationspage
+caseGOSSIP_PREV_PAGED:
+--PageD(player);
+AffichDest(playercreature);
+break;
+
+//Nextdestinationpage
+caseGOSSIP_NEXT_PAGED:
+++PageD(player);
+AffichDest(playercreature);
+break;
+
+//Displaymainmenu
+caseGOSSIP_MAIN_MENU:
+GossipHello_npc_teleport(playercreature);
+break;
+
+//Teleportation
+caseGOSSIP_TELEPORT:
+player->CLOSE_GOSSIP_MENU();
+if(player->HasAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS0)){
+creature->CastSpell(player38588false);//Healingeffect
+player->RemoveAurasDueToSpell(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS);
+}
+
+ActionTeleport(playercreatureparam);
+break;
+}
+returntrue;
+}
+
+
+voidAddSC_npc_teleport()
+{
+Script*newscript;
+
+newscript=newScript;
+newscript->Name="npc_teleport";
+newscript->pGossipHello=&GossipHello_npc_teleport;
+newscript->pGossipSelect=&GossipSelect_npc_teleport;
+newscript->RegisterSelf();
+}
---a/src/bindings/scripts/system/ScriptLoader.cpp2009-08-1615:21:06.000000000+0200
+++b/src/bindings/scripts/system/ScriptLoader.cpp2009-08-1615:22:33.000000000+0200
@@-116+118@@
externvoidAddSC_example_escort();
externvoidAddSC_example_gossip_codebox();
externvoidAddSC_example_misc();
+//TeleNPC2
+externvoidAddSC_npc_teleport();

//world
externvoidAddSC_areatrigger_scripts();
@@-5226+5248@@
AddSC_example_escort();
AddSC_example_gossip_codebox();
AddSC_example_misc();
+//TeleNPC2
+AddSC_npc_teleport();

//world
AddSC_areatrigger_scripts();
[顶部]