Skip to content
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
4 changes: 4 additions & 0 deletions Framework/Intersect.Framework.Core/Entities/SpellEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ public enum SpellEffect
Taunt = 12,

Knockback = 13,

HealingReduction = 14,

HealingBoost = 15,
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public string PercentageStatDiffJson

public SpellEffect Effect { get; set; }

/// <summary>
/// Number of tiles to push the target when Knockback effect is applied.
/// </summary>
public int KnockbackTiles { get; set; } = 1;

public int? PercentageEffect { get; set; }

public string TransformSprite { get; set; }

[Column("OnHit")]
Expand Down
3 changes: 3 additions & 0 deletions Intersect.Client.Core/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,9 @@ public partial struct SpellDescription
{10, @"Sleep"},
{11, @"On-Hit"},
{12, @"Taunt"},
{13, @"Knockback"},
{14, @"Grievous Wounds"},
{15, @"Healing Boost"},
};

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
Expand Down
71 changes: 70 additions & 1 deletion Intersect.Editor/Forms/Editors/frmSpell.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Intersect.Editor/Forms/Editors/frmSpell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ private void UpdateSpellTypePanels()
chkHOTDOT.Checked = mEditorItem.Combat.HoTDoT;
nudBuffDuration.Value = mEditorItem.Combat.Duration;
nudTick.Value = mEditorItem.Combat.HotDotInterval;
nudPercentageEffect.Value = mEditorItem.Combat.PercentageEffect ?? 0;
cmbExtraEffect.SelectedIndex = (int)mEditorItem.Combat.Effect;
cmbExtraEffect_SelectedIndexChanged(null, null);
}
Expand Down Expand Up @@ -535,6 +536,10 @@ private void cmbExtraEffect_SelectedIndexChanged(object sender, EventArgs e)
lblSprite.Visible = false;
cmbTransform.Visible = false;
picSprite.Visible = false;
lblKnockbackTiles.Visible = false;
nudKnockbackTiles.Visible = false;
lblPercentageEffect.Visible = false;
nudPercentageEffect.Visible = false;

if (cmbExtraEffect.SelectedIndex == 6) //Transform
{
Expand Down Expand Up @@ -567,6 +572,19 @@ private void cmbExtraEffect_SelectedIndexChanged(object sender, EventArgs e)
picSprite.BackgroundImage = null;
}
}

if (cmbExtraEffect.SelectedIndex == (int)SpellEffect.Knockback) // Knockback
{
lblKnockbackTiles.Visible = true;
nudKnockbackTiles.Visible = true;
nudKnockbackTiles.Value = Math.Max(1, mEditorItem.Combat.KnockbackTiles);
}

if (cmbExtraEffect.SelectedIndex == (int)SpellEffect.HealingReduction || cmbExtraEffect.SelectedIndex == (int)SpellEffect.HealingBoost)
{
lblPercentageEffect.Visible = true;
nudPercentageEffect.Visible = true;
}
}

private void frmSpell_FormClosed(object sender, FormClosedEventArgs e)
Expand Down Expand Up @@ -1100,4 +1118,14 @@ private void cmbTickAnimation_SelectedIndexChanged(object sender, EventArgs e)
Guid animationId = AnimationDescriptor.IdFromList(cmbTickAnimation.SelectedIndex - 1);
mEditorItem.TickAnimation = AnimationDescriptor.Get(animationId);
}

private void nudKnockbackTiles_ValueChanged(object sender, EventArgs e)
{
mEditorItem.Combat.KnockbackTiles = (int)nudKnockbackTiles.Value;
}

private void nudPercentageEffect_ValueChanged(object sender, EventArgs e)
{
mEditorItem.Combat.PercentageEffect = (int)nudPercentageEffect.Value;
}
}
6 changes: 6 additions & 0 deletions Intersect.Editor/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5312,6 +5312,9 @@ public partial struct SpellEditor
{10, @"Sleep"},
{11, @"OnHit"},
{12, @"Taunt"},
{13, @"Knockback"},
{14, @"Grievous Wounds"},
{15, @"Healing Boost"},
};

public static LocalizedString effectgroup = @"Effect";
Expand Down Expand Up @@ -5361,6 +5364,9 @@ public partial struct SpellEditor
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString TickAnimation = @"Tick Animation:";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString knockbacktiles = @"Tiles:";

public static LocalizedString magicresist = @"Magic Resist:";

public static LocalizedString manacost = @"Mana Cost:";
Expand Down
20 changes: 15 additions & 5 deletions Intersect.Server.Core/Database/DbInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,25 +220,28 @@ private static void ProcessMigrations<TContext>(TContext context)
{
if (!context.HasPendingMigrations)
{
ApplicationContext.Context.Value?.Logger.LogDebug($"No pending migrations for {context.GetType().GetName(qualified: true)}, skipping...");
ApplicationContext.Context.Value?.Logger.LogInformation($"No pending migrations for {context.GetType().GetName(qualified: true)}, skipping...");
return;
}

ApplicationContext.Context.Value?.Logger.LogDebug($"Pending schema migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingSchemaMigrations)}");
ApplicationContext.Context.Value?.Logger.LogDebug($"Pending data migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingDataMigrationNames)}");
ApplicationContext.Context.Value?.Logger.LogInformation($"Pending schema migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingSchemaMigrations)}");
ApplicationContext.Context.Value?.Logger.LogInformation($"Pending data migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingDataMigrationNames)}");

var migrationScheduler = new MigrationScheduler<TContext>(context);
ApplicationContext.Context.Value?.Logger.LogDebug("Scheduling pending migrations...");
ApplicationContext.Context.Value?.Logger.LogInformation("Scheduling pending migrations...");
migrationScheduler.SchedulePendingMigrations();

ApplicationContext.Context.Value?.Logger.LogDebug("Applying scheduled migrations...");
ApplicationContext.Context.Value?.Logger.LogInformation("Applying scheduled migrations...");
migrationScheduler.ApplyScheduledMigrations();
ApplicationContext.Context.Value?.Logger.LogInformation("Scheduled migrations applied.");

var remainingPendingSchemaMigrations = context.PendingSchemaMigrations.ToList();
var processedSchemaMigrations =
context.PendingSchemaMigrations.Where(migration => !remainingPendingSchemaMigrations.Contains(migration));

ApplicationContext.Context.Value?.Logger.LogInformation("Notifying context of processed schema migrations...");
context.OnSchemaMigrationsProcessed(processedSchemaMigrations.ToArray());
ApplicationContext.Context.Value?.Logger.LogInformation("Migration processing complete.");
}

internal static ILoggerFactory CreateLoggerFactory<TDBContext>(DatabaseOptions databaseOptions)
Expand Down Expand Up @@ -302,6 +305,7 @@ private static bool EnsureUpdated(IServerContext serverContext)
EnableSensitiveDataLogging = true,
LoggerFactory = CreateLoggerFactory<LoggingContext>(loggingDatabaseOptions),
});
ApplicationContext.Context.Value?.Logger.LogInformation("Logging context created.");

// We don't want anyone running the old migration tool accidentally
try
Expand All @@ -326,6 +330,7 @@ private static bool EnsureUpdated(IServerContext serverContext)
// ignored
}

ApplicationContext.Context.Value?.Logger.LogInformation("Checking pending migrations...");
var gameContextPendingMigrations = gameContext.PendingSchemaMigrations;
var playerContextPendingMigrations = playerContext.PendingSchemaMigrations;
var loggingContextPendingMigrations = loggingContext.PendingSchemaMigrations;
Expand All @@ -340,6 +345,8 @@ private static bool EnsureUpdated(IServerContext serverContext)
!loggingContextPendingMigrations.Contains("20191118024649_RequestLogs")
);

ApplicationContext.Context.Value?.Logger.LogInformation($"Show migration warning: {showMigrationWarning}");

if (showMigrationWarning)
{
if (serverContext.StartupOptions.MigrateAutomatically)
Expand Down Expand Up @@ -394,11 +401,14 @@ private static bool EnsureUpdated(IServerContext serverContext)
Console.WriteLine("No migrations pending that require user acceptance, skipping prompt...");
}

ApplicationContext.Context.Value?.Logger.LogInformation("Processing migrations...");
var contexts = new List<DbContext> { gameContext, playerContext, loggingContext };
foreach (var context in contexts)
{
var contextType = context.GetType().FindGenericTypeParameters(typeof(IntersectDbContext<>)).First();
ApplicationContext.Context.Value?.Logger.LogInformation($"Processing migration for context: {contextType.Name}");
_methodInfoProcessMigrations.MakeGenericMethod(contextType).Invoke(null, new object[] { context });
ApplicationContext.Context.Value?.Logger.LogInformation($"Finished migration for context: {contextType.Name}");
}

return true;
Expand Down
5 changes: 5 additions & 0 deletions Intersect.Server.Core/Database/MigrationScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ public void ApplyScheduledMigrations()

while (scheduleSegment.Any())
{
ApplicationContext.Context.Value?.Logger.LogInformation($"Schedule segment count: {scheduleSegment.Count}");
var targetMigration = scheduleSegment
.TakeWhile(metadata => metadata is SchemaMigrationMetadata)
.LastOrDefault();

if (targetMigration is SchemaMigrationMetadata)
{
ApplicationContext.Context.Value?.Logger.LogInformation($"Migrating schema via EF Core to: {targetMigration.Name}");
migrator.Migrate(targetMigration.Name);
ApplicationContext.Context.Value?.Logger.LogInformation($"EF Core migration to {targetMigration.Name} finished.");

scheduleSegment = scheduleSegment
.SkipWhile(metadata => metadata is SchemaMigrationMetadata)
Expand All @@ -94,7 +97,9 @@ public void ApplyScheduledMigrations()
throw new InvalidOperationException($"Failed to create instance of data migration: {scheduledDataMigration.MigratorType.FullName}");
}

ApplicationContext.Context.Value?.Logger.LogInformation($"Executing data migration: {scheduledDataMigration.Name}");
dataMigration.Up(_context.ContextOptions);
ApplicationContext.Context.Value?.Logger.LogInformation($"Data migration {scheduledDataMigration.Name} finished.");

scheduleSegment = scheduleSegment
.Skip(1)
Expand Down
Loading