Trinitycore: Core/Spells: Player can't cast spells on certain friendly NPCs

Created on 1 Feb 2021  路  9Comments  路  Source: TrinityCore/TrinityCore

Description:

Player can't cast spells on certain friendly NPCs, spell simply redirects to player.
Works if you add UNIT_FLAG_PLAYER_CONTROLLED to creature. UNIT_FLAG_PLAYER_CONTROLLED should be never added to DB.
Personally I think there is something wrong globally in logic that allows to cast spells on friendly faction units. I can't buff lots of creatures, nearly all. Should I? I don't know. In several quests you're supposed to cast spell on friendly creatures

Expected behaviour:

Player should be able to cast spells on certain friendly NPCs

Steps to reproduce the problem:

create dwarf priest
.level 79
.learn my trainer
.npc add temp 12427
.q a 5625
find in spellbook Lesser Heal (Rank 2) and try to cast on NPC
spell is casted on player instead

Then I applied

UPDATE creature_Template SET unit_Flags = unit_flags | 8 WHERE entry IN (12427)

.reload creature_Template 12427
.npc add tem 12427
find in spellbook Lesser Heal (Rank 2) and try to cast on NPC
works

Branch(es): 3.3.5
TC rev. hash/commit: e5518b53fa37fbcf401db635d95099b474a916d0

Branch-3.3.5a Comp-Core Sub-Creature Sub-Spells

All 9 comments

This is pvp flagging related

Also no, this is NOT anything wrong with serverside targeting logic, such "redirection" happens on client (and it only "redirects" because you have auto self cast enabled)

[4] UpdateType: CreateObject1
[4] GUID: Full: 0xF13000308B035C61 Type: Creature Entry: 12427 Low: 220257
[4] Object Type: 3 (Unit)
[4] Update Flags: 96 (Living, StationaryObject)
[4] Movement Flags: 0 (None)
[4] Extra Movement Flags: 0 (None)
[4] Time: 1068626106
[4] Position: X: -5668.6924 Y: -454.09006 Z: 394.46713
[4] Orientation: 1.797689080238342285
[4] Fall Time: 0
[4] Walk Speed: 2.5
[4] Run Speed: 8
[4] RunBack Speed: 4.5
[4] Swim Speed: 4.722222328186035156
[4] SwimBack Speed: 2.5
[4] Turn Speed: 7
[4] Fly Speed: 4.5
[4] FlyBack Speed: 3.141592741012573242
[4] Pitch Speed: 3.141592741012573242
[4] OBJECT_FIELD_GUID: Full: 0xF13000308B035C61 Type: Creature Entry: 12427 Low: 220257
[4] OBJECT_FIELD_TYPE: 9
[4] OBJECT_FIELD_ENTRY: 12427
[4] OBJECT_FIELD_SCALE_X: 1
[4] UNIT_FIELD_BYTES_0: 0/1/0/1
[4] UNIT_FIELD_HEALTH: 100
[4] UNIT_FIELD_POWER3: 100/1.4E-43
[4] UNIT_FIELD_POWER4: 100/1.4E-43
[4] UNIT_FIELD_POWER5: 1000000/1.401298E-39
[4] UNIT_FIELD_MAXHEALTH: 137/1.92E-43
[4] UNIT_FIELD_MAXPOWER3: 100/1.4E-43
[4] UNIT_FIELD_MAXPOWER4: 100/1.4E-43
[4] UNIT_FIELD_MAXPOWER5: 1000000/1.401298E-39
[4] UNIT_FIELD_LEVEL: 7/1E-44
[4] UNIT_FIELD_FACTIONTEMPLATE: 55/7.7E-44 (55)
[4] UNIT_VIRTUAL_ITEM_SLOT_ID: 2557/3.583E-42
[4] UNIT_VIRTUAL_ITEM_SLOT_ID + 2: 2552/3.576E-42
[4] UNIT_FIELD_BASEATTACKTIME: 2000/2.803E-42
[4] UNIT_FIELD_UNK63: 2000/2.803E-42
[4] UNIT_FIELD_BOUNDINGRADIUS: 0.347
[4] UNIT_FIELD_COMBATREACH: 1.5
[4] UNIT_FIELD_DISPLAYID: 12474/1.748E-41
[4] UNIT_FIELD_NATIVEDISPLAYID: 12474/1.748E-41
[4] UNIT_FIELD_BYTES_1: 8/0/0/0
[4] UNIT_MOD_CAST_SPEED: 1065353216/1
[4] UNIT_FIELD_BYTES_2: 1/1/0/0
[4] UNIT_FIELD_HOVERHEIGHT: 1

Yep, there should be PvP flag

Thank you for the discussion, I had completely forgotten the part about game client being set to auto self cast.

I am try to auto self is off and still can't use the spell on npc

I am also having this issue as a Night Elf with the Quest "Garments of the moon" I know this quest was working at some point in the past and I am not sure at what point it broke again. This may not even be relevant, but when I select Sentinel Shaya and admin command .cast spell 2052 I get "invalid target" and the spell fails and the self auto cast doesn't make a difference.

Maybe you could try using the cast command with the self parameter while having selected the target NPC?

.cast self 2052
.cast self 1243

Ok, that was interesting it forces Sentinel Shaya to cast the spells on her self, however it did not complete the quest. Btw I should be on a very recent version as I just updated source and db a few days ago.

TrinityCore rev. bce5d0c25a51 2021-03-23 00:24:53 +0200 (3.3.5 branch) (Unix, RelWithDebInfo, Static)

Tested the same. It does look odd that the NPC casts a priest spell on itself, so it is clear that this is not the correct spell behaviour. Anyway, unless something could be possible via SAI and not from the command line, it still looks like the spell scripting needs to be made more versatile.

edit: BTW, TrinityCore rev. 80f30d5ca94f 2021-03-26 13:26:21 +0100 (3.3.5 branch) (Win64, Release, Static)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jerbookins picture jerbookins  路  3Comments

besplash picture besplash  路  3Comments

Lopfest picture Lopfest  路  3Comments

Rushor picture Rushor  路  3Comments

funjoker picture funjoker  路  3Comments