/// <summary> /// Purchase something in a shop. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Buy(CharData ch, string[] str) { if( ch == null ) return; string arg2 = String.Empty; string arg3 = String.Empty; string text; bool fPerm = false; if (str.Length == 0) { ch.SendText("Buy what?\r\n"); return; } if (ch.InRoom.HasFlag(RoomTemplate.ROOM_PET_SHOP)) { if (ch.IsNPC()) return; Room nextRoom = Room.GetRoom(ch.InRoom.IndexNumber + 1); if (nextRoom == null) { Log.Error("Buy: bad pet shop at index number {0}.", ch.InRoom.IndexNumber); ch.SendText("Sorry, you can't buy that here.\r\n"); return; } Room inRoom = ch.InRoom; ch.InRoom = nextRoom; CharData pet = ch.GetCharRoom(str[0]); ch.InRoom = inRoom; if (pet && ch.MaxPets()) { ch.SendText("Sorry, you can't keep track of that many pets.\r\n"); return; } if (pet == null || !pet.HasActionBit(MobTemplate.ACT_PET)) { ch.SendText("Sorry, you can't buy that here.\r\n"); return; } // Altered Pricing to match the ones that were given in the list // command below... original was set to 500 * pet.level * pet.level // Xangis tweaked it to 100 * pet level squared if (ch.GetCash() < ((100 * pet.Level) * pet.Level)) { ch.SendText("You can't afford it.\r\n"); return; } ch.SpendCash(((100 * pet.Level) * pet.Level)); pet = Database.CreateMobile(pet.MobileTemplate); pet.SetActionBit(MobTemplate.ACT_PET); pet.SetActionBit(MobTemplate.ACT_NOEXP); pet.SetAffectBit(Affect.AFFECT_CHARM); if (!String.IsNullOrEmpty(str[0])) { text = String.Format("{0} {1}", pet.Name, str[0]); pet.Name = text; } text = String.Format("{0}&+LA neck tag says '&+RI belong to {1}&+L'.&n\r\n", pet.Description, ch.Name); pet.Description = text; pet.AddToRoom(ch.InRoom); CharData.AddFollower(pet, ch); ch.SendText("Enjoy your pet.\r\n"); SocketConnection.Act("$n&n just purchased $N&n.", ch, null, pet, SocketConnection.MessageTarget.room); return; } ObjTemplate objTemplate; Object obj = null; CharData keeper; int itemCount = 1; /* buy only one by default */ if (MUDString.IsNumber(str[0])) { Int32.TryParse(str[0], out itemCount); str[0] = arg2; arg2 = arg3; } if (!(keeper = ch.FindShopkeeper(arg2))) { return; } if (!ch.IsNPC()) { // Won't sell to bottom 25% of faction range. if (((PC)ch).GetFaction(keeper) < (Limits.MIN_FACTION / 2)) { SocketConnection.Act("$n&+W tells you 'I won't do business with scum like you.'&n", keeper, null, ch, SocketConnection.MessageTarget.victim); ch.ReplyTo = keeper; return; } } if (keeper.MobileTemplate.ShopData.ItemsForSale.Count != 0) { foreach (int item in keeper.MobileTemplate.ShopData.ItemsForSale) { objTemplate = Database.GetObjTemplate(item); if (!objTemplate) { continue; } if (MUDString.NameContainedIn(str[0], objTemplate.Name)) { obj = Database.CreateObject(objTemplate, objTemplate.Level); fPerm = true; break; } } } if (!obj) { obj = keeper.GetObjCarrying(str[0]); } if (!obj || !CharData.CanSeeObj(ch, obj)) { SocketConnection.Act("$n&+W tells you 'I don't sell that -- try 'list'.'&n", keeper, null, ch, SocketConnection.MessageTarget.victim); ch.ReplyTo = keeper; return; } int cost = Object.GetCost(ch, keeper, obj, true); if (cost < obj.Cost) { Log.Error("Shopkeeper with index number {0} sells for less than 100 percent of value.\r\n", keeper.MobileTemplate.IndexNumber); cost = obj.Cost; } if (itemCount < 1) { ch.SendText("Buy how many? Quantity must be greater than zero.\r\n"); return; } if (ch.GetCash() < (cost * itemCount)) { if (itemCount == 1) { SocketConnection.Act("$n&+W tells you 'You can't afford to buy $p&+W.'&n", keeper, obj, ch, SocketConnection.MessageTarget.victim); ch.ReplyTo = keeper; return; } else { string buf4; if ((ch.GetCash() / cost) > 0) { buf4 = String.Format("$n&+W tells you, 'You can only afford {0} of those!'&n", (ch.GetCash() / cost)); } else { buf4 = String.Format("$n&+W tells you, 'You can't even afford one!'&n"); } SocketConnection.Act(buf4, keeper, obj, ch, SocketConnection.MessageTarget.victim); ch.ReplyTo = keeper; return; } } if (ch.CarryNumber + itemCount > ch.GetMaxItemsCarried()) { ch.SendText("You cannot carry that many items.\r\n"); return; } if (ch.CarryWeight + (itemCount * obj.GetWeight()) > ch.MaxCarryWeight()) { ch.SendText("You cannot carry that much weight.\r\n"); return; } if ((itemCount > 1) && !obj.HasFlag(ObjTemplate.ITEM_INVENTORY)) { SocketConnection.Act("$n&+W tells you, 'Sorry, $p&+W is something I have only one of.'&n", keeper, obj, ch, SocketConnection.MessageTarget.character); ch.ReplyTo = keeper; return; } if (cost < 1) cost = 1; if (itemCount == 1) { text = String.Format("You buy $p&n for {0}.", StringConversion.CoinString(cost * itemCount)); SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n purchases $p&n.", ch, obj, null, SocketConnection.MessageTarget.room); } else { text = String.Format("$n&n purchases {0} * $p&n.", itemCount); SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.room); text = String.Format("You buy {0} * $p&n.", itemCount); SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character); } ch.SpendCash(cost * itemCount); if (fPerm) { obj.ObjToChar(ch); } else if (obj.HasFlag(ObjTemplate.ITEM_INVENTORY)) { for (; itemCount > 0; itemCount--) { obj = Database.CreateObject(obj.ObjIndexData, obj.Level); obj.ObjToChar(ch); } } else { obj.RemoveFromChar(); obj.ObjToChar(ch); } obj.Timer = -1; // Selling an object decreases its scarcity. --obj.ObjIndexData.Scarcity; return; }
/// <summary> /// Bandage someone's wounds. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Bandage(CharData ch, string[] str) { if( ch == null ) return; if (ch.IsNPC() || !ch.HasSkill("bandage")) { ch.SendText("You don't know how to bandage!\r\n"); return; } if (str.Length == 0) { ch.SendText("Bandage whom?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (victim == null) { ch.SendText("They're not here.\r\n"); return; } if (victim.Hitpoints > 0) { ch.SendText("They do not need your help.\r\n"); return; } int chance = ((PC)ch).SkillAptitude["bandage"]; if (ch.IsClass(CharClass.Names.cleric)) chance += 4; else if (ch.IsClass(CharClass.Names.antipaladin)) chance -= 4; /* Don't allow someone doing more than 1 pt. of damage with bandage. */ int change = (Math.Max(chance - MUDMath.NumberPercent(), -1) / 20) + 1; // Bandage is rarely used, make it likely to increase ch.PracticeSkill("bandage"); ch.PracticeSkill("bandage"); ch.PracticeSkill("bandage"); ch.WaitState(Skill.SkillList["bandage"].Delay); if (change < 0) { ch.SendText("You just made the problem worse!\r\n"); SocketConnection.Act("$n&n tries bandage you but your condition only worsens.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n tries bandage $N&n but $S condition only worsens.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); } else if (change > 0) { ch.SendText("You manage to fix them up a _bitvector.\r\n"); SocketConnection.Act("$n&n bandages you.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n bandages $N&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); } else { ch.SendText("Your bandaging attempt had no effect.\r\n"); SocketConnection.Act("$n&n tries to bandage you but the wounds are too great.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n tries to bandage $N&n but is unable to have any effect.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); } victim.Hitpoints += change; victim.UpdatePosition(); return; }
/* * Modified to up the damage and allow for a * chance to stun victim or self * damage = (level) d2, for an average of 75 hp at level 50 * stun damage = (level) d3, for an average of 100 hp at level 50 * Player vs player damage is reduced in damage() */ /// <summary> /// Headbutt. Usable to initiate combat and during combat. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Headbutt(CharData ch, string[] str) { if( ch == null ) return; int chance; int ko; string text; /* Check player's level and class, mobs can use this skill */ if ((!ch.HasSkill("headbutt"))) { ch.SendText("Your skull is much too soft to headbutt anyone.\r\n"); return; } if (ch.IsBlind()) { return; } CharData victim = ch.Fighting; if (str.Length != 0) { if (!(victim = ch.GetCharRoom(str[0])) || victim.CurrentPosition == Position.dead) { ch.SendText("They are nowhere to be seen.\r\n"); return; } } else { if (!victim || victim.CurrentPosition == Position.dead) { ch.SendText("You aren't fighting anyone.\r\n"); return; } } /* anti headbutt me code */ if (ch == victim) { ch.SendText("You get dizzy as you ponder the mechanics of headbutting yourself.\r\n"); return; } if (ch.CurrentPosition < Position.fighting) { ch.SendText("You need to stand up to do that.\r\n"); return; } /* Check size of ch vs. victim. */ /* If ch is too small. */ /* Made it 2 sizes */ if (ch.CurrentSize - 2 > victim.CurrentSize) { SocketConnection.Act("You would crush such a small and delicate being with your mass.", ch, null, victim, SocketConnection.MessageTarget.character); return; } /* Ch 2 or more sizes larger than victim => bad! */ if (ch.CurrentSize + 1 < victim.CurrentSize) { SocketConnection.Act("You can't reach their head!", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n slams $s head into your thigh.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n slams $s head into $N's thigh.", ch, null, victim, SocketConnection.MessageTarget.room_vict); ch.WaitState((Skill.SkillList["headbutt"].Delay * 9) / 10); if (victim.Fighting == null) { Combat.SetFighting(victim, ch); } return; } ch.WaitState(MUDMath.FuzzyNumber(Skill.SkillList["headbutt"].Delay)); ch.PracticeSkill("headbutt"); if (!ch.Fighting) { Combat.SetFighting(ch, victim); } if (!victim.Fighting) { Combat.SetFighting(victim, ch); } /* Added a PC skill level */ // Chance was over-downgraded at some point. Was skill level - 5%, // then it was changed to skill level / 2 giving a level 50 a headbutt // success rate of about 47%. I've upped it to 4/5 of skill level, // meaning that a level 50 has a success rate of 76%, which is a good // target success rate. Keep in mind minotaur will have a success rate of // about 83%. if (ch.IsNPC()) { chance = 50 + ch.Level; } else { chance = ((PC)ch).SkillAptitude["headbutt"] * 4 / 5; } // Minotaur headbutt bonus if (ch.GetRace() == Race.RACE_MINOTAUR) { chance += 7; } if (victim.CurrentPosition < Position.fighting) { chance /= 3; } if (MUDMath.NumberPercent() < chance) /* Headbutt successful, possible KO */ { /* First give the victim a chance to dodge */ if (Combat.CheckDodge(ch, victim)) { return; } /* OK, lets settle for stun right now * a skill level of 100% has a 20% chance of stun * a skill level of 50% has a 2.5% chance of stun * a skill level of 23% has a 1% chance of stun * immortals get a 15% bonus */ // The stun math was bad. Stun was way more often that it should have // been. Now we have a flat /4 chance, meaning a the following stun chances // at each skill level: // 25 = 5% 50 = 10 % 75 = 15% 95 = 19% ko = chance / 4; if (ch.IsImmortal()) { ko += 15; } text = String.Format("Commandheadbutt: {0}&n attempting a KO with {1}%% chance.", ch.Name, ko); ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, text); if (MUDMath.NumberPercent() < ko + 1) { // deal some decent damage // This was previously level d 3 which was fairly pathetic. // Level d 8 = 50 min, 400 max at level 50 with an average of 225 // PvP damage is quartered, so headbutt will do about 56 against a player. if (ch.GetRace() != Race.RACE_MINOTAUR) { Combat.InflictDamage(ch, victim, MUDMath.Dice(ch.Level, 8), "headbutt", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } else { Combat.InflictDamage(ch, victim, MUDMath.Dice(ch.Level, 9), "headbutt", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } if (victim.CurrentPosition > Position.stunned) { SocketConnection.Act("$n&n staggers about, then collapses in a heap.", victim, null, null, SocketConnection.MessageTarget.room); victim.SendText("You fall to the ground &+Wstunned&n.\r\n"); SocketConnection.Act("$n&n is &+Wstunned!&n", victim, null, null, SocketConnection.MessageTarget.room); victim.CurrentPosition = Position.stunned; victim.WaitState((Skill.SkillList["headbutt"].Delay)); text = String.Format("Commandheadbutt: {0}&n stunned {1}&n.", ch.Name, victim.Name); ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, text); } } else { // just your ordinary headbutt damage // This was previously level d 2 which was fairly pathetic. // Level d 6 = 50 min, 300 max at level 50 with an average of 175 // PvP damage is quartered, so headbutt will do about 43 against a player. if (ch.GetRace() != Race.RACE_MINOTAUR) { if (!Combat.InflictDamage(ch, victim, MUDMath.Dice(ch.Level, 6), "headbutt", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon)) { // Someone blasts you in the head it'll definitely stun you for 3/4 of a second. victim.WaitState(3); } } else { if (!Combat.InflictDamage(ch, victim, MUDMath.Dice(ch.Level, 7), "headbutt", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon)) { // Someone blasts you in the head with horns it'll definitely stun you for a second. // -- Xangis victim.WaitState(4); } } } } else /* Headbutt failed, possible damgage to self, possible KO of self */ { /* Don't allow char to kill self, just mort self */ /* Give them a chance to not take any damage */ // Checking chance instead of player's level. Since this should be based on skill // this should be about right (average of 24% chance of screwing yourself at level 50 // instead of 50%, 17% chance for minos). if (MUDMath.NumberPercent() < chance) { ch.SendText("Your headbutt fails to strike its target.\r\n"); SocketConnection.Act("$n&n tries to headbutt $N&n but can't quite connect.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); SocketConnection.Act("$n&n bobs around you in a feeble attempt at a headbutt.", ch, null, victim, SocketConnection.MessageTarget.victim); return; } SocketConnection.Act("You bang your head against the brick wall of $N&n.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n tries a headbutt but $N&n gets the best of $m.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); SocketConnection.Act("$n&n bangs into you in a feeble attempt at a headbutt.", ch, null, victim, SocketConnection.MessageTarget.victim); // KO chance of 24% for normals, 17% for minos. // You have to fail three checks to get your ass kicked by KO, one for the actual skill check, // one for the damage check and finally one for the KO check. // keep in mind this KO does damage of about 100 to self at level 50, which is a hell of a lot // for a failed skill. // The chance of ko'ing yourself at each skill level is as follows: (after all 3 checks) // Skill 25 = 59.2% Skill 50 = 29.6% Skill 75 = 14.4% Skill 95 = 9.38% ko = 108 - chance; int dam; if (MUDMath.NumberPercent() < ko) { // doh! This is gonna hurt //deal some decent damage...to self! if (ch.GetRace() != Race.RACE_MINOTAUR) { dam = MUDMath.Dice(ch.Level, 3); } else { dam = MUDMath.Dice(ch.Level, 2); } if (dam > ch.Hitpoints) { dam = ch.Hitpoints + 1; } if (Combat.InflictDamage(ch, ch, dam, "headbutt", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon)) { // ch invalidated, can't send messages. return; } SocketConnection.Act("$n&n staggers about, then collapses in a heap.", ch, null, null, SocketConnection.MessageTarget.room); ch.SendText("You fall to the ground stunned.\r\n"); SocketConnection.Act("$n&n is stunned!", ch, null, null, SocketConnection.MessageTarget.room); ch.CurrentPosition = Position.stunned; ch.WaitState((Skill.SkillList["headbutt"].Delay * 2)); text = String.Format("Commandheadbutt: {0}&n stunned self.", ch.Name); ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, text); } else { // Was previously level d 2, which averaged 30 damage at 20 and 75 at 50. PC to PC // damage is not quartered when it is done to yourself, so this it kind of high at the // upper levels. This has been reduced by level / 5, so the damage at 50 averages 65 // instead of 65. // Keep in mind that the real penalties come from KO and comparitively someone that // fails a bash doesen't take insane damage. dam = MUDMath.Dice(ch.Level, 2) - ch.Level / 5; if (dam > ch.Hitpoints) { dam = ch.Hitpoints + 1; } Combat.InflictDamage(ch, ch, dam, "headbutt", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } } //end if() headbutt failed return; }
/// <summary> /// Stab someone in the back. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Backstab(CharData ch, string[] str) { if( ch == null ) return; if (!ch.HasSkill("backstab")) { ch.SendText("You better leave the assassination trade to those more skilled.\r\n"); return; } if (ch.IsBlind()) { return; } if (ch.Riding) { ch.SendText("You can't get close enough while mounted.\r\n"); return; } if (str.Length == 0) { ch.SendText("Backstab whom?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They aren't here.\r\n"); return; } if (victim == ch) { ch.SendText("How can you sneak up on yourself?\r\n"); return; } Combat.Backstab(ch, victim); return; }
public static void Glance(CharData ch, string[] str) { if( ch == null ) return; if (str.Length == 0) { ch.SendText("&nGlance at whom?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("&nThey're not here.\r\n"); return; } string msg = String.Format("&nYou glance at $N&n.\r\n$N&n is {0}.", SocketConnection.ConditionString(victim)); SocketConnection.Act(msg, ch, null, victim, SocketConnection.MessageTarget.character); Look.ShowAffectLines(ch, victim); return; }
/// <summary> /// Throw dirt in someone's eyes. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void DirtToss(CharData ch, string[] str) { if( ch == null ) return; int percent; /* Don't allow the unskilled to do this, check player's level */ if (!ch.HasSkill("dirt toss")) { ch.SendText("You get your feet dirty.\r\n"); return; } if (ch.IsBlind()) { ch.SendText("You can't see anything!\r\n"); return; } if (ch.FlightLevel != 0) { ch.SendText("Perhaps you should land first matey.\r\n"); return; } CharData victim = ch.Fighting; if (str.Length != 0) { if (!(victim = ch.GetCharRoom(str[0])) || victim.CurrentPosition == Position.dead) { ch.SendText("They aren't here.\r\n"); return; } } if (!victim || victim.CurrentPosition == Position.dead) { ch.SendText("You aren't fighting anyone.\r\n"); return; } if (victim == ch) { ch.SendText("How about sticking a fork your eye instead?\r\n"); return; } if (victim.IsAffected( Affect.AFFECT_BLIND)) { SocketConnection.Act("$E's already been &+Lblinded&n.", ch, null, victim, SocketConnection.MessageTarget.character); return; } if (!ch.IsNPC()) { percent = ((PC)ch).SkillAptitude["dirt toss"]; } else { percent = (ch.Level * 3) / 2 + 25; } percent += (ch.Level - victim.Level) * 2; percent += (ch.GetCurrDex() / 10); percent -= (victim.GetCurrDex() / 10); percent -= (victim.GetCurrAgi() / 10); // Why waste time listing sectors with no modifier? switch (ch.InRoom.TerrainType) { case TerrainType.inside: case TerrainType.arctic: case TerrainType.swamp: percent -= 20; break; case TerrainType.city: case TerrainType.mountain: percent -= 10; break; case TerrainType.plane_of_fire: case TerrainType.plane_of_air: case TerrainType.plane_of_water: case TerrainType.plane_ethereal: case TerrainType.plane_astral: case TerrainType.underwater_has_ground: case TerrainType.underwater_no_ground: case TerrainType.swimmable_water: case TerrainType.unswimmable_water: case TerrainType.air: case TerrainType.ocean: case TerrainType.underground_swimmable_water: case TerrainType.underground_unswimmable_water: percent = 0; break; case TerrainType.field: percent += 5; break; case TerrainType.desert: percent += 10; break; case TerrainType.plane_of_earth: percent += 15; break; default: break; } if (percent > 75) { percent = 75; } else if (percent < 5) { percent = 5; } if (percent <= 0) { ch.SendText("There isn't any &n&+ydirt&n to kick.\r\n"); return; } ch.PracticeSkill("dirt toss"); if (percent < MUDMath.NumberPercent()) { Affect af = new Affect(); SocketConnection.Act("$n is &+Lblinded&n by the &n&+ydirt&n in $s eyes!", victim, null, null, SocketConnection.MessageTarget.room); SocketConnection.Act("$n kicks &n&+ydirt&n into your eyes!", ch, null, victim, SocketConnection.MessageTarget.victim); victim.SendText("&+LYou can't see a thing!&n\r\n"); af.Value = "dirt toss"; af.Type = Affect.AffectType.skill; af.Duration = MUDMath.NumberRange(1, 2); af.AddModifier(Affect.Apply.hitroll, -4); af.SetBitvector(Affect.AFFECT_BLIND); victim.AddAffect(af); } else { ch.SendText("&+LYou kick dirt at your target!&n\r\n"); } Combat.SetFighting(victim, ch); ch.WaitState(Skill.SkillList["dirt toss"].Delay); return; }
/// <summary> /// Assist someone in combat by joining them against their primary target. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Assist(CharData ch, string[] str) { if( ch == null ) return; CharData victim; if (!ch.IsBlind()) { ch.SendText("You can't assist the invisible.\r\n"); return; } if (ch.Fighting) { ch.SendText("You're a bit busy at the moment.\r\n"); return; } if (str.Length != 0) { victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They aren't here.\r\n"); return; } } else { ch.SendText("Assist who?\r\n"); return; } if (victim == ch) { ch.SendText("You're too busy assisting yourself to assist yourself.\r\n"); return; } if (!victim.Fighting) { ch.SendText("They're not fighting anyone.\r\n"); return; } if (victim.Fighting == ch) { ch.SendText("Assist!? They're fighting YOU, fool!\r\n"); return; } SocketConnection.Act("You scream a battle cry, and assist $N&n heroically.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n leaps into the fray, valiantly assisting you.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n charges into battle and assists $N&n heroically.", ch, null, victim, SocketConnection.MessageTarget.room_vict); Combat.SingleAttack(ch, victim.Fighting, String.Empty, ObjTemplate.WearLocation.hand_one); return; }
public static void Trust(CharData ch, string[] str) { if( ch == null ) return; CharData victim; string arg1 = String.Empty; string arg2 = String.Empty; int level; CharData realChar = ch.GetChar(); if (!realChar.Authorized("trust")) { return; } if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2) || !MUDString.IsNumber(arg2)) { ch.SendText("Syntax: trust <char> <level>.\r\n"); return; } if (!(victim = ch.GetCharRoom(arg1))) { ch.SendText("That player is not here.\r\n"); return; } Int32.TryParse(arg2, out level); if (level < 1 || level > Limits.MAX_LEVEL) { ch.SendText(String.Format("Trust within range 1 to {0}.\r\n", Limits.MAX_LEVEL)); return; } if (level > ch.GetTrust()) { ch.SendText("Limited to your trust.\r\n"); return; } string text = String.Format("{0} has been trusted at level {1} by {2}", victim.Name, level, ch.Name); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LEVELS, realChar.GetTrust(), text); victim.TrustLevel = level; return; }
/// <summary> /// Try to free someone who has been bound. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Untangle(CharData ch, string[] str) { if( ch == null ) return; CharData victim; if (!ch.IsNPC() && !ch.HasSkill("untangle")) { ch.SendText("You aren't nimble enough.\r\n"); return; } if (str.Length == 0) { victim = ch; } else { victim = ch.GetCharRoom(str[0]); if (victim == null) { ch.SendText("They aren't here.\r\n"); return; } } if (!victim.HasAffect( Affect.AffectType.skill, "capture")) { ch.SendText("There's nothing to untangle.\r\n"); return; } if ((ch.IsNPC() && !ch.IsAffected( Affect.AFFECT_CHARM)) || (!ch.IsNPC() && MUDMath.NumberPercent() < ((PC)ch).SkillAptitude["untangle"])) { victim.AffectStrip( Affect.AffectType.skill, "capture"); if (victim != ch) { SocketConnection.Act("You untangle $N&n.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n untangles you.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n untangles $n&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); } else { ch.SendText("You untangle yourself.\r\n"); SocketConnection.Act("$n&n untangles $mself.", ch, null, null, SocketConnection.MessageTarget.room); } ch.PracticeSkill("untangle"); return; } }
/// <summary> /// Immortal command to change a player's level. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Advance(CharData ch, string[] str) { if( ch == null ) return; CharData victim; string text; int level = 0; int iLevel = 0; CharData realChar = ch.GetChar(); if (!realChar.Authorized("advance")) { return; } if (str.Length < 2 || String.IsNullOrEmpty(str[0]) || String.IsNullOrEmpty(str[1]) || !MUDString.IsNumber(str[1])) { ch.SendText("Syntax: advance <char> <level>.\r\n"); return; } if (!(victim = ch.GetCharRoom(str[0]))) { ch.SendText("That player is not here.\r\n"); return; } if (victim.IsNPC()) { ch.SendText("Not on NPC's.\r\n"); return; } Int32.TryParse(str[1], out level); if (level < 1 || level > Limits.MAX_LEVEL) { ch.SendText(String.Format("Advance within range 1 to {0}.\r\n", Limits.MAX_LEVEL)); return; } if (level > ch.GetTrust()) { ch.SendText("Limited to your trust level.\r\n"); return; } /* * Lower level: * Reset to level 1. * Then raise again. * Currently, an imp can lower another imp. */ if (level <= victim.Level) { ch.SendText("Lowering a player's level!\r\n"); victim.SendText("**** OOOOHHHHHHHHHH NNNNOOOO ****\r\n"); victim.Level = 1; // Max_hit should only be accessed for PERMENANT changes. victim.MaxHitpoints = 20; if (ch.CharacterClass.GainsMana) { victim.MaxMana = 50; // Mana bonuses for newbies. victim.MaxMana += (victim.GetCurrInt() / 10); victim.MaxMana += (victim.GetCurrWis() / 14); victim.MaxMana += (victim.GetCurrPow() / 7); } else { victim.MaxMana = 0; } victim.MaxMoves = 150; // removed resetting of skills. victim.Hitpoints = victim.GetMaxHit(); victim.CurrentMana = victim.MaxMana; victim.CurrentMoves = victim.MaxMoves; text = String.Format("{0} has been demoted to level {1} by {2}", victim.Name, level, ch.Name); ImmortalChat.SendImmortalChat(victim, ImmortalChat.IMMTALK_LEVELS, realChar.GetTrust(), text); } else { ch.SendText("Raising a player's level!\r\n"); victim.SendText("**** OOOOHHHHHHHHHH YYYYEEEESSS ****\r\n"); text = String.Format("{0} has been advanced to level {1} by {2}", victim.Name, level, ch.Name); ImmortalChat.SendImmortalChat(victim, ImmortalChat.IMMTALK_LEVELS, realChar.GetTrust(), text); } // Do not advance skills -- rerolling someone will auto-master // their skills with no effort from the player... so we advance // them with skills set to false -- Xangis for (iLevel = victim.Level; iLevel < level; iLevel++) { victim.AdvanceLevel(victim); } victim.ExperiencePoints = 1; victim.TrustLevel = 0; return; }
/// <summary> /// Attempt to trip a foe. Can initiate combat with this and can use during combat. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Trip(CharData ch, string[] str) { if( ch == null ) return; int chance; /* Check player's level and class, mobs can use this skill */ if ((!ch.HasSkill("trip"))) { ch.SendText("You would just fall over if you tried to trip someone.\r\n"); return; } if (ch.IsBlind()) { return; } CharData victim = ch.Fighting; if (str.Length != 0) { victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("You look around, unable to find them.\r\n"); return; } } else { if (!victim) { ch.SendText("You aren't fighting anyone.\r\n"); return; } } /* anti 'trip me' code */ if (victim == ch) { ch.SendText("You don't think you're clumsy enough already?\r\n"); return; } ch.WaitState(MUDMath.FuzzyNumber(Skill.SkillList["trip"].Delay)); ch.PracticeSkill("trip"); if (ch.IsNPC()) { chance = (ch.Level * 3) / 2 + 10; } else { chance = ((PC)ch).SkillAptitude["trip"]; } if (chance > 90) { chance = 90; } if ((ch.Fighting == null) && (ch != victim)) { Combat.SetFighting(ch, victim); } if ((!victim.Fighting) && (victim != ch)) { Combat.SetFighting(victim, ch); } /* Mobs do NOT auto-trip! */ if (MUDMath.NumberPercent() < chance) { victim.WaitState((Skill.SkillList["trip"].Delay * 5 / 6)); SocketConnection.Act("You trip $N&n and send $M sprawling to the &n&+yearth&n!", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n trips you and you go down!", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n trips $N&n and $E falls face-first to the &n&+yground&n!", ch, null, victim, SocketConnection.MessageTarget.room_vict); if (victim.CurrentPosition > Position.reclining) { victim.CurrentPosition = Position.reclining; } } else { SocketConnection.Act("You try to trip $N&n and fall down!", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n attempts to knock you from your feet, and falls down $sself!", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n tries to trip $N&n and tumbles to the &n&+yground&n!", ch, null, victim, SocketConnection.MessageTarget.room_vict); ch.CurrentPosition = Position.reclining; } return; }
/// <summary> /// Capture command - restrain another character. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Capture(CharData ch, string[] str) { if( ch == null ) return; CharData victim; Affect af = new Affect(); /* Check player's level and class, allow mobs to do this too */ if ((!ch.HasSkill("capture"))) { ch.SendText("You couldn't capture a dead rat.\r\n"); return; } if (str.Length == 0) { victim = ch.Fighting; if (!victim) { ch.SendText("Capture whom?\r\n"); return; } } else /* argument supplied */ { victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They aren't here.\r\n"); return; } } if (ch.Fighting && ch.Fighting != victim) { ch.SendText("Take care of the person you are fighting first!\r\n"); return; } if (!ch.IsImmortal()) { ch.WaitState(Skill.SkillList["capture"].Delay); } Object rope = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one); if (!rope || rope.ItemType != ObjTemplate.ObjectType.rope) { rope = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_two); if (!rope || rope.ItemType != ObjTemplate.ObjectType.rope) { rope = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_three); if (!rope || rope.ItemType != ObjTemplate.ObjectType.rope) { rope = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_four); if (!rope || rope.ItemType != ObjTemplate.ObjectType.rope) rope = null; } } } if (!rope) { ch.SendText("You must have some rope to tie someone up!\r\n"); return; } rope.RemoveFromWorld(); /* only appropriately skilled PCs and uncharmed mobs */ if ((ch.IsNPC() && !ch.IsAffected( Affect.AFFECT_CHARM)) || (!ch.IsNPC() && MUDMath.NumberPercent() < ((PC)ch).SkillAptitude["capture"] / 4)) { victim.AffectStrip( Affect.AffectType.skill, "capture"); af.Value = "capture"; af.Type = Affect.AffectType.skill; af.Duration = 3 + ((ch.Level) / 8); af.SetBitvector(Affect.AFFECT_BOUND); victim.AddAffect(af); SocketConnection.Act("You have captured $M!", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n has captured you!", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n has captured $N&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); } else { SocketConnection.Act("You failed to capture $M. Uh oh!", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n tried to capture you! Get $m!", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n attempted to capture $N&n, but failed!", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); } /* go for the one who wanted to fight :) */ if (ch.IsNPC() && ch.IsAffected( Affect.AFFECT_CHARM) && !victim.Fighting) { victim.AttackCharacter(ch.Master); } else if (!victim.Fighting) { victim.AttackCharacter(ch); } return; }
/// <summary> /// Steal an object or some coins from a victim. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Steal(CharData ch, string[] str) { if( ch == null ) return; Object obj = null; CharData victim; bool sleeping = false; string arg1 = String.Empty; string arg2 = String.Empty; string arg = String.Empty; int percent; if (!ch.HasSkill("steal") && !ch.IsAffected(Affect.AFFECT_CHARM)) { ch.SendText("Who are you trying to kid? You couldn't steal shoes from a &n&+mbl&+Mo&n&+ma&+Mte&n&+md&n corpse.\r\n"); return; } if (ch.Riding != null) { ch.SendText("You can't do that while mounted.\r\n"); return; } if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2)) { ch.SendText("Steal what from whom?\r\n"); return; } if ((victim = ch.GetCharRoom(arg2)) == null) { ch.SendText("They aren't here.\r\n"); return; } if (victim == ch) { ch.SendText("That's pointless.\r\n"); return; } if (Combat.IsSafe(ch, victim)) return; if (!ch.IsImmortal()) { ch.WaitState(Skill.SkillList["steal"].Delay); } // Justice stuff Crime.CheckThief(ch, victim); if (ch.IsNPC()) { percent = ch.Level * 2; } else { percent = ((PC)ch).SkillAptitude["steal"]; } percent += ch.GetCurrLuck() / 20; /* Luck */ percent -= victim.Level; /* Character level vs victim's */ if (ch.GetRace() == Race.RACE_HALFLING) { // Halflings get a racial bonus percent += 10; } if (victim.IsAffected(Affect.AFFECT_CURSE)) percent += 15; if (ch.IsAffected(Affect.AFFECT_CURSE)) percent -= 15; if (!victim.IsAwake()) percent += 25; /* Sleeping characters are easier */ if (ch.CheckSneak()) percent += 10; /* Quiet characters steal better */ if (!CharData.CanSee(ch, victim)) percent += 10; /* Unseen characters steal better */ if (!MUDString.IsPrefixOf(arg1, "coins")) { percent = (int)(percent * 1.2); /* Cash is fairly easy to steal */ } else { int number = MUDString.NumberArgument(arg1, ref arg); int count = 0; foreach (Object iobj in victim.Carrying) { if (CharData.CanSeeObj(ch, iobj) && MUDString.NameContainedIn(arg, iobj.Name)) { if (++count == number) { obj = iobj; break; } } } if (!obj) { ch.SendText("You can't find it.\r\n"); return; } if (ch.Level < victim.Level) { // stealing from higher level is possible, but harder percent -= 5 * (victim.Level - ch.Level); } else { // slight bonus for mobs lower level percent += (ch.Level - victim.Level); } if (obj.WearLocation == ObjTemplate.WearLocation.none) /* Items worn are harder */ percent = (int)(percent * .8); else percent = (int)(percent * .4); } ch.PracticeSkill("steal"); if (percent > 85) percent = 85; if (percent < 2) percent = 2; if (percent < MUDMath.NumberPercent()) { /* * Failure. */ //strip sneak ch.RemoveAffect(Affect.AFFECT_SNEAK); // chance of removing invis if (ch.IsAffected(Affect.AFFECT_INVISIBLE) && MUDMath.NumberPercent() > percent) { ch.SendText("You really bungled that attempt.\r\n"); ch.RemoveAffect(Affect.AFFECT_INVISIBLE); } else { ch.SendText("Oops.\r\n"); } SocketConnection.Act("$n&n tried to steal from $N&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); if (victim.IsAwake()) { SocketConnection.Act("$n&n tried to steal from you!", ch, null, victim, SocketConnection.MessageTarget.victim); } else { sleeping = true; } // Thief flag for justice. // Added so blind mobs dont hit who ever failed steal from em. if (victim.IsNPC()) { if (!sleeping && !victim.IsBlind()) { CommandType.Interpret(victim, "kill " + ch.Name); } } else { if (!victim.IsBlind() && !sleeping && victim.IsAffected(Affect.AFFECT_BERZERK)) { victim.SendText("In your &+Rblood rage&n, you lash out in anger!\r\n"); CommandType.Interpret(victim, "kill " + ch.Name); } } /* if ( !Macros.IS_SET( ch.actflags, PC.PLAYER_THIEF ) ) { Macros.SET_BIT( ref ch.actflags, PC.PLAYER_THIEF ); buf = String.Format( "{0} became a THIEF by stealing from {1}", ch._name, victim._name ); Immtalk.Immtalk( ch, Immtalk.IMMTALK_CRIME, ch.GetTrust(), buf ); CharData.SavePlayer( ch ); } */ // } if (sleeping) { if (MUDMath.NumberPercent() < victim.GetCurrLuck()) { CommandType.Interpret(victim, "wake"); } } return; } //end failure if (!MUDString.IsPrefixOf(arg1, "coins")) { int amount = victim.GetGold() * MUDMath.NumberRange(1, 20) / 100; int amount2 = victim.GetSilver() * MUDMath.NumberRange(1, 20) / 100; int amount3 = victim.GetCopper() * MUDMath.NumberRange(1, 20) / 100; int amount4 = victim.GetPlatinum() * MUDMath.NumberRange(1, 20) / 100; if ((amount + amount2 + amount3 + amount4) <= 0) { ch.SendText("You couldn't get any &n&+wcoins&n.\r\n"); return; } ch.ReceiveGold(amount); ch.ReceiveSilver(amount2); ch.ReceiveCopper(amount3); ch.ReceivePlatinum(amount4); victim.SpendGold(amount); victim.SpendSilver(amount2); victim.SpendCopper(amount3); victim.SpendPlatinum(amount4); string text = String.Format("Success! You got {0} &+Wplatinum&n, {1} &+Ygold&n, {2} silver, and {3} &+ycopper&n.\r\n", amount2, amount3, amount, amount4); ch.SendText(text); return; } if (!ch.CanDropObject(obj) || obj.HasFlag(ObjTemplate.ITEM_INVENTORY)) { ch.SendText("You can't pry it away.\r\n"); return; } if (ch.CarryNumber + 1 > Limits.MAX_CARRY) { ch.SendText("You have your hands full.\r\n"); return; } if (ch.CarryWeight + obj.GetWeight() > ch.MaxCarryWeight()) { ch.SendText("You cannot carry that much weight.\r\n"); return; } if (obj.WearLocation != ObjTemplate.WearLocation.none) { ch.SendText("Very daring, and you got it!\r\n"); victim.UnequipObject(obj); } obj.RemoveFromChar(); obj.ObjToChar(ch); ch.SendText("Nice work.\r\n"); if (obj.Trap != null && obj.Trap.CheckTrigger( Trap.TriggerType.steal)) { ch.SetOffTrap(obj); if (ch.CurrentPosition == Position.dead) { return; } } return; }
/// <summary> /// Springleap. Can be used to initiate combat and can be used during combat. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Springleap(CharData ch, string[] str) { if( ch == null ) return; int chance; /* Check player's level and class, mobs can use this skill */ if ((!ch.HasSkill("springleap"))) { ch.SendText("You'd better leave the martial arts to Bruce Lee.\r\n"); return; } if (ch.GetRace() == Race.RACE_CENTAUR) { ch.SendText("Your anatomy prevents you from springleaping.\r\n"); return; } if (ch.IsBlind()) { return; } CharData victim = ch.Fighting; if (str.Length != 0) { if (!(victim = ch.GetCharRoom(str[0])) || victim.CurrentPosition == Position.dead) { ch.SendText("You don't see them here.\r\n"); return; } } else { if (!victim || victim.CurrentPosition == Position.dead) { ch.SendText("You aren't fighting anyone.\r\n"); return; } } /* springleap self */ if (ch == victim) { ch.SendText("You can't quite figure out how to do that.\r\n"); return; } /* Check size of ch vs. victim. */ /* If ch is too small. */ if (ch.CurrentSize - 2 > victim.CurrentSize) { SocketConnection.Act("Your acrobatic maneuver cannot accurately leap into such a small being.", ch, null, victim, SocketConnection.MessageTarget.character); return; } /* Ch 2 or more sizes larger than victim => bad! */ if (ch.CurrentSize + 2 < victim.CurrentSize) { SocketConnection.Act("Your acrobatic maneuver does not seem to work on someone so large.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n jumps into you, and slides down your leg.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n jumps into $N&n and slides down $S leg.", ch, null, victim, SocketConnection.MessageTarget.room_vict); ch.WaitState(Skill.SkillList["springleap"].Delay); ch.CurrentPosition = Position.reclining; if (victim.Fighting == null) { Combat.SetFighting(victim, ch); } return; } ch.WaitState(MUDMath.FuzzyNumber(Skill.SkillList["springleap"].Delay)); ch.PracticeSkill("springleap"); if (ch.IsNPC()) { chance = (ch.Level * 3) / 2 + 15; } else { chance = ((PC)ch).SkillAptitude["springleap"] - 5; } if (chance > 95) { chance = 95; } if (victim.CurrentPosition < Position.fighting) { chance /= 4; } if (MUDMath.NumberPercent() < chance) { ch.CurrentPosition = Position.fighting; SocketConnection.Act("&+WYour springleap knocks $N&n&+W on $S butt.&n", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("&+W$n&n&+W leaps gracefully at $N&n&+W, sending $M to the ground.&n", ch, null, victim, SocketConnection.MessageTarget.room); SocketConnection.Act("&+W$n&n&+W leaps at you, knocking you to the ground!&n", ch, null, victim, SocketConnection.MessageTarget.victim); if (victim.IsAffected(Affect.AFFECT_SINGING)) { victim.RemoveAffect(Affect.AFFECT_SINGING); SocketConnection.Act("$n&n gasps and falls silent as $e falls over backward!", victim, null, null, SocketConnection.MessageTarget.room); victim.SendText("You abort your singing!\r\n"); } if (victim.IsAffected(Affect.AFFECT_CASTING)) { victim.RemoveAffect(Affect.AFFECT_CASTING); SocketConnection.Act("$n&n no longer has any idea what $e was casting.", victim, null, null, SocketConnection.MessageTarget.room); victim.SendText("Lying on the ground, you realize you have no idea what you were just casting.\r\n"); } if (!ch.Fighting) { Combat.SetFighting(ch, victim); } if (!victim.Fighting) { Combat.SetFighting(victim, ch); } if (!Combat.CheckTumble(victim)) { victim.WaitState((Skill.SkillList["springleap"].Delay * 5 / 6)); if (victim.CurrentPosition > Position.sitting) { victim.CurrentPosition = Position.sitting; } Combat.InflictDamage(ch, victim, MUDMath.NumberRange(1, ch.Level), "springleap", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } else { Combat.InflictDamage(ch, victim, MUDMath.NumberRange(1, (ch.Level / 3)), "springleap", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); ch.SendText("You roll with the blow, finally landing on your feet.\r\n"); SocketConnection.Act("$n&n rolls with the blow, finally landing on $s feet.", victim, null, null, SocketConnection.MessageTarget.room); } } else { bool pissedOff = false; if (ch.Fighting == victim || victim.GetCurrInt() > MUDMath.NumberPercent()) { pissedOff = true; } if (pissedOff) { SocketConnection.Act("As $N&n avoids your leap you crash to the ground.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n crashes to the ground as you avoid $s springleap.", ch, null, victim, SocketConnection.MessageTarget.victim); if (!ch.Fighting) { Combat.SetFighting(ch, victim); } if (!victim.Fighting) { Combat.SetFighting(victim, ch); } } else { SocketConnection.Act("You ungracefully leap at $N and miss, landing head first!", ch, null, victim, SocketConnection.MessageTarget.character); } SocketConnection.Act("$n&n misses a springleap and falls awkwardly to the ground.", ch, null, null, SocketConnection.MessageTarget.room); ch.CurrentPosition = Position.reclining; Combat.InflictDamage(ch, ch, MUDMath.NumberRange(1, 4), "springleap", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } return; }
/// <summary> /// Consider killing a target. Lets the actor know whether it would be a good idea or not. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Consider(CharData ch, string[] str) { if( ch == null ) return; string msg; if (str.Length == 0) { ch.SendText("&nConsider killing whom?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("&nThey're not here.\r\n"); return; } if (victim == ch) { ch.SendText("Killing yourself? Try 'suicide confirm'.\r\n"); return; } int diff = victim.Level - ch.Level; if (victim.IsAffected( Affect.AFFECT_PROWESS)) diff += (5 + victim.Level / 5); if (victim.IsAffected( Affect.AFFECT_INCOMPETENCE)) diff -= (5 + victim.Level / 5); if (ch.HasActionBit(PC.PLAYER_COLOR_CON)) { if (diff <= -10) msg = "&n&+bToo easy to bother with.&n"; else if (diff <= -5) msg = "&n&+bYou could do it blindfolded!&n"; else if (diff <= -2) msg = "&n&+BEasy.&n"; else if (diff <= -1) msg = "&n&+gFairly easy.&n"; else if (diff <= 0) msg = "&n&+GAn even fight!&n"; else if (diff <= 1) msg = "&n&+gYou would need some luck.&n"; else if (diff <= 2) msg = "&n&+yYou would need a lot of luck!&n"; else if (diff <= 3) msg = "&n&+YYou would need a lot of luck and great equipment!&n"; else if (diff <= 5) msg = "&n&+YYou would probably lose that fight.&n"; else if (diff <= 10) msg = "&n&+RAre you mad!?&n"; else if (diff <= 15) msg = "&n&+RYou ARE mad!&n"; else if (diff <= 20) msg = "&n&+rWhy don't you just lie down and pretend you're dead instead?&n"; else if (diff <= 25) msg = "&n&+rWhat do you want your epitaph to say?!?&n"; else msg = "&n&+LYou wouldn't last one round of combat!&n"; } else { if (diff <= -10) msg = "&nToo easy to bother with.&n"; else if (diff <= -5) msg = "&nYou could do it blindfolded!&n"; else if (diff <= -2) msg = "&nEasy.&n"; else if (diff <= -1) msg = "&nFairly easy.&n"; else if (diff <= 0) msg = "&nAn even fight!&n"; else if (diff <= 1) msg = "&nYou would need some luck.&n"; else if (diff <= 2) msg = "&nYou would need a lot of luck!&n"; else if (diff <= 3) msg = "&nYou would need a lot of luck and great equipment!&n"; else if (diff <= 5) msg = "&nYou would probably lose that fight.&n"; else if (diff <= 10) msg = "&nAre you mad!?&n"; else if (diff <= 15) msg = "&nYou ARE mad!&n"; else if (diff <= 20) msg = "&nWhy don't you just lie down and pretend you're dead instead?&n"; else if (diff <= 25) msg = "&nWhat do you want your epitaph to say?!?&n"; else msg = "&nYou wouldn't last one round of combat!&n"; } SocketConnection.Act(msg, ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n sizes $N&n up with a quick glance.", ch, null, victim, SocketConnection.MessageTarget.room); SocketConnection.Act("$n&n sizes you up with a quick glance.", ch, null, victim, SocketConnection.MessageTarget.victim); return; }
/// <summary> /// Wake one's self or someone else. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Wake(CharData ch, string[] str) { if( ch == null ) return; string arg = String.Empty; if (ch.IsAwake()) { ch.SendText("You are already awake.\r\n"); return; } if (str.Length == 0 || String.IsNullOrEmpty(str[0]) || str[0].Equals("me", StringComparison.CurrentCultureIgnoreCase) && ch.CurrentMana > 0) { Stand(ch, str); return; } if (!ch.IsAwake()) { ch.SendText("You are asleep yourself!\r\n"); return; } CharData victim = ch.GetCharRoom(arg); if (victim == null) { ch.SendText("They aren't here.\r\n"); return; } if (victim.IsAwake()) { SocketConnection.Act("$N&n is already awake.", ch, null, victim, SocketConnection.MessageTarget.character); return; } if (victim.IsAffected(Affect.AFFECT_SLEEP)) { SocketConnection.Act("You can't wake $M!", ch, null, victim, SocketConnection.MessageTarget.character); return; } victim.CurrentPosition = Position.resting; SocketConnection.Act("You wake $M.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n wakes you.", ch, null, victim, SocketConnection.MessageTarget.victim); return; }
/// <summary> /// Ask: Primarily used for quest files, but can be used in regular conversation too. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Ask(CharData ch, string[] str) { if( ch == null ) return; QuestTemplate quest; if (str.Length < 2) { ch.SendText("Ask who what?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They're not here.\r\n"); return; } if (ch.IsAffected( Affect.AFFECT_MUTE) || ch.HasInnate(Race.RACE_MUTE) || ch.InRoom.HasFlag(RoomTemplate.ROOM_SILENT)) { ch.SendText("Your lips move but nothing escapes their bounds.\r\n"); return; } string text = String.Join(" ", str, 1, (str.Length - 1)); text = DrunkSpeech.MakeDrunk(text, ch); SocketConnection.Act("$n&n asks $N&n a question.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); string buf = String.Format("&n&+c$n&n&+c asks you '&+c{0}&n&+c'&n", text); SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim); buf = String.Format("&n&+cYou ask $N&n&+c '{0}&n&+c'&n", text); SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.character); // players can't have talk files -- go home! if (!victim.IsNPC()) return; bool questfound = false; foreach (QuestTemplate it in QuestTemplate.QuestList) { quest = it; if (quest.Messages == null || (quest.IndexNumber != victim.MobileTemplate.IndexNumber)) continue; foreach (TalkData message in quest.Messages) { if (MUDString.NameContainedIn(text, message.Keywords)) { ch.SendText("\r\n"); ch.SendText(message.Message); questfound = true; } } } // Only check chatterbot responses when there isn't a quest with the same keywords. if (!questfound && victim.ChatBot != null) { victim.ChatBot.CheckConversation(victim, ch, text); } return; }
/// <summary> /// Private communication between two characters. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Whisper(CharData ch, string[] str) { if( ch == null ) return; if (str.Length == 0) { ch.SendText("Whisper what to who?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They're not here.\r\n"); return; } if (str.Length < 2) { ch.SendText("Whisper what?\r\n"); return; } if (!ch.CanSpeak()) { return; } string text = String.Join(" ", str, 1, (str.Length - 1)); text = DrunkSpeech.MakeDrunk(text, ch); SocketConnection.Act("$n&n whispers quietly to $N&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); string buf = "&n&+c$n&n&+c whispers '&+c" + text + "&n&+c'&n"; SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim); buf = "&n&+cYou whisper &+c'" + text + "&n&+c' to $N&n"; SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.character); // Chatterbot code. if (victim.ChatBot != null) { victim.ChatBot.CheckConversation(victim, ch, text); } return; }
/// <summary> /// Knock the weapon from an opponent's hand. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Disarm(CharData ch, string[] str) { if( ch == null ) return; int odds; /* Don't allow charmed mobiles to do this, check player's level */ if ((ch.IsNPC() && ch.IsAffected( Affect.AFFECT_CHARM)) || (!ch.IsNPC() && !ch.HasSkill("disarm"))) { ch.SendText("You don't know how to disarm opponents.\r\n"); return; } if (!Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one) && !Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_two)) { ch.SendText("You must wield a weapon to disarm.\r\n"); return; } if (!ch.Fighting) { ch.SendText("You aren't fighting anyone.\r\n"); return; } CharData victim = ch.Fighting; if (str.Length != 0) { if (!(victim = ch.GetCharRoom(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } } if (victim.Fighting != ch && ch.Fighting != victim) { SocketConnection.Act("$E is not fighting you!", ch, null, victim, SocketConnection.MessageTarget.character); return; } if (!Object.GetEquipmentOnCharacter(victim, ObjTemplate.WearLocation.hand_one) && !Object.GetEquipmentOnCharacter(victim, ObjTemplate.WearLocation.hand_two)) { ch.SendText("Your opponent is not wielding a weapon.\r\n"); return; } if (victim.Level > ch.Level + 10) { ch.SendText("They are much too clever for such a clumsy attempt at that maneuver.\r\n"); return; } ch.WaitState(Skill.SkillList["disarm"].Delay); ch.PracticeSkill("disarm"); if (ch.IsNPC()) { odds = ch.Level; } else { odds = ((PC)ch).SkillAptitude["disarm"] / 2; } if (victim.IsNPC()) { odds += 2 * (ch.Level - victim.Level); } else { /* Offense skill helps prevent disarms */ odds -= ((PC)victim).SkillAptitude["offense"] / 4; } if (!Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one)) { odds /= 2; /* 1/2 as likely with only 2nd weapon */ } odds = Math.Min(odds, 98); odds = Math.Max(odds, 2); string lbuf = String.Format("Disarm: {0} attempting with {1}%% chance.", ch.Name, odds); ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, lbuf); if (MUDMath.NumberPercent() < odds) { Combat.Disarm(ch, victim); } else if (MUDMath.NumberPercent() > 80) { ch.SendText("Expertly countering your maneuver, they dislodge your weapon and send it flying.\r\n"); Combat.Disarm(victim, ch); } else { ch.SendText("You failed in your attempt.\r\n"); } return; }
/// <summary> /// Zap a wand, using its spell power. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Zap(CharData ch, string[] str) { if( ch == null ) return; Object wand = null; Object obj = null; CharData victim; int level; if (str.Length == 0 && ch.Fighting == null) { ch.SendText("Zap whom or what?\r\n"); return; } if (!String.IsNullOrEmpty(str[0]) && !(wand = ch.GetObjWear(str[0]))) { if (!(wand = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one))) { ch.SendText("You hold nothing in your hand.\r\n"); return; } } else /* Wand was first argument.. arg is now second argument. */ if (wand.ItemType != ObjTemplate.ObjectType.wand) { ch.SendText("You can zap only with a wand.\r\n"); return; } level = wand.Level; if (String.IsNullOrEmpty(str[0])) { if (ch.Fighting != null) { victim = ch.Fighting; } else { ch.SendText("Zap whom or what?\r\n"); return; } } else { if (((victim = ch.GetCharRoom(str[0])) == null) && (obj = ch.GetObjHere(str[0])) == null) { ch.SendText("You can't find your _targetType.\r\n"); return; } } if (ch.IsNPC() && !ch.IsFreewilled()) { SocketConnection.Act("You try to zap $p&n, but you have no free will.", ch, wand, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n tries to zap $p&n, but has no free will.", ch, wand, null, SocketConnection.MessageTarget.room); return; } String spellName = SpellNumberToTextMap.GetSpellNameFromNumber(wand.Values[3]); if (String.IsNullOrEmpty(spellName)) { ch.SendText("You try to zap, but your wand fizzles.\r\n"); Log.Error("Zap: Spell number " + wand.Values[3] + " not found in SpellNumberToTextMap for object " + wand.ObjIndexNumber + "."); return; } Spell spell = StringLookup.SpellLookup(spellName); if (!spell) { ch.SendText("You try to zap, but your wand fizzles.\r\n"); Log.Error("Zap: Spell '" + spellName + "' not found for object " + wand.ObjIndexNumber + ". Check that it exists in the spells file."); return; } ch.PracticeSkill("wands"); if (wand.Values[2] > 0) { if (victim != null) { if (victim == ch) { SocketConnection.Act("You zap yourself with $p&n.", ch, wand, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n zaps $mself with $p&n.", ch, wand, null, SocketConnection.MessageTarget.room); } else { SocketConnection.Act("You zap $N&n with $p&n.", ch, wand, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n zaps $N&n with $p&n.", ch, wand, victim, SocketConnection.MessageTarget.room); } } else { SocketConnection.Act("You zap $P&n with $p&n.", ch, wand, obj, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n zaps $P&n with $p&n.", ch, wand, obj, SocketConnection.MessageTarget.room); } if (!ch.IsNPC() && (MUDMath.NumberPercent() > ((PC)ch).SkillAptitude["wands"])) { switch (MUDMath.NumberBits(3)) { case 0: case 1: case 2: case 3: SocketConnection.Act("You are unable to invoke the power of $p&n.", ch, wand, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n is unable to invoke the power of $p&N.", ch, wand, null, SocketConnection.MessageTarget.room); break; case 4: case 5: case 6: SocketConnection.Act("You summon the power of $p&n, but it fizzles away.", ch, wand, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n summons the power of $p&n, but it fizzles away.", ch, wand, null, SocketConnection.MessageTarget.room); break; case 7: SocketConnection.Act("You can't control the power of $p&n, and it &+Rexplodes&n!", ch, wand, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$p&n &n&+rexplodes&n into fragments!", ch, wand, null, SocketConnection.MessageTarget.room); /* * Command.damage( ) call after Object.extract_obj in case the damage would * have extracted ch. This is okay because we merely mark * obj.deleted; it still retains all values until list_update. * Sloppy? Okay, create another integer variable. * I hate sloppy... */ wand.RemoveFromWorld(); Combat.InflictDamage(ch, ch, level, "wands", ObjTemplate.WearLocation.none, AttackType.DamageType.energy); break; } return; } Magic.ObjectCastSpell(ch, spell, level, victim, obj); } if (--(wand.Values[2]) <= 0) { if (!ch.IsNPC() && MUDMath.NumberPercent() > ((PC)ch).SkillAptitude["wands"]) { SocketConnection.Act("$p&n &n&+rexplodes&n into fragments.", ch, wand, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$p&n &+Rexplodes&n into fragments.", ch, wand, null, SocketConnection.MessageTarget.room); wand.RemoveFromWorld(); Combat.InflictDamage(ch, ch, level, "wands", ObjTemplate.WearLocation.none, AttackType.DamageType.energy); } else { SocketConnection.Act("$p&n blazes bright and is gone.", ch, wand, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$p&n blazes bright and is gone.", ch, wand, null, SocketConnection.MessageTarget.room); wand.RemoveFromWorld(); } } return; }
/// <summary> /// Command to follow someone. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Follow(CharData ch, string[] str) { if( ch == null ) return; if (str.Length == 0) { ch.SendText("Follow whom?\r\n"); return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They aren't here.\r\n"); return; } if (ch.IsAffected(Affect.AFFECT_CHARM) && ch.Master) { SocketConnection.Act("But you'd rather follow $N&n!", ch, null, ch.Master, SocketConnection.MessageTarget.character); return; } if (victim.Master == ch) { ch.SendText("No following in loops!\r\n"); return; } if (victim == ch) { if (!ch.Master) { ch.SendText("You already follow yourself.\r\n"); return; } Combat.StopFighting(ch, true); return; } if (ch.Master) { Combat.StopFighting(ch, true); } // This sets following state and then sends a "you now follow" message to the follower. CharData.AddFollower(ch, victim); return; }
public static void Apply(CharData ch, string[] str) { if( ch == null ) return; if (ch.Level < 25) { ch.SendText("You don't have enough experience to join a guild.\r\n"); return; } if (str.Length == 0) { ch.SendText("Where do you want to apply?\r\n"); return; } PC leader = (PC)ch.GetCharRoom(str[0]); if (leader == null) { ch.SendText("You do not see that person here.\r\n"); return; } if (leader.IsNPC() || leader.GuildMembership == null) { ch.SendText("Apply to whom?!\r\n"); return; } if (leader.GuildMembership.Applicant != null) { ch.SendText("That guild is currently reviewing another applicant. Try again later.\r\n"); return; } leader.GuildMembership.Applicant = ch; SocketConnection.Act("$n&n submits an application to join your guild.", ch, null, leader, SocketConnection.MessageTarget.victim); ch.SendText("You turn in your application.\r\n"); return; }
/// <summary> /// Give an item to someone. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Give(CharData ch, string[] str) { if( ch == null ) return; CharData victim; string arg1 = String.Empty; string arg2 = String.Empty; if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2)) { ch.SendText("Give what to whom?\r\n"); return; } if (MUDString.IsNumber(arg1)) { /* 'give NNNN coins victim' */ string buf; string arg3 = String.Empty; int amount; Int32.TryParse(arg1, out amount); if (amount <= 0) { ch.SendText("Sorry, you can't do that.\r\n"); return; } if (String.IsNullOrEmpty(arg3)) { ch.SendText("Give what to whom?\r\n"); return; } victim = ch.GetCharRoom(arg3); if (victim == null) { ch.SendText("They aren't here.\r\n"); return; } if (!MUDString.IsPrefixOf(arg2, "copper")) { if (ch.GetCopper() < amount) { ch.SendText("You haven't got that many &+ycopper&n coins.\r\n"); return; } ch.SpendCopper(amount); SocketConnection.Act("You give $N&n some &+ycopper&n.", ch, null, victim, SocketConnection.MessageTarget.character); buf = String.Format("$n&n gives you {0} &+ycopper&n.", amount); SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n gives $N&n some &+ycopper&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); // prog_bribe_trigger( victim, ch, amount ); if (!ch.CheckQuest(victim, null, amount)) { victim.ReceiveCopper(amount); } // Prevent money duping CharData.SavePlayer(ch); CharData.SavePlayer(victim); return; } if (!MUDString.IsPrefixOf(arg2, "silver")) { if (ch.GetSilver() < amount) { ch.SendText("You haven't got that many silver coins.\r\n"); return; } ch.SpendSilver(amount); SocketConnection.Act("You give $N&n some silver.", ch, null, victim, SocketConnection.MessageTarget.character); buf = String.Format("$n&n gives you {0} silver.", amount); SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n gives $N&n some silver.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); // prog_bribe_trigger( victim, ch, amount * 10); if (!ch.CheckQuest(victim, null, (amount * 10))) victim.ReceiveSilver(amount); // Prevent money duping CharData.SavePlayer(ch); CharData.SavePlayer(victim); return; } if (!MUDString.IsPrefixOf(arg2, "gold")) { if (ch.GetGold() < amount) { ch.SendText("You haven't got that many &+Ygold&n coins.\r\n"); return; } ch.SpendGold(amount); SocketConnection.Act("You give $N&n some &+Ygold&n.", ch, null, victim, SocketConnection.MessageTarget.character); buf = String.Format("$n&n gives you {0} &+Ygold&n.", amount); SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n gives $N&n some &+Ygold&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); // prog_bribe_trigger( victim, ch, amount *100); if (!ch.CheckQuest(victim, null, (amount * 100))) { victim.ReceiveGold(amount); } // Prevent money duping CharData.SavePlayer(ch); CharData.SavePlayer(victim); return; } if (!MUDString.IsPrefixOf(arg2, "platinum")) { if (ch.GetPlatinum() < amount) { ch.SendText("You haven't got that many &+Wplatinum&n coins.\r\n"); return; } ch.SpendPlatinum(amount); SocketConnection.Act("You give $N&n some &+Wplatinum&n.", ch, null, victim, SocketConnection.MessageTarget.character); buf = String.Format("$n&n gives you {0} &+Wplatinum&n.", amount); SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n gives $N&n some &+Wplatinum&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); // prog_bribe_trigger( victim, ch, amount* 1000 ); if (!ch.CheckQuest(victim, null, (amount * 1000))) { victim.ReceivePlatinum(amount); } // Prevent money duping CharData.SavePlayer(ch); CharData.SavePlayer(victim); return; } ch.SendText("You don't have any of _that_ type of coin yet.\r\n"); return; } Object obj = ch.GetObjCarrying(arg1); if (!obj) { ch.SendText("You do not have that item.\r\n"); return; } if (obj.WearLocation != ObjTemplate.WearLocation.none) { ch.SendText("You must remove it first.\r\n"); return; } victim = ch.GetCharRoom(arg2); if (victim == null) { ch.SendText("They aren't here.\r\n"); return; } if (!ch.CanDropObject(obj)) { ch.SendText("You couldn't possibly part with it.\r\n"); return; } /* * How silly of shopkeepers to refuse blessed items... previously vampires would * refuse blessed items... now all undead types refuse blessed items. */ if (obj.HasFlag(ObjTemplate.ITEM_BLESS) && victim.IsUndead()) { SocketConnection.Act("$N&n refuses to touch the blessed $p&n.", ch, obj, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n tries to give $N&n a $p&n but $E refuses.", ch, obj, victim, SocketConnection.MessageTarget.room); SocketConnection.Act("You refuse to accept the blessed $p&n from $n&n.", ch, obj, victim, SocketConnection.MessageTarget.victim); return; } if (victim.CarryNumber + 1 > Limits.MAX_CARRY) { SocketConnection.Act("$N&n has $S hands full.", ch, null, victim, SocketConnection.MessageTarget.character); return; } if (victim.CarryWeight + obj.GetWeight() > victim.MaxCarryWeight()) { SocketConnection.Act("$N&n cannot carry that much weight.", ch, null, victim, SocketConnection.MessageTarget.character); return; } if (!CharData.CanSeeObj(victim, obj)) { SocketConnection.Act("$N&n can't see it.", ch, null, victim, SocketConnection.MessageTarget.character); return; } obj.RemoveFromChar(); obj.ObjToChar(victim); // Prevent item duplication. CharData.SavePlayer(ch); CharData.SavePlayer(victim); SocketConnection.Act("You give $p&n to $N&n.", ch, obj, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n gives you $p&n.", ch, obj, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n gives $p&n to $N&n.", ch, obj, victim, SocketConnection.MessageTarget.everyone_but_victim); // prog_give_trigger( victim, ch, obj ); if (Database.IsArtifact(obj.ObjIndexData.IndexNumber)) { string buf = String.Format("{0} has given artifact {1} to {2}", ch.Name, obj.ObjIndexData.IndexNumber, victim.Name); Log.Trace(buf); } if (!victim.IsNPC()) { return; } // Destroy the item so they can't kill the mob for the item. if (ch.CheckQuest(victim, obj, 0)) { obj.RemoveFromWorld(); } return; }
/// <summary> /// Charge into someone. Helps to have horns on your head. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Charge(CharData ch, string[] str) { if( ch == null ) return; CharData victim; /* Check player's level and class, mobs can use this skill */ if (!ch.HasInnate(Race.RACE_CHARGE)) { ch.SendText("You can't do that.\r\n"); return; } if (ch.IsBlind()) { return; } if (str.Length != 0) { if (!(victim = ch.GetCharRoom(str[0])) || victim.CurrentPosition == Position.dead) { ch.SendText("They aren't here.\r\n"); return; } } else { ch.SendText("Charge who?\r\n"); return; } /* charge me trap */ if (ch == victim) { ch.SendText("You chase your tail for a while.\r\n"); return; } ch.WaitState(MUDMath.FuzzyNumber(Skill.SkillList["charge"].Delay)); if (!ch.Fighting) { Combat.SetFighting(ch, victim); } if (!victim.Fighting) { Combat.SetFighting(victim, ch); } // Chance is based on level of charger and victim. int chance = (ch.Level * 2) - victim.Level + 25; if (chance > 95) { chance = 95; } if (ch.IsNPC() || MUDMath.NumberPercent() < chance) { Combat.InflictDamage(ch, victim, MUDMath.NumberRange(1, ch.Level), "charge", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } else { Combat.InflictDamage(ch, victim, 0, "charge", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } return; }
public static void Group(CharData ch, string[] str) { if( ch == null ) return; // Group with no arguments should show group staus. if (str.Length == 0) { ch.ShowGroup(); return; } if (!MUDString.IsPrefixOf(str[0], "all")) { int added = 0; foreach (CharData ivictim in ch.InRoom.People) { if (ivictim == ch || ivictim.FlightLevel != ch.FlightLevel || ch.IsRacewar(ivictim)) continue; if (((ivictim.IsNPC() && ivictim.HasActionBit(MobTemplate.ACT_PET)) || (!ivictim.IsNPC() && ivictim.IsConsenting(ch))) && ivictim.Master == ch && !ivictim.GroupLeader) { ch.AddGroupMember(ivictim); ++added; } } if (added < 1) { ch.SendText("No new group members.\r\n"); } return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("They aren't here.\r\n"); return; } if (ch == victim) { ch.RemoveFromGroup(victim); return; } if (ch.IsRacewar(victim) && !victim.IsNPC()) { ch.SendText("You can't group with such slime!\r\n"); return; } if (ch.IsSameGroup(victim)) { if (ch.GroupLeader == ch) { ch.RemoveFromGroup(victim); } else { ch.SendText("Only the leader of a group may kick someone out.\r\n"); } return; } if (ch.GroupLeader == null || ch.GroupLeader == ch) { string buf; if (victim.GroupLeader == null) { if ((!victim.IsNPC() && !victim.IsConsenting(ch)) || (victim.IsNPC() && victim.Master != ch)) { buf = String.Format("{0} doesn't want to be in your group.\r\n", victim.ShowNameTo(ch, true)); ch.SendText(buf); } else { ch.GroupLeader = ch; ch.AddGroupMember(victim); } } else { buf = String.Format("{0} is in another group.\r\n", victim.ShowNameTo(ch, true)); ch.SendText(buf); } } else { ch.SendText("You must be the head of the group to add someone.\r\n"); } return; }
/// <summary> /// Circle around behind someone and backstab them. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Circle(CharData ch, string[] str) { if( ch == null ) return; CharData victim; /* Verify that ch can circle. */ if (!ch.IsNPC() && !ch.HasSkill("circle")) { ch.SendText("You'd better leave the assassination trade to those more skilled.\r\n"); return; } /* No charmies or NPC's are allowed to circle. */ if (ch.IsNPC() && ch.IsAffected(Affect.AFFECT_CHARM)) { return; } /* Yeah, gallop around them without them noticing. */ if (ch.Riding) { ch.SendText("You can't circle while mounted.\r\n"); return; } /* Find the unlucky soul. */ if (str.Length == 0) { victim = ch.Fighting; } else { if (!(victim = ch.GetCharRoom(str[0]))) { ch.SendText("They aren't here.\r\n"); return; } } /* No target. */ if (!victim) { ch.SendText("Circle who?\r\n"); return; } /* Run around yourself? Ok. */ if (victim == ch) { ch.SendText("You spin around in a circle. Whee!\r\n"); return; } /* Check for protection of victim. */ victim = Combat.CheckGuarding(ch, victim); if (Combat.IsSafe(ch, victim)) { return; } // is_safe could wipe out victim, as it calls procs if a boss // check and see that victim is still valid if (!victim) { return; } /* Check if someone is attacking ch. */ CharData roomChar = null; foreach (CharData irch in ch.InRoom.People) { if (irch.Fighting == ch) { roomChar = irch; break; } } if (roomChar) { ch.SendText("You're too busy being hit right now.\r\n"); return; } Object obj = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one); if (!obj || obj.Values[3] != 11) { ch.SendText("You need to wield a piercing weapon.\r\n"); return; } SocketConnection.Act("You circle around behind $N&n...", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n circles around behind $N&n...", ch, null, victim, SocketConnection.MessageTarget.room_vict); Crime.CheckAttemptedMurder(ch, victim); ch.WaitState(Skill.SkillList["circle"].Delay); if (ch.IsNPC() || MUDMath.NumberPercent() < ((PC)ch).SkillAptitude["circle"] + ch.GetCurrAgi() - victim.GetCurrAgi()) { /* Don't always switch. */ if (MUDMath.NumberPercent() < 40) { Combat.StopFighting(victim, false); } Combat.SingleAttack(ch, victim, "circle", ObjTemplate.WearLocation.hand_one); } else { SocketConnection.Act("You failed to get around $M!", ch, null, victim, SocketConnection.MessageTarget.character); } ch.PracticeSkill("circle"); return; }
/// <summary> /// Guard someone - try to prevent them from becoming the target of attacks. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Guard(CharData ch, string[] str) { if( ch == null ) return; CharData worldChar; if (ch.IsNPC()) return; if (!ch.HasSkill("guard")) { ch.SendText("Guard!? You can't even protect yourself!\r\n"); return; } if (str.Length == 0) { if (!((PC)ch).Guarding) { ch.SendText("Guard who?\r\n"); return; } if (!((PC)ch).Guarding) { string buf = "You are guarding " + (((PC)ch).Guarding.IsNPC() ? ((PC)ch).Guarding.ShortDescription : ((PC)ch).Guarding.Name) + ".\r\n"; ch.SendText(buf); return; } } if (!MUDString.StringsNotEqual(str[0], "who")) { if (!((PC)ch).Guarding) { ch.SendText("You are not guarding anyone.\r\n"); } else { SocketConnection.Act("You are guarding $N&n.", ch, null, ((PC)ch).Guarding, SocketConnection.MessageTarget.character); } foreach (CharData it in Database.CharList) { worldChar = it; if (worldChar.IsNPC()) { continue; } if (((PC)worldChar).Guarding && ((PC)worldChar).Guarding == ch) { SocketConnection.Act("$N&n is guarding you.", ch, null, worldChar, SocketConnection.MessageTarget.character); } } return; } CharData victim = ch.GetCharRoom(str[0]); if (!victim) { ch.SendText("You don't see them here.\r\n"); return; } if (victim == ch) { ch.SendText("You no longer guard anyone.\r\n"); ((PC)ch).Guarding = null; return; } if (ch.IsClass(CharClass.Names.paladin) && victim.IsEvil()) { ch.SendText("Their blackened soul is hardly worth the effort.\r\n"); return; } if (((PC)ch).Guarding) { SocketConnection.Act("$N&n stops guarding you.", ((PC)ch).Guarding, null, ch, SocketConnection.MessageTarget.character); SocketConnection.Act("You stop guarding $N&n.", ch, null, ((PC)ch).Guarding, SocketConnection.MessageTarget.character); } ((PC)ch).Guarding = victim; SocketConnection.Act("You now guard $N&n.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n is now guarding you.", ch, null, victim, SocketConnection.MessageTarget.victim); return; }
/// <summary> /// Make a clone of something. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Clone(CharData ch, string[] str) { if( ch == null ) return; string text; Object obj; CharData mob; if (str.Length == 0) { ch.SendText("Clone what?\r\n"); return; } if (str.Length > 1 && !MUDString.IsPrefixOf(str[0], "object")) { mob = null; obj = ch.GetObjHere(str[1]); if (obj == null) { ch.SendText("You don't see that here.\r\n"); return; } } else if (str.Length > 1 && !MUDString.IsPrefixOf(str[0], "mobile") || (!MUDString.IsPrefixOf(str[0], "character"))) { obj = null; mob = ch.GetCharRoom(str[1]); if (mob == null) { ch.SendText("You don't see that here.\r\n"); return; } } else { mob = ch.GetCharRoom(str[0]); obj = ch.GetObjHere(str[0]); if (mob == null && obj == null) { ch.SendText("You don't see that here.\r\n"); return; } } /* clone object */ if (obj != null) { Object clone = Database.CreateObject(obj.ObjIndexData, 0); Database.CloneObject(obj, ref clone); if (obj.CarriedBy != null) { clone.ObjToChar(ch); } else { clone.AddToRoom(ch.InRoom); } Object.RecursiveClone(ch, obj, clone); SocketConnection.Act("$n has created $p.", ch, clone, null, SocketConnection.MessageTarget.room); SocketConnection.Act("You clone $p.", ch, clone, null, SocketConnection.MessageTarget.character); text = String.Format("{0} clones {1}.", ch.Name, clone.ShortDescription); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOAD, ch.GetTrust(), text); return; } if (mob != null) { if (!mob.IsNPC()) { ch.SendText("You can only clone mobiles.\r\n"); return; } CharData clone = Database.CreateMobile(mob.MobileTemplate); Database.CloneMobile(mob, clone); foreach (Object obj2 in mob.Carrying) { Object newObj = Database.CreateObject(obj2.ObjIndexData, 0); Database.CloneObject(obj2, ref newObj); Object.RecursiveClone(ch, obj2, newObj); newObj.ObjToChar(clone); newObj.WearLocation = obj2.WearLocation; } clone.AddToRoom(ch.InRoom); SocketConnection.Act("$n has created $N.", ch, null, clone, SocketConnection.MessageTarget.room); SocketConnection.Act("You clone $N.", ch, null, clone, SocketConnection.MessageTarget.character); text = String.Format("{0} clones {1}.", ch.Name, clone.ShortDescription); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOAD, ch.GetTrust(), text); return; } }
/// <summary> /// Bash. Usable to initiate combat and during combat. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Bash(CharData ch, string[] str) { if( ch == null ) return; int chance; /* Check player's level and class, mobs can use this skill */ if ((!ch.HasSkill("bash"))) { ch.SendText("You'd better leave that to those with more skills.\r\n"); return; } if (ch.IsBlind() && !ch.Fighting) { return; } /* Verify a target. */ CharData victim = ch.Fighting; if (str.Length != 0) { victim = ch.GetCharRoom(str[0]); if (!victim || victim.CurrentPosition == Position.dead) { ch.SendText("They aren't anywhere to be found.\r\n"); return; } } else { if (!victim || victim.CurrentPosition == Position.dead) { ch.SendText("You aren't fighting anyone.\r\n"); return; } } /* Bash self? Ok! */ // Toned down the damage cuz you can't really bash yourself // like you could with someone else. if (victim == ch) { ch.SendText("You throw yourself to the ground!\r\n"); SocketConnection.Act("$N&n knocks $mself to the ground.", ch, null, victim, SocketConnection.MessageTarget.room_vict); ch.CurrentPosition = Position.kneeling; ch.WaitState((Skill.SkillList["bash"].Delay * 8) / 10); Combat.InflictDamage(ch, ch, MUDMath.NumberRange(1, 3), "bash", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); return; } /* Check size of ch vs. victim. */ /* If ch is too small. */ if (ch.CurrentSize < victim.CurrentSize) { SocketConnection.Act("$N&n is too big for you to bash!", ch, null, victim, SocketConnection.MessageTarget.character); return; } /* Ch 2 or more sizes larger than victim => bad! */ if (ch.CurrentSize - 2 > victim.CurrentSize) { SocketConnection.Act("You nearly topple over as you try to bash $N&n.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n nearly topples over as $e attempts to bash you.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n nearly topples over as $e attempts to bash $N&n.", ch, null, victim, SocketConnection.MessageTarget.room_vict); ch.WaitState((Skill.SkillList["bash"].Delay)); ch.CurrentPosition = Position.kneeling; if (victim.Fighting == null) { Combat.SetFighting(victim, ch); } return; } /* Lag to basher from bash. Pets get more lag because pets are cheesy */ if (!ch.IsNPC()) { ch.WaitState(MUDMath.FuzzyNumber(Skill.SkillList["bash"].Delay)); } else { ch.WaitState((Skill.SkillList["bash"].Delay * 6 / 5)); } /* Base chance to bash, followed by chance modifications. */ if (ch.IsNPC()) { chance = (ch.Level * 3) / 2 + 15; } else { chance = ((PC)ch).SkillAptitude["bash"] - 5; } if (victim.CurrentPosition < Position.fighting) { chance /= 5; //used to be 0 } else { chance += ch.GetCurrAgi() - victim.GetCurrAgi(); } if (chance > 95) { chance = 95; } Object obj = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one); if (!obj) { /* No primary item. */ if (!(obj = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_two))) { /* No items in hand. */ if (!ch.IsClass(CharClass.Names.paladin) && !ch.IsClass(CharClass.Names.antipaladin)) { if (!ch.IsClass(CharClass.Names.warrior)) { chance -= 25; } else { chance -= 20; } ch.SendText("You lower your shoulder and attempt to bash without a shield...\r\n"); } else { chance -= 3; // Hidden penalty for not having a shield } } else if (obj.ItemType != ObjTemplate.ObjectType.shield) { /* Secondary item isn't a shield, no primary. */ if (!ch.IsClass(CharClass.Names.paladin) && !ch.IsClass(CharClass.Names.antipaladin)) { if (!ch.IsClass(CharClass.Names.warrior)) { chance -= 25; } else { chance -= 20; } ch.SendText("Bashing without a shield is tough, but you try anyway...\r\n"); } else { chance -= 5; // Small hidden penalty for not having a shield } } /* Secondary item is a shield, no primary. */ else if (ch.IsClass(CharClass.Names.paladin) || ch.IsClass(CharClass.Names.antipaladin)) { chance += 3; // Small hidden bonus for having a shield } } else if (obj.ItemType != ObjTemplate.ObjectType.shield) { /* Primary item isn't a shield. */ if (!(obj = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_two))) { /* No secondary. */ if (!ch.IsClass(CharClass.Names.paladin) && !ch.IsClass(CharClass.Names.antipaladin)) { if (!ch.IsClass(CharClass.Names.warrior)) { chance -= 25; } else { chance -= 20; } ch.SendText("Without a shield, bashing is a wistful thought, but you try anyway...\r\n"); } else { chance -= 5; // Hidden penalty for not having a shield } } else if (obj.ItemType != ObjTemplate.ObjectType.shield) { /* Secondary item is not a shield. */ if (!ch.IsClass(CharClass.Names.paladin) && !ch.IsClass(CharClass.Names.antipaladin)) { if (!ch.IsClass(CharClass.Names.warrior)) { chance -= 25; } else { chance -= 20; } ch.SendText("Without a shield, your shoulder bash is but wishful thinking...\r\n"); } else { chance -= 5; // Hidden penalty for not having a shield } } else if (ch.IsClass(CharClass.Names.paladin) || ch.IsClass(CharClass.Names.antipaladin)) { /* Secondary is a shield. */ chance += 3; // Small hidden bonus for having a shield } else if (ch.IsClass(CharClass.Names.ranger)) { chance -= 8; } else if (ch.IsClass(CharClass.Names.warrior)) { chance -= 5; } } // Centaurs are awful damned hard to bash -- Xangis if (victim.GetRace() == Race.RACE_CENTAUR) { chance -= 25; } // damned high penalty for bashing blind if (ch.IsAffected(Affect.AFFECT_BLIND) && !victim.IsAffected(Affect.AFFECT_BLIND)) { chance /= 10; } if (ch.IsAffected(Affect.AFFECT_BLIND) && victim.IsAffected(Affect.AFFECT_BLIND)) { chance /= 4; } ch.PracticeSkill("bash"); /* Start a fight if not already in one. */ if (ch != victim) { if (!ch.Fighting) { Combat.SetFighting(ch, victim); } if (!victim.Fighting) { Combat.SetFighting(victim, ch); } } string lbuf = "Bash: " + ch.Name + " bashing " + victim.Name + " with " + chance + " chance."; ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, lbuf); /* Do the bash, deal the damage. */ if (MUDMath.NumberPercent() < chance) { /* Hit the bash. */ if (victim.IsAffected(Affect.AFFECT_SINGING)) { victim.RemoveAffect(Affect.AFFECT_SINGING); SocketConnection.Act("$n&n chokes on a note and falls silent as $e slams into the ground!", victim, null, null, SocketConnection.MessageTarget.room); victim.SendText("You abort your singing!\r\n"); } if (victim.IsAffected(Affect.AFFECT_CASTING)) { victim.RemoveAffect(Affect.AFFECT_CASTING); SocketConnection.Act("$n&n's eyes roll back in $s head and $e forgets all about $s spell.", victim, null, null, SocketConnection.MessageTarget.room); victim.SendText("Being knocked over so forcefully makes it hard to cast.\r\n"); } if (!Combat.CheckTumble(victim)) { victim.WaitState(((Skill.SkillList["bash"].Delay * 5) / 6)); if (victim.CurrentPosition > Position.kneeling) { victim.CurrentPosition = Position.kneeling; } victim.SendText("You are knocked to the ground!\r\n"); Combat.InflictDamage(ch, victim, MUDMath.NumberRange(1, ch.Level), "bash", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); } else { Combat.InflictDamage(ch, victim, MUDMath.NumberRange(1, (ch.Level / 3)), "bash", ObjTemplate.WearLocation.none, AttackType.DamageType.bludgeon); victim.SendText("You roll with the blow, finally landing on your feet.\r\n"); SocketConnection.Act("$n&n rolls with the blow, finally landing on $s feet.", victim, null, null, SocketConnection.MessageTarget.room); } } else { /* Miss the bash. */ SocketConnection.Act("As $N&n avoids your bash, you topple to the &n&+yground&n with a loud crash.", ch, null, victim, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n crashes to the &n&+yground&n as you sidestep $s bash.", ch, null, victim, SocketConnection.MessageTarget.victim); SocketConnection.Act("$n&n misses $s bash at $N&n and is driven to the &n&+yground&n.", ch, null, victim, SocketConnection.MessageTarget.room_vict); ch.CurrentPosition = Position.kneeling; } return; }
/// <summary> /// Makes any character instantly sober. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Sober(CharData ch, string[] str) { if( ch == null ) return; CharData realChar = ch.GetChar(); CharData victim; string arg = String.Empty; if (!realChar.Authorized("sober")) { return; } if (!(victim = ch.GetCharRoom(arg))) { ch.SendText("They aren't here.\r\n"); return; } if (victim.IsNPC()) { ch.SendText("Not on mobs.\r\n"); return; } ((PC)victim).Drunk = 0; ch.SendText("Done.\r\n"); victim.SendText("You feel sober again.\r\n"); return; }