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; dbkeephp.X = client.Player.X - comp.X; dbkeephp.Y = client.Player.Y - comp.Y; dbkeephp.Z = client.Player.Z - comp.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)); } }
protected int Proceed(RegionTimer timer) { GamePlayer player = (GamePlayer)timer.Properties.getProperty <object>("repair_player", null); GameLiving obj = (GameLiving)timer.Properties.getProperty <object>("repair_target", null); if (player == null || obj == null) { if (log.IsWarnEnabled) { log.Warn("There was a problem getting back the target or player in door/component repair!"); } return(0); } player.CraftTimer.Stop(); player.Out.SendCloseTimerWindow(); if (!PreFireChecks(player, obj)) { return(0); } if (Util.ChanceDouble(CalculateRepairChance(player, obj))) { int start = obj.HealthPercent; if (obj is GameKeepDoor) { GameKeepDoor door = obj as GameKeepDoor; door.Repair((int)(door.MaxHealth * 0.15)); } if (obj is GameKeepComponent) { GameKeepComponent component = obj as GameKeepComponent; component.Repair((int)(component.MaxHealth * 0.15)); } if (obj is GameSiegeWeapon) { GameSiegeWeapon weapon = obj as GameSiegeWeapon; weapon.Repair(); } int finish = obj.HealthPercent; CalculatePlayersWood(player, (GetTotalWoodForLevel(obj.Level + 1))); DisplayMessage(player, "You successfully repair the component by 15%!"); /* * - Realm points will now be awarded for successfully repairing a door or outpost piece. * Players will receive approximately 10% of the amount repaired in realm points. * (Note that realm points for repairing a door or outpost piece will not work in the battlegrounds.) */ // tolakram - we have no idea how many hit points a live door has so this code is not accurate int amount = (finish - start) * obj.Level; // level of non claimed keep is 4 player.GainRealmPoints(Math.Min(150, amount)); } else { DisplayMessage(player, "You fail to repair the component!"); } return(0); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort keepId = packet.ReadShort(); ushort wallId = packet.ReadShort(); ushort responce = packet.ReadShort(); int HPindex = packet.ReadShort(); AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepId); if (keep == null || !(GameServer.ServerRules.IsSameRealm(client.Player, (GameKeepComponent)keep.KeepComponents[wallId], true) || client.Account.PrivLevel > 1)) { return; } if (responce == 0x00) //show info { client.Out.SendKeepComponentInteract(((GameKeepComponent)keep.KeepComponents[wallId])); } else if (responce == 0x01) // click on hookpoint button { client.Out.SendKeepComponentHookPoint(((GameKeepComponent)keep.KeepComponents[wallId]), HPindex); } else if (responce == 0x02) //select an hookpoint { if (client.Account.PrivLevel > 1) { client.Out.SendMessage("DEBUG : selected hookpoint id " + HPindex, eChatType.CT_Say, eChatLoc.CL_SystemWindow); } GameKeepComponent hp = keep.KeepComponents[wallId] as GameKeepComponent; client.Out.SendClearKeepComponentHookPoint(hp, HPindex); client.Out.SendHookPointStore(hp.KeepHookPoints[HPindex] as GameKeepHookPoint); } }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort keepId = packet.ReadShort(); ushort wallId = packet.ReadShort(); int hookpointID = packet.ReadShort(); ushort itemslot = packet.ReadShort(); int payType = packet.ReadByte(); //gold RP BP contrat??? int unk2 = packet.ReadByte(); int unk3 = packet.ReadByte(); int unk4 = packet.ReadByte(); // client.Player.Out.SendMessage("x="+unk2+"y="+unk3+"z="+unk4,eChatType.CT_Say,eChatLoc.CL_SystemWindow); AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepId); if (keep == null) { return; } GameKeepComponent component = keep.KeepComponents[wallId] as GameKeepComponent; if (component == null) { return; } /*GameKeepHookPoint hookpoint = component.HookPoints[hookpointID] as GameKeepHookPoint; * if (hookpoint == null) return 1; */ HookPointInventory inventory = null; if (hookpointID > 0x80) { inventory = HookPointInventory.YellowHPInventory; //oil } else if (hookpointID > 0x60) { inventory = HookPointInventory.GreenHPInventory; //big siege } else if (hookpointID > 0x40) { inventory = HookPointInventory.LightGreenHPInventory; //small siege } else if (hookpointID > 0x20) { inventory = HookPointInventory.BlueHPInventory; //npc } else { inventory = HookPointInventory.RedHPInventory; //guard } if (inventory != null) { HookPointItem item = inventory.GetItem(itemslot); if (item != null) { item.Invoke(client.Player, payType, component.KeepHookPoints[hookpointID] as GameKeepHookPoint, component); } } }
private GameKeepComponent CreateKeepWall() { var dbKeep = new DBKeep(); var keep = new GameKeep(); keep.DBKeep = dbKeep; var keepComponent = new GameKeepComponent(); keepComponent.Skin = GuardPositionAtKeepWallTemplate.ComponentSkin; keepComponent.ComponentHeading = GuardPositionAtKeepWallTemplate.ComponentRotation; return(keepComponent); }
public void HandlePacket(GameClient client, GSPacketIn packet) { ushort keepId = packet.ReadShort(); ushort wallId = packet.ReadShort(); int hookpointID = packet.ReadShort(); ushort itemslot = packet.ReadShort(); int payType = packet.ReadByte(); //gold RP BP contrat??? packet.ReadByte(); packet.ReadByte(); packet.ReadByte(); AbstractGameKeep keep = GameServer.KeepManager.GetKeepByID(keepId); if (keep == null) { return; } GameKeepComponent component = keep.KeepComponents[wallId] as GameKeepComponent; if (component == null) { return; } HookPointInventory inventory = null; if (hookpointID > 0x80) { inventory = HookPointInventory.YellowHPInventory; // oil } else if (hookpointID > 0x60) { inventory = HookPointInventory.GreenHPInventory; // big siege } else if (hookpointID > 0x40) { inventory = HookPointInventory.LightGreenHPInventory; // small siege } else if (hookpointID > 0x20) { inventory = HookPointInventory.BlueHPInventory; // npc } else { inventory = HookPointInventory.RedHPInventory; // guard } HookPointItem item = inventory?.GetItem(itemslot); item?.Invoke(client.Player, payType, component.HookPoints[hookpointID], component); }
public void OnCommand(GameClient client, string[] args) { if (IsSpammingCommand(client.Player, "repair")) { return; } WorldInventoryItem item = client.Player.TargetObject as WorldInventoryItem; if (item != null) { client.Player.RepairItem(item.Item); return; } GameKeepDoor door = client.Player.TargetObject as GameKeepDoor; if (door != null) { if (!PreFireChecks(client.Player, door)) { return; } StartRepair(client.Player, door); } GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; if (component != null) { if (!PreFireChecks(client.Player, component)) { return; } StartRepair(client.Player, component); } GameSiegeWeapon weapon = client.Player.TargetObject as GameSiegeWeapon; if (weapon != null) { if (!PreFireChecks(client.Player, weapon)) { return; } StartRepair(client.Player, weapon); } }
public override int CalcValue(GameLiving living, eProperty property) { if (living is GamePlayer) { int af; // 1.5*1.25 spec line buff cap af = Math.Min((int)(living.Level * 1.875), living.SpecBuffBonusCategory[(int)property]); // debuff af -= living.DebuffCategory[(int)property]; // TrialsOfAtlantis af bonus af += Math.Min(living.Level, living.ItemBonus[(int)property]); // uncapped category af += living.BuffBonusCategory4[(int)property]; return(af); } else if (living is GameKeepDoor || living is GameKeepComponent) { GameKeepComponent component = null; if (living is GameKeepDoor) { component = (living as GameKeepDoor).Component; } if (living is GameKeepComponent) { component = living as GameKeepComponent; } int amount = component.AbstractKeep.BaseLevel; if (component.Keep is GameKeep) { return(amount); } else { return(amount / 2); } } else { return((int)((1 + (living.Level / 170.0)) * (living.Level << 1) * 4.67) + living.SpecBuffBonusCategory[(int)property] - living.DebuffCategory[(int)property] + living.BuffBonusCategory4[(int)property]); } }
public void OnCommand(GameClient client, string[] args) { if (args.Length == 1) { DisplaySyntax(client); return; } AbstractGameKeep myKeep = GameServer.KeepManager.GetKeepCloseToSpot(client.Player.CurrentRegionID, client.Player, WorldMgr.OBJ_UPDATE_DISTANCE); if (myKeep == null) { DisplayMessage(client, "You are not near a keep."); } switch (args[1]) { #region Create case "create": { if (args.Length < 3) { int i = 0; foreach (string str in Enum.GetNames(typeof(GameKeepComponent.eComponentSkin))) { client.Out.SendMessage("#" + i + ": " + str, eChatType.CT_System, eChatLoc.CL_SystemWindow); i++; } DisplaySyntax(client); return; } if (myKeep == null) { DisplaySyntax(client); return; } int skin = 0; try { skin = Convert.ToInt32(args[2]); } catch { int i = 0; foreach (string str in Enum.GetNames(typeof(GameKeepComponent.eComponentSkin))) { client.Out.SendMessage("#" + i + ": " + str, eChatType.CT_System, eChatLoc.CL_SystemWindow); i++; } DisplaySyntax(client); return; } if (args.Length >= 4) { int keepid = 0; try { keepid = Convert.ToInt32(args[3]); myKeep = GameServer.KeepManager.GetKeepByID(keepid); } catch { DisplaySyntax(client); return; } } GameKeepComponent component = new GameKeepComponent(); component.X = client.Player.X; component.Y = client.Player.Y; component.Z = client.Player.Z; component.ComponentHeading = (client.Player.Heading - myKeep.Heading) / 1024; component.Heading = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading); component.Keep = myKeep; //todo good formula //component.ComponentX = (component.X - myKeep.X) / 148; //component.ComponentY = (component.Y - myKeep.Y) / 148; double angle = myKeep.Heading * ((Math.PI * 2) / 360); // angle*2pi/360; //component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y) // / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle))); //component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle))); component.ComponentX = CalcCX(client.Player, myKeep, angle); component.ComponentY = CalcCY(client.Player, myKeep, angle); /* * x = (component.X-myKeep.X)/148 = a*cos(t) - b*sin(t) * y = (component.Y-myKeep.Y)/148 = a*sin(t) + b*cos(t) * a = sqrt((x+b*sin(t))^2 + (y-b*cos(t))^2) * a = sqrt(x²+y²+b² +2*x*b*sin(t)-2*y*b*cos(t)) * b = sqrt((x-a*cos(t))^2 + (y-a*sin(t))^2) * b = sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t)) * 0 = 2x²+2y²-2*x*a*cos(t)-2*y*a*sin(t)+2*x*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*sin(t)-2*y*sqrt(x²+y²+a²-2*x*a*cos(t)-2*y*a*sin(t))*cos(t) * pfff * so must find an other way to find it.... */ component.Name = myKeep.Name; component.Model = INVISIBLE_MODEL; component.Skin = skin; component.Level = (byte)myKeep.Level; component.CurrentRegion = client.Player.CurrentRegion; component.Health = component.MaxHealth; component.ID = myKeep.KeepComponents.Count; component.Keep.KeepComponents.Add(component); component.SaveInDB = true; component.AddToWorld(); component.SaveIntoDatabase(); client.Out.SendKeepInfo(myKeep); client.Out.SendKeepComponentInfo(component); client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepComponents.Create.KCCreated"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; #endregion Create #region Move case "move": { GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; component.X = client.Player.X; component.Y = client.Player.Y; component.Z = client.Player.Z; component.ComponentHeading = (client.Player.Heading - myKeep.Heading) / 1024; component.Heading = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading); component.Keep = myKeep; //todo good formula //component.ComponentX = (component.X - myKeep.X) / 148; //component.ComponentY = (myKeep.Y - component.Y) / 148; double angle = myKeep.Heading * ((Math.PI * 2) / 360); // angle*2pi/360; //component.ComponentX = (int)((148 * Math.Sin(angle) * myKeep.X - 148 * Math.Sin(angle) * client.Player.X + client.Player.Y - myKeep.Y) // / (148 * Math.Sin(angle) - 148 * 148 * 2 * Math.Sin(angle) * Math.Cos(angle))); //component.ComponentY = (int)((myKeep.Y - client.Player.Y + 148 * Math.Sin(angle) * component.ComponentX) / (148 * Math.Cos(angle))); component.ComponentX = CalcCX(client.Player, myKeep, angle); component.ComponentY = CalcCY(client.Player, myKeep, angle); client.Out.SendKeepInfo(myKeep); client.Out.SendKeepComponentInfo(component); client.Out.SendKeepComponentDetailUpdate(component); client.Out.SendMessage("Component moved. Use /keepcomponent save to save, or reload to reload the original position.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; #endregion #region Rotate case "rotate": { try { ushort amount = Convert.ToUInt16(args[2]); if (amount > 3) { amount = 3; } GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; component.ComponentHeading = amount; component.Heading = (ushort)(component.ComponentHeading * 1024 + myKeep.Heading); client.Out.SendKeepInfo(myKeep); client.Out.SendKeepComponentInfo(component); client.Out.SendKeepComponentDetailUpdate(component); client.Out.SendMessage("Component rotated. Use /keepcomponent save to save, or reload to reload the original position.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } catch { DisplayMessage(client, "/keepcomponent rotate [0 - 3]"); } } break; #endregion #region Skin case "skin": { if (args.Length < 3) { int i = 0; foreach (string str in Enum.GetNames(typeof(GameKeepComponent.eComponentSkin))) { client.Out.SendMessage("#" + i + ": " + str, eChatType.CT_System, eChatLoc.CL_SystemWindow); i++; } DisplaySyntax(client); return; } int skin = 0; try { skin = Convert.ToInt32(args[2]); } catch { DisplaySyntax(client); return; } GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; if (component == null) { DisplaySyntax(client); return; } component.Skin = skin; foreach (GameClient cli in WorldMgr.GetClientsOfRegion(client.Player.CurrentRegionID)) { cli.Out.SendKeepComponentInfo(component); cli.Out.SendKeepComponentDetailUpdate(component); } //client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepComponents.Skin.YChangeSkin"), eChatType.CT_System, eChatLoc.CL_SystemWindow); client.Out.SendMessage("Component skin updated. Use /keepcomponent save to save, or reload to reload the original skin.", eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; #endregion Skin #region Delete case "delete": { GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; if (component == null) { DisplaySyntax(client); return; } component.RemoveFromWorld(); component.Delete(); component.DeleteFromDatabase(); client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepComponents.Delete.YDeleteKC"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; #endregion Delete #region Save case "save": { GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; if (component == null) { DisplaySyntax(client); return; } component.SaveIntoDatabase(); client.Out.SendMessage(string.Format("Saved ComponentID: {0}, KeepID: {1}, Skin: {2}, Health: {3}%", component.ID, (component.Keep == null ? "0" : component.Keep.KeepID.ToString()), component.Skin, component.HealthPercent), eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; #endregion Save #region Reload case "reload": { GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; if (component == null) { DisplaySyntax(client); return; } var dbcomponent = DOLDB <DBKeepComponent> .SelectObject(DB.Column(nameof(DBKeepComponent.KeepID)).IsEqualTo(component.Keep.KeepID).And(DB.Column(nameof(DBKeepComponent.ID)).IsEqualTo(component.ID))); component.ComponentX = dbcomponent.X; component.ComponentY = dbcomponent.Y; component.ComponentHeading = dbcomponent.Heading; component.Skin = dbcomponent.Skin; foreach (GameClient cli in WorldMgr.GetClientsOfRegion(client.Player.CurrentRegionID)) { cli.Out.SendKeepComponentInfo(component); cli.Out.SendKeepComponentDetailUpdate(component); } client.Out.SendMessage("Component Reloaded", eChatType.CT_System, eChatLoc.CL_SystemWindow); break; } #endregion Reload #region Default default: { DisplaySyntax(client); return; } #endregion Default } }
/// <summary> /// The command handler itself /// </summary> /// <param name="client">The client using the command</param> /// <param name="args">The command arguments</param> public void OnCommand(GameClient client, string[] args) { if (args.Length == 1) { DisplaySyntax(client); return; } switch (args[1].ToLower()) { #region Create case "create": { GameKeepGuard guard = null; if (args.Length < 3) { DisplaySyntax(client); return; } switch (args[2].ToLower()) { #region Lord case "lord": { guard = new GuardLord(); break; } #endregion Lord #region Fighter case "fighter": { guard = new GuardFighter(); break; } #endregion Fighter #region Archer case "archer": { if (args.Length > 3) { guard = new GuardStaticArcher(); } else { guard = new GuardArcher(); } break; } #endregion Archer #region Healer case "healer": { guard = new GuardHealer(); break; } #endregion Healer #region Stealther case "stealther": { guard = new GuardStealther(); break; } #endregion Stealther #region Caster case "caster": { if (args.Length > 3) { guard = new GuardStaticCaster(); } else { guard = new GuardCaster(); } break; } #endregion Caster #region Hastener case "hastener": { guard = new FrontierHastener(); break; } #endregion Hastener #region Mission case "mission": { guard = new MissionMaster(); break; } #endregion Mission #region Patrol case "patrol": { if (args.Length < 4) { DisplayMessage(client, "You need to provide a name for this patrol."); return; } AbstractGameKeep.eKeepType keepType = AbstractGameKeep.eKeepType.Any; if (args.Length < 5) { DisplayMessage(client, "You need to provide the type of keep this patrol works with."); int i = 0; foreach (string str in Enum.GetNames(typeof(Keeps.AbstractGameKeep.eKeepType))) { DisplayMessage(client, "#" + i + ": " + str); i++; } return; } try { keepType = (AbstractGameKeep.eKeepType)Convert.ToInt32(args[4]); } catch { DisplayMessage(client, "Type of keep specified was not valid."); return; } if (client.Player.TargetObject is GameKeepComponent == false) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Create.NoKCompTarget")); return; } GameKeepComponent c = client.Player.TargetObject as GameKeepComponent;; Patrol p = new Patrol(c); p.PatrolID = args[3]; p.KeepType = keepType; p.SpawnPosition = PositionMgr.CreatePatrolPosition(p.PatrolID, c, client.Player, keepType); p.PatrolID = p.SpawnPosition.TemplateID; p.InitialiseGuards(); DisplayMessage(client, "Patrol created for Keep Type " + Enum.GetName(typeof(AbstractGameKeep.eKeepType), keepType)); return; } #endregion Patrol } if (guard == null) { DisplaySyntax(client); return; } GameKeepComponent component = client.Player.TargetObject as GameKeepComponent; if (component != null) { int height = component.Height; if (args.Length > 4) { int.TryParse(args[4], out height); } DBKeepPosition pos = PositionMgr.CreatePosition(guard.GetType(), height, client.Player, Guid.NewGuid().ToString(), component); //PositionMgr.AddPosition(pos); //PositionMgr.FillPositions(); DBKeepPosition[] list = component.Positions[pos.TemplateID] as DBKeepPosition[]; if (list == null) { list = new DBKeepPosition[4]; component.Positions[pos.TemplateID] = list; } list[pos.Height] = pos; component.LoadPositions(); component.FillPositions(); } else { guard.CurrentRegion = client.Player.CurrentRegion; guard.X = client.Player.X; guard.Y = client.Player.Y; guard.Z = client.Player.Z; guard.Heading = client.Player.Heading; guard.Realm = guard.CurrentZone.Realm; guard.LoadedFromScript = false; guard.SaveIntoDatabase(); foreach (AbstractArea area in guard.CurrentAreas) { if (area is KeepArea) { AbstractGameKeep keep = (area as KeepArea).Keep; guard.Component = new GameKeepComponent(); guard.Component.Keep = keep; break; } } TemplateMgr.RefreshTemplate(guard); guard.AddToWorld(); if (guard.Component != null && guard.Component.Keep != null) { guard.Component.Keep.Guards.Add(DOL.Database.UniqueID.IDGenerator.GenerateID(), guard); } } PositionMgr.FillPositions(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Create.GuardAdded")); break; } #endregion Create #region Position case "position": { switch (args[2].ToLower()) { #region Add case "add": { if (!(client.Player.TargetObject is GameKeepGuard)) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.TargetGuard")); return; } if (args.Length != 4) { DisplaySyntax(client); return; } byte height = byte.Parse(args[3]); //height = KeepMgr.GetHeightFromLevel(height); GameKeepGuard guard = client.Player.TargetObject as GameKeepGuard; if (PositionMgr.GetPosition(guard) != null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.PAlreadyAss", height)); return; } DBKeepPosition pos = PositionMgr.CreatePosition(guard.GetType(), height, client.Player, guard.TemplateID, guard.Component); PositionMgr.AddPosition(pos); PositionMgr.FillPositions(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.GuardPAdded")); break; } #endregion Add #region Remove case "remove": { if (!(client.Player.TargetObject is GameKeepGuard)) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.TargetGuard")); return; } GameKeepGuard guard = client.Player.TargetObject as GameKeepGuard; DBKeepPosition pos = guard.Position; if (pos != null) { PositionMgr.RemovePosition(pos); if (guard.LoadedFromScript) { if (guard.PatrolGroup != null) { foreach (GameKeepGuard g in guard.PatrolGroup.PatrolGuards) { g.Delete(); } } else { guard.Delete(); } } } PositionMgr.FillPositions(); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Position.GuardRemoved")); break; } #endregion Remove #region Default default: { DisplaySyntax(client); return; } #endregion Default } break; } #endregion Position #region Path case "path": { switch (args[2].ToLower()) { #region Create case "create": { RemoveAllTempPathObjects(client); PathPoint startpoint = new PathPoint(client.Player.X, client.Player.Y, client.Player.Z, 100000, ePathType.Once); client.Player.TempProperties.setProperty(TEMP_PATH_FIRST, startpoint); client.Player.TempProperties.setProperty(TEMP_PATH_LAST, startpoint); client.Player.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.CreationStarted"), eChatType.CT_System, eChatLoc.CL_SystemWindow); CreateTempPathObject(client, startpoint, "TMP PP 1"); break; } #endregion Create #region Add case "add": { PathPoint path = (PathPoint)client.Player.TempProperties.getProperty <object>(TEMP_PATH_LAST, null); if (path == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.NoPathCreatedYet")); return; } int speedlimit = 1000; if (args.Length == 4) { try { speedlimit = int.Parse(args[3]); } catch { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.NoValidSpLimit", args[2])); return; } } PathPoint newpp = new PathPoint(client.Player.X, client.Player.Y, client.Player.Z, speedlimit, path.Type); path.Next = newpp; newpp.Prev = path; client.Player.TempProperties.setProperty(TEMP_PATH_LAST, newpp); int len = 0; while (path.Prev != null) { len++; path = path.Prev; } len += 2; CreateTempPathObject(client, newpp, "TMP PP " + len); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.PPAdded", len)); break; } #endregion Add #region Save case "save": { PathPoint path = (PathPoint)client.Player.TempProperties.getProperty <object>(TEMP_PATH_LAST, null); if (path == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.NoPathCreatedYet")); return; } GameKeepGuard guard = client.Player.TargetObject as GameKeepGuard; if (guard == null || guard.PatrolGroup == null) { DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.TargPatrolGuard")); return; } path.Type = ePathType.Loop; PositionMgr.SavePatrolPath(guard.TemplateID, path, guard.Component); DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.KeepGuard.Path.Saved")); RemoveAllTempPathObjects(client); guard.PatrolGroup.InitialiseGuards(); PositionMgr.FillPositions(); DisplayMessage(client, "Patrol groups initialized!"); break; } #endregion Save #region Default default: { DisplaySyntax(client); return; } #endregion Default } break; } #endregion Path #region Default default: { DisplaySyntax(client); return; } #endregion Default } }
public override int CalcValue(GameLiving living, eProperty property) { if (living is GamePlayer) { GamePlayer player = living as GamePlayer; int hpBase = player.CalculateMaxHealth(player.Level, player.GetModified(eProperty.Constitution)); int buffBonus = living.BaseBuffBonusCategory[(int)property]; if (buffBonus < 0) { buffBonus = (int)((1 + (buffBonus / -100.0)) * hpBase) - hpBase; } int itemBonus = living.ItemBonus[(int)property]; int cap = Math.Max(player.Level * 4, 20) + // at least 20 Math.Min(living.ItemBonus[(int)eProperty.MaxHealthCapBonus], player.Level * 4); itemBonus = Math.Min(itemBonus, cap); if (player.HasAbility(Abilities.ScarsOfBattle) && player.Level >= 40) { int levelbonus = Math.Min(player.Level - 40, 10); hpBase = (int)(hpBase * (100 + levelbonus) * 0.01); } int abilityBonus = living.AbilityBonus[(int)property]; return(Math.Max(hpBase + itemBonus + buffBonus + abilityBonus, 1)); // at least 1 } else if (living is GameKeepComponent) { GameKeepComponent keepComp = living as GameKeepComponent; if (keepComp.Keep != null) { return((keepComp.Keep.EffectiveLevel(keepComp.Keep.Level) + 1) * keepComp.AbstractKeep.BaseLevel * 200); } return(0); } else if (living is GameKeepDoor) { GameKeepDoor keepdoor = living as GameKeepDoor; if (keepdoor.Component != null && keepdoor.Component.Keep != null) { return((keepdoor.Component.Keep.EffectiveLevel(keepdoor.Component.Keep.Level) + 1) * keepdoor.Component.AbstractKeep.BaseLevel * 200); } return(0); //todo : use material too to calculate maxhealth } else if (living is GameNPC) { int hp = 0; if (living.Level < 10) { hp = living.Level * 20 + 20 + living.BaseBuffBonusCategory[(int)property]; // default } else { // approx to original formula, thx to mathematica :) hp = (int)(50 + 11 * living.Level + 0.548331 * living.Level * living.Level) + living.BaseBuffBonusCategory[(int)property]; if (living.Level < 25) { hp += 20; } } int basecon = (living as GameNPC).Constitution; int conmod = 20; // at level 50 +75 con ~= +300 hit points // first adjust hitpoints based on base CON if (basecon != ServerProperties.Properties.GAMENPC_BASE_CON) { hp = Math.Max(1, hp + ((basecon - ServerProperties.Properties.GAMENPC_BASE_CON) * ServerProperties.Properties.GAMENPC_HP_GAIN_PER_CON)); } // Now adjust for buffs // adjust hit points based on constitution difference from base con // modified from http://www.btinternet.com/~challand/hp_calculator.htm int conhp = hp + (conmod * living.Level * (living.GetModified(eProperty.Constitution) - basecon) / 250); // 50% buff / debuff cap if (conhp > hp * 1.5) { conhp = (int)(hp * 1.5); } else if (conhp < hp / 2) { conhp = hp / 2; } return(conhp); } else { if (living.Level < 10) { return(living.Level * 20 + 20 + living.BaseBuffBonusCategory[(int)property]); // default } else { // approx to original formula, thx to mathematica :) int hp = (int)(50 + 11 * living.Level + 0.548331 * living.Level * living.Level) + living.BaseBuffBonusCategory[(int)property]; if (living.Level < 25) { hp += 20; } return(hp); } } }
public bool PreFireChecks(GamePlayer player, GameLiving obj) { if (obj == null) { return(false); } if (player.Realm != obj.Realm) { return(false); } if (player.Client.Account.PrivLevel > (int)ePrivLevel.Player) { return(true); } if ((obj as GameLiving).InCombat) { DisplayMessage(player, "You can't repair object while it is under attack!"); return(false); } if (obj is GameKeepDoor) { GameKeepDoor doorcomponent = obj as GameKeepDoor; if (doorcomponent.Component.AbstractKeep.InCombat) { DisplayMessage(player, "You can't repair the keep door while keep is under attack!"); return(false); } } if (obj is IKeepItem) { if (obj.CurrentRegion.Time - obj.LastAttackedByEnemyTick <= 60 * 1000) { DisplayMessage(player, "You can't repair the keep component while it is under attack!"); return(false); } } if ((obj as GameLiving).HealthPercent == 100) { DisplayMessage(player, "The component is already at full health!"); return(false); } if (obj is GameKeepComponent) { GameKeepComponent component = obj as GameKeepComponent; if (component.IsRaized) { DisplayMessage(player, "You cannot repair a raized tower!"); return(false); } } if (player.IsCrafting) { DisplayMessage(player, "You must end your current action before you repair anything!"); return(false); } if (player.IsMoving) { DisplayMessage(player, "You can't repair while moving"); return(false); } if (!player.IsAlive) { DisplayMessage(player, "You can't repair while dead."); return(false); } if (player.IsSitting) { DisplayMessage(player, "You can't repair while sitting."); return(false); } if (player.InCombat) { DisplayMessage(player, "You can't repair while in combat."); return(false); } if (!player.IsWithinRadius(obj, WorldMgr.INTERACT_DISTANCE)) { DisplayMessage(player, "You are too far away to repair this component."); return(false); } int repairamount = (GetTotalWoodForLevel(obj.Level) / 100) * 15; int playerswood = CalculatePlayersWood(player, 0); if (playerswood < repairamount) { DisplayMessage(player, "You need another " + (repairamount - playerswood) + " units of wood!"); return(false); } if (player.GetCraftingSkillValue(eCraftingSkill.WoodWorking) < 1) { DisplayMessage(player, "You need woodworking skill to repair."); return(false); } player.Stealth(false); return(true); }