Action Flower Pots System

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
I was bored so I decided to do an actionscript for the flower pots, so first, the scripts, then the explaining part.

Add this in items.xml:
Code:
<item id="7655" name="flower pot">
		<attribute key="description" value="You should try planting some seeds."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="7665" name="flower pot">
		<attribute key="description" value="Something has been planted in there, but you cannot see what it is yet."/>
		<attribute key="weight" value="150"/>
		
	</item>
	<item id="7670" name="flower pot">
		<attribute key="description" value="The plant in there sprouted, but only gardeners might recognise what it will develop into."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7678"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7673" name="flower pot">
		<attribute key="description" value="Something has been planted in there, but you cannot see what it is yet."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7679"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7674" name="withered plant">
		<attribute key="description" value="This plant urgently needs some water, else it will wither away and disappear completely."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="0"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7675" name="withered plant">
		<attribute key="description" value="This plant urgently needs some water, else it will wither away and disappear completely."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="0"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7676" name="withered plant">
		<attribute key="description" value="This plant urgently needs some water, else it will wither away and disappear completely."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="0"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7677" name="withered plant">
		<attribute key="description" value="This plant urgently needs some water, else it will wither away and disappear completely."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="0"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7678" name="flower pot">
		<attribute key="description" value="The plant in there sprouted, but only gardeners might recognise what it will develop into."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="7679" name="flower pot">
		<attribute key="description" value="Something has been planted in there, but you cannot see what it is yet."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="7680" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a lizard tongue fern."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7681"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7681" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a lizard tongue fern."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="7682" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a dryad's heart flower."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7683"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7683" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a dryad's heart flower."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="7684" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a midnight bloom flower."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7685"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7685" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a midnight bloom flower."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="7686" name="flower pot">
		<attribute key="description" value="The plant in it seems to be an ember queen flower."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7687"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7687" name="flower pot">
		<attribute key="description" value="The plant in it seems to be an ember queen flower."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="7688" name="flower pot">
		<attribute key="description" value="There is a fully grown lizard tongue plant in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7689"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7689" name="flower pot">
		<attribute key="description" value="There is a fully grown lizard tongue plant in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7674"/>
		<attribute key="duration" value="259200"/>
	</item>
	<item id="7690" name="flower pot">
		<attribute key="description" value="There is a fully grown dryad's heart flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7691"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7691" name="flower pot">
		<attribute key="description" value="There is a fully grown dryad's heart flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7675"/>
		<attribute key="duration" value="259200"/>
	</item>
	<item id="7692" name="flower pot">
		<attribute key="description" value="There is a fully grown midnight bloom flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7693"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7693" name="flower pot">
		<attribute key="description" value="There is a fully grown midnight bloom flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7676"/>
		<attribute key="duration" value="259200"/>
	</item>
	<item id="7694" name="flower pot">
		<attribute key="description" value="There is a fully grown ember queen flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7695"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="7695" name="flower pot">
		<attribute key="description" value="There is a fully grown ember queen flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="7677"/>
		<attribute key="duration" value="259200"/>
	</item>



	<item id="9982" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a finger snapper plant."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="9983"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="9983" name="flower pot">
		<attribute key="description" value="The plant in it seems to be an finger snapper plant."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="9984" name="withered plant">
		<attribute key="description" value="This plant urgently needs some water, else it will wither away and disappear completely."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="0"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="9985" name="withered plant">
		<attribute key="description" value="This plant urgently needs some water, else it will wither away and disappear completely."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="0"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="9986" name="flower pot">
		<attribute key="description" value="The plant in it seems to be a fairy dance flower."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="9987"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="9987" name="flower pot">
		<attribute key="description" value="The plant in it seems to be an fairy dance flower."/>
		<attribute key="weight" value="150"/>
	</item>
	<item id="9988" name="flower pot">
		<attribute key="description" value="There is a fully grown fairy dance flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="9989"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="9989" name="flower pot">
		<attribute key="description" value="There is a fully grown fairy dance flower in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="9985"/>
		<attribute key="duration" value="259200"/>
	</item>
	<item id="9990" name="flower pot">
		<attribute key="description" value="There is a fully grown finger snapper plant in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="9991"/>
		<attribute key="duration" value="86400"/>
	</item>
	<item id="9991" name="flower pot">
		<attribute key="description" value="There is a fully grown finger snapper plant in it."/>
		<attribute key="weight" value="150"/>
		<attribute key="decayTo" value="9984"/>
		<attribute key="duration" value="259200"/>
	</item>
