Jump to content

Make Actor Sit at random chair and read


Oblis

Recommended Posts

Cleaned your script up a bit...

 

 

 

 

ScriptName NPC01ScriptPackages

Ref NPC
String_var Name

Short Dice_Package

Ref CurrentRef
Array_var LocationData
Array_var NPC01_Chairs
Ref NPC01_ChosenChair
short NPC01_ChairSelection
short NPC01_ChairsLast

short DancingTrigger
short LuteTrigger

Short ItemCount
Ref Package
Short UseScriptChair


;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Begin Function {NPC, Name}
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If eval ((ar_Size NPC01_Chairs) == -1)
	Let NPC01_Chairs := ar_Construct Array
endif

Let CurrentRef := GetFirstRef 32 

Label 100 

If (CurrentRef) 

	If (CurrentRef.NameIncludes "Chair") || (CurrentRef.NameIncludes "Stool") || (CurrentRef.NameIncludes "Bench") || (CurrentRef.NameIncludes "Cushion")

		ar_Append NPC01_Chairs CurrentRef
		PrintToConsole "%z: %n added to array" Name CurrentRef

	endif

	Let CurrentRef := GetNextRef

	GoTo 100 

endif

Let NPC01_ChairsLast := ar_Last NPC01_Chairs
set NPC01_ChairSelection to Rand 0 NPC01_ChairsLast


;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;Package Generator
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

set Dice_Package to Rand 1 10	


Set ItemCount to (NPC.GetItemCount NPCDrinkingObject)

If ItemCount
	NPC.RemoveItem NPCDrinkingObject ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCReadingObject)

If ItemCount
	NPC.RemoveItem NPCReadingObject ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCAlchemyObject)

If ItemCount
	NPC.RemoveItem NPCAlchemyObject ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject1)

If ItemCount
	NPC.RemoveItem NPCDancingObject1 ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject2)

If ItemCount
	NPC.RemoveItem NPCDancingObject2 ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject3)

if ItemCount
	NPC.RemoveItem NPCDancingObject3 ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject3)

If ItemCount
	NPC.RemoveItem NPCDancingObject3 ItemCount
endif

Set ItemCount to (NPC.GetItemCount 0miscUdeUluteU01)

If ItemCount
	NPC.RemoveItem 0miscUdeUluteU01 ItemCount
endif


Let NPC01_ChosenChair := NPC01_Chairs[NPC01_ChairSelection]



If Dice_Package == 1

	NPC.AddItem NPCDrinkingObject 1
	Set UseScriptChair to 1
	Set Package to NPCDrinkingNPC01CurrentLocation

ElseIf Dice_Package == 2

	NPC.AddItem NPCReadingObject 1
	Set UseScriptChair to 1
	Set Package to NPCReadingNPC01CurrentLocation

ElseIf Dice_Package == 3

	NPC.AddItem NPCAlchemyObject 1
	Set UseScriptChair to 1
	Set Package to NPCAlchemyNPC01CurrentLocation

ElseIf Dice_Package == 4

	NPC.AddItem NPCEatingObject 1
	Set Package to NPCEatingCurrentLocation

ElseIf Dice_Package == 5

	Set Package to NPCSleepingCurrentLocation

ElseIf Dice_Package == 6

	Set Package to NPCWanderingCurrentLocation

ElseIf Dice_Package == 7

	NPC.AddItem 0apparatusUaUspipeU01 1
	Set UseScriptChair to 1
	Set Package to NPCSmokingNPC01CurrentLocation

ElseIf Dice_Package == 8

	set LuteTrigger to Rand 1 4

	if LuteTrigger == 1

		Set Package to NPCPlayingLute01PartnerCurrentLocation

	Elseif LuteTrigger == 2

		Set Package to NPCPlayingLute02PartnerCurrentLocation

	Elseif LuteTrigger == 3

		Set Package to NPCPlayingLute03PartnerCurrentLocation

	Endif


ElseIf Dice_Package == 9

	set DancingTrigger to Rand 1 4

	if DancingTrigger == 1

		Set Package to NPCDancing01PartnerCurrentLocation

	Elseif DancingTrigger == 2

		Set Package to NPCDancing02PartnerCurrentLocation

	Elseif DancingTrigger == 3

		Set Package to NPCDancing03PartnerCurrentLocation

	Endif
Endif


If UseScriptChair == 1

	Let LocationData := GetPackageLocationData Package
	Let LocationData["Object"] := NPC01_ChosenChair
	SetPackageLocationData Package LocationData

endif


NPC.AddScriptPackage Package

Let NPC01_Chairs := ar_Null
Let LocationData := ar_Null
sv_Destruct Name

END

 

 

 

It is mostly the same script. As before, here is what I have done...

- NPC and Name are passed directly from the calling script as arguements (I updated the first script to accommodate this)

- RemoveItem works properly to clear an inventory.

- DoOnce loops are removed, because the script only runs once before all local variables are cleared anyway

- When a scripted chair is used, a bool is turned on that runs all the location data one time, instead of under each and every If statement. It saves a few lines.

- A variable was declared twice. I don't think this would hurt the integrity of the script, but it may as well be cleaned up.

 

 

The first script is updated here:

 

 

 

scriptname NPCScript
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

String_var Name

ref NPC
Ref NPCBaseObject

float Time

short NPCConfidence
short NPCEnergy 
short NPCResponsibility 
short NPCClass
short NPCBirthSign

short Dice_Behaviour
short Dice_Class
short Dice_BirthSign

short DoOnceTrigger1 

Short ItemCount
Short DoOnceTimeZone

;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

begin GameMode

       
       Set NPC to GetSelf 
       set Name to NPC.GetName
       set Time to GameHour

       player.AddSpell NPCConfortsCushion
       
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
       
       if Dice_Behaviour == 0
               
               Set NPCConfidence to Rand 30 100
               Set NPCEnergy to Rand 30 100
               Set NPCResponsibility to Rand 30 100
               NPC.SetActorValue Confidence NPCConfidence 
               NPC.SetActorValue Energy NPCEnergy 
               NPC.SetActorValue Responsibility NPCResponsibility 
               set Dice_Behaviour to 1
               
       endif
       
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
       
       IF Dice_Birthsign == 0
               
               Set NPCBirthSign to Rand 1 14
               Set Dice_Birthsign to 1


               
               If NPC.GetItemCount NPCBirthApprentice > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthApprentice > 0
                       NPC.RemoveItem NPCBirthApprentice ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthAtronach > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthAtronach > 0
                       NPC.RemoveItem NPCBirthAtronach ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthLady > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthLady > 0
                       NPC.RemoveItem NPCBirthLady ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthLord > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthLord > 0
                       NPC.RemoveItem NPCBirthLord ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthLover > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthLover > 0
                       NPC.RemoveItem NPCBirthLover ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthMage > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthMage > 0
                       NPC.RemoveItem NPCBirthMage ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthRitual > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthRitual > 0
                       NPC.RemoveItem NPCBirthRitual ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthSerpent > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthSerpent > 0
                       NPC.RemoveItem NPCBirthSerpent ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthShadow > 0
                       Set ItemCount to NPC.GetItemCount NPCBirthShadow > 0
                       NPC.RemoveItem NPCBirthShadow ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthSteed > 0
                       Set ItemCount to NPC.GetItemCount NPCBirthSteed > 0
                       NPC.RemoveItem NPCBirthSteed ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthThief > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthThief > 0
                       NPC.RemoveItem NPCBirthThief ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthTower > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthTower > 0
                       NPC.RemoveItem NPCBirthTower ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthWarrior > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthWarrior > 0
                       NPC.RemoveItem NPCBirthWarrior ItemCount
                       
               ElseIf NPC.GetItemCount NPCBirthMage > 0
                       
                       Set ItemCount to NPC.GetItemCount NPCBirthMage > 0
                       NPC.RemoveItem NPCBirthMage ItemCount
                       
               Endif 



               
               If NPCBirthsign == 1
                       
                       NPC.AddSpell BSApprentice 
                       NPC.AddItem NPCBirthApprentice 1
                       
               ElseIf NPCBirthsign == 2
                       
                       NPC.AddSpell BSAtronach 
                       NPC.AddItem NPCBirthAtronach 1
                       
               ElseIf NPCBirthsign == 3
                       
                       NPC.AddSpell BSLadyBlessing
                       NPC.AddItem NPCBirthLady 1
                       
               ElseIf NPCBirthsign == 4 
                       
                       NPC.AddSpell BSLordBloodoftheNorth
                       NPC.AddSpell BSLordTrollkin
                       NPC.AddItem NPCBirthLord 1 
                       
               ElseIf NPCBirthsign == 5
                       
                       NPC.AddSpell BSLoverKiss
                       NPC.AddItem NPCBirthLover 1
                       
               ElseIf NPCBirthsign == 6
                       
                       NPC.AddSpell BSMage
                       NPC.AddItem NPCBirthMage 1 
                       
               ElseIf NPCBirthsign == 7
                       
                       NPC.AddSpell BSRitualBlessedWord
                       NPC.AddSpell BSRitualMaraGift
                       NPC.AddItem NPCBirthRitual 1 
                       
               ElseIf NPCBirthsign == 8
                       
                       NPC.AddSpell BSSerpent
                       NPC.AddItem NPCBirthSerpent 1
                       
               ElseIf NPCBirthsign == 9
                       
                       NPC.AddSpell BSShadowMoonshadow
                       NPC.AddItem NPCBirthShadow 1
                       
               ElseIf NPCBirthsign == 10
                       
                       NPC.AddSpell BSSteed
                       NPC.AddItem NPCBirthSteed 1
                       
               ElseIf NPCBirthsign == 11
                       
                       NPC.AddSpell BSThief
                       NPC.AddItem NPCBirthThief 1
                       
               ElseIf NPCBirthsign == 12
                       
                       NPC.AddSpell BSTower
                       NPC.AddSpell BSTowerWarden
                       NPC.AddItem NPCBirthTower 1
                       
               ElseIf NPCBirthsign == 13
                       
                       NPC.AddSpell BSWarrior
                       NPC.AddItem NPCBirthWarrior 1
                       
               ElseIf NPCBirthsign == 14
                       
                       Set Dice_Birthsign to 0
                       
               Endif
       Endif
       
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
       
       if Dice_Class == 0
               
               Set NPCClass to Rand 1 15
               set Dice_Class to 1

               
               If NPCClass == 1
                       
                       NPC.SetClass Warrior
                       
               elseIf NPCClass == 2
                       
                       NPC.SetClass Warlock
                       
               elseIf NPCClass == 3
                       
                       NPC.SetClass Thief
                       
               elseIf NPCClass == 4
                       
                       NPC.SetClass Sorcerer
                       
               elseIf NPCClass == 5
                       
                       NPC.SetClass Rogue
                       
               elseIf NPCClass == 6
                       
                       NPC.SetClass Priest
                       
               elseIf NPCClass == 7
                       
                       NPC.SetClass Nightblade
                       
               elseIf NPCClass == 8
                       
                       NPC.SetClass Mage
                       
               elseIf NPCClass == 9
                       
                       NPC.SetClass Knight
                       
               elseIf NPCClass == 10
                       
                       NPC.SetClass Acrobat
                       
               elseIf NPCClass == 11
                       
                       NPC.SetClass Assassin
                       
               elseIf NPCClass == 12
                       
                       NPC.SetClass Barbarian
                       
               elseIf NPCClass == 13
                       
                       NPC.SetClass Bard
                       
               elseIf NPCClass == 14
                       
                       NPC.SetClass Monk
                       
               elseIf NPCClass == 15
                       
                       set Dice_Class to 0
                       
               endif

               
               Call NPCScriptClass
               
       ENDIF
       
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       
       IF Time > DoOnceTimeZone * 2
               
               Set DoOnceTimeZone to ((Time + 2) / 2)
               
                       
               If (NPC == NPC01ARef) || (NPC == NPC01BRef) || (NPC == NPC01CRef)
                       
                       Call NPC01ScriptPackages NPC Name
                       
               elseif (NPC == NPC02ARef) || (NPC == NPC02BRef) || (NPC == NPC02CRef)
                       
                       Call NPC02ScriptPackages NPC Name
                       
               elseif (NPC == NPC03ARef) || (NPC == NPC03BRef) || (NPC == NPC03CRef)
                       
                       Call NPC03ScriptPackages NPC Name
                       
               elseif (NPC == NPC04ARef) || (NPC == NPC04BRef) || (NPC == NPC04CRef)
                       
                       Call NPC04ScriptPackages NPC Name
                       
               elseif (NPC == NPC05ARef) || (NPC == NPC05BRef) || (NPC == NPC05CRef)
                       
                       Call NPC05ScriptPackages NPC Name
                       
               elseif (NPC == NPC06ARef) || (NPC == NPC06BRef) || (NPC == NPC06CRef)
                       
                       Call NPC06ScriptPackages NPC Name
                       
               elseif (NPC == NPC07ARef) || (NPC == NPC07BRef) || (NPC == NPC07CRef)
                       
                       Call NPC07ScriptPackages NPC Name
                       
               elseif (NPC == NPC08ARef) || (NPC == NPC08BRef) || (NPC == NPC08CRef)
                       
                       Call NPC08ScriptPackages NPC Name
                       
               elseif (NPC == NPC09ARef) || (NPC == NPC09BRef) || (NPC == NPC09CRef)
                       
                       Call NPC09ScriptPackages NPC Name
                       
               elseif (NPC == NPC10ARef) || (NPC == NPC10BRef) || (NPC == NPC10CRef)
                       
                       Call NPC10ScriptPackages NPC Name
                       
               elseif (NPC == NPC11ARef) || (NPC == NPC11BRef) || (NPC == NPC11CRef)
                       
                       Call NPC11ScriptPackages NPC Name
                       
               elseif (NPC == NPC12ARef) || (NPC == NPC12BRef) || (NPC == NPC12CRef)
                       
                       Call NPC12ScriptPackages NPC Name
                       
               elseif (NPC == NPC13ARef) || (NPC == NPC13BRef) || (NPC == NPC13CRef)
                       
                       Call NPC13ScriptPackages NPC Name
                       
               elseif (NPC == NPC14ARef) || (NPC == NPC14BRef) || (NPC == NPC14CRef)
                       
                       Call NPC14ScriptPackages NPC Name
                       
               elseif (NPC == NPC15ARef) || (NPC == NPC15BRef) || (NPC == NPC15CRef)
                       
                       Call NPC15ScriptPackages NPC Name
                       
               elseif (NPC == NPC16ARef) || (NPC == NPC16BRef) || (NPC == NPC16CRef)
                       
                       Call NPC16ScriptPackages NPC Name
                       
               elseif (NPC == NPC17ARef) || (NPC == NPC17BRef) || (NPC == NPC17CRef)
                       
                       Call NPC17ScriptPackages NPC Name
                       
               elseif (NPC == NPC18ARef) || (NPC == NPC18BRef) || (NPC == NPC18CRef)
                       
                       Call NPC18ScriptPackages NPC Name
                       
               elseif (NPC == NPC19ARef) || (NPC == NPC19BRef) || (NPC == NPC19CRef)
                       
                       Call NPC19ScriptPackages NPC Name
                       
               elseif (NPC == NPC20ARef) || (NPC == NPC20BRef) || (NPC == NPC20CRef)
                       
                       Call NPC20ScriptPackages NPC Name
                       
               endif
               
       ENDIF

