Ejemplo n.º 1
0
bool CMagicState::ValidCast(CSpell* PSpell, CBattleEntity* PTarget)
{
    if (!CheckValidTarget(PTarget))
    {
        PushError(MSGBASIC_CANNOT_ON_THAT_TARG, 0);
        return false;
    }

	if(!m_enableCasting ||
		m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_SILENCE) ||
		m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_MUTE))
	{
        PushError(MSGBASIC_UNABLE_TO_CAST_SPELLS, PSpell->getID());
		return false;
	}

    if (PSpell->getSpellGroup() == SPELLGROUP_NINJUTSU)
    {
        if(m_PEntity->objtype == TYPE_PC && !(m_flags & MAGICFLAGS_IGNORE_TOOLS) && !battleutils::HasNinjaTool(m_PEntity, PSpell, false))
        {
            PushError(MSGBASIC_NO_NINJA_TOOLS, PSpell->getID());
            return false;
        }
    }
    // check has mp available
    else if(!m_PEntity->StatusEffectContainer->HasStatusEffect(EFFECT_MANAFONT) && !(m_flags & MAGICFLAGS_IGNORE_MP) && CalculateMPCost(PSpell) > m_PEntity->health.mp)
    {
        if(m_PEntity->objtype == TYPE_MOB && m_PEntity->health.maxmp == 0)
        {
            ShowWarning("CMagicState::ValidCast Mob (%u) tried to cast magic with no mp!\n", m_PEntity->id);
        }
        PushError(MSGBASIC_NOT_ENOUGH_MP, PSpell->getID());
        return false;
    }

    if (!spell::CanUseSpell(m_PEntity, PSpell->getID()))
    {
        PushError(MSGBASIC_CANNOT_CAST_SPELL, PSpell->getID());
        return false;
    }

    if(PTarget->isDead() && !(PSpell->getValidTarget() & TARGET_PLAYER_DEAD))
    {
        return false;
    }

    if(!PTarget->isDead() && (PSpell->getValidTarget() & TARGET_PLAYER_DEAD))
    {
        return false;
    }

	return true;
}
Ejemplo n.º 2
0
STATESTATUS CMagicState::Update(uint32 tick)
{
	if(CState::Update(tick) == STATESTATUS_ERROR || !CheckValidTarget(m_PTarget))
	{
		return STATESTATUS_ERROR;
	}

	if(m_startTime == 0) m_startTime = tick;

	if(tick - m_startTime >= m_castTime)
	{
		if(CheckInterrupt())
		{
			return STATESTATUS_INTERRUPT;
		}
		else
		{
			return STATESTATUS_FINISH;
		}
	}

	return STATESTATUS_TICK;
}
Ejemplo n.º 3
0
STATESTATUS CMobSkillState::Update(uint32 tick)
{
	PROFILE_FUNC();
  if(CState::Update(tick) == STATESTATUS_ERROR || !CheckValidTarget(m_PTarget))
  {
    return STATESTATUS_ERROR;
  }

  if(m_startTime == 0) m_startTime = tick;

  if(tick - m_startTime >= m_useTime)
  {
    if(!ValidUse())
    {
      return STATESTATUS_INTERRUPT;
    }
    else
    {
      return STATESTATUS_FINISH;
    }
  }

  return STATESTATUS_TICK;
}