Esempio n. 1
0
int KTeamClient::LuaGetTeamMemberList(Lua_State* L)
{
    int nResult     = 0;
    int nRetCode    = 0;
    int nToble      = 0;
    int nIndex      = 1;
    int nTopIndex   = 0;

    nTopIndex = Lua_GetTopIndex(L);
    // KGLOG_PROCESS_ERROR(nTopIndex == 0);

    Lua_NewTable(L);
    int nTable = Lua_GetTopIndex(L);

    for (int i = 0; i < m_nGroupNum; i++)
    {
        for (
            KTEAM_MEMBER_LIST::iterator it = m_TeamGroup[i].MemberList.begin();
            it != m_TeamGroup[i].MemberList.end(); ++it
        )
        {
            Lua_PushNumber(L, nIndex);
            Lua_PushNumber(L, it->dwMemberID);
            Lua_SetTable(L, nTable);

            nIndex++;
        }
    }

    nResult = 1;
Exit0:
    return nResult;
}
Esempio n. 2
0
int KSkillList::_LuaGetSkillKungfuList(Lua_State* L, DWORD dwSchollID)
{
	std::map<DWORD, DWORD> KungfuList;
	for (PLAYER_SKILL_LIST::iterator it = m_PlayerSkillList.begin(); it != m_PlayerSkillList.end(); ++it)
	{
		KSkill* pSkill = g_pSO3World->m_SkillManager.GetSkill_RAW(it->first, it->second.dwLevel);
		if(pSkill && 
			dwSchollID == pSkill->m_pBaseInfo->dwBelongSchool && 
			pSkill->m_pBaseInfo->dwBelongKungfu == 0)
		{
			KungfuList[it->first] = it->second.dwLevel;
		}
	}

	Lua_NewTable(L);
	int nTable = Lua_GetTopIndex(L);
	for (std::map<DWORD, DWORD>::iterator it = KungfuList.begin(); it != KungfuList.end(); ++it)
	{
		Lua_PushNumber(L, it->first);
		Lua_PushNumber(L, it->second);
		Lua_SetTable(L, nTable);
	}

	return 1;
}
Esempio n. 3
0
int KTeamClient::LuaGetClientTeamMemberPortraitID(Lua_State* L)
{
    int             nResult     = 0;
    int             nRetCode    = 0;
    DWORD           dwMemberID  = 0;
    KTEAM_MEMBER_INFO*   pMemberInfo = NULL;

    nRetCode = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    dwMemberID = (DWORD)Lua_ValueToNumber(L, 1);

    KG_PROCESS_ERROR(m_dwTeamID != ERROR_ID);

    pMemberInfo = GetMemberInfo(dwMemberID);
    KGLOG_PROCESS_ERROR(pMemberInfo);

    Lua_PushNumber(L, pMemberInfo->PortraitInfo.dwHelmStyle);
    Lua_PushNumber(L, pMemberInfo->PortraitInfo.dwHelmColor);
    Lua_PushNumber(L, pMemberInfo->PortraitInfo.dwFaceStyle);
    Lua_PushNumber(L, pMemberInfo->PortraitInfo.dwHairStyle);

    Lua_PushNumber(L, pMemberInfo->nRoleType);

    nResult = 5;
Exit0:
    return nResult;
}
Esempio n. 4
0
//---------------------------------------------------------------------------
// 函数:	Lua_SetTable_IntFromId
// 功能:	
// 参数:	Lua_State * L
// 参数:	int nIndex
// 参数:	int Id
// 参数:	int nNumber
// 返回:	int 
//---------------------------------------------------------------------------
int Lua_SetTable_IntFromId(Lua_State * L, int nIndex, int Id, int nNumber)
{
	if (! Lua_IsTable(L, nIndex))
		return 0;
	Lua_PushNumber(L, (double) Id);
	Lua_PushNumber(L, (double) nNumber);
	Lua_SetTable(L, nIndex);
	return 1;
}
Esempio n. 5
0
int	KSkillList::_LuaGetAllSkillList(Lua_State* L)
{
	Lua_NewTable(L);
	for (PLAYER_SKILL_LIST::iterator it = m_PlayerSkillList.begin(); it != m_PlayerSkillList.end(); ++it)
	{
		Lua_PushNumber(L, it->first);
		Lua_PushNumber(L, it->second.dwLevel);
		Lua_SetTable(L, -3);
	}
	return 1;
}
Esempio n. 6
0
int KCustomEquipInfo::LuaGetMagicAttrib(Lua_State* L)
{
	int nResult     = false;
	int nRelIndex   = 0;
    int nTable      = 0;

	Lua_NewTable(L);

	nTable = Lua_GetTopIndex(L);

	for(int i = 0; i < MAX_ITEM_MAGIC_COUNT; ++i)
	{
		KAttribInfo* pInfo = g_pSO3World->m_ItemManager.m_ItemLib.GetAttribInfo(nAttribIndex[i]);
		if (pInfo && pInfo->nAttribID != atInvalid)
		{
			++nRelIndex;

			Lua_PushNumber(L, nRelIndex);
			Lua_NewTable(L);
			int nAttrib = Lua_GetTopIndex(L);

			Lua_PushString(L, "nID");
			Lua_PushNumber(L, pInfo->nAttribID);
			Lua_SetTable(L, nAttrib);

			Lua_PushString(L, "nImportance");
			Lua_PushNumber(L, pInfo->nImportance);
			Lua_SetTable(L, nAttrib);

			for (int j = 0; j < MAX_ATTRIB_PARAM_NUM; ++j)
			{
				char szKey[16];
				sprintf(szKey, "%s%d", "Param", (j * 2));

				Lua_PushString(L, szKey);
				Lua_PushNumber(L, pInfo->Param[j].nMin);
				Lua_SetTable(L, nAttrib);

				sprintf(szKey, "%s%d", "Param", (j * 2 + 1));
				Lua_PushString(L, szKey);
				Lua_PushNumber(L, pInfo->Param[j].nMax);
				Lua_SetTable(L, nAttrib);
			}

			Lua_SetTable(L, nTable);
		}
	}

	nResult = true;
Exit0:
	if (!nResult) 
		Lua_PushNil(L);
	return 1;
}
Esempio n. 7
0
int KSystemScriptTable::LuaGetCurrentAdapterMode(Lua_State* L)
{
    DEVMODE devMode;

    ASSERT(L);

    ::EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode);

    Lua_PushNumber(L, devMode.dmPelsWidth);
    Lua_PushNumber(L, devMode.dmPelsHeight);
    Lua_PushNumber(L, devMode.dmDisplayFrequency);
    return 3;
}
Esempio n. 8
0
    // 返回帐号月卡截止时间,计点剩余秒数,计天剩余秒数和总截止时间
    int LuaGetTimeOfFee(Lua_State* L)
    {
        KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 0);

        Lua_PushNumber(L, g_GatewayClient.m_nEndOfDayTime);
        Lua_PushNumber(L, g_GatewayClient.m_dwLeftTimeOfPoint);
        Lua_PushNumber(L, g_GatewayClient.m_dwLeftTimeOfDay);
        Lua_PushNumber(L, g_GatewayClient.m_nEndTimeOfFee);

        return 4;
Exit0:
        return 0;
    }
Esempio n. 9
0
int KTeamClient::LuaGetClientTeamMemberCurrentMana(Lua_State* L)
{
    int             nResult      = 0;
    int             nRetCode     = 0;
    int             nCurrentMana = 0;
    DWORD           dwMemberID   = 0;
    KTEAM_MEMBER_INFO*   pMemberInfo  = NULL;


    nRetCode = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    dwMemberID = (DWORD)Lua_ValueToNumber(L, 1);

    KG_PROCESS_ERROR(m_dwTeamID != ERROR_ID);

    pMemberInfo = GetMemberInfo(dwMemberID);
    KGLOG_PROCESS_ERROR(pMemberInfo);

    nCurrentMana = pMemberInfo->nMaxMana * pMemberInfo->nManaPercent / UCHAR_MAX;

    Lua_PushNumber(L, nCurrentMana);

    nResult = 1;
Exit0:
    return nResult;
}
Esempio n. 10
0
BOOL	KMission::ExecuteScript(DWORD dwScriptId,  char * szFunName, int nParam)
{
	try
	{
		KLuaScript * pScript = (KLuaScript* )g_GetScript(dwScriptId);
		if (pScript)
		{
			KSubWorld * pSubWorld = (KSubWorld*)GetOwner();
			
			if (pSubWorld)
			{
				Lua_PushNumber(pScript->m_LuaState, pSubWorld->m_nIndex);
				pScript->SetGlobalName(SCRIPT_SUBWORLDINDEX);
			}
			
			int nTopIndex = 0;
			
			pScript->SafeCallBegin(&nTopIndex);
			pScript->CallFunction(szFunName,0, "d", nParam);
			pScript->SafeCallEnd(nTopIndex);
		}
		return TRUE;
	}
	catch(...)
	{
		printf("Exception Have Caught When Execute Script[%d]!!!!!", dwScriptId);
		g_DebugLog("Exception Have Caught When Execute Script[%d]!!!!!", dwScriptId);
		return FALSE;
	}
	return TRUE;
}
Esempio n. 11
0
int KItem::LuaCanEquip(Lua_State* L)
{
    assert(L);

    int nCanEquipPos = -1;
    int nCanEquip = false;

    KPlayer* pPlayer = g_pSO3World->m_PlayerSet.GetObj(g_pSO3World->m_dwClientPlayerID);
    KGLOG_PROCESS_ERROR(pPlayer);

    KG_PROCESS_ERROR(getGenre() == igEquipment);

    for (int i = 0; i < eitTotal; ++i)
    {
        if (pPlayer->m_ItemList.CanEquip(this, i) == ircSuccess)
        {
            nCanEquipPos = i;
            if (i == eitLeftRing)
                if (pPlayer->m_ItemList.GetItem(igEquipment, eitLeftRing))
                    if (pPlayer->m_ItemList.CanEquip(this, eitRightRing) == ircSuccess)
                        nCanEquipPos = eitRightRing;
            goto Exit1;
        }
    }
    goto Exit0;

Exit1:
    nCanEquip = true;
Exit0:
    Lua_PushBoolean(L, nCanEquip);
    Lua_PushNumber(L, nCanEquipPos);
    return 2;
}
Esempio n. 12
0
int KTeamClient::LuaGetMemberGroupIndex(Lua_State* L)
{
    int     nResult     = 0;
    int     nTopIndex   = 0;
    DWORD   dwMemberID  = ERROR_ID;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 1);

    dwMemberID = (DWORD)Lua_ValueToNumber(L, 1);

    for (int i = 0; i < m_nGroupNum; i++)
    {
        for (
            KTEAM_MEMBER_LIST::iterator it = m_TeamGroup[i].MemberList.begin();
            it != m_TeamGroup[i].MemberList.end(); ++it
        )
        {
            if (it->dwMemberID == dwMemberID)
            {
                Lua_PushNumber(L, i);
                nResult = 1;
                goto Exit0;
            }
        }
    }