End

 

 

 

 

 

While all NPCs do load the same chairs if they are in the same cell, they are not saved in the same array. The array may be identical, but they are different arrays. This is because they are local variables. CurrentRef is not shared between scripts either.

 

I think that a syntax error may have lead your script to believe that all NPCs were NPC01, thus assigning them all the same package. It may have been to do with those quotation marks. Give the new scripts a try and see how they work ;)

Edited by WarRatsG
Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Well... unfortunatelly it didnt work.

I used both your updated scripts but still i get the same things.

I made some tests and the results are

 

1.

When i first enter the npc01 cell, all the other companion are building their arrays with the chairs of the cell that the npc 01 is.

I passed NPC01 and went to meet NCP02. All the NPC got his CELL chairs to add in their arrays.

I believe that they are inactive until you meet them. When I enter their CELL they start counting their chairs.

But everybody adds the first npcs i meet, the chairs and is going there.

The result is that all the npcs are coming to that place.

 

2.

I beleive that every npc in his script shall get a limit on what to add in his array. A good idea whould be that the npc will only check the CELL he is currently is, all the time, so he will fill his array all the time with new variables.

Maybe when he changes CELL he can reset the array.

Right now the script gives a mess because the npcs "see" and "add" chairs that they never know to excist.

 

3. Sometimes I get errors in console as you can see in the screenshots:

 

