Skip to content
Merged
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
Expand Up @@ -331,6 +331,11 @@ public partial class GiveExperienceCommand : EventCommand
/// The Variable Id to use.
/// </summary>
public Guid VariableId { get; set; }

/// <summary>
/// If true, when a player have their experience reduced, they will be able to level down.
/// </summary>
public bool EnableLosingLevels { get; set; } = false;
}

public partial class ChangeLevelCommand : EventCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ public enum CommonEventTrigger
MapChanged,

UserVariableChange,

LevelDown,
}
2 changes: 2 additions & 0 deletions Intersect (Core)/CustomColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public sealed partial class CombatNamespace

public Color LevelUp = Color.Cyan;

public Color LevelLost = Color.Red;

public Color MagicDamage = new Color(255, 255, 0, 255);

public Color Missed = new Color(255, 255, 255, 255);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@

namespace Intersect.Editor.Forms.Editors.Events.Event_Commands;


public partial class EventCommandGiveExperience : UserControl
{
private readonly FrmEvent _eventEditor;

private readonly FrmEvent mEventEditor;

private GiveExperienceCommand mMyCommand;
private readonly GiveExperienceCommand _command;

public EventCommandGiveExperience(GiveExperienceCommand refCommand, FrmEvent editor)
{
InitializeComponent();
mMyCommand = refCommand;
mEventEditor = editor;
_command = refCommand;
_eventEditor = editor;
InitLocalization();

rdoVariable.Checked = mMyCommand.UseVariable;
rdoGlobalVariable.Checked = mMyCommand.VariableType == VariableType.ServerVariable;
rdoGuildVariable.Checked = mMyCommand.VariableType == VariableType.GuildVariable;
rdoVariable.Checked = _command.UseVariable;
rdoGlobalVariable.Checked = _command.VariableType == VariableType.ServerVariable;
rdoGuildVariable.Checked = _command.VariableType == VariableType.GuildVariable;

nudExperience.Minimum = -long.MaxValue;
nudExperience.Maximum = long.MaxValue;

SetupAmountInput();
chkEnableLevelDown.Checked = _command.EnableLosingLevels;

SetupAmountInput(default, default);
}

private void InitLocalization()
{
grpGiveExperience.Text = Strings.EventGiveExperience.title;
lblExperience.Text = Strings.EventGiveExperience.label;
grpGiveExperience.Text = Strings.EventGiveExperience.Title;
lblExperience.Text = Strings.EventGiveExperience.Label;

lblVariable.Text = Strings.EventGiveExperience.Variable;

Expand All @@ -45,60 +48,40 @@ private void InitLocalization()
rdoGlobalVariable.Text = Strings.EventGiveExperience.ServerVariable;
rdoGuildVariable.Text = Strings.EventGiveExperience.GuildVariable;

btnSave.Text = Strings.EventGiveExperience.okay;
btnCancel.Text = Strings.EventGiveExperience.cancel;
chkEnableLevelDown.Text = Strings.EventGiveExperience.EnableLosingLevels;

btnSave.Text = Strings.General.Okay;
btnCancel.Text = Strings.General.Cancel;
}

private void btnSave_Click(object sender, EventArgs e)
{
mMyCommand.Exp = (long) nudExperience.Value;
_command.Exp = (long)nudExperience.Value;

if (rdoPlayerVariable.Checked)
{
mMyCommand.VariableType = VariableType.PlayerVariable;
mMyCommand.VariableId = PlayerVariableDescriptor.IdFromList(cmbVariable.SelectedIndex, VariableDataType.Integer);
_command.VariableType = VariableType.PlayerVariable;
_command.VariableId = PlayerVariableDescriptor.IdFromList(cmbVariable.SelectedIndex, VariableDataType.Integer);
}
else if (rdoGlobalVariable.Checked)
{
mMyCommand.VariableType = VariableType.ServerVariable;
mMyCommand.VariableId = ServerVariableDescriptor.IdFromList(cmbVariable.SelectedIndex, VariableDataType.Integer);
_command.VariableType = VariableType.ServerVariable;
_command.VariableId = ServerVariableDescriptor.IdFromList(cmbVariable.SelectedIndex, VariableDataType.Integer);
}
else if (rdoGuildVariable.Checked)
{
mMyCommand.VariableType = VariableType.GuildVariable;
mMyCommand.VariableId = GuildVariableDescriptor.IdFromList(cmbVariable.SelectedIndex, VariableDataType.Integer);
_command.VariableType = VariableType.GuildVariable;
_command.VariableId = GuildVariableDescriptor.IdFromList(cmbVariable.SelectedIndex, VariableDataType.Integer);
}
mMyCommand.UseVariable = !rdoManual.Checked;
mEventEditor.FinishCommandEdit();
}

private void btnCancel_Click(object sender, EventArgs e)
{
mEventEditor.CancelCommandEdit();
}

private void rdoManual_CheckedChanged(object sender, EventArgs e)
{
SetupAmountInput();
}

private void rdoVariable_CheckedChanged(object sender, EventArgs e)
{
SetupAmountInput();
_command.UseVariable = !rdoManual.Checked;
_command.EnableLosingLevels = chkEnableLevelDown.Checked;
_eventEditor.FinishCommandEdit();
}

private void rdoPlayerVariable_CheckedChanged(object sender, EventArgs e)
{
SetupAmountInput();
}

private void rdoGlobalVariable_CheckedChanged(object sender, EventArgs e)
{
SetupAmountInput();
}

private void rdoGuildVariable_CheckedChanged(object sender, EventArgs e)
private void btnCancel_Click(object sender, EventArgs e)
{
SetupAmountInput();
_eventEditor.CancelCommandEdit();
}

private void VariableBlank()
Expand All @@ -114,7 +97,7 @@ private void VariableBlank()
}
}

