/// <title>Saga.AddStep</title> /// <code> /// Saga.AddStep(cid, QuestID, StepId, State); /// </code> /// <description> /// Adds a step to the quest. This can only be done during initialisation. /// 0 = Hidden, 1 = Visible, 2 = Completed /// </description> /// <example> ///function QUEST_START(cid) /// -- Initialize all quest steps /// -- Initialize all starting navigation points /// /// Saga.AddStep(cid, QuestID, 101, 1); /// Saga.AddStep(cid, QuestID, 102, 0); /// Saga.AddStep(cid, QuestID, 103, 0); /// Saga.InsertQuest(cid, QuestID, 1); /// /// return 0; ///end /// </example> public static bool NpcTakeItem(uint CID, uint ItemId, int ItemCount) { Character Character; if (LifeCycle.TryGetById(CID, out Character)) { foreach (KeyValuePair <byte, Rag2Item> pair in Character.container.GetAllItems()) { if (pair.Value.info.item != ItemId || pair.Value.count < ItemCount) { continue; } int newCount = pair.Value.count -= ItemCount; if (newCount > 0) { SMSG_ITEMADJUST spkt = new SMSG_ITEMADJUST(); spkt.Container = 2; spkt.Function = 4; spkt.Slot = pair.Key; spkt.UpdateReason = (byte)ItemUpdateReason.GiveToNpc; spkt.Value = (byte)pair.Value.count; spkt.SessionId = Character.id; Character.client.Send((byte[])spkt); } else { Character.container.RemoveAt(pair.Key); SMSG_DELETEITEM spkt = new SMSG_DELETEITEM(); spkt.Container = 2; spkt.Index = pair.Key; spkt.UpdateReason = (byte)ItemUpdateReason.GiveToNpc; spkt.SessionId = Character.id; Character.client.Send((byte[])spkt); } return(true); } } return(false); }
/// <summary> /// Looses durabillity loss on defensive equipment /// </summary> /// <remarks> /// Durabillity loss on kro2 is calculated with a ratio of 50 : 1. /// Shield, Shirt, Pants, Shoes each durabillity loss it will rotate /// over the next equipment set. /// </remarks> public static void DoEquipment(Character target, uint damage) { if (target == null) { return; } bool canupdate = false; int NewDurabillity = 0; byte Slot = 0; target.TakenDamage += damage; while (target.TakenDamage > 50) { target.TakenDamage -= 50; switch (target.LastEquipmentDuraLoss) { case 0: //Shield Rag2Item equip = target.Equipment[15]; if (equip == null || equip.active == 1 || equip.durabillty == 0) { goto case 1; } Slot = 15; equip.durabillty -= 1; NewDurabillity = equip.durabillty; target.LastEquipmentDuraLoss = 1; canupdate = true; break; case 1: //Shirt Rag2Item shirt = target.Equipment[3]; if (shirt == null || shirt.active == 1 || shirt.durabillty == 0) { goto case 2; } Slot = 3; shirt.durabillty -= 1; NewDurabillity = shirt.durabillty; target.LastEquipmentDuraLoss = 2; canupdate = true; break; case 2: //Pants Rag2Item pants = target.Equipment[4]; if (pants == null || pants.active == 1 || pants.durabillty == 0) { goto case 3; } Slot = 4; pants.durabillty -= 1; NewDurabillity = pants.durabillty; target.LastEquipmentDuraLoss = 3; canupdate = true; break; case 3: //Shoes Rag2Item shoes = target.Equipment[5]; if (shoes == null || shoes.active == 1 || shoes.durabillty == 0) { return; } Slot = 5; shoes.durabillty -= 1; NewDurabillity = shoes.durabillty; target.LastEquipmentDuraLoss = 0; canupdate = true; break; } if (canupdate == true) { SMSG_ITEMADJUST spkt = new SMSG_ITEMADJUST(); spkt.Container = 1; spkt.Function = 3; spkt.Slot = Slot; spkt.SessionId = target.id; spkt.Value = (uint)NewDurabillity; target.client.Send((byte[])spkt); } } }