Terraria 1.4.0.5 Source Code

This commit is contained in:
MikeyIsBaeYT 2021-10-26 12:45:26 -04:00
commit 05205f009e
1059 changed files with 563450 additions and 0 deletions

View file

@ -0,0 +1,125 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.Chains
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public static class Chains
{
public static void ReportDroprates(
List<IItemDropRuleChainAttempt> ChainedRules,
float personalDropRate,
List<DropRateInfo> drops,
DropRateInfoChainFeed ratesInfo)
{
foreach (IItemDropRuleChainAttempt chainedRule in ChainedRules)
chainedRule.ReportDroprates(personalDropRate, drops, ratesInfo);
}
public static IItemDropRule OnFailedRoll(
this IItemDropRule rule,
IItemDropRule ruleToChain,
bool hideLootReport = false)
{
rule.ChainedRules.Add((IItemDropRuleChainAttempt) new Chains.TryIfFailedRandomRoll(ruleToChain, hideLootReport));
return ruleToChain;
}
public static IItemDropRule OnSuccess(
this IItemDropRule rule,
IItemDropRule ruleToChain,
bool hideLootReport = false)
{
rule.ChainedRules.Add((IItemDropRuleChainAttempt) new Chains.TryIfSucceeded(ruleToChain, hideLootReport));
return ruleToChain;
}
public static IItemDropRule OnFailedConditions(
this IItemDropRule rule,
IItemDropRule ruleToChain,
bool hideLootReport = false)
{
rule.ChainedRules.Add((IItemDropRuleChainAttempt) new Chains.TryIfDoesntFillConditions(ruleToChain, hideLootReport));
return ruleToChain;
}
public class TryIfFailedRandomRoll : IItemDropRuleChainAttempt
{
private bool _hideLootReport;
public IItemDropRule RuleToChain { get; private set; }
public TryIfFailedRandomRoll(IItemDropRule rule, bool hideLootReport = false)
{
this.RuleToChain = rule;
this._hideLootReport = hideLootReport;
}
public bool CanChainIntoRule(ItemDropAttemptResult parentResult) => parentResult.State == ItemDropAttemptResultState.FailedRandomRoll;
public void ReportDroprates(
float personalDropRate,
List<DropRateInfo> drops,
DropRateInfoChainFeed ratesInfo)
{
if (this._hideLootReport)
return;
this.RuleToChain.ReportDroprates(drops, ratesInfo.With(1f - personalDropRate));
}
}
public class TryIfSucceeded : IItemDropRuleChainAttempt
{
private bool _hideLootReport;
public IItemDropRule RuleToChain { get; private set; }
public TryIfSucceeded(IItemDropRule rule, bool hideLootReport = false)
{
this.RuleToChain = rule;
this._hideLootReport = hideLootReport;
}
public bool CanChainIntoRule(ItemDropAttemptResult parentResult) => parentResult.State == ItemDropAttemptResultState.Success;
public void ReportDroprates(
float personalDropRate,
List<DropRateInfo> drops,
DropRateInfoChainFeed ratesInfo)
{
if (this._hideLootReport)
return;
this.RuleToChain.ReportDroprates(drops, ratesInfo.With(personalDropRate));
}
}
public class TryIfDoesntFillConditions : IItemDropRuleChainAttempt
{
private bool _hideLootReport;
public IItemDropRule RuleToChain { get; private set; }
public TryIfDoesntFillConditions(IItemDropRule rule, bool hideLootReport = false)
{
this.RuleToChain = rule;
this._hideLootReport = hideLootReport;
}
public bool CanChainIntoRule(ItemDropAttemptResult parentResult) => parentResult.State == ItemDropAttemptResultState.DoesntFillConditions;
public void ReportDroprates(
float personalDropRate,
List<DropRateInfo> drops,
DropRateInfoChainFeed ratesInfo)
{
if (this._hideLootReport)
return;
this.RuleToChain.ReportDroprates(drops, ratesInfo.With(personalDropRate));
}
}
}
}

View file

@ -0,0 +1,117 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.CommonCode
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.Utilities;
namespace Terraria.GameContent.ItemDropRules
{
public static class CommonCode
{
public static void DropItemFromNPC(NPC npc, int itemId, int stack, bool scattered = false)
{
if (itemId <= 0 || itemId >= 5045)
return;
int X = (int) npc.position.X + npc.width / 2;
int Y = (int) npc.position.Y + npc.height / 2;
if (scattered)
{
X = (int) npc.position.X + Main.rand.Next(npc.width + 1);
Y = (int) npc.position.Y + Main.rand.Next(npc.height + 1);
}
int itemIndex = Item.NewItem(X, Y, 0, 0, itemId, stack, pfix: -1);
CommonCode.ModifyItemDropFromNPC(npc, itemIndex);
}
public static void DropItemLocalPerClientAndSetNPCMoneyTo0(
NPC npc,
int itemId,
int stack,
bool interactionRequired = true)
{
if (itemId <= 0 || itemId >= 5045)
return;
if (Main.netMode == 2)
{
int number = Item.NewItem((int) npc.position.X, (int) npc.position.Y, npc.width, npc.height, itemId, stack, true, -1);
Main.timeItemSlotCannotBeReusedFor[number] = 54000;
for (int remoteClient = 0; remoteClient < (int) byte.MaxValue; ++remoteClient)
{
if (Main.player[remoteClient].active && (npc.playerInteraction[remoteClient] || !interactionRequired))
NetMessage.SendData(90, remoteClient, number: number);
}
Main.item[number].active = false;
}
else
CommonCode.DropItemFromNPC(npc, itemId, stack);
npc.value = 0.0f;
}
public static void DropItemForEachInteractingPlayerOnThePlayer(
NPC npc,
int itemId,
UnifiedRandom rng,
int dropsAtXOutOfY_TheX,
int dropsAtXOutOfY_TheY,
int stack = 1,
bool interactionRequired = true)
{
if (itemId <= 0 || itemId >= 5045)
return;
if (Main.netMode == 2)
{
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
Player player = Main.player[index];
if (player.active && (npc.playerInteraction[index] || !interactionRequired) && rng.Next(dropsAtXOutOfY_TheY) < dropsAtXOutOfY_TheX)
{
int itemIndex = Item.NewItem(player.position, player.Size, itemId, stack, prefixGiven: -1);
CommonCode.ModifyItemDropFromNPC(npc, itemIndex);
}
}
}
else if (rng.Next(dropsAtXOutOfY_TheY) < dropsAtXOutOfY_TheX)
CommonCode.DropItemFromNPC(npc, itemId, stack);
npc.value = 0.0f;
}
private static void ModifyItemDropFromNPC(NPC npc, int itemIndex)
{
Item obj = Main.item[itemIndex];
switch (obj.type)
{
case 23:
if (npc.type != 1 || npc.netID == -1 || npc.netID == -2 || npc.netID == -5 || npc.netID == -6)
break;
obj.color = npc.color;
NetMessage.SendData(88, number: itemIndex, number2: 1f);
break;
case 319:
switch (npc.netID)
{
case 542:
obj.color = new Color(189, 148, 96, (int) byte.MaxValue);
NetMessage.SendData(88, number: itemIndex, number2: 1f);
return;
case 543:
obj.color = new Color(112, 85, 89, (int) byte.MaxValue);
NetMessage.SendData(88, number: itemIndex, number2: 1f);
return;
case 544:
obj.color = new Color(145, 27, 40, (int) byte.MaxValue);
NetMessage.SendData(88, number: itemIndex, number2: 1f);
return;
case 545:
obj.color = new Color(158, 113, 164, (int) byte.MaxValue);
NetMessage.SendData(88, number: itemIndex, number2: 1f);
return;
default:
return;
}
}
}
}
}

View file

@ -0,0 +1,62 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.CommonDrop
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class CommonDrop : IItemDropRule
{
protected int _itemId;
protected int _dropsOutOfY;
protected int _amtDroppedMinimum;
protected int _amtDroppedMaximum;
protected int _dropsXoutOfY;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public CommonDrop(
int itemId,
int dropsOutOfY,
int amountDroppedMinimum = 1,
int amountDroppedMaximum = 1,
int dropsXOutOfY = 1)
{
this._itemId = itemId;
this._dropsOutOfY = dropsOutOfY;
this._amtDroppedMinimum = amountDroppedMinimum;
this._amtDroppedMaximum = amountDroppedMaximum;
this._dropsXoutOfY = dropsXOutOfY;
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
}
public virtual bool CanDrop(DropAttemptInfo info) => true;
public virtual ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
if (info.player.RollLuck(this._dropsOutOfY) < this._dropsXoutOfY)
{
CommonCode.DropItemFromNPC(info.npc, this._itemId, info.rng.Next(this._amtDroppedMinimum, this._amtDroppedMaximum + 1));
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
public virtual void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
float personalDropRate = (float) this._dropsXoutOfY / (float) this._dropsOutOfY;
float dropRate = personalDropRate * ratesInfo.parentDroprateChance;
drops.Add(new DropRateInfo(this._itemId, this._amtDroppedMinimum, this._amtDroppedMaximum, dropRate, ratesInfo.conditions));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,36 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.CommonDropNotScalingWithLuck
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public class CommonDropNotScalingWithLuck : CommonDrop
{
public CommonDropNotScalingWithLuck(
int itemId,
int dropsOutOfY,
int amountDroppedMinimum,
int amountDroppedMaximum)
: base(itemId, dropsOutOfY, amountDroppedMinimum, amountDroppedMaximum)
{
}
public override ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
if (info.rng.Next(this._dropsOutOfY) < this._dropsXoutOfY)
{
CommonCode.DropItemFromNPC(info.npc, this._itemId, info.rng.Next(this._amtDroppedMinimum, this._amtDroppedMaximum + 1));
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
}
}

View file

@ -0,0 +1,57 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.CommonDropWithRerolls
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class CommonDropWithRerolls : CommonDrop
{
private int _timesToRoll;
public CommonDropWithRerolls(
int itemId,
int dropsOutOfY,
int amountDroppedMinimum,
int amountDroppedMaximum,
int rerolls)
: base(itemId, dropsOutOfY, amountDroppedMinimum, amountDroppedMaximum)
{
this._timesToRoll = rerolls + 1;
}
public override ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
bool flag = false;
for (int index = 0; index < this._timesToRoll; ++index)
flag = flag || info.player.RollLuck(this._dropsOutOfY) < this._dropsXoutOfY;
if (flag)
{
CommonCode.DropItemFromNPC(info.npc, this._itemId, info.rng.Next(this._amtDroppedMinimum, this._amtDroppedMaximum + 1));
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
public override void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
float num1 = 1f - (float) this._dropsXoutOfY / (float) this._dropsOutOfY;
float num2 = 1f;
for (int index = 0; index < this._timesToRoll; ++index)
num2 *= num1;
float personalDropRate = 1f - num2;
float dropRate = personalDropRate * ratesInfo.parentDroprateChance;
drops.Add(new DropRateInfo(this._itemId, this._amtDroppedMinimum, this._amtDroppedMaximum, dropRate, ratesInfo.conditions));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,576 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.Conditions
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Terraria.Localization;
namespace Terraria.GameContent.ItemDropRules
{
public class Conditions
{
private static bool SoulOfWhateverConditionCanDrop(DropAttemptInfo info)
{
if (info.npc.boss)
return false;
switch (info.npc.type)
{
case 1:
case 13:
case 14:
case 15:
case 121:
case 535:
return false;
default:
return Main.hardMode && info.npc.lifeMax > 1 && !info.npc.friendly && (double) info.npc.position.Y > Main.rockLayer * 16.0 && (double) info.npc.value >= 1.0;
}
}
public class NeverTrue : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => false;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class IsUsingSpecificAIValues : IItemDropRuleCondition, IProvideItemConditionDescription
{
private int _aiSlotToCheck;
private float _valueToMatch;
public IsUsingSpecificAIValues(int aislot, float valueToMatch)
{
this._aiSlotToCheck = aislot;
this._valueToMatch = valueToMatch;
}
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.ai[this._aiSlotToCheck] == (double) this._valueToMatch;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class FrostMoonDropGatingChance : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info)
{
if (!Main.snowMoon)
return false;
int waveNumber = NPC.waveNumber;
if (Main.expertMode)
waveNumber += 7;
int range = (int) ((double) (30 - waveNumber) / 2.5);
if (Main.expertMode)
range -= 2;
if (range < 1)
range = 1;
return info.player.RollLuck(range) == 0;
}
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class PumpkinMoonDropGatingChance :
IItemDropRuleCondition,
IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info)
{
if (!Main.pumpkinMoon)
return false;
int waveNumber = NPC.waveNumber;
if (Main.expertMode)
waveNumber += 6;
int range = (int) ((double) (17 - waveNumber) / 1.25);
if (Main.expertMode)
--range;
if (range < 1)
range = 1;
return info.player.RollLuck(range) == 0;
}
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class FrostMoonDropGateForTrophies :
IItemDropRuleCondition,
IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info)
{
if (!Main.snowMoon)
return false;
int waveNumber = NPC.waveNumber;
if (NPC.waveNumber < 15)
return false;
int maxValue = 4;
if (waveNumber == 16)
maxValue = 4;
if (waveNumber == 17)
maxValue = 3;
if (waveNumber == 18)
maxValue = 3;
if (waveNumber == 19)
maxValue = 2;
if (waveNumber >= 20)
maxValue = 2;
if (Main.expertMode && Main.rand.Next(3) == 0)
--maxValue;
return info.rng.Next(maxValue) == 0;
}
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class IsPumpkinMoon : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.pumpkinMoon;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class FromCertainWaveAndAbove : IItemDropRuleCondition, IProvideItemConditionDescription
{
private int _neededWave;
public FromCertainWaveAndAbove(int neededWave) => this._neededWave = neededWave;
public bool CanDrop(DropAttemptInfo info) => NPC.waveNumber >= this._neededWave;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class IsBloodMoonAndNotFromStatue :
IItemDropRuleCondition,
IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !Main.dayTime && Main.bloodMoon && !info.npc.SpawnedFromStatue && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class DownedAllMechBosses : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class DownedPlantera : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => NPC.downedPlantBoss;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class FirstTimeKillingPlantera : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !NPC.downedPlantBoss;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class MechanicalBossesDummyCondition :
IItemDropRuleCondition,
IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => true;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class PirateMap : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && (double) info.npc.position.Y / 16.0 < Main.worldSurface + 10.0 && ((double) info.npc.Center.X / 16.0 < 380.0 || (double) info.npc.Center.X / 16.0 > (double) (Main.maxTilesX - 380)) && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.PirateMap");
}
public class IsChristmas : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.xMas;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.IsChristmas");
}
public class NotExpert : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !Main.expertMode;
public bool CanShowItemDropInUI() => !Main.expertMode;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.NotExpert");
}
public class NotMasterMode : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !Main.masterMode;
public bool CanShowItemDropInUI() => !Main.masterMode;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.NotMasterMode");
}
public class MissingTwin : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info)
{
int Type = 125;
if (info.npc.type == 125)
Type = 126;
return !NPC.AnyNPCs(Type);
}
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class EmpressOfLightIsGenuinelyEnraged :
IItemDropRuleCondition,
IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => info.npc.AI_120_HallowBoss_IsGenuinelyEnraged();
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.EmpressOfLightOnlyTookDamageWhileEnraged");
}
public class PlayerNeedsHealing : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => info.player.statLife < info.player.statLifeMax2;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.PlayerNeedsHealing");
}
public class LegacyHack_IsBossAndExpert :
IItemDropRuleCondition,
IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => info.npc.boss && Main.expertMode;
public bool CanShowItemDropInUI() => Main.expertMode;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.LegacyHack_IsBossAndExpert");
}
public class LegacyHack_IsBossAndNotExpert :
IItemDropRuleCondition,
IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => info.npc.boss && !Main.expertMode;
public bool CanShowItemDropInUI() => !Main.expertMode;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.LegacyHack_IsBossAndNotExpert");
}
public class LegacyHack_IsABoss : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => info.npc.boss;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => (string) null;
}
public class IsExpert : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.expertMode;
public bool CanShowItemDropInUI() => Main.expertMode;
public string GetConditionDescription() => Main.masterMode ? Language.GetTextValue("Bestiary_ItemDropConditions.IsMasterMode") : Language.GetTextValue("Bestiary_ItemDropConditions.IsExpert");
}
public class IsMasterMode : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.masterMode;
public bool CanShowItemDropInUI() => Main.masterMode;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.IsMasterMode");
}
public class IsCrimson : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => WorldGen.crimson;
public bool CanShowItemDropInUI() => WorldGen.crimson;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.IsCrimson");
}
public class IsCorruption : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !WorldGen.crimson;
public bool CanShowItemDropInUI() => !WorldGen.crimson;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.IsCorruption");
}
public class IsCrimsonAndNotExpert : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => WorldGen.crimson && !Main.expertMode;
public bool CanShowItemDropInUI() => WorldGen.crimson && !Main.expertMode;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.IsCrimsonAndNotExpert");
}
public class IsCorruptionAndNotExpert : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !WorldGen.crimson && !Main.expertMode;
public bool CanShowItemDropInUI() => !WorldGen.crimson && !Main.expertMode;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.IsCorruptionAndNotExpert");
}
public class HalloweenWeapons : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info)
{
float num1 = 500f * Main.GameModeInfo.EnemyMoneyDropMultiplier;
float num2 = 40f * Main.GameModeInfo.EnemyDamageMultiplier;
float num3 = 20f * Main.GameModeInfo.EnemyDefenseMultiplier;
return Main.halloween && (double) info.npc.value > 0.0 && (double) info.npc.value < (double) num1 && (double) info.npc.damage < (double) num2 && (double) info.npc.defense < (double) num3 && !info.IsInSimulation;
}
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.HalloweenWeapons");
}
public class SoulOfNight : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info)
{
if (!Conditions.SoulOfWhateverConditionCanDrop(info))
return false;
return info.player.ZoneCorrupt || info.player.ZoneCrimson;
}
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.SoulOfNight");
}
public class SoulOfLight : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Conditions.SoulOfWhateverConditionCanDrop(info) && info.player.ZoneHallow;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.SoulOfLight");
}
public class NotFromStatue : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !info.npc.SpawnedFromStatue;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.NotFromStatue");
}
public class HalloweenGoodieBagDrop : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.halloween && info.npc.lifeMax > 1 && info.npc.damage > 0 && !info.npc.friendly && info.npc.type != 121 && info.npc.type != 23 && (double) info.npc.value > 0.0 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.HalloweenGoodieBagDrop");
}
public class XmasPresentDrop : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.xMas && info.npc.lifeMax > 1 && info.npc.damage > 0 && !info.npc.friendly && info.npc.type != 121 && info.npc.type != 23 && (double) info.npc.value > 0.0 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.XmasPresentDrop");
}
public class LivingFlames : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => info.npc.lifeMax > 5 && (double) info.npc.value > 0.0 && !info.npc.friendly && Main.hardMode && (double) info.npc.position.Y / 16.0 > (double) Main.UnderworldLayer && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.LivingFlames");
}
public class NamedNPC : IItemDropRuleCondition, IProvideItemConditionDescription
{
private string _neededName;
public NamedNPC(string neededName) => this._neededName = neededName;
public bool CanDrop(DropAttemptInfo info) => info.npc.GivenOrTypeName == this._neededName;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.NamedNPC");
}
public class HallowKeyCondition : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && !info.IsInSimulation && info.player.ZoneHallow;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.HallowKeyCondition");
}
public class JungleKeyCondition : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && !info.IsInSimulation && info.player.ZoneJungle;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.JungleKeyCondition");
}
public class CorruptKeyCondition : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && !info.IsInSimulation && info.player.ZoneCorrupt;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.CorruptKeyCondition");
}
public class CrimsonKeyCondition : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && !info.IsInSimulation && info.player.ZoneCrimson;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.CrimsonKeyCondition");
}
public class FrozenKeyCondition : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && !info.IsInSimulation && info.player.ZoneSnow;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.FrozenKeyCondition");
}
public class DesertKeyCondition : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && !info.IsInSimulation && info.player.ZoneDesert && !info.player.ZoneBeach;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.DesertKeyCondition");
}
public class BeatAnyMechBoss : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => NPC.downedMechBossAny;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.BeatAnyMechBoss");
}
public class YoyoCascade : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => !Main.hardMode && info.npc.HasPlayerTarget && info.npc.lifeMax > 5 && !info.npc.friendly && (double) info.npc.position.Y / 16.0 > (double) (Main.maxTilesY - 350) && NPC.downedBoss3 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.YoyoCascade");
}
public class YoyosAmarok : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.hardMode && info.npc.HasPlayerTarget && info.player.ZoneSnow && info.npc.lifeMax > 5 && !info.npc.friendly && (double) info.npc.value > 0.0 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.YoyosAmarok");
}
public class YoyosYelets : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.hardMode && info.player.ZoneJungle && NPC.downedMechBossAny && info.npc.lifeMax > 5 && info.npc.HasPlayerTarget && !info.npc.friendly && (double) info.npc.value > 0.0 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.YoyosYelets");
}
public class YoyosKraken : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.hardMode && info.player.ZoneDungeon && NPC.downedPlantBoss && info.npc.lifeMax > 5 && info.npc.HasPlayerTarget && !info.npc.friendly && (double) info.npc.value > 0.0 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.YoyosKraken");
}
public class YoyosHelFire : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.hardMode && !info.player.ZoneDungeon && (double) info.npc.position.Y / 16.0 > (Main.rockLayer + (double) (Main.maxTilesY * 2)) / 3.0 && info.npc.lifeMax > 5 && info.npc.HasPlayerTarget && !info.npc.friendly && (double) info.npc.value > 0.0 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.YoyosHelFire");
}
public class KOCannon : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.hardMode && Main.bloodMoon && (double) info.npc.value > 0.0 && !info.IsInSimulation;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.KOCannon");
}
public class WindyEnoughForKiteDrops : IItemDropRuleCondition, IProvideItemConditionDescription
{
public bool CanDrop(DropAttemptInfo info) => Main.WindyEnoughForKiteDrops;
public bool CanShowItemDropInUI() => true;
public string GetConditionDescription() => Language.GetTextValue("Bestiary_ItemDropConditions.IsItAHappyWindyDay");
}
}
}

