Jump to content

Need another help with simple script


Recommended Posts

Posted

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?

 

Posted

You should write it in this way:

 

Function ChangeSpeedNPC(Actor TargetNPC)
    TargetNPC.SetActorValue("SpeedMult", 0.7)

EndFunction

 

Posted
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 :(

Posted

Have you unpacked and correctly placed the source PSC files of F4SE?

Posted
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"

 

 

Posted
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".

Posted
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.

Posted
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.

Posted
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.

Posted

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.

Posted
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 ?

Posted

"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

 

 

Posted
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 ^_^

Posted

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.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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