Jump to content

Need help getting workshop "Defense" value


Recommended Posts

Hello all!

 

I've been trying to find a way to get the defense value in Sanctuary without altering WorkshopScript.pex.

 

If I add in a function at the end of WorkshopScript and call the function with an activator button it works just fine but I want to get the value in a non-invasive way and not change any vanilla script source. Here is what worked:

 

Working function at end of WorkshopScript.pex:

int Function SafetyCheckup()

    WorkshopDataScript:WorkshopRatingKeyword[] rating_checkup = WorkshopParent.WorkshopRatings
    int current_safety = GetValue(rating_checkup[WorkshopParent.WorkshopRatingSafety].resourceValue) as int
    return current_safety

EndFunction

Working script on an activator button:

Scriptname ButtonTest04 extends ObjectReference

WorkshopScript property SanctuaryWorkshopREF auto const

Event OnActivate(ObjectReference akActionRef)
    
    int TheCheckup = SanctuaryWorkshopREF.SafetyCheckup()
    debug.messagebox(TheCheckup)

EndEvent

And here is my attempt at a non-invasive approach on an activator button which always shows a 0 in the messagebox:

Scriptname ButtonTest03 extends ObjectReference

WorkshopScript property SanctuaryWorkshopREF auto const

Event OnActivate(ObjectReference akActionRef)

    WorkshopDataScript:WorkshopRatingKeyword[] rating_checkup = SanctuaryWorkshopREF.WorkshopParent.WorkshopRatings
    int current_safety = GetValue(rating_checkup[SanctuaryWorkshopREF.WorkshopParent.WorkshopRatingSafety].resourceValue) as int

    debug.messagebox(current_safety)

EndEvent

I've tried a bunch of variations of the above and always double check to make sure my properties are initiated.

 

I even made this "crazy-person-attaching-red-yarn-to-newspapers-on-the-wall" level drawing to try to understand wtf is going on in the vanilla code but I don't know how useful or accurate it is:

odIm90b.jpg

 

I came up pretty dry on Google and the wiki. Any help would be greatly appreciated, thank you guys and girls!

 

how I feel:

https://youtu.be/_nTpsv9PNqo?t=18

Edited by shatsnazzle
Link to comment
Share on other sites

Ratings are exposed as properties or variables on the scripts that you can query:

Import WorkshopScript
WorkshopParentScript Property pWorkshopParentScript Auto Const Mandatory ; WorkshopParent Quest

WorkshopScript WorkshopREF = pWorkshopParentScript.Workshops[iTheIndexIWant]
Int iTheValueIWant = WorkshopREF.GetValue(pWorkshopParentScript.WorkshopRatings[pWorkshopParentScript.WorkshopRatingSafety].resourceValue) as Int

Replace WorkshopRatingSafety with any of the WorkshopActorValues from line 104 of the WorkshopParentScript.

 

EDIT: for those who feel the need to point this stuff out, no this wont run as is. I don't hand out ready made code any more, rather the primers and pointers.

Edited by SKK50
Link to comment
Share on other sites

Ratings are exposed as properties or variables on the scripts that you can query:

Import WorkshopScript
WorkshopParentScript Property pWorkshopParentScript Auto Const Mandatory ; WorkshopParent Quest

WorkshopScript WorkshopREF = pWorkshopParentScript.Workshops[iTheIndexIWant]
Int ValueIWant = WorkshopREF.GetValue(pWorkshopParentScript.WorkshopRatings[pWorkshopParentScript.WorkshopRatingSafety].resourceValue) as Int

Replace WorkshopRatingSafety with any of the WorkshopActorValues from line 104 of the WorkshopParentScript.

 

EDIT: for those who feel the need to point this stuff out, no this wont run as is. I don't hand out ready made code any more, rather the primers and pointers.

 

wow Thank you so much SKK50! Again! That's the second time you've answered my scripting question!! :) https://forums.nexusmods.com/index.php?/topic/6452476-quick-question-on-properties-and-dependency/

 

I attached it to an activator button and it works perfectly!

Is the index on the workshops the same for all savegames/players or is everyone's different? I used a while loop to find the index on sanctuary

Scriptname ButtonTest03 extends ObjectReference

Import WorkshopScript
WorkshopParentScript Property pWorkshopParentScript Auto Const Mandatory ; WorkshopParent Quest

Event OnActivate(ObjectReference akActionRef)

int indexiwant = 0
while indexiwant<28
    WorkshopScript WorkshopREF = pWorkshopParentScript.Workshops[indexiwant]
    Int ValueIWant = WorkshopREF.GetValue(pWorkshopParentScript.WorkshopRatings[pWorkshopParentScript.WorkshopRatingSafety].resourceValue) as Int

        debug.messagebox(ValueIWant + " " +indexiwant)
    indexiwant = indexiwant + 1
endwhile
EndEvent

and then distilled it down to:

Scriptname ButtonTest03 extends ObjectReference

Import WorkshopScript
WorkshopParentScript Property pWorkshopParentScript Auto Const Mandatory ; WorkshopParent Quest

Event OnActivate(ObjectReference akActionRef)

    WorkshopScript WorkshopREF = pWorkshopParentScript.Workshops[21]
    Int ValueIWant = WorkshopREF.GetValue(pWorkshopParentScript.WorkshopRatings[pWorkshopParentScript.WorkshopRatingSafety].resourceValue) as Int
    
    debug.messagebox(ValueIWant)

EndEvent

Lol I am so excited thanks again!!

Link to comment
Share on other sites

Happy to help. Can't describe the time and brain pain involved in figuring out that nested mess, its a suppressed memory now.

 

For the base game settlement workshops, they always seem to index the the same order across new games but as I haven't found any relevant script it may not be consistent so always match to a hard REF property to be sure. This is the usual base game order I see at each load across *A LOT* of new game starts:

WorkshopAttacks 00 [workshopscript < (0009B1DB)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 101
WorkshopAttacks 01 [workshopscript < (0009B19D)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 02 [workshopscript < (001654BD)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 03 [workshopscript < (0016D28E)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 04 [workshopscript < (00161F4B)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 05 [workshopscript < (0009B197)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 06 [workshopscript < (00066EB6)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 07 [workshopscript < (00019956)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 08 [workshopscript < (001E81EA)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 09 [workshopscript < (0009B1BE)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 10 [workshopscript < (001654D5)>] PlayerOwned True  Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 11 [workshopscript < (00168945)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 100
WorkshopAttacks 12 [workshopscript < (00135A90)>] PlayerOwned True  Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 13 [workshopscript < (0009B1A5)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 14 [workshopscript < (0009B1AC)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 15 [workshopscript < (001654B8)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 16 [workshopscript < (0001D0E2)>] PlayerOwned True  Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 17 [workshopscript < (001F0711)>] PlayerOwned True  Vassal False Attacks True DaysSinceLast 6
WorkshopAttacks 18 [workshopscript < (00164321)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 19 [workshopscript < (0009B1F1)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 9
WorkshopAttacks 20 [workshopscript < (0006F5C5)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 21 [workshopscript < (000250FE)>] PlayerOwned True  Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 22 [workshopscript < (0009B1D1)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 100
WorkshopAttacks 23 [workshopscript < (000B3506)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 24 [workshopscript < (00054BAE)>] PlayerOwned True  Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 25 [workshopscript < (001654CF)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 26 [workshopscript < (00024A26)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 20
WorkshopAttacks 27 [workshopscript < (000E0505)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119
WorkshopAttacks 28 [workshopscript < (0009B18F)>] PlayerOwned False Vassal False Attacks True DaysSinceLast 119

If your interested workshop attack status can be set remotely with WorkshopREF.AllowAttacks = False

Edited by SKK50
Link to comment
Share on other sites

Happy to help. Can't describe the time and brain pain involved in figuring out that nested mess, its a suppressed memory now.

 

Lol I believe it!

 

For the base game settlement workshops, they always seem to index the the same order across new games but as I haven't found any relevant script it may not be consistent so always match to a hard REF property to be sure.

. . .

If your interested workshop attack status can be set remotely with WorkshopREF.AllowAttacks = False

Thank you again and again SKK50, and happy modding! :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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