• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Action Fusion/upgrade script - ver. 2 (final? + recipes) for TFS 0.3.4+

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,968
Solutions
99
Reaction score
3,384
Location
Poland
GitHub
gesior
In this version you can set items needed with ActionID, recipes (writeable items with ActionID) and create much modified items.
FUSION/UPGRADE SCRIPT
Configurable item upgrades/changes:
actionid
name
description
attack
extraAttack
defense
extraDefense
armor
hitChance
shootRange
name, description = 'text'
rest.. = value (number, it will add this value to default value of created item, like normal club has 7 attack, if you set attack=6 new item will have 13 attack, if you set attack=-6 new will have 1 attack)
Example config informations:
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
PHP:
{{{2197,999,actionid=125,name="Test"}, {2197,999,actionid=103,description="Desc of item\nSecond line"}}, {{2154,0},{2154,0}}}
Player must put in bag 2 items with ID 2154 (yellow gem) and script create 2 items:
19:29 You see a stone skin amulet (protection physical +80%, death +80%) that has 999 charges left.
It weighs 7.60 oz.
Desc of item
Second line
ItemID: [2197], ActionID: [103].
19:30 You see a Test (protection physical +80%, death +80%) that has 999 charges left.
It weighs 7.60 oz.
ItemID: [2197], ActionID: [125].
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
PHP:
{{{2382,0,name="Super Club",description="Upgraded club",attack=5,extraAttack=10,defense=3,extraDefense=4}}, {{2154,0,actionid=130}}}
Player must put in bag 1 item with ID 2154 (yellow gem) and this item must have ActionID 130 (you can add few fusion recipes with same item id, but different actionid [if you want add like me Yellow Gem without ActionID and other recipe with Yellow Gem (with action id 130) always first paste config with actionid]) - script create 1 item:
19:31 You see a Super Club (Atk:12 +10, Def:10 +4).
It weighs 25.00 oz.
Upgraded club
ItemID: [2382].
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
PHP:
{{{2650,0,name="Super Jacket",description="Upgraded jacket",armor=-5}}, {{2154,0}}}
Player must put in bag 1 item with ID 2154 (yellow gem) and script create 1 item:
19:30 You see a Super Jacket (Arm:-4).
It weighs 24.00 oz.
Upgraded jacket
ItemID: [2650].
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
PHP:
{{{2382,0,name="Super Mega Club",attack=50,defense=3}}, {{2154,0},{recipe=120}}}
Player must put in bag 'recipe' (recipe is writeable item with any text inside and actionid) with actionID 120 (from script below) and item 2154 (yellow gem) - script create 1 item:
19:32 You see a Super Mega Club (Atk:57, Def:10).
It weighs 25.00 oz.
ItemID: [2382].
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
actions.xml:
PHP:
<action actionid="8000" event="script" value="quests/fusion.lua"/>
fusion.lua:
PHP:
-- Script by Gesior  --
-- Fusion/Upgrade Script ver. 2 --

local item_config = {
{{{2197,999,actionid=125,name="Test"}, {2197,999,actionid=103,description="Desc of item\nSecond line"}}, {{2154,0},{2154,0}}},
{{{2382,0,name="Super Club",description="Upgraded club",attack=5,extraAttack=10,defense=3,extraDefense=4}}, {{2154,0,actionid=130}}},
{{{2650,0,name="Super Jacket",description="Upgraded jacket",armor=-5}}, {{2154,0}}},
{{{2382,0,name="Super Mega Club",attack=50,defense=3}}, {{2154,0},{recipe=120}}}
}