Exit0:
    return nResult;
}
Esempio n. 13
0
int KHero::LuaCheckAISelfDefData(Lua_State* L)
{
    int nRetCode = KAI_BRANCH_ERROR;
    BOOL bRetCode	= false;
    int	 nTopIndex	= 0;
    const char* pszKey = NULL;
    int nMinValue = 0;
    int nMaxValue = 0;
    int nCurValue = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    pszKey = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszKey);

    nMinValue = (int)Lua_ValueToNumber(L, 1);
    nMaxValue = (int)Lua_ValueToNumber(L, 2);

    if (m_dictAISelfDefData.find(pszKey) == m_dictAISelfDefData.end())
        goto Exit0;

    nCurValue = m_dictAISelfDefData[pszKey];
    if (nCurValue < nMinValue || nCurValue > nMaxValue)
    {
        nRetCode = KAI_BRANCH_FAILED;
        goto Exit0;
    }

    nRetCode = KAI_BRANCH_SUCCESS;
Exit0:
    Lua_PushNumber(L, nRetCode);
    return 1;
}
Esempio n. 14
0
int	KItemInfo::LuaGetCoolDown(Lua_State* L)
{
	int     nCoolDown   = 0;
	KSkill* pSkill      = NULL;

	assert(L);

	pSkill = g_pSO3World->m_SkillManager.GetSkill_RAW(dwSkillID, dwSkillLevel);
	if (pSkill)
	{
		for (int i = 0; i < MAX_SKILL_COOL_DOWN_TIMER; i++)
		{
			DWORD dwID      = pSkill->m_dwCoolDownID[i];
			if (dwID == 0)
				continue;
			int nFrame = g_pSO3World->m_Settings.m_CoolDownList.GetCoolDownValue(dwID);
			if (nFrame > nCoolDown)
				nCoolDown = nFrame;
		}
	}

	int nFrame = g_pSO3World->m_Settings.m_CoolDownList.GetCoolDownValue(dwCoolDownID);
	if (nFrame > nCoolDown)
		nCoolDown = nFrame;

	Lua_PushNumber(L, nCoolDown);
	return 1;
}
Esempio n. 15
0
int KSystemScriptTable::LuaGetUnpakFileSize(Lua_State* L)
{
    int nRetCode = false;
    int nSize = 0;
    const char * pcszFile = NULL;
    FILE * pFile = NULL;

    KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 1);

    pcszFile = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pcszFile);

    pFile = fopen(pcszFile, "rb");
    KG_PROCESS_ERROR(pFile);

    fseek(pFile, 0, SEEK_END);
    nSize = (int)ftell(pFile);

