Guitar Freak
_LüA_n☺b_
Hello everyone again, Ive been very bored today and I wanted to do some scripting, and I saw the "Super transforming ring thing" idea and decided to try and script a similar one for newest TFS.
I know it has been done before but well, this is just my own rendition, its not like Im charging anything for it
♠ Changelog:
♠ Description:
This is similar but not the exact same as the usual "Super Transforming Rings", this is a bit simpler I think.
Anyway, it is a ring that when you wear it, it will:
► Multiply your max HP/MP by the amount you want.
► Transform you to a new outfit, vocation/gender dependant, and without changing the outfit colors/addons you had before.
► Extra features for promoted players (different outfits, different stat gains).
► Everything being easily configurable on the beginning of the script.
Again I know its nothing really special, and probably the other versions out there are better, but I tried to make this one as "easily configurable" as possible for non-scripters who want a simple and customizable transforming ring
♠ Credits:
► Im not sure who the initial idea was by, but credits to him/her!
► To Chojrak because Im using his isMale(cid)/isFemale(cid) simple functions
► Everything else was done by me, I scripted it all from scratch.
(which makes me be a bit proud of myself )
♠ Compatibility:
Tested and working in 0.3.5pl1.
Should also work on any 0.3+
♠ Miscellaneous:
<- guIt00r!
♠ Script:
Ok first of all, go to /data/lib/function.lua and add these simple functions:
Notice, if you dont do that first step, you will have to change the respective functions on the script.
Now, in /data/movements/movements.xml:
Use the itemID you wish. I used 2166/2203 which is "Power Ring".
In case you want to know, in /data/items/items.xml for what was the "Power Ring" you can change it like:
Change the "whatever" to whatever name you want ^_^ And set "duration" to your wish, in seconds.
Ok, so now that you're done with all that, in /data/movements/scripts/Transforming Ring.lua:
♠ Bug Im aware of:
(I need help from the pr0s here because I honestly couldnt figure how to solve it)
► The "visual bars" part at the end of the script, but I dont think this gives any problem at all.
And thats it, as for the script, I tried to explain most parts so you can change anything you want without screwing it up
As always, if you find any other bugs or can shorten/optimize it, feel free to (specially if you can shorten it Id be happy ). And this took me 2 hours, Im so noobish
Regards.
I know it has been done before but well, this is just my own rendition, its not like Im charging anything for it
♠ Changelog:
v1.1 (29/01/10):
* Fixed the decay bug, now its working 100%.
* Optimized the script so now when you unwear the ring you go back to the outfit you had before using it.
v1.0 (23/11/09):
* Initial release.
* Keep reading below for the description, features, etc. of the script.
♠ Description:
This is similar but not the exact same as the usual "Super Transforming Rings", this is a bit simpler I think.
Anyway, it is a ring that when you wear it, it will:
► Multiply your max HP/MP by the amount you want.
► Transform you to a new outfit, vocation/gender dependant, and without changing the outfit colors/addons you had before.
► Extra features for promoted players (different outfits, different stat gains).
► Everything being easily configurable on the beginning of the script.
Again I know its nothing really special, and probably the other versions out there are better, but I tried to make this one as "easily configurable" as possible for non-scripters who want a simple and customizable transforming ring
♠ Credits:
► Im not sure who the initial idea was by, but credits to him/her!
► To Chojrak because Im using his isMale(cid)/isFemale(cid) simple functions
► Everything else was done by me, I scripted it all from scratch.
(which makes me be a bit proud of myself )
♠ Compatibility:
Tested and working in 0.3.5pl1.
Should also work on any 0.3+
♠ Miscellaneous:
<- guIt00r!
♠ Script:
Ok first of all, go to /data/lib/function.lua and add these simple functions:
Lua:
function isPlayerPromoted(cid)
return getPlayerPromotionLevel(cid) >= 1 and true or false
end
function isFemale(cid) -- By Chojrak
return getPlayerSex(cid) == 0 and true or false
end
function isMale(cid) -- By Chojrak
return getPlayerSex(cid) == 1 and true or false
end
Notice, if you dont do that first step, you will have to change the respective functions on the script.
Now, in /data/movements/movements.xml:
PHP:
<movevent type="Equip" itemid="2166" slot="ring" event="script" value="Transforming Ring.lua"/>
<movevent type="DeEquip" itemid="2203" slot="ring" event="script" value="Transforming Ring.lua"/>
Use the itemID you wish. I used 2166/2203 which is "Power Ring".
In case you want to know, in /data/items/items.xml for what was the "Power Ring" you can change it like:
PHP:
<item id="2166" article="a" name="whatever ring">
<attribute key="weight" value="80"/>
<attribute key="slotType" value="ring"/>
<attribute key="transformEquipTo" value="2203"/>
<attribute key="stopduration" value="1"/>
<attribute key="showduration" value="1"/>
</item>
<item id="2203" article="a" name="whatever ring">
<attribute key="weight" value="80"/>
<attribute key="slotType" value="ring"/>
<attribute key="decayTo" value="0"/>
<attribute key="transformDeEquipTo" value="2166"/>
<attribute key="duration" value="300"/> <!-- 300 = 5 minutes -->
<attribute key="showduration" value="1"/>
</item>
Change the "whatever" to whatever name you want ^_^ And set "duration" to your wish, in seconds.
Ok, so now that you're done with all that, in /data/movements/scripts/Transforming Ring.lua:
Lua:
--[[
* Simple Transforming Ring *
Compatibility: Tested and working on 0.3.5pl1. Should work on any 0.3+
Script Author: Guitar Freak
]]--
------------
-- Config --
------------
local config = {
hpmulti = 1.5, -- "Max HP" multiplier after putting the ring on (1.5 = 1.5x HP). Do NOT put 0 on any multiplier.
manamulti = 1, -- "Max Mana" multiplier after putting the ring on (1 = 1x Mana = No change).
promoboost = false, -- Default is "false". Set this to "true" if you want the ring to be stronger for promoted players. Config for this below.
promohp = 2, -- Same as "hpmulti" but this one is for promoted players, if you put promoboost = true.
promomana = 1.5, -- Same as "manamulti" but this one is for promoted players, if you put promoboost = true.
fullonwear = false, -- "false" is default. Set this to "true" if you want the players to get full -new- hp/mana at the MOMENT of wearing the ring.
effects = false, -- "false" is default. Set this to "true" if you want it to send magic effects on the player WHILE wearing the ring.
curr_outfit = 51015, -- Put here an unused Storage Value, this is to save the current outfit value, read the script's ending for a better understanding of this!
ringunworn = 2166, -- Put here the itemID of the UNWORN ring you will use. Default is 2166 (UNWORN Power Ring).
ringworn = 2203, -- Put here the itemID of the WORN ring you will use (worn is when it is in use). Default is 2203 (WORN Power Ring).
wornstorage = 51016, -- Put here an unused Storage Value, to use for the "effects" part if you have it set to 'true'.
}
local effects = { -- Put here the effects that you want randomized on the player while he has the ring on him, in case you set the "effects" to true on the config.
CONST_ME_FIREWORK_BLUE,
CONST_ME_GIFT_WRAPS
}
local outfits = { -- Put here the outfits that each vocation will look like when putting ring on.
-- ["vocname"] = {maleoutfitID, femaleoutfitID}
["knight"] = {143, 147},
["pally"] = {146, 150},
["sorc"] = {145, 149},
["druid"] = {144, 148}
}
local promooutfits = { -- Put here the outfits that each PROMOTED vocation will look like when putting ring on, in case you are using "promoboost = true".
-- ["vocname"] = {maleoutfitID, femaleoutfitID}
["knight"] = {2, 2},
["pally"] = {12, 12},
["sorc"] = {226, 226},
["druid"] = {264, 264}
}
-- Remember that if you add new VOCATIONS to the outfit lists, you have to add some lines down there on the script too!
------------
-- Script --
------------
function onEquip(cid, item, slot)
doPlayerSetStorageValue(cid, config.wornstorage, 1)
local getOutfit = getCreatureOutfit(cid)
function SendEffects()
local delay = 1 -- Delay between the effects (1 = 1 second).
for i = 1, #effects do
doSendMagicEffect(getCreaturePosition(cid), effects[math.random(1,#effects)])
end
if getPlayerStorageValue(cid, config.wornstorage) == 1 then
addEvent(SendEffects, delay * 1000)
end
end
doTransformItem(item.uid, config.ringworn, 1)
doDecayItem(item.uid)
doPlayerSetStorageValue(cid, config.curr_outfit, getOutfit.lookType)
doPlayerSendTextMessage(cid, 22, "Enjoy the power of this godly ring!")
if config.promoboost == true then
if isPlayerPromoted(cid) then
setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid) * config.promohp))
setCreatureMaxMana(cid, (getCreatureMaxMana(cid) * config.promomana))
else
setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid) * config.hpmulti))
setCreatureMaxMana(cid, (getCreatureMaxMana(cid) * config.manamulti))
end
else
setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid) * config.hpmulti))
setCreatureMaxMana(cid, (getCreatureMaxMana(cid) * config.manamulti))
end
if config.fullonwear == true then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid))
end
if config.effects == true then
SendEffects()
end
if config.promoboost == true then
if isPlayerPromoted(cid) then -- If promoboost = true and player is promoted, the outfits will be:
if isKnight(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = promooutfits.knight[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = promooutfits.knight[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isPaladin(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = promooutfits.pally[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = promooutfits.pally[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isSorcerer(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = promooutfits.sorc[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = promooutfits.sorc[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isDruid(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = promooutfits.druid[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = promooutfits.druid[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
end
elseif isKnight(cid) then -- Else if promoboost = true but player is not promoted, the outfits will be:
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.knight[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.knight[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isPaladin(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.pally[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.pally[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isSorcerer(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.sorc[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.sorc[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isDruid(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.druid[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.druid[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
end
elseif isKnight(cid) then -- And if promoboost = false, the outfits will be:
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.knight[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.knight[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isPaladin(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.pally[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.pally[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isSorcerer(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.sorc[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.sorc[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
elseif isDruid(cid) then
if isMale(cid) then
doCreatureChangeOutfit(cid, {lookType = outfits.druid[1], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
else
doCreatureChangeOutfit(cid, {lookType = outfits.druid[2], lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
end
end
return TRUE
end
function onDeEquip(cid, item, slot)
doPlayerSetStorageValue(cid, config.wornstorage, 0)
local getOutfit = getCreatureOutfit(cid)
doTransformItem(item.uid, config.ringunworn, 1)
doPlayerSendTextMessage(cid, 22, "The mighty powers of the ring have been taken away from you!")
if config.promoboost == true then
if isPlayerPromoted(cid) then
setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid) / config.promohp))
setCreatureMaxMana(cid, (getCreatureMaxMana(cid) / config.promomana))
else
setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid) / config.hpmulti))
setCreatureMaxMana(cid, (getCreatureMaxMana(cid) / config.manamulti))
end
else
setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid) / config.hpmulti))
setCreatureMaxMana(cid, (getCreatureMaxMana(cid) / config.manamulti))
end
doCreatureAddHealth(cid, 1) -- This is because for some reason the "visual" stat bars of the client wont update when unwearing.
doCreatureAddMana(cid, 1) -- This is because for some reason the "visual" stat bars of the client wont update when unwearing.
-- After unwearing the ring, the player's outfit will be transformed to the one he previously had before using it!
doCreatureChangeOutfit(cid, {lookType = getPlayerStorageValue(cid, config.curr_outfit), lookHead = getOutfit.lookHead, lookAddons = getOutfit.lookAddons, lookLegs = getOutfit.lookLegs, lookBody = getOutfit.lookBody, lookFeet = getOutfit.lookFeet})
return TRUE
end
♠ Bug Im aware of:
(I need help from the pr0s here because I honestly couldnt figure how to solve it)
► The "visual bars" part at the end of the script, but I dont think this gives any problem at all.
And thats it, as for the script, I tried to explain most parts so you can change anything you want without screwing it up
As always, if you find any other bugs or can shorten/optimize it, feel free to (specially if you can shorten it Id be happy ). And this took me 2 hours, Im so noobish
Regards.
Last edited: