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

Lua Ethernal Spear getPlayerSkillLevel(cid, SKILL_DISTANCE)

ex eclipse

New Member
Joined
Jul 15, 2007
Messages
282
Reaction score
1
Location
Brazil
hello there,

my ethernal spear spell

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local levelTotal = level / 5
    local skillTotal = getPlayerSkillLevel(cid, SKILL_DISTANCE)
    local min = levelTotal + (skillTotal * 0.7)
    local max = levelTotal + (skillTotal) + 5
    return -math.ceil(min), -math.ceil(max)
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

the problem is that its not working with the items that increase skilldist also with utito tempo san.. it only returns the skill value without the increase from items/utito tempo san... shouldnt it count the increase from items/spell ? cuz the mage spells works fine with the items that add ml
 
Last edited:
Depends on the level
Hypothetical level / distance
Code:
dist = 100
level = 1
1/5  = .2
0.2 + 100 x 0.7 = 70.2
0.2 + 100 + 5 = 105.2
return -71, -106
post the creatures xml file
 
why don't you print
getPlayerSkillLevel(cid, 4)
to see what's comming from that?

i'll try.. but what about the items that increase skill that are not being considered

why don't you print
getPlayerSkillLevel(cid, 4)
to see what's comming from that?

Code:
function onSay(cid, words, param)

local str = getPlayerSkillLevel(cid, 4)


doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
end

its working fine, but as i said it doesnt consider the increased skill from utito tempo san/items

so if i get skill 50 and + 25 from utito tempo san + 25 from items for example = 100 total.

but the spell/talkaction returns 50 =/
 
Last edited by a moderator:
Correct me if I'm wrong but if you can cast the spell and you have nothing in ur console the script works fine, You can just higher the locals to make it do more dmg.

Tested the script and it works pretty fine for me.
the problem is that if he has a skill buff the
getPlayerSkillLevel(cid, 4) doesn't seems to return that.

well if that is true maybe you have to edit the sources of
getPlayerSkillLevel(cid, 4) to return the true value with buffs and everything

or if somehow you could check if the player has those items that gives buffs and a spell that does that and calculate the true value with lua
what is your server version?
 
Sorry I don't know how to check for the actual subId or arguments of the conditions.. no server setup
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local levelTotal = level / 5
    local skillTotal = getPlayerSkillLevel(cid, SKILL_DISTANCE)
    if getCreatureCondition(cid, CONDITION_ATTRIBUTES) then
        skillTotal = skillTotal + 50
    end
    local min = levelTotal + (skillTotal * 0.7)
    local max = levelTotal + (skillTotal) + 5
    return -math.ceil(min), -math.ceil(max)
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Last edited:
this seems the answer for the bug, but its for 3884 im using 3777 i'll try anyway its similar thanks a lot!!
It'll work in 3777 too.

so should i change to if(player && skillId <= SKILL_LAST)

?
Of course.

Make sure that line you've found is inside this function:
int32_t LuaInterface::luaGetPlayerSkillLevel(lua_State* L)
 
Oh, I see. There's a missing code in revision 3777.

To ease this, just replace this whole code:
Code:
int32_t LuaInterface::luaGetPlayerSkillLevel(lua_State* L)
{
   //getPlayerSkillLevel(cid, skillid)
   uint32_t skillId = popNumber(L);

   ScriptEnviroment* env = getEnv();
   if(const Player* player = env->getPlayerByUID(popNumber(L)))
   {
     if(skillId <= SKILL_LAST)
       lua_pushnumber(L, player->skills[skillId][SKILL_LEVEL]);
     else
       lua_pushboolean(L, false);
   }
   else
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }

   return 1;
}

With this one:
Code:
int32_t LuaInterface::luaGetPlayerSkillLevel(lua_State* L)
{
   //getPlayerSkillLevel(cid, skill[, ignoreModifiers = false])
   bool ignoreModifiers = false;
   if(lua_gettop(L) > 2)
     ignoreModifiers = popNumber(L);

   uint32_t skill = popNumber(L);

   ScriptEnviroment* env = getEnv();
   if(const Player* player = env->getPlayerByUID(popNumber(L)))
   {
     if(player && skill <= SKILL_LAST)
       lua_pushnumber(L, ignoreModifiers ? player->skills[skill][SKILL_LEVEL] :
         player->skills[skill][SKILL_LEVEL] + player->getVarSkill((skills_t)skill));
     else
       lua_pushboolean(L, false);
   }
   else
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }

   return 1;
}
 
Oh, I see. There's a missing code in revision 3777.

To ease this, just replace this whole code:
Code:
int32_t LuaInterface::luaGetPlayerSkillLevel(lua_State* L)
{
   //getPlayerSkillLevel(cid, skillid)
   uint32_t skillId = popNumber(L);

   ScriptEnviroment* env = getEnv();
   if(const Player* player = env->getPlayerByUID(popNumber(L)))
   {
     if(skillId <= SKILL_LAST)
       lua_pushnumber(L, player->skills[skillId][SKILL_LEVEL]);
     else
       lua_pushboolean(L, false);
   }
   else
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }

   return 1;
}

With this one:
Code:
int32_t LuaInterface::luaGetPlayerSkillLevel(lua_State* L)
{
   //getPlayerSkillLevel(cid, skill[, ignoreModifiers = false])
   bool ignoreModifiers = false;
   if(lua_gettop(L) > 2)
     ignoreModifiers = popNumber(L);

   uint32_t skill = popNumber(L);

   ScriptEnviroment* env = getEnv();
   if(const Player* player = env->getPlayerByUID(popNumber(L)))
   {
     if(player && skill <= SKILL_LAST)
       lua_pushnumber(L, ignoreModifiers ? player->skills[skill][SKILL_LEVEL] :
         player->skills[skill][SKILL_LEVEL] + player->getVarSkill((skills_t)skill));
     else
       lua_pushboolean(L, false);
   }
   else
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
   }

   return 1;
}

lol, myth.

thanks a lot i'll try soon and post here what happened
 
Back
Top