private static void HandleUpgradeBuff(GameSession session, PacketReader packet) { int buffId = packet.ReadInt(); Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildBuff buff = guild.Buffs.First(x => x.Id == buffId); // get next level's data GuildBuffLevel metadata = GuildBuffMetadataStorage.GetGuildBuffLevelData(buffId, buff.Level + 1); GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); if (guildProperty.Level < metadata.LevelRequirement) { return; } if (guild.Funds < metadata.UpgradeCost) { return; } guild.ModifyFunds(session, guildProperty, -metadata.UpgradeCost); buff.Level++; guild.BroadcastPacketGuild(GuildPacket.UpgradeBuff(buffId, buff.Level, session.Player.Name)); }
public void ActivateBuff(int Id) { GuildBuff Buff = GetBuff(Id); if (Buff == null) { return; } if (Buff.Active) { return; //no point activating buffs if they have no time limit anyway } if (Gold < Buff.Info.ActivationCost) { return; } Buff.Active = true; Buff.ActiveTimeRemaining = Buff.Info.TimeLimit; Gold -= (uint)Buff.Info.ActivationCost; List <GuildBuff> NewBuff = new List <GuildBuff>(); NewBuff.Add(Buff); SendServerPacket(new ServerPackets.GuildBuffList { ActiveBuffs = NewBuff }); SendServerPacket(new ServerPackets.GuildStorageGoldChange() { Type = 2, Name = "", Amount = (uint)Buff.Info.ActivationCost }); NeedSave = true; RefreshAllStats(); }
public void RefreshGuildBuffs() { if (User != this) { return; } if (GameScene.Scene.GuildDialog == null) { return; } for (int i = 0; i < GameScene.Scene.GuildDialog.EnabledBuffs.Count; i++) { GuildBuff buff = GameScene.Scene.GuildDialog.EnabledBuffs[i]; if (buff == null) { continue; } if (!buff.Active) { continue; } if (buff.Info == null) { buff.Info = GameScene.Scene.GuildDialog.FindGuildBuffInfo(buff.Id); } if (buff.Info == null) { continue; } Stats.Add(buff.Info.Stats); } }
private void ChargeForBuff(GuildBuff buff) { if (buff == null) { return; } SparePoints -= buff.Info.PointsRequirement; }
public void NewBuff(int Id, bool charge = true) { GuildBuffInfo info = Envir.FindGuildBuffInfo(Id); if (info == null) { return; } GuildBuff buff = new GuildBuff() { Id = Id, Info = info, Active = true, }; buff.ActiveTimeRemaining = buff.Info.TimeLimit; if (charge) { ChargeForBuff(buff); } BuffList.Add(buff); List <GuildBuff> NewBuff = new List <GuildBuff> { buff }; SendServerPacket(new ServerPackets.GuildBuffList { ActiveBuffs = NewBuff }); //now tell everyone our new sparepoints for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].Player != null) { SendGuildStatus((PlayerObject)Ranks[i].Members[j].Player); } } } NeedSave = true; RefreshAllStats(); }
public void RefreshGuildBuffs() { if (User != this) { return; } if (GameScene.Scene.GuildDialog == null) { return; } for (int i = 0; i < GameScene.Scene.GuildDialog.EnabledBuffs.Count; i++) { GuildBuff Buff = GameScene.Scene.GuildDialog.EnabledBuffs[i]; if (Buff == null) { continue; } if (!Buff.Active) { continue; } if (Buff.Info == null) { Buff.Info = GameScene.Scene.GuildDialog.FindGuildBuffInfo(Buff.Id); } if (Buff.Info == null) { continue; } MaxAC = (ushort)Math.Min(ushort.MaxValue, MaxAC + Buff.Info.BuffAc); MaxMAC = (ushort)Math.Min(ushort.MaxValue, MaxMAC + Buff.Info.BuffMac); MaxDC = (ushort)Math.Min(ushort.MaxValue, MaxDC + Buff.Info.BuffDc); MaxMC = (ushort)Math.Min(ushort.MaxValue, MaxMC + Buff.Info.BuffMc); MaxSC = (ushort)Math.Min(ushort.MaxValue, MaxSC + Buff.Info.BuffSc); MaxHP = (ushort)Math.Min(ushort.MaxValue, MaxHP + Buff.Info.BuffMaxHp); MaxMP = (ushort)Math.Min(ushort.MaxValue, MaxMP + Buff.Info.BuffMaxMp); HealthRecovery = (byte)Math.Min(byte.MaxValue, HealthRecovery + Buff.Info.BuffHpRegen); SpellRecovery = (byte)Math.Min(byte.MaxValue, SpellRecovery + Buff.Info.BuffMPRegen); } }
public void NewBuff(int Id) { GuildBuffInfo Info = Envir.FindGuildBuffInfo(Id); if (Info == null) { return; } GuildBuff Buff = new GuildBuff() { Id = Id, Info = Info, Active = true, }; Buff.ActiveTimeRemaining = Buff.Info.TimeLimit; SparePoints -= Buff.Info.PointsRequirement; BuffList.Add(Buff); List <GuildBuff> NewBuff = new List <GuildBuff>(); NewBuff.Add(Buff); SendServerPacket(new ServerPackets.GuildBuffList { ActiveBuffs = NewBuff }); //now tell everyone our new sparepoints for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].Player != null) { SendGuildStatus((PlayerObject)Ranks[i].Members[j].Player); } } } NeedSave = true; RefreshAllStats(); }
private bool UpdateGuildBuff(GuildBuff buff, bool Remove = false) { for (int i = 0; i < GuildBuffDialog.EnabledBuffs.Count; i++) { if (GuildBuffDialog.EnabledBuffs[i].Id == buff.Id) { if (Remove) { GuildBuffDialog.EnabledBuffs.RemoveAt(i); } else GuildBuffDialog.EnabledBuffs[i] = buff; return true; } } return false; }
public void NewBuff(int Id) { GuildBuffInfo Info = Envir.FindGuildBuffInfo(Id); if (Info == null) return; GuildBuff Buff = new GuildBuff() { Id = Id, Info = Info, Active = true, }; Buff.ActiveTimeRemaining = Buff.Info.TimeLimit; SparePoints -= Buff.Info.PointsRequirement; BuffList.Add(Buff); List<GuildBuff> NewBuff = new List<GuildBuff>(); NewBuff.Add(Buff); SendServerPacket(new ServerPackets.GuildBuffList { ActiveBuffs = NewBuff }); //now tell everyone our new sparepoints for (int i = 0; i < Ranks.Count; i++) for (int j = 0; j < Ranks[i].Members.Count; j++) if (Ranks[i].Members[j].Player != null) SendGuildStatus((PlayerObject)Ranks[i].Members[j].Player); NeedSave = true; RefreshAllStats(); }
private void ChargeForBuff(GuildBuff buff) { if (buff == null) return; SparePoints -= buff.Info.PointsRequirement; }
private void CreateGuildBuff(GuildBuff Buff) { int buffImage = BuffImage(BuffType.GuildBuff); MLibrary buffLibrary = Libraries.BuffIcon; if (buffImage >= 20000) { buffImage -= 20000; buffLibrary = Libraries.MagIcon; } if (buffImage >= 10000) { buffImage -= 10000; buffLibrary = Libraries.Prguse2; } MirImageControl image = new MirImageControl { Library = buffLibrary, Parent = this, Visible = true, Sort = false, Index = buffImage }; new MirLabel { DrawFormat = TextFormatFlags.Right, NotControl = true, ForeColour = Color.Yellow, Location = new Point(-7, 10), Size = new Size(30, 20), Parent = image }; GuildBuffImgList.Insert(0, image); }