all repos — RPG @ 502924ae35666f2d5ac541310b3e57f2e4fe70b4

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

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

 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5[System.Serializable]
 6public class Heal : Ability
 7{
 8    protected double heal_amount;
 9
10    public Heal()
11    {
12        dbName = "Heal";
13        guiName = "Heal";
14        hasTarget = true;
15        ow_usable = true;
16        MP_cost = 50;
17        heal_amount = 200;
18    }
19
20    public override string Execute(Fighter source, Fighter target, out bool output)
21    {
22        double amount = heal_amount;
23        output = false;
24        if(target.stats.HP <= 0)
25        {
26            return source + " can't heal " + target + " because they're dead!";
27        }
28        if(target.stats.HP == target.stats.MaxHP)
29        {
30            return target + " already has max HP, they don't need healing.";
31        }
32        amount += (amount * 0.05);
33        target.stats.HP += amount;
34        UI.ShowDamage(target, -(int)amount, false); //this should give a negative result
35        output = true;
36        return target + " recovered " + (int)amount + " HP.";
37        
38    }
39
40    public override string GetDescription()
41    {
42        return "Heals about " + heal_amount + "HP to one target.";
43    }
44}