本文整理汇总了C#中MUDEngine.CharData.AddToRoom方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.AddToRoom方法的具体用法?C# CharData.AddToRoom怎么用?C# CharData.AddToRoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MUDEngine.CharData
的用法示例。
在下文中一共展示了CharData.AddToRoom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Goto
/// <summary>
/// Teleport to another location.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Goto(CharData ch, string[] str)
{
if( ch == null ) return;
CharData realChar = ch.GetChar();
if (!realChar.Authorized("goto") || !ch.IsImmortal())
{
return;
}
if (str.Length == 0)
{
ch.SendText("Goto where?\r\n");
return;
}
Room location = Room.FindLocation(ch, str[0]);
if (!location)
{
ch.SendText("No such location.\r\n");
return;
}
if (location.IsPrivate())
{
ch.SendText("That room is private right now.\r\n");
return;
}
if (ch.Fighting)
{
Combat.StopFighting(ch, true);
}
if (!ch.HasActionBit(PC.PLAYER_WIZINVIS))
{
if (!ch.IsNPC() && ((PC)ch).ImmortalData.DisappearMessage.Length > 0)
{
SocketConnection.Act("$T", ch, null, ((PC)ch).ImmortalData.DisappearMessage, SocketConnection.MessageTarget.room);
}
else
{
SocketConnection.Act("$n disappears in a puff of smoke.", ch, null, null, SocketConnection.MessageTarget.room);
}
}
ch.RemoveFromRoom();
ch.AddToRoom(location);
if (!ch.HasActionBit(PC.PLAYER_WIZINVIS))
{
if (!ch.IsNPC() && ((PC)ch).ImmortalData.AppearMessage.Length > 0)
{
SocketConnection.Act("$T", ch, null, ((PC)ch).ImmortalData.AppearMessage, SocketConnection.MessageTarget.room);
}
else
{
SocketConnection.Act("$n appears in a swirling mist", ch, null, null, SocketConnection.MessageTarget.room);
}
}
CommandType.Interpret(ch, "look auto");
return;
}
示例2: FoundPrey
/// <summary>
/// Tracking mob has found the person its after. Attack or react accordingly.
/// </summary>
/// <param name="ch"></param>
/// <param name="victim"></param>
public static void FoundPrey( CharData ch, CharData victim )
{
string victname = String.Empty;
string text = String.Empty;
string lbuf = String.Empty;
if (!victim)
{
Log.Error("FoundPrey: null victim", 0);
return;
}
if (!victim.InRoom)
{
Log.Error("FoundPrey: null victim._inRoom", 0);
return;
}
ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, string.Format("{0}&n has found {1}.", ch.ShortDescription, victim.Name));
if (ch.IsAffected(Affect.AFFECT_TRACK))
{
ch.RemoveAffect(Affect.AFFECT_TRACK);
Combat.StopHunting(ch);
return;
}
if (ch.IsAffected(Affect.AFFECT_JUSTICE_TRACKER))
{
/* Give Justice the ability to ground flying culprits */
if (victim.FlightLevel != 0)
{
SocketConnection.Act("$n&n forces you to land!", ch, null, victim, SocketConnection.MessageTarget.victim);
SocketConnection.Act("$n&n forces $N&n to land!", ch, null, victim, SocketConnection.MessageTarget.room_vict);
victim.FlightLevel = 0;
}
SocketConnection.Act("$n&n says, 'Stop, $N&n, you're under ARREST!'", ch, null, victim, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n says, 'Stop, $N&n, you're under ARREST!'", ch, null, victim, SocketConnection.MessageTarget.room);
SocketConnection.Act("$n&n chains you up.", ch, null, victim, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n binds $N&n so $E can't move.", ch, null, victim, SocketConnection.MessageTarget.room);
victim.SetAffectBit(Affect.AFFECT_BOUND);
victim.RemoveFromRoom();
if (ch.InRoom.Area.JailRoom != 0)
{
victim.AddToRoom(Room.GetRoom(victim.InRoom.Area.JailRoom));
}
else
{
victim.SendText("Justice is broken in this town - there is no jail and you're screwed.\r\n");
}
Combat.StopHunting(ch);
return;
}
victname = victim.IsNPC() ? victim.ShortDescription : victim.Name;
if (ch.FlightLevel != victim.FlightLevel)
{
if (ch.CanFly())
{
if (ch.FlightLevel < victim.FlightLevel && ch.FlightLevel < CharData.FlyLevel.high)
{
Command.Fly(ch, new string[] { "up" });
}
else
{
Command.Fly(ch, new string[] { "down" });
}
}
else
{
SocketConnection.Act("$n peers around looking for something.", ch, null, null, SocketConnection.MessageTarget.room);
}
return;
}
if (!CharData.CanSee(ch, victim))
{
if (MUDMath.NumberPercent() < 90)
return;
switch (MUDMath.NumberBits(5))
{
case 0:
text = String.Format("You can't hide forever, {0}!", victname);
Command.Say(ch, new string[]{text});
break;
case 1:
SocketConnection.Act("$n&n sniffs around the room.", ch, null, victim, SocketConnection.MessageTarget.room);
text = "I can smell your blood!";
Command.Say(ch, new string[]{text});
break;
case 2:
text = String.Format("I'm going to tear {0} apart!", victname);
Command.Yell(ch, new string[]{text});
break;
case 3:
//.........这里部分代码省略.........
示例3: Enter
//.........这里部分代码省略.........
if (!location)
{
ch.SendText("That boat is broken. You may not board it.\r\n");
return;
}
}
if (location.IsPrivate())
{
ch.SendText("There is no room for you on the other side.\r\n");
return;
}
if (!ship)
{
SocketConnection.Act("$n&n steps into $p&n.", ch, portal, null, SocketConnection.MessageTarget.room);
if (Macros.IsSet(portal.Values[3], ObjTemplate.PORTAL_RANDOM)
|| Macros.IsSet(portal.Values[3], ObjTemplate.PORTAL_BUGGY))
{
SocketConnection.Act("You walk through $p&n and find yourself somewhere else...",
ch, portal, null, SocketConnection.MessageTarget.character);
}
else
{
SocketConnection.Act("You enter $p&n.", ch, portal, null, SocketConnection.MessageTarget.character);
}
}
else
{
SocketConnection.Act("$n&n boards $p&n.", ch, portal, null, SocketConnection.MessageTarget.room);
SocketConnection.Act("You board $p&n.", ch, portal, null, SocketConnection.MessageTarget.character);
}
ch.RemoveFromRoom();
ch.AddToRoom(location);
if (!ship)
{
if (Macros.IsSet(portal.Values[3], ObjTemplate.PORTAL_RANDOM)
|| Macros.IsSet(portal.Values[3], ObjTemplate.PORTAL_BUGGY))
{
SocketConnection.Act("$n&n has arrived from elsewhere.", ch, portal, null, SocketConnection.MessageTarget.room);
}
else
{
SocketConnection.Act("$n&n steps out of $p&n.", ch, portal, null, SocketConnection.MessageTarget.room);
}
}
else
{
SocketConnection.Act("$n&n has boarded.", ch, portal, null, SocketConnection.MessageTarget.room);
}
CommandType.Interpret(ch, "look auto");
if (!ship)
{
if (portal.Values[2] > 0) /*
* This way i prevent an underflow
*/
portal.Values[2]--;
if (portal.Values[2] == 0)/*
* If there are no more charges; remove
*/
{
SocketConnection.Act("$p&n fades out of existence.", ch, portal, null, SocketConnection.MessageTarget.character);
SocketConnection.Act("$p&n fades out of existence.", ch, portal, null, SocketConnection.MessageTarget.room);
portal.RemoveFromWorld();
return;
}
if (Macros.IsSet(portal.Values[3], ObjTemplate.PORTAL_GO_WITH))
{
portal.RemoveFromRoom();
portal.AddToRoom(location);
}
}
foreach (CharData follower in original.People)
{
if (!follower.IsAffected(Affect.AFFECT_CHARM) || follower.Master != ch)
{
continue;
}
if (follower.CurrentPosition < Position.standing)
{
CommandType.Interpret(ch, "stand");
}
if (follower.CurrentPosition == Position.standing && follower.Wait == 0)
{
SocketConnection.Act("You follow $N&n.", follower, null, ch, SocketConnection.MessageTarget.character);
Enter(follower, str);
}
}
return;
}
示例4: Fly
//.........这里部分代码省略.........
follower.FlightLevel++;
follower.SendText("You fly up.\r\n");
SocketConnection.Act("$n&n flies in from below.", follower, null, null, SocketConnection.MessageTarget.room);
}
}
}
}
else
{
// If in a zone then fly out.
if (!ch.InRoom.Area.HasFlag(Area.AREA_WORLDMAP))
{
int lower = ch.InRoom.Area.LowRoomIndexNumber;
int higher = ch.InRoom.Area.HighRoomIndexNumber;
int iroom;
for (iroom = lower; iroom <= higher; iroom++)
{
troom = Room.GetRoom(iroom);
if (!troom)
continue;
// Now check all exits.
int i;
for (i = 0; i < Limits.MAX_DIRECTION; i++)
{
texit = troom.ExitData[i];
if (!texit || !(texit.TargetRoom))
continue;
if (texit.TargetRoom.Area.HasFlag(Area.AREA_WORLDMAP))
{
// Found a way out. Should check for exit zone being flyable.
ch.SendText("You fly up.\r\n");
SocketConnection.Act("$n&n flies up higher.", ch, null, null, SocketConnection.MessageTarget.room);
ch.RemoveFromRoom();
ch.AddToRoom(Room.GetRoom(texit.IndexNumber));
ch.FlightLevel = CharData.FlyLevel.low;
CommandType.Interpret(ch, "look auto");
return;
}
}
}
ch.SendText("You can't fly out of this zone.\r\n"); // Glitch or no exits to worldmap.
}
ch.SendText("If you were any higher you'd be Woody Harrelson.\r\n");
}
}
else if (!MUDString.IsPrefixOf(str[0], "down"))
{
if (ch.FlightLevel > 0)
{
SocketConnection.Act("$n&n flies down lower.", ch, null, null, SocketConnection.MessageTarget.room);
ch.FlightLevel--;
SocketConnection.Act("$n&n flies in from above.", ch, null, null, SocketConnection.MessageTarget.room);
if (ch.FlightLevel == 0)
{
ch.SendText("You fly down to the ground.\r\n");
}
else
{
ch.SendText("You fly down.\r\n");
}
CommandType.Interpret(ch, "look auto");
foreach (CharData follower in ch.InRoom.People)
{
if (follower == ch)
{
continue;
示例5: Drag
/// <summary>
/// Used for dragging corpses into another room.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Drag(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj;
Object obj2;
if (ch.IsAffected( Affect.AFFECT_HOLD) ||
ch.IsAffected(Affect.AFFECT_MINOR_PARA))
{
ch.SendText("You can't move!\r\n");
return;
}
if (str.Length == 0)
{
ch.SendText("Drag which what where?\r\n");
return;
}
if (str.Length == 0)
{
ch.SendText("You need to specify a direction.\r\n");
return;
}
if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEMORIZING))
{
ch.RemoveActionBit(PC.PLAYER_MEMORIZING);
ch.SendText("You abandon your studies.\r\n");
}
if (!(obj = ch.GetObjHere(str[0])))
{
ch.SendText("You do not see that here.\r\n");
return;
}
if (obj.ItemType != ObjTemplate.ObjectType.npc_corpse && obj.ItemType != ObjTemplate.ObjectType.pc_corpse)
{
ch.SendText("You can only drag corpses.\r\n");
return;
}
if (str.Length > 2 && str[1] == "enter")
{
if ((obj2 = ch.GetObjHere(str[3])))
{
switch (obj2.ItemType)
{
case ObjTemplate.ObjectType.teleport:
case ObjTemplate.ObjectType.portal:
if (obj2.ItemType == ObjTemplate.ObjectType.teleport && !CommandType.CheckCommandTrigger("enter", obj2.Values[1]))
{
ch.SendText("Nothing happens.\r\n");
return;
};
Room location;
if (Macros.IsSet(obj2.Values[3], ObjTemplate.PORTAL_RANDOM))
{
location = Movement.GetRandomRoom();
}
else
{
location = Room.GetRoom(obj2.Values[0]);
}
if (!location)
{
ch.SendText("That portal doesn't seem to go anywhere.\r\n");
return;
}
SocketConnection.Act("You drag the $p&n into $P&n.", ch, obj, obj2, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n drags the $p&n into $P&n.", ch, obj, obj2, SocketConnection.MessageTarget.room);
if (obj2.Values[2] >= 0)
{
obj2.Values[2] -= 2;
if (obj2.Values[2] <= 0)
{
SocketConnection.Act("$p&n fades into nothingness.", ch, obj2, null, SocketConnection.MessageTarget.room);
obj2.RemoveFromRoom();
}
}
obj.RemoveFromRoom();
ch.RemoveFromRoom();
ch.AddToRoom(location);
obj.AddToRoom(location);
if (obj2.ItemType == ObjTemplate.ObjectType.portal)
{
SocketConnection.Act("$n&n steps out of $P&n dragging the $p&n.", ch, obj, obj2, SocketConnection.MessageTarget.room);
}
else
{
SocketConnection.Act("$n&n appears from elsewhere, dragging the $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
}
CommandType.Interpret(ch, "look auto");
//.........这里部分代码省略.........
示例6: At
/// <summary>
/// Perform a command at another location.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void At(CharData ch, string[] str)
{
if( ch == null ) return;
CharData realChar = ch.GetChar();
if (!realChar.Authorized("at"))
{
return;
}
if (str.Length < 2)
{
ch.SendText("At where what?\r\n");
return;
}
Room location = Room.FindLocation(ch, str[0]);
if (!location)
{
ch.SendText("No such location.\r\n");
return;
}
if (location.IsPrivate())
{
ch.SendText("That room is private right now.\r\n");
return;
}
Room original = ch.InRoom;
ch.RemoveFromRoom();
ch.AddToRoom(location);
string text = String.Join(" ", str, 1, (str.Length - 1));
CommandType.Interpret(ch, text);
/*
* See if 'ch' still exists before continuing!
* Handles 'at XXXX quit' case.
*/
foreach (CharData worldChar in Database.CharList)
{
if (worldChar == ch)
{
ch.RemoveFromRoom();
ch.AddToRoom(original);
break;
}
}
return;
}
示例7: LookOut
public static void LookOut(CharData ch, string[] str)
{
if( ch == null ) return;
Vehicle vehicle;
if (ch.InRoom == null)
return;
foreach (Vehicle it in Database.VehicleList)
{
vehicle = it;
if (vehicle.ParentObject == null)
continue;
if (ch.InRoom.IndexNumber == vehicle.EntryRoomTemplateNumber)
{
if (vehicle.ParentObject.InRoom)
{
// Copied from farsee code - Xangis
Room room = ch.InRoom;
ch.RemoveFromRoom();
ch.AddToRoom(vehicle.ParentObject.InRoom);
CommandType.Interpret(ch, "look");
ch.RemoveFromRoom();
ch.AddToRoom(room);
return;
}
}
}
ch.SendText("You do not see that here.\r\n");
return;
}
示例8: Interpret
/// <summary>
/// The main entry point for executing commands.
/// Can be recursively called from 'at', 'order', 'force'.
/// </summary>
/// <param name="ch"></param>
/// <param name="argument"></param>
public static void Interpret(CharData ch, string argument)
{
// Get rid of leading and trailing spaces.
argument = argument.Trim();
// Strip leading spaces.
argument.Trim();
if (argument.Length == 0)
{
return;
}
// Remove AFK
if (!ch.IsNPC())
{
ch.RemoveActionBit(PC.PLAYER_AFK);
}
// Implement freeze command.
if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_FREEZE))
{
ch.SendText("You're totally frozen!\r\n");
return;
}
// Grab the command word. Special parsing so ' can be a command,
// also no spaces needed after punctuation.
string command;
Object obj;
Room room;
int cmd;
string logline = argument;
int argptr = 0;
if (!Char.IsLetter(argument[0]) && !Char.IsDigit(argument[0]))
{
command = argument.Substring(0, 1);
argptr++;
while (argument.Length > argptr && Char.IsWhiteSpace(argument[argptr]))
{
argument = argument.Remove(0, 1);
}
}
else
{
command = MUDString.OneArgument(argument, ref argument);
argument.Trim(); // Clean up the remainder of the command.
}
// Nothing to do if command is empty. Just send them a newline and bail.
if (string.IsNullOrEmpty(command) && string.IsNullOrEmpty(argument))
{
ch.SendText("\r\n");
return;
}
// Look for an item with a teleport trigger in the room.
// and check to see if the command is a teleport trigger
if (ch.InRoom && (obj = ch.GetObjHere(argument)))
{
if (obj.ItemType == ObjTemplate.ObjectType.teleport)
{
if (CheckCommandTrigger(command, obj.Values[1]) && obj.Values[2] != 0)
{
if (obj.Values[2] != -1)
{
obj.Values[2]--;
}
room = Room.GetRoom(obj.Values[0]);
if (room)
{
SocketConnection.Act("$n&n vanishes suddenly.", ch, null, null, SocketConnection.MessageTarget.room);
string text = String.Format("You {0} $p&n.\r\n", command);
SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character);
Log.Trace(String.Format("{0} activated keyword and was teleported by object.", ch.Name));
ch.RemoveFromRoom();
ch.AddToRoom(room);
Interpret(ch, "look auto");
SocketConnection.Act("$n&n arrives suddenly.", ch, null, null, SocketConnection.MessageTarget.room);
}
else
{
ch.SendText("BUG: The target room for this teleporter does not exist.\r\n");
Log.Error("Target room for object {0} does not exist.", obj.ObjIndexData.IndexNumber);
}
return;
}
}
else if (obj.ItemType == ObjTemplate.ObjectType.switch_trigger)
{
Exit exit;
string cbuf = String.Format("Checking {0} against command no. {1} for {2}.", command, obj.Values[0], obj.Name);
ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_SPAM, 0, cbuf);
if (CheckCommandTrigger(command, obj.Values[0]))
{
//.........这里部分代码省略.........
示例9: StopIdling
/// <summary>
/// Used with AFK folks -- resets a player's idle timer and displays a string
/// saying that they are back at keys.
/// </summary>
/// <param name="ch"></param>
private static void StopIdling( CharData ch )
{
if (!ch || !ch.Socket || ch.Socket.ConnectionStatus != ConnectionState.playing
|| !ch.WasInRoom || ch.InRoom != Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_LIMBO")))
{
return;
}
ch.Timer = 0;
ch.RemoveFromRoom();
ch.AddToRoom( ch.WasInRoom );
ch.WasInRoom = null;
Act( "$n&+L has returned from the &+RA&n&+rb&+Rys&n&+rs&+L.&n", ch, null, null, MessageTarget.room );
return;
}
示例10: LookCommand
//.........这里部分代码省略.........
else if ("nw".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
door = 6;
else if ("sw".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
door = 7;
else if ("ne".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
door = 8;
else if ("se".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
door = 9;
}
if (door != -1)
{
// If no exit data, then return.
exit = ch.InRoom.ExitData[door];
if (!exit)
{
ch.SendText("There's nothing to see in that direction.\r\n");
return;
}
if (exit.HasFlag(Exit.ExitFlag.walled))
{
ch.SendText("There's a wall in the way.\r\n");
return;
}
// Check for farsee
if ((ch.IsAffected( Affect.AFFECT_FARSEE) || ch.HasActionBit(PC.PLAYER_GODMODE))
&& !exit.HasFlag(Exit.ExitFlag.closed))
{
if (exit.TargetRoom)
{
Room room = ch.InRoom;
ch.RemoveFromRoom();
ch.AddToRoom(Room.GetRoom(exit.IndexNumber));
CommandType.Interpret(ch, "look");
ch.RemoveFromRoom();
ch.AddToRoom(room);
return;
}
ch.SendText("Nothing special there.\r\n");
}
if (exit.Description.Length != 0)
{
ch.SendText(exit.Description);
}
else
{
ch.SendText("Nothing special there.\r\n");
}
if (exit.Keyword.Length != 0)
{
if (exit.HasFlag(Exit.ExitFlag.bashed))
SocketConnection.Act("The $d has been bashed from its &n&+whinges&n.",
ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
else if (exit.HasFlag(Exit.ExitFlag.closed))
SocketConnection.Act("The $d is closed.", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
else if (exit.HasFlag(Exit.ExitFlag.secret))
SocketConnection.Act("The $d is secret.", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
else if (exit.HasFlag(Exit.ExitFlag.blocked))
SocketConnection.Act("The $d is blocked.", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
}
else
{
if (exit.HasFlag(Exit.ExitFlag.bashed))
示例11: ExtractChar
//.........这里部分代码省略.........
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;
示例12: CreateCharacterFromObject
/// <summary>
/// Creates a character based on an object. Used for animate-object-type spells.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public CharData CreateCharacterFromObject( ref Object obj )
{
int count;
MobTemplate mobTemplate = Database.GetMobTemplate( StaticMobs.MOB_NUMBER_OBJECT );
if( !mobTemplate )
{
Log.Error( "CreateCharacterFromObject: null object template.", 0 );
return null;
}
CharData mob = new CharData();
mob.MobileTemplate = mobTemplate;
mob.Name = obj._name;
mob.ShortDescription = obj._shortDescription;
mob.FullDescription = obj._fullDescription;
mob.Description = obj._fullDescription;
mob.CharacterClass = mobTemplate.CharacterClass;
mob.Level = Math.Max( obj._level, 1 );
mob.ActionFlags = mobTemplate.ActionFlags;
mob.CurrentPosition = mobTemplate.DefaultPosition;
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 = 55;
mob.PermIntelligence = 55;
mob.PermWisdom = 55;
mob.PermDexterity = 55;
mob.PermConstitution = 55;
mob.PermAgility = 55;
mob.PermCharisma = 55;
mob.PermPower = 55;
mob.PermLuck = 55;
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.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 lvl 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
mob.MaxHitpoints = mob.Level * 100;
mob.Hitpoints = mob.GetMaxHit();
/*
* Insert in list.
*/
Database.CharList.Add( mob );
// Increment in-game count of mob.
mobTemplate.NumActive++;
mob.AddToRoom( obj._inRoom );
return mob;
}
示例13: CheckFall
/// <summary>
/// Check for falling. Called from room update and movement.
/// </summary>
/// <param name="room"></param>
/// <param name="target"></param>
/// <param name="ch"></param>
public static void CheckFall( Room room, Room target, CharData ch )
{
int chance;
if( !room || !target || !ch )
return;
if( room.TerrainType != TerrainType.air &&
room.TerrainType != TerrainType.plane_of_air &&
room.TerrainType != TerrainType.underground_no_ground )
{
if( MUDMath.NumberPercent() > room.FallChance )
return;
}
if( ch.CanFly() || ch.IsAffected( Affect.AFFECT_LEVITATE ) )
return;
if( ch.InRoom.People != null )
{
SocketConnection.Act( "You are falling down!", ch, null, null, SocketConnection.MessageTarget.character );
SocketConnection.Act( "$n&n falls away.", ch, null, null, SocketConnection.MessageTarget.room );
}
ch.RemoveFromRoom();
ch.AddToRoom( target );
if( !ch.HasSkill( "safe_fall" ) )
chance = 0;
else if( ch.IsNPC() )
chance = ( ( ch.Level * 3 ) / 2 ) + 15;
else
chance = ( (PC)ch ).SkillAptitude[ "safe fall" ];
// People with high agility have a small chance to safe fall, and those with
// the skill already get a bonus.
chance += ( ch.GetCurrAgi() / 20 );
// Minimum 1% chance of a bad fall.
if( chance > 99 )
{
chance = 99;
}
// Safe fall added by Xangis
if( target.FallChance == 0 || !target.ExitData[ 5 ]
|| !target.ExitData[ 5 ].TargetRoom )
{
if( MUDMath.NumberPercent() < chance )
{
// Decent chance of skill increase - people don't fall very often.
ch.PracticeSkill( "safe fall" );
ch.PracticeSkill( "safe fall" );
ch.PracticeSkill( "safe fall" );
ch.PracticeSkill( "safe fall" );
ch.SendText( "You fall to the ground!\r\n" );
if( MUDMath.NumberPercent() < chance )
{
SocketConnection.Act( "$n&n falls from above and lands gracefully.", ch, null, null, SocketConnection.MessageTarget.room );
ch.SendText( "You land gracefully, avoiding any injury.\r\n" );
}
else
{
SocketConnection.Act( "$n&n falls from above and lands on $s arse.", ch, null, null, SocketConnection.MessageTarget.room );
if( Race.MAX_SIZE > 0 && !ch.IsNPC() )
{
Combat.InflictDamage(ch, ch, MUDMath.NumberRange(2, 4), String.Empty, ObjTemplate.WearLocation.none, AttackType.DamageType.none);
ch.CurrentPosition = Position.sitting;
ch.WaitState( 3 );
}
}
}
else
{
ch.SendText( "You slam into the ground!\r\n" );
ch.CurrentPosition = Position.sitting;
ch.WaitState( 8 );
SocketConnection.Act( "$n&n comes crashing in from above.", ch, null, null, SocketConnection.MessageTarget.room );
if( Race.MAX_SIZE > 0 && !ch.IsNPC() )
{
Combat.InflictDamage( ch, ch, ( ( MUDMath.NumberPercent() * (int)ch.CurrentSize ) / Race.MAX_SIZE ),
String.Empty, ObjTemplate.WearLocation.none, AttackType.DamageType.none);
}
}
}
else if( ch && ch.InRoom )
{
if( ch.InRoom.People.Count > 0 )
{
SocketConnection.Act( "$n&n falls by.", ch, null, null, SocketConnection.MessageTarget.room );
}
}
return;
//.........这里部分代码省略.........
示例14: HuntVictim
//.........这里部分代码省略.........
if (ch.Hunting != null && ch.Hunting.Who == tmp)
found = true;
}
if (!found || !CharData.CanSee(ch, ch.Hunting.Who))
{
if (!ch.IsAffected(Affect.AFFECT_TRACK))
CommandType.Interpret(ch, "say Damn! My prey is gone!");
else
{
ch.SendText("The trail seems to disappear.\r\n");
ch.RemoveAffect(Affect.AFFECT_TRACK);
}
Combat.StopHunting(ch);
return;
}
if (ch.InRoom == ch.Hunting.Who.InRoom)
{
if (ch.Fighting)
{
return;
}
FoundPrey(ch, ch.Hunting.Who);
return;
}
ch.WaitState(Skill.SkillList["track"].Delay);
Exit.Direction dir = FindPath(ch.InRoom.IndexNumber, ch.Hunting.Who.InRoom.IndexNumber, ch, -40000, true);
if (dir == Exit.Direction.invalid)
{
if (!ch.IsAffected(Affect.AFFECT_TRACK))
{
SocketConnection.Act("$n&n says 'Damn! Lost $M!'", ch, null, ch.Hunting.Who, SocketConnection.MessageTarget.room);
}
else
{
ch.SendText("You lose the trail.\r\n");
ch.RemoveAffect(Affect.AFFECT_TRACK);
Combat.StopHunting(ch);
}
return;
}
/*
* Give a random direction if the mob misses the die roll.
*/
if (MUDMath.NumberPercent() > 75) /* @ 25% */
{
do
{
dir = Database.RandomDoor();
}
while (!(ch.InRoom.ExitData[(int)dir]) || !(ch.InRoom.ExitData[(int)dir].TargetRoom));
}
if (ch.InRoom.ExitData[(int)dir].HasFlag(Exit.ExitFlag.closed))
{
CommandType.Interpret(ch, "open " + dir.ToString());
return;
}
ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, String.Format("{0}&n leaves room {1} to the {2}.",
ch.ShortDescription, ch.InRoom.IndexNumber, dir.ToString()));
if (ch.IsAffected(Affect.AFFECT_TRACK))
{
SocketConnection.Act(String.Format("You sense $N&n's trail {0} from here...", dir.ToString()),
ch, null, ch.Hunting.Who, SocketConnection.MessageTarget.character);
}
ch.Move(dir);
if (ch.IsAffected(Affect.AFFECT_TRACK))
SocketConnection.Act("$n&n peers around looking for tracks.", ch, null, null, SocketConnection.MessageTarget.room);
if (!ch.Hunting)
{
if (!ch.InRoom)
{
string text = String.Empty;
text = String.Format("Hunt_victim: no ch.in_room! Mob #{0}, _name: {1}. Placing mob in limbo (ch.AddToRoom()).",
ch.MobileTemplate.IndexNumber, ch.Name);
Log.Error(text, 0);
ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_LIMBO")));
text = String.Format("{0}&n has gone to limbo while hunting {1}.", ch.ShortDescription, ch.Hunting.Name);
ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, text);
return;
}
CommandType.Interpret(ch, "say Damn! Lost my prey!");
return;
}
if (ch.InRoom == ch.Hunting.Who.InRoom)
{
FoundPrey(ch, ch.Hunting.Who);
}
return;
}
catch (Exception ex)
{
Log.Error("Exception in HuntVictim: " + ex.ToString());
}
}
示例15: Disembark
/// <summary>
/// Disembark (exit) from a ship or vehicle.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Disembark(CharData ch, string[] str)
{
if (ch == null || !ch.InRoom)
{
return;
}
foreach (Vehicle vehicle in Database.VehicleList)
{
if (!vehicle.ParentObject)
continue;
if (ch.InRoom.IndexNumber == vehicle.EntryRoomTemplateNumber)
{
if (vehicle.ParentObject.InRoom)
{
ch.RemoveFromRoom();
ch.AddToRoom(vehicle.ParentObject.InRoom);
SocketConnection.Act("$n&n disembarks from $p&n.", ch, vehicle.ParentObject, null, SocketConnection.MessageTarget.room);
SocketConnection.Act("You disembark from $p&n.", ch, vehicle.ParentObject, null, SocketConnection.MessageTarget.character);
return;
}
}
}
ch.SendText("You don't realize you're not on a boat right now?\r\n");
}