Jump to content

Understanding dynamic array correctly


SMB92

Recommended Posts

Didn't see the edit til just now sorry. I'll have a play around with the CK, I see what they mean about special UI now from your video. Thanks for that.

Link to comment
Share on other sites

  • Replies 111
  • Created
  • Last Reply

Top Posters In This Topic

Is there a reliable way to get the struct/array from another script? I'm guessing no due to the lack of information about it. So if I put just this part of the code in say a quest and have my functions use them as if they were properties on themselves

Struct ActorTypeStruct
    ActorBase LvlActorBase
    ActorBase LvlActorBossBase
    GlobalVariable ASC_Allowed
    GlobalVariable ASC_Allowed_Boss
    GlobalVariable ASC_Max_Allowed
    GlobalVariable ASC_Max_Allowed_Boss
    GlobalVariable ASC_Chance
    GlobalVariable ASC_Chance_Boss
    GlobalVariable ASC_Reroll_Allowed
    GlobalVariable ASC_Reroll_Chance
EndStruct

ActorTypeStruct[] Property ActorTypes Auto Const

Anyway I'm really leaning on making this fully dynamic now, as in have the whole code on a quest, and have the code pick out a marker in the loaded area and run the script on it for a spawn. I really want to use this struct system, but filling the properties is gonna be hell especially with updates.

Link to comment
Share on other sites

Is there a reliable way to get the struct/array from another script? I'm guessing no due to the lack of information about it. So if I put just this part of the code in say a quest and have my functions use them as if they were properties on themselves

Struct ActorTypeStruct
    ActorBase LvlActorBase
    ActorBase LvlActorBossBase
    GlobalVariable ASC_Allowed
    GlobalVariable ASC_Allowed_Boss
    GlobalVariable ASC_Max_Allowed
    GlobalVariable ASC_Max_Allowed_Boss
    GlobalVariable ASC_Chance
    GlobalVariable ASC_Chance_Boss
    GlobalVariable ASC_Reroll_Allowed
    GlobalVariable ASC_Reroll_Chance
EndStruct

ActorTypeStruct[] Property ActorTypes Auto Const
Anyway I'm really leaning on making this fully dynamic now, as in have the whole code on a quest, and have the code pick out a marker in the loaded area and run the script on it for a spawn. I really want to use this struct system, but filling the properties is gonna be hell especially with updates.

 

I'm not sure I understand exactly what you're trying to do. But I'll throw this out there.

 

Bethesda shares a single struct definition with multiple scripts by making a single script with the definition then importing it in the others. You can see this done with WorkshopDataScript.psc (just the struct definitions). Then imported into scripts like WorkshopParent.psc and WorkshopObjectScript.psc. Import is powerful in some respects though so be cautious when using it. You can do things like Import Debug so you just type Trace("something") instead of Debug.Trace("something"). You can create havoc if you have conflicting function or event names. This is why Bethesda uses a separate script that only has struct definitions. This also allows them to re-use the same definitions between scripts.

 

See this for info. Although it's pretty sparse. http://www.creationkit.com/fallout4/index.php?title=Script_File_Structure#Imports

 

As for getting a struct/array from another script, this is where I'm confused. If you mean can you access the content data of an array that's in a script running on another object, then yes. If the data you want to access is a property on that script. You would reference the object, cast as the script, then identify the property. Something like this:

 

 

;this is in the script you want to access. lets say it's on an xmarker just for simplicity sake.
Scriptname SomeObjectScript extends ObjectReference
 
Actor[] Property SomeActors Auto Const
 
 
; This is how you'd access the SomeActors array from another script.
; you'll need to someone get the ObjectReference of the object (xmarker in this example) and set it. either from a property, using a find refs command, or some other means.
Debug.Trace("The array length is: " + (TheXmarker as SomeObjectScript).SomeActors.Length)

; you can get even more advanced if both scripts were on the same object, thus both extending ObjectReference. you can use self then.
;(self as SomeObjectScript).SomeActors

