• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent "Upgrade weapon by killing monsters!" v2.0

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,984
Solutions
2
Reaction score
119
Location
Germany
GitHub
Shawak
Hello all,
I decided to update the script, because so much people asked me this:
"Can you make me that it is for all weapons?"
or: "Can you make this with all monsters?".
Here you have a easy config, where you can disable these two things.

Version:
TFS 0.3.5pl1, tested.

Credits:
[v2.0] - Shawak
[v1.0] - Slawkens

Changelog:
v2.0:
- added "ignore_monsters"
- added monsters list
- added "ingore_weapons"
- added weapons {}
- added default {}
- removed the old monsters list
- players don't longer get a storage value
- fixed/added/removed the script

v1.0:
http://otland.net/f82/upgrade-weapon-killing-monsters-35146/

Script:
- data/creaturescripts/scripts/monster_weapon_upgrade.lua
Lua:
--[[
	** Monster weapon upgrader by slawkens **
	** Updated to version 2.0 by Shawak **

	[ignore_monsters]
	- type "yes" and only by the [monsters] the weapon gain kills
	[monsters]
	• {"..","..",".."} - list of monsters where weapon gain kills
	[ingore_weapons]
	- type "yes" and only the [weapons] can be upgraded
	[weapons]
	•       [2395] = {100, 1, 3},
	   	   |       |   |  |
	    	   |       |   |  •> extraAttackLimit
	    	   |       |   •> extraAttack
	   	   |       •> kills
		   •> id of the weapon
	[default]
	• 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 ignore_monsters = "yes"
local monsters = {"Rat","Dragon","Dragon Lord"}

local ingore_weapons = "yes"
local weapons = {
	[2395] = {600, 1, 5},
	[2383] = {500, 1, 4}

} -- weapon end --

local default = {
	500,   -- kills
	1,     -- extraAttack
	5      -- extraAttackLimit
} -- default end --

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

	if (string.lower(ignore_monsters) == "no" and isInArray(monsters, getCreatureName(target)) == TRUE or string.lower(ignore_monsters) == "yes") then

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

		local weapon = weapons[getPlayerWeapon(cid).itemid]
		if string.lower(ingore_weapons) == "yes" then
			weapon = default
		end

		if (string.lower(ingore_weapons) == "no" and (not weapon) == FALSE or string.lower(ingore_weapons) == "yes") then

			local currentExtraAttack = getItemExtraAttack(playerWeapon.uid)
			if(currentExtraAttack >= weapon[3]) then
				return TRUE
			end

			local add = weapon[2]
			if(currentExtraAttack + add > weapon[3]) then
				add = currentExtraAttack - weapon[3]
			end

			if(playerWeapon.actionid ~= 0) then
				if(playerWeapon.actionid >= weapon[1]+9999) then
					doSetItemActionId(playerWeapon.uid, 10000)
					setItemExtraAttack(playerWeapon.uid, currentExtraAttack + add)
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" ..add.. " attack points and now have total extra damage of +" .. getItemExtraAttack(playerWeapon.uid) .. " points!")
					doSetItemSpecialDescription(playerWeapon.uid, "["..(playerWeapon.actionid-9999).."/"..weapon[1].." | ".. getItemExtraAttack(playerWeapon.uid).."/"..weapon[3].."]")
				else
					doSetItemActionId(playerWeapon.uid, playerWeapon.actionid + 1)
					doSetItemSpecialDescription(playerWeapon.uid, "["..(playerWeapon.actionid-9999).."/"..weapon[1].." | ".. getItemExtraAttack(playerWeapon.uid).."/"..weapon[3].."]")
				end
			else
				doSetItemActionId(playerWeapon.uid, 10001)
				doSetItemSpecialDescription(playerWeapon.uid, "[1/"..weapon[1].." | ".. getItemExtraAttack(playerWeapon.uid).."/"..weapon[3].."]")
			end
		end
	end
	return TRUE
end
- data/creaturescripts/scripts/login.lua
Lua:
registerCreatureEvent(cid, "Monster_Weapon_Upgrade")
- data/creaturescripts/creaturescripts.xml
Lua:
	<event type="kill" name="Monster_Weapon_Upgrade" event="script" value="monster_weapon_upgrade.lua"/>

If you don't understand what the script make/do, read the post below.
I hope you like it, :thumbup:.

Regards,
Shawak
 
Screonshot:
attachment.php


  1. You see a spike sword (Atk:24 + 3,
    Def:21+2).
    [*]It wieghs 50.00 oz.
    [*][12/15 | 3/4]
1. You see a <item name> (Atk: <normal atk> + <extra atk>, Def: <defense>)
2. Normal item weight.
3. [<killed monsters>/<monsters for upgrade weapon> | <extra atk>/<max extra atk>]

Full Upgraded:
attachment.php


Instruction:
  1. [ignore_monsters]
  2. [monsters]
  3. [ingore_weapons]
  4. [weapons]
  5. [default]
1. [ignore_monsters]:
  • "yes" = The script will ignore what monster you are killing, so your weapon always get kills.
  • "no" = Your weapon only get kills, if you kill one of the monsters listen on "[monsters]".

2. [monsters]:
  • Ignore it, if you have ignore_monsters = "yes".
  • Else, only by these monsters, your weapon get kills.

3. [ingore_weapons]:
  • "yes" = The script will ignore what weapon you are using, so all weapons get kills, the "[default]" settings.
  • "no" = Your weapon only get kills, if you kill one of the monsters listen on "[monsters]".

4. [weapons]:
Code:
[2395] = {[COLOR="Red"]100[/COLOR], [COLOR="SeaGreen"]1[/COLOR], [COLOR="Blue"]3[/COLOR]},
   |       |   |  |
   |       |   |  •> extraAttackLimit, maximal extraAttack
   |       |   •> extraAttack, after "kills" the weapon gain these extraAttack
   |       •> kills, (1x these kills and your weapon get 1x + extraAttack)
   •> id of the weapon
5. [default]:
Code:
local default = {
	[COLOR="Red"]500[/COLOR],   -- [COLOR="Red"]kills[/COLOR]
	[COLOR="SeaGreen"]1[/COLOR],     -- [COLOR="SeaGreen"]extraAttack[/COLOR]
	[COLOR="Blue"]5[/COLOR]      -- [COLOR="Blue"]extraAttackLimit[/COLOR]
} -- default end --
  • kills: after killing "kills" monster, the weapon gain 1x + extraAttack
  • extraAttack: amout of extraAttack, the weapon get after killing "kills" monsters
  • extraAttackLimit: maximun of extraAttack

By questions ask in this theard, thanks :thumbup:.
 

Attachments

Last edited:
It's better, but you made a mistake to completly change the sctipt. You should leave the possibility of upgrading a certain weapon only with certain mosnter. Now it's all weapons by certain monsters or certain weapon by all monsters, isn't it?
 
It's better, but you made a mistake to completly change the sctipt. You should leave the possibility of upgrading a certain weapon only with certain mosnter. Now it's all weapons by certain monsters or certain weapon by all monsters, isn't it?

Then use slawkens one, :thumbup:.

@All Other: Thanks, allways love comments :wub:
 
Awesome work. Thanks Shawak i'll use it on my fun server.
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
I never did say "Nice Release Shawak."

So, Nice Release! :thumbup:
 
I have some question
In the version 1.0 i can define one monster for one weapon
Now is all monsters for all weapon ???
How i put 1 monster for a specified weapon ??

EX:
Weapon id = 2395
You only get kills if you kill 5 Demon
 
So i change the script =D
For use more fast and useful!!


I'm scripter but i stoped a one year ago =/
I think this works
NOT TESTED !!!!!!!!!!!!!!


PHP:
  --[[
        ** Monster weapon upgrader by slawkens **
        ** Updated to version 2.0 by Shawak **

        [ignore_monsters]
        - type "yes" and only by the [monsters] the weapon gain kills
        [monsters]
        • {"..","..",".."} - list of monsters where weapon gain kills
        [ingore_weapons]
        - type "yes" and only the [weapons] can be upgraded
        [weapons]
        •       [2395] = {100, 1, 3},
                   |       |   |  |
                   |       |   |  •> extraAttackLimit
                   |       |   •> extraAttack
                   |       •> kills
                   •> id of the weapon
        [default]
        • 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 ignore_monsters = "yes"
local ingore_weapons = "yes"

local weapons = {
        [2395] = {600, 1, 5, {"Demon", "Medusa"}},
        [2383] = {500, 1, 4, {"Rat"}}

} -- weapon end --

local default = {
        500,   -- kills
        1,     -- extraAttack
        5      -- extraAttackLimit
} -- default end --

function onKill(cid, target)
        if(isPlayer(target) == TRUE) then
                return TRUE
        end
                  local weapon = weapons[getPlayerWeapon(cid).itemid]
                  
                  if (not weapon) then
                     return TRUE
                  end
                  
        if (string.lower(ignore_monsters) == "yes") or string.lower(ignore_monsters) == "no" and isInArray(weapon[4], getCreatureName(target)) == TRUE then

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

                local weapon = weapons[getPlayerWeapon(cid).itemid]
                if string.lower(ingore_weapons) == "yes" then
                        weapon = default
                end

                if (string.lower(ingore_weapons) == "no" and (not weapon) == FALSE or string.lower(ingore_weapons) == "yes") then

                        local currentExtraAttack = getItemExtraAttack(playerWeapon.uid)
                        if(currentExtraAttack >= weapon[3]) then
                                return TRUE
                        end

                        local add = weapon[2]
                        if(currentExtraAttack + add > weapon[3]) then
                                add = currentExtraAttack - weapon[3]
                        end

                        if(playerWeapon.actionid ~= 0) then
                                if(playerWeapon.actionid >= weapon[1]+9999) then
                                        doSetItemActionId(playerWeapon.uid, 10000)
                                        setItemExtraAttack(playerWeapon.uid, currentExtraAttack + add)
                                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" ..add.. " attack points and now have total extra damage of +" .. getItemExtraAttack(playerWeapon.uid) .. " points!")
                                        doSetItemSpecialDescription(playerWeapon.uid, "["..(playerWeapon.actionid-9999).."/"..weapon[1].." | ".. getItemExtraAttack(playerWeapon.uid).."/"..weapon[3].."]")
                                else
                                        doSetItemActionId(playerWeapon.uid, playerWeapon.actionid + 1)
                                        doSetItemSpecialDescription(playerWeapon.uid, "["..(playerWeapon.actionid-9999).."/"..weapon[1].." | ".. getItemExtraAttack(playerWeapon.uid).."/"..weapon[3].."]")
                                end
                        else
                                doSetItemActionId(playerWeapon.uid, 10001)
                                doSetItemSpecialDescription(playerWeapon.uid, "[1/"..weapon[1].." | ".. getItemExtraAttack(playerWeapon.uid).."/"..weapon[3].."]")
                        end
                end
        end
        return TRUE
end


@EDIT !!!!!!


Shawak


I fix the script and now i think work =D
For work with the Ignore_monsters = "yes" then use:

PHP:
if (string.lower(ignore_monsters) == "yes") or string.lower(ignore_monsters) == "no" and isInArray(weapon[4], getCreatureName(target)) == TRUE then
 
Last edited:
Back
Top