Item Gossip calling a Spell

Hey folks. I got this script I am working on. I have an item that has a script. The item_script calls

player->CastSpell(…)
. The spell it casts is a ground targeting spell like the Hunter’s Volly spell. I use

const WorldLocation* pos = GetExplTargetDest();
to get the position. (this part is in the spell script, not the item script.) This unfortunately does not work! It returns the location of the player versus where I targetted the spell! This only happens when I use the item to cast the spell however. If I add the spell to my player and cast it that way, it works as expected.

So how can I get the item script to cast this spell properly?

Did you use

void Player::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0);

?
It seems to set the target correctly to the location of xyz

Show us the whole function you use to cast the spell.

bool OnUse(Player* player, Item* item, SpellCastTargets const& /targets/)
{
entryId = item->GetEntry();
player->CastSpell(player, 27651, true);
}

So, the reason I didn’t use

void Player::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0);

was because I wasn’t sure how to get the target location without using

SpellScript::GetExplTargetDest()
first. But I have to call that in a spell script, not the item script, no? Any other way I can supply the targeted coordinates? Maybe it is because I call GetExplTargetDest() in HandleAfterCast()?

Hmm … doesnt

player[COLOR=rgb(102,102,0)]->[COLOR=rgb(102,0,102)]CastSpell[COLOR=rgb(102,102,0)](player[COLOR=rgb(102,102,0)], [COLOR=rgb(0,102,102)]27651[COLOR=rgb(102,102,0)], [COLOR=rgb(0,0,136)]true[COLOR=rgb(102,102,0)]);

[COLOR=rgb(102,102,0)]Automatically cast (without green selection circle or anything) to player location?
It also probably sets the target location to player as well, as the player is the target if you didnt notice /emoticons/default_tongue.png

[COLOR=rgb(102,102,0)]To get a near position you can use something like player->GetNearPoint or something similar. ([COLOR=rgb(102,102,0)]GetNearPoint2D, [COLOR=rgb(102,102,0)]GetNearPosition[COLOR=rgb(102,102,0)])

[COLOR=rgb(102,102,0)]This should get a point relative to the player at some distance in specified angle.

[COLOR=rgb(102,102,0)]Never used it, but I recreated it and then noticed it already existed : |

Not exactly. It does cast with the green selection circle but you are correct that it sets the target location to the player.

Any advise on a work around?

Update! I did some messing around with it, cleared my cache, and you’re right. Using the item doesn’t bring up the [COLOR=rgb(102,102,0)]green selection circle. So, now to figure out why that is.

I have figured out the solution. Thanks for allowing me to bounce some ideas off of you Rochet.