Digineaux Posted February 5, 2020 Share Posted February 5, 2020 I've made A custom NPC Follower which is supposed to be moved to/spawned nest to the player upon equipping the Masque of Clavicus Vile. It summons him fine, but on repeated use it spawns a copy instead of moving the original.Scriptname DBFSummonBarbas extends ObjectReference ActorBase Property Barbas AutoEvent OnEquipped(Actor akActor)If (akActor == Game.GetPlayer())Enable(Barbas) Actor PlayerRef = Game.GetPlayer()Game.GetPlayer().PlaceActorAtMe(Barbas)EndIfEndEventI tried the MoveTo function listed here https://www.creation...ObjectReference and here https://www.creation...hp?title=MoveTo. But despite being listed twice on the official documentation "MoveTo is not a function or does not exist" according to the papyrus compiler using;Barbas.MoveTo(PlayerRef) Link to comment Share on other sites More sharing options...
maxarturo Posted February 5, 2020 Share Posted February 5, 2020 (edited) PlaceActorAtMe & PlaceAtMe will create a "NEW INSTANCE" of the object and not move the original, so everytime you use this function you will be creating new actors. You need to use: Function MoveTo(ObjectReference akTarget, float afXOffset = 0.0, float afYOffset = 0.0, float afZOffset = 0.0, bool abMatchRotation = true) native https://www.creationkit.com/index.php?title=ObjectReference.MoveTo_(Papyrus) But in order for this to work the actor must exist in the world, you need to place him in a cell, even if that is a simple Navmesh floor room cell. Example: Actor Property Barbas Auto Event OnEquipped(Actor akActor) If (akActor == Game.GetPlayer()) Barbas.MoveTo(akActor) EndIf EndEvent You also need to set the position of the "MoveTo" so that he won't just spawn out of thin air in front of the Player, but behind him, or where ever you might want. Beware that your script as it is will move the Actor every time you equip the helmet, if this is what you want then ok, but if not, then you will need to put STATES in your script so that it will only fire ONCE. * This is actually not summon... In order to "Summon" him you need to make a summon spell that OnEquip will fire. * You will also need to create a quest that will be listening when the Player equips the "Masque of Clavicus Vile", and in your quest insert a script that will summon him. Otherwise any action on the vanilla item is consider a "Dirty Edit". Edited February 5, 2020 by maxarturo Link to comment Share on other sites More sharing options...
Digineaux Posted February 5, 2020 Author Share Posted February 5, 2020 Thanks so much. Quote PlaceActorAtMe & PlaceAtMe will create a "NEW INSTANCE" of the object and not move the original, so everytime you use this function you will be creating new actors.I though that might be what was happening, i decided to test the similar console command in game on a few different npcs. Quote But in order for this to work the actor must exist in the world, you need to place him in a cell, even if that is a simple Navmesh floor room cell.Will it work if i use the "PlaceAtMe" once to create a reference in the world and then have an if statement to use the "moveto" from then on as long as the engine can find an already existing reference of him? If not will hiding him in the "elsweyr" cell with 'Maiq the liar' until the player gets the masque work? Essentially i don't want the player to be able to encounter him, until the original Barbas returns to Clavicus and gets disabled via the regular quest. Quote Beware that your script as it is will move the Actor every time you equip the helmet, if this is what you want then ok, but if not, then you will need to put STATES in your script so that it will only fire ONCE.Yeh that's exactly what i want. It's reasonably thematic and shouldn't cause any issues. Though i'm not sure if attaching a script to the helm will have compatibility issues with other mods that overhaul daedric artifacts and what not, but i can attach it to a custom item or something later if need be. Quote * You will also need to create a quest that will be listening when the Player equips the "Masque of Clavicus Vile", and in your quest insert a script that will summon him.Otherwise any action on the vanilla item is consider a "Dirty Edit".Well i think you already solved my compatibility concern lol. thanks again. Link to comment Share on other sites More sharing options...
Digineaux Posted February 5, 2020 Author Share Posted February 5, 2020 I want to punch whoever designed the Quest UI in the Creation kit. Why must everything be refined as an alias, when it's already defined in the creation kit? Why bother creating the tool at all, when all the triggers have to be manually scripted anyway? Why do half the buttons and checkboxes do literally nothing and nothing is automated? /Rant\ Quote You will also need to create a quest that will be listening when the Player equips the "Masque of Clavicus Vile"How do i get a quest to listen for such an event? I can't find any documentation or tutorials for triggering a quest that don't rely on the very unreliable "start game enabled" box or attaching a script to the item or actor in question to set stage. I could add a line to the clavicus vile quest to trigger my quest at completion, but that's just moving the dirty edit from the masque to the quest. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted February 5, 2020 Share Posted February 5, 2020 (edited) According to your first posting here, I assume the script (you have given here) has been attached to the mask of clavicus vile DBFSummonBarbasToPlayerScript Reveal hidden contents Scriptname DBFSummonBarbasToPlayerScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/8381548-spawn-unique-npc-without-creating-duplicates/ ActorBase PROPERTY Barbas auto ; have to be filled with CK Actor myBarbas ; placeholder for spawned actor ; -- EVENTs -- 4 EVENT OnInit() Debug.Trace(self+" OnInit() -- has been reached.. spawner BaseObject = " +Barbas) ENDEVENT EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) IF (akOldContainer == Game.GetPlayer() as ObjectReference) IF ( myBarbas ) myBarbas.Delete() ; mark spawned actor for delete, remove actor persistence for "myBarbas" ENDIF ENDIF ENDEVENT EVENT OnUnEquipped(Actor akActor) IF ( myBarbas ) ; spawned Barbas exists, and player unequipped the mask of clavicus myBarbas.Disable(TRUE) ; switch OFF ENDIF ENDEVENT EVENT OnEquipped(Actor akActor) IF (akActor == Game.GetPlayer()) ELSE RETURN ; - STOP - mask not player equipped, do nothing ENDIF ;--------------------- akActor is the player IF ( myBarbas ) myBarbas.MoveTo(akActor as ObjectReference) ; move to player myBarbas.Enable(TRUE) ; switch ON ELSE myBarbas = akActor.PlaceActorAtMe(Barbas) ; spawn Barbas first time ENDIF ENDEVENT Edited February 5, 2020 by ReDragon2013 Link to comment Share on other sites More sharing options...
maxarturo Posted February 5, 2020 Share Posted February 5, 2020 (edited) "Will it work if i use the "PlaceAtMe" once to create a reference in the world and then have an if statement to use the "moveto"..." Yes it will work, but: 1) The script needs to have "States" so that "PlaceAtMe" fires only the first time you equip it. 2) If the Actor has some special "AI Packages" you will need to add an "Evaluate Package" on the script. * In testings where i need to have a follower i use "PlaceAtMe" to call a specific actor from a "Follower Mod" (from one of my favorites) that has extensive AI. I have notice that sometimes (3 out of 10) the actor placed is either unresponsive or frozen like a statue, and it needs "Console Command" to reset its AI. "If not will hiding him in the "elsweyr" cell with 'Maiq the liar' until the player gets the masque work?" "Essentially i don't want the player to be able to encounter him..." "Beware that your script as it is will move the Actor every time.." " You will also need to create a quest that will be listening when the Player equips the "Masque of Clavicus Vile"" 1) The quest doesn't needs to be an actual "Quest" but a dummy quest (it will never fire as a quest), it will only have the Player in a Ref Alias and the script. * This topic has been posted so many times in this Nexus forums, you can easily find a bunch of info on this an some awesome advice and guides from other experienced modder like IsharaMeradin, ReDragon2013... etc. I'm not going to rewrite something that has been written so many times... 2) One simple way that i would do this without creating quests or editing the helmet, is to: - Create a simple NavMesh cell without any connection to the world, and place there the actor. - Place in that cell an xMarker (rename it), so that your script can obtain heading target (it will be explained further down). - Create and place on the Actor (your actor) a script that will fire whenever the Player equips the helmet. - The script should be made with states and restrictions to avoid any issues if you equip > re equip the helmet multiple times while you are in MENU, as a fail safe. - The script will have 2 Event "OnEquip" and "OnUnequipped". OnEquip will summon the Actor to the Player. OnUnequipped will "summon" / return the Actor back to the cell. - The summon / unsummon should be handle by a Summon Spell, the main reason is that the spell has the advantage of not needing to define by script functions the position where to place the actor, it will place him in a NavMesh part of the cell near the player. By using script to pre define the position where the actor should be placed has the flaw of: What if you define to place the actor 4 meters behinde the Player, and the Player equips the helmet while he is standing with his back on a wall, and in the other side of the wall there is only VOID... I hope that this can help you... Have a happy modding !. Edited February 5, 2020 by maxarturo Link to comment Share on other sites More sharing options...
maxarturo Posted February 5, 2020 Share Posted February 5, 2020 I completely forgot that Barbas is an actual vanilla character and not a custom made by you actor. In this case this needs to be done ONLY with a dummy quest that will fire when the actual vanilla quest finish. You will need to start doing some research / learning on quests. Link to comment Share on other sites More sharing options...
foamyesque Posted February 5, 2020 Share Posted February 5, 2020 On 2/5/2020 at 10:12 AM, kodaxmax said: I want to punch whoever designed the Quest UI in the Creation kit. Why must everything be refined as an alias, when it's already defined in the creation kit? Why bother creating the tool at all, when all the triggers have to be manually scripted anyway? Why do half the buttons and checkboxes do literally nothing and nothing is automated? /Rant\ Quest Aliases are actually arguably one of the most potent things in the CK. In particular, they allow multiple mods to edit the same thing, alongside all the other stuff they enable like searching, radiant stuff, temporary changes to a thing, naming items, etc. Link to comment Share on other sites More sharing options...
Digineaux Posted February 6, 2020 Author Share Posted February 6, 2020 To clarify, the "Barbas" i'm spawning is a completely different actor to the vanilla one, for compatibility sake. I do not want to treat him like a summon spell, such as summon familiar. I just want him to be created/ summoned to the player on the first equip and then simply moved to the player on subsequent equips. I did have the script attached to the helm, but taking maxaturo's advice, im trying to attach it to a quests for compatibilitys sake. Quote The quest doesn't needs to be an actual "Quest" but a dummy quest (it will never fire as a quest), it will only have the Player in a Ref Alias and the script.I think i get, ill have to do some more testing. I couldn't find a search function for this forum yesterday, it seems it's only on some pages?. Quote What if you define to place the actor 4 meters behinde the Player, and the Player equips the helmet while he is standing with his back on a wall, and in the other side of the wall there is only VOID...From my own limited research and testing, both the moveto and placeAtMe functions will only place the actor on navmesh (unless there's none in range), regardless of parameters, so thats probably not an issue. but i will soon find out. Thankls for all the tips everyone, i have alot of new leads to learn and test. Link to comment Share on other sites More sharing options...
maxarturo Posted February 6, 2020 Share Posted February 6, 2020 (edited) Summon spells can also be used as a teleportation not just as "summon familiar" works. "both the moveto and placeAtMe functions will only place the actor on navmesh" This only occurs if the function doesn't have in its parametres a pre define where to place the actor position. Edited February 6, 2020 by maxarturo Link to comment Share on other sites More sharing options...
Recommended Posts