View file

@ -0,0 +1,20 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropAttemptInfo
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Terraria.Utilities;
namespace Terraria.GameContent.ItemDropRules
{
public struct DropAttemptInfo
{
public NPC npc;
public Player player;
public UnifiedRandom rng;
public bool IsInSimulation;
public bool IsExpertMode;
public bool IsMasterMode;
}
}

View file

@ -0,0 +1,50 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropBasedOnExpertMode
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class DropBasedOnExpertMode : IItemDropRule, INestedItemDropRule
{
private IItemDropRule _ruleForNormalMode;
private IItemDropRule _ruleForExpertMode;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public DropBasedOnExpertMode(IItemDropRule ruleForNormalMode, IItemDropRule ruleForExpertMode)
{
this._ruleForNormalMode = ruleForNormalMode;
this._ruleForExpertMode = ruleForExpertMode;
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
}
public bool CanDrop(DropAttemptInfo info) => info.IsExpertMode ? this._ruleForExpertMode.CanDrop(info) : this._ruleForNormalMode.CanDrop(info);
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info) => new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.DidNotRunCode
};
public ItemDropAttemptResult TryDroppingItem(
DropAttemptInfo info,
ItemDropRuleResolveAction resolveAction)
{
return info.IsExpertMode ? resolveAction(this._ruleForExpertMode, info) : resolveAction(this._ruleForNormalMode, info);
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
DropRateInfoChainFeed ratesInfo1 = ratesInfo.With(1f);
ratesInfo1.AddCondition((IItemDropRuleCondition) new Conditions.IsExpert());
this._ruleForExpertMode.ReportDroprates(drops, ratesInfo1);
DropRateInfoChainFeed ratesInfo2 = ratesInfo.With(1f);
ratesInfo2.AddCondition((IItemDropRuleCondition) new Conditions.NotExpert());
this._ruleForNormalMode.ReportDroprates(drops, ratesInfo2);
Chains.ReportDroprates(this.ChainedRules, 1f, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,50 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropBasedOnMasterMode
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class DropBasedOnMasterMode : IItemDropRule, INestedItemDropRule
{
private IItemDropRule _ruleForDefault;
private IItemDropRule _ruleForMasterMode;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public DropBasedOnMasterMode(IItemDropRule ruleForDefault, IItemDropRule ruleForMasterMode)
{
this._ruleForDefault = ruleForDefault;
this._ruleForMasterMode = ruleForMasterMode;
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
}
public bool CanDrop(DropAttemptInfo info) => info.IsMasterMode ? this._ruleForMasterMode.CanDrop(info) : this._ruleForDefault.CanDrop(info);
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info) => new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.DidNotRunCode
};
public ItemDropAttemptResult TryDroppingItem(
DropAttemptInfo info,
ItemDropRuleResolveAction resolveAction)
{
return info.IsMasterMode ? resolveAction(this._ruleForMasterMode, info) : resolveAction(this._ruleForDefault, info);
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
DropRateInfoChainFeed ratesInfo1 = ratesInfo.With(1f);
ratesInfo1.AddCondition((IItemDropRuleCondition) new Conditions.IsMasterMode());
this._ruleForMasterMode.ReportDroprates(drops, ratesInfo1);
DropRateInfoChainFeed ratesInfo2 = ratesInfo.With(1f);
ratesInfo2.AddCondition((IItemDropRuleCondition) new Conditions.NotMasterMode());
this._ruleForDefault.ReportDroprates(drops, ratesInfo2);
Chains.ReportDroprates(this.ChainedRules, 1f, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,42 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropLocalPerClientAndResetsNPCMoneyTo0
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public class DropLocalPerClientAndResetsNPCMoneyTo0 : CommonDrop
{
private IItemDropRuleCondition _condition;
public DropLocalPerClientAndResetsNPCMoneyTo0(
int itemId,
int dropsOutOfY,
int amountDroppedMinimum,
int amountDroppedMaximum,
IItemDropRuleCondition optionalCondition)
: base(itemId, dropsOutOfY, amountDroppedMinimum, amountDroppedMaximum)
{
this._condition = optionalCondition;
}
public override bool CanDrop(DropAttemptInfo info) => this._condition == null || this._condition.CanDrop(info);
public override ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
if (info.rng.Next(this._dropsOutOfY) < this._dropsXoutOfY)
{
CommonCode.DropItemLocalPerClientAndSetNPCMoneyTo0(info.npc, this._itemId, info.rng.Next(this._amtDroppedMinimum, this._amtDroppedMaximum + 1));
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
}
}

View file

@ -0,0 +1,26 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropNothing
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class DropNothing : IItemDropRule
{
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public DropNothing() => this.ChainedRules = new List<IItemDropRuleChainAttempt>();
public bool CanDrop(DropAttemptInfo info) => false;
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info) => new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.DoesntFillConditions
};
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo) => Chains.ReportDroprates(this.ChainedRules, 1f, drops, ratesInfo);
}
}

