MoveEvent [Release] Simple Transforming Ring v1.1 (0.3+)

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela
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:

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 :D
► Everything else was done by me, I scripted it all from scratch.
(which makes me be a bit proud of myself :D)

♠ Compatibility:

Tested and working in 0.3.5pl1.
Should also work on any 0.3+

♠ Miscellaneous:

<- guIt00r! :D

♠ 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 :p). And this took me 2 hours, Im so noobish :(

Regards.
 
Last edited:

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,168
Best answers
9
Reaction score
1,011
Location
Germany :O
Nice script

About your problem just use a storage value and set it to 1 if the ring is equiped and to 0 if not..

Code:
        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,13371) == 1 then
                addEvent(SendEffects, delay * 1000)
                end
        end
 
OP
Guitar Freak

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela
Nice script

About your problem just use a storage value and set it to 1 if the ring is equiped and to 0 if not..

Code:
        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,13371) == 1 then
                addEvent(SendEffects, delay * 1000)
                end
        end
Ohhh! So true man I dont know why I didnt think of that :thumbup:

Edited first post, I also added another bug I just found, if you or anyone can take a minute to test it to see if it happens on your server too, Id appreciate it!

+Rep to you Rhux!
 
OP
Guitar Freak

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela
Bump! Wow 204 views and 1 comment :) Is it that useless? :D

And nobody knows about this?:

► 27/11/09: I think I cant make it work like a "ring" for some reason, I mean, everything works now but when you wear the ring the remaining time doesnt decrease! Any idea of why is this happening?
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
I think it is great that you updated this script, but I also think there are to many "RPG" servers out there, that don't really need this.
Good work though :thumbup:
 
OP
Guitar Freak

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela
I think it is great that you updated this script, but I also think there are to many "RPG" servers out there, that don't really need this.
Good work though :thumbup:
Thanks and yeh you're right :p

I wasnt expecting too many views for that matter! In my other comment I was pretty much only highlighting the horrible views/comments ratio :)

Btw do you have any idea of what could be happening on that bug I posted? Im clueless there :confused:
 
OP
Guitar Freak

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela
Bump, still need some advice on this bug guys:

► 27/11/09: I think I cant make it work like a "ring" for some reason, I mean, everything works now but when you wear the ring the remaining time doesnt decrease! Any idea of why is this happening?
Thanks in advance.
 
OP
Guitar Freak

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela

(nvm edited the last pic, dont want to end up getting banned for inappropiacy :p)

But this one is funny too :D, anyway seriously somebody has to know what Im doing wrong on the script for that bug to happen, please if you know post it!

Only takes a few seconds :)
 

babalow

Nobody o/
Joined
Nov 7, 2007
Messages
392
Best answers
0
Reaction score
0
Location
Brazil
to decrease time works I think u have to add "doDecayItem(uid)"
nice anyway
 
OP
Guitar Freak

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela
Bump.

I was checking some random stuff around otland and suddenly I realized what I was missing here in this script so I fixed it and updated the script to v1.1.

Check the changelog in the main post.

Regards.
 

Zyntax

*WannaBe Scripter*
Joined
Jan 27, 2010
Messages
533
Best answers
0
Reaction score
36
Location
Lua & XML Section
Could it be that you saw the "Exp Ring" thread and realized the
doDecayItem() function there? :D

Just wondering ... ;)
 
OP
Guitar Freak

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Best answers
0
Reaction score
11
Location
Caracas, Venezuela
Could it be that you saw the "Exp Ring" thread and realized the
doDecayItem() function there? :D

Just wondering ... ;)
Sort of, when I saw that thread and your post it was what "ringed the bell" for me to remember that I had to fix this script! so I tried the way you had scripted but it didnt work for some unknown reason (as I told you on that PM), so I started searching on the forum for similar scripts that used decays until I found one that was like doDecayItem(itemEx.uid) and thats when I noticed the sillyness I was missing :p

Btw, sorry for not answering your PMs yet! I did read them but Im very busy on weekdays and I dont have the time I want for this, but hopefully this weekend Ill take my time to answer them correctly :D

Peace mate.
 

davidcantu96

New Member
Joined
May 9, 2016
Messages
17
Best answers
0
Reaction score
0
Im using tfs 0.4 on 8.6 rl server, when i place the item on the ground the etire server just shuts down. :O
 
Top