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

Lua Gain X% Attributes When Equiped.[Creaturescript]

LightTenshimaru

LightTenshimaru
Joined
Mar 15, 2014
Messages
28
Reaction score
1
I'm making a script that when equipping [Wand + Shield], [Sword, Axe, Mace + Shield], [Crossbow] have an attribute bonus in [ML], [SWORD, AXE, MACE], [DISTANCE] respectively.

But I have a lot of problems, the first is that activation message
Lua:
creature: say ("Damage Bonus", TALKTYPE_MONSTER_SAY
keeps repeating without stopping on the screen, the second is that when an attribute is applied when putting the item, when removed the stats do not return to normal, and the third is that I can not combine more than one item to work, I can only with one.
I also have no idea how to include two-handed weapons using the tag [slotType = "two-handed"]

I would be extremely grateful if anyone could help.

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORDPERCENT, 500)

    function onThink(creature, cid)
    if creature:isPlayer() and creature:getWeaponType() == WEAPON_SHIELD then
  
    creature:say("Damage Bonus", TALKTYPE_MONSTER_SAY, 36)
    creature:addCondition(condition)
  
    else
    creature:removeCondition(condition)
    creature:say("Bonus Removed", TALKTYPE_MONSTER_SAY, 36)
    return true  
end
end
 
Last edited:

For this i need to configure every single item to work on the script, but on creatureevents it can work on any item, can you help with this script?

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
        setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
        setConditionParam(condition, CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, 150)
        setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, 1)

local condition2 = createConditionObject(CONDITION_ATTRIBUTES)
        setConditionParam(condition2, CONDITION_PARAM_TICKS, -1)
        setConditionParam(condition2, CONDITION_PARAM_SKILL_DISTANCEPERCENT, 150)
        setConditionParam(condition2, CONDITION_PARAM_BUFF_SPELL, 1)   

local condition3 = createConditionObject(CONDITION_ATTRIBUTES)
        setConditionParam(condition3, CONDITION_PARAM_TICKS, -1)
        setConditionParam(condition3, CONDITION_PARAM_SKILL_MELEEPERCENT, 150)
        setConditionParam(condition3, CONDITION_PARAM_BUFF_SPELL, 1)           
       
local voc = {
    {
        id = 1, -- Sorcerer
    },
    {
        id = 2, -- Druid        
    },
    {
        id = 3, -- Paladin
    },
    {
        id = 4, -- Knight
    },
}

function onThink(creature, interval)
    if creature:isPlayer() then
       local vocation = creature:getVocation():getBase():getId()
            for i=1, #voc do
                if vocation == voc[i].id then
                    --print(creature:getWeaponType())
                        if vocation == 1 or vocation == 2 then
                            local weapontype = nil
                            local slotItem = creature:getSlotItem(CONST_SLOT_LEFT) or creature:getSlotItem(CONST_SLOT_RIGHT)
                            if    slotItem then
                               weaponType = slotItem:getType():getWeaponType()
                            end
                            if weaponType == WEAPON_SHIELD then
                               creature:addCondition(condition)
                               creature:say("MAGIC!", TALKTYPE_MONSTER_SAY)                       
                            elseif
                               creature:removeCondition(CONDITION_ATTRIBUTES)                              
                            end
                            end
                            end
                            end
                           
                        if vocation == 3 then
                            local slotItem = creature:getSlotItem(CONST_SLOT_LEFT) or creature:getSlotItem(CONST_SLOT_RIGHT)
                            if    slotItem then
                                  slotPos = slotItem:getType():getSlotPosition()
                                  --print("Slot position: ", slotPos)
                            end
                            if slotPos == 2096 then --Indentify slotType: Two-Handed for Bow/Crossbow
                               creature:addCondition(condition2)                           
                               --creature:say("DISTANCE!", TALKTYPE_MONSTER_SAY)
                            elseif
                               slotPos == 48 then                              
                               creature:removeCondition(CONDITION_ATTRIBUTES)                              
                            end
                            end
                           
                        if vocation == 4 then
                            local weapontype = nil
                            local slotItem = creature:getSlotItem(CONST_SLOT_LEFT) or creature:getSlotItem(CONST_SLOT_RIGHT)
                            if slotItem then
                               weaponType = slotItem:getType():getWeaponType()
                            end                               
                            if weaponType == WEAPON_SHIELD then
                               creature:addCondition(condition3)
                                --creature:say("BERSERKER!", TALKTYPE_MONSTER_SAY)
                            else
                               creature:removeCondition(CONDITION_ATTRIBUTES)               
   
                            end
                            end
                        end
                    end

Here the part of the code that I am trying to make work, although the bonus is applied when the shield is equipped, but it does not disappear when i unequip, and at the same time when a wand is equiped the bonus is lost.

Lua:
function onThink(creature, interval)
    if creature:isPlayer() then
       local vocation = creature:getVocation():getBase():getId()
            for i=1, #voc do
                if vocation == voc[i].id then
                    --print(creature:getWeaponType())
                        if vocation == 1 or vocation == 2 then
                            local weapontype = nil
                            local slotItem = creature:getSlotItem(CONST_SLOT_LEFT) or creature:getSlotItem(CONST_SLOT_RIGHT)
                            if    slotItem then
                               weaponType = slotItem:getType():getWeaponType()
                            end
                            if weaponType == WEAPON_SHIELD then
                               creature:addCondition(condition)
                               creature:say("MAGIC!", TALKTYPE_MONSTER_SAY)                      
                            elseif
                               creature:removeCondition(CONDITION_ATTRIBUTES)                             
                            end
                            end
                            end
                            end
 
Back
Top