From 3db9e63bd96fced0aaeae1b1708e8fb9dbe74c46 Mon Sep 17 00:00:00 2001 From: Grymskvll Date: Sat, 9 Jun 2018 16:56:07 +0200 Subject: [PATCH] Fixed player:HasTalent, changed unit:GetCreatureType description, added creature:GetCreatureFamily --- CreatureMethods.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++- LuaFunctions.cpp | 3 +- PlayerMethods.h | 19 ++++++++----- UnitMethods.h | 25 ++++++++++++++-- 4 files changed, 107 insertions(+), 12 deletions(-) diff --git a/CreatureMethods.h b/CreatureMethods.h index b834a90..25b334a 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2010 - 2016 Eluna Lua Engine * This program is free software licensed under GPL version 3 * Please see the included DOCS/LICENSE.md for more information @@ -1312,5 +1312,75 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); return 0; } #endif + + /** + * Returns the [Creature]'s creature family ID (enumerated in CreatureFamily.dbc). + * + *
+     * enum CreatureFamily
+     * {
+     *     CREATURE_FAMILY_NONE                = 0,    // TrinityCore only
+     *     CREATURE_FAMILY_WOLF                = 1,
+     *     CREATURE_FAMILY_CAT                 = 2,
+     *     CREATURE_FAMILY_SPIDER              = 3,
+     *     CREATURE_FAMILY_BEAR                = 4,
+     *     CREATURE_FAMILY_BOAR                = 5,
+     *     CREATURE_FAMILY_CROCOLISK           = 6,
+     *     CREATURE_FAMILY_CARRION_BIRD        = 7,
+     *     CREATURE_FAMILY_CRAB                = 8,
+     *     CREATURE_FAMILY_GORILLA             = 9,
+     *     CREATURE_FAMILY_HORSE_CUSTOM        = 10,   // Does not exist in DBC but used for horse like beasts in DB
+     *     CREATURE_FAMILY_RAPTOR              = 11,
+     *     CREATURE_FAMILY_TALLSTRIDER         = 12,
+     *     CREATURE_FAMILY_FELHUNTER           = 15,
+     *     CREATURE_FAMILY_VOIDWALKER          = 16,
+     *     CREATURE_FAMILY_SUCCUBUS            = 17,
+     *     CREATURE_FAMILY_DOOMGUARD           = 19,
+     *     CREATURE_FAMILY_SCORPID             = 20,
+     *     CREATURE_FAMILY_TURTLE              = 21,
+     *     CREATURE_FAMILY_IMP                 = 23,
+     *     CREATURE_FAMILY_BAT                 = 24,
+     *     CREATURE_FAMILY_HYENA               = 25,
+     *     CREATURE_FAMILY_BIRD_OF_PREY        = 26,   // Named CREATURE_FAMILY_OWL in Mangos
+     *     CREATURE_FAMILY_WIND_SERPENT        = 27,
+     *     CREATURE_FAMILY_REMOTE_CONTROL      = 28,
+     *     CREATURE_FAMILY_FELGUARD            = 29,   // This and below is TBC+
+     *     CREATURE_FAMILY_DRAGONHAWK          = 30,
+     *     CREATURE_FAMILY_RAVAGER             = 31,
+     *     CREATURE_FAMILY_WARP_STALKER        = 32,
+     *     CREATURE_FAMILY_SPOREBAT            = 33,
+     *     CREATURE_FAMILY_NETHER_RAY          = 34,
+     *     CREATURE_FAMILY_SERPENT             = 35,
+     *     CREATURE_FAMILY_SEA_LION            = 36,   // TBC only
+     *     CREATURE_FAMILY_MOTH                = 37,   // This and below is WotLK+
+     *     CREATURE_FAMILY_CHIMAERA            = 38,
+     *     CREATURE_FAMILY_DEVILSAUR           = 39,
+     *     CREATURE_FAMILY_GHOUL               = 40,
+     *     CREATURE_FAMILY_SILITHID            = 41,
+     *     CREATURE_FAMILY_WORM                = 42,
+     *     CREATURE_FAMILY_RHINO               = 43,
+     *     CREATURE_FAMILY_WASP                = 44,
+     *     CREATURE_FAMILY_CORE_HOUND          = 45,
+     *     CREATURE_FAMILY_SPIRIT_BEAST        = 46
+     * };
+     * 
+ * + * @return [CreatureFamily] creatureFamily + */ + int GetCreatureFamily(lua_State* L, Creature* creature) + { + uint32 entry = creature->GetEntry(); + +#if defined TRINITY || AZEROTHCORE + CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry); + if (cInfo) + Eluna::Push(L, cInfo->family); +#else + CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(entry); + if (cInfo) + Eluna::Push(L, cInfo->Family); +#endif + return 1; + } }; #endif diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 99ab856..a80f6cc 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2010 - 2016 Eluna Lua Engine * This program is free software licensed under GPL version 3 * Please see the included DOCS/LICENSE.md for more information @@ -784,6 +784,7 @@ ElunaRegister CreatureMethods[] = { "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue }, #endif { "GetDBTableGUIDLow", &LuaCreature::GetDBTableGUIDLow }, + { "GetCreatureFamily", &LuaCreature::GetCreatureFamily }, // Setters { "SetHover", &LuaCreature::SetHover }, diff --git a/PlayerMethods.h b/PlayerMethods.h index f8a6ea5..fa88dd1 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2010 - 2016 Eluna Lua Engine * This program is free software licensed under GPL version 3 * Please see the included DOCS/LICENSE.md for more information @@ -25,19 +25,24 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] has a talent by ID in specified talent tree, 'false' otherwise. + * Returns 'true' if the [Player] has a talent by ID in specified spec, 'false' otherwise. * - * @param uint32 talentId : talent ID to check - * @param uint8 spec : specified talent tree + * @param uint32 spellId : talent spellId to check + * @param uint8 spec : specified spec. 0 for primary, 1 for secondary. * @return bool hasTalent */ int HasTalent(lua_State* L, Player* player) { - uint32 talentId = Eluna::CHECKVAL(L, 2); + uint32 spellId = Eluna::CHECKVAL(L, 2); +#ifdef MANGOS + uint8 maxSpecs = MAX_TALENT_SPEC_COUNT; +#else + uint8 maxSpecs = MAX_TALENT_SPECS; +#endif uint8 spec = Eluna::CHECKVAL(L, 3); - if (spec < MAX_TALENT_SPECS) + if (spec >= maxSpecs) return 1; - Eluna::Push(L, player->HasTalent(talentId, spec)); + Eluna::Push(L, player->HasTalent(spellId, spec)); return 1; } diff --git a/UnitMethods.h b/UnitMethods.h index 9cea741..843d063 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2010 - 2016 Eluna Lua Engine * This program is free software licensed under GPL version 3 * Please see the included DOCS/LICENSE.md for more information @@ -1070,9 +1070,28 @@ namespace LuaUnit } /** - * Returns the [Unit]'s creature type ID like wolf or humanoid. + * Returns the [Unit]'s creature type ID (enumerated in CreatureType.dbc). * - * @return uint32 creatureType + *
+     * enum CreatureType
+     * {
+     *     CREATURE_TYPE_BEAST            = 1,
+     *     CREATURE_TYPE_DRAGONKIN        = 2,
+     *     CREATURE_TYPE_DEMON            = 3,
+     *     CREATURE_TYPE_ELEMENTAL        = 4,
+     *     CREATURE_TYPE_GIANT            = 5,
+     *     CREATURE_TYPE_UNDEAD           = 6,
+     *     CREATURE_TYPE_HUMANOID         = 7,
+     *     CREATURE_TYPE_CRITTER          = 8,
+     *     CREATURE_TYPE_MECHANICAL       = 9,
+     *     CREATURE_TYPE_NOT_SPECIFIED    = 10,
+     *     CREATURE_TYPE_TOTEM            = 11,
+     *     CREATURE_TYPE_NON_COMBAT_PET   = 12,     // This and below is TBC+ 
+     *     CREATURE_TYPE_GAS_CLOUD        = 13
+     * };
+     * 
+ * + * @return [CreatureType] creatureType */ int GetCreatureType(lua_State* L, Unit* unit) {