public override void RestoreSaveData(object dataIn) { SaveData_v1 data = (SaveData_v1)dataIn; if (dataIn == null) { return; } FactionFile.FactionData dsfactionData; if (!GameManager.Instance.PlayerEntity.FactionData.GetFactionData(data.factionID, out dsfactionData)) { throw new Exception("Could not deserialize Person resource FactionID to FactionData"); } race = data.race; nameBank = data.nameBank; npcGender = data.npcGender; faceIndex = data.faceIndex; nameSeed = data.nameSeed; isQuestor = data.isQuestor; isIndividualNPC = data.isIndividualNPC; isIndividualAtHome = data.isIndividualAtHome; displayName = data.displayName; godName = data.godName; homeTownName = data.homeTownName; homeRegionName = data.homeRegionName; homeBuildingName = data.homeBuildingName; homePlaceSymbol = data.homePlaceSymbol; lastAssignedPlaceSymbol = data.lastAssignedPlaceSymbol; assignedToHome = data.assignedToHome; factionData = dsfactionData; questorData = data.questorData; }
void SetFoeName() { // Set type name with fallback MobileEnemy enemy; if (EnemyBasics.GetEnemy(foeType, out enemy)) { typeName = enemy.Name; } else { typeName = foeType.ToString(); } // Monster types get a random monster name // Always treating monsters as male for now as they don't have any gender in game files if ((int)foeType < 128) { DFRandom.srand(DateTime.Now.Millisecond); displayName = DaggerfallUnity.Instance.NameHelper.MonsterName(); return; } // Randomly assign a gender for humanoid foes humanoidGender = (UnityEngine.Random.Range(0.0f, 1.0f) < 0.5f) ? Genders.Male : Genders.Female; // Create a random display name for humanoid foes DFRandom.srand(DateTime.Now.Millisecond); NameHelper.BankTypes nameBank = GameManager.Instance.PlayerGPS.GetNameBankOfCurrentRegion(); displayName = DaggerfallUnity.Instance.NameHelper.FullName(nameBank, humanoidGender); }
public override void RestoreSaveData(object dataIn) { if (dataIn == null) { return; } SaveData_v1 data = (SaveData_v1)dataIn; FactionFile.FactionData dsfactionData; if (!GameManager.Instance.PlayerEntity.FactionData.GetFactionData(data.factionID, out dsfactionData) && data.factionID != 0) { throw new Exception("Could not deserialize Person resource FactionID to FactionData"); } race = data.race; nameBank = data.nameBank; npcGender = data.npcGender; faceIndex = data.faceIndex; nameSeed = data.nameSeed; isQuestor = data.isQuestor; isIndividualNPC = data.isIndividualNPC; isIndividualAtHome = data.isIndividualAtHome; displayName = data.displayName; homePlaceSymbol = data.homePlaceSymbol; lastAssignedPlaceSymbol = data.lastAssignedPlaceSymbol; assignedToHome = data.assignedToHome; factionData = dsfactionData; factionTableKey = data.factionTableKey; questorData = data.questorData; discoveredThroughTalkManager = data.discoveredThroughTalkManager; isMuted = data.isMuted; isDestroyed = data.isDestroyed; }
void OnGUI() { if (!IsReady()) { EditorGUILayout.HelpBox("DaggerfallUnity instance not ready. Have you set your Arena2 path?", MessageType.Info); return; } EditorGUILayout.Space(); bankType = (NameHelper.BankTypes)EditorGUILayout.EnumPopup(new GUIContent("Type"), bankType); gender = (Genders)EditorGUILayout.EnumPopup(new GUIContent("Gender"), gender); seed = EditorGUILayout.IntField(new GUIContent("Seed"), seed); count = EditorGUILayout.IntField(new GUIContent("Count"), count); if (GUILayout.Button("Generate Names")) { if (seed != -1) { DFRandom.srand(seed); } generatedNames.Clear(); for (int i = 0; i < count; i++) { generatedNames.Add(nameHelper.FullName(bankType, gender)); } } scrollPos = GUILayoutHelper.ScrollView(scrollPos, () => { for (int i = 0; i < generatedNames.Count; i++) { EditorGUILayout.SelectableLabel(generatedNames[i], EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); } }); }
// Sets gender and display name // Has some logic to handle individual faction objects and certain flat limitations void AssignDisplayName(string genderName) { // Set gender npcGender = GetGender(genderName); // Witches only have female flats if (factionData.type == (int)FactionFile.FactionTypes.WitchesCoven) { npcGender = Genders.Female; } // Get name bank NameHelper.BankTypes bankType = GameManager.Instance.PlayerGPS.GetNameBankOfCurrentRegion(); // Assign name - some types have their own individual name to use if (factionData.type == (int)FactionFile.FactionTypes.Individual || factionData.type == (int)FactionFile.FactionTypes.Daedra) { // Use individual name displayName = factionData.name; } else { // Set a name seed if not configured if (nameSeed == -1) { nameSeed = DateTime.Now.Millisecond; } // Generate a random name based on gender and race name bank DFRandom.srand(nameSeed); displayName = DaggerfallUnity.Instance.NameHelper.FullName(bankType, npcGender); } }
public override string Name() { // %bn System.Random random = new System.Random(); DFRandom.Seed = (uint)random.Next(); NameHelper.BankTypes race = MacroHelper.GetNameBank((Races)parent.characterDocument.raceTemplate.ID); return(DaggerfallUnity.Instance.NameHelper.FullName(race, Genders.Male)); }
public override string MaleName() { DFRandom.Seed += 3547; NameHelper.BankTypes nameBank = (NameHelper.BankTypes)MapsFile.RegionRaces[GameManager.Instance.PlayerGPS.CurrentRegionIndex]; string name = DaggerfallUnity.Instance.NameHelper.FullName(nameBank, Genders.Male); DFRandom.Seed -= 3547; return(name); }
public override string ArtistName() { // %an DFRandom.rand(); // Classic uses every other value. uint rand = DFRandom.rand() & 1; Genders gender = (Genders)rand; rand = DFRandom.rand(); NameHelper.BankTypes race = (NameHelper.BankTypes)(rand & 7); return(DaggerfallUnity.Instance.NameHelper.FullName(race, gender)); }
void AssignRace() { // Try to get the race from the current faction race = RaceTemplate.GetRaceFromFactionRace((FactionFile.FactionRaces)factionData.race); if (race == Races.None) { // Otherwise use race of current region race = GameManager.Instance.PlayerGPS.GetRaceOfCurrentRegion(); } nameBank = GameManager.Instance.PlayerGPS.GetNameBankOfCurrentRegion(); }
void AssignRace() { // Use faction race only for individuals if (isIndividualNPC) { race = RaceTemplate.GetRaceFromFactionRace((FactionFile.FactionRaces)factionData.race); if (race != Races.None) { return; } } // Otherwise use race of current region race = GameManager.Instance.PlayerGPS.GetRaceOfCurrentRegion(); nameBank = GameManager.Instance.PlayerGPS.GetNameBankOfCurrentRegion(); }
/// <summary> /// used to set remaining fields of person (with random values) and update billboards /// this function should be called after race, gender and personOutfitVariant has been set beforehand /// </summary> void SetPerson() { // get person's face texture record index for this race and gender and outfit variant int[] recordIndices = null; switch (race) { case Races.Redguard: recordIndices = (gender == Genders.Male) ? maleRedguardFaceRecordIndex : femaleRedguardFaceRecordIndex; break; case Races.Nord: recordIndices = (gender == Genders.Male) ? maleNordFaceRecordIndex : femaleNordFaceRecordIndex; break; case Races.Breton: default: recordIndices = (gender == Genders.Male) ? maleBretonFaceRecordIndex : femaleBretonFaceRecordIndex; break; } // get correct nameBankType for this race and create name for npc NameHelper.BankTypes nameBankType = NameHelper.BankTypes.Breton; if (GameManager.Instance.PlayerGPS.CurrentRegionIndex > -1) { nameBankType = (NameHelper.BankTypes)MapsFile.RegionRaces[GameManager.Instance.PlayerGPS.CurrentRegionIndex]; } this.nameNPC = DaggerfallUnity.Instance.NameHelper.FullName(nameBankType, gender); // get face record id to use (randomize portrait for current person outfit variant) int personFaceVariant = Random.Range(0, numPersonFaceVariants); this.personFaceRecordId = recordIndices[personOutfitVariant] + personFaceVariant; // set billboard to correct race, gender and outfit variant Asset = GetComponentInChildren <MobilePersonAsset>(); Asset.SetPerson(race, gender, personOutfitVariant, IsGuard); }
void AssignRace() { // Use faction race only for individuals if (isIndividualNPC) { FactionFile.FactionRaces factionRace = (FactionFile.FactionRaces)factionData.race; if (factionRace != FactionFile.FactionRaces.None) { switch (factionRace) { case FactionFile.FactionRaces.Redguard: race = Races.Redguard; return; case FactionFile.FactionRaces.Nord: race = Races.Nord; return; case FactionFile.FactionRaces.DarkElf: race = Races.DarkElf; return; case FactionFile.FactionRaces.WoodElf: race = Races.WoodElf; return; case FactionFile.FactionRaces.Breton: default: race = Races.Breton; return; } } } // Otherwise use race of current region race = GameManager.Instance.PlayerGPS.GetRaceOfCurrentRegion(); nameBank = GameManager.Instance.PlayerGPS.GetNameBankOfCurrentRegion(); }
public override string FemaleName() { NameHelper.BankTypes nameBank = (NameHelper.BankTypes)MapsFile.RegionRaces[GameManager.Instance.PlayerGPS.CurrentRegionIndex]; return(DaggerfallUnity.Instance.NameHelper.FullName(nameBank, Genders.Female)); }
public override string MaleName() { // %mn DFRandom.Seed = (uint)parent.UID + 3457; NameHelper.BankTypes nameBank = (NameHelper.BankTypes)MapsFile.RegionRaces[GameManager.Instance.PlayerGPS.CurrentRegionIndex]; return(DaggerfallUnity.Instance.NameHelper.FullName(nameBank, Genders.Male)); }
public static string GetName(int seed, DFLocation.BuildingTypes type, int factionID, string locationName, string regionName) { const string firstNameTitleVar = "%ef"; const string cityNameTitleVar = "%cn"; const string royalTitleVar = "%rt"; string a = string.Empty, b = string.Empty; string result = string.Empty; bool singleton = false; FactionFile.FactionData factionData; DFRandom.srand(seed); switch (type) { case DFLocation.BuildingTypes.HouseForSale: return("House for sale"); case DFLocation.BuildingTypes.Tavern: b = TavernsB[DFRandom.random_range(0, TavernsB.Length)]; a = TavernsA[DFRandom.random_range(0, TavernsA.Length)]; break; case DFLocation.BuildingTypes.GeneralStore: b = GeneralStoresB[DFRandom.random_range(0, GeneralStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.WeaponSmith: b = WeaponStoresB[DFRandom.random_range(0, WeaponStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.Armorer: b = ArmorStoresB[DFRandom.random_range(0, ArmorStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.Bookseller: b = BookStoresB[DFRandom.random_range(0, BookStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.ClothingStore: b = ClothingStoresB[DFRandom.random_range(0, ClothingStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.Alchemist: b = AlchemyStoresB[DFRandom.random_range(0, AlchemyStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.GemStore: b = GemStoresB[DFRandom.random_range(0, GemStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.PawnShop: b = PawnStoresB[DFRandom.random_range(0, PawnStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.FurnitureStore: b = FurnitureStoresB[DFRandom.random_range(0, FurnitureStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.Library: b = LibraryStoresB[DFRandom.random_range(0, LibraryStoresB.Length)]; a = StoresA[DFRandom.random_range(0, StoresA.Length)]; break; case DFLocation.BuildingTypes.Bank: // Banks always appear to be named "The Bank of RegionName" b = regionName; a = "The Bank of"; break; case DFLocation.BuildingTypes.GuildHall: // Guild halls get the name from faction data if (DaggerfallUnity.Instance.ContentReader.FactionFileReader.GetFactionData(factionID, out factionData)) { a = factionData.name; singleton = true; } break; case DFLocation.BuildingTypes.Temple: // Temples get name from faction data - always seem to be first child of factionID if (DaggerfallUnity.Instance.ContentReader.FactionFileReader.GetFactionData(factionID, out factionData)) { if (factionData.children.Count > 0) { FactionFile.FactionData firstChild; if (DaggerfallUnity.Instance.ContentReader.FactionFileReader.GetFactionData(factionData.children[0], out firstChild)) { a = firstChild.name; singleton = true; } } } break; case DFLocation.BuildingTypes.Palace: // Main palace names come from TEXT.RSC (e.g. "Castle Daggerfall") // Other palaces are just named "Palace" (still need to confirm behaviour) int textId = 0; if (locationName == "Daggerfall") { textId = 475; } else if (locationName == "Wayrest") { textId = 476; } else if (locationName == "Sentinel") { textId = 477; } if (textId > 0) { TextFile.Token[] nameTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(textId); foreach (TextFile.Token token in nameTokens) { if (token.formatting == TextFile.Formatting.Text) { a = token.text; break; } } a = a.TrimEnd('.'); // remove character '.' from castle text record entry if it is last character } else { a = "Palace"; } singleton = true; break; default: // Do nothing for unknown/unsupported building type // Houses can actually change names based on active quests return(string.Empty); } // Replace %cn a = a.Replace(cityNameTitleVar, locationName); // Replace %ef if (a.Contains(firstNameTitleVar)) { // Need to burn a rand() for %ef roll to be correct. // Classic is always doing this when expanding a macro. DFRandom.rand(); // In classic, the function expanding the %ef macro uses a global variable containing the current // region race. However, this variable is never updated when the character travels // and remains at 0. This explains why the Breton name bank is always used for shops. // This global variable is probably a leftover from Daggerfall early development as, // with the exception of %lp, which presents a similar issue and always returns // "High Rock", all naming functions use a global array of 62 fixed race values, one for each region. // As with %lp, we choose to fix the original bug in DFU and use this array, meaning that // all shops in Hammerfell now use Redguard names. NameHelper.BankTypes nameBank = (NameHelper.BankTypes)MapsFile.RegionRaces[GameManager.Instance.PlayerGPS.CurrentRegionIndex]; string firstName = DaggerfallUnity.Instance.NameHelper.FirstName(nameBank, Game.Entity.Genders.Male); a = a.Replace(firstNameTitleVar, firstName); } // Replace %rt based on faction ruler if (a.Contains(royalTitleVar)) { a = a.Replace(royalTitleVar, MacroHelper.RegentTitle(null)); } // Final text is "{a} {b}" for two-part names or just "{a}" for singleton names if (!singleton) { result = string.Format("{0} {1}", a, b); } else { result = a; } return(result); }
void OnGUI() { if (!IsReady()) { EditorGUILayout.HelpBox("DaggerfallUnity instance not ready. Have you set your Arena2 path?", MessageType.Info); return; } EditorGUILayout.Space(); bankType = (NameHelper.BankTypes)EditorGUILayout.EnumPopup(new GUIContent("Type"), bankType); gender = (Genders)EditorGUILayout.EnumPopup(new GUIContent("Gender"), gender); seed = EditorGUILayout.IntField(new GUIContent("Seed"), seed); count = EditorGUILayout.IntField(new GUIContent("Count"), count); if (GUILayout.Button("Generate Names")) { if (seed != -1) DFRandom.srand(seed); generatedNames.Clear(); for (int i = 0; i < count; i++) { generatedNames.Add(nameHelper.FullName(bankType, gender)); } } scrollPos = GUILayoutHelper.ScrollView(scrollPos, () => { for (int i = 0; i < generatedNames.Count; i++) { EditorGUILayout.SelectableLabel(generatedNames[i], EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); } }); }
private void RandomNameButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { // Generate name based on race NameHelper.BankTypes bankType = MacroHelper.GetNameBank((Races)raceTemplate.ID); textBox.Text = nameHelper.FullName(bankType, gender); }
public override string MaleName() { // %mn DFRandom.Seed = (uint)parent.GetHashCode() + 9543; NameHelper.BankTypes nameBank = MacroHelper.GetNameBank((Races)parent.characterDocument.raceTemplate.ID); return(DaggerfallUnity.Instance.NameHelper.FullName(nameBank, Genders.Male)); }