Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Quest Scripts


 Share

Recommended Posts

This is the hear of my mod Sands of Time. It modifies the game script PlayerSleepQuest (000FC1A2) to allow for sleeping to be randomly interrupted with the type of attackers beind dermined by location. the move to comand that moves the player to the exact spot he is in is crucial. It causes the sleep countdown to stop.


ScriptName PlayerSleepQuestScript extends Quest


import form


Spell Property Rested Auto

Spell Property WellRested Auto

Spell Property MarriageSleepAbility Auto

ReferenceAlias Property LoveInterest Auto

Keyword Property LocTypeInn Auto

Keyword Property LocTypePlayerHouse Auto

Keyword Property LocTypeDungeon Auto

Keyword Property LocTypeDraugrCrypt Auto

Quest Property RelationshipMarriageFIN Auto

Spell Property pDoomLoverAbility Auto

CompanionsHousekeepingScript Property CHScript Auto

int Property pSleeping  Auto Conditional

Int random

Int ambushnumb

Int ambushnum2

Int Property chance Auto

; all the actorbase monsters need to be deffined in properties.

ActorBase Property Ambushers1 Auto

ActorBase Property Ambushers2 Auto

ActorBase Property Ambushers3 Auto

ActorBase Property Ambushers4 Auto

ActorBase Property Ambushers5 Auto

ActorBase Property Ambushers6 Auto

ActorBase Property Ambushers7 Auto

ActorBase Property Ambushers8 Auto

ActorBase Property Ambushers9 Auto

ActorBase Property Ambushers10 Auto

ActorBase Property Ambushers11 Auto

ActorBase Property Ambushers12 Auto

ActorBase Property Ambushers13 Auto

ActorBase Property Ambushers14 Auto

ActorBase Property Ambushers15 Auto

ActorBase Property Ambushers16 Auto

ActorBase Property Ambushers17 Auto

ActorBase Property Ambushers18 Auto

ActorBase Property Ambushers19 Auto

ActorBase Property Ambushers20 Auto

ActorBase Property Ambushers21 Auto

ActorBase Property Ambushers22 Auto

ActorBase Property Ambushers23 Auto

ActorBase Property Ambushers24 Auto

ActorBase Property Ambushers25 Auto

ActorBase Property Ambushers26 Auto

ActorBase Property Ambushers27 Auto

ActorBase Property Ambushers28 Auto

ActorBase Property Ambushers29 Auto

ActorBase Property Ambushers30 Auto


Function RemoveRested()


	;remove all previous rested states

	Game.GetPlayer().RemoveSpell(Rested)

	Game.GetPlayer().RemoveSpell(WellRested)

	Game.GetPlayer().RemoveSpell(MarriageSleepAbility)


EndFunction



Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypePlayerHouse) == False

random = Utility.RandomInt(1, 100)

ambushnumb = Utility.RandomInt(1, 10)

ambushnum2 = ambushnumb

chance = 20

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeInn) == True

chance = 3

EndIf

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeDungeon) == True

chance = 40

ambushnumb = ambushnum2 + 10

EndIf

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeDraugrCrypt) == True 

chance = 45

ambushnumb = ambushnum2 + 20

EndIf

if random <= chance

pSleeping = 1


;Utility.WaitMenuMode(Utility.RandomInt(1, 6))

float SleepStart = afSleepStartTime * 24

float SleepEnd = afDesiredSleepEndTime * 24

float SleepTime = (SleepEnd - SleepStart) - 1

Utility.WaitMenuMode(Utility.RandomFloat(0, SleepTime))

	Game.DisablePlayerControls(ablooking = true, abCamSwitch = true)

	       Game.ForceFirstPerson()

ObjectReference PlayerRef = Game.GetPlayer()

		 	  Game.GetPlayer().MoveTo(PlayerRef)

			  Debug.MessageBox("Ambush!")

Woozy.Apply()

		Game.GetPlayer().PlayIdle (WakeUp)

		Utility.Wait (1)

		if ambushnumb == 1		

		PlayerRef.PlaceActorAtMe (Ambushers1, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 2

		PlayerRef.PlaceActorAtMe (Ambushers2, 1).StartCombat(Game.GetPlayer())

				ElseIf ambushnumb == 3

		PlayerRef.PlaceActorAtMe (Ambushers3, 1).StartCombat(Game.GetPlayer())	

				ElseIf ambushnumb == 4

		PlayerRef.PlaceActorAtMe (Ambushers4, 1).StartCombat(Game.GetPlayer())	

		PlayerRef.PlaceActorAtMe (Ambushers7, 1).StartCombat(Game.GetPlayer())

				ElseIf ambushnumb == 5

		PlayerRef.PlaceActorAtMe(Ambushers5, 1).StartCombat(Game.GetPlayer())	

		PlayerRef.PlaceActorAtMe (Ambushers8, 1).StartCombat(Game.GetPlayer())

				ElseIf ambushnumb == 6

		PlayerRef.PlaceActorAtMe (Ambushers6, 1).StartCombat(Game.GetPlayer())	

				ElseIf ambushnumb == 7

		PlayerRef.PlaceActorAtMe (Ambushers7, 1).StartCombat(Game.GetPlayer())	

				ElseIf ambushnumb == 8

		PlayerRef.PlaceActorAtMe (Ambushers8, 1).StartCombat(Game.GetPlayer())	

				ElseIf ambushnumb == 9

		PlayerRef.PlaceActorAtMe(Ambushers9, 1).StartCombat(Game.GetPlayer())	

				ElseIf ambushnumb == 10

		PlayerRef.PlaceActorAtMe(Ambushers10, 1).StartCombat(Game.GetPlayer())	

		ElseIf ambushnumb == 10

		PlayerRef.PlaceActorAtMe(Ambushers10, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 11

		PlayerRef.PlaceActorAtMe(Ambushers11, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 12

		PlayerRef.PlaceActorAtMe(Ambushers12, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 13

		PlayerRef.PlaceActorAtMe(Ambushers13, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 14

		PlayerRef.PlaceActorAtMe(Ambushers14, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 15

		PlayerRef.PlaceActorAtMe(Ambushers15, 1).StartCombat(Game.GetPlayer())

		PlayerRef.PlaceActorAtMe(Ambushers13, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 16

		PlayerRef.PlaceActorAtMe(Ambushers16, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 17

		PlayerRef.PlaceActorAtMe(Ambushers17, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 18

		PlayerRef.PlaceActorAtMe(Ambushers18, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 19

		PlayerRef.PlaceActorAtMe(Ambushers17, 1).StartCombat(Game.GetPlayer())

		PlayerRef.PlaceActorAtMe(Ambushers19, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 20

		PlayerRef.PlaceActorAtMe(Ambushers20, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 21

		PlayerRef.PlaceActorAtMe(Ambushers21, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 22

		PlayerRef.PlaceActorAtMe(Ambushers22, 1).StartCombat(Game.GetPlayer())

		PlayerRef.PlaceActorAtMe(Ambushers21, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 23

		PlayerRef.PlaceActorAtMe(Ambushers23, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 24

		PlayerRef.PlaceActorAtMe(Ambushers24, 1).StartCombat(Game.GetPlayer())

		PlayerRef.PlaceActorAtMe(Ambushers25, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 25

		PlayerRef.PlaceActorAtMe(Ambushers25, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 26

		PlayerRef.PlaceActorAtMe(Ambushers26, 1).StartCombat(Game.GetPlayer())

		PlayerRef.PlaceActorAtMe(Ambushers27, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 27

		PlayerRef.PlaceActorAtMe(Ambushers27, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 28

		PlayerRef.PlaceActorAtMe(Ambushers28, 1).StartCombat(Game.GetPlayer())

		PlayerRef.PlaceActorAtMe(Ambushers29, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 29

		PlayerRef.PlaceActorAtMe(Ambushers29, 1).StartCombat(Game.GetPlayer())

		ElseIf ambushnumb == 30

		PlayerRef.PlaceActorAtMe(Ambushers30, 1).StartCombat(Game.GetPlayer())

		PlayerRef.PlaceActorAtMe(Ambushers21, 1).StartCombat(Game.GetPlayer())

EndIf

Game.EnablePlayerControls()

EndIf

EndIf

EndEvent




Event OnSleepStop(bool abInterrupted)

if pSleeping == 0

; 	debug.trace(self + "Player is sleeping")

	If CHScript.PlayerHasBeastBlood == 1 && Utility.RandomInt(1, 100)>50

; 		Debug.Trace(Self + "Player is werewolf; no restedness on sleep.")

		;RemoveRested()

		;BeastBloodMessage.Show()

	ElseIf Game.GetPlayer().HasSpell(pDoomLoverAbility) == 0

		;don't run this if player has the Lover sign


		If RelationshipMarriageFIN.IsRunning() == True && RelationshipMarriageFIN.GetStage() > 10 && Game.GetPlayer().GetCurrentLocation() == LoveInterest.GetActorRef().GetCurrentLocation()

; 			debug.trace(Self + "Giving player the Lover's Comfort spell on Sleep End")

			MarriageRestedMessage.Show()

			RemoveRested()

			Game.GetPlayer().AddSpell(MarriageSleepAbility, abVerbose = false)

		ElseIf Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeInn) == True

; 			debug.trace(Self + "Giving player the Well Rested spell for sleeping in an Inn")	

			WellRestedMessage.Show()

			RemoveRested()

			Game.GetPlayer().AddSpell(WellRested, abVerbose = false)

		ElseIf Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypePlayerHouse) == True

; 			debug.trace(Self + "Giving player the Well Rested spell for sleeping in Player House")	

			Game.GetPlayer().AddSpell(WellRested, abVerbose = false)

		Else

; 			debug.trace(Self + "Giving player the Rested spell for sleeping")	

			RestedMessage.Show()

			RemoveRested()

			Game.GetPlayer().AddSpell(Rested, abVerbose = false)

		EndIf


	EndIf

	ElseIf pSleeping == 1

	pSleeping = 0

EndIf	

EndEvent


Message Property RestedMessage  Auto  


Message Property WellRestedMessage  Auto  


Message Property MarriageRestedMessage  Auto  


Message Property BeastBloodMessage  Auto


ImageSpaceModifier Property Woozy  Auto  


Idle Property WakeUp  Auto  




Edited by Tonycubed2
Link to comment
Share on other sites

Hi Tonycubed2, I posted a request on skyrim nexus for a way to change the percentages in your mod. Forgive me but I am extremely limited in my knowledge of scripting. I was able to identify this section of your script,

Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypePlayerHouse) == False

random = Utility.RandomInt(1, 100)

ambushnumb = Utility.RandomInt(1, 10)

ambushnum2 = ambushnumb

chance = 20

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeInn) == True

chance = 3

EndIf

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeDungeon) == True

chance = 40

ambushnumb = ambushnum2 + 10

EndIf

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeDraugrCrypt) == True

chance = 45

ambushnumb = ambushnum2 + 20

EndIf

if random <= chance

pSleeping = 1

And I believe I need to change the values following "chance =" to something more along the lines of

Event OnSleepStart(float afSleepStartTime, float afDesiredSleepEndTime)

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypePlayerHouse) == False

random = Utility.RandomInt(1, 100)

ambushnumb = Utility.RandomInt(1, 10)

ambushnum2 = ambushnumb

chance = 5

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeInn) == True

chance = 1

EndIf

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeDungeon) == True

chance = 8

ambushnumb = ambushnum2 + 10

EndIf

If Game.GetPlayer().GetCurrentLocation().HasKeyword(LocTypeDraugrCrypt) == True

chance = 10

ambushnumb = ambushnum2 + 20

EndIf

if random <= chance

pSleeping = 1

So I believe (correct me if I'm wrong) this is a default 5% chance outdoors, 1% at an Inn, 8% in a dungeon, and 10% in a draugr dungeon. Now I just don't know where to go from here. IE how do I turn your modified script into a usable mod? Do I need to download the creation kit and use that? If so any further help would be appreciated. Thanks and great work btw. I will definitely endorse your mods.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...