Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
1.0.1! (hopefully?)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilysen committed Aug 17, 2019
1 parent 3be6cb7 commit 871898e
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 273 deletions.
102 changes: 63 additions & 39 deletions ChallengeRunes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace ChallengeRunes
Expand All @@ -15,6 +18,11 @@ public ChallengeRunes()
};
}

public static Dictionary<Player, string> armageddon = new Dictionary<Player, string>();
public static Dictionary<Player, string> defiled = new Dictionary<Player, string>();
public static Dictionary<Player, string> frozen = new Dictionary<Player, string>();
public static Dictionary<Player, string> scorched = new Dictionary<Player, string>();

public static void NewText(Player player, string text, byte r, byte g, byte b)
{
if (player.whoAmI == Main.myPlayer)
Expand All @@ -23,57 +31,73 @@ public static void NewText(Player player, string text, byte r, byte g, byte b)
}
}

public static bool IsChallenger(Player player)
{
return player.whoAmI == Main.myPlayer;
}

private bool armageddonActive;
private bool defiledActive;
private bool frozenActive; // LET IT GOOO
private bool scorchedActive;

private bool apocalypse;

public bool Armageddon(bool checkOnly = false)
public static bool AntiCheese(Player player)
{
if(!checkOnly)
armageddonActive = !armageddonActive;
return armageddonActive;
}

public bool Defiled(bool checkOnly = false)
{
if (!checkOnly)
defiledActive = !defiledActive;
return defiledActive;
foreach (NPC npc in Main.npc)
{
if (npc.boss && npc.active)
{
PlayerDeathReason runeDeath = PlayerDeathReason.ByCustomReason(player.name + " defied the runes.");
Main.PlaySound(SoundID.NPCDeath59.WithVolume(0.5f), player.Center);
player.KillMe(runeDeath, 1.0, 0, false);
return true;
}
}
return false;
}

public bool Frozen(bool checkOnly = false)
public static bool CheckRune(Player p, string runeKey)
{
if (!checkOnly)
frozenActive = !frozenActive;
return frozenActive;
switch (runeKey)
{
case "armageddon":
return armageddon.TryGetValue(p, out _);
case "defiled":
return defiled.TryGetValue(p, out _);
case "frozen":
return frozen.TryGetValue(p, out _);
case "scorched":
return scorched.TryGetValue(p, out _);
}
return false;
}

public bool Scorched(bool checkOnly = false)
public static void SetRune(Player p, string runeKey)
{
if (!checkOnly)
scorchedActive = !scorchedActive;
return scorchedActive;
switch (runeKey)
{
case "armageddon":
armageddon.Add(p, runeKey);
break;
case "defiled":
defiled.Add(p, runeKey);
break;
case "frozen":
frozen.Add(p, runeKey);
break;
case "scorched":
scorched.Add(p, runeKey);
break;
}
}

public bool Apocalypse(bool checkOnly = false)
public static void RemoveRune(Player p, string runeKey)
{
if (!checkOnly)
switch (runeKey)
{
apocalypse = !apocalypse;
armageddonActive = apocalypse;
defiledActive = apocalypse;
frozenActive = apocalypse;
scorchedActive = apocalypse;
case "armageddon":
armageddon.Remove(p);
break;
case "defiled":
defiled.Remove(p);
break;
case "frozen":
frozen.Remove(p);
break;
case "scorched":
scorched.Remove(p);
break;
}
return apocalypse;
}
}
}
57 changes: 23 additions & 34 deletions ChallengeRunesPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,74 +10,63 @@ public class ChallengeRunesPlayer : ModPlayer
{
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
{
if (ChallengeRunes.IsChallenger(player))
bool armageddon = ChallengeRunes.CheckRune(player, "armageddon");
bool defiled = ChallengeRunes.CheckRune(player, "defiled");
if (armageddon)
{
ChallengeRunes crMod = (ChallengeRunes)mod;
bool armageddon = crMod.Armageddon(true);
bool defiled = crMod.Defiled(true);
if (armageddon)
foreach (NPC npc in Main.npc)
{
foreach (NPC npc in Main.npc)
if (npc.boss && npc.active)
{
if (npc.boss && npc.active)
{
PlayerDeathReason armageddonDeath = PlayerDeathReason.ByCustomReason(player.name + " didn't survive Armageddon.");
Main.PlaySound(SoundID.NPCDeath59.WithVolume(0.5f), player.Center);
player.KillMe(armageddonDeath, 1.0, 0, false);
}
PlayerDeathReason armageddonDeath = PlayerDeathReason.ByCustomReason(player.name + " failed Armageddon.");
Main.PlaySound(SoundID.NPCDeath59.WithVolume(0.5f), player.Center);
player.KillMe(armageddonDeath, 1.0, 0, false);
ChallengeRunes.RemoveRune(player, "armageddon");
}
}
if (defiled && damageSource.SourceNPCIndex > 0)
{
damage *= 2;
}
}
if (defiled && damageSource.SourceNPCIndex > 0)
{
damage *= 2;
}
return base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource);
}

public override void PostUpdateBuffs()
{
if (ChallengeRunes.IsChallenger(player))
if(ChallengeRunes.CheckRune(player, "frozen"))
player.allDamageMult *= 0.5f;
if(ChallengeRunes.CheckRune(player, "scorched"))
{
ChallengeRunes crMod = (ChallengeRunes)mod;
if (crMod.Frozen(true))
{
player.allDamageMult *= 0.5f;
}
if (crMod.Scorched(true))
{
player.lifeRegen = 0;
player.lifeRegenCount = 0;
player.lifeRegenTime = 0;
}
EmitDusts(crMod);
player.lifeRegen = 0;
}
EmitDusts();
}

public void EmitDusts(ChallengeRunes crMod)
public void EmitDusts()
{
if (crMod.Armageddon(true))
if (ChallengeRunes.CheckRune(player, "armageddon"))
{
if (Main.rand.Next(0, 15) == 0)
{
Dust.NewDust(player.Center, 5, 5, 264, -0.5f, 0, 0, new Color(255, 0, 255), 1f);
}
}
if (crMod.Defiled(true))
if (ChallengeRunes.CheckRune(player, "defiled"))
{
if (Main.rand.Next(0, 15) == 0)
{
Dust.NewDust(player.Center, 5, 5, 264, -0.25f, 0, 0, new Color(0, 255, 0), 1f);
}
}
if (crMod.Frozen(true))
if (ChallengeRunes.CheckRune(player, "frozen"))
{
if (Main.rand.Next(0, 15) == 0)
{
Dust.NewDust(player.Center, 5, 5, 264, 0.25f, 0, 0, new Color(135, 245, 255), 1f);
}
}
if (crMod.Scorched(true))
if (ChallengeRunes.CheckRune(player, "scorched"))
{
if (Main.rand.Next(0, 15) == 0)
{
Expand Down
63 changes: 0 additions & 63 deletions Items/ApocalypseSigil.cs

This file was deleted.

Binary file removed Items/ApocalypseSigil.png
Binary file not shown.
37 changes: 14 additions & 23 deletions Items/ArmageddonRune.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

Expand All @@ -10,10 +9,10 @@ public class ArmageddonRune : ModItem
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Armageddon Rune");
Tooltip.SetDefault("A rune prophesying the end\n" +
"While active, bosses will instantly kill you\n" +
"Defeating a boss will yield five additional treasure bags\n" +
"Causes instant death if toggled while a boss is active");
Tooltip.SetDefault("While active, bosses will instantly kill you\n" +
"Defeating a boss will yield six additional treasure bags\n" +
"Causes instant death if toggled while a boss is active\n" +
"Deactivates upon death");
}

public override void SetDefaults()
Expand All @@ -28,32 +27,24 @@ public override void SetDefaults()
item.useStyle = 4;
}

public override bool CanUseItem(Player player)
{
if (ChallengeRunes.AntiCheese(player))
return false;
return true;
}

public override bool UseItem(Player player)
{
foreach (NPC npc in Main.npc)
{
if (npc.boss && npc.active)
{
PlayerDeathReason runeDeath = PlayerDeathReason.ByCustomReason(player.name + " defied the runes.");
Main.PlaySound(SoundID.NPCDeath59.WithVolume(0.5f), player.Center);
player.KillMe(runeDeath, 1.0, 0, false);
return true;
}
}
ChallengeRunes crMod = (ChallengeRunes)mod;
if(crMod.Apocalypse(true))
{
ChallengeRunes.NewText(player, "Apocalypse is active; disable that first.", 125, 125, 125);
return true;
}
bool arma = crMod.Armageddon();
if(arma)
if(!ChallengeRunes.CheckRune(player, "armageddon"))
{
ChallengeRunes.NewText(player, "Armageddon is now active.", 255, 0, 255);
ChallengeRunes.SetRune(player, "armageddon");
}
else
{
ChallengeRunes.NewText(player, "Armageddon is no longer active.", 255, 0, 255);
ChallengeRunes.RemoveRune(player, "armageddon");
}
return true;
}
Expand Down
Loading

0 comments on commit 871898e

Please sign in to comment.