Jump to content

Reset timer for tiny actor spawn script in trigger


Recommended Posts

That's why I wrote tibits on how most of the lines operate. For arrays which is obviously advanced, I needed them because I remembered that PlaceAtMe only returns the last reference created, so I needed to store each reference to an index. Otherwise you'd have 4 of the 5 references you can't delete at run time. I probably should have taken a much more beginner friendly approach, but always when handling multiple references, I run to arrays to save my butt XD.

Looking at it, it doesn't do exactly what you want(I realized I send the script back to the DefaultState each time the Update runs, meaning it wont happen again until the player walks back through it) but you can make changes.

Also will stress again that this is in game time. 10 minutes game time is much shorter than you think relative to real time. You may want to go a little higher if 10min isn't to your liking.

Edited by Lisselli
Link to comment
Share on other sites

All my timing is up in the air anyhow, so that's just fine. =)

Mostly just there now to remind myself that I had intednddd to have timers, heh. Will for sure need to be tested...if they remain in at all.

 

If, ultimately, they have to spawn all at once instead of x sets of x amount each time it's entered, then so be it. You 2 are getting me closer than I would have on my own, even if I could recall anything useful on my own (after seeing this, I'm sure of that). =)

The big thing is getting it not work every time you enter it, but only work once then be dormant (even if entered) for x amount of time before being able to be activated again when entered.

Otherwise, end up with "player walks through and activates, then backs up and activates again,then player overwhelmed, then player dead, then player plays no more mods by mod author Blah (me)". =P

 

Hopefully I get some time tonight to try it out.

 

Note: This all started from a friend of mine asking about vanilla REtrigger and the vanilla random encounter quests. I looked at those and saw so much excess hoohaw, that I decided to do what I could with scripts on my own and then came here to get farther.

Link to comment
Share on other sites

Compiling "ASmallAdditionSpawnPointNew001"...
C:\Users\%username%\AppData\Local\Temp\PapyrusTemp\ASmallAdditionSpawnPointNew001.psc(30,12): RegisterForSingleUpdateGameTime is not a function or does not exist
C:\Users\%username%\AppData\Local\Temp\PapyrusTemp\ASmallAdditionSpawnPointNew001.psc(43,0): new event onupdategametime cannot be defined because the script is not flagged as native
No output generated for ASmallAdditionSpawnPointNew001, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on ASmallAdditionSpawnPointNew001

...clearly I'm not understanding something...=(

 

Maybe this is what's confusing me since this is a recent change...:

from Differences_from_Skyrim_to_Fallout_4

Native Scripts:

Scripts can now be flagged as "Native" by adding it to the end of the Scriptname line. Scripts flagged as such are expected to be a script the game itself knows about and are the only scripts allowed to have new events defined in them. They also are not allowed to have states, variables, or auto properties. Modders should not need to make any native scripts and the flag is added mostly to improve error reporting from the compiler and prevent mistakes.
Link to comment
Share on other sites

Well I fooled around and got it to compile, but broke it functionally. =/

