public bool CanUseSkill(MobSkill toUse) { //if (toUse == null) //{ // return false; //} //if (!usedSkills.stream().noneMatch((skill)-> (skill.getLeft() == toUse.getSkillId() && skill.getRight() == toUse.getSkillLevel()))) //{ // return false; //} //if (toUse.limit > 0) //{ // if (this.skillsUsed.containsKey(new Pair<>(toUse.getSkillId(), toUse.getSkillLevel()))) // { // int times = this.skillsUsed.get(new Pair<>(toUse.getSkillId(), toUse.getSkillLevel())); // if (times >= toUse.getLimit()) // { // return false; // } // } //} //if (toUse.skillId == 200) //{ // List<IMapleMapObject> mmo = Map.Mapobjects; // int i = 0; // i = mmo.stream().filter((mo)-> (mo.getType() == MapleMapObjectType.MONSTER)).map((_item)-> 1).reduce(i, Integer::sum); // if (i > 100) // { // return false; // } //} //int percHpLeft = (Hp / maxhp) * 100; //return toUse.getHP() >= percHpLeft; return(false); }
public static MobSkill GetMobSkill(byte skillId, byte level) { MobSkill ret; if (MobSkills.TryGetValue(Tuple.Create(skillId, level), out ret)) { return(ret); } lock (MobSkills) { if (!MobSkills.TryGetValue(Tuple.Create(skillId, level), out ret)) { var skillData = SkillRoot.GetChildByPath(skillId + "/level/" + level); if (skillData != null) { var mpCon = MapleDataTool.GetInt(skillData.GetChildByPath("mpCon"), 0); var toSummon = new List <int>(); for (var i = 0; i > -1; i++) { if (skillData.GetChildByPath(i.ToString()) == null) { break; } toSummon.Add(MapleDataTool.GetInt(skillData.GetChildByPath(i.ToString()), 0)); } var effect = MapleDataTool.GetInt("summonEffect", skillData, 0); var hp = MapleDataTool.GetInt("hp", skillData, 100); var x = MapleDataTool.GetInt("x", skillData, 1); var y = MapleDataTool.GetInt("y", skillData, 1); var duration = MapleDataTool.GetInt("time", skillData, 0); var cooltime = MapleDataTool.GetInt("interval", skillData, 0); var iprop = MapleDataTool.GetInt("prop", skillData, 100); var prop = (float)iprop / 100; var limit = MapleDataTool.GetInt("limit", skillData, 0); var count = MapleDataTool.GetInt("count", skillData, 1); var ltd = skillData.GetChildByPath("lt"); var rtd = skillData.GetChildByPath("rb"); var lt = Point.Empty; var rb = Point.Empty; if (ltd != null && rtd != null) { lt = (Point)ltd.Data; rb = (Point)rtd.Data; } ret = new MobSkill(skillId, level); ret.ToSummon.AddRange(toSummon); ret.Cooltime = cooltime * 1000; ret.Duration = duration * 1000; ret.Hp = hp; ret.MpCon = mpCon; ret.SpawnEffect = effect; ret.X = x; ret.Y = y; ret.Prop = prop; ret.Limit = limit; ret.SetLtRb(lt, rb); ret.Count = count; } var key = Tuple.Create(skillId, level); if (MobSkills.ContainsKey(key)) { MobSkills[key] = ret; } else { MobSkills.Add(key, ret); } } return(ret); } }
public void ApplyMonsterBuff(MonsterStatus status, int x, int skillId, int duration, MobSkill skill) { var timerManager = TimerManager.Instance; var applyPacket = PacketCreator.ApplyMonsterStatus(ObjectId, new Dictionary <MonsterStatus, int> { { status, x } }, skillId, true, 0, skill); Map.BroadcastMessage(applyPacket, Position); if (GetController() != null && !GetController().VisibleMapObjects.Contains(this)) { GetController().Client.Send(applyPacket); } timerManager.RunOnceTask(() => { if (IsAlive) { var packet = PacketCreator.CancelMonsterStatus(ObjectId, new Dictionary <MonsterStatus, int> { { status, x } }); Map.BroadcastMessage(packet, Position); if (GetController() != null && !GetController().VisibleMapObjects.Contains(this)) { GetController().Client.Send(packet); } MonsterBuffs.Remove(status); } }, duration); MonsterBuffs.Add(status); }