Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Fixes #7 (Infinite stimpacks)
Browse files Browse the repository at this point in the history
Stimpack improvements
  • Loading branch information
Jofairden committed Jul 14, 2017
1 parent f1cde99 commit 766d08d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
24 changes: 15 additions & 9 deletions Items/HealthStimPack.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tremor.Items
{

public class HealthStimPack : ModItem
{
public override void SetDefaults()
{
item.width = 36;
item.height = 36;
item.Size = new Vector2(36);
item.maxStack = 999;
item.rare = 11;
item.useAnimation = 15;
Expand All @@ -26,21 +26,27 @@ public override void SetStaticDefaults()
Tooltip.SetDefault("Restores 50 health\nHas no cooldown");
}

public override bool ConsumeItem(Player player) => true;

public override bool UseItem(Player player)
{
Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 3);
Main.player[Main.myPlayer].HealEffect(50);
player.statLife += 50;
return true;
if (player.whoAmI == Main.myPlayer)
{
Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 3);
player.HealEffect(50);
player.statLife = Math.Min(player.statLifeMax2, player.statLife + 50);
return true;
}
return false;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "BrassBar", 2);
recipe.AddIngredient(mod.ItemType<BrassBar>(), 2);
recipe.AddIngredient(ItemID.SuperHealingPotion);
recipe.AddIngredient(ItemID.BottledWater);
recipe.AddIngredient(null, "NightmareBar", 5);
recipe.AddIngredient(mod.ItemType<NightmareBar>(), 5);
recipe.SetResult(this);
recipe.AddTile(13);
recipe.AddRecipe();
Expand Down
24 changes: 15 additions & 9 deletions Items/ManaStimPack.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tremor.Items
{

public class ManaStimPack : ModItem
{
public override void SetDefaults()
{
item.width = 36;
item.height = 36;
item.Size = new Vector2(36);
item.maxStack = 999;
item.rare = 11;
item.useAnimation = 15;
Expand All @@ -20,6 +20,8 @@ public override void SetDefaults()
item.consumable = true;
}

public override bool ConsumeItem(Player player) => true;

public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mana Stim Pack");
Expand All @@ -28,19 +30,23 @@ public override void SetStaticDefaults()

public override bool UseItem(Player player)
{
Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 3);
Main.player[Main.myPlayer].ManaEffect(20);
player.statMana += 20;
return true;
if (player.whoAmI == Main.myPlayer)
{
Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 3);
player.ManaEffect(20);
player.statMana = Math.Min(player.statManaMax2, player.statMana + 20);
return true;
}
return false;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "BrassBar", 2);
recipe.AddIngredient(mod.ItemType<BrassBar>(), 2);
recipe.AddIngredient(ItemID.SuperManaPotion);
recipe.AddIngredient(ItemID.BottledWater);
recipe.AddIngredient(null, "NightmareBar", 5);
recipe.AddIngredient(mod.ItemType<NightmareBar>(), 5);
recipe.SetResult(this);
recipe.AddTile(13);
recipe.AddRecipe();
Expand Down

0 comments on commit 766d08d

Please sign in to comment.