demidekidasu Posted September 23, 2013 Share Posted September 23, 2013 (edited) I'd like to share the following script with the modding world. It works, but does nothing more than print debug messages for now as there is currently no way to update skin tones. Essentially it works like this: You must create a global variable for the "Sun Tan Level"(value of 0.1) and a variable for the rate at which it increases (value of whatever you want). You also need to create two more Globals, one for daylight hours start time(7, perhaps?) and one for daylight hours end time(20?). The script will fetch the weather type flag and if it is sunny weather during daylight hours, it will increase the value of the "sun tan level" global by the "rate" global's value. When the "sun tan level" reaches a value of 1.0, it will modify the colour form of the Skin. When it reaches 2.0, it will change it again, and so on. Setting up all the different colours is the fun part - first you need to create a new colour form for each race and gender, then a form list for each one as the CK cannot match script properties to colour forms. Then you need to calculate the colour values you want the script to change them to. To do so, you need to decide upon an ARGB value with A(alpha) being 0, then convert the ARGB to hex, then convert the hex value to decimal. And you need to do this for each skin tone you want to apply to each race and each gender. Also, you will need to add each colour form you created to each race and gender, and also add them into the form lists you created for them. When the player installs the mod, they will need to change their character's skin tone to the one you added. For the sake of convenience, this script forces the Race Menu to pop-up on installation of the mod. As I said, it currently does nothing more than print debug messages, but I hope to see new functions added to SKSE such as the UpdateHairColour() function in the future. You can see how many different things I've tried to force the skin tone to update :tongue: Anyway, here is the script for anyone who might know something to overcome this hurdle. I just ask for credit, of course, if you can get it to work! Be sure to read my notes in the script... ; This script is the meat and bones of a potential dynamic suntan mod. ; It seems to work perfectly, for the most part. The problem is that I cannot find any way to update the skin tone via Papyrus! ;============================== ;==|=PROPERTIES AND FUNCTIONS=|== ;============================== ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;|GLOBAL VARIABLES| GlobalVariable Property DDDSunTanLevel Auto GlobalVariable Property DDDSunTanLevelRate Auto GlobalVariable Property DDDSunTanStartTime Auto GlobalVariable Property DDDSunTanEndTime Auto ;---------------------------------------- ;---------------------------------------- ;|TIME OF DAY| ; |CURRENT HOUR| float Function DAYHOUR() global float Time = Utility.GetCurrentGameTime() Time -= Math.Floor(Time) Time *= 24 Return Time EndFunction ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;|COLORFORMS| ; Only female Humans for now(Nord, Breton, Imperial)... ; |DARK ELF| ; FormList property DDD_SUNTAN_DarkElf_Form auto ; FormList property DDD_SUNTAN_DarkElfFemale_Form Auto ;---------------------------------------- ;---------------------------------------- ; |HIGH ELF| ; FormList property DDD_SUNTAN_HighElf_Form Auto ; FormList property DDD_SUNTAN_HighElfFemale_Form Auto ;---------------------------------------- ;---------------------------------------- ; |BRETON, IMPERIAL, NORD| ; FormList property DDD_SUNTAN_Human_Form Auto FormList property DDD_SUNTAN_HumanFemale_Form Auto ;---------------------------------------- ;---------------------------------------- ; |REDGUARD| ; FormList property DDD_SUNTAN_HumanDark_Form Auto ;---------------------------------------- ;---------------------------------------- ; |ORC| ; FormList property DDD_SUNTAN_Orc_Form Auto ; FormList property DDD_SUNTAN_OrcFemale_Form Auto ;---------------------------------------- ;---------------------------------------- ; |WOOD ELF| ; FormList property DDD_SUNTAN_WoodElf_Form Auto ; FormList property DDD_SUNTAN_WoodElfFemale_Form Auto ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;|PLAYER| Actor Property PlayerRef auto Armor Property DDD_SUNTAN_SkinNaked Auto Armor Property SkinNaked Auto ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;|UPDATE PLAYER| ; This whole section is disabled until a solution becomes available. You can see how many things I have tried. NOTHING will update the skin tone... ;---------------------------------------- ;---------------------------------------- ; Function UpdatePlayer() ;---------------------------------------- ;---------------------------------------- ; |UPDATE WEIGHT| ; Utility.Wait(0.2) ; float PlayerOrigWeight = PlayerRef.GetWeight() ; Utility.Wait(0.2) ; float PlayerNewWeight = PlayerRef.GetWeight() ; Utility.Wait(0.2) ; Float NeckDelta = (PlayerOrigWeight / 100) - (PlayerNewWeight / 100) ; Utility.Wait(0.2) ; PlayerRef.GetActorBase().SetWeight(PlayerNewWeight) ; Utility.Wait(0.2) ; PlayerRef.UpdateWeight(NeckDelta) ; Utility.Wait(0.2) ;---------------------------------------- ;---------------------------------------- ; |UPDATE MESHES AND COLOURS| ; PlayerRef.GetActorBase().SetSkin(DDD_SUNTAN_SkinNaked) ; Utility.Wait(0.2) ; PlayerRef.GetActorBase().SetSkin(SkinNaked) ; Utility.Wait(0.2) ; Game.UpdateHairColor() ; Utility.Wait(0.2) ; PlayerRef.RegenerateHead() ; Utility.Wait(0.2) ; PlayerRef.QueueNiNodeUpdate() ; Utility.Wait(0.2) ;---------------------------------------- ;---------------------------------------- ; |WHAT I DREAM OF SEEING IN A FUTURE SKSE VERSION WHICH WOULD MAKE THIS WHOLE MOD WORK INSTANTLY| ; Something along the lines of... ; Game.UpdateSkinColor() ;---------------------------------------- ;---------------------------------------- ; EndFunction ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;|DEBUG MESSAGE| Function DisplaySuntanStats() Utility.Wait(0.2) Debug.notification("Weather=" + (Weather.GetCurrentWeather().GetClassification()) + " Tan=" + (DDDSunTanLevel.GetValue()) + " ARGB=" + ((DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).GetColor())) Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;|CHANGE TAN| ; This is the grim part. Not only does one have to come up with many different colour tones for each race and sex, one must then take each ARGB value, convert to hex and then convert from hex back into decimal. Pain! ; I almost died doing the female Human colour tones alone! ; |LEVEL 1| Function TanLevelOne() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(14606046) ; ARGB: 0 221 221 221 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 2| Function TanLevelTwo() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(13487565) ; ARGB: 0 206 205 204 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 3| Function TanLevelThree() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(12170410) ; ARGB: 0 185 179 170 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 4| Function TanLevelFour() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(11313303) ; ARGB: 0 172 159 151 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 5| Function TanLevelFive() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(10193795) ; ARGB: 0 155 139 132 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 6| Function TanLevelSix() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(9533038) ; ARGB: 0 145 119 111 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 7| Function TanLevelSeven() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(9400932) ; ARGB: 0 143 114 101 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 8| Function TanLevelEight() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(8481377) ; ARGB: 0 130 106 98 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 9| Function TanLevelNine() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(8152149) ; ARGB: 0 125 99 85 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ; |LEVEL 10| Function TanLevelTen() Utility.Wait(0.2) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(7496015) ; ARGB: 0 115 97 79 Utility.Wait(0.2) EndFunction ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;============================== ;==|=EVENTS=|== ;============================== ;---------------------------------------- ;---------------------------------------- ;|STARTUP| Event OnInit() utility.wait(5.0) Debug.MessageBox("Thank you for installing the DDD Suntan mod! In a short moment, you will be shown the menu to customise your character where you should set the skin tone slider all the way to the right.") utility.wait(5.0) (DDD_SUNTAN_HumanFemale_Form.GetAt(0) as colorform).SetColor(16736767) ; Crazy colour for testing. And for lulz. utility.wait(1.0) ; UpdatePlayer() ; Pointless to enable the above as it is currently impossible to update the skin tone... utility.wait(1.0) Game.ShowRaceMenu() utility.wait(5.0) DisplaySuntanStats() utility.wait(1.0) RegisterForSingleUpdate(60.0) Utility.Wait(0.2) EndEvent ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;|DAS LOOP| Event OnUpdate() ;---------------------------------------- ;---------------------------------------- float TimeStart = DDDSunTanStartTime.GetValue() float TimeEnd = DDDSunTanEndTime.GetValue() float CurrentWeatherClass = Weather.GetCurrentWeather().GetClassification() float SunTanRate = DDDSunTanLevelRate.GetValue() float SunTanCurrent = DDDSunTanLevel.GetValue() ;---------------------------------------- ;---------------------------------------- ; |CHECK WEATHER| ; |UNKNOWN WEATHER| ; I do not know if this part even works... If (CurrentWeatherClass == -1) && (DAYHOUR() >= TimeStart) && (DAYHOUR() <= TimeEnd) Utility.Wait(0.2) Debug.Notification("This weather does not have the correct flags!") Utility.Wait(0.2) EndIf ;---------------------------------------- ;---------------------------------------- ; |SUNNY WEATHER| ; Works but loses accuracy over time...GG Papyrus... If (CurrentWeatherClass == 0) && (DAYHOUR() >= TimeStart) && (DAYHOUR() <= TimeEnd) Utility.Wait(0.2) DDDSunTanLevel.Mod(SunTanRate) Utility.Wait(0.2) EndIf ;---------------------------------------- ;---------------------------------------- ; |BAD WEATHER| ; Not used as it seems to be problematic...I do not know if this a problem with my script or a problem with Papyrus itself, which wouldn't shock me... ; If (CurrentWeatherClass <= 2) && (DAYHOUR() >= TimeStart) && (DAYHOUR() < = TimeEnd) && (SunTanCurrent > 1.0) ; Utility.Wait(0.2) ; DDDSunTanLevel.Mod(-0.1) ; Utility.Wait(0.2) ; EndIf ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ; |CHANGE COLOURS| ; |LEVEL 1| If SunTanCurrent <= 0.9 Debug.Notification("TanLevelOne") TanLevelOne() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 2| If SunTanCurrent >= 1.0 && SunTanCurrent <= 1.9 Debug.Notification("TanLevelTwo") TanLevelTwo() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 3| If SunTanCurrent >= 2.0 && SunTanCurrent <= 2.9 Debug.Notification("TanLevelThree") TanLevelThree() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 4| If SunTanCurrent >= 3.0 && SunTanCurrent <= 3.9 Debug.Notification("TanLevelFour") TanLevelFour() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 5| If SunTanCurrent >= 4.0 && SunTanCurrent <= 4.9 Debug.Notification("TanLevelFive") TanLevelFive() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 6| If SunTanCurrent >= 5.0 && SunTanCurrent <= 5.9 Debug.Notification("TanLevelSix") TanLevelSix() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 7| If SunTanCurrent >= 6.0 && SunTanCurrent <= 6.9 Debug.Notification("TanLevelSeven") TanLevelSeven() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 8| If SunTanCurrent >= 7.0 && SunTanCurrent <= 7.9 Debug.Notification("TanLevelEight") TanLevelEight() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 9| If SunTanCurrent >= 8.0 && SunTanCurrent <= 8.9 Debug.Notification("TanLevelNine") TanLevelNine() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ; |LEVEL 10| If SunTanCurrent >= 9.0 Debug.Notification("TanLevelTen") TanLevelTen() Utility.Wait(1.0) EndIf ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ; |REGISTER AND COOKIES| Debug.Notification("Loop") utility.wait(1.0) ; UpdatePlayer() ; Again, the above is pointless... utility.wait(1.0) DisplaySuntanStats() utility.wait(1.0) RegisterForSingleUpdate(60.0) Utility.Wait(0.2) ;---------------------------------------- ;---------------------------------------- EndEvent ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- ;---------------------------------------- The original inspiration for this came from reading a joke between prod80 and ewi65 in prod80's sunglare mod. Edited September 23, 2013 by demidekidasu Link to comment Share on other sites More sharing options...
prod80 Posted September 25, 2013 Share Posted September 25, 2013 all I can do is smile ;Dand I thought you would just be joking ... lol if you're good in scripting (and I don't know nothing about that) perhaps you can give me a hand if this can be solved with scripts/SKSE: http://forums.nexusmods.com/index.php?/topic/1127973-help-needed-with-camera-attached-meshes-cot-patch/ Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 25, 2013 Share Posted September 25, 2013 Check with expired6978 the author of RaceMenu. Perhaps there could be a variable or color form entry on a form list from that mod which you could hook onto and use to adjust the current color of the player's skin. Link to comment Share on other sites More sharing options...
demidekidasu Posted September 26, 2013 Author Share Posted September 26, 2013 all I can do is smile :laugh:and I thought you would just be joking ... lol if you're good in scripting (and I don't know nothing about that) perhaps you can give me a hand if this can be solved with scripts/SKSE: http://forums.nexusmods.com/index.php?/topic/1127973-help-needed-with-camera-attached-meshes-cot-patch/Hehe, yeah, I was being absolutely serious :D I'll take a look but can't promise anything, I'm still very much learning :) Check with expired6978 the author of RaceMenu. Perhaps there could be a variable or color form entry on a form list from that mod which you could hook onto and use to adjust the current color of the player's skin.Perhaps, though I doubt I'm missing anything as I combed every script category on the wiki and everything the SKSE documentation, including the source files themselves...In any case, the problem is not with changing the colour—this script does that and it works—the problem is with updating the skin colour on the fly. It updates correctly if you "showracemenu" and switch the skin tone to another and back, just not on the fly. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 26, 2013 Share Posted September 26, 2013 You didn't state in the first post that the color change worked. You had said that it only printed debug messages because there was no way to update the skin tone. That indicated that the color change did not work. At any rate...Try something off the wall like a forced race change to the same race. Might refresh the skin color... Worth a shot at any rate :P Link to comment Share on other sites More sharing options...
demidekidasu Posted October 1, 2013 Author Share Posted October 1, 2013 You didn't state in the first post that the color change worked. You had said that it only printed debug messages because there was no way to update the skin tone. That indicated that the color change did not work. At any rate...Try something off the wall like a forced race change to the same race. Might refresh the skin color... Worth a shot at any rate :tongue:Ah, sorry for the confusion there lol But yeah, it might work but it's messy. I'll just wait for moar SKSE functions...No rush :D Link to comment Share on other sites More sharing options...
Recommended Posts