Fixed player:HasTalent, changed unit:GetCreatureType description, added creature:GetCreatureFamily

This commit is contained in:
Grymskvll
2018-06-09 16:56:07 +02:00
parent 9b5499db9c
commit 3db9e63bd9
4 changed files with 107 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
* 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).
*
* <pre>
* 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
* };
* </pre>
*
* @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

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
* 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<Creature> CreatureMethods[] =
{ "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue },
#endif
{ "GetDBTableGUIDLow", &LuaCreature::GetDBTableGUIDLow },
{ "GetCreatureFamily", &LuaCreature::GetCreatureFamily },
// Setters
{ "SetHover", &LuaCreature::SetHover },

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
* 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<uint32>(L, 2);
uint32 spellId = Eluna::CHECKVAL<uint32>(L, 2);
#ifdef MANGOS
uint8 maxSpecs = MAX_TALENT_SPEC_COUNT;
#else
uint8 maxSpecs = MAX_TALENT_SPECS;
#endif
uint8 spec = Eluna::CHECKVAL<uint8>(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;
}

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
* 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
* <pre>
* 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
* };
* </pre>
*
* @return [CreatureType] creatureType
*/
int GetCreatureType(lua_State* L, Unit* unit)
{