Jump to content

scripting / timer issue


bjornl

Recommended Posts

I have a timed events issue which seems simple but I have tried multiple approaches and have not been able solve it.


What I am trying to do.


Based on a conversation with an NPC, do the following:


play a sound file

do something once the sound file is complete

disable the NPC


I have tried various things without success.






Any scripting guru's with tips on how to do this?


Link to comment
Share on other sites

Attach this script to your NPC, and change the words before my comments that correspond to you (e.g. PlaySound, Player.AddItem, NPCXXX.Disable)

 

This should work, at least it does in my head. Post back if it did.

SCN XXX                                 ;Change XXX to something like CustomNPCScriptSCPT

short doOnce
short fTimerStarted
short iStage
float fTimer

Begin SayToDone NPCTOPIC                ;Change the topic name to your npcs topic

    if (doOnce == 0)
        Set fTimerStarted to 1
        Set doOnce to 1
    endif

End


Begin GameMode

    if (fTimerStarted == 1)
        if (fTimer > 0)
            Set fTimer to (fTimer - GetSecondsPassed)
        elseif (iStage == 0)
            PlaySound XXX               ;Change the XXX to the sound you want to play
            Set iStage to 1
            Set fTimer to 3
        elseif (iStage == 1)
            Player.AddItem Caps001 1    ;After 3 seconds have passed, add caps to player. Change this line to
            Set iStage to 2             ;your action
            set fTimer to 2
        elseif (iStage == 2)
            NPCXXX.Disable              ;After 2 seconds have passed, disable npc. Change NPCXXX to your npcs
            Set iStage to 3             ;reference name
            Set fTimer to 0
        endif
    endif

End
Link to comment
Share on other sites

Thanks man, you rock.

 

I modified it slightly and got just the effect I was hoping for.

SCN BLBoomScript

short doOnce
short fTimerStarted
short iStage
float fTimer

Begin OnAdd
    if (doOnce == 0)
        Set fTimerStarted to 1
        Set doOnce to 1
         PlaySound blboom
    endif
End

Begin GameMode
    if (fTimerStarted == 1)
        if (fTimer > 0)
            Set fTimer to (fTimer - GetSecondsPassed)
        elseif (iStage == 0)
            Set iStage to 1
            Set fTimer to 21
        elseif (iStage == 1)
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 0
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 1
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 2
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 3
            BLElvisREF.PlaceAtMe FatManNukeExplosion 0 
            BLElvisREF.PlaceAtMe FatManNukeExplosion 1 
            BLElvisREF.PlaceAtMe FatManNukeExplosion 2 
            BLElvisREF.PlaceAtMe FatManNukeExplosion 3 
            Set iStage to 2
        elseif (iStage == 2)
            BLElvisREF.PlaceAtMe FatManNukeExplosion 1 
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 0
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 1
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 2
            BLElvisREF.PlaceAtMe ExplosionPlasmaCritEffect 3
            BLElvisREF.Disable 
            Set iStage to 3
            Set fTimer to 0
        endif
    endif
End
Link to comment
Share on other sites

  • Recently Browsing   0 members

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