Skip to content

Commit

Permalink
added mob drops
Browse files Browse the repository at this point in the history
  • Loading branch information
RenderBr committed Nov 16, 2022
1 parent 8efa1cc commit 3f569bc
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SimpleEcon/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using TShockAPI.DB;
using SimpleEcon;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace SimpleEcon
{
Expand Down Expand Up @@ -52,6 +53,9 @@ public void SaveAllPlayers()
}
}




public bool userExists(EconPlayer player)
{
using (var reader = _db.QueryReader("SELECT * FROM SimpleEcon WHERE Name = @0", player.name))
Expand Down
92 changes: 92 additions & 0 deletions SimpleEcon/SimpleEcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using TerrariaApi.Server;
using TShockAPI;
using TShockAPI.Hooks;
Expand Down Expand Up @@ -63,6 +64,7 @@ public override void Initialize()
ServerApi.Hooks.NetGreetPlayer.Register(this, PlayerJoin);
ServerApi.Hooks.ServerLeave.Register(this, PlayerLeave);
ServerApi.Hooks.GameInitialize.Register(this, Loaded);
ServerApi.Hooks.NetSendData.Register(this, NetHooks_SendData);
TShockAPI.Hooks.GeneralHooks.ReloadEvent += Reloaded;
}

Expand Down Expand Up @@ -91,6 +93,96 @@ public async void rewardsManager()
}
}

void NetHooks_SendData(SendDataEventArgs e)
{
if (e.MsgId == PacketTypes.NpcStrike)
{
NPC npc = Main.npc[e.number];
if (npc.life <= 0)
{
var player = TSPlayer.FindByNameOrID(e.ignoreClient.ToString());
Color color;

int totalGiven = 1;
color = Color.Gold;

if (npc.netID == NPCID.EyeofCthulhu)
{
totalGiven = 100;
color = Color.IndianRed;
}

if (npc.netID == NPCID.EaterofWorldsBody)
{
totalGiven = 150;
color = Color.MediumPurple;
}


if (npc.netID == NPCID.SkeletronHead)
{
totalGiven = 150;
color = Color.Gray;
}


if (npc.netID == NPCID.Skeleton)
{
totalGiven = 3;
color = Color.Gray;
}

if (npc.netID == NPCID.Pinky)
{
totalGiven = 1000;
color = Color.Pink;
}

if (npc.netID == NPCID.DemonEye)
{
totalGiven = 2;
color = Color.DarkRed;
}

if (npc.netID == NPCID.Zombie)
{
totalGiven = 2;
color = Color.DarkGreen;
}

if (npc.netID == NPCID.BlueSlime)
{
totalGiven = 1;
color = Color.Blue;
}

if (npc.netID == NPCID.GreenSlime)
{
totalGiven = 1;
color = Color.Green;
}

if (npc.netID == NPCID.RedSlime)
{
totalGiven = 1;
color = Color.Red;
}

PlayerManager.GetPlayer(player[0].Name).balance += totalGiven;
if (totalGiven == 1)
{
player[0].SendMessage("+ " + totalGiven + " " + config.currencyNameSingular + " from killing " + npc.FullName, color);
}
else
{
player[0].SendMessage("+ " + totalGiven + " " + config.currencyNamePlural + " from killing " + npc.FullName, color);
}

}
}
}


private void Balance(CommandArgs args)
{
EconPlayer player = PlayerManager.GetPlayer(args.Player.Name);
Expand Down

0 comments on commit 3f569bc

Please sign in to comment.