public bool OnCommand(Character chr, string args) { if (chr.CommandWeight > 3) { return(true); } if (args == null || args == "") { if (!chr.CurrentCell.IsBalmFountain && !Map.IsNextToBalmFountain(chr)) { chr.WriteToDisplay("What do you want to drink?"); return(true); } else { goto balmFountain; } } if (chr.RightHand != null && chr.RightHand.itemType == Globals.eItemType.Potable) { if (chr.RightHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.DrinkBottle((Bottle)chr.RightHand, chr); return(true); } } else if (chr.LeftHand != null && chr.LeftHand.itemType == Globals.eItemType.Potable) { if (chr.LeftHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.DrinkBottle((Bottle)chr.LeftHand, chr); return(true); } } else //TODO: expand here to allow drinking from a fluid source (eg: fountains) { chr.WriteToDisplay("You are not holding a bottle."); return(true); } balmFountain: if (chr.CurrentCell.IsBalmFountain || Map.IsNextToBalmFountain(chr)) { chr.WriteToDisplay("You drink your fill of the refreshing fluid seeping from the balm tree."); int effectAmount = chr.HitsFull - chr.Hits; if (effectAmount < 0) { effectAmount = 0; } Effect.CreateCharacterEffect(Effect.EffectTypes.Balm, effectAmount, chr, -1, chr); } return(true); }
public bool OnCommand(Character chr, string args) { Bottle bottle; try { if (args == null || args == "") { if (chr.RightHand != null && chr.RightHand.itemID == Item.ID_BALM) { bottle = (Bottle)chr.RightHand; if (!bottle.IsEmpty()) { Bottle.OpenBottle(bottle, chr); Bottle.DrinkBottle(bottle, chr); chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.BreakingGlass)); chr.UnequipRightHand(chr.RightHand); return(true); } } if (chr.LeftHand != null && chr.LeftHand.itemID == Item.ID_BALM) { bottle = (Bottle)chr.LeftHand; if (!bottle.IsEmpty()) { Bottle.OpenBottle(bottle, chr); Bottle.DrinkBottle(bottle, chr); chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.BreakingGlass)); chr.UnequipLeftHand(chr.LeftHand); return(true); } } int balmCount = 0; bool drankBalm = false; foreach (Item item in chr.sackList) { if (item.itemID == Item.ID_BALM) { bottle = (Bottle)item; if (!bottle.IsEmpty()) { drankBalm = true; Bottle.OpenBottle(bottle, chr); Bottle.DrinkBottle(bottle, chr); chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.BreakingGlass)); chr.RemoveFromSack(item); return(true); } else { balmCount++; } } } if (drankBalm) { if (balmCount == 1) { chr.WriteToDisplay("You have only 1 balm remaining."); } return(true); } chr.WriteToDisplay("You don't have any balms to quaff. Good luck."); } // TODO: else if supplied a worldItemID } catch (Exception e) { Utils.LogException(e); } return(true); }