本文整理汇总了C++中SpellCast函数的典型用法代码示例。如果您正苦于以下问题:C++ SpellCast函数的具体用法?C++ SpellCast怎么用?C++ SpellCast使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SpellCast函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AIUpdate
void AIUpdate()
{
float val = RandomFloat(100.0f);
SpellCast(val);
}
示例2: switch
/* virtual */ void COrder_SpellCast::Execute(CUnit &unit)
{
COrder_SpellCast &order = *this;
if (unit.Wait) {
unit.Wait--;
return ;
}
const SpellType &spell = order.GetSpell();
switch (this->State) {
case 0:
// Check if we can cast the spell.
if (!CanCastSpell(unit, spell, order.GetGoal(), order.goalPos)) {
// Notify player about this problem
if (unit.Variable[MANA_INDEX].Value < spell.ManaCost) {
unit.Player->Notify(NotifyYellow, unit.tilePos,
_("%s: not enough mana for spell: %s"),
unit.Type->Name.c_str(), spell.Name.c_str());
} else if (unit.SpellCoolDownTimers[spell.Slot]) {
unit.Player->Notify(NotifyYellow, unit.tilePos,
_("%s: spell is not ready yet: %s"),
unit.Type->Name.c_str(), spell.Name.c_str());
} else if (unit.Player->CheckCosts(spell.Costs, false)) {
unit.Player->Notify(NotifyYellow, unit.tilePos,
_("%s: not enough resources to cast spell: %s"),
unit.Type->Name.c_str(), spell.Name.c_str());
} else {
unit.Player->Notify(NotifyYellow, unit.tilePos,
_("%s: can't cast spell: %s"),
unit.Type->Name.c_str(), spell.Name.c_str());
}
if (unit.Player->AiEnabled) {
DebugPrint("FIXME: do we need an AI callback?\n");
}
if (!unit.RestoreOrder()) {
this->Finished = true;
}
return ;
}
if (CheckForDeadGoal(unit)) {
return;
}
// FIXME FIXME FIXME: Check if already in range and skip straight to 2(casting)
unit.ReCast = 0; // repeat spell on next pass? (defaults to `no')
this->State = 1;
// FALL THROUGH
case 1: // Move to the target.
if (spell.Range && spell.Range != INFINITE_RANGE) {
if (SpellMoveToTarget(unit) == true) {
if (!unit.RestoreOrder()) {
this->Finished = true;
}
return ;
}
return ;
} else {
this->State = 2;
}
// FALL THROUGH
case 2: // Cast spell on the target.
if (!spell.IsCasterOnly() || spell.ForceUseAnimation) {
AnimateActionSpellCast(unit, *this);
if (unit.Anim.Unbreakable) {
return ;
}
} else {
// FIXME: what todo, if unit/goal is removed?
CUnit *goal = order.GetGoal();
if (goal && goal != &unit && !goal->IsVisibleAsGoal(*unit.Player)) {
unit.ReCast = 0;
} else {
unit.ReCast = SpellCast(unit, spell, goal, order.goalPos);
}
}
// Target is dead ? Change order ?
if (CheckForDeadGoal(unit)) {
return;
}
// Check, if goal has moved (for ReCast)
if (unit.ReCast && order.GetGoal() && unit.MapDistanceTo(*order.GetGoal()) > this->Range) {
this->State = 0;
return;
}
if (!unit.ReCast && unit.CurrentAction() != UnitActionDie) {
if (!unit.RestoreOrder()) {
this->Finished = true;
}
return ;
}
break;
default:
this->State = 0; // Reset path, than move to target
break;
}
}