• 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 and Cast System

Togu

Advanced OT User
Joined
Jun 22, 2018
Messages
308
Solutions
1
Reaction score
178
Location
Brazil
Im thinking on give a try to make that.
I've seen that OTClient has lua calls for almost everything, for example, on skill window module:
Code:
connect(LocalPlayer, {
        onExperienceChange = onExperienceChange,
        onLevelChange = onLevelChange,
        onHealthChange = onHealthChange,
        onManaChange = onManaChange,
        onSoulChange = onSoulChange,
        onSkillPointsChange = onSkillPointsChange,
        onFreeCapacityChange = onFreeCapacityChange,
        onTotalCapacityChange = onTotalCapacityChange,
        onSpeedChange = onSpeedChange,
        onBaseSpeedChange = onBaseSpeedChange,
        onAttackSpeedChange = onAttackSpeedChange,
        onStaminaChange = onStaminaChange,
        onRegenerationChange = onRegenerationChange,
        onBaseMagicLevelChange = onBaseMagicLevelChange,
        onMagicLevelChange = onMagicLevelChange,
        onNewBaseMagicLevelChange = onNewBaseMagicLevelChange,
        onBaseSkillChange = onBaseSkillChange,
        onSkillChange = onSkillChange,
        onNewBaseSkillChange = onNewBaseSkillChange,
    })

The client connects the localPlayer to the server and receives a message when "experience changes", "level changes", and etc:
Code:
void LocalPlayer::setExperience(double experience) //client parse the changed experience sent from the server, set the new experience by calling this function and this function calls the lua script on skill window module, then the lua script sets the interface with values and etc
{
    if(m_experience != experience) {
        double oldExperience = m_experience;
        m_experience = experience;

        callLuaField("onExperienceChange", experience, oldExperience);
    }
}

Then he calls in the same script the function that handle that information:
Code:
function onExperienceChange(localPlayer, value)
  setSkillValue('experience', value)
end

function onLevelChange(localPlayer, value, percent)
  setSkillValue('level', value)
  local text = tr('You have %s percent to go', 100 - percent) .. '\n' ..
               tr('%s of experience left', expToAdvance(localPlayer:getLevel(), localPlayer:getExperience()))

  if localPlayer.expSpeed ~= nil then
     local expPerHour = math.floor(localPlayer.expSpeed * 3600)
     if expPerHour > 0 then
        local nextLevelExp = expForLevel(localPlayer:getLevel()+1)
        local hoursLeft = (nextLevelExp - localPlayer:getExperience()) / expPerHour
        local minutesLeft = math.floor((hoursLeft - math.floor(hoursLeft))*60)
        hoursLeft = math.floor(hoursLeft)
        text = text .. '\n' .. tr('%d of experience per hour', expPerHour)
        text = text .. '\n' .. tr('Next level in %d hours and %d minutes', hoursLeft, minutesLeft)
     end
  end

  setSkillPercent('level', percent, text)
end

So, I guess that rather than using localPlayer position to render localPlayer on screen, I can get playerCasting position and render on any screen everything related to him, am I right?

I'm gonna try it and I need some tips. If I manage to make that I'll release for free anyway
 
This would be awesome. If this is possible, I think server load will be significantly less than using regular cast systems out there.
 
Last edited:
Back
Top