local pos_1 = {x = 479, y = 1470, z = 13}
local pos_2 = {x = 481, y = 1470, z = 13}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local create_item_pos = pos_2
	local container = getTileItemByType(pos_1, ITEM_TYPE_CONTAINER)
	if(container.uid == 0 or not(isContainer(container.uid))) then
		create_item_pos = pos_1
		container = getTileItemByType(pos_2, ITEM_TYPE_CONTAINER)
	end
	if(container.uid == 0 or not(isContainer(container.uid))) then
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Put bag or backpack with items to fusion.")
		return FALSE
	end
	items_in_container = {}
	item_slot = 0
	while(true) do
		item_in = getContainerItem(container.uid, item_slot)
		if item_in.itemid > 0 then
			table.insert(items_in_container, item_in)
		else
			break
		end
		item_slot = item_slot+1
	end
	local fusion_id = 0
	for i = 1, table.getn(item_config) do
		fusion_items = item_config[i]
		items_create = fusion_items[1]
		items_required = fusion_items[2]
		local tmp_items_required = {}
		for s = 1, table.getn(items_required) do
			table.insert(tmp_items_required, items_required[s])
		end
		if(table.getn(items_in_container) == table.getn(tmp_items_required)) then
			for c = 1, table.getn(items_in_container) do
				local item_in_container = items_in_container[c]
				for r = 1, table.getn(tmp_items_required) do
					local item_required = tmp_items_required[r]
					if(item_in_container.itemid == item_required[1] and item_in_container.type == item_required[2] and (item_required["actionid"] == nil or item_required["actionid"] == item_in_container.actionid)) or (item_required["recipe"] ~= nil and item_required["recipe"] == item_in_container.actionid and getItemDescriptions(item_in_container.uid).text ~= '') then
						table.remove(tmp_items_required, r)
						break
					end
				end
			end
			if(table.getn(tmp_items_required) == 0) then
				fusion_id = i
				break
			end
		end
	end
	if(fusion_id > 0) then
		while(true) do
			item_in = getContainerItem(container.uid, 0)
			if item_in.uid > 0 then
				doRemoveItem(item_in.uid)
			else
				break
			end
		end
		for u = 1, table.getn(items_create) do
			local item_to_create = items_create[u]
			local new_item_uid = doCreateItemEx(item_to_create[1], item_to_create[2])
			doTileAddItemEx(create_item_pos, new_item_uid)
			if(item_to_create["actionid"] ~= nil) then
				doSetItemActionId(new_item_uid, item_to_create["actionid"])
			end
			if(item_to_create["name"] ~= nil) then
				setItemName(new_item_uid, item_to_create["name"])
			end
			if(item_to_create["description"] ~= nil) then
				doSetItemSpecialDescription(new_item_uid, item_to_create["description"])
			end
			if(item_to_create["attack"] ~= nil) then
				setItemAttack(new_item_uid, getItemAttack(new_item_uid)+item_to_create["attack"])
			end
			if(item_to_create["extraAttack"] ~= nil) then
				setItemExtraAttack(new_item_uid, getItemExtraAttack(new_item_uid)+item_to_create["extraAttack"])
			end
			if(item_to_create["defense"] ~= nil) then
				setItemDefense(new_item_uid, getItemDefense(new_item_uid)+item_to_create["defense"])
			end
			if(item_to_create["extraDefense"] ~= nil) then
				setItemExtraDefense(new_item_uid, getItemExtraDefense(new_item_uid)+item_to_create["extraDefense"])
			end
			if(item_to_create["armor"] ~= nil) then
				setItemArmor(new_item_uid, getItemArmor(new_item_uid)+item_to_create["armor"])
			end
			--if(item_to_create["attackSpeed"] ~= nil) then
			--	setItemAttackSpeed(new_item_uid, getItemAttackSpeed(new_item_uid)+item_to_create["attackSpeed"])
			--end
			if(item_to_create["hitChance"] ~= nil) then
				setItemHitChance(new_item_uid, getItemHitChance(new_item_uid)+item_to_create["hitChance"])
			end
			if(item_to_create["shootRange"] ~= nil) then
				setItemShootRange(new_item_uid, getItemShootRange(new_item_uid)+item_to_create["shootRange"])
			end
		end
		doSendMagicEffect(pos_1,CONST_ME_GREEN_RINGS)
		doSendMagicEffect(pos_2,CONST_ME_GREEN_RINGS)
		doSendMagicEffect(getPlayerPosition(cid),CONST_ME_MAGIC_GREEN)
	else
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Unknown recipe.")
	end
	if(item.itemid == 1945) then
		doTransformItem(item.uid,item.itemid+1)
	elseif(item.itemid == 1946) then
		doTransformItem(item.uid,item.itemid-1)
	end
	return TRUE
