Jump to content

Understanding dynamic array correctly


SMB92

Recommended Posts

Quest alias packages only work while the actor is in the alias. When they are out of the alias, all "stuff" from quest alias is lost.

 

That's why I love quests myself, I can do how many I want, I can turn them on/off when I want, I can have one quest to give actor some keyword/package/faction/etc etc and turn it off whenever I want. Updating is easy just turn off quests and turn them back on and even totally modified scripts are updated. Even uninstalling is easy, just turn off all the quests and disable/delete every alias.

 

It's pretty easy to make good patrol/travel packages just using stuff ingame already, you can have already existing Xmarkers as destinations for example.

 

What you could do with your system: You could have each spawnpoint have their own keyword that they add to the actors that they spawn, then you could start quest after they are spawned, finding matching reference and looking for actors that have your keyword. That way you could have own quest for each "spawn area" and then the quest alias(collection alias?) would have packages. Or, instead of starting/stopping the quest all time to fill aliases, there propably is function to add the actor to RefCollectionAlias in quest that is already running. You could also remove them from the alias in OnDying event in the alias, and mark them for delete etc..

 

But, honestly, I think just using quest for everything is super smooth. I'm not saying there's anything wrong in your system, actually I like it.. it's just a personal preference for quests, lol. I know in the other hand that some people absolutely hate quests and they do have their own problems too, like sometimes for no real reason, alias not filling or quest not starting etc.

 

Just throwing out ideas. Waiting to see your new system in action :smile:

Edited by vkz89q
Link to comment
Share on other sites

  • Replies 111
  • Created
  • Last Reply

Top Posters In This Topic

  On 5/29/2017 at 12:45 PM, SMB92 said:

Another thing that crosses my mind here, seems the OnCellAttach/detach works within the ugrids range, I have not implemented anything in the case that you happen to "pass by" a cell very quickly. I think in WOTC, a lot of CTDs happen when the player moves across a lot of cells and the script isn't keeping up, and by the time it elects a place to MoveTo the spawned actors, they're out of the loaded area (probably why I see up to 5 "could not find navmesh with MoveToNearestNavmeshLocation function before most regular crashes). I think my script is a bit faster though and from what I can see (given I don't intend on having any more than 2 points per cell mostly) it will be finished before that could happen. Just thoughts based on what I have seen anyway

 

 

On an entirely separate note, it's in the back of my head that if I set up a patrol marker network, this will be persistent. I wanted to set it up so that other modders could also use it, a bit of a convenience feature, as well as to address the problem that WOTC sees with it's patrol AI packages and the fact I don't want to modify/have too many custom ActorBases/LvlNPCs (for cross compatibility). But for shiz and giggles I was looking at how it could be possible to dynamically give each NPC a "patrol" package. Apparently the only way to do this is ForceRefTo() a reference alias and assign the package (maybe having to force with EvaluatePackage()). I wonder though, if I had a single Ref Alias on the quest, and I kept forcing NPCs in and out of it and assigning them the package, would that work for the way things are set up (possibly multiple "spawnpoints" sending NPCs to the RefAlias, will they keep package after they are out of it, how to remove the very last NPC fro mthe RefAlias when they've all been through etc etc)

 

Just reading that back to myself, I'll stay with the patrol marker network lol. Just curious how far I can "rev the engine" lol. On that note, I kinda thought of a way to make them non-persistent using an uninstall script. If my whole network is linked from one end of the CW to another, I could do some code that specifically starts at one of them, and keeps getting the next linked ref and setting it to none. Until they are all unlinked in that savegame, so users can have peace of mind. Suppose that would take some very careful placement though, but hey at least I think this way :smile:

 

