/// <summary> /// Take money from your guild bank account. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void GuildWithdraw(CharData ch, string[] str) { if( ch == null ) return; string arg = String.Empty; if (ch.IsNPC()) return; Guild guild = ((PC)ch).GuildMembership; if (guild == null) { ch.SendText("You're not in a guild!\r\n"); return; } if (((PC)ch).GuildRank < Guild.Rank.deputy) { ch.SendText("You'll have to be promoted before you can withdraw from the guild.\r\n"); return; } if (str.Length == 0) { ch.SendText("Withdraw what?\r\n"); return; } if (MUDString.IsNumber(str[0])) { int amount; Int32.TryParse(str[0], out amount); if (amount <= 0) { ch.SendText("Sorry, you can't do that.\r\n"); return; } if ("copper".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase)) { if (guild.GuildBankAccount.Copper < amount) { ch.SendText("The guild doesen't have that many &n&+ycopper&n coins.\r\n"); return; } ch.ReceiveCopper(amount); guild.GuildBankAccount.Copper -= amount; } else if ("silver".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase)) { if (guild.GuildBankAccount.Silver < amount) { ch.SendText("The guild doesen't have that many &n&+wsilver&n coins.\r\n"); return; } ch.ReceiveSilver(amount); guild.GuildBankAccount.Silver -= amount; } else if ("gold".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase)) { if (guild.GuildBankAccount.Gold < amount) { ch.SendText("The guild doesen't have that many &+Ygold&n coins.\r\n"); return; } ch.ReceiveGold(amount); guild.GuildBankAccount.Gold -= amount; } else if ("platinum".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase)) { if (guild.GuildBankAccount.Platinum < amount) { ch.SendText("The guild doesen't have that many &+Wplatinum&n coins.\r\n"); return; } ch.ReceivePlatinum(amount); guild.GuildBankAccount.Platinum -= amount; } else { ch.SendText("You don't have any idea what you are trying to do, do you?\r\n"); return; } guild.Save(); CharData.SavePlayer(ch); ch.SendText("You make a withdrawal.\r\n"); } else { ch.SendText("&+LSyntax: &+RWithdraw &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n"); } return; }
/// <summary> /// Take money out of your bank account. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Withdraw(CharData ch, string[] str) { if( ch == null ) return; int coinage; bool success = false; Coins coin = new Coins(); if (ch.IsNPC()) { return; } if (!ch.InRoom || !ch.InRoom.HasFlag(RoomTemplate.ROOM_BANK)) { ch.SendText("You're not in a bank!\r\n"); return; } if (str.Length == 0) { ch.SendText("Withdraw what?\r\n"); return; } if (!coin.FillFromString(str, ch)) { ch.SendText("&+LSyntax: &+RWithdraw &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n"); return; } if (coin.Copper == 0 && coin.Silver == 0 && coin.Gold == 0 && coin.Platinum == 0) { ch.SendText("The bank has none of that type of &+Lcoin&n yet.\r\n"); return; } for (coinage = 0; coinage < 4; coinage++) { switch (coinage) { case 0: //copper if (coin.Copper < 0) { ch.SendText("You can't liquidate a debt!\r\n"); continue; } if (coin.Copper > ((PC)ch).Bank.Copper) { ch.SendText("You haven't saved that much &+ycopper&n coin!\r\n"); continue; } if (coin.Copper == 0) continue; ch.ReceiveCopper(coin.Copper); ((PC)ch).Bank.Copper -= coin.Copper; success = true; break; case 1: //silver if (coin.Silver < 0) { ch.SendText("You can't liquidate a debt!\r\n"); continue; } if (coin.Silver > ((PC)ch).Bank.Silver) { ch.SendText("You haven't saved that much &+wsilver&n coin!\r\n"); continue; } if (coin.Silver == 0) continue; ch.ReceiveSilver(coin.Silver); ((PC)ch).Bank.Silver -= coin.Silver; success = true; break; case 2: //gold if (coin.Gold < 0) { ch.SendText("You can't liquidate a debt!\r\n"); continue; } if (coin.Gold > ((PC)ch).Bank.Gold) { ch.SendText("You haven't saved that much &+Ygold&n coin!\r\n"); continue; } if (coin.Gold == 0) continue; ch.ReceiveGold(coin.Gold); ((PC)ch).Bank.Gold -= coin.Gold; success = true; break; case 3: //platinum if (coin.Platinum < 0) { ch.SendText("You can't liquidate a debt!\r\n"); continue; } if (coin.Platinum > ((PC)ch).Bank.Platinum) { ch.SendText("You haven't saved that much &+Wplatinum&n coin!\r\n"); continue; } if (coin.Platinum == 0) continue; ch.ReceivePlatinum(coin.Platinum); ((PC)ch).Bank.Platinum -= coin.Platinum; success = true; break; } //end switch } //end for if (success) { ch.SendText("You make a withdrawal.\r\n"); SocketConnection.Act("$n&n makes a transaction.", ch, null, null, SocketConnection.MessageTarget.room); } else { ch.SendText("&+LSyntax: &+RDeposit &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n"); } return; }
/// <summary> /// Create an instance of a mobile from the provided template. /// </summary> /// <param name="mobTemplate"></param> /// <returns></returns> public static CharData CreateMobile( MobTemplate mobTemplate ) { int count; if( !mobTemplate ) { Log.Error("CreateMobile: null MobTemplate.", 0); throw new NullReferenceException(); } CharData mob = new CharData(); mob.MobileTemplate = mobTemplate; mob.Followers = null; mob.Name = mobTemplate.PlayerName; mob.ShortDescription = mobTemplate.ShortDescription; mob.FullDescription = mobTemplate.FullDescription; mob.Description = mobTemplate.Description; mob.SpecialFunction = mobTemplate.SpecFun; mob.SpecialFunctionNames = mobTemplate.SpecFunNames; mob.CharacterClass = mobTemplate.CharacterClass; mob.Level = MUDMath.FuzzyNumber( mobTemplate.Level ); mob.ActionFlags = mobTemplate.ActionFlags; mob.CurrentPosition = mobTemplate.DefaultPosition; mob.ChatterBotName = mobTemplate.ChatterBotName; // TODO: Look up the chatter bot name and load a runtime bot into the variable. mob.ChatBot = null; for( count = 0; count < Limits.NUM_AFFECT_VECTORS; ++count ) { mob.AffectedBy[ count ] = mobTemplate.AffectedBy[ count ]; } mob.Alignment = mobTemplate.Alignment; mob.Gender = mobTemplate.Gender; mob.SetPermRace( mobTemplate.Race ); mob.CurrentSize = Race.RaceList[ mob.GetRace() ].DefaultSize; if (mob.HasActionBit(MobTemplate.ACT_SIZEMINUS)) mob.CurrentSize--; if (mob.HasActionBit(MobTemplate.ACT_SIZEPLUS)) mob.CurrentSize++; mob.CastingSpell = 0; mob.CastingTime = 0; mob.PermStrength = MUDMath.Dice( 2, 46 ) + 8; mob.PermIntelligence = MUDMath.Dice( 2, 46 ) + 8; mob.PermWisdom = MUDMath.Dice( 2, 46 ) + 8; mob.PermDexterity = MUDMath.Dice( 2, 46 ) + 8; mob.PermConstitution = MUDMath.Dice( 2, 46 ) + 7; mob.PermAgility = MUDMath.Dice( 2, 46 ) + 8; mob.PermCharisma = MUDMath.Dice( 2, 46 ) + 8; mob.PermPower = MUDMath.Dice( 2, 46 ) + 8; mob.PermLuck = MUDMath.Dice( 2, 46 ) + 8; mob.ModifiedStrength = 0; mob.ModifiedIntelligence = 0; mob.ModifiedWisdom = 0; mob.ModifiedDexterity = 0; mob.ModifiedConstitution = 0; mob.ModifiedAgility = 0; mob.ModifiedCharisma = 0; mob.ModifiedPower = 0; mob.ModifiedLuck = 0; mob.Resistant = mobTemplate.Resistant; mob.Immune = mobTemplate.Immune; mob.Susceptible = mobTemplate.Susceptible; mob.Vulnerable = mobTemplate.Vulnerable; mob.MaxMana = mob.Level * 10; if( Race.RaceList[mobTemplate.Race].Coins ) { int level = mobTemplate.Level; mob.ReceiveCopper( MUDMath.Dice( 12, level ) / 32 ); mob.ReceiveSilver( MUDMath.Dice( 9, level ) / 32 ); mob.ReceiveGold( MUDMath.Dice( 5, level ) / 32 ); mob.ReceivePlatinum( MUDMath.Dice( 2, level ) / 32 ); } else { mob.SetCoins( 0, 0, 0, 0 ); } mob.ArmorPoints = MUDMath.Interpolate( mob.Level, 100, -100 ); // * MOB HITPOINTS * // // Was level d 8, upped it to level d 13 // considering mobs *still* won't have as many hitpoints as some players until // at least level 10, this shouldn't be too big an upgrade. // // Mob hitpoints are not based on constitution *unless* they have a // constitution modifier from an item, spell, or other affect // In light of recent player dissatisfaction with the // mob hitpoints, I'm implementing a log curve, using // hp = exp( 2.15135 + level*0.151231) // This will will result in the following hp matrix: // Level Hitpoints // 20 175 // 30 803 // 40 3643 // 50 16528 // 55 35207 // 60 75000 mob.MaxHitpoints = MUDMath.Dice( mob.Level, 13 ) + 1; // Mob hps are non-linear above level 10. if( mob.Level > 20 ) { int upper = (int)Math.Exp( 1.85 + mob.Level * 0.151231 ); int lower = (int)Math.Exp( 1.80 + mob.Level * 0.151231 ); mob.MaxHitpoints += MUDMath.NumberRange( lower, upper ); } else if (mob.Level > 10) { mob.MaxHitpoints += MUDMath.NumberRange(mob.Level * 2, ((mob.Level - 8) ^ 2 * mob.Level) / 2); } // Demons/devils/dragons gain an extra 30 hitpoints per level (+1500 at lvl 50). if (mob.GetRace() == Race.RACE_DEMON || mob.GetRace() == Race.RACE_DEVIL || mob.GetRace() == Race.RACE_DRAGON) { mob.MaxHitpoints += (mob.Level * 30); } mob.Hitpoints = mob.GetMaxHit(); // Horses get more moves, necessary for mounts. if(Race.RaceList[ mob.GetRace() ].Name.Equals( "Horse", StringComparison.CurrentCultureIgnoreCase )) { mob.MaxMoves = 290 + MUDMath.Dice( 4, 5 ); mob.CurrentMoves = mob.MaxMoves; } mob.LoadRoomIndexNumber = 0; // Insert in list. CharList.Add( mob ); // Increment count of in-game instances of mob. mobTemplate.NumActive++; return mob; }
/// <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; }
public static void GetObject(CharData ch, Object obj, Object container) { if (!obj.HasWearFlag(ObjTemplate.WEARABLE_CARRY)) { ch.SendText("You can't pick that up.\r\n"); return; } if (obj._itemType != ObjTemplate.ObjectType.money) { if (ch.CarryWeight + obj.GetWeight() > ch.MaxCarryWeight()) { SocketConnection.Act("$p&n is quite literally the &+Ystraw&n that would break the &n&+ycamel&n's back.", ch, obj, null, SocketConnection.MessageTarget.character); return; } } if (container != null) { SocketConnection.Act("You get $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n retrieves $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.room); obj.RemoveFromObject(); // Fix for corpse EQ dupe on crash if (container._itemType == ObjTemplate.ObjectType.pc_corpse) { Database.CorpseList.Save(); } } else { SocketConnection.Act("You get $p&n.", ch, obj, container, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n picks up $p&n.", ch, obj, container, SocketConnection.MessageTarget.room); obj.RemoveFromRoom(); } if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil()) { SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L. Ouch!&n", ch, obj, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room); Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic); obj.AddToRoom(ch.InRoom); return; } if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil()) { SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L. Ouch!&n", ch, obj, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room); Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic); obj.AddToRoom(ch.InRoom); return; } if (obj.HasFlag(ObjTemplate.ITEM_ANTI_GOOD) && ch.IsGood()) { SocketConnection.Act("&+LYou are &n&+rconsumed&+L by &+Rfire&+L and &+Ldespair&n from $p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&+L is &n&+rengulfed&+L by an abundancy of &+Rflames&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room); Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic); obj.AddToRoom(ch.InRoom); return; } if (obj._itemType == ObjTemplate.ObjectType.money) { int amount = obj._values[0] + obj._values[1] + obj._values[2] + obj._values[3]; ch.ReceiveCopper(obj._values[0]); ch.ReceiveSilver(obj._values[1]); ch.ReceiveGold(obj._values[2]); ch.ReceivePlatinum(obj._values[3]); if (amount > 1) { string text = String.Format("You pick up"); string text2; if (obj._values[3] > 0) { text2 = String.Format(" {0} &+Wplatinum&n", obj._values[3]); if (obj._values[0] > 0 || obj._values[1] > 0 || obj._values[2] > 0) { text2 += ","; } text += text2; } if (obj._values[2] > 0) { text2 = String.Format(" {0} &+Ygold&n", obj._values[2]); if (obj._values[0] > 0 || obj._values[1] > 0) { text2 += ","; } text += text2; } if (obj._values[1] > 0) { text2 = String.Format(" {0} &n&+wsilver&n", obj._values[1]); if (obj._values[0] > 0) { text2 += ","; } text += text2; } if (obj._values[0] > 0) { text2 = String.Format(" {0} &n&+ycopper&n", obj._values[0]); text += text2; } text += " coins.\r\n"; ch.SendText(text); } obj.RemoveFromWorld(); } else { obj.ObjToChar(ch); // Prevent item duplication. CharData.SavePlayer(ch); } return; }