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

Alright everyone I'm on my dad's computer. I'll start on elemental damage immediately. Could someone give me a list of them? I don't have any OTS info on this lame computer.
 
Looks cool,

I am assuming the weapon loses attack after server restart?
 
Nope it's saved on storages so the weapon will remain. And there are more than 4 elements. xD
 
Okay everyone, I made the elements, but it doesn't work, so I'm going to post what I have and if anyone can fix it, feel free.

Code:
--[[
	** Monster weapon upgrader by slawkens **
        ** extra stats added by Cocoamonkey **


	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
	extraDefense - how much extraDefense points will this weapon get
	extraDefenseLimit - you can set limit of extraDefense points added
	fireDamage - amount of fire damage the weapon will receive
	fireDamageLimit - limit to the amount of fire damage the weapon will receive
	energyDamage - amount of energy damage the weapon will receive
	energyDamageLimit - limit to the amount of energy damage the weapon will receive
	poisonDamage - amount of poison damage the weapon will receive
	poisonDammageLimit - limit to the amount of poison damage the weapon will receive
	earthDamage - amount of earth damage the weapon will receive
	earthDamageLimit - limit to the amount of earth damage the weapon will receive
	iceDamage - amount of ice damage the weapon will receive
	iceDamageLimit - limit to the amount of ice damage the weapon will receive
	holyDamage - amount of holy damage the weapon will receive
	holyDamageLimit - limit to the amount of ice damage the weapon will receive
	deathDamage - amount of death damage the weapon will receive
	deathDamageLimit - limit to the amount of death damage the weapon will receive
]]--

local monsters = {
	["demon"] = {
		[7382] = {
			kills = 5,
			extraAttack = 1,
			extraAttackLimit = 20,
			extraDefense = 1,
			extraDefenseLimit = 20,
			storage = 34000
	},
			[2400] = {
			kills = 1,
			extraAttack = 1,
			extraAttackLimit = 25,
			extraDefense = 2,
			extraDefenseLimit = 40,
			fireDamage = 1,
			fireDamageLimit = 10,
			energyDamage = 1,
			energyDamageLimit = 10,
			poisonDamage = 1,
			poisonDamageLimit = 10,
			earthDamage = 1,
			earthDamageLimit = 10,
			iceDamage = 1,
			iceDamageLimit = 10,
			holyDamage = 1,
			holyDamageLimit = 10,
			deathDamage = 1,
			deathDamageLimit = 10,
			storage = 34005
		}
	},
	["dragon"] = {
		[7407] = {
			kills = 2,
			extraAttack = 2,
			extraAttackLimit = 20,
			extraDefense = 2,
			extraDefenseLimit = 30,
			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
	end

	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 has a total extra damage of +" .. getItemExtraAttack(playerWeapon.uid) .. " points!")
	end
	
	local currentExtraDefense = getItemExtraDefense(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentExtraDefense < weapon.extraDefenseLimit) then
		setItemExtraDefense(playerWeapon.uid, currentExtraDefense + weapon.extraDefense)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.extraDefense .. " defense points and now has a total extra defense of +" .. getItemExtraDefense(playerWeapon.uid) .. " points!")
	end

	local currentFireDamage = getItemElementFire(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentFireDamage < weapon.fireDamageLimit) then
		setItemElementFire(playerWeapon.uid, currentFireDamage + weapon.fireDamage)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.fireDamage .. " fire damage points and now has total of +" .. getItemElementFire(playerWeapon.uid) .. " fire damage points!")
	end


	local currentEnergyDamage = getItemElementEnergy(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentEnergyDamage < weapon.energyDamageLimit) then
		setItemElementEnergy(playerWeapon.uid, currentEnergyDamage + weapon.energyDamage)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.energyDamage .. " energy damage points and now has total of +" .. getItemElementEnergy(playerWeapon.uid) .. " energy damage points!")
	end

	local currentPoisonDamage = getItemElementPoison(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentPoisonDamage < weapon.poisonDamageLimit) then
		setItemElementPoison(playerWeapon.uid, currentPoisonDamage + weapon.poisonDamage)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.poisonDamage .. " poison damage points and now has total of +" .. getItemElementPoison(playerWeapon.uid) .. " poison damage points!")
	end

	local currentEarthDamage = getItemElementEarth(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentEarthDamage < weapon.earthDamageLimit) then
		setItemElementEarth(playerWeapon.uid, currentEarthDamage + weapon.earthDamage)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.earthDamage .. " earth damage points and now has total of +" .. getItemElementEarth(playerWeapon.uid) .. " earth damage points!")
	end

	local currentIceDamage = getItemElementIce(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentIceDamage < weapon.iceDamageLimit) then
		setItemElementIce(playerWeapon.uid, currentIceDamage + weapon.iceDamage)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.iceDamage .. " ice damage points and now has total of +" .. getItemElementIce(playerWeapon.uid) .. " ice damage points!")
	end

	local currentHolyDamage = getItemElementHoly(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentHolyDamage < weapon.holyDamageLimit) then
		setItemElementHoly(playerWeapon.uid, currentHolyDamage + weapon.holyDamage)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.holyDamage .. " holy damage points and now has total of +" .. getItemElementHoly(playerWeapon.uid) .. " holy damage points!")
	end

	local currentDeathDamage = getItemElementDeath(playerWeapon.uid)
	if(killedMonsters % weapon.kills == 0 and currentDeathDamage < weapon.deathDamageLimit) then
		setItemElementDeath(playerWeapon.uid, currentDeathDamage + weapon.deathDamage)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.deathDamage .. " death damage points and now has total of +" .. getItemElementDeath(playerWeapon.uid) .. " death damage points!")
	end
	setPlayerStorageValue(cid, weapon.storage, killedMonsters + 1)
	return TRUE
end
 
[01/07/2009 18:59:21] Warning: [Event::loadScript] Can not load script. data/creaturescripts/scripts/monster_weapon_upgrade.lua
[01/07/2009 18:59:21] data/creaturescripts/scripts/monster_weapon_upgrade.lua:1: unexpected symbol near '{'

help me
 
What would be nice is that it goes on the Exp of the monster instead. Like kill 100 mobs with exp higher than 1000 to get an add +1 atk.
 
Alright, I'm still not very good with this lua scripting stuff xD but I tried. It doesn't work yet, but if anyone can find the errors, I'll try and fix them ^_^

Code:
--[[
	** Monster weapon upgrader by slawkens **
        ** Extra Defense added by Cocoamonkey **


	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
	extraDefense - how much extraDefense points will this weapon get
	extraDefenseLimit - you can set limit of extraDefense points added
	monsterExp - Amount of exp a monster must have
]]--

local monsters = {
	["demon"] = {
		[7382] = {
			kills = 1,
			extraAttack = 50,
			extraAttackLimit = 800,
			extraDefense = 50,
			extraDefenseLimit = 800,
			storage = 34000
	},
		[2400] = {
			kills = 30,
			extraAttack = 1,
			extraAttackLimit = 25,
			extraDefense = 50,
			extraDefenseLimit = 800,
			storage = 34001
		}
	},
	["dragon"] = {
		[7407] = {
			kills = 2,
			extraAttack = 2,
			extraAttackLimit = 20,
			extraDefense = 2,
			extraDefenseLimit = 30,
			storage = 34003
		}
	}
}

local monstersExp = {
	["1000"] = {
		[7382] = {
			kills = 1,
			extraAttack = 1,
			extraAttackLimit = 25,
			extraDefense = 2,
			extraDefenseLimit = 20,
			storage = 34005
	},
		[2400] = {
			kills = 30,
			extraAttack = 1,
			extraAttackLimit = 25,
			extraDefense = 1,
			extraDefenseLimit = 25,
			storage = 34006
		}
	},
	["5000"] = {
		[7407] = {
			kills = 2,
			extraAttack = 2,
			extraAttackLimit = 20,
			extraDefense = 2,
			extraDefenseLimit = 30,
			storage = 34007
		}
	}
}

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 monsterExp = monstersExp[string.lower(getCreatureExperience(target))]
	if(not monster) then
	if getCreatureExperience < (monsterExp) 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
	end

	local weapon = monsterExp[playerWeapon.itemid]
	if(not weapon) then
		return TRUE
	end

	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
	
		local currentExtraDefense = getItemExtraDefense(playerWeapon.uid)
		if(killedMonsters % weapon.kills == 0 and currentExtraDefense < weapon.extraDefenseLimit) then
		setItemExtraDefense(playerWeapon.uid, currentExtraDefense + weapon.extraDefense)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.extraDefense .. " defense points and now have total extra defense of +" .. getItemExtraDefense(playerWeapon.uid) .. " points!")
	end
	setPlayerStorageValue(cid, weapon.storage, killedMonsters + 1)
	return TRUE
end
 
Very Good

Since I saw the OT projects I got very excited with the idea of using it to tests ( and learn of course :D ) for my strategy/rpg game.

This kind of Ideas are exactly what I'm looking for to do on it ...

Thanks very much its a wandefull idea ... !
 
I can't help remember the "turin tunambar" sword of the LOR World ...

It gets stronger with the taste of blood !!

----

any way don´t know if this is the right place to ask about it but, Anybody knows How I could create like monsters that are stronger against Cutting ( AXE) , Piercing (SWORD), and Stuck (?) (CLUB) ??

I first had the idea of putting it to the "Magic" slot ( for example ICE, FIRE ), Trasforming the PHISICAL DAMAGE to this differents tipes of damage . But I don't know how this would be possible ...

I have lot'd of ideas but I am very new to programming ...

Any way Thanks for reading it ... And sorry for my bad english ,
 
Back
Top