int KHero::LuaSetAISelfDefData(Lua_State* L) { BOOL bResult = false; BOOL bRetCode = false; int nTopIndex = 0; const char* pszKey = NULL; int nNewValue = 0; BOOL bDirectlySet = false; int nDefaultValue = 0; int nCurValue = 0; nTopIndex = Lua_GetTopIndex(L); KGLOG_PROCESS_ERROR(nTopIndex == 4); pszKey = Lua_ValueToString(L, 1); KGLOG_PROCESS_ERROR(pszKey); nNewValue = (int)Lua_ValueToNumber(L, 2); bDirectlySet = (BOOL)Lua_ValueToBoolean(L, 3); nDefaultValue = (int)Lua_ValueToNumber(L, 4); if (bDirectlySet) m_dictAISelfDefData[pszKey] = nNewValue; else if (m_dictAISelfDefData.find(pszKey) == m_dictAISelfDefData.end()) m_dictAISelfDefData[pszKey] = nDefaultValue + nNewValue; else m_dictAISelfDefData[pszKey] += nNewValue; Exit0: return 0; }
int KScene::LuaSetBattleTotalFrame(Lua_State* L) { BOOL bResult = false; BOOL bRetCode = false; int nTopIndex = 0; int nTotalFrame = 0; BOOL bReTiming = false; nTopIndex = Lua_GetTopIndex(L); KGLOG_PROCESS_ERROR(nTopIndex == 1 || nTopIndex == 2); nTotalFrame = (int)Lua_ValueToNumber(L, 1); KGLOG_PROCESS_ERROR(nTotalFrame > 0); if (nTopIndex == 2) bReTiming = (BOOL)Lua_ValueToBoolean(L, 2); bRetCode = m_Battle.SetBattleTotalFrame(nTotalFrame, bReTiming); KGLOG_PROCESS_ERROR(bRetCode); bResult = true; Exit0: Lua_PushBoolean(L, bResult); return 1; }
int KHero::LuaMoveToTarget(Lua_State* L) { BOOL bRetCode = false; int nDestX = 0; int nDestY = 0; int nDestZ = 0; int nDirection = 0; BOOL bWalk = false; int nTopIndex = 0; nTopIndex = Lua_GetTopIndex(L); KG_PROCESS_ERROR(nTopIndex == 1); bWalk = Lua_ValueToBoolean(L, 1); bRetCode = GetAITargetPos(nDestX, nDestY, nDestZ); KG_PROCESS_ERROR(bRetCode); nDirection = g_GetDirection(m_nX, m_nY, nDestX, nDestY); if (bWalk) bRetCode = WalkTo(nDirection, true); else bRetCode = RunTo(nDirection, true); Exit0: return 0; }
int KHero::LuaTakeBall(Lua_State* L) { int nTopIndex = 0; int bNotifyClient = 0; nTopIndex = Lua_GetTopIndex(L); KGLOG_PROCESS_ERROR(nTopIndex == 1); bNotifyClient = (BOOL)Lua_ValueToBoolean(L, 1); TakeBall(bNotifyClient); Exit0: return 0; }
int KScene::LuaPause(Lua_State* L) { int nTopIndex = 0; BOOL bPause = 0; nTopIndex = Lua_GetTopIndex(L); KGLOG_PROCESS_ERROR(nTopIndex == 1); m_bPause = Lua_ValueToBoolean(L, 1); g_PlayerServer.DoBroadcastScenePause(this, m_bPause); Exit0: return 0; }
int KHero::LuaSwitchAIMode(Lua_State* L) { BOOL bSuccess = false; BOOL bAiMode = false; int nTopIndex = 0; nTopIndex = Lua_GetTopIndex(L); KG_PROCESS_ERROR(nTopIndex == 1); bAiMode = Lua_ValueToBoolean(L, 1); bSuccess = bAiMode ? TurnOnAI() : TurnOffAI(); Exit0: Lua_PushBoolean(L, bSuccess); return 1; }
int KSystemScriptTable::LuaSwapMouseButton(Lua_State* L) { ASSERT(L); int nSwap = FALSE; KG_PROCESS_ERROR(lua_gettop(L) == 1); if (lua_isboolean(L, 1)) nSwap = (int)Lua_ValueToBoolean(L, 1); else nSwap = (int)Lua_ValueToNumber(L, 1); ::SwapMouseButton(nSwap); Exit0: return 0; }
int LuaSetAccountPassword(Lua_State* L) { BOOL bRetCode = false; const char* pszAccountName = NULL; const char* pszPassword = NULL; const char* pszActiveCode = NULL; BOOL bMD5 = false; int nTopIndex = Lua_GetTopIndex(L); char szDestMD5String[64] = { 0 }; KGLOG_PROCESS_ERROR(nTopIndex == 3 || nTopIndex == 4); pszAccountName = Lua_ValueToString(L, 1); KGLOG_PROCESS_ERROR(pszAccountName); pszPassword = Lua_ValueToString(L, 2); KGLOG_PROCESS_ERROR(pszPassword); bMD5 = Lua_ValueToBoolean(L, 3); if (bMD5) { KGLOG_PROCESS_ERROR(g_pGameWorldUIHandler); bRetCode = g_pGameWorldUIHandler->GetPassword(pszPassword, szDestMD5String); KGLOG_PROCESS_ERROR(bRetCode); } if (nTopIndex == 4) { pszActiveCode = Lua_ValueToString(L, 4); KGLOG_PROCESS_ERROR(pszActiveCode); } g_GatewayClient.SetAccountPassword(pszAccountName, szDestMD5String, pszActiveCode); Exit0: return 0; }
int KScene::LuaSetBasketNotCostHP(Lua_State* L) { int nTopIndex = 0; BOOL bCanCostHP = false; nTopIndex = Lua_GetTopIndex(L); KGLOG_PROCESS_ERROR(nTopIndex == 1); bCanCostHP = (BOOL)Lua_ValueToBoolean(L, 1); for (KObjEnumerator it = m_pSceneObjMgr->GetEnumerator(); it.HasElement(); it.MoveToNext()) { KSceneObject* pObj = it.GetValue(); if (pObj->GetType() == sotBasket) { KBasket* pBasket = (KBasket*)pObj; pBasket->m_bNotCostHP = bCanCostHP; } } Exit0: return 0; }