[HELP] condition isDead

Hi everyone !

I have a trouble with a contition which check if the creature is dead.

This condition is the following but it doesn’t work :

if (Creature* pDrok = Unit::GetCreature(*me, DrokGUID))
if (pDrok->isDead())
events.ScheduleEvent(EVENT_IRIS_13, 2000);

I have already make this kind of condition in another custom code and it works !

Please, can you healp me ?

Regards.

Belitharian.

Have you tested that the creature is actually found?

How does it not work? Does it always return false? True?

Did you test that it doesnt work with something like a message instead of the timed event?

^All above: Are you sure the fault is in isDead()?

Try !isAlive() ?

?

Thanks for your answer !

I’m testing…

How can I do to return false or true ?

Well, It returns true if the code after it is run…

false otherwise.

So you could just test if a message after it is run or not, if not, it was false.

I tested with :

if (pDrok->isDead())
{
me->MonsterSay(JainaEnd1, LANG_UNIVERSAL, 0);
events.ScheduleEvent(EVENT_IRIS_13, 2000);
}

I tested with [FONT=‘courier new’]if (!pDrok->isAlive())[/FONT] but nothing work.

No message, so, it is false ?

EDIT : It works with [FONT=‘courier new’]if (pDrok->isAlive()) [/FONT]or [FONT=‘courier new’]if (!pDrok->isDead())[/FONT] but it isn’t what I want. /emoticons/default_sad.png

What do you want then?

It seems that the NPC is alive.

I just tested if with FONT=‘courier new’[/FONT]the timed event works and she talks… It functions.

But I want when the NPC is DEAD. It must be a conslusion. Sorry for the quiproquo…

EDIT : I’m on a good way ! It almost works…

To help you “we” need more information.

This code snippet is nowhere enough when we dont know when the event is executed.

As seen, the function is not the problem, the problem is when you are calling it and what the creature’s state is at that time.

It works !!

case EVENT_IRIS_13_0:
if (Creature* pDrok = Unit::GetCreature((*me), DrokGUID))
if (pDrok->isDead())
{
events.ScheduleEvent(EVENT_IRIS_13, 5000);
return;
}
else
events.ScheduleEvent(EVENT_IRIS_13_0, 1000);
break;

What do you think of that ? /emoticons/default_smile.png

You are checking every second if Drok is there and if he is dead.

Possibly not the most efficent solution, but due to lack of visible code … the only solution at the time …

Dont even know the creature state or anything …

Creatures states are :

  • Jaina is channelling a spell.

  • Drok is alive and in combat.

I put it to solved ?