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

OTClient TFS1.4.2/OTC-mehah error with custom skill

edddaaan

New Member
Joined
May 28, 2014
Messages
5
Reaction score
2
Im trying to make custom skills that start on 0 but it triggers error in the clientSkärmbild 2023-07-09 035947.png
and when i log into a char with 0 skill it only shows the bars


here is the lua part that breaks on line 251
Lua:
local hasAdditionalSkills = g_game.getFeature(GameAdditionalSkills)
    for i = Skill.Melee, Skill.ManaLeechAmount do
        onSkillChange(player, i, player:getSkillLevel(i), player:getSkillLevelPercent(i))
        onBaseSkillChange(player, i, player:getSkillBaseLevel(i))
        if i > Skill.Fishing then
            toggleSkill('skillId' .. i, hasAdditionalSkills)
        end
    end
on line 224 there is just "refresh()" without the ""

skills.otui
Rich (BB code):
SkillFirstWidget < UIWidget

SkillButton < UIButton
  height: 21
  margin-bottom: 2
  &onClick: onSkillButtonClick

SmallSkillButton < SkillButton
  height: 14

HiddenSkillButton < SkillButton
  height: 0
  visible: false

SkillNameLabel < GameLabel
  font: verdana-11px-monochrome
  anchors.left: parent.left
  anchors.top: parent.top
  anchors.bottom: parent.bottom

SkillValueLabel < GameLabel
  id: value
  font: verdana-11px-monochrome
  text-align: topright
  anchors.right: parent.right
  anchors.top: parent.top
  anchors.bottom: parent.bottom
  anchors.left: prev.left

SkillPercentPanel < ProgressBar
  id: percent
  background-color: green
  height: 5
  margin-top: 15
  anchors.left: parent.left
  anchors.right: parent.right
  anchors.top: parent.top
  phantom: false

MiniWindow
  id: skillWindow
  !text: tr('Skills')
  height: 150
  icon: /images/topbuttons/skills
  @onOpen: modules.game_skills.onMiniWindowOpen()
  @onClose: modules.game_skills.onMiniWindowClose()
  &save: true

  MiniWindowContents
    padding-left: 5
    padding-right: 5
    layout: verticalBox

    SkillButton
      margin-top: 5
      id: experience
      height: 15
      SkillNameLabel
        !text: tr('Experience')
      SkillValueLabel

    SkillButton
      id: level
      SkillNameLabel
        !text: tr('Level')
      SkillValueLabel
      SkillPercentPanel
        background-color: red

    SkillButton
      id: health
      height: 15
      SkillNameLabel
        !text: tr('Hit Points')
      SkillValueLabel

    SkillButton
      id: mana
      height: 15
      SkillNameLabel
        !text: tr('Mana')
      SkillValueLabel

    HiddenSkillButton
      id: soul
      height: 15
      SkillNameLabel
        !text: tr('Soul Points')
      SkillValueLabel

    SkillButton
      id: capacity
      height: 15
      SkillNameLabel
        !text: tr('Capacity')
      SkillValueLabel

    SkillButton
      id: speed
      height: 15
      SkillNameLabel
        !text: tr('Speed')
      SkillValueLabel

    HiddenSkillButton
      id: regenerationTime
      SkillNameLabel
        !text: tr('Regeneration Time')
      SkillValueLabel

    HiddenSkillButton
      id: stamina
      SkillNameLabel
        !text: tr('Stamina')
      SkillValueLabel
      SkillPercentPanel

    SkillButton
      id: offlineTraining
      SkillNameLabel
        !text: tr('Offline Training')
      SkillValueLabel
      SkillPercentPanel

    SkillButton
      id: magiclevel
      SkillNameLabel
        !text: tr('Magic Level')
      SkillValueLabel
      SkillPercentPanel
        background-color: red

    SkillButton
      id: skillId0
      SkillNameLabel
        !text: tr('Melee Fighting')
      SkillValueLabel
      SkillPercentPanel

    SkillButton
      id: skillId1
      SkillNameLabel
        !text: tr('Distance Fighting')
      SkillValueLabel
      SkillPercentPanel

    SkillButton
      id: skillId2
      SkillNameLabel
        !text: tr('Shielding')
      SkillValueLabel
      SkillPercentPanel

    HiddenSkillButton
      id: skillId3
      SkillNameLabel
        !text: tr('Fishing')
      SkillValueLabel
      SkillPercentPanel

    SmallSkillButton
      id: skillId4
      SkillNameLabel
        !text: tr('Critical Hit Chance')
      SkillValueLabel

    SmallSkillButton
      id: skillId5
      SkillNameLabel
        !text: tr('Critical Hit Damage')
      SkillValueLabel

    SmallSkillButton
      id: skillId6
      SkillNameLabel
        !text: tr('Life Leech Chance')
      SkillValueLabel

    SmallSkillButton
      id: skillId7
      SkillNameLabel
        !text: tr('Life Leech Amount')
      SkillValueLabel

    SmallSkillButton
      id: skillId8
      SkillNameLabel
        !text: tr('Mana Leech Chance')
      SkillValueLabel

    SmallSkillButton
      id: skillId9
      SkillNameLabel
        !text: tr('Mana Leech Amount')
      SkillValueLabel

const.h enums looks like this
C++:
    enum Skill : uint8_t
    {
        Melee = 0,
        Distance,
        Shielding,
        Fishing,
        CriticalChance,
        CriticalDamage,
        LifeLeechChance,
        LifeLeechAmount,
        ManaLeechChance,
        ManaLeechAmount,
        Fatal,
        Dodge,
        Momentum,
        LastSkill
    };

protocolgameparce.cpp is edited to
C++:
for (int_fast32_t skill = Otc::Melee; skill <= Otc::Fishing; ++skill) {
        uint16_t level;
...
and on server side i have replaced fist,club,sword,axe with melee everywhere i can think of
player.h
C++:
static constexpr int16_t MINIMUM_SKILL_LEVEL = 0;
enums.h
C++:
enum skills_t : uint8_t {
    SKILL_MELEE = 0,
    SKILL_DISTANCE = 1,
    SKILL_SHIELD = 2,
    SKILL_FISHING = 3,

    SKILL_MAGLEVEL = 4,
    SKILL_LEVEL = 5,

    SKILL_FIRST = SKILL_MELEE,
    SKILL_LAST = SKILL_FISHING
};
tools.cpp
C++:
std::string getSkillName(uint8_t skillid)
{
    switch (skillid) {
        case SKILL_MELEE:
            return "melee fighting";
           
        case SKILL_DISTANCE:
            return "distance fighting";

        case SKILL_SHIELD:
            return "shielding";

        case SKILL_FISHING:
            return "fishing";

        case SKILL_MAGLEVEL:
            return "magic level";

        case SKILL_LEVEL:
            return "level";

        default:
            return "unknown";
    }
}
Skärmbild 2023-07-09 033656.png
Post automatically merged:

i tried with changing
player.h
C++:
static constexpr int16_t MINIMUM_SKILL_LEVEL = 1;
and changed the skills to 1 on the char and the skillwindow show them but the specialskills below wont show numbers and the lua error is still there
 
Last edited:
i missed to edit client\modules\gamelib\const.lua to correct ids

1688931566751.png
Lua:
Skill = {
    Melee = 0,
    Distance = 1,
    Shielding = 2,
    Fishing = 3,
    CriticalChance = 4,
    CriticalDamage = 5,
    LifeLeechChance = 6,
    LifeLeechAmount = 7,
    ManaLeechChance = 8,
    ManaLeechAmount = 9
}
 
Back
Top