Jump to content

[LE] EquipItem script function not working.


Andrew1024

Recommended Posts

I'm make a no-death mod where the Player gets teleported to Beggars Row and loses all his/her items on death. The effect works. The Player dies, screen fade, all items get destroyed and you have a set of ragged robes and ragged boots in your inventory. Problem is when I use the line Game.GetPlayer().EquipItem(ItemProperty) from the wiki it doesn't work. They are still naked. Here is my script so far...

 

Scriptname __Teleport__Script extends activemagiceffect

ObjectReference Property Loc01 Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
Game.FadeOutGame(False, True, 2.0, 1.0)
Game.GetPlayer().RemoveAllItems()
Game.GetPlayer().AddItem(Feet, 1, true)
Game.GetPlayer().AddItem(torso, 1, true)
akTarget.Moveto(Loc01)
Debug.MessageBox("You have bled-out and died. You have been sent back to the land of the living, but it has cost you all of your worldy possessions. All that you own are the clothes on your back and a bedroll to lay your head.")
EndEvent


ObjectReference Property torso Auto

ObjectReference Property Feet Auto

 

As I said, it all works up to this point and all I need to finish that part of the mod is for the Boots and Robes in their inventory to auto-equip. Can anyone help?

Link to comment
Share on other sites

Do not use RemoveAllItems without sending the items to a container. There could be objects that they want to keep and cannot obtain again. Send the items to a container somewhere so they could retrieve them if they wish.

 

Did you fill the properties correctly? Are you testing on a new game or save that has not seen the mod in question before?

Link to comment
Share on other sites

I almost wonder if you might be better served triggering the go-to-jail routines instead. Set up a crime faction and use the Faction function SendPlayerToJail(). You could set up a prisoner outfit, chests for items, etc, in much the same way. With a *bit* of work you might even be able to make the items appear at the site of death instead...

Link to comment
Share on other sites

Your using ObjectReference Property values!!

 

Try Armor Properties for Beggars cloths, your possible mistake.....

 

So to fix, change ObjectReference properties to Armor, leave additem alone if the same values match Armor Properties, else change to suite, then....

; Forces this actor to equip the specified item, preventing removal if requested
Function EquipItem(Form akItem, bool abPreventRemoval = false, bool abSilent = false) native 

Should work fine.

 

Unless you have place beggars clothes in the world somewhere? Then Filled the values correctly??? Then my BAD. & I have no idea why it not working.

 

But that not necessary... & over kill. & asking for trouble on repeat Events. Use Armor Property to point to the Beggars Clothes & Feet.

 

Cheers you dark soul fan you. Have fun losing your gear.

Link to comment
Share on other sites

No idea, next will help to fix your equipment issue.

Please take note from links inside the script!

 

__Teleport_PlayerDead_Script

 

Scriptname __Teleport_PlayerDead_Script extends ActiveMagicEffect  
; https://forums.nexusmods.com/index.php?/topic/7154866-equipitem-script-function-not-working/

  ObjectReference PROPERTY TeleportMarker auto    ; xMarker set by CK
  ObjectReference PROPERTY myChest        auto    ; container (placed anywhere in Skyrim) by CK to transfer all player collected items

; beggar armor addons, maybe this is what you used
 ;Armor PROPERTY BeggarTorso01AA auto            ; BeggarTorso01AA [ARMA:00013101]
 ;Armor PROPERTY BeggarBoots01AA auto            ; BeggarBoots01AA [ARMA:00013102]

; beggar clothes
  Armor  PROPERTY ClothesBeggarRobes auto        ; [ARMO:00013105] "Ragged Robes"
  Armor  PROPERTY ClothesBeggarBoots auto        ; [ARMO:00013106] "Ragged Boots"
  Outfit PROPERTY BeggarOutfit       auto        ; [OTFT:00028B60] BeggarOutfit


; -- EVENT --

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
IF (akTarget == Game.GetPlayer())
ELSE
    self.Dispel()
    RETURN    ; - STOP -    not the player, safety net
ENDIF
;---------------------
; https://www.creationkit.com/index.php?title=UnequipAll_-_Actor
    akTarget.UnEquipAll()                            

; https://www.creationkit.com/index.php?title=RemoveAllItems_-_ObjectReference
    akTarget.RemoveAllItems(myChest, TRUE, False)    

; https://www.creationkit.com/index.php?title=FadeOutGame_-_Game
    Game.FadeOutGame(False, TRUE, 2.0, 1.0)            ; Spend 2 seconds on a black screen before fading in (instantly removed after the fade-in)

    akTarget.MoveTo(TeleportMarker)
    Utility.Wait(0.1)

; https://www.creationkit.com/index.php?title=SetOutfit_-_Actor
    akTarget.SetOutfit(BeggarOutfit, False)
;;;    akTarget.AddItem(ClothesBeggarRobes, 1, TRUE)
;;;    akTarget.AddItem(ClothesBeggarBoots, 1, TRUE)

; *** Note: "EquipItem() does not work with leveled items". ***
; https://www.creationkit.com/index.php?title=EquipItem_-_Actor
    akTarget.EquipItem(ClothesBeggarRobes, False, TRUE)
    akTarget.EquipItem(ClothesBeggarBoots, False, TRUE)

    Debug.MessageBox("You have bled-out and died. You have been sent back to the land of the living, but it has cost you all of your worldy possessions. All that you own are the clothes on your back and a bedroll to lay your head.")
ENDEVENT

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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