Exit0:
    if (pFile)
    {
        fclose(pFile);
        pFile = NULL;
    }
    Lua_PushNumber(L, nSize);
    return 1;
}
Esempio n. 16
0
int LuaCreatePQ(Lua_State* L)
{
    int     nResult         = 0;
    int     nTopIndex       = 0;
    DWORD   dwPQTemplateID  = 0;
    int     nOwnerType      = pqotInvalid;
    DWORD   dwOwnerID1      = 0;
    DWORD   dwOwnerID2      = 0;
    DWORD   dwOwnerID3      = 0;
    DWORD   dwPQID          = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 1 || nTopIndex == 5);

    dwPQTemplateID = (DWORD)Lua_ValueToNumber(L, 1);

    if (nTopIndex == 5)
    {
        nOwnerType = (int)Lua_ValueToNumber(L, 2);
        dwOwnerID1 = (DWORD)Lua_ValueToNumber(L, 3);
        dwOwnerID2 = (DWORD)Lua_ValueToNumber(L, 4);
        dwOwnerID3 = (DWORD)Lua_ValueToNumber(L, 5);
    }

    dwPQID = g_pSO3GameCenter->m_PQCenter.CreatePQ(dwPQTemplateID, (KGPQ_OWNER_TYPE)nOwnerType, dwOwnerID1, dwOwnerID2, dwOwnerID3);

Exit0:
    Lua_PushNumber(L, dwPQID);
    return 1;
}
Esempio n. 17
0
int LuaGetSceneConnIndex(Lua_State* L)
{
    int         nResult         = 0;
    int         nTopIndex       = 0;
    DWORD       dwMapID         = 0;
    int         nMapCopyIndex   = 0;
    KMapCopy*   pMapCopy        = NULL;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);

    dwMapID         = (DWORD)Lua_ValueToNumber(L, 1);
    nMapCopyIndex   = (int)Lua_ValueToNumber(L, 2);

    pMapCopy = g_pSO3GameCenter->m_MapManager.GetMapCopy(dwMapID, nMapCopyIndex);
    KG_PROCESS_ERROR(pMapCopy);
    
    nResult = pMapCopy->m_nConnIndex;
