Initial MSVC 2008 projects workspace
This commit is contained in:
84
l2detect/se_funcs/SE_funcs.cpp
Normal file
84
l2detect/se_funcs/SE_funcs.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "SE_funcs.h"
|
||||
|
||||
// called by ScriptEngine on init()
|
||||
void SE_funcs_register( lua_State *L )
|
||||
{
|
||||
// sys
|
||||
lua_register( L, "sys_should_exit", sys_should_exit );
|
||||
lua_register( L, "sys_register_onChat", sys_register_onChat );
|
||||
// sys
|
||||
lua_register( L, "l2h_delay", l2h_delay );
|
||||
lua_register( L, "l2h_print", l2h_print );
|
||||
lua_register( L, "l2h_console_enable", l2h_console_enable );
|
||||
lua_register( L, "l2h_soundAlert", l2h_soundAlert );
|
||||
lua_register( L, "l2h_time", l2h_time );
|
||||
lua_register( L, "l2h_timeMsec", l2h_timeMsec );
|
||||
// user info
|
||||
lua_register( L, "l2c_is_INGAME", l2c_is_INGAME );
|
||||
lua_register( L, "l2c_getHPMPCPWeight", l2c_getHPMPCPWeight );
|
||||
lua_register( L, "l2c_getStats", l2c_getStats );
|
||||
// chatting
|
||||
lua_register( L, "l2c_say", l2c_say );
|
||||
lua_register( L, "l2c_sayPm", l2c_sayPm );
|
||||
lua_register( L, "l2c_npcDlg", l2c_npcDlg );
|
||||
lua_register( L, "l2c_npcDlgClear", l2c_npcDlgClear );
|
||||
lua_register( L, "l2c_npcDlgExists", l2c_npcDlgExists );
|
||||
// Moving
|
||||
lua_register( L, "l2c_getPos", l2c_getPos );
|
||||
lua_register( L, "l2c_moveTo", l2c_moveTo );
|
||||
lua_register( L, "l2c_moveToDelta", l2c_moveToDelta );
|
||||
lua_register( L, "l2c_getSitRun", l2c_getSitRun );
|
||||
lua_register( L, "l2c_sitStand", l2c_sitStand );
|
||||
lua_register( L, "l2c_runWalk", l2c_runWalk );
|
||||
// Target,Attack
|
||||
lua_register( L, "l2c_action", l2c_action );
|
||||
lua_register( L, "l2c_attack", l2c_attack );
|
||||
lua_register( L, "l2c_targetByName", l2c_targetByName );
|
||||
lua_register( L, "l2c_targetCancel", l2c_targetCancel );
|
||||
lua_register( L, "l2c_getTarget", l2c_getTarget );
|
||||
// Items
|
||||
lua_register( L, "l2c_autoSoulshot", l2c_autoSoulshot );
|
||||
lua_register( L, "l2c_getItemCount", l2c_getItemCount );
|
||||
lua_register( L, "l2c_useItem", l2c_useItem );
|
||||
lua_register( L, "l2c_useItemByObjectId", l2c_useItemByObjectId );
|
||||
lua_register( L, "l2c_getPaperdollItem", l2c_getPaperdollItem );
|
||||
// Skills
|
||||
lua_register( L, "l2c_useSkill", l2c_useSkill );
|
||||
lua_register( L, "l2c_getSkillLevel", l2c_getSkillLevel );
|
||||
lua_register( L, "l2c_getSkillReuseLeft", l2c_getSkillReuseLeft );
|
||||
lua_register( L, "l2c_isCastingNow", l2c_isCastingNow );
|
||||
// Buffs
|
||||
lua_register( L, "l2c_getBuffs", l2c_getBuffs );
|
||||
lua_register( L, "l2c_buffCancel", l2c_buffCancel );
|
||||
// world information
|
||||
lua_register( L, "l2c_getVisibleChars", l2c_getVisibleChars );
|
||||
lua_register( L, "l2c_getVisibleMobs", l2c_getVisibleMobs );
|
||||
lua_register( L, "l2c_getVisibleNpcs", l2c_getVisibleNpcs );
|
||||
lua_register( L, "l2c_getVisibleItems", l2c_getVisibleItems );
|
||||
// individual world object information, based on objectID
|
||||
lua_register( L, "l2c_getCharObjectIdByName", l2c_getCharObjectIdByName );
|
||||
lua_register( L, "l2c_getNpcObjectIdByName", l2c_getNpcObjectIdByName );
|
||||
lua_register( L, "l2c_getObjectInfoByObjectId", l2c_getObjectInfoByObjectId );
|
||||
lua_register( L, "l2c_isCharDead", l2c_isCharDead );
|
||||
// Party info
|
||||
lua_register( L, "l2c_getParty", l2c_getParty );
|
||||
lua_register( L, "l2c_getPartyMemberBuffs", l2c_getPartyMemberBuffs );
|
||||
lua_register( L, "l2c_partySendInvite", l2c_partySendInvite );
|
||||
lua_register( L, "l2c_partyLeave", l2c_partyLeave );
|
||||
lua_register( L, "l2c_partyKickMember", l2c_partyKickMember );
|
||||
lua_register( L, "l2c_partyChangeLeader", l2c_partyChangeLeader );
|
||||
// bot config, not works here, just null-functions
|
||||
lua_register( L, "l2c_isCombatEnabled", l2c_isCombatEnabled );
|
||||
lua_register( L, "l2c_combatEnable", l2c_combatEnable );
|
||||
lua_register( L, "l2ccfg_getInt", l2ccfg_getInt );
|
||||
lua_register( L, "l2ccfg_setInt", l2ccfg_setInt );
|
||||
lua_register( L, "l2ccfg_getStr", l2ccfg_getStr );
|
||||
lua_register( L, "l2ccfg_setStr", l2ccfg_setStr );
|
||||
lua_register( L, "l2ccfg_getAllConfig", l2ccfg_getAllConfig );
|
||||
// hack packet send func
|
||||
lua_register( L, "l2c_sendPacketHex", l2c_sendPacketHex );
|
||||
}
|
||||
|
||||
81
l2detect/se_funcs/SE_funcs.h
Normal file
81
l2detect/se_funcs/SE_funcs.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
// called by ScriptEngine on init()
|
||||
void SE_funcs_register( lua_State *L );
|
||||
|
||||
// "system" functions
|
||||
int sys_should_exit( lua_State *L );
|
||||
int sys_register_onChat( lua_State *L );
|
||||
//
|
||||
int l2h_print( lua_State *L );
|
||||
int l2h_console_enable( lua_State *L );
|
||||
int l2h_delay( lua_State *L );
|
||||
int l2h_soundAlert( lua_State *L );
|
||||
int l2h_time( lua_State *L );
|
||||
int l2h_timeMsec( lua_State *L );
|
||||
|
||||
// User info
|
||||
int l2c_is_INGAME( lua_State *L );
|
||||
int l2c_getHPMPCPWeight( lua_State *L );
|
||||
int l2c_getStats( lua_State *L );
|
||||
// Chatting
|
||||
int l2c_say( lua_State *L );
|
||||
int l2c_sayPm( lua_State *L );
|
||||
int l2c_npcDlg( lua_State *L );
|
||||
int l2c_npcDlgClear( lua_State *L );
|
||||
int l2c_npcDlgExists( lua_State *L );
|
||||
// Moving
|
||||
int l2c_getPos( lua_State *L );
|
||||
int l2c_moveTo( lua_State *L );
|
||||
int l2c_moveToDelta( lua_State *L );
|
||||
int l2c_getSitRun( lua_State *L );
|
||||
int l2c_sitStand( lua_State *L );
|
||||
int l2c_runWalk( lua_State *L );
|
||||
// Target,Attack
|
||||
int l2c_action( lua_State *L );
|
||||
int l2c_attack( lua_State *L );
|
||||
int l2c_targetByName( lua_State *L );
|
||||
int l2c_targetCancel( lua_State *L );
|
||||
int l2c_getTarget( lua_State *L );
|
||||
// Items
|
||||
int l2c_autoSoulshot( lua_State *L );
|
||||
int l2c_getItemCount( lua_State *L );
|
||||
int l2c_useItem( lua_State *L );
|
||||
int l2c_useItemByObjectId( lua_State *L );
|
||||
int l2c_getPaperdollItem( lua_State *L );
|
||||
// Skills
|
||||
int l2c_useSkill( lua_State *L );
|
||||
int l2c_getSkillLevel( lua_State *L );
|
||||
int l2c_getSkillReuseLeft( lua_State *L );
|
||||
int l2c_isCastingNow( lua_State *L );
|
||||
// Buffs
|
||||
int l2c_getBuffs( lua_State *L );
|
||||
int l2c_buffCancel( lua_State *L );
|
||||
// world information
|
||||
int l2c_getVisibleChars( lua_State *L );
|
||||
int l2c_getVisibleMobs( lua_State *L );
|
||||
int l2c_getVisibleNpcs( lua_State *L );
|
||||
int l2c_getVisibleItems( lua_State *L );
|
||||
// individual world object information, based on objectID
|
||||
int l2c_getCharObjectIdByName( lua_State *L );
|
||||
int l2c_getNpcObjectIdByName( lua_State *L );
|
||||
int l2c_getObjectInfoByObjectId( lua_State *L );
|
||||
int l2c_isCharDead( lua_State *L );
|
||||
// Party info
|
||||
int l2c_getParty( lua_State *L );
|
||||
int l2c_getPartyMemberBuffs( lua_State *L );
|
||||
int l2c_partySendInvite( lua_State *L );
|
||||
int l2c_partyLeave( lua_State *L );
|
||||
int l2c_partyKickMember( lua_State *L );
|
||||
int l2c_partyChangeLeader( lua_State *L );
|
||||
// bot config, not works here, just null-functions
|
||||
int l2c_isCombatEnabled( lua_State *L );
|
||||
int l2c_combatEnable( lua_State *L );
|
||||
int l2ccfg_getInt( lua_State *L );
|
||||
int l2ccfg_setInt( lua_State *L );
|
||||
int l2ccfg_getStr( lua_State *L );
|
||||
int l2ccfg_setStr( lua_State *L );
|
||||
int l2ccfg_getAllConfig( lua_State *L );
|
||||
// hack packet send func
|
||||
int l2c_sendPacketHex( lua_State *L );
|
||||
|
||||
83
l2detect/se_funcs/sef_buffs.cpp
Normal file
83
l2detect/se_funcs/sef_buffs.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
extern class GameClient *g_game_client;
|
||||
#include "../PacketInjector.h"
|
||||
|
||||
int l2c_getBuffs( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
UserBuffs *b = &(g_game_client->ai.buffs);
|
||||
int i;
|
||||
lua_createtable( L, 0, 0 );
|
||||
int tableIndex = 1;
|
||||
// usual buffs
|
||||
for( i=0; i<b->USER_MAX_BUFFS; i++ )
|
||||
{
|
||||
if( b->buff[i].skillID == 0 ) continue;
|
||||
lua_pushnumber( L, tableIndex );
|
||||
//
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "skillID" );
|
||||
lua_pushnumber( L, b->buff[i].skillID );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "skillLvl" );
|
||||
lua_pushnumber( L, b->buff[i].skillLvl );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "durationSecs" );
|
||||
lua_pushnumber( L, b->buff[i].duration );
|
||||
lua_settable( L, -3 );
|
||||
// skill name
|
||||
char skillName[256] = {0};
|
||||
L2Data_DB_GetSkillNameByID( b->buff[i].skillID, skillName );
|
||||
lua_pushstring( L, "skillName" );
|
||||
lua_pushstring( L, skillName );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
tableIndex++;
|
||||
}
|
||||
// short buffs
|
||||
for( i=0; i<b->USER_MAX_SHORT_BUFFS; i++ )
|
||||
{
|
||||
if( b->short_buff[i].skillID == 0 ) continue;
|
||||
lua_pushnumber( L, tableIndex );
|
||||
//
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "skillID" );
|
||||
lua_pushnumber( L, b->short_buff[i].skillID );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "skillLvl" );
|
||||
lua_pushnumber( L, b->short_buff[i].skillLvl );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "durationSecs" );
|
||||
lua_pushnumber( L, b->short_buff[i].duration );
|
||||
lua_settable( L, -3 );
|
||||
// skill name
|
||||
char skillName[256] = {0};
|
||||
L2Data_DB_GetSkillNameByID( b->short_buff[i].skillID, skillName );
|
||||
lua_pushstring( L, "skillName" );
|
||||
lua_pushstring( L, skillName );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
tableIndex++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2c_buffCancel( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
unsigned int skillID = (unsigned int)lua_tonumber( L, 1 );
|
||||
PGen_RequestDispel( skillID );
|
||||
return 0;
|
||||
}
|
||||
140
l2detect/se_funcs/sef_chat.cpp
Normal file
140
l2detect/se_funcs/sef_chat.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
extern class GameClient *g_game_client;
|
||||
#include "../PacketInjector.h"
|
||||
|
||||
int l2c_say( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs == 0 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
size_t len = 0;
|
||||
double dchannel = lua_tonumber( L, 1 );
|
||||
unsigned int ichannel = (unsigned int)dchannel;
|
||||
const char *mes = luaL_checklstring( L, 2, &len );
|
||||
wchar_t *text = (wchar_t *)malloc( len*2 + 2 );
|
||||
if( text )
|
||||
{
|
||||
memset( text, 0, len*2+2 );
|
||||
MultiByteToWideChar( CP_ACP, 0, mes, -1, text, len );
|
||||
PGen_Say2C( ichannel, text, NULL );
|
||||
free( text );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_sayPm( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 2 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
size_t lenmes = 0;
|
||||
size_t lento = 0;
|
||||
const char *mes = luaL_checklstring( L, 1, &lenmes );
|
||||
const char *to = luaL_checklstring( L, 2, &lento );
|
||||
wchar_t *text = (wchar_t *)malloc( lenmes*2 + 2 );
|
||||
if( text )
|
||||
{
|
||||
wchar_t tto[64] = {0};
|
||||
memset( text, 0, lenmes*2+2 );
|
||||
memset( tto, 0, sizeof(tto) );
|
||||
MultiByteToWideChar( CP_ACP, 0, mes, -1, text, lenmes );
|
||||
MultiByteToWideChar( CP_ACP, 0, to, -1, tto, 63 );
|
||||
tto[63] = 0;
|
||||
PGen_Say2C( 2, text, tto ); // public final static int TELL = 2;
|
||||
free( text );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// l2c_npcDlg( string bypassActionName )
|
||||
int l2c_npcDlg( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
const char *abypass = lua_tolstring( L, 1, NULL );
|
||||
if( !abypass ) return 0;
|
||||
wchar_t bypass[256] = {0};
|
||||
MultiByteToWideChar( CP_ACP, 0, abypass, -1, bypass, 255 );
|
||||
if( bypass[0] == 0 ) return 0;
|
||||
//
|
||||
unsigned int last_npc_html_oid = 0;
|
||||
wchar_t *last_html = NULL;
|
||||
last_html = g_game_client->ai.get_last_NPC_HTML( &last_npc_html_oid );
|
||||
if( !last_html ) return 0;
|
||||
//
|
||||
wchar_t strtofind[512] = {0};
|
||||
swprintf( strtofind, 511, L">%s</a>", bypass );
|
||||
//log_error_np( LOG_OK, "NPCDLG: to find: [%S]\n", strtofind );
|
||||
wchar_t *ps = wcsstr( last_html, strtofind );
|
||||
if( !ps )
|
||||
{
|
||||
char areq[256] = {0};
|
||||
WideCharToMultiByte( CP_ACP, 0, bypass, -1, areq, 255, NULL, NULL );
|
||||
log_error( LOG_ERROR, "l2c_npcDlg(): not found requested NPCDLG [%s]\n", areq );
|
||||
return 0;
|
||||
}
|
||||
while( (ps > last_html) && ((*ps) != L'<') ) ps--;
|
||||
if( ps == last_html )
|
||||
{
|
||||
log_error( LOG_ERROR, "l2c_npcDlg(): not found bypass link to requested NPCDLG\n" );
|
||||
return 0;
|
||||
}
|
||||
//log_error_np( LOG_OK, "NPCDLG: found: [%S]\n", ps );
|
||||
wchar_t bypassStr[256];
|
||||
wchar_t *pbypassStr = bypassStr;
|
||||
(*pbypassStr) = 0;
|
||||
// now find first occurence of "
|
||||
while( (*ps) != L'\"' ) ps++;
|
||||
ps++;
|
||||
// now copy till second "
|
||||
while( (*ps) != L'\"' )
|
||||
{
|
||||
(*pbypassStr) = (*ps);
|
||||
ps++;
|
||||
pbypassStr++;
|
||||
(*pbypassStr) = 0;
|
||||
}
|
||||
log_error_np( LOG_OK, "l2c_npcDlg(): got bypassStr [%S]\n", bypassStr );
|
||||
if( wcsstr( bypassStr, L"bypass -h " ) == bypassStr )
|
||||
{
|
||||
PGen_RequestBypassToserver( bypassStr + 10 /*wcslen( L"bypass -h " )*/ );
|
||||
}
|
||||
else if( wcsstr( bypassStr, L"link " ) == bypassStr )
|
||||
{
|
||||
PGen_RequestLinkHtml( bypassStr + 5 /*wcslen( L"link " )*/ );
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error( LOG_WARNING, "l2c_npcDlg(): bypassStr must start with \"bypass -h \"!\n" );
|
||||
}
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
// l2c_npcDlgClear()
|
||||
int l2c_npcDlgClear( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER( L );
|
||||
if( !g_game_client ) return 0;
|
||||
g_game_client->ai.clear_last_NPC_HTML();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// bool l2c_npcDlgExists()
|
||||
int l2c_npcDlgExists( lua_State *L )
|
||||
{
|
||||
if( !g_game_client )
|
||||
{
|
||||
lua_pushboolean( L, 0 );
|
||||
return 0;
|
||||
}
|
||||
wchar_t *html = g_game_client->ai.get_last_NPC_HTML( NULL );
|
||||
lua_pushboolean( L, html ? 1 : 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
73
l2detect/se_funcs/sef_items.cpp
Normal file
73
l2detect/se_funcs/sef_items.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
extern class GameClient *g_game_client;
|
||||
#include "../PacketInjector.h"
|
||||
|
||||
//l2c_autoSoulshot( int itemID, [boolean enable = true] )
|
||||
int l2c_autoSoulshot( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
unsigned int itemID = (unsigned int)lua_tonumber( L, 1 );
|
||||
bool bEnable = true;
|
||||
if( nArgs >= 2 ) bEnable = lua_toboolean( L, 2 ) ? true : false;
|
||||
PGen_RequestAutoSoulshot( itemID, bEnable );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int l2c_getItemCount( int itemID )
|
||||
int l2c_getItemCount( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 )
|
||||
{
|
||||
lua_pushnumber( L, 0 );
|
||||
return 1;
|
||||
}
|
||||
unsigned int itemID = (unsigned int)lua_tonumber( L, 1 );
|
||||
UserInventoryItem it;
|
||||
g_game_client->ai.inv.getItemInfoByItemId( itemID, it );
|
||||
lua_Number cnt = (lua_Number)it.count;
|
||||
lua_pushnumber( L, cnt );
|
||||
return 1;
|
||||
}
|
||||
|
||||
// l2c_useItem( int itemID )
|
||||
int l2c_useItem( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
if( lua_gettop( L ) < 1 ) return 0;
|
||||
UserInventoryItem it;
|
||||
unsigned int itemID = (unsigned int)lua_tonumber( L, 1 );
|
||||
g_game_client->ai.inv.getItemInfoByItemId( itemID, it );
|
||||
if( it.objectID > 0 && it.count > 0 )
|
||||
PGen_UseItem( it.objectID );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// l2c_useItemByObjectId( int objectID )
|
||||
int l2c_useItemByObjectId( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
if( lua_gettop( L ) < 1 ) return 0;
|
||||
PGen_UseItem( (unsigned int)lua_tonumber( L, 1 ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int, int l2c_getPaperdollItem( int slot )
|
||||
int l2c_getPaperdollItem( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
unsigned int slot = (unsigned int)lua_tonumber( L, 1 );
|
||||
UserState *pusr = &(g_game_client->ai.usr);
|
||||
lua_pushnumber( L, pusr->paperdoll_iid[ slot ] );
|
||||
lua_pushnumber( L, pusr->paperdoll_oid[ slot ] );
|
||||
return 2;
|
||||
}
|
||||
74
l2detect/se_funcs/sef_misc.cpp
Normal file
74
l2detect/se_funcs/sef_misc.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
#include "../PacketInjector.h"
|
||||
extern class GameClient *g_game_client;
|
||||
|
||||
// bool l2c_isCombatEnabled()
|
||||
// here always returns true
|
||||
int l2c_isCombatEnabled( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
lua_pushboolean( L, 1 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
// l2c_combatEnable( bool bEnable = true )
|
||||
int l2c_combatEnable( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int l2ccfg_getInt( string varName )
|
||||
int l2ccfg_getInt( lua_State *L )
|
||||
{
|
||||
lua_pushnumber( L, 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
// int l2ccfg_setInt( string varName, int val )
|
||||
int l2ccfg_setInt( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// string l2ccfg_getStr( string varName )
|
||||
int l2ccfg_getStr( lua_State *L )
|
||||
{
|
||||
lua_pushstring( L, "" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
// int l2ccfg_setStr( string varName, string val )
|
||||
int l2ccfg_setStr( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// table l2ccfg_getAllConfig()
|
||||
int l2ccfg_getAllConfig( lua_State *L )
|
||||
{
|
||||
//int tableIndex = 1;
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// l2c_sendPacketHex( string packetHex )
|
||||
int l2c_sendPacketHex( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
const char *hex = lua_tolstring( L, 1, NULL );
|
||||
if( !hex ) return 0;
|
||||
PGen_send_hackPacketHex_toServer( hex );
|
||||
return 0;
|
||||
}
|
||||
|
||||
92
l2detect/se_funcs/sef_move.cpp
Normal file
92
l2detect/se_funcs/sef_move.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
#include "../PacketInjector.h"
|
||||
extern class GameClient *g_game_client;
|
||||
|
||||
int l2c_getPos( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs != 0 )
|
||||
{
|
||||
lua_pushnumber( L, 0 );
|
||||
lua_pushnumber( L, 0 );
|
||||
lua_pushnumber( L, 0 );
|
||||
return 3;
|
||||
}
|
||||
if( !g_game_client )
|
||||
{
|
||||
lua_pushnumber( L, 0 );
|
||||
lua_pushnumber( L, 0 );
|
||||
lua_pushnumber( L, 0 );
|
||||
return 3;
|
||||
}
|
||||
UserState *usr = &(g_game_client->ai.usr);
|
||||
lua_pushnumber( L, usr->x );
|
||||
lua_pushnumber( L, usr->y );
|
||||
lua_pushnumber( L, usr->z );
|
||||
return 3;
|
||||
}
|
||||
|
||||
int l2c_moveTo( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 2 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
int x = (int)lua_tonumber( L, 1 );
|
||||
int y = (int)lua_tonumber( L, 2 );
|
||||
int z = g_game_client->ai.usr.z;
|
||||
if( nArgs == 3 ) z = (int)lua_tonumber( L, 3 );
|
||||
PGen_MoveBackwardToLocation( x, y, z, g_game_client->ai.usr.x, g_game_client->ai.usr.y, g_game_client->ai.usr.z );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_moveToDelta( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 2 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
int x = (int)lua_tonumber( L, 1 );
|
||||
int y = (int)lua_tonumber( L, 2 );
|
||||
int z = 0;
|
||||
if( nArgs == 3 ) z = (int)lua_tonumber( L, 3 );
|
||||
PGen_MoveBackwardToLocation(
|
||||
g_game_client->ai.usr.x + x,
|
||||
g_game_client->ai.usr.y + y,
|
||||
g_game_client->ai.usr.z + z,
|
||||
g_game_client->ai.usr.x,
|
||||
g_game_client->ai.usr.y,
|
||||
g_game_client->ai.usr.z );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_getSitRun( lua_State *L )
|
||||
{
|
||||
if( !g_game_client )
|
||||
{
|
||||
lua_pushboolean( L, 0 );
|
||||
lua_pushboolean( L, 1 );
|
||||
return 2;
|
||||
}
|
||||
lua_pushboolean( L, g_game_client->ai.usr.isSitting );
|
||||
lua_pushboolean( L, g_game_client->ai.usr.isRunning );
|
||||
return 2;
|
||||
}
|
||||
|
||||
int l2c_sitStand( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
if( !g_game_client ) return 0;
|
||||
PGen_RequestActionUse( 0, false, false ); // actionId 0: sit/stand
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_runWalk( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
if( !g_game_client ) return 0;
|
||||
PGen_RequestActionUse( 1, false, false ); // actionId 1: run/walk
|
||||
return 0;
|
||||
}
|
||||
255
l2detect/se_funcs/sef_party.cpp
Normal file
255
l2detect/se_funcs/sef_party.cpp
Normal file
@@ -0,0 +1,255 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
#include "../PacketInjector.h"
|
||||
extern class GameClient *g_game_client;
|
||||
|
||||
// table l2c_getParty()
|
||||
int l2c_getParty( lua_State *L )
|
||||
{
|
||||
if( !g_game_client )
|
||||
{
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
UserParty *pty = &g_game_client->ai.party;
|
||||
if( !pty )
|
||||
{
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
pty->Lock(); // really?
|
||||
int cnt = pty->getCount();
|
||||
int i;
|
||||
lua_createtable( L, 0, 0 );
|
||||
int tableIndex = 1;
|
||||
char aname[256] = {0};
|
||||
for( i=0; i<cnt; i++ )
|
||||
{
|
||||
L2Player *pl = pty->getPartyPlayer( i );
|
||||
if( !pl ) continue;
|
||||
//
|
||||
lua_pushnumber( L, tableIndex );
|
||||
//
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "objectID" );
|
||||
lua_pushnumber( L, pl->objectID );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "name" );
|
||||
sprintf( aname, "%S", pl->charName );
|
||||
lua_pushstring( L, aname );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "level" );
|
||||
lua_pushnumber( L, pl->level );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "curHp" );
|
||||
lua_pushnumber( L, pl->curHp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "maxHp" );
|
||||
lua_pushnumber( L, pl->maxHp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "curMp" );
|
||||
lua_pushnumber( L, pl->curMp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "maxMp" );
|
||||
lua_pushnumber( L, pl->maxMp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "curCp" );
|
||||
lua_pushnumber( L, pl->curCp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "maxCp" );
|
||||
lua_pushnumber( L, pl->maxCp );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "classID" );
|
||||
lua_pushnumber( L, pl->classID );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "targetObjectID" );
|
||||
lua_pushnumber( L, pl->targetObjectID );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_settable( L, -3 );
|
||||
tableIndex++;
|
||||
}
|
||||
pty->Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// table l2c_getPartyMemberBuffs( int objectID )
|
||||
int l2c_getPartyMemberBuffs( lua_State *L )
|
||||
{
|
||||
if( !g_game_client )
|
||||
{
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 )
|
||||
{
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
unsigned int objectID = (unsigned int)lua_tonumber( L, 1 );
|
||||
if( objectID == 0 )
|
||||
{
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
UserParty *pty = &g_game_client->ai.party;
|
||||
if( !pty )
|
||||
{
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
if( pty->getCount() < 1 )
|
||||
{
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
int idx = -1;
|
||||
pty->Lock();
|
||||
if( !pty->isInParty( objectID, &idx ) )
|
||||
{
|
||||
pty->Unlock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
if( idx == -1 )
|
||||
{
|
||||
pty->Unlock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
UserBuffs *buffs = pty->getPartyPlayerBuffs( idx );
|
||||
if( !buffs )
|
||||
{
|
||||
pty->Unlock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
return 1;
|
||||
}
|
||||
// at last, we can push buffs :)
|
||||
lua_createtable( L, 0, 0 );
|
||||
int tableIndex = 1;
|
||||
int i = 0;
|
||||
for( i=0; i<UserBuffs::USER_MAX_BUFFS; i++ )
|
||||
{
|
||||
if( buffs->buff[i].skillID == 0 ) continue;
|
||||
//
|
||||
lua_pushnumber( L, tableIndex );
|
||||
//
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "skillID" );
|
||||
lua_pushnumber( L, buffs->buff[i].skillID );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "skillLvl" );
|
||||
lua_pushnumber( L, buffs->buff[i].skillLvl );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "durationSecs" );
|
||||
lua_pushnumber( L, buffs->buff[i].duration );
|
||||
lua_settable( L, -3 );
|
||||
// skill name
|
||||
char skillName[256] = {0};
|
||||
L2Data_DB_GetSkillNameByID( buffs->buff[i].skillID, skillName );
|
||||
lua_pushstring( L, "skillName" );
|
||||
lua_pushstring( L, skillName );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
tableIndex++;
|
||||
}
|
||||
for( i=0; i<UserBuffs::USER_MAX_SHORT_BUFFS; i++ )
|
||||
{
|
||||
if( buffs->short_buff[i].skillID == 0 ) continue;
|
||||
//
|
||||
lua_pushnumber( L, tableIndex );
|
||||
//
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "skillID" );
|
||||
lua_pushnumber( L, buffs->short_buff[i].skillID );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "skillLvl" );
|
||||
lua_pushnumber( L, buffs->short_buff[i].skillLvl );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "durationSecs" );
|
||||
lua_pushnumber( L, buffs->short_buff[i].duration );
|
||||
lua_settable( L, -3 );
|
||||
// skill name
|
||||
char skillName[256] = {0};
|
||||
L2Data_DB_GetSkillNameByID( buffs->buff[i].skillID, skillName );
|
||||
lua_pushstring( L, "skillName" );
|
||||
lua_pushstring( L, skillName );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
tableIndex++;
|
||||
}
|
||||
//
|
||||
pty->Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// l2c_partySendInvite( string name, int loot )
|
||||
int l2c_partySendInvite( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 2 ) return 0;
|
||||
const char *aname = lua_tolstring( L, 1, NULL );
|
||||
int loot = (int)lua_tonumber( L, 2 );
|
||||
wchar_t name[256] = {0};
|
||||
MultiByteToWideChar( CP_ACP, 0, aname, -1, name, 255 );
|
||||
PGen_RequestJoinParty( name, (unsigned int)loot );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// l2c_partyLeave()
|
||||
int l2c_partyLeave( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
if( !g_game_client ) return 0;
|
||||
UserParty *pty = &g_game_client->ai.party;
|
||||
if( pty->getCount() < 1 ) return 0; // no party?
|
||||
PGen_RequestWithdrawalParty(); // ok, leave party
|
||||
return 0;
|
||||
}
|
||||
|
||||
// l2c_partyKickMember( string name )
|
||||
int l2c_partyKickMember( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
UserParty *pty = &g_game_client->ai.party;
|
||||
if( pty->getCount() < 1 ) return 0; // no party?
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
const char *aname = lua_tolstring( L, 1, NULL );
|
||||
wchar_t name[256] = {0};
|
||||
MultiByteToWideChar( CP_ACP, 0, aname, -1, name, 255 );
|
||||
PGen_RequestOustPartyMember( name );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// l2c_partyChangeLeader( string name )
|
||||
int l2c_partyChangeLeader( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
UserParty *pty = &g_game_client->ai.party;
|
||||
if( pty->getCount() < 1 ) return 0; // no party?
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
const char *aname = lua_tolstring( L, 1, NULL );
|
||||
wchar_t name[256] = {0};
|
||||
MultiByteToWideChar( CP_ACP, 0, aname, -1, name, 255 );
|
||||
PGen_RequestChangePartyLeader( name );
|
||||
return 0;
|
||||
}
|
||||
56
l2detect/se_funcs/sef_skills.cpp
Normal file
56
l2detect/se_funcs/sef_skills.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
#include "../PacketInjector.h"
|
||||
extern class GameClient *g_game_client;
|
||||
|
||||
// l2c_useSkill( int skillID, [bool force = false] )
|
||||
int l2c_useSkill( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
unsigned int skillID = (unsigned int)lua_tonumber( L, 1 );
|
||||
unsigned int force = 0;
|
||||
if( nArgs >= 2 ) force = lua_toboolean( L, 2 );
|
||||
PGen_RequestMagicSkillUse( skillID, force, 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int l2c_getSkillLevel( int skillID )
|
||||
int l2c_getSkillLevel( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) { lua_pushnumber( L, 0 ); return 1; }
|
||||
if( lua_gettop( L ) < 1 ) { lua_pushnumber( L, 0 ); return 1; }
|
||||
unsigned int skillID = (unsigned int)lua_tonumber( L, 1 );
|
||||
UserSkill skill;
|
||||
g_game_client->ai.skills.getSkillInfoBySkillId( skillID, &skill );
|
||||
lua_pushnumber( L, (lua_Number)(skill.level) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
// int l2c_getSkillReuseLeft( int skillID )
|
||||
int l2c_getSkillReuseLeft( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) { lua_pushnumber( L, 0 ); return 1; }
|
||||
if( lua_gettop( L ) < 1 ) { lua_pushnumber( L, 0 ); return 1; }
|
||||
unsigned int skillID = (unsigned int)lua_tonumber( L, 1 );
|
||||
UserSkills *sk = &(g_game_client->ai.skills);
|
||||
UserSkill skill;
|
||||
sk->getSkillInfoBySkillId( skillID, &skill );
|
||||
lua_pushnumber( L, (lua_Number)skill.coolTimeRemaining );
|
||||
return 1;
|
||||
}
|
||||
|
||||
// boolean l2c_isCastingNow()
|
||||
int l2c_isCastingNow( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) { lua_pushboolean( L, 0 ); return 1; }
|
||||
UserSkills *sk = &(g_game_client->ai.skills);
|
||||
int b = 0;
|
||||
if( sk->isCasting() ) b = 1;
|
||||
lua_pushboolean( L, b );
|
||||
return 1;
|
||||
}
|
||||
139
l2detect/se_funcs/sef_sys.cpp
Normal file
139
l2detect/se_funcs/sef_sys.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
|
||||
// "system" functions
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int sys_should_exit( lua_State *L )
|
||||
{
|
||||
ScriptEngine *se = ScriptEngine::getInstance();
|
||||
if( !se )
|
||||
{
|
||||
log_error( LOG_ERROR, "sys_should_exit(): ScriptEngine ptr == NULL!\n" );
|
||||
lua_pushboolean( L, 1 );
|
||||
return 1;
|
||||
}
|
||||
if( se->should_stop ) lua_pushboolean( L, 1 );
|
||||
else lua_pushboolean( L, 0 );
|
||||
return 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
// sys_register_onChat( function_name )
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> function_name <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Lua
|
||||
// function onChat( senderObjectID, chatChannelID, chatText, senderName )
|
||||
int sys_register_onChat( lua_State *L )
|
||||
{
|
||||
ScriptEngine *se = ScriptEngine::getInstance();
|
||||
if( se == NULL )
|
||||
{
|
||||
log_error( LOG_ERROR, "sys_register_onChat(): ptr to ScriptEngine == NULL!\n" );
|
||||
return 0;
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Lua <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sys_register_onChat <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
const char *funcName = lua_tolstring( L, 1, NULL );
|
||||
// funcName <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> NULL, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
se->set_onChat_handler( funcName );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> (<28> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int l2h_print( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs > 0 )
|
||||
{
|
||||
int i;
|
||||
for( i=1; i<=nArgs; i++ )
|
||||
{
|
||||
int typ = lua_type( L, i );
|
||||
switch( typ )
|
||||
{
|
||||
case LUA_TNIL: log_error_np( LOG_OK, "NULL" ); break;
|
||||
case LUA_TNUMBER:
|
||||
{
|
||||
double d = lua_tonumber( L, i );
|
||||
double floor_d = floor( d * 100 ); // 10012.00
|
||||
__int64 int_d = (__int64)floor_d; // 10012
|
||||
__int64 eds_cnt = int_d % 100; // 12
|
||||
if( eds_cnt ) log_error_np( LOG_OK, "%0.2f", d ); // original double
|
||||
else log_error_np( LOG_OK, "%I64d", int_d/100 ); // rounded integer
|
||||
} break;
|
||||
case LUA_TBOOLEAN:
|
||||
{
|
||||
lua_toboolean( L, i ) ? log_error_np( LOG_OK, "true" ) : log_error_np( LOG_OK, "false" );
|
||||
} break;
|
||||
case LUA_TSTRING: log_error_np( LOG_OK, "%s", lua_tostring( L, i ) ); break;
|
||||
case LUA_TTABLE: { log_error_np( LOG_OK, "(table)" ); /*lua_pop( L, i );*/ } break;
|
||||
case LUA_TFUNCTION: { log_error_np( LOG_OK, "(function)" ); /*lua_pop( L, i );*/ } break;
|
||||
default: lua_pop( L, i ); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2h_console_enable( lua_State *L )
|
||||
{
|
||||
int n = lua_gettop( L ); // number of arguments
|
||||
if( n > 0 )
|
||||
{
|
||||
if( lua_type( L, 1 ) == LUA_TBOOLEAN )
|
||||
{
|
||||
int enable = lua_toboolean( L, 1 );
|
||||
ErrorLogger_EnableLoggingToConsole( enable ? true : false );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2h_delay( lua_State *L )
|
||||
{
|
||||
int n = lua_gettop( L ); // number of arguments
|
||||
//log_error_np( LOG_OK, "delay_lua: %d args\n", n );
|
||||
if( n >= 1 )
|
||||
{
|
||||
if( lua_type( L, 1 ) == LUA_TNUMBER )
|
||||
{
|
||||
int msec = (int)lua_tonumber( L, 1 );
|
||||
//log_error_np( LOG_OK, "delay_lua( %d );\n", msec );
|
||||
Sleep( (DWORD)msec );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2h_soundAlert( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
TCHAR fileName[256] = {0};
|
||||
if( nArgs == 0 )
|
||||
{
|
||||
GetWindowsDirectory( fileName, 255 );
|
||||
_tcscat( fileName, _T("\\Media\\ringin.wav") );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *astr = lua_tolstring( L, 1, NULL );
|
||||
MultiByteToWideChar( CP_ACP, 0, astr, -1, fileName, 255 );
|
||||
}
|
||||
PlaySound( fileName, NULL, SND_FILENAME|SND_ASYNC );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2h_time( lua_State *L )
|
||||
{
|
||||
unsigned int secs = (unsigned int)time( NULL );
|
||||
lua_pushnumber( L, secs );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2h_timeMsec( lua_State *L )
|
||||
{
|
||||
unsigned int msecs = GetTickCount();
|
||||
lua_pushnumber( L, msecs );
|
||||
return 1;
|
||||
}
|
||||
114
l2detect/se_funcs/sef_targ.cpp
Normal file
114
l2detect/se_funcs/sef_targ.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
#include "../PacketInjector.h"
|
||||
extern class GameClient *g_game_client;
|
||||
|
||||
int l2c_action( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
unsigned int objectID = (unsigned int)lua_tonumber( L, 1 );
|
||||
PGen_Action( objectID, g_game_client->ai.usr.x, g_game_client->ai.usr.y, g_game_client->ai.usr.z, 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_attack( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
if( !g_game_client ) return 0;
|
||||
if( g_game_client->ai.usr.targetObjectID == 0 ) return 0;
|
||||
PGen_AttackRequest(
|
||||
g_game_client->ai.usr.targetObjectID,
|
||||
g_game_client->ai.usr.x,
|
||||
g_game_client->ai.usr.y,
|
||||
g_game_client->ai.usr.z, 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_targetByName( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) return 0;
|
||||
if( !g_game_client ) return 0;
|
||||
const char *aname = lua_tolstring( L, 1, NULL );
|
||||
wchar_t name[256];
|
||||
memset( name, 0, sizeof(name) );
|
||||
MultiByteToWideChar( CP_ACP, 0, aname, -1, name, 255 );
|
||||
UserState *usr = &(g_game_client->ai.usr);
|
||||
unsigned int nPassed = 0, i = 0, count = CharArray_GetCount();
|
||||
unsigned int objectID = 0;
|
||||
if( _wcsicmp( name, usr->charName ) == 0 )
|
||||
{
|
||||
objectID = usr->objectID;
|
||||
}
|
||||
if( objectID == 0 )
|
||||
{
|
||||
// try chars
|
||||
count = CharArray_GetCount();
|
||||
nPassed = 0;
|
||||
if( count > 0 )
|
||||
{
|
||||
CharArray_Lock();
|
||||
for( i=0; i<CHARARRAY_MAX_CHARS; i++ )
|
||||
{
|
||||
if( chars_array[i]->isUnused() ) continue;
|
||||
nPassed++;
|
||||
if( _wcsicmp( name, chars_array[i]->charName ) == 0 )
|
||||
{
|
||||
objectID = chars_array[i]->objectID;
|
||||
break;
|
||||
}
|
||||
if( nPassed >= count ) break;
|
||||
}
|
||||
CharArray_Unlock();
|
||||
}
|
||||
}
|
||||
if( objectID == 0 )
|
||||
{
|
||||
// try NPCs
|
||||
NpcArray_Lock();
|
||||
for( i=0; i<NPCA_MAX_NPCS; i++ )
|
||||
{
|
||||
if( npc_array[i]->isUnused() ) continue;
|
||||
if( _wcsicmp( name, npc_array[i]->charName ) == 0 )
|
||||
{
|
||||
objectID = npc_array[i]->objectID;
|
||||
break;
|
||||
}
|
||||
NpcArray_Unlock();
|
||||
}
|
||||
}
|
||||
if( objectID == 0 ) return 0; // name not found
|
||||
// check current target
|
||||
if( g_game_client->ai.usr.targetObjectID == objectID ) return 0; // already on target
|
||||
PGen_Action( objectID, g_game_client->ai.usr.x, g_game_client->ai.usr.y, g_game_client->ai.usr.z, 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_targetCancel( lua_State *L )
|
||||
{
|
||||
UNREFERENCED_PARAMETER(L);
|
||||
if( !g_game_client ) return 0;
|
||||
PGen_RequestTargetCanceld( false );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l2c_getTarget( lua_State *L )
|
||||
{
|
||||
if( !g_game_client )
|
||||
{
|
||||
lua_pushnumber( L, 0 );
|
||||
lua_pushnumber( L, 0 );
|
||||
lua_pushnumber( L, 0 );
|
||||
return 3;
|
||||
}
|
||||
UserState *pusr = &(g_game_client->ai.usr);
|
||||
lua_pushnumber( L, pusr->targetObjectID );
|
||||
lua_pushnumber( L, pusr->targetCurHP );
|
||||
lua_pushnumber( L, pusr->targetMaxHP );
|
||||
return 3;
|
||||
}
|
||||
61
l2detect/se_funcs/sef_userInfo.cpp
Normal file
61
l2detect/se_funcs/sef_userInfo.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
extern class GameClient *g_game_client;
|
||||
|
||||
int l2c_is_INGAME( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs != 0 || g_game_client==NULL ) { lua_pushboolean( L, 0 ); return 1; }
|
||||
int st = g_game_client->getState();
|
||||
if( st == GCST_IN_GAME ) lua_pushboolean( L, 1 ); else lua_pushboolean( L, 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2c_getHPMPCPWeight( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs != 0 ) { lua_pushnil( L ); return 1; }
|
||||
if( !g_game_client ) { lua_pushnil( L ); return 1; }
|
||||
UserState *usr = &(g_game_client->ai.usr);
|
||||
lua_pushnumber( L, usr->hp );
|
||||
lua_pushnumber( L, usr->hp_max );
|
||||
lua_pushnumber( L, usr->mp );
|
||||
lua_pushnumber( L, usr->mp_max );
|
||||
lua_pushnumber( L, usr->cp );
|
||||
lua_pushnumber( L, usr->cp_max );
|
||||
lua_pushnumber( L, usr->curLoad );
|
||||
lua_pushnumber( L, usr->maxLoad );
|
||||
return 8;
|
||||
}
|
||||
|
||||
int l2c_getStats( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) { lua_pushnil( L ); return 1; }
|
||||
UserState *usr = &(g_game_client->ai.usr);
|
||||
lua_createtable( L, 0, 0 );
|
||||
// name
|
||||
char aname[256] = {0};
|
||||
sprintf( aname, "%S", usr->charName );
|
||||
lua_pushstring( L, "name" );
|
||||
lua_pushstring( L, aname );
|
||||
lua_settable( L, -3 );
|
||||
// number stats:
|
||||
// pAtk, mAtk, pDef, mDef, pAtkSpd, mAtkSpd
|
||||
#define LUA_PUSHTABLEKEY( sKeyName, keyName ) lua_pushstring( L, sKeyName ); lua_pushnumber( L, usr->keyName ); lua_settable( L, -3 );
|
||||
LUA_PUSHTABLEKEY( "pAtk", pAtk )
|
||||
LUA_PUSHTABLEKEY( "pDef", pDef )
|
||||
LUA_PUSHTABLEKEY( "mAtk", mAtk )
|
||||
LUA_PUSHTABLEKEY( "mDef", mDef )
|
||||
LUA_PUSHTABLEKEY( "pAtkSpd", pAtkSpd )
|
||||
LUA_PUSHTABLEKEY( "mAtkSpd", mAtkSpd )
|
||||
// self objectID
|
||||
LUA_PUSHTABLEKEY( "objectID", objectID )
|
||||
LUA_PUSHTABLEKEY( "heading", heading )
|
||||
LUA_PUSHTABLEKEY( "karma", karma )
|
||||
#undef LUA_PUSHTABLEKEY
|
||||
//
|
||||
return 1;
|
||||
}
|
||||
383
l2detect/se_funcs/sef_world.cpp
Normal file
383
l2detect/se_funcs/sef_world.cpp
Normal file
@@ -0,0 +1,383 @@
|
||||
#include "stdafx.h"
|
||||
#include "../Logger.h"
|
||||
#include "../lua/lua.hpp"
|
||||
#include "../ScriptEngine.h"
|
||||
#include "../GameClient.h"
|
||||
#include "../PacketInjector.h"
|
||||
extern class GameClient *g_game_client;
|
||||
|
||||
int l2c_getVisibleChars( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
CharArray_Lock();
|
||||
unsigned int charCount = CharArray_GetCount();
|
||||
lua_createtable( L, 0, 0 );
|
||||
unsigned int i;
|
||||
unsigned int nPassed = 0;
|
||||
unsigned int tableIndex = 1;
|
||||
for( i=0; i<CHARARRAY_MAX_CHARS; i++ )
|
||||
{
|
||||
if( chars_array[i]->isUnused() ) continue;
|
||||
nPassed++;
|
||||
//
|
||||
lua_pushnumber( L, tableIndex );
|
||||
lua_pushnumber( L, chars_array[i]->objectID );
|
||||
lua_settable( L, -3 );
|
||||
tableIndex++;
|
||||
//
|
||||
if( nPassed >= charCount ) break;
|
||||
}
|
||||
CharArray_Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2c_getVisibleMobs( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
NpcArray_Lock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
unsigned int i;
|
||||
unsigned int tableIndex = 1;
|
||||
for( i=0; i<NPCA_MAX_NPCS; i++ )
|
||||
{
|
||||
if( npc_array[i]->isUnused() ) continue;
|
||||
if( !npc_array[i]->isAttackable ) continue;
|
||||
//
|
||||
lua_pushnumber( L, tableIndex );
|
||||
lua_pushnumber( L, npc_array[i]->objectID );
|
||||
lua_settable( L, -3 );
|
||||
tableIndex++;
|
||||
}
|
||||
NpcArray_Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2c_getVisibleNpcs( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
NpcArray_Lock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
unsigned int i;
|
||||
unsigned int tableIndex = 1;
|
||||
for( i=0; i<NPCA_MAX_NPCS; i++ )
|
||||
{
|
||||
if( npc_array[i]->isUnused() ) continue;
|
||||
if( npc_array[i]->isAttackable ) continue;
|
||||
//
|
||||
lua_pushnumber( L, tableIndex );
|
||||
lua_pushnumber( L, npc_array[i]->objectID );
|
||||
lua_settable( L, -3 );
|
||||
tableIndex++;
|
||||
}
|
||||
NpcArray_Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2c_getVisibleItems( lua_State *L )
|
||||
{
|
||||
if( !g_game_client ) return 0;
|
||||
GIArray *a = GIArray::getInstance();
|
||||
a->Lock();
|
||||
unsigned int count = a->getCount();
|
||||
lua_createtable( L, 0, 0 );
|
||||
unsigned int i;
|
||||
unsigned int nPassed = 0;
|
||||
unsigned int tableIndex = 1;
|
||||
for( i=0; i<GIArray::GA_MAX_ITEMS; i++ )
|
||||
{
|
||||
if( a->gi_array[i]->isUnused() ) continue;
|
||||
nPassed++;
|
||||
//
|
||||
lua_pushnumber( L, tableIndex );
|
||||
lua_pushnumber( L, a->gi_array[i]->objectID );
|
||||
lua_settable( L, -3 );
|
||||
tableIndex++;
|
||||
//
|
||||
if( nPassed >= count ) break;
|
||||
}
|
||||
a->Unlock();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2c_getCharObjectIdByName( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) { lua_pushnil( L ); return 1; }
|
||||
if( !g_game_client ) { lua_pushnil( L ); return 1; }
|
||||
const char *aname = lua_tolstring( L, 1, NULL );
|
||||
if( !aname ) { lua_pushnil( L ); return 1; }
|
||||
wchar_t wname[128] = {0};
|
||||
memset( wname, 0, sizeof(wname) );
|
||||
MultiByteToWideChar( CP_ACP, 0, aname, -1, wname, 127 );
|
||||
unsigned int nPassed = 0, i = 0, nChars = CharArray_GetCount();
|
||||
if( nChars > 0 )
|
||||
{
|
||||
CharArray_Lock();
|
||||
for( i=0; i<CHARARRAY_MAX_CHARS; i++ )
|
||||
{
|
||||
if( chars_array[i]->isUnused() ) continue;
|
||||
nPassed++;
|
||||
if( _wcsicmp( wname, chars_array[i]->charName ) == 0 )
|
||||
{
|
||||
CharArray_Unlock();
|
||||
lua_pushnumber( L, chars_array[i]->objectID );
|
||||
return 1;
|
||||
}
|
||||
if( nPassed >= nChars ) break;
|
||||
}
|
||||
CharArray_Unlock();
|
||||
}
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2c_getNpcObjectIdByName( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) { lua_pushnil( L ); return 1; }
|
||||
if( !g_game_client ) { lua_pushnil( L ); return 1; }
|
||||
const char *aname = lua_tolstring( L, 1, NULL );
|
||||
if( !aname ) { lua_pushnil( L ); return 1; }
|
||||
wchar_t wname[128] = {0};
|
||||
memset( wname, 0, sizeof(wname) );
|
||||
MultiByteToWideChar( CP_ACP, 0, aname, -1, wname, 127 );
|
||||
unsigned int i = 0;
|
||||
NpcArray_Lock();
|
||||
for( i=0; i<NPCA_MAX_NPCS; i++ )
|
||||
{
|
||||
if( npc_array[i]->isUnused() ) continue;
|
||||
if( _wcsicmp( wname, npc_array[i]->charName ) == 0 )
|
||||
{
|
||||
NpcArray_Unlock();
|
||||
lua_pushnumber( L, npc_array[i]->objectID );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
NpcArray_Unlock();
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int l2c_getObjectInfoByObjectId( lua_State *L )
|
||||
{
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) { lua_pushnil( L ); return 1; }
|
||||
if( !g_game_client ) { lua_pushnil( L ); return 1; }
|
||||
unsigned int objectID = (unsigned int)lua_tonumber( L, 1 );
|
||||
L2OBJECT_TYPE objType = L2OT_NONE;
|
||||
int idx = -1;
|
||||
if( WorldObjectTree_GetInfoByObjectID( objectID, &objType, &idx ) )
|
||||
{
|
||||
char ansi[256] = {0};
|
||||
switch( objType )
|
||||
{
|
||||
case L2OT_PC:
|
||||
{
|
||||
if( chars_array[idx] == NULL ) { lua_pushnil( L ); return 1; }
|
||||
CharArray_Lock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "type" );
|
||||
lua_pushstring( L, "pc" );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "objectID" );
|
||||
lua_pushnumber( L, chars_array[idx]->objectID );
|
||||
lua_settable( L, -3 );
|
||||
// heading
|
||||
lua_pushstring( L, "heading" );
|
||||
lua_pushnumber( L, chars_array[idx]->heading );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "targetObjectID" );
|
||||
lua_pushnumber( L, chars_array[idx]->targetObjectID );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "pvpFlag" );
|
||||
lua_pushnumber( L, chars_array[idx]->pvpFlag );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "karma" );
|
||||
lua_pushnumber( L, chars_array[idx]->karma );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "x" );
|
||||
lua_pushnumber( L, chars_array[idx]->x );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "y" );
|
||||
lua_pushnumber( L, chars_array[idx]->y );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "z" );
|
||||
lua_pushnumber( L, chars_array[idx]->z );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "xDst" );
|
||||
lua_pushnumber( L, chars_array[idx]->xDst );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "yDst" );
|
||||
lua_pushnumber( L, chars_array[idx]->yDst );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "zDst" );
|
||||
lua_pushnumber( L, chars_array[idx]->zDst );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "name" );
|
||||
sprintf( ansi, "%S", chars_array[idx]->charName );
|
||||
lua_pushstring( L, ansi );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "curHp" );
|
||||
lua_pushnumber( L, chars_array[idx]->curHp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "maxHp" );
|
||||
lua_pushnumber( L, chars_array[idx]->maxHp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "isAlikeDead" );
|
||||
lua_pushnumber( L, chars_array[idx]->isAlikeDead );
|
||||
lua_settable( L, -3 );
|
||||
// player specific
|
||||
lua_pushstring( L, "classID" );
|
||||
lua_pushnumber( L, chars_array[idx]->classID );
|
||||
lua_settable( L, -3 );
|
||||
CharArray_Unlock();
|
||||
} break;
|
||||
case L2OT_NPC:
|
||||
{
|
||||
if( npc_array[idx] == NULL ) { lua_pushnil( L ); return 1; }
|
||||
NpcArray_Lock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "type" );
|
||||
if( npc_array[idx]->isAttackable ) lua_pushstring( L, "mob" );
|
||||
else lua_pushstring( L, "npc" );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "objectID" );
|
||||
lua_pushnumber( L, npc_array[idx]->objectID );
|
||||
lua_settable( L, -3 );
|
||||
// heading
|
||||
lua_pushstring( L, "heading" );
|
||||
lua_pushnumber( L, npc_array[idx]->heading );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "x" );
|
||||
lua_pushnumber( L, npc_array[idx]->x );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "y" );
|
||||
lua_pushnumber( L, npc_array[idx]->y );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "z" );
|
||||
lua_pushnumber( L, npc_array[idx]->z );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "xDst" );
|
||||
lua_pushnumber( L, npc_array[idx]->xDst );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "yDst" );
|
||||
lua_pushnumber( L, npc_array[idx]->yDst );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "zDst" );
|
||||
lua_pushnumber( L, npc_array[idx]->zDst );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "name" );
|
||||
sprintf( ansi, "%S", npc_array[idx]->charName );
|
||||
lua_pushstring( L, ansi );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "curHp" );
|
||||
lua_pushnumber( L, npc_array[idx]->curHp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "maxHp" );
|
||||
lua_pushnumber( L, npc_array[idx]->maxHp );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "isAlikeDead" );
|
||||
lua_pushnumber( L, npc_array[idx]->isAlikeDead );
|
||||
lua_settable( L, -3 );
|
||||
// npc specific
|
||||
lua_pushstring( L, "templateID" );
|
||||
lua_pushnumber( L, npc_array[idx]->templateID );
|
||||
lua_settable( L, -3 );
|
||||
NpcArray_Unlock();
|
||||
} break;
|
||||
case L2OT_ITEM:
|
||||
{
|
||||
GIArray *a = GIArray::getInstance();
|
||||
if( a->gi_array[idx] == NULL ) { lua_pushnil( L ); return 1; }
|
||||
a->Lock();
|
||||
lua_createtable( L, 0, 0 );
|
||||
//
|
||||
lua_pushstring( L, "type" );
|
||||
lua_pushstring( L, "item" );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "objectID" );
|
||||
lua_pushnumber( L, a->gi_array[idx]->objectID );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "x" );
|
||||
lua_pushnumber( L, a->gi_array[idx]->x );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "y" );
|
||||
lua_pushnumber( L, a->gi_array[idx]->y );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "z" );
|
||||
lua_pushnumber( L, a->gi_array[idx]->z );
|
||||
lua_settable( L, -3 );
|
||||
//
|
||||
lua_pushstring( L, "name" );
|
||||
char itemName[256] = {0};
|
||||
L2Data_DB_GetItemNamePicByID( a->gi_array[idx]->itemID, itemName, NULL );
|
||||
lua_pushstring( L, itemName ); // at last
|
||||
lua_settable( L, -3 );
|
||||
// item specific
|
||||
lua_pushstring( L, "itemID" );
|
||||
lua_pushnumber( L, a->gi_array[idx]->itemID );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "stackable" );
|
||||
lua_pushboolean( L, a->gi_array[idx]->stackable );
|
||||
lua_settable( L, -3 );
|
||||
lua_pushstring( L, "count" );
|
||||
lua_pushnumber( L, (lua_Number)a->gi_array[idx]->count );
|
||||
lua_settable( L, -3 );
|
||||
a->Unlock();
|
||||
} break;
|
||||
default: lua_pushnil( L ); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnil( L );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// boolean l2c_isCharDead( int objectID )
|
||||
int l2c_isCharDead( lua_State *L )
|
||||
{
|
||||
// get number of arguments
|
||||
int nArgs = lua_gettop( L );
|
||||
if( nArgs < 1 ) { lua_pushnil( L ); return 1; }
|
||||
if( !g_game_client ) { lua_pushnil( L ); return 1; }
|
||||
// convert 1st argument to number
|
||||
unsigned int objectID = (unsigned int)lua_tonumber( L, 1 );
|
||||
L2OBJECT_TYPE objType = L2OT_NONE;
|
||||
int idx = -1;
|
||||
int return_value = 1; // default - dead
|
||||
// find objectID in world
|
||||
if( WorldObjectTree_GetInfoByObjectID( objectID, &objType, &idx ) )
|
||||
{
|
||||
switch( objType )
|
||||
{
|
||||
case L2OT_PC:
|
||||
{
|
||||
L2Player *pl = chars_array[idx];
|
||||
if( pl ) return_value = pl->isAlikeDead; // may be alive
|
||||
} break;
|
||||
case L2OT_NPC:
|
||||
{
|
||||
L2Npc *pnpc = npc_array[idx];
|
||||
if( pnpc ) return_value = pnpc->isAlikeDead; // may be alive
|
||||
} break;
|
||||
default: return_value = 1; break; // items are always "dead"
|
||||
}
|
||||
}
|
||||
lua_pushboolean( L, return_value );
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user