Jump to content

[LE] Get a trigger from another interior


alcarewan

Recommended Posts

Hello,

I'm totally new in CK, and working on a cooking mod few days ago.

The problem i can't resolve, is there a trigger in an interior(Whiterun Bannered Mare),

and I want to move it to the actual position(example The Drunken Huntsman, or exterior) by a script.

It seems impossible, SetPosition and MoveTo functions works only in the same interior(Bannered Mare).

Doesn't work my last idea too, when I'd create a new trigger from the base.

If you can, help me please.

Scriptname ToT_FireplaceScript extends ObjectReference  
{Script of the Fireplace}

GlobalVariable Property ToT_IsCooking  Auto  

Message Property ToT_FireplaceMenu1 auto

ObjectReference Property ToT_TriggerBase Auto           ;Trigger or TriggerBase
Form Property ToT_Trigger Auto
ObjectReference Property ToT_TriggR Auto

Event OnActivate(ObjectReference akActionRef)
    If akActionRef == Game.GetPlayer()
        Menu()
    EndIf
EndEvent

Function Menu(int Button = 0)
    Button = ToT_FireplaceMenu1.show()
    If Button == 0                                      ;Wants fast food = original cooking
    ElseIf Button == 1                                  ;Wants create food
                                                        ;Get ready for trigger setup
	float posX = Self.GetPositionX() + 28
        float posY = Self.GetPositionY() - 2.5
        float posZ = Self.GetPositionZ() + 44.4

        ;ToT_TriggerBase.SetPosition(posX, posY, posZ) - Works, but only same interior
        ToT_Trigger = ToT_TriggerBase.GetBaseObject()
        ToT_TriggR = PlaceAtMe(ToT_Trigger)
        ToT_TriggR.MoveTo(Self,28,-2.5,44.4)

        ToT_IsCooking.SetValueInt(1)                    ;Setup cooking
        Debug.Notification("The pot is warm enough")
        Return                                          ;Close craft menu NOT WORK YET!

        ElseIf Button == 2                              ;Wants look
        ElseIf Button == 3                              ;Wants finish
                                                        ;Unload cooking
        ToT_IsCooking.SetValueInt(0)
        ;ToT_TriggerBase.Delete()
    EndIf
EndFunction
Link to comment
Share on other sites

If the cell isn't loaded, you can't do anything with it. So, if you are in the Bannered mare, you can't drop an object into the Drunken Huntsman. What you CAN do, is set a quest variable, so that when you walk into the proper cell, the quest will check the variable, and if conditions are correct, add or enable the object.

Link to comment
Share on other sites

Can you explain what You want to do?...

Step by step?...

 

Why would you want to move this tirggerbox?...

 

 

You want to create something like "Craftable Cooking Station" ?...

 

1) Create empty cell

2) Create Sweetroll and give it MasterScript to handle this

3) Create spell or whatever you want to use to spawn Cooking pot

4) Using spell communicate with Sweetroll

 

you can use

 

<Target>.Activate( <User> )

example:

 

Cook.Activate( self );

You can also use Keywords to decide what you want from "Cook" Reference

 

"Cook" reference handle everything and only recive messages from world

 

Event OnActivate( ObjectReference Qref )

if( QRef == ValidRef )

