Jump to content

Understanding dynamic array correctly


SMB92

Recommended Posts

 

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.

 

I tried to use in on actors. And while the script recieved some events ( like OnItemAdded ) , it could not obtain the actor reference("GetReference()" and "GetActorReference()" failed) and it also never recieved the "Oninit" event where you could register the script for some other events. The alias has no problems with getting filled. The problem only happens with the alias script.

Edited by kitcat81
Link to comment
Share on other sites

  • Replies 111
  • Created
  • Last Reply

Top Posters In This Topic

I don't know why it didn't work for you, but my ForceRefTo alias works with OnHit, OnInit or OnAliasInit(tested both) and OnDying events. Timers and EnterBleedOut etc work too.

 

I remember once when event didn't fire and it was OnDying() event. The actor was having some degen damage(bleed?)? And I fast traveled just before he died, then fast traveled back, he was dead but the event didnt fire. Since this script needed the alias to clear when actor dies, I simply made slow timer that check if the actor is dead every 30sec or so and clears it then if OnDying() didn't fire.. But like I said, that happened only once so far and I have play tested my mod a lot.

 

I even used AnotherAlias.GetReference() as Actor in OnInit event, without it working the whole script would not work, but I don't do that anymore. Now I just store it in the scripts property, another script fills this property since it doesn't need to change often. I do same for globals, they change but not often so they are not needed on every OnAliasInit() event, so now I just change them from another script when needed. It has worked so far with no problems.

 

 

edit: My bad, OnInit() and OnAliasInit() do NOT work with ForceRefTo().

Edited by vkz89q
Link to comment
Share on other sites

This is a part of the script that i`d change :
int iSpawnCounter = 0
int iPosition = 0 ; what is the point of this variable? I removed it
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)
Actor akSpawned = Self.PlaceActorAtMe(varBaseActor, Utility.RandomInt(1,iDifficulty), (MasterQuest as ASC_MasterRandomQuestScript).EzArray[iEzLevel]);Other way to do it, left for reference
GroupList.Add(akSpawned)
Then somewhere, where you need to remove packages from actors you can add :
If GroupList.Length > 0
int i = 0
While i < GroupList.Length
MyAlias.RemoveFromRef(GroupList)
GroupList.DeleteWhenAble()
Debug.Notification("Deleted index" + i) ; show the array index of deleted reference
i += 1
EndWhile
GroupList.Clear()
EndIf
Edited by kitcat81
Link to comment
Share on other sites

I don't know why it didn't work for you, but my ForceRefTo alias works with OnHit, OnInit or OnAliasInit(tested both) and OnDying events. Timers and EnterBleedOut etc work too.

 

I remember once when event didn't fire and it was OnDying() event. The actor was having some degen damage(bleed?)? And I fast traveled just before he died, then fast traveled back, he was dead but the event didnt fire. Since this script needed the alias to clear when actor dies, I simply made slow timer that check if the actor is dead every 30sec or so and clears it then if OnDying() didn't fire.. But like I said, that happened only once so far and I have play tested my mod a lot.

 

I even used AnotherAlias.GetReference() as Actor in OnInit event, without it working the whole script would not work, but I don't do that anymore. Now I just store it in the scripts property, another script fills this property since it doesn't need to change often. I do same for globals, they change but not often so they are not needed on every OnAliasInit() event, so now I just change them from another script when needed. It has worked so far with no problems.

When did you test it? Maybe they changed something since then. I had a magic effect that used ForceRefTo() function to apply alias to some settlers. i used it because the quest was "start game enabled" and should not have been restarted ever. And though the aliases were filled properly and packages +keywords did work, the script ( alias script) never recieved OnInit. It was attached to the actor and I could see it using ShowVars console command, but the script thought that it has no object bounds. GetReference () created an error in the log (something like can`t use GetReference on a none object).

Edited by kitcat81
Link to comment
Share on other sites

 

When did you test it? Maybe they changed something since then. I had a magic effect that used ForceRefTo() function to apply alias to some settlers. i used it because the quest was "start game enabled" and should not have been restarted ever. And though the aliases were filled properly and packages +keywords did work, the script ( alias script) never recieved OnInit. It was attached to the actor and I could see it using ShowVars console command, but the script thought that it has no object bounds. GetReference () created an error in the log (something like can`t use GetReference on a none object).

 

 

I use it all time testing my mod. Last time today.

 

But I just re-tested something and you are right. OnInit() and OnAliasInit() do not fire. The reason my script worked before was because OnInit() fired once so it get's the globals I needed and I used to restart the quest when the globals changed. But now I'm using ForceRefTo in another script, then calling function to check for the globals so no OnInit() is needed. It also used to GetReference() from alias that was already filled and never changed, so no problems there either.

 

Other events seem to fire fine and OnInit() but only once when quest is started. My bad.

 

So, when you call ForceRefTo() you also want to call function in your script.. like:

 

SomeAlias.ForceRefTo(someActor)

ScriptOfSomeAlias.DoFunctionThatImitatesOnInit()

Edited by vkz89q
Link to comment
Share on other sites

 

I use it all time testing my mod. Last time today.

 

But I just re-tested something and you are right. OnInit() and OnAliasInit() do not fire. The reason my script worked before was because OnInit() fired once so it get's the globals I needed and I used to restart the quest when the globals changed. But now I'm using ForceRefTo in another script, then calling function to check for the globals so no OnInit() is needed. It also used to GetReference() from alias that was already filled and never changed, so no problems there either.

 

Other events seem to fire fine and OnInit() but only once when quest is started. My bad.

 

So, when you call ForceRefTo() you also want to call function in your script.. like:

 

SomeAlias.ForceRefTo(someActor)

ScriptOfSomeAlias.DoFunctionThatImitatesOnInit()

 

I understand now , you just restarted the quest so it made the script fully functional . But without it, the sctipt would only recive some of the actor events and it would not be able to run functions on the actor. Without getting Oninit the script thinks it`s attached to nothing ( no game object bounds etc). But if you restart the quest each time you apply the alias to a new actor, it should work. It`s an option when the quest is not responsible for other important things and can be restarted at any time.

Edited by kitcat81
Link to comment
Share on other sites

Interesting stuff with these refaliases, no doubt I'll get around to testing them more and more in future. Suppose if i really had to or wanted to, i could place the base actor in a prefilled alias, cant recall if i seen a function that could remove that later though (think: uninstall)

 

Thanks for pointing that useless variable out kitcat. Maybe thats whats confusing things but i suspect thats not the problem. It should be adding to the array anyway, but its either adding nothing or garbaging the array instantly. I'll have a test of it.

Link to comment
Share on other sites

I'm not restarting the quest anymore. That was what I was doing. What I now do is call ForceRefTo and then call script function in that script that is attached to this actor I just used ForceRefTo.

 

The alias changes several times every combat and it all works flawless without restarting the quest. I do not restart the quest anymore, unless I toggle this feature off in the holotape.

 

I have 2 different scripts attached to this alias and I can see they work because they have things like casting magic effect, dismembering limbs etc attached to them.

 

If you want I can post a video of 1 alias handling all hit events in combat if you want. All without restarting quest.

Link to comment
Share on other sites

In my case all i would probably want it to do is receive OnKill and OnDying so i can increment a global float or script variable, aka the score. A quest would handle everything else.
Link to comment
Share on other sites

I'm not restarting the quest anymore. That was what I was doing. What I now do is call ForceRefTo and then call script function in that script that is attached to this actor I just used ForceRefTo.

 

The alias changes several times every combat and it all works flawless without restarting the quest. I do not restart the quest anymore, unless I toggle this feature off in the holotape.

 

I have 2 different scripts attached to this alias and I can see they work because they have things like casting magic effect, dismembering limbs etc attached to them.

 

If you want I can post a video of 1 alias handling all hit events in combat if you want. All without restarting quest.

 

I trust you . No need to post videos. And I got actor events too . But I could not run any functions on actors ( all errors were the same : can`t use getreference() on a none object). Though it was months ago so maybe something was fixed by Beth.

 

Sorry, wrong quate , deleted and replaced.

Edited by kitcat81
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...