bool BattleHazard::updateInner(GameState &state, unsigned int ticks) { nextUpdateTicksAccumulated += ticks; while (nextUpdateTicksAccumulated >= TICKS_PER_HAZARD_UPDATE) { nextUpdateTicksAccumulated -= TICKS_PER_HAZARD_UPDATE; if (hazardType->fire) { // Explanation for how fire works is at the end of battlehazard.h if (power > 0) { age -= 6; if (age <= 10) { power = -power; } } else { age += 10; } power += power / std::abs(power); if (power % 2) { applyEffect(state); if (age < 130) { grow(state); } } if (age >= 130) { die(state, true); return true; } } else { age++; if (age % 2) { applyEffect(state); updateTileVisionBlock(state); if (age < lifetime) { grow(state); } } if (age >= lifetime) { die(state, true); return true; } } } return false; }
float IMusicListener::listenTo(int line,float *fft) { float lowVal=0; float highVal=0; for(int c1=Line[line].lowerBound;c1<Line[line].lowerBound+Line[line].bandWidth;c1++) lowVal += fft[c1]; for(int c2=Line[line].upperBound-Line[line].bandWidth;c2<Line[line].upperBound;c2++) highVal += fft[c2]; lowVal/=Line[line].bandWidth; highVal/=(Line[line].bandWidth/2); applyEffect(line,lowVal,highVal); if(Line[line].clampf) Line[line].Effect=Line[line].Effect<Line[line].MINClampf?Line[line].MINClampf:Line[line].Effect>Line[line].MAXClampf?Line[line].MAXClampf:Line[line].Effect; Line[line].value[0]=lowVal; Line[line].value[1]=highVal; if(this->callbacks[line]) callbacks[line](line,&Line[line],clients[line]); return Line[line].Effect; }
JNIEXPORT void JNICALL Java_si_majcn_frameoffame_MainActivity_applyEffect(JNIEnv *env, jobject obj, jobject bitmap, jint effectNumber) { AndroidBitmapInfo info; int ret; void *pixels; if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) { LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret); return; } if (info.format != ANDROID_BITMAP_FORMAT_RGB_565) { LOGE("Bitmap format is not RGBA_565 !"); return; } if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) { LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret); } applyEffect(&info, pixels, effectNumber); AndroidBitmap_unlockPixels(env, bitmap); }
//virtual void EffectsListWidget::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { emit applyEffect(currentEffect()); e->accept(); return; } QTreeWidget::keyPressEvent(e); }
virtual void apply(osg::Node& node) { if (osgFX::Effect* effect = dynamic_cast<osgFX::Effect*>(&node)) applyEffect(*effect); osg::StateSet* stateset = node.getStateSet(); if (stateset) applyStateSet(stateset); traverse(node); }
EffectEditor::EffectEditor(QWidget *editor, QWidget *parent) : QWidget(parent), ui(new Ui::EffectEditor) { ui->setupUi(this); auto *layout = new QHBoxLayout(); layout->addWidget(editor); layout->setMargin(0); ui->editorPanel->setLayout(layout); connect(ui->applyButton, SIGNAL(clicked()), SIGNAL(applyEffect())); connect(ui->revertButton, SIGNAL(clicked()), SIGNAL(revertEffect())); }
void BattleHazard::update(GameState &state, unsigned int ticks) { if (ticksUntilVisible > 0) { if (ticksUntilVisible > ticks) { ticksUntilVisible -= ticks; } else { ticksUntilVisible = 0; } } ticksUntilNextFrameChange -= ticks; if (ticksUntilNextFrameChange <= 0) { ticksUntilNextFrameChange += TICKS_PER_HAZARD_EFFECT; frame++; frame %= HAZARD_FRAME_COUNT; } ticksUntilNextEffect -= ticks; if (ticksUntilNextEffect <= 0) { ticksUntilNextEffect += TICKS_PER_HAZARD_EFFECT; applyEffect(state); age++; updateTileVisionBlock(state); if (age >= lifetime) { die(state); } else { grow(state); } } }
void BattleSquad::applyAttackRolls(bool rangedattack, int d, AttackInfo &attackinfo) { DataLibrary *datalib = DataLibrary::getSingletonPtr(); int soildernum = getUnitNum(); float deff; if(rangedattack) { deff = getAttr(ATTR_RANGEDDEFENCE, ATTRCALC_FULL); deff += RANGEDDEFENCEBONUS; float formation; formation = getAttr(ATTR_FORM, ATTRCALC_FULL); formation = (formation < 0.0f)?0.0f:formation; formation = formation * soildernum / 50.0f; switch(getFormation()) { case Line: formation *= FORMBONSE_LINE_RANGED; break; case Circular: formation *= FORMBONSE_CIRC_RANGED; break; default: formation *= FORMBONSE_LOOS_RANGED; break; } deff -= formation; } else { deff = getAttr(ATTR_DEFENCE, ATTRCALC_FULL); float formation; formation = getAttr(ATTR_FORM, ATTRCALC_FULL); formation = (formation < 0.0f)?0.0f:formation; formation = formation * soildernum / 50.0f; int formtype = getFormation(); int mydir = getDirection(); int side = GetSide(mydir,d); formation *= GetFormationBonus(side, formtype); deff += formation; } int def = floor(deff + 0.5f); int atk = floor(attackinfo.Atk + 0.5f); float perc = AtkDefToPerc(atk,def); float killf = perc * attackinfo.AtkTime; killf += killf * (rand() % (attackinfo.Randomness * 2 + 1) - attackinfo.Randomness) / 100.0f; int kill = floor(killf + 0.5f); if(kill == 0) { if(rand() % 100 < attackinfo.Randomness) kill = 1; } if(kill > 9) { std::string eid; applyEffect("Waver", eid); } if(kill > 18) { std::string eid; applyEffect("Waver", eid); } soildernum -= kill; soildernum = (soildernum < 0)? 0: soildernum; setUnitNum(soildernum); if(getType() == SQUAD_NORMAL) { int maxnum = getUnitMaxNum(); maxnum -= kill * (1.0f - getAttr(ATTR_TOUGHNESS, ATTRCALC_FULL) / 10.0f); setUnitMaxNum(maxnum); } }
void Deity::onPrayer(Creature* c) { bool prayerAnswered = false; for (Epithet epithet : randomPermutation(epithets)) { if (contains(usedEpithets, epithet)) continue; bool noEffect = false; switch (epithet) { case Epithet::DEATH: { PCreature death = CreatureFactory::fromId(CreatureId::DEATH, Tribes::get(TribeId::KILL_EVERYONE)); for (Vec2 v : c->getPosition().neighbors8(true)) if (c->getLevel()->inBounds(v) && c->getLevel()->getSquare(v)->canEnter(death.get())) { c->privateMessage("Death appears before you."); c->getLevel()->addCreature(v, std::move(death)); break; } if (death) noEffect = true; break; } case Epithet::WAR: grantGift(c, chooseRandom( {ItemId::SPECIAL_SWORD, ItemId::SPECIAL_BATTLE_AXE, ItemId::SPECIAL_WAR_HAMMER}), name); break; case Epithet::WISDOM: grantGift(c, chooseRandom({ItemId::MUSHROOM_BOOK, ItemId::POTION_BOOK, ItemId::AMULET_BOOK}), name); break; case Epithet::DESTRUCTION: applyEffect(c, EffectType::DESTROY_EQUIPMENT, ""); break; case Epithet::SECRETS: grantGift(c, ItemId::INVISIBLE_POTION, name); break; case Epithet::LIGHTNING: c->bleed(0.9); c->you(MsgType::ARE, "struck by a lightning bolt!"); break; case Epithet::FEAR: applyEffect(c, EffectType::PANIC, name + " puts fear in your heart"); break; case Epithet::MIND: if (Random.roll(2)) applyEffect(c, EffectType::RAGE, name + " fills your head with anger"); else applyEffect(c, EffectType::HALLU, ""); break; case Epithet::CHANGE: if (Random.roll(2) && c->getEquipment().getItem(EquipmentSlot::WEAPON)) { PCreature snake = CreatureFactory::fromId(CreatureId::SNAKE, Tribes::get(TribeId::PEST)); for (Vec2 v : c->getPosition().neighbors8(true)) if (c->getLevel()->inBounds(v) && c->getLevel()->getSquare(v)->canEnter(snake.get())) { c->getLevel()->addCreature(v, std::move(snake)); c->steal({c->getEquipment().getItem(EquipmentSlot::WEAPON)}); c->privateMessage("Ouch!"); c->you(MsgType::YOUR, "weapon turns into a snake!"); break; } if (!snake) break; } for (Item* it : randomPermutation(c->getEquipment().getItems())) { if (it->getType() == ItemType::POTION) { c->privateMessage("Your " + it->getName() + " changes color!"); c->steal({it}); c->take(ItemFactory::potions().random()); break; } if (it->getType() == ItemType::SCROLL) { c->privateMessage("Your " + it->getName() + " changes label!"); c->steal({it}); c->take(ItemFactory::scrolls().random()); break; } if (it->getType() == ItemType::AMULET) { c->privateMessage("Your " + it->getName() + " changes shape!"); c->steal({it}); c->take(ItemFactory::amulets().random()); break; } } break; case Epithet::HEALTH: if (c->getHealth() < 1 || c->lostLimbs()) applyEffect(c, EffectType::HEAL, "You feel a healing power overcoming you"); else { if (Random.roll(4)) grantGift(c, ItemId::HEALING_AMULET, name); else grantGift(c, ItemId::HEALING_POTION, name, Random.getRandom(1, 4)); } break; case Epithet::NATURE: grantGift(c, ItemId::FRIENDLY_ANIMALS_AMULET, name); break; // case Epithet::LOVE: grantGift(c, ItemId::PANIC_MUSHROOM, name); break; case Epithet::WEALTH: grantGift(c, ItemId::GOLD_PIECE, name, Random.getRandom(100, 200)); break; case Epithet::DEFENSE: grantGift(c, ItemId::DEFENSE_AMULET, name); break; case Epithet::DARKNESS: applyEffect(c, EffectType::BLINDNESS, ""); break; case Epithet::CRAFTS: applyEffect(c, chooseRandom({EffectType::ENHANCE_ARMOR, EffectType::ENHANCE_WEAPON}), ""); break; // case Epithet::HUNTING: grantGift(c, ItemId::PANIC_MUSHROOM, name); break; default: noEffect = true; } usedEpithets.push_back(epithet); if (!noEffect) { prayerAnswered = true; break; } } if (!prayerAnswered) c->privateMessage("Your prayer is not answered."); }
// public static QImage kpEffectInvert::applyEffect (const QImage &img, int channels) { QImage retImage = img; applyEffect (&retImage, channels); return retImage; }