Now, add this to movements.xml
Code:
<movevent event="AddItem" tileitem="1" itemid="7655" event="script" value="seeds.lua" />
And create a file in movements/scripts called seeds.lua with this:
Code:
function onAddItem(moveitem, tileitem, position)
	if tileitem.itemid == 7655 then
		doRemoveItem(moveitem.uid,1)
		doTransformItem(tileitem.uid,tileitem.itemid+10)
		doSendMagicEffect(position,CONST_ME_MAGIC_BLUE)
	end
	return 1
end
Now, add this to actions.xml
Code:
<action itemid="7734" event="script" value="flowerpot.lua" />
And finally, create a file in actions/scripts called flowerpot.lua with this:
Code:
local CHANCES = 50 --Chances of advancing to the next stadium
local WATERINGCAN_ID = 7734
local WATERED = {7673, 7670, 7680, 7682, 7684, 7686, 7688, 7690, 7992, 7994, 9982, 9990, 9986, 9988} --Plants that don't need water...for the moment
local PLANTSPECIES = {7680, 7682, 7684, 7686, 9982, 9986} --The first time the plant type will be recognizable
local PLANTADVANCES = {[7679] = {7670, 7673}, [7681] = {7688, 7680}, [7683] = {7690, 7682}, [7685] = {7692, 7684}, [7687] = {7694, 7686}, [9983] = {9990, 9982}, [9987] = {9988, 9986}} --In what will it transforms to if it advances or not
local LASTSTADIUM = {7689, 7691, 7693, 7695, 9991, 9989} --When you water this plant's, they don't change, but the time remaining for them to dry resets
local WHITEREDPLANTS = {[7674] = 7688, [7675] = 7690, [7676] = 7692, [7677] = 7694, [9984] = 9990, [9985] = 9988} --Whitered plants Id's and the plant's they will become when recovered
function onUse(cid, item, fromPosition, itemEx, toPosition)
local RANDOM = math.random(100)
	if WHITEREDPLANTS[itemEx.itemid] ~= nil then
		doCreatureSay(cid,"You finally remembered to water your plant and it recovered.",TALKTYPE_ORANGE_1)
		doTransformItem(itemEx.uid,WHITEREDPLANTS[itemEx.itemid])
	elseif itemEx.itemid == 7655 then
		doCreatureSay(cid,"You should plant some seeds first.",TALKTYPE_ORANGE_1)
	elseif itemEx.itemid == 7665 then
		doCreatureSay(cid,"You watered your plant.",TALKTYPE_ORANGE_1)
		doTransformItem(itemEx.uid,itemEx.itemid+8)
	elseif isInArray(WATERED,itemEx.itemid) == TRUE then
		doCreatureSay(cid,"Your plant doesn't need water.",TALKTYPE_ORANGE_1)
	elseif PLANTADVANCES[itemEx.itemid] ~= nil then
		if RANDOM <= CHANCES then
			doTransformItem(itemEx.uid,PLANTADVANCES[itemEx.itemid][1])
			doCreatureSay(cid,"Your plant has grown to the next stage!",TALKTYPE_ORANGE_1)
		else
			doTransformItem(itemEx.uid,PLANTADVANCES[itemEx.itemid][2])
			doCreatureSay(cid,"You watered your plant.",TALKTYPE_ORANGE_1)
		end
	elseif itemEx.itemid == 7678 then
		if RANDOM <= CHANCES then
			doCreatureSay(cid,"Your plant has grown to the next stage!",TALKTYPE_ORANGE_1)
			doTransformItem(itemEx.uid,PLANTSPECIES[math.random(4)])
		else
			doCreatureSay(cid,"You watered your plant.",TALKTYPE_ORANGE_1)
			doTransformItem(itemEx.uid,itemEx.itemid-8)
		end
	elseif isInArray(LASTSTADIUM, itemEx.itemid) == TRUE then
		doCreatureSay(cid,"You watered your plant.",TALKTYPE_ORANGE_1)
		doTransformItem(itemEx.uid,itemEx.itemid-1)
	end
	doDecayItem(itemEx.uid)
	return TRUE
