Junglemaster Posted December 25, 2013 Posted December 25, 2013 Im working on a spell pack mod, and one of the spells is controlling an npc for 30s.heres my script:Scriptname MindControlScript extends ActiveMagicEffect Event OnEffectStart(Actor Target, Actor Caster) Game.DisablePlayerControls(true, true, true, true, true, true, true) Target.EnableAI(False) Target.SetPlayerControls(True) Game.SetCameraTarget(Target) EndEvent Event OnEffectFinish(Actor Target, Actor Caster) Target.SetPlayerControls(False) Target.EnableAI(True) Game.EnablePlayerControls() Game.SetCameraTarget(Game.GetPlayer()) EndEventThe camera switches, my player stops moving, but I cant move my new npc body. It just literally freezez in its current pose, no movement at all. Ill just stare at a statue for 30s then everything goes back to normal, the npc continues doing whatever it was doing.
meh321 Posted December 25, 2013 Posted December 25, 2013 Few things, you are disabling all player controls of course you can't move. I think for this you needed order: Game.SetCameraTarget(Target)Target.SetPlayerControls(True)Target.EnableAI(False)Target.EnableAI(true) And to disable almost all controls except movement. But I did this about a month ago I don't remember exactly.
Junglemaster Posted December 25, 2013 Author Posted December 25, 2013 Well my player isnt supposed to move so thats good, but my target npc doesnt move either. Its not just that it doesnt move, it literally freezes in a pose , like a statue.Also why did you disable then imedietly enable the targets AI?Anyway Ill try the code you wrote. tnx
meh321 Posted December 25, 2013 Posted December 25, 2013 Ok yes you can remove the (false) one so it's: Game.SetCameraTarget(Target)Target.SetPlayerControls(True)Target.EnableAI(true) The order is important. If you disable movement control then you will disable movement control and can't move. So you have to do that part some other way. Also you need to make the player follow the target otherwise it won't load cells if you move around with the NPC. One way would be to actually use script to make player follow but I think a better way might be to make the player invisible and disable AI so he will stand like that in freeze pose and use "MoveTo" to teleport player near the NPC every few seconds so cells load properly and you can't see player or hear him move. Not sure I'm just thinking out loud I didn't test any of this maybe I'm giving you bad advice here :D Good luck :)
Junglemaster Posted December 25, 2013 Author Posted December 25, 2013 I was expecting you'd remove the (true) one. I mean shouldnt the AI be disabled if youre controlling an npc. Maybe thats why it freezes in place. but doesnt the function DisablePlayerControls() only work for the player.Since you said cells wont load does that mean that while controlling the npc you cant enter interiors either. I was thinking of limiting the distance you could move away from the player to fix that one but the interiors may be a problem.Ill test the new code now, thanks :thumbsup:
meh321 Posted December 25, 2013 Posted December 25, 2013 If AI is disabled you can't move the NPC. Disabling controls does disable player controls because you are the player so it disables your controls! NPC doesn't have a keyboard :P Most of the interior problems can be solved by disabling "activation" controls with disableplayercontrols but that still leaves stuff like caves where you can just walk in. I never tested this so no idea what would happen.
Junglemaster Posted December 25, 2013 Author Posted December 25, 2013 I just tested the code and this is what i found out:disabling the AI is what makes them freezeenabling it makes them stand and talk random stuff, but not move, because setplayercontrols is truethey cant move because I disabled the playercontrols, but enabling them will make my player move with the targetso I need to disable just the players controls but...here it says that the setplayercontrols(false) function should NOT be used on the player what do i do now?
meh321 Posted December 25, 2013 Posted December 25, 2013 Couple of things that come to mind: 1. disable AI on player 2. paralyze player or any other effect that doesn't allow you to move normally 3. set player speed to 0 4. make player use an invisible furniture Would also be helpful if you made player invisible during all of this. :)
Junglemaster Posted December 25, 2013 Author Posted December 25, 2013 Its a spell so it will be weird if the player disappeared.I like the speed Idea the most.gonna try it out now :smile:
Junglemaster Posted December 25, 2013 Author Posted December 25, 2013 tried the speed and AI and neither work :sad:the player keeps moving about, is there a way to disable movement for a specific actor like Game.GetPlayer().StopMovement()?
Recommended Posts