Jump to content

[LE] Script on a trigger that activate a Display Case


Recommended Posts

Seeing the code actually helps. Have you tried activating the "weapon rack" imbedded in the display case? When a weapon is in a rack, doesn't the player take the weapon when activating it? So.. instead of trying to add / move the item into the player's inventory, just activate the rack again. At least worth testing to see what happens.

Link to comment
Share on other sites

Seeing the code actually helps. Have you tried activating the "weapon rack" imbedded in the display case? When a weapon is in a rack, doesn't the player take the weapon when activating it? So.. instead of trying to add / move the item into the player's inventory, just activate the rack again. At least worth testing to see what happens.

 

Yes, it was the first thing I thought about, if activated the first time it puts the weapon inside the display case, in theory activating it when the weapon is already inside the display case it should remove it, as it normally does, instead it always activates the first action only to insert the weapon in the display case...

The script was like the following and it dsn't work as i would (i've changed the Teca.Activate(Game.GetPlayer()) with Teca.SetOpen(1 and 0) to make it more comprensible)

 

 

If aiButton == 1

If CheckArmaEsposta == 1

Teca.SetOpen(1)

Utility.Wait(1)

Espositore.Activate(Game.GetPlayer())

Utility.Wait(1)

Teca.SetOpen(0)

CheckArmaEsposta = 0

Else

Debug.MessageBox("La teca è vuota")

EndIf

EndIf

 

 

Edited by Tiziano74
Link to comment
Share on other sites

OK

I've solved so, but id really like to find a way to remove the weapon from the display case by script . . .

 

I made 2 triggers, the 1st one that activate the menu and the 2nd one that when left reanable the 1st one

I've decided also to not check if inside the display case i've put the weapon (the Player can see it by himself), btw does exist a different metod to chech if the display case is empty or not?

 

In the 1st trigger i've put this script:

 

 

 

Scriptname QLH_Teca_Arma_Thane_script_01 extends ObjectReference

Quest Property QuestThane Auto
Int Property Stage Auto
String Property NomeCitta Auto
Actor Property PlayerRef Auto
ObjectReference Property Espositore Auto
ObjectReference Property CollisionMarker Auto
ObjectReference Property TriggerChiudiTeca Auto
ObjectReference Property Teca Auto
ObjectReference Property XMarkerHeadingPortale Auto
Message Property MenuTeca Auto

Weapon ArmaSinistra
Weapon ArmaDestra
Weapon ArmaEsposta

Event OnActivate(ObjectReference akActionRef)
If (QuestThane.GetStageDone(Stage))
Menu()
Else
Debug.MessageBox("In questa teca potrai esporre l'arma che ti sarà donata dallo Jarl di " + NomeCitta + " quando ti nominerà Thane, ed attivare il Portale per " + NomeCitta + ", ma non sei ancora stato nominato Thane di " + NomeCitta)
EndIf
EndEvent

Function Menu(int aiButton = 0)
aiButton = MenuTeca.show()
If aiButton == 0
ArmaSinistra = Game.GetPlayer().GetEquippedWeapon(True) as Weapon
ArmaDestra = Game.GetPlayer().GetEquippedWeapon() as Weapon
If (ArmaSinistra == "None") && (ArmaDestra == "None")
Debug.MessageBox("Devi avere l'arma equipaggiata per poterla esporre")
ElseIf (ArmaSinistra != "None") && (ArmaDestra != "None")
Debug.MessageBox("Hai 2 armi diverse equipaggiate, puoi equipaggiarne solo una da esporre")
ElseIf (ArmaSinistra != "None") && (ArmaDestra == "None")
ArmaEsposta = ArmaSinistra as Weapon
Teca.SetOpen(1)
Utility.Wait(1)
Espositore.Activate(Game.GetPlayer())
Utility.Wait(1)
Teca.SetOpen(0)
ElseIf (ArmaSinistra == "None") && (ArmaDestra != "None")
ArmaEsposta = ArmaDestra as Weapon
Teca.SetOpen(1)
Utility.Wait(1)
Espositore.Activate(Game.GetPlayer())
Utility.Wait(1)
Teca.SetOpen(0)
EndIf
EndIf
If aiButton == 1
Teca.SetOpen(1)
Utility.Wait(1)
CollisionMarker.Disable()
TriggerChiudiTeca.Enable()
Self.Disable()
Debug.MessageBox("La teca è stata sbloccata. Ora puoi prendere l'arma al suo interno.")
EndIf
If aiButton == 2
Game.FadeOutGame(False, True, 2.0, 1.0)
Game.GetPlayer().MoveTo(XMarkerHeadingPortale)
Game.EnableFastTravel()
Game.FastTravel(XMarkerHeadingPortale)
EndIf
EndFunction

 

 

In the 2nd trigger i've put this one:

 

 

 

