shivaria
Active Member
- Joined
- Sep 2, 2009
- Messages
- 158
- Reaction score
- 36
SOLVED: When using Shield Skills, always "getEffectiveSkillLevel" and not "getSkillLevel"
Wish I knew about this before! lol
I am using a hammer on an item(9966) while its on an anvil. The code works and removes the item, creates the item, but ignores my code and goes straight to where i wrote fail22.
TFS 1.1 (10.77)
Wish I knew about this before! lol
I am using a hammer on an item(9966) while its on an anvil. The code works and removes the item, creates the item, but ignores my code and goes straight to where i wrote fail22.
TFS 1.1 (10.77)
Code:
local config = {
exhaustOnUse = 500 -- miliseconds
}
local exhaust = Condition(CONDITION_EXHAUST_WEAPON)
exhaust:setParameter(CONDITION_PARAM_TICKS, config.exhaustOnUse)
local lootCommon = {7386, 15454, 2425, 2435, 2532, 15410, 15409, 21692, 2474}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local forgingLevel = player:getSkillLevel(cid, SKILL_SHIELD)
-- --------------------- --
if player:getCondition(CONDITION_EXHAUST_WEAPON) then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
return true
end
player:addCondition(exhaust)
-------------------- start area clear path ----------------------------------
if target.itemid == 9966 then
if toPosition.x == 65535 or getTileItemById(toPosition, 2555).uid == 0 then
player:say("Must be forged at an Anvil", TALKTYPE_MONSTER_SAY)
return true
end
toPosition:sendMagicEffect(6)
if forgingLevel < 3 then
if math.random(5) == 1 then
target:remove(1)
player:say("Fail", TALKTYPE_MONSTER_SAY)
return true
else
player:say("Miss!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 1)
return true
end
elseif forgingLevel < 6 then ---------- LEVELS ----------------
if math.random(10) == 1 then
target:remove(1)
player:addItem(lootCommon[math.random(#lootCommon)], 1)
toPosition:sendMagicEffect(7)
player:say("Success!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 7)
return true
else
player:say("Fail22 KEEPS GOING HERE EVEN WITH SHIELD LEVEL 1,2,3,4 etc", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 1)
target:remove(1)
return true
end
elseif forgingLevel < 9 then ---------- LEVELS ----------------
if math.random(8) == 1 then
player:addItem(lootCommon[math.random(#lootCommon)], 1)
toPosition:sendMagicEffect(7)
player:say("Success!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 7)
return true
else
player:say("Fail", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 1)
target:transform(0)
return true
end
elseif forgingLevel < 12 then ---------- LEVELS ----------------
if math.random(6) == 1 then
player:addItem(lootCommon[math.random(#lootCommon)], 1)
toPosition:sendMagicEffect(7)
player:say("Success!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 7)
return true
else
player:say("Fail", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 1)
target:transform(0)
return true
end
elseif forgingLevel < 15 then ---------- LEVELS ----------------
if math.random(4) == 1 then
player:addItem(lootCommon[math.random(#lootCommon)], 1)
toPosition:sendMagicEffect(7)
player:say("Success!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 7)
return true
else
player:say("Fail", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 1)
target:transform(0)
return true
end
elseif forgingLevel < 18 then ---------- LEVELS ----------------
if math.random(3) == 1 then
player:addItem(lootCommon[math.random(#lootCommon)], 1)
toPosition:sendMagicEffect(7)
player:say("Success!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 7)
return true
else
player:say("Fail", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 1)
target:transform(0)
return true
end
elseif forgingLevel < 20 then ---------- LEVELS ----------------
if math.random(2) == 1 then
player:addItem(lootCommon[math.random(#lootCommon)], 1)
toPosition:sendMagicEffect(7)
player:say("Success!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 7)
return true
else
player:say("Fail", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 1)
target:transform(0)
return true
end
elseif forgingLevel < 255 then ---------- LEVELS ----------------
if math.random(1) == 1 then
player:addItem(lootCommon[math.random(#lootCommon)], 1)
toPosition:sendMagicEffect(7)
player:say("Perfect!", TALKTYPE_MONSTER_SAY)
player:addSkillTries(SKILL_SHIELD, 7)
return true
end
end
else
return false
end
end
Last edited: