Beispiel #1
0
    /*
    ============================================================================
    Use functions
    ============================================================================
    */
    public bool Use(Combatant user, int element, Combatant target, float damageFactor, float damageMultiplier)
    {
        bool hit = false;

        if(target.IsBlockBaseAttacks())
        {
            DataHolder.BattleSystemData().blockTextSettings.ShowText("", target);
        }
        else if((user is Enemy || this.ConsumeItems()) &&
            (!this.hitChance || DataHolder.GameSettings().GetRandom() <=
            (DataHolder.Formulas().formula[this.hitFormula].Calculate(user, target) + user.GetHitBonus())))
        {
            hit = true;

            int eID = user.GetEffectAttackElement();
            if(eID < 0)
            {
                eID = element;
            }

            ValueChange[] changes = this.consume;
            AudioClip clip = null;

            if(this.hasCritical && DataHolder.GameSettings().GetRandom() <=
                DataHolder.Formula(user.baseCritical).Calculate(user, target) + user.GetCriticalBonus())
            {
                changes = this.criticalConsume;
                clip = this.GetCriticalAudio();
            }

            if(clip == null)
            {
                clip = this.GetAttackAudio();
            }

            if(clip != null && target.prefabInstance != null)
            {
                AudioSource s = target.GetAudioSource();
                if(s != null)
                {
                    s.PlayOneShot(clip);
                }
            }

            for(int i=0; i<changes.Length; i++)
            {
                if(changes[i].active)
                {
                    int change = changes[i].ChangeValue(i, eID, user, target, true, damageFactor, damageMultiplier);
                    if(this.absorb)
                    {
                        change *= this.absorbValue;
                        change /= 100;
                        user.status[i].AddValue(change, true, false, true);
                    }
                }
            }

            this.stealChance.Steal(user, target);
        }
        else
        {
            DataHolder.BattleSystemData().missTextSettings.ShowText("", target);
        }

        return hit;
    }