Scriptname QLH_Chiusura_Teca_Arma_Th_script_01 extends ObjectReference

Actor Property PlayerRef Auto
ObjectReference Property CollisionMarker Auto
ObjectReference Property Teca Auto
ObjectReference Property TriggerMenu Auto

Event OnTriggerLeave(ObjectReference triggerRef)
Teca.SetOpen(0)
Utility.Wait(0)
CollisionMarker.Enable()
TriggerMenu.Enable()
Self.Disable()
EndEvent

 

 

 

If anyone has a better idea please let me know!

Really thanks Ishara for the help!

Edited by Tiziano74
Link to comment
Share on other sites

This assumes that the script on your weapon rack is: WeaponRackActivateSCRIPT

Access the hidden property PlayersDroppedWeapon on the previously mentioned script. You should then be able to use AddItem to move the weapon to the player inventory.

 

In the empty state where you define properties add this:

WeaponRackActivateSCRIPT WRAScript

 

Before calling the menu in the OnActivate event add this:

WRAScript = Espositore as WeaponRackActivateSCRIPT

 

Then when wanting to get the weapon from the rack use this:

PlayerRef.AddItem(WRAScript.PlayersDroppedWeapon)

 

This, of course, assumes that you do not have a mod which drastically changes the stock WeaponRackActivateSCRIPT. I know that the unofficial patch has a variant of the script, so you'll need to investigate if the property is still in use on that version.

 

When you tried AddItem before, it was using the base object as opposed to the specific object reference. This is why it was creating a new instance in the inventory rather than moving it.

Link to comment
Share on other sites

This assumes that the script on your weapon rack is: WeaponRackActivateSCRIPT

Access the hidden property PlayersDroppedWeapon on the previously mentioned script. You should then be able to use AddItem to move the weapon to the player inventory.

 

In the empty state where you define properties add this:

WeaponRackActivateSCRIPT WRAScript

 

Before calling the menu in the OnActivate event add this:

WRAScript = Espositore as WeaponRackActivateSCRIPT

 

Then when wanting to get the weapon from the rack use this:

PlayerRef.AddItem(WRAScript.PlayersDroppedWeapon)

 

This, of course, assumes that you do not have a mod which drastically changes the stock WeaponRackActivateSCRIPT. I know that the unofficial patch has a variant of the script, so you'll need to investigate if the property is still in use on that version.

 

When you tried AddItem before, it was using the base object as opposed to the specific object reference. This is why it was creating a new instance in the inventory rather than moving it.

WOW!!!!

Thanks really!!!

I have the last USSEP installed and the script WORKS!!

What if id like to know if the Display Case is empty or not?

 

BTW this is the last script:

 

 

 

Scriptname QLH_Teca_Arma_Thane_script_01 extends ObjectReference

 

Quest Property QuestThane Auto

Int Property Stage Auto

String Property NomeCitta Auto

Actor Property PlayerRef Auto

ObjectReference Property Espositore Auto

ObjectReference Property Teca Auto

ObjectReference Property XMarkerHeadingPortale Auto

Message Property MenuTeca Auto

 

Weapon ArmaSinistra

Weapon ArmaDestra

Weapon ArmaEsposta

 

WeaponRackActivateSCRIPT WRAScript

 

Event OnActivate(ObjectReference akActionRef)

If (QuestThane.GetStageDone(Stage))

WRAScript = Espositore as WeaponRackActivateSCRIPT

Menu()

Else

Debug.MessageBox("In questa teca potrai esporre l'arma che ti sarà donata dallo Jarl di " + NomeCitta + " quando ti nominerà Thane, ed attivare il Portale per " + NomeCitta + ", ma non sei ancora stato nominato Thane di " + NomeCitta)

EndIf

EndEvent

 

Function Menu(int aiButton = 0)

aiButton = MenuTeca.show()

If aiButton == 0

ArmaSinistra = Game.GetPlayer().GetEquippedWeapon(True) as Weapon

ArmaDestra = Game.GetPlayer().GetEquippedWeapon() as Weapon

If (ArmaSinistra == "None") && (ArmaDestra == "None")

Debug.MessageBox("Devi avere l'arma equipaggiata per poterla esporre")

ElseIf (ArmaSinistra != "None") && (ArmaDestra != "None")

Debug.MessageBox("Hai 2 armi diverse equipaggiate, puoi equipaggiarne solo una da esporre")

ElseIf (ArmaSinistra != "None") && (ArmaDestra == "None")

ArmaEsposta = ArmaSinistra as Weapon

Teca.SetOpen(1)

Utility.Wait(1)

Espositore.Activate(Game.GetPlayer())

Utility.Wait(1)

Teca.SetOpen(0)

ElseIf (ArmaSinistra == "None") && (ArmaDestra != "None")

ArmaEsposta = ArmaDestra as Weapon

Teca.SetOpen(1)

Utility.Wait(1)

Espositore.Activate(Game.GetPlayer())

Utility.Wait(1)

Teca.SetOpen(0)

EndIf

EndIf

If aiButton == 1

Teca.SetOpen(1)

Utility.Wait(1)

PlayerRef.AddItem(WRAScript.PlayersDroppedWeapon)

Utility.Wait(1)

Teca.SetOpen(0)

EndIf

If aiButton == 2

Game.FadeOutGame(False, True, 2.0, 1.0)

Game.GetPlayer().MoveTo(XMarkerHeadingPortale)

Game.EnableFastTravel()

Game.FastTravel(XMarkerHeadingPortale)

EndIf

EndFunction

 

 

Edited by Tiziano74
Link to comment
Share on other sites

 

To check if it is empty, check the status of the PlayersDroppedWeapon

If WRAScript.PlayersDroppedWeapon ;a valid object is assigned, display must have a weapon
  ;do something
Else
  ;do something else
EndIf

Perfect!!

THANKS!!!

 

Link to comment
Share on other sites

I just looked at the script, what I posted earlier will only work when the display is empty to begin with. The WeaponRackActivateSCRIPT never empties the property. It only updates the value when a new weapon is displayed. You'll have to call is3dLoaded on the weapon instance instead. Since the weapon's 3D cannot be loaded when in inventory or a container, it will always be false when the display is empty.

If WRAScript.PlayersDroppedWeapon 
  ;valid object -- check if display is full
  If WRAScript.PlayersDroppedWeapon.is3dLoaded()  
    ;weapons 3d is loaded display is full
    ;do something
  Else
    ;weapons 3d is not loaded display is empty
    ;do something else
  EndIf
Else
  ;not a valid object -- display is empty
  ;do some other thing
EndIf
Link to comment
Share on other sites

Thanks again!

 

Now that the SKSE finally works, i'm going to check the name of the weapon displayed, because is a random generated one, but the name is always the same, so i can check if is exactly the Riften Sword

 

 

 

If aiButton == 0
ArmaSinistra = Game.GetPlayer().GetEquippedWeapon(True) as Weapon
ArmaDestra = Game.GetPlayer().GetEquippedWeapon() as Weapon
If (ArmaSinistra == "None") && (ArmaDestra == "None")
Debug.MessageBox("Devi avere l'arma equipaggiata per poterla esporre")
ElseIf WRAScript.PlayersDroppedWeapon
If WRAScript.PlayersDroppedWeapon.is3dLoaded()
Debug.MessageBox("C'è già un'arma esposta nella teca!")
EndIf
ElseIf (ArmaSinistra != "None") && (ArmaDestra != "None")
Debug.MessageBox("Hai 2 armi diverse equipaggiate, puoi equipaggiarne solo una da esporre")
ElseIf (ArmaSinistra != "None") && (ArmaDestra == "None")
ArmaEsposta = ArmaSinistra as Weapon
Teca.SetOpen(1)
Utility.Wait(1)
Espositore.Activate(Game.GetPlayer())
Utility.Wait(1)
Teca.SetOpen(0)
ElseIf (ArmaSinistra == "None") && (ArmaDestra != "None")
ArmaEsposta = ArmaDestra as Weapon
Teca.SetOpen(1)
Utility.Wait(1)
Espositore.Activate(Game.GetPlayer())
Teca.SetOpen(0)
Utility.Wait(1)
NomeArmaEsposta = ArmaEsposta.GetName()
Debug.MessageBox("Hai esposto: " + NomeArmaEsposta)
If AttivazionePortale != 1
Debug.MessageBox("Congratulazioni Thane di " + NomeCitta + "! Da ora in poi puoi teletrasportarti direttamente a " + NomeCitta + " utilizzando il Portale nel menu di questa teca!")
AttivazionePortale = 1
EndIf
EndIf
EndIf

 

Link to comment
Share on other sites

Hi again

Another issue

Now i want to check if in the Name of the displayed weapon there is the string "Rift", to identify that the weapon being displayed is the one given by the Jarl to the player.

 

To identify the weapon's name i used this code

String NomeArmaEsposta = WRAScript.PlayersDroppedWeapon.GetBaseObject().GetName()

To check if "Rift" is in the weapon's name i used this one, and then I would have introduced an If

Int ControlloNomeArmaEsposta = StringUtil.Find(NomeArmaEsposta, "Rift")

I made a check on the NomeArmaEsposta with a debug.messagebox and NomeArmaEsposta doesn't take the real name of the weapon "Blade of the Rift" but it takes the base name of the random created weapon (for example) "Iron Sword of Souls" :dry:

I put the check after the Menu function, so as to be sure, at least I thought, that the name of the weapon was correct.

How can i have the reall weapon's name?

Edited by Tiziano74
Link to comment
Share on other sites

  • Recently Browsing   0 members

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