To give npc a package you can also apply an alias to the npc. It`s not the same as "ForceRefTo". There is a function "ApplyToRef" and "RemoveFromRef". It allows to apply alias data ( keywords, packages, factions) to multiple npc without filling the alias( means you can use 1 Reference Alias for all your npc in the same time). To do this you need to check "can be applied to non aliased refs" in the alias file. The only thing about this is that applying the data does not make the npc persistent and the data can be auto removed on unload sometimes.

Edited by kitcat81
Link to comment
Share on other sites

  On 5/29/2017 at 12:45 PM, SMB92 said:

Another thing that crosses my mind here, seems the OnCellAttach/detach works within the ugrids range, I have not implemented anything in the case that you happen to "pass by" a cell very quickly. I think in WOTC, a lot of CTDs happen when the player moves across a lot of cells and the script isn't keeping up, and by the time it elects a place to MoveTo the spawned actors, they're out of the loaded area (probably why I see up to 5 "could not find navmesh with MoveToNearestNavmeshLocation function before most regular crashes). I think my script is a bit faster though and from what I can see (given I don't intend on having any more than 2 points per cell mostly) it will be finished before that could happen. Just thoughts based on what I have seen anyway

 

 

 

I can think of a mod that might cause that, drive-able motorcycles. Especially if you have the throttle going and you're moving fast. I know I can move faster than the objects can load. For example, I can get to the Diamond City gate for the first time when meeting Piper and the gate and her haven't loaded yet and it takes a couple of seconds for them to appear.

 

So when traveling fast enough via the mod, a player might be able to cross several grids much faster than would otherwise be possible.

 

Just thought I'd mention that as that could cause an issue from what you're saying.

Edited by TheCourier13
Link to comment
Share on other sites

  Quote

 

Quest alias packages only work while the actor is in the alias. When they are out of the alias, all "stuff" from quest alias is lost.

That's why I love quests myself, I can do how many I want, I can turn them on/off when I want, I can have one quest to give actor some keyword/package/faction/etc etc and turn it off whenever I want. Updating is easy just turn off quests and turn them back on and even totally modified scripts are updated. Even uninstalling is easy, just turn off all the quests and disable/delete every alias.
It's pretty easy to make good patrol/travel packages just using stuff ingame already, you can have already existing Xmarkers as destinations for example.
What you could do with your system: You could have each spawnpoint have their own keyword that they add to the actors that they spawn, then you could start quest after they are spawned, finding matching reference and looking for actors that have your keyword. That way you could have own quest for each "spawn area" and then the quest alias(collection alias?) would have packages. Or, instead of starting/stopping the quest all time to fill aliases, there propably is function to add the actor to RefCollectionAlias in quest that is already running. You could also remove them from the alias in OnDying event in the alias, and mark them for delete etc..
But, honestly, I think just using quest for everything is super smooth. I'm not saying there's anything wrong in your system, actually I like it.. it's just a personal preference for quests, lol. I know in the other hand that some people absolutely hate quests and they do have their own problems too, like sometimes for no real reason, alias not filling or quest not starting etc.
Just throwing out ideas. Waiting to see your new system in action :smile:

Thanks for following the thread :). Personally I quite like it the way it is. But I guess one reason for that is I haven't fully figured out how to run the function from the quest on the marker properly :D. But I still just like it how it is anyway :P. You could say I like a mix of the Quest + script. The quest now contains all the timers and Formlist events, first install stages and uninstall stages as well, and I am thinking to dynamically fill the array of structs now if that's possible (to achieve only having what's allowed to spawn to be present there). I also like being able to copy and replace in the marker script, for variations etc.

 

  Quote

 

To give npc a package you can also apply an alias to the npc. It`s not the same as "ForceRefTo". There is a function "ApplyToRef" and "RemoveFromRef". It allows to apply alias data ( keywords, packages, factions) to multiple npc without filling the alias( means you can use 1 Reference Alias for all your npc in the same time). To do this you need to check "can be applied to non aliased refs" in the alias file. The only thing about this is that applying the data does not make the npc persistent and the data can be auto removed on unload sometimes.

 

That is perfect. I'll look into it asap. If this works I can just assign them on spawn like the way they get linked to a patrol marker and unlinked on unload.

Link to comment
Share on other sites

  On 5/29/2017 at 11:24 PM, TheCourier13 said:

 

  On 5/29/2017 at 12:45 PM, SMB92 said:

Another thing that crosses my mind here, seems the OnCellAttach/detach works within the ugrids range, I have not implemented anything in the case that you happen to "pass by" a cell very quickly. I think in WOTC, a lot of CTDs happen when the player moves across a lot of cells and the script isn't keeping up, and by the time it elects a place to MoveTo the spawned actors, they're out of the loaded area (probably why I see up to 5 "could not find navmesh with MoveToNearestNavmeshLocation function before most regular crashes). I think my script is a bit faster though and from what I can see (given I don't intend on having any more than 2 points per cell mostly) it will be finished before that could happen. Just thoughts based on what I have seen anyway

 

 

 

I can think of a mod that might cause that, drive-able motorcycles. Especially if you have the throttle going and you're moving fast. I know I can move faster than the objects can load. For example, I can get to the Diamond City gate for the first time when meeting Piper and the gate and her haven't loaded yet and it takes a couple of seconds for them to appear.

 

So when traveling fast enough via the mod, a player might be able to cross several grids much faster than would otherwise be possible.

 

Just thought I'd mention that as that could cause an issue from what you're saying.

 

This is a good point in a sense, but I won't be accommodating for this kind of thing :D. I wouldn't use it myself, vanilla would probably crash with it (I have tried the mod though). I will look at failsafes for when players are in Vertibirds however, that is a big one from WOTC people had a problem with (and there are some vanilla random spawns, believe it or not)

 

I'm excited about this ApplyToRef() function kitcat81 mentioned, I'd like to see what I can do that

Link to comment
Share on other sites

So as it would be, the "accumating array" is not working at all. I cannot for the life of me see why though. The Debug Note always returns iPosition as -1 after every spawn, even though actors are spawning just fine. Therefore, cleanup function does nothing either. I've tried both the Add function originally and casting it in but results are identical. I'm not sure what to do right now, this is a fundamental flaw in the mod if these spawned actors cannot be applied to the arrays

 

This would have been the final version of the script:

 

  Reveal hidden contents

 

Link to comment
Share on other sites

Okay so thanks to BigandFlabby again, I've moved over to the dynamic struct/array of structs. However the same problem remains as my last post with the SpawnEnemyActors function. It seems to me that if the first actor fails to spawn, they all do, and if the first is a success, it spawns the maximum amount. Sometimes the debug note says that it's size (iPosition) is -1, sometimes 0. When it says -1, there is usually 4 base actors there or 1 boss. Or nothing. So far, there has never been anything when it reports the size as 0. Wtf.

 

Here would be the "dynamic" versions of the scripts (above has the array of structs as a full property)

 

Quest

 

  Reveal hidden contents

 

Spawnpoint object:

 

  Reveal hidden contents

 

 

Edit: I am also looking at another angle here, I'm thinking of ditching the arrays on the object altogether and the cleanup OnCellDetach event, in favor of applying a script to each actor via a referencealias that may be able to clean them up and track them better. One upside to that I'm considering is tracking their killers, so I can make a score system.

 

So in theory

 

-Marker script spawns the actor and we give it the refalias data via ApplyToRef() on it (scripts and AI)

-Scripts in the refalias include events for OnCellDetach or similar that will clean up the actor etc + OnCellAttach event to keep him loaded

-Script has OnKill or OnDeath event that each kill they get in a region up their "regional score"

-(Potentially if user enables this system), different actor types chances to spawn goes up or down depending on the score and maybe we could have an event happen where when the score gets high a special boss = group spawns that you battle it out with, and whoever wins claims the area (so all scores are reset)

 

Something along those lines anyway :wink:

Link to comment
Share on other sites

"ApplyToRef" won`t work for a script. It will add the script, but the script won`t work properly. The only way to add a working alias script is to make aliases filled on quest start. It won`t properly work with "ForceRefTo" either.

 

Maybe you can highlight that part of the script that does not work. It takes to long to find the part :wink: I think you would get more help.

 

You have so many different values there that it`s hard to find out where is the error. What the papyrus log says ?

I`ll just give you a simple example of an array that stores object references (it`s just simplified functions from the vanilla workshopobjectscript ):

 

Function CreateFurnitureMarkers() ; Function runs when we assign a new actor to the object
If myFurnitureBase ; if we have filled MyFurnitureBase property in the CK
ObjectReference newMarker = PlaceAtMe(myFurnitureBase)
myFurnitureMarkerRefs.Add(newMarker) ; an array defined outside of any function or event (ObjectReference[] myFurnitureMarkerRefs)
newMarker.MoveToNearestNavmeshLocation()
endFunction

 

Function DeleteFurnitureMarkers()

If myFurnitureMarkerRefs.Length > 0 ; if we do have any markers
int i = 0
While i < myFurnitureMarkerRefs.Length
myFurnitureMarkerRefs.SetActorRefOwner(none)
myFurnitureMarkerRefs.Delete()
i += 1
EndWhile
myFurnitureMarkerRefs.Clear()
EndIf
endFunction

 

Function HideMarkers()
int i = 0
int size = myFurnitureMarkerRefs.Length
While i < size
myFurnitureMarkerRefs.Disable()
i += 1
EndWhile
endFunction

Edited by kitcat81
Link to comment
Share on other sites

Ah i kinda suspected that might be the case with the refsliases, what a shame.

 

Its the SpawnEnemyActors function on the Object script. Its not filling the array at all.

 

Log is empty, nothing about anything in the mod at all. Seems very strange to me.

Link to comment
Share on other sites

  On 6/3/2017 at 1:07 PM, kitcat81 said:

The only way to add a working alias script is to make aliases filled on quest start. It won`t properly work with "ForceRefTo" either.

 

 

What makes you think that? I use forcerefto a lot and never had any problems. I use it on actors, doors, terminals, weapons, etc etc and not even once they failed to fill or had any problems with scripts. When I need to store variables I store them in properties so no problem there either.

 

Only issue I know with ForceRefTo is if you use it on actor on a scene that is running package, if you too it several times a row (more than once per second), it can mess up actors scene package.

Edited by vkz89q
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...