How to use GetRace with conditionals?

Post » Sat Aug 24, 2013 12:31 pm

I'm trying to create a "genetics" code that hooks into another mod (an ESM file) that will take two parents and create a child based off them. So far I have successfully managed to get the child to inherit facial features and hair color, but I've been running into trouble getting the script to recognize the parents' races.

Here is the relevant code:

Spoiler
ActorBase Function InheritLooks(ActorBase ChildBase, Actor Father, Actor Mother) ActorBase FatherBaseRef = Father.GetLeveledActorBase()ActorBase MotherBaseRef = Mother.GetLeveledActorBase()ActorBase FatherRaceRef = Father.GetActorBase()ActorBase MotherRaceRef = Mother.GetActorBase() Race InheritRace Int Haircolor = Utility.RandomInt(0,1)Int Eyes = Utility.RandomInt(0,1)Int Nose = Utility.RandomInt(0,1)Int Mouth = Utility.RandomInt(0,1)Int ChildRace = Utility.RandomInt(0,1)Int gender = Utility.RandomInt(0,1) Int FatherNosePreset = FatherBaseRef.GetFacePreset(0)Int FatherEyesPreset = FatherBaseRef.GetFacePreset(2)Int FatherMouthPreset = FatherBaseRef.GetFacePreset(3)ColorForm FatherHairColor = FatherBaseRef.GetHairColor()Race FatherRace = FatherRaceRef.GetRace()  Int MotherNosePreset = MotherBaseRef.GetFacePreset(0)Int MotherEyesPreset = MotherBaseRef.GetFacePreset(2)Int MotherMouthPreset = MotherBaseRef.GetFacePreset(3)ColorForm MotherHairColor = MotherBaseRef.GetHairColor()Race MotherRace = MotherRaceRef.GetRace()  If ChildRace == 0          InheritRace = FatherRace          Debug.Notification("Child is inheriting father's race.")Else          InheritRace = MotherRace          Debug.Notification("Child is inheriting mother's race.")EndIf If (InheritRace == ArgonianRace)          Debug.Notification("Child will be Argonian.")          If gender == 0                   ChildBase = ArgonianBoy1          Else                   ChildBase = ArgonianGirl1          EndIfElseIf (InheritRace == BretonRace)          Debug.Notification("Child will be Breton.")          If gender == 0                   ChildBase = BretonBoy1          Else                   ChildBase = BretonGirl1          EndIfElseIf (InheritRace == DarkElfRace)          Debug.Notification("Child will be Dunmer.")          If gender == 0                   ChildBase = DunmerBoy1          Else                    ChildBase = DunmerGirl1          EndIfElseIf (InheritRace == HighElfRace)Debug.Notification("Child will be Altmer.")          If gender == 0                   ChildBase = AltmerBoy1          Else                    ChildBase = AltmerGirl1          EndIfElseIf (InheritRace == ImperialRace)          Debug.Notification("Child will be Imperial.")          If gender == 0                  ChildBase = ImperialBoy1          Else                   ChildBase = ImperialGirl1          EndIfElseIf (InheritRace == KhajiitRace)          Debug.Notification("Child will be Khajiit.")          If gender == 0                  ChildBase = KhajitBoy1          Else                   ChildBase = KhajitGirl1          EndIfElseIf (InheritRace == NordRace)          Debug.Notification("Child will be Nord.")          If gender == 0                  ChildBase = NordBoy1          Else                   ChildBase = NordGirl1          EndIfElseIf (InheritRace == OrcRace)          Debug.Notification("Child will be Orc.")          If gender == 0                 ChildBase = OrcBoy1          Else                  ChildBase = OrcGirl1          EndIfElseIf (InheritRace == RedguardRace)           Debug.Notification("Child will be Redguard.")           If gender == 0                 ChildBase = RedguardBoy1           Else                  ChildBase = RedguardGirl1           EndIfElseIf (InheritRace == WoodElfRace)           Debug.Notification("Child will be Bosmer.")           If gender == 0                  ChildBase = BosmerBoy1           Else                   ChildBase = BosmerGirl1           EndIfElse           Debug.Notification("Parent is a custom race. Defaulting to Nord.")           If gender == 0                   ChildBase = NordBoy1           Else                    ChildBase = NordGirl1           EndIfEndIf If Haircolor == 0         ChildBase.SetHairColor(FatherHairColor)Else         ChildBase.SetHairColor(MotherHairColor)EndIf If Eyes == 0         ChildBase.SetFacePreset(FatherEyesPreset, 2)Else         ChildBase.SetFacePreset(MotherEyesPreset, 2)EndIf If Nose == 0         ChildBase.SetFacePreset(FatherNosePreset, 0)Else         ChildBase.SetFacePreset(MotherNosePreset, 0)EndIf If Mouth == 0         ChildBase.SetFacePreset(FatherMouthPreset, 3)Else         ChildBase.SetFacePreset(MotherMouthPreset, 3)EndIf Return ChildBase EndFunction

The script is intended to randomly pick one of the parents races to pass on to the child (InheritRace). Once this has been picked, the script checks the InheritRace against the available races until it finds a match, at which point it picks the appropriate child base to apply facial features to (the rest of the script). If the script does not recognize the race (for instance, if the selected parent is a custom race) it defaults to Nord.

Unfortunately the script doesn't seem to be recognizing any races, which means the children are always Nord no matter who the parents are. Everything before or after that specific part of the script works fine. What am I missing?

User avatar
louise hamilton
 
Posts: 3412
Joined: Wed Jun 07, 2006 9:16 am

Return to V - Skyrim