private void SetupAmountInput()
private void SetupAmountInput(object? sender, EventArgs? e)
{
grpManualAmount.Visible = rdoManual.Checked;
grpVariableAmount.Visible = !rdoManual.Checked;
Expand All @@ -124,9 +107,9 @@ private void SetupAmountInput()
{
cmbVariable.Items.AddRange(PlayerVariableDescriptor.GetNamesByType(VariableDataType.Integer));
// Do not update if the wrong type of variable is saved
if (mMyCommand.VariableType == VariableType.PlayerVariable)
if (_command.VariableType == VariableType.PlayerVariable)
{
var index = PlayerVariableDescriptor.ListIndex(mMyCommand.VariableId, VariableDataType.Integer);
var index = PlayerVariableDescriptor.ListIndex(_command.VariableId, VariableDataType.Integer);
if (index > -1)
{
cmbVariable.SelectedIndex = index;
Expand All @@ -145,9 +128,9 @@ private void SetupAmountInput()
{
cmbVariable.Items.AddRange(ServerVariableDescriptor.GetNamesByType(VariableDataType.Integer));
// Do not update if the wrong type of variable is saved
if (mMyCommand.VariableType == VariableType.ServerVariable)
if (_command.VariableType == VariableType.ServerVariable)
{
var index = ServerVariableDescriptor.ListIndex(mMyCommand.VariableId, VariableDataType.Integer);
var index = ServerVariableDescriptor.ListIndex(_command.VariableId, VariableDataType.Integer);
if (index > -1)
{
cmbVariable.SelectedIndex = index;
Expand All @@ -166,9 +149,9 @@ private void SetupAmountInput()
{
cmbVariable.Items.AddRange(GuildVariableDescriptor.GetNamesByType(VariableDataType.Integer));
// Do not update if the wrong type of variable is saved
if (mMyCommand.VariableType == VariableType.GuildVariable)
if (_command.VariableType == VariableType.GuildVariable)
{
var index = GuildVariableDescriptor.ListIndex(mMyCommand.VariableId, VariableDataType.Integer);
var index = GuildVariableDescriptor.ListIndex(_command.VariableId, VariableDataType.Integer);
if (index > -1)
{
cmbVariable.SelectedIndex = index;
Expand All @@ -184,6 +167,6 @@ private void SetupAmountInput()
}
}

nudExperience.Value = Math.Max(1, mMyCommand.Exp);
nudExperience.Value = _command.Exp;
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema

Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple

There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down
20 changes: 10 additions & 10 deletions Intersect.Editor/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2800,6 +2800,7 @@ public partial struct EventEditor
{16, @"Inventory Changed"},
{17, @"Map Changed"},
{18, @"User Variable Changed"},
{19, @"Level Down"},
};

public static LocalizedString conditions = @"Conditions";
Expand Down Expand Up @@ -2947,20 +2948,17 @@ public partial struct EventEndQuest

public partial struct EventGiveExperience
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString AmountType = @"Amount Type";

public static LocalizedString cancel = @"Cancel";

public static LocalizedString label = @"Give Experience:";

public static LocalizedString okay = @"Ok";

public static LocalizedString title = @"Give Experience";
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString EnableLosingLevels = @"Enable losing levels?";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString AmountType = @"Amount Type";
public static LocalizedString GuildVariable = @"Guild Variable";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString Variable = @"Variable";
public static LocalizedString Label = @"Give Experience:";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString Manual = @"Manual";
Expand All @@ -2972,8 +2970,10 @@ public partial struct EventGiveExperience
public static LocalizedString ServerVariable = @"Global Variable";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString GuildVariable = @"Guild Variable";
public static LocalizedString Title = @"Give Experience";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString Variable = @"Variable";
}

public partial struct EventGotoLabel
Expand Down
11 changes: 9 additions & 2 deletions Intersect.Server.Core/Entities/Events/CommandProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ private static void ProcessCommand(
Stack<CommandInstance> callStack
)
{
player.LevelUp();
player.AddLevels();
}

//Give Experience Command
Expand Down Expand Up @@ -454,7 +454,14 @@ Stack<CommandInstance> callStack
}
}

player.GiveExperience(quantity);
if(quantity > 0)
{
player.GiveExperience(quantity);
}
else if (quantity < 0)
{
player.TakeExperience(Math.Abs(quantity), command.EnableLosingLevels, force: true);
}
}

//Change Level Command
Expand Down
Loading
Loading