void EffectManager::clearNegativeEffects() { for (unsigned i=effect_list.size(); i > 0; i--) { if (effect_list[i-1].type == "damage") removeEffect(i-1); else if (effect_list[i-1].type == "speed" && effect_list[i-1].magnitude_max < 100) removeEffect(i-1); else if (effect_list[i-1].type == "stun") removeEffect(i-1); } }
void EffectManager::clearNegativeEffects(int type) { for (size_t i=effect_list.size(); i > 0; i--) { if ((type == -1 || type == EFFECT_IMMUNITY_DAMAGE) && effect_list[i-1].type == EFFECT_DAMAGE) removeEffect(i-1); else if ((type == -1 || type == EFFECT_IMMUNITY_DAMAGE) && effect_list[i-1].type == EFFECT_DAMAGE_PERCENT) removeEffect(i-1); else if ((type == -1 || type == EFFECT_IMMUNITY_SLOW) && effect_list[i-1].type == EFFECT_SPEED && effect_list[i-1].magnitude_max < 100) removeEffect(i-1); else if ((type == -1 || type == EFFECT_IMMUNITY_STUN) && effect_list[i-1].type == EFFECT_STUN) removeEffect(i-1); else if ((type == -1 || type == EFFECT_KNOCKBACK) && effect_list[i-1].type == EFFECT_KNOCKBACK) removeEffect(i-1); } }
void NeoVibrateAccessory::setVibrateNow(const bool value, int timeoutMs, int strength) { struct input_event event; //qLog(Modem) << "setVibrateNow " << value << ", timeoutMs=" << timeoutMs << ", strength=" << strength; if (value && rumbleFd < 0) rumbleFd = openRumble(); if (rumbleFd < 0) return; if (value && effectId < 0) effectId = uploadEffect(rumbleFd, (quint16)(strength), timeoutMs); if (effectId < 0) return; // Play/stop the effect event.type = EV_FF; event.code = effectId; event.value = (value ? 1 : 0); if (write(rumbleFd, (const void *)&event, sizeof(event)) == -1) { perror("rumble write"); } if (!value) removeEffect(rumbleFd, effectId, true); QVibrateAccessoryProvider::setVibrateNow(value); }
void Exit::doDispelMagic(BaseRoom* parent) { bringDownTheWall(getEffect("wall-of-fire"), parent, this); bringDownTheWall(getEffect("wall-of-thorns"), parent, this); // true we'll show, false don't remove perm effects removeEffect("concealed", true, false); }
void EffectManager::addEffect(EffectDef &effect, int duration, int magnitude, bool item, int trigger, int passive_id, int source_type) { int effect_type = getType(effect.type); // if we're already immune, don't add negative effects if (immunity_damage && (effect_type == EFFECT_DAMAGE || effect_type == EFFECT_DAMAGE_PERCENT)) return; else if (immunity_slow && effect_type == EFFECT_SPEED && magnitude < 100) return; else if (immunity_stun && effect_type == EFFECT_STUN) return; else if (immunity_knockback && effect_type == EFFECT_KNOCKBACK) return; // only allow one knockback effect at a time if (effect_type == EFFECT_KNOCKBACK && knockback_speed != 0) return; for (size_t i=effect_list.size(); i>0; i--) { if (effect_list[i-1].name == effect.id) { if (trigger > -1 && effect_list[i-1].trigger == trigger) return; // trigger effects can only be cast once per trigger if (!effect.can_stack) removeEffect(i-1); } // if we're adding an immunity effect, remove all negative effects if (effect_type == EFFECT_IMMUNITY) clearNegativeEffects(); else if (effect_type == EFFECT_IMMUNITY_DAMAGE) clearNegativeEffects(EFFECT_IMMUNITY_DAMAGE); else if (effect_type == EFFECT_IMMUNITY_SLOW) clearNegativeEffects(EFFECT_IMMUNITY_SLOW); else if (effect_type == EFFECT_IMMUNITY_STUN) clearNegativeEffects(EFFECT_IMMUNITY_STUN); else if (effect_type == EFFECT_IMMUNITY_KNOCKBACK) clearNegativeEffects(EFFECT_IMMUNITY_KNOCKBACK); } Effect e; e.name = effect.id; e.icon = effect.icon; e.type = effect_type; e.render_above = effect.render_above; if (effect.animation != "") { anim->increaseCount(effect.animation); e.animation = loadAnimation(effect.animation); e.animation_name = effect.animation; } e.ticks = e.duration = duration; e.magnitude = e.magnitude_max = magnitude; e.item = item; e.trigger = trigger; e.passive_id = passive_id; e.source_type = source_type; effect_list.push_back(e); }
void EffectManager::clearEffects() { for (unsigned i=effect_list.size(); i > 0; i--) { removeEffect(i-1); } // clear triggers triggered_others = triggered_block = triggered_hit = triggered_halfdeath = triggered_joincombat = triggered_death = false; }
void Creature::removeStatEffects() { Player* pThis = getAsPlayer(); if(pThis) { pThis->loseRage(); pThis->loseFrenzy(); pThis->losePray(); } removeEffect("strength"); removeEffect("enfeeblement"); removeEffect("haste"); removeEffect("slow"); removeEffect("fortitude"); removeEffect("weakness"); removeEffect("insight"); removeEffect("feeblemind"); removeEffect("prayer"); removeEffect("damnation"); }
/** * Update this entity's status. * * Decreases remaining effect durations for entities. Overloading * implementations should call this method in their base class to ensure that * all time-related processing is completed. * @param[in] deferred A vector of actions to be taken some time after * the entity's present map has finished ticking. * @return true if this entity should be removed from its containing map, false * otherwise. The default implementation is guaranteed to return false */ bool Entity::tick(std::vector<std::function<void()> > &deferred) { for (int i = 0; i < StatusEffect::SE_KINDS; i++) { if (effects[i] && effects[i]->tick(this) <= 0) { removeEffect((StatusEffect::Kind) i); } } return false; }
void MTexturePixmapPrivate::installEffect(MCompositeWindowShaderEffect* effect) { if (effect == prev_effect) return; if (prev_effect) { disconnect(prev_effect, SIGNAL(enabledChanged(bool)), this, SLOT(activateEffect(bool))); disconnect(prev_effect, SIGNAL(destroyed()), this, SLOT(removeEffect())); } current_effect = effect; prev_effect = effect; if (effect) { connect(effect, SIGNAL(enabledChanged(bool)), SLOT(activateEffect(bool)), Qt::UniqueConnection); connect(effect, SIGNAL(destroyed()), SLOT(removeEffect()), Qt::UniqueConnection); } }
bool Entity::removeEffectId(int seid) { BaseEffect *be = BaseEffect::getById(seid); assert(be); if (be) { if (effects[be->kind] && effects[be->kind]->getId() == seid) { return removeEffect((StatusEffect::Kind) be->kind); } } return false; }
QgsEffectStackPropertiesWidget::QgsEffectStackPropertiesWidget( QgsEffectStack *stack, QWidget *parent ) : QgsPanelWidget( parent ) , mStack( stack ) , mPreviewPicture( nullptr ) { // TODO #ifdef Q_OS_MAC //setWindowModality( Qt::WindowModal ); #endif mPresentWidget = nullptr; setupUi( this ); mAddButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) ); mRemoveButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) ); mUpButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) ); mDownButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) ); mModel = new QStandardItemModel(); // Set the effect mEffectsList->setModel( mModel ); QItemSelectionModel* selModel = mEffectsList->selectionModel(); connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( effectChanged() ) ); loadStack( stack ); updatePreview(); connect( mUpButton, SIGNAL( clicked() ), this, SLOT( moveEffectUp() ) ); connect( mDownButton, SIGNAL( clicked() ), this, SLOT( moveEffectDown() ) ); connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addEffect() ) ); connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeEffect() ) ); updateUi(); // set first selected effect as active item in the tree int initialRow = 0; for ( int i = 0; i < stack->count(); ++i ) { // list shows effects in opposite order to stack if ( stack->effect( stack->count() - i - 1 )->enabled() ) { initialRow = i; break; } } QModelIndex newIndex = mEffectsList->model()->index( initialRow, 0 ); mEffectsList->setCurrentIndex( newIndex ); setPanelTitle( tr( "Effects Properties" ) ); }
bool EngineEffectChain::processEffectsRequest(const EffectsRequest& message, EffectsResponsePipe* pResponsePipe) { EffectsResponse response(message); switch (message.type) { case EffectsRequest::ADD_EFFECT_TO_CHAIN: if (kEffectDebugOutput) { qDebug() << debugString() << "ADD_EFFECT_TO_CHAIN" << message.AddEffectToChain.pEffect << message.AddEffectToChain.iIndex; } response.success = addEffect(message.AddEffectToChain.pEffect, message.AddEffectToChain.iIndex); break; case EffectsRequest::REMOVE_EFFECT_FROM_CHAIN: if (kEffectDebugOutput) { qDebug() << debugString() << "REMOVE_EFFECT_FROM_CHAIN" << message.RemoveEffectFromChain.pEffect << message.RemoveEffectFromChain.iIndex; } response.success = removeEffect(message.RemoveEffectFromChain.pEffect, message.RemoveEffectFromChain.iIndex); break; case EffectsRequest::SET_EFFECT_CHAIN_PARAMETERS: if (kEffectDebugOutput) { qDebug() << debugString() << "SET_EFFECT_CHAIN_PARAMETERS" << "enabled" << message.SetEffectChainParameters.enabled << "mix" << message.SetEffectChainParameters.mix; } response.success = updateParameters(message); break; case EffectsRequest::ENABLE_EFFECT_CHAIN_FOR_CHANNEL: if (kEffectDebugOutput) { qDebug() << debugString() << "ENABLE_EFFECT_CHAIN_FOR_CHANNEL" << message.channel; } response.success = enableForChannel(message.channel); break; case EffectsRequest::DISABLE_EFFECT_CHAIN_FOR_CHANNEL: if (kEffectDebugOutput) { qDebug() << debugString() << "DISABLE_EFFECT_CHAIN_FOR_CHANNEL" << message.channel; } response.success = disableForChannel(message.channel); break; default: return false; } pResponsePipe->writeMessages(&response, 1); return true; }
//----------------------------------------------------------------------- void TextureUnitState::setScrollAnimation(Real uSpeed, Real vSpeed) { // Remove existing effects removeEffect(ET_UVSCROLL); removeEffect(ET_USCROLL); removeEffect(ET_VSCROLL); // don't create an effect if the speeds are both 0 if(uSpeed == 0.0f && vSpeed == 0.0f) { return; } // Create new effect TextureEffect eff; if(uSpeed == vSpeed) { eff.type = ET_UVSCROLL; eff.arg1 = uSpeed; addEffect(eff); } else { if(uSpeed) { eff.type = ET_USCROLL; eff.arg1 = uSpeed; addEffect(eff); } if(vSpeed) { eff.type = ET_VSCROLL; eff.arg1 = vSpeed; addEffect(eff); } } }
//---------------------------------------------------------------------------// RenderEffectManager::~RenderEffectManager() { // Destroy any RenderEffect objects we created that still exist. while (!d_effects.empty()) destroy(*d_effects.begin()->first); // Remove (destroy) all the RenderEffectFactory objects. while (!d_effectRegistry.empty()) removeEffect(d_effectRegistry.begin()->first); char addr_buff[32]; sprintf(addr_buff, "(%p)", static_cast<void*>(this)); Logger::getSingleton().logEvent( "CEGUI::RenderEffectManager singleton destroyed " + String(addr_buff)); }
//----------------------------------------------------------------------- void TextureUnitState::setRotateAnimation(Real speed) { // Remove existing effect removeEffect(ET_ROTATE); // don't create an effect if the speed is 0 if(speed == 0.0f) { return; } // Create new effect TextureEffect eff; eff.type = ET_ROTATE; eff.arg1 = speed; addEffect(eff); }
//----------------------------------------------------------------------- void TextureUnitState::setEnvironmentMap(bool enable, EnvMapType envMapType) { if (enable) { TextureEffect eff; eff.type = ET_ENVIRONMENT_MAP; eff.subtype = envMapType; addEffect(eff); } else { removeEffect(ET_ENVIRONMENT_MAP); } }
void EffectManager::removeEffectID(const std::vector< std::pair<std::string, int> >& remove_effects) { for (size_t i = 0; i < remove_effects.size(); i++) { int count = remove_effects[i].second; bool remove_all = (count == 0 ? true : false); for (size_t j = effect_list.size(); j > 0; j--) { if (!remove_all && count <= 0) break; if (effect_list[j-1].id == remove_effects[i].first) { removeEffect(j-1); count--; } } } }
//----------------------------------------------------------------------- void TextureUnitState::setProjectiveTexturing(bool enable, const Frustum* projectionSettings) { if (enable) { TextureEffect eff; eff.type = ET_PROJECTIVE_TEXTURE; eff.frustum = projectionSettings; addEffect(eff); } else { removeEffect(ET_PROJECTIVE_TEXTURE); } }
void EffectManager::addEffect(EffectDef &effect, int duration, int magnitude, bool item, int trigger, int passive_id, int source_type) { // if we're already immune, don't add negative effects if (immunity) { if (effect.type == "damage") return; else if (effect.type == "speed" && magnitude < 100) return; else if (effect.type == "stun") return; } for (unsigned i=effect_list.size(); i>0; i--) { if (effect_list[i-1].name == effect.name) { if (trigger > -1 && effect_list[i-1].trigger == trigger) return; // trigger effects can only be cast once per trigger if (!effect.can_stack) removeEffect(i-1); } // if we're adding an immunity effect, remove all negative effects if (effect.type == "immunity") { clearNegativeEffects(); } } Effect e; e.name = effect.name; e.icon = effect.icon; e.type = effect.type; e.render_above = effect.render_above; if (effect.animation != "") { anim->increaseCount(effect.animation); e.animation = loadAnimation(effect.animation); e.animation_name = effect.animation; } e.ticks = e.duration = duration; e.magnitude = e.magnitude_max = magnitude; e.item = item; e.trigger = trigger; e.passive_id = passive_id; e.source_type = source_type; effect_list.push_back(e); }
void Attribute::update(float dt) { if(!mEffectList.empty()) { int i = 0; cocos2d::Vector<IEffect*> toRemoveEffectList; for( ; i < mEffectList.size(); i++ ) { auto pEffect = mEffectList.at(i); pEffect->updateEffectStatus(dt); if(pEffect->getEffectStatus() == EffectStatus::OVERDUE) { toRemoveEffectList.pushBack(pEffect); } } int j = 0; for(; j < toRemoveEffectList.size(); j++ ) { auto pToRemoveEffect = toRemoveEffectList.at(j); removeEffect(pToRemoveEffect); } if(mIsAttributeDirty) { mIsAttributeDirty = false; int i = 0; mAfterEffectValue = mBaseValue; mIsLockIncrease = false; //恢复默认状态 mIsLockDecrease = false; //恢复默认状态 sortAllEffect(); for( ; i < mEffectList.size(); i++ ) { auto pEffect = mEffectList.at(i); if(pEffect->getEffectStatus() == EffectStatus::EFFECTING) { pEffect->calcuAfterEffectValue(); } } } } }
QgsEffectStackPropertiesWidget::QgsEffectStackPropertiesWidget( QgsEffectStack *stack, QWidget *parent ) : QWidget( parent ) , mStack( stack ) , mPreviewPicture( 0 ) { // TODO #ifdef Q_OS_MAC //setWindowModality( Qt::WindowModal ); #endif mPresentWidget = NULL; setupUi( this ); mAddButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) ); mRemoveButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) ); mUpButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) ); mDownButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) ); mModel = new QStandardItemModel(); // Set the effect mEffectsList->setModel( mModel ); QItemSelectionModel* selModel = mEffectsList->selectionModel(); connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( effectChanged() ) ); loadStack( stack ); updatePreview(); connect( mUpButton, SIGNAL( clicked() ), this, SLOT( moveEffectUp() ) ); connect( mDownButton, SIGNAL( clicked() ), this, SLOT( moveEffectDown() ) ); connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addEffect() ) ); connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeEffect() ) ); updateUi(); // set effect as active item in the tree QModelIndex newIndex = mEffectsList->model()->index( 0, 0 ); mEffectsList->setCurrentIndex( newIndex ); }
bool SDL2FFBDevice::removeAndEraseEffect(const int idx) { CHECK_EFFECT_IDX(idx); if (m_effects[idx]->status() == FFBEffect::FFBEffectStatus::NOT_LOADED) return true; if (removeEffect(idx)) { m_effects[idx] = SDL2FFBEffectFactory::createEffect(FFBEffectTypes::NONE); if (m_effects[idx]->type() != FFBEffectTypes::NONE) { qCritical("Unable to empty the effect slot."); return false; } } else { qCritical("Unable to stop the effect."); return false; } m_effects[idx]->setStatus(FFBEffect::FFBEffectStatus::NOT_LOADED); return true; }
bool Player::checkOppositeResistSpell(bstring effect) { if(effect == "resist-cold" ) removeEffect("resist-fire"); else if(effect == "resist-fire" ) removeEffect("resist-cold"); else if(effect == "resist-earth" ) removeEffect("resist-air"); else if(effect == "resist-air" ) removeEffect("resist-earth"); else if(effect == "resist-water" ) removeEffect("resist-electric"); else if(effect == "resist-electric" ) removeEffect("resist-water"); else return(false); return(true); }
void Entity::struck(Entity *eatk, float dmg) { int idmg; if (dmg > 1000000000.0) idmg = 1000000000; else idmg = (int) ceil(dmg); if (effects[StatusEffect::INVULNERABILITY]) { //cant strike me return; } if (effects[StatusEffect::SLEEP]) { idmg <<= 1; removeEffect(StatusEffect::SLEEP); } this->damage(eatk, idmg); m->forEachNearby(this, [&](Entity *e) { e->entityStruck(this, this->getDispHp(), 1); }); }
void PickableModel::onUnpicked() { removeEffect(mPickedEffect); }
void EffectManager::logic() { clearStatus(); for (unsigned i=0; i<effect_list.size(); i++) { // expire timed effects and total up magnitudes of active effects if (effect_list[i].duration >= 0) { if (effect_list[i].type == "damage" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) damage += effect_list[i].magnitude; else if (effect_list[i].type == "hpot" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) hpot += effect_list[i].magnitude; else if (effect_list[i].type == "mpot" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) mpot += effect_list[i].magnitude; else if (effect_list[i].type == "speed") speed = (effect_list[i].magnitude * speed) / 100; else if (effect_list[i].type == "immunity") immunity = true; else if (effect_list[i].type == "stun") stun = true; else if (effect_list[i].type == "revive") revive = true; else if (effect_list[i].type == "convert") convert = true; else if (effect_list[i].type == "fear") fear = true; else if (effect_list[i].type == "offense") bonus_offense += effect_list[i].magnitude; else if (effect_list[i].type == "defense") bonus_defense += effect_list[i].magnitude; else if (effect_list[i].type == "physical") bonus_physical += effect_list[i].magnitude; else if (effect_list[i].type == "mental") bonus_mental += effect_list[i].magnitude; else { bool found_key = false; for (unsigned j=0; j<STAT_COUNT; j++) { if (effect_list[i].type == STAT_NAME[j]) { bonus[j] += effect_list[i].magnitude; found_key = true; } } if (!found_key) { for (unsigned j=0; j<bonus_resist.size(); j++) { if (effect_list[i].type == ELEMENTS[j].name + "_resist") bonus_resist[j] += effect_list[i].magnitude; } } } if (effect_list[i].duration > 0) { if (effect_list[i].ticks > 0) effect_list[i].ticks--; if (effect_list[i].ticks == 0) { //death sentence is only applied at the end of the timer if (effect_list[i].type == "death_sentence") death_sentence = true; removeEffect(i); i--; continue; } } } // expire shield effects if (effect_list[i].magnitude_max > 0 && effect_list[i].magnitude == 0) { if (effect_list[i].type == "shield") { removeEffect(i); i--; continue; } } // expire effects based on animations if ((effect_list[i].animation && effect_list[i].animation->isLastFrame()) || !effect_list[i].animation) { if (effect_list[i].type == "heal") { removeEffect(i); i--; continue; } } // animate if (effect_list[i].animation) { if (!effect_list[i].animation->isCompleted()) effect_list[i].animation->advanceFrame(); } } }
void EffectManager::removeEffectType(std::string type) { for (unsigned i=effect_list.size(); i > 0; i--) { if (effect_list[i-1].type == type) removeEffect(i-1); } }
void EffectManager::clearTriggerEffects(int trigger) { for (unsigned i=effect_list.size(); i > 0; i--) { if (effect_list[i-1].trigger > -1 && effect_list[i-1].trigger == trigger) removeEffect(i-1); } }
void EffectManager::clearItemEffects() { for (unsigned i=effect_list.size(); i > 0; i--) { if (effect_list[i-1].item) removeEffect(i-1); } }
void EffectManager::removeEffectPassive(int id) { for (unsigned i=effect_list.size(); i > 0; i--) { if (effect_list[i-1].passive_id == id) removeEffect(i-1); } }