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...

"Stop actor from sitting down on bench-function" needed


TheWinterhawk
 Share

Recommended Posts

I'm on a little project again, and this time I'd like to add a script to a farm bench, which I already did successfully so far. I use onactivate() to start an event, which should open a little options menu. The thing is, the player actor always sits down on the farm bench and I want to stop him from doing that in first case.

I've been searching the Creation Kit Wiki for an appropriate function, etc., alas, with no success. When the farm bench is activated, the menu should open (which it does), but the actor should be stopped from sitting down first. Only if the player chooses the "Sit Down" option from my menu, the player character should sit down. Otherwise the using furniture animation should be interrupted. Actually in 4 cases the animation/using furniture event must be stopped first and maybe later in 1 case the sit down animation/using furniture event should be called again.

Does anybody have a clue about what function I can try to stop/interrupt the actor from sitiing down? And will I be able to use the SendAnimationEvent function to later make him use the furniture for sitting down, in case this option was chosen from my menu?

I hope I could make myself clear on this subject. Many thanks in advance! =)

Link to comment
Share on other sites

Yes, I have a clue.

Its going to be a bit complicated to get working, but its doable.

I did this exact thing with the entrance door in my Levelers Tower mod.

You need to use the BlockActivation function.

Here is how I used it.

 
Scriptname LevelersEntranceDoor extends ObjectReference
{Script on entrance door to towers}
GlobalVariable Property LevelersEntranceDoorGBL Auto
SPELL Property VoiceUnrelentingForce3 Auto
ObjectReference Property LevelersDoorShoutXREF Auto
ObjectReference Property LevelersEntry2REF Auto
Message Property MesgQuestionBox1 Auto
Message Property MesgOkay Auto
Message Property MesgNo Auto
int Button
int myState
Event OnInit()
myState == LevelersEntranceDoorGBL.GetValue()
if myState == 0
BlockActivation()
LevelersEntry2REF.BlockActivation()
; Debug.messagebox("Door initalized as blocked")
else
BlockActivation(false)
LevelersEntry2REF.BlockActivation(false)
; Debug.messagebox("Door initalized as unblocked")
endif
endEvent
EVENT onactivate(objectReference akActionRef)
If akActionRef == Game.GetPlayer()
myState == LevelersEntranceDoorGBL.GetValue()
if myState == 0
button = MesgQuestionBox1.show()
if Button == 0
myState = 1
LevelersEntranceDoorGBL.SetValue(1)
MesgOkay.show()
BlockActivation(false)
LevelersEntry2REF.BlockActivation(false)
Activate(Game.GetPlayer())
; Debug.messagebox("Answered yes")
elseif Button == 1
MesgNo.show()
; Debug.messagebox("Answered no")
LevelersDoorShoutXREF.PushActorAway(Game.GetPlayer(), 9.0)
endif
else
BlockActivation(false)
LevelersEntry2REF.BlockActivation(false)
; Activate(Game.GetPlayer())
; Debug.messagebox("Open, already answered yes")
endif
EndIf
endEVENT
[/CODE]

Link to comment
Share on other sites

Hi Willie!

Alrighties, I'll try to figure it out with BlockActivation() by taking a closer look at your script later, when I come home from shopping. Thanks so far. Will get back to you when anything isn't clear to me, and I'll let you know whether it worked or not.

I'll be off for Saturday shopping. See you later! =)

Link to comment
Share on other sites

Alright, I'm back from testing some stuff. I tried a lot of combinations of code. Problem number one: the bench has only one state which is ALWAYS 0. OK, I could work around that by setting its state manually to 1. So this is a minor problem.

BUT... problem number two is a major one: the BlockActivation() function only seems to work on the bench after the player has sat down at least for one time (using onactivate() event). So he will always sit down first and only after he gets up again, the bench will be blocked. So, I think what works for the lever, alas, doesn't work for the bench.(BTW, yes, I have made the bench a global variable, but it didn't work.) And I tried to call the blocking function OnInit(), but when I did that the script wasn't working at all. Debug messages didn't show up.

If any more ideas or hints come to mind, I'm really grateful for sharing. Thanks so far! =)

I might have to live with the fact, that the player character WILL sit down in any case, when the bench is activated. Not the way I wanted it, but if there's no way to work around it... hmm... a little inconvenience for the mod users, but still a bearable one, if nothing else will work. However, I really would love to find a solution for it. *goes wracking brain for a solution* :wallbash::question:

Edited by TheWinterhawk
Link to comment
Share on other sites

The OnInit() functioned isn't called at all. It doesn't even work with a simple debug notification. Before it doesn't show me a notification ingame there's no use in creating code, when I know it's not initialized. I have used some code, but have already deleted it, because it wasn't working. The following simple test was not successful. The debug notifications which are connected to the OnInit() do not work. But The options menu shows up when the bench is activated and the player sits down.

BTW, the script isn't complete, yet, the options menu doesn't do anything, yet. Just ignore that part.


Scriptname aa_ManageCampfireHutScript extends ObjectReference


;==========================================


Actor Property PlayerREF Auto


GlobalVariable Property BenchCampfire1 Auto

;ObjectReference Property BenchCampfire1 Auto  ;some functions I tested needed ObjectReference, some GlobalVariable, that why I have it twice and commented one of it out for testing

ObjectReference Property CampfireHutOn Auto

ObjectReference Property CampfireLightON Auto

ObjectReference Property CampfireHutOff Auto


Message Property CampfireOptionsMSG Auto


int BenchState


;==========================================


Event OnInit()


Debug.Notification("Script Initialized")			  ;doesn't show up

BenchState == BenchCampfire1.GetValue()

Debug.Notification(BenchState)					  ;doesn't show up


EndEvent


;==========================================


Event onactivate(ObjectReference akActionRef)


;BenchState == BenchCampfire1.GetValue()	 ;just implemented here for testing and works, commented out

;Debug.Notification(BenchState)					    ;just implemented here for testing and works, commented out



BenchState == BenchCampfire1.GetValue()

If (PlayerREF.GetSitState() == 2)

    Debug.Notification("Player is not sitting, but wants to sit")

  Int MSGboxHutChoice = CampfireOptionsMSG.Show()   ;menu doesn't do anything yet

   If MSGboxHutChoice == 0

	 Debug.Notification("You kindle a fire") ; kindle fire without BBQ

    ElseIf MSGboxHutChoice == 1

	 Debug.Notification("You kindle a fire for barbecue") ;setup BBQ

    ElseIf MSGboxHutChoice == 2

	 Debug.Notification("You choose to sit down") ;sit down

    ElseIf MSGboxHutChoice == 3

	 Debug.Notification("You choose to do nothing") ;cancel

   EndIf

EndIf

EndEvent

Link to comment
Share on other sites

1. I have made a special save, which I use for checking all the progress. It's always the same save game. Do you think while scripting, I should uninstall the mod every time and make a clean save, then freshly install it? Hell, that would take forever, for I make a lot of small changes and then check them. O_O

2. And yes, I spawn in the cell where the bench is positioned. Maybe I should fast travel and then check what happens when I come back? Or better: make a save further away and always travel freshly to that cell, yeah?

I'll try something with those hints. Thanks a lot, Willie!

Link to comment
Share on other sites

Hmm... somehow I don't even get a simple debug notification when using OnInit(), when I start a completely new save game and enter the area for the first time. I'm tending to cut down on my intent to prevent the player from sitting down. Thanks for all the help anyways. I'm still open to suggestions and hints, but at the moment nothing seems to work for me. Always willing to give a try on something else, though.

Link to comment
Share on other sites

1. A clean save game is one that you saved with your mod 'deactivated' and had never been activated at all when it was created.

2. Yes, the onInit has trouble if you load your save game in the cell the object is in.

I will see what I can come up with. The door took me 2 weeks to get working right. Of course, it was my very first script and I had no idea what I was doing and there was little help since papyrus was new to everyone.

In the meantime, change your debug.notifications to Debug.messagebox instead.

The notification may be dropped while the cell is still loading..

Edited by WillieSea
Link to comment
Share on other sites

Hi Willie!

Thanks for the further suggestions and informations. It's much appreciated! *thumbsup*

I have found a work around for my problem. I have abandoned the script from the farm bench and have installed an activation trigger, which is now holding the script. So I have no more trouble with the sitting issue. Simple, but very effective and in no way a worse solution than what I actually wanted to do. Everything works fine now.

I've given you a kudos on the nexus for your precious help. Thanks again!

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...