Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement damage reflection skill #479

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// <copyright file="ReflectionEffectInitializer.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.Persistence.Initialization.Skills;

using MUnique.OpenMU.AttributeSystem;
using MUnique.OpenMU.DataModel.Attributes;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.GameLogic.Attributes;

/// <summary>
/// Initializer for the reflection buff effect.
/// </summary>
public class ReflectionEffectInitializer : InitializerBase
{
/// <summary>
/// Initializes a new instance of the <see cref="ReflectionEffectInitializer"/> class.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="gameConfiguration">The game configuration.</param>
public ReflectionEffectInitializer(IContext context, GameConfiguration gameConfiguration)
: base(context, gameConfiguration)
{
}

/// <inheritdoc/>
public override void Initialize()
{
var magicEffect = this.Context.CreateNew<MagicEffectDefinition>();
this.GameConfiguration.MagicEffects.Add(magicEffect);
magicEffect.Number = (byte)MagicEffectNumber.Reflection;
magicEffect.Name = "Reflection";
magicEffect.InformObservers = true;
magicEffect.SendDuration = false;
magicEffect.StopByDeath = true;
var powerUpDefinition = this.Context.CreateNew<PowerUpDefinition>();
magicEffect.PowerUpDefinitions.Add(powerUpDefinition);
powerUpDefinition.TargetAttribute = Stats.DamageReflection.GetPersistent(this.GameConfiguration);
magicEffect.Duration = this.Context.CreateNew<PowerUpDefinitionValue>();
magicEffect.Duration.ConstantValue.Value = 30;
var durationPerEnergy = this.Context.CreateNew<AttributeRelationship>();
durationPerEnergy.InputAttribute = Stats.TotalEnergy.GetPersistent(this.GameConfiguration);
durationPerEnergy.InputOperator = InputOperator.Multiply;
durationPerEnergy.InputOperand = 1f / 25f; // 25 energy adds 1 second duration
magicEffect.Duration.RelatedValues.Add(durationPerEnergy);

// one percent per 42 energy
var boostPerEnergy = this.Context.CreateNew<AttributeRelationship>();
boostPerEnergy.InputAttribute = Stats.TotalEnergy.GetPersistent(this.GameConfiguration);
boostPerEnergy.InputOperator = InputOperator.Multiply;
boostPerEnergy.InputOperand = 0.01f / 42f;

// Reflection % = 30 + (Energi / 42)
powerUpDefinition.Boost = this.Context.CreateNew<PowerUpDefinitionValue>();
powerUpDefinition.Boost.ConstantValue.Value = 0.29f;
powerUpDefinition.Boost.ConstantValue.AggregateType = AggregateType.AddRaw;
powerUpDefinition.Boost.RelatedValues.Add(boostPerEnergy);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal class SkillsInitializer : SkillsInitializerBase
{ SkillNumber.IncreaseHealth, MagicEffectNumber.IncreaseHealth },
{ SkillNumber.IncreaseBlock, MagicEffectNumber.IncreaseBlock },
{ SkillNumber.ExpansionofWizardry, MagicEffectNumber.WizEnhance },
{ SkillNumber.DamageReflection, MagicEffectNumber.Reflection },
};

private readonly IDictionary<byte, MasterSkillRoot> _masterSkillRoots;
Expand Down Expand Up @@ -173,7 +174,7 @@ public override void Initialize()
this.CreateSkill(SkillNumber.ShieldBurn, "Shield-Burn", CharacterClasses.All, distance: 3, manaConsumption: 30, elementalModifier: ElementalType.Ice, cooldownMinutes: 5);
this.CreateSkill(SkillNumber.DrainLife, "Drain Life", CharacterClasses.AllSummoners, DamageType.Curse, 35, 6, manaConsumption: 50, energyRequirement: 150, skillType: SkillType.AreaSkillExplicitTarget);
this.CreateSkill(SkillNumber.ChainLightning, "Chain Lightning", CharacterClasses.AllSummoners, DamageType.Curse, 70, 6, manaConsumption: 85, energyRequirement: 245, skillType: SkillType.AreaSkillExplicitTarget, skillTarget: SkillTarget.Explicit);
this.CreateSkill(SkillNumber.DamageReflection, "Damage Reflection", CharacterClasses.AllSummoners, distance: 5, abilityConsumption: 10, manaConsumption: 40, energyRequirement: 375);
this.CreateSkill(SkillNumber.DamageReflection, "Damage Reflection", CharacterClasses.AllSummoners, distance: 5, abilityConsumption: 10, manaConsumption: 40, energyRequirement: 375, skillType: SkillType.Buff, implicitTargetRange: 0, targetRestriction: SkillTargetRestriction.Self);
this.CreateSkill(SkillNumber.Berserker, "Berserker", CharacterClasses.AllSummoners, DamageType.Curse, distance: 5, abilityConsumption: 50, manaConsumption: 100, energyRequirement: 620);
this.CreateSkill(SkillNumber.Sleep, "Sleep", CharacterClasses.AllSummoners, distance: 6, abilityConsumption: 3, manaConsumption: 20, energyRequirement: 180);
this.CreateSkill(SkillNumber.Weakness, "Weakness", CharacterClasses.AllSummoners, distance: 6, abilityConsumption: 15, manaConsumption: 50, energyRequirement: 663);
Expand Down Expand Up @@ -572,6 +573,7 @@ private void InitializeEffects()
new IncreaseHealthEffectInitializer(this.Context, this.GameConfiguration).Initialize();
new IncreaseBlockEffectInitializer(this.Context, this.GameConfiguration).Initialize();
new WizardryEnhanceEffectInitializer(this.Context, this.GameConfiguration).Initialize();
new ReflectionEffectInitializer(this.Context, this.GameConfiguration).Initialize();
}

private void MapSkillsToEffects()
Expand Down