This commit is contained in:
alexey.min 2012-05-10 13:05:31 +00:00
parent 9fe62a4274
commit 070dc51e92
5 changed files with 48 additions and 1 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 );

View File

@ -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 );

View File

@ -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; i<UserSkills::USERSKILL_MAX_SKILLS; i++ )
{
if( sk->skill[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;
}