public static bool SetOutfitReplacement(SosigEnemyTemplate tem, PlayerSosigBody ___m_sosigPlayerBody) { if (___m_sosigPlayerBody == null) { return(false); } GM.Options.ControlOptions.MBClothing = tem.SosigEnemyID; if (tem.SosigEnemyID != SosigEnemyID.None) { if (tem.OutfitConfig.Count > 0 && LoadedTemplateManager.LoadedSosigsDict.ContainsKey(tem)) { OutfitConfig outfitConfig = LoadedTemplateManager.LoadedSosigsDict[tem].OutfitConfigs.GetRandom(); foreach (GameObject item in ___m_sosigPlayerBody.m_curClothes) { UnityEngine.Object.Destroy(item); } ___m_sosigPlayerBody.m_curClothes.Clear(); if (outfitConfig.Chance_Headwear >= UnityEngine.Random.value) { EquipSosigClothing(outfitConfig.Headwear, ___m_sosigPlayerBody.m_curClothes, ___m_sosigPlayerBody.Sosig_Head, outfitConfig.ForceWearAllHead); } if (outfitConfig.Chance_Facewear >= UnityEngine.Random.value) { EquipSosigClothing(outfitConfig.Facewear, ___m_sosigPlayerBody.m_curClothes, ___m_sosigPlayerBody.Sosig_Head, outfitConfig.ForceWearAllFace); } if (outfitConfig.Chance_Eyewear >= UnityEngine.Random.value) { EquipSosigClothing(outfitConfig.Eyewear, ___m_sosigPlayerBody.m_curClothes, ___m_sosigPlayerBody.Sosig_Head, outfitConfig.ForceWearAllEye); } if (outfitConfig.Chance_Torsowear >= UnityEngine.Random.value) { EquipSosigClothing(outfitConfig.Torsowear, ___m_sosigPlayerBody.m_curClothes, ___m_sosigPlayerBody.Sosig_Torso, outfitConfig.ForceWearAllTorso); } if (outfitConfig.Chance_Pantswear >= UnityEngine.Random.value) { EquipSosigClothing(outfitConfig.Pantswear, ___m_sosigPlayerBody.m_curClothes, ___m_sosigPlayerBody.Sosig_Abdomen, outfitConfig.ForceWearAllPants); } if (outfitConfig.Chance_Pantswear_Lower >= UnityEngine.Random.value) { EquipSosigClothing(outfitConfig.Pantswear_Lower, ___m_sosigPlayerBody.m_curClothes, ___m_sosigPlayerBody.Sosig_Legs, outfitConfig.ForceWearAllPantsLower); } if (outfitConfig.Chance_Backpacks >= UnityEngine.Random.value) { EquipSosigClothing(outfitConfig.Backpacks, ___m_sosigPlayerBody.m_curClothes, ___m_sosigPlayerBody.Sosig_Torso, outfitConfig.ForceWearAllBackpacks); } } } return(false); }
public SosigEnemyTemplate GetSosigEnemyTemplate() { if (template == null) { TNHTweakerLogger.Log("TNHTweaker -- Getting sosig template", TNHTweakerLogger.LogType.Character); template = (SosigEnemyTemplate)ScriptableObject.CreateInstance(typeof(SosigEnemyTemplate)); template.DisplayName = DisplayName; template.SosigEnemyCategory = SosigEnemyCategory; template.SecondaryChance = SecondaryChance; template.TertiaryChance = TertiaryChance; TNHTweakerLogger.Log("TNHTweaker -- Getting sosig config", TNHTweakerLogger.LogType.Character); template.ConfigTemplates = new List <SosigConfigTemplate>(); foreach (SosigConfig temp in Configs) { if (temp == null) { TNHTweakerLogger.LogError("One of the sosig configs is null!"); continue; } template.ConfigTemplates.Add(temp.GetConfigTemplate()); } template.ConfigTemplates_Easy = ConfigsEasy.Select(o => o.GetConfigTemplate()).ToList(); template.OutfitConfig = OutfitConfigs.Select(o => o.GetOutfitConfig()).ToList(); } return(template); }
/// <summary> /// Takes a custom SosigTemplate object, and adds it to the necessary dictionaries. This method assumes that you are sending a template for a custom sosig, and that it should be given a new the SosigEnemyID /// </summary> /// <param name="template">A template for a custom sosig (Loaded at runtime)</param> public static void AddSosigTemplate(SosigTemplate template) { SosigEnemyTemplate realTemplate = template.GetSosigEnemyTemplate(); //Since this template is for a custom sosig, we should give it a brand new SosigEnemyID if (!SosigIDDict.ContainsKey(template.SosigEnemyID)) { SosigIDDict.Add(template.SosigEnemyID, NewSosigID); NewSosigID += 1; } else { TNHTweakerLogger.LogError("TNHTweaker -- Loaded sosig had same SosigEnemyID as another sosig -- SosigEnemyID : " + template.SosigEnemyID); return; } //Now fill out the SosigEnemyIDs values for the real sosig template (These will effectively be ints, but this is ok since enums are just ints in disguise) realTemplate.SosigEnemyID = (SosigEnemyID)SosigIDDict[template.SosigEnemyID]; //Finally add the templates to our global dictionary CustomSosigs.Add(template); LoadedSosigsDict.Add(realTemplate, template); TNHTweakerLogger.Log("TNHTweaker -- Sosig added successfuly : " + template.DisplayName, TNHTweakerLogger.LogType.Character); }
public static void AddSosigTemplate(SosigEnemyTemplate realTemplate) { SosigTemplate template = new SosigTemplate(realTemplate); //This template is from a sogig that already has a valid SosigEnemyID, so we can just add that to the dictionary casted as an int if (!SosigIDDict.ContainsKey(template.SosigEnemyID)) { SosigIDDict.Add(template.SosigEnemyID, (int)realTemplate.SosigEnemyID); } else { TNHTweakerLogger.LogError("TNHTweaker -- Loaded sosig had same SosigEnemyID as another sosig -- SosigEnemyID : " + template.SosigEnemyID); return; } //Since the real template already had a valid SosigEnemyID, we can skip the part where we reassign them DefaultSosigs.Add(realTemplate); LoadedSosigsDict.Add(realTemplate, template); TNHTweakerLogger.Log("TNHTweaker -- Sosig added successfuly : " + template.DisplayName, TNHTweakerLogger.LogType.Character); }
public SosigTemplate(SosigEnemyTemplate template) { DisplayName = template.DisplayName; SosigEnemyCategory = template.SosigEnemyCategory; SosigEnemyID = template.SosigEnemyID.ToString(); SecondaryChance = template.SecondaryChance; TertiaryChance = template.TertiaryChance; SosigPrefabs = template.SosigPrefabs.Select(o => o.ItemID).ToList(); WeaponOptions = template.WeaponOptions.Select(o => o.ItemID).ToList(); WeaponOptionsSecondary = template.WeaponOptions_Secondary.Select(o => o.ItemID).ToList(); WeaponOptionsTertiary = template.WeaponOptions_Tertiary.Select(o => o.ItemID).ToList(); Configs = template.ConfigTemplates.Select(o => new SosigConfig(o)).ToList(); ConfigsEasy = template.ConfigTemplates_Easy.Select(o => new SosigConfig(o)).ToList(); OutfitConfigs = template.OutfitConfig.Select(o => new OutfitConfig(o)).ToList(); DroppedLootChance = 0; DroppedObjectPool = new EquipmentGroup(); this.template = template; }
public static void SpawnSosigWithTemplate(SosigEnemyTemplate template, SpawnOptions spawnOptions, Vector3 position, Vector3 forward) { var sosigPrefab = template.SosigPrefabs[Random.Range(0, template.SosigPrefabs.Count)]; var configTemplate = template.ConfigTemplates[Random.Range(0, template.ConfigTemplates.Count)]; var outfitConfig = template.OutfitConfig[Random.Range(0, template.OutfitConfig.Count)]; var sosig = SpawnSosigAndConfigureSosig(sosigPrefab.GetGameObject(), position, Quaternion.LookRotation(forward, Vector3.up), configTemplate, outfitConfig); sosig.InitHands(); sosig.Inventory.Init(); if (template.WeaponOptions.Count > 0) { var weapon = SpawnWeapon(template.WeaponOptions); weapon.SetAutoDestroy(true); sosig.ForceEquip(weapon); if (weapon.Type == SosigWeapon.SosigWeaponType.Gun && spawnOptions.SpawnWithFullAmmo) { sosig.Inventory.FillAmmoWithType(weapon.AmmoType); } } var spawnWithSecondaryWeapon = spawnOptions.EquipmentMode == 0 || spawnOptions.EquipmentMode == 2 || spawnOptions.EquipmentMode == 3 && Random.Range(0.0f, 1f) >= template.SecondaryChance; if (template.WeaponOptions_Secondary.Count > 0 && spawnWithSecondaryWeapon) { var weapon = SpawnWeapon(template.WeaponOptions_Secondary); weapon.SetAutoDestroy(true); sosig.ForceEquip(weapon); if (weapon.Type == SosigWeapon.SosigWeaponType.Gun && spawnOptions.SpawnWithFullAmmo) { sosig.Inventory.FillAmmoWithType(weapon.AmmoType); } } var spawnWithTertiaryWeapon = spawnOptions.EquipmentMode == 0 || spawnOptions.EquipmentMode == 3 && Random.Range(0.0f, 1f) >= template.TertiaryChance; if (template.WeaponOptions_Tertiary.Count > 0 && spawnWithTertiaryWeapon) { var w2 = SpawnWeapon(template.WeaponOptions_Tertiary); w2.SetAutoDestroy(true); sosig.ForceEquip(w2); if (w2.Type == SosigWeapon.SosigWeaponType.Gun && spawnOptions.SpawnWithFullAmmo) { sosig.Inventory.FillAmmoWithType(w2.AmmoType); } } var sosigIFF = spawnOptions.IFF; if (sosigIFF >= 5) { sosigIFF = Random.Range(6, 10000); } sosig.E.IFFCode = sosigIFF; sosig.CurrentOrder = Sosig.SosigOrder.Disabled; switch (spawnOptions.SpawnState) { case 0: sosig.FallbackOrder = Sosig.SosigOrder.Disabled; break; case 1: sosig.FallbackOrder = Sosig.SosigOrder.GuardPoint; break; case 2: sosig.FallbackOrder = Sosig.SosigOrder.Wander; break; case 3: sosig.FallbackOrder = Sosig.SosigOrder.Assault; break; } var targetPos = spawnOptions.SosigTargetPosition; var targetRot = spawnOptions.SosigTargetRotation; sosig.UpdateGuardPoint(targetPos); sosig.SetDominantGuardDirection(targetRot); sosig.UpdateAssaultPoint(targetPos); if (!spawnOptions.SpawnActivated) { return; } sosig.SetCurrentOrder(sosig.FallbackOrder); }