Merge pull request #1758 from Pryaxis/1.4-updates
Updating HandleProjectileNew
This commit is contained in:
commit
2e1c629fd9
4 changed files with 171 additions and 70 deletions
|
|
@ -99,7 +99,7 @@ namespace TShockAPI
|
||||||
byte plr = args.PlayerId;
|
byte plr = args.PlayerId;
|
||||||
BitsByte control = args.Control;
|
BitsByte control = args.Control;
|
||||||
BitsByte pulley = args.Pulley;
|
BitsByte pulley = args.Pulley;
|
||||||
byte item = args.Item;
|
byte item = args.SelectedItem ;
|
||||||
var pos = args.Position;
|
var pos = args.Position;
|
||||||
var vel = args.Velocity;
|
var vel = args.Velocity;
|
||||||
|
|
||||||
|
|
@ -183,6 +183,7 @@ namespace TShockAPI
|
||||||
/// <param name="args">The packet arguments that the event has.</param>
|
/// <param name="args">The packet arguments that the event has.</param>
|
||||||
internal void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args)
|
internal void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args)
|
||||||
{
|
{
|
||||||
|
// TODO: Add checks on the new edit actions. ReplaceTile, ReplaceWall, TryKillTile, Acutate, PokeLogicGate, SlopePoundTile
|
||||||
EditAction action = args.Action;
|
EditAction action = args.Action;
|
||||||
int tileX = args.X;
|
int tileX = args.X;
|
||||||
int tileY = args.Y;
|
int tileY = args.Y;
|
||||||
|
|
@ -795,6 +796,17 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (stabProjectile.ContainsKey(type))
|
||||||
|
{
|
||||||
|
if (stabProjectile[type] == args.Player.TPlayer.HeldItem.type)
|
||||||
|
{
|
||||||
|
args.Handled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Main.projHostile contains projectiles that can harm players
|
// Main.projHostile contains projectiles that can harm players
|
||||||
// without PvP enabled and belong to enemy mobs, so they shouldn't be
|
// without PvP enabled and belong to enemy mobs, so they shouldn't be
|
||||||
// possible for players to create. (Source: Ijwu, QuiCM)
|
// possible for players to create. (Source: Ijwu, QuiCM)
|
||||||
|
|
@ -1284,7 +1296,7 @@ namespace TShockAPI
|
||||||
internal void OnPlayerBuff(object sender, GetDataHandlers.PlayerBuffEventArgs args)
|
internal void OnPlayerBuff(object sender, GetDataHandlers.PlayerBuffEventArgs args)
|
||||||
{
|
{
|
||||||
byte id = args.ID;
|
byte id = args.ID;
|
||||||
byte type = args.Type;
|
int type = args.Type;
|
||||||
int time = args.Time;
|
int time = args.Time;
|
||||||
|
|
||||||
if (TShock.Players[id] == null)
|
if (TShock.Players[id] == null)
|
||||||
|
|
@ -1341,7 +1353,7 @@ namespace TShockAPI
|
||||||
internal void OnNPCAddBuff(object sender, GetDataHandlers.NPCAddBuffEventArgs args)
|
internal void OnNPCAddBuff(object sender, GetDataHandlers.NPCAddBuffEventArgs args)
|
||||||
{
|
{
|
||||||
short id = args.ID;
|
short id = args.ID;
|
||||||
byte type = args.Type;
|
int type = args.Type;
|
||||||
short time = args.Time;
|
short time = args.Time;
|
||||||
|
|
||||||
if (id >= Main.npc.Length)
|
if (id >= Main.npc.Length)
|
||||||
|
|
@ -1856,7 +1868,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Dictionary<byte, short> NPCAddBuffTimeMax = new Dictionary<byte, short>()
|
private static Dictionary<int, short> NPCAddBuffTimeMax = new Dictionary<int, short>()
|
||||||
{
|
{
|
||||||
{ BuffID.Poisoned, 3600 },
|
{ BuffID.Poisoned, 3600 },
|
||||||
{ BuffID.OnFire, 1200 },
|
{ BuffID.OnFire, 1200 },
|
||||||
|
|
@ -1921,5 +1933,18 @@ namespace TShockAPI
|
||||||
TileID.Campfire
|
TileID.Campfire
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static Dictionary<int, int> stabProjectile = new Dictionary<int, int>()
|
||||||
|
{
|
||||||
|
{ ProjectileID.GladiusStab, ItemID.Gladius },
|
||||||
|
{ ProjectileID.RulerStab, ItemID.Ruler },
|
||||||
|
{ ProjectileID.CopperShortswordStab, ItemID.CopperShortsword },
|
||||||
|
{ ProjectileID.TinShortswordStab, ItemID.TinShortsword },
|
||||||
|
{ ProjectileID.IronShortswordStab, ItemID.IronShortsword },
|
||||||
|
{ ProjectileID.LeadShortswordStab, ItemID.LeadShortsword },
|
||||||
|
{ ProjectileID.SilverShortswordStab, ItemID.SilverShortsword },
|
||||||
|
{ ProjectileID.TungstenShortswordStab, ItemID.TungstenShortsword },
|
||||||
|
{ ProjectileID.GoldShortswordStab, ItemID.GoldShortsword },
|
||||||
|
{ ProjectileID.PlatinumShortswordStab, ItemID.PlatinumShortsword }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -307,25 +307,44 @@ namespace TShockAPI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Control { get; set; }
|
public byte Control { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Selected item
|
/// Pulley update (BitFlags)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Item { get; set; }
|
public byte Pulley { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Position of the player
|
/// Misc (BitFlags) Check tshock.readme.io
|
||||||
|
/// </summary>
|
||||||
|
public byte Misc { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// (BitFlags) Wether or not the player is sleeping.
|
||||||
|
/// </summary>
|
||||||
|
public byte Sleeping { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The selected item in player's hand.
|
||||||
|
/// </summary>
|
||||||
|
public byte SelectedItem { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Position of the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 Position { get; set; }
|
public Vector2 Position { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Velocity of the player
|
/// Velocity of the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 Velocity { get; set; }
|
public Vector2 Velocity { get; set; }
|
||||||
/// <summary>Pulley update (BitFlags)</summary>
|
/// <summary>
|
||||||
public byte Pulley { get; set; }
|
/// Original poisition of the player when using Potion of Return.
|
||||||
|
/// </summary>
|
||||||
|
public Vector2? OriginalPos { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Home Position of the player for Potion of Return.
|
||||||
|
/// </summary>
|
||||||
|
public Vector2? HomePos { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PlayerUpdate - When the player sends it's updated information to the server
|
/// PlayerUpdate - When the player sends it's updated information to the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HandlerList<PlayerUpdateEventArgs> PlayerUpdate = new HandlerList<PlayerUpdateEventArgs>();
|
public static HandlerList<PlayerUpdateEventArgs> PlayerUpdate = new HandlerList<PlayerUpdateEventArgs>();
|
||||||
private static bool OnPlayerUpdate(TSPlayer player, MemoryStream data, byte plr, byte control, byte item, Vector2 position, Vector2 velocity, byte pulley)
|
private static bool OnPlayerUpdate(TSPlayer player, MemoryStream data, byte plr, byte control, byte pulley, byte misc, byte sleeping, byte selectedItem, Vector2 position, Vector2 velocity, Vector2? originalPos, Vector2? homePos)
|
||||||
{
|
{
|
||||||
if (PlayerUpdate == null)
|
if (PlayerUpdate == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -336,10 +355,14 @@ namespace TShockAPI
|
||||||
Data = data,
|
Data = data,
|
||||||
PlayerId = plr,
|
PlayerId = plr,
|
||||||
Control = control,
|
Control = control,
|
||||||
Item = item,
|
Pulley = pulley,
|
||||||
|
Misc = misc,
|
||||||
|
Sleeping = sleeping,
|
||||||
|
SelectedItem = selectedItem,
|
||||||
Position = position,
|
Position = position,
|
||||||
Velocity = velocity,
|
Velocity = velocity,
|
||||||
Pulley = pulley
|
OriginalPos = originalPos,
|
||||||
|
HomePos = homePos
|
||||||
};
|
};
|
||||||
PlayerUpdate.Invoke(null, args);
|
PlayerUpdate.Invoke(null, args);
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
|
|
@ -746,12 +769,21 @@ namespace TShockAPI
|
||||||
/// Y location of the player's spawn
|
/// Y location of the player's spawn
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int SpawnY { get; set; }
|
public int SpawnY { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Value of the timer countdown before the player can respawn alive.
|
||||||
|
/// If > 0, then player is still dead.
|
||||||
|
/// </summary>
|
||||||
|
public int RespawnTimer { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Context of where the player is spawning from.
|
||||||
|
/// </summary>
|
||||||
|
public PlayerSpawnContext SpawnContext { get; set; }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PlayerSpawn - When a player spawns
|
/// PlayerSpawn - When a player spawns
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HandlerList<SpawnEventArgs> PlayerSpawn = new HandlerList<SpawnEventArgs>();
|
public static HandlerList<SpawnEventArgs> PlayerSpawn = new HandlerList<SpawnEventArgs>();
|
||||||
private static bool OnPlayerSpawn(TSPlayer player, MemoryStream data, byte pid, int spawnX, int spawnY)
|
private static bool OnPlayerSpawn(TSPlayer player, MemoryStream data, byte pid, int spawnX, int spawnY, int respawnTimer, PlayerSpawnContext spawnContext)
|
||||||
{
|
{
|
||||||
if (PlayerSpawn == null)
|
if (PlayerSpawn == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -763,6 +795,8 @@ namespace TShockAPI
|
||||||
PlayerId = pid,
|
PlayerId = pid,
|
||||||
SpawnX = spawnX,
|
SpawnX = spawnX,
|
||||||
SpawnY = spawnY,
|
SpawnY = spawnY,
|
||||||
|
RespawnTimer = respawnTimer,
|
||||||
|
SpawnContext = spawnContext
|
||||||
};
|
};
|
||||||
PlayerSpawn.Invoke(null, args);
|
PlayerSpawn.Invoke(null, args);
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
|
|
@ -910,7 +944,7 @@ namespace TShockAPI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BitsByte Zone3 { get; set; }
|
public BitsByte Zone3 { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 0 = Old One's Army
|
/// 0 = Old One's Army, 1 = Granite, 2 = Marble, 3 = Hive, 4 = Gem Cave, 5 = Lihzhard Temple, 6 = Graveyard
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BitsByte Zone4 { get; set; }
|
public BitsByte Zone4 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -1181,7 +1215,7 @@ namespace TShockAPI
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Buff Type
|
/// Buff Type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Type { get; set; }
|
public int Type { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time the buff lasts
|
/// Time the buff lasts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1191,7 +1225,7 @@ namespace TShockAPI
|
||||||
/// NPCAddBuff - Called when a npc is buffed
|
/// NPCAddBuff - Called when a npc is buffed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HandlerList<NPCAddBuffEventArgs> NPCAddBuff = new HandlerList<NPCAddBuffEventArgs>();
|
public static HandlerList<NPCAddBuffEventArgs> NPCAddBuff = new HandlerList<NPCAddBuffEventArgs>();
|
||||||
private static bool OnNPCAddBuff(TSPlayer player, MemoryStream data, short id, byte type, short time)
|
private static bool OnNPCAddBuff(TSPlayer player, MemoryStream data, short id, int type, short time)
|
||||||
{
|
{
|
||||||
if (NPCAddBuff == null)
|
if (NPCAddBuff == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1220,7 +1254,7 @@ namespace TShockAPI
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Buff Type
|
/// Buff Type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Type { get; set; }
|
public int Type { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time the buff lasts
|
/// Time the buff lasts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1230,7 +1264,7 @@ namespace TShockAPI
|
||||||
/// PlayerBuff - Called when a player is buffed
|
/// PlayerBuff - Called when a player is buffed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static HandlerList<PlayerBuffEventArgs> PlayerBuff = new HandlerList<PlayerBuffEventArgs>();
|
public static HandlerList<PlayerBuffEventArgs> PlayerBuff = new HandlerList<PlayerBuffEventArgs>();
|
||||||
private static bool OnPlayerBuff(TSPlayer player, MemoryStream data, byte id, byte type, int time)
|
private static bool OnPlayerBuff(TSPlayer player, MemoryStream data, byte id, int type, int time)
|
||||||
{
|
{
|
||||||
if (PlayerBuff == null)
|
if (PlayerBuff == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -2006,11 +2040,13 @@ namespace TShockAPI
|
||||||
|
|
||||||
private static bool HandleSpawn(GetDataHandlerArgs args)
|
private static bool HandleSpawn(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var player = args.Data.ReadInt8();
|
byte player = args.Data.ReadInt8();
|
||||||
var spawnx = args.Data.ReadInt16();
|
short spawnx = args.Data.ReadInt16();
|
||||||
var spawny = args.Data.ReadInt16();
|
short spawny = args.Data.ReadInt16();
|
||||||
|
int respawnTimer = args.Data.ReadInt32();
|
||||||
|
PlayerSpawnContext context = (PlayerSpawnContext)args.Data.ReadByte();
|
||||||
|
|
||||||
if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny))
|
if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny, respawnTimer, context))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY)))
|
if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY)))
|
||||||
|
|
@ -2029,7 +2065,10 @@ namespace TShockAPI
|
||||||
args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48);
|
args.Player.Teleport(args.Player.sX * 16, (args.Player.sY * 16) - 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
args.Player.Dead = false;
|
if (respawnTimer > 0)
|
||||||
|
args.Player.Dead = true;
|
||||||
|
else
|
||||||
|
args.Player.Dead = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2040,34 +2079,45 @@ namespace TShockAPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte plr = args.Data.ReadInt8();
|
byte playerID = args.Data.ReadInt8();
|
||||||
BitsByte control = args.Data.ReadInt8();
|
BitsByte control = (BitsByte)args.Data.ReadByte();
|
||||||
BitsByte pulley = args.Data.ReadInt8();
|
BitsByte pulley = (BitsByte)args.Data.ReadByte();
|
||||||
byte item = args.Data.ReadInt8();
|
BitsByte misc = (BitsByte)args.Data.ReadByte();
|
||||||
var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
|
BitsByte sleeping = (BitsByte)args.Data.ReadByte();
|
||||||
var vel = Vector2.Zero;
|
byte selectedItem = args.Data.ReadInt8();
|
||||||
if (pulley[2])
|
Vector2 position = args.Data.ReadVector2();
|
||||||
vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
|
|
||||||
|
|
||||||
if (OnPlayerUpdate(args.Player, args.Data, plr, control, item, pos, vel, pulley))
|
Vector2 velocity = Vector2.Zero;
|
||||||
|
if (pulley[2]) // if UpdateVelocity
|
||||||
|
velocity = args.Data.ReadVector2();
|
||||||
|
|
||||||
|
Vector2? originalPosition = new Vector2?();
|
||||||
|
Vector2? homePosition = Vector2.Zero;
|
||||||
|
if (misc[6]) // if UsedPotionofReturn
|
||||||
|
{
|
||||||
|
originalPosition = new Vector2?(args.Data.ReadVector2());
|
||||||
|
homePosition = new Vector2?(args.Data.ReadVector2());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OnPlayerUpdate(args.Player, args.Data, playerID, control, pulley, misc, sleeping, selectedItem, position, velocity, originalPosition, homePosition))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (control[5])
|
if (control[5])
|
||||||
{
|
{
|
||||||
// Reimplementation of normal Terraria stuff?
|
// Reimplementation of normal Terraria stuff?
|
||||||
if (args.TPlayer.inventory[item].Name == "Mana Crystal" && args.Player.TPlayer.statManaMax <= 180)
|
if (args.TPlayer.inventory[selectedItem].Name == "Mana Crystal" && args.Player.TPlayer.statManaMax <= 180)
|
||||||
{
|
{
|
||||||
args.Player.TPlayer.statMana += 20;
|
args.Player.TPlayer.statMana += 20;
|
||||||
args.Player.TPlayer.statManaMax += 20;
|
args.Player.TPlayer.statManaMax += 20;
|
||||||
args.Player.PlayerData.maxMana += 20;
|
args.Player.PlayerData.maxMana += 20;
|
||||||
}
|
}
|
||||||
else if (args.TPlayer.inventory[item].Name == "Life Crystal" && args.Player.TPlayer.statLifeMax <= 380)
|
else if (args.TPlayer.inventory[selectedItem].Name == "Life Crystal" && args.Player.TPlayer.statLifeMax <= 380)
|
||||||
{
|
{
|
||||||
args.TPlayer.statLife += 20;
|
args.TPlayer.statLife += 20;
|
||||||
args.TPlayer.statLifeMax += 20;
|
args.TPlayer.statLifeMax += 20;
|
||||||
args.Player.PlayerData.maxHealth += 20;
|
args.Player.PlayerData.maxHealth += 20;
|
||||||
}
|
}
|
||||||
else if (args.TPlayer.inventory[item].Name == "Life Fruit" && args.Player.TPlayer.statLifeMax >= 400 && args.Player.TPlayer.statLifeMax <= 495)
|
else if (args.TPlayer.inventory[selectedItem].Name == "Life Fruit" && args.Player.TPlayer.statLifeMax >= 400 && args.Player.TPlayer.statLifeMax <= 495)
|
||||||
{
|
{
|
||||||
args.TPlayer.statLife += 5;
|
args.TPlayer.statLife += 5;
|
||||||
args.TPlayer.statLifeMax += 5;
|
args.TPlayer.statLifeMax += 5;
|
||||||
|
|
@ -2076,11 +2126,11 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Where we rebuild sync data for Terraria?
|
// Where we rebuild sync data for Terraria?
|
||||||
args.TPlayer.selectedItem = item;
|
args.TPlayer.selectedItem = selectedItem;
|
||||||
args.TPlayer.position = pos;
|
args.TPlayer.position = position;
|
||||||
args.TPlayer.oldVelocity = args.TPlayer.velocity;
|
args.TPlayer.oldVelocity = args.TPlayer.velocity;
|
||||||
args.TPlayer.velocity = vel;
|
args.TPlayer.velocity = velocity;
|
||||||
args.TPlayer.fallStart = (int)(pos.Y / 16f);
|
args.TPlayer.fallStart = (int)(position.Y / 16f);
|
||||||
args.TPlayer.controlUp = false;
|
args.TPlayer.controlUp = false;
|
||||||
args.TPlayer.controlDown = false;
|
args.TPlayer.controlDown = false;
|
||||||
args.TPlayer.controlLeft = false;
|
args.TPlayer.controlLeft = false;
|
||||||
|
|
@ -2199,17 +2249,17 @@ namespace TShockAPI
|
||||||
private static bool HandleTile(GetDataHandlerArgs args)
|
private static bool HandleTile(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
EditAction action = (EditAction)args.Data.ReadInt8();
|
EditAction action = (EditAction)args.Data.ReadInt8();
|
||||||
var tileX = args.Data.ReadInt16();
|
short tileX = args.Data.ReadInt16();
|
||||||
var tileY = args.Data.ReadInt16();
|
short tileY = args.Data.ReadInt16();
|
||||||
var editData = args.Data.ReadInt16();
|
short editData = args.Data.ReadInt16();
|
||||||
EditType type = (action == EditAction.KillTile || action == EditAction.KillWall ||
|
EditType type = (action == EditAction.KillTile || action == EditAction.KillWall ||
|
||||||
action == EditAction.KillTileNoItem)
|
action == EditAction.KillTileNoItem || action == EditAction.TryKillTile)
|
||||||
? EditType.Fail
|
? EditType.Fail
|
||||||
: (action == EditAction.PlaceTile || action == EditAction.PlaceWall)
|
: (action == EditAction.PlaceTile || action == EditAction.PlaceWall || action == EditAction.ReplaceTile || action == EditAction.ReplaceWall)
|
||||||
? EditType.Type
|
? EditType.Type
|
||||||
: EditType.Slope;
|
: EditType.Slope;
|
||||||
|
|
||||||
var style = args.Data.ReadInt8();
|
byte style = args.Data.ReadInt8();
|
||||||
|
|
||||||
if (OnTileEdit(args.Player, args.Data, tileX, tileY, action, type, editData, style))
|
if (OnTileEdit(args.Player, args.Data, tileX, tileY, action, type, editData, style))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2296,23 +2346,21 @@ namespace TShockAPI
|
||||||
private static bool HandleProjectileNew(GetDataHandlerArgs args)
|
private static bool HandleProjectileNew(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
short ident = args.Data.ReadInt16();
|
short ident = args.Data.ReadInt16();
|
||||||
var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
|
Vector2 pos = args.Data.ReadVector2();
|
||||||
var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
|
Vector2 vel = args.Data.ReadVector2();
|
||||||
float knockback = args.Data.ReadSingle();
|
|
||||||
short dmg = args.Data.ReadInt16();
|
|
||||||
byte owner = args.Data.ReadInt8();
|
byte owner = args.Data.ReadInt8();
|
||||||
short type = args.Data.ReadInt16();
|
short type = args.Data.ReadInt16();
|
||||||
BitsByte bits = args.Data.ReadInt8();
|
BitsByte bits = (BitsByte)args.Data.ReadByte();
|
||||||
//owner = (byte)args.Player.Index;
|
|
||||||
float[] ai = new float[Projectile.maxAI];
|
float[] ai = new float[Projectile.maxAI];
|
||||||
|
for (int i = 0; i < Projectile.maxAI; ++i)
|
||||||
|
ai[i] = !bits[i] ? 0.0f : args.Data.ReadSingle();
|
||||||
|
short dmg = bits[4] ? args.Data.ReadInt16() : (short)0;
|
||||||
|
float knockback = bits[5] ? args.Data.ReadSingle() : 0.0f;
|
||||||
|
short origDmg = bits[6] ? args.Data.ReadInt16() : (short)0;
|
||||||
|
short projUUID = bits[7] ? args.Data.ReadInt16() : (short)-1;
|
||||||
|
if (projUUID >= 1000)
|
||||||
|
projUUID = -1;
|
||||||
|
|
||||||
for (int i = 0; i < Projectile.maxAI; i++)
|
|
||||||
{
|
|
||||||
if (bits[i])
|
|
||||||
ai[i] = args.Data.ReadSingle();
|
|
||||||
else
|
|
||||||
ai[i] = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = TShock.Utils.SearchProjectile(ident, owner);
|
var index = TShock.Utils.SearchProjectile(ident, owner);
|
||||||
|
|
||||||
|
|
@ -2666,7 +2714,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
for (int i = 0; i < Terraria.Player.maxBuffs; i++)
|
for (int i = 0; i < Terraria.Player.maxBuffs; i++)
|
||||||
{
|
{
|
||||||
var buff = args.Data.ReadInt8();
|
var buff = args.Data.ReadUInt16();
|
||||||
|
|
||||||
if (buff == 10 && TShock.Config.DisableInvisPvP && args.TPlayer.hostile)
|
if (buff == 10 && TShock.Config.DisableInvisPvP && args.TPlayer.hostile)
|
||||||
buff = 0;
|
buff = 0;
|
||||||
|
|
@ -2717,7 +2765,7 @@ namespace TShockAPI
|
||||||
private static bool HandleNPCAddBuff(GetDataHandlerArgs args)
|
private static bool HandleNPCAddBuff(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var id = args.Data.ReadInt16();
|
var id = args.Data.ReadInt16();
|
||||||
var type = args.Data.ReadInt8();
|
var type = args.Data.ReadUInt16();
|
||||||
var time = args.Data.ReadInt16();
|
var time = args.Data.ReadInt16();
|
||||||
|
|
||||||
if (OnNPCAddBuff(args.Player, args.Data, id, type, time))
|
if (OnNPCAddBuff(args.Player, args.Data, id, type, time))
|
||||||
|
|
@ -2729,7 +2777,7 @@ namespace TShockAPI
|
||||||
private static bool HandlePlayerAddBuff(GetDataHandlerArgs args)
|
private static bool HandlePlayerAddBuff(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var id = args.Data.ReadInt8();
|
var id = args.Data.ReadInt8();
|
||||||
var type = args.Data.ReadInt8();
|
var type = args.Data.ReadUInt16();
|
||||||
var time = args.Data.ReadInt32();
|
var time = args.Data.ReadInt32();
|
||||||
|
|
||||||
if (OnPlayerBuff(args.Player, args.Data, id, type, time))
|
if (OnPlayerBuff(args.Player, args.Data, id, type, time))
|
||||||
|
|
@ -3358,7 +3406,13 @@ namespace TShockAPI
|
||||||
SlopeTile,
|
SlopeTile,
|
||||||
FrameTrack,
|
FrameTrack,
|
||||||
PlaceWire4,
|
PlaceWire4,
|
||||||
KillWire4
|
KillWire4,
|
||||||
|
PokeLogicGate,
|
||||||
|
Acutate,
|
||||||
|
TryKillTile,
|
||||||
|
ReplaceTile,
|
||||||
|
ReplaceWall,
|
||||||
|
SlopePoundTile
|
||||||
}
|
}
|
||||||
public enum EditType
|
public enum EditType
|
||||||
{
|
{
|
||||||
|
|
@ -3366,7 +3420,6 @@ namespace TShockAPI
|
||||||
Type,
|
Type,
|
||||||
Slope,
|
Slope,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum place styles for each tile.
|
/// The maximum place styles for each tile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -156,9 +156,9 @@ namespace TShockAPI
|
||||||
DisableFlags disableFlags = TShock.Config.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
DisableFlags disableFlags = TShock.Config.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
|
||||||
bool useItem = ((BitsByte) args.Control)[5];
|
bool useItem = ((BitsByte) args.Control)[5];
|
||||||
TSPlayer player = args.Player;
|
TSPlayer player = args.Player;
|
||||||
string itemName = player.TPlayer.inventory[args.Item].Name;
|
string itemName = player.TPlayer.inventory[args.SelectedItem].Name;
|
||||||
|
|
||||||
if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[args.Item].netID), args.Player))
|
if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[args.SelectedItem].netID), args.Player))
|
||||||
{
|
{
|
||||||
player.TPlayer.controlUseItem = false;
|
player.TPlayer.controlUseItem = false;
|
||||||
player.Disable($"holding banned item: {itemName}", disableFlags);
|
player.Disable($"holding banned item: {itemName}", disableFlags);
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,8 @@ namespace TShockAPI
|
||||||
Item[] piggy = TPlayer.bank.item;
|
Item[] piggy = TPlayer.bank.item;
|
||||||
Item[] safe = TPlayer.bank2.item;
|
Item[] safe = TPlayer.bank2.item;
|
||||||
Item[] forge = TPlayer.bank3.item;
|
Item[] forge = TPlayer.bank3.item;
|
||||||
|
Item[] voidVault = TPlayer.bank4.item;
|
||||||
|
|
||||||
Item trash = TPlayer.trashItem;
|
Item trash = TPlayer.trashItem;
|
||||||
for (int i = 0; i < NetItem.MaxInventory; i++)
|
for (int i = 0; i < NetItem.MaxInventory; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -507,7 +509,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (i < NetItem.TrashIndex.Item2)
|
else if (i < NetItem.TrashIndex.Item2)
|
||||||
{
|
{
|
||||||
// 179-219
|
// 178-179
|
||||||
Item item = new Item();
|
Item item = new Item();
|
||||||
if (trash != null && trash.netID != 0)
|
if (trash != null && trash.netID != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -525,9 +527,9 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (i < NetItem.ForgeIndex.Item2)
|
||||||
{
|
{
|
||||||
// 220
|
// 179-220
|
||||||
var index = i - NetItem.ForgeIndex.Item1;
|
var index = i - NetItem.ForgeIndex.Item1;
|
||||||
Item item = new Item();
|
Item item = new Item();
|
||||||
if (forge[index] != null && forge[index].netID != 0)
|
if (forge[index] != null && forge[index].netID != 0)
|
||||||
|
|
@ -545,8 +547,29 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (i < NetItem.VoidIndex.Item2)
|
||||||
|
{
|
||||||
|
// 220-260
|
||||||
|
var index = i - NetItem.VoidIndex.Item1;
|
||||||
|
Item item = new Item();
|
||||||
|
if (voidVault[index] != null && voidVault[index].netID != 0)
|
||||||
|
{
|
||||||
|
item.netDefaults(voidVault[index].netID);
|
||||||
|
item.Prefix(voidVault[index].prefix);
|
||||||
|
item.AffixName();
|
||||||
|
|
||||||
|
if (voidVault[index].stack > item.maxStack || voidVault[index].stack < 0)
|
||||||
|
{
|
||||||
|
check = true;
|
||||||
|
if (shouldWarnPlayer)
|
||||||
|
{
|
||||||
|
SendErrorMessage("Stack cheat detected. Remove Void Vault item {0} ({1}) and then rejoin.", item.Name, voidVault[index].stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return check;
|
return check;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue