chore: initialize OshimaBot repository (rename from Enhancement)
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
using FunGame.Core.Entity;
|
||||
using FunGame.Core.Library.Constant;
|
||||
using FunGame.Core.Model.EffectContext;
|
||||
using FunGame.Core.Model.EffectResult;
|
||||
|
||||
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 => $"当生命值低于 30% 时,进入力量模式,核心属性转为力量,将所有基础智力转化为额外力量;当生命值高于或等于 30% 时,进入智力模式,核心属性转为智力,还原所有基础智力。力量模式下,造成伤害必定暴击;智力模式下,获得 15% 暴击率、15% 闪避率和 15% 魔法抗性。" +
|
||||
(Skill.Character != null ? "(当前模式:" + CharacterSet.GetPrimaryAttributeName(Skill.Character.PrimaryAttribute) + ")" : "");
|
||||
|
||||
private double 交换的基础智力 = 0;
|
||||
private readonly double 实际增加暴击率 = 0.15;
|
||||
private readonly double 实际增加闪避率 = 0.15;
|
||||
private readonly double 实际增加魔法抗性 = 0.15;
|
||||
private bool 已经加过 = false;
|
||||
|
||||
public override void OnEffectGained(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
ResetEffect(character, true);
|
||||
}
|
||||
|
||||
public override void OnEffectLost(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
ResetEffect(character, false);
|
||||
}
|
||||
|
||||
private void ResetEffect(Character character, bool isAdd)
|
||||
{
|
||||
if (isAdd)
|
||||
{
|
||||
if (!已经加过)
|
||||
{
|
||||
已经加过 = true;
|
||||
character.ExEvadeRate += 实际增加闪避率;
|
||||
character.ExCritRate += 实际增加暴击率;
|
||||
character.MDF[character.MagicType] += 实际增加魔法抗性;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (已经加过)
|
||||
{
|
||||
已经加过 = false;
|
||||
character.ExEvadeRate -= 实际增加闪避率;
|
||||
character.ExCritRate -= 实际增加暴击率;
|
||||
character.MDF[character.MagicType] -= 实际增加魔法抗性;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override BeforeCriticalCheckResult BeforeCriticalCheck(DamageContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character actor || ctx.Enemy is not Character enemy) return default;
|
||||
bool isNormalAttack = ctx.IsNormalAttack;
|
||||
if (actor == Skill.Character)
|
||||
{
|
||||
// 力量模式下必定暴击:提供极高的暴击检定加值
|
||||
return new BeforeCriticalCheckResult { ThrowingBonusDelta = 200 };
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public override void OnTimeElapsed(TimeLapseContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
double elapsed = ctx.Elapsed;
|
||||
Changed(character);
|
||||
}
|
||||
|
||||
public override void OnAttributeChanged(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
Changed(character);
|
||||
}
|
||||
|
||||
private void Changed(Character character)
|
||||
{
|
||||
if (Skill.Character != null)
|
||||
{
|
||||
Character c = Skill.Character;
|
||||
if (c.HP < c.MaxHP * 0.3)
|
||||
{
|
||||
if (c.PrimaryAttribute == PrimaryAttribute.INT)
|
||||
{
|
||||
double pastHP = c.HP;
|
||||
double pastMaxHP = c.MaxHP;
|
||||
double pastMP = c.MP;
|
||||
double pastMaxMP = c.MaxMP;
|
||||
c.PrimaryAttribute = PrimaryAttribute.STR;
|
||||
交换的基础智力 = c.BaseINT;
|
||||
c.ExINT -= 交换的基础智力;
|
||||
c.ExSTR += 交换的基础智力;
|
||||
c.Recovery(pastHP, pastMP, pastMaxHP, pastMaxMP);
|
||||
ResetEffect(character, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c.PrimaryAttribute == PrimaryAttribute.STR)
|
||||
{
|
||||
double pastHP = c.HP;
|
||||
double pastMaxHP = c.MaxHP;
|
||||
double pastMP = c.MP;
|
||||
double pastMaxMP = c.MaxMP;
|
||||
c.PrimaryAttribute = PrimaryAttribute.INT;
|
||||
c.ExSTR -= 交换的基础智力;
|
||||
c.ExINT += 交换的基础智力;
|
||||
交换的基础智力 = 0;
|
||||
c.Recovery(pastHP, pastMP, pastMaxHP, pastMaxMP);
|
||||
ResetEffect(character, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
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().Description : "";
|
||||
public override string DispelDescription => Effects.Count > 0 ? Effects.First().DispelDescription : "";
|
||||
public override double EPCost => 100;
|
||||
public override double CD => 20;
|
||||
public override double HardnessTime { get; set; } = 3;
|
||||
public override bool CanSelectSelf => true;
|
||||
public override bool CanSelectEnemy => false;
|
||||
|
||||
public 变幻之心(Character? character = null) : base(SkillType.SuperSkill, character)
|
||||
{
|
||||
Effects.Add(new 变幻之心特效(this));
|
||||
}
|
||||
}
|
||||
|
||||
public class 变幻之心特效(Skill skill) : Effect(skill)
|
||||
{
|
||||
public override long Id => Skill.Id;
|
||||
public override string Name => "变幻之心";
|
||||
public override string Description => $"检查 [ 双生流转 ] 的模式。在力量模式下,立即回复 {生命值回复 * 100:0.##}% 生命值,同时下 {吸血次数} 次对敌人造成伤害时获得 30% 生命偷取;" +
|
||||
$"智力模式下,下 {魔法加成次数} 次魔法伤害提升 {伤害提升 * 100:0.##}%。此技能效果不叠加,重复释放时将重置次数;若是模式切换后重复释放,将回收先前的效果。{当前次数描述}";
|
||||
public override DispelledType DispelledType => DispelledType.CannotBeDispelled;
|
||||
|
||||
private string 当前次数描述
|
||||
{
|
||||
get
|
||||
{
|
||||
string str = "";
|
||||
if (当前吸血次数 > 0 || 当前魔法加成次数 > 0)
|
||||
{
|
||||
str = 当前吸血次数 > 0 ? "吸血次数" : (当前魔法加成次数 > 0 ? "魔法加成次数" : "");
|
||||
if (str != "")
|
||||
{
|
||||
str = $"剩余{str}:";
|
||||
}
|
||||
if (当前吸血次数 > 0)
|
||||
{
|
||||
str += $"{当前吸血次数} 次。";
|
||||
}
|
||||
else if (当前魔法加成次数 > 0)
|
||||
{
|
||||
str += $"{当前魔法加成次数} 次。";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
private int 吸血次数
|
||||
{
|
||||
get
|
||||
{
|
||||
return Level switch
|
||||
{
|
||||
1 => 2,
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
4 => 3,
|
||||
5 => 4,
|
||||
6 => 3,
|
||||
_ => 2
|
||||
};
|
||||
}
|
||||
}
|
||||
private int 魔法加成次数
|
||||
{
|
||||
get
|
||||
{
|
||||
return Level switch
|
||||
{
|
||||
1 => 1,
|
||||
2 => 1,
|
||||
3 => 2,
|
||||
4 => 2,
|
||||
5 => 3,
|
||||
6 => 3,
|
||||
_ => 1
|
||||
};
|
||||
}
|
||||
}
|
||||
private double 生命值回复 => 0.25 + 0.03 * (Level - 1);
|
||||
private double 伤害提升 => 0.6 + 0.4 * (Level - 1);
|
||||
private int 当前吸血次数 = 0;
|
||||
private int 当前魔法加成次数 = 0;
|
||||
|
||||
public override void OnEffectGained(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
if (character.PrimaryAttribute == PrimaryAttribute.STR)
|
||||
{
|
||||
当前吸血次数 = 吸血次数;
|
||||
}
|
||||
else if (character.PrimaryAttribute == PrimaryAttribute.INT)
|
||||
{
|
||||
当前魔法加成次数 = 魔法加成次数;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEffectLost(HookContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character) return;
|
||||
当前吸血次数 = 0;
|
||||
当前魔法加成次数 = 0;
|
||||
}
|
||||
|
||||
public override double AlterExpectedDamageBeforeCalculation(DamageContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character || ctx.Enemy is not Character enemy) return 0;
|
||||
double damage = ctx.Damage;
|
||||
bool isNormalAttack = ctx.IsNormalAttack;
|
||||
DamageType damageType = ctx.DamageType;
|
||||
MagicType magicType = ctx.MagicType;
|
||||
Dictionary<Effect, double> totalDamageBonus = ctx.TotalDamageBonus;
|
||||
if (character == Skill.Character && damageType == DamageType.Magical && 当前魔法加成次数 > 0)
|
||||
{
|
||||
当前魔法加成次数--;
|
||||
double 实际伤害提升百分比 = 伤害提升;
|
||||
double 实际伤害提升 = damage * 实际伤害提升百分比;
|
||||
WriteLine($"[ {character} ] 发动了变幻之心!伤害提升了 {实际伤害提升:0.##} 点!变幻之心加成剩余:{当前魔法加成次数} 次。");
|
||||
if (当前魔法加成次数 == 0)
|
||||
{
|
||||
character.Effects.Remove(this);
|
||||
OnEffectLost(new HookContext(GamingQueue, character));
|
||||
}
|
||||
return 实际伤害提升;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override void AfterDamageCalculation(DamageContext ctx)
|
||||
{
|
||||
if (ctx.Trigger is not Character character || ctx.Enemy is not Character enemy) return;
|
||||
double damage = ctx.Damage;
|
||||
double actualDamage = ctx.ActualDamage;
|
||||
bool isNormalAttack = ctx.IsNormalAttack;
|
||||
DamageType damageType = ctx.DamageType;
|
||||
MagicType magicType = ctx.MagicType;
|
||||
DamageResult damageResult = ctx.DamageResult;
|
||||
if (character == Skill.Character && 当前吸血次数 > 0 && (damageResult == DamageResult.Normal || damageResult == DamageResult.Critical) && damage > 0)
|
||||
{
|
||||
当前吸血次数--;
|
||||
double 实际吸血 = damage * 0.3;
|
||||
character.HP += 实际吸血;
|
||||
WriteLine($"[ {character} ] 发动了变幻之心!回复了 {实际吸血:0.##} 点生命值!变幻之心加成剩余:{当前吸血次数} 次。");
|
||||
if (当前吸血次数 == 0)
|
||||
{
|
||||
character.Effects.Remove(this);
|
||||
OnEffectLost(new HookContext(GamingQueue, 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;
|
||||
IEnumerable<Effect> effects = caster.Effects.Where(e => e is 双生流转特效 && e.Skill.Character == Skill.Character);
|
||||
if (effects.Any())
|
||||
{
|
||||
if (caster.Effects.Contains(this))
|
||||
{
|
||||
caster.Effects.Remove(this);
|
||||
OnEffectLost(new HookContext(GamingQueue, caster));
|
||||
}
|
||||
caster.Effects.Add(this);
|
||||
OnEffectGained(new HookContext(GamingQueue, caster));
|
||||
if (caster.PrimaryAttribute == PrimaryAttribute.STR)
|
||||
{
|
||||
double 回复的生命 = 生命值回复 * caster.MaxHP;
|
||||
HealToTarget(caster, caster, 回复的生命);
|
||||
GamingQueue?.AddApplyEffects(caster, EffectType.Lifesteal);
|
||||
}
|
||||
else if (caster.PrimaryAttribute == PrimaryAttribute.INT)
|
||||
{
|
||||
GamingQueue?.AddApplyEffects(caster, EffectType.DamageBoost);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user