Jump to content

Script help needed for a bard.


Deleted31005User

Recommended Posts

So I always wanted to add a singing bard that goes to different locations around my town and the Hearthfire bard script seems perfect for that, after changing a few things on it it works all well as intended except for one thing:

-Normally he shouldn't start playing during night hours when hes sleeping, but it doesn't work and he still gets up and starts to play/sing in the middle of the night.

Can someone with some scripting experience please help me, this is how the script looks so far:

 

  Quote

 

Scriptname Tel_Nalta_Script_HouseBard extends ObjectReference

String Property sInstrument = "Lute" Auto
{current instrument to play instrumental music
defaults to Lute}

int Property iPlayOnLoadPercent = 40 Auto
{ percent chance that bard will be playing when you enter the house
default = 50
}

int Property iPlayOnLoadStartHour = 7 Auto
{ earliest time to start playing onload }

int Property iPlayOnLoadEndHour = 20 Auto
{ latest time to start playing onload }

GlobalVariable Property GameHour Auto

BardSongsScript Property BardSongs Auto

event OnCellAttach()
if !IsEnabled()
; move back to my editor location and enable
MoveToMyEditorLocation()
Enable()
else

; if I'm in the house, and between the right hours, play music
if GameHour.GetValueInt() >= iPlayOnLoadStartHour && GameHour.GetValueInt() <= iPlayOnLoadEndHour && GetEditorLocation() == GetCurrentLocation()
debug.trace(self + " OnLoad: play music")
; instrumental or sung?
if Utility.RandomInt(1, 2) == 1
debug.trace(self + " OnLoad: instrumental")
BardSongs.PlaySong(self, sInstrument, true )
else
debug.trace(self + " OnLoad: vocal")
BardSongs.PlaySongRequest(self, "Any", true, BardSongs.GetRandomSong(self))
endif
else
if GetEditorLocation() == GetCurrentLocation()
BardSongs.StopAllSongs()
endif
endif

endif
endEvent

 

Link to comment
Share on other sites

  • 2 weeks later...

You need another check. You do not want the NPC to play if they are sleeping right?

 

A made a few modifications to your script. You will need to change the script your script is extending from ObjectReference, to Actor in order for this to work.

Scriptname Tel_Nalta_Script_HouseBard extends Actor

String Property sInstrument = "Lute" Auto
{current instrument to play instrumental music
defaults to Lute}

int Property iPlayOnLoadPercent = 40 Auto
{ percent chance that bard will be playing when you enter the house
 default = 50
}

int Property iPlayOnLoadStartHour = 7 Auto
{ earliest time to start playing onload }

int Property iPlayOnLoadEndHour = 20 Auto
{ latest time to start playing onload }

GlobalVariable Property GameHour Auto

BardSongsScript Property BardSongs  Auto

event OnCellAttach()
Int GetCurrentHour = GameHour.GetValueInt()

        if !IsEnabled()
            ; move back to my editor location and enable
            MoveToMyEditorLocation()
            Enable()
        else
            ;Check if Im sleeping, and if I am, dont do anything.
            if GetSleepState() == 3
                return
            else

            ; if Im in the house, and between the right hours, play music
                if GetCurrentHour >= iPlayOnLoadStartHour && GetCurrentHour <= iPlayOnLoadEndHour && GetEditorLocation() == GetCurrentLocation()
                    debug.trace(self + " OnLoad: play music")
                    ; instrumental or sung?
                    if Utility.RandomInt(1, 2) == 1
                        debug.trace(self + " OnLoad: instrumental")
                        BardSongs.PlaySong(self, sInstrument, true )
                    else
                        debug.trace(self + " OnLoad: vocal")
                        BardSongs.PlaySongRequest(self, "Any", true, BardSongs.GetRandomSong(self))
                    endif
                else
                    if GetEditorLocation() == GetCurrentLocation()
                        BardSongs.StopAllSongs()
                    endif
                endif
            endif

        endif
endevent
Edited by Terra Nova
Link to comment
Share on other sites

  • Recently Browsing   0 members

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