void ConditionAttributes::addCondition(Creature* creature, const Condition* addCondition) { if(!updateCondition(addCondition)) return; setTicks(addCondition->getTicks()); const ConditionAttributes& conditionAttrs = static_cast<const ConditionAttributes&>(*addCondition); endCondition(creature, CONDITIONEND_ABORT); //Apply the new one memcpy(skills, conditionAttrs.skills, sizeof(skills)); memcpy(skillsPercent, conditionAttrs.skillsPercent, sizeof(skillsPercent)); memcpy(stats, conditionAttrs.stats, sizeof(stats)); memcpy(statsPercent, conditionAttrs.statsPercent, sizeof(statsPercent)); if(Player* player = creature->getPlayer()) { updatePercentSkills(player); updateSkills(player); updatePercentStats(player); updateStats(player); } }
bool LyricsLine::setProperty(Pid propertyId, const QVariant& v) { switch (propertyId) { case Pid::SPANNER_TICKS: { // if parent lyrics has a melisma, change its length too if (parent() && parent()->type() == ElementType::LYRICS && toLyrics(parent())->ticks() > 0) { int newTicks = toLyrics(parent())->ticks() + v.toInt() - ticks(); parent()->undoChangeProperty(Pid::LYRIC_TICKS, newTicks); } setTicks(v.toInt()); } break; default: if (!SLine::setProperty(propertyId, v)) return false; break; } score()->setLayoutAll(); return true; }
void ConditionSpeed::addCondition(Creature* creature, const Condition* addCondition) { if (conditionType != addCondition->getType()) { return; } if (getTicks() == -1 && addCondition->getTicks() > 0) { return; } setTicks(addCondition->getTicks()); const ConditionSpeed& conditionSpeed = static_cast<const ConditionSpeed&>(*addCondition); int32_t oldSpeedDelta = speedDelta; speedDelta = conditionSpeed.speedDelta; mina = conditionSpeed.mina; maxa = conditionSpeed.maxa; minb = conditionSpeed.minb; maxb = conditionSpeed.maxb; if (speedDelta == 0) { int32_t min; int32_t max; getFormulaValues(creature->getBaseSpeed(), min, max); speedDelta = random_range(min, max); } int32_t newSpeedChange = (speedDelta - oldSpeedDelta); if (newSpeedChange != 0) { g_game.changeSpeed(creature, newSpeedChange); } }
void ConditionGeneric::addCondition(Creature*, const Condition* addCondition) { if(updateCondition(addCondition)) setTicks(addCondition->getTicks()); }
bool ConditionDamage::unserializeProp(const ConditionAttr_t& attr, PropStream& propStream) { if (attr == CONDITIONATTR_DELAYED) { uint8_t value = 0; if (!propStream.GET_UINT8(value)) { return false; } delayed = value != 0; return true; } else if (attr == CONDITIONATTR_PERIODDAMAGE) { int32_t value = 0; if (!propStream.GET_INT32(value)) { return false; } periodDamage = value; return true; } else if (attr == CONDITIONATTR_OWNER) { uint32_t value = 0; if (!propStream.GET_UINT32(value)) { return false; } owner = value; return true; } else if (attr == CONDITIONATTR_INTERVALDATA) { IntervalInfo damageInfo; if (!propStream.GET_INT32(damageInfo.timeLeft) || !propStream.GET_INT32(damageInfo.value) || !propStream.GET_INT32(damageInfo.interval)) { return false; } damageList.push_back(damageInfo); if (getTicks() != -1) { setTicks(getTicks() + damageInfo.interval); } return true; } return Condition::unserializeProp(attr, propStream); }
void ConditionSpellGroupCooldown::addCondition(Creature* creature, const Condition* addCondition) { if (updateCondition(addCondition)) { setTicks(addCondition->getTicks()); } }
void LyricsLine::layout() { bool tempMelismaTicks = (lyrics()->ticks() == Lyrics::TEMP_MELISMA_TICKS); if (lyrics()->ticks()) { // melisma setLineWidth(score()->styleP(Sid::lyricsLineThickness)); // if lyrics has a temporary one-chord melisma, set to 0 ticks (just its own chord) if (tempMelismaTicks) lyrics()->setTicks(0); // Lyrics::_ticks points to the beginning of the last spanned segment, // but the line shall include it: // include the duration of this last segment in the melisma duration Segment* lyricsSegment = lyrics()->segment(); int lyricsStartTick = lyricsSegment->tick(); int lyricsEndTick = lyrics()->endTick(); int lyricsTrack = lyrics()->track(); // find segment with tick >= endTick Segment* s = lyricsSegment; while (s && s->tick() < lyricsEndTick) s = s->nextCR(lyricsTrack, true); if (!s) { // user probably deleted measures at end of score, leaving this melisma too long // set s to last segment and reset lyricsEndTick to trigger FIXUP code below s = score()->lastSegment(); lyricsEndTick = -1; } Element* se = s->element(lyricsTrack); // everything is OK if we have reached a chord at right tick on right track if (s->tick() == lyricsEndTick && se && se->type() == ElementType::CHORD) { // advance to next CR, or last segment if no next CR s = s->nextCR(lyricsTrack, true); if (!s) s = score()->lastSegment(); } else { // FIXUP - lyrics tick count not valid // this happens if edits to score have removed the original end segment // so let's fix it here // s is already pointing to segment past endTick (or to last segment) // we should shorten the lyrics tick count to make this work Segment* ns = s; Segment* ps = s->prev1(SegmentType::ChordRest); while (ps && ps != lyricsSegment) { Element* pe = ps->element(lyricsTrack); // we're looking for an actual chord on this track if (pe && pe->type() == ElementType::CHORD) break; s = ps; ps = ps->prev1(SegmentType::ChordRest); } if (!ps || ps == lyricsSegment) { // no valid previous CR, so try to lengthen melisma instead ps = ns; s = ps->nextCR(lyricsTrack, true); Element* e = s ? s->element(lyricsTrack) : nullptr; // check to make sure we have a chord if (!e || e->type() != ElementType::CHORD) { // nothing to do but set ticks to 0 // this will result in melisma being deleted later lyrics()->undoChangeProperty(Pid::LYRIC_TICKS, 0); setTicks(0); return; } } lyrics()->undoChangeProperty(Pid::LYRIC_TICKS, ps->tick() - lyricsStartTick); } setTicks(s->tick() - lyricsStartTick); } else { // dash(es) _nextLyrics = searchNextLyrics(lyrics()->segment(), staffIdx(), lyrics()->no(), lyrics()->placement()); setTick2(_nextLyrics ? _nextLyrics->segment()->tick() : tick()); } if (ticks()) { // only do layout if some time span // do layout with non-0 duration if (tempMelismaTicks) lyrics()->setTicks(Lyrics::TEMP_MELISMA_TICKS); SLine::layout(); // if temp melisma and there is a first line segment, // extend it to be after the lyrics syllable (otherwise // the melisma segment will be often covered by the syllable itself) if (tempMelismaTicks && segments.size() > 0) segmentAt(0)->rxpos2() += lyrics()->width(); } }
Goodie::Goodie(int IID, int startX, int startY, StudentWorld* world) : TimedLifeActor(IID, startX, startY, world) { int ticks = getWorld()->getLev()->getOptionValue(optionGoodieLifetimeInTicks); setTicks(ticks); }