end
map editor/script use:
fusion.png

------------------------------------------------
------------------------------------------------
------------------------------------------------
RECIPE QUESTS SCRIPT
actions.xml:
PHP:
<action actionid="1750" event="script" value="quests/recipequests.lua"/>
recipequests.lua:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, item.uid) ~= 1 and isContainer(item.uid) == TRUE then
		local item_in = getContainerItem(item.uid, 0)
		local uid = doPlayerAddItem(cid, item_in.itemid, 0, 1)
		doSetItemText(uid, getItemDescriptions(item_in.uid).text)
		doSetItemActionId(uid, item_in.actionid)
		setPlayerStorageValue(cid, item.uid, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found some interesting informations.')
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'The chest is empty.')
	end
	return TRUE
end
recipe quests config in map editor:
recipes.png
 
This is really but really what i need :)
Now i can make different jobs with this like alchemy or smithing w/e
Thanks a million :)
 
'loule?' dota - Warcraft3: Defense of the Ancients? I took this idea from mu-online, lineage2 and my rl friends (tibia, mu and lineage2 players) ideas.

I play DotA and W3 rpg maps/tower defense from over 3 years, but I didn't think about dota and otses.
DotA is for max. 5 v 5 players. OTSes are for 20 vs 50 or even 50 vs 100.
@down
// ja gram od 2 lat [wczesniej na lan party tylko] (na garena z piratem :/ ) i noobie po calosci :)
 
Last edited:
'loule?' dota - Warcraft3: Defense of the Ancients? I took this idea from mu-online, lineage2 and my rl friends (tibia, mu and lineage2 players) ideas.

I play DotA and W3 rpg maps/tower defense from over 3 years, but I didn't think about dota and otses.
DotA is for max. 5 v 5 players. OTSes are for 20 vs 50 or even 50 vs 100.

you didn't get what I ment. "Too much DotA" was a sarcasm directly to your person: "you have played too much dota, d00d!". I've never played mu, nor lineage so I don't know. The only place I met item + item + scroll = better item was DotA, so thats it! No offence at all.

//a ja gram dotę od 6 lat i nie szpanuję >_<
 
Sorry for bringing this thread to life but i need this script for 0.3.6 can anybody fix ?
It gives nil error. I don't know anything about it.

@Edit
Here is the error:
[06/12/2010 19:42:35] data/actions/scripts/other/fusion.lua:eek:nUse
[06/12/2010 19:42:35] Description:
[06/12/2010 19:42:35] data/actions/scripts/other/fusion.lua:79: attempt to call global 'doSetItemActionId' (a nil value)
[06/12/2010 19:42:35] stack traceback:
[06/12/2010 19:42:35] data/actions/scripts/other/fusion.lua.lua:79: in function <data/actions/scripts/other/fusion.lua.lua:17>

Not only for actionid. It gives error for everything when i want to change new item's name,attack,etc.
 
Last edited:
@GangsteR

Lua:
function doSetItemActionId(uid, aid)
return doItemSetAttribute(uid, "aid", aid)
end
 
[27/03/2011 18:13:17] [Error - Action Interface]
[27/03/2011 18:13:17] data/actions/scripts/fusion.lua:eek:nUse
[27/03/2011 18:13:17] Description:
[27/03/2011 18:13:17] data/actions/scripts/fusion.lua:79: attempt to call global 'setItemName' (a nil value)
[27/03/2011 18:13:17] stack traceback:
[27/03/2011 18:13:17] data/actions/scripts/fusion.lua:79: in function <data/actions/scripts/fusion.lua:14>



my problem :(
 
How would I change this to not check for a position on the map, but to make sure item(s) is/are in the backpack instead?
 
Back
Top