• 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!

Solved Enchanted weapons decays after one hit.

Kyran

Member
Joined
Jan 17, 2009
Messages
68
Reaction score
5
When i enchant a weapon it just decays back to a normal weapon after one hit. I've searched around and haven't gotten any answers to what's wrong.

Here is my script.
Lua:
local config = {
	
	[2429] = {2429, 7778, 7749, 7859, 7874}, --Barbarian Axe
	[7406] = {7406, 7766, 7747, 7857, 7872}, --Blacksteel Sword
	[2423] = {2423, 7773, 7754, 7864, 7879}, --Clerical Mace
	[7415] = {7415, 7775, 7756, 7866, 7881}, --Cranial Basher
	[2445] = {2445, 7774, 7755, 7865, 7880}, --Crystal Mace
	[7402] = {7402, 7767, 7748, 7858, 7873}, --Dragon Slayer
	[7380] = {7380, 7771, 7752, 7862, 7877}, --Headchopper
	[7389] = {7389, 7770, 7751, 7861, 7876}, --Heroic Axe
	[2430] = {2430, 7779, 7750, 7860, 7875}, --Knight Axe
	[7384] = {7384, 7765, 7746, 7856, 7871}, --Mystic Blade
	[7392] = {7392, 7776, 7757, 7867, 7882}, --Orcish Maul
	[7383] = {7383, 7764, 7745, 7855, 7870}, --Relic Sword
	[2383] = {2383, 7763, 7744, 7854, 7869}, --Spike Sword
	[2454] = {2454, 7772, 7753, 7863, 7878}, --War Axe
	[2391] = {2391, 7777, 7758, 7868, 7883}, --War Hammer
	
	[8905] = {8905, 8907, 8906, 8909, 8908}, --Rainbow Shield
	
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local i = config[itemEx.itemid]
	if itemEx.itemid == 9934 then
		if item.itemid == 7760 then
			doRemoveItem(item.uid, 1)
			doRemoveItem(itemEx.uid, 1)
			doPlayerAddItem(cid, 9933)
		else doPlayerSendCancel(cid, "Sorry, not possible.")
		end
	elseif itemEx.itemid == i[1] then
		doRemoveItem(item.uid, 1)
		if item.itemid == 7759 then
			doRemoveItem(itemEx.uid, 1)
			doPlayerAddItem(cid, i[2], 1)
		elseif item.itemid == 7760 then
			doRemoveItem(itemEx.uid, 1)
			doPlayerAddItem(cid, i[3], 1)
		elseif item.itemid == 7761 then
			doRemoveItem(itemEx.uid, 1)
			doPlayerAddItem(cid, i[4])
		elseif item.itemid == 7762 then
			doRemoveItem(itemEx.uid, 1)
			doPlayerAddItem(cid, i[5])
		end
	else doPlayerSendCancel(cid, "Sorry, not possible.")
	end
return TRUE
end
I've tried to change doPlayerAddItem(cid,,i[4]) to set different charges, but it doesn't change anything.

And here is my items.xml
Code:
<item id="7744" name="fiery spike sword" article="a">
		<attribute key="weight" value="5000"/>
		<attribute key="defense" value="21"/>
		<attribute key="attack" value="24"/>
		<attribute key="weaponType" value="sword"/>
		<attribute key="extradef" value="2"/>
		<attribute key="elementFire" value="4"/>
		<attribute key="charges" value="1000"/>
		<attribute key="decayTo" value="2383"/>
		<attribute key="showcharges" value="1"/>
	</item>
I've also tried to change the charges in items.xml without luck.
When you look at the weapons it sais that it has 1000 charges, or whatever i set it too. But it still decays back to a normal weapon.

Im useing TFS 0.2.8.

Help is greatly appreciated!
 
Last edited:
You where right Cycotitan, there seems to be a bug with the TFS 028 distro. Do you know if there's an easy source fix for this problem?
 
Okay, gonna do that.. Do you know if there's anywhere else than in weapons.cpp that defines the enchanted weapons? Thanks again for all help

"You must spread some Reputation around before giving it to Cykotitan again."
 
weapons.cpp replace
[cpp]//
if(g_config.getBoolean(ConfigManager::REMOVE_WEAPON_CHARGES))
{
int32_t newCount = std::max(0, item->getItemCount() - 1);
g_game.transformItem(item, item->getID(), newCount);
}[/cpp]
with
[cpp]//
if(g_config.getBoolean(ConfigManager::REMOVE_WEAPON_CHARGES))
{
int32_t newCharge = std::max((int32_t)0, ((int32_t)item->getCharges()) - 1);
g_game.transformItem(item, item->getID(), newCharge);
}[/cpp]
in case it works but removes 2 charges, just remove the whole piece of code
 
Back
Top