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

MoveEvent 0.3.6 - 8.6 - Custom Equipment with stat attributes, based on vocation.

Codex NG

Recurrent Flamer
Joined
Jul 24, 2015
Messages
2,994
Solutions
12
Reaction score
1,657
This script will allow you to assign stat attributes to equipment which normally don't have stats or bonuses based on the player's vocation.

Written for cryingdamson-0.3.6-8.60-V8.2, but I am sure it will work for 0.4 as well.

Save this in data\movements\scripts\ as equipmentWithStats.lua
Code:
-- base vocations
local vocations = {
    -- sorcerer
    [1] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- druid
    [2] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- paladin
    [3] = {
        stats = {
            {CONDITION_PARAM_SKILL_DISTANCE, 9},
            {CONDITION_PARAM_SKILL_SHIELD, 8}
        },
        buff = false
    },
    -- knight
    [4] = {
        stats = {
            {CONDITION_PARAM_SKILL_CLUB, 3},
            {CONDITION_PARAM_SKILL_SWORD, 3},
            {CONDITION_PARAM_SKILL_AXE, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 9}
        },
        buff = false
    }
}
--[[
    Slot Id's of equipment
    1 - helmet
    2 - necklace slot (amulet of loss etc.)
    3 - backpack, bag
    4 - armor
    5 - left hand
    6 - right hand
    7 - legs
    8 - boots
    9 - ring slot
    10 - ammo slot (arrows etc.)
]]
-- Sub id is in place so the attributes stack
local subId = 1 -- leave this as is or change it correspond with the slot id

-- Do not edit below
---------------------------------------------------
local condition = {}

function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

for voc, param in pairs(vocations) do
    condition[voc] = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(condition[voc], CONDITION_PARAM_SUBID, subId)
    setConditionParam(condition[voc], CONDITION_PARAM_TICKS, -1)

    for x = 1, #param.stats do
        setConditionParam(condition[voc], param.stats[x][1], param.stats[x][2])
    end

    if param.buff ~= nil then
        setConditionParam(condition[voc], CONDITION_PARAM_BUFF, param.buff)
    end
end

function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        else
            local playerVocation = getBaseVocation(getPlayerVocation(cid))
            doAddCondition(cid, condition[playerVocation])
        end
    end
    return true
end

function onDeEquip(cid, item, slot)
    doRemoveCondition(cid, CONDITION_ATTRIBUTES, subId)
    return true
end

For each item you intend to use this script on, you must add these 2 lines code to movements.xml
Code:
    <movevent type="Equip" itemid="item id of item" slot="slot name of item" event="script" value="equipmentWithStats.lua"/>
    <movevent type="DeEquip" itemid="item id of item" slot="slot name of item" event="script" value="equipmentWithStats.lua"/>

If you are unsure which slot name to use, please refer to this section of code in the sources for the corresponding slot name.
https://github.com/Jo-Tran/cryingda...f21b5602cde8a6771a2f4d/movement.cpp#L742-L766

For a list of possible conditions to add to the equipment please refer to these sections of code in the sources.
https://github.com/Jo-Tran/cryingda...8a6771a2f4d/data/lib/000-constant.lua#L15-L57

and here
https://github.com/Jo-Tran/cryingda...a6771a2f4d/data/lib/000-constant.lua#L96-L121
 
How can I make this script give different stats to different items without doing one script for each item?
 
This script will allow you to assign stat attributes to equipment which normally don't have stats or bonuses based on the player's vocation.

Written for cryingdamson-0.3.6-8.60-V8.2, but I am sure it will work for 0.4 as well.

Save this in data\movements\scripts\ as equipmentWithStats.lua
Code:
-- base vocations
local vocations = {
    -- sorcerer
    [1] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- druid
    [2] = {
        stats = {
            {CONDITION_PARAM_STAT_MAGICLEVEL, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 5}
        },
        buff = false
    },
    -- paladin
    [3] = {
        stats = {
            {CONDITION_PARAM_SKILL_DISTANCE, 9},
            {CONDITION_PARAM_SKILL_SHIELD, 8}
        },
        buff = false
    },
    -- knight
    [4] = {
        stats = {
            {CONDITION_PARAM_SKILL_CLUB, 3},
            {CONDITION_PARAM_SKILL_SWORD, 3},
            {CONDITION_PARAM_SKILL_AXE, 3},
            {CONDITION_PARAM_SKILL_SHIELD, 9}
        },
        buff = false
    }
}
--[[
    Slot Id's of equipment
    1 - helmet
    2 - necklace slot (amulet of loss etc.)
    3 - backpack, bag
    4 - armor
    5 - left hand
    6 - right hand
    7 - legs
    8 - boots
    9 - ring slot
    10 - ammo slot (arrows etc.)
]]
-- Sub id is in place so the attributes stack
local subId = 1 -- leave this as is or change it correspond with the slot id

-- Do not edit below
---------------------------------------------------
local condition = {}

function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

for voc, param in pairs(vocations) do
    condition[voc] = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(condition[voc], CONDITION_PARAM_SUBID, subId)
    setConditionParam(condition[voc], CONDITION_PARAM_TICKS, -1)

    for x = 1, #param.stats do
        setConditionParam(condition[voc], param.stats[x][1], param.stats[x][2])
    end

    if param.buff ~= nil then
        setConditionParam(condition[voc], CONDITION_PARAM_BUFF, param.buff)
    end
end

function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        else
            local playerVocation = getBaseVocation(getPlayerVocation(cid))
            doAddCondition(cid, condition[playerVocation])
        end
    end
    return true
end

function onDeEquip(cid, item, slot)
    doRemoveCondition(cid, CONDITION_ATTRIBUTES, subId)
    return true
end

For each item you intend to use this script on, you must add these 2 lines code to movements.xml
Code:
    <movevent type="Equip" itemid="item id of item" slot="slot name of item" event="script" value="equipmentWithStats.lua"/>
    <movevent type="DeEquip" itemid="item id of item" slot="slot name of item" event="script" value="equipmentWithStats.lua"/>

If you are unsure which slot name to use, please refer to this section of code in the sources for the corresponding slot name.
https://github.com/Jo-Tran/cryingda...f21b5602cde8a6771a2f4d/movement.cpp#L742-L766

For a list of possible conditions to add to the equipment please refer to these sections of code in the sources.
https://github.com/Jo-Tran/cryingda...8a6771a2f4d/data/lib/000-constant.lua#L15-L57

and here
https://github.com/Jo-Tran/cryingda...a6771a2f4d/data/lib/000-constant.lua#L96-L121

well good script
but you may need to give some comments for beginners :D where to add new attributes for each vocations ..

but may i ask a question
what is the different between adding things in items.xml then register them to movements.xml ?? and your script
because as i see all attributes you used " skill " i can do it with items.xml and movements.xml
for example
spellbooks for mage
rings for other vocs
i think i can do it in movements.xml to make only 1 vocation is allowed to equip this item as well

i will much appreciate your answer .. maybe you will make something clear to me :)
 
I could understand you need comments if the code was written in an obscure manner such as a +b = c return d, but the the functionality, naming convention and execution is written in english.

I even linked to the means to expand the script, anything more than that you need to take matters into your own hands, there is no easy solution in development.
i mean it will be good for beginners
btw answer my question .. what is the different ?
I thought I just did.

You people seem to lack critical thinking skills.. what the hell are they teaching you kids in school?
 
I could understand you need comments if the code was written in an obscure manner such as a +b = c return d, but the the functionality, naming convention and execution is written in english.

I even linked to the means to expand the script, anything more than that you need to take matters into your own hands, there is no easy solution in development.

I thought I just did.
just forgot about comments and tell me the different between your script and using items.xml and movements.xml ?

and i really want to figure , why all of your answers contain learn to code even if that guy who asked you never asked for a code :D
Cheers .!
 
just forgot about comments and tell me the different between your script and using items.xml and movements.xml ?

and i really want to figure , why all of your answers contain learn to code even if that guy who asked you never asked for a code :D
Cheers .!
Oh how rude of me, I forgot to introduce myself.. Hi I am the guy who doesn't give a fuck what you want.
 
How would i add the script to this code? This is not my code btw credits for https://otland.net/members/destinationser.33000/
Code:
function onEquip(cid, item, slot)
if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid == PLACE_ID and getPlayerStorageValue(cid, 4500) >= 100 then
return true
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You must be Prestige 100 or higher to equip this.")
return false
end
end
 
Back
Top