Exit0:
    if (nResult)
        Lua_PushNumber(L, nResult);
    else
        Lua_PushNil(L);

    return 1;
}
Esempio n. 18
0
int LuaGetPlayerEnterNewCopyTimesInfo(Lua_State* L)
{
    int         nResult             = 0;
    KMapInfo*   pMapInfo            = NULL;
    int         nTopIndex           = 0;
    DWORD       dwMapID             = 0;
    DWORD       dwPlayerID          = 0;
    int         nAlreadyEnterTimes  = 0;
    KNEW_MAP_LIMIT_TABLE::iterator it;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);
    
    dwMapID     = (DWORD)Lua_ValueToNumber(L, 1);
    dwPlayerID  = (DWORD)Lua_ValueToNumber(L, 2);

    pMapInfo = g_pSO3GameCenter->m_MapManager.GetMapInfo(dwMapID);
    KGLOG_PROCESS_ERROR(pMapInfo);
    
    KG_PROCESS_ERROR(pMapInfo->m_nType == emtDungeon || pMapInfo->m_nType == emtBattleField);

    it = pMapInfo->m_PlayerEnterNewCopyTimes.find(dwPlayerID);
    if (it != pMapInfo->m_PlayerEnterNewCopyTimes.end())
    {
        nAlreadyEnterTimes = it->second.nTimes;
    }   
    
    Lua_PushNumber(L, nAlreadyEnterTimes);

    nResult = 1;
Exit0:
    return nResult;
}
Esempio n. 19
0
int KItem::LuaGetRequireLevel(Lua_State* L)
{
    int nResult = 0;

    nResult = GetRequireLevel();
    Lua_PushNumber(L, nResult);
    return 1;
}
Esempio n. 20
0
int KTeamClient::LuaGetGroupInfo(Lua_State* L)
{
    int nResult     = 0;
    int nTopIndex   = 0;
    int nTable      = 0;
    int nSubTable   = 0;
    int nTeamGroup  = 0;
    int nIndex      = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 1);

    KGLOG_PROCESS_ERROR(m_dwTeamID != ERROR_ID);

    nTeamGroup = (int)Lua_ValueToNumber(L, 1);

    KGLOG_PROCESS_ERROR(nTeamGroup >= 0 && nTeamGroup < m_nGroupNum);

    Lua_NewTable(L);
    nTable = Lua_GetTopIndex(L);

    Lua_PushString(L, "dwFormationLeader");
    Lua_PushNumber(L, m_TeamGroup[nTeamGroup].dwFormationLeader);
    Lua_SetTable(L, nTable);

    Lua_PushString(L, "MemberList");
    Lua_NewTable(L);
    nSubTable = Lua_GetTopIndex(L);

    for (
        KTEAM_MEMBER_LIST::iterator it = m_TeamGroup[nTeamGroup].MemberList.begin();
        it != m_TeamGroup[nTeamGroup].MemberList.end(); ++it
    )
    {
        Lua_PushNumber(L, ++nIndex);
        Lua_PushNumber(L, it->dwMemberID);
        Lua_SetTable(L, nSubTable);
    }

    Lua_SetTable(L, nTable);

    nResult = 1;
Exit0:
    return nResult;
}
Esempio n. 21
0
    int LuaGetLoginTime(Lua_State* L)
    {
        KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 0);

        Lua_PushNumber(L, g_GatewayClient.m_nLoginTime);
        return 1;
Exit0:
        return 0;
    }