if( QRef.haskeyword( spawn_cooking_pot )

SpawnPotOnPlayer()

else if ( ... )

 

...

 

EndIf

EndEvent

 

 

in short... but im still not sure what you want to do...

if you could explain what exacly you want to do i could help u more...

 

Look at this vide:

https://www.youtube.com/watch?v=fpb1LYRub54 

if You need something from it here are scripts:

 

 

 

Main Script:

 

 

Scriptname QLG_Script_Soda extends ObjectReference  
{ This Script handle its Soda }
Import Sound
;===- Base Info. -===;
 ;Created: 2019-10-11
 ;Update: 2019-10-11
 ;Author: TobiPL
 ;Unit: M.PC<1>
;===- Var. setup -============================================
	Actor Property QPlayer Auto
	{ Player Ref. }
	GlobalVariable Property MachineMoney Auto
	{ Money inside Soda Machine }
	GlobalVariable Property SodaFree Auto
	{ Can be used only if Soda Slot is Free }
	GlobalVariable Property SodaID Auto
	{ Here is ID of Soda player pick }
;===- Items Var. -===============================
;***********************************************;
	ObjectReference Property MySoda Auto
	Float Property MySoda_Price Auto
	int Property MySoda_ID Auto
	
	ObjectReference Property SodaSource Auto
	ObjectReference Property SodaTarget Auto
	
	ObjectReference Property SodaTake Auto
	
	Message Property NoMoney Auto

	Sound Property SoundSodaButton Auto
	Sound Property SoundSodaError Auto
;================================================
;===- Main Script -==============================
;***********************************************;
Event OnActivate( ObjectReference QRef )
	If( QRef == QPlayer )
		If( SodaFree.GetValue() != 1 )
			If( MachineMoney.GetValue() > MySoda_Price )
				
				int SoundTemp = SoundSodaButton.Play( self )
					Utility.Wait( 0.5 )
				StopInstance( SoundTemp )
			
				SodaFree.SetValue( 1 )
				MachineMoney.Mod( -2 )
				SodaID.SetValue( MySoda_ID )
				
					PlaySoda()
				
				SodaTake.enable()
					
					Else	; NO ENOUGH MONEY IN SODA MACHINE
				int SoundTemp = SoundSodaError.Play( self )
					Utility.Wait( 0.5 )
				StopInstance( SoundTemp )
				NoMoney.Show()
			EndIf
		EndIf
	EndIf
EndEvent

	Sound Property SoundSodaMachine Auto
Function PlaySoda()
	int SoundTemp = SoundSodaMachine.Play( self )
		Utility.Wait( 5.4 )
		MySoda.TranslateToRef( SodaSource, 100 , 444 )
		Utility.Wait( 0.7 )
		MySoda.TranslateToRef( SodaTarget, 100 , 444 )
		Utility.Wait( 1.7 )
	StopInstance( SoundTemp )
EndFunction
; The End

; SODA ID
; Zip			( 0 )
; ZipLite		( 1 )
; Cherry		( 2 )
; Dr.Pepper		( 3 )
; Mr.Fizz		( 4 )
; Boom			( 5 )
; Beveredge		( 6 ) 

 

 

Script to handle Money input:

 

 

Scriptname QLG_Script_SodaMoney extends ObjectReference  
{ This Script handle Money Input for Soda Machine }
Import Sound
;===- Base Info. -===;
 ;Created: 2019-10-11
 ;Update: 2019-10-11
 ;Author: TobiPL
 ;Unit: M.PC<1>
;===- Var. setup -============================================
	Actor Property QPlayer Auto
	{ Player Ref. }
	GlobalVariable Property Credits Auto
	{ Player Credits Ref. pick ( QLG_Global_Credits ) }
	GlobalVariable Property MachineMoney Auto
	{ Money inside Soda Machine }
;===- Items Var. -===============================
;***********************************************;
	Message Property SodaNoMoney Auto
	Sound Property SoundSodaButton Auto
	Sound Property SoundSodaError Auto
;===- DEBUG MESSAGE CONTROL -===****************;
	GlobalVariable Property QDebug Auto
	{ Global, true/false to show Debug Notifications ! 
		please, use "QLG_DEBUG_SCRIPT" }
;================================================
;===- Main Script -==============================
;***********************************************;
Event OnActivate( ObjectReference QRef )
	If( QRef == QPlayer )
		If( Credits.GetValue() > 2 )
			int SoundTemp = SoundSodaButton.Play( self )
			Credits.Mod( -2 )
			Debug.Notification( ":ChipBank: Paid 2 Credits to Soda Machine" )
			Utility.Wait( 0.5 )
			StopInstance( SoundTemp )
			MachineMoney.Mod( 2 )
				Else
			int SoundTemp = SoundSodaError.Play( self )
			Utility.Wait( 0.5 )
			StopInstance( SoundTemp )
			SodaNoMoney.show()
		EndIf
	EndIf
EndEvent
; The End 

 

 

Script to recive soda:

 

 

Scriptname QLG_Script_SodaTake extends ObjectReference   
{ This script give player his Soda }
;===- Base Info. -===;
 ;Created: 2019-10-11
 ;Update: 2019-10-11
 ;Author: TobiPL
 ;Unit: M.PC<1>
;===- Var. setup -============================================
	Actor Property QPlayer Auto
	{ Player Ref. }
	GlobalVariable Property SodaFree Auto
	{ Can be used only if Soda Slot is Free }
	GlobalVariable Property SodaID Auto
	{ Here is ID of Soda player pick }
;===- Items Var. -===============================
;***********************************************;
	FormList Property SodaForm Auto
	GlobalVariable Property QDebug Auto
	{ Global, true/false to show Debug Notifications ! 
		please, use "QLG_DEBUG_SCRIPT" }
;================================================
;===- Main Script -==============================
;***********************************************;
Event OnActivate( ObjectReference QRef )
	If( QRef == QPlayer )
		If( SodaFree.GetValue() == 1 )
			SodaFree.SetValue( 2 )
			QPlayer.AddItem(SodaForm.GetAt(((SodaID.GetValue()*2)+1 ) as Int ), 1)
			(SodaForm.GetAt((SodaID.GetValue()*2) as Int ) as ObjectReference ).TranslateToRef(SodaForm.GetAt(14) as ObjectReference , 100 , 500 )
			(SodaForm.GetAt((SodaID.GetValue()*2) as Int ) as ObjectReference ).TranslateToRef(SodaForm.GetAt(15) as ObjectReference , 100 , 500 )
			Utility.Wait( 0.2 )
			self.Disable()
		EndIf
	EndIf
EndEvent
; The End
; Discord: https://discord.gg/2Vh6NVc 

 

 

 

 

 

keep in mind that my english is pretty potato

If you want you can download my .esp from discord too see how everything is setted

 

explain what you want to do in easy english so i can help you :x...

right now all i know is that you want to move trigger between cells

 

 

https://discord.gg/2Vh6NVc

Link to comment
Share on other sites

Set everything to a global variable. The cell reacts based on the global when entering.

GlobalVariable Property Vat Auto ; <-- set up the global for script use

 

Int BrewVat = 0 ; <-- set up an int to hold the value so I don't need to keep re-reading the global.

 

BrewVat=(Vat.GetValueInt()) ; <-- get the global

 

If(BrewVat==(1)) ; <-- test the global

;set things up one way

 

ElseIf(BrewVat==(2))

;set things up the other way

 

EndIf

 

----------- other script from other cell

 

GlobalVariable Property Vat Auto ; <-- set up the global for script use

 

Vat.SetValueInt(1) ; <-- set the global

 

 

You will also need to physically set up a usable global in the creation kit.

Just duplicate one (with the same type of variable you're going to be using and rename it).

(in this case I used a int ... just looking for a simple number to key off)

Edited by NexusComa
Link to comment
Share on other sites

Thank you all of you for reply!

I wasn't specific enough.

 

 

HeyYou, It was the base problem, can't access an object from another, unloaded cell.

 

 

TobiaszPL, You're right, I need to explain better.

Your mod are great, I've read the scripts too, and maybe I want something like the Script of recive soda.

Although, it should be a Fallout mod too :D

So my idea, create an immersive, more realistic cooking mechanism than Skyrim has.

There are two main things, First is drag and drop, you need to grab the ingredients, and drop into the pot.

Here is the problem, Skyrim has a lot of cooking spits, and need to be compatible with most of big mods,

like Campfire, so I can't place the triggers manual.

The Second thing is the cooking of every ingredient have time.

When you done, resets your inventory and give you only the ingredients you cooked, and opens the cooking craft menu.

Well, this last one not too nice solution, but i'm not here yet.

 

So my problem now, I spawn one trigger from the base object, but it doesn't work.

What i know?

- When it spawns, the script works.

Event OnInit()
	Debug.Notification("Collision works")
EndEvent

Works right.

- It has the right position in every cell by GetPositionX..Y..Z.

- It has 10x10 sizes by GetLength, GetWidth

Event OnTriggerEnter(ObjectReference akActionRef)
	Debug.Notification("Something works!")
	...
EndEvent 

But this event not works, not triggered by actors or items.

 

 

NexusComa I have the IsCooking global variable, this for to create/delete the actual triggers.

I will need an 'saveable' array for the ingredients, because I don't want lose every dropped ingredients when restarted the game.

 

If you have solutions, or different ideas, share with me pls!

Link to comment
Share on other sites

In order to make the Trigger Box to be able to react to the ingredient you need to change the trigger's box " Collision Layer " from " L_Actortrigger " to " TRIGGER " and define in the script's properties the Ingredient as the trigger Reference ( If akActionRef == ingredient ).

 

One way to do this by not editing every single cooking pot in Skyrim or editing all cooking pots in CK, is :
Place in the Player a script that will search / detect when the player is near a cooking pot and then fire / do its stuff.
Edited by maxarturo
Link to comment
Share on other sites

When was an trigger on the map, it worked, OnTriggerEnter() event worked perfectly, but i couldn't move it to another cell.

So now there is just the "base object" activator

http://users.atw.hu/fantasyrp/src/ck1.jpg

 

The script create a trigger from this

ToT_TriggR = Self.PlaceAtMe(ToT_Trigger,1,true)
ToT_TriggR.MoveTo(Self,28,-2.5,44.4)

After the debug says it's on the right position.

Just doesn't work the OnTriggerEnter() event.

 

I'll come back afternoon, to try some stuffs, thanks for replies!

Link to comment
Share on other sites

Since my last reply i tried some things.

I learn the basics continuously, and see we have limits, with and without SKSE too.

I found two Fallout 4 functions may can do this right, but it won't help me.

 

A little improve, I created a local variable for reading the global.

This works well.

 

Trigger-thing

The problem hold true, i can define little bit better.

If I create a trigger in the editor from my trigger-base activator, works fine anywhere.

So the checking script is good.

When I create a trigger from script with PlaceAtMe, the "object" created, but the trigger function not working.

Maybe we can't create a working trigger after cell load.

 

I found the Location Ref Type tab on references and brings me a hope for first idea, moving the number one trigger from Bannered Mare.

I can't figure out how it works exactly, think i need to look after the quest system.

This can be more compatible and easier way, than create trigger for every pots with hand.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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