Пример #1
0
    //override, adds this effect to the character's active effects
    public override int ApplyEffect(ref CharacterTargetInfo targetInfo)
    {
        int finalPower = base.ApplyEffect(ref targetInfo);

        AddCopy(ref targetInfo, finalPower);
        return(finalPower);
    }
Пример #2
0
    //applies this effect to the target, modifying target attribute by power
    public virtual int ApplyEffect(ref CharacterTargetInfo targetInfo)
    {
        //initial finalPower is the base power - the target's armor if this effect is affected by armor
        int finalPower = power + (int)(targetInfo.source.GetAttribute(powerBonus) * powerBonusMultiplier) - (isAffectedByArmor?targetInfo.target.GetAttribute(CharacterAttributes.Armor):0);

        for (int i = 0; i < numDice; i++)
        {
            finalPower += Random.Range(1, diceSides + 1);
        }
        //ensures finalPower is never negative
        if (finalPower < 0)
        {
            finalPower = 0;
        }
        int rolledPower = finalPower;

        //doubles all damage dealt in excess of Endurance, assuming isDamage and target attribute is Health
        if (isDamage && attribute == CharacterAttributes.Health && finalPower > targetInfo.target.GetAttribute(CharacterAttributes.Endurance))
        {
            finalPower += finalPower - targetInfo.target.GetAttribute(CharacterAttributes.Endurance);
        }

        targetInfo.logMessage += "\n\t" + name + " applied, " + targetInfo.target.GetName() + "'s " + attribute + " changes by " + (isDamage?-1 * finalPower:finalPower) +
                                 "(rolled " + rolledPower + " on " + numDice + "d" + diceSides + "+" + (power + (int)(targetInfo.source.GetAttribute(powerBonus) * powerBonusMultiplier)) + (isAffectedByArmor?"-" + targetInfo.target.GetAttribute(CharacterAttributes.Armor):"") + ")";

        //if isDamage, change the target attribute by -1* finalPower, otherwise change it by finalPower
        targetInfo.target.ChangeAttribute(attribute, isDamage?-1 * finalPower:finalPower);
        targetInfo.logMessage += "(now: " + targetInfo.target.GetAttribute(attribute) + ")";
        //Debug.Log(targetInfo.logMessage);

        return(finalPower);
    }
Пример #3
0
 //every tick countsdown the duration, at 0 removes the effect, at period applies Effects
 public override void TickEffect(CharacterTargetInfo targetInfo)
 {
     duration--;
     targetInfo.logMessage += name + " ticked, " + duration + " ticks remaining";
     //check if effects should be applied ,if so apply each effect
     if (duration % period == 0)
     {
         targetInfo.logMessage += ", applying effects";
         foreach (ImmediateEffect eff in effects)
         {
             eff.ApplyEffect(ref targetInfo);
         }
         timesApplied++;
     }
     Debug.Log(targetInfo.logMessage);
     if (duration <= 0)
     {
         targetInfo.logMessage = name + " removed";
         targetInfo.target.RemoveEffect(this);
         if (reverseOnRemove)                             //if it should be reversed on removal, if the sub effects have a non-Zero powBonus, this may not fully reverse the effect
         {
             for (int i = 0; i < timesApplied; i++)       //for each time applied
             {
                 foreach (ImmediateEffect eff in effects) //for each effect
                 {
                     //apply the reverse of the effect
                     ImmediateEffect efTemp = new ImmediateEffect(name + " Remover", eff.GetAttribute(), eff.GetPower(), CharacterAttributes.Zero, 0f, !eff.GetIsDamage());
                     efTemp.ApplyEffect(ref targetInfo);
                 }
             }
         }
         Debug.Log(targetInfo.logMessage);
     }
 }
Пример #4
0
 //removes the effect from the character
 public virtual void RemoveEffect(CharacterTargetInfo targetInfo)
 {
     targetInfo.logMessage += name + " removed, " + targetInfo.target.GetName() + "'s " + attribute + " changes by " + (isDamage?powerApplied:powerApplied * -1);
     //targetInfo.logMessage += "\n" + name + " deals " + strength + " to " + targetInfo.target.GetName();
     targetInfo.target.ChangeAttribute(attribute, isDamage ? powerApplied : powerApplied * -1);
     targetInfo.logMessage += "(now: " + targetInfo.target.GetAttribute(attribute) + ")";
     Debug.Log(targetInfo.logMessage);
 }
