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

CreatureEvent Upgrade weapon by killing monsters!

Hm. Slawkens, something is wrong with my script, I added one weapon:

Code:
--[[
	** Monster weapon upgrader by slawkens **

	kills - how much monsters must be killed
	extraAttack - how much extraAttack points will this weapon get
	extraAttackLimit - you can set limit of extraAttack points added
]]--

local monsters = {
	["rat"] = {
		[2395] = {
			kills = 30,
			extraAttack = 1,
			extraAttackLimit = 3,
			storage = 34001
		}
		[2399] = {
			kills = 2,
			extraAttack = 1,
			extraAttackLimit = 5,
			storage = 34002
		}
	},
	["dragon"] = {
		[2383] = {
			kills = 500,
			extraAttack = 1,
			extraAttackLimit = 20,
			storage = 34003
		}
	}
}

function onKill(cid, target)
	if(isPlayer(target) == TRUE) then
		return TRUE
	end

	local monster = monsters[string.lower(getCreatureName(target))]
	if(not monster) then
		return TRUE
	end

	local playerWeapon = getPlayerWeapon(cid, TRUE)
	if(playerWeapon.itemid == 0) then
		return TRUE
	end

	local weapon = monster[playerWeapon.itemid]
	if(not weapon) then
		return TRUE
	ebd

	local killedMonsters = getPlayerStorageValue(cid, weapon.storage)
	if(killedMonsters == -1) then
		killedMonsters = 1
	end

	local currentExtraAttack = getItemExtraAttack(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentExtraAttack < weapon.extraAttackLimit) then
		setItemExtraAttack(playerWeapon.uid, currentExtraAttack + weapon.extraAttack)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.extraAttack .. " attack points and now have total extra damage of +" .. getItemExtraAttack(playerWeapon.uid) .. " points!")
	end

	setPlayerStorageValue(cid, weapon.storage, killedMonsters + 1)
	return TRUE
end

And error in log:
Code:
[08/06/2009 18:20:06] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/monster_weapon_upgrade.lua)
[08/06/2009 18:20:06] data/creaturescripts/scripts/monster_weapon_upgrade.lua:17: '}' expected (to close '{' at line 10) near '['
[08/06/2009 18:20:06] Reloaded creature events.

I did something wrong? :p.
 
YES, I see now! In script on first post you have bug! :D.

Code:
	local weapon = monster[playerWeapon.itemid]
	if(not weapon) then
		return TRUE
	[B]ebd[/B]
:). Repair this ;p.
But my script is still don't working :(. Or tell me how to add new weapon to existing monster xd.
 
Last edited:
Hm. Slawkens, something is wrong with my script, I added one weapon:

Code:
--[[
	** Monster weapon upgrader by slawkens **

	kills - how much monsters must be killed
	extraAttack - how much extraAttack points will this weapon get
	extraAttackLimit - you can set limit of extraAttack points added
]]--

local monsters = {
	["rat"] = {
		[2395] = {
			kills = 30,
			extraAttack = 1,
			extraAttackLimit = 3,
			storage = 34001
		}
		[2399] = {
			kills = 2,
			extraAttack = 1,
			extraAttackLimit = 5,
			storage = 34002
		}
	},
	["dragon"] = {
		[2383] = {
			kills = 500,
			extraAttack = 1,
			extraAttackLimit = 20,
			storage = 34003
		}
	}
}

function onKill(cid, target)
	if(isPlayer(target) == TRUE) then
		return TRUE
	end

	local monster = monsters[string.lower(getCreatureName(target))]
	if(not monster) then
		return TRUE
	end

	local playerWeapon = getPlayerWeapon(cid, TRUE)
	if(playerWeapon.itemid == 0) then
		return TRUE
	end

	local weapon = monster[playerWeapon.itemid]
	if(not weapon) then
		return TRUE
	ebd

	local killedMonsters = getPlayerStorageValue(cid, weapon.storage)
	if(killedMonsters == -1) then
		killedMonsters = 1
	end

	local currentExtraAttack = getItemExtraAttack(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentExtraAttack < weapon.extraAttackLimit) then
		setItemExtraAttack(playerWeapon.uid, currentExtraAttack + weapon.extraAttack)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.extraAttack .. " attack points and now have total extra damage of +" .. getItemExtraAttack(playerWeapon.uid) .. " points!")
	end

	setPlayerStorageValue(cid, weapon.storage, killedMonsters + 1)
	return TRUE
end

And error in log:
Code:
[08/06/2009 18:20:06] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/monster_weapon_upgrade.lua)
[08/06/2009 18:20:06] data/creaturescripts/scripts/monster_weapon_upgrade.lua:17: '}' expected (to close '{' at line 10) near '['
[08/06/2009 18:20:06] Reloaded creature events.

I did something wrong? :p.

You must separate them by commas (,)

so

},
[2399] = {
 
I finally got myself 0.3.4 and tested this. It's great ^.^ just for kicks I set the limit to 800 and you get 50 for every demon killed and I killed 16 demons and got 800 and then I could hit 1500ish with a demonrage sword :p
 
works great!! Thanks=) PS: I use cryingdamson4pl2-gui TFS 0.3.4 ^^ client 8.42

I will add a few weapons to this script :D
 
Can you add array weapons?(many weapons in one "monster"?)

Yes, just do like...

Code:
local monsters = {
	["demon"] = {
		[7382] = {
			kills = 1,
			extraAttack = 50,
			extraAttackLimit = 800,
			storage = 34000
[B]	},
			[2400] = {
			kills = 30,
			extraAttack = 1,
			extraAttackLimit = 25,
			storage = 34001[/B]
		}
	},
	["dragon"] = {
		[2383] = {
			kills = 500,
			extraAttack = 1,
			extraAttackLimit = 20,
			storage = 34002
		}
	}
}

Be sure to seperate them with }, not with just }
I'm glad so many people like my idea :D
 
Yes, just do like...

Code:
local monsters = {
	["demon"] = {
		[7382] = {
			kills = 1,
			extraAttack = 50,
			extraAttackLimit = 800,
			storage = 34000
[B]	},
			[2400] = {
			kills = 30,
			extraAttack = 1,
			extraAttackLimit = 25,
			storage = 34001[/B]
		}
	},
	["dragon"] = {
		[2383] = {
			kills = 500,
			extraAttack = 1,
			extraAttackLimit = 20,
			storage = 34002
		}
	}
}

Be sure to seperate them with }, not with just }
I'm glad so many people like my idea :D

That is good idea, but not working I think :)
 
It works, that's a paste straight outta my script xD It works great. TFS 0.3.X only though because lower doesn't have getPlayerWeapon
 
Hey slawkens.. could you do like, 70% chances that you get +1 but also 30% that you get -1 attack :p hope you understand. That weapon with +20 attack would be like a real rare then. But it won't work when you finally get 20 attack points, then you'll keep loosing 1 and getting 1 again, that sucks. So instead of getting attack points for killing, make getting some gems after killing x monsters, that gives 70% attack +1 and 30% attack -1, so if you want to use u use, if u don't want u don't ;)
 
Back
Top