/// <summary> /// Do the combine. /// </summary> /// <param name="target"></param> /// <param name="effectiveness"></param> public override void ApplyEffectOnTarget(GameLiving target, double effectiveness) { GamePlayer player = Caster as GamePlayer; if (player == null) { return; } InventoryItem useItem = player.UseItem; if (useItem == null || !ArtifactMgr.IsArtifactScroll(useItem)) { return; } WorldInventoryItem combinedScroll = WorldInventoryItem.CreateFromTemplate("artifact_scroll"); if (combinedScroll == null) { return; } combinedScroll.AddOwner(player); combinedScroll.Name = useItem.Name; combinedScroll.Item.Name = useItem.Name; var backpack = player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack); ArrayList removeItems = new ArrayList(); removeItems.Add(useItem); bool combinesToBook = false; foreach (InventoryItem item in backpack) { if (item == null) { continue; } if (ArtifactMgr.CanCombine(combinedScroll.Item, item)) { combinedScroll = ArtifactMgr.CombineScrolls(combinedScroll.Item, item, ref combinesToBook); removeItems.Add(item); if (combinesToBook) { break; } } } player.Out.SendSpellEffectAnimation(player, player, 1, 0, false, 1); Artifact artifact = ArtifactMgr.GetArtifact(combinedScroll.Item); if (artifact == null) { log.Warn(String.Format("Missing artifact for item '{0}'", combinedScroll.Name)); } else { String receiveMessage = (combinesToBook) ? artifact.MessageReceiveBook : artifact.MessageReceiveScrolls; player.Out.SendMessage(String.Format(receiveMessage, combinedScroll.Name, useItem.Name), eChatType.CT_Skill, eChatLoc.CL_SystemWindow); } if (player.ReceiveItem(player, combinedScroll)) { foreach (InventoryItem item in removeItems) { player.Inventory.RemoveItem(item); InventoryLogging.LogInventoryAction(player, "(ARTIFACT;CombineScrolls)", eInventoryActionType.Quest, item.Template, item.Count); } } }