Пример #5
0
    //adds a copy of this effect to the target with a powerApplied of finalPower
    protected virtual void AddCopy(ref CharacterTargetInfo targetInfo, int finalPower)
    {
        RemovableEffect temp = new RemovableEffect(this)
        {
            powerApplied = finalPower
        };

        targetInfo.target.AddEffect(temp);
    }
Пример #6
0
    //adds a copy of this effect to the target with a powerApplied of finalPower
    protected override void AddCopy(ref CharacterTargetInfo targetInfo, int finalPower)
    {
        TemporaryEffect temp = new TemporaryEffect(this)
        {
            powerApplied = finalPower
        };

        targetInfo.target.AddEffect(temp);
        targetInfo.target.OnTick += temp.TickEffect;
    }
Пример #7
0
 //every tick countsdown the duration, at 0 removes the effect
 public virtual void TickEffect(CharacterTargetInfo targetInfo)
 {
     duration--;
     targetInfo.logMessage += name + " ticked, " + duration + " ticks remaining";
     Debug.Log(targetInfo.logMessage);
     if (duration <= 0)
     {
         targetInfo.target.RemoveEffect(this);
         //emoveEffect(targetInfo);
     }
 }
Пример #8
0
    //override, applies all subeffects and adds TickEffect
    public override int ApplyEffect(ref CharacterTargetInfo targetInfo)
    {
        PeriodicTemporaryEffect temp = new PeriodicTemporaryEffect(this);

        targetInfo.target.AddEffect(temp);
        foreach (ImmediateEffect eff in temp.effects)
        {
            eff.ApplyEffect(ref targetInfo);
        }
        temp.timesApplied++;
        targetInfo.target.OnTick += temp.TickEffect;
        return(0);
    }
Пример #9
0
    public void ApplyEffects(int coverValue, CharacterTargetInfo targetInfo)
    {
        int diceRoll = targetInfo.source.GetAttribute(attackAttribute);

        //roll the dice
        for (int i = 0; i < numDice; i++)
        {
            diceRoll += Random.Range(1, diceSides + 1);
        }
        int targetNumber = targetInfo.target.GetAttribute(targetAttribute) + baseDifficulty;

        if (affectedByCover)
        {
            targetNumber += coverValue;
        }

        //adds information to log message: source uses ability on target, rolling diceRoll (XdY+bonus) against targetNumber
        targetInfo.logMessage += targetInfo.source.GetName() + " uses " + name + " on " + targetInfo.target.GetName() +
                                 ", rolling " + diceRoll + "(" + numDice + "d" + diceSides + "+" + targetInfo.source.GetAttribute(attackAttribute) + ") against target number: " + targetNumber;
        if (affectedByCover)
        {
            targetInfo.logMessage += "(cover: " + coverValue + ")";
        }

        //check if the ability has hit the atrget number
        if (diceRoll >= targetNumber)
        {
            targetInfo.logMessage += ", hitting";
            foreach (ImmediateEffect eff in effects)
            {
                //Debug.Log("apply");
                eff.ApplyEffect(ref targetInfo);
            }
        }
        else
        {
            targetInfo.logMessage += ", missing";
        }
        Debug.Log(targetInfo.logMessage);
    }
Пример #10
0
 //override removes the effect and removes self from the OnTick event
 public override void RemoveEffect(CharacterTargetInfo targetInfo)
 {
     base.RemoveEffect(targetInfo);
     targetInfo.target.OnTick -= TickEffect;
 }
Пример #11
0
 //uses abl on target, applying the effects of abl to the target
 public void UseAbility(Ability abl, int coverValue, CharacterTargetInfo targetInfo)
 {
     //Debug.Log("use");
     abl.ApplyEffects(coverValue, targetInfo);
 }