From aba2a05415e035cb35b06d518bfcdef7edd0c145 Mon Sep 17 00:00:00 2001 From: vipix Date: Sat, 7 Oct 2017 22:49:07 +0200 Subject: [PATCH] New item: Swap Pickaxe --- Items/SwapPickaxe.cs | 139 +++++++++++++++++++++++++++++++++++ Items/SwapPickaxe.png | Bin 0 -> 3235 bytes NPCs/Shops.cs | 5 ++ UI/Color/ColorUI.cs | 8 +- UI/Color/{0.png => null.png} | Bin 3052 -> 3032 bytes build.txt | 2 +- description.txt | 3 + 7 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 Items/SwapPickaxe.cs create mode 100644 Items/SwapPickaxe.png rename UI/Color/{0.png => null.png} (89%) diff --git a/Items/SwapPickaxe.cs b/Items/SwapPickaxe.cs new file mode 100644 index 0000000..5ad0d90 --- /dev/null +++ b/Items/SwapPickaxe.cs @@ -0,0 +1,139 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using VipixToolBox; +using VipixToolBox.Items; + +namespace VipixToolBox.Items +{ + public class SwapPickaxe : ModItem + { + public int baseRange = 12; + public int toolRange; + public bool operationAllowed; + public List validBlocks; + public List validItems; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Swap Pickaxe"); + Tooltip.SetDefault("Nothing is lost, nothing is created\n100% equivalent pickaxe power"); + } + public override void SetDefaults() + { + Item moltenPickaxe = new Item(); //defaults on copper pickaxe + moltenPickaxe.CloneDefaults(ItemID.MoltenPickaxe); + item.damage = moltenPickaxe.damage; + item.knockBack = moltenPickaxe.knockBack; + item.useStyle = 1; + item.useAnimation = 16; + item.useTime = 16; + item.width = 32; + item.height = 32; + item.rare = moltenPickaxe.rare + +1; + item.UseSound = SoundID.Item1; + item.value = Item.buyPrice(0, 5, 0, 0); + item.autoReuse = true; + validBlocks = new List{ + 0,1,6,7,8,9,38,39,40,45,46,47,53,54,57,59,75,76,188,112,116,118,119,120, + 121,122,123,130,131,137,140,145,146,147,148,150,151,152,153,154,155,156, + 160,161,166,167,168,169,175,176,177,189,193,195,196,194,197,198,202,163, + 164,200,206,224,229,230,137,137,137,137,234,272,248,249,250,170,262,263, + 264,265,266,267,268,273,274,284,311,312,313,315,325,326,327,328,329,336, + 340,341,342,343,344,345,346,347,348,350,351,357,367,368,369,370,371,379, + 385,396,397,398,399,400,401,402,403,404,407,408,409,415,416,417,418, + 30,157,159,208,251,252,253,321,322,2,70,179,180,181,182,183,184 + + };//IDs of blocks that need 1 hit from a pickaxe with >100 power except the grass + + validItems = new List{ + 2,3,11,12,13,14,129,131,133,141,143,145,169,170,172,176,192,214,276,370, + 408,412,413,414,415,416,424,511,512,539,577,586,591,593,594,604,607,609, + 611,612,613,614,662,664,699,700,701,702,717,718,719,751,762,763,765,766, + 767,775,824,833,834,835,883,1103,1125,1127,1146,1147,1148,1149,1246,1344, + 1589,1591,1593,1872,1970,1971,1972,1973,1974,1975,1976,2119,2120,2173, + 2260,2261,2262,2435,2692,2693,2694,2695,2697,2701,2751,2752,2753,2754, + 2755,2787,2792,2793,2794,2860,2868,3066,3081,3086,3087,3100,3113,3214, + 3234,3271,3272,3274,3275,3276,3277,3338,3339,3347,3380,3460,3461,3573, + 3574,3575,3576, + 9,619,621,911,1725,1727,1729,2503,2504,2,176,1,1,1,1,1,1 + };//IDs of corresponding items + } + + public override bool AltFunctionUse(Player player) + { + return false; + } + public override void HoldItem(Player player) + { + //this method determines if the pointed block is buildable and in range of the player + //it shows the item icon if true + //and it allows the actions in CanUseItem + VipixToolBoxPlayer myPlayer = player.GetModPlayer(mod); + toolRange = Math.Max(baseRange, myPlayer.fargoRange);//blocks + + if (Vector2.Distance(player.position,myPlayer.pointerCoord) < toolRange*16 && + myPlayer.pointedTile.active() && + Main.tileSolid[myPlayer.pointedTile.type]) + { + operationAllowed = true; + player.showItemIcon = true; + } + else + { + operationAllowed = false; + player.showItemIcon = false; + } + } + + public override bool CanUseItem(Player player) + { + VipixToolBoxPlayer myPlayer = player.GetModPlayer(mod); + + return true; + } + public override bool UseItem(Player player) + { + VipixToolBoxPlayer myPlayer = player.GetModPlayer(mod); + if (operationAllowed && validBlocks.Contains(myPlayer.pointedTile.type)) + { + int index = -1; + int iindex = -1; + for (int i = 0; i < player.inventory.Length; i++) + { + if (validItems.Contains(player.inventory[i].type)) + { + iindex = i; + index = validItems.FindIndex(a => a == player.inventory[i].type); + break; + } + } + //need to check for resource first + //player.inventory[boneIndex].stack--; + if (index != -1) + { + bool halfBrick = myPlayer.pointedTile.halfBrick(); + byte slope = myPlayer.pointedTile.slope(); + bool actuator = myPlayer.pointedTile.actuator(); + byte color = myPlayer.pointedTile.color(); + + WorldGen.KillTile(myPlayer.pointedTileX, myPlayer.pointedTileY); + WorldGen.PlaceTile(myPlayer.pointedTileX, myPlayer.pointedTileY, validBlocks[index]); + player.inventory[iindex].stack--; + + myPlayer.pointedTile.halfBrick(halfBrick); + myPlayer.pointedTile.slope(slope); + myPlayer.pointedTile.actuator(actuator); + myPlayer.pointedTile.color(color); + + if (Main.netMode == 1) NetMessage.SendTileSquare(-1, myPlayer.pointedTileX, myPlayer.pointedTileY, 1);//player, X, Y, square "diameter". -1 as the player equals all ? + Main.PlaySound(SoundID.Dig); + } + } + return true; + } + } +} diff --git a/Items/SwapPickaxe.png b/Items/SwapPickaxe.png new file mode 100644 index 0000000000000000000000000000000000000000..b1f162ae3d8754734daa78859c9fe79ec7b5b0ee GIT binary patch literal 3235 zcmV;U3|#YxP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h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3m|KE0OtcYisfB0}Xp%b6pr7uHJonJJ{RS z3LZXs99eh0mWJ8&gW$@Gu^^cq*jyi0SHaNGASf;uBRRj=Q%%Q)YI=$r<^RM3*=)7~ z9jO#}wXgv8*T#1zCL(zcmAKr}0q(W!NoXJF>+7pPZe#>Jo0>Z+|{J3+CtNgGOE$dLcO}2+1$ya^U9Z=pT_M@1HOvKbOfgg*?6r zgyd(_Y4BijvMJ>8Qy?Ti-P>FJp6ByTC67-ZNTpH{^0`7`Tgc<5Kv>&F9vcOI4giRv VszwJIFZ=)i002ovPDHLkV1k?F4DkQ} literal 0 HcmV?d00001 diff --git a/NPCs/Shops.cs b/NPCs/Shops.cs index 582714d..e90abc3 100644 --- a/NPCs/Shops.cs +++ b/NPCs/Shops.cs @@ -37,6 +37,11 @@ public override void SetupShop(int type, Chest shop, ref int nextSlot) shop.item[nextSlot].SetDefaults(mod.ItemType()); nextSlot++; } + if (type == NPCID.Mechanic) + { + shop.item[nextSlot].SetDefaults(mod.ItemType()); + nextSlot++; + } } } } diff --git a/UI/Color/ColorUI.cs b/UI/Color/ColorUI.cs index dc1ee56..463d8ab 100644 --- a/UI/Color/ColorUI.cs +++ b/UI/Color/ColorUI.cs @@ -51,7 +51,13 @@ public override void OnInitialize() toolList = new List(); Texture2D buttonTexture; //color buttons - for (int i = 0; i < 31; i++) + buttonTexture = ModLoader.GetMod("VipixToolBox").GetTexture("UI/Color/null"); + colorList.Add(new UIImageButton(buttonTexture)); + disabledList.Add(new UIImageButton(ModLoader.GetMod("VipixToolBox").GetTexture("UI/Color/no"))); + colorList[0].Left.Set(0f,0f); + colorList[0].Top.Set(0f,0f); + + for (int i = 1; i < 31; i++) { buttonTexture = ModLoader.GetMod("VipixToolBox").GetTexture("UI/Color/" + i.ToString()); colorList.Add(new UIImageButton(buttonTexture)); diff --git a/UI/Color/0.png b/UI/Color/null.png similarity index 89% rename from UI/Color/0.png rename to UI/Color/null.png index 76979b22e727f83106eb2521a4d26d3fe5b30498..1c1287d96e1864cf0d4b731aec1c810f8d81a745 100644 GIT binary patch delta 290 zcmV+-0p0%W7uXlDzzTl@NklW9A1oKa z(gMuh0S|#u2e8oE0yZ`_yt!dC3I#tij(3Z zQN(*EP9w=+Se!1y0D9aH-Vh+RXGEyvg!y>T_ly`veD4@A0MMe2LG=WZAOHXW07*qo IM6N<$g7AxlPXGV_ diff --git a/build.txt b/build.txt index d83260c..f41cf57 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = vipix -version = 1.3.2 +version = 1.4.0 displayName = VipixToolbox buildIgnore = *.psd, *.template, *.csproj, *.csproj.user, *.zip, *.user, obj\*, bin\*, .vs\*, *.txt, archive\*, .git\, *.gitignore includePDB = true diff --git a/description.txt b/description.txt index d2300bd..0f006fa 100644 --- a/description.txt +++ b/description.txt @@ -10,11 +10,14 @@ New items: - Greater Wand (bloc wand interface) - Wall Hammer - Unstable Staff +- Swap Pickaxe Modified items: - Staff of regrowth (moss color interface) ------------ +v1.4.0 +- New tool: Swap Pickaxe. Swaps blocks with the ones in your inventory but keeps all other characteristics v1.3.2 - Fixed an icon - Mod icon introduced