internal bool InvokeNpcLootDrop( ref int x, ref int y, ref int w, ref int h, ref int itemId, ref int stack, ref bool broadcast, ref int prefix, int npcId, int npcArrayIndex, ref bool nodelay) { NpcLootDropEventArgs args = new NpcLootDropEventArgs { X = x, Y = y, Width = w, Height = h, ItemId = itemId, Stack = stack, Broadcast = broadcast, Prefix = prefix, NpcId = npcId, NpcArrayIndex = npcArrayIndex, NoGrabDelay = nodelay }; this.NpcLootDrop.Invoke(args); x = args.X; y = args.Y; w = args.Width; h = args.Height; itemId = args.ItemId; stack = args.Stack; broadcast = args.Broadcast; prefix = args.Prefix; nodelay = args.NoGrabDelay; return(args.Handled); }
internal bool InvokeNpcLootDrop( ref Vector2 position, ref int w, ref int h, ref int itemId, ref int stack, ref bool broadcast, ref int prefix, int npcId, int npcArrayIndex, ref bool nodelay, ref bool reverseLookup) { NpcLootDropEventArgs args = new NpcLootDropEventArgs { Position = position, Width = w, Height = h, ItemId = itemId, Stack = stack, Broadcast = broadcast, Prefix = prefix, NpcId = npcId, NpcArrayIndex = npcArrayIndex, NoGrabDelay = nodelay, ReverseLookup = reverseLookup }; this.NpcLootDrop.Invoke(args); position = args.Position; w = args.Width; h = args.Height; itemId = args.ItemId; stack = args.Stack; broadcast = args.Broadcast; prefix = args.Prefix; nodelay = args.NoGrabDelay; return(args.Handled); }
internal bool InvokeNpcLootDrop( ref Vector2 position, ref int w, ref int h, ref int itemId, ref int stack, ref bool broadcast, ref int prefix, int npcId, int npcArrayIndex, ref bool nodelay, ref bool reverseLookup) { NpcLootDropEventArgs args = new NpcLootDropEventArgs { Position = position, Width = w, Height = h, ItemId = itemId, Stack = stack, Broadcast = broadcast, Prefix = prefix, NpcId = npcId, NpcArrayIndex = npcArrayIndex, NoGrabDelay = nodelay, ReverseLookup = reverseLookup }; this.NpcLootDrop.Invoke(args); position = args.Position; w = args.Width; h = args.Height; itemId = args.ItemId; stack = args.Stack; broadcast = args.Broadcast; prefix = args.Prefix; nodelay = args.NoGrabDelay; return args.Handled; }
internal bool InvokeNpcLootDrop( ref int x, ref int y, ref int w, ref int h, ref int itemId, ref int stack, ref bool broadcast, ref int prefix, int npcId, int npcArrayIndex, ref bool nodelay) { NpcLootDropEventArgs args = new NpcLootDropEventArgs { X = x, Y = y, Width = w, Height = h, ItemId = itemId, Stack = stack, Broadcast = broadcast, Prefix = prefix, NpcId = npcId, NpcArrayIndex = npcArrayIndex, NoGrabDelay = nodelay }; this.NpcLootDrop.Invoke(args); x = args.X; y = args.Y; w = args.Width; h = args.Height; itemId = args.ItemId; stack = args.Stack; broadcast = args.Broadcast; prefix = args.Prefix; nodelay = args.NoGrabDelay; return args.Handled; }
private void OnLootDrop(NpcLootDropEventArgs args) { //Debug print //Console.WriteLine("{0}[{1}]: ({2}, {3}) - Item:{4}", args.NPCID, args.NPCArrayIndex, args.X, args.Y, // args.ItemID); if (config.LootReplacements.ContainsKey(args.NpcId)) { DropReplacement repl = config.LootReplacements[args.NpcId]; if (Main.bloodMoon && repl.drops.ContainsKey(State.Bloodmoon)) { foreach (Drop d in repl.drops[State.Bloodmoon]) { double rng = random.NextDouble(); if (d.chance >= rng) { var item = TShock.Utils.GetItemById(d.itemID); int stack = random.Next(d.low_stack, d.high_stack + 1); Item.NewItem((int)args.Position.X, (int)args.Position.Y, item.width, item.height, d.itemID, stack, args.Broadcast, d.prefix); args.Handled = true; if (!repl.tryEachItem) break; } } } if (Main.eclipse && repl.drops.ContainsKey(State.Eclipse)) { foreach (Drop d in repl.drops[State.Eclipse]) { double rng = random.NextDouble(); if (d.chance >= rng) { var item = TShock.Utils.GetItemById(d.itemID); int stack = random.Next(d.low_stack, d.high_stack + 1); Item.NewItem((int)args.Position.X, (int)args.Position.Y, item.width, item.height, d.itemID, stack, args.Broadcast, d.prefix); args.Handled = true; if (!repl.tryEachItem) break; } } } if (Main.moonPhase == 0 && !Main.dayTime && repl.drops.ContainsKey(State.Fullmoon)) { foreach (Drop d in repl.drops[State.Fullmoon]) { double rng = random.NextDouble(); if (d.chance >= rng) { var item = TShock.Utils.GetItemById(d.itemID); int stack = random.Next(d.low_stack, d.high_stack + 1); Item.NewItem((int)args.Position.X, (int)args.Position.Y, item.width, item.height, d.itemID, stack, args.Broadcast, d.prefix); args.Handled = true; if (!repl.tryEachItem) break; } } } if (!Main.dayTime && repl.drops.ContainsKey(State.Night)) { foreach (Drop d in repl.drops[State.Night]) { double rng = random.NextDouble(); if (d.chance >= rng) { var item = TShock.Utils.GetItemById(d.itemID); int stack = random.Next(d.low_stack, d.high_stack + 1); Item.NewItem((int)args.Position.X, (int)args.Position.Y, item.width, item.height, d.itemID, stack, args.Broadcast, d.prefix); args.Handled = true; if (!repl.tryEachItem) break; } } } if (Main.dayTime && repl.drops.ContainsKey(State.Day)) { foreach (Drop d in repl.drops[State.Day]) { double rng = random.NextDouble(); if (d.chance >= rng) { var item = TShock.Utils.GetItemById(d.itemID); int stack = random.Next(d.low_stack, d.high_stack + 1); Item.NewItem((int)args.Position.X, (int)args.Position.Y, item.width, item.height, d.itemID, stack, args.Broadcast, d.prefix); args.Handled = true; if (!repl.tryEachItem) break; } } } if (repl.drops.ContainsKey(State.Normal)) { foreach (Drop d in repl.drops[State.Normal]) { double rng = random.NextDouble(); if (d.chance >= rng) { var item = TShock.Utils.GetItemById(d.itemID); int stack = random.Next(d.low_stack, d.high_stack + 1); Item.NewItem((int)args.Position.X, (int)args.Position.Y, item.width, item.height, d.itemID, stack, args.Broadcast, d.prefix); args.Handled = true; if (!repl.tryEachItem) break; } } } if (!repl.alsoDropDefaultLoot) args.Handled = true; } }
void OnNpcLootDrop(NpcLootDropEventArgs e) { Item item = TShock.Utils.GetItemById(e.ItemId); bool precious = itemsToWatch.Contains(e.ItemId); // If new item is watched and roll-off is enabled if (rollOnLoot && precious) { // Build item manually since we will not let the game process the drop item.SetDefaults(e.ItemId, false); item.Prefix(e.Prefix); item.stack = e.Stack; // Add to roll off items itemsToRoll.Add(item); if (itemsToRoll.Count == 1) TSPlayer.All.SendMessage(string.Format("Loot: {0} ({1}). Type /roll for this item", item.AffixName(),item.stack), Color.Pink); else TSPlayer.All.SendMessage(string.Format("{0} ({1}) added to loot roll queue.", item.AffixName(),item.stack), Color.LightPink); e.Handled = true; } }
/// <summary> /// NpcLootDrop callback. /// </summary> /// <param name="args"></param> private void OnNpcLootDrop(NpcLootDropEventArgs args) { lock (this.m_AddonsLock) { this.m_Addons.ForEach(a => { var ret = a.Value.InvokeEvent("NpcLootDrop", args); if (ret != null && ret.Length >= 1) { bool result; if (bool.TryParse(ret[0].ToString(), out result) && result) args.Handled = true; } }); } }