Skip to content

Commit

Permalink
[11986] Improve targeting for spells with TARGET_TOTEM_* targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmoozerd committed May 4, 2012
1 parent 62a00dc commit b6db6c7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/game/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,27 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_TOTEM_WATER:
case TARGET_TOTEM_AIR:
case TARGET_TOTEM_FIRE:
{
float angle = m_caster->GetOrientation();
switch (targetMode)
{
case TARGET_TOTEM_EARTH: break;
case TARGET_TOTEM_WATER: angle += M_PI_F; break;
case TARGET_TOTEM_AIR: angle += M_PI_F * 0.5f; break;
case TARGET_TOTEM_FIRE: angle += M_PI_F * 1.5f; break;
}

float x, y;
float z = m_caster->GetPositionZ();
// Ignore the BOUNDING_RADIUS for spells with radius (add a small value to prevent < 0 rounding errors)
m_caster->GetNearPoint2D(x, y, radius > 0.001f ? radius - m_caster->GetObjectBoundingRadius() + 0.01f : 2.0f, angle);
m_caster->UpdateAllowedPositionZ(x, y, z);
m_targets.setDestination(x, y, z);

// Add Summoner
targetUnitMap.push_back(m_caster);
break;
}
case TARGET_SELF:
case TARGET_SELF2:
targetUnitMap.push_back(m_caster);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11985"
#define REVISION_NR "11986"
#endif // __REVISION_NR_H__

7 comments on commit b6db6c7

@rsa
Copy link
Contributor

@rsa rsa commented on b6db6c7 May 5, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

author MaxXx2021 (Mioka) if remember correctly. method not fully good, and have some problems - at least possibility summon behind the wal...

@Schmoozerd
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am aware that the position might be behind a wall.
But such a corner case will require some more research (change angle/ change distante?).

Sure it is possible that Mioka wrote a similar patch ago. But I am not aware of this (and as mangos forum is down I could not go on search for such patches)

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, old code where totem created auto select proper point nearest to expected, including LoS check.

@Shauren
Copy link
Contributor

@Shauren Shauren commented on b6db6c7 May 6, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I will share some retail research about this. When a totem (or any other summon, for the record) would be summoned in an invalid position (such as out of LoS) the position is instead moved directly on top of caster.

@Schmoozerd
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you shauren :)
Question about this: Is only the summon position a valid position, or already the position that the spell targets?

@Shauren
Copy link
Contributor

@Shauren Shauren commented on b6db6c7 May 6, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to do testing what is sent in SMSG_SPELL_GO, will do some time soon.

@Shauren
Copy link
Contributor

@Shauren Shauren commented on b6db6c7 May 7, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, here it is http://pastebin.com/ZLeTtzsf

As you can see in sniff, the spell target destination is also set to caster's position (this is only case when dest = caster, no normal case in there)

Please sign in to comment.