View file

@ -0,0 +1,70 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropOneByOne
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class DropOneByOne : IItemDropRule
{
private int _itemId;
private DropOneByOne.Parameters _parameters;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public DropOneByOne(int itemId, DropOneByOne.Parameters parameters)
{
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
this._parameters = parameters;
this._itemId = itemId;
}
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
if (info.player.RollLuck(this._parameters.DropsXOutOfYTimes_TheY) < this._parameters.DropsXOutOfYTimes_TheX)
{
int num1 = info.rng.Next(this._parameters.MinimumItemDropsCount, this._parameters.MaximumItemDropsCount + 1);
int activePlayersCount = Main.CurrentFrameFlags.ActivePlayersCount;
int minValue = this._parameters.MinimumStackPerChunkBase + activePlayersCount * this._parameters.BonusMinDropsPerChunkPerPlayer;
int num2 = this._parameters.MaximumStackPerChunkBase + activePlayersCount * this._parameters.BonusMaxDropsPerChunkPerPlayer;
for (int index = 0; index < num1; ++index)
CommonCode.DropItemFromNPC(info.npc, this._itemId, info.rng.Next(minValue, num2 + 1), true);
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
float personalDropRate = this._parameters.GetPersonalDropRate();
float dropRate = personalDropRate * ratesInfo.parentDroprateChance;
drops.Add(new DropRateInfo(this._itemId, this._parameters.MinimumItemDropsCount * (this._parameters.MinimumStackPerChunkBase + this._parameters.BonusMinDropsPerChunkPerPlayer), this._parameters.MaximumItemDropsCount * (this._parameters.MaximumStackPerChunkBase + this._parameters.BonusMaxDropsPerChunkPerPlayer), dropRate, ratesInfo.conditions));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo);
}
public bool CanDrop(DropAttemptInfo info) => true;
public struct Parameters
{
public int DropsXOutOfYTimes_TheX;
public int DropsXOutOfYTimes_TheY;
public int MinimumItemDropsCount;
public int MaximumItemDropsCount;
public int MinimumStackPerChunkBase;
public int MaximumStackPerChunkBase;
public int BonusMinDropsPerChunkPerPlayer;
public int BonusMaxDropsPerChunkPerPlayer;
public float GetPersonalDropRate() => (float) this.DropsXOutOfYTimes_TheX / (float) this.DropsXOutOfYTimes_TheY;
}
}
}

