Level 120 (L1-L5): exp curve, AVA2 maps/drops, AVA2 dungeon quest support
- L1: level cap 120 with the AVA2 exp curve, 64-bit exp sums, unsigned exp column; level-difference exp/drop floors kept as before. - L2/L3/L5: AVA2 maps and their mob drops (data side in the client repo's tools/server/ava2-maps). - L4: quest functions the AVA2 snow / ship defence / Meley quests call (port_ava2_dungeon.cpp), QUEST_ATTACK_EVENT (<vnum>.attack), Meley and hydra HP helpers. A hit never takes a dragon statue (6230) below 1 HP so only npc.dead_by_vnum kills it (AVA2 could leave the lair stuck). - docs/FEATURE-LEVEL-120.md: plan and sbtest test record (Meley full run passed: 9 floors + chest + exit warp, 837 s). Only installed on sbtest; not deployed live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3222614dd2
commit
3c0141d639
@@ -61,7 +61,7 @@ CPPFILE = BattleArena.cpp FSM.cpp MarkConvert.cpp MarkImage.cpp MarkManager.cpp
|
||||
desc_client.cpp desc_manager.cpp desc_p2p.cpp dev_log.cpp dungeon.cpp empire_text_convert.cpp entity.cpp\
|
||||
entity_view.cpp event.cpp event_queue.cpp exchange.cpp file_loader.cpp fishing.cpp gm.cpp guild.cpp\
|
||||
guild_manager.cpp guild_war.cpp horse_rider.cpp horsename_manager.cpp input.cpp input_auth.cpp input_db.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp port_attr_lock.cpp port_sash.cpp port_mount.cpp port_costume_attr.cpp port_pendant.cpp port_rings.cpp port_switchbot.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp port_attr_lock.cpp port_sash.cpp port_mount.cpp port_costume_attr.cpp port_pendant.cpp port_rings.cpp port_switchbot.cpp port_ava2_dungeon.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
item.cpp item_addon.cpp item_attribute.cpp item_manager.cpp item_manager_idrange.cpp locale.cpp\
|
||||
locale_service.cpp log.cpp login_data.cpp lzo_manager.cpp marriage.cpp matrix_card.cpp\
|
||||
messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
|
||||
|
||||
@@ -267,6 +267,8 @@ void CHARACTER::Initialize()
|
||||
m_bPKMode = PK_MODE_PEACE;
|
||||
|
||||
m_dwQuestNPCVID = 0;
|
||||
m_dwQuestNPCVIDAttack = 0;
|
||||
m_protection_Time.clear();
|
||||
m_dwQuestByVnum = 0;
|
||||
m_pQuestItem = NULL;
|
||||
|
||||
@@ -3142,9 +3144,11 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||
DWORD iExpBalance = 0;
|
||||
|
||||
// 레벨 업!
|
||||
if (exp + amount >= next_exp)
|
||||
// PORT: 64-bit sum; with next_exp up to 4.2e9 (docs/FEATURE-LEVEL-120.md) exp + amount wraps a DWORD
|
||||
const unsigned long long total = (unsigned long long) exp + (unsigned long long) amount;
|
||||
if (total >= next_exp)
|
||||
{
|
||||
iExpBalance = (exp + amount) - next_exp;
|
||||
iExpBalance = (DWORD) (total - next_exp);
|
||||
amount = next_exp - exp;
|
||||
|
||||
SetExp(0);
|
||||
@@ -3152,7 +3156,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||
}
|
||||
else
|
||||
{
|
||||
SetExp(exp + amount);
|
||||
SetExp((DWORD) total);
|
||||
exp = GetExp();
|
||||
}
|
||||
|
||||
@@ -6172,6 +6176,36 @@ LPCHARACTER CHARACTER::GetQuestNPC() const
|
||||
return CHARACTER_MANAGER::instance().Find(m_dwQuestNPCVID);
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON
|
||||
LPCHARACTER CHARACTER::GetQuestNPCAttack() const
|
||||
{
|
||||
return CHARACTER_MANAGER::instance().Find(m_dwQuestNPCVIDAttack);
|
||||
}
|
||||
|
||||
void CHARACTER::SetProtectTime(const std::string& flagname, int value)
|
||||
{
|
||||
m_protection_Time[flagname] = value;
|
||||
}
|
||||
|
||||
int CHARACTER::GetProtectTime(const std::string& flagname) const
|
||||
{
|
||||
std::map<std::string, int>::const_iterator it = m_protection_Time.find(flagname);
|
||||
return it != m_protection_Time.end() ? it->second : 0;
|
||||
}
|
||||
|
||||
bool CHARACTER::IsMeley() const
|
||||
{
|
||||
switch (GetRaceNum())
|
||||
{
|
||||
case 6119:
|
||||
case 6230:
|
||||
case 6231:
|
||||
case 9563:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CHARACTER::SetQuestItemPtr(LPITEM item)
|
||||
{
|
||||
m_pQuestItem = item;
|
||||
|
||||
@@ -1666,6 +1666,20 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
DWORD GetQuestNPCID() const { return m_dwQuestNPCVID; }
|
||||
LPCHARACTER GetQuestNPC() const;
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. The victim of the pc's last attack (npc.*(1, ...) in a
|
||||
// "when <vnum>.attack" handler), per-character int flags ("IsMeleyBlock" blocks all damage), and
|
||||
// the Meley races, which stand still and cast their mob skills every 5 s.
|
||||
void SetQuestNPCIDAttack(DWORD vid) { m_dwQuestNPCVIDAttack = vid; }
|
||||
LPCHARACTER GetQuestNPCAttack() const;
|
||||
void SetProtectTime(const std::string& flagname, int value);
|
||||
int GetProtectTime(const std::string& flagname) const;
|
||||
bool IsMeley() const;
|
||||
// PORT: AVA2 ENABLE_DEFENSAWE_SHIP. The hydra ship's mast (6801) survives d.kill_all/purge and can be
|
||||
// attacked; the hydra (6812) and its crew (6802-6809) ignore players and go for the mast.
|
||||
bool IsHydraNPC() const { return GetRaceNum() == 6801; }
|
||||
bool IsHydra() const { return GetRaceNum() == 6812; }
|
||||
bool IsHydraMob() const { return (GetRaceNum() >= 6802 && GetRaceNum() <= 6809) || IsHydra(); }
|
||||
|
||||
void SetQuestItemPtr(LPITEM item);
|
||||
void ClearQuestItemPtr();
|
||||
LPITEM GetQuestItemPtr() const;
|
||||
@@ -1680,6 +1694,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
|
||||
private:
|
||||
DWORD m_dwQuestNPCVID;
|
||||
DWORD m_dwQuestNPCVIDAttack; // PORT: AVA2 meley lair
|
||||
std::map<std::string, int> m_protection_Time; // PORT: AVA2 meley lair
|
||||
DWORD m_dwQuestByVnum;
|
||||
LPITEM m_pQuestItem;
|
||||
|
||||
|
||||
@@ -261,6 +261,13 @@ bool CHARACTER::Attack(LPCHARACTER pkVictim, BYTE bType)
|
||||
iRet = ComputeSkill(bType, pkVictim);
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON, "when <vnum>.attack" quest event.
|
||||
if (IsPC() && (pkVictim->IsMonster() || pkVictim->IsStone()))
|
||||
{
|
||||
SetQuestNPCIDAttack(pkVictim->GetVID());
|
||||
quest::CQuestManager::instance().Attack(GetPlayerID(), pkVictim->GetRaceNum());
|
||||
}
|
||||
|
||||
//if (test_server && IsPC())
|
||||
// sys_log(0, "%s Attack %s type %u ret %d", GetName(), pkVictim->GetName(), bType, iRet);
|
||||
if (iRet == BATTLE_DAMAGE || iRet == BATTLE_DEAD)
|
||||
@@ -331,7 +338,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
||||
}
|
||||
// END_OF_NO_DEATH_PENALTY_BUG_FIX
|
||||
|
||||
int iLoss = ((GetNextExp() * aiExpLossPercents[MINMAX(1, GetLevel(), PLAYER_EXP_TABLE_MAX)]) / 100);
|
||||
int iLoss = (int) (((unsigned long long) GetNextExp() * aiExpLossPercents[MINMAX(1, GetLevel(), PLAYER_EXP_TABLE_MAX)]) / 100); // PORT: 64-bit, next exp up to 4.2e9
|
||||
|
||||
if (true == LC_IsYMIR())
|
||||
{
|
||||
@@ -1707,6 +1714,13 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||
DAMAGE_CRITICAL = (1 << 5),
|
||||
};
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. A Meley statue turned to stone (npc.set_protect_time "IsMeleyBlock").
|
||||
if (pAttacker && GetProtectTime("IsMeleyBlock") == 1)
|
||||
{
|
||||
SendDamagePacket(pAttacker, 0, DAMAGE_BLOCK);
|
||||
return false;
|
||||
}
|
||||
|
||||
//PROF_UNIT puAttr("Attr");
|
||||
|
||||
//
|
||||
@@ -2291,6 +2305,11 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||
//
|
||||
// !!!!!!!!! ½ÇÁ¦ HP¸¦ ÁÙÀÌ´Â ºÎºÐ !!!!!!!!!
|
||||
//
|
||||
// PORT: AVA2 meley lair. Only the quest kills a statue (npc.dead_by_vnum); one hit past the last
|
||||
// stage's 30000 HP threshold (MeleyDungeon 6230.attack) left it dead and the lair stuck.
|
||||
if (GetRaceNum() == 6230 && dam >= GetHP())
|
||||
dam = MAX(0, GetHP() - 1);
|
||||
|
||||
if (!cannot_dead)
|
||||
{
|
||||
PointChange(POINT_HP, -dam, false);
|
||||
@@ -3645,7 +3664,8 @@ void CHARACTER::ChangeVictimByAggro(int iNewAggro, LPCHARACTER pNewVictim)
|
||||
if (itFind != m_map_kDamage.end())
|
||||
{
|
||||
m_iMaxAggro = iNewAggro;
|
||||
SetVictim(CHARACTER_MANAGER::instance().Find(itFind->first));
|
||||
if (!IsHydraMob()) // PORT: AVA2, hydra mobs keep hitting the mast
|
||||
SetVictim(CHARACTER_MANAGER::instance().Find(itFind->first));
|
||||
m_dwStateDuration = 1;
|
||||
}
|
||||
}
|
||||
@@ -3654,7 +3674,8 @@ void CHARACTER::ChangeVictimByAggro(int iNewAggro, LPCHARACTER pNewVictim)
|
||||
if (m_iMaxAggro < iNewAggro)
|
||||
{
|
||||
m_iMaxAggro = iNewAggro;
|
||||
SetVictim(pNewVictim);
|
||||
if (!IsHydraMob()) // PORT: AVA2, hydra mobs keep hitting the mast
|
||||
SetVictim(pNewVictim);
|
||||
m_dwStateDuration = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
BOOL g_test_server;
|
||||
extern LPCHARACTER FindVictim(LPCHARACTER pkChr, int iMaxDistance);
|
||||
extern LPCHARACTER FindVictimHydra(LPCHARACTER pkChr, int iMaxDistance); // PORT: AVA2 port_ava2_dungeon.cpp
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -620,6 +621,30 @@ void CHARACTER::__StateIdle_NPC()
|
||||
|
||||
void CHARACTER::__StateIdle_Monster()
|
||||
{
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. Meley and her statues never move or melee; Meley casts a
|
||||
// mob skill whenever one is ready, then idles 5 s.
|
||||
if (IsMeley())
|
||||
{
|
||||
if (!IsStone() && time(0) > GetProtectTime("MeleyTime"))
|
||||
{
|
||||
if (HasMobSkill())
|
||||
{
|
||||
for (unsigned int iSkillIdx = 0; iSkillIdx < MOB_SKILL_MAX_NUM; ++iSkillIdx)
|
||||
{
|
||||
if (CanUseMobSkill(iSkillIdx) && UseMobSkill(iSkillIdx))
|
||||
{
|
||||
SendMovePacket(FUNC_MOB_SKILL, iSkillIdx, GetX(), GetY(), 0, get_dword_time());
|
||||
float fDuration = CMotionManager::instance().GetMotionDuration(GetRaceNum(), MAKE_MOTION_KEY(MOTION_MODE_GENERAL, MOTION_SPECIAL_1 + iSkillIdx));
|
||||
m_dwStateDuration = (DWORD) (fDuration == 0.0f ? PASSES_PER_SEC(2) : PASSES_PER_SEC(fDuration));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
SetProtectTime("MeleyTime", time(0) + 5);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsStun())
|
||||
return;
|
||||
|
||||
@@ -665,7 +690,7 @@ void CHARACTER::__StateIdle_Monster()
|
||||
if (GetMapIndex() == 61 && quest::CQuestManager::instance().GetEventFlag("xmas_tree"));
|
||||
// 서한산에서 나무가 있으면 선공하지않는다.
|
||||
else
|
||||
victim = FindVictim(this, m_pkMobData->m_table.wAggressiveSight);
|
||||
victim = IsHydraMob() ? FindVictimHydra(this, 40000) : FindVictim(this, m_pkMobData->m_table.wAggressiveSight); // PORT: AVA2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,7 +974,7 @@ void CHARACTER::StateBattle()
|
||||
if (victim && victim->IsDead() &&
|
||||
!no_wander && IsAggressive() && (!GetParty() || GetParty()->GetLeader() == this))
|
||||
{
|
||||
LPCHARACTER new_victim = FindVictim(this, m_pkMobData->m_table.wAggressiveSight);
|
||||
LPCHARACTER new_victim = IsHydraMob() ? FindVictimHydra(this, 40000) : FindVictim(this, m_pkMobData->m_table.wAggressiveSight); // PORT: AVA2
|
||||
|
||||
SetVictim(new_victim);
|
||||
m_dwStateDuration = PASSES_PER_SEC(1);
|
||||
|
||||
@@ -293,22 +293,22 @@ const DWORD exp_table_common[PLAYER_EXP_TABLE_MAX + 1] =
|
||||
2250000000,
|
||||
2280000000,
|
||||
2310000000,
|
||||
2330000000, // 105
|
||||
2350000000,
|
||||
2370000000,
|
||||
2390000000,
|
||||
2400000000,
|
||||
2410000000, // 110
|
||||
2420000000,
|
||||
2430000000,
|
||||
2440000000,
|
||||
2450000000,
|
||||
2460000000, // 115
|
||||
2470000000,
|
||||
2480000000,
|
||||
2490000000,
|
||||
2490000000,
|
||||
2500000000, // 120
|
||||
2330000000, // 105 // PORT: 105-119 rise geometrically to 4.2e9 (docs/FEATURE-LEVEL-120.md); DWORD, player.exp must be INT UNSIGNED
|
||||
2430000000u,
|
||||
2530000000u,
|
||||
2640000000u,
|
||||
2760000000u,
|
||||
2880000000u, // 110
|
||||
3000000000u,
|
||||
3130000000u,
|
||||
3260000000u,
|
||||
3400000000u,
|
||||
3550000000u, // 115
|
||||
3700000000u,
|
||||
3860000000u,
|
||||
4030000000u,
|
||||
4200000000u,
|
||||
4200000000u, // 120 (MAX_LEVEL; never needed)
|
||||
};
|
||||
|
||||
const DWORD exp_table_newcibn[PLAYER_EXP_TABLE_MAX + 1 ] =
|
||||
|
||||
@@ -927,7 +927,7 @@ namespace
|
||||
{
|
||||
LPCHARACTER ch = (LPCHARACTER) ent;
|
||||
|
||||
if (!ch->IsPC() && !ch->IsPet())
|
||||
if (!ch->IsPC() && !ch->IsPet() && !ch->IsHydraNPC()) // PORT: AVA2 hydra mast
|
||||
ch->Dead();
|
||||
}
|
||||
}
|
||||
@@ -942,7 +942,7 @@ namespace
|
||||
{
|
||||
LPCHARACTER ch = (LPCHARACTER) ent;
|
||||
|
||||
if (!ch->IsPC() && !ch->IsPet()) {
|
||||
if (!ch->IsPC() && !ch->IsPet() && !ch->IsHydraNPC()) { // PORT: AVA2 hydra mast
|
||||
M2_DESTROY_CHARACTER(ch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
// PORT: AVA2 dungeon quest functions (questlua_dungeon.cpp dracaryS_DUNGEON_LIB + ENABLE_DEFENSAWE_SHIP,
|
||||
// questlua_npc.cpp ENABLE_MELEY_LAIR_DUNGEON, trigger.cpp FindVictimHydra) for the snow dungeon, the hydra
|
||||
// ship defence and Meley's lair (tools/server/ava2-dungeons in the client repo).
|
||||
// Differences from AVA2: d.mission_notice sends a big notice (no CHAT_TYPE_MISSION here); the statue affect
|
||||
// has no visual (AFFECT_STATUE does not exist), the statues only block damage; the npc.*(1|2, ...) selector
|
||||
// reads the number (AVA2 used lua_isnumber, so it always picked the attack victim).
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "char.h"
|
||||
#include "char_manager.h"
|
||||
#include "dungeon.h"
|
||||
#include "event.h"
|
||||
#include "sectree_manager.h"
|
||||
#include "questmanager.h"
|
||||
#include "questlua.h"
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
|
||||
extern void SendNoticeMap(const char* c_pszBuf, int nMapIndex, bool bBigFont);
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class F> void ForEachCharInMap(long mapIndex, F f)
|
||||
{
|
||||
LPSECTREE_MAP map = SECTREE_MANAGER::instance().GetMap(mapIndex);
|
||||
if (!map)
|
||||
return;
|
||||
struct Each
|
||||
{
|
||||
F& f;
|
||||
void operator () (LPENTITY ent) { if (ent->IsType(ENTITY_CHARACTER)) f((LPCHARACTER) ent); }
|
||||
} each = { f };
|
||||
map->for_each(each);
|
||||
}
|
||||
|
||||
LPDUNGEON CurrentDungeon() { return quest::CQuestManager::instance().GetCurrentDungeon(); }
|
||||
|
||||
// npc.*(1, ...) = the victim of the pc's last attack, npc.*(2, ...) = the quest npc
|
||||
LPCHARACTER SelectNPC(lua_State* L)
|
||||
{
|
||||
quest::CQuestManager& q = quest::CQuestManager::instance();
|
||||
switch ((int) lua_tonumber(L, 1))
|
||||
{
|
||||
case 1: return q.GetCurrentNPCAttackCharacterPtr();
|
||||
case 2: return q.GetCurrentNPCCharacterPtr();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EVENTINFO(warp_all_to_base_event_info)
|
||||
{
|
||||
int x, y;
|
||||
long mapIndex;
|
||||
warp_all_to_base_event_info() : x(0), y(0), mapIndex(0) {}
|
||||
};
|
||||
|
||||
EVENTFUNC(warp_all_to_base_event)
|
||||
{
|
||||
warp_all_to_base_event_info* info = dynamic_cast<warp_all_to_base_event_info*>(event->info);
|
||||
if (!info)
|
||||
return 0;
|
||||
const int x = info->x, y = info->y;
|
||||
ForEachCharInMap(info->mapIndex, [x, y](LPCHARACTER ch) { if (ch->IsPC()) ch->WarpSet(x, y); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WarpAllToBase(int x, int y, long mapIndex, int sec)
|
||||
{
|
||||
warp_all_to_base_event_info* info = AllocEventInfo<warp_all_to_base_event_info>();
|
||||
info->x = x;
|
||||
info->y = y;
|
||||
info->mapIndex = mapIndex;
|
||||
event_create(warp_all_to_base_event, info, PASSES_PER_SEC(sec));
|
||||
}
|
||||
|
||||
// The hydra ship's mast: every 2 s its hp goes to the players ("gethydrahp", AVA2's client bar); once it
|
||||
// is gone the defence failed and everyone is sent back to the cape after 15 s.
|
||||
EVENTINFO(hydra_mast_event_info)
|
||||
{
|
||||
DWORD vid;
|
||||
long mapIndex;
|
||||
hydra_mast_event_info() : vid(0), mapIndex(0) {}
|
||||
};
|
||||
|
||||
EVENTFUNC(hydra_mast_event)
|
||||
{
|
||||
hydra_mast_event_info* info = dynamic_cast<hydra_mast_event_info*>(event->info);
|
||||
if (!info || !SECTREE_MANAGER::instance().GetMap(info->mapIndex))
|
||||
return 0;
|
||||
LPCHARACTER mast = CHARACTER_MANAGER::instance().Find(info->vid);
|
||||
if (!mast)
|
||||
{
|
||||
WarpAllToBase(1108200, 1782400, info->mapIndex, 15);
|
||||
// "15秒后将传送出副本。" (GB2312)
|
||||
SendNoticeMap("15\xc3\xeb\xba\xf3\xbd\xab\xb4\xab\xcb\xcd\xb3\xf6\xb8\xb1\xb1\xbe\xa1\xa3", info->mapIndex, false);
|
||||
sys_log(0, "%ld MapIndex defensawe ship unsuccess", info->mapIndex);
|
||||
if (LPDUNGEON dungeon = CDungeonManager::instance().FindByMapIndex(info->mapIndex))
|
||||
dungeon->SetFlag("Complete", 1);
|
||||
return 0;
|
||||
}
|
||||
const int hp = mast->GetHP();
|
||||
ForEachCharInMap(info->mapIndex, [hp](LPCHARACTER ch) { if (ch->IsPC()) ch->ChatPacket(CHAT_TYPE_COMMAND, "gethydrahp %d", hp); });
|
||||
return PASSES_PER_SEC(2);
|
||||
}
|
||||
}
|
||||
|
||||
// The hydra and its crew only go for the mast (AVA2 FuncFindMobHydraVictim without the building case).
|
||||
LPCHARACTER FindVictimHydra(LPCHARACTER pkChr, int iMaxDistance)
|
||||
{
|
||||
struct Find
|
||||
{
|
||||
LPCHARACTER self, victim;
|
||||
int best, max;
|
||||
void operator () (LPENTITY ent)
|
||||
{
|
||||
if (!ent->IsType(ENTITY_CHARACTER))
|
||||
return;
|
||||
LPCHARACTER ch = (LPCHARACTER) ent;
|
||||
if (!ch->IsHydraNPC() || ch->IsDead())
|
||||
return;
|
||||
const int d = DISTANCE_APPROX(self->GetX() - ch->GetX(), self->GetY() - ch->GetY());
|
||||
if (d < best && d <= max)
|
||||
{
|
||||
victim = ch;
|
||||
best = d;
|
||||
}
|
||||
}
|
||||
} f = { pkChr, NULL, INT_MAX, iMaxDistance };
|
||||
if (pkChr->GetSectree())
|
||||
pkChr->GetSectree()->ForEachAround(f);
|
||||
return f.victim;
|
||||
}
|
||||
|
||||
namespace quest
|
||||
{
|
||||
// d.mission_notice(map index, text)
|
||||
int dungeon_mission_notice(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isstring(L, 2))
|
||||
return 0;
|
||||
const std::string text = lua_tostring(L, 2);
|
||||
ForEachCharInMap(lua_isnumber(L, 1) ? (long) lua_tonumber(L, 1) : dungeon->GetMapIndex(),
|
||||
[&text](LPCHARACTER ch) { if (ch->IsPC()) ch->ChatPacket(CHAT_TYPE_BIG_NOTICE, "%s", text.c_str()); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.global_warp_all_to_base(x, y, map index, seconds)
|
||||
int dungeon_global_warp_all_to_base(lua_State* L)
|
||||
{
|
||||
WarpAllToBase((int) lua_tonumber(L, 1), (int) lua_tonumber(L, 2), (long) lua_tonumber(L, 3), (int) lua_tonumber(L, 4));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.new_kill_all(): kill_all that spares the hydra mast
|
||||
int dungeon_new_kill_all(lua_State* L)
|
||||
{
|
||||
if (LPDUNGEON dungeon = CurrentDungeon())
|
||||
dungeon->KillAll();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.command(cmd): a CHAT_TYPE_COMMAND line to every player in the dungeon
|
||||
int dungeon_command(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isstring(L, 1))
|
||||
return 0;
|
||||
const std::string text = lua_tostring(L, 1);
|
||||
ForEachCharInMap(dungeon->GetMapIndex(), [&text](LPCHARACTER ch) { if (ch->IsPC()) ch->ChatPacket(CHAT_TYPE_COMMAND, "%s", text.c_str()); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.dungeon_remove_all(vnum): takes up to 99 of the item from every player in the dungeon
|
||||
int dungeon_remove_all_item(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isnumber(L, 1))
|
||||
return 0;
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 1);
|
||||
ForEachCharInMap(dungeon->GetMapIndex(), [vnum](LPCHARACTER ch) { if (ch->IsPC()) ch->RemoveSpecifyItem(vnum, 99); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.kill_area(x1, y1, x2, y2): destroys the monsters and stones inside the global rectangle
|
||||
int dungeon_kill_area(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3) || !lua_isnumber(L, 4))
|
||||
return 0;
|
||||
const long x1 = (long) lua_tonumber(L, 1), y1 = (long) lua_tonumber(L, 2), x2 = (long) lua_tonumber(L, 3), y2 = (long) lua_tonumber(L, 4);
|
||||
LPCHARACTER except = CQuestManager::instance().GetCurrentNPCCharacterPtr();
|
||||
std::vector<LPCHARACTER> victims;
|
||||
ForEachCharInMap(dungeon->GetMapIndex(), [&](LPCHARACTER ch) {
|
||||
if (ch != except && !ch->IsPet() && !ch->GetRider() && (ch->IsMonster() || ch->IsStone()) &&
|
||||
x1 <= ch->GetX() && ch->GetX() <= x2 && y1 <= ch->GetY() && ch->GetY() <= y2)
|
||||
victims.push_back(ch);
|
||||
});
|
||||
for (LPCHARACTER ch : victims)
|
||||
M2_DESTROY_CHARACTER(ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.spawn_mob_new(vnum, x, y[, radius[, count]]): d.spawn_mob plus the hydra mast watch; returns the last vid
|
||||
int dungeon_spawn_mob_new(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3))
|
||||
return 0;
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 1);
|
||||
const long x = (long) lua_tonumber(L, 2), y = (long) lua_tonumber(L, 3);
|
||||
const float radius = lua_isnumber(L, 4) ? (float) lua_tonumber(L, 4) : 0;
|
||||
DWORD count = lua_isnumber(L, 5) ? (DWORD) lua_tonumber(L, 5) : 1;
|
||||
DWORD vid = 0;
|
||||
for (count = count ? count : 1; count--; )
|
||||
{
|
||||
long nx = x, ny = y;
|
||||
if (radius >= 1)
|
||||
{
|
||||
const float angle = number(0, 999) * M_PI * 2 / 1000, r = number(0, 999) * radius / 1000;
|
||||
nx += (long) (r * cos(angle));
|
||||
ny += (long) (r * sin(angle));
|
||||
}
|
||||
LPCHARACTER mob = dungeon->SpawnMob(vnum, nx, ny);
|
||||
if (!mob)
|
||||
continue;
|
||||
vid = mob->GetVID();
|
||||
hydra_mast_event_info* info = AllocEventInfo<hydra_mast_event_info>();
|
||||
info->vid = vid;
|
||||
info->mapIndex = dungeon->GetMapIndex();
|
||||
event_create(hydra_mast_event, info, PASSES_PER_SEC(1));
|
||||
}
|
||||
lua_pushnumber(L, vid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// npc.get_protect_time(1|2, flag)
|
||||
int npc_get_protect_time(lua_State* L)
|
||||
{
|
||||
LPCHARACTER ch = lua_isstring(L, 2) ? SelectNPC(L) : NULL;
|
||||
lua_pushnumber(L, ch ? ch->GetProtectTime(lua_tostring(L, 2)) : 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// npc.set_protect_time(1|2, flag, value)
|
||||
int npc_set_protect_time(lua_State* L)
|
||||
{
|
||||
LPCHARACTER ch = lua_isstring(L, 2) && lua_isnumber(L, 3) ? SelectNPC(L) : NULL;
|
||||
if (ch)
|
||||
ch->SetProtectTime(lua_tostring(L, 2), (int) rint(lua_tonumber(L, 3)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_statu_affect(1|2, look): AVA2 turns the statue to stone; only remembered here
|
||||
int npc_set_statu_affect(lua_State* L)
|
||||
{
|
||||
if (LPCHARACTER ch = lua_isnumber(L, 2) ? SelectNPC(L) : NULL)
|
||||
ch->SetProtectTime("Statue", (int) lua_tonumber(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_statu_clear_aff(map index)
|
||||
int npc_set_statu_clear_aff(lua_State* L)
|
||||
{
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) ch->SetProtectTime("Statue", 0); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.show_end_statu(map index)
|
||||
int npc_show_end_statu(lua_State* L)
|
||||
{
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) ch->SetProtectTime("Statue", 3); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.dead_by_vnum(map index, vnum)
|
||||
int npc_dead_by_vnum(lua_State* L)
|
||||
{
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 2);
|
||||
std::vector<LPCHARACTER> victims;
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [&](LPCHARACTER ch) { if (!ch->IsPC() && ch->GetRaceNum() == vnum && !ch->IsDead()) victims.push_back(ch); });
|
||||
for (LPCHARACTER ch : victims)
|
||||
ch->Dead();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.show_statu(map index): re-sends every monster and stone to the players around it
|
||||
int npc_show_statu(lua_State* L)
|
||||
{
|
||||
std::vector<LPCHARACTER> mobs;
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [&](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) mobs.push_back(ch); });
|
||||
for (LPCHARACTER ch : mobs)
|
||||
ch->Show(ch->GetMapIndex(), ch->GetX(), ch->GetY(), ch->GetZ(), true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_meley_hp(map index, vnum, hp)
|
||||
int npc_set_meley_hp(lua_State* L)
|
||||
{
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 2);
|
||||
const int hp = (int) lua_tonumber(L, 3);
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [vnum, hp](LPCHARACTER ch) {
|
||||
if (!ch->IsPC() && ch->GetRaceNum() == vnum)
|
||||
{
|
||||
ch->SetHP(hp);
|
||||
ch->UpdatePacket();
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_protect_flag2(map index, flag, value): on every monster and stone
|
||||
int npc_set_protect_flag2(lua_State* L)
|
||||
{
|
||||
if (!lua_isnumber(L, 1) || !lua_isstring(L, 2) || !lua_isnumber(L, 3))
|
||||
return 0;
|
||||
const std::string flag = lua_tostring(L, 2);
|
||||
const int value = (int) lua_tonumber(L, 3);
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [&](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) ch->SetProtectTime(flag, value); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCHARACTER HPTarget(lua_State* L)
|
||||
{
|
||||
switch ((int) lua_tonumber(L, 1))
|
||||
{
|
||||
case 1: return CQuestManager::instance().GetCurrentNPCAttackCharacterPtr();
|
||||
case 2: return CHARACTER_MANAGER::instance().Find((DWORD) lua_tonumber(L, 2));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// npc.get_hp(1) = attack victim, npc.get_hp(2, vid)
|
||||
int npc_get_hp(lua_State* L)
|
||||
{
|
||||
LPCHARACTER ch = HPTarget(L);
|
||||
if (!ch)
|
||||
return 0;
|
||||
lua_pushnumber(L, ch->GetHP());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// npc.set_hp(1, _, hp) / npc.set_hp(2, vid, hp)
|
||||
int npc_set_hp(lua_State* L)
|
||||
{
|
||||
if (LPCHARACTER ch = HPTarget(L))
|
||||
{
|
||||
ch->SetHP((int) lua_tonumber(L, 3));
|
||||
ch->UpdatePacket();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AddLuaFunctions(lua_State* L, const char* table, const luaL_reg* reg)
|
||||
{
|
||||
lua_getglobal(L, table);
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
sys_err("AVA2 dungeon functions: no lua table %s", table);
|
||||
return;
|
||||
}
|
||||
for (; reg->name; ++reg)
|
||||
{
|
||||
lua_pushstring(L, reg->name);
|
||||
lua_pushcfunction(L, reg->func);
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
// Called after RegisterDungeonFunctionTable/RegisterNPCFunctionTable built the d and npc tables.
|
||||
void RegisterAva2DungeonFunctionTable()
|
||||
{
|
||||
static const luaL_reg dungeon_functions[] =
|
||||
{
|
||||
{ "mission_notice", dungeon_mission_notice },
|
||||
{ "global_warp_all_to_base", dungeon_global_warp_all_to_base },
|
||||
{ "new_kill_all", dungeon_new_kill_all },
|
||||
{ "command", dungeon_command },
|
||||
{ "dungeon_remove_all", dungeon_remove_all_item },
|
||||
{ "kill_area", dungeon_kill_area },
|
||||
{ "spawn_mob_new", dungeon_spawn_mob_new },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
static const luaL_reg npc_functions[] =
|
||||
{
|
||||
{ "get_protect_time", npc_get_protect_time },
|
||||
{ "set_protect_time", npc_set_protect_time },
|
||||
{ "set_statu_affect", npc_set_statu_affect },
|
||||
{ "set_statu_clear_aff", npc_set_statu_clear_aff },
|
||||
{ "show_statu", npc_show_statu },
|
||||
{ "set_meley_hp", npc_set_meley_hp },
|
||||
{ "show_end_statu", npc_show_end_statu },
|
||||
{ "set_protect_flag2", npc_set_protect_flag2 },
|
||||
{ "dead_by_vnum", npc_dead_by_vnum },
|
||||
{ "set_hp", npc_set_hp },
|
||||
{ "get_hp", npc_get_hp },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
lua_State* L = CQuestManager::instance().GetLuaState();
|
||||
AddLuaFunctions(L, "d", dungeon_functions);
|
||||
AddLuaFunctions(L, "npc", npc_functions);
|
||||
}
|
||||
}
|
||||
@@ -349,6 +349,7 @@ bool CPVPManager::CanAttack(LPCHARACTER pkChr, LPCHARACTER pkVictim)
|
||||
switch (pkVictim->GetCharType())
|
||||
{
|
||||
case CHAR_TYPE_NPC:
|
||||
return pkVictim->IsHydraNPC(); // PORT: AVA2 hydra mast, the ship's monsters attack it
|
||||
case CHAR_TYPE_WARP:
|
||||
case CHAR_TYPE_GOTO:
|
||||
return false;
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace quest
|
||||
QUEST_ITEM_PICK_EVENT,
|
||||
QUEST_SIG_USE_EVENT,
|
||||
QUEST_ITEM_INFORMER_EVENT,
|
||||
QUEST_ATTACK_EVENT, // PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON (when <vnum>.attack)
|
||||
QUEST_EVENT_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -490,6 +490,7 @@ namespace quest
|
||||
RegisterDragonLairFunctionTable();
|
||||
RegisterSpeedServerFunctionTable();
|
||||
RegisterDragonSoulFunctionTable();
|
||||
RegisterAva2DungeonFunctionTable(); // PORT: after the d and npc tables
|
||||
|
||||
{
|
||||
luaL_reg member_functions[] =
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace quest
|
||||
extern void RegisterDragonLairFunctionTable();
|
||||
extern void RegisterSpeedServerFunctionTable();
|
||||
extern void RegisterDragonSoulFunctionTable();
|
||||
extern void RegisterAva2DungeonFunctionTable(); // PORT: AVA2 port_ava2_dungeon.cpp, extends d and npc
|
||||
|
||||
extern void combine_lua_string(lua_State* L, std::ostringstream &s);
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace quest
|
||||
m_mapEventName.insert(TEventNameMap::value_type("pick", QUEST_ITEM_PICK_EVENT)); // 떨어져있는 아이템을 습득함.
|
||||
m_mapEventName.insert(TEventNameMap::value_type("sig_use", QUEST_SIG_USE_EVENT)); // Special item group에 속한 아이템을 사용함.
|
||||
m_mapEventName.insert(TEventNameMap::value_type("item_informer", QUEST_ITEM_INFORMER_EVENT)); // 독일선물기능테스트
|
||||
m_mapEventName.insert(TEventNameMap::value_type("attack", QUEST_ATTACK_EVENT)); // PORT: AVA2 meley lair
|
||||
|
||||
m_bNoSend = false;
|
||||
|
||||
@@ -1078,6 +1079,27 @@ namespace quest
|
||||
return GetCurrentCharacterPtr() ? GetCurrentCharacterPtr()->GetQuestNPC() : NULL;
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. The monster/stone the current pc just attacked (when <vnum>.attack).
|
||||
LPCHARACTER CQuestManager::GetCurrentNPCAttackCharacterPtr()
|
||||
{
|
||||
return GetCurrentCharacterPtr() ? GetCurrentCharacterPtr()->GetQuestNPCAttack() : NULL;
|
||||
}
|
||||
|
||||
void CQuestManager::Attack(unsigned int pc, unsigned int npc)
|
||||
{
|
||||
PC * pPC;
|
||||
|
||||
if ((pPC = GetPC(pc)))
|
||||
{
|
||||
if (!CheckQuestLoaded(pPC))
|
||||
return;
|
||||
|
||||
m_mapNPC[npc].OnAttack(*pPC);
|
||||
}
|
||||
else
|
||||
sys_err("QUEST: no such pc id : %d", pc);
|
||||
}
|
||||
|
||||
const string & CQuestManager::GetCurrentQuestName()
|
||||
{
|
||||
return GetCurrentPC()->GetCurrentQuestName();
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace quest
|
||||
|
||||
//void SetCurrentNPCCharacterPtr(LPCHARACTER ch) { m_pkCurrentNPC = ch; }
|
||||
LPCHARACTER GetCurrentNPCCharacterPtr();
|
||||
LPCHARACTER GetCurrentNPCAttackCharacterPtr(); // PORT: AVA2 meley lair
|
||||
|
||||
void SetCurrentEventIndex(int index) { m_iRunningEventIndex = index; }
|
||||
|
||||
@@ -84,6 +85,7 @@ namespace quest
|
||||
bool Timer(unsigned int pc, unsigned int npc);
|
||||
bool Click(unsigned int pc, LPCHARACTER pkNPC);
|
||||
void Kill(unsigned int pc, unsigned int npc);
|
||||
void Attack(unsigned int pc, unsigned int npc); // PORT: AVA2 meley lair
|
||||
void LevelUp(unsigned int pc);
|
||||
void AttrIn(unsigned int pc, LPCHARACTER ch, int attr);
|
||||
void AttrOut(unsigned int pc, LPCHARACTER ch, int attr);
|
||||
|
||||
@@ -323,6 +323,12 @@ namespace quest
|
||||
}
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON
|
||||
bool NPC::OnAttack(PC& pc)
|
||||
{
|
||||
return HandleReceiveAllEvent(pc, QUEST_ATTACK_EVENT);
|
||||
}
|
||||
|
||||
bool NPC::OnPartyKill(PC & pc)
|
||||
{
|
||||
if (m_vnum)
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace quest
|
||||
bool OnClick(PC& pc);
|
||||
bool OnKill(PC& pc);
|
||||
bool OnPartyKill(PC& pc);
|
||||
bool OnAttack(PC& pc); // PORT: AVA2 meley lair
|
||||
bool OnTimer(PC& pc);
|
||||
bool OnLevelUp(PC& pc);
|
||||
bool OnLogin(PC& pc, const char * c_pszQuestName = NULL);
|
||||
|
||||
@@ -638,7 +638,7 @@ namespace quest
|
||||
case RewardData::REWARD_TYPE_EXP:
|
||||
sys_log(0, "EXP cur %d add %d next %d",ch->GetExp(), it->value1, ch->GetNextExp());
|
||||
|
||||
if (ch->GetExp() + it->value1 > ch->GetNextExp())
|
||||
if ((unsigned long long) ch->GetExp() + it->value1 > ch->GetNextExp()) // PORT: 64-bit, next exp up to 4.2e9
|
||||
ch->PointChange(POINT_EXP, ch->GetNextExp() - 1 - ch->GetExp());
|
||||
else
|
||||
ch->PointChange(POINT_EXP, it->value1);
|
||||
|
||||
Reference in New Issue
Block a user