Jump to content

Recommended Posts

Well, I hit a blockade, a very very large and obstinate blockade. I been trying to find a way to force persistence dynamically on equipment so I can access their objectreference while equipped to see if it's been tempered or not via getitemhealthpercent. I'm fairly new at scripting (this would be my second, my first was a botched attempt at seeing if I could get it by getting the wornform data, alas as I expected,'twas not so simple) and I need to find a way to force persistence to have access to the object reference. I could try a placeatme, but I have no idea how to use the syntax by using the getwornform function and passing the true for forcepersistence boolean. I know I could use a reference from what I gather and so I thought I could use a forcerefto from the actor to the equipment. Any thoughts suggestions or help would be much appreciated! Thank you for taking the time to read through this mess! lol

Link to comment
Share on other sites

I'll just do a workaround for now by having a forcerefto from the actor to nearest objectreference on an item drop, not ideal, but better than nothing lol

Link to comment
Share on other sites

ForceRefTo is for forcing a Quest RefernceAlias to an object reference, if your not using a quest alias then you have the wrong function for what your trying to do.

 

When you call DropObject() on a form, then the Return from DropObject() is the Object Reference for the the dropped form.

 

eg:

Armor Cuirass = Game.GetPlayer().GetWornForm(0x00000004) as Armor
If Cuirass != None
    ObjectRefeence CuirassRef = Game.GetPlayer().DropObject(Cuirass)
    If CuirassRef != None
        If CuirassRef.GetItemHealthPercent() <= 1.0
            Debug.Notification("This cuirass has not been tempered. GET TO IT!")
        Else    
            Debug.Notification("This cuirass has been tempered.")
        EndIf
    Else
        Debug.Notification("Failed to get the object reference after dropping the worn Cuirass.")
    EndIf
Else
    Debug.Notification("Failed to get the worn Cuirass.")
EndIf
Link to comment
Share on other sites

You, my good sir, are a LIFESAVER! I'm gonna test this out and let you know how it turns out! If this works I can get around to finishing up this unarmed mod lol

Link to comment
Share on other sites

One note:

Do not call DropObject() on the equipped item in the OnObjectEquipped event.

 

As it will make it so the user can never equip the armor item as it will always get dropped when they Equip the the item.

 

Instead do it when the user Unequips the armor.

This code below attached to the player would make it so when the user Unequips the armor it will drop the armor, tell them if it's tempered and then add the armor back to their inventory:

 

ScriptName TemperTest Extends Actor

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
    If akBaseObject As Armor
        ObjectReference ArmorRef = Self.DropObject(akBaseObject)
        Int i
        While !ArmorRef.Is3DLoaded() && i < 10 ;Takes a split second for Dropped Object to load it's 3D.
            Utility.Wait(0.1)
            i += 1
        EndWhile
        If ArmorRef != None
            If ArmorRef.GetItemHealthPercent() <= 1.0
                Debug.Notification(akBaseObject.GetName() + " has not been tempered. GET TO IT!")
            Else
                Debug.Notification(akBaseObject.GetName() + " has been tempered.")
            EndIf
            Self.AddItem(ArmorRef, 1, True)
        Else
            Debug.Notification("Failed to get " + akBaseObject.GetName() + " object reference after dropping it.")
        EndIf
    EndIf
EndEvent
Link to comment
Share on other sites

Hmm I used that exact code and tried compiling it and I get this error:

 

 


C:\Program Files (x86)\Notepad++>cd
C:\Program Files (x86)\Notepad++

C:\Program Files (x86)\Notepad++>if defined ProgramFiles(x86) ("C:\Program Files
(x86)\Steam\SteamApps\Common\Skyrim\Papyrus Compiler\PapyrusCompiler.exe" "Temp
erTest.psc" -f="TESV_Papyrus_Flags.flg" -i="C:\Program Files (x86)\Steam\SteamAp
ps\Common\Skyrim\Data\Scripts\Source" -o="C:\Program Files (x86)\Steam\SteamApps
\Common\Skyrim\Data\Scripts" ) else ("C:\Program Files (x86)\Steam\SteamApps\Co
mmon\Skyrim\Papyrus Compiler\PapyrusCompiler.exe" "TemperTest.psc" -f="TESV_Papy
rus_Flags.flg" -i="C:\Program Files (x86)\Steam\SteamApps\Common\Skyrim\Data\Scr
ipts\Source" -o="C:\Program Files (x86)\Steam\SteamApps\Common\Skyrim\Data\Scrip
ts" )
Starting 1 compile threads for 1 files...
Compiling "TemperTest"...
C:\Program Files (x86)\Steam\SteamApps\Common\Skyrim\Data\Scripts\Source\TemperT
est.psc(13,48): GetName is not a function or does not exist
C:\Program Files (x86)\Steam\SteamApps\Common\Skyrim\Data\Scripts\Source\TemperT
est.psc(15,48): GetName is not a function or does not exist
C:\Program Files (x86)\Steam\SteamApps\Common\Skyrim\Data\Scripts\Source\TemperT
est.psc(19,63): GetName is not a function or does not exist
No output generated for TemperTest.psc, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on TemperTest.psc

C:\Program Files (x86)\Notepad++>pause
Press any key to continue . . .

 

 

I even tried reinstalling SKSE just in case it's that, but no dice *Scratches head*

Link to comment
Share on other sites

Might be best to try and take a crack at this in the morning after work or something lol...

 

Thinking bout that now I probably should get some rest for work xD

 

Thank you for your time and patience and hopefully this conundrum can be solved, I'm trying to make this dynamic for the simple fact I want a unarmed perk mod that for one, fixes fist of steel to hold true to the name(the cuirass is just a good simple example lol) and most fix almost everything, save for taking tempering into account, which bugs my idiosyncrasies to no end lol, so I'm trying to make it dynamic, and mod friendly for armor mods, so unarmed players aren't stuck with vanilla armor all the time lol

Link to comment
Share on other sites

That code above compile fine for me, copied what I posted, pasted it into my text editor and saved as TemperTest.psc

 

Then I had CK open I just used Gameplay -> Papyrus Sript Manager -> TemperTest -> Right Click and Compile.

 

Then I attached the script to Object Window -> Actors -> Actor -> Player

 

Saved as TemperTest.esp and ran a game save and unequipped an item and it does exactly as intended.

 

Cant tell you why you can't compile it.

 

GetName() is a native Skyrim function which you use on the base form to get it's name.

 

Edit: GetName() is an SKSE function, I think it's time you updated SKSE.

GetName() was added in SKSE Version 1.5.4 (Current SKSE version is 1.7.3)

So your version is older then 1.5.4 or it's not installed properly or if at all.

 

Quite simple look in Data\Scripts\Source\Form.psc and see if the GetName() function is listed in there.

If not then your SKSE scripts or version is not correct.

 

Don't take this the wrong way, just my view and I'm not saying you fit my crappy view...

I hope your not one of the people that rely on an installer or mod manager to intsall SKSE, as I really don't have the patience for it.

SKSE is a simple thing to install and those that can not copy a few files from one directory to another and click yes to overwrite should not be writing code imho.

 

So the same thing without GetName():

ScriptName TemperTest Extends Actor

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
    If akBaseObject As Armor
        ObjectReference ArmorRef = Self.DropObject(akBaseObject)
        Int i
        While !ArmorRef.Is3DLoaded() && i < 10 ;Takes a split second for Dropped Object to load it's 3D.
            Utility.Wait(0.1)
            i += 1
        EndWhile
        If ArmorRef != None
            If ArmorRef.GetItemHealthPercent() <= 1.0
                Debug.Notification("Armor has not been tempered. GET TO IT!")
            Else
                Debug.Notification("Armor has been tempered.")
            EndIf
            Self.AddItem(ArmorRef, 1, True)
        Else
            Debug.Notification("Failed to get Armor object reference after dropping it.")
        EndIf
    EndIf
EndEvent
Link to comment
Share on other sites

No I had to reinstall creation kit cause it kept crashing and I just read somewhere it would overwrite the skse scripts so I haveto reinstall it that's all, rookie mistake so thank you for the help and the patience :)
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...