View file

@ -0,0 +1,35 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropPerPlayerOnThePlayer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public class DropPerPlayerOnThePlayer : CommonDrop
{
private IItemDropRuleCondition _condition;
public DropPerPlayerOnThePlayer(
int itemId,
int dropsOutOfY,
int amountDroppedMinimum,
int amountDroppedMaximum,
IItemDropRuleCondition optionalCondition)
: base(itemId, dropsOutOfY, amountDroppedMinimum, amountDroppedMaximum)
{
this._condition = optionalCondition;
}
public override bool CanDrop(DropAttemptInfo info) => this._condition == null || this._condition.CanDrop(info);
public override ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
CommonCode.DropItemForEachInteractingPlayerOnThePlayer(info.npc, this._itemId, info.rng, this._dropsXoutOfY, this._dropsOutOfY, info.rng.Next(this._amtDroppedMinimum, this._amtDroppedMaximum + 1));
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
}
}

View file

@ -0,0 +1,43 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropRateInfo
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public struct DropRateInfo
{
public int itemId;
public int stackMin;
public int stackMax;
public float dropRate;
public List<IItemDropRuleCondition> conditions;
public DropRateInfo(
int itemId,
int stackMin,
int stackMax,
float dropRate,
List<IItemDropRuleCondition> conditions = null)
{
this.itemId = itemId;
this.stackMin = stackMin;
this.stackMax = stackMax;
this.dropRate = dropRate;
this.conditions = (List<IItemDropRuleCondition>) null;
if (conditions == null || conditions.Count <= 0)
return;
this.conditions = new List<IItemDropRuleCondition>((IEnumerable<IItemDropRuleCondition>) conditions);
}
public void AddCondition(IItemDropRuleCondition condition)
{
if (this.conditions == null)
this.conditions = new List<IItemDropRuleCondition>();
this.conditions.Add(condition);
}
}
}

View file

@ -0,0 +1,37 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.DropRateInfoChainFeed
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public struct DropRateInfoChainFeed
{
public float parentDroprateChance;
public List<IItemDropRuleCondition> conditions;
public void AddCondition(IItemDropRuleCondition condition)
{
if (this.conditions == null)
this.conditions = new List<IItemDropRuleCondition>();
this.conditions.Add(condition);
}
public DropRateInfoChainFeed(float droprate)
{
this.parentDroprateChance = droprate;
this.conditions = (List<IItemDropRuleCondition>) null;
}
public DropRateInfoChainFeed With(float multiplier)
{
DropRateInfoChainFeed rateInfoChainFeed = new DropRateInfoChainFeed(this.parentDroprateChance * multiplier);
if (this.conditions != null)
rateInfoChainFeed.conditions = new List<IItemDropRuleCondition>((IEnumerable<IItemDropRuleCondition>) this.conditions);
return rateInfoChainFeed;
}
}
}

View file

@ -0,0 +1,21 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.IItemDropRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public interface IItemDropRule
{
List<IItemDropRuleChainAttempt> ChainedRules { get; }
bool CanDrop(DropAttemptInfo info);
void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo);
ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info);
}
}

View file

@ -0,0 +1,22 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.IItemDropRuleChainAttempt
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public interface IItemDropRuleChainAttempt
{
IItemDropRule RuleToChain { get; }
bool CanChainIntoRule(ItemDropAttemptResult parentResult);
void ReportDroprates(
float personalDropRate,
List<DropRateInfo> drops,
DropRateInfoChainFeed ratesInfo);
}
}

View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.IItemDropRuleCondition
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public interface IItemDropRuleCondition : IProvideItemConditionDescription
{
bool CanDrop(DropAttemptInfo info);
bool CanShowItemDropInUI();
}
}

View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.INestedItemDropRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public interface INestedItemDropRule
{
ItemDropAttemptResult TryDroppingItem(
DropAttemptInfo info,
ItemDropRuleResolveAction resolveAction);
}
}

View file

@ -0,0 +1,13 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.IProvideItemConditionDescription
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public interface IProvideItemConditionDescription
{
string GetConditionDescription();
}
}

View file

@ -0,0 +1,13 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.ItemDropAttemptResult
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public struct ItemDropAttemptResult
{
public ItemDropAttemptResultState State;
}
}

View file

@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.ItemDropAttemptResultState
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public enum ItemDropAttemptResultState
{
DoesntFillConditions,
FailedRandomRoll,
Success,
DidNotRunCode,
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,65 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.ItemDropResolver
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class ItemDropResolver
{
private ItemDropDatabase _database;
public ItemDropResolver(ItemDropDatabase database) => this._database = database;
public void TryDropping(DropAttemptInfo info)
{
List<IItemDropRule> rulesForNpcid = this._database.GetRulesForNPCID(info.npc.netID);
for (int index = 0; index < rulesForNpcid.Count; ++index)
this.ResolveRule(rulesForNpcid[index], info);
}
private ItemDropAttemptResult ResolveRule(
IItemDropRule rule,
DropAttemptInfo info)
{
if (!rule.CanDrop(info))
{
ItemDropAttemptResult parentResult = new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.DoesntFillConditions
};
this.ResolveRuleChains(rule, info, parentResult);
return parentResult;
}
ItemDropAttemptResult parentResult1 = !(rule is INestedItemDropRule nestedItemDropRule) ? rule.TryDroppingItem(info) : nestedItemDropRule.TryDroppingItem(info, new ItemDropRuleResolveAction(this.ResolveRule));
this.ResolveRuleChains(rule, info, parentResult1);
return parentResult1;
}
private void ResolveRuleChains(
IItemDropRule rule,
DropAttemptInfo info,
ItemDropAttemptResult parentResult)
{
this.ResolveRuleChains(ref info, ref parentResult, rule.ChainedRules);
}
private void ResolveRuleChains(
ref DropAttemptInfo info,
ref ItemDropAttemptResult parentResult,
List<IItemDropRuleChainAttempt> ruleChains)
{
if (ruleChains == null)
return;
for (int index = 0; index < ruleChains.Count; ++index)
{
IItemDropRuleChainAttempt ruleChain = ruleChains[index];
if (ruleChain.CanChainIntoRule(parentResult))
this.ResolveRule(ruleChain.RuleToChain, info);
}
}
}
}

View file

@ -0,0 +1,146 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.ItemDropRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public class ItemDropRule
{
public static IItemDropRule Common(
int itemId,
int dropsOutOfX = 1,
int minimumDropped = 1,
int maximumDropped = 1)
{
return (IItemDropRule) new CommonDrop(itemId, dropsOutOfX, minimumDropped, maximumDropped);
}
public static IItemDropRule BossBag(int itemId) => (IItemDropRule) new DropBasedOnExpertMode(ItemDropRule.DropNothing(), (IItemDropRule) new DropLocalPerClientAndResetsNPCMoneyTo0(itemId, 1, 1, 1, (IItemDropRuleCondition) null));
public static IItemDropRule BossBagByCondition(
IItemDropRuleCondition condition,
int itemId)
{
return (IItemDropRule) new DropBasedOnExpertMode(ItemDropRule.DropNothing(), (IItemDropRule) new DropLocalPerClientAndResetsNPCMoneyTo0(itemId, 1, 1, 1, condition));
}
public static IItemDropRule ExpertGetsRerolls(
int itemId,
int dropsOutOfX,
int expertRerolls)
{
return (IItemDropRule) new DropBasedOnExpertMode(ItemDropRule.WithRerolls(itemId, 0, dropsOutOfX), ItemDropRule.WithRerolls(itemId, expertRerolls, dropsOutOfX));
}
public static IItemDropRule MasterModeCommonDrop(int itemId) => ItemDropRule.ByCondition((IItemDropRuleCondition) new Conditions.IsMasterMode(), itemId);
public static IItemDropRule MasterModeDropOnAllPlayers(
int itemId,
int dropsAtXOutOfY_TheY = 1)
{
return (IItemDropRule) new DropBasedOnMasterMode(ItemDropRule.DropNothing(), (IItemDropRule) new DropPerPlayerOnThePlayer(itemId, dropsAtXOutOfY_TheY, 1, 1, (IItemDropRuleCondition) new Conditions.IsMasterMode()));
}
public static IItemDropRule WithRerolls(
int itemId,
int rerolls,
int dropsOutOfX = 1,
int minimumDropped = 1,
int maximumDropped = 1)
{
return (IItemDropRule) new CommonDropWithRerolls(itemId, dropsOutOfX, minimumDropped, maximumDropped, rerolls);
}
public static IItemDropRule ByCondition(
IItemDropRuleCondition condition,
int itemId,
int dropsOutOfX = 1,
int minimumDropped = 1,
int maximumDropped = 1,
int dropsXOutOfY = 1)
{
return (IItemDropRule) new ItemDropWithConditionRule(itemId, dropsOutOfX, minimumDropped, maximumDropped, condition, dropsXOutOfY);
}
public static IItemDropRule NotScalingWithLuck(
int itemId,
int dropsOutOfX = 1,
int minimumDropped = 1,
int maximumDropped = 1)
{
return (IItemDropRule) new CommonDrop(itemId, dropsOutOfX, minimumDropped, maximumDropped);
}
public static IItemDropRule OneFromOptionsNotScalingWithLuck(
int dropsOutOfX,
params int[] options)
{
return (IItemDropRule) new OneFromOptionsNotScaledWithLuckDropRule(dropsOutOfX, 1, options);
}
public static IItemDropRule OneFromOptionsNotScalingWithLuckWithX(
int dropsOutOfY,
int xOutOfY,
params int[] options)
{
return (IItemDropRule) new OneFromOptionsNotScaledWithLuckDropRule(dropsOutOfY, xOutOfY, options);
}
public static IItemDropRule OneFromOptions(int dropsOutOfX, params int[] options) => (IItemDropRule) new OneFromOptionsDropRule(dropsOutOfX, 1, options);
public static IItemDropRule OneFromOptionsWithX(
int dropsOutOfY,
int xOutOfY,
params int[] options)
{
return (IItemDropRule) new OneFromOptionsDropRule(dropsOutOfY, xOutOfY, options);
}
public static IItemDropRule DropNothing() => (IItemDropRule) new Terraria.GameContent.ItemDropRules.DropNothing();
public static IItemDropRule NormalvsExpert(
int itemId,
int oncePerXInNormal,
int oncePerXInExpert)
{
return (IItemDropRule) new DropBasedOnExpertMode(ItemDropRule.Common(itemId, oncePerXInNormal), ItemDropRule.Common(itemId, oncePerXInExpert));
}
public static IItemDropRule NormalvsExpertNotScalingWithLuck(
int itemId,
int oncePerXInNormal,
int oncePerXInExpert)
{
return (IItemDropRule) new DropBasedOnExpertMode(ItemDropRule.NotScalingWithLuck(itemId, oncePerXInNormal), ItemDropRule.NotScalingWithLuck(itemId, oncePerXInExpert));
}
public static IItemDropRule NormalvsExpertOneFromOptionsNotScalingWithLuck(
int dropsOutOfXNormalMode,
int dropsOutOfXExpertMode,
params int[] options)
{
return (IItemDropRule) new DropBasedOnExpertMode(ItemDropRule.OneFromOptionsNotScalingWithLuck(dropsOutOfXNormalMode, options), ItemDropRule.OneFromOptionsNotScalingWithLuck(dropsOutOfXExpertMode, options));
}
public static IItemDropRule NormalvsExpertOneFromOptions(
int dropsOutOfXNormalMode,
int dropsOutOfXExpertMode,
params int[] options)
{
return (IItemDropRule) new DropBasedOnExpertMode(ItemDropRule.OneFromOptions(dropsOutOfXNormalMode, options), ItemDropRule.OneFromOptions(dropsOutOfXExpertMode, options));
}
public static IItemDropRule Food(
int itemId,
int dropsOutOfX,
int minimumDropped = 1,
int maximumDropped = 1)
{
return (IItemDropRule) new ItemDropWithConditionRule(itemId, dropsOutOfX, minimumDropped, maximumDropped, (IItemDropRuleCondition) new Conditions.NotFromStatue());
}
public static IItemDropRule StatusImmunityItem(int itemId, int dropsOutOfX) => ItemDropRule.ExpertGetsRerolls(itemId, dropsOutOfX, 1);
}
}

View file

@ -0,0 +1,12 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.ItemDropRuleResolveAction
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.ItemDropRules
{
public delegate ItemDropAttemptResult ItemDropRuleResolveAction(
IItemDropRule rule,
DropAttemptInfo info);
}

View file

@ -0,0 +1,39 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.ItemDropWithConditionRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class ItemDropWithConditionRule : CommonDrop
{
private IItemDropRuleCondition _condition;
public ItemDropWithConditionRule(
int itemId,
int dropsOutOfY,
int amountDroppedMinimum,
int amountDroppedMaximum,
IItemDropRuleCondition condition,
int dropsXOutOfY = 1)
: base(itemId, dropsOutOfY, amountDroppedMinimum, amountDroppedMaximum, dropsXOutOfY)
{
this._condition = condition;
}
public override bool CanDrop(DropAttemptInfo info) => this._condition.CanDrop(info);
public override void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
DropRateInfoChainFeed ratesInfo1 = ratesInfo.With(1f);
ratesInfo1.AddCondition(this._condition);
float personalDropRate = (float) this._dropsXoutOfY / (float) this._dropsOutOfY;
float dropRate = personalDropRate * ratesInfo1.parentDroprateChance;
drops.Add(new DropRateInfo(this._itemId, this._amtDroppedMinimum, this._amtDroppedMaximum, dropRate, ratesInfo1.conditions));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo1);
}
}
}

View file

@ -0,0 +1,36 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.LeadingConditionRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class LeadingConditionRule : IItemDropRule
{
private IItemDropRuleCondition _condition;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public LeadingConditionRule(IItemDropRuleCondition condition)
{
this._condition = condition;
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
}
public bool CanDrop(DropAttemptInfo info) => this._condition.CanDrop(info);
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
ratesInfo.AddCondition(this._condition);
Chains.ReportDroprates(this.ChainedRules, 1f, drops, ratesInfo);
}
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info) => new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
}

View file

@ -0,0 +1,64 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.MechBossSpawnersDropRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class MechBossSpawnersDropRule : IItemDropRule
{
private Conditions.MechanicalBossesDummyCondition _dummyCondition = new Conditions.MechanicalBossesDummyCondition();
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public MechBossSpawnersDropRule() => this.ChainedRules = new List<IItemDropRuleChainAttempt>();
public bool CanDrop(DropAttemptInfo info) => (double) info.npc.value > 0.0 && Main.hardMode && (!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && !info.IsInSimulation;
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
if (!NPC.downedMechBoss1 && info.player.RollLuck(2500) == 0)
{
CommonCode.DropItemFromNPC(info.npc, 556, 1);
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
if (!NPC.downedMechBoss2 && info.player.RollLuck(2500) == 0)
{
CommonCode.DropItemFromNPC(info.npc, 544, 1);
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
if (!NPC.downedMechBoss3 && info.player.RollLuck(2500) == 0)
{
CommonCode.DropItemFromNPC(info.npc, 557, 1);
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
ratesInfo.AddCondition((IItemDropRuleCondition) this._dummyCondition);
float personalDropRate = 0.0004f;
float dropRate = personalDropRate * ratesInfo.parentDroprateChance;
drops.Add(new DropRateInfo(556, 1, 1, dropRate, ratesInfo.conditions));
drops.Add(new DropRateInfo(544, 1, 1, dropRate, ratesInfo.conditions));
drops.Add(new DropRateInfo(557, 1, 1, dropRate, ratesInfo.conditions));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,54 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.OneFromOptionsDropRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class OneFromOptionsDropRule : IItemDropRule
{
private int[] _dropIds;
private int _outOfY;
private int _xoutOfY;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public OneFromOptionsDropRule(int outOfY, int xoutOfY, params int[] options)
{
this._outOfY = outOfY;
this._xoutOfY = xoutOfY;
this._dropIds = options;
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
}
public bool CanDrop(DropAttemptInfo info) => true;
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
if (info.player.RollLuck(this._outOfY) < this._xoutOfY)
{
CommonCode.DropItemFromNPC(info.npc, this._dropIds[info.rng.Next(this._dropIds.Length)], 1);
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
float personalDropRate = (float) this._xoutOfY / (float) this._outOfY;
float dropRate = 1f / (float) this._dropIds.Length * (personalDropRate * ratesInfo.parentDroprateChance);
for (int index = 0; index < this._dropIds.Length; ++index)
drops.Add(new DropRateInfo(this._dropIds[index], 1, 1, dropRate, ratesInfo.conditions));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,54 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.OneFromOptionsNotScaledWithLuckDropRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class OneFromOptionsNotScaledWithLuckDropRule : IItemDropRule
{
private int[] _dropIds;
private int _outOfY;
private int _xoutOfY;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public OneFromOptionsNotScaledWithLuckDropRule(int outOfY, int xoutOfY, params int[] options)
{
this._outOfY = outOfY;
this._dropIds = options;
this._xoutOfY = xoutOfY;
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
}
public bool CanDrop(DropAttemptInfo info) => true;
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
if (info.rng.Next(this._outOfY) < this._xoutOfY)
{
CommonCode.DropItemFromNPC(info.npc, this._dropIds[info.rng.Next(this._dropIds.Length)], 1);
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
float personalDropRate = (float) this._xoutOfY / (float) this._outOfY;
float dropRate = 1f / (float) this._dropIds.Length * (personalDropRate * ratesInfo.parentDroprateChance);
for (int index = 0; index < this._dropIds.Length; ++index)
drops.Add(new DropRateInfo(this._dropIds[index], 1, 1, dropRate, ratesInfo.conditions));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,60 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.OneFromRulesRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class OneFromRulesRule : IItemDropRule, INestedItemDropRule
{
private IItemDropRule[] _options;
private int _outOfY;
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public OneFromRulesRule(int outOfY, params IItemDropRule[] options)
{
this._outOfY = outOfY;
this._options = options;
this.ChainedRules = new List<IItemDropRuleChainAttempt>();
}
public bool CanDrop(DropAttemptInfo info) => true;
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info) => new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.DidNotRunCode
};
public ItemDropAttemptResult TryDroppingItem(
DropAttemptInfo info,
ItemDropRuleResolveAction resolveAction)
{
if (info.rng.Next(this._outOfY) == 0)
{
int index = info.rng.Next(this._options.Length);
ItemDropAttemptResult dropAttemptResult = resolveAction(this._options[index], info);
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.FailedRandomRoll
};
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
{
float personalDropRate = 1f / (float) this._outOfY;
float multiplier = 1f / (float) this._options.Length * (personalDropRate * ratesInfo.parentDroprateChance);
for (int index = 0; index < this._options.Length; ++index)
this._options[index].ReportDroprates(drops, ratesInfo.With(multiplier));
Chains.ReportDroprates(this.ChainedRules, personalDropRate, drops, ratesInfo);
}
}
}

View file

@ -0,0 +1,81 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.ItemDropRules.SlimeBodyItemDropRule
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
namespace Terraria.GameContent.ItemDropRules
{
public class SlimeBodyItemDropRule : IItemDropRule
{
public List<IItemDropRuleChainAttempt> ChainedRules { get; private set; }
public SlimeBodyItemDropRule() => this.ChainedRules = new List<IItemDropRuleChainAttempt>();
public bool CanDrop(DropAttemptInfo info) => info.npc.type == 1 && (double) info.npc.ai[1] > 0.0 && (double) info.npc.ai[1] < 5045.0;
public ItemDropAttemptResult TryDroppingItem(DropAttemptInfo info)
{
int itemId = (int) info.npc.ai[1];
int amountDroppedMinimum;
int amountDroppedMaximum;
this.GetDropInfo(itemId, out amountDroppedMinimum, out amountDroppedMaximum);
CommonCode.DropItemFromNPC(info.npc, itemId, info.rng.Next(amountDroppedMinimum, amountDroppedMaximum + 1));
return new ItemDropAttemptResult()
{
State = ItemDropAttemptResultState.Success
};
}
private void GetDropInfo(
int itemId,
out int amountDroppedMinimum,
out int amountDroppedMaximum)
{
amountDroppedMinimum = 1;
amountDroppedMaximum = 1;
switch (itemId)
{
case 8:
amountDroppedMinimum = 5;
amountDroppedMaximum = 10;
break;
case 11:
case 12:
case 13:
case 14:
case 699:
case 700:
case 701:
case 702:
amountDroppedMinimum = 3;
amountDroppedMaximum = 13;
break;
case 71:
amountDroppedMinimum = 50;
amountDroppedMaximum = 99;
break;
case 72:
amountDroppedMinimum = 20;
amountDroppedMaximum = 99;
break;
case 73:
amountDroppedMinimum = 1;
amountDroppedMaximum = 2;
break;
case 166:
amountDroppedMinimum = 2;
amountDroppedMaximum = 6;
break;
case 965:
amountDroppedMinimum = 20;
amountDroppedMaximum = 45;
break;
}
}
public void ReportDroprates(List<DropRateInfo> drops, DropRateInfoChainFeed ratesInfo) => Chains.ReportDroprates(this.ChainedRules, 1f, drops, ratesInfo);
}
}