Jump to content

[Question][unit->canFly() ]


Guest mns

Recommended Posts

void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
{
   // Check if caster is player and if this player can fly
   if(m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->CanFly)
   {
       // Your effect
   }
// Recheck immune (only for delayed spells)
if( m_spellInfo->speed && (
.
.
.
.
}

Link to comment
Share on other sites

void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
{
   // Check if caster is player and if this player can fly
   if(m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->CanFly)
   {
       // Your effect
   }
// Recheck immune (only for delayed spells)
if( m_spellInfo->speed && (
.
.
.
.
}

Thx

But This Error !

Spell.cpp(956) : error C3867: 'Player::CanFly': function call missing argument list; use '&Player::CanFly' to create a pointer to member

Link to comment
Share on other sites

also it could be trying to cast a player to creature so try

if(unit->GetTypeId != TYPEID_PLAYER && ((Creature*)unit)->canFly())

Creature* creature = ((Creature*)unit);

if(creature && creature->canFly())
{
}

Thx All :)

These Cods Work Without Crash But Always Return False !

I Think Mangos Can`t Support CanFly() For Creature !

Example :

Return False For This NPC

http://www.wowhead.com/?npc=19514

Please Developers Answer CanFly() Support For Creature Or Not :(

Link to comment
Share on other sites

 bool canFly()  const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }

 INHABIT_AIR    = 4,

You must update in the db columm InhabitType to 4.

hmmm

Thx

Solve My Problem :)

I Use This Query :

 
UPDATE `creature_template` SET `inhabittype` = '4' WHERE `entry` = '19514' ;

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use