Esempio n. 22
0
//---------------------------------------------------------------------------
// 函数:	Lua_SetTable_StringFromId
// 功能:	
// 参数:	Lua_State * L
// 参数:	int nIndex
// 参数:	int Id
// 参数:	const char * szString
// 返回:	int 
//---------------------------------------------------------------------------
int Lua_SetTable_StringFromId(Lua_State * L, int nIndex, int Id, const char * szString)
{
	if (! Lua_IsTable(L, nIndex))
		return 0;
	Lua_PushNumber(L, (double)Id);
	Lua_PushString(L, szString);
	Lua_SetTable(L, nIndex);
	return 1;
}
Esempio n. 23
0
//---------------------------------------------------------------------------
// 函数:	Lua_SetTable_CFunFromId
// 功能:	
// 参数:	Lua_State * L
// 参数:	int nIndex
// 参数:	int nId
// 参数:	Lua_CFunction CFun
// 返回:	int 
//---------------------------------------------------------------------------
int Lua_SetTable_CFunFromId(Lua_State * L, int nIndex, int nId, Lua_CFunction CFun)
{
	if (! Lua_IsTable(L, nIndex))
		return 0;
	Lua_PushNumber(L, nId);
	Lua_PushCFunction(L, CFun);
	Lua_SetTable(L, nIndex);
	return 1;
}
Esempio n. 24
0
int KItem::LuaGetTemporaryEnchantAttrib(Lua_State* L)
{
    int nFirst = true;
    int nResult = 0;
    int nIndex  = 1;

    KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 0);
    KG_PROCESS_ERROR(m_pTemporaryEnchant);
    KG_PROCESS_ERROR(m_pTemporaryEnchant->pAttribute);
    for (KAttribute* pAttribute = m_pTemporaryEnchant->pAttribute; pAttribute; pAttribute = pAttribute->pNext)
    {
        if (pAttribute->nKey != atInvalid)
        {
            if (nFirst)
            {
                Lua_NewTable(L);
                nFirst = false;
            }

            Lua_PushNumber(L, nIndex);
            nIndex++;
            Lua_NewTable(L);

            Lua_PushString(L, "nID");
            Lua_PushNumber(L, pAttribute->nKey);
            Lua_SetTable(L, -3);

            Lua_PushString(L, "nValue1");
            Lua_PushNumber(L, pAttribute->nValue1);
            Lua_SetTable(L, -3);

            Lua_PushString(L, "nValue2");
            Lua_PushNumber(L, pAttribute->nValue2);
            Lua_SetTable(L, -3);

            Lua_SetTable(L, -3);
        }
    }

    if (!nFirst)
        nResult = 1;
Exit0:
    return nResult;
}
Esempio n. 25
0
int LuaResetMap(Lua_State* L)
{
    int     nResult     = 0;
    BOOL    bRetCode    = false;
    int     nTopIndex   = 0;
    DWORD   dwPlayerID  = ERROR_ID;
    DWORD   dwMapID     = 0;
    int     nCopySN     = 0;
    int     i           = 1;
    std::vector<DWORD> vecFailedMap;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);
    
    dwPlayerID  = (DWORD)Lua_ValueToNumber(L, 1);
    dwMapID     = (DWORD)Lua_ValueToNumber(L, 2);
    nCopySN     = (int)Lua_ValueToNumber(L, 3);

    if (dwMapID == 0)
    {
        g_pSO3GameCenter->m_MapManager.ResetAllMap(dwPlayerID, vecFailedMap);
    }
    else
    {
        bRetCode = g_pSO3GameCenter->m_MapManager.ResetMap(dwPlayerID, dwMapID, nCopySN);
        if (!bRetCode)
        {
            vecFailedMap.push_back(dwMapID);
        }
    }
    
    Lua_NewTable(L);
    
    for (std::vector<DWORD>::iterator it = vecFailedMap.begin(); it != vecFailedMap.end(); ++it, ++i)
    {
        Lua_PushNumber(L, i);
        Lua_PushNumber(L, *it);
        Lua_SetTable(L, -3);
    }
    
    nResult = 1;
Exit0:
    return nResult;
}
Esempio n. 26
0
    int LuaGetHometownList(Lua_State* L)
    {
        const KUI_HOMETOWN_MAP_TABLE&   HometownList        = g_GatewayClient.GetHometownList();
        int                             nHometownMapCount   = (int)HometownList.size();

		Lua_NewTable(L);

		for (int nMap = 0; nMap < nHometownMapCount; ++nMap)
		{
            int nCopyCount = (int)HometownList[nMap].LoadFactorTable.size();
			
			Lua_PushNumber(L, nMap);
			Lua_NewTable(L);

			lua_pushliteral(L, "MapID");
			Lua_PushNumber(L, HometownList[nMap].dwMapID);
			Lua_SetTable(L, -3);

			lua_pushliteral(L, "Copy");
			Lua_NewTable(L);

            for (int nCopy = 0; nCopy < nCopyCount; ++nCopy)
            {
				Lua_PushNumber(L, nCopy + 1);
				Lua_NewTable(L);

				lua_pushliteral(L, "CopyIndex");
			    Lua_PushNumber(L, HometownList[nMap].LoadFactorTable[nCopy].dwCopyIndex);
			    Lua_SetTable(L, -3);

				lua_pushliteral(L, "LoadFactor");
				Lua_PushNumber(L, HometownList[nMap].LoadFactorTable[nCopy].nLoadFactor);
			    Lua_SetTable(L, -3);

				Lua_SetTable(L, -3); // nCopyCount
			}

			Lua_SetTable(L, -3); // Copy
			Lua_SetTable(L, -3); // nIndex
		}

        return 1;
    }
