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
For each item you intend to use this script on, you must add these 2 lines code to movements.xml
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
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