Trinitycore: Core/Spells: Spells cast by traps should not miss

Created on 30 Mar 2019  路  12Comments  路  Source: TrinityCore/TrinityCore

Description: When a gob cast a spell it mustn't miss.
the issue could be caused by data1=0 an considered as caster level
GAMEOBJECT_TYPE_TRAP = 6
data1: level (npc equivalent level for casted spell)

Steps to reproduce the problem:

  1. .gob add temp 179526
  2. move around the gob an you will get many misses
  3. with a character level 5 it will miss less

Branch(es): 3.3.5

TC rev. hash/commit: rev. a926a3088d39

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

Most helpful comment

The code that returns the level of the GameObject is https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/game/Entities/GameObject/GameObject.cpp#L1258

When summoning a GameObject with ".gob add temp" command the owner is not set so the GameObject has a default level of 1

All 12 comments

does this behavior apply to all gameobjects ? it should be easy to add a check "if (goCaster) return 100.f; // % chance

But isn't caster being replaced by unit in current code for gameobjects?

For GAMEOBJECT_TYPE_TRAP = 6
data1: level (npc equivalent level for casted spell) is probably used to calculate the result of the cast.
It looks like the only case where the spell could miss.

Slightly disagree with this issue. In PvP hunter traps can miss (How it worked on retail 3.3.5, pvp movies from retail will serve as proof). Probably there's target condition or something else?

Maybe for traps summoned by players data1 must be overwritten by player's level.

the issue could be caused by data1=0 an considered as caster level

I didn't find any reference in the code reading that value at all for traps. If you want to do a test feel free to set it to 255 but it seems not handled to me.

Yes the spell will always miss whatever the value in data1, so probably not implemented at all.

is there a way to spawn 179526 without using gm commands ? is there a spell or so that should summon it ? or how does a player usually summon it ?

The code that returns the level of the GameObject is https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/game/Entities/GameObject/GameObject.cpp#L1258

When summoning a GameObject with ".gob add temp" command the owner is not set so the GameObject has a default level of 1

Personnally I have done the following and it seems to have solved that particular problem. I think the logic is sound, but it does not solve the issue for gameobjects which are not traps but still cast spells (like in some raid fights).

`
uint8 GameObject::getLevelForTarget(WorldObject const* target) const
{
if (Unit* owner = GetOwner())
return owner->getLevelForTarget(target);

if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP) {
if (GetGOInfo()->trap.level != 0)
return GetGOInfo()->trap.level;
if (const Unit* targetUnit = target->ToUnit())
return targetUnit->getLevel();
}

 return 1;

}
`

I presume you intended to format the code similar to this (feel free to copy, edit and use MarkDown to fence & highlight the code):

uint8 GameObject::getLevelForTarget(WorldObject const* target) const
{
    if (Unit* owner = GetOwner())
        return owner->getLevelForTarget(target);

    if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP)
    {
        if (GetGOInfo()->trap.level != 0)
            return GetGOInfo()->trap.level;
        if (const Unit* targetUnit = target->ToUnit())
            return targetUnit->getLevel();
    }

    return 1;
}

(if you intended to make a diff, use ```diff to highlight the code and add +/- as needed)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

besplash picture besplash  路  3Comments

funjoker picture funjoker  路  3Comments

ZenoX92 picture ZenoX92  路  3Comments

Rushor picture Rushor  路  3Comments

DDuarte picture DDuarte  路  3Comments