public override void Apply(Prop ch, Character caster = null) { Power p = null; if (caster) { p = caster.activePower; } if (AINode.IsCondition(condition, ch, p)) { status.Apply(ch, caster); } }
public Status ApplyStatus(Status s, float duration, Character caster, ScriptableObject power, float buffPower = 1.0f) { if (s.isImmediate() == false) { // can we find a status of the same type, with the same character and name (if required)? Status copy = null; if (s.maxStacks > 0) // search for an existing copy if this status supports stacking { for (int i = 0; i < statusEffects.Count; i++) { if (statusEffects[i].name == s.name && (s.sourceSelectiveStacks == false || (statusEffects[i].sourceCharacter == caster && statusEffects[i].sourcePower == power))) { copy = statusEffects[i]; } } } statusDirty = true; Status returnVal = copy; if (copy) { // refresh the duration, and possibly increase how many stacks we have copy.timer = 0; if (copy.stacks < copy.maxStacks) { copy.stacks++; } } else { // status with a duration - add to character's queue Status status = Instantiate(s) as Status; status.stacks = 1; status.name = s.name; status.sourceCharacter = caster; status.sourcePower = power; status.duration = duration; // TODO modify with debuff resistance? statusEffects.Add(status); returnVal = status; } // if its a buff, multiply the base by the buffMultiplier Buff buff = returnVal as Buff; if (buff) { Buff originalBuff = s as Buff; for (int i = 0; i < buff.modifiers.Length; i++) { buff.modifiers[i].modifier = originalBuff.modifiers[i].modifier * buffPower; } } // set the direction of Repel here if (returnVal as Repel) { returnVal.Apply(this, caster); } return(returnVal); } else { // apply immediately once s.duration = duration; // pass this in for Conversions s.Apply(this, caster); return(null); } }