end
So this is how it works:
1.- You get a flower pot, from an npc or however you want.
2.- You get seeds, some monsters drop it.
3.- You put the flower pot on the ground
4.- You throw the seeds on the flower pot.
5.- Now water the flower pot.
6.- You have to wait 24h till you can water it again
7.- Now, when you water again, you have a CHANCE% of the pot advancing to the next stadium(you can edit CHANCE in flowerpot.lua).
Wheter it advances or not, you cannot water again in 24h.
8.- When it reaches the final stadium, you don't need to water it daily, however, if you don't water it in 3 days it will turn into a whitered plant.
If you water it, the 3 days counter will reset.
9.- If it turns into a whitered day, you have 1 day to water it so it recovers, or it will dissapear completly.

And that's it!
Hope you like it.

I didn't test the decays, but I tested the actions
I know it can be made shorter, but belive me, the first "draft" was waaaay longer.
(Rep if you like it:rolleyes:)
 
Last edited:
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
Fixed a bug on the script, so if you are using it, you should update it.
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,668
Best answers
202
Reaction score
1,376
Location
Norway, Oslo
TFS users might want to add this aswell:

data/items

items.xml
Code:
	<item id="7734" name="watering can">
		<attribute key="description" value="This will help you to water some flowers and pots."/>
		<attribute key="weight" value="150"/>
	</item>
Its customly added though, don't know what the original name is.


edit1:
I need the id for the seeds! XD
 
Last edited:
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
Here are the seeds and the watering can.
Code:
<item id="7732" name="seeds" plural="seeds">
		<attribute key="description" value="They might be worth keeping, who knows what will happen to them."/>
		<attribute key="weight" value="50"/>
	</item>
	<item id="7734" article="a" name="watering can">
		<attribute key="weight" value="850"/>
	</item>
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,668
Best answers
202
Reaction score
1,376
Location
Norway, Oslo
I made an NPC, feel free to stick to your main post ^^

Notice!
This seem to be a very regular NPC, but I made it, trying to make it a little rpgish, you will have to talk a little in order to know how to buy the diffrent things!
Dude: hi
NPC: Hello Dude. I am an specialist on flower care.
Dude: flower
NPC: I am selling a very special flower pot, you will have to take care of it to make it sprout beautiful.
Dude: special flower pot
NPC: Do you want to buy a special flower pot for 50000gp? [notice if he would only say flower pot she would talk about the flower pot first, not sell it to him straight ahead]
Dude: yes

-- the dude looks at this expensive shitty pot --
You see flower pot.
It weighs 1.50 oz.
You should try planting some seeds.


-- The dude thinks a little, and talks to the NPC again --

Dude: hi
NPC: Hello Dude. I am an specialist on flower care.
Dude: seeds
NPC: I am selling the most unique seeds in this server! They sprout the most beutiful flowers you can get!
Dude: unique seeds
NPC: Do you want to buy unique seeds for 50000gp?
[notice if he would only say seeds she would talk about the seeds first, not sell it to him straight ahead]
Dude: yes