http://i208.photobucket.com/albums/bb180/Aramis1979/Bug2.png

 

http://i208.photobucket.com/albums/bb180/Aramis1979/bug1.png

 

It has something to do with the LET command...

Edited by Oblis
Link to comment
Share on other sites

You have to edit the function script first - right now it has 0 parameters, therefore expects 0 arguements. When you edit the function script, then it will expect 2 arguements.

 

I suppose this is for 3 right?

 

 

I m definitevely sure that GetInSameCell will be very useful.

But i cannot figure how...

 

These changes actually gave me some results.

Now I can check if the NPC is in the same sell with the object.

I used GetParentCell

 

Mayve it will help a bit to figure how to make them not incert chairs that are not in the same cell, in their array, but only the chairs that are in their parent cell?

Dunno I m a bit lost on this...

 

If (CurrentRef) 
if ( CellLastFrame == CurrentRef.GetParentCell )
If (CurrentRef.NameIncludes "Chair") || (CurrentRef.NameIncludes "Stool") || (CurrentRef.NameIncludes "Bench") || (CurrentRef.NameIncludes "Cushion")
ar_Append NPC20_Chairs CurrentRef
PrintToConsole "%z: %n added to array" Name CurrentRef
endif
endif

if ( CellLastFrame != CurrentRef.GetParentCell )
PrintToConsole "%z:  This is somewhere else" Name
endif

Let CurrentRef := GetNextRef
GoTo 100 
endif

Edited by Oblis
Link to comment
Share on other sites

Heh this is funny.

I noticed that the array (at least what i see from the messages) fills with elements from the place I am.

I mean that when I move from CELL to CELL I see the chairs around to be added to the array, even if the npc is not there.

Why adding the chairs around the player to the array?

Maybe this is the problem?

Link to comment
Share on other sites

Ah, I think I know where the problem is...

 

I was under the impression that the NPCs were meant to be in the same cell as the player, at least when the package was set. I think we can fix this ;)

 

GetFirstRefInCell is all that you would need to change. The rest of the script should not be very different - however I have added in several Output messages in each function call to help isolate the problem with the Let statement. My guess is that when GetNextRef is called for the last time, there is no "next ref" and therefore is technically invalid. If it causes no problems, it's not worth fixing ;)

 

Nonetheless, here is a slightly modified function script that should root out any problems with Let commands. It will print a lot of information to the console - use PageUp and PageDown to look through it. If error messages appear again, Please tell me what messages appear around it (All debug messages begin with "OBLIS::")

 

 

 

ScriptName NPC01ScriptPackages

Ref NPC
String_var Name

Short Dice_Package

Ref CurrentRef
Array_var LocationData
Array_var NPC01_Chairs
Ref NPC01_ChosenChair
short NPC01_ChairSelection
short NPC01_ChairsLast

short DancingTrigger
short LuteTrigger

Short ItemCount
Ref Package
Short UseScriptChair
Ref CurrentCell


;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Begin Function {NPC, Name}
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


PrintToConsole "OBLIS:: Function call initiated"

Let NPC01_Chairs := ar_Construct Array
PrintToConsole "OBLIS:: Array Initialised"

Set CurrentCell to NPC.GetParentCell

PrintToConsole "OBLIS:: Loop sequence Starting"

Let CurrentRef := GetFirstRefInCell CurrentCell 32 

Label 100 

If (CurrentRef) 

	If (CurrentRef.NameIncludes "Chair") || (CurrentRef.NameIncludes "Stool") || (CurrentRef.NameIncludes "Bench") || (CurrentRef.NameIncludes "Cushion")

		ar_Append NPC01_Chairs CurrentRef
		PrintToConsole "%z: %n added to array" Name CurrentRef

	endif

	Let CurrentRef := GetNextRef

	GoTo 100 

endif

PrintToConsole "OBLIS:: Loop sequence finished"

Let NPC01_ChairsLast := ar_Last NPC01_Chairs
PrintToConsole "OBLIS:: Last chair == %.0f" NPC01_ChairsLast

set NPC01_ChairSelection to Rand 0 NPC01_ChairsLast


;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;Package Generator
;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

set Dice_Package to Rand 1 10   


Set ItemCount to (NPC.GetItemCount NPCDrinkingObject)

If ItemCount
	NPC.RemoveItem NPCDrinkingObject ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCReadingObject)

If ItemCount
	NPC.RemoveItem NPCReadingObject ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCAlchemyObject)

If ItemCount
	NPC.RemoveItem NPCAlchemyObject ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject1)

If ItemCount
	NPC.RemoveItem NPCDancingObject1 ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject2)

If ItemCount
	NPC.RemoveItem NPCDancingObject2 ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject3)

if ItemCount
	NPC.RemoveItem NPCDancingObject3 ItemCount
endif

Set ItemCount to (NPC.GetItemCount NPCDancingObject3)

If ItemCount
	NPC.RemoveItem NPCDancingObject3 ItemCount
endif

Set ItemCount to (NPC.GetItemCount 0miscUdeUluteU01)

If ItemCount
	NPC.RemoveItem 0miscUdeUluteU01 ItemCount
endif


Let NPC01_ChosenChair := NPC01_Chairs[NPC01_ChairSelection]
PrintToConsole "OBLIS:: Chosen chair is %n" NPC01_ChosenChair



If Dice_Package == 1

	NPC.AddItem NPCDrinkingObject 1
	Set UseScriptChair to 1
	Set Package to NPCDrinkingNPC01CurrentLocation

ElseIf Dice_Package == 2

	NPC.AddItem NPCReadingObject 1
	Set UseScriptChair to 1
	Set Package to NPCReadingNPC01CurrentLocation

ElseIf Dice_Package == 3

	NPC.AddItem NPCAlchemyObject 1
	Set UseScriptChair to 1
	Set Package to NPCAlchemyNPC01CurrentLocation

ElseIf Dice_Package == 4

	NPC.AddItem NPCEatingObject 1
	Set Package to NPCEatingCurrentLocation

ElseIf Dice_Package == 5

	Set Package to NPCSleepingCurrentLocation

ElseIf Dice_Package == 6

	Set Package to NPCWanderingCurrentLocation

ElseIf Dice_Package == 7

	NPC.AddItem 0apparatusUaUspipeU01 1
	Set UseScriptChair to 1
	Set Package to NPCSmokingNPC01CurrentLocation

ElseIf Dice_Package == 8

	set LuteTrigger to Rand 1 4

	if LuteTrigger == 1

		Set Package to NPCPlayingLute01PartnerCurrentLocation

	Elseif LuteTrigger == 2

		Set Package to NPCPlayingLute02PartnerCurrentLocation

	Elseif LuteTrigger == 3

		Set Package to NPCPlayingLute03PartnerCurrentLocation

	Endif


ElseIf Dice_Package == 9

	set DancingTrigger to Rand 1 4

	if DancingTrigger == 1

		Set Package to NPCDancing01PartnerCurrentLocation

	Elseif DancingTrigger == 2

		Set Package to NPCDancing02PartnerCurrentLocation

	Elseif DancingTrigger == 3

		Set Package to NPCDancing03PartnerCurrentLocation

	Endif
Endif


If UseScriptChair == 1

	PrintToConsole "OBLIS:: Package alteration - starting"
	Let LocationData := GetPackageLocationData Package
	PrintToConsole "OBLIS:: Package alteration - checkpoint"
	Let LocationData["Object"] := NPC01_ChosenChair
	PrintToConsole "OBLIS:: Package alteration - finished"
	SetPackageLocationData Package LocationData

endif


NPC.AddScriptPackage Package

sv_Destruct Name

PrintToConsole "OBLIS:: Function Call terminated"

END

 

 

Edited by WarRatsG
Link to comment
Share on other sites

You forgot to end spoiler :)

Anyway...

 

The only error i get at them moment is a well known problem that occurs when there is not pesistent chairs in the cell.

Since the GetFirstRefInCell is looking for persistent chairs it gives error if there are not any.

This doesnt affect the game but only the npc which is just standing doing nothing.

 

As i searched there is not way to make chairs persistent whrough a script and that why it will be always the problem.

Also I m thinking that it could be done some additional lines in case there are not persistent ref in cell to do somthing else. (wander/sleep etc for example)

Link to comment
Share on other sites

The only error i get at them moment is a well known problem that occurs when there is not pesistent chairs in the cell.

Since the GetFirstRefInCell is looking for persistent chairs it gives error if there are not any.

This doesnt affect the game but only the npc which is just standing doing nothing.

 

So they don't just stand and read? I guess it makes sense that having no location and an invalid location may not be the same thing. Still, good positioning of the NPC would fix it.

 

 

As i searched there is not way to make chairs persistent whrough a script and that why it will be always the problem.

Also I m thinking that it could be done some additional lines in case there are not persistent ref in cell to do somthing else. (wander/sleep etc for example)

 

You seem to know what you're doing, but if you do need any more help then you can let me know. Sorry I took so long to help you before ;)

 

If it really matters then adjacent interior cells could be found through script, by ref-walking the doors in the cell and seeing where each one leads with GetTeleportCell.

Edited by WarRatsG
Link to comment
Share on other sites

So they don't just stand and read? I guess it makes sense that having no location and an invalid location may not be the same thing. Still, good positioning of the NPC would fix it.

 

Possibly yes. I just tell you what is happening in console.

 

If it really matters then adjacent interior cells could be found through script, by ref-walking the doors in the cell and seeing where each one leads with GetTeleportCell.

 

I think GetFirstRefInCell / GetNextRef can extend in more that 1 cell.

(reference:ref) GetFirstRefInCell cell:ref type:int cellDepth:int includeInactiveRefs:bool

 

You seem to know what you're doing, but if you do need any more help then you can let me know. Sorry I took so long to help you before ;)

 

Ye thanks for the help! It took much time but finally it worked as properly as it should.

Keep the good work

Edited by Oblis
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...