public static bool ItemExistsAtExactLocation(ItemAndLocation itemAndLocation) { Location loc = itemAndLocation.Location; int itemid = itemAndLocation.ItemID; return(Server.getFirstObjectOftype(loc, itemid) != 0); }
public static bool Test_getNextObjectOftype() { ItemAndLocation itemandlocation = GetRandomItemAndLocation(); StateBegin("getFirstObjectOftype"); int serial_1 = CreateTestItemThenFind(itemandlocation); int serial_2 = CreateTestItemThenFind(itemandlocation); Assert(serial_1 != serial_2, "Both created items have same serial."); int serial_found1 = Server.getFirstObjectOftype(itemandlocation.Location, itemandlocation.ItemID); int serial_found2 = Server.getNextObjectOfType(itemandlocation.Location, itemandlocation.ItemID, serial_found1); Assert(serial_found1 != serial_found2, "Both found items have same serial."); List <int> found = new List <int>(); found.Add(serial_found1); found.Add(serial_found2); Assert( found.Contains(serial_1) && found.Contains(serial_2), "Item And Location: {0} Both Items not found. expected:{1},{2} found:{3},{4}", itemandlocation, serial_1, serial_2, serial_found1, serial_found2); DeleteTestItems(serial_1, serial_2); return(StateResultFinal()); }
private ItemAndLocation[] GetItems() { ItemAndLocation[] toReturn = new ItemAndLocation[2]; switch (Type) { case AnkhType.NorthSouthBloody: toReturn[0].ItemID = 7773; toReturn[1].ItemID = 7772; toReturn[0].Location = toReturn[1].Location = LeftStartPoint; toReturn[1].Location.X++; //toReturn[1].location.Y++; break; case AnkhType.NorthSouth: toReturn[0].ItemID = 4; toReturn[1].ItemID = 5; toReturn[0].Location = toReturn[1].Location = LeftStartPoint; toReturn[1].Location.X++; //toReturn[1].location.Y++; break; default: toReturn[0].ItemID = 2; toReturn[1].ItemID = 3; toReturn[0].Location = toReturn[1].Location = LeftStartPoint; //toReturn[1].location.X++; toReturn[1].Location.Y--; break; } return(toReturn); }
protected static ItemAndLocation GetRandomItemAndLocation() { ItemAndLocation itemandlocation = new ItemAndLocation(); itemandlocation.ItemID = GetRandomTestItem(); itemandlocation.Location = GetRandomOceanTestLocation(); return(itemandlocation); }
protected static void AddTeleporterScript(ref ItemAndLocation ItemAndLocation, string script) { string result = Builder.AddScriptToFirstItemAtLocation(ItemAndLocation, script); if (result != null && !result.StartsWith("Script already attached")) { Console.WriteLine("Teleporters Error: Failed to attach script {0} to teleporter @ {1} {2} {3} Message: {4}", script, ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z, result); } }
public TeleporterGeneric(Location worldLocation, string script, Location destination, TeleporterGraphic graphic = TeleporterGraphic.NoDraw) { ItemAndLocation = new ItemAndLocation() { Location = worldLocation, ItemID = (ushort)graphic }; Script = script; Destination = destination; }
public void CreateAt(Location loc) { ItemAndLocation ItemAndLocation = new ItemAndLocation() { Location = loc, ItemID = (ushort)Graphic }; CreateTeleporterItem(ref ItemAndLocation); AddTeleporterScript(ref ItemAndLocation, Script); }
public static string AddScriptToFirstItemAtLocation(ItemAndLocation itemAndLocation, string script) { int serial = Server.getFirstObjectOftype(itemAndLocation.Location, itemAndLocation.ItemID); if (serial != 0) { return(Server.addScript(serial, script)); } else { return("Item Not Found."); } }
public uint CreateItem(ItemAndLocation itemandlocation) { Serial serial = nextSerial++; ItemObject item = new ItemObject(); item.ObjectType = itemandlocation.ItemID; item.Location = itemandlocation.Location; item.Serial = serial; WorldObjects.Add(serial, item); return(serial); }
public static bool Test_getFirstObjectOftype() { ItemAndLocation itemandlocation = GetRandomItemAndLocation(); StateBegin("getFirstObjectOftype"); int serial_expected = CreateTestItemThenFind(itemandlocation); int serial_found = Server.getFirstObjectOftype(itemandlocation.Location, itemandlocation.ItemID); Assert(serial_found == serial_expected, "Item And Location: {0} Serials don't match. found:{1}, expected:{2}", itemandlocation, serial_found, serial_expected); DeleteTestItem(serial_expected); return(StateResultFinal()); }
public static int FindItemWithinZRangeAboveOrBelow(ItemAndLocation itemAndLocation, byte Zrange) { int serial = 0; sbyte zStart = (sbyte)Math.Max(itemAndLocation.Location.Z - Zrange, sbyte.MinValue); sbyte zEnd = (sbyte)Math.Min(itemAndLocation.Location.Z + Zrange, sbyte.MaxValue); itemAndLocation.Location.Z = zStart; while (serial == 0 && itemAndLocation.Location.Z <= zEnd) { serial = SerialOfFirstExistingItemAtLocation(itemAndLocation); itemAndLocation.Location.Z += zRangeForItemLocationEqualityInCore; } return(serial); }
public static int SerialOfExistingItemAtLocation(ItemAndLocation itemAndLocation) { int serial = Server.getFirstObjectOftype(itemAndLocation.Location, itemAndLocation.ItemID); while (serial != 0) { Location locationOfFoundItem = Server.getLocation(serial); if (locationOfFoundItem == itemAndLocation.Location) { break; } else { serial = Server.getNextObjectOfType(itemAndLocation.Location, itemAndLocation.ItemID, serial); } } return(serial); }
private void RemoveInvalidAnhkObjectsAtLocation(ItemAndLocation ankhPiece) { Location location = ankhPiece.Location; int ProperAnhkItemID = ankhPiece.ItemID; foreach (int id in AllAnhkItemIDs) { if (id == ProperAnhkItemID) { continue; } int serial = Builder.SerialOfFirstExistingItemAtLocation(ankhPiece); if (serial > 0) { Builder.DeleteItem(serial); } } }
public static int FindExistingItemSerial(ItemAndLocation itemAndLocation) { int serial = 0; if (isPortcullis(itemAndLocation.ItemID)) { serial = FindItemWithinZRangeAboveOrBelow(itemAndLocation, 40); } else if (isDoor(itemAndLocation.ItemID)) { serial = FindAnyNearbyDoorWithExactHomeLocationOf(itemAndLocation.Location); } else { serial = SerialOfExistingItemAtLocation(itemAndLocation); } return(serial); }
protected static void SetTeleporterDest(ref ItemAndLocation ItemAndLocation, Location destination) { if (destination.Equals(Location.Zero)) { Console.WriteLine("Teleporters Error: Tried to set location on teleporter @ {0} {1} {2} to ZERO", ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z); return; } int serial = Builder.SerialOfFirstExistingItemAtLocation(ItemAndLocation); if (serial > 0) { Server.setObjVar(serial, "dest", destination); } else { Console.WriteLine("Teleporters Error: Failed to set location on teleporter @ {0} {1} {2}", ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z); } }
protected static void CreateTeleporterItem(ref ItemAndLocation ItemAndLocation) { if (!Builder.ItemExistsAtExactLocation(ItemAndLocation)) { if (Builder.TryCreateItem(ItemAndLocation)) { created++; } else { Console.WriteLine("Teleporters Error: Failed to create teleporter @ {0} {1} {2}", ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z); failed++; } } else { existed++; } }
public static bool Test_ObjProps_GetLocation() { int serial; StateBegin("Test_ObjProps_GetLocation"); ItemAndLocation itemandlocation = GetRandomItemAndLocation(); serial = CreateTestItemThenFind(itemandlocation); Item item; if (Assert(Server.TryFindObject(serial, out item), "Couldn't find item.")) { AssertSame(itemandlocation.Location, Server.getLocation(serial)); } DeleteTestItem(serial); return(StateResultFinal()); }
static bool TryParseItemAndLocation(string[] itemAndLocationArray, out ItemAndLocation itemAndLocation) { ushort id; Location loc; if (itemAndLocationArray.Length >= 4 && ushort.TryParse(itemAndLocationArray[0], out id) && short.TryParse(itemAndLocationArray[1], out loc.X) && short.TryParse(itemAndLocationArray[2], out loc.Y) && short.TryParse(itemAndLocationArray[3], out loc.Z)) { ItemAndLocation toReturn = new ItemAndLocation() { ItemID = id, Location = loc, }; itemAndLocation = toReturn; return(true); } itemAndLocation = new ItemAndLocation(); return(false); }
protected static int CreateTestItemThenFind(ItemAndLocation itemandlocation) { int ItemID = itemandlocation.ItemID; Location location = itemandlocation.Location; int serial = Server.createGlobalObjectAt(ItemID, location); if (Assert(serial > 0, "Failed to create Object. {0}", itemandlocation)) { Item item; if (Assert(Server.TryFindObject(serial, out item), "Created Item not found in world. serial:{0}", serial)) { Assert(item.ObjectType == ItemID, "Created Item not of correct ObjectType. expected:({0}) actual:({1})", ItemID, item.ObjectType); Assert(item.Location == location, "Created Item not in correct location. expected:({0}) actual:({1})", location, item.Location); } } StateAddObject(serial); return(serial); }
public static int SerialOfFirstExistingItemAtLocation(ItemAndLocation itemAndLocation) { return(Server.getFirstObjectOftype(itemAndLocation.Location, itemAndLocation.ItemID)); }
public static bool TryCreateItem(ItemAndLocation itemAndLocation) { int serial = TryCreateItemReturnSerial(itemAndLocation); return(serial != 0); }
public static int TryCreateItemReturnSerial(ItemAndLocation itemAndLocation) { return(Server.createGlobalObjectAt(itemAndLocation.ItemID, itemAndLocation.Location)); }