Skip to content

Commit e415a36

Browse files
WeylonSantanapandinocoder
authored andcommitted
feat: random drops
1 parent e58ebab commit e415a36

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
@@ -211,7 +211,8 @@ private void InitLocalization()
211211

212212
grpDrops.Text = Strings.NpcEditor.drops;
213213
lblDropItem.Text = Strings.NpcEditor.dropitem;
214-
lblDropAmount.Text = Strings.NpcEditor.dropamount;
214+
lblDropAmount.Text = Strings.NpcEditor.DropMaxAmount;
215+
lblDropMinAmount.Text = Strings.NpcEditor.DropMinAmount;
215216
lblDropChance.Text = Strings.NpcEditor.dropchance;
216217
btnDropAdd.Text = Strings.NpcEditor.dropadd;
217218
btnDropRemove.Text = Strings.NpcEditor.dropremove;
@@ -446,7 +447,9 @@ private void UpdateDropValues(bool keepIndex = false)
446447
{
447448
lstDrops.Items.Add(
448449
Strings.NpcEditor.dropdisplay.ToString(
449-
ItemBase.GetName(mEditorItem.Drops[i].ItemId), mEditorItem.Drops[i].Quantity,
450+
ItemBase.GetName(mEditorItem.Drops[i].ItemId),
451+
mEditorItem.Drops[i].MinQuantity,
452+
mEditorItem.Drops[i].Quantity,
450453
mEditorItem.Drops[i].Chance
451454
)
452455
);
@@ -726,25 +729,34 @@ private void nudExp_ValueChanged(object sender, EventArgs e)
726729

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

737+
mEditorItem.Drops[lstDrops.SelectedIndex].ItemId = ItemBase.IdFromList(cmbDropItem.SelectedIndex - 1);
734738
UpdateDropValues(true);
735739
}
736740

737741
private void nudDropAmount_ValueChanged(object sender, EventArgs e)
738742
{
739-
// This should never be below 1. We shouldn't accept giving 0 items!
740-
nudDropAmount.Value = Math.Max(1, nudDropAmount.Value);
743+
if (lstDrops.SelectedIndex < 0 || lstDrops.SelectedIndex > lstDrops.Items.Count)
744+
{
745+
return;
746+
}
741747

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

747-
mEditorItem.Drops[(int)lstDrops.SelectedIndex].Quantity = (int)nudDropAmount.Value;
759+
mEditorItem.Drops[lstDrops.SelectedIndex].MinQuantity = (int)nudDropMinAmount.Value;
748760
UpdateDropValues(true);
749761
}
750762

@@ -754,6 +766,7 @@ private void lstDrops_SelectedIndexChanged(object sender, EventArgs e)
754766
{
755767
cmbDropItem.SelectedIndex = ItemBase.ListIndex(mEditorItem.Drops[lstDrops.SelectedIndex].ItemId) + 1;
756768
nudDropAmount.Value = mEditorItem.Drops[lstDrops.SelectedIndex].Quantity;
769+
nudDropMinAmount.Value = mEditorItem.Drops[lstDrops.SelectedIndex].MinQuantity;
757770
nudDropChance.Value = (decimal)mEditorItem.Drops[lstDrops.SelectedIndex].Chance;
758771
}
759772
}
@@ -763,6 +776,7 @@ private void btnDropAdd_Click(object sender, EventArgs e)
763776
mEditorItem.Drops.Add(new Drop());
764777
mEditorItem.Drops[mEditorItem.Drops.Count - 1].ItemId = ItemBase.IdFromList(cmbDropItem.SelectedIndex - 1);
765778
mEditorItem.Drops[mEditorItem.Drops.Count - 1].Quantity = (int)nudDropAmount.Value;
779+
mEditorItem.Drops[mEditorItem.Drops.Count - 1].MinQuantity = (int)nudDropMinAmount.Value;
766780
mEditorItem.Drops[mEditorItem.Drops.Count - 1].Chance = (double)nudDropChance.Value;
767781

768782
UpdateDropValues();
@@ -782,7 +796,7 @@ private void btnDropRemove_Click(object sender, EventArgs e)
782796

783797
private void nudDropChance_ValueChanged(object sender, EventArgs e)
784798
{
785-
if (lstDrops.SelectedIndex < lstDrops.Items.Count)
799+
if (lstDrops.SelectedIndex < 0 || lstDrops.SelectedIndex > lstDrops.Items.Count)
786800
{
787801
return;
788802
}

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)