all repos — RPG @ 502924ae35666f2d5ac541310b3e57f2e4fe70b4

Fully functional 3D turn based role playing game coded in C# and base Unity.

Assets/Scripts/Battle/Abilities/ReviveHalf.cs (view raw)

 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5[System.Serializable]
 6public class ReviveHalf : Ability
 7{
 8    public ReviveHalf()
 9    {
10        dbName = "ReviveHalf";
11        guiName = "Blessing";
12        hasTarget = true;
13        ow_usable = true;
14        MP_cost = 100;
15    }
16
17    public override string Execute(Fighter source, Fighter target, out bool output)
18    {
19        if (target.stats.HP == 0)
20        {
21            double tmp = target.stats.HP;
22            target.dead = false;
23            target.stats.HP = (target.stats.MaxHP / 2) + (target.stats.MaxHP * 0.05);
24            UI.ShowDamage(target, (int)(tmp - target.stats.HP), false); //this should give a negative result
25            if(target.animator)
26                target.animator.SetTrigger("Alive");
27            output = true;
28            return target + " was brought back to life!";
29        } else
30        {
31            output = false;
32            return target + " isn't dead yet!";
33        }
34    }
35
36    public override string GetDescription()
37    {
38        return "Revives a party member with 50% of his health.";
39    }
40}