Skip to content

Commit

Permalink
fix/enhancement: remove bounded spells through events (#1900)
Browse files Browse the repository at this point in the history
* fix/enhancement: remove bounded spells through events

* review: fix typo "Bounded" to "Bound"
  • Loading branch information
Arufonsu authored Sep 11, 2023
1 parent 670ff53 commit bdabcf4
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Intersect (Core)/GameObjects/Events/Commands/EventCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ public ChangeSpellsCommand(Dictionary<Guid, List<EventCommand>> commandLists)

public bool Add { get; set; } //If !Add then Remove

public bool RemoveBoundSpell { get; set; }

//Branch[0] is the event commands to execute when taught/removed successfully, Branch[1] is for when it's not.
public Guid[] BranchIds { get; set; } = new Guid[2];

Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public EventCommandChangeSpells(ChangeSpellsCommand refCommand, EventPage refPag
cmbSpell.Items.AddRange(SpellBase.Names);
cmbAction.SelectedIndex = refCommand.Add ? 0 : 1;
cmbSpell.SelectedIndex = SpellBase.ListIndex(mMyCommand.SpellId);
chkRemoveBound.Checked = mMyCommand.RemoveBoundSpell;
}

private void InitLocalization()
Expand All @@ -42,6 +43,7 @@ private void InitLocalization()

lblAction.Text = Strings.EventChangeSpells.action;
lblSpell.Text = Strings.EventChangeSpells.spell;
chkRemoveBound.Text = Strings.EventChangeSpells.RemoveBound;
btnSave.Text = Strings.EventChangeSpells.okay;
btnCancel.Text = Strings.EventChangeSpells.cancel;
}
Expand All @@ -50,9 +52,23 @@ private void btnSave_Click(object sender, EventArgs e)
{
mMyCommand.Add = !Convert.ToBoolean(cmbAction.SelectedIndex);
mMyCommand.SpellId = SpellBase.IdFromList(cmbSpell.SelectedIndex);
mMyCommand.RemoveBoundSpell = chkRemoveBound.Checked;
mEventEditor.FinishCommandEdit();
}

private void cmbAction_IndexChanged(object sender, EventArgs e)
{
if (cmbAction.SelectedIndex == 0)
{
chkRemoveBound.Checked = false;
chkRemoveBound.Enabled = false;
}
else
{
chkRemoveBound.Enabled = true;
}
}

private void btnCancel_Click(object sender, EventArgs e)
{
mEventEditor.CancelCommandEdit();
Expand Down
2 changes: 2 additions & 0 deletions Intersect.Editor/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,8 @@ public partial struct EventChangeSpells

public static LocalizedString okay = @"Ok";

public static LocalizedString RemoveBound = @"Remove Bound Spell ?";

public static LocalizedString spell = @"Spell: ";

public static LocalizedString title = @"Change Player Spells";
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server/Entities/Events/CommandProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ Stack<CommandInstance> callStack
{
if (player.FindSpell(command.SpellId) > -1 && command.SpellId != Guid.Empty)
{
player.ForgetSpell(player.FindSpell(command.SpellId));
player.ForgetSpell(player.FindSpell(command.SpellId), command.RemoveBoundSpell);
success = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Intersect.Server/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4844,9 +4844,9 @@ public void SwapSpells(int spell1, int spell2)
PacketSender.SendPlayerSpellUpdate(this, spell2);
}

public void ForgetSpell(int spellSlot)
public void ForgetSpell(int spellSlot, bool removeBoundSpell = false)
{
if (!SpellBase.Get(Spells[spellSlot].SpellId).Bound)
if (!SpellBase.Get(Spells[spellSlot].SpellId).Bound || removeBoundSpell)
{
Spells[spellSlot].Set(Spell.None);
PacketSender.SendPlayerSpellUpdate(this, spellSlot);
Expand Down

0 comments on commit bdabcf4

Please sign in to comment.