Spawned on triggerenter and just kept on spawning until crash...=(

 

Fully admit at this point, I don't know what the hell I'm doing. Complete ignorance.

Scriptname ASmallAdditionSpawnPointNew001 extends ObjectReference


ActorBase property ActorToSpawn auto


ObjectReference property SpawnPlace auto
ObjectReference property SpawnPlace1 auto
ObjectReference property SpawnPlace2 auto
ObjectReference property SpawnPlace3 auto
ObjectReference property SpawnPlace4 auto


Form kActorRef
Actor[] CreatedActors


Event OnInit()
CreatedActors = new Actor[5]
kActorRef = ActorToSpawn as form


EndEvent


; Ill use this to track how many times the update has run.
Int iTimesUpdateRan


; When needing a trigger to do different things, always start the first thing you want it to do in the auto state.
AUTO STATE DefaultState
    Event OnTriggerEnter(ObjectReference akActionRef)
        if akActionRef == Game.GetPlayer()
            ; Player has walked through me. Turn myself off.
            GoToState("Waiting")
            ; Have Update handle my spawning.
            StartTimer(120) ; 2 minutes.
            ; Note this is in Game Time, not Real time.
        endif
    EndEvent
ENDSTATE
    
STATE Waiting
    ; Dont need to add anything in the Event. Its to block the trigger.
    Event OnTriggerEnter(ObjectReference akActionRef)
    ; empty event is thrown out by the game engine.
    EndEvent
ENDSTATE


Event OnBeginState(string asDefaultState)
    GoToState("DefaultState")
    if iTimesUpdateRan == 0
        ; We're going to spawn our first actor.'
        SpawnPlace.PlaceAtMe(kActorRef)
        iTimesUpdateRan += 1
        CreatedActors[0] = kActorRef as Actor
    elseif iTimesUpdateRan == 1
        SpawnPlace1.PlaceAtMe(kActorRef)
        iTimesUpdateRan += 1
        CreatedActors[1] = kActorRef as Actor
    elseif iTimesUpdateRan == 2
        SpawnPlace2.PlaceAtMe(kActorRef)
        iTimesUpdateRan += 1
        CreatedActors[2] = kActorRef as Actor
    elseif iTimesUpdateRan == 3
        SpawnPlace3.PlaceAtMe(kActorRef)
        iTimesUpdateRan += 1
        CreatedActors[3] = kActorRef as Actor
    elseif iTimesUpdateRan == 4
        SpawnPlace4.PlaceAtMe(kActorRef)
        CreatedActors[4] = kActorRef as Actor
        ; All spawns have been placed. Disable this trigger for good.
        GoToState("Waiting")
    endif
        
EndEvent


Function DeleteCreatedActors()
    ; Stores the amount of indexs in this array.
    Int Index = CreatedActors.Length
        
    While Index
        ; Loop until it reaches the first element.
        Index -= 1
        
        ; We need to disable the actors.
        CreatedActors[Index].Disable()
        
        ; Now we delet them.
        CreatedActors[Index].Delete()
    EndWhile
EndFunction
Link to comment
Share on other sites

Started over again with simpler script to see if I could improve my understanding.

Now, I understand this is horribly poorly optimized and problematic (with a long Wait, since it will be at least a couple of hours), but I'm just not getting anywhere with either of your scripts. =(

States and arrays seem to be outside of my grasp with my limited time to research and, as far as I can tell, registerforupdate just plain doesn't exist as an option for non-native Fallout 4 creation kit scripts.

Scriptname ASmallAdditionSpawnPointNew001 extends ObjectReference


ActorBase property ActorToSpawn auto


ObjectReference property SpawnPlace0 auto
ObjectReference property SpawnPlace1 auto
ObjectReference property SpawnPlace2 auto
ObjectReference property SpawnPlace3 auto
ObjectReference property SpawnPlace4 auto


Actor Property PlayerREF Auto


Event Ontriggerenter(ObjectReference akActionRef)
If akActionRef == PlayerREF
 SpawnPlace0.PlaceActorAtMe(ActorToSpawn, 0)
 SpawnPlace0.PlaceActorAtMe(ActorToSpawn, 0)
  Utility.Wait(2)
 SpawnPlace1.PlaceActorAtMe(ActorToSpawn, 0)
 SpawnPlace1.PlaceActorAtMe(ActorToSpawn, 0)
  Utility.Wait(2)
 SpawnPlace2.PlaceActorAtMe(ActorToSpawn, 0)
  Utility.Wait(2)
 SpawnPlace3.PlaceActorAtMe(ActorToSpawn, 0)
  Utility.Wait(2)
 SpawnPlace4.PlaceActorAtMe(ActorToSpawn, 0)
EndIf
EndEvent


Event OnTriggerLeave(ObjectReference akActionRef)
Self.Disable()
Utility.Wait(60)
Enable()
EndEvent

If either of you (or anyone else) can get either of the fancy ones working, I'm all for it.

But, as said, I'm not having any luck with them. =/

Link to comment
Share on other sites

  • Recently Browsing   0 members

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