本文整理汇总了C++中GetTargetUnit函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTargetUnit函数的具体用法?C++ GetTargetUnit怎么用?C++ GetTargetUnit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetTargetUnit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckCast
SpellCastResult CheckCast()
{
Player* caster = GetCaster()->ToPlayer();
if (GetTargetUnit())
if (Unit* target = GetTargetUnit())
if (!caster->IsFriendlyTo(target) && !caster->IsValidAttackTarget(target))
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
示例2: CheckCast
SpellCastResult CheckCast()
{
Player* caster = GetCaster()->ToPlayer();
if (GetTargetUnit())
if (Player* target = GetTargetUnit()->ToPlayer())
if (caster->GetTeam() != target->GetTeam() && !caster->IsValidAttackTarget(target))
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
示例3: CheckTarget
void CheckTarget(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(EFFECT_0);
if (!GetTargetUnit())
return;
uint32 triggered_spell_id = GetSpellInfo()->Effects[effIndex].TriggerSpell;
// let Rotface handle the cast - caster dies before this executes
if (InstanceScript* script = GetTargetUnit()->GetInstanceScript())
if (Creature* rotface = script->instance->GetCreature(script->GetData64(DATA_ROTFACE)))
rotface->CastSpell(GetTargetUnit(), triggered_spell_id, true, NULL, NULL, GetCaster()->GetGUID());
}
示例4: CheckCast
SpellCastResult CheckCast()
{
Player* caster = GetCaster()->ToPlayer();
if (GetTargetUnit())
if (Player* target = GetTargetUnit()->ToPlayer())
// Fix Penance after Mind Control in arena,
// probably bugged because of the crossfaction script
if (caster->GetOTeam() != target->GetOTeam() && !caster->IsValidAttackTarget(target)
// AllowTwoSide.Interaction.Group will break this spell so
// set friendly also players in your party or raid group
&& !caster->IsInRaidWith(target))
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
示例5: FilterTargets
void FilterTargets(std::list<Unit*>& unitList)
{
if (!GetCaster()->ToPlayer()->GetGroup())
{
unitList.clear();
unitList.push_back(GetCaster());
}
else
{
unitList.remove(GetTargetUnit());
std::list<Unit*> tempTargets;
for (std::list<Unit*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
if ((*itr)->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsInRaidWith(*itr))
tempTargets.push_back(*itr);
if (tempTargets.empty())
{
unitList.clear();
FinishCast(SPELL_FAILED_DONT_REPORT);
return;
}
std::list<Unit*>::const_iterator it2 = tempTargets.begin();
std::advance(it2, urand(0, tempTargets.size() - 1));
unitList.clear();
unitList.push_back(*it2);
}
}
示例6: HandleDummy
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Unit* target = GetTargetUnit())
if (target->GetTypeId() == TYPEID_UNIT && target->HasAura(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3))
// Make sure nobody else is channeling the same target
if (!target->HasAura(SPELL_SCOURGING_CRYSTAL_CONTROLLER))
GetCaster()->CastSpell(target, SPELL_SCOURGING_CRYSTAL_CONTROLLER, true, GetCastItem());
}
示例7: HandleForceCast
void HandleForceCast(SpellEffIndex i)
{
Player * plr = GetHitPlayer();
if (!plr)
return;
plr->CastSpell(GetTargetUnit(), GetSpellInfo()->EffectTriggerSpell[i], true); // Don't send m_originalCasterGUID param here or underlying
PreventHitEffect(i); // AureEffect::HandleAuraControlVehicle will fail on caster == target
}
示例8: HandleScript
void HandleScript(SpellEffIndex /*eff*/)
{
Unit* target = GetTargetUnit();
if (!target)
return;
target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
target->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND);
}
示例9: CheckTarget
SpellCastResult CheckTarget()
{
Unit* target = GetTargetUnit();
if(!target)
return SPELL_FAILED_BAD_TARGETS;
if(target->GetEntry() == NPC_OZZIE_TOGGLEVOLT || target->GetEntry() == NPC_MILLI_FEATHERWHISTLE || target->GetEntry() == NPC_TOG_RUSTSPROCKET)
return SPELL_CAST_OK;
return SPELL_FAILED_BAD_TARGETS;
}
示例10: CheckCast
SpellCastResult CheckCast()
{
if (Player* caster = GetCaster()->ToPlayer())
{
// Death Grip should not be castable while jumping/falling
if (caster->HasUnitState(UNIT_STATE_JUMPING) || caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING))
return SPELL_FAILED_MOVING;
float x = GetTargetUnit()->GetPositionX();
float y = GetTargetUnit()->GetPositionY();
float z = GetTargetUnit()->GetPositionZ();
// Death Grip's minimum range set to 8 yards in PvE
if (GetTargetUnit()->GetTypeId() != TYPEID_PLAYER)
if (caster->GetDistance(x, y, z) < 8)
return SPELL_FAILED_TOO_CLOSE;
}
return SPELL_CAST_OK;
}
示例11: CheckTarget
SpellCastResult CheckTarget()
{
Unit* target = GetTargetUnit();
if(!target || target->GetTypeId() != TYPEID_PLAYER || target->isAlive())
return SPELL_FAILED_BAD_TARGETS;
else if(GetCaster()->ToPlayer()->InArena())
return SPELL_FAILED_NOT_IN_ARENA;
return SPELL_CAST_OK;
}
示例12: CheckRequirement
SpellCastResult CheckRequirement()
{
if (!GetCaster()->HasAura(GetSpellInfo()->Effects[EFFECT_1].CalcValue()))
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; // This is actually correct
if (!GetTargetUnit())
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
示例13: CheckTarget
SpellCastResult CheckTarget()
{
if (IsVampire(GetTargetUnit()))
{
SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_CANT_TARGET_VAMPIRES);
return SPELL_FAILED_CUSTOM_ERROR;
}
return SPELL_CAST_OK;
}
示例14: CheckRequirement
SpellCastResult CheckRequirement()
{
if(!GetCaster()->HasAura(SpellMgr::CalculateSpellEffectAmount(GetSpellInfo(), EFFECT_1)))
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; // This is actually correct
if(!GetTargetUnit())
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
示例15: HandleTriggerMissile
void HandleTriggerMissile(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
Unit* caster = GetCaster();
Unit* target = GetTargetUnit();
if (caster && target)
{
uint32 id = uint32(caster->GetMap()->GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL ? 61912 : 63494);
caster->CastSpell(target, id, true);
}
}