Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
WiredEffect MoveFurniToUserBox Lag
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Hahn" data-source="post: 451914" data-attributes="member: 73428"><p>My code of MoveFurniToUser is:</p><p>[CODE=csharp]public Point GetChaseMovement(Item Item)</p><p> {</p><p> int Distance = 99;</p><p> Point Coord = new Point(0, 0);</p><p> int iX = Item.GetX;</p><p> int iY = Item.GetY;</p><p> bool X = false;</p><p></p><p> foreach (RoomUser User in _room.GetRoomUserManager().GetRoomUsers())</p><p> {</p><p> if (User.X == Item.GetX || Item.GetY == User.Y)</p><p> {</p><p> if (User.X == Item.GetX)</p><p> {</p><p> int Difference = Math.Abs(User.Y - Item.GetY);</p><p> if (Difference < Distance)</p><p> {</p><p> Distance = Difference;</p><p> Coord = User.Coordinate;</p><p> X = false;</p><p> }</p><p> else</p><p> continue;</p><p></p><p> }</p><p> else if (User.Y == Item.GetY)</p><p> {</p><p> int Difference = Math.Abs(User.X - Item.GetX);</p><p> if (Difference < Distance)</p><p> {</p><p> Distance = Difference;</p><p> Coord = User.Coordinate;</p><p> X = true;</p><p> }</p><p> else</p><p> continue;</p><p> }</p><p> else if (User.Y != Item.GetY)</p><p> {</p><p> int Difference = Math.Abs(User.X - Item.GetY);</p><p> if (Difference < Distance)</p><p> {</p><p> Distance = Difference;</p><p> Coord = User.Coordinate;</p><p> X = true;</p><p> }</p><p> else</p><p> continue;</p><p> }</p><p> else</p><p> continue;</p><p> }</p><p> }</p><p></p><p> if (Distance > 5)</p><p> return Item.GetSides().OrderBy(x => Guid.NewGuid()).FirstOrDefault();</p><p> if (X && Distance < 99)</p><p> {</p><p> if (iX > Coord.X)</p><p> {</p><p> iX--;</p><p> return new Point(iX, iY);</p><p> }</p><p> else</p><p> {</p><p> iX++;</p><p> return new Point(iX, iY);</p><p> }</p><p> }</p><p> else if (!X && Distance < 99)</p><p> {</p><p> if (iY > Coord.Y)</p><p> {</p><p> iY--;</p><p> return new Point(iX, iY);</p><p> }</p><p> else</p><p> {</p><p> iY++;</p><p> return new Point(iX, iY);</p><p> }</p><p> }</p><p> else</p><p> return Item.Coordinate;</p><p> }[/CODE]</p><p></p><p>My OnCycle:</p><p></p><p>[CODE=csharp]public bool OnCycle()</p><p> {</p><p> if (Instance == null || !Requested || _next < 1)</p><p> return false;</p><p> var time = OreoServer.GetUnixTimestamp(); </p><p> if (_next <= time)</p><p> {</p><p> foreach (</p><p> var Item in</p><p> SetItems.Values.ToList()</p><p> .Where(Item => Item != null)</p><p> .Where(Item => Instance.GetRoomItemHandler().GetFloor.Contains(Item)))</p><p> {</p><p> Item toRemove;</p><p></p><p> if (Instance.GetWired().OtherBoxHasItem(this, Item.Id))</p><p> SetItems.TryRemove(Item.Id, out toRemove);</p><p></p><p> var Point = Instance.GetGameMap().GetChaseMovement(Item);</p><p></p><p> Instance.GetWired().onUserFurniCollision(Instance, Item);</p><p></p><p> if (!Instance.GetGameMap().ItemCanMove(Item, Point))</p><p> continue;</p><p></p><p> if (Instance.GetGameMap().CanRollItemHere(Point.X, Point.Y) &&</p><p> !Instance.GetGameMap().SquareHasUsers(Point.X, Point.Y))</p><p> {</p><p> var NewZ = Item.GetZ;</p><p> var CanBePlaced = true;</p><p></p><p> var Items = Instance.GetGameMap().GetCoordinatedItems(Point);</p><p> foreach (var IItem in Items.ToList().Where(IItem => IItem != null && IItem.Id != Item.Id))</p><p> {</p><p> if (!IItem.GetBaseItem().Walkable)</p><p> {</p><p> _next = 0;</p><p> CanBePlaced = false;</p><p> break;</p><p> }</p><p></p><p> if (IItem.TotalHeight > NewZ)</p><p> NewZ = IItem.TotalHeight;</p><p></p><p> if (CanBePlaced && !IItem.GetBaseItem().Stackable)</p><p> CanBePlaced = false;</p><p> }</p><p></p><p> if (CanBePlaced && Point != Item.Coordinate)</p><p> {</p><p> Instance.SendMessage(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, Point.X,</p><p> Point.Y, NewZ, 0, 0, Item.Id));</p><p> Instance.GetRoomItemHandler().SetFloorItem(Item, Point.X, Point.Y, NewZ);</p><p> }</p><p> }</p><p> }</p><p></p><p> _next = 0;</p><p> return true;</p><p> }</p><p> return false;</p><p> }[/CODE]</p></blockquote><p></p>
[QUOTE="Hahn, post: 451914, member: 73428"] My code of MoveFurniToUser is: [CODE=csharp]public Point GetChaseMovement(Item Item) { int Distance = 99; Point Coord = new Point(0, 0); int iX = Item.GetX; int iY = Item.GetY; bool X = false; foreach (RoomUser User in _room.GetRoomUserManager().GetRoomUsers()) { if (User.X == Item.GetX || Item.GetY == User.Y) { if (User.X == Item.GetX) { int Difference = Math.Abs(User.Y - Item.GetY); if (Difference < Distance) { Distance = Difference; Coord = User.Coordinate; X = false; } else continue; } else if (User.Y == Item.GetY) { int Difference = Math.Abs(User.X - Item.GetX); if (Difference < Distance) { Distance = Difference; Coord = User.Coordinate; X = true; } else continue; } else if (User.Y != Item.GetY) { int Difference = Math.Abs(User.X - Item.GetY); if (Difference < Distance) { Distance = Difference; Coord = User.Coordinate; X = true; } else continue; } else continue; } } if (Distance > 5) return Item.GetSides().OrderBy(x => Guid.NewGuid()).FirstOrDefault(); if (X && Distance < 99) { if (iX > Coord.X) { iX--; return new Point(iX, iY); } else { iX++; return new Point(iX, iY); } } else if (!X && Distance < 99) { if (iY > Coord.Y) { iY--; return new Point(iX, iY); } else { iY++; return new Point(iX, iY); } } else return Item.Coordinate; }[/CODE] My OnCycle: [CODE=csharp]public bool OnCycle() { if (Instance == null || !Requested || _next < 1) return false; var time = OreoServer.GetUnixTimestamp(); if (_next <= time) { foreach ( var Item in SetItems.Values.ToList() .Where(Item => Item != null) .Where(Item => Instance.GetRoomItemHandler().GetFloor.Contains(Item))) { Item toRemove; if (Instance.GetWired().OtherBoxHasItem(this, Item.Id)) SetItems.TryRemove(Item.Id, out toRemove); var Point = Instance.GetGameMap().GetChaseMovement(Item); Instance.GetWired().onUserFurniCollision(Instance, Item); if (!Instance.GetGameMap().ItemCanMove(Item, Point)) continue; if (Instance.GetGameMap().CanRollItemHere(Point.X, Point.Y) && !Instance.GetGameMap().SquareHasUsers(Point.X, Point.Y)) { var NewZ = Item.GetZ; var CanBePlaced = true; var Items = Instance.GetGameMap().GetCoordinatedItems(Point); foreach (var IItem in Items.ToList().Where(IItem => IItem != null && IItem.Id != Item.Id)) { if (!IItem.GetBaseItem().Walkable) { _next = 0; CanBePlaced = false; break; } if (IItem.TotalHeight > NewZ) NewZ = IItem.TotalHeight; if (CanBePlaced && !IItem.GetBaseItem().Stackable) CanBePlaced = false; } if (CanBePlaced && Point != Item.Coordinate) { Instance.SendMessage(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, Point.X, Point.Y, NewZ, 0, 0, Item.Id)); Instance.GetRoomItemHandler().SetFloorItem(Item, Point.X, Point.Y, NewZ); } } } _next = 0; return true; } return false; }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
WiredEffect MoveFurniToUserBox Lag
Top