Add GCN Quest class & fix NL/WA badge value offset

This commit is contained in:
Cuyler36 2018-10-31 03:57:50 -04:00
parent 2d07b14f81
commit d7a384cdcd
3 changed files with 91 additions and 2 deletions

View file

@ -5482,6 +5482,7 @@
<Compile Include="Classes\TrainStation.cs" />
<Compile Include="Classes\Updater.cs" />
<Compile Include="Classes\Utilities\ImageUtility.cs" />
<Compile Include="Classes\Villagers\Quests\GCNQuests.cs" />
<Compile Include="Classes\Villagers\SimpleVillager.cs" />
<Compile Include="Classes\Villagers\Villager.cs" />
<Compile Include="Classes\Yaz0.cs" />

View file

@ -0,0 +1,89 @@
using System;
namespace ACSE.Quests
{
public enum QuestCategory
{
Delivery,
Errand,
Contest,
None
}
public enum QuestDeliveryType
{
QuestBox1,
QuestBox2,
QuestBox3,
Invalid,
LostItem
}
public enum QuestErrandType
{
Invalid,
Cloth,
Seed,
Invalid2,
Letter,
Invalid3,
Invalid4,
Invalid5,
Letter2,
Invalid6,
Hello,
Invalid7
}
public enum QuestContestType
{
Ball = 0,
Flowers = 1,
Fish = 2,
Insect = 3,
Letter = 4,
Furniture = 5,
Shop = 6,
Weeds = 7,
Sick = 8
}
public static class GCNQuests
{
public static void GetCurrentQuest(Save save, Villager villager)
{
byte questInfo;
switch (save.SaveType)
{
case SaveType.DoubutsuNoMoriEPlus:
case SaveType.AnimalForestEPlus:
questInfo = save.ReadByte(villager.Offset + 0x59C);
var questCategory = (QuestCategory) (questInfo >> 6);
switch (questCategory)
{
case QuestCategory.Delivery:
Console.WriteLine(
$"Quest Category: {questCategory.ToString()} | Quest Type: {((QuestDeliveryType) (questInfo & 0x3F)).ToString()}");
break;
case QuestCategory.Errand:
Console.WriteLine(
$"Quest Category: {questCategory.ToString()} | Quest Type: {((QuestErrandType)(questInfo & 0x3F)).ToString()}");
break;
case QuestCategory.Contest:
Console.WriteLine(
$"Quest Category: {questCategory.ToString()} | Quest Type: {((QuestContestType)(questInfo & 0x3F)).ToString()}");
break;
case QuestCategory.None:
Console.WriteLine($"No quest for villager #{villager.Index}");
break;
}
break;
}
}
}
}

View file

@ -1358,14 +1358,13 @@ await Task.Run(() =>
private void AddBadges()
{
if (SaveFile == null || _selectedPlayer == null || !_selectedPlayer.Exists) return;
var badge11ValueOffset = SaveFile.SaveType == SaveType.NewLeaf ? 0x6B84 : 0x6BA4;
const int badgeValueOffset = 0x55DC; // These are the same for each version.
const int badgeLevelOffset = 0x569C; // These are also the same.
for (var i = 0; i < 24; i++)
{
var badgeControl = new BadgeControl(SaveFile, i, _selectedPlayer.Offset + badgeLevelOffset + i,
_selectedPlayer.Offset + (i == 11 ? badge11ValueOffset : badgeValueOffset + i * 8));
_selectedPlayer.Offset + badgeValueOffset + i * 8);
badgeGroupBox.Controls.Add(badgeControl);
badgeControl.Location = new Point(10 + (i % 6) * 30, 16 + (i / 6) * 30);
}