Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 KB | None | 0 0
  1. -- Query: Add new NPC into database with shop option.
  2.  
  3.  
  4. DECLARE @nType tinyint = 1 -- 1 = npc, 2 = tab, 3 = group
  5. ---------------------------------------------------------------------------------------
  6. -- NPC Related
  7. , @szNpc varchar(129) = 'KAISTERU' -- NPC name without "NPC_" tag (eg. CH_JINJIN)
  8. , @szNpcModel varchar(129) = 'kisaeng.bsr' -- Full path to .bsr located in data (eg. npc\npc\EastEuropeSystem_HunterUnion.bsr)
  9. , @szCharname varchar(17) = 'tcpcshow003' -- Character name, the char should be in place, where NPC has to be located.
  10. , @wInitialDir smallint = 32766 -- The direction of NPC.
  11. , @nFortressID tinyint = 1 -- FortressID here. 1 - Jangan, 2- Bandit, 3- Hotan 4 - Constantinople
  12.  
  13. ---------------------------------------------------------------------------------------
  14. -- Shop Related
  15.  
  16. , @nCreateShops tinyint = 1 -- 1 to enable shops, 0 to create just npc.
  17. , @szTabName varchar(129) = 'TEXT' -- Tab name without SN* and *TABn (eg. POTIONS_PRO)
  18. , @nGameWorldIndex int = 1; -- Gameworld index. Use 1 for default, 99 for Jupiter.
  19. ---------------------------------------------------------------------------------------
  20.  
  21. -- Last Ids
  22. DECLARE @nTabIndex tinyint
  23.  
  24. SELECT TOP 1 @nTabIndex = CAST(RIGHT(CodeName128,1) as tinyint)
  25. FROM _RefShopTab WHERE CodeName128 LIKE 'STORE_'+@szNPC+'_TAB_'
  26. ORDER BY CodeName128 DESC
  27.  
  28. DECLARE @nGroupIndex tinyint
  29.  
  30. SELECT TOP 1 @nGroupIndex = CAST(RIGHT(CodeName128,1) as tinyint)
  31. FROM _RefShopTab WHERE CodeName128 LIKE 'STORE_'+@szNPC+'_GROUP_'
  32. ORDER BY CodeName128 DESC
  33.  
  34. DECLARE @nObjCharIndex int
  35. , @nObjCommonIndex int
  36. , @nHiveIndex int
  37. , @nTacticsIndex int;
  38.  
  39. ---------------------------------------------------------
  40.  
  41. IF (@nType = 1)
  42. BEGIN
  43. -- Step 1 - Insert NPC into tables.
  44.  
  45. IF EXISTS (SELECT * FROM _RefObjCommon WHERE CodeName128 like '%'+@szNPC+'%')
  46. BEGIN
  47. print('Are you gay? This NPC exists already.')
  48. RETURN
  49. END
  50.  
  51. DECLARE @nRegionID smallint = (SELECT LatestRegion FROM _Char where CharName16 = @szCharname)
  52. , @nPosX real = (SELECT PosX FROM _Char WHERE CharName16 = @szCharname)
  53. , @nPosY real = (SELECT PosY FROM _Char WHERE CharName16 = @szCharname)
  54. , @nPosZ real = (SELECT PosZ FROM _Char WHERE CharName16 = @szCharname);
  55.  
  56. INSERT _RefObjChar
  57. VALUES('0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','336860180','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');
  58. SET @nObjCharIndex = SCOPE_IDENTITY();
  59.  
  60. INSERT _RefObjCommon
  61. VALUES('1','NPC_' + @szNPC,'xxx','xxx','SN_NPC_'+@szNpc,'xxx','0','1','1','2','2','0','5000','3','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','-1','0','-1','0','-1','0','-1','0','-1','0','0','0','0','0','0','0','100','0','0','0',+@szNpcModel,'xxx','xxx',@nFortressID,'xxx',@nObjCharIndex);
  62. SET @nObjCommonIndex = SCOPE_IDENTITY();
  63.  
  64. INSERT Tab_RefHive
  65. VALUES('0','0','0','0','0','0',@nGameWorldIndex,'2','NPC_'+@szNpc);
  66. SET @nHiveIndex = SCOPE_IDENTITY();
  67.  
  68. INSERT Tab_RefTactics
  69. VALUES(@nObjCommonIndex,'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','0','0','0','0','0','0','0','Npc_Test');
  70. SET @nTacticsIndex = SCOPE_IDENTITY();
  71.  
  72. INSERT Tab_RefNest
  73. VALUES(@nHiveIndex, @nTacticsIndex, @nRegionID, @nPosX, @nPosY, @nPosZ, @wInitialDir,'0','0','0','0','0','1','0','1','0');
  74.  
  75. if(@nCreateShops = 1)
  76. BEGIN
  77. -- Step 2 - Insert Shop into tables.
  78. INSERT _RefShop
  79. VALUES('1','15','STORE_' + @szNpc,'-1','xxx','-1','xxx','-1','xxx','-1','xxx');
  80.  
  81. INSERT _RefShopGroup
  82. VALUES('1','15','GROUP_' +@szNpc,'NPC_'+@szNpc,'-1','xxx','-1','xxx','-1','xxx','-1','xxx');
  83.  
  84. INSERT _RefShopTab
  85. VALUES ('1','15','STORE_'+@szNpc+'_TAB1','STORE_'+@szNpc+'_GROUP1','SN_'+@szTabName+'_TAB1');
  86.  
  87. INSERT _RefShopTabGroup
  88. VALUES ('1','15','STORE_'+@szNpc+'_GROUP1','SN_STORE_'+@szNpc+'_GROUP1');
  89.  
  90. INSERT _RefShopItemGroup
  91. VALUES('1', 'STORE_'+@szNPC+'_GROUP1', 'SN_STORE_'+@szNPC+'_GROUP1')
  92.  
  93. INSERT _RefMappingShopGroup
  94. VALUES('1','15','GROUP_STORE_'+@szNpc,'STORE_'+@szNpc);
  95.  
  96. INSERT _RefMappingShopWithTab
  97. VALUES('1','15','STORE_'+@szNpc,'STORE_'+@szNpc+'_GROUP1');
  98. END
  99. END
  100.  
  101. ELSE IF (@nType = 2)
  102. BEGIN
  103. IF NOT EXISTS (SELECT * FROM _RefObjCommon WHERE CodeName128 like '%'+@szNPC+'%')
  104. BEGIN
  105. print('Are you gay? This NPC does not exist!');
  106. RETURN
  107. END
  108.  
  109. if (@nTabIndex > 4)
  110. BEGIN
  111. print('You have got already 4 tabs for this npc. Please try other one!');
  112. RETURN
  113.  
  114. INSERT _RefShopTab
  115. VALUES ('1','15','STORE_'+@szNpc+'_TAB'+@nTabIndex,'STORE_'+@szNpc+'_GROUP'+@nGroupIndex,'SN_'+@szTabName+'_TAB'+@nTabIndex);
  116.  
  117. END
  118.  
  119. ELSE IF (@nType = 3)
  120. BEGIN
  121. IF NOT EXISTS (SELECT * FROM _RefObjCommon WHERE CodeName128 like '%'+@szNPC+'%')
  122. BEGIN
  123. print('Are you gay? This NPC does not exist!')
  124. RETURN
  125. END
  126.  
  127. if (@nGroupIndex > 6)
  128. BEGIN
  129. print('You have got already 6 groups for this npc. Please try other one!')
  130. RETURN
  131. END
  132.  
  133.  
  134. INSERT _RefShopItemGroup
  135. VALUES('1', 'STORE_'+@szNPC+'_GROUP'+@nGroupIndex, 'SN_STORE_'+@szNPC+'_GROUP'+@nGroupIndex);
  136.  
  137. INSERT _RefShopTabGroup
  138. VALUES ('1','15','STORE_'+@szNpc+'_GROUP'+@nGroupIndex,'SN_STORE_'+@szNpc+'_GROUP'+@nGroupIndex);
  139.  
  140. INSERT _RefMappingShopGroup
  141. VALUES('1','15','GROUP_STORE_'+@szNpc,'STORE_'+@szNpc);
  142.  
  143. INSERT _RefMappingShopWithTab
  144. VALUES('1','15','STORE_'+@szNpc,'STORE_'+@szNpc+'_GROUP'+@nGroupIndex);
  145.  
  146. END
  147. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement