Jump to content

Make Actor Sit at random chair and read


Oblis

Recommended Posts

Hello,

I created 2 packages

 

1 is FIND Furniture so the npc will find a chair and sit

2 is USEITEMAT Books and he is using idle animation for reading

 

The script works as it should be but i face a small problem.

The NPC sits on the chair and when the reading package starts he stands and reads.

 

The purpose was to make him read in random chair (not a specific place).

 

If I use on Reading Package the location "Furniture" the package is not running.

I used the GetSitting function to make a condition when to start reading.

Here is my script lines:

 

Do you know how to achieve reading by sitting on a random chair?

 

 



short NPCSitting
short SittingTrigger

....
....
set NPCSitting to NPC.GetSitting
....
....
If Dice_Package == 2
if SittingTrigger == 0
NPC.AddScriptPackage NPCSittingCurrentLocation
set SittingTrigger to 1
endif
if NPCSitting == 3
NPC.RemoveScriptPackage NPCSittingCurrentLocation
NPC.AddScriptPackage NPCReadingCurrentLocation
PrintToConsole "%z is Reading" name
set SittingTrigger to 0
set DoOnceTrigger7 to 1
endif
endif

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

May be a problem caused by non-persistent chairs. Check the particular chair you're play testing in the CS and see if the 'persistent' flag is set. You could also test your script in an area that has some persistent chairs and see if the problem is still there (which would prove or disprove my theory).
Link to comment
Share on other sites

The chair the npc was trying was persistent I removed the flag and load the game again.

Unfortunatelly I got the same problem again

 

The npcs executes the find package.

Finds and the chair and sits.

But the the drink package starts and he stands to drink.

I m checking the NPCSitting == 3 since the 3 value gives info to the machine that he is sitting.

 

I also tried to put in "drinking" package a location (any object -- > furniture) but it gives idle.

I dont know if it really can be done at all.

Edited by Oblis
Link to comment
Share on other sites

I haven't tried accomplishing what you are trying to do using scripts myself. When using AI packages the NPCs won't use a bed or chair unless it is marked as persistent. For drinking I have used a marker to get them to the spot I want them drinking (either a marker I've added or a vanilla marker) and then a 'Use Item' package with a pewter mug as the target. Using this method I have 'my girls' getting together in various inns for happy hour or 'Friday night and lets get seriously drunk'. Depending on how it fits into your overall mod perhaps using AI packages may be a simpler solution.
Link to comment
Share on other sites

No this is not helping

The npcs are followers that means they move all around the map with player.

Every package has current location so the player may take them leave to his castle or home.

Or just let them leave somewhere.

 

If I put specific ids to location they will travel to find the location.

And the whole will be a mess because they will dissapear etc.

Link to comment
Share on other sites

I understand. Your situation is completely different than in my own simple mods. Perhaps one of the scripting experts will chime in with some ideas on your problem.
Link to comment
Share on other sites

I thought that it may be done the way the eat package works. At eat package the actor will sit down in a random chair (if it is not specified) and eat automatically. Can this be done with UseItemAt (drink) package too?
Link to comment
Share on other sites

Packages and animations are not my thing, but you might be able to force the animation using script ;)

 

What you need to do is make an Idle Animation with the same KF file as the Sit-Reading animation. If Sit-Reading is already an idle, which I strongly think it is, then you can just copy it. After that, you set the new Idle's conditions to check if the NPC is sitting, and also to check if the NPC is carrying a special "token". This token is just a random, unplayable item, but it will act as a marker to show who will play the animation. You will need to add it to the NPC whenever you want them to read.

 

When the NPC is sitting down and has the token, you can use the function "PickIdle" and if your Animation is a high enough priority then the NPC should begin to read. The AI package will still be to sit, but they will be playing the reading animation.

 

I'm not sure if this will work as well for you as it has for me. Just make sure that the Idle is near the top of the "tree" in the CS and you should be fine ;)

Link to comment
Share on other sites

The only time I had any luck getting NPCs to sit and drink (as opposed to their favoured stand and drink) I had a specific chair assigned for the NPC to sit in and then drink (not at my gaming computer so I can't give you the exact specifics). For your purposes this wouldn't help unless your script searched for all available chairs in the NPC's current cell and assigned one of those chairs to the NPC for the drink package (making sure the assigned chair was a persistent reference).

 

WarRatsG will be of much more help than any primitive method I could suggest.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...