Halstrom Posted July 23, 2016 Posted July 23, 2016 I've done a bit of GECK in NV scripting but haven't done any Skyrim Papyrus, so just starting to get into it now. There don't seem to be many Papyrus experts in the FO4 forums so I'm trying here. I got my first script working, its a ring that just heals the player by a scripted Magical Effect and it works. My problems going forward are: No Debug Traces are showing up in the Log files, I probably haven't switched debugging on or something? My Message box won't show anything after it tries to display the actors name and this won't compile: ; rActorName = akTarget.GetName() I want to adjust the healing rate according to the level of the actor wearing it, when I re-enable the commented out bit this fails to compile: float fActorLevel ; = rActor.GetLevel() float HPHealRate = 1.0 ; * fActorLevel / 100 This line aslo fails to compile if I enable it: ; Debug.Trace("SuperPowers: Rads: " + (string)iRads + " HealthPerc: " + (string)iHealthPerc) Complete script below: Scriptname SuperPowers:SuperPowers extends activemagiceffect ActorValue Property Level Auto Const ActorValue Property HealthAV Auto Const ActorValue Property RadsAV Auto Const ActorValue Property AddictionCountAV Auto const ActorValue Property RadsRateAV Auto Const ActorValue Property RadsHealthMaxAV Auto Const ActorValue Property RadsResistExposureAV Auto Const ActorValue Property RadsResistIngestionAV Auto Const ActorValue Property BrainConditionAV Auto const ActorValue Property PerceptionConditionAV Auto const ActorValue Property EnduranceConditionAV Auto const ActorValue Property LeftAttackConditionAV Auto const ActorValue Property LeftMobilityConditionAV Auto const ActorValue Property RightAttackConditionAV Auto const ActorValue Property RightMobilityConditionAV Auto const ObjectReference rActor ObjectReference rActorName float HealTimer = 1.0 int HealTimerID = 32 Event OnEffectStart(Actor akCaster, Actor akTarget) rActor = (akTarget as ObjectReference) ; rActorName = akTarget.GetName() RegisterForRemoteEvent(akTarget as ObjectReference, "OnUnload") RegisterForRemoteEvent(akTarget, "OnDeath") StartTimer(HealTimer,HealTimerID) Debug.Trace("SuperPowers: Actor: " + rActor + " Effect Event Started") Debug.MessageBox("SuperPowers: Effect Event Started" + rActor) EndEvent Event OnTimer(int aiTimerID) If (aiTimerID >= HealTimerID) float fActorLevel ; = rActor.GetLevel() float HPHealRate = 1.0 ; * fActorLevel / 100 int iRadsRate = (rActor.GetValue(RadsRateAV) as int) float RadHealRate = 0.1 if (iRadsRate <= 0) int iRads = (rActor.GetValue(RadsAV) as int) int iHealthPerc = ((rActor.GetValuePercentage(HealthAV) * 100) as int) int iHealth = ((rActor.GetValue(HealthAV) * 100) as int) Debug.Trace("SuperPowers: Actor: " + rActor + " Timer Trigger") ; Debug.Trace("SuperPowers: Rads: " + (string)iRads + " HealthPerc: " + (string)iHealthPerc) If (iRads <= 0) If (iHealthPerc < 100) int iCondHealRate = (HPHealRate / 10) as int rActor.RestoreValue(HealthAV, HPHealRate) rActor.RestoreValue(PerceptionConditionAV, iCondHealRate) rActor.RestoreValue(BrainConditionAV, iCondHealRate) rActor.RestoreValue(EnduranceConditionAV, iCondHealRate) rActor.RestoreValue(LeftAttackConditionAV, iCondHealRate) rActor.RestoreValue(LeftMobilityConditionAV, iCondHealRate) rActor.RestoreValue(RightAttackConditionAV, iCondHealRate) rActor.RestoreValue(RightMobilityConditionAV, iCondHealRate) EndIf Else If (iRads > 0) rActor.RestoreValue(RadsAV, RadHealRate) EndIf Endif Endif EndIF StartTimer(HealTimer,HealTimerID) EndEvent Event ObjectReference.OnUnload(ObjectReference akSender) CleanUp() EndEvent Event Actor.OnDeath(Actor akSender, Actor akKiller) CleanUp() EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) CleanUp() EndEvent Function CleanUp() rActor = None CancelTimer(HealTimerID) UnregisterForAllEvents() Dispel() EndFunction
Guest Posted July 23, 2016 Posted July 23, 2016 Debug.trace In case you use Mod Organizer: -> Go in the Profiles folder of Mod Organizer, go in the profile you are using and edit the skyrim.ini file In case NMM of manual install: -> C:\Users\<your name>\Documents\My Games\Skyrim\skirim.ini Be sure you have a section like this: [Papyrus] fPostLoadUpdateTimeMS=500.0 bEnableLogging=1 bEnableTrace=1 bLoadDebugInformation=1 bEnableProfiling=1 Compiling problems Actor.getLevel() returns an Int, so you cannot really assign it as is to a Float. Try: float fActorLevel = rActor.GetLevel() as float The line: Debug.Trace("SuperPowers: Rads: " + (string)iRads + " HealthPerc: " + (string)iHealthPerc) Does not compile because the "casting" is wrong. Casts in Papyrus are done in this way: <variable> as <type> And you don't need to "cast" a Int to a string, it is automatic. use this: Debug.Trace("SuperPowers: Rads: " + iRads + " HealthPerc: " + iHealthPerc)
Halstrom Posted July 23, 2016 Author Posted July 23, 2016 Debug.trace In case you use Mod Organizer: -> Go in the Profiles folder of Mod Organizer, go in the profile you are using and edit the skyrim.ini file In case NMM of manual install: -> C:\Users\<your name>\Documents\My Games\Skyrim\skirim.ini Be sure you have a section like this: [Papyrus] fPostLoadUpdateTimeMS=500.0 bEnableLogging=1 bEnableTrace=1 bLoadDebugInformation=1 bEnableProfiling=1 Compiling problems Actor.getLevel() returns an Int, so you cannot really assign it as is to a Float. Try: float fActorLevel = rActor.GetLevel() as float The line: Debug.Trace("SuperPowers: Rads: " + (string)iRads + " HealthPerc: " + (string)iHealthPerc) Does not compile because the "casting" is wrong. Casts in Papyrus are done in this way: <variable> as <type> And you don't need to "cast" a Int to a string, it is automatic. use this: Debug.Trace("SuperPowers: Rads: " + iRads + " HealthPerc: " + iHealthPerc) Cool that solved a few problems, I did the above to my Fallout4.ini and Fallout4Custom.ini still nothing in the Debug log files. I tried removing "bEnableProfiling=1" because it wasn't in the Fallout4.ini but no difference. I also found no way to print to console yet either, this won't compile. Print("SuperPowers: Rads: " + iRads + " HealthPerc: " + iHealthPerc) I just changed GetLevel to an int instead, I'm assuming Papyrus doesn't fall foul of mathmatical quirks when doing calculations involving floats and ints when dividing, another engine I worked on did and you always had to use only ints or only floats or you got zeroed results. Unfortunately GetLevel, GetLevelActor, GetActorLevel all seem to be invalid in a MagicEffect script for whatever reason and I haven't been able to find any example to copy in the vanilla scripts so I just have to wait till that resolves itself and work on other stuff instead for now
Guest Posted July 23, 2016 Posted July 23, 2016 Printing in the console is not supported. It was an extension in Skyrim. Inside a magic effect you have an "activemagiceffect", not an actor. But the ActiveMagicEffect, in the Event OnEffectStart() gives you two actors, the target and the caster. You can define an Actor variable outside the function, and when you receive the OnEffectStart, you can save the Target actor (the caster in some cases it is empty.) Then you can call your getLevel(), getlevelActor(0, etc on the stored actor.
Halstrom Posted July 24, 2016 Author Posted July 24, 2016 So there's no vanilla way to display debug messaging in the console like FONV, we have to close the game and look at logfiles to see what variables are doing or use MessageBoxEx? When you say outside the function do you mean get the players level in another script and then send the data via a global or something to this script? In this ring effectrs case the caster and target are the same actor of course. Side Question: In Skyrim what ranges do armors Health set in a healthbox go up to for most balanced mods 0-100, 0-1000, 0-10,000?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.