Most commonly a quest is used to house the master store of data. Then a script on that quest has an array, usually of some sort of structs. Depending on the use case that can vary.

 

Something that could be used to help with the issue of certain targets that would only spawn in some areas. Such as Fog Crawlers. You could make a couple of arrays. Like one that is only used in Commonwealth, another only for Far Harbor, and then one for Nuka-World. Or something like that. You may have some repetition between them, like normal raiders or deathclaws in CW and NW.

Edited by BigAndFlabby
Link to comment
Share on other sites

What I was thinking, if I had the struct and array on a quest script as the property, I would only need to set the property once, instead of on every instance of the script. And then each marker can look at those properties. Just like you mentioned above.

 

I'm having a hard time grasping how to get the script to get/look at the array out of the quest script though, I tried a few examples from other script but compiler will give me different sort of errors each time, mostly 'ActorTypes is not an array" and "cannot cast, types incompatible".

 

So the quest script is exactly as above:

 

 

Scriptname ASC_MasterRandomQuestScript extends Quest

Struct ActorTypeStruct
    ActorBase LvlActorBase
    ActorBase LvlActorBossBase
    GlobalVariable ASC_Allowed
    GlobalVariable ASC_Allowed_Boss
    GlobalVariable ASC_Max_Allowed
    GlobalVariable ASC_Max_Allowed_Boss
    GlobalVariable ASC_Chance
    GlobalVariable ASC_Chance_Boss
    GlobalVariable ASC_Reroll_Allowed
    GlobalVariable ASC_Reroll_Chance
EndStruct

ActorTypeStruct[] Property ActorTypes Auto Const

 

 

And then the rest on the code runs on the marker

 

 

Scriptname ASC_Random_R1 extends ObjectReference

Quest Property ASC_MasterRandomQuest Auto Const
GlobalVariable Property ASC_Main_ModEnabled Auto Const
GlobalVariable Property ASC_Main_RandomEnabled_R1 Auto Const
GlobalVariable Property ASC_Main_Random_Chance_R1 Auto Const
GlobalVariable Property ASC_Main_Random_DisableOnBlock_R1 Auto Const
FormList Property ASC_ResetList_R1 Auto Const
Actor Property PlayerRef Auto Const
ObjectReference Property PatrolMarker Auto Const
GlobalVariable Property ASC_Main_Difficulty_R1 Auto Const
GlobalVariable Property ASC_Reroll_Main_Chance_R1 Auto Const
GlobalVariable Property ASC_Reroll_Main_R1 Auto Const
GlobalVariable Property ASC_DeleteTimer_R1 Auto Const

bool Rerolled = false
Actor[] Grouplist

Function Spawn()
    int iNumSpawnTypes = ActorTypes.Length ; how many types of spawning actors can we support
    int iWhoToSpawn = Utility.RandomInt(1,iNumSpawnTypes) ; changed to use the size of our array of actor types
    ActorTypeStruct spawnDetails = ActorTypes[iWhoToSpawn]
    if (spawnDetails.ASC_Allowed.GetValueInt() == 1)
        SpawnEnemyActors(spawnDetails.ASC_Max_Allowed.GetValueInt(), spawnDetails.ASC_Chance.GetValueInt(), spawnDetails.LvlActorBase, spawnDetails.ASC_Allowed_Boss.GetValue() as Bool, spawnDetails.ASC_Max_Allowed_Boss.GetValueInt(), spawnDetails.ASC_Chance_Boss.GetValueInt(), spawnDetails.LvlActorBossBase)
    elseif (spawnDetails.ASC_Allowed.GetValueInt() == 0) && (spawnDetails.ASC_Reroll_Allowed.GetValueInt() == 1)
        RerollCheck(spawnDetails.ASC_Reroll_Chance.GetValueInt())
    ;else
        ; should there be something to handle a case where we're not allowed and have no reroll allowance? the way this is right now, if both were 0 then nothing would get spawned and the script stalls until the cell unloads and the spawn is called again on the new cell load.
    endif
EndFunction

Function SpawnEnemyActors(int iMaxSpawnCount, int iChance, ActorBase varBaseActor, bool bBossAllowed, int iMaxBossCount, int iBossChance, ActorBase varBossActor)
    int Difficulty = ASC_Main_Difficulty_R1.GetValueInt()
    int iSpawnCounter = iMaxSpawnCount
	int iPosition = 0
    bool bSpawnSuccess = false
    GroupList = new Actor[0] ; since we don't have 100% chance of spawning actors, we need this to be an accumulating array
    Debug.Notification("Spawning enemies") ; unless we add a function parameter for text this had to be changed to be something generic
        while (iSpawnCounter < iMaxSpawnCount)
            if (Utility.RandomInt(1,100) <= iChance)
                GroupList.Add(Self.PlaceActorAtMe(varBaseActor, Utility.RandomInt(1,Difficulty), None))
                iPosition = GroupList.Length - 1
                GroupList[iPosition].SetLinkedRef(PatrolMarker)
                Debug.Notification("Array Add Success. Actor count now: " + iPosition)
                bSpawnSuccess = True
            endif
            iSpawnCounter += 1
        endwhile
        if bBossAllowed == 1
            iSpawnCounter = 0 ; reuse var. memory efficient
            while (iSpawnCounter < iMaxBossCount)
                if (Utility.RandomInt(1,100) <= iBossChance)
                    GroupList.Add(Self.PlaceActorAtMe(varBossActor, Utility.RandomInt(1,Difficulty), None))
                    iPosition = GroupList.Length - 1
                    GroupList[iPosition].SetLinkedRef(PatrolMarker)
                    Debug.Notification("Array Add Success. Actor count now: " + iPosition)
                    bSpawnSuccess = True
                endif
                iSpawnCounter += 1
            endwhile
        endif
EndFunction

Function RerollCheck(int iRerollChance)
    if (Rerolled == false) && (Utility.RandomInt(1,100) <= iRerollChance)
        Spawn()
        Rerolled = true
        Debug.Notification("Rerolling after block")
    else
        Debug.Notification("Reroll on block denied")
    endif
EndFunction

 

 

 

I've removed the attempts at casting I tried, but left the quest as a property.

 

On a separate note, when I said above I was looking at having ALL the code run on a quest, I was thinking of having the script do a FindRandomRefOfType (or similar) and run the functions/placeatme on the marker it found. But this poses a limitation in that I'd need lots of arrays to track all the spawned groups, which would end up extremely messy or not possible.

 

If I can just point the script on the marker to the array of structs in the quest script, I can solve that problem and the hassle of filling millions of properties :). I do intend to have multiple arrays of the struct for locations like you said, if I can achieve this.

Link to comment
Share on other sites

What I was thinking, if I had the struct and array on a quest script as the property, I would only need to set the property once, instead of on every instance of the script. And then each marker can look at those properties. Just like you mentioned above.

 

I'm having a hard time grasping how to get the script to get/look at the array out of the quest script though, I tried a few examples from other script but compiler will give me different sort of errors each time, mostly 'ActorTypes is not an array" and "cannot cast, types incompatible".

 

So the quest script is exactly as above:

 

 

Scriptname ASC_MasterRandomQuestScript extends Quest

Struct ActorTypeStruct
    ActorBase LvlActorBase
    ActorBase LvlActorBossBase
    GlobalVariable ASC_Allowed
    GlobalVariable ASC_Allowed_Boss
    GlobalVariable ASC_Max_Allowed
    GlobalVariable ASC_Max_Allowed_Boss
    GlobalVariable ASC_Chance
    GlobalVariable ASC_Chance_Boss
    GlobalVariable ASC_Reroll_Allowed
    GlobalVariable ASC_Reroll_Chance
EndStruct

ActorTypeStruct[] Property ActorTypes Auto Const

 

And then the rest on the code runs on the marker

 

 

Scriptname ASC_Random_R1 extends ObjectReference

Quest Property ASC_MasterRandomQuest Auto Const
GlobalVariable Property ASC_Main_ModEnabled Auto Const
GlobalVariable Property ASC_Main_RandomEnabled_R1 Auto Const
GlobalVariable Property ASC_Main_Random_Chance_R1 Auto Const
GlobalVariable Property ASC_Main_Random_DisableOnBlock_R1 Auto Const
FormList Property ASC_ResetList_R1 Auto Const
Actor Property PlayerRef Auto Const
ObjectReference Property PatrolMarker Auto Const
GlobalVariable Property ASC_Main_Difficulty_R1 Auto Const
GlobalVariable Property ASC_Reroll_Main_Chance_R1 Auto Const
GlobalVariable Property ASC_Reroll_Main_R1 Auto Const
GlobalVariable Property ASC_DeleteTimer_R1 Auto Const

bool Rerolled = false
Actor[] Grouplist

Function Spawn()
    int iNumSpawnTypes = ActorTypes.Length ; how many types of spawning actors can we support
    int iWhoToSpawn = Utility.RandomInt(1,iNumSpawnTypes) ; changed to use the size of our array of actor types
    ActorTypeStruct spawnDetails = ActorTypes[iWhoToSpawn]
    if (spawnDetails.ASC_Allowed.GetValueInt() == 1)
        SpawnEnemyActors(spawnDetails.ASC_Max_Allowed.GetValueInt(), spawnDetails.ASC_Chance.GetValueInt(), spawnDetails.LvlActorBase, spawnDetails.ASC_Allowed_Boss.GetValue() as Bool, spawnDetails.ASC_Max_Allowed_Boss.GetValueInt(), spawnDetails.ASC_Chance_Boss.GetValueInt(), spawnDetails.LvlActorBossBase)
    elseif (spawnDetails.ASC_Allowed.GetValueInt() == 0) && (spawnDetails.ASC_Reroll_Allowed.GetValueInt() == 1)
        RerollCheck(spawnDetails.ASC_Reroll_Chance.GetValueInt())
    ;else
        ; should there be something to handle a case where we're not allowed and have no reroll allowance? the way this is right now, if both were 0 then nothing would get spawned and the script stalls until the cell unloads and the spawn is called again on the new cell load.
    endif
EndFunction

Function SpawnEnemyActors(int iMaxSpawnCount, int iChance, ActorBase varBaseActor, bool bBossAllowed, int iMaxBossCount, int iBossChance, ActorBase varBossActor)
    int Difficulty = ASC_Main_Difficulty_R1.GetValueInt()
    int iSpawnCounter = iMaxSpawnCount
	int iPosition = 0
    bool bSpawnSuccess = false
    GroupList = new Actor[0] ; since we don't have 100% chance of spawning actors, we need this to be an accumulating array
    Debug.Notification("Spawning enemies") ; unless we add a function parameter for text this had to be changed to be something generic
        while (iSpawnCounter < iMaxSpawnCount)
            if (Utility.RandomInt(1,100) <= iChance)
                GroupList.Add(Self.PlaceActorAtMe(varBaseActor, Utility.RandomInt(1,Difficulty), None))
                iPosition = GroupList.Length - 1
                GroupList[iPosition].SetLinkedRef(PatrolMarker)
                Debug.Notification("Array Add Success. Actor count now: " + iPosition)
                bSpawnSuccess = True
            endif
            iSpawnCounter += 1
        endwhile
        if bBossAllowed == 1
            iSpawnCounter = 0 ; reuse var. memory efficient
            while (iSpawnCounter < iMaxBossCount)
                if (Utility.RandomInt(1,100) <= iBossChance)
                    GroupList.Add(Self.PlaceActorAtMe(varBossActor, Utility.RandomInt(1,Difficulty), None))
                    iPosition = GroupList.Length - 1
                    GroupList[iPosition].SetLinkedRef(PatrolMarker)
                    Debug.Notification("Array Add Success. Actor count now: " + iPosition)
                    bSpawnSuccess = True
                endif
                iSpawnCounter += 1
            endwhile
        endif
EndFunction

Function RerollCheck(int iRerollChance)
    if (Rerolled == false) && (Utility.RandomInt(1,100) <= iRerollChance)
        Spawn()
        Rerolled = true
        Debug.Notification("Rerolling after block")
    else
        Debug.Notification("Reroll on block denied")
    endif
EndFunction

 

 

I've removed the attempts at casting I tried, but left the quest as a property.

 

On a separate note, when I said above I was looking at having ALL the code run on a quest, I was thinking of having the script do a FindRandomRefOfType (or similar) and run the functions/placeatme on the marker it found. But this poses a limitation in that I'd need lots of arrays to track all the spawned groups, which would end up extremely messy or not possible.

 

If I can just point the script on the marker to the array of structs in the quest script, I can solve that problem and the hassle of filling millions of properties :smile:. I do intend to have multiple arrays of the struct for locations like you said, if I can achieve this.

 

Modify your ASC_Random_R1 to look like:

Scriptname ASC_Random_R1 extends ObjectReference

import ASC_MasterRandomQuestScript

;then rest of script
Then the struct type is available for use in ASC_Random_R1. I'm not sure how it's going to react to the array property though. It might create a second array property in ASC_Random_R1. If you open the properties on the marker and see the array then it did.

 

Then every occurance of "ActorTypes" in ASC_Random_R1 will be changed to "(ASC_MasterRandomQuest as ASC_MasterRandomQuestScript).ActorTypes". So the Spawn() function will look like this:

Function Spawn()
    int iNumSpawnTypes = (ASC_MasterRandomQuest as ASC_MasterRandomQuestScript).ActorTypes.Length ; how many types of spawning actors can we support
    int iWhoToSpawn = Utility.RandomInt(1,iNumSpawnTypes) ; changed to use the size of our array of actor types
    ActorTypestruct spawnDetails = (ASC_MasterRandomQuest as ASC_MasterRandomQuestScript).ActorTypes[iWhoToSpawn]
    if (spawnDetails.ASC_Allowed.GetValueInt() == 1)
        SpawnEnemyActors(spawnDetails.ASC_Max_Allowed.GetValueInt(), spawnDetails.ASC_Chance.GetValueInt(), spawnDetails.LvlActorBase, spawnDetails.ASC_Allowed_Boss.GetValue() as Bool, spawnDetails.ASC_Max_Allowed_Boss.GetValueInt(), spawnDetails.ASC_Chance_Boss.GetValueInt(), spawnDetails.LvlActorBossBase)
    elseif (spawnDetails.ASC_Allowed.GetValueInt() == 0) && (spawnDetails.ASC_Reroll_Allowed.GetValueInt() == 1)
        RerollCheck(spawnDetails.ASC_Reroll_Chance.GetValueInt())
    ;else
        ; should there be something to handle a case where we're not allowed and have no reroll allowance? the way this is right now, if both were 0 then nothing would get spawned and the script stalls until the cell unloads and the spawn is called again on the new cell load.
    endif
EndFunction
Since ActorTypeStruct is imported to the local script we don't have to cast that to define spawnDetails.
Link to comment
Share on other sites

One thing I didn't try yet is using another marker with just the arrays/struct on it script and using that. From what I can tell using a quest is better though.

I'll look at using an object now just for fun.

 

EDIT: just saw your post.

Link to comment
Share on other sites

Interesting, I was doing it right then to begin with....

 

However I still get a compiler error, (type mismatch while assigning to a asc_masterrandomquestscript#actortypestruct (cast missing or types unrelated)) when the code looks like this:

 

 

 

Scriptname ASC_Random extends ObjectReference

import ASC_MasterRandomQuestScript

Quest Property ASC_MasterRandomQuest Auto Const
GlobalVariable Property ASC_Main_ModEnabled Auto Const
GlobalVariable Property ASC_Main_RandomEnabled_R1 Auto Const
GlobalVariable Property ASC_Main_Random_Chance_R1 Auto Const
GlobalVariable Property ASC_Main_Random_DisableOnBlock_R1 Auto Const
FormList Property ASC_ResetList_R1 Auto Const
Actor Property PlayerRef Auto Const
ObjectReference Property PatrolMarker Auto Const
GlobalVariable Property ASC_Main_Difficulty_R1 Auto Const
GlobalVariable Property ASC_Reroll_Main_Chance_R1 Auto Const
GlobalVariable Property ASC_Reroll_Main_R1 Auto Const
GlobalVariable Property ASC_DeleteTimer_R1 Auto Const

bool Rerolled = false
Actor[] Grouplist

Function Spawn()
    int iNumSpawnTypes = (ASC_MasterRandomQuest as ASC_MasterRandomQuestScript).ActorTypes.Length ; how many types of spawning actors can we support
    int iWhoToSpawn = Utility.RandomInt(1,iNumSpawnTypes) ; changed to use the size of our array of actor types
    ActorTypeStruct spawnDetails = (ASC_MasterRandomQuest as ASC_MasterRandomQuestScript).ActorTypes.Length
    if (spawnDetails.ASC_Allowed.GetValueInt() == 1)
        SpawnEnemyActors(spawnDetails.ASC_Max_Allowed.GetValueInt(), spawnDetails.ASC_Chance.GetValueInt(), spawnDetails.LvlActorBase, spawnDetails.ASC_Allowed_Boss.GetValue() as Bool, spawnDetails.ASC_Max_Allowed_Boss.GetValueInt(), spawnDetails.ASC_Chance_Boss.GetValueInt(), spawnDetails.LvlActorBossBase)
    elseif (spawnDetails.ASC_Allowed.GetValueInt() == 0) && (spawnDetails.ASC_Reroll_Allowed.GetValueInt() == 1)
        RerollCheck(spawnDetails.ASC_Reroll_Chance.GetValueInt())
    ;else
        ; should there be something to handle a case where we're not allowed and have no reroll allowance? the way this is right now, if both were 0 then nothing would get spawned and the script stalls until the cell unloads and the spawn is called again on the new cell load.
    endif
EndFunction

Function SpawnEnemyActors(int iMaxSpawnCount, int iChance, ActorBase varBaseActor, bool bBossAllowed, int iMaxBossCount, int iBossChance, ActorBase varBossActor)
    int Difficulty = ASC_Main_Difficulty_R1.GetValueInt()
    int iSpawnCounter = iMaxSpawnCount
	int iPosition = 0
    bool bSpawnSuccess = false
    GroupList = new Actor[0] ; since we don't have 100% chance of spawning actors, we need this to be an accumulating array
    Debug.Notification("Spawning enemies") ; unless we add a function parameter for text this had to be changed to be something generic
        while (iSpawnCounter < iMaxSpawnCount)
            if (Utility.RandomInt(1,100) <= iChance)
                GroupList.Add(Self.PlaceActorAtMe(varBaseActor, Utility.RandomInt(1,Difficulty), None))
                iPosition = GroupList.Length - 1
                GroupList[iPosition].SetLinkedRef(PatrolMarker)
                Debug.Notification("Array Add Success. Actor count now: " + iPosition)
                bSpawnSuccess = True
            endif
            iSpawnCounter += 1
        endwhile
        if bBossAllowed == 1
            iSpawnCounter = 0 ; reuse var. memory efficient
            while (iSpawnCounter < iMaxBossCount)
                if (Utility.RandomInt(1,100) <= iBossChance)
                    GroupList.Add(Self.PlaceActorAtMe(varBossActor, Utility.RandomInt(1,Difficulty), None))
                    iPosition = GroupList.Length - 1
                    GroupList[iPosition].SetLinkedRef(PatrolMarker)
                    Debug.Notification("Array Add Success. Actor count now: " + iPosition)
                    bSpawnSuccess = True
                endif
                iSpawnCounter += 1
            endwhile
        endif
EndFunction

Function RerollCheck(int iRerollChance)
    if (Rerolled == false) && (Utility.RandomInt(1,100) <= iRerollChance)
        Spawn()
        Rerolled = true
        Debug.Notification("Rerolling after block")
    else
        Debug.Notification("Reroll on block denied")
    endif
EndFunction

 

 

 

If I remove the Quest property, I get the compiler error ActorTypes is not an array/ActorTypes is undefined (thats with import still there)

 

Just to note, the ASC_MasterRandomQuest is setup and it's script compiled and ready to go, just in case that could have been a possible cause.

Link to comment
Share on other sites

Well regardless of it not compiling, the array showed up on the object script as a property like you suggested, thus defeating the purpose of the whole endeavor to avoid manually filling all the properties.

 

Unless there is some way to copy the array from the quest script to a new one in the marker script, but even then performance would be of concern

 

I'm not sure what else to do other than not use a struct all so I can use autofill, but even then it's gonna be a pain in the ass to deal with.

 

I guess this is why programmers are on the big bucks

Link to comment
Share on other sites

I suggest that you copy the error from the compiler. It would be easier to find the line .

 

I don`t know what you are trying to do and why but your quest script does not have any return functions. To obtain any value/variable/property from another script, you need to define a funcion in the quest script .

Then you can run the function from another scripts.

For example :

Var Function GetActor()

Return MyActor as Var ; MyActor is a property or a variable that is defined in the script

EndFunction

 

Int Function GetNumber()

Return MyNumber ; Int MyNumber must be defined in the script

EndFunction

 

Not sure that it`s possible to create a function that returns an array....It requires some experiments.

Link to comment
Share on other sites

I suggest that you copy the error from the compiler. It would be easier to find the line .

 

I don`t know what you are trying to do and why but your quest script does not have any return functions. To obtain any value/variable/property from another script, you need to define a funcion in the quest script .

Then you can run the function from another scripts.

For example :

Var Function GetActor()

Return MyActor as Var ; MyActor is a property or a variable that is defined in the script

EndFunction

 

Int Function GetNumber()

Return MyNumber ; Int MyNumber must be defined in the script

EndFunction

 

Not sure that it`s possible to create a function that returns an array....It requires some experiments.

The way he's got it setup right now is kind of like a remote storage. The quest script doesn't do anything except have properties to remotely access. In practice it's probably good to put the get random function in that script and just have the remote script call it to get a value to play with. That's really only an important issue if multi-threading becomes a case where values are being added and removed. Then things can get out of sync and race conditions occur.

 

Returning an Actor as Var seems counter productive since you'd just have to cast back. And you could return an array.

 

Well regardless of it not compiling, the array showed up on the object script as a property like you suggested, thus defeating the purpose of the whole endeavor to avoid manually filling all the properties.

 

Unless there is some way to copy the array from the quest script to a new one in the marker script, but even then performance would be of concern

 

I'm not sure what else to do other than not use a struct all so I can use autofill, but even then it's gonna be a pain in the ass to deal with.

 

I guess this is why programmers are on the big bucks

 

Use the struct. But move the struct to its own file. Then put an import in ASC_Random and ASC_MasterRandomQuestScript pointing to the struct only file. And remove the import from ASC_Random pointing to ASC_MasterRandomQuestScript. You leave the array in ASC_MasterRandomQuestScript and then it won't show up in ASC_Random.

 

There's a few ways to make the new script. I use an external editor so my preferred method is to just use the Papyrus Script Manager in CK. Goto the Gameplay menu and choose the Papyrus Script Manager. It may take some time to load. Then right click in the manager window and choose new. Name it whatever you want and don't extend anything. Then double click it and it should open in the external editor. Put the struct in that and remove it from ASC_MasterRandomQuestScript .

 

If you're not using an external editor (you should) then pick any object and add a script. Choose new and do the same. Then open for editing and put the struct in that and remove it from ASC_MasterRandomQuestScript.

 

So now you would have ASC_MasterRandomQuestScript with just the first line script definition, and import, and the array property. Seems like a waste but maybe you have plans to expand it further later.

 

Incase it's not clear why to use an external editor here's a comparison.

 

 

 

Edited by BigAndFlabby
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...