From 070dc51e92e86c6e87d9a26ee2872dd59708cb43 Mon Sep 17 00:00:00 2001 From: "alexey.min" Date: Thu, 10 May 2012 13:05:31 +0000 Subject: [PATCH] --- l2detect/UserSkills.cpp | 14 +++++++++++++- l2detect/UserSkills.h | 1 + l2detect/se_funcs/SE_funcs.cpp | 1 + l2detect/se_funcs/SE_funcs.h | 1 + l2detect/se_funcs/sef_skills.cpp | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/l2detect/UserSkills.cpp b/l2detect/UserSkills.cpp index 97f69d6..a5d76b9 100644 --- a/l2detect/UserSkills.cpp +++ b/l2detect/UserSkills.cpp @@ -48,11 +48,23 @@ void UserSkill::setUnused() void UserSkill::getSkillName( wchar_t *out, size_t maxCount ) { - char aname[256] = {0}; + char aname[1024] = {0}; L2Data_DB_GetSkillNameByID( skillID, aname ); MultiByteToWideChar( CP_ACP, 0, aname, -1, out, maxCount ); } +void UserSkill::getSkillName( char *out, size_t maxCount ) +{ + out[0] = 0; + char *aname = (char *)malloc( 1024 ); + if( aname ) + { + L2Data_DB_GetSkillNameByID( skillID, aname ); + strncpy( out, aname, maxCount ); + free( aname ); + } +} + void UserSkill::process_coolTime( unsigned int curTick ) { //if( skillID == 0 ) return; diff --git a/l2detect/UserSkills.h b/l2detect/UserSkills.h index 88e1298..9696643 100644 --- a/l2detect/UserSkills.h +++ b/l2detect/UserSkills.h @@ -12,6 +12,7 @@ public: void setUnused(); bool isUnused() { return (skillID == 0); } void getSkillName( wchar_t *out, size_t maxCount ); + void getSkillName( char *out, size_t maxCount ); public: unsigned int skillID; unsigned int level; diff --git a/l2detect/se_funcs/SE_funcs.cpp b/l2detect/se_funcs/SE_funcs.cpp index 723e70c..4b03b17 100644 --- a/l2detect/se_funcs/SE_funcs.cpp +++ b/l2detect/se_funcs/SE_funcs.cpp @@ -50,6 +50,7 @@ void SE_funcs_register( lua_State *L ) lua_register( L, "l2c_getSkillLevel", l2c_getSkillLevel ); lua_register( L, "l2c_getSkillReuseLeft", l2c_getSkillReuseLeft ); lua_register( L, "l2c_isCastingNow", l2c_isCastingNow ); + lua_register( L, "l2c_getUserSkills", l2c_getUserSkills ); // Buffs lua_register( L, "l2c_getBuffs", l2c_getBuffs ); lua_register( L, "l2c_buffCancel", l2c_buffCancel ); diff --git a/l2detect/se_funcs/SE_funcs.h b/l2detect/se_funcs/SE_funcs.h index 2802d0f..46a288d 100644 --- a/l2detect/se_funcs/SE_funcs.h +++ b/l2detect/se_funcs/SE_funcs.h @@ -48,6 +48,7 @@ int l2c_useSkill( lua_State *L ); int l2c_getSkillLevel( lua_State *L ); int l2c_getSkillReuseLeft( lua_State *L ); int l2c_isCastingNow( lua_State *L ); +int l2c_getUserSkills( lua_State *L ); // Buffs int l2c_getBuffs( lua_State *L ); int l2c_buffCancel( lua_State *L ); diff --git a/l2detect/se_funcs/sef_skills.cpp b/l2detect/se_funcs/sef_skills.cpp index 4295c9f..a530600 100644 --- a/l2detect/se_funcs/sef_skills.cpp +++ b/l2detect/se_funcs/sef_skills.cpp @@ -54,3 +54,35 @@ int l2c_isCastingNow( lua_State *L ) lua_pushboolean( L, b ); return 1; } + + +// table l2c_getUserSkills() +int l2c_getUserSkills( lua_State *L ) +{ + if( !g_game_client ) { lua_pushboolean( L, 0 ); return 1; } + UserSkills *sk = &(g_game_client->ai.skills); + // + int tableIndex = 0; + lua_createtable( L, 0, 0 ); + int i = 0; + char skillName[255] = {0}; + for( i=0; iskill[i].isUnused() ) continue; + sk->skill[i].getSkillName( skillName, sizeof(skillName)-1 ); + lua_pushnumber( L, tableIndex ); + lua_createtable( L, 0, 0 ); + // + lua_pushstring( L, "skillId" ); + lua_pushinteger( L, sk->skill[i].skillID ); + lua_settable( L, -3 ); + // + lua_pushstring( L, "skillName" ); + lua_pushstring( L, skillName ); + lua_settable( L, -3 ); + // + lua_settable( L, -3 ); + } + // + return 1; +}