Esempio n. 27
0
//---------------------------------------------------------------------------
// 函数:	Lua_SetTable_IntFromName
// 功能:	
// 参数:	Lua_State * L
// 参数:	int nIndex
// 参数:	const char * szMemberName
// 参数:	int Number
// 返回:	int 
//---------------------------------------------------------------------------
int Lua_SetTable_IntFromName(Lua_State * L, int nIndex, const char * szMemberName, int Number)
{

	if (! Lua_IsTable(L, nIndex))
		return 0;
	Lua_PushString(L, szMemberName);
	Lua_PushNumber(L, (double)Number);
	Lua_SetTable(L, nIndex);
	return 1;
	
}
Esempio n. 28
0
int LuaGetMapList(Lua_State* L)
{
    int nIndex = 1;
    std::vector<DWORD> vecMapList;
    
    g_pSO3GameCenter->m_MapManager.GetMapList(vecMapList);

    Lua_NewTable(L);

    for (std::vector<DWORD>::iterator it = vecMapList.begin(); it != vecMapList.end(); ++it)
    {
        Lua_PushNumber(L, nIndex);
        Lua_PushNumber(L, *it);

        Lua_SetTable(L, -3);
        nIndex++;
    }
    
    return 1;
}
Esempio n. 29
0
int KTeamClient::LuaGetTeamMark(Lua_State *L)
{
    int         nResult = 0;

    KGLOG_PROCESS_ERROR(m_dwTeamID != ERROR_ID);

    lua_newtable(L);
    for (int i = 0; i < _countof(m_dwTeamMark); i++)
    {
        if (m_dwTeamMark[i] == 0)
            continue;

        Lua_PushNumber(L, m_dwTeamMark[i]);
        Lua_PushNumber(L, i + 1);	// 0 = Cancel, so MarkID begin with 1
        Lua_SetTable(L, -3);
    }

    nResult = 1;
Exit0:
    return nResult;
}
Esempio n. 30
0
//-------------------------------------------------------------------------
//	功能:	运行物件脚本
//-------------------------------------------------------------------------
void	KObj::ExecScript(int nPlayerIdx)
{
	if (!m_dwScriptID)
		return;
	if (nPlayerIdx < 0)
		return;
	DWORD dwScriptId = m_dwScriptID;//g_FileName2Id(m_szScriptName);
	KLuaScript * pScript = (KLuaScript*)g_GetScript(dwScriptId);
	try
	{
		if (pScript)
		{
			if (Player[nPlayerIdx].m_nIndex < 0) return ;
			Npc[Player[nPlayerIdx].m_nIndex].m_ActionScriptID = dwScriptId;
			Lua_PushNumber(pScript->m_LuaState, Player[nPlayerIdx].GetPlayerIndex());
			pScript->SetGlobalName(SCRIPT_PLAYERINDEX);
			
			Lua_PushNumber(pScript->m_LuaState, Player[nPlayerIdx].GetPlayerID());
			pScript->SetGlobalName(SCRIPT_PLAYERID);
			
			Lua_PushNumber(pScript->m_LuaState, m_nIndex);
			pScript->SetGlobalName(SCRIPT_OBJINDEX);
			
			int nTopIndex = 0;
			pScript->SafeCallBegin(&nTopIndex);
			
			BOOL bResult = FALSE;
			bResult = pScript->CallFunction("main", 0, "");
			pScript->SafeCallEnd(nTopIndex);
			
		}
	}
	catch(...)
	{
		printf("Exception Have Chought When Execute Obj Script[%d]!!!!!", dwScriptId);
	}
	return;
}