- Konu Yazar
- #1
Öncelikle Selam
Bildiginiz Gibi Twostars 18xx Projesinde Arena Girenler Cıkamıyordu. Lua System İnceledi ZoneChangeParty Ekli Olmadığını Gördüm.. Bu Yamayı Ben Size Paylasım Dedim. Buyrun
Bildiginiz Gibi Twostars 18xx Projesinde Arena Girenler Cıkamıyordu. Lua System İnceledi ZoneChangeParty Ekli Olmadığını Gördüm.. Bu Yamayı Ben Size Paylasım Dedim. Buyrun
Ebenezerdan lua_bindings.cpp Geliyoruz Ve DEFINE_LUA_CLASS en Altına
MAKE_LUA_METHOD(ZoneChangeParty) Ekliyoruz..
Ebenezerdan User.h Gelip void ReqSealItem(Packet & pkt); Aratıp Hemen Altına
bool ZoneChangeParty(uint16 sNewZone, float x, float z); Ekliyoruz..
Ebenezerda User.h Tekrardan Gelip En Alta
DECLARE_LUA_FUNCTION(ZoneChangeParty) {
LUA_RETURN(LUA_GET_INSTANCE()->ZoneChangeParty(
LUA_ARG(uint8, 2), // skill point category
LUA_ARG(uint8, 3), // min
LUA_ARG(uint8, 4))); // max
} Ekliyoruz..
Ebenezerdan CharacterMovementHandler.cpp Gelip
bool CUser::ZoneChangeParty(uint16 sNewZone, float x, float z)
{
C3DMap * pMap = g_pMain->GetZoneByID(sNewZone);
if (pMap == nullptr)
return true;
ZoneChangeError errorReason;
if (!CanChangeZone(pMap, errorReason))
{
Packet result;
switch (errorReason)
{
case ZoneChangeErrorWrongLevel:
/* this will depend on the zone */
break;
case ZoneChangeErrorWarActive:
result.Initialize(WIZ_WARP_LIST);
result << uint8(2) << uint8(4);
Send(&result);
break;
case ZoneChangeErrorNeedLoyalty:
/* does this have an error? */
break;
}
return true;
}
m_bWarp = true;
m_bZoneChangeFlag = true;
UserInOut(INOUT_OUT);
if (sNewZone == ZONE_SNOW_BATTLE)
SetMaxHp(1);
if (GetZoneID() != sNewZone)
{
SetZoneAbilityChange();
// Reset the user's anger gauge when leaving the zone
// Unknown if this is official behaviour, but it's logical.
if (GetAngerGauge() > 0)
UpdateAngerGauge(0);
/*
Here we also send a clan packet with subopcode 0x16 (with a byte flag of 2) if war zone/Moradon
or subopcode 0x17 (with nWarEnemyID) for all else
*/
#if 0
if (isInClan())
{
CKnights * pKnights = g_pMain->GetClanPtr(GetClanID());
if (pKnights != nullptr
&& pKnights->bKnightsWarStarted)
{
Packet clanPacket(WIZ_KNIGHTS_PROCESS);
if (pMap->isWarZone() || byNewZone == ZONE_MORADON)
clanPacket << uint8(0x17) << uint8(2);
else
clanPacket << uint16(0x16) << uint16(0 /*nWarEnemyID*/);
Send(&clanPacket);
}
}
#endif
if (sNewZone == ZONE_SNOW_BATTLE)
SetMaxHp();
if (isInParty())
PartyRemove(GetSocketID());
ResetWindows();
}
m_bZone = (uint8) sNewZone; // this is 2 bytes to support the warp data loaded from SMDs. It should not go above a byte, however.
SetPosition(x, 0.0f, z);
m_pMap = pMap;
if (g_pMain->m_nServerNo != pMap->m_nServerNo)
{
_ZONE_SERVERINFO *pInfo = g_pMain->m_ServerArray.GetData(pMap->m_nServerNo);
if (pInfo == nullptr)
return true;
UserDataSaveToAgent();
m_bLogout = 2; // server change flag
SendServerChange(pInfo->strServerIP, 2);
return true;
}
SetRegion(GetNewRegionX(), GetNewRegionZ());
Packet result(WIZ_ZONE_CHANGE, uint8(ZoneChangeTeleport));
result << uint16(GetZoneID()) << GetSPosX() << GetSPosZ() << GetSPosY() << g_pMain->m_byOldVictory;
Send(&result);
if (!m_bZoneChangeSameZone)
{
m_sWhoKilledMe = -1;
m_iLostExp = 0;
m_bRegeneType = 0;
m_tLastRegeneTime = 0;
m_sBind = -1;
InitType3();
InitType4();
CMagicProcess::CheckExpiredType9Skills(this, true);
SetUserAbility();
}
result.Initialize(AG_ZONE_CHANGE);
result << GetSocketID() << GetZoneID();
Send_AIServer(&result);
m_bZoneChangeSameZone = false;
m_bZoneChangeFlag = false;
return true;
} Ekliyoruz..
Bu Arenadan Cıkış NPC 13010_Move.lua Kodları..
-----
-- Sample Lua script.
-----
-- Globals
pUser = nil
pNpc = nil
local eventMap = {
[500] = function() pUser:SelectMsg(2, 407, 4070, 4070, 501, 10, CancelButton) end,
[501] = Event501,
}
function Main(event)
print("Event: " .. event)
local func = eventMap[event]
if (func and type(func) == "function") then
func()
end
end
function DefaultMenu()
-- Sample menu
pUser:SelectMsg(2, -- unknown flag
-1, -- quest ID
191, -- menu header text/type
11, 10, -- text | event
20, 20)
-- Sample new-style menu/dialog (does whatever's needed by the NPC, apparently)
-- pUser:NpcMsg(193, 16079)
-- Other sample uses
-- pUser:GiveItem(910014000, 1) -- give player the Kiss item
-- pUser:RobItem(910014000, 1) -- take Kiss item from player
-- pUser:ShowMap(1)
end
function Event501()
pUser:ZoneChangeParty(21,818,441)
end
function HandleSomeButton()
pUser:KissUser()
end
Ve Artık LUA System ZoneChangeParty Fonksiyonu Aktif..
MAKE_LUA_METHOD(ZoneChangeParty) Ekliyoruz..
Ebenezerdan User.h Gelip void ReqSealItem(Packet & pkt); Aratıp Hemen Altına
bool ZoneChangeParty(uint16 sNewZone, float x, float z); Ekliyoruz..
Ebenezerda User.h Tekrardan Gelip En Alta
DECLARE_LUA_FUNCTION(ZoneChangeParty) {
LUA_RETURN(LUA_GET_INSTANCE()->ZoneChangeParty(
LUA_ARG(uint8, 2), // skill point category
LUA_ARG(uint8, 3), // min
LUA_ARG(uint8, 4))); // max
} Ekliyoruz..
Ebenezerdan CharacterMovementHandler.cpp Gelip
bool CUser::ZoneChangeParty(uint16 sNewZone, float x, float z)
{
C3DMap * pMap = g_pMain->GetZoneByID(sNewZone);
if (pMap == nullptr)
return true;
ZoneChangeError errorReason;
if (!CanChangeZone(pMap, errorReason))
{
Packet result;
switch (errorReason)
{
case ZoneChangeErrorWrongLevel:
/* this will depend on the zone */
break;
case ZoneChangeErrorWarActive:
result.Initialize(WIZ_WARP_LIST);
result << uint8(2) << uint8(4);
Send(&result);
break;
case ZoneChangeErrorNeedLoyalty:
/* does this have an error? */
break;
}
return true;
}
m_bWarp = true;
m_bZoneChangeFlag = true;
UserInOut(INOUT_OUT);
if (sNewZone == ZONE_SNOW_BATTLE)
SetMaxHp(1);
if (GetZoneID() != sNewZone)
{
SetZoneAbilityChange();
// Reset the user's anger gauge when leaving the zone
// Unknown if this is official behaviour, but it's logical.
if (GetAngerGauge() > 0)
UpdateAngerGauge(0);
/*
Here we also send a clan packet with subopcode 0x16 (with a byte flag of 2) if war zone/Moradon
or subopcode 0x17 (with nWarEnemyID) for all else
*/
#if 0
if (isInClan())
{
CKnights * pKnights = g_pMain->GetClanPtr(GetClanID());
if (pKnights != nullptr
&& pKnights->bKnightsWarStarted)
{
Packet clanPacket(WIZ_KNIGHTS_PROCESS);
if (pMap->isWarZone() || byNewZone == ZONE_MORADON)
clanPacket << uint8(0x17) << uint8(2);
else
clanPacket << uint16(0x16) << uint16(0 /*nWarEnemyID*/);
Send(&clanPacket);
}
}
#endif
if (sNewZone == ZONE_SNOW_BATTLE)
SetMaxHp();
if (isInParty())
PartyRemove(GetSocketID());
ResetWindows();
}
m_bZone = (uint8) sNewZone; // this is 2 bytes to support the warp data loaded from SMDs. It should not go above a byte, however.
SetPosition(x, 0.0f, z);
m_pMap = pMap;
if (g_pMain->m_nServerNo != pMap->m_nServerNo)
{
_ZONE_SERVERINFO *pInfo = g_pMain->m_ServerArray.GetData(pMap->m_nServerNo);
if (pInfo == nullptr)
return true;
UserDataSaveToAgent();
m_bLogout = 2; // server change flag
SendServerChange(pInfo->strServerIP, 2);
return true;
}
SetRegion(GetNewRegionX(), GetNewRegionZ());
Packet result(WIZ_ZONE_CHANGE, uint8(ZoneChangeTeleport));
result << uint16(GetZoneID()) << GetSPosX() << GetSPosZ() << GetSPosY() << g_pMain->m_byOldVictory;
Send(&result);
if (!m_bZoneChangeSameZone)
{
m_sWhoKilledMe = -1;
m_iLostExp = 0;
m_bRegeneType = 0;
m_tLastRegeneTime = 0;
m_sBind = -1;
InitType3();
InitType4();
CMagicProcess::CheckExpiredType9Skills(this, true);
SetUserAbility();
}
result.Initialize(AG_ZONE_CHANGE);
result << GetSocketID() << GetZoneID();
Send_AIServer(&result);
m_bZoneChangeSameZone = false;
m_bZoneChangeFlag = false;
return true;
} Ekliyoruz..
Bu Arenadan Cıkış NPC 13010_Move.lua Kodları..
-----
-- Sample Lua script.
-----
-- Globals
pUser = nil
pNpc = nil
local eventMap = {
[500] = function() pUser:SelectMsg(2, 407, 4070, 4070, 501, 10, CancelButton) end,
[501] = Event501,
}
function Main(event)
print("Event: " .. event)
local func = eventMap[event]
if (func and type(func) == "function") then
func()
end
end
function DefaultMenu()
-- Sample menu
pUser:SelectMsg(2, -- unknown flag
-1, -- quest ID
191, -- menu header text/type
11, 10, -- text | event
20, 20)
-- Sample new-style menu/dialog (does whatever's needed by the NPC, apparently)
-- pUser:NpcMsg(193, 16079)
-- Other sample uses
-- pUser:GiveItem(910014000, 1) -- give player the Kiss item
-- pUser:RobItem(910014000, 1) -- take Kiss item from player
-- pUser:ShowMap(1)
end
function Event501()
pUser:ZoneChangeParty(21,818,441)
end
function HandleSomeButton()
pUser:KissUser()
end
Ve Artık LUA System ZoneChangeParty Fonksiyonu Aktif..