[DiscordArchive] Then also why use 0 as a case?
[DiscordArchive] Then also why use 0 as a case?
Archived author: M'Dic • Posted: 2023-10-29T13:04:01.047000+00:00
Original source
Then also why use 0 as a case?
Archived author: M'Dic • Posted: 2023-10-29T13:04:19.941000+00:00
Original source
That can be a bit of a recipe for disaster... well to me atleast.
Archived author: M'Dic • Posted: 2023-10-29T13:04:33.081000+00:00
Original source
Will action false also trigger the case?
Archived author: M'Dic • Posted: 2023-10-29T13:05:07.870000+00:00
Original source
Unless thats not possible in todays time
Archived author: wakemeup • Posted: 2023-10-29T13:15:09.102000+00:00
Original source
ValueObject to the rescue..
Archived author: Alistar • Posted: 2023-10-29T13:16:48.414000+00:00
Original source
btw player can be null here and you're dereferencing
Archived author: Alistar • Posted: 2023-10-29T13:22:15.114000+00:00
Original source
Also why not use an EventMap and do all tests in UpdateAI() and when DoAction is called by another script schedule an event
Archived author: M'Dic • Posted: 2023-10-29T13:32:58.422000+00:00
Original source
Cuz it was chatgpt generated dude
Archived author: Alistar • Posted: 2023-10-29T13:45:08.850000+00:00
Original source
```c++
enum eTestNpc
{
EVENT_ATTACK = 1,
ACTION_ATTACK = 1
};
struct npc_test : public ScriptedAI
{
npc_test(Creature* creature)
: ScriptedAI(creature)
{
}
void Reset() override
{
m_Events.Reset();
}
void DoAction(int32 action) override
{
if (action == ACTION_ATTACK)
m_Events.ScheduleEvent(EVENT_ATTACK, 3s);
}
void UpdateAI(uint32 diff) override
{
m_Events.Update(diff);
while (uint32 eventId = m_Events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_ATTACK:
{
if (!me->GetVictim())
break;
if (Player* victim = me->GetVictim()->ToPlayer())
{
if (me->GetDistance(victim) <= m_MinDistance)
{
// Some code
m_Events.Repeat(3s);
}
}
break;
}
}
}
}
private:
const float m_MinDistance = 6.0f;
EventMap m_Events;
};
```
This should help if I understood you correctly. Also it might be better to just use MoveInLineOfSight for what you're trying to achieve