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 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 static bool LoadDoor(DBDoor door) { IDoor mydoor = null; ushort zone = (ushort)(door.InternalID / 1000000); Zone currentZone = WorldMgr.GetZone(zone); if (currentZone == null) { return(false); } //check if the door is a keep door foreach (AbstractArea area in currentZone.GetAreasOfSpot(door.X, door.Y, door.Z)) { if (area is KeepArea) { mydoor = new GameKeepDoor(); mydoor.LoadFromDatabase(door); break; } } //if the door is not a keep door, create a standard door if (mydoor == null) { mydoor = new GameDoor(); mydoor.LoadFromDatabase(door); } //add to the list of doors if (mydoor != null) { RegisterDoor(mydoor); } return(true); }
public void SendKeepDoorUpdate(GameKeepDoor door) { }
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); }