- Katılım
- 7 Nis 2025
- Konular
- 75
- Mesajlar
- 485
- Çözümler
- 1
- Tepkime puanı
- 114
- Puan
- 93
- Konum
- İstanbul
- Web sitesi
- forumagel.com
GuardNPC olan npcler kendi krallığından olmayan oyunculara saldırıp anında öldürüyor.
C++:
bool CHARACTER::IsGuardNPC() const
{
return IsNPC() && (GetRaceNum() == 11000 || GetRaceNum() == 11001 || GetRaceNum() == 11002 || GetRaceNum() == 11003 || GetRaceNum() == 11004 || GetRaceNum() == 11005);
}
//GetRaceNum() == xxxx --> xxx alanı npc vnum'udur. İstediğiniz kadar npcyi || ile ayırıp ekleyebilirsiniz.
C++:
void CHARACTER::__StateIdle_NPC() üstüne ekle.
class FuncGuardFindVictim
{
public:
FuncGuardFindVictim(LPCHARACTER pkChr) :
m_pkChr(pkChr),
m_pkVictim(nullptr),
m_iMaxDistance(pkChr->GetMobAttackRange())
{}
void operator()(LPENTITY ent)
{
if (!ent->IsType(ENTITY_CHARACTER))
return;
LPCHARACTER pkChr = static_cast<LPCHARACTER>(ent);
if (pkChr->IsPC() && pkChr->GetEmpire() != m_pkChr->GetEmpire())
{
int iDistance = DISTANCE_APPROX(m_pkChr->GetX() - pkChr->GetX(), m_pkChr->GetY() - pkChr->GetY());
if (iDistance <= m_iMaxDistance)
{
m_pkVictim = pkChr;
}
}
}
LPCHARACTER GetVictim() const
{
return m_pkVictim;
}
private:
LPCHARACTER m_pkChr;
LPCHARACTER m_pkVictim;
int m_iMaxDistance;
};
else if (IsGuardNPC()) bu else ifi komple aşağıdaki ile değiştir.
else if (IsGuardNPC())
{
if (!quest::CQuestManager::instance().GetEventFlag("noguard"))
{
FuncGuardFindVictim f(this);
if (GetSectree())
{
GetSectree()->ForEachAround(f);
}
LPCHARACTER victim = f.GetVictim();
if (victim)
{
m_dwStateDuration = passes_per_sec / 2;
if (CanBeginFight())
{
BeginFight(victim);
}
}
}
}