/// <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> /// Displays the "who list" based on provided paramters. /// </summary> /// <param name="ch"></param> /// <param name="str"></param> public static void Who(CharData ch, string[] str) { if( ch == null ) return; if (ch.Fighting || (ch.CurrentPosition == Position.fighting)) { ch.SendText("&nEnd the fight first!\r\n"); return; } // Set racewar side to check Race.RacewarSide rws; // for RaceWarSide wholist if (ch.IsImmortal()) { rws = Race.RacewarSide.neutral; } else { rws = ch.GetRacewarSide(); } // Initialize races and classes to false. bool[] rgfClass = new bool[CharClass.ClassList.Length]; bool[] rgfRace = new bool[Limits.MAX_PC_RACE]; int iClass; int iRace; for (iClass = 0; iClass < CharClass.ClassList.Length; ++iClass) { rgfClass[iClass] = false; } for (iRace = 0; iRace < Limits.MAX_PC_RACE; ++iRace) { rgfRace[iRace] = false; } // Handle command arguments. int iLevelLower = 0; int iLevelUpper = Limits.MAX_LEVEL; int numbers = 0; bool immortalOnly = false; bool sorted = false; /* for sorted list */ bool fClassRestrict = false; bool fRaceRestrict = false; string name = String.Empty; for (int i = 0; i < str.Length; i++ ) { // Level numbers. if (MUDString.IsNumber(str[i])) { switch (++numbers) { case 1: Int32.TryParse(str[i], out iLevelLower); break; case 2: Int32.TryParse(str[i], out iLevelUpper); break; default: ch.SendText("&nOnly two level numbers allowed.\r\n"); return; } } else { // Look for classes to turn on. if (!MUDString.IsPrefixOf(str[i], "immortals")) { immortalOnly = true; } else if (!MUDString.IsPrefixOf(str[i], "sort")) { sorted = true; } else if (ch.IsImmortal() && !MUDString.IsPrefixOf(str[i], "good")) { rws = Race.RacewarSide.good; } else if (ch.IsImmortal() && !MUDString.IsPrefixOf(str[i], "evil")) { rws = Race.RacewarSide.evil; } else { int iClass2; for (iClass2 = 0; iClass2 < CharClass.ClassList.Length; ++iClass2) { if (!MUDString.IsPrefixOf(str[i], CharClass.ClassList[iClass2].Name)) { rgfClass[iClass2] = true; fClassRestrict = true; break; } } for (iRace = 0; iRace < Limits.MAX_PC_RACE; ++iRace) { if (!MUDString.IsPrefixOf(str[i], Race.RaceList[iRace].Name)) { rgfRace[iRace] = true; fRaceRestrict = true; break; } } if (iClass2 == CharClass.ClassList.Length && iRace == Limits.MAX_PC_RACE) { name = str[i]; } } } } // Now show characters that match our parameters. int nMatch = 0; List<String> immortals = new List<String>(); List<String> mortals = new List<String>(); /* Limits.L_DIR; Used to be Max_level.. Why change this? */ string text = String.Empty; int temp; int numPlayers = 0; for (temp = 0; temp <= Limits.MAX_LEVEL; ++temp) { /* for sorted list */ foreach (SocketConnection socket in Database.SocketList) { string cclass; CharData workingChar = (socket.Original != null) ? socket.Original : socket.Character; /* * Check for match against restrictions. * Don't use trust as that exposes trusted mortals. */ if (socket.ConnectionStatus != SocketConnection.ConnectionState.playing || !CharData.CanSee(ch, workingChar)) { continue; } if (name.Length == 0) { /* Outside level/class restrictions. */ if ((workingChar.Level < iLevelLower) || (workingChar.Level > iLevelUpper) || (fClassRestrict && !rgfClass[(int)workingChar.CharacterClass.ClassNumber]) || (fRaceRestrict && !rgfRace[workingChar.GetRace()])) continue; if (sorted != false && (workingChar.Level != temp)) continue; /* Imm only . skip non-immortals. */ if (immortalOnly && !workingChar.IsImmortal()) continue; } else if (!MUDString.NameContainedIn(workingChar.Name, name) || (workingChar.Level != temp && sorted != false)) continue; /* Opposite racewar sides, and both chars are mortals. */ if (workingChar.GetRacewarSide() != rws && rws != Race.RacewarSide.neutral && !workingChar.IsImmortal()) continue; nMatch++; /* * Figure out what to print for class. */ if (workingChar.Level >= Limits.LEVEL_HERO) { switch (workingChar.Level) { default: cclass = "&+yUnknown &n"; break; case Limits.LEVEL_OVERLORD: cclass = "&+r Overlord &n"; break; case Limits.LEVEL_GREATER_GOD: cclass = "&+mGreater God&n"; break; case Limits.LEVEL_LESSER_GOD: cclass = "&+MLesser God &n"; break; case Limits.LEVEL_DEMIGOD: cclass = "&+y Demigod &n"; break; case Limits.LEVEL_AVATAR: cclass = "&+R Avatar &n"; break; case Limits.LEVEL_HERO: cclass = "&+c Hero &n"; break; } } else { cclass = workingChar.CharacterClass.WholistName; } /* * Format it up. */ if (!workingChar.IsImmortal()) { string buf5 = String.Format("{0}{1}{2}{3}{4} {5} ({6})", workingChar.HasActionBit(PC.PLAYER_BOTTING) ? "[BOT] " : String.Empty, workingChar.HasActionBit(PC.PLAYER_AFK) ? "[AFK] " : String.Empty, workingChar.IsAffected(Affect.AFFECT_INVISIBLE) ? "*" : String.Empty, workingChar.Name, ((PC)workingChar).Title, !workingChar.IsGuild() ? String.Empty : ((PC)workingChar).GuildMembership.WhoName, Race.RaceList[workingChar.GetRace()].ColorName); text = String.Format("&+L[&n{0} {1}&+L]&n {2}\r\n", MUDString.PadInt(workingChar.Level, 2), MUDString.PadStr(cclass, 13), buf5); } else { string buf1 = String.Format("{0}{1}{2}{3}{4}", workingChar.HasActionBit(PC.PLAYER_WIZINVIS) ? "(WIZINVIS) " : String.Empty, workingChar.HasActionBit(PC.PLAYER_AFK) ? "[AFK] " : String.Empty, workingChar.HasActionBit(PC.PLAYER_BOTTING) ? "[BOT] " : String.Empty, workingChar.Name, ((PC)workingChar).Title); string buf2 = String.Format(" {0}", !workingChar.IsGuild() ? String.Empty : ((PC)workingChar).GuildMembership.WhoName); text = String.Format("&+L[&n{0}&+L]&n {1}{2}\r\n", MUDString.PadStr(cclass, 15), buf1, buf2); } if (!workingChar.IsImmortal()) { mortals.Add(text); } else { immortals.Add(text); } } if (sorted == false) { break; } } // Immortals show up above mortals because immortals are more important. ch.SendText("\r\n"); if (immortals.Count > 0) { ch.SendText("&+b-----------------------------------[ &+BIMMORTALS&+b ]-----------------------------&n\r\n"); } foreach( String who in immortals ) { ch.SendText(who); } if (mortals.Count > 0) { ch.SendText("&n&+b------------------------------------[ &+BMORTALS&n&+b ]------------------------------&n\r\n"); } foreach (String who in mortals) { ch.SendText(who); } ch.SendText("&n&+b-----------------------------------------------------------------------------&n\r\n"); foreach (SocketConnection socket in Database.SocketList) { if (socket.ConnectionStatus == SocketConnection.ConnectionState.playing) { numPlayers++; } } text = String.Format("&nYou see {0} of {1} player{2} in the game.\r\n", nMatch, numPlayers, numPlayers == 1 ? String.Empty : "s"); ch.SendText(text); return; }
/// <summary> /// Check to see if the char is able to attack the victim, and if not, give a message saying why they can't. /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> /// <returns></returns> public static bool IsSafe( CharData ch, CharData victim ) { if (ch == null || victim == null) return false; // Always safe to attack yourself. if (ch == victim) return false; if (!ch.IsNPC() && !victim.IsNPC() && victim.GetRacewarSide() == ch.GetRacewarSide() && !ch.IsImmortal()) { SocketConnection.Act("You can't attack an ally.\r\n", ch, null, victim, SocketConnection.MessageTarget.character); return true; } if( !ch.IsNPC() && ch.IsAffected( Affect.AFFECT_WRAITHFORM ) ) { ch.SendText( "&+LYou may not participate in combat while in &+Cgh&n&+co&+Cu&n&+cl&+L form.&n\r\n" ); return true; } if( !victim.IsNPC() && victim.HasActionBit(PC.PLAYER_JUST_DIED ) ) { ch.SendText( "&+cThey just died, try in a few seconds...&n\r\n" ); return true; } if (!victim.IsNPC() && victim.IsAffected(Affect.AFFECT_WRAITHFORM)) { SocketConnection.Act( "Your attack passes through $N.", ch, null, victim, SocketConnection.MessageTarget.character ); SocketConnection.Act( "$n's attack passes through $N.", ch, null, victim, SocketConnection.MessageTarget.room_vict ); SocketConnection.Act( "$n's attack passes through you.", ch, null, victim, SocketConnection.MessageTarget.victim ); return true; } // removed restriction allowing only registered players to pkill if( victim.Level > Limits.LEVEL_HERO && victim != ch && !victim.IsNPC() ) { SocketConnection.Act( "$N&n is an IMMORTAL and is automatically safe.", ch, null, victim, SocketConnection.MessageTarget.character ); return true; } if( victim.Fighting ) return false; if( victim.InRoom.HasFlag( RoomTemplate.ROOM_SAFE ) ) { SocketConnection.Act( "$N&n is in a safe room.", ch, null, victim, SocketConnection.MessageTarget.character ); return true; } if( IsBossMob( victim ) ) { //keep fighting, but allow the boss to invoke his special function // ensures the function will be called string lbuf = String.Format( "{0} is a boss", victim.ShortDescription ); Log.Trace( lbuf ); victim.Fighting = ch; if( victim.SpecialFunction.Count > 0 ) { foreach( MobSpecial spec in victim.SpecialFunction ) { if( spec.SpecFunction( victim, MobFun.PROC_NORMAL ) ) { // Only execute one function. break; } } } return false; } if( ch.IsNPC() || victim.IsNPC() ) return false; return false; }
/// <summary> /// Check whether the being entering the area is an enemy and needs to be dealt with. /// </summary> /// <param name="ch"></param> public static void CheckInvader( CharData ch ) { string lbuf; if (ch == null || ch.IsNPC() || ch.IsImmortal()) return; if( ch.InRoom == null || ch.InRoom.Area == null || ch.InRoom.Area.JusticeType == 0 ) return; switch( ch.GetRacewarSide() ) { case Race.RacewarSide.good: if( ch.InRoom.Area.JusticeType == JusticeType.chaotic_evil || ch.InRoom.Area.JusticeType == JusticeType.chaotic_evil_only || ch.InRoom.Area.JusticeType == JusticeType.chaotic_neutral_only || ch.InRoom.Area.JusticeType == JusticeType.evil_only || ch.InRoom.Area.JusticeType == JusticeType.neutral_only || ch.InRoom.Area.JusticeType == JusticeType.evil ) { lbuf = String.Format( "Check_invader: {0} invading !good justice", ch.Name ); ImmortalChat.SendImmortalChat( null, ImmortalChat.IMMTALK_SPAM, 0, lbuf ); StartInvasion( ch ); } return; case Race.RacewarSide.evil: if( ch.InRoom.Area.JusticeType == JusticeType.chaotic_good || ch.InRoom.Area.JusticeType == JusticeType.chaotic_good_only || ch.InRoom.Area.JusticeType == JusticeType.chaotic_neutral_only || ch.InRoom.Area.JusticeType == JusticeType.good_only || ch.InRoom.Area.JusticeType == JusticeType.neutral_only || ch.InRoom.Area.JusticeType == JusticeType.good ) { lbuf = String.Format( "Check_invader: {0} invading !evil justice", ch.Name ); ImmortalChat.SendImmortalChat( null, ImmortalChat.IMMTALK_SPAM, 0, lbuf ); StartInvasion( ch ); } return; case Race.RacewarSide.neutral: if( ch.InRoom.Area.JusticeType == JusticeType.chaotic_good_only || ch.InRoom.Area.JusticeType == JusticeType.chaotic_evil_only || ch.InRoom.Area.JusticeType == JusticeType.evil_only || ch.InRoom.Area.JusticeType == JusticeType.good_only) { lbuf = String.Format( "Check_invader: {0} invading !neutral justice", ch.Name ); ImmortalChat.SendImmortalChat( null, ImmortalChat.IMMTALK_SPAM, 0, lbuf ); StartInvasion( ch ); } return; } return; }
/// <summary> /// Checks whether the caller is aggressive toward the victim. /// </summary> /// <param name="victim"></param> /// <returns></returns> public bool IsAggressive(CharData victim) { CharData ch = this; Guild guild = null; if (victim == null) { Log.Error("IsAggressive: called with null ch or victim.", 0); return false; } if (ch == victim) { return false; } if (MUDString.NameContainedIn("_guildgolem_", ch.Name)) { foreach (Guild it in Database.GuildList) { guild = it; if (guild.ID == Guild.GolemGuildID(ch)) break; } if (guild != null && guild.Ostracized.Length != 0) { if (MUDString.NameContainedIn(victim.Name, guild.Ostracized)) return true; } } if (MUDString.NameContainedIn(Race.RaceList[victim.GetRace()].Name, Race.RaceList[ch.GetOrigRace()].Hate)) { Log.Trace("Returning true for IsAggressive due to race hatred."); return true; } if (ch.HasActionBit(MobTemplate.ACT_AGGROGOOD) && victim.IsGood()) { Log.Trace("Returning true for IsAggressive due to aggro good and good victim."); return true; } if (ch.HasActionBit(MobTemplate.ACT_AGGROEVIL) && victim.IsEvil()) { Log.Trace("Returning true for IsAggressive due to aggro evil and evil victim."); return true; } if (ch.HasActionBit(MobTemplate.ACT_AGGRONEUT) && victim.IsNeutral()) { Log.Trace("Returning true for IsAggressive due to aggro neutral and neutral victim."); return true; } if (ch.HasActionBit(MobTemplate.ACT_AGGROEVILRACE) && victim.GetRacewarSide() == Race.RacewarSide.evil) { Log.Trace("Returning true for IsAggressive due to aggro evil race and victim evil racewar."); return true; } if (ch.HasActionBit(MobTemplate.ACT_AGGROGOODRACE) && victim.GetRacewarSide() == Race.RacewarSide.good) { Log.Trace("Returning true for IsAggressive due to aggro good race and victim good racewar."); return true; } if (ch.HasActionBit(MobTemplate.ACT_AGGRESSIVE)) { Log.Trace("Returning true for IsAggressive due to aggressive flag on ch."); return true; } return ch.IsHating(victim); }
/// <summary> /// Checks whether the object can be worn by the character and provides a message /// to the character if it can't be. /// </summary> /// <param name="ch"></param> /// <returns></returns> public bool IsWearableBy(CharData ch) { if (ch.IsImmortal() && ch.HasActionBit(PC.PLAYER_GODMODE)) return true; if (ch.IsClass(CharClass.Names.monk)) { if (_weight > (1 + (ch.Level / 15))) { SocketConnection.Act("$p&n is too heavy for you to use.", ch, this, null, SocketConnection.MessageTarget.character); return false; } } if (HasWearFlag(ObjTemplate.USE_ANYONE)) return true; switch (ch.Gender) { case MobTemplate.Sex.male: if (HasAntiFlag(ObjTemplate.USE_ANTIMALE)) { SocketConnection.Act("$p&n is too dainty for one of such as yourself.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case MobTemplate.Sex.female: if (HasAntiFlag(ObjTemplate.USE_ANTIFEMALE)) { SocketConnection.Act("$p&n is too bulky and poorly designed for one as skilled as you.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case MobTemplate.Sex.neutral: if (HasAntiFlag(ObjTemplate.USE_ANTINEUTER)) { SocketConnection.Act("$p&n was not designed for your form.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; default: SocketConnection.Act("$p&n cannot be used by you because your sex is buggy.", ch, this, null, SocketConnection.MessageTarget.character); return false; } switch (ch.CharacterClass.ClassNumber) { default: break; case CharClass.Names.warrior: if (!HasAntiFlag(ObjTemplate.USE_WARRIOR)) { SocketConnection.Act("You won't abide such inferiority as found in $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.ranger: case CharClass.Names.hunter: if (!HasAntiFlag(ObjTemplate.USE_RANGER)) { SocketConnection.Act("Your professionalism prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.paladin: if (!HasAntiFlag(ObjTemplate.USE_PALADIN)) { SocketConnection.Act("Your convictions prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.antipaladin: if (!HasAntiFlag(ObjTemplate.USE_ANTI)) { SocketConnection.Act("Your skill and pride prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.cleric: if (!HasAntiFlag(ObjTemplate.USE_CLERIC)) { SocketConnection.Act("Your faith prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.druid: if (!HasAntiFlag(ObjTemplate.USE_DRUID)) { SocketConnection.Act("Your path prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.shaman: if (!HasAntiFlag(ObjTemplate.USE_SHAMAN)) { SocketConnection.Act("You lack the proper know-how to use $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.sorcerer: case CharClass.Names.illusionist: if (!HasAntiFlag(ObjTemplate.USE_SORCERER)) { SocketConnection.Act("You neglected use of $p&n in deference to your magics.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.elementAir: case CharClass.Names.elementEarth: case CharClass.Names.elementFire: case CharClass.Names.elementWater: if (!HasAntiFlag(ObjTemplate.USE_ELEMENTAL)) { SocketConnection.Act("You have better things to waste time on than $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.thief: if (!HasAntiFlag( ObjTemplate.USE_THIEF)) { SocketConnection.Act("Using $p&n would only hinder your abilities.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.psionicist: if (!HasAntiFlag(ObjTemplate.USE_PSI)) { SocketConnection.Act("The thought of using $p&n makes your brain hurt.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.assassin: if (!HasAntiFlag(ObjTemplate.USE_ASSASSIN)) { SocketConnection.Act("You never studied the art behind $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.mercenary: if (!HasAntiFlag( ObjTemplate.USE_MERCENARY)) { SocketConnection.Act("Your training never addressed using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case CharClass.Names.mystic: case CharClass.Names.monk: if (!HasAntiFlag( ObjTemplate.USE_MONK)) { SocketConnection.Act("You cannot use $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; } switch (ch.GetRace()) { default: break; case Race.RACE_HUMAN: if (HasAntiFlag( ObjTemplate.USE_NOHUMAN)) { SocketConnection.Act("Your race is ill fit to use $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_GREYELF: if (HasAntiFlag(ObjTemplate.USE_NOGREYELF)) { SocketConnection.Act("Your race is too weak to handle $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_HALFELF: if (HasAntiFlag( ObjTemplate.USE_NOHALFELF)) { SocketConnection.Act("Your bastardized nature prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_DWARF: if (HasAntiFlag( ObjTemplate.USE_NODWARF)) { SocketConnection.Act("Your body wasn't designed to use $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_HALFLING: if (HasAntiFlag( ObjTemplate.USE_NOGNOME)) { SocketConnection.Act("Just contemplating $p&n makes you long for food.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_BARBARIAN: if (HasAntiFlag( ObjTemplate.USE_NOBARBARIAN)) { SocketConnection.Act("Your size and mass prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_DUERGAR: if (HasAntiFlag( ObjTemplate.USE_NODUERGAR)) { SocketConnection.Act("Of what use is $p&n to a &n&+rduergar&n?", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_DROW: if (HasAntiFlag( ObjTemplate.USE_NODROW)) { SocketConnection.Act("The design of $p&n is too inferior for use by a &n&+mdrow&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_TROLL: if (HasAntiFlag( ObjTemplate.USE_NOTROLL)) { SocketConnection.Act("You try to use $p&n, but become quickly frustrated.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_OGRE: if (HasAntiFlag( ObjTemplate.USE_NOOGRE)) { SocketConnection.Act("You can't quite figure out how to use $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_ORC: if (HasAntiFlag( ObjTemplate.USE_NOORC)) { SocketConnection.Act("Obviously, $p&n was not crafted for an &+Lorc&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_CENTAUR: if (HasAntiFlag( ObjTemplate.USE_NOCENTAUR)) { SocketConnection.Act("Your find $p&n's design unsuitable for a &n&+gcen&+Ltaur&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_GITHYANKI: if (HasAntiFlag( ObjTemplate.USE_NOGITHYANKI)) { SocketConnection.Act("You find $p&n to be unfitting for a &+Wgith&+Gyanki&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_GITHZERAI: if (HasAntiFlag( ObjTemplate.USE_NOGITHZERAI)) { SocketConnection.Act("Your nature prevents you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_MINOTAUR: if (HasAntiFlag( ObjTemplate.USE_NOMINOTAUR)) { SocketConnection.Act("Your distinctive build prevents your use of $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_GOBLIN: if (HasAntiFlag( ObjTemplate.USE_NOGOBLIN)) { SocketConnection.Act("Your stature and build make it impossible for you to use $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_RAKSHASA: if (HasAntiFlag( ObjTemplate.USE_NORAKSHASA)) { SocketConnection.Act("Your feline structure inhibits you from using $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RACE_GNOLL: if (HasAntiFlag( ObjTemplate.USE_NOGNOLL)) { SocketConnection.Act("Your canine features hinder the use of $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; } switch (ch.GetRacewarSide()) { case Race.RacewarSide.good: if (HasAntiFlag( ObjTemplate.USE_ANTIGOODRACE)) { SocketConnection.Act("Your &n&+cs&+Co&n&+cu&+Cl&n is too &+Wpure&n to use $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; case Race.RacewarSide.evil: if (HasAntiFlag( ObjTemplate.USE_ANTIEVILRACE)) { SocketConnection.Act("Your &+Lblack &n&+rhe&+Ra&n&+rr&+Rt&n prevents use of $p&n.", ch, this, null, SocketConnection.MessageTarget.character); return false; } break; default: break; } return true; }
/// <summary> /// Formats an object for display to a character. /// </summary> /// <param name="obj"></param> /// <param name="ch"></param> /// <param name="shortDisplay"></param> /// <returns></returns> public static string FormatObjectToCharacter(Object obj, CharData ch, bool shortDisplay) { string text = String.Empty; if (obj == null || ch == null) { Log.Error("format_obj_to_char: null ch or obj.", 0); return null; } if (shortDisplay) { if (obj.ShortDescription.Length > 0) { text += obj.ShortDescription; } text += " "; } if (obj.HasFlag(ObjTemplate.ITEM_NOSHOW) && ch.IsImmortal()) { text += "&n(&+LNoshow&n) "; } else if (obj.HasFlag(ObjTemplate.ITEM_NOSHOW)) { return text; } if (obj.HasFlag(ObjTemplate.ITEM_INVIS)) { text += "&n(&+LInvis&n) "; } if ((ch.IsAffected( Affect.AFFECT_DETECT_EVIL) || ch.HasInnate(Race.RACE_DETECT_ALIGN) || ch.IsClass(CharClass.Names.antipaladin) || ch.IsClass(CharClass.Names.paladin)) && obj.HasFlag(ObjTemplate.ITEM_EVIL)) { text += "&n(&+LDark Aura&n) "; } if ((ch.IsAffected(Affect.AFFECT_DETECT_GOOD) || ch.HasInnate(Race.RACE_DETECT_ALIGN) || ch.IsClass(CharClass.Names.antipaladin) || ch.IsClass(CharClass.Names.paladin)) && obj.HasFlag(ObjTemplate.ITEM_BLESS)) { text += "&n(&+WLight Aura&n) "; } if (obj.HasFlag(ObjTemplate.ITEM_MAGIC) && (ch.IsAffected(Affect.AFFECT_DETECT_MAGIC) || (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_GODMODE)))) { text += "&n(&+BMagic&n) "; } if (obj.HasFlag(ObjTemplate.ITEM_GLOW)) { text += "&n(&+CGlowing&n) "; } if (obj.HasFlag(ObjTemplate.ITEM_LIT)) { text += "&n(&+WIlluminating&n) "; } if (obj.HasFlag(ObjTemplate.ITEM_SECRET) && (ch.IsAffected(Affect.AFFECT_DETECT_HIDDEN) || (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_GODMODE)))) { text += "&n(&+yHidden&n) "; } if (!shortDisplay) { if (obj.ItemType == ObjTemplate.ObjectType.pc_corpse && (ch.IsImmortal() || (int)ch.GetRacewarSide() == obj.Values[4])) { text += "The " + obj.ShortDescription + " is lying here."; } else if (obj.FullDescription.Length > 0) { text += obj.FullDescription; } } text += "&n"; return text; }