-- Dude mixes the pot with the seed, a working result --
but ...
-- After a slice of pizza, Dude think the progress goes pretty slowly, there gotta be something hes missing --
-- He thinks a little logic, maybe some water would help, so he goes to the NPC --

Dude: hi
NPC: Hello Dude. I am an specialist on flower care.
Dude: water
NPC: I have an special watering can that will help you to water the pot, its recomanded to put the seeds in the pot, then water it to make it sprout.
Dude: special watering can
[notice if he would only say watering can she would talk about the watering can first, not sell it to him straight ahead]
NPC: Do you want to buy special watering can for 50000gp?
Dude: yes

-- And finally, this Dude can start to water his flower, and make it grow beauty! --

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This NPC is created by Znote/Luxitur, but its pretty standard tho... -->
<npc name="Nature Care"
script="data/npc/scripts/flower.lua" "autowalk="1" changefloor="0" access= "5"/>
<health now="150" max="150"/>
<look type="144" head="0" body="78" legs="75" feet="97" corpse="6080" addons = "1"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I am an specialist on flower care."/>
<parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="flower;seeds;water;help" />
        <parameter key="keyword_reply1" value="I am selling a very special flower pot, you will have to take care of it to make it sprout beautiful." />
        <parameter key="keyword_reply2" value="I am selling the most unique seeds in this server! They sprout the most beutiful flowers you can get!" />
        <parameter key="keyword_reply3" value="I have an special watering can that will help you to water the pot, its recomanded to put the seeds in the pot, then water it to make it sprout." />
        <parameter key="keyword_reply4" value="In order to take care of your flower, you need a pot, some seeds which will become the flower, and a watering can in order to water the pot." />
<parameter key="module_shop" value="1"/>
	<parameter key="shop_buyable" value="special flower pot,7655,50000;special watering can,7734,50000;unique seeds,7732,50000"/>
	<parameter key="message_needmoremoney" value="You need more money"/>
</parameters>
</npc>
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
-- OTServ event handling functions end

npcHandler:addModule(FocusModule:new())
Even tho its not a master's work, im pretty proud of myself making this NPC. ^^
 
Last edited:
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
Lol, your explanation really made me laugh xD.

I like the npc, but I think it's a bit too expensive, and seeds are already droped by many monsters :p
 

Tony

New Member
Joined
Sep 23, 2007
Messages
81
Best answers
0
Reaction score
0
Nice Script i will use! :p
 

Riven

New Member
Joined
Dec 19, 2007
Messages
4
Best answers
0
Reaction score
0
This script is great!!.. Great idea as well.. Although I think you should add on to it. For example, most player won't really waste their time on planting if there no benefit to it. So I was thinking, Why not make the plant produce some type of fruit, that helps increase a skill for a time period, or increase an hp/mp value for a time period also. Would actually have great use by then, if its possible. Thats my suggestion, but overall its unique to an rpg server's game play.

~Riven
 
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
I fixed some bugs, and added two new plant species, finger snapper plant and fairy dance flower.
 

Sannnna

New Member
Joined
Jun 28, 2009
Messages
58
Best answers
0
Reaction score
0
Location
Sweden
Thanks, works great.

But for those using TFS

Code:
<movevent type="AddItem" tileitem="1" itemid="7655" event="script" value="seeds.lua"/>
 

Koon

New Member
Joined
May 7, 2016
Messages
11
Best answers
0
Reaction score
1
I'm learning scripting. And I'm reading the scrip again and again and again, but I still don't know what function is for time. I mean how to change the script, that I don't have to wait 24h to water the pot again and time that i have to watered it. And how to change the time of flower to grow up? For example I plant the seed, watered it, after X minutes it grow up to next form. Then I watered it again and after Y minutes it fully grow up. And between growing up i have Z minutes to watered it (not 3 days) before it will turn into a whitered plant?
Also very nice script @AGS :)

One more thing. Where change id of seed for another item?
 
Last edited by a moderator:
Top