Compare commits

...

3 Commits

Author SHA1 Message Date
Trust 2434bab697 Updated for bypass all rule 2024-02-25 16:00:44 -05:00
Trust 7a5a755033 [Bug Fix] Cleanup NPC Mana Tap Logic
Mana Tap rule logic was invalid - Cleaned up and simplified, either we care about npc mana or we dont.
2024-02-25 15:20:58 -05:00
Alex King 35fe38cd09 [Quest API] Add Pet Owner Methods to Perl/Lua (#4115)
* [Quest API] Add Pet Owner Methods to Perl/Lua

- Add `$mob->IsPetOwnerBot()`.
- Add `$mob->IsPetOwnerClient()`.
- Add `$mob->IsPetOwnerNPC()`.

- Add `mob:IsPetOwnerBot()`.
- Add `mob:IsPetOwnerClient()`.
- Add `mob:IsPetOwnerNPC()`.

- Allows operators to use these short hands instead of doing a `GetOwner() && GetOwner()->IsClient()`.

* Update npc.cpp
2024-02-25 00:38:34 -05:00
8 changed files with 62 additions and 17 deletions
+1
View File
@@ -495,6 +495,7 @@ RULE_BOOL(Spells, EvacClearCharmPet, false, "Enable to have evac in zone clear c
RULE_BOOL(Spells, ManaTapsRequireNPCMana, false, "Enabling will require target to have mana to tap. Default off as many npc's are caster class with 0 mana and need fixed.")
RULE_INT(Spells, HarmTouchCritRatio, 200, "Harmtouch crit bonus, on top of BaseCritRatio")
RULE_BOOL(Spells, UseClassicSpellFocus, false, "Enabling will tell the server to handle random focus damage as classic spell imports lack the limit values.")
RULE_BOOL(Spells, ManaTapsOnAnyClass, false, "Enabling this will allow you to cast mana taps on any class, this will bypass ManaTapsRequireNPCMana rule.")
RULE_CATEGORY_END()
RULE_CATEGORY(Combat)
+21
View File
@@ -3249,6 +3249,24 @@ bool Lua_Mob::IsTargetLockPet()
return self->IsTargetLockPet();
}
bool Lua_Mob::IsPetOwnerBot()
{
Lua_Safe_Call_Bool();
return self->IsPetOwnerBot();
}
bool Lua_Mob::IsPetOwnerClient()
{
Lua_Safe_Call_Bool();
return self->IsPetOwnerClient();
}
bool Lua_Mob::IsPetOwnerNPC()
{
Lua_Safe_Call_Bool();
return self->IsPetOwnerNPC();
}
luabind::scope lua_register_mob() {
return luabind::class_<Lua_Mob, Lua_Entity>("Mob")
.def(luabind::constructor<>())
@@ -3648,6 +3666,9 @@ luabind::scope lua_register_mob() {
.def("IsMoving", &Lua_Mob::IsMoving)
.def("IsPausedTimer", &Lua_Mob::IsPausedTimer)
.def("IsPet", (bool(Lua_Mob::*)(void))&Lua_Mob::IsPet)
.def("IsPetOwnerBot", &Lua_Mob::IsPetOwnerBot)
.def("IsPetOwnerClient", &Lua_Mob::IsPetOwnerClient)
.def("IsPetOwnerNPC", &Lua_Mob::IsPetOwnerNPC)
.def("IsRoamer", (bool(Lua_Mob::*)(void))&Lua_Mob::IsRoamer)
.def("IsRooted", (bool(Lua_Mob::*)(void))&Lua_Mob::IsRooted)
.def("IsRunning", (bool(Lua_Mob::*)(void))&Lua_Mob::IsRunning)
+3
View File
@@ -574,6 +574,9 @@ public:
bool IsCharmed();
bool IsFamiliar();
bool IsTargetLockPet();
bool IsPetOwnerBot();
bool IsPetOwnerClient();
bool IsPetOwnerNPC();
};
#endif
+1
View File
@@ -392,6 +392,7 @@ Mob::Mob(
pet_stop = false;
pet_regroup = false;
_IsTempPet = false;
pet_owner_bot = false;
pet_owner_client = false;
pet_owner_npc = false;
pet_targetlock_id = 0;
+7 -4
View File
@@ -1076,10 +1076,12 @@ public:
inline int16 GetTempPetCount() const { return count_TempPet; }
inline void SetTempPetCount(int16 i) { count_TempPet = i; }
bool HasPetAffinity() { if (aabonuses.GivePetGroupTarget || itembonuses.GivePetGroupTarget || spellbonuses.GivePetGroupTarget) return true; return false; }
inline bool IsPetOwnerBot() const { return pet_owner_bot; }
inline void SetPetOwnerBot(bool b) { pet_owner_bot = b; }
inline bool IsPetOwnerClient() const { return pet_owner_client; }
inline void SetPetOwnerClient(bool value) { pet_owner_client = value; }
inline void SetPetOwnerClient(bool b) { pet_owner_client = b; }
inline bool IsPetOwnerNPC() const { return pet_owner_npc; }
inline void SetPetOwnerNPC(bool value) { pet_owner_npc = value; }
inline void SetPetOwnerNPC(bool b) { pet_owner_npc = b; }
inline bool IsTempPet() const { return _IsTempPet; }
inline void SetTempPet(bool value) { _IsTempPet = value; }
inline bool IsHorse() { return is_horse; }
@@ -1838,8 +1840,9 @@ protected:
bool hasTempPet;
bool _IsTempPet;
int16 count_TempPet;
bool pet_owner_client; //Flags regular and pets as belonging to a client
bool pet_owner_npc; //Flags regular and pets as belonging to a npc
bool pet_owner_bot; // Flags pets as belonging to a Bot
bool pet_owner_client; // Flags pets as belonging to a Client
bool pet_owner_npc; // Flags pets as belonging to an NPC
uint32 pet_targetlock_id;
glm::vec3 m_TargetRing;
+10 -3
View File
@@ -2162,7 +2162,9 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns)
}
}
if (swarm_owner->IsNPC()) {
if (swarm_owner->IsBot()) {
SetPetOwnerBot(true);
} else if (swarm_owner->IsNPC()) {
SetPetOwnerNPC(true);
}
} else if (GetOwnerID()) {
@@ -2179,8 +2181,13 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns)
}
}
} else {
if (entity_list.GetNPCByID(GetOwnerID())) {
SetPetOwnerNPC(true);
Mob* owner = entity_list.GetMob(GetOwnerID());
if (owner) {
if (owner->IsBot()) {
SetPetOwnerBot(true);
} else if (owner->IsNPC()) {
SetPetOwnerNPC(true);
}
}
}
}
+18
View File
@@ -3380,6 +3380,21 @@ bool Perl_Mob_IsTargetLockPet(Mob* self)
return self->IsTargetLockPet();
}
bool Perl_Mob_IsPetOwnerBot(Mob* self)
{
return self->IsPetOwnerBot();
}
bool Perl_Mob_IsPetOwnerClient(Mob* self)
{
return self->IsPetOwnerClient();
}
bool Perl_Mob_IsPetOwnerNPC(Mob* self)
{
return self->IsPetOwnerNPC();
}
void perl_register_mob()
{
perl::interpreter perl(PERL_GET_THX);
@@ -3782,6 +3797,9 @@ void perl_register_mob()
package.add("IsOfClientBotMerc", &Perl_Mob_IsOfClientBotMerc);
package.add("IsPausedTimer", &Perl_Mob_IsPausedTimer);
package.add("IsPet", &Perl_Mob_IsPet);
package.add("IsPetOwnerBot", &Perl_Mob_IsPetOwnerBot);
package.add("IsPetOwnerClient", &Perl_Mob_IsPetOwnerClient);
package.add("IsPetOwnerNPC", &Perl_Mob_IsPetOwnerNPC);
package.add("IsPlayerCorpse", &Perl_Mob_IsPlayerCorpse);
package.add("IsRoamer", &Perl_Mob_IsRoamer);
package.add("IsRooted", &Perl_Mob_IsRooted);
+1 -10
View File
@@ -223,16 +223,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
// check to see if target is a caster mob before performing a mana tap
if(GetTarget() && IsManaTapSpell(spell_id)) {
if (
GetTarget()->GetCasterClass() == 'N' &&
(
!RuleB(Spells, ManaTapsRequireNPCMana) ||
(
RuleB(Spells, ManaTapsRequireNPCMana) &&
GetTarget()->GetMana() == 0
)
)
) {
if (!RuleB(Spells, ManaTapsOnAnyClass) && GetTarget()->GetCasterClass() != 'N' && RuleB(Spells, ManaTapsRequireNPCMana) && GetTarget()->GetMana() == 0) {
InterruptSpell(TARGET_NO_MANA, 0x121, spell_id);
return false;
}