all repos — RPG @ e4654d09764a984539ba6cb6880cea7492aff7b6

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        guiName = "Blessing";
11        hasTarget = true;
12        ow_usable = true;
13        MP_cost = 100;
14    }
15
16    public override string Execute(Fighter source, Fighter target, out bool output)
17    {
18        if (target.stats.HP == 0)
19        {
20            double tmp = target.stats.HP;
21            target.dead = false;
22            target.stats.HP = (target.stats.MaxHP / 2) + (target.stats.MaxHP * 0.05);
23            UI.ShowDamage(target, (int)(tmp - target.stats.HP), false); //this should give a negative result
24            if(target.animator)
25                target.animator.SetTrigger("Alive");
26            output = true;
27            return target + " was brought back to life!";
28        } else
29        {
30            output = false;
31            return target + " isn't dead yet!";
32        }
33    }
34
35    public override string GetDescription()
36    {
37        return "Revives a party member with 50% of his health.";
38    }
39}