public static BountyInfo FromPackage(ZPackage pkg) { var result = new BountyInfo(); var version = pkg.ReadInt(); result.Interval = pkg.ReadInt(); result.PlayerID = pkg.ReadLong(); result.Biome = (Heightmap.Biome)pkg.ReadInt(); result.State = (BountyState)pkg.ReadInt(); result.Target = BountyTargetInfo.FromPackage(pkg); result.TargetName = pkg.ReadString(); result.RewardIron = pkg.ReadInt(); result.RewardGold = pkg.ReadInt(); result.Position = SerializableVector3.FromPackage(pkg); result.MinimapCircleOffset = SerializableVector3.FromPackage(pkg); var addsCount = pkg.ReadInt(); result.Adds = new List <BountyTargetInfo>(); for (var index = 0; index < addsCount; index++) { result.Adds.Add(BountyTargetInfo.FromPackage(pkg)); } result.Slain = pkg.ReadBool(); return(result); }
public void Reinitialize() { if (ZNet.instance.IsServer() || !ZNet.instance.IsServer() && !ZNet.instance.IsDedicated()) { var pkgString = _zdo.GetString(BountyDataKey); var pkg = new ZPackage(pkgString); try { _bountyInfo = BountyInfo.FromPackage(pkg); } catch (Exception) { Debug.LogError($"[EpicLoot] Error loading bounty info on creature ({name})! Possibly old or outdated bounty target, destroying creature.\nBountyData:\n{pkgString}"); _zdo.Set("BountyTarget", ""); _zdo.Set(BountyDataKey, ""); _character.m_nview.Destroy(); return; } } _monsterID = _zdo.GetString(MonsterIDKey); _isAdd = _zdo.GetBool(IsAddKey); _character.m_name = _zdo.GetString(BountyTargetNameKey); _character.m_boss = !_zdo.GetBool(IsAddKey); }
public void Show(BountyInfo bountyInfo) { gameObject.SetActive(true); _bountyInfo = bountyInfo; BountyDisplay.SetItem(_bountyInfo); }
public void Reinitialize() { var pkgString = _zdo.GetString(BountyDataKey); var pkg = new ZPackage(pkgString); _bountyInfo = BountyInfo.FromPackage(pkg); _monsterID = _zdo.GetString(MonsterIDKey); _isAdd = _zdo.GetBool(IsAddKey); _character.m_name = _zdo.GetString(BountyTargetNameKey); _character.m_boss = !_zdo.GetBool(IsAddKey); }
private static float GetModifiedMaxHealth(Character character, BountyInfo bounty, bool isAdd) { if (isAdd) { return(character.GetMaxHealth() * AdventureDataManager.Config.Bounties.AddsHealthMultiplier); } if (bounty.RewardGold > 0) { return(character.GetMaxHealth() * AdventureDataManager.Config.Bounties.GoldHealthMultiplier); } return(character.GetMaxHealth() * AdventureDataManager.Config.Bounties.IronHealthMultiplier); }
private static int GetTargetLevel(BountyInfo bounty, string monsterID, bool isAdd) { if (isAdd) { foreach (var targetInfo in bounty.Adds) { if (targetInfo.MonsterID == monsterID) { return(targetInfo.Level); } } return(1); } return(bounty.Target.Level); }
public void Initialize(BountyInfo bounty, string monsterID, bool isAdd) { _zdo.Set(BountyIDKey, bounty.ID); var pkg = new ZPackage(); bounty.ToPackage(pkg); pkg.SetPos(0); _zdo.Set(BountyDataKey, pkg.GetBase64()); _zdo.Set(MonsterIDKey, monsterID); _zdo.Set(IsAddKey, isAdd); _zdo.Set(BountyTargetNameKey, GetTargetName(_character.m_name, isAdd, bounty.TargetName)); _character.SetLevel(GetTargetLevel(bounty, monsterID, isAdd)); _character.SetMaxHealth(GetModifiedMaxHealth(_character, bounty, isAdd)); _character.m_baseAI.SetPatrolPoint(); Reinitialize(); }
public bool AcceptedBounty(BountyInfo bounty, Vector3 spawnPoint, Vector3 offset) { if (HasAcceptedBounty(bounty.Interval, bounty.ID)) { EpicLoot.LogError($"Player has already accepted bounty! (interval={bounty.Interval} bountyID={bounty.ID})"); return(false); } if (bounty.State != BountyState.Available) { EpicLoot.LogError($"Can only accept available bounties! (interval={bounty.Interval} bountyID={bounty.ID})"); return(false); } bounty.State = BountyState.InProgress; bounty.Position = spawnPoint; bounty.MinimapCircleOffset = offset; Bounties.Add(bounty); return(true); }
public static string GetBountyName(BountyInfo bountyInfo) { return(Localization.instance.Localize(string.IsNullOrEmpty(bountyInfo.TargetName) ? GetMonsterName(bountyInfo.Target.MonsterID) : bountyInfo.TargetName)); }