This commit is contained in:
Andrew Marheine committed 2022-01-03 03:58:13 -06:00
commit e6dd172832
63 files changed
+875 -215

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Buffs
{
public class RancorBurn : ModBuff
{
public override void SetDefaults()
{
DisplayName.SetDefault("Rancor Burn");
Description.SetDefault("Burning");
Main.debuff[Type] = true;
Main.buffNoSave[Type] = true;
Main.buffNoTimeDisplay[Type] = true;
canBeCleared = false;
}
public override void Update(NPC npc, ref int buffIndex)
{
if (npc.Calamity().RancorBurnTime < npc.buffTime[buffIndex])
npc.Calamity().RancorBurnTime = npc.buffTime[buffIndex];
npc.DelBuff(buffIndex);
buffIndex--;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

+53 -5
View File
@@ -1153,6 +1153,31 @@ namespace CalamityMod.CalPlayer
public bool AbleToSelectExoMech = false;
#endregion Draedon Summoning
#region Mouse Controls Syncing
public bool mouseRight = false;
private bool oldMouseRight = false;
public Vector2 mouseWorld;
private Vector2 oldMouseWorld;
/// <summary>
/// Set this to true if you need to recieve updates on right clicks from players and sync them in mp.
/// Automatically resets itself after sending an update
/// <\summary>
public bool rightClickListener = false;
/// <summary>
/// Set this to true if you need to recieve updates on the position of the player's mouse and sync them in mp.
/// Automatically resets itself after sending an update
/// <\summary>
public bool mouseWorldListener = false;
/// <summary>
/// Set this to true if you need to recieve updates on the rotation of the mouse to the player. This sends updates less frequently than the more tight tolerance mouseWorldListener
/// Automatically resets itself after sending an update
/// <\summary>
public bool mouseRotationListener = false;
public bool syncMouseControls = false;
#endregion
#endregion
#region Saving And Loading
@@ -3887,10 +3912,10 @@ namespace CalamityMod.CalPlayer
player.AddBuff(ModContent.BuffType<ProfanedCrystalBuff>(), 60, true);
}
}
#endregion
#endregion
#region PreUpdate
public override void PreUpdate()
#region PreUpdate
public override void PreUpdate()
{
tailFrameUp++;
if (tailFrameUp == 8)
@@ -3926,7 +3951,30 @@ namespace CalamityMod.CalPlayer
GameShaders.Armor.GetSecondaryShader(player.dye[i].dye, player)?.UseColor(CalamityPlayerDrawEffects.GetCurrentMoonlightDyeColor());
}
}
}
//Syncing mouse controls
if (Main.myPlayer == player.whoAmI)
{
mouseRight = PlayerInput.Triggers.Current.MouseRight;
if (rightClickListener && mouseRight != oldMouseRight)
{
oldMouseRight = mouseRight;
syncMouseControls = true;
rightClickListener = false;
}
if (mouseWorldListener && Vector2.Distance(mouseWorld, oldMouseWorld) > 10f)
{
oldMouseWorld = mouseWorld;
syncMouseControls = true;
mouseWorldListener = false;
}
if (mouseRotationListener && Math.Abs((mouseWorld - player.MountedCenter).ToRotation() - (oldMouseWorld - player.MountedCenter).ToRotation()) > 0.15f)
{
oldMouseWorld = mouseWorld;
syncMouseControls = true;
mouseRotationListener = false;
}
}
}
#endregion
#region PreUpdateBuffs
@@ -4422,7 +4470,7 @@ namespace CalamityMod.CalPlayer
if (silvaSet && silvaCountdown > 0)
{
if (player.FindBuffIndex(ModContent.BuffType<SilvaRevival>()) == -1)
if (silvaCountdown == 480 && !hasSilvaEffect)
{
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaActivation"), (int)player.position.X, (int)player.position.Y);
+8 -1
View File
@@ -165,7 +165,7 @@ namespace CalamityMod.CalPlayer
// Update the gem tech armor set.
modPlayer.GemTechState.Update();
// Regularly sync player stats during multiplayer
// Regularly sync player stats & mouse control info during multiplayer
if (player.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient)
{
modPlayer.packetTimer++;
@@ -174,8 +174,15 @@ namespace CalamityMod.CalPlayer
modPlayer.packetTimer = 0;
modPlayer.StandardSync();
}
if (modPlayer.syncMouseControls)
{
modPlayer.syncMouseControls = false;
modPlayer.MouseControlsSync();
}
}
// After everything else, if Daawnlight Spirit Origin is equipped, set ranged crit to the base 4%.
// Store all the crit so it can be used in damage calculations.
if (modPlayer.spiritOrigin)
+37
View File
@@ -35,6 +35,12 @@ namespace CalamityMod.CalPlayer
SyncLevel(false, 3);
SyncLevel(false, 4);
}
internal void MouseControlsSync()
{
SyncRightClick(false);
SyncMousePosition(false);
}
#endregion
#region Creating and Sending Packets
@@ -198,6 +204,24 @@ namespace CalamityMod.CalPlayer
packet.Write(reforgeTierSafety);
player.SendPacket(packet, server);
}
public void SyncRightClick(bool server)
{
ModPacket packet = mod.GetPacket(256);
packet.Write((byte)CalamityModMessageType.RightClickSync);
packet.Write(player.whoAmI);
packet.Write(mouseRight);
player.SendPacket(packet, server);
}
public void SyncMousePosition(bool server)
{
ModPacket packet = mod.GetPacket(256);
packet.Write((byte)CalamityModMessageType.MousePositionSync);
packet.Write(player.whoAmI);
packet.WriteVector2(mouseWorld);
player.SendPacket(packet, server);
}
#endregion
#region Reading and Handling Packets
@@ -323,6 +347,19 @@ namespace CalamityMod.CalPlayer
if (Main.netMode == NetmodeID.Server)
SyncDodgeCooldown(true);
}
internal void HandleRightClick(BinaryReader reader)
{
mouseRight = reader.ReadBoolean();
if (Main.netMode == NetmodeID.Server)
SyncRightClick(true);
}
internal void HandleMousePosition(BinaryReader reader)
{
mouseWorld = reader.ReadVector2();
if (Main.netMode == NetmodeID.Server)
SyncMousePosition(true);
}
#endregion
}
}
+14 -2
View File
@@ -299,7 +299,7 @@ namespace CalamityMod
CalamityShaders.LoadShaders();
FusableParticleManager.LoadParticleRenderSets();
Main.OnPreDraw += _ => FusableParticleManager.PrepareFusableParticleTargets();
Main.OnPreDraw += PrepareRenderTargets;
RipperUI.Load();
AstralArcanumUI.Load(this);
@@ -384,7 +384,7 @@ namespace CalamityMod
TileFraming.Unload();
FusableParticleManager.UnloadParticleRenderSets();
Main.OnPreDraw -= _ => FusableParticleManager.PrepareFusableParticleTargets();
Main.OnPreDraw -= PrepareRenderTargets;
RipperUI.Unload();
AstralArcanumUI.Unload();
@@ -422,6 +422,14 @@ namespace CalamityMod
}
#endregion
#region Render Target Management
public static void PrepareRenderTargets(GameTime gameTime)
{
FusableParticleManager.PrepareFusableParticleTargets();
DeathAshParticle.PrepareRenderTargets();
}
#endregion Render Target Management
#region ConfigCrap
internal static void SaveConfig(CalamityConfig cfg)
{
@@ -1578,6 +1586,10 @@ namespace CalamityMod
public override void MidUpdateTimeWorld() => TileEntityTimeHandler.Update();
#endregion
#region Ash Drawing
public override void MidUpdateItemDust() => DeathAshParticle.UpdateAll();
#endregion Ash Drawing
#region Post NPC Updating
// TODO - Apply caching to this process. For now most of the looping issues should be eradicated but it can be reduced further.
public override void MidUpdateNPCGore() => CalamityGlobalTownNPC.ResetTownNPCNameBools();
+23 -6
View File
@@ -280,11 +280,24 @@ namespace CalamityMod
Main.player[reader.ReadInt32()].Calamity().HandleReforgeTierSafety(reader);
break;
//
// Default case: with no idea how long the packet is, we can't safely read data.
// Throw an exception now instead of allowing the network stream to corrupt.
//
default:
//
// Mouse control syncs
//
case CalamityModMessageType.RightClickSync:
Main.player[reader.ReadInt32()].Calamity().HandleRightClick(reader);
break;
case CalamityModMessageType.MousePositionSync:
Main.player[reader.ReadInt32()].Calamity().HandleMousePosition(reader);
break;
//
// Default case: with no idea how long the packet is, we can't safely read data.
// Throw an exception now instead of allowing the network stream to corrupt.
//
default:
CalamityMod.Instance.Logger.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}.");
throw new Exception("Failed to parse Calamity packet: Invalid Calamity packet ID.");
}
@@ -399,6 +412,10 @@ namespace CalamityMod
// Reforge syncs
ItemTypeLastReforgedSync, // TODO -- there has to be a better way to do this, but I don't know what it is
ReforgeTierSafetySync
ReforgeTierSafetySync,
// Mouse Controls syncs
RightClickSync,
MousePositionSync
}
}
+3
View File
@@ -45,12 +45,14 @@ namespace CalamityMod.ILEditing
IL.Terraria.Player.ItemCheck += ApplyManaBurnIfNeeded;
IL.Terraria.Player.AddBuff += AllowBuffTimeStackingForManaBurn;
IL.Terraria.Main.DoDraw += DrawFusableParticles;
IL.Terraria.Main.DoDraw += DrawAshParticles;
On.Terraria.Main.SetDisplayMode += ResetRenderTargetSizes;
IL.Terraria.Main.DrawTiles += DrawCustomLava;
IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw += DrawCustomLava2;
IL.Terraria.Main.oldDrawWater += DrawCustomLava3;
IL.Terraria.WaterfallManager.DrawWaterfall += DrawCustomLavafalls;
On.Terraria.NPC.Collision_DecideFallThroughPlatforms += EnableCalamityBossPlatformCollision;
IL.Terraria.Wiring.HitWireSingle += AddTwinklersToStatue;
// Damage and health balance
IL.Terraria.Main.DamageVar += AdjustDamageVariance;
@@ -117,6 +119,7 @@ namespace CalamityMod.ILEditing
IL.Terraria.Player.ItemCheck -= ApplyManaBurnIfNeeded;
IL.Terraria.Player.AddBuff -= AllowBuffTimeStackingForManaBurn;
IL.Terraria.Main.DoDraw -= DrawFusableParticles;
IL.Terraria.Main.DoDraw -= DrawAshParticles;
On.Terraria.Main.SetDisplayMode -= ResetRenderTargetSizes;
IL.Terraria.Main.DrawTiles -= DrawCustomLava;
IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw -= DrawCustomLava2;
+102
View File
@@ -1,5 +1,6 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.CalPlayer;
using CalamityMod.NPCs.Astral;
using CalamityMod.NPCs.AstrumAureus;
using CalamityMod.NPCs.Crabulon;
using CalamityMod.NPCs.Ravager;
@@ -522,6 +523,21 @@ namespace CalamityMod.ILEditing
}
#endregion Fusable Particle Rendering
#region Ash Particle Rendering
private static void DrawAshParticles(ILContext il)
{
ILCursor cursor = new ILCursor(il);
// Over NPCs but before Projectiles.
if (!cursor.TryGotoNext(c => c.MatchCallOrCallvirt<Main>("DrawDust")))
{
LogFailure("Ash Particle Rendering", "Could not locate the DrawDust reference method to attach to.");
return;
}
cursor.EmitDelegate<Action>(DeathAshParticle.DrawAll);
}
#endregion Ash Particle Rendering
#region Custom Lava Visuals
private static void ResetRenderTargetSizes(On.Terraria.Main.orig_SetDisplayMode orig, int width, int height, bool fullscreen)
{
@@ -647,5 +663,91 @@ namespace CalamityMod.ILEditing
cursor.Emit(OpCodes.Stloc, 51);
}
#endregion Custom Lava Visuals
#region Statue Additions
/// <summary>
/// Change the following code sequence in Wiring.HitWireSingle
/// num8 = (int) Utils.SelectRandom<short>(Main.rand, new short[2]
/// {
/// 355,
/// 358
/// });
///
/// to
///
/// var arr = new short[2]
/// {
/// 355,
/// 358
/// });
/// arr = arr.ToList().Add(id).ToArray();
/// num8 = Utils.SelectRandom(Main.rand, arr);
///
/// </summary>
/// <param name="il"></param>
private static void AddTwinklersToStatue(ILContext il)
{
// obtain a cursor positioned before the first instruction of the method
// the cursor is used for navigating and modifying the il
var c = new ILCursor(il);
// the exact location for this hook is very complex to search for due to the hook instructions not being unique, and buried deep in control flow
// switch statements are sometimes compiled to if-else chains, and debug builds litter the code with no-ops and redundant locals
// in general you want to search using structure and function rather than numerical constants which may change across different versions or compile settings
// using local variable indices is almost always a bad idea
// we can search for
// switch (*)
// case 54:
// Utils.SelectRandom *
// in general you'd want to look for a specific switch variable, or perhaps the containing switch (type) { case 105:
// but the generated IL is really variable and hard to match in this case
// we'll just use the fact that there are no other switch statements with case 54, followed by a SelectRandom
ILLabel[] targets = null;
while (c.TryGotoNext(i => i.MatchSwitch(out targets)))
{
// some optimising compilers generate a sub so that all the switch cases start at 0
// ldc.i4.s 51
// sub
// switch
int offset = 0;
if (c.Prev.MatchSub() && c.Prev.Previous.MatchLdcI4(out offset))
{
;
}
// get the label for case 54: if it exists
int case54Index = 54 - offset;
if (case54Index < 0 || case54Index >= targets.Length || !(targets[case54Index] is ILLabel target))
{
continue;
}
// move the cursor to case 54:
c.GotoLabel(target);
// there's lots of extra checks we could add here to make sure we're at the right spot, such as not encountering any branching instructions
c.GotoNext(i => i.MatchCall(typeof(Utils), nameof(Utils.SelectRandom)));
// goto next positions us before the instruction we searched for, so we can insert our array modifying code right here
c.EmitDelegate<Func<short[], short[]>>(arr =>
{
// resize the array and add our custom firefly
Array.Resize(ref arr, arr.Length+1);
arr[arr.Length-1] = (short)ModContent.NPCType<Twinkler>();
return arr;
});
// hook applied successfully
return;
}
// couldn't find the right place to insert
throw new Exception("Hook location not found, switch(*) { case 54: ...");
}
#endregion Statue Additions
}
}
+3 -1
View File
@@ -768,6 +768,7 @@ namespace CalamityMod.Items
// This function is shorthand for appending a stat sheet to a pair of wings.
void AddWingStats(float h, float a, int v, int f, string s = null) => EditTooltipByNum(0, (line) => line.text += WingStatsTooltip(h, a, v, f, s));
void AddWingStats2(float h, float a, int v, int f, string s = null, string lineName = null) => EditTooltipByName(lineName, (line) => line.text += WingStatsTooltip(h, a, v, f, s));
if (item.type == ItemID.AngelWings)
AddWingStats(6.25f, 1f, 0, 100, "+20 max life, +10 defense and +2 life regen");
@@ -872,8 +873,9 @@ namespace CalamityMod.Items
AddWingStats(6.5f, 1.5f, 1, 160, "+20 max mana, 5% increased magic damage and critical strike chance,\n" +
"and 5% decreased mana usage while wearing the Nebula Armor");
// Betsy's Wings (and dev wings) are the only wings without "Allows flight and free fall"
if (item.type == ItemID.BetsyWings)
AddWingStats(6f, 2.5f, 1, 150);
AddWingStats2(6f, 2.5f, 1, 150, null, "Equipable");
#endregion
// Provide the full stats of every vanilla grappling hook
-1
View File
@@ -19,7 +19,6 @@ namespace CalamityMod.Items.Mounts
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = ItemUseStyleID.SwingThrow;
item.expert = true;
item.UseSound = SoundID.Item3;
item.noMelee = true;
item.mountType = ModContent.MountType<PhuppersChair>();
-1
View File
@@ -20,7 +20,6 @@ namespace CalamityMod.Items.Mounts
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = ItemUseStyleID.SwingThrow;
item.expert = true;
item.UseSound = SoundID.Item3;
item.noMelee = true;
item.mountType = ModContent.MountType<AlicornMount>();
-1
View File
@@ -19,7 +19,6 @@ namespace CalamityMod.Items.Mounts
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = ItemUseStyleID.SwingThrow;
item.expert = true;
item.UseSound = SoundID.Item3;
item.noMelee = true;
item.mountType = ModContent.MountType<SquishyBean>();
@@ -1,10 +1,10 @@
using CalamityMod.Items.Materials;
using CalamityMod.Tiles;
using CalamityMod.Tiles.Furniture;
using CalamityMod.Tiles.Furniture.CraftingStations;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables
namespace CalamityMod.Items.Placeables.Furniture
{
public class SCalAltarItem : ModItem
{
File renamed without changes.

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 397 B

@@ -1,6 +1,7 @@
using CalamityMod.Items.Materials;
using CalamityMod.Tiles.Furniture.CraftingStations;
using CalamityMod.Tiles.FurnitureExo;
using CalamityMod.Items.Placeables.Walls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
@@ -45,6 +46,11 @@ namespace CalamityMod.Items.Placeables.FurnitureExo
recipe.AddIngredient(ModContent.ItemType<ExoPlatform>(), 2);
recipe.SetResult(this);
recipe.AddRecipe();
recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<ExoPlatingWallItem>(), 4);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
@@ -1,6 +1,7 @@
using CalamityMod.Items.Materials;
using CalamityMod.Tiles.Furniture.CraftingStations;
using CalamityMod.Tiles.FurnitureExo;
using CalamityMod.Items.Placeables.Walls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
@@ -45,6 +46,11 @@ namespace CalamityMod.Items.Placeables.FurnitureExo
recipe.AddIngredient(ModContent.ItemType<ExoPrismPlatform>(), 2);
recipe.SetResult(this);
recipe.AddRecipe();
recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<ExoPrismPanelWallItem>(), 4);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
@@ -0,0 +1,38 @@
using CalamityMod.Items.Placeables.FurnitureExo;
using CalamityMod.Walls;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.Walls
{
public class ExoPlatingWallItem : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exo Plating Wall");
}
public override void SetDefaults()
{
item.width = 12;
item.height = 12;
item.maxStack = 999;
item.useTurn = true;
item.autoReuse = true;
item.useAnimation = 15;
item.useTime = 7;
item.useStyle = ItemUseStyleID.SwingThrow;
item.consumable = true;
item.createWall = ModContent.WallType<ExoPlatingWall>();
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<ExoPlating>());
recipe.SetResult(this, 4);
recipe.AddTile(TileID.WorkBenches);
recipe.AddRecipe();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

@@ -0,0 +1,38 @@
using CalamityMod.Items.Placeables.FurnitureExo;
using CalamityMod.Walls;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables.Walls
{
public class ExoPrismPanelWallItem : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Exo Prism Panel Wall");
}
public override void SetDefaults()
{
item.width = 12;
item.height = 12;
item.maxStack = 999;
item.useTurn = true;
item.autoReuse = true;
item.useAnimation = 15;
item.useTime = 7;
item.useStyle = ItemUseStyleID.SwingThrow;
item.consumable = true;
item.createWall = ModContent.WallType<ExoPrismPanelWall>();
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<ExoPrismPanel>());
recipe.SetResult(this, 4);
recipe.AddTile(TileID.WorkBenches);
recipe.AddRecipe();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

+18
View File
@@ -1,5 +1,7 @@
using CalamityMod.Buffs.Potions;
using CalamityMod.Items.Materials;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,6 +10,8 @@ namespace CalamityMod.Items.Potions
{
public class DraconicElixir : ModItem
{
public int frameCounter = 0;
public int frame = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Draconic Elixir");
@@ -35,6 +39,20 @@ namespace CalamityMod.Items.Potions
public override bool CanUseItem(Player player) => !player.Calamity().draconicSurgeCooldown;
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Potions/DraconicElixir_Animated");
spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 10), Color.White, 0f, origin, scale, SpriteEffects.None, 0);
return false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Potions/DraconicElixir_Animated");
spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 10), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
return false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 893 B

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

+8 -8
View File
@@ -58,9 +58,12 @@ namespace CalamityMod.Items.Tools
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
public override void HoldItem(Player player)
{
if (Main.myPlayer == player.whoAmI)
player.Calamity().rightClickListener = true;
if (player.Calamity().mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType<CrystylCrusherRay>()] <= 0)
{
item.shoot = ProjectileID.None;
item.shootSpeed = 0f;
@@ -70,22 +73,19 @@ namespace CalamityMod.Items.Tools
item.useTurn = true;
item.autoReuse = true;
item.noMelee = false;
item.channel = false;
}
else
{
item.shoot = ModContent.ProjectileType<CrystylCrusherRay>();
item.shootSpeed = LaserSpeed;
item.tileBoost = -6;
item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge");
item.UseSound = null;
item.useStyle = ItemUseStyleID.HoldingOut;
item.useTurn = false;
item.autoReuse = false;
item.noMelee = true;
item.channel = true;
}
return base.CanUseItem(player);
}
}
public override void ModifyTooltips(List<TooltipLine> list)
{
+3 -3
View File
@@ -17,10 +17,10 @@ namespace CalamityMod.Items.Weapons.Melee
public override void SetDefaults()
{
item.width = 40;
item.height = 42;
item.width = 56;
item.height = 60;
item.damage = 30;
item.scale = 1.5f;
item.scale = 1.05f;
item.melee = true;
item.useAnimation = item.useTime = 26;
item.useStyle = ItemUseStyleID.SwingThrow;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 734 B

+1 -1
View File
@@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Melee
item.width = 92;
item.height = 92;
item.value = Item.buyPrice(5, 0, 0, 0);
item.rare = ItemRarityID.Red;
item.rare = ItemRarityID.Purple;
item.shoot = ModContent.ProjectileType<ElementalExcaliburBeam>();
item.shootSpeed = 6f;
item.Calamity().customRarity = CalamityRarity.Rainbow;
-1
View File
@@ -34,7 +34,6 @@ namespace CalamityMod.Items.Weapons.Melee
item.autoReuse = true;
item.value = Item.buyPrice(1, 80, 0, 0);
item.rare = ItemRarityID.Red;
item.shootSpeed = 24f;
item.Calamity().customRarity = CalamityRarity.DarkBlue;
}
+1 -1
View File
@@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged
{
item.damage = 165;
item.ranged = true;
item.width = 60;
item.width = 62;
item.height = 90;
item.useTime = 15;
item.useAnimation = 30;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

+5 -8
View File
@@ -31,10 +31,12 @@ namespace CalamityMod.Items.Weapons.Ranged
item.useAnimation = 30;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.channel = true;
item.knockBack = 4.25f;
item.value = CalamityGlobalItem.Rarity10BuyPrice;
item.rare = ItemRarityID.Red;
item.UseSound = SoundID.Item5;
item.noUseGraphic = true;
item.UseSound = SoundID.Item20;
item.autoReuse = true;
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 15f;
@@ -50,13 +52,8 @@ namespace CalamityMod.Items.Weapons.Ranged
recipe.SetResult(this);
recipe.AddRecipe();
}
public override bool CanUseItem(Player player)
{
item.noUseGraphic = true;
item.UseSound = SoundID.Item20;
item.channel = true;
return player.ownedProjectileCounts[ModContent.ProjectileType<ClockworkBowHoldout>()] <= 0;
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType<ClockworkBowHoldout>()] <= 0;
public override float UseTimeMultiplier(Player player)
{
return 1f;
+11 -9
View File
@@ -26,6 +26,7 @@ namespace CalamityMod.Items.Weapons.Ranged
item.height = 42;
item.useTime = item.useAnimation = 23;
item.useStyle = ItemUseStyleID.HoldingOut;
item.channel = true;
item.noMelee = true;
item.knockBack = 5f;
item.value = CalamityGlobalItem.RarityVioletBuyPrice;
@@ -42,31 +43,32 @@ namespace CalamityMod.Items.Weapons.Ranged
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player)
public override void HoldItem(Player player)
{
if (player.altFunctionUse == 2)
if (Main.myPlayer == player.whoAmI)
player.Calamity().rightClickListener = true;
if (player.Calamity().mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType<CondemnationHoldout>()] <= 0)
{
item.noUseGraphic = false;
item.UseSound = SoundID.DD2_BallistaTowerShot;
item.channel = false;
}
else
{
item.noUseGraphic = true;
item.UseSound = SoundID.Item20;
item.channel = true;
return player.ownedProjectileCounts[ModContent.ProjectileType<CondemnationHoldout>()] <= 0;
}
return base.CanUseItem(player);
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType<CondemnationHoldout>()] <= 0;
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2 shootVelocity = new Vector2(speedX, speedY);
Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction);
// Single arrow firing.
if (player.altFunctionUse == 2)
if (player.Calamity().mouseRight)
{
Vector2 tipPosition = position + shootDirection * 110f;
Projectile.NewProjectile(tipPosition, shootVelocity, item.shoot, damage, knockBack, player.whoAmI);
+4 -8
View File
@@ -29,8 +29,10 @@ namespace CalamityMod.Items.Weapons.Ranged
item.knockBack = 1.25f;
item.value = Item.buyPrice(0, 2, 0, 0);
item.rare = ItemRarityID.Green;
item.UseSound = SoundID.Item11;
item.noUseGraphic = true;
item.UseSound = SoundID.Item20;
item.autoReuse = true;
item.channel = true;
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 11f;
item.Calamity().canFirePointBlankShots = true;
@@ -38,13 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged
public override Vector2? HoldoutOffset() => new Vector2(-30f, 0f);
public override bool CanUseItem(Player player)
{
item.noUseGraphic = true;
item.UseSound = SoundID.Item20;
item.channel = true;
return player.ownedProjectileCounts[ModContent.ProjectileType<PumplerHoldout>()] <= 0;
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType<PumplerHoldout>()] <= 0;
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
+11 -10
View File
@@ -24,6 +24,7 @@ namespace CalamityMod.Items.Weapons.Ranged
item.useTime = item.useAnimation = 56;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.channel = true;
item.knockBack = 8f;
item.value = CalamityGlobalItem.RarityVioletBuyPrice;
item.rare = ItemRarityID.Purple;
@@ -38,27 +39,27 @@ namespace CalamityMod.Items.Weapons.Ranged
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player)
public override void HoldItem(Player player)
{
if (player.altFunctionUse == 2)
if (Main.myPlayer == player.whoAmI)
player.Calamity().rightClickListener = true;
if (player.Calamity().mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType<SurgeDriverHoldout>()] <= 0)
{
item.noUseGraphic = false;
item.reuseDelay = 0;
item.UseSound = SoundID.Item14;
item.channel = false;
}
else
{
item.noUseGraphic = true;
item.reuseDelay = 28;
item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon");
item.channel = true;
return player.ownedProjectileCounts[ModContent.ProjectileType<SurgeDriverHoldout>()] <= 0;
}
return base.CanUseItem(player);
}
public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 5f : 1f;
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType<SurgeDriverHoldout>()] <= 0;
public override float UseTimeMultiplier(Player player) => player.Calamity().mouseRight ? 5f : 1f;
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
@@ -68,7 +69,7 @@ namespace CalamityMod.Items.Weapons.Ranged
gunTip.Y -= 6f;
// Large bullet/rocket releasing.
if (player.altFunctionUse == 2)
if (player.Calamity().mouseRight)
{
for (int i = 0; i < 2; i++)
{
+2 -2
View File
@@ -19,8 +19,8 @@ namespace CalamityMod.Items.Weapons.Rogue
"Fires a frying pan at high velocity\n" +
"Enemy hits summon fireballs that linger around the target\n" +
"Landing three consecutive hits grants full stealth\n" +
"Stealth strikes explode into golden sparks and after hitting an enemy,\n" +
"cause all fireballs to aggressively home in on their target");
"Stealth strikes explode into golden sparks, and after hitting an enemy,\n" +
"they cause all fireballs to aggressively home in on their target");
}
public override void SafeSetDefaults()
+1 -1
View File
@@ -30,7 +30,7 @@ Fire rate and range increase the longer it targets an enemy");
item.knockBack = 4f;
item.value = CalamityGlobalItem.Rarity6BuyPrice;
item.rare = ItemRarityID.Purple;
item.rare = ItemRarityID.LightPurple;
item.Calamity().devItem = true;
item.UseSound = SoundID.Item78;
+6 -3
View File
@@ -596,12 +596,15 @@ namespace CalamityMod
{
BossDifficulty.TryGetValue("SupremeCalamitas", out float order);
int type = NPCType<SupremeCalamitas>();
int summon = ItemType<EyeofExtinction>();
int summon1 = ItemType<CalamityDust>();
int summon2 = ItemType<EyeofExtinction>();
int altar = ItemType<SCalAltarItem>();
List<int> summons = new List<int>() { summon1, summon2 };
List<int> loot = new List<int>() { ItemType<SCalBag>(), ItemType<CalamitousEssence>(), ItemType<Vehemenc>(), ItemType<Heresy>(), ItemType<Perdition>(), ItemType<Vigilance>(), ItemType<Sacrifice>(), ItemType<Violence>(), ItemType<GaelsGreatsword>(), ItemType<OmegaHealingPotion>() };
List<int> collection = new List<int>() { ItemType<SupremeCalamitasTrophy>(), ItemType<AshenHorns>(), ItemType<SCalMask>(), ItemType<SCalRobes>(), ItemType<SCalBoots>(), ItemType<KnowledgeCalamitas>(), ItemType<BrimstoneJewel>(), ItemType<Levi>() };
string instructions = $"Use an [i:{summon}]";
string instructions = $"Use [i:{summon1}] or a [i:{summon2}] as offering at an [i:{altar}]";
string despawn = CalamityUtils.ColorMessage("Please don't waste my time.", new Color(0xFF, 0xA5, 0x00));
AddBoss(bossChecklist, calamity, "Supreme Calamitas", order, type, DownedSCal, summon, loot, collection, instructions, despawn);
AddBoss(bossChecklist, calamity, "Supreme Calamitas", order, type, DownedSCal, summons, loot, collection, instructions, despawn);
}
// Adult Eidolon Wyrm
-90
View File
@@ -76,95 +76,5 @@ namespace CalamityMod.NPCs.Astral
return;
}
}
public override bool Autoload(ref string name)
{
IL.Terraria.Wiring.HitWireSingle += HookStatue;
return base.Autoload(ref name);
}
/// <summary>
/// Change the following code sequence in Wiring.HitWireSingle
/// num8 = (int) Utils.SelectRandom<short>(Main.rand, new short[2]
/// {
/// 355,
/// 358
/// });
///
/// to
///
/// var arr = new short[2]
/// {
/// 355,
/// 358
/// });
/// arr = arr.ToList().Add(id).ToArray();
/// num8 = Utils.SelectRandom(Main.rand, arr);
///
/// </summary>
/// <param name="il"></param>
private void HookStatue(ILContext il)
{
// obtain a cursor positioned before the first instruction of the method
// the cursor is used for navigating and modifying the il
var c = new ILCursor(il);
// the exact location for this hook is very complex to search for due to the hook instructions not being unique, and buried deep in control flow
// switch statements are sometimes compiled to if-else chains, and debug builds litter the code with no-ops and redundant locals
// in general you want to search using structure and function rather than numerical constants which may change across different versions or compile settings
// using local variable indices is almost always a bad idea
// we can search for
// switch (*)
// case 54:
// Utils.SelectRandom *
// in general you'd want to look for a specific switch variable, or perhaps the containing switch (type) { case 105:
// but the generated IL is really variable and hard to match in this case
// we'll just use the fact that there are no other switch statements with case 54, followed by a SelectRandom
ILLabel[] targets = null;
while (c.TryGotoNext(i => i.MatchSwitch(out targets)))
{
// some optimising compilers generate a sub so that all the switch cases start at 0
// ldc.i4.s 51
// sub
// switch
int offset = 0;
if (c.Prev.MatchSub() && c.Prev.Previous.MatchLdcI4(out offset))
{
;
}
// get the label for case 54: if it exists
int case54Index = 54 - offset;
if (case54Index < 0 || case54Index >= targets.Length || !(targets[case54Index] is ILLabel target))
{
continue;
}
// move the cursor to case 54:
c.GotoLabel(target);
// there's lots of extra checks we could add here to make sure we're at the right spot, such as not encountering any branching instructions
c.GotoNext(i => i.MatchCall(typeof(Utils), nameof(Utils.SelectRandom)));
// goto next positions us before the instruction we searched for, so we can insert our array modifying code right here
c.EmitDelegate<Func<short[], short[]>>(arr =>
{
// resize the array and add our custom firefly
Array.Resize(ref arr, arr.Length+1);
arr[arr.Length-1] = (short)ModContent.NPCType<Twinkler>();
return arr;
});
// hook applied successfully
return;
}
// couldn't find the right place to insert
throw new Exception("Hook location not found, switch(*) { case 54: ...");
}
}
}
+10 -4
View File
@@ -218,9 +218,10 @@ namespace CalamityMod.NPCs
public int vulnerabilityHex = 0;
public int banishingFire = 0;
public int wither = 0;
public int RancorBurnTime = 0;
// whoAmI Variables
public static int[] bobbitWormBottom = new int[5];
// whoAmI Variables
public static int[] bobbitWormBottom = new int[5];
public static int DD2CrystalIndex = -1;
public static int hiveMind = -1;
public static int perfHive = -1;
@@ -4300,6 +4301,8 @@ namespace CalamityMod.NPCs
banishingFire--;
if (wither > 0)
wither--;
if (RancorBurnTime > 0)
RancorBurnTime--;
// Queen Bee is completely immune to having her movement impaired if not in a high difficulty mode.
if (npc.type == NPCID.QueenBee && !CalamityWorld.revenge && !CalamityWorld.malice && !BossRushEvent.BossRushActive)
@@ -4861,7 +4864,10 @@ namespace CalamityMod.NPCs
#region Hit Effect
public override void HitEffect(NPC npc, int hitDirection, double damage)
{
if (CalamityWorld.revenge)
if (npc.life <= 0 && npc.Organic() && RancorBurnTime > 0)
DeathAshParticle.CreateAshesFromNPC(npc);
if (CalamityWorld.revenge)
{
switch (npc.type)
{
@@ -5603,7 +5609,7 @@ namespace CalamityMod.NPCs
public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
{
if (npc.type != NPCID.BrainofCthulhu && (npc.type != NPCID.DukeFishron || npc.ai[0] <= 9f))
if (npc.type != NPCID.BrainofCthulhu && (npc.type != NPCID.DukeFishron || npc.ai[0] <= 9f) && npc.active)
{
if (CalamityConfig.Instance.DebuffDisplay && (npc.boss || BossHealthBarManager.MinibossHPBarList.Contains(npc.type) || BossHealthBarManager.OneToMany.ContainsKey(npc.type) || CalamityLists.needsDebuffIconDisplayList.Contains(npc.type)))
{
+14 -9
View File
@@ -9,6 +9,7 @@ using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Particles;
namespace CalamityMod.NPCs.SupremeCalamitas
{
@@ -51,9 +52,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas
npc.noTileCollide = true;
npc.HitSound = SoundID.DD2_OgreRoar;
npc.DeathSound = SoundID.NPCDeath52;
npc.Calamity().VulnerableToHeat = false;
npc.Calamity().VulnerableToCold = true;
}
npc.Calamity().VulnerableToHeat = false;
npc.Calamity().VulnerableToCold = true;
}
public override void SendExtraAI(BinaryWriter writer)
{
@@ -256,12 +257,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas
public override void NPCLoot()
{
if (!CalamityWorld.malice && !CalamityWorld.revenge)
{
int heartAmt = Main.rand.Next(3) + 3;
for (int i = 0; i < heartAmt; i++)
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart);
}
if (!CalamityWorld.malice && !CalamityWorld.revenge)
{
int heartAmt = Main.rand.Next(3) + 3;
for (int i = 0; i < heartAmt; i++)
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart);
}
DropHelper.DropItemChance(npc, ModContent.ItemType<SupremeCataclysmTrophy>(), 10);
}
@@ -295,6 +296,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas
num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f);
Main.dust[num624].velocity *= 2f;
}
// Turn into dust on death.
if (npc.life <= 0)
DeathAshParticle.CreateAshesFromNPC(npc);
}
}
}
+14 -9
View File
@@ -9,6 +9,7 @@ using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Particles;
namespace CalamityMod.NPCs.SupremeCalamitas
{
@@ -52,9 +53,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas
npc.noTileCollide = true;
npc.HitSound = SoundID.DD2_OgreRoar;
npc.DeathSound = SoundID.NPCDeath52;
npc.Calamity().VulnerableToHeat = false;
npc.Calamity().VulnerableToCold = true;
}
npc.Calamity().VulnerableToHeat = false;
npc.Calamity().VulnerableToCold = true;
}
public override void SendExtraAI(BinaryWriter writer)
{
@@ -260,12 +261,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas
public override void NPCLoot()
{
if (!CalamityWorld.malice && !CalamityWorld.revenge)
{
int heartAmt = Main.rand.Next(3) + 3;
for (int i = 0; i < heartAmt; i++)
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart);
}
if (!CalamityWorld.malice && !CalamityWorld.revenge)
{
int heartAmt = Main.rand.Next(3) + 3;
for (int i = 0; i < heartAmt; i++)
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart);
}
DropHelper.DropItemChance(npc, ModContent.ItemType<SupremeCatastropheTrophy>(), 10);
}
@@ -299,6 +300,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas
num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f);
Main.dust[num624].velocity *= 2f;
}
// Turn into dust on death.
if (npc.life <= 0)
DeathAshParticle.CreateAshesFromNPC(npc);
}
}
}
+2 -2
View File
@@ -269,7 +269,7 @@ namespace CalamityMod.NPCs.TownNPCs
displayThisText = "Be careful when defeating Plantera and the Golem. You might accidentally unleash a new threat in the jungle that needs to be quelled.";
break;
case 7f:
displayThisText = "When exploring the jungle temple be careful. You may not wish to disturb the Lihzard's idol, the Golem. It's quite the destructive force.";
displayThisText = "When exploring the jungle temple be careful. You may not wish to disturb the Lihzahrd's idol, the Golem. It's quite the destructive force.";
break;
}
}
@@ -296,7 +296,7 @@ namespace CalamityMod.NPCs.TownNPCs
displayThisText = "Be careful what you attack in the " + worldEvil + ". You might just unveil a greater threat than what was there before.";
break;
case 6f:
displayThisText = "Scattered across the lands are shrines dedicated to the gods. You can take whatever is in them, but a few items you may not be able to use until much later.";
displayThisText = "Scattered across the lands are shrines dedicated to the gods. They contain powerful gear that may help you on your adventures.";
break;
case 7f:
displayThisText = "I'm assuming you've heard the legends that speak of the ninja, Statis? There are some who say that if you were able to defeat the gods which his clan once worshipped you would be able to harness some of his powers.";
+6 -1
View File
@@ -14,6 +14,7 @@ using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.TownNPCs;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Boss;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.Tiles.Ores;
@@ -2852,7 +2853,7 @@ namespace CalamityMod.NPCs.Yharon
DropHelper.DropItem(npc, ModContent.ItemType<HellcasterFragment>(), true, soulFragMin, soulFragMax);
// Equipment
DropHelper.DropItem(npc, ModContent.ItemType<DrewsWings>(), Main.expertMode);
DropHelper.DropItem(npc, ModContent.ItemType<DrewsWings>());
}
// Vanity
@@ -3088,6 +3089,10 @@ namespace CalamityMod.NPCs.Yharon
num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 244, 0f, 0f, 100, default, 2f);
Main.dust[num624].velocity *= 2f;
}
// Turn into dust on death.
if (npc.life <= 0)
DeathAshParticle.CreateAshesFromNPC(npc);
}
}
#endregion
+1 -1
View File
@@ -87,7 +87,7 @@ namespace CalamityMod.Particles
// Clear away any particles that shouldn't exist anymore.
Particles.RemoveAll(p => p.Size <= 5f);
// Prepare the sprite batch for specialized drawing in prepration that the graphics device will to new render targets.
// Prepare the sprite batch for specialized drawing in prepration that the graphics device will draw to new render targets.
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix);
// Draw the surviving particles.
+251
View File
@@ -0,0 +1,251 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.ID;
namespace CalamityMod.Particles
{
public class DeathAshParticle
{
internal static Dictionary<NPC, RenderTarget2D> PendingNPCsToDraw = new Dictionary<NPC, RenderTarget2D>();
internal static BasicEffect basicShader = null;
internal static VertexPositionColorTexture[] VertexCache = new VertexPositionColorTexture[PrimitiveBatchSize * 4];
internal static short[] IndexCache = new short[PrimitiveBatchSize * 6];
public int Time;
public int Lifetime;
public int ID;
public float Scale = 1f;
public Color AshColor;
public Vector2 Center;
public Vector2 Velocity;
public Vector2 TopLeft => Center - Vector2.One * Scale * 3.5f;
public Vector2 TopRight => Center + new Vector2(1f, -1f) * Scale * 3.5f;
public Vector2 BottomRight => Center + Vector2.One * Scale * 3.5f;
public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Scale * 3.5f;
public static HashSet<DeathAshParticle> Ashes = new HashSet<DeathAshParticle>();
public const int PrimitiveBatchSize = 256;
public const int AshCountLimit = 45000;
public static BasicEffect BasicShader
{
get
{
if (Main.netMode != NetmodeID.Server && basicShader is null)
{
basicShader = new BasicEffect(Main.instance.GraphicsDevice)
{
VertexColorEnabled = true,
TextureEnabled = false
};
}
return basicShader;
}
}
public DeathAshParticle(int lifetime, float brightness, Vector2 spawnPosition)
{
Time = 0;
Lifetime = lifetime;
ID = Ashes.Count;
AshColor = Main.hslToRgb(0f, 0f, brightness * 0.67f);
Scale = Main.rand.NextFloat(0.7f, 1.3f);
Center = spawnPosition;
}
public static void PrepareRenderTargets()
{
foreach (NPC npc in PendingNPCsToDraw.Keys)
{
// Prepare the sprite batch for specialized drawing in prepration that the graphics device will draw to new render targets.
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Matrix.Identity);
// Draw the NPC to the temporary render target so that all of its drawcode is localized, and then get the colors from the results.
Main.instance.GraphicsDevice.SetRenderTarget(PendingNPCsToDraw[npc]);
Main.instance.GraphicsDevice.Clear(Color.Transparent);
Vector2 oldPosition = npc.position;
npc.oldPos = new Vector2[npc.oldPos.Length];
npc.position = Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f;
try
{
Main.instance.DrawNPC(npc.whoAmI, true);
}
catch { }
npc.position = oldPosition;
npc.Opacity = 0f;
Main.spriteBatch.End();
}
Main.instance.GraphicsDevice.SetRenderTarget(null);
}
public static void CreateAshesFromNPC(NPC npc)
{
// Don't create ashes serverside.
if (Main.netMode == NetmodeID.Server)
return;
PendingNPCsToDraw[npc] = new RenderTarget2D(Main.instance.GraphicsDevice, Main.screenWidth, Main.screenHeight);
}
public static Dictionary<Vector2, Color> GetColorCacheFromTexture(Texture2D texture, Rectangle? frame = null, bool pruneForEfficency = false)
{
Dictionary<Vector2, Color> colorCache = new Dictionary<Vector2, Color>();
Color[] uncleanedCache = new Color[texture.Width * texture.Height];
texture.GetData(uncleanedCache);
// Initialize the frame to its default of the texture size if nothing else is specified.
int width = texture.Width;
int height = texture.Height;
if (frame is null)
frame = new Rectangle(0, 0, width, height);
int stride = 1;
int totalFilledPixels = uncleanedCache.Count(c => c.R != 0 || c.G != 0 || c.B != 0 || c.A != 0);
if (pruneForEfficency && totalFilledPixels > 16000)
stride = 2;
if (pruneForEfficency && totalFilledPixels > 38000)
stride = 3;
// Store all non-empty pixels.
for (int i = 0; i < width; i += stride)
{
for (int j = 0; j < height; j += stride)
{
Color color = uncleanedCache[i + j * width];
// Ignore textures outside the bounds of the frame.
if (i < frame.Value.Left || i >= frame.Value.Right || j < frame.Value.Top || j >= frame.Value.Bottom)
continue;
if (color.R != 0 || color.G != 0 || color.B != 0 || color.A != 0)
colorCache[new Vector2(i - frame.Value.X, j - frame.Value.Y)] = color;
}
}
return colorCache;
}
public static void FlushContentsAndCreateAshes()
{
// Don't do anything if no NPCs have to be drawn.
if (PendingNPCsToDraw.Count == 0)
return;
foreach (NPC npc in PendingNPCsToDraw.Keys)
{
RenderTarget2D temporaryTextureDrawTarget = PendingNPCsToDraw[npc];
Rectangle frame = new Rectangle(0, 0, temporaryTextureDrawTarget.Width, temporaryTextureDrawTarget.Height);
Dictionary<Vector2, Color> colorsOnNPC = GetColorCacheFromTexture(temporaryTextureDrawTarget, frame, true);
// Enforce a hard limit on the amount of ashes that can exist.
if (Ashes.Count + colorsOnNPC.Count > AshCountLimit)
break;
// Create ashes.
foreach (Vector2 drawOffset in colorsOnNPC.Keys)
{
int ashLifetime = Main.rand.Next(105, 145);
// Adjust the offset of the ashes from pixel space by accounting for direction, rotation, and scale.
Vector2 ashSpawnPosition = npc.position + drawOffset - new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f;
Color color = colorsOnNPC[drawOffset];
float brightness = (color.R + color.G + color.B) / 765f;
DeathAshParticle ash = new DeathAshParticle(ashLifetime, brightness, ashSpawnPosition)
{
Velocity = (Main.npc.IndexInRange(npc.realLife) ? Main.npc[npc.realLife].velocity : npc.velocity) * 0.7f
};
if (brightness > 0.05f)
Ashes.Add(ash);
}
// And release the render target.
PendingNPCsToDraw[npc].Dispose();
}
// Clear the pending NPCs once done.
PendingNPCsToDraw.Clear();
}
public static void DrawAll()
{
FlushContentsAndCreateAshes();
// Redefine the perspective matrices of the shader.
CalamityUtils.CalculatePerspectiveMatricies(out Matrix effectView, out Matrix effectProjection);
BasicShader.View = effectView;
BasicShader.Projection = effectProjection;
int batchIndex = 0;
// Reset the cache before drawing.
Array.Clear(VertexCache, 0, VertexCache.Length);
Array.Clear(IndexCache, 0, IndexCache.Length);
// Go through all particles and draw them directly with primitives.
// Particles are drawn in batches, to prevent unnecessary overhead in the form of primitive draw preparations.
BasicShader.CurrentTechnique.Passes[0].Apply();
foreach (DeathAshParticle ash in Ashes)
{
Color fadedAshColor = ash.AshColor * ash.Scale;
VertexCache[batchIndex * 4] = new VertexPositionColorTexture(new Vector3(ash.TopLeft - Main.screenPosition, 0f), fadedAshColor, new Vector2(0f, 0f));
VertexCache[batchIndex * 4 + 1] = new VertexPositionColorTexture(new Vector3(ash.TopRight - Main.screenPosition, 0f), fadedAshColor, new Vector2(1f, 0f));
VertexCache[batchIndex * 4 + 2] = new VertexPositionColorTexture(new Vector3(ash.BottomRight - Main.screenPosition, 0f), fadedAshColor, new Vector2(1f, 1f));
VertexCache[batchIndex * 4 + 3] = new VertexPositionColorTexture(new Vector3(ash.BottomLeft - Main.screenPosition, 0f), fadedAshColor, new Vector2(0f, 1f));
// Construct independent primitives by creating a square from two triangles defined by the edges of the particle.
IndexCache[batchIndex * 6] = (short)(batchIndex * 4);
IndexCache[batchIndex * 6 + 1] = (short)(batchIndex * 4 + 1);
IndexCache[batchIndex * 6 + 2] = (short)(batchIndex * 4 + 2);
IndexCache[batchIndex * 6 + 3] = (short)(batchIndex * 4);
IndexCache[batchIndex * 6 + 4] = (short)(batchIndex * 4 + 2);
IndexCache[batchIndex * 6 + 5] = (short)(batchIndex * 4 + 3);
batchIndex++;
// Draw the batch once it is at full capacity.
if (batchIndex >= PrimitiveBatchSize)
{
Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, VertexCache, 0, PrimitiveBatchSize * 4, IndexCache, 0, PrimitiveBatchSize * 2);
batchIndex = 0;
}
}
// Draw any remaining primitives which did not fit neatly into individual batches in the above loop.
// All undeclared vertices in the cache are ignored.
if (batchIndex > 0)
Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, VertexCache, 0, batchIndex * 4, IndexCache, 0, batchIndex * 2);
}
public void Update()
{
float brightness = (AshColor.R + AshColor.G + AshColor.B) / 765f;
Time++;
Scale = MathHelper.Clamp(Scale - (brightness < 0.1f ? 0.08f : 0.008f), 0f, 1f);
float dissipationFactor = Utils.InverseLerp(6f, 16f, Velocity.Length(), true);
float velocityInterpolant = Utils.InverseLerp(25f - dissipationFactor * 10f, 80f - dissipationFactor * 45f, Time, true);
Vector2 idealVelocity = new Vector2(Main.windSpeed * MathHelper.Lerp(0.8f, 1.2f, (float)Math.Sin(Center.Y / 50f + ID)) * 20f, (float)Math.Sin(Main.time / 20f + ID * 0.01f) * 3f - 1f);
Velocity = Vector2.Lerp(Velocity, idealVelocity, velocityInterpolant * 0.16f);
Center += Velocity;
}
public static void UpdateAll()
{
// Don't draw ashes serverside.
if (Main.netMode == NetmodeID.Server)
return;
foreach (DeathAshParticle ash in Ashes)
ash.Update();
Ashes.RemoveWhere(a => a.Time >= a.Lifetime);
}
}
}
+9 -3
View File
@@ -1,3 +1,4 @@
using CalamityMod.Buffs;
using CalamityMod.Particles;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -48,9 +49,9 @@ namespace CalamityMod.Projectiles.Magic
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.hide = true;
projectile.Calamity().PierceResistHarshness = 0.06f;
projectile.Calamity().PierceResistCap = 0.4f;
}
projectile.Calamity().PierceResistHarshness = 0.06f;
projectile.Calamity().PierceResistCap = 0.4f;
}
public override void AI()
{
@@ -189,6 +190,11 @@ namespace CalamityMod.Projectiles.Magic
drawCacheProjsOverWiresUI.Add(index);
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<RancorBurn>(), 150);
}
public override bool ShouldUpdatePosition() => false;
}
}
+4 -4
View File
@@ -115,6 +115,10 @@ namespace CalamityMod.Projectiles.Melee
public override void AI()
{
Player player = Main.player[projectile.owner];
if (projectile.timeLeft == 300)
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"), player.Center);
projectile.position = player.Center + projectile.velocity * MOVE_DISTANCE;
projectile.timeLeft = 2;
@@ -283,10 +287,6 @@ namespace CalamityMod.Projectiles.Melee
}
}
AchievementsHelper.CurrentlyMining = false;
if (Main.netMode != NetmodeID.SinglePlayer)
{
NetMessage.SendData(MessageID.KillProjectile, -1, -1, null, projectile.identity, projectile.owner, 0f, 0f, 0, 0, 0);
}
}
}
+5
View File
@@ -33,6 +33,11 @@ namespace CalamityMod.Projectiles.Ranged
public override void AI()
{
//Sound is played in the first frame instead of in the weapon shoot for proper mp sync
if (projectile.timeLeft == 300)
Main.PlaySound(SoundID.DD2_BallistaTowerShot, projectile.Center);
Lighting.AddLight(projectile.Center, Color.Violet.ToVector3());
projectile.Opacity = Utils.InverseLerp(0f, 20f, Time, true);
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2;
+3 -1
View File
@@ -46,14 +46,16 @@ namespace CalamityMod.Projectiles.Ranged
// Fire one charged arrow every frame until you're out of arrows.
ShootProjectiles(tipPosition);
--ArrowsLoaded;
Main.PlaySound(SoundID.DD2_BallistaTowerShot);
}
else
{
// Frame 1 effects: Record how fast the Condemnation item being used is, to determine how fast to load arrows.
if (FramesToLoadNextArrow == 0f)
{
Main.PlaySound(SoundID.Item20, projectile.Center);
FramesToLoadNextArrow = Owner.ActiveItem().useAnimation;
}
// Actually make progress towards loading more arrows.
++CurrentChargingFrames;
+4
View File
@@ -2,6 +2,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
@@ -30,6 +31,9 @@ namespace CalamityMod.Projectiles.Ranged
public override void AI()
{
if (projectile.timeLeft == 300)
Main.PlaySound(SoundID.Item14, projectile.Center);
CurrentLaserLength = (int)MathHelper.Lerp(1f, 70f, Utils.InverseLerp(0f, 15f, Time, true) * Utils.InverseLerp(0f, 15f, projectile.timeLeft, true));
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2;
Time++;
+13 -10
View File
@@ -30,16 +30,19 @@ namespace CalamityMod.Projectiles.Rogue
public override void Kill(int timeLeft)
{
int dustType = Main.rand.NextBool() ? 246 : 176;
float dustSpeed = Main.rand.NextFloat(3f, 9f);
Vector2 dustVel = CalamityUtils.RandomVelocity(10f, dustSpeed, dustSpeed, 1f);
int boom = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f);
Dust dust = Main.dust[boom];
dust.noGravity = true;
dust.position = projectile.Center;
dust.position.X += (float)Main.rand.Next(-10, 11);
dust.position.Y += (float)Main.rand.Next(-10, 11);
dust.velocity = dustVel;
for (int s = 0; s < 20; s++)
{
int dustType = Main.rand.NextBool() ? 246 : 176;
float dustSpeed = Main.rand.NextFloat(3f, 9f);
Vector2 dustVel = CalamityUtils.RandomVelocity(10f, dustSpeed, dustSpeed, 1f);
int boom = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f);
Dust dust = Main.dust[boom];
dust.noGravity = true;
dust.position = projectile.Center;
dust.position.X += (float)Main.rand.Next(-10, 11);
dust.position.Y += (float)Main.rand.Next(-10, 11);
dust.velocity = dustVel;
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
+1 -1
View File
@@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Summon
get => (int)projectile.ai[0];
set => projectile.ai[0] = value;
}
public const float DistanceToCheck = 1600f;
public const float DistanceToCheck = 2800f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Hydra Body");
+1 -1
View File
@@ -112,7 +112,7 @@ namespace CalamityMod.Projectiles.Summon
Vector2 returnPosition = body.Center + new Vector2(body.spriteDirection == 1 ? 12 : -14, -50f) + DeltaPositionMoving;
// Beam shooting
if (body.ai[0] >= 0 && body.ai[0] < Main.npc.Length)
if (body.ai[0] >= 0 && body.ai[0] < Main.maxNPCs)
{
NPC target = Main.npc[(int)body.ai[0]];
bool targetAliveAndInLineOfSight = target.active && projectile.Distance(target.Center) < EndoHydraBody.DistanceToCheck;
+1 -1
View File
@@ -97,7 +97,7 @@ namespace CalamityMod.TileEntities
int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
return "Within an army, as weapons do, the soldiers serve different purposes. That distinction is crucial, as the wrong tool in the wrong hands—no matter how potent—may as well be a wooden club.\n" +
"Addendum: Seek out my base of operations closest to the Lihzard’s home. I wish you the best of luck with all sincerity, for it has been a long time since I have had a worthy test subject. ";
"Addendum: Seek out my base of operations closest to the Lihzahrd’s home. I wish you the best of luck with all sincerity, for it has been a long time since I have had a worthy test subject. ";
if (schematicType == ModContent.ItemType<EncryptedSchematicJungle>())
return "As rank progresses, so often does the lethality of equipment. In the hands of competent soldiers, the weapons have the ability to make change. However, competent soldiers take no action but orders from above.\n" +
"Addendum: If you read this, you have come far. Do not disappoint. Go now to Hell, for the next component stored in what were once my forges.";
+1
View File
@@ -9,6 +9,7 @@ using CalamityMod.Tiles.AstralDesert;
using CalamityMod.Tiles.Crags;
using CalamityMod.Tiles.DraedonStructures;
using CalamityMod.Tiles.DraedonSummoner;
using CalamityMod.Tiles.Furniture;
using CalamityMod.Tiles.FurnitureExo;
using CalamityMod.Tiles.Ores;
using CalamityMod.Tiles.SunkenSea;
@@ -1,6 +1,6 @@
using CalamityMod.Events;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
using CalamityMod.Items.Placeables.Furniture;
using CalamityMod.Items.SummonItems;
using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.Projectiles.Boss;
@@ -13,7 +13,7 @@ using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace CalamityMod.Tiles
namespace CalamityMod.Tiles.Furniture
{
public class SCalAltar : ModTile
{
File renamed without changes.

Before

Width:  |  Height:  |  Size: 648 B

After

Width:  |  Height:  |  Size: 648 B

@@ -195,7 +195,7 @@ namespace CalamityMod.UI.CalamitasEnchants
"CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral",
null,
player => player.Calamity().dischargingItemEnchant = true,
item => item.IsEnchantable() && item.damage > 0 && !item.summon),
item => item.IsEnchantable() && item.damage > 0 && !item.summon && !item.channel),
new Enchantment("Hellbound", "Causes minions to be created with a 40 second timer.\nOnce it runs out, they explode violently. Minions do more damage the longer they live and idly explode as well.",
700,
+25
View File
@@ -0,0 +1,25 @@
using CalamityMod.Items.Placeables.Walls;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Walls
{
public class ExoPlatingWall : ModWall
{
public override void SetDefaults()
{
Main.wallHouse[Type] = true;
drop = ModContent.ItemType<ExoPlatingWallItem>();
AddMapEntry(new Color(41, 55, 65));
}
public override bool CreateDust(int i, int j, ref int type)
{
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 107, 0f, 0f, 1, new Color(255, 255, 255), 1f);
return false;
}
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

+77
View File
@@ -0,0 +1,77 @@
using CalamityMod.Items.Placeables.Walls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Walls
{
public class ExoPrismPanelWall : ModWall
{
public override void SetDefaults()
{
Main.wallHouse[Type] = true;
drop = ModContent.ItemType<ExoPrismPanelWallItem>();
AddMapEntry(new Color(41, 55, 65));
}
public override bool CreateDust(int i, int j, ref int type)
{
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 107, 0f, 0f, 1, new Color(255, 255, 255), 1f);
return false;
}
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Texture2D sprite = Main.wallTexture[Type];
Color lightColor = GetWallColour(i, j);
Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
zero -= new Vector2(8, 8);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero;
int[] sheetOffset = CreatePattern(i, j);
spriteBatch.Draw
(
sprite,
drawOffset,
new Rectangle(sheetOffset[0] + Main.tile[i, j].wallFrameX(), sheetOffset[1] + Main.tile[i, j].wallFrameY(), 32, 32),
lightColor,
0,
new Vector2(0f, 0f),
1,
SpriteEffects.None,
0f
);
return false;
}
private int[] CreatePattern(int i, int j)
{
int[] sheetOffset = new int[2] { 0, (i + j) % 6 };
sheetOffset[1] = sheetOffset[1] * 180;
return sheetOffset;
}
private Color GetWallColour(int i, int j)
{
int colType = Main.tile[i, j].wallColor();
Color paintCol = WorldGen.paintColor(colType);
if (colType < 13)
{
paintCol.R = (byte)((paintCol.R / 2f) + 128);
paintCol.G = (byte)((paintCol.G / 2f) + 128);
paintCol.B = (byte)((paintCol.B / 2f) + 128);
}
if (colType == 29)
{
paintCol = Color.Black;
}
Color col = Lighting.GetColor(i, j);
col.R = (byte)(paintCol.R / 255f * col.R);
col.G = (byte)(paintCol.G / 255f * col.G);
col.B = (byte)(paintCol.B / 255f * col.B);
return col;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB