cold steel Posted May 27, 2019 Posted May 27, 2019 Hello again dear modders. Can someone help me please to write a simple script which change NPC movement speed? Here I write my version for that: Function ChangeSpeedNPC( Actor TargetNPC) TargetNPC.SetActorValue(SpeedMult, 0.7 as float) EndFunction This function called when my custom gun shoot in NPC. Of course I am getting error "SetActorValue is not a function or does not exist" and "variable SpeedMult is undefined". If it is for playable charcter I can write: Actor player = Game.getPlayer() player.SetValue(SpeedMult, 0.7 as float) I guess there should be some function like Game.getPlayer() for NPC, but I can't find it. Can someone help me to understand what I need to do?
Guest Posted May 27, 2019 Posted May 27, 2019 You should write it in this way: Function ChangeSpeedNPC(Actor TargetNPC) TargetNPC.SetActorValue("SpeedMult", 0.7) EndFunction
cold steel Posted May 27, 2019 Author Posted May 27, 2019 32 minutes ago, CPU said: You should write it in this way: Function ChangeSpeedNPC(Actor TargetNPC) TargetNPC.SetActorValue("SpeedMult", 0.7) EndFunction Thanks, now I don't get any errors about SpeedMult variable, but I still get an error "SetActorValue is not a function or does not exist". I tried to change it on "SetAV", but compiler don't understand it too
Guest Posted May 27, 2019 Posted May 27, 2019 Have you unpacked and correctly placed the source PSC files of F4SE?
Seijin8 Posted May 27, 2019 Posted May 27, 2019 10 minutes ago, cold steel said: Thanks, now I don't get any errors about SpeedMult variable, but I still get an error "SetActorValue is not a function or does not exist". I tried to change it on "SetAV", but compiler don't understand it too I've had this happen on some scripts. Might try adding the line "Import Actor"
cold steel Posted May 27, 2019 Author Posted May 27, 2019 7 minutes ago, CPU said: Have you unpacked and correctly placed the source PSC files of F4SE? I guess yes. It is in "\Data\Scripts\Source\User".
cold steel Posted May 27, 2019 Author Posted May 27, 2019 Just now, Seijin8 said: I've had this happen on some scripts. Might try adding the line "Import Actor" What is "Import Actor"? I can't find this on wiki.
Seijin8 Posted May 27, 2019 Posted May 27, 2019 1 minute ago, cold steel said: What is "Import Actor"? I can't find this on wiki. Not all script extension carry all data. This tells the game to grab the actor extensions in addition to whatever kind of script it is. Just put that near your properties, and see if it compiles.
cold steel Posted May 27, 2019 Author Posted May 27, 2019 4 minutes ago, Seijin8 said: Not all script extension carry all data. This tells the game to grab the actor extensions in addition to whatever kind of script it is. Just put that near your properties, and see if it compiles. unfortunately still getting error.
Seijin8 Posted May 27, 2019 Posted May 27, 2019 1 minute ago, cold steel said: unfortunately still getting error. Okay, sorry. Best of luck.
Carreau Posted May 27, 2019 Posted May 27, 2019 SetActorValue() is a Skyrim function. It was removed from being part of Actor Script in Fallout 4. Use SetValue() for any character. But I would also say you would be better to use ModValue() instead so you don't change the base of SpeedMult. Or just use Value Modifier magic effects like we were discussing in the other thread.
cold steel Posted May 27, 2019 Author Posted May 27, 2019 21 minutes ago, Carreau said: SetActorValue() is a Skyrim function. It was removed from being part of Actor Script in Fallout 4. Use SetValue() for any character. But I would also say you would be better to use ModValue() instead so you don't change the base of SpeedMult. Or just use Value Modifier magic effects like we were discussing in the other thread. Thank you. Now my string look like this: TargetNPC.ModValue("SpeedMult", -0.1 as float) But I am getting error: "type mismatch on parameter 1 - cannot pass a string to a actorvalue" Actually with SetValue I am getting the same error ?
Carreau Posted May 27, 2019 Posted May 27, 2019 "SpeedMult" would be a string. SpeedMult as an ActorValue would be the correct variable to pass in. https://www.creationkit.com/index.php?title=SetActorValue_-_Actor SetActorValue() takes a string as its first parameter. SetValue() takes an ActorValue as its first parameter. https://www.creationkit.com/fallout4/index.php?title=SetValue_-_ObjectReference So... ActorValue Property SpeedMult Auto Function ChangeSpeedNPC(Actor TargetNPC) TargetNPC.ModValue(SpeedMult, -10) EndFunction
cold steel Posted May 27, 2019 Author Posted May 27, 2019 6 minutes ago, Carreau said: "SpeedMult" would be a string. SpeedMult as an ActorValue would be the correct variable to pass in. https://www.creationkit.com/index.php?title=SetActorValue_-_Actor SetActorValue() takes a string as its first parameter. SetValue() takes an ActorValue as its first parameter. https://www.creationkit.com/fallout4/index.php?title=SetValue_-_ObjectReference So... ActorValue Property SpeedMult Auto Function ChangeSpeedNPC(Actor TargetNPC) TargetNPC.ModValue(SpeedMult, -10) EndFunction Thank you very much ^_^
Carreau Posted May 27, 2019 Posted May 27, 2019 But remember, if you decide to go the perk route, this is completely unnecessary. Just have the magic effect from your gun add the perk to the target, and speed multiplier changes become a lot cleaner.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.