Skip to content

Commit

Permalink
add mineResist and minPick fields to ModTile
Browse files Browse the repository at this point in the history
  • Loading branch information
blushiemagic committed Aug 1, 2015
1 parent dfef4bf commit 3642a20
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Terraria.ModLoader/ModTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public ushort Type
public int animationFrameHeight = 0;
public Color? mapColor = null;
public string mapName = "";
public float mineResist = 1f;
public int minPick = 0;

public void AddToArray(ref int[] array)
{
Expand Down
29 changes: 29 additions & 0 deletions Terraria.ModLoader/TileLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -683,4 +683,33 @@ internal static bool TileFrame(int i, int j, int type, ref bool resetFrame, ref
}
return flag;
}

//in Terraria.Player.ItemCheck in if statements for mining
// replace num222 += item.hammer; with TileLoader.MineDamage(item.hammer, ref num222);
// replace num222 += item.axe; with TileLoader.MineDamage(item.axe, ref num222);
//in Terraria.Player.PickTile replace num += pickPower; with TileLoader.MineDamage(pickPower, ref num);
internal static void MineDamage(int minePower, ref int damage)
{
Tile target = Main.tile[Player.tileTargetX, Player.tileTargetY];
ModTile modTile = GetTile(target.type);
if(modTile != null)
{
damage = (int)(damage + minePower / modTile.mineResist);
}
else
{
damage += minePower;
}
}

//in Terraria.Player.ItemCheck at end of else if chain setting num to 0 add
// else { TileLoader.PickPowerCheck(tile, pickPower, ref num); }
internal static void PickPowerCheck(Tile target, int pickPower, ref int damage)
{
ModTile modTile = GetTile(target.type);
if(modTile != null && pickPower < modTile.minPick)
{
damage = 0;
}
}
}}

0 comments on commit 3642a20

Please sign in to comment.