Jump to content

Create/add a non removal Item to a Follower.


Anathorn

Recommended Posts

Hi everyone!

 

I'm trying to add/Equip a non removal item to a Custom Follower. I'm using this script:

 

Link: https://www.creationkit.com/index.php?title=EquipItem_-_Actor

Function declaration: Function EquipItem(Form akItem, bool abPreventRemoval = false, bool abSilent = false) native

 

Game.GetPlayer().EquipItem(TutuProperty, true) This is working fine with the player. I can't remove/unequip the item

CustomFollower.getReference()..EquipItem(DressProperty, true) This is adding the item to my Follower, But I can still remove/unequip the Item.

 

If this is not possible using this function. How can I make a non removable item using the creation kit?, something like a quest required item.

 

Thanks in advance.

Link to comment
Share on other sites

Good catch on the difference between player and NPC removing item. Only the wearer is prevented from removing. I suppose you could script an OnItemUnequipped event ( https://www.creationkit.com/fallout4/index.php?title=OnItemUnequipped_-_Actor ) to force re-equipping and slap the player's hand, but that just feels ugly.

 

Is it something the follower *has* to wear, or can you hide it in a container or variable?

 

Edit: OnItemUnequipped triggers on actor for all items. If you just want the script on the item itself, use OnUnequipped ( https://www.creationkit.com/fallout4/index.php?title=OnUnequipped_-_ObjectReference )

Link to comment
Share on other sites

Thanks for the answer

 

answering yor questions: yes. Is it something that the follower *has* to wear. (at least in the firsts quest stages)

 

I'm new in the Fallout 4 creation kit and I have some questions:

 

1- Until this moment I know how to create Functions (Scripts) in the tab Scrips in the Quest ¿Can I create the Events in the same way?

2- If I create a Event like this OnItemUnequipped . I have to create this like a Script in a Quest? and ¿I have to call it like a normal function? or ¿The OnItemUnequipped will be always active for any unequipped event in the game?

3- Currently I'm calling the functions in the sateges of the Quest: For example FollowersScript.GetScript().SetCompanion(Companion.GetActorReference()). I have to call the Events in the same way?

 

I think another solution could be something like the vaultSuit, trying to make the item invisible in the inventory, but I don't have any idea how can I make something like this D:

 

If you could help with this I will be very greatfull.

 

Thanks in advance.

Link to comment
Share on other sites

1. Events are functions that go in your script.

 

2. You can attach the script that contains the event function to whatever makes the most sense, depending on what you are trying to accomplish. Actors, objects, quests.

 

When script is attached to actor or object, the script is notified when that event occurs (ie. you don't have to call the event function).

 

When script is attached to a quest, if you want script to be notified when event happens to actor or objectreference, you have to RegisterForRemoteEvent (remote because the event is not happening to the quest itself).

 

Events: https://www.creationkit.com/fallout4/index.php?title=Category:Events

 

Remote event registration: https://www.creationkit.com/fallout4/index.php?title=Remote_Papyrus_Event_Registration

 

RegisterForRemoteEvent: https://www.creationkit.com/fallout4/index.php?title=RegisterForRemoteEvent_-_ScriptObject

 

If you can't find a better solution than hand slapping* player (anyone? Idk...), the lesser of two evils would be an OnUnequipped event in a script attached to the ObjectReference that isn't supposed to be unequipped. The alternative, OnItemUnequipped in a script attached to NPC, would require handling unequips of any/all items the NPC ever uses.

 

3. Check the posted links and you'll send how event calls are automatic. The trick is listening for them in the right place, and having your code ready to implement your desired response.

 

Events are where the magic happens, in my opinion. You can do pretty much anything with enough trial and error.

 

But there may be a better non-event solution to your problem. I just don't know what it is.

 

* Hand slapping = letting the player do something (reach for the cookie jar) then telling them it was wrong to do. I agree that any solution that avoids that (hiding/locking the item) would be a better way to go.

 

Hmm... more examples? I'm not home, but have some things on Pastebin.

 

Scavver has several event functions: https://pastebin.com/u7p114FH

 

Line 46: OnInit

Line 68: OnItemAdded

Line 184: OnCombatStateChanged

Line 200: OnKill

Line 213: OnLocationChange

Line 265: OnRadiationDamage

Line 295: OnTimer

Line 361: OnItemEquipped

 

Note that my script is attached to Scavver (extends Actor, line 1). If you wanted to see all available events for Actors, check Actor Script wiki page: https://www.creationkit.com/fallout4/index.php?title=Actor_Script#Events

 

There are also wiki pages for ObjectReference Script, Container Script, Quest Script, etc. Those pages are where I usually start a project and browse what is possible.

Link to comment
Share on other sites

Thanks alot for the information. I tested many events and they are working now.

I have only one question. Some events like this

https://www.creationkit.com/fallout4/index.php?title=OnUnequipped_-_ObjectReference

When I try to attach the function to the scrip the compiler is forcing me to add the word «native»

With the word added the compile finish in sucess but the script do not work. What the «native» word mean?

 

Thanks in advance.

Link to comment
Share on other sites

you shouldn't use native keyword. You get errors because onunequipped is event of objectreference script. That means it should be called from that type of script objects. (The ones which extend objectreference)

If you still want to use it from another type of object you can use remote event https://www.creationkit.com/fallout4/index.php?title=Remote_Papyrus_Event_Registration

Link to comment
Share on other sites

  • Recently Browsing   0 members

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