mmft93 Posted May 3, 2017 Share Posted May 3, 2017 Could somebody take a look at my script and tell me what I've done wrong. I wanted to create a script that would spawn an NPC at the player when they activate my activator and do other things as well, everything else works except for the npc spawning. I've read just about all I could on the wiki and here's what I came up with....---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ScriptName MMFTDemonicShrine1 extends ObjectReferenceArmor property DiscipleRobes autoArmor property GoatHead autoWeapon property DaggerofCeremony autoPerk property MarkoftheDamned autoActor Property Familiar autoSpell property AzazelCurse autoActorBase MyActorBaseEvent OnActivate(ObjectReference akActionRef) If akActionRef == Game . GetPlayer() ; only the pla yer can activate this ObjectReference SelfObj = Self as ObjectReference AzazelCurse.cast(SelfObj, game.getplayer()) Game. GetPlayer(). AddItem(DiscipleRobes, 1, true) Game.GetPlayer().AddItem(GoatHead, 1, true) Game.GetPlayer().AddItem(DaggerofCeremony, 1, true) Game.GetPlayer().EquipItem(DiscipleRobes) Game.GetPlayer().EquipItem(GoatHead) Game.GetPlayer().EquipItem(DaggerofCeremony) Game.GetPlayer().AddPerk(MarkoftheDamned) MyActorBase = Familiar.GetBaseObject() as ActorBase PlaceActorAtMe(MyActorBase) utility.wait(1) SelfObj.delete() EndIfEndEvent ----------------------------------------------------------------------------------------------------------------------------------------- ....Like I said everything else works except the Npc I'm trying to spawn doesn't spawn. I looked up all I could on the CK wiki, so now I turn to you skyrim modding community :cool: Link to comment Share on other sites More sharing options...
Ghaunadaur Posted May 3, 2017 Share Posted May 3, 2017 Not sure, but try to replace 'GetBaseObject() as Actorbase' with 'GetActorBase()'...? Link to comment Share on other sites More sharing options...
foamyesque Posted May 3, 2017 Share Posted May 3, 2017 What do you have in that Actor property? Because that only works with things that are already spawned in the world. I think if you replace it with an ActorBase property instead, and then use that directly in the PlaceAtMe, it should work correctly. Link to comment Share on other sites More sharing options...
mmft93 Posted May 3, 2017 Author Share Posted May 3, 2017 Yeah it worked :laugh:! Thanks for the help guys I realized that foamyerque was right an that the actor would already have to be in skyrim, other wise I'd have to do as Ghaunadaur said.here's the new script in case anybody wants to know ------------------------------------------------------------------------------------------------------------------------------------------------ ScriptName MMFTDemonicShrine1 extends ObjectReferenceArmor property DiscipleRobes autoArmor property GoatHead autoWeapon property DaggerofCeremony autoPerk property MarkoftheDamned autoSpell property AzazelCurse autoActorBase property MyActorBase autoEvent OnActivate(ObjectReference akActionRef) If akActionRef == Game . GetPlayer() ; only the pla yer can activate this ObjectReference SelfObj = Self as ObjectReference AzazelCurse.cast(SelfObj, game.getplayer()) Game. GetPlayer(). AddItem(DiscipleRobes, 1, true) Game.GetPlayer().AddItem(GoatHead, 1, true) Game.GetPlayer().AddItem(DaggerofCeremony, 1, true) Game.GetPlayer().EquipItem(DiscipleRobes) Game.GetPlayer().EquipItem(GoatHead) Game.GetPlayer().EquipItem(DaggerofCeremony) Game.GetPlayer().AddPerk(MarkoftheDamned) Game.GetPlayer().PlaceActorAtMe(MyActorBase) utility.wait(1) SelfObj.delete() EndIfEndEvent ------------------------------------------------------------------------------------------------------------------------------------------------------- now that he spawns I have to figure out how to place him instead of spawning literally right at the player, like say behind the player. I'll check the wiki but if anybody knows how please let me know. Thanks again guys :laugh: Link to comment Share on other sites More sharing options...
foamyesque Posted May 3, 2017 Share Posted May 3, 2017 Spawn a marker, move the marker, spawn the NPC at the marker, delete the marker. Link to comment Share on other sites More sharing options...
Lisselli Posted May 3, 2017 Share Posted May 3, 2017 You can play around with the example on this page: http://www.creationkit.com/index.php?title=MoveTo_-_ObjectReferenceto get something behind the player. Link to comment Share on other sites More sharing options...
mmft93 Posted May 4, 2017 Author Share Posted May 4, 2017 (edited) Thanks for the reply I'm stuck though trying to move the NPC. I don't think the marker will work either because if I cant move the Npc I don't think I'd be able to move the marker.This is my script:------------------------------------------------------------------------------------------------------------------------------------------------ ScriptName MMFTDemonicShrine1 extends ObjectReferenceArmor property DiscipleRobes autoArmor property GoatHead autoWeapon property DaggerofCeremony autoPerk property MarkoftheDamned autoSpell property AzazelCurse autoActorBase property MyActorBase auto Function MoveTo(ObjectReference akTarget, float afXOffset = 0.0, float afYOffset = 0.0, float afZOffset = 0.0, bool abMatchRotation = false ) native Event OnActivate(ObjectReference akActionRef) If akActionRef == Game . GetPlayer() ; only the player can activate this ObjectReference SelfObj = Self as ObjectReference AzazelCurse.cast(SelfObj, game.getplayer()) Game. GetPlayer(). AddItem(DiscipleRobes, 1, true) Game.GetPlayer().AddItem(GoatHead, 1, true) Game.GetPlayer().AddItem(DaggerofCeremony, 1, true) Game.GetPlayer().EquipItem(DiscipleRobes) Game.GetPlayer().EquipItem(GoatHead) Game.GetPlayer().EquipItem(DaggerofCeremony) Game.GetPlayer().AddPerk(MarkoftheDamned) Game.GetPlayer().PlaceActorAtMe(MyActorBase) Actor PlayerRef = Game.GetPlayer() MyActorBase.SetPosition(PlayerRef, 120.0 * Math. Sin (Player Ref.GetAngleZ()), 120.0 * Math. Cos (Player Ref.GetAngleZ()), PlayerRef.GetHeight()) utility.wait(1) SelfObj.delete() EndIfEndEventEndFunction ------------------------------------------------------------------------------------------------------------------------------------------------------- This is the script I came up with based on the reading the wiki. Whenever I try to compile I get failed. it says no viable alternative at input '\\r\\n'error while attempting to read script MMFTDemonicShrine1: Object reference not set to an instance of an object.Not sure what that means. My first thought was that it doesn't know what actor to move since Myactorbase is an Actorbase not an Actor. So i tried setting the setposition command right after the spawn so it was like this:Game.GetPlayer().PlaceActorAtMe(MyActorBase.SetPosition(PlayerRef, 120.0 * Math.Sin(PlayerRef.GetAngleZ()), 120.0 * Math.Cos(PlayerRef.GetAngleZ()), PlayerRef.GetHeight())But I still got the same error, so than I tried changeing the Setposition command to MoveTo but ended up with the same results. Any thoughts or suggestions? I feel like it should be a simple script but its driving me crazy. Oh yeah I even tried setting akTarget as a property likeActor property akTarget autoThan in the Ck i was going to put the akTarget property to be the player but it still didn't compile. I tried replacing the aktarget with Game.GetPlayer() but still no luck. Edited May 4, 2017 by mmft93 Link to comment Share on other sites More sharing options...
Ghaunadaur Posted May 4, 2017 Share Posted May 4, 2017 (edited) The actor reference can be stored like this: Actor MyActorRef = Game.GetPlayer().PlaceActorAtMe(MyActorBase) SetPosition is expecting an ObjectReference, so you may need to make a cast (MyActorRef as ObjectReference).SetPosition(PlayerRef, 120.0 * Math. Sin (Player Ref.GetAngleZ()), 120.0 * Math. Cos (Player Ref.GetAngleZ()), PlayerRef.GetHeight()) Cleaned up script: ScriptName MMFTDemonicShrine1 extends ObjectReference Armor property DiscipleRobes auto Armor property GoatHead auto Weapon property DaggerofCeremony auto Perk property MarkoftheDamned auto Spell property AzazelCurse auto ActorBase property MyActorBase auto Event OnActivate(ObjectReference akActionRef) Actor PlayerRef = Game.GetPlayer() If akActionRef == PlayerRef ; only the player can activate this ObjectReference SelfObj = Self as ObjectReference AzazelCurse.cast(SelfObj, game.getplayer()) PlayerRef.AddItem(DiscipleRobes, 1, true) PlayerRef.AddItem(GoatHead, 1, true) PlayerRef.AddItem(DaggerofCeremony, 1, true) PlayerRef.EquipItem(DiscipleRobes) PlayerRef.EquipItem(GoatHead) PlayerRef.EquipItem(DaggerofCeremony) PlayerRef.AddPerk(MarkoftheDamned) Actor MyActorRef = PlayerRef.PlaceActorAtMe(MyActorBase) (MyActorRef as ObjectReference).SetPosition(120.0 * Math.Sin(PlayerRef.GetAngleZ()), 120.0 * Math.Cos(PlayerRef.GetAngleZ()), PlayerRef.GetHeight()) utility.wait(1) SelfObj.delete() EndIf EndEvent Edited May 4, 2017 by Ghaunadaur Link to comment Share on other sites More sharing options...
foamyesque Posted May 4, 2017 Share Posted May 4, 2017 PlaceAtMe doesn't allow offsets. That's why you create an invisible marker via placeatme, and then move it, once it has been spawned. You can then call PlaceAtMe on the marker, creating the NPC where you wish. Link to comment Share on other sites More sharing options...
mmft93 Posted May 9, 2017 Author Share Posted May 9, 2017 Hey thanks guys for the reply. Sorry got busy with finales. I still wasn't able to move the new actor, but I found it easier to have markers already placed in the area and than just spawn the new NPC at those markers. :) thanks again for the replies. Link to comment Share on other sites More sharing options...
Recommended Posts