//TODO: Create a single method to handle casting spells from items. 1/6/2017 -Eb public bool OnCommand(Character chr, string args) { if (chr.CommandWeight > 3) { chr.WriteToDisplay("Command weight limit exceeded. Cast command not processed."); return(true); } chr.CommandType = CommandTasker.CommandType.Cast; string outOfCharges = ""; if (args == null) { goto normalSpell; } string[] sArgs = args.Split(" ".ToCharArray()); #region Cast a spell from an Item try { #region Right Hand if (chr.RightHand != null && chr.RightHand.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.RightHand.spell).Command) { if (chr.RightHand.charges <= 0) { if (chr.RightHand.baseType == Globals.eItemBaseType.Scroll) { outOfCharges += "The " + chr.RightHand.name + " does not contain the proper runes to cast a spell. Perhaps it can be scribed."; } else { outOfCharges += "The " + chr.RightHand.name + " is out of charges. "; } goto checkLeftHand; } var storedSpell = chr.preppedSpell; var storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.RightHand.spell); if (chr.RightHand.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.RightHand.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.RightHand.charges > 0 && chr.RightHand.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.RightHand.charges--; // scrolls with charges disintegrate when they reach 0 charges if (chr.RightHand.baseType == Globals.eItemBaseType.Scroll && chr.RightHand.charges == 0) { chr.WriteToDisplay("The " + chr.RightHand.name + " disintegrates."); chr.UnequipRightHand(chr.RightHand); } } return(true); } #endregion checkLeftHand: #region Left Hand if (chr.LeftHand != null && chr.LeftHand.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.LeftHand.spell).Command) { if (chr.LeftHand.charges <= 0) { if (chr.LeftHand.baseType == Globals.eItemBaseType.Scroll) { outOfCharges += "The " + chr.LeftHand.name + " does not contain the proper runes to cast a spell. Perhaps it can be scribed."; } else { outOfCharges += "The " + chr.LeftHand.name + " is out of charges. "; } goto checkRightRing1; } var storedSpell = chr.preppedSpell; var storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.LeftHand.spell); if (chr.LeftHand.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.LeftHand.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.LeftHand.charges > 0 && chr.LeftHand.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.LeftHand.charges--; // scrolls with charges disintegrate when they reach 0 charges if (chr.LeftHand.baseType == Globals.eItemBaseType.Scroll && chr.LeftHand.charges == 0) { chr.WriteToDisplay("The " + chr.LeftHand.name + " disintegrates."); chr.UnequipLeftHand(chr.LeftHand); } } return(true); } #endregion checkRightRing1: #region Right Ring 1 if (chr.RightRing1 != null && chr.RightRing1.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.RightRing1.spell).Command) { if (chr.RightRing1.charges == 0) { outOfCharges += "The " + chr.RightRing1.name + " is out of charges. "; goto checkRightRing2; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.RightRing1.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.RightRing1.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.RightRing1.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.RightRing1.charges > 0 && chr.RightRing1.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.RightRing1.charges--; } return(true); } #endregion checkRightRing2: #region Right Ring 2 if (chr.RightRing2 != null && chr.RightRing2.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.RightRing2.spell).Command) { if (chr.RightRing2.charges == 0) { outOfCharges += "The " + chr.RightRing2.name + " is out of charges. "; goto checkRightRing3; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.RightRing2.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.RightRing2.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.RightRing2.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.RightRing2.charges > 0 && chr.RightRing2.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.RightRing2.charges--; } return(true); } #endregion checkRightRing3: #region Right Ring 3 if (chr.RightRing3 != null && chr.RightRing3.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.RightRing3.spell).Command) { if (chr.RightRing3.charges == 0) { outOfCharges += "The " + chr.RightRing3.name + " is out of charges. "; goto checkRightRing4; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.RightRing3.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.RightRing3.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.RightRing3.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.RightRing3.charges > 0 && chr.RightRing3.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.RightRing3.charges--; } return(true); } #endregion checkRightRing4: #region Right Ring 4 if (chr.RightRing4 != null && chr.RightRing4.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.RightRing4.spell).Command) { if (chr.RightRing4.charges == 0) { outOfCharges += "The " + chr.RightRing4.name + " is out of charges. "; goto checkLeftRing1; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.RightRing4.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.RightRing4.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.RightRing4.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.RightRing4.charges > 0 && chr.RightRing4.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.RightRing4.charges--; } return(true); } #endregion checkLeftRing1: #region Left Ring 1 if (chr.LeftRing1 != null && chr.LeftRing1.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.LeftRing1.spell).Command) { if (chr.LeftRing1.charges == 0) { outOfCharges += "The " + chr.LeftRing1.name + " is out of charges. "; goto checkLeftRing2; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.LeftRing1.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.LeftRing1.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.LeftRing1.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.LeftRing1.charges > 0 && chr.LeftRing1.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.LeftRing1.charges--; } return(true); } #endregion checkLeftRing2: #region Left Ring 2 if (chr.LeftRing2 != null && chr.LeftRing2.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.LeftRing2.spell).Command) { if (chr.LeftRing2.charges == 0) { outOfCharges += "The " + chr.LeftRing2.name + " is out of charges. "; goto checkLeftRing3; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.LeftRing2.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.LeftRing2.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.LeftRing2.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.LeftRing2.charges > 0 && chr.LeftRing2.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.LeftRing2.charges--; } return(true); } #endregion checkLeftRing3: #region Left Ring 3 if (chr.LeftRing3 != null && chr.LeftRing3.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.LeftRing3.spell).Command) { if (chr.LeftRing3.charges == 0) { outOfCharges += "The " + chr.LeftRing3.name + " is out of charges. "; goto checkLeftRing4; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.LeftRing3.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.LeftRing3.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.LeftRing3.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.LeftRing3.charges > 0 && chr.LeftRing3.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.LeftRing3.charges--; } return(true); } #endregion checkLeftRing4: #region Left Ring 4 if (chr.LeftRing4 != null && chr.LeftRing4.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(chr.LeftRing4.spell).Command) { if (chr.LeftRing4.charges == 0) { outOfCharges += "The " + chr.LeftRing4.name + " is out of charges. "; goto checkInventory; } GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(chr.LeftRing4.spell); if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.LeftRing4.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(chr.LeftRing4.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (chr.LeftRing4.charges > 0 && chr.LeftRing4.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { chr.LeftRing4.charges--; } return(true); } #endregion checkInventory: #region Inventory for (int a = 0; a < chr.wearing.Count; a++) { Item item = (Item)chr.wearing[a]; if (item != null && item.spell > 0 && sArgs[0].ToLower() == GameSpell.GetSpell(item.spell).Command) { if (item.charges == 0) { if (item.spell != (int)GameSpell.GameSpellID.Venom) { outOfCharges += "The " + item.name + " is out of charges. "; } } else { GameSpell storedSpell = chr.preppedSpell; long storedMagicSkill = chr.magic; chr.preppedSpell = GameSpell.GetSpell(item.spell); // Found an item with the spell venom. This will mean the item may be charged with venom. if (storedSpell != null && storedSpell.ID != (int)GameSpell.GameSpellID.Venom && chr.preppedSpell.ID == (int)GameSpell.GameSpellID.Venom && sArgs[0].ToLower() == "venom") { chr.WriteToDisplay("Items must be envenomed, or recharged with venom, by the spell."); chr.preppedSpell = storedSpell; continue; } if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (item.spellPower <= 0) { chr.magic = Skills.GetSkillForLevel(chr.preppedSpell.RequiredLevel); } else { chr.magic = Skills.GetSkillForLevel(item.spellPower); } chr.preppedSpell.CastSpell(chr, args); chr.preppedSpell = storedSpell; chr.magic = storedMagicSkill; if (item.charges > 0 && item.charges < Item.NUM_FOR_UNLIMITED_CHARGES) { item.charges--; } chr.wearing[a] = item; return(true); } } } #endregion } catch (Exception e) { Utils.LogException(e); } #endregion #region Knight or Ravager Spell if (chr.BaseProfession == Character.ClassType.Knight || chr.BaseProfession == Character.ClassType.Ravager) // caster is a knight or ravager { if (chr.HasKnightRing) // knight or ravager is wearing their ring { try { if (chr.IsPC) // npc knights already prepped their spell in Creature.prepareSpell { GameSpell spell = GameSpell.GetSpell(sArgs[0].ToLower()); if (spell != null && spell.IsClassSpell(chr.BaseProfession) && spell.IsAvailableAtTrainer && chr.Level >= spell.RequiredLevel) { chr.preppedSpell = GameSpell.GetSpell(sArgs[0].ToLower()); } else { if (outOfCharges != "") { chr.WriteToDisplay(outOfCharges); } else { chr.WriteToDisplay("You do not know that spell. You have not learned it or do not meet the level requirement to cast it."); } return(true); } } if (chr.preppedSpell != null) { // lawful knight or evil ravager if ((chr.Alignment == Globals.eAlignment.Lawful && chr.BaseProfession == Character.ClassType.Knight) || (chr.Alignment == Globals.eAlignment.Evil && chr.BaseProfession == Character.ClassType.Ravager)) { if (chr.Mana < chr.preppedSpell.ManaCost) // knight does not have enough mana { chr.WriteToDisplay("You do not have enough mana to cast the spell."); // message chr.preppedSpell = null; // remove the prepped spell return(true); } chr.preppedSpell.CastSpell(chr, args); chr.Mana -= chr.preppedSpell.ManaCost; chr.preppedSpell = null; chr.updateMP = true; } else // someone other than a lawful knight or evil ravager is using a ring with the "knight effect" { Item ring = null; chr.preppedSpell = null; for (int rnum = 1; rnum < 5; rnum++) { // check right ring = chr.GetSpecificRing(true, rnum); if (ring != null && (ring.itemID == Item.ID_KNIGHTRING || ring.itemID == Item.ID_RAVAGERRING)) { chr.WriteToDisplay("Your " + ring.identifiedName + " explodes!"); Combat.DoSpellDamage(chr, chr, null, Rules.RollD(2, 12), "concussion"); chr.SetSpecificRing(true, rnum, null); } // check left ring = chr.GetSpecificRing(false, rnum); if (ring != null && (ring.itemID == Item.ID_KNIGHTRING || ring.itemID == Item.ID_RAVAGERRING)) { chr.WriteToDisplay("Your " + ring.identifiedName + " explodes!"); Combat.DoSpellDamage(chr, chr, null, Rules.RollD(2, 12), "concussion"); chr.SetSpecificRing(false, rnum, null); } } } } return(true); } catch (Exception e) { Utils.Log("Command.cast(" + args + ") by " + chr.GetLogString(), Utils.LogType.CommandFailure); Utils.LogException(e); return(true); } } else { chr.WriteToDisplay("You are not wearing your " + Utils.FormatEnumString(chr.BaseProfession.ToString()) + "'s ring."); return(true); } } #endregion normalSpell: #region Normal Spell try { bool memorizedSpell = false; // Check if a spell is not prepared. Spells ALWAYS go to the preppedSpell object before being cast. if (chr.preppedSpell == null) { if (outOfCharges != "") { chr.WriteToDisplay(outOfCharges); chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.SpellFail)); } else { chr.WriteToDisplay("You don't have a spell warmed."); } if (!string.IsNullOrEmpty(chr.MemorizedSpellChant)) { if (chr.HasEffect(Effect.EffectTypes.Silence)) { chr.WriteToDisplay("You have been silenced."); return(true); } memorizedSpell = true; string[] mArgs = chr.MemorizedSpellChant.Split(" ".ToCharArray()); chr.CommandWeight = 0; CommandTasker.ParseCommand(chr, mArgs[0], mArgs[1] + " " + mArgs[2] + " " + mArgs[3]); } else { return(true); } } if (memorizedSpell) { if (chr.Stamina < Talents.MemorizeTalent.STAMINA_COST) { chr.WriteToDisplay("You do not have enough stamina to cast your memorized spell."); chr.preppedSpell = null; chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.SpellFail)); return(true); } chr.Stamina -= Talents.MemorizeTalent.STAMINA_COST; // reduce stamina whether the spell is cast or not, or whether if fails or succeeds } // memorized spell costs more mana int manaCost = memorizedSpell ? chr.preppedSpell.ManaCost + (chr.preppedSpell.ManaCost / 2) : chr.preppedSpell.ManaCost; // Check spell failure for newbie thaumaturge players casting higher level spells. if (chr.IsWisdomCaster && chr.IsPC) { if (Rules.CheckSpellFailure(Skills.GetSkillLevel(chr.magic), chr.preppedSpell.RequiredLevel)) { chr.Mana -= manaCost; chr.preppedSpell = null; chr.WriteToDisplay("The spell fizzles."); chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.SpellFail)); return(true); } } // Spell failure if not enough mana. if (chr.Mana < manaCost) { chr.Mana -= manaCost; chr.preppedSpell = null; chr.WriteToDisplay("The spell fails."); chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.SpellFail)); return(true); } else { // If no arguments then this spell will be cast at us (if it requires a target). if (args == null) { args = chr.preppedSpell.Command + " " + chr.Name; } if (chr.preppedSpell.CastSpell(chr, args)) { if (chr != null) { // give skill experience for casting a spell that requires mana int magicSkillLevel = Skills.GetSkillLevel(chr.magic); int bonusForHighSkill = 1; if (magicSkillLevel >= 11) { bonusForHighSkill = magicSkillLevel - 9; } int addend = chr.NumAttackers; // Adjustment here for Thief profession, both because they are hidden when casting and lack numAttackers and they do not // gain as much magic skill experience since they do not target enemies with spells. if (chr.BaseProfession == Character.ClassType.Thief) { addend += Skills.GetSkillLevel(chr.magic) / 2; } int skillAmount = (manaCost + addend) * magicSkillLevel * bonusForHighSkill; Skills.GiveSkillExp(chr, skillAmount, Globals.eSkillType.Magic); #region Give random experience if current map is 'magic intense' if (chr.Map.HasRandomMagicIntensity && chr.IsSpellWarmingProfession && (Rules.RollD(1, 6) == Rules.RollD(1, 6))) { switch (chr.BaseProfession) { case Character.ClassType.Wizard: chr.WriteToDisplay("Static electricity gathers around you and then dissipates gradually."); break; case Character.ClassType.Thaumaturge: chr.WriteToDisplay("An almost overwhelming feeling of serenity passes through you."); break; case Character.ClassType.Sorcerer: chr.WriteToDisplay("Black wisps of acrid smoke rapidly encircle your entire body and then slowly fade away."); break; default: chr.WriteToDisplay("You feel a rush of adrenalin coursing through your body."); break; } if (chr != null && chr.preppedSpell != null) { Skills.GiveSkillExp(chr, manaCost * (Skills.GetSkillLevel(chr.magic) * Rules.RollD(2, 4)), Globals.eSkillType.Magic); } } #endregion if (chr.preppedSpell != null) { chr.Mana -= manaCost; chr.preppedSpell = null; } } } else { if (chr != null) { if (chr.preppedSpell != null) { chr.Mana -= chr.preppedSpell.ManaCost; } chr.preppedSpell = null; chr.WriteToDisplay(GameSystems.Text.TextManager.YOUR_SPELL_FAILS); chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.SpellFail)); } } } if (chr != null) // NPC could be null due to death { chr.CommandWeight += 3; } return(true); } catch (Exception e) { Utils.Log("Command.cast(" + args + ") by " + chr.GetLogString(), Utils.LogType.CommandFailure); Utils.LogException(e); return(true); } #endregion }
public bool OnCommand(Character chr, string args) { Item coins = null; if (args == null || args == "") { chr.WriteToDisplay("Drop what?"); return(true); } string[] sArgs = args.Split(" ".ToCharArray()); int ItemLoc = chr.WhichHand(args.ToLower()); if (sArgs.Length < 2) { // if the item is in the player's hand if (ItemLoc == (int)Globals.eWearOrientation.Right || (sArgs[0] == "right" && chr.RightHand != null)) // Trap "Drop Right" { if (!chr.RightHand.special.Contains(Item.EXTRAPLANAR)) { chr.CurrentCell.Add(chr.RightHand); } chr.UnequipRightHand(chr.RightHand); } else if (ItemLoc == (int)Globals.eWearOrientation.Left || (sArgs[0] == "left" && chr.LeftHand != null)) // Trap "Drop Left" { if (!chr.LeftHand.special.Contains(Item.EXTRAPLANAR)) { chr.CurrentCell.Add(chr.LeftHand); } chr.UnequipLeftHand(chr.LeftHand); } else { chr.WriteToDisplay("You are not carrying that."); } } else if (sArgs.Length == 2) { // drop # <item> if (sArgs[1] == "coins" || sArgs[1] == "coin") { if (Convert.ToInt32(sArgs[0]) < 1) { return(CommandTasker.ParseCommand(chr, "drop", "coins")); } if (chr.RightHand != null && chr.RightHand.itemType == Globals.eItemType.Coin) { if (chr.RightHand.coinValue == Convert.ToInt32(sArgs[0])) { return(CommandTasker.ParseCommand(chr, "drop", "coins")); } else if (chr.RightHand.coinValue > Convert.ToInt32(sArgs[0])) { coins = Item.CopyItemFromDictionary(Item.ID_COINS); chr.RightHand.coinValue -= Convert.ToInt32(sArgs[0]); coins.coinValue = Convert.ToInt32(sArgs[0]); chr.CurrentCell.Add(coins); return(true); } else { chr.WriteToDisplay("You are not holding that many coins."); return(true); } } else if (chr.LeftHand != null && chr.LeftHand.itemType == Globals.eItemType.Coin) { if (chr.LeftHand.coinValue == Convert.ToInt32(sArgs[0])) { return(CommandTasker.ParseCommand(chr, "drop", "coins")); } else if (chr.LeftHand.coinValue > Convert.ToInt32(sArgs[0])) { coins = Item.CopyItemFromDictionary(Item.ID_COINS); chr.LeftHand.coinValue -= Convert.ToInt32(sArgs[0]); coins.coinValue = Convert.ToInt32(sArgs[0]); chr.CurrentCell.Add(coins); return(true); } else { chr.WriteToDisplay("You are not holding that many coins."); return(true); } } else { chr.WriteToDisplay("You are not holding any coins."); return(true); } } else { chr.WriteToDisplay("You are not carrying that many " + sArgs[1] + "."); return(true); } } else if (sArgs.Length > 2) { return(CommandTasker.ParseCommand(chr, "put", args)); } return(true); }
public bool OnPerform(Character chr, string args) { if (args == null) { chr.WriteToDisplay("DaggerStorm who?"); return(false); } string[] sArgs = args.Split(" ".ToCharArray()); Character target = TargetAcquisition.AcquireTarget(chr, sArgs, GameWorld.Cell.DEFAULT_VISIBLE_DISTANCE, 0); // failed to find the target if (target == null) { chr.WriteToDisplay("You don't see a " + (sArgs.Length >= 2 ? sArgs[0] + " " + sArgs[1] : sArgs[0]) + " here."); return(false); } // one hand must be free if (chr.RightHand != null && chr.LeftHand != null) { chr.WriteToDisplay("You must have one hand free to perform DaggerStorm."); return(false); } int daggerCount = (Skills.GetSkillLevel(chr.dagger) / 2) + 1; int prevSavageryPower = 0; if (!chr.EffectsList.ContainsKey(Effect.EffectTypes.Savagery)) { Effect.CreateCharacterEffect(Effect.EffectTypes.Savagery, 50, chr, 0, null); } else if (chr.EffectsList[Effect.EffectTypes.Savagery].Power < 50) { prevSavageryPower = chr.EffectsList[Effect.EffectTypes.Savagery].Power; chr.EffectsList[Effect.EffectTypes.Savagery].Power = 50; } for (int a = 0; a <= daggerCount; a++) { Item shadowDagger = Item.CopyItemFromDictionary(Item.ID_DAGGER_PLUS_TWO); shadowDagger.special += " " + Item.EXTRAPLANAR; shadowDagger.name = "shadowdagger"; shadowDagger.combatAdds = daggerCount; shadowDagger.longDesc = "a slender dagger made from the very fabric of shadow"; if (!chr.EquipEitherHand(shadowDagger)) { if (chr.RightHand != null && chr.RightHand.name == "shadowdagger") { chr.UnequipRightHand(chr.RightHand); } if (chr.LeftHand != null && chr.LeftHand.name == "shadowdagger") { chr.UnequipLeftHand(chr.LeftHand); } return(true); } if (!target.IsDead) { CommandTasker.ParseCommand(chr, "throw", "shadowdagger at " + target.UniqueID); chr.CommandWeight = 0; } else { if (chr.RightHand != null && chr.RightHand.name == "shadowdagger") { chr.UnequipRightHand(chr.RightHand); } if (chr.LeftHand != null && chr.LeftHand.name == "shadowdagger") { chr.UnequipLeftHand(chr.LeftHand); } return(true); } } if (prevSavageryPower > 0) { chr.EffectsList[Effect.EffectTypes.Savagery].Power = prevSavageryPower; } else if (chr.EffectsList.ContainsKey(Effect.EffectTypes.Savagery)) { chr.EffectsList[Effect.EffectTypes.Savagery].StopCharacterEffect(); } if (chr.RightHand != null && chr.RightHand.name == "shadowdagger") { chr.UnequipRightHand(chr.RightHand); } if (chr.LeftHand != null && chr.LeftHand.name == "shadowdagger") { chr.UnequipLeftHand(chr.LeftHand); } return(true); }
public bool OnCommand(Character chr, string args) { return(CommandTasker.ParseCommand(chr, "impgotoloc", chr.FacetID.ToString() + " 2 10 20 30 0")); }
public bool OnCommand(Character chr, string args) { int taketype = 0; string takeitem = ""; string takefrom = ""; int takenum = 0; Item item = new Item(); if (args == null) { chr.WriteToDisplay("Take what?"); return(true); } else { String[] sArgs = args.Split(" ".ToCharArray()); if (sArgs.GetLength(0) < 2) { taketype = 1; // take <item> takeitem = sArgs[0].ToLower(); } else if (sArgs.Length == 2) { taketype = 2; // Take # <item> try { takenum = Convert.ToInt32(sArgs[0]); takeitem = sArgs[1].ToLower(); } catch (Exception) { chr.WriteToDisplay("Useage: Take <#> item"); return(true); } } else if (sArgs[1].ToLower().Equals("from")) { if (sArgs[2] == null) { chr.WriteToDisplay("Take " + sArgs[0] + " from what?"); return(true); } else { taketype = 3; // take <item> from <something> takeitem = sArgs[0].ToLower(); takefrom = sArgs[2].ToLower(); } } else if (sArgs[0].ToLower().Equals("ring") && sArgs[1].ToLower().Equals("off")) { //Trap "Take Ring off left/right" return(CommandTasker.ParseCommand(chr, "remove", args)); } else if (sArgs[1].ToLower().Equals("ring") && sArgs[2].ToLower().Equals("off")) { //Trap "Take x Ring off left/right" return(CommandTasker.ParseCommand(chr, "remove", args)); } else if (sArgs[2].ToLower().Equals("from")) { if (sArgs[3] == null) { chr.WriteToDisplay("Take " + sArgs[1] + " from what?"); return(true); } else { taketype = 4; // take # <item> from <something> takeitem = sArgs[1].ToLower(); takefrom = sArgs[3].ToLower(); takenum = Convert.ToInt32(sArgs[0]); } } else { taketype = 0; // Default type - nothing/catchall } } // Now we switch on the taketype switch (taketype) { case 0: // default type chr.WriteToDisplay("Take what?"); break; case 1: // take <item> // check if an itemID number was sent as the argument, to help AI find a specific item... #region take item by using item ID bool isNumber = int.TryParse(takeitem, out int uniqueWorldID); if (isNumber) { if (Item.IsItemOnGround(uniqueWorldID, chr.CurrentCell)) { Item tItem = Item.FindItemOnGround(uniqueWorldID, chr.CurrentCell); if (chr.EquipEitherHand(tItem)) { chr.CurrentCell.Remove(tItem); } return(true); } else { chr.WriteToDisplay(GameSystems.Text.TextManager.NullItemMessage(takeitem)); return(true); } } #endregion if (Item.IsItemOnGround(takeitem.ToLower(), chr.FacetID, chr.LandID, chr.MapID, chr.X, chr.Y, chr.Z)) { for (int a = 0; a < chr.CurrentCell.Items.Count; a++) { Item tItem = (Item)chr.CurrentCell.Items[a]; if (tItem.name.ToLower() == takeitem.ToLower()) { if (chr.EquipEitherHand(tItem)) { chr.CurrentCell.Remove(tItem); } return(true); } } } else { chr.WriteToDisplay(GameSystems.Text.TextManager.NullItemMessage(takeitem)); return(true); } break; case 2: // take # <item> int z = 0; if (takeitem.IndexOf("coin") > -1 || takeitem == "gold") { item = Item.FindItemOnGround(takeitem, chr.FacetID, chr.LandID, chr.MapID, chr.X, chr.Y, chr.Z); foreach (Item itm in chr.CurrentCell.Items) { if (itm.name.ToLower().IndexOf("coin") > -1) { item = itm; } } if (item == null) { chr.WriteToDisplay("You do not see any coins here."); return(true); } else if (takenum <= 0) { chr.WriteToDisplay("You cannot do that."); return(true); } else if (item.coinValue < takenum) { chr.WriteToDisplay("There aren't that many coins here."); return(true); } else if (item.coinValue == takenum) { if (chr.EquipEitherHand(item)) { chr.CurrentCell.Remove(item); } return(true); } else { if (chr.RightHand == null) { item.coinValue -= takenum; chr.EquipRightHand(Item.CopyItemFromDictionary(Item.ID_COINS)); chr.RightHand.coinValue = takenum; return(true); } else if (chr.LeftHand == null) { item.coinValue -= takenum; chr.EquipLeftHand(Item.CopyItemFromDictionary(Item.ID_COINS)); chr.LeftHand.coinValue = takenum; return(true); } else { chr.WriteToDisplay("Your hands are full."); return(true); } } } List <Item> tmpList = chr.CurrentCell.Items; if (takenum > tmpList.Count) { chr.WriteToDisplay(GameSystems.Text.TextManager.NullItemMessage(null)); return(true); } z = tmpList.Count - 1; int itemcount = 0; foreach (Item tItem in tmpList) { Item tmpitem = tItem; if (tmpitem.name == takeitem) { itemcount++; if (takenum == itemcount) { if (tmpitem.IsArtifact() && chr.PossessesItem(tmpitem.itemID)) { chr.WriteToDisplay("You already possess this artifact."); return(true); } if (chr.EquipEitherHand(tItem)) { chr.CurrentCell.Remove(tItem); } return(true); } } } chr.WriteToDisplay("There aren't that many " + takeitem + "'s here."); break; case 3: // take <item> from <something> if (chr.RightHand != null && chr.LeftHand != null) { chr.WriteToDisplay("Your hands are full."); return(true); } else if (takefrom.ToLower() == "sack" || takefrom.ToLower() == "sac" || takefrom.ToLower() == "sakc") { item = chr.RemoveFromSack(takeitem.ToLower()); } else if (takefrom.ToLower() == "pouch" || takefrom.ToLower() == "pou") { item = chr.RemoveFromPouch(takeitem.ToLower()); } else if (takefrom.ToLower() == "locker") { if (chr.CurrentCell.IsLocker) { item = chr.RemoveFromLocker(takeitem.ToLower()); } else { chr.WriteToDisplay("There are no lockers here."); return(true); } } else if (takefrom.ToLower() == "counter" || takefrom.ToLower() == "altar") { if (Map.IsNextToCounter(chr)) { item = Map.RemoveItemFromCounter(chr, takeitem.ToLower()); } else { chr.WriteToDisplay("There is no " + takefrom.ToLower() + " here."); } if (item == null || item.name.ToLower() == "undefined") { chr.WriteToDisplay("There is no " + takefrom.ToLower() + " here."); } } else if (takefrom.ToLower() == "ground") { return(CommandTasker.ParseCommand(chr, "take", takeitem)); } else { chr.WriteToDisplay("I don't understand that command."); break; } if (item != null) { chr.EquipEitherHand(item); } else { chr.WriteToDisplay("The " + takefrom + " does not have a " + takeitem + " in it."); } break; case 4: // take # <item> from <something> List <Item> tmplist; switch (takefrom) { case "ground": tmplist = chr.CurrentCell.Items; break; case "sack": tmplist = chr.sackList; break; case "pouch": tmplist = chr.pouchList; break; case "locker": if (!chr.CurrentCell.IsLocker) { chr.WriteToDisplay("There are no lockers here."); return(true); } tmplist = chr.lockerList; break; case "counter": case "altar": Cell curCell = Map.GetNearestCounterOrAltarCell(chr.CurrentCell); tmplist = curCell.Items; if (tmplist == null) { chr.WriteToDisplay("I see no " + takefrom + " here."); return(true); } break; default: chr.WriteToDisplay("I don't understand that command."); return(true); } if (takeitem.IndexOf("coin") > -1 || takeitem == "gold") { foreach (Item itm in tmplist) { if (itm.name.ToLower().IndexOf("coin") > -1) { item = itm; } } if (item == null || item.name.ToLower() == "undefined") { chr.WriteToDisplay(GameSystems.Text.TextManager.NullItemMessage(takeitem)); return(true); } else if (takenum <= 0) { chr.WriteToDisplay("You cannot do that."); return(true); } else if (item.coinValue < takenum) { chr.WriteToDisplay("There aren't that many coins here."); return(true); } else if (item.coinValue == takenum) { if (chr.EquipEitherHand(item)) { tmplist.Remove(item); } return(true); } else { if (chr.RightHand == null) { item.coinValue -= takenum; chr.EquipRightHand(Item.CopyItemFromDictionary(Item.ID_COINS)); chr.RightHand.coinValue = takenum; return(true); } else if (chr.LeftHand == null) { item.coinValue -= takenum; chr.EquipLeftHand(Item.CopyItemFromDictionary(Item.ID_COINS)); chr.LeftHand.coinValue = takenum; return(true); } else { chr.WriteToDisplay("Your hands are full."); return(true); } } } if (takenum > tmplist.Count) { chr.WriteToDisplay(GameSystems.Text.TextManager.NullItemMessage(null)); return(true); } int itmcount = 0; foreach (Item tItem in tmplist) { Item tmpitem = tItem; if (tmpitem.name == takeitem) { itmcount++; if (takenum == itmcount) { if (chr.EquipEitherHand(tItem)) { tmplist.Remove(tItem); return(true); } else { chr.WriteToDisplay("Your hands are full."); return(true); } } } } chr.WriteToDisplay("There are not that many " + takeitem + "s here."); break; default: break; } return(true); }
public bool OnCommand(Character chr, string args) { if (args == null || args == "") { chr.WriteToDisplay("What do you want to open?"); return(true); } string[] sArgs = args.Split(" ".ToCharArray()); if (sArgs[0] == "right" && chr.RightHand != null && chr.RightHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.OpenBottle((Bottle)chr.RightHand, chr); } else if (sArgs[0] == "left" && chr.LeftHand != null && chr.LeftHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.OpenBottle((Bottle)chr.LeftHand, chr); } else if (chr.RightHand != null && chr.RightHand.name == sArgs[0] && chr.RightHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.OpenBottle((Bottle)chr.RightHand, chr); } else if (chr.LeftHand != null && chr.LeftHand.name == sArgs[0] && chr.LeftHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.OpenBottle((Bottle)chr.LeftHand, chr); } else if (Autonomy.ItemBuilding.ItemBuilder.BOTTLE_SYNONYMS.Contains(sArgs[0].ToLower())) { if (chr.RightHand != null && chr.RightHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.OpenBottle((Bottle)chr.RightHand, chr); } else if (chr.LeftHand != null && chr.LeftHand.baseType == Globals.eItemBaseType.Bottle) { Bottle.OpenBottle((Bottle)chr.LeftHand, chr); } else { chr.WriteToDisplay("You are not holding a " + sArgs[0] + "."); } return(true); } else if (Autonomy.ItemBuilding.ItemBuilder.BOOK_SYNONYMS.Contains(sArgs[0].ToLower())) { return(CommandTasker.ParseCommand(chr, "flip", args)); } else if (sArgs[0].ToLower() == "door") { if (sArgs.Length == 1) { chr.WriteToDisplay("Format: open door <direction>"); return(true); } Cell cell = Map.GetCellRelevantToCell(chr.CurrentCell, sArgs[1], true); string newGraphic = cell.CellGraphic; if (cell.DisplayGraphic == Cell.GRAPHIC_OPEN_DOOR_HORIZONTAL || cell.DisplayGraphic == Cell.GRAPHIC_OPEN_DOOR_VERTICAL) { chr.WriteToDisplay("The door is already open."); return(true); } else if (cell.DisplayGraphic != Cell.GRAPHIC_CLOSED_DOOR_VERTICAL && cell.DisplayGraphic != Cell.GRAPHIC_CLOSED_DOOR_HORIZONTAL) { chr.WriteToDisplay("You don't see a door there."); return(true); } OpenCommand.OpenDoor(cell); } return(true); }
public bool OnCommand(Character chr, string args) { try { //if (chr.cmdWeight > 3) //{ // chr.WriteToDisplay("Command weight limit exceeded. Shoot command not processed."); // return true; //} if (args == null || args == "") { chr.WriteToDisplay("Shoot what?"); return(true); } // weapon in right hand is returning and not a bow if (chr.RightHand != null && chr.RightHand.returning && chr.RightHand.skillType != Globals.eSkillType.Bow) { return(CommandTasker.ParseCommand(chr, "throw", chr.RightHand.name + " at " + args)); } else if (chr.LeftHand != null && chr.LeftHand.returning && chr.LeftHand.skillType != Globals.eSkillType.Bow) // weapon in left hand is returning and not a bow { return(CommandTasker.ParseCommand(chr, "throw", chr.LeftHand.name + " at " + args)); } // determine what weapon is being shot Item weapon = null; // bow in right hand is nocked or autofire (returning) if (chr.RightHand != null && chr.RightHand.RequiresOneFreeHandToShoot() && (chr.RightHand.IsNocked || chr.RightHand.returning)) { if (chr.GetFirstFreeHand() != (int)Globals.eWearOrientation.Left) { chr.WriteToDisplay("Your left hand must be empty to shoot " + chr.RightHand.shortDesc + "."); return(true); } weapon = chr.RightHand; goto ShootBowOrSling; }// else if bow in left hand is nocked (check for returning bow (autofire is done above) else if (chr.LeftHand != null && chr.LeftHand.RequiresOneFreeHandToShoot() && (chr.LeftHand.IsNocked || chr.LeftHand.returning)) { if (chr.GetFirstFreeHand() != (int)Globals.eWearOrientation.Right) { chr.WriteToDisplay("Your right hand must be empty to shoot " + chr.LeftHand.shortDesc + "."); return(true); } weapon = chr.LeftHand; goto ShootBowOrSling; } foreach (Item item in chr.wearing) { if (item.baseType == Globals.eItemBaseType.Bow) { weapon = item; break; } } if (weapon != null && (weapon.baseType == Globals.eItemBaseType.Bow || weapon.baseType == Globals.eItemBaseType.Sling)) { goto ShootBowOrSling; } // one hand is empty, check belt for throwable weapon if (weapon == null) { int firstFreeHand = chr.GetFirstFreeHand(); if (firstFreeHand != (int)Globals.eWearOrientation.None) { #region One hand is not empty, check belt for throwable weapon. foreach (Item beltItem in new System.Collections.Generic.List <Item>(chr.beltList)) { foreach (string thrownFromBelt in Item.ThrowFromBelt) { if (beltItem.name == thrownFromBelt) { string notifyMessage = ""; switch (firstFreeHand) { case 1: if (chr.LeftHand != null && (chr.LeftHand.skillType == Globals.eSkillType.Bow || chr.LeftHand.baseType == Globals.eItemBaseType.Sling) && !chr.LeftHand.IsNocked) { notifyMessage = "Your " + chr.LeftHand.name + " is not nocked. "; } break; case 2: if (chr.RightHand != null && (chr.RightHand.skillType == Globals.eSkillType.Bow || chr.RightHand.baseType == Globals.eItemBaseType.Sling) && !chr.RightHand.IsNocked) { notifyMessage = "Your " + chr.RightHand.name + " is not nocked. "; } break; default: break; } chr.WriteToDisplay(notifyMessage + "You throw " + beltItem.shortDesc + " from your belt."); return(CommandTasker.ParseCommand(chr, "throw", beltItem.name + " at " + args)); } } } #endregion } } // last resort, use any item in the left then right hand that is not a shooting weapon such as a bow or sling if (chr.LeftHand != null && !chr.LeftHand.RequiresOneFreeHandToShoot()) { return(CommandTasker.ParseCommand(chr, "throw", chr.LeftHand.name + " at " + args)); } else if (chr.RightHand != null && chr.RightHand.RequiresOneFreeHandToShoot()) { return(CommandTasker.ParseCommand(chr, "throw", chr.RightHand.name + " at " + args)); } if (weapon == null) { chr.WriteToDisplay("You do not have a weapon ready to shoot."); return(true); } ShootBowOrSling: if (weapon == null) { chr.WriteToDisplay("You do not have a weapon ready to shoot."); return(true); } if (weapon.skillType == Globals.eSkillType.Bow || weapon.baseType == Globals.eItemBaseType.Sling) { string nocking = weapon.baseType == Globals.eItemBaseType.Sling ? "loading" : "nocking"; string nocked = weapon.baseType == Globals.eItemBaseType.Sling ? "loaded" : "nocked"; if (!weapon.returning && chr.CommandsProcessed.Contains(CommandTasker.CommandType.Nock)) { chr.WriteToDisplay("You are still " + nocking + " your " + weapon.name + "."); return(true); } if (!weapon.IsNocked && !weapon.returning) { chr.WriteToDisplay("The " + weapon.name + " is not " + nocked + "."); return(true); } // wrist xbow is a hands item if (chr.GetFirstFreeHand() == (int)Globals.eWearOrientation.None && weapon != null && weapon.wearLocation != Globals.eWearLocation.Hands) { chr.WriteToDisplay("You must have one empty hand to shoot a " + Utils.FormatEnumString(weapon.baseType.ToString()).ToLower() + "."); return(true); } } #region Check if weapon is attuned if (chr.IsPC && weapon.IsAttunedToOther(chr)) { chr.CurrentCell.Add(weapon); chr.WriteToDisplay("The " + weapon.name + " leaps from your hand!"); if (weapon == chr.RightHand) { chr.UnequipRightHand(weapon); } else { chr.UnequipLeftHand(weapon); } return(true); } #endregion #region Check alignment of weapon if (!weapon.AlignmentCheck(chr)) { if (!weapon.name.ToLower().Contains("crossweapon") && !weapon.longDesc.ToLower().Contains("crossweapon")) { weapon.IsNocked = false; } chr.CurrentCell.Add(weapon); chr.WriteToDisplay("The " + weapon.name + " singes your hand and falls to the ground!"); if (weapon == chr.RightHand) { chr.UnequipRightHand(weapon); } else { chr.UnequipLeftHand(weapon); } Combat.DoDamage(chr, chr, Rules.RollD(1, 4), false); return(true); } #endregion string[] sArgs = args.Split(" ".ToCharArray()); Character target; if (sArgs.Length == 2 && char.IsNumber(sArgs[0].ToCharArray()[0])) { target = GameSystems.Targeting.TargetAquisition.FindTargetInView(chr, sArgs[1], Convert.ToInt32(sArgs[0])); } else { target = GameSystems.Targeting.TargetAquisition.FindTargetInView(chr, sArgs[0], false, chr.IsImmortal); } if (target == null) { chr.WriteToDisplay(GameSystems.Text.TextManager.NullTargetMessage(args)); return(true); } chr.CommandType = CommandTasker.CommandType.Shoot; Combat.DoCombat(chr, target, weapon); // Possible double attack if returning weapon. if (weapon != null && weapon.returning) { Combat.CheckDoubleAttack(chr, target, weapon); } if (chr.LeftHand != null && chr.LeftHand.returning) { Combat.CheckDualWield(chr, target, chr.LeftHand); } // Implemented check for "returning" bows (crossbows) which are auto-nock. if (weapon != null) { if (weapon == chr.RightHand && !chr.RightHand.returning) { chr.RightHand.IsNocked = false; } else if (weapon == chr.LeftHand && !chr.LeftHand.returning) { chr.LeftHand.IsNocked = false; } else if (weapon.wearLocation == Globals.eWearLocation.Hands && !weapon.returning) { weapon.IsNocked = false; } else if (weapon.returning) // auto-nocking sound { if (weapon.name == "crossbow" || weapon.longDesc.ToLower().Contains("crossbow")) { chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.NockCrossbow)); } else if (weapon.name.Contains("bow")) // should there be auto-nocking bows that don't have a mechanism? { chr.EmitSound(Sound.GetCommonSound(Sound.CommonSound.NockBow)); } } } } catch (Exception e) { Utils.LogException(e); return(false); } return(true); }
public bool OnCommand(Character chr, string args) { if (chr.PCState == Globals.ePlayerState.CONFERENCE) { #region Conference Room Help chr.WriteLine("", ProtocolYuusha.TextType.Help); chr.WriteLine("Conference Room Commands", ProtocolYuusha.TextType.Help); chr.WriteLine("------------------------", ProtocolYuusha.TextType.Help); chr.WriteLine(" /play - Enter the game.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /exit - Disconnect from " + DragonsSpineMain.Instance.Settings.ServerName + ".", ProtocolYuusha.TextType.Help); chr.WriteLine(" /list - List your current characters.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /switch # - Switch to character #.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /scores or /topten - Get player rankings.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /scores me - Your current score.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /scores <class> <amount>", ProtocolYuusha.TextType.Help); chr.WriteLine(" /scores <class>", ProtocolYuusha.TextType.Help); chr.WriteLine(" /scores <player>", ProtocolYuusha.TextType.Help); chr.WriteLine(" /scores all <amount>", ProtocolYuusha.TextType.Help); chr.WriteLine(" /page - Toggle paging.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /page <name> - Page someone in the game.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /tell or /t - Toggle private tells.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /tell <name> <message> - Send a private tell.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /friend - View your friends list.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /friend <name> - Add or remove a player from your friends list.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /notify - Toggle friend notification.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /ignore - View your ignore list.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /ignore <name> - Add or remove a player from your ignore list.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /users - Shows everyone in the game.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /menu - Return to the main menu.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /afk - Toggle A.F.K. (Away From Keyboard).", ProtocolYuusha.TextType.Help); chr.WriteLine(" /afk <message> - Use personal A.F.K. message.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /anon - Toggle anonymous.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /filter - Toggle profanity filter.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /rename <new name> - Change your character's name.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /echo - Toggle command echo.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /macro - View your macros list.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /macro # <text> - Set # macro, where # macro is between 0 and " + Character.MAX_MACROS + ".", ProtocolYuusha.TextType.Help); chr.WriteLine(" /lottery - View current lottery jackpots.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /commands - View a full list of available game commands.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /displaycombatdamage - Toggle combat damage statistics.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /help - This help list.", ProtocolYuusha.TextType.Help); chr.WriteLine("", ProtocolYuusha.TextType.Help); if ((chr as PC).ImpLevel > Globals.eImpLevel.USER) { chr.WriteLine("Staff Commands", ProtocolYuusha.TextType.Help); chr.WriteLine(" /stafftitle - Toggle staff title.", ProtocolYuusha.TextType.Help); chr.WriteLine("", ProtocolYuusha.TextType.Help); } if ((chr as PC).ImpLevel >= Globals.eImpLevel.GM) { chr.WriteLine("GM Commands", ProtocolYuusha.TextType.Help); chr.WriteLine(" /invis - Toggle invisibility.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /announce - Send announcement to all, anonymously.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /selfannounce - Send announcement to all, includes your name.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /immortal - Toggle immortality.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /ban <name> <# of days> - Ban a player (includes their account)", ProtocolYuusha.TextType.Help); chr.WriteLine(" /boot <name> - Disconnects a player from the server.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /rename <old> <new> - Change a player's name.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /restock - Restock all merchant inventory items.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /clearstores - Clears all non original merchant inventory items.", ProtocolYuusha.TextType.Help); chr.WriteLine("", ProtocolYuusha.TextType.Help); } if ((chr as PC).ImpLevel >= Globals.eImpLevel.DEV) { chr.WriteLine("DEV Commands", ProtocolYuusha.TextType.Help); chr.WriteLine(" /bootplayers - Force all players to quit.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /lockserver - Locks the server.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /unlockserver - Unlocks the server.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /implevel <name> <impLevel#> - Set a player's implevel.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /listf - Lists the Player table columns in the database.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /getf <name> <field name> - Get a player's field value.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /setf <name> <field name> <value> <notify> - Set a player's field value.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /processemptyworld <on|off> - No argument displays status of this attribute.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /purgeaccount <account> - Purge a players account.", ProtocolYuusha.TextType.Help); //chr.WriteLine(" /searchnpcloot <itemID> - Search for an item on an NPC currently in the game.", Protocol.TextType.Help); chr.WriteLine(" /getskill <name> <skill> - Get a PC's skill level.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /setskill <name> <skill> <skill level> - Set a PC's skill level.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /restartserver - Forces a hard shutdown, with no PC saves, and restarts the DragonsSpine.exe process.", ProtocolYuusha.TextType.Help); chr.WriteLine(" /deleteplayer | /dplayer <name> - Delete a player from the database.", ProtocolYuusha.TextType.Help); chr.WriteLine("", ProtocolYuusha.TextType.Help); } chr.WriteLine("", ProtocolYuusha.TextType.Help); #endregion return(true); } if (args == null || args == "") { chr.WriteToDisplay("Help is in need of an update if we have any volunteers."); chr.WriteToDisplay("Help Topics: ( help <topic> )"); chr.WriteToDisplay("merchants talk magic training"); chr.WriteToDisplay("map movement combat formulas"); } else { string[] sArgs = args.Split(" ".ToCharArray()); switch (sArgs[0].ToLower()) { case "map": chr.WriteToDisplay("The map consists of the following tiles:"); chr.WriteToDisplay("%% = Air [_ = Ruins "); chr.WriteToDisplay("~~ = Water ** = Fire "); chr.WriteToDisplay("@ = Tree /\\ = Mountain"); chr.WriteToDisplay("== = Counter .~ = Ice"); chr.WriteToDisplay("up = Up Stairs dn = Down Stairs"); chr.WriteToDisplay(". = Empty [] = Wall "); break; case "movement": chr.WriteToDisplay("N N NE would move you 3 spaces North and one space NorthEast."); chr.WriteToDisplay("You can use up to three moves in one turn. For instance"); chr.WriteToDisplay("Portals can be used with a magic chant."); chr.WriteToDisplay("D = Down U = Up Climb Up Climb Down"); chr.WriteToDisplay("NE = NorthEast NW = NorthWest SE = SouthEast SW = SouthWest"); chr.WriteToDisplay("N = North S = South E = East W = West"); chr.WriteToDisplay("The possible directions are:"); chr.WriteToDisplay("to move using the first letter of the direction."); chr.WriteToDisplay("Movement is done by typing the direction you want"); break; case "combat": chr.WriteToDisplay("NAME is the name of the thing you are attacking."); chr.WriteToDisplay("the FIGHT command. The usage is Attack <NAME> where "); chr.WriteToDisplay("Combat is done by using either the Attack command, or"); break; case "merchants": chr.WriteToDisplay("Use the command 'show prices' while in front of a counter"); chr.WriteToDisplay("to see what items are for sale. To purchase an item place"); chr.WriteToDisplay("your gold coins on the counter (put coins on counter) and"); chr.WriteToDisplay("then ask the merchant to sell you the item with the command"); chr.WriteToDisplay("'<name>, SELL <item name>'. To sell an item use"); chr.WriteToDisplay("'<name>, BUY <item name>' or '<name>, BUY ALL'."); chr.WriteToDisplay("Note that you can use the command 'dump <item name> on counter'"); chr.WriteToDisplay("to place all <item name> from your sack on the counter in front"); chr.WriteToDisplay("of you."); break; case "talk": chr.WriteToDisplay("using the SAY command to display your message to anyone in "); chr.WriteToDisplay("instance \"Where is the armor shop? would work the same as"); chr.WriteToDisplay("A shortcut is to use the \" instead of the SAY command. For"); chr.WriteToDisplay("usage: SAY <MESSAGE> where message is what you want to say."); chr.WriteToDisplay("You can talk to other players by using the SAY command."); break; case "training": chr.WriteToDisplay("Training will greatly increase the amount of skill experience you earn while using the skill."); //chr.WriteToDisplay("Training Costs:"); //for (int a = 0; a <= Skills.MAX_SKILL_LEVEL; a++) // chr.WriteToDisplay("Level " + a + ": Full Cost = " + Rules.Formula_TrainingCostForLevel(a) + ", Rank = " + // Skills.GetTrainingCostPerRank(a)); break; case "formula": case "formulas": chr.WriteToDisplay("Current Stat Formulas (" + chr.Land.Name + "):"); string[] classes = Enum.GetNames(typeof(Character.ClassType)); string hitsFormula = ""; string stamFormula = ""; string manaFormula = ""; string outputString = ""; for (int a = 1; a < classes.Length; a++) { hitsFormula = "(" + GameWorld.World.HitDice[a].ToString() + " * level) + " + 64; stamFormula = "(" + GameWorld.World.StaminaDice[a].ToString() + " * level)"; if (chr.Land.ManaDice[a] > 0) { manaFormula = "(" + GameWorld.World.ManaDice[a].ToString() + " * level)"; outputString = "[" + Utils.FormatEnumString(classes[a]) + "] H: " + hitsFormula + " S: " + stamFormula + " M: " + manaFormula; } else { outputString = "[" + Utils.FormatEnumString(classes[a]) + "] H: " + hitsFormula + " S: " + stamFormula; } chr.WriteToDisplay(outputString); } break; case "experience": case "exp": CommandTasker.ParseCommand(chr, "showxp", ""); break; case "magic": break; default: break; } } return(true); }
public bool OnCommand(Character chr, string args) { args = args.TrimEnd(); bool usingMacro = args.Length == 1 || args.Length == 2; if (args == null || args == "" || args.StartsWith("list") || (usingMacro && chr.PCState != Globals.ePlayerState.PLAYING)) { #region No arguments or argument is "list" - display list of macros. if ((chr as PC).macros.Count == 0) { chr.WriteToDisplay("You do not have any macros set."); return(true); } string result = ""; chr.WriteToDisplay("Macros List:"); int count = 0; foreach (string macro in (chr as PC).macros) { chr.WriteToDisplay(count + ": " + macro); count++; } //for (int a = 0; a < (chr as PC).macros.Count; a++) //{ // string text = (chr as PC).macros[a].ToString(); // if(text.Length > 0) // do not display empty macros // result += (a + " = " + (chr as PC).macros[a].ToString() + "\r\n"); //} chr.WriteToDisplay("" + result); if (chr.protocol == DragonsSpineMain.Instance.Settings.DefaultProtocol) { ProtocolYuusha.SendCharacterMacros(chr as PC, chr as PC); } return(true); #endregion } int macrosIndex = -1; if (usingMacro) // using a macro, has to be a macros list index { if (!Int32.TryParse(args, out macrosIndex)) { chr.WriteToDisplay("Invalid macro command. View command help for details."); return(true); } } else if (args.IndexOf(" ") >= 1) // setting a macro { if (!Int32.TryParse(args.Substring(0, args.IndexOf(" ")), out macrosIndex)) { chr.WriteToDisplay("Invalid macro command. View command help for details."); return(true); } else { args = args.Substring(args.IndexOf(" ") + 1, args.Length - macrosIndex.ToString().Length - 1); } } else { chr.WriteToDisplay("Invalid macro command. View command help for details."); return(true); } if (macrosIndex >= Character.MAX_MACROS) // 0 through 19 { chr.WriteToDisplay("The current maximum amount of macros is " + Character.MAX_MACROS + "."); return(true); } else if (macrosIndex < 0) { chr.WriteToDisplay("Invalid macro command. View command help for details."); return(true); } else if (usingMacro && ((chr as PC).macros.Count < macrosIndex + 1 || (chr as PC).macros[macrosIndex].Length < 1)) { chr.WriteToDisplay("Macro " + macrosIndex + " is not set."); return(true); } try { if (usingMacro) { if ((chr as PC).macros[macrosIndex].ToString().IndexOf(" ") != -1) { string command = (chr as PC).macros[macrosIndex].ToString().Substring(0, (chr as PC).macros[macrosIndex].ToString().IndexOf(" ")); string newArgs = (chr as PC).macros[macrosIndex].ToString().Substring((chr as PC).macros[macrosIndex].ToString().IndexOf(" ") + 1); return(CommandTasker.ParseCommand(chr, command, newArgs)); } else { return(CommandTasker.ParseCommand(chr, (chr as PC).macros[macrosIndex].ToString(), "")); } } else { if (args.IndexOf(ProtocolYuusha.ISPLIT) != -1) { chr.WriteToDisplay("Your macro contains an illegal character. The character " + ProtocolYuusha.ISPLIT + " is reserved."); return(true); } if ((chr as PC).macros.Count >= macrosIndex + 1) { (chr as PC).macros[macrosIndex] = args; if (chr.protocol == DragonsSpineMain.Instance.Settings.DefaultProtocol) { ProtocolYuusha.SendCharacterMacros(chr as PC, chr as PC); } chr.WriteToDisplay("Macro " + macrosIndex + " has been set to \"" + args + "\"."); } else { (chr as PC).macros.Add(args); if (chr.protocol == DragonsSpineMain.Instance.Settings.DefaultProtocol) { ProtocolYuusha.SendCharacterMacros(chr as PC, chr as PC); } chr.WriteToDisplay("Macro " + macrosIndex + " has been set to \"" + args + "\"."); } } return(true); } catch (Exception e) { Utils.LogException(e); return(true); } }
public bool OnCommand(Character chr, string args) { if (args.IndexOf("book") != -1) // "read book" is the same as "flip book" { return(CommandTasker.ParseCommand(chr, "flip", args)); } bool rightHand = true; if (args == null) { if (chr.RightHand != null && chr.RightHand.baseType == Globals.eItemBaseType.Book) { return(CommandTasker.ParseCommand(chr, "flip", args)); } if (chr.RightHand != null && chr.RightHand.baseType == Globals.eItemBaseType.Scroll) { goto readScroll; } if (chr.LeftHand != null && chr.LeftHand.baseType == Globals.eItemBaseType.Book) { return(CommandTasker.ParseCommand(chr, "flip", args)); } if (chr.LeftHand != null && chr.LeftHand.baseType == Globals.eItemBaseType.Scroll) { rightHand = false; } } readScroll: // verification if ((rightHand && (chr.RightHand == null || chr.RightHand.baseType != Globals.eItemBaseType.Scroll)) || (!rightHand && (chr.LeftHand == null || chr.LeftHand.baseType != Globals.eItemBaseType.Scroll))) { chr.WriteToDisplay("You are unable to read that. Try bringing it to someone who can."); return(true); } Item scroll = rightHand ? chr.RightHand : chr.LeftHand; if ((scroll as Book).Pages == null || (scroll as Book).Pages[0] == "") { if (scroll.spell > -1) { GameSpell scrollSpell = GameSpell.GetSpell(chr.RightHand.spell); if (!scrollSpell.IsClassSpell(chr.BaseProfession)) { chr.WriteToDisplay("The " + scroll.name + " contains runes that are illegible to you."); } else { if (chr.spellDictionary.ContainsKey(scrollSpell.ID)) { chr.WriteToDisplay("The " + chr.RightHand.name + " contains the spell of " + scrollSpell.Name + "."); // TODO: Implement the ability to see how many charges and perhaps how powerful the spell is. } else { chr.WriteToDisplay("The " + scroll.name + " contains a " + Utils.FormatEnumString(chr.BaseProfession.ToString()).ToLower() + " spell that is unfamiliar to you." + (Skills.GetSkillLevel(chr.magic) >= scrollSpell.RequiredLevel ? " With enough effort you believe this scroll could be scribed into your spellbook." : "")); // TODO: Should the player be informed that the spell can be scribed or not? -- added 1/25/2019 Eb } } } else // blank scroll { chr.WriteToDisplay("The scroll is blank."); // TODO: Does this mean a spell can be added to the scroll? } } return(true); }