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

C++ Special skill magic level

_M4G0_

Intermediate OT User
Joined
Feb 6, 2016
Messages
540
Solutions
16
Reaction score
106
I have a tfs 1.2 system with special magic attribute, I tried to add it in tfs 1.4, BTS version, added successfully, but with problems in working
enum SpecialSkills_t {
SPECIALSKILL_MAGICLEVEL = 1,

SPECIALSKILL_FIRST = SPECIALSKILL_MAGICLEVEL,
SPECIALSKILL_LAST = SPECIALSKILL_MAGICLEVEL
};

enum itemCustomAttrTypes : uint32_t {
ITEM_CUSTOMATTRIBUTE_SPECIALSKILL_MAGICLEVEL = 1,
};
int32_t getSpecialSkillMagicLevel() const
{
if (abilities->specialSkills[SPECIALSKILL_MAGICLEVEL]) {
return abilities->specialSkills[SPECIALSKILL_MAGICLEVEL];
}
return 0;
}
registerEnum(ITEM_CUSTOMATTRIBUTE_SPECIALSKILL_MAGICLEVEL)
registerMethod("ItemType", "getSpecialSkillMagicLevel", LuaScriptInterface::luaItemTypeGetSpecialSkillMagicLevel);

int LuaScriptInterface::luaItemTypeGetSpecialSkillMagicLevel(lua_State* L) {
// itemType:getSpecialSkillMagicLevel()
const ItemType* itemType = getUserdata<const ItemType>(L, 1);
if (itemType) {
lua_pushnumber(L, itemType->getSpecialSkillMagicLevel());
} else {
lua_pushnil(L);
}
return 1;
}
static int luaItemTypeGetSpecialSkillMagicLevel(lua_State* L);
void Player::updateSpecialSkills()
{
for (int32_t i = SPECIALSKILL_FIRST; i <= SPECIALSKILL_LAST; ++i) {
setVarSpecialSkill(static_cast<SpecialSkills_t>(i), 0);
}

for (uint8_t slot = CONST_SLOT_FIRST; slot < CONST_SLOT_LAST; slot++) {
Thing* thing = getThing(slot);
if (thing) {
Item* item = thing->getItem();
if (item) {
const ItemType& iType = Item::items[item->getID()];

for (int32_t i = SPECIALSKILL_FIRST; i <= SPECIALSKILL_LAST; ++i) {
if (iType.abilities->specialSkills) {
int64_t skillValue = iType.abilities->specialSkills;
setVarSpecialSkill(static_cast<SpecialSkills_t>(i), skillValue);
}

// const ItemAttributes::CustomAttribute* attr = item->getCustomAttribute(getSpecialSkillCustomAttribute(i));
// if (attr) {
// int64_t skillValue = boost::get<int64_t>(attr->value);
// addVarSpecialSkill(static_cast<SpecialSkills_t>(i), skillValue);
// }
}
}
}
}
sendSkills();
sendStats();
}
uint32_t getMagicLevel() const {
return std::max<int32_t>(0, magLevel + varStats[STAT_MAGICPOINTS] + getSpecialSkill(SPECIALSKILL_MAGICLEVEL));
}

void addVarSpecialSkill(SpecialSkills_t skill, int32_t modifier) {
varSpecialSkills[skill] += modifier;
}
itemCustomAttrTypes getSpecialSkillCustomAttribute(uint8_t skillid)
{
switch (skillid) {
case SPECIALSKILL_MAGICLEVEL:
return ITEM_CUSTOMATTRIBUTE_SPECIALSKILL_MAGICLEVEL;

default:
return (itemCustomAttrTypes)0;
}
}


SpecialSkills_t getCustomAttributeSpecialSkill(itemCustomAttrTypes attr)
{
switch (attr) {
case ITEM_CUSTOMATTRIBUTE_SPECIALSKILL_MAGICLEVEL:
return SPECIALSKILL_MAGICLEVEL;

default:
return (SpecialSkills_t)0;
}
}
itemCustomAttrTypes getSpecialSkillCustomAttribute(uint8_t skillid);
SpecialSkills_t getCustomAttributeSpecialSkill(itemCustomAttrTypes attr);
 
Back
Top