public SpNpcStatus(Npc npc, int unk1, int unk2, Creature target = null) { Npc = npc; Unk1 = unk1; Unk2 = unk2; Target = target; }
public static Npc CreateNpc(SpawnTemplate spawnTemplate) { NpcTemplate npcTemplate = (Data.Data.NpcTemplates.ContainsKey(spawnTemplate.NpcId)) ? Data.Data.NpcTemplates[spawnTemplate.NpcId] : new NpcTemplate(); var npc = new Npc { NpcId = spawnTemplate.NpcId, SpawnTemplate = spawnTemplate, NpcTemplate = npcTemplate, Position = new WorldPosition { MapId = spawnTemplate.MapId, X = spawnTemplate.X, Y = spawnTemplate.Y, Z = spawnTemplate.Z, }, }; npc.BindPoint = npc.Position.Clone(); npc.GameStats = CreatureLogic.InitGameStats(npc); CreatureLogic.UpdateCreatureStats(npc); AiLogic.InitAi(npc); return npc; }
public void Release() { Creature = null; Npc = null; Projectile = null; TargetPosition = null; }
public virtual void Release() { Creature = null; Npc = null; Player = null; Random = null; }
public NpcBattleController(Npc npc) { Npc = npc; if (!Data.Data.Skills.ContainsKey(npc.NpcTemplate.HuntingZoneId)) return; if (!Data.Data.Skills[npc.NpcTemplate.HuntingZoneId].ContainsKey(npc.NpcTemplate.Id)) return; var skills = Data.Data.Skills[npc.NpcTemplate.HuntingZoneId][npc.NpcTemplate.Id]; foreach (var skill in skills.Values) { if ((skill.Id / 100) % 10 == 1) { if (skill.TotalAtk > 0) AttackSkills.Add(skill); } else MoveSkills.Add(skill); } SkillsCount = AttackSkills.Count + MoveSkills.Count; }
public static Npc CreateNpc(SpawnTemplate spawnTemplate) { var npc = new Npc { NpcId = spawnTemplate.NpcId, SpawnTemplate = spawnTemplate, NpcTemplate = Data.Data.NpcTemplates[spawnTemplate.Type][spawnTemplate.NpcId], Position = new WorldPosition { MapId = spawnTemplate.MapId, X = spawnTemplate.X, Y = spawnTemplate.Y, Z = spawnTemplate.Z + ((spawnTemplate.FullId == 6301151 || spawnTemplate.FullId == 6301152 || spawnTemplate.FullId == 6301153) ? 0 : 25), Heading = spawnTemplate.Heading, } }; npc.BindPoint = npc.Position.Clone(); npc.GameStats = CreatureLogic.InitGameStats(npc); CreatureLogic.UpdateCreatureStats(npc); AiLogic.InitAi(npc); return npc; }
public virtual void Init(Creature creature) { Creature = creature; Npc = creature as Npc; Player = creature as Player; Random = new Random((int) (DateTime.Now.Ticks + Funcs.Random().Next(int.MinValue, (int) Math.Abs(creature.Position.X)))); }
public NpcMoveController(Creature creature) { Creature = creature; Npc = creature as Npc; TargetPosition = new Point3D(); MoveVector = new Point3D(); }
public override void OnKillNpc(Player player, Npc npc) { QuestData questData = player.Quests[Quest.QuestId]; if (questData.Counters[0] == Task.Count || !Task.DroppedFrom.Contains(npc.NpcTemplate.FullId)) return; questData.Counters[0]++; Processor.UpdateStepCounters(player); }
public override void OnNpcKill(Player player, Npc killed) { if (killed.NpcTemplate.Name == "Karascha") { Players.ForEach(pl => new SpQuestMovie(6).Send(pl)); foreach (Npc npc in Npcs) if (npc.NpcId == 1501 && npc.NpcTemplate.HuntingZoneId == 436)//exit teleport npc.LifeStats.Rebirth(); } }
public void UseSkill(Npc npc, Skill skill) { if (npc.Target == null) return; ProcessSkill(npc, new UseSkillArgs { IsTargetAttack = false, SkillId = (skill != null) ? skill.Id : 0, TargetPosition = npc.Target.Position.Clone(), }, skill); }
public void Release() { Npc = null; Damage.Clear(); Damage = null; Hate.Clear(); Hate = null; Lock = null; }
public void AddExp(Player player, long value, Npc npc = null) { value *= Config.GetServerRates(); //todo rate modifiers if (player.GetLevel() >= Config.GetLevelCap()) { new SpSystemNotice("Sorry, but now, level cap is " + Config.GetLevelCap()).Send(player); return; } SetExp(player, player.Exp + value, npc); }
public SpShowDialog(Npc npc, int stage, List<DialogButton> buttons, int dialogId, int special1, int special2, int page, int dialogUid, Quest quest = null, QuestReward reward = null) { Npc = npc; Stage = stage; Buttons = buttons; DialogUid = dialogUid; DialogId = dialogId; Special1 = special1; Special2 = special2; Page = page; Quest = quest; Reward = reward; }
public void AddExp(Player player, long value, Npc npc = null) { value *= GamePlay.Default.ServerRates; //todo rate modifiers if (player.GetLevel() >= GamePlay.Default.LevelCap) { new SpSystemNotice("Sorry, but now, level cap is " + GamePlay.Default.LevelCap).Send(player); return; } SetExp(player, player.Exp + value, npc); }
public Npc Clone() { Npc clone = new Npc { NpcId = NpcId, SpawnTemplate = SpawnTemplate, NpcTemplate = NpcTemplate, Position = Position.Clone(), BindPoint = BindPoint.Clone(), }; return clone; }
public void AddExp(Player player, long value, Npc npc = null) { value *= Rate.EXP; //todo rate modifiers if (player.GetLevel() >= Rate.LEVEL_CAP) { //new SpSystemNotice("Sorry, but now, level cap is " + GamePlay.Default.LevelCap).Send(player); return; } int val1 = npc.NpcTemplate.Exp * Rate.KI_EXP; int val2 = val1 / 3; int ki = Funcs.Random().Next(val1 - val2, val1 + val2); player.SkillPoint += ki; SetExp(player, player.Exp + value, npc); }
public override void OnKillNpc(Player player, Npc npc) { QuestData questData = player.Quests[Quest.QuestId]; for (int i = 0; i < Task.Targets.Count; i++) { if (Task.Targets[i].Key != npc.NpcTemplate.FullId) continue; if (questData.Counters[i] == Task.Targets[i].Value) return; questData.Counters[i]++; Processor.UpdateStepCounters(player); } if (IsCountersComplete(player)) Processor.FinishStep(player); else Processor.UpdateStepCounters(player); }
public static void NpcDied(Npc npc) { var player = npc.Ai.GetKiller() as Player; if (player != null) { if (player.Party != null) foreach (Player member in PartyService.GetOnlineMembers(player.Party)) QuestEngine.OnPlayerKillNpc(member, npc); else QuestEngine.OnPlayerKillNpc(player, npc); player.Instance.OnNpcKill(player, npc); } if (npc.NpcTemplate.Size != NpcSize.Small) npc.Ai.DealExp(); if (player != null) { MapService.CreateDrop(npc, player); } }
public SpUNK007B(Npc npc) { Npc = npc; }
public void SetExp(Player player, long add, Npc npc) { int maxLevel = Data.Data.PlayerExperience.Count - 1; long maxExp = Data.Data.PlayerExperience[maxLevel - 1]; int level = 1; if (add > maxExp) add = maxExp; while ((level + 1) != maxLevel && add >= Data.Data.PlayerExperience[level]) { level++; } long added = add - player.Exp; if (level != player.Level) { player.Level = level; player.Exp = add; player.AbilityPoint += 1; PlayerLogic.LevelUp(player); } else player.Exp = add; new SpPlayerExpAndPointUp(player, added, npc).Send(player.Connection); }
private void CheckNpc(Npc npc) { if (IsVisible(Player, npc)) { if (!Player.VisibleNpcs.Contains(npc)) { Player.VisibleNpcs.Add(npc); npc.VisiblePlayers.Add(Player); PlayerLogic.InTheVision(Player, npc); } } else { if (Player.VisibleNpcs.Contains(npc)) { Player.VisibleNpcs.Remove(npc); npc.VisiblePlayers.Remove(Player); PlayerLogic.OutOfVision(Player, npc); } } }
public SpNpcDespawn(Npc npc) { Npc = npc; }
public DialogController(Player player, Npc npc) { Npc = npc; Player = player; Special1 = npc.NpcTemplate.HuntingZoneId; DialogId = npc.NpcTemplate.Id; Buttons = new List<DialogButton>(); Global.QuestEngine.AddButtonsToDialog(player, npc, Buttons); if (Npc.SpawnTemplate.FullId == 6301151) { Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.ArmorsmithDesign)); Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.WeaponsmithMaterials)); } else if (Npc.SpawnTemplate.FullId == 6301152) { Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.TailoringDesign)); } else if (Npc.SpawnTemplate.FullId == 6301153) { Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.AlchemyMaterials)); } else if(Data.Data.StaticTeleports.ContainsKey(Npc.SpawnTemplate.FullId)) { Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.Teleport)); } else { switch (Npc.NpcTemplate.Title) { case NpcTitle.Guard: //case NpcTitle.Monster: break; /*case NpcTitle.Dummy: new SpShowDialog(Npc, Npc.NpcTemplate.Id, Npc.NpcTemplate.Type).Send(Player.Connection); return;*/ case NpcTitle.Merchant: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.Shop)); break; case NpcTitle.MagicInstructor: if (MagicClasses.Contains(Player.PlayerData.Class)) Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.LearnSkills)); break; case NpcTitle.TacticsInstructor: if (TacticClasses.Contains(Player.PlayerData.Class)) Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.LearnSkills)); break; /* case NpcTitle.ArmorMerchant: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.BuyArmor)); break; */ case NpcTitle.CrystalMerchant: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.BuyCrystals)); break; case NpcTitle.Banker: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.Bank)); break; case NpcTitle.WeaponMerchant: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.BuyWeapons)); break; case NpcTitle.FlightMaster: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.FlightPoints)); break; case NpcTitle.GuildManager: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.CreateGuild)); break; case NpcTitle.DyeMerchant: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.DyeShop)); break; case NpcTitle.PetMerchant: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.ShopForPets)); break; case NpcTitle.GuildEmblems: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.GuildEmblem)); break; case NpcTitle.BadgeMerchant: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.RedeemTrialBadges)); // Badges O_________o break; case NpcTitle.TradeBroker: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.ViewBrokerage)); break; case NpcTitle.WeaponsmithingMaterials: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.WeaponsmithMaterials)); break; case NpcTitle.ArmorsmithingMaterials: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.ArmorsmithMaterials)); break; case NpcTitle.LeatherworkingMaterials: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.LeatherworkMaterials)); break; case NpcTitle.TailoringMaterials: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.TailoringMaterials)); break; case NpcTitle.WeaponsmithingDesigns: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.WeaponsmithDesign)); break; case NpcTitle.ArmorsmithingDesigns: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.ArmorsmithDesign)); break; case NpcTitle.LeatherworkingPatterns: Buttons.Add(new DialogButton(DialogIcon.CenteredGray, DialogNpcString.LeatherworkPatterns)); break; } } SendDialog(); new SpNpcTalk(npc, "@npc:" + npc.NpcTemplate).Send(player.Connection);//safe? }
public void AddButtonsToDialog(Player player, Npc npc, List<DialogButton> buttons) { foreach (var data in player.Quests) { //Reward if (npc.NpcTemplate.FullId == Quests[data.Key].TryGetRewardNpc(player)) { DialogIcon icon = DialogIcon.CenteredGray; switch (Data.Data.Quests[data.Key].Type) { case QuestType.Mission: icon = DialogIcon.MissionQuestReward; break; case QuestType.Normal: icon = DialogIcon.NormalQuestReward; break; case QuestType.Guild: icon = DialogIcon.GuildQuestReward; break; } buttons.Add(new DialogButton(icon, Data.Data.Quests[data.Key].QuestTitle)); } else { //Talk QStepDefault step = Quests[data.Key].GetNowStep(player); if (step == null) continue; List<int> villagers = step.GetParticipantVillagers(player); if (villagers.Count > 0 && npc.NpcTemplate.FullId == villagers[0]) { DialogIcon icon = DialogIcon.CenteredGray; switch (Data.Data.Quests[data.Key].Type) { case QuestType.Mission: icon = DialogIcon.MissionQuestProgress; break; case QuestType.Normal: icon = DialogIcon.NormalQuestProgress; break; case QuestType.Guild: icon = DialogIcon.GuildQuestProgress; break; } buttons.Add(new DialogButton(icon, Data.Data.Quests[data.Key].QuestTitle)); } } } //Start if (NpcStartQuests.ContainsKey(npc.NpcTemplate.FullId)) { for (int i = 0; i < NpcStartQuests[npc.NpcTemplate.FullId].Count; i++) { Quest quest = NpcStartQuests[npc.NpcTemplate.FullId][i]; if (player.Quests.ContainsKey(quest.QuestId)) continue; if (!quest.NeedClasses.Contains(player.PlayerData.Class)) continue; if (quest.NeedLevel > player.Level) continue; DialogIcon icon = DialogIcon.CenteredGray; switch (quest.Type) { case QuestType.Mission: icon = DialogIcon.MissionQuestStart; break; case QuestType.Normal: icon = DialogIcon.NormalQuestStart; break; case QuestType.Guild: icon = DialogIcon.GuildQuestStart; break; } buttons.Add(new DialogButton(icon, quest.QuestTitle)); } } }
public void ShowIcon(Player player, Npc npc, bool force = false) { if (!npc.NpcTemplate.IsVillager) return; QuestType questType = QuestType.Guild; QuestStatusIcon icon = QuestStatusIcon.None; //Rewards { bool isReward = false; foreach (var data in player.Quests) { if (npc.NpcTemplate.FullId == Quests[data.Key].TryGetRewardNpc(player)) { if (Data.Data.Quests[data.Key].Type < questType) { questType = Data.Data.Quests[data.Key].Type; isReward = true; if (questType == 0) break; } } } if (isReward) { switch (questType) { case QuestType.Mission: icon = QuestStatusIcon.RewardMissionQuest; break; case QuestType.Normal: icon = QuestStatusIcon.RewardNormalQuest; break; case QuestType.Guild: icon = QuestStatusIcon.RewardGuildQuest; break; } new SpNpcIcon(npc, icon, 1).Send(player.Connection); return; } } //Talk { bool isTalk = false; foreach (var data in player.Quests) { QStepDefault step = Quests[data.Key].GetNowStep(player); if (step == null) continue; List<int> villagers = step.GetParticipantVillagers(player); if (villagers.Count > 0 && npc.NpcTemplate.FullId == villagers[0]) { if (Data.Data.Quests[data.Key].Type < questType) { questType = Data.Data.Quests[data.Key].Type; isTalk = true; if (questType == 0) break; } } } if (isTalk) { switch (questType) { case QuestType.Mission: icon = QuestStatusIcon.ProgressMissionQuest; break; case QuestType.Normal: icon = QuestStatusIcon.ProgressNormalQuest; break; case QuestType.Guild: icon = QuestStatusIcon.ProgressGuildQuest; break; } new SpNpcIcon(npc, icon, 1).Send(player.Connection); return; } } //Start if (NpcStartQuests.ContainsKey(npc.NpcTemplate.FullId)) { bool isStart = false; for (int i = 0; i < NpcStartQuests[npc.NpcTemplate.FullId].Count; i++) { Quest quest = NpcStartQuests[npc.NpcTemplate.FullId][i]; if (player.Quests.ContainsKey(quest.QuestId)) continue; if (!quest.NeedClasses.Contains(player.PlayerData.Class)) continue; if (quest.NeedLevel > player.Level) continue; isStart = true; if (quest.Type < questType) questType = quest.Type; if (questType == 0) break; } if (isStart) { switch (questType) { case QuestType.Mission: icon = QuestStatusIcon.MissionQuest; break; case QuestType.Normal: icon = QuestStatusIcon.NormalQuest; break; case QuestType.Guild: icon = QuestStatusIcon.GuildQuest; break; } } } if (icon != QuestStatusIcon.None) new SpNpcIcon(npc, icon, 1).Send(player.Connection); else if (force) new SpNpcIcon(npc, 0, 0).Send(player.Connection); }
public SpUpdateExp(Player player, long added, Npc npc = null) { Player = player; Added = added; Npc = npc; }
public void CreateDrop(Npc npc, Player player) { if (Funcs.IsLuck(75)) { var money = (int)(10 * Data.Data.NpcExperience[npc.GetLevel()] / Funcs.Random().Next(20, 60)); player.Instance.AddDrop( new Item { Owner = player, Npc = npc, ItemId = 20000000, Count = money, Position = Geom.RandomCirclePosition(npc.Position, Funcs.Random().Next(60, 100)), Instance = player.Instance, }); } if (!Data.Data.Drop.ContainsKey(npc.NpcTemplate.FullId)) return; List<int> items = Data.Data.Drop[npc.NpcTemplate.FullId]; if (items == null) return; int count = 0; int rate = Funcs.Random().Next(0, 2500); if (rate < 10) count = 6; else if (rate < 30) count = 5; else if (rate < 90) count = 4; else if (rate < 270) count = 3; else if (rate < 600) count = 2; else if (rate < 1800) count = 1; if (items.Count < count) count = items.Count; for (int i = 0; i < count; i++) { int itemId = items[Funcs.Random().Next(0, items.Count)]; if (!Data.Data.ItemTemplates.ContainsKey(itemId)) continue; player.Instance.AddDrop( new Item { Owner = player, Npc = npc, ItemId = itemId, Count = 1, Position = Geom.RandomCirclePosition(npc.Position, Funcs.Random().Next(60, 100)), Instance = player.Instance, }); } }
public void OnPlayerKillNpc(Player player, Npc npc) { foreach (var data in player.Quests) if (data.Value.Status == QuestStatus.Start) Quests[data.Key].GetNowStep(player).OnKillNpc(player, npc); }
public virtual void OnKillNpc(Player player, Npc npc) { }