Skip to content

Commit e4a6c83

Browse files
committed
feat: random drops
1 parent 91b0fba commit e4a6c83

File tree

10 files changed

+2755
-2753
lines changed

10 files changed

+2755
-2753
lines changed

Framework/Intersect.Framework.Core/GameObjects/Drop.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ public partial class Drop
66

77
public Guid ItemId { get; set; }
88

9-
public int Quantity { get; set; }
9+
public int Quantity { get; set; } = 1;
10+
11+
public int MinQuantity { get; set; } = 1;
1012
}

Intersect.Editor/Forms/Editors/frmNpc.Designer.cs

Lines changed: 1758 additions & 1827 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Intersect.Editor/Forms/Editors/frmNpc.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ private void InitLocalization()
213213

214214
grpDrops.Text = Strings.NpcEditor.drops;
215215
lblDropItem.Text = Strings.NpcEditor.dropitem;
216-
lblDropAmount.Text = Strings.NpcEditor.dropamount;
216+
lblDropAmount.Text = Strings.NpcEditor.DropMaxAmount;
217+
lblDropMinAmount.Text = Strings.NpcEditor.DropMinAmount;
217218
lblDropChance.Text = Strings.NpcEditor.dropchance;
218219
btnDropAdd.Text = Strings.NpcEditor.dropadd;
219220
btnDropRemove.Text = Strings.NpcEditor.dropremove;
@@ -448,7 +449,9 @@ private void UpdateDropValues(bool keepIndex = false)
448449
{
449450
lstDrops.Items.Add(
450451
Strings.NpcEditor.dropdisplay.ToString(
451-
ItemBase.GetName(mEditorItem.Drops[i].ItemId), mEditorItem.Drops[i].Quantity,
452+
ItemBase.GetName(mEditorItem.Drops[i].ItemId),
453+
mEditorItem.Drops[i].MinQuantity,
454+
mEditorItem.Drops[i].Quantity,
452455
mEditorItem.Drops[i].Chance
453456
)
454457
);
@@ -728,25 +731,34 @@ private void nudExp_ValueChanged(object sender, EventArgs e)
728731

729732
private void cmbDropItem_SelectedIndexChanged(object sender, EventArgs e)
730733
{
731-
if (lstDrops.SelectedIndex > -1 && lstDrops.SelectedIndex < mEditorItem.Drops.Count)
734+
if (lstDrops.SelectedIndex < 0 || lstDrops.SelectedIndex > lstDrops.Items.Count)
732735
{
733-
mEditorItem.Drops[lstDrops.SelectedIndex].ItemId = ItemBase.IdFromList(cmbDropItem.SelectedIndex - 1);
736+
return;
734737
}
735738

739+
mEditorItem.Drops[lstDrops.SelectedIndex].ItemId = ItemBase.IdFromList(cmbDropItem.SelectedIndex - 1);
736740
UpdateDropValues(true);
737741
}
738742

739743
private void nudDropAmount_ValueChanged(object sender, EventArgs e)
740744
{
741-
// This should never be below 1. We shouldn't accept giving 0 items!
742-
nudDropAmount.Value = Math.Max(1, nudDropAmount.Value);
745+
if (lstDrops.SelectedIndex < 0 || lstDrops.SelectedIndex > lstDrops.Items.Count)
746+
{
747+
return;
748+
}
743749

744-
if (lstDrops.SelectedIndex < lstDrops.Items.Count)
750+
mEditorItem.Drops[lstDrops.SelectedIndex].Quantity = (int)nudDropAmount.Value;
751+
UpdateDropValues(true);
752+
}
753+
754+
private void nudDropMinAmount_ValueChanged(object sender, EventArgs e)
755+
{
756+
if (lstDrops.SelectedIndex < 0 || lstDrops.SelectedIndex > lstDrops.Items.Count)
745757
{
746758
return;
747759
}
748760

749-
mEditorItem.Drops[(int)lstDrops.SelectedIndex].Quantity = (int)nudDropAmount.Value;
761+
mEditorItem.Drops[lstDrops.SelectedIndex].MinQuantity = (int)nudDropMinAmount.Value;
750762
UpdateDropValues(true);
751763
}
752764

@@ -756,6 +768,7 @@ private void lstDrops_SelectedIndexChanged(object sender, EventArgs e)
756768
{
757769
cmbDropItem.SelectedIndex = ItemBase.ListIndex(mEditorItem.Drops[lstDrops.SelectedIndex].ItemId) + 1;
758770
nudDropAmount.Value = mEditorItem.Drops[lstDrops.SelectedIndex].Quantity;
771+
nudDropMinAmount.Value = mEditorItem.Drops[lstDrops.SelectedIndex].MinQuantity;
759772
nudDropChance.Value = (decimal)mEditorItem.Drops[lstDrops.SelectedIndex].Chance;
760773
}
761774
}
@@ -765,6 +778,7 @@ private void btnDropAdd_Click(object sender, EventArgs e)
765778
mEditorItem.Drops.Add(new Drop());
766779
mEditorItem.Drops[mEditorItem.Drops.Count - 1].ItemId = ItemBase.IdFromList(cmbDropItem.SelectedIndex - 1);
767780
mEditorItem.Drops[mEditorItem.Drops.Count - 1].Quantity = (int)nudDropAmount.Value;
781+
mEditorItem.Drops[mEditorItem.Drops.Count - 1].MinQuantity = (int)nudDropMinAmount.Value;
768782
mEditorItem.Drops[mEditorItem.Drops.Count - 1].Chance = (double)nudDropChance.Value;
769783

770784
UpdateDropValues();
@@ -784,7 +798,7 @@ private void btnDropRemove_Click(object sender, EventArgs e)
784798

785799
private void nudDropChance_ValueChanged(object sender, EventArgs e)
786800
{
787-
if (lstDrops.SelectedIndex < lstDrops.Items.Count)
801+
if (lstDrops.SelectedIndex < 0 || lstDrops.SelectedIndex > lstDrops.Items.Count)
788802
{
789803
return;
790804
}

Intersect.Editor/Forms/Editors/frmNpc.resx

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
3+
<!--
44
Microsoft ResX Schema
5-
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
5151
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->

0 commit comments

Comments
 (0)