/// <summary> /// By Xangis. Currently only lists known languages /// Can change current language too. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Speak(CharData ch, string[] str) { if( ch == null ) return; string arg1 = String.Empty; if (ch.IsNPC()) return; if (String.IsNullOrEmpty(arg1)) { int count; string text; for (count = 0; count < Race.MAX_LANG; ++count) { if (count == (int)Race.Language.unknown) continue; if (((PC)ch).LanguageAptitude[count] > 20) { if (((PC)ch).LanguageAptitude[count] < 40) text = String.Format("You have a basic understanding of {0}.\r\n", Race.LanguageTable[count]); else if (((PC)ch).LanguageAptitude[count] < 60) text = String.Format("You comprehend {0}.\r\n", Race.LanguageTable[count]); else if (((PC)ch).LanguageAptitude[count] < 90) text = String.Format("You are quite fluent in {0}.\r\n", Race.LanguageTable[count]); else text = String.Format("You are a master of {0}.\r\n", Race.LanguageTable[count]); ch.SendText(text); } } if (((PC)ch).Speaking == Race.Language.unknown) ((PC)ch).Speaking = Race.RaceList[ch.GetOrigRace()].PrimaryLanguage; text = String.Format("Currently speaking "); text += Race.LanguageTable[(int)((PC)ch).Speaking]; text += ".\r\n"; ch.SendText(text); } else { Race.Language lang = StringLookup.LanguageLookup(ch, arg1); if (ch.CanSpeakLanguage(lang)) { string buf7 = String.Format("You begin speaking {0}.\r\n", Race.LanguageTable[(int)lang]); ((PC)ch).Speaking = lang; ch.SendText(buf7); } else { ch.SendText("You don't know that language!\r\n"); } } }
/// <summary> /// Direct telepathy-like communication with another individual. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Tell(CharData ch, string[] str) { if( ch == null ) return; if (!ch.CanSpeak()) { ch.SendText("Your lips move but no sound comes out.\r\n"); return; } if (str.Length < 2) { ch.SendText("Tell what to who?\r\n"); return; } /* * PCs can receive a tell anywhere, but NPCs only can only hear them in the same room. * * get PC target first, if fails then get NPC */ CharData victim = ch.GetCharWorld(str[0]); if (!victim || (victim.IsNPC() && victim.InRoom != ch.InRoom)) { ch.SendText("They aren't here.\r\n"); return; } if (victim == ch) { ch.SendText("You listen to your own thoughts. *cricket* *cricket*\r\n"); return; } if ((ch.IsRacewar(victim)) && (!ch.IsImmortal() && !victim.IsImmortal()) && (ch.InRoom != victim.InRoom)) { ch.SendText("They aren't here.\r\n"); return; } /* Can tell to other side of racewar iff the opponent is in the same room or one of the people are Immortals. */ if ((!ch.IsImmortal() && !victim.IsImmortal()) && (ch.IsRacewar(victim)) && (victim.InRoom != ch.InRoom)) { ch.SendText("They aren't here.\r\n"); return; } if ((!ch.IsNPC() && (ch.HasActionBit(PC.PLAYER_SILENCE) || !ch.HasActionBit(PC.PLAYER_TELL) || (!victim.IsNPC() && !victim.HasActionBit(PC.PLAYER_TELL)))) || victim.InRoom.HasFlag(RoomTemplate.ROOM_SILENT)) { ch.SendText("They can't hear you.\r\n"); return; } if (!victim.Socket && !victim.IsNPC()) { SocketConnection.Act("$N&n is &+Llinkdead&n.", ch, null, victim, SocketConnection.MessageTarget.character); return; } if (!ch.IsImmortal() && !victim.IsAwake()) { SocketConnection.Act("$E isn't paying attention.", ch, null, victim, SocketConnection.MessageTarget.character); return; } if (victim.IsIgnoring(ch)) { SocketConnection.Act("$E is ignoring you.", ch, null, victim, SocketConnection.MessageTarget.character); return; } string text = String.Join(" ", str, 1, (str.Length - 1)); text = DrunkSpeech.MakeDrunk(text, ch); int position = victim.CurrentPosition; victim.CurrentPosition = Position.standing; Race.Language lang = ch.IsNPC() ? Race.RaceList[ch.GetOrigRace()].PrimaryLanguage : ((PC)ch).Speaking; if (lang == Race.Language.god || lang == Race.Language.unknown) { text = String.Format("&+WYou tell $N&+W '$t&+W'&n"); } else { text = String.Format("&+WYou tell $N&+W in {0} '$t&+W'&n", Race.LanguageTable[(int)lang]); } SocketConnection.Act(text, ch, text, victim, SocketConnection.MessageTarget.character); if (lang == Race.Language.god || lang == Race.Language.unknown) { text = String.Format("&+W$n&+W tells you '$t&+W'&n"); } else { text = String.Format("&+W$n&+W tells you in {0} '$t&+W'&n", Race.LanguageTable[(int)lang]); } SocketConnection.Act(text, ch, SocketConnection.TranslateText(text, ch, victim), victim, SocketConnection.MessageTarget.victim); victim.CurrentPosition = position; victim.ReplyTo = ch; if (victim.HasActionBit(PC.PLAYER_AFK)) { SocketConnection.Act("Just so you know, $E is &+RAFK&n.", ch, null, victim, SocketConnection.MessageTarget.character); } else if (victim.HasActionBit(PC.PLAYER_BOTTING)) { SocketConnection.Act("Just so you know, $E is a &+YBOT&n", ch, null, victim, SocketConnection.MessageTarget.character); } // players can't have talk files -- go home! Quest stuff. if (!victim.IsNPC()) { return; } bool questfound = false; foreach (QuestTemplate it in QuestTemplate.QuestList) { bool isquest = (ch.IsImmortal() && !MUDString.StringsNotEqual(text, "quest")) ? true : false; if (it.Messages == null || (it.IndexNumber != victim.MobileTemplate.IndexNumber)) continue; foreach (TalkData message in it.Messages) { if (MUDString.NameContainedIn(text, message.Keywords) || isquest) { ch.SendText("\r\n"); ch.SendText(message.Message); questfound = true; } } } // Chatterbot code. Bots won't check if a quest matched (prevents multiple statements). if (!questfound && victim.ChatBot != null) { victim.ChatBot.CheckConversation(victim, ch, text); } return; }
/// <summary> /// Code to check if someone just fragged. /// Will also have to add to race, class, and guild frag tables in /// addition to the master frag table. This does not update any /// lists yet and instead only updates the totals. /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> public static void CheckForFrag( CharData ch, CharData victim ) { // NPC's don't participate in fragging, can't frag yourself, // have to be within 10 levels, no same side frags, no frags // from races not participating in racewars, have to be level // 20 to frag, and have to be a valid class. // Check to see if kill qualifies for a frag. if( ch.IsNPC() ) return; if( victim.IsNPC() ) return; if( ch == victim ) return; if( ch.GetRacewarSide() == Race.RacewarSide.neutral ) return; if( !ch.IsRacewar( victim ) ) return; if( ch.IsImmortal() ) return; if( victim.IsImmortal() ) return; if( victim.Level < 20 ) return; if( ch.Level < 20 ) return; if( ( ch.Level - 10 ) > victim.Level ) return; if (ch.IsClass(CharClass.Names.none) || victim.IsClass(CharClass.Names.none)) return; if( victim.GetOrigRace() > Limits.MAX_PC_RACE ) return; // Give frag to ch. ( (PC)ch ).Frags++; // Protect against polymorphed character race frags. if( ch.GetOrigRace() < Limits.MAX_PC_RACE ) { _fraglist._totalFragsByRaceAndClass[ch.GetOrigRace()][ (int)ch.CharacterClass.ClassNumber]++; _fraglist._totalFragsBySide[ (int)ch.GetRacewarSide() ]++; } if( ( (PC)ch ).GuildMembership != null ) ( (PC)ch ).GuildMembership.Frags++; // Take frag from victim. ( (PC)victim ).Frags--; // Protect against polymorphed character race frags if( victim.GetOrigRace() < Limits.MAX_PC_RACE ) { _fraglist._totalFragsByRaceAndClass[victim.GetOrigRace()][ (int)victim.CharacterClass.ClassNumber]--; _fraglist._totalFragsBySide[ (int)victim.GetRacewarSide() ]--; } if (((PC)victim).GuildMembership != null) { ((PC)victim).GuildMembership.Frags--; } ch.SendText( "&+WYou gain a frag!&n\r\n" ); victim.SendText( "&+WYou lose a frag!&n\r\n" ); string text = ch.Name + " has fragged " + victim.Name + " in room " + ch.InRoom.IndexNumber + "."; ImmortalChat.SendImmortalChat( ch, ImmortalChat.IMMTALK_DEATHS, Limits.LEVEL_AVATAR, text ); Log.Trace( text ); // Check to see if either person goes up or down on their particular lists. if( ( (PC)ch ).Frags > 0 ) { SortFraglist( ch, _fraglist._topFrags ); SortFraglist( ch, _fraglist._topRaceFrags[ ch.GetOrigRace() ] ); SortFraglist(ch, _fraglist._topClassFrags[(int)ch.CharacterClass.ClassNumber]); } else if( ( (PC)ch ).Frags < 0 ) { SortFraglist( ch, _fraglist._bottomFrags ); SortFraglist( ch, _fraglist._bottomRaceFrags[ ch.GetOrigRace() ] ); SortFraglist(ch, _fraglist._bottomClassFrags[(int)ch.CharacterClass.ClassNumber]); } if( ( (PC)victim ).Frags > 0 ) { SortFraglist( victim, _fraglist._topFrags ); SortFraglist( victim, _fraglist._topRaceFrags[ victim.GetOrigRace() ] ); SortFraglist(victim, _fraglist._topClassFrags[(int)victim.CharacterClass.ClassNumber]); } else if( ( (PC)victim ).Frags < 0 ) { SortFraglist( victim, _fraglist._bottomFrags ); SortFraglist( victim, _fraglist._bottomRaceFrags[ victim.GetOrigRace() ] ); SortFraglist(victim, _fraglist._bottomClassFrags[(int)victim.CharacterClass.ClassNumber]); } _fraglist.Save(); return; }
/// <summary> /// Say something out loud. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Say(CharData ch, string[] str) { if( ch == null ) return; if (str.Length == 0) { ch.SendText("Say what?\r\n"); return; } if (!ch.CanSpeak()) { ch.SendText("Your lips move but no sound comes out.\r\n"); return; } string text = String.Join(" ", str); text = DrunkSpeech.MakeDrunk(text, ch); if (ch.InRoom != null) { foreach (CharData roomChar in ch.InRoom.People) { if (roomChar == ch || roomChar.IsNPC()) continue; string output; if (ch.IsNPC() || (!ch.IsNPC() && (((PC)ch).Speaking == Race.Language.god || ((PC)ch).Speaking == Race.Language.unknown))) { output = String.Format("{0} says '&n$T&n'", ch.ShowNameTo(roomChar, true)); } else { output = String.Format("{0} says in {1} '&n$T&n'", ch.ShowNameTo(roomChar, true), ch.IsNPC() ? Race.LanguageTable[(int)Race.RaceList[ch.GetOrigRace()].PrimaryLanguage] : Race.LanguageTable[(int)((PC)ch).Speaking]); } // Add foreign language filter. SocketConnection.Act(output, roomChar, null, SocketConnection.TranslateText(text, ch, roomChar), SocketConnection.MessageTarget.character); // Chatterbot code. May want to restrict chatterbots to tells, asks, and whispers. if (roomChar.ChatBot != null) { roomChar.ChatBot.CheckConversation(roomChar, ch, text); } } } // MOBtrigger = false; SocketConnection.Act("You say '&n$T&n'", ch, null, text, SocketConnection.MessageTarget.character); // prog_speech_trigger( argument, ch ); ch.DoorTrigger(text); return; }
/* * Compute xp for a kill. * Also adjust alignment of killer. * Edit this function to change xp computations. */ static int ComputeExperience( CharData killer, CharData victim ) { int percent = 100; int sign; int alignDir; // Uses a semi-exponential table called ExperienceTable.Table // no exp is awarded for anything 20 levels below you. // exp is reduced by 10% per level of the creature below you // for the first 9 levels, and then another 1% for the next 9 levels. // It actually counts down starting at 91%. /* If victim is lower level */ if( victim.Level < killer.Level ) { /* If victim is less than 10 levels below */ if( killer.Level - victim.Level < 10 ) { percent = 101 - ( ( killer.Level - victim.Level ) * 10 ); } /* If victim is less than 20 levels below */ else if( killer.Level - victim.Level < 20 ) { percent = 20 - ( killer.Level - victim.Level ); } else { percent = 0; } } /* If victim is over 10 levels over */ else if( victim.Level > ( killer.Level + 10 ) && killer.Level <= 20 ) { // Experience penalty for killing stuff way higher than you, 33 level difference and you // get about nothing. // Tweaked this slightly, 96 % at 10 levels above, 96% at 10 levels, etc percent = 129 - ( ( victim.Level - killer.Level ) * 4 ); if( percent < 2 ) percent = 2; } else percent += ( victim.Level - killer.Level ); if( killer.Alignment > 0 ) sign = 1; else sign = -1; if( victim.Alignment > 0 ) alignDir = -1; else alignDir = 1; int chance = Math.Abs( killer.Alignment - victim.Alignment ) - sign * killer.Alignment; chance /= 10; if( chance < 0 ) chance *= -1; if( killer.Level > victim.Level ) chance -= ( killer.Level - victim.Level ); chance = Macros.Range( 0, chance, 100 ); string lbuf = String.Format( "ComputeExperience: {0} has a {1} chance of gaining {2} align.", killer.Name, chance, alignDir ); ImmortalChat.SendImmortalChat( null, ImmortalChat.IMMTALK_SPAM, 0, lbuf ); if( MUDMath.NumberPercent() < chance && killer.Alignment != -1000 ) { killer.Alignment += alignDir; if( killer.Alignment <= -1000 ) killer.SendText( "&+RThe d&+rarkside t&+lakes over...&n\r\n" ); } killer.Alignment = Macros.Range( -1000, killer.Alignment, 1000 ); // 25% bonus for sanctuary if (victim.IsAffected(Affect.AFFECT_SANCTUARY)) { percent = ( percent * 5 ) / 4; } // 10% bonus for fireshield if( victim.IsAffected( Affect.AFFECT_FIRESHIELD ) ) { percent = ( percent * 11 ) / 10; } // 12.5% bonus for an armed opponent Object obj = Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_one ); if( obj ) { percent = ( percent * 9 ) / 8; } // 8.25% bonus for secondary weapon obj = Object.GetEquipmentOnCharacter( victim, ObjTemplate.WearLocation.hand_two ); if( obj ) { percent = ( percent * 13 ) / 12; } // 10% bonus for racially hated mobs if( MUDString.NameContainedIn( Race.RaceList[ victim.GetRace() ].Name, Race.RaceList[ killer.GetOrigRace() ].Hate ) ) { percent = ( percent * 11 ) / 10; } // 10% penalty for killing same race if( victim.GetRace() == killer.GetOrigRace() ) { percent = ( percent * 9 ) / 10; } // Lowbie experience bonus was eliminated since the ExperienceTable.Table // made it no longer necessary if( victim.IsNPC() ) { // 5% bonus for aggros if( victim.HasActionBit(MobTemplate.ACT_AGGRESSIVE ) ) { percent = ( percent * 21 ) / 20; } // 50% penalty for killing shopkeepers if( victim.MobileTemplate.ShopData != null ) percent = percent / 2; // No bonus for special function #1 because they get that by having a class. // 10% bonus for each extra special function. int count = victim.SpecialFunction.Count; percent = ( percent * ( 10 + count ) ) / 10; } else { // Player-vs-player experience // // Killing a level 1-5 makes you lose a small amount of experience // and you get no experience for anyone under level 10. // // Those 11-20 are worth one fifth experience. if( victim.Level < 6 ) { killer.SendText( "You killed a newbie! You feel like a twink!\r\n" ); return (victim.Level - 6); } if( victim.Level < 11 ) { return 0; } if( victim.Level < 20 ) { percent /= 5; } else { percent *= 2; } if( !killer.IsRacewar( victim ) ) { if( !killer.HasActionBit( PC.PLAYER_BOTTING )) { killer.SendText("You gain no experience for killing your own side.\r\n"); return 0; } // Same-side bot kills are worth normal experience. killer.SendText("You gain experience for vanquishing an automaton.\r\n"); } else if( killer.HasActionBit( PC.PLAYER_BOTTING )) { // Racewar bot kills. 50% bonus exp. killer.SendText("You gain bonus experience for killing an automaton.\r\n"); percent = percent * 3/2; } } int xp = ( percent * ExperienceTable.Table[ victim.Level ].MobExperience ) / 100; xp = Math.Max( 0, xp ); return xp; }
/// <summary> /// Mangles text based on languages used by speaker and listener. /// </summary> /// <param name="sstring"></param> /// <param name="ch"></param> /// <param name="victim"></param> /// <returns></returns> public static string TranslateText( string sstring, CharData ch, CharData victim ) { if (String.IsNullOrEmpty(sstring) || ch == null || victim == null) { return String.Empty; } const string alphabet = "ecdfighjaklmnpyqrstvowxzub "; const string numbers = "1234567890"; int i; Race.Language lang = ch.IsNPC() ? Race.RaceList[ ch.GetOrigRace() ].PrimaryLanguage : ( (PC)ch ).Speaking; // Immortals have perfect speech & NPCs have perfect ears & nobody misunderstands themselves. if (victim.IsImmortal() || ch.IsImmortal() || victim.IsNPC() || (ch == victim) || ch.IsNPC()) return sstring; /* Step 1: Copy string. */ char[] buffer = sstring.ToCharArray(); /* Step 3: Check to see if ch says everything right. * NPC's never say anything wrong. */ if( !ch.IsNPC() ) { for( i = 0; i < buffer.Length; i++ ) { if( MUDMath.NumberPercent() > ( (PC)ch ).LanguageAptitude[ (int)lang ] && MUDMath.NumberPercent() < 50 ) { if( Char.IsLetter( buffer[ i ] ) ) { if( Char.IsLower( buffer[ i ] ) ) buffer[ i ] = alphabet[ buffer[ i ] - 'a' ]; else buffer[ i ] = Char.ToUpper( alphabet[ buffer[ i ] - 'A' ] ); } else if( Char.IsDigit( buffer[ i ] ) ) buffer[ i ] = numbers[ buffer[ i ] - '0' ]; else buffer[ i ] = buffer[ i ]; } } } // Step 4: Check for comprehend languages. If so, victim understands perfectly. if (victim.IsAffected(Affect.AFFECT_COMP_LANG) || (lang == Race.Language.unknown)) { return new String(buffer); } victim.PracticeLanguage( lang ); // Step 5: Check to see if victim hears everything right. for( i = 0; i < buffer.Length; i++ ) { if( MUDMath.NumberPercent() > ( (PC)victim ).LanguageAptitude[ (int)lang ] && MUDMath.NumberPercent() < 50 ) { if( Char.IsLetter( buffer[ i ] ) ) { if (Char.IsLower(buffer[i])) { buffer[i] = alphabet[buffer[i] - 'a']; } else { buffer[i] = Char.ToUpper(alphabet[buffer[i] - 'A']); } } else if (Char.IsDigit(buffer[i])) { buffer[i] = numbers[buffer[i] - '0']; } else { buffer[i] = buffer[i]; } } } /* Step 6: return the (probably messed up if it got this far) string. */ return new String(buffer); }
/// <summary> /// When player ch kills victim, adjusts faction standings of the player, player's guild, /// and the player's race. /// /// Keep in mind that _raceFaction values are "how they feel about us" values and not /// "how we feel about them" values. /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> public static void AdjustFaction(CharData ch, CharData victim) { // Faction hits can only be had when a player kills a mob. if (ch == null || victim == null || ch.IsNPC() || !victim.IsNPC()) { return; } if (Macros.IsSet((int)Database.SystemData.ActFlags, (int)Sysdata.MudFlags.disablefaction)) { return; } if (Macros.IsSet((int)Database.SystemData.ActFlags, (int)Sysdata.MudFlags.checkfactionbit) && victim.HasActionBit(MobTemplate.ACT_FACTION)) { return; } // First we do player faction. PC pc = (PC)ch; int race = victim.GetOrigRace(); pc.RaceFaction[race] -= 1.0; if (pc.RaceFaction[race] < Limits.MIN_FACTION) { pc.RaceFaction[race] = Limits.MIN_FACTION; } // Now we do guild faction at 1/10 the strength. if (pc.GuildMembership != null) { pc.GuildMembership.RaceFactionStandings[race] -= 0.1; if (pc.GuildMembership.RaceFactionStandings[race] < Limits.MIN_FACTION) { pc.GuildMembership.RaceFactionStandings[race] = Limits.MIN_FACTION; } } // Now we do race faction at 1/100 the strength. int pcrace = pc.GetOrigRace(); Race.RaceList[pcrace].RaceFaction[race] -= 0.01; if (Race.RaceList[pcrace].RaceFaction[race] < Limits.MIN_FACTION) { Race.RaceList[pcrace].RaceFaction[race] = Limits.MIN_FACTION; } // Now we check rival races to see whether we get any faction bonuses. for( int racenum = 0; racenum < Race.RaceList.Length; racenum++ ) { // Already adjusted this one or it's our race. if (racenum == race || racenum == pcrace ) continue; // Adjustment is done in fractions of a percent of a point (-1% to 1% based on how strongly the // opposing race feels). This may need to be increased. double adjustment = (Race.RaceList[racenum].RaceFaction[race] / Limits.MAX_FACTION) * 0.01; // Since a race that has high faction with the race that was just killed will result in a positive number // we subtract it from the player's faction with that race. pc.RaceFaction[racenum] -= adjustment; if (pc.RaceFaction[racenum] < Limits.MIN_FACTION) { pc.RaceFaction[racenum] = Limits.MIN_FACTION; } else if (pc.RaceFaction[racenum] > Limits.MAX_FACTION) { pc.RaceFaction[racenum] = Limits.MAX_FACTION; } // Adjust the race faction rankings of the player's guild. if (pc.GuildMembership != null) { // Guild takes 1/10 the adjustment. pc.GuildMembership.RaceFactionStandings[racenum] -= (adjustment / 10.0); if (pc.GuildMembership.RaceFactionStandings[racenum] < Limits.MIN_FACTION) { pc.GuildMembership.RaceFactionStandings[racenum] = Limits.MIN_FACTION; } else if (pc.GuildMembership.RaceFactionStandings[racenum] > Limits.MAX_FACTION) { pc.GuildMembership.RaceFactionStandings[racenum] = Limits.MAX_FACTION; } } // Adjust the race faction rankings of the players race. Race.RaceList[pcrace].RaceFaction[racenum] -= (adjustment / 100.0); if (Race.RaceList[pcrace].RaceFaction[racenum] < Limits.MIN_FACTION) { Race.RaceList[pcrace].RaceFaction[racenum] = Limits.MIN_FACTION; } else if (Race.RaceList[pcrace].RaceFaction[racenum] > Limits.MAX_FACTION) { Race.RaceList[pcrace].RaceFaction[racenum] = Limits.MAX_FACTION; } } }
/// <summary> /// Checks whether the current character is at racewar with the supplied character. /// </summary> /// <param name="ch"></param> /// <returns></returns> public bool IsRacewar( CharData ch ) { // Gods don't participate in racewars. if( IsImmortal() || ch.IsImmortal() ) { return false; } // NPCs are not a part of the war. if( IsNPC() || ch.IsNPC() ) { return false; } // We check using original race because racewars are based on the side a person is *really* on at heart. if( Race.RaceList[ GetOrigRace() ].WarSide != Race.RaceList[ ch.GetOrigRace() ].WarSide ) { return true; } return false; }
/// <summary> /// Gets the caller's faction standing with the victim. /// </summary> /// <param name="victim"></param> /// <returns></returns> public virtual double GetFaction(CharData victim) { int race = victim.GetOrigRace(); return GetFaction(race); }
/// <summary> /// Extracts a character from the world. If delete is true, it then deletes that character. /// </summary> /// <param name="ch"></param> /// <param name="delete"></param> public static void ExtractChar( CharData ch, bool delete ) { if( ch == null ) { Log.Error( "ExtractChar: null ch.", 0 ); return; } try { if (ch.Fighting) { Combat.StopFighting(ch, true); } Magic.ForgetAllSpells(ch); Event.DeleteAttachedEvents(ch); // Remove any affects we want to be gone next time they log in. ch.RemoveAffect(Affect.AFFECT_CASTING); ch.RemoveAffect(Affect.AFFECT_SINGING); // Meaning they're dead for good or have left the game. if (delete) { string name; if (ch.IsNPC()) { name = ch.ShortDescription; } else { name = ch.Name; } ch.DieFollower(name); if (ch.GroupLeader || ch.NextInGroup) { ch.RemoveFromGroup(ch); } /* Get rid of weapons _first_ */ { Object obj3 = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one); Object obj2 = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_two); if (obj3 != null) { obj3.RemoveFromWorld(); } /* Now kill obj2 if it exists no matter if on body or floor */ if (obj2) { obj2.RemoveFromWorld(); } } for (int i = ch.Carrying.Count - 1; i >= 0; --i) { ch.Carrying[i].RemoveFromWorld(); } } CharData worldChar; for (int xx = Database.CharList.Count - 1; xx >= 0; xx--) { worldChar = Database.CharList[xx]; if (worldChar.ReplyTo == ch) { worldChar.ReplyTo = null; } if (worldChar.IsConsenting(ch)) { worldChar.StopConsenting(ch); SocketConnection.Act("You stop consenting $N&n.", worldChar, null, ch, SocketConnection.MessageTarget.character); } if (worldChar.IsIgnoring(ch)) { worldChar.StopIgnoring(ch); SocketConnection.Act("You stop ignoring $N&n.", worldChar, null, ch, SocketConnection.MessageTarget.character); } if (!worldChar.IsNPC() && ((PC)worldChar).Guarding == ch) { ((PC)worldChar).Guarding = null; SocketConnection.Act("You stop guarding $N&n.", worldChar, null, ch, SocketConnection.MessageTarget.character); } if (worldChar.IsHating(ch)) worldChar.StopHating(ch); if (worldChar.Hunting && worldChar.Hunting.Who == ch) Combat.StopHunting(worldChar); if (worldChar.Fearing && worldChar.Fearing.Who == ch) Combat.StopFearing(worldChar); // Remove from the active character list. // BUG: TODO: FIXME: This invalidates the list for anyone iterating through // a list that may kill characters, such as violence_update. // it = CharList.erase( it ); } if (ch.InRoom) { // This was placed *after* the act strings to be safe. for (int iwch = ch.InRoom.People.Count - 1; iwch >= 0; iwch--) { if (ch.InRoom.People[iwch] == ch) { ch.RemoveFromRoom(); break; } } } // They're not being yanked from game, probably just dead and going to the menu. if (!delete) { Room location; if (ch.Level < 5 || Macros.IsSet((int)Database.SystemData.ActFlags, (int)Sysdata.MudFlags.alwaysequip)) ch.ReceiveNewbieEquipment(); if (!ch.IsNPC() && (ch.GetOrigRace() < Limits.MAX_PC_RACE) && ((int)ch.CharacterClass.ClassNumber < CharClass.ClassList.Length)) { // Get the default respawn location based on currhome, then race/class default. location = Room.GetRoom(((PC)ch).CurrentHome); if (location == null) { int place; List<RepopulationPoint> repoplist = ch.GetAvailableRepops(); if (repoplist.Count < 1) { place = StaticRooms.GetRoomNumber("ROOM_NUMBER_START"); } else { place = repoplist[0].RoomIndexNumber; } location = Room.GetRoom(place); if (location == null) { Log.Error("Starting room does not exist for class {0} of player's race! Calling ch.AddToRoom() for altar.", (int)ch.CharacterClass.ClassNumber); ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_ALTAR"))); } } else { ch.AddToRoom(location); } } else { location = Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_START")); if (location == null) { Log.Error("Starting room {0} does not exist! Calling char_to_room for altar.", StaticRooms.GetRoomNumber("ROOM_NUMBER_START")); ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_ALTAR"))); } else { ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_START"))); } } return; } // Clear modifiers. if (ch.IsNPC()) { --ch.MobileTemplate.NumActive; } else { ((PC)ch).Hunger = 48; ((PC)ch).Thirst = 48; ((PC)ch).Drunk = 0; ((PC)ch).LastRentLocation = 0; ch.ArmorPoints = 100; ch.CurrentPosition = Position.standing; ch.Hitpoints = Math.Max(1, ch.Hitpoints); ch.CurrentMana = Math.Max(1, ch.CurrentMana); ch.CurrentMoves = Math.Max(1, ch.CurrentMoves); ((PC)ch).HitpointModifier = 0; ch.Hitroll = 0; ch.Damroll = 0; ch.SavingThrows[0] = 0; ch.SavingThrows[1] = 0; ch.SavingThrows[2] = 0; ch.SavingThrows[3] = 0; ch.SavingThrows[4] = 0; ch.ModifiedStrength = 0; ch.ModifiedIntelligence = 0; ch.ModifiedWisdom = 0; ch.ModifiedDexterity = 0; ch.ModifiedConstitution = 0; ch.ModifiedAgility = 0; ch.ModifiedCharisma = 0; ch.ModifiedPower = 0; ch.ModifiedLuck = 0; ((PC)ch).MaxStrMod = 0; ((PC)ch).MaxIntMod = 0; ((PC)ch).MaxWisMod = 0; ((PC)ch).MaxDexMod = 0; ((PC)ch).MaxConMod = 0; ((PC)ch).MaxAgiMod = 0; ((PC)ch).MaxChaMod = 0; ((PC)ch).MaxPowMod = 0; ((PC)ch).MaxLukMod = 0; } if (ch.Socket && ch.Socket.Original) { CommandType.Interpret(ch, "return"); } ch.DeleteMe = true; } catch (Exception ex) { Log.Error("Exception in ExtractChar: " + ex.ToString()); } return; }
/// <summary> /// Gets the player's faction standing with the victim. Uses race, guild, and player standings in calculation. /// </summary> /// <param name="victim"></param> /// <returns></returns> public override double GetFaction(CharData victim) { int race = victim.GetOrigRace(); return GetFaction(race); }