public GameKeepHookPoint(DBKeepHookPoint dbhookPoint, GameKeepComponent component) { double angle = component.Keep.Heading * ((Math.PI * 2) / 360); // angle*2pi/360; switch (component.ComponentHeading) { case 0: X = (int)(component.X + Math.Cos(angle) * dbhookPoint.X + Math.Sin(angle) * dbhookPoint.Y); Y = (int)(component.Y - Math.Cos(angle) * dbhookPoint.Y + Math.Sin(angle) * dbhookPoint.X); break; case 1: X = (int)(component.X + Math.Cos(angle) * dbhookPoint.Y - Math.Sin(angle) * dbhookPoint.X); Y = (int)(component.Y + Math.Cos(angle) * dbhookPoint.X + Math.Sin(angle) * dbhookPoint.Y); break; case 2: X = (int)(component.X - Math.Cos(angle) * dbhookPoint.X - Math.Sin(angle) * dbhookPoint.Y); Y = (int)(component.Y + Math.Cos(angle) * dbhookPoint.Y - Math.Sin(angle) * dbhookPoint.X); break; case 3: X = (int)(component.X - Math.Cos(angle) * dbhookPoint.Y + Math.Sin(angle) * dbhookPoint.X); Y = (int)(component.Y - Math.Cos(angle) * dbhookPoint.X - Math.Sin(angle) * dbhookPoint.Y); break; } this.Z = component.Z + dbhookPoint.Z; this.Heading = (ushort)(component.Heading + dbhookPoint.Heading); this.m_index = dbhookPoint.HookPointID; this.Component = component; m_hookpointTimer = new HookpointTimer(this, this.Component); }
/// <summary> /// This method is important, because players could fall through air /// if they are on the top of a keep when it is captured because /// the keep size will reset /// </summary> protected void ResetPlayersOfKeep() { ushort distance = 0; int id = 0; if (this is GameKeepTower) { distance = 750; id = 11; } else { distance = 1500; id = 10; } GameKeepComponent component = null; foreach (GameKeepComponent c in this.KeepComponents) { if (c.Skin == id) { component = c; break; } } if (component == null) { return; } if (!component.HookPoints.TryGetValue(97, out var hookpoint)) { return; } //predict Z DBKeepHookPoint hp = DOLDB <DBKeepHookPoint> .SelectObject(DB.Column(nameof(DBKeepHookPoint.HookPointID)).IsEqualTo(97).And(DB.Column(nameof(DBKeepHookPoint.Height)).IsEqualTo(Height))); if (hp == null) { return; } int z = component.Z + hp.Z; foreach (GamePlayer player in component.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { int d = hookpoint.GetDistance(player as IPoint2D); if (d > distance) { continue; } if (player.Z > z) { player.MoveTo(player.CurrentRegionID, player.X, player.Y, z, player.Heading); } } }
public void OnCommand(GameClient client, string[] args) { if (args.Length < 3) { DisplaySyntax(client); return; } int id = 0; int skin = 0; try { GameKeepComponent comp = client.Player.TargetObject as GameKeepComponent; if (comp == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.HookPoint.NoGKCTarget")); return; } skin = Convert.ToInt32(args[1]); id = Convert.ToInt32(args[2]); DBKeepHookPoint dbkeephp = new DBKeepHookPoint(); dbkeephp.HookPointID = id; dbkeephp.KeepComponentSkinID = skin; var diff = client.Player.Position - comp.Position; dbkeephp.X = (int)diff.X; dbkeephp.Y = (int)diff.Y; dbkeephp.Z = (int)diff.Z; dbkeephp.Heading = client.Player.Heading - comp.Heading; GameServer.Database.AddObject(dbkeephp); } catch (Exception e) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Error", e.Message)); } }
/// <summary> /// This method is important, because players could fall through air /// if they are on the top of a keep when it is captured because /// the keep size will reset /// </summary> protected void ResetPlayersOfKeep() { ushort distance = 0; int id = 0; if (this is GameKeepTower) { distance = 750; id = 11; } else { distance = 1500; id = 10; } GameKeepComponent component = null; foreach (GameKeepComponent c in this.KeepComponents) { if (c.Skin == id) { component = c; break; } } if (component == null) { return; } GameKeepHookPoint hookpoint = component.KeepHookPoints[97] as GameKeepHookPoint; if (hookpoint == null) { return; } //calculate target height int height = GameServer.KeepManager.GetHeightFromLevel(this.Level); //predict Z DBKeepHookPoint hp = GameServer.Database.SelectObjects <DBKeepHookPoint>("`HookPointID` = @HookPointID AND `Height` = @Height", new[] { new QueryParameter("@HookPointID", 97), new QueryParameter("@Height", height) }).FirstOrDefault(); if (hp == null) { return; } int z = component.Z + hp.Z; foreach (GamePlayer player in component.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { int d = hookpoint.GetDistance(player as IPoint2D); if (d > distance) { continue; } if (player.Z > z) { player.MoveTo(player.CurrentRegionID, player.X, player.Y, z, player.Heading); } } }