chore: initialize OshimaBot repository (rename from Enhancement)
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
using FunGame.Core.Api;
|
||||
using FunGame.Core.Entity;
|
||||
using FunGame.Core.Library.Constant;
|
||||
using FunGame.Core.Model.EffectContext;
|
||||
using FunGame.Core.Model.Framework;
|
||||
|
||||
namespace OshimaBot.Content.Skills
|
||||
{
|
||||
public class 全军出击 : Skill
|
||||
{
|
||||
public override long Id => (long)SuperSkillID.全军出击;
|
||||
public override string Name => "全军出击";
|
||||
public override string Description => Effects.Count > 0 ? ((全军出击特效)Effects.First()).GeneralDescription : "";
|
||||
public override string DispelDescription => Effects.Count > 0 ? Effects.First().DispelDescription : "";
|
||||
public override double EPCost => 100;
|
||||
public override double CD => 100;
|
||||
public override double HardnessTime { get; set; } = 5;
|
||||
public override bool CanSelectSelf => true;
|
||||
public override bool CanSelectEnemy => false;
|
||||
|
||||
public 全军出击(Character? character = null) : base(SkillType.SuperSkill, character)
|
||||
{
|
||||
Effects.Add(new 全军出击特效(this));
|
||||
}
|
||||
}
|
||||
|
||||
public class 全军出击特效 : Effect
|
||||
{
|
||||
public override long Id => Skill.Id;
|
||||
public override string Name => Skill.Name;
|
||||
public override string Description { get; set; } = "";
|
||||
public override DispelledType DispelledType => DispelledType.CannotBeDispelled;
|
||||
public string GeneralDescription => $"将雇佣兵数量立即补全至 {雇佣兵团特效.最大数量} 名,每名雇佣兵的生命值回复至满并提升 {攻击力提升 * 100:0.##}% 攻击力。在 {持续时间} {GameplayEquilibriumConstant.InGameTime}内,场上的每名雇佣兵额外为{Skill.SkillOwner()}提供 {攻击力 * 100:0.##}% 攻击力和 {行动速度:0.##} 点行动速度、{加速系数 * 100:0.##}% 加速系数、{冷却缩减 * 100:0.##}% 冷却缩减。";
|
||||
public override bool Durative => true;
|
||||
public override double Duration => 持续时间;
|
||||
|
||||
public double 持续时间 => 20 + 2 * (Skill.Level - 1);
|
||||
public const double 攻击力 = 0.04;
|
||||
public const double 冷却缩减 = 0.03;
|
||||
public const double 加速系数 = 0.03;
|
||||
public const double 行动速度 = 30;
|
||||
public const double 攻击力提升 = 0.4;
|
||||
private double 实际攻击力提升 = 0;
|
||||
private double 实际行动速度提升 = 0;
|
||||
private double 实际加速系数提升 = 0;
|
||||
private double 实际冷却缩减提升 = 0;
|
||||
|
||||
public 全军出击特效(Skill skill) : base(skill)
|
||||
{
|
||||
Description = GeneralDescription;
|
||||
}
|
||||
|
||||
public override void OnTimeElapsed(TimeLapseContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
double elapsed = ctx.Elapsed;
|
||||
刷新技能效果(character);
|
||||
}
|
||||
|
||||
public override void OnEffectLost(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
Skill.IsInEffect = false;
|
||||
刷新技能效果(character);
|
||||
}
|
||||
|
||||
public override void OnSkillCasted(SkillCastContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character caster) return;
|
||||
List<Character> targets = ctx.Targets;
|
||||
List<Grid> grids = ctx.Grids;
|
||||
Dictionary<string, object> others = ctx.Others;
|
||||
Skill.IsInEffect = true;
|
||||
RemainDuration = Duration;
|
||||
if (!caster.Effects.Contains(this))
|
||||
{
|
||||
caster.Effects.Add(this);
|
||||
OnEffectGained(new HookContext(GamingQueue, caster));
|
||||
}
|
||||
if (caster.Effects.FirstOrDefault(e => e is 雇佣兵团特效 && e.Skill.Character == Skill.Character) is 雇佣兵团特效 e)
|
||||
{
|
||||
e.Skill.CurrentCD = 0;
|
||||
e.Skill.Enable = true;
|
||||
int count = e.雇佣兵团.Count;
|
||||
if (count < 雇佣兵团特效.最大数量)
|
||||
{
|
||||
do
|
||||
{
|
||||
count = e.新增雇佣兵(caster);
|
||||
}
|
||||
while (count < 雇佣兵团特效.最大数量);
|
||||
}
|
||||
foreach (雇佣兵 gyb in e.雇佣兵团)
|
||||
{
|
||||
gyb.Recovery();
|
||||
gyb.ExATKPercentage += 0.05;
|
||||
}
|
||||
}
|
||||
刷新技能效果(caster);
|
||||
}
|
||||
|
||||
public void 刷新技能效果(Character character)
|
||||
{
|
||||
if (实际攻击力提升 != 0)
|
||||
{
|
||||
character.ExATKPercentage -= 实际攻击力提升;
|
||||
实际攻击力提升 = 0;
|
||||
}
|
||||
if (实际行动速度提升 != 0)
|
||||
{
|
||||
character.ExSPD -= 实际行动速度提升;
|
||||
实际行动速度提升 = 0;
|
||||
}
|
||||
if (实际加速系数提升 != 0)
|
||||
{
|
||||
character.ExAccelerationCoefficient -= 实际加速系数提升;
|
||||
实际加速系数提升 = 0;
|
||||
}
|
||||
if (实际冷却缩减提升 != 0)
|
||||
{
|
||||
character.ExCDR -= 实际冷却缩减提升;
|
||||
实际冷却缩减提升 = 0;
|
||||
}
|
||||
if (!Skill.IsInEffect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (character.Effects.FirstOrDefault(e => e is 雇佣兵团特效 && e.Skill.Character == Skill.Character) is 雇佣兵团特效 e)
|
||||
{
|
||||
int count = e.雇佣兵团.Count;
|
||||
实际攻击力提升 = 攻击力 * count;
|
||||
实际行动速度提升 = 行动速度 * count;
|
||||
实际加速系数提升 = 加速系数 * count;
|
||||
实际冷却缩减提升 = 冷却缩减 * count;
|
||||
character.ExATKPercentage += 实际攻击力提升;
|
||||
character.ExSPD += 实际行动速度提升;
|
||||
character.ExAccelerationCoefficient += 实际加速系数提升;
|
||||
character.ExCDR += 实际冷却缩减提升;
|
||||
Description = $"{GeneralDescription}(当前雇佣兵数量:{count},攻击力提升:{实际攻击力提升 * 100:0.##}% [ {character.BaseATK * 实际攻击力提升:0.##} ] 点,行动速度提升:{实际行动速度提升:0.##} 点,加速系数提升:{实际加速系数提升 * 100:0.##}%,冷却缩减提升:{实际冷却缩减提升 * 100:0.##}%)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
using FunGame.Core.Api;
|
||||
using FunGame.Core.Entity;
|
||||
using FunGame.Core.Library.Constant;
|
||||
using FunGame.Core.Model.EffectContext;
|
||||
using FunGame.Core.Model.Framework;
|
||||
using Milimoe.FunGameTesting.Others;
|
||||
|
||||
namespace OshimaBot.Content.Skills
|
||||
{
|
||||
public class 雇佣兵团 : Skill
|
||||
{
|
||||
public override long Id => (long)PassiveID.雇佣兵团;
|
||||
public override string Name => "雇佣兵团";
|
||||
public override string Description => Effects.Count > 0 ? Effects.First().Description : "";
|
||||
|
||||
public 雇佣兵团(Character? character = null) : base(SkillType.Passive, character)
|
||||
{
|
||||
Effects.Add(new 雇佣兵团特效(this));
|
||||
}
|
||||
|
||||
public override IEnumerable<Effect> AddPassiveEffectToCharacter()
|
||||
{
|
||||
return Effects;
|
||||
}
|
||||
}
|
||||
|
||||
public class 雇佣兵团特效(Skill skill) : Effect(skill)
|
||||
{
|
||||
public override long Id => Skill.Id;
|
||||
public override string Name => Skill.Name;
|
||||
public override string Description => $"{Skill.SkillOwner()}在场上时,会召唤数名雇佣兵协助战斗,初始数量为 {最小数量} 名,雇佣兵具有独立的回合,生命值为{Skill.SkillOwner()}的 {生命值比例 * 100:0.##}% [ {Skill.Character?.MaxHP * 生命值比例:0.##} ],攻击力为{Skill.SkillOwner()}的 {攻击力比例 * 100:0.##}% 基础攻击力 [ {Skill.Character?.BaseATK * 攻击力比例:0.##} ]," +
|
||||
$"完整继承其他能力值(暴击率、闪避率等),雇佣兵每{GameplayEquilibriumConstant.InGameTime}流失 {生命流失 * 100:0.##}% 当前生命值。当{Skill.SkillOwner()}参与击杀时,便会临时产生一名额外的雇佣兵。场上最多可以存在 {最大数量} 名雇佣兵,达到数量后不再产生新的雇佣兵;当不足 {最小数量} 名雇佣兵时,{补充间隔} {GameplayEquilibriumConstant.InGameTime}后会重新补充一名雇佣兵。" +
|
||||
(雇佣兵团.Count < 最小数量 && Skill.CurrentCD > 0 ? $"(下次补充:{Skill.CurrentCD:0.##} {GameplayEquilibriumConstant.InGameTime}后)" : "");
|
||||
|
||||
public List<雇佣兵> 雇佣兵团 { get; } = [];
|
||||
public const int 最小数量 = 1;
|
||||
public const int 最大数量 = 5;
|
||||
public const int 补充间隔 = 30;
|
||||
public const double 生命值比例 = 0.1;
|
||||
public const double 攻击力比例 = 0.6;
|
||||
public const double 生命流失 = 0.09;
|
||||
|
||||
private bool 激活 = false;
|
||||
|
||||
public override void OnGameStart(HookContext ctx)
|
||||
{
|
||||
if (!激活)
|
||||
{
|
||||
激活 = true;
|
||||
if (Skill.Character != null)
|
||||
{
|
||||
保底补充(Skill.Character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void AfterDeathCalculation(DeathContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character death) return;
|
||||
bool hasMaster = ctx.HasMaster;
|
||||
Character? killer = ctx.Killer;
|
||||
Dictionary<Character, int> continuousKilling = ctx.ContinuousKilling;
|
||||
Dictionary<Character, int> earnedMoney = ctx.EarnedMoney;
|
||||
Character[] assists = ctx.Assists;
|
||||
if (death is 雇佣兵 gyb)
|
||||
{
|
||||
WriteLine($"[ {killer} ] 杀死了 [ {death} ]!");
|
||||
雇佣兵团.Remove(gyb);
|
||||
if (GamingQueue is FunGame.Core.Model.Queue.GamingQueue queue)
|
||||
{
|
||||
if (queue.Map != null) queue.RemoveCharacterFromMap(gyb);
|
||||
else queue.RemoveCharacterFromQueue(gyb);
|
||||
}
|
||||
if (雇佣兵团.Count < 最小数量 && Skill.CurrentCD == 0)
|
||||
{
|
||||
Skill.CurrentCD = 补充间隔;
|
||||
Skill.Enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (death == Skill.Character)
|
||||
{
|
||||
OnEffectLost(new HookContext(GamingQueue, death));
|
||||
}
|
||||
|
||||
if (Skill.Character != null && death != Skill.Character && (killer == Skill.Character || assists.Contains(Skill.Character)) && 雇佣兵团.Count < 最大数量)
|
||||
{
|
||||
新增雇佣兵(Skill.Character);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnTimeElapsed(TimeLapseContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
double elapsed = ctx.Elapsed;
|
||||
if (character == Skill.Character)
|
||||
{
|
||||
保底补充(character);
|
||||
}
|
||||
foreach (雇佣兵 gyb in 雇佣兵团)
|
||||
{
|
||||
if (gyb.HP > 0)
|
||||
{
|
||||
double lost = gyb.HP * 生命流失 * elapsed;
|
||||
gyb.HP -= lost;
|
||||
if (gyb.HP <= 0)
|
||||
{
|
||||
gyb.HP = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEffectLost(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
if (GamingQueue != null)
|
||||
{
|
||||
if (GamingQueue is FunGame.Core.Model.Queue.GamingQueue queue)
|
||||
{
|
||||
if (queue.Map != null) queue.RemoveCharacterFromMap(雇佣兵团);
|
||||
else queue.RemoveCharacterFromQueue(雇佣兵团);
|
||||
}
|
||||
雇佣兵团.Clear();
|
||||
WriteLine($"[ {character} ] 的雇佣兵团已消散!");
|
||||
}
|
||||
}
|
||||
|
||||
public void 保底补充(Character character)
|
||||
{
|
||||
if (!激活) return;
|
||||
int count = 雇佣兵团.Count;
|
||||
if (count < 最小数量 && Skill.Enable)
|
||||
{
|
||||
do
|
||||
{
|
||||
count = 新增雇佣兵(character);
|
||||
}
|
||||
while (count < 最小数量);
|
||||
}
|
||||
if (GamingQueue != null)
|
||||
{
|
||||
foreach (雇佣兵 gyb in 雇佣兵团.Where(g => !GamingQueue.Queue.Contains(g)))
|
||||
{
|
||||
if (gyb.HP <= 0) gyb.HP = 1;
|
||||
添加到地图(character, gyb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int 新增雇佣兵(Character character)
|
||||
{
|
||||
雇佣兵 gyb = new(character, RandomNames.GenerateRandomChineseName(Random))
|
||||
{
|
||||
Level = 1,
|
||||
InitialHP = character.MaxHP * 生命值比例,
|
||||
InitialATK = character.BaseATK * 攻击力比例,
|
||||
ExCritRate = character.CritRate - GameplayEquilibriumConstant.CritRate,
|
||||
ExCritDMG = character.CritDMG - GameplayEquilibriumConstant.CritDMG,
|
||||
ExEvadeRate = character.EvadeRate - GameplayEquilibriumConstant.EvadeRate,
|
||||
InitialSPD = character.SPD,
|
||||
InitialDEF = character.DEF,
|
||||
InitialHR = character.HR,
|
||||
InitialMR = character.MR,
|
||||
Lifesteal = character.Lifesteal,
|
||||
ExPDR = character.ExPDR,
|
||||
PhysicalPenetration = character.PhysicalPenetration,
|
||||
MagicalPenetration = character.MagicalPenetration,
|
||||
ExMOV = character.MOV,
|
||||
ExATR = character.ATR - 1
|
||||
};
|
||||
gyb.MDF.AddAllValue(character.MDF.Avg);
|
||||
gyb.Recovery();
|
||||
雇佣兵团.Add(gyb);
|
||||
|
||||
添加到地图(character, gyb);
|
||||
WriteLine($"[ {character} ] 召唤了{gyb}!");
|
||||
|
||||
return 雇佣兵团.Count;
|
||||
}
|
||||
|
||||
public void 添加到地图(Character character, 雇佣兵 gyb)
|
||||
{
|
||||
// 添加到地图/队列
|
||||
if (GamingQueue != null)
|
||||
{
|
||||
if (GamingQueue.Map is GameMap map)
|
||||
{
|
||||
Grid? current = map.GetCharacterCurrentGrid(character);
|
||||
if (current != null)
|
||||
{
|
||||
List<Grid> nearbyGrids = map.GetGridsByRange(current, 5, false);
|
||||
Grid? target = nearbyGrids.OrderBy(g => GameMap.CalculateManhattanDistance(g, current)).FirstOrDefault();
|
||||
if (target != null)
|
||||
{
|
||||
map.SetCharacterCurrentGrid(gyb, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
GamingQueue.Queue.Add(gyb);
|
||||
GamingQueue.ChangeCharacterHardnessTime(gyb, 5, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user