Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.26 KB | None | 0 0
  1. --[[
  2. Super Vocation Transformation Ring, originally written by artofwork aka Breed, Jotran, Codex NG :p
  3. Updated for a 1.2 server, however this will work as well for a 1.0 or 1.1 server.
  4.  
  5. This script uses a gold ring (itemid 2179), however you can set it to use whatever item in movements.xml.
  6.  
  7. What does this script do?
  8. When the item is equipped it will change the player's vocation to a new vocation and apply a series of conditions.
  9.  
  10. Individual Health and Mana regen settings per vocation.
  11. Individual Health and Mana points settings per vocation.
  12. Individual Skills and Magic Level settings per vocation.
  13. A new outfit for the player including a mount they can ride.
  14. Super Haste for all vocations.
  15. Auto Manashield for sorcerer and druid.
  16.  
  17. Please update your vocations.xml file in the data\XML directory with the new vocations.
  18.  
  19. New in this script, outfits which contain mounts (amongst other things), settings to remove soul or an item.
  20. Items or Soul are removed per interval.
  21.  
  22. Settings to disable constant special effect (can be an eyesore or just cpu intensive on older machines).
  23.  
  24. Place this in movements.xml
  25.  
  26. <!-- super vocation transformation ring -->
  27. <!-- gold ring -->
  28. <movevent event="Equip" itemid="2179" slot="ring" script="superVocationTransformationRing.lua" />
  29. <movevent event="DeEquip" itemid="2179" slot="ring" script="superVocationTransformationRing.lua" />
  30.  
  31. Save this script as superVocationTransformationRing.lua
  32. In data\movements\scripts
  33. ]]
  34.  
  35. -- Configuration Start
  36. local c = {
  37. useSoul = true, -- true to use soul, false to use an item instead
  38. soulAmount = 20, -- amount of soul to remove per interval, setting it to 0 will make the ring last forever
  39. itemid = 2160, -- item to use if useSoul is set to false
  40. itemAmount = 0, -- item amount to remove from the player, setting it to 0 will make the ring last forever
  41. vocationStorage = 18009, -- this holds the players old vocation
  42. effectsStorage = 18010, -- the special effects storage
  43. interval = 1, -- this effects the constant special effect but also the removal of the item/soul, 1 equals 1 second
  44. destroyItem = false, -- should the item be destroyed when it runs out of soul/item amount?
  45. disableAnimation = false -- the constant special effect that is applied to the player will be suppressed if set to true
  46. }
  47.  
  48. local outfits = {
  49. [1] = { -- sorcerer new outfit after transformation --
  50. lookType = 130,
  51. lookHead = 19,
  52. lookBody = 71,
  53. lookLegs = 128,
  54. lookFeet = 128,
  55. lookMount = 368,
  56. lookAddons = 3
  57. },
  58. [2] = { -- druid new outfit after transformation --
  59. lookType = 63,
  60. lookHead = 20,
  61. lookBody = 30,
  62. lookLegs = 40,
  63. lookFeet = 50,
  64. lookMount = 624,
  65. lookAddons = 3
  66. },
  67. [3] = { -- paladin new outfit after transformation --
  68. lookType = 129,
  69. lookHead = 95,
  70. lookBody = 116,
  71. lookLegs = 121,
  72. lookFeet = 115,
  73. lookMount = 647,
  74. lookAddons = 3
  75. },
  76. [4] = { -- knight new outfit after transformation --
  77. lookType = 131,
  78. lookHead = 95,
  79. lookBody = 95,
  80. lookLegs = 95,
  81. lookFeet = 95,
  82. lookMount = 373,
  83. lookAddons = 3
  84. }
  85. }
  86.  
  87. local effects = {
  88. [1] = { -- sorcer
  89. firsteffect = CONST_ME_ENERGYAREA,
  90. secondeffect = CONST_ME_BLOCKHIT,
  91. flingeffect = CONST_ANI_SMALLHOLY,
  92. landeffect = CONST_ME_TELEPORT,
  93. ringwaste = CONST_ME_FIREWORK_YELLOW,
  94. ringsorb = CONST_ME_FIREATTACK
  95. },
  96. [2] = { -- druid
  97. firsteffect = CONST_ME_ICEATTACK,
  98. secondeffect = CONST_ME_ICETORNADO,
  99. flingeffect = CONST_ME_ICETORNADO,
  100. landeffect = CONST_ME_ICETORNADO,
  101. ringwaste = CONST_ME_FIREWORK_BLUE,
  102. ringsorb = CONST_ME_MAGIC_BLUE
  103. },
  104. [3] = { -- paladin
  105. firsteffect = CONST_ME_YELLOW_RINGS,
  106. secondeffect = CONST_ME_BLOCKHIT,
  107. flingeffect = CONST_ANI_SMALLHOLY,
  108. landeffect = CONST_ME_HOLYAREA,
  109. ringwaste = CONST_ME_FIREWORK_YELLOW,
  110. ringsorb = CONST_ME_MAGIC_GREEN
  111. },
  112. [4] = { -- knight
  113. firsteffect = CONST_ME_EXPLOSIONAREA,
  114. secondeffect = CONST_ME_FIREAREA,
  115. flingeffect = CONST_ANI_FIRE,
  116. landeffect = CONST_ME_FIREWORK_RED,
  117. ringwaste = CONST_ME_FIREWORK_RED,
  118. ringsorb = CONST_ME_MAGIC_RED
  119. }
  120.  
  121. }
  122.  
  123. local stats = {
  124. [1] = { -- sorcerer
  125. parameters = {
  126. {CONDITION_PARAM_SKILL_SHIELD, 20},
  127. {CONDITION_PARAM_STAT_MAGICPOINTS, 35},
  128. {CONDITION_PARAM_STAT_MAXHITPOINTS, 100},
  129. {CONDITION_PARAM_STAT_MAXMANAPOINTS, 700}
  130. }
  131. },
  132. [2] = { -- druid
  133. parameters = {
  134. {CONDITION_PARAM_SKILL_SHIELD, 20},
  135. {CONDITION_PARAM_STAT_MAGICPOINTS, 35},
  136. {CONDITION_PARAM_STAT_MAXHITPOINTS, 100},
  137. {CONDITION_PARAM_STAT_MAXMANAPOINTS, 700}
  138. }
  139. },
  140. [3] = { -- paladin
  141. parameters = {
  142. {CONDITION_PARAM_SKILL_DISTANCE, 35},
  143. {CONDITION_PARAM_SKILL_SHIELD, 30},
  144. {CONDITION_PARAM_STAT_MAGICPOINTS, 15},
  145. {CONDITION_PARAM_STAT_MAXHITPOINTS, 400},
  146. {CONDITION_PARAM_STAT_MAXMANAPOINTS, 350}
  147. }
  148. },
  149. [4] = { -- knight
  150. parameters = {
  151. {CONDITION_PARAM_SKILL_FIST, 50},
  152. {CONDITION_PARAM_SKILL_CLUB, 50},
  153. {CONDITION_PARAM_SKILL_SWORD, 50},
  154. {CONDITION_PARAM_SKILL_AXE, 50},
  155. {CONDITION_PARAM_SKILL_SHIELD, 75},
  156. {CONDITION_PARAM_STAT_MAGICPOINTS, 10},
  157. {CONDITION_PARAM_STAT_MAXHITPOINTS, 1000},
  158. {CONDITION_PARAM_STAT_MAXMANAPOINTS, 250}
  159. }
  160. }
  161. }
  162.  
  163. local regen = {
  164. [1] = { -- sorcerer
  165. health = 35,
  166. mana = 150
  167. },
  168. [2] = { -- druid
  169. health = 35,
  170. mana = 150
  171. },
  172. [3] = { -- paladin
  173. health = 100,
  174. mana = 100
  175. },
  176. [4] = { -- knight
  177. health = 150,
  178. mana = 50
  179. }
  180. }
  181. -- Configuration End
  182. -- Do not edit anything below unless you know what you are doing.
  183. local statsCondition = {}
  184.  
  185. for x = 1, #stats do
  186. statsCondition[x] = Condition(CONDITION_ATTRIBUTES, x)
  187. statsCondition[x]:setTicks(-1)
  188. for n = 1, #stats[x].parameters do
  189. statsCondition[x]:setParameter(stats[x].parameters[n][1], stats[x].parameters[n][2])
  190. end
  191. end
  192.  
  193. local regenCondition = {}
  194.  
  195. for i = 1, #regen do
  196. regenCondition[i] = Condition(CONDITION_REGENERATION, i)
  197. regenCondition[i]:setTicks(-1)
  198. regenCondition[i]:setParameter(CONDITION_PARAM_HEALTHGAIN, regen[i].health)
  199. regenCondition[i]:setParameter(CONDITION_PARAM_MANAGAIN, regen[i].mana)
  200. end
  201.  
  202. local haste = Condition(CONDITION_HASTE)
  203. haste:setTicks(-1)
  204. haste:setFormula( 2.5, 0, 3.0, 0)
  205.  
  206. local manashield = Condition(CONDITION_MANASHIELD)
  207. manashield:setTicks(-1)
  208.  
  209. function distanceEffect(pos)
  210. return {
  211. [1] = {x = pos.x, y = pos.y - 3, z = pos.z, stackpos = 255}, -- north
  212. [2] = {x = pos.x, y = pos.y + 3, z = pos.z, stackpos = 255}, -- south
  213. [3] = {x = pos.x - 3, y = pos.y, z = pos.z, stackpos = 255}, -- west
  214. [4] = {x = pos.x + 3, y = pos.y, z = pos.z, stackpos = 255}, -- east
  215.  
  216. [5] = {x = pos.x - 2, y = pos.y - 2, z = pos.z, stackpos = 255}, -- north west
  217. [6] = {x = pos.x + 2, y = pos.y - 2, z = pos.z, stackpos = 255}, -- north east
  218. [7] = {x = pos.x + 2, y = pos.y + 2, z = pos.z, stackpos = 255}, -- south east
  219. [8] = {x = pos.x - 2, y = pos.y + 2, z = pos.z, stackpos = 255} -- south west
  220. }
  221. end
  222.  
  223. function isValidVocation(id)
  224. local possibleVocations = { -- corresponding vocations
  225. [{1, 5, 9}] = 13, -- sorcerer / master sorcerer to super master sorcerer
  226. [{2, 6, 10}] = 14, -- druid / elder druid to super elder druid
  227. [{3, 7, 11}] = 15, -- paladin / royal paladin to super royal paladin
  228. [{4, 8, 12}] = 16 -- knight / elite knight to super elite knight
  229. }
  230. for oldVocation, newVocation in pairs(possibleVocations) do
  231. if isInArray(oldVocation, id) then
  232. return newVocation
  233. end
  234. end
  235. return id
  236. end
  237.  
  238. function reset(p)
  239. local player = Player(p.cid)
  240. if player then
  241. player:removeCondition(CONDITION_ATTRIBUTES, p.id)
  242. player:removeCondition(CONDITION_REGENERATION, p.id)
  243. player:removeCondition(CONDITION_HASTE)
  244. player:removeCondition(CONDITION_OUTFIT)
  245. if isInArray({1, 2}, p.id) then
  246. player:removeCondition(CONDITION_MANASHIELD)
  247. end
  248. if c.destroyItem then
  249. local item = player:getSlotItem(p.slot)
  250. if item then
  251. item:remove()
  252. end
  253. end
  254. player:setStorageValue(c.vocationStorage, -1)
  255. player:setVocation(p.id)
  256. end
  257. end
  258.  
  259. function animate(cid, position, id)
  260. local player = Player(cid)
  261. if player then
  262. if player:getStorageValue(c.effectsStorage) == 1 then
  263. Position(position):sendMagicEffect(effects[id].firsteffect)
  264. Position(position):sendMagicEffect(effects[id].secondeffect)
  265. local direction = distanceEffect(position)
  266. for m = 1, #direction do
  267. Position(position):sendDistanceEffect(direction[m], effects[id].flingeffect)
  268. end
  269. for o = 1, #direction do
  270. Position(direction[o]):sendMagicEffect(effects[id].landeffect)
  271. end
  272. end
  273. end
  274. end
  275.  
  276. function transform(p)
  277. local player = Player(p.cid)
  278. if player then
  279. animate(p.cid, player:getPosition(), p.id)
  280. doSetCreatureOutfit(player, outfits[p.id], -1)
  281. player:addCondition(statsCondition[p.id])
  282. if isInArray({1, 2}, p.id) then
  283. player:addCondition(manashield)
  284. end
  285. player:addCondition(haste)
  286. player:addCondition(regenCondition[p.id])
  287. player:setVocation( isValidVocation( p.id ) )
  288. if not c.disableAnimation then
  289. addEvent(specialEffect, 1, p)
  290. else
  291. addEvent(skipToVerification, 1, p)
  292. end
  293. end
  294. end
  295.  
  296. function skipToVerification(p)
  297. if verify(p.cid) then
  298. addEvent(skipToVerification, c.interval * 1000, p)
  299. else
  300. reset(p)
  301. end
  302. end
  303.  
  304. function verify(cid)
  305. local player = Player(cid)
  306. if player then
  307. if c.useSoul then
  308. if player:getSoul() < c.soulAmount then
  309. return false
  310. end
  311. player:addSoul(-c.soulAmount)
  312. else
  313. if player:getItemCount(c.itemid) < c.itemAmount then
  314. return false
  315. end
  316. player:removeItem(c.itemid, c.itemAmount)
  317. end
  318. end
  319. return true
  320. end
  321.  
  322. function specialEffect(p)
  323. local player = Player(p.cid)
  324. if player then
  325. if verify(p.cid) then
  326. if player:getStorageValue(c.effectsStorage) == 1 then
  327. local position = player:getPosition()
  328. position:sendMagicEffect(effects[p.id].ringwaste)
  329. position:sendMagicEffect(effects[p.id].ringsorb)
  330. animate(position, p.id)
  331. addEvent(specialEffect, c.interval * 1000, p)
  332. end
  333. else
  334. reset(p)
  335. end
  336. end
  337. end
  338.  
  339. function getMsg()
  340. local name = c.useSoul and 'soul point' or ItemType(c.itemid):getName()
  341. local amount = c.useSoul and c.soulAmount or c.itemAmount
  342. return " you don't have enough " .. name .. "s, you need atleast " .. amount .. " to benefit from the effects of this ring."
  343. end
  344.  
  345. function onEquip(cid, item, slot)
  346. -- this will make it compatible for 1.0, 1.1, 1.2
  347. local player = type(cid) == 'number' and Player(cid) or cid
  348. local slots = player:getSlotItem(slot)
  349. if slots then
  350. if slots.itemid ~= item.itemid then
  351. return true
  352. else
  353. if not verify(player:getId()) then
  354. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Sorry, ' .. player:getName() .. getMsg())
  355. return false
  356. end
  357. if player:getStorageValue(c.vocationStorage) < 1 then
  358. local vocationId = player:getVocation():getId()
  359. player:setStorageValue(c.vocationStorage, vocationId)
  360. player:setStorageValue(c.effectsStorage, 1)
  361. end
  362. player:say("Rutilus Vox", TALKTYPE_ORANGE_1)
  363. local p = { cid = player:getId(), item = item, slot = slot, id = player:getStorageValue(c.vocationStorage) }
  364. addEvent(transform, 1, p)
  365. end
  366. end
  367. return true
  368. end
  369.  
  370. function onDeEquip(cid, item, slot)
  371. -- this will make it compatible for 1.0, 1.1, 1.2
  372. local player = type(cid) == 'number' and Player(cid) or cid
  373. local vocationId = player:getStorageValue(c.vocationStorage)
  374. if vocationId > 0 then
  375. player:say("Rutilus Vox", TALKTYPE_ORANGE_1)
  376. animate(player:getId(), player:getPosition(), vocationId)
  377. local p = {cid = player:getId(), id = vocationId, slot = slot}
  378. player:setStorageValue(c.effectsStorage, -1)
  379. reset(p)
  380. end
  381. return true
  382. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement