-
Notifications
You must be signed in to change notification settings - Fork 3
/
PokeModBlue.cs
99 lines (87 loc) · 3.68 KB
/
PokeModBlue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using PokeModBlue.Items.Weapons;
using PokeModBlue.NPCs.Pokemon;
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.ModLoader;
namespace PokeModBlue {
public partial class PokeModBlue : Mod {
public static byte pokeSpawns = 1;
public static IDictionary<int, float> originalSpawnPool;
private double pressedSpawnToggleHotKeyTime;
public PokeModBlue() {
Properties = new ModProperties() {
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public override void Load() {
Pokedex.DoNothing();
RegisterHotKey("Activate/Deactivate Pokemon Spawns", "P");
}
public override void HotKeyPressed(string name) {
if (name == "Activate/Deactivate Pokemon Spawns") {
if (Math.Abs(Main.time - pressedSpawnToggleHotKeyTime) > 60) {
pressedSpawnToggleHotKeyTime = Main.time;
if (pokeSpawns == 1) {
pokeSpawns = 2;
Main.NewText("Only Mod NPCs Spawn");
} else if (pokeSpawns == 2) {
pokeSpawns = 3;
Main.NewText("Only Normal NPCs Spawn");
} else if (pokeSpawns == 3) {
pokeSpawns = 4;
Main.NewText("Only Pokemon Spawn");
} else if (pokeSpawns == 4) {
pokeSpawns = 1;
Main.NewText("All NPCs Spawn");
}
}
}
}
private void PokedexCommand(string[] args) {
int id;
if (args.Length == 0 || !Int32.TryParse(args[0], out id)) {
Main.NewText("Usage: /pokedex [number]");
Main.NewText("Input the number as the National Pokedex number");
return;
} else {
PokedexEntry entry;
if (Pokedex.pokedex.TryGetValue((float)id, out entry)) {
Main.NewText(entry.Print());
} else {
Main.NewText("No Pokemon found by that ID");
}
}
}
public override void HandlePacket(BinaryReader reader, int whoAmI) {
PokeModMessageType msgType = (PokeModMessageType)reader.ReadByte();
switch (msgType) {
// This message sent by the player when they load to initialize the custom Pokemon Weapon Data for all players
case PokeModMessageType.SetPokemonWeaponData:
break;
case PokeModMessageType.SummonPokemon:
int npc = NPC.NewNPC(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
Main.npc[npc].releaseOwner = reader.ReadByte();
Main.npc[npc].life = reader.ReadInt32();
PokemonNPC pokemon = Main.npc[npc].modNPC as PokemonNPC;
if (pokemon != null) {
PokemonWeapon pokemonWeapon = Main.player[Main.npc[npc].releaseOwner].inventory[Main.player[Main.npc[npc].releaseOwner].selectedItem].modItem as PokemonWeapon;
if (pokemonWeapon != null) {
pokemon.pokemon = pokemonWeapon;
}
}
break;
default:
ErrorLogger.Log("PokeMod: Unknown Message type: " + msgType);
break;
}
}
}
internal enum PokeModMessageType : byte {
SetPokemonWeaponData,
SummonPokemon,
}
}