344 lines
5.7 KiB
C#
344 lines
5.7 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.Collections;
|
|
using Godot.NativeInterop;
|
|
|
|
[GlobalClass]
|
|
[ScriptPath("res://Scripts/Data/Battlers.cs")]
|
|
public partial class Battlers : Resource, BattleStats
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
public string name;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Array<int> partyAction = new Array<int> { 0 };
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Array<Acts.IDs> acts;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Vector2 center = new Vector2(0f, -16f);
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Vector2 positionOffset;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Vector2 defaultBubbleSize;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Vector2 cageSize = Vector2.One;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Acts.IDs callEventOnDefeat = Acts.IDs.None;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Acts.IDs callOnFullMercy = Acts.IDs.None;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Acts.IDs callEventOnExecution = Acts.IDs.None;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public bool isOutlaw;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public bool noMercy;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public bool spareMax;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public bool dontFlee;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public float resistArrest = -1f;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int hasSpecial = -1;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public BulletConds[] bulletBoards;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public string diagSound;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int[] blurbOrder;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int[] randomBlurbs;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public Array<Array<Variant>> animOverrides;
|
|
|
|
public int[] atkMod;
|
|
|
|
public int[] defMod;
|
|
|
|
public float bulletSpeedMod = 1f;
|
|
|
|
public HashSet<StringName> internalFlags = new HashSet<StringName>();
|
|
|
|
public Coroutine animRoutine;
|
|
|
|
public Entity.IDs id;
|
|
|
|
public Entity.Animations defaultIdle = Entity.Animations.BattleIdle;
|
|
|
|
public bool acted;
|
|
|
|
public bool enemy;
|
|
|
|
public bool doMagicMenu;
|
|
|
|
public bool fleeing;
|
|
|
|
public bool skipAttack;
|
|
|
|
public bool lockAnim;
|
|
|
|
public StringName splitPart;
|
|
|
|
public int[] selectedAction;
|
|
|
|
public SaveFile.Flags partyFlag;
|
|
|
|
public int spare;
|
|
|
|
public int internalID;
|
|
|
|
public int posID;
|
|
|
|
public int actFrame;
|
|
|
|
public int blurbOverride = -1;
|
|
|
|
public int title;
|
|
|
|
public int MAGIC;
|
|
|
|
public int hpLastTurn;
|
|
|
|
public int blurbCount;
|
|
|
|
public List<int> lastestAct = new List<int>();
|
|
|
|
public Vector2 atkPartOffset;
|
|
|
|
public Vector2 startPos;
|
|
|
|
public StringName hitPart = "KanakoHit";
|
|
|
|
public Texture2D weaponIcon;
|
|
|
|
public Entity entity;
|
|
|
|
public Entity oEntity;
|
|
|
|
private static readonly StringName specialString = "Special";
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public BattleBlurbs[] blurbs;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int HP { get; set; } = 100;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int MAXHP { get; set; } = 100;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int ATK { get; set; } = 25;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int DEF { get; set; } = 10;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int LV { get; set; }
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
public int MONEY { get; set; }
|
|
|
|
public int ATKBONUS { get; set; }
|
|
|
|
public int HPBONUS { get; set; }
|
|
|
|
public int DEFBONUS { get; set; }
|
|
|
|
public int[] EQUIP { get; set; } = new int[3] { -1, -1, -1 };
|
|
|
|
public bool CanAct()
|
|
{
|
|
if (HP > 0)
|
|
{
|
|
return !acted;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public float HPPercent()
|
|
{
|
|
return (float)HP / (float)MAXHP;
|
|
}
|
|
|
|
public Vector2 GetCenter()
|
|
{
|
|
return entity.sprite.RegionRect.Size.Y / 2f * Vector2.Up;
|
|
}
|
|
|
|
public bool HasEquip(Items.IDs[] equip)
|
|
{
|
|
bool flag = false;
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
for (int j = 0; j < equip.Length; j++)
|
|
{
|
|
if (EQUIP[i] == (int)equip[j])
|
|
{
|
|
flag = true;
|
|
break;
|
|
}
|
|
if (flag)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (!flag)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public float GetProgress()
|
|
{
|
|
return Mathf.Max(1f - HPPercent(), (float)spare / 100f);
|
|
}
|
|
|
|
public bool CanSpare()
|
|
{
|
|
if (noMercy)
|
|
{
|
|
return false;
|
|
}
|
|
if (spare < 95)
|
|
{
|
|
if (!spareMax)
|
|
{
|
|
return HPPercent() < 0.2f;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool CanSpecial()
|
|
{
|
|
if (hasSpecial > -1 && (spare >= 80 || HPPercent() <= 0.2f))
|
|
{
|
|
HashSet<StringName> hashSet = internalFlags;
|
|
if (hashSet == null)
|
|
{
|
|
return false;
|
|
}
|
|
return !hashSet.Contains(specialString);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void AddBonus(bool increaseLV = false)
|
|
{
|
|
ATKBONUS += 5;
|
|
HPBONUS += 10;
|
|
HP += 10;
|
|
DEFBONUS += 5;
|
|
if (increaseLV)
|
|
{
|
|
LV++;
|
|
}
|
|
}
|
|
|
|
public void Heal(int amt = -1, bool playSound = true)
|
|
{
|
|
if (amt == -1)
|
|
{
|
|
HP = MAXHP;
|
|
}
|
|
else
|
|
{
|
|
HP = Mathf.Clamp(HP + amt, 0, MAXHP);
|
|
}
|
|
if (playSound)
|
|
{
|
|
Audio.PlaySound("snd_power.wav");
|
|
}
|
|
}
|
|
|
|
public void Delete()
|
|
{
|
|
entity?.QueueFree();
|
|
Dispose();
|
|
}
|
|
|
|
public void SetTitle()
|
|
{
|
|
if (LV == 0)
|
|
{
|
|
LV = 1;
|
|
}
|
|
switch (id)
|
|
{
|
|
case Entity.IDs.Clover:
|
|
if (SaveFile.HasFlag(SaveFile.Flags.WeirdStart))
|
|
{
|
|
title = 5;
|
|
}
|
|
else if (SaveFile.HasFlag(SaveFile.Flags.AteMoss))
|
|
{
|
|
title = 4;
|
|
}
|
|
else if (SaveFile.HasFlag(SaveFile.Flags.WardenExposited))
|
|
{
|
|
title = 3;
|
|
}
|
|
else
|
|
{
|
|
title = 0;
|
|
}
|
|
break;
|
|
case Entity.IDs.Kanako:
|
|
if (SaveFile.HasFlag(SaveFile.Flags.WeirdStart))
|
|
{
|
|
title = 6;
|
|
}
|
|
else if (SaveFile.HasFlag(SaveFile.Flags.WardenExposited))
|
|
{
|
|
title = 7;
|
|
}
|
|
else
|
|
{
|
|
title = 1;
|
|
}
|
|
break;
|
|
case Entity.IDs.Axis:
|
|
if (SaveFile.HasFlag(SaveFile.Flags.AxisTrashEvent))
|
|
{
|
|
title = 8;
|
|
}
|
|
else
|
|
{
|
|
title = 2;
|
|
}
|
|
break;
|
|
case Entity.IDs.Melody:
|
|
title = 0;
|
|
break;
|
|
case Entity.IDs.June:
|
|
title = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|