Jump to content

Recommended Posts

Posted

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.

Posted (edited)
  On 6/13/2021 at 1:13 PM, IsharaMeradin said:

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)

 

  Reveal hidden contents

 

Edited by Tiziano74
Posted (edited)

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:

 

 

  Reveal hidden contents

 

 

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

 

 

  Reveal hidden contents

 

 

If anyone has a better idea please let me know!

Really thanks Ishara for the help!

Edited by Tiziano74
Posted

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.

Posted (edited)
  On 6/13/2021 at 2:49 PM, IsharaMeradin said:

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:

 

 

  Reveal hidden contents

 

Edited by Tiziano74
Posted

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
Posted
  On 6/13/2021 at 11:13 PM, IsharaMeradin said:

 

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

 

Posted

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
Posted

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

 

 

  Reveal hidden contents

 

Posted (edited)

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
  • Recently Browsing   0 members

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