示例#1
0
void SpellShell::killSpawn(const Item* deceased)
{
  uint16_t id = deceased->id();
  SpellItem* spell;

  if (m_lastPlayerSpell && (m_lastPlayerSpell->targetId() == id))
    m_lastPlayerSpell = 0;

  QValueList<SpellItem*>::Iterator it = m_spellList.begin();
  while(it != m_spellList.end())
  {
    spell = *it;
    if (spell->targetId() == id)
    {
      it = m_spellList.remove(it);
      emit delSpell(spell);
      delete spell;
    }
    else
      ++it;
  }

  if (m_spellList.count() == 0)
    m_timer->stop();
}
示例#2
0
void SpellShell::timeout()
{
  SpellItem* spell;

  QValueList<SpellItem*>::Iterator it = m_spellList.begin();
  while (it != m_spellList.end()) 
  {
    spell = *it;

    int d = spell->duration() -
      pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6);
    if (d > -6) 
    {
      spell->setDuration(d);
      emit changeSpell(spell);
      it++;
    } 
    else 
    {
      seqInfo("SpellItem '%s' finished.", (*it)->spellName().latin1());
      if (m_lastPlayerSpell == spell)
	m_lastPlayerSpell = 0;
      emit delSpell(spell);
      it = m_spellList.remove(it);
      delete spell;
    }
   }

  if (m_spellList.count() == 0)
    m_timer->stop();
}
示例#3
0
SpellItem* SpellShell::FindSpell(int spell_id, int target_id)
{
  bool target = true;
  const Spell* spell = m_spells->spell(spell_id);
  if (spell)
    target = (spell->targetType() != 6);

  for(QValueList<SpellItem*>::Iterator it = m_spellList.begin();
      it != m_spellList.end(); it++) {
    SpellItem *i = *it;

    //loop to trap a spell being added that is already cast on self.
    if (i->spellId() == spell_id)
    {
      // if it's a targeted spell, check target, else just return the item
      if (target) 
      {
	// if the target id is non-zero, then check it, otherwise return it
	if (i->targetId())
	{
	  // if target id matches then return it
	  if (i->targetId() == target_id)
	    return i;
	}
	else
	  return i; // no target id, return item
      }
      else 
	return i; // non-targeted spell, return item
    }
  }
  return NULL;
}
示例#4
0
//slot for loading buffs when main char struct is loaded
void SpellShell::buffLoad(const spellBuff* c)
{
#ifdef DIAG_SPELLSHELL
  seqDebug("Loading buff - id=%d.",c->spellid);
#endif // DIAG_SPELLSHELL

  const Spell* spell = m_spells->spell(c->spellid);
  int duration = c->duration * 6;
  SpellItem *item = findSpell(c->spellid, m_player->id(), m_player->name());
  if (item) 
  { // exists
    item->update(c->spellid, spell, duration, 
		 0, "Buff", m_player->id(), m_player->name());
    emit changeSpell(item);
  } 
  else 
  { // new spell
    item = new SpellItem();
    item->update(c->spellid, spell, duration, 
		 0, "Buff", m_player->id(), m_player->name());
    m_spellList.append(item);
    if ((m_spellList.count() > 0) && (!m_timer->isActive()))
      m_timer->start(1000 *
		     pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6));
    emit addSpell(item);
  }
}
示例#5
0
void SpellShell::action(const uint8_t* data, size_t, uint8_t)
{
  const actionStruct* a = (const actionStruct*)data;

  if (a->type != 0xe7) // only things to do if action is a spell
    return;

  const Item* s;
  QString targetName;

  if (a->target && 
      ((s = m_spawnShell->findID(tSpawn, a->target))))
    targetName = s->name();

  SpellItem *item = findSpell(a->spell, a->target, targetName);

  if (item || (a->target == m_player->id()))
  {
    int duration = 0;
    const Spell* spell = m_spells->spell(a->spell);
    if (spell)
      duration = spell->calcDuration(a->level) * 6;
    
    QString casterName;
    if (a->source && 
	((s = m_spawnShell->findID(tSpawn, a->source))))
      casterName = s->name();

    if (item)
    {
#ifdef DIAG_SPELLSHELL
      seqDebug("action - found - source=%d (lvl: %d) cast id=%d on target=%d causing %d damage", 
	       a->source, a->level, a->spell, a->target, a->damage);
#endif // DIAG_SPELLSHELL
      
      item->update(a->spell, spell, duration, 
		   a->source, casterName, a->target, targetName);
      emit changeSpell(item);
    }
    else
    {
      // otherwise check for spells cast on us
#ifdef DIAG_SPELLSHELL
      seqDebug("action - new - source=%d (lvl: %d) cast id=%d on target=%d causing %d damage", 
	       a->source, a->level, a->spell, a->target, a->damage);
#endif // DIAG_SPELLSHELL
      
      // only way to get here is if there wasn't an existing spell, so...
      item = new SpellItem();
      item->update(a->spell, spell, duration, 
		   a->source, casterName, a->target, targetName);
      m_spellList.append(item);
      if ((m_spellList.count() > 0) && (!m_timer->isActive()))
	m_timer->start(1000 *
		       pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6));
      emit addSpell(item);
    }    
  }
}
示例#6
0
void SpellShell::UpdateSpell(const castStruct *c)
{
   if (c) {
      SpellItem *item = FindSpell(c->spellId, m_player->getPlayerID(),
         c->targetId);
      item->UpdateSpell(m_spawnShell, m_player->getPlayerID(), c);
      emit changeSpell(item);
   }
}
		void CSEHallOfFameSpellItem::Initialize( UInt32 FormID )
		{
			void* Throwaway = NULL;
			SpellItem* Spell = SpellItem::InitializeDefaultPlayerSpell(Throwaway);
			Spell->name.Set(Title);
			Spell->SetFormID(FormID);
			Spell->SetEditorID(Name);
			Spell->SetFromActiveFile(false);

			_DATAHANDLER->spellItems.AddAt(Spell, eListEnd);
		}
示例#8
0
void SpellShell::selfFinishSpellCast(const memSpellStruct *b)
{
  if (b->param2 != 3)
    return;

   printf("selfFinishSpellCast - id=%d, by=%d\n", b->spellId, b->spawnId);
   SpellItem *item = FindSpell(b->spellId, m_player->getPlayerID(), b->spawnId);
   if (item) {
      struct spellInfoStruct *info = spell_info(b->spellId);
      item->setDuration(info->duration);
   }
}
示例#9
0
void SpellShell::selfStartSpellCast(const uint8_t* data)
{
  const startCastStruct *c = (const startCastStruct *)data;
#ifdef DIAG_SPELLSHELL
  seqDebug("selfStartSpellCast - id=%d (slot=%d, inv=%d) on spawnid=%d", 
	   c->spellId, c->slot, c->inventorySlot, c->targetId);
#endif // DIAG_SPELLSHELL

  // get the target 
  const Item* s;
  QString targetName;
  int duration = 0;
  const Spell* spell = m_spells->spell(c->spellId);
  SpellItem *item;
  if (spell)
    duration = spell->calcDuration(m_player->level()) * 6;

  if (!spell || spell->targetType() != 6)
  {
    if (c->targetId && 
	((s = m_spawnShell->findID(tSpawn, c->targetId))))
      targetName = s->name();
    
    item = findSpell(c->spellId, c->targetId, targetName);
  }
  else
  {
    targetName = m_player->name();
    item = findSpell(c->spellId);
  }

  if (item) 
  { // exists
    item->update(c->spellId, spell, duration,
		 m_player->id(), m_player->name(),
		 c->targetId, targetName);
    emit changeSpell(item);
  } 
  else 
  { // new spell
    item = new SpellItem();
    item->update(c->spellId, spell, duration,
		 m_player->id(), m_player->name(),
		 c->targetId, targetName);
    m_spellList.append(item);
    if ((m_spellList.count() > 0) && (!m_timer->isActive()))
      m_timer->start(1000 *
		     pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6));
    emit addSpell(item);
    m_lastPlayerSpell = item;
  }
}
示例#10
0
void SpellShell::zoneChanged(void)
{
  m_lastPlayerSpell = 0;
  SpellItem* spell;
  for(QValueList<SpellItem*>::Iterator it = m_spellList.begin();
      it != m_spellList.end(); it++) 
  {
    spell = *it;

    // clear all the invalidated spawn ids
    spell->setTargetId(0);
    spell->setCasterId(0);
  }
}
示例#11
0
SpellItem* SpellShell::findSpell(int spell_id)
{
  for(QValueList<SpellItem*>::Iterator it = m_spellList.begin(); 
      it != m_spellList.end(); 
      it++)
  {      
    SpellItem *si = *it;

    if (si->spellId() == spell_id)
      return si;
  }

  return NULL;
}
示例#12
0
SpellItem* SpellShell::FindSpell(int spell_id, int caster_id, int target_id)
{
   for(QValueList<SpellItem*>::Iterator it = m_spellList.begin();
         it != m_spellList.end(); it++) {
      SpellItem *i = *it;
      if ((i->spellId() == spell_id) && (i->casterId() == caster_id)) {
         struct spellInfoStruct *info;
         info = spell_info(spell_id);
         if ( (info->target) && (target_id) ) {
            if (i->targetId() == target_id)
               return i;
         } else return i;
      }
   }
   return NULL;
}
示例#13
0
void SpellShell::buff(const uint8_t* data, size_t, uint8_t dir)
{
  // we only care about the server
  if (dir == DIR_Client)
    return;

  const buffStruct* b = (const buffStruct*)data;

  // if this is the second server packet then ignore it
  if (b->spellid == 0xffffffff)
    return;

#ifdef DIAG_SPELLSHELL
  seqDebug("Changing buff - id=%d from spawn=%d", b->spellid, b->spawnid);
#endif // DIAG_SPELLSHELL

  const Spell* spell = m_spells->spell(b->spellid);

  // find the spell item
  SpellItem* item;
  const Item* s;
  QString targetName;
  if (!spell || spell->targetType() != 6)
  {
    if (b->spawnid && 
	((s = m_spawnShell->findID(tSpawn, b->spawnid))))
      targetName = s->name();
    
    item = findSpell(b->spellid, b->spawnid, targetName);
  }
  else
    item = findSpell(b->spellid);

  if (!item)
    return;

  if (b->changetype == 0x01) // removing buff
    deleteSpell(item);
  else if (b->changetype == 0x02)
  {
    // right now we only know how to find the updated duration
    item->setDuration(b->duration * 6);
    emit changeSpell(item);
  }
}
示例#14
0
SpellItem* SpellShell::FindSpell(int spell_id, int caster_id, int target_id)
{
  bool target = true;
  const Spell* spell = m_spells->spell(spell_id);
  if (spell)
    target = (spell->targetType() != 6);

  for(QValueList<SpellItem*>::Iterator it = m_spellList.begin();
      it != m_spellList.end(); it++) {
    SpellItem *i = *it;
    //loop to trap a spell being added that is already cast on self.
    if ((i->spellId() == spell_id) && (i->casterId() == i->targetId()))
      if (caster_id == target_id)
	return i;
	
    if ((i->spellId() == spell_id) && (i->targetId() == target_id)) 
    {
      if ( (target) && (target_id) ) 
      {
	if (i->targetId() == target_id)
	  return i;
      }
      else return i;
    }
  }
  return NULL;
}
示例#15
0
SpellItem* SpellShell::findSpell(uint16_t spellId, 
				 uint16_t targetId, const QString& targetName)
{
  for(QValueList<SpellItem*>::Iterator it = m_spellList.begin();
      it != m_spellList.end(); 
      it++) 
  {
    SpellItem *i = *it;
    if (i->spellId() == spellId)
    {
      if ((i->targetId() == targetId) || 
	  ((i->targetId() == 0) && (i->targetName() == targetName)))
	return i;
    }
  }

  return NULL;
}
示例#16
0
void SpellShell::killSpawn(const Item* deceased)
{
    uint16_t id = deceased->id();

    if (id == m_player->id())
    {
        // We're dead. No more buffs for us.
        clear();
    }
    else
    {
        SpellItem* spell;

        if (m_lastPlayerSpell && (m_lastPlayerSpell->targetId() == id))
        {
            m_lastPlayerSpell = 0;
        }

        QValueList<SpellItem*>::Iterator it = m_spellList.begin();
        while(it != m_spellList.end())
        {
            spell = *it;
            if (spell->targetId() == id)
            {
                it = m_spellList.remove(it);
                emit delSpell(spell);
                delete spell;
            }
            else
            {
                ++it;
            }
        }

        if (m_spellList.count() == 0)
        {
            m_timer->stop();
        }
    }

}
示例#17
0
void SpellItem::drawSpell()
{
	Q_ASSERT(spell_ != NULL);

	// Setting brush
	this->setPen(this->getDefaultPen());
	this->setBrush(QBrush(colorBackground()));

	float innerRadius = 0.0f;
	float outerRadius = 0.0f;

	// Center part
	if (spell_->isCenterSpell())
	{
		innerSpell_ = new SpellItem(spell_->getCenterSpell(), this, runeImages_, runeEngine_);
		innerSpell_->drawSpell();

		innerRadius = innerSpell_->getTotalRadius();

		// Positioning outer circle
		this->setRect(-outerRadius, -outerRadius, outerRadius * 2, outerRadius * 2);
	}
	else
	{
		innerRune_ = new RuneItem(spell_, this, runeImages_, runeEngine_);
		innerRune_->drawSpell();
		connect(innerRune_, SIGNAL(requestRedraw()),
			this, SLOT(redraw()));

		innerRadius = this->getInnerRadius();
	}

	// Creating and positioning components and their paths
	if (!spell_->getComponents().empty())
	{
		// Creating
		vector<Spell*> spellComponents = spell_->getComponents();
		for (Spell* comp : spellComponents)
		{
			SpellItem* ri = new SpellItem(comp, this, runeImages_, runeEngine_);
			ri->drawSpell();
			this->components_.push_back(ri);
		}

		// Positioning components
		float componentRadius = this->getBiggestComponentRadius();
		componentRadius += innerRadius + _GRAPHICS_SPELLITEM_DISTANCE;
		int i = 0;
		for (SpellItem* ri : components_)
		{
			QPointF pos = getPositionOnSpell(i, this->components_.size(), componentRadius, this->pos());
			ri->setPos(pos);
			this->positionPath(ri, innerRadius);
			++i;
		}

		outerRadius = this->getTotalRadius();
		this->setRect(-outerRadius, -outerRadius, outerRadius * 2, outerRadius * 2);
	}
	else
		outerRadius = innerRadius;

	// Creating and positioning children and their paths
	if (!spell_->getChildren().empty())
	{
		// Creating
		vector<Spell*> spellChildren = spell_->getChildren();
		for (Spell* child : spellChildren)
		{
			// Components
			SpellItem* ri = new SpellItem(child, this, runeImages_, runeEngine_);
			ri->drawSpell();
			this->children_.push_back(ri);
		}

		// Positioning
		float biggestChildRadius = this->getBiggestChildrenRadius();
		biggestChildRadius += outerRadius + _GRAPHICS_SPELLITEM_DISTANCE;
		int i = 0;
		for (SpellItem* ri : children_)
		{
			QPointF pos = getModifierPositionOnSpell(i,
				children_.size(),
				biggestChildRadius,
				this->pos());
			ri->setPos(pos);
			this->positionPath(ri, outerRadius);
			++i;
		}
	}

	// Creating and positioning modifiers
	if (!spell_->getModifiers().empty())
	{
		// Creating
		vector<Spell*> spellModifiers = spell_->getModifiers();
		for (Spell* mod : spellModifiers)
		{
			// Components
			SpellItem* ri = new SpellItem(mod, this, runeImages_, runeEngine_);
			ri->setScale(0.5f);
			ri->drawSpell();
			this->modifiers_.push_back(ri);
		}

		// Positioning
		int i = 0;
		for (SpellItem* ri : modifiers_)
		{
			QPointF pos = getPositionOnSpell(i, modifiers_.size(), innerRadius, this->pos());
			ri->setPos(pos);
			++i;
		}
	}

	if (this->parentItem() == NULL)
		colorCenterPart(true);
}