Forums WoW Modding Support Archives TrinityCore Discord Archives [DiscordArchive] Then also why use 0 as a case?

[DiscordArchive] Then also why use 0 as a case?

[DiscordArchive] Then also why use 0 as a case?

rektbyfaith
Administrator
0
10-29-2023, 01:04 PM
#1
Archived author: M'Dic • Posted: 2023-10-29T13:04:01.047000+00:00
Original source

Then also why use 0 as a case?
rektbyfaith
10-29-2023, 01:04 PM #1

Archived author: M'Dic • Posted: 2023-10-29T13:04:01.047000+00:00
Original source

Then also why use 0 as a case?

rektbyfaith
Administrator
0
10-29-2023, 01:04 PM
#2
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.
rektbyfaith
10-29-2023, 01:04 PM #2

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.

rektbyfaith
Administrator
0
10-29-2023, 01:04 PM
#3
Archived author: M'Dic • Posted: 2023-10-29T13:04:33.081000+00:00
Original source

Will action false also trigger the case?
rektbyfaith
10-29-2023, 01:04 PM #3

Archived author: M'Dic • Posted: 2023-10-29T13:04:33.081000+00:00
Original source

Will action false also trigger the case?

rektbyfaith
Administrator
0
10-29-2023, 01:05 PM
#4
Archived author: M'Dic • Posted: 2023-10-29T13:05:07.870000+00:00
Original source

Unless thats not possible in todays time
rektbyfaith
10-29-2023, 01:05 PM #4

Archived author: M'Dic • Posted: 2023-10-29T13:05:07.870000+00:00
Original source

Unless thats not possible in todays time

rektbyfaith
Administrator
0
10-29-2023, 01:15 PM
#5
Archived author: wakemeup • Posted: 2023-10-29T13:15:09.102000+00:00
Original source

ValueObject to the rescue..
rektbyfaith
10-29-2023, 01:15 PM #5

Archived author: wakemeup • Posted: 2023-10-29T13:15:09.102000+00:00
Original source

ValueObject to the rescue..

rektbyfaith
Administrator
0
10-29-2023, 01:16 PM
#6
Archived author: Alistar • Posted: 2023-10-29T13:16:48.414000+00:00
Original source

btw player can be null here and you're dereferencing
rektbyfaith
10-29-2023, 01:16 PM #6

Archived author: Alistar • Posted: 2023-10-29T13:16:48.414000+00:00
Original source

btw player can be null here and you're dereferencing

rektbyfaith
Administrator
0
10-29-2023, 01:22 PM
#7
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
rektbyfaith
10-29-2023, 01:22 PM #7

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

rektbyfaith
Administrator
0
10-29-2023, 01:32 PM
#8
Archived author: M'Dic • Posted: 2023-10-29T13:32:58.422000+00:00
Original source

Cuz it was chatgpt generated dude
rektbyfaith
10-29-2023, 01:32 PM #8

Archived author: M'Dic • Posted: 2023-10-29T13:32:58.422000+00:00
Original source

Cuz it was chatgpt generated dude

rektbyfaith
Administrator
0
10-29-2023, 01:45 PM
#9
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
rektbyfaith
10-29-2023, 01:45 PM #9

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

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)