Jump to content

SD or ELUNA for npc abilities


Recommended Posts

Posted

Hi,

I'm working on a mangos one.

In Karazhan raid, we have some npc (spectral charger) who have to charge every 20 sec. the farthest player and then cast an aoe fear.

I've try to script this in the creature_ai_scripts table.

action1_type : 11 (ACTION_T_CAST)

action1_param1 : 29320 (spell charge)

action1_param2 : 3 (TARGET_T_HOSTILE_LAST_AGGRO)

action1_param3 : 0 (CastFlags ???)

In param2 I need something like "SELECT_TARGET_FARTHEST" who exists in ELUNA system (for TRINITY CORE ??) and not in SD.

How could I resolve this, please ?

Posted

Hi!

The DB EventAI is good solution for simple combat AIs like that you described above, in particular, for instance trash mobs.

Consider event_type=EVENT_T_TIMER (timer during in-combat) for your events (in particular, casts). For an event to repeat, do not forget EFLAG_REPEATABLE in event_flags. The only problem is that the mob with EventAI can target only someone from his aggro list. I just realised the Wiki documentation misses a critical part of EventAI description. So I promise to make this evening a PR with it, and for now, see this part here:

    TARGET_T_SELF                           = 0,            // Self cast

   // Hostile targets
   TARGET_T_HOSTILE                        = 1,            // Our current target (ie: highest aggro)
   TARGET_T_HOSTILE_SECOND_AGGRO           = 2,            // Second highest aggro (generaly used for cleaves and some special attacks)
   TARGET_T_HOSTILE_LAST_AGGRO             = 3,            // Dead last on aggro (no idea what this could be used for)
   TARGET_T_HOSTILE_RANDOM                 = 4,            // Just any random target on our threat list
   TARGET_T_HOSTILE_RANDOM_NOT_TOP         = 5,            // Any random target except top threat

   // Invoker targets
   TARGET_T_ACTION_INVOKER                 = 6,            // Unit who caused this Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF, EVENT_T_RECEIVE_EMOTE, EVENT_T_RECEIVE_AI_EVENT)
   TARGET_T_ACTION_INVOKER_OWNER           = 7,            // Unit who is responsible for Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF, EVENT_T_RECEIVE_EMOTE, EVENT_T_RECEIVE_AI_EVENT)
   TARGET_T_EVENT_SENDER                   = 10,           // Unit who sent an AIEvent that was received with EVENT_T_RECEIVE_AI_EVENT

   // Hostile players
   TARGET_T_HOSTILE_RANDOM_PLAYER          = 8,            // Just any random player on our threat list
   TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER  = 9,            // Any random player from threat list except top threat

An unconventional limatation is that there is no distance parameters here. So, I recommend to consider for your charge spell the TARGET_T_HOSTILE_LAST_AGGRO target type, which refers usually to a healer. As we know, the healers try to stand as far from the combating mobs as possible.

Posted

Hi Olion, and Thx for your explanation.

Using TARGET_T_HOSTILE_LAST_AGGRO seems to be a stopgap imho :)

Lua could find the farthest target but can't cast the second spell (fear) on the first one hit (charge), SD2 don't know the farthest target and the mangos one core doesn't display the visual effect of the first spell (charge) :D

Not easy.

btw, your pr annonce is a good news :)

Posted
btw, your pr annonce is a good news :)

No, it is not a one :)

Here

https://github.com/mangoszero/database/blob/release20/World/Updates/Rel20/20007_13_minor_dbdocs_update.sql#L100

is present the needed change. As it is already a part of Zero DB, it was merged sometime. Applying it to the Wiki is (and was) out of my scope of responsibility.

The EventAI lacks distance-related target types. However, the aggro-defined target is selected with checking the spell properties including range (see this method) if no one of the following castFlags is set in the 3rd parameter:

CAST_TRIGGERED = 2
CAST_FORCE_CAST = 4
CAST_FORCE_TARGET_SELF = 16

So, when you select TARGET_T_HOSTILE_LAST_AGGRO for a spellcast, the core chooses the target to which the spell is applicable from the mob aggro list in the reverse order, i.e. considering the aggro-lowest victim, then next to aggro-lowest so on. This scheme ensures that the spell will not fail silently.

Note if there is just a single target, meeting the spell requirements, in the whole aggro list, then there will be no difference between all TARGET_T_HOSTILE_* types except RANDOM will be the slowest. Maybe for the spellcast discussed (charge), the TARGET_T_HOSTILE_RANDOM_PLAYER will be the most appropriate.

Posted

Hi,

I do something wrong :P

With this row in crature_ai_scripts :

id,creature_id,event_type,event_inverse_phase_mask,event_chance,event_flags,event_param1,event_param2,event_param3,event_param4,action1_type,action1_param1,action1_param2,action1_param3,action2_type,action2_param1,action2_param2,action2_param3,action3_type,action3_param1,action3_param2,action3_param3,comment
1554701,15547,0,0,100,3,20000,20000,20000,20000,11,29320,3,0,11,29321,3,0,0,0,0,0,"Spectral Charger - Cast Charge"

The npc cast "29320" (action1_param1) on the top aggro player (the tank) and don't cast the "29321" (action2_param1).

The world-server.log :

2015-05-04 07:53:04 CreatureEventAI: Event type 0 (script 1554701) triggered for Creature (Entry: 15547 Guid: 85182) (invoked by <no invoker>)
2015-05-04 07:53:04 CreatureEventAI: Process action 11 (script 1554701) triggered for Creature (Entry: 15547 Guid: 85182) (invoked by <no invoker>)
2015-05-04 07:53:04 Sending SMSG_SPELL_START id=29320
2015-05-04 07:53:04 CreatureEventAI: Process action 11 (script 1554701) triggered for Creature (Entry: 15547 Guid: 85182) (invoked by <no invoker>)
2015-05-04 07:53:04 MELEE OUTCOME: miss 43.799999 crit 4.968800 dodge 5.000000 parry 0.000000 block 0.000000
2015-05-04 07:53:04 RollMeleeOutcomeAgainst: skill bonus of -408 for attacker
2015-05-04 07:53:04 RollMeleeOutcomeAgainst: rolled 8860, miss 4379, dodge 500, parry 0, block 0, crit 496
2015-05-04 07:53:04 RollMeleeOutcomeAgainst: GLANCING <5162, 9162)
2015-05-04 07:53:04 WORLD: Sending SMSG_ATTACKERSTATEUPDATE
2015-05-04 07:53:04 DealDamageStart
2015-05-04 07:53:04 deal dmg:5 to health:57999 
2015-05-04 07:53:04 DealDamageAlive
2015-05-04 07:53:04 DealDamageEnd returned 5 damage
2015-05-04 07:53:04 AttackerStateUpdate: (Player) 7 attacked 85182 (TypeId: 3) for 5 dmg, absorbed 0, blocked 0, resisted 0.
2015-05-04 07:53:04 Sending SMSG_SPELL_GO id=29320
2015-05-04 07:53:04 Spell 29320 Effect1 : 58 Targets: Player Lala (Guid: 2), -, -
2015-05-04 07:53:04 CHAT: packet received. type 3, lang 4294967295
2015-05-04 07:53:05 Spell 29320 Effect0 : 96 Targets: Player Lala (Guid: 2), -, -
2015-05-04 07:53:05 Spell 29320 Effect2 : 6 Targets: Player Lala (Guid: 2), -, -
2015-05-04 07:53:05 Spell: Aura is: 4
2015-05-04 07:53:05 Aura: construct Spellid : 29320, Aura : 4 Target : 6 Damage : 0
2015-05-04 07:53:05 Holder of spell 29320 now is in use
2015-05-04 07:53:05 DealDamageStart
2015-05-04 07:53:05 deal dmg:1221 to health:877168 
2015-05-04 07:53:05 DealDamageAlive
2015-05-04 07:53:05 DealDamageEnd returned 1221 damage

Posted

Maybe it is due to one more missing documentation part ;)

enum CastFlags
   CAST_INTERRUPT_PREVIOUS     = 0x01,                     // Interrupt any spell casting
   CAST_TRIGGERED              = 0x02,                     // Triggered (this makes spell cost zero mana and have no cast time)
   CAST_FORCE_CAST             = 0x04,                     // Forces cast even if creature is out of mana or out of range
   CAST_NO_MELEE_IF_OOM        = 0x08,                     // Prevents creature from entering melee if out of mana or out of range
   CAST_FORCE_TARGET_SELF      = 0x10,                     // Forces the target to cast this spell on itself
   CAST_AURA_NOT_PRESENT       = 0x20,                     // Only casts the spell if the target does not have an aura from the spell

The most spells cannot be used in any "caster -> target" mode you want to.

Of the mentioned spells, 29320 has target type 6 (TARGET_UNIT_TARGET_ENEMY in 3.3.5, I believe this name is correct but not a strange to me TARGET_CHAIN_DAMAGE from One), which means any enemy unit, for all 3 spell effects. So casting mob->player is ok until they are not friendly to each other.

29321 has target type 22/15 (TARGET_SRC_CASTER/TARGET_UNIT_SRC_AREA_ENEMY) being AoE selfcast spell with effect radius index 14, i.e. 8 yards (or meters, what do you like better). When you try to cast it with the same mode mob->player, it may either fail silently or be casted in the mob->mob mode (and the targets in 8 yrds around the mob become feared). The choice depends on the implementation, I did not read the core about it.

EventAI gives you the possibility to cast the spell in the EventAI target->target mode with the CAST_FORCE_TARGET_SELF cast flag. However I doubt that it is a desired behaviour because fear will be applied to units hostile to the spell caster, i.e. hostile to the player in your case. The 29321 should be casted in the mob->mob mode, so contact enemies get the fear. With the 29320 charge, you succeded already, this is a mechanic for the mob to damage distant enemies. It seems logical to throw fear upon contact combatants and right after that to use charge to gamage a distant combatant. Your order of action_type-s will do the same.

So, if the mob was fighting with any enemy in contact, 29321 should not fail, but better you use correct EventAI target type TARGET_T_SELF for it. I do not know either, will the core write log for mob1->mob2 spellcast in case you tanked the mob by your hunter's (warlock's...) pet. Also feel free to experiment :) with 1) target for 29320 charge (TARGET_T_HOSTILE_RANDOM_NOT_TOP, for example) and 2) separate casts of the two spells in different EventAI commands with non-overlapping timers (like 5th, 15th ... second for one spell and 10th, 20th ... for the other).

  • madmax locked this topic

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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