TheBlob2 Posted April 20, 2015 Share Posted April 20, 2015 (edited) I need a function that returns the reference of the nearest actor to the player, but I have no idea what it is Edited April 20, 2015 by TheBlob2 Link to comment Share on other sites More sharing options...
Fallout2AM Posted April 20, 2015 Share Posted April 20, 2015 You probably would want to scan the zone for actors and then check the distance with the player, and pick the closer one. Link to comment Share on other sites More sharing options...
Ladez Posted April 20, 2015 Share Posted April 20, 2015 (edited) Try this UDF: ScriptName NearestActorUDF reference rActor reference rClosestActor Begin Function { } Set rActor to GetFirstRef 200 0 Set rClosestActor to rActor While rActor If rActor.GetDead || rActor.GetDisabled || rActor.GetIsCreature ; skip ElseIf rActor.GetDistance Player < rClosestActor.GetDistance Player Set rClosestActor to rActor EndIf Set rActor to GetNextRef Loop SetFunctionValue rClosestActor End Edited April 20, 2015 by Ladez Link to comment Share on other sites More sharing options...
TheBlob2 Posted April 20, 2015 Author Share Posted April 20, 2015 Try this UDF: ScriptName NearestActorUDF reference rActor reference rClosestActor Begin Function { } Set rActor to GetFirstRef 200 0 Set rClosestActor to rActor While rActor If rActor.GetDead || rActor.GetDisabled || rActor.GetIsCreature ; skip ElseIf rActor.GetDistance Player < rClosestActor.GetDistance Player Set rClosestActor to rActor EndIf Set rActor to GetNextRef Loop SetFunctionValue rClosestActor Endwhat about a way to check if the nearest actor is close enough to start dialog? and a way to check if the player has their crosshair on nearest actor? Link to comment Share on other sites More sharing options...
Ladez Posted April 20, 2015 Share Posted April 20, 2015 (edited) Both should be easy once you know how close you need to be to enter dialog and how to find out what object the player's crosshair is pointing at. I don't know either, right at this moment. Edited April 20, 2015 by Ladez Link to comment Share on other sites More sharing options...
Fallout2AM Posted April 20, 2015 Share Posted April 20, 2015 (edited) what about a way to check if the nearest actor is close enough to start dialog? and a way to check if the player has their crosshair on nearest actor? If this compiles if eval (Call NearestActorUDF) == GetCrosshairREFor just in case Let rTemp := GetCrosshairREF if eval (Call NearestActorUDF) == rTempAbout the distance, you could check if the value is at least 150 (or 120, don't remember), but you wouldn't really need it. Distance can be forced via Dialogue package, and there's a brand new StartConversationDistance function that allows to specify it. Not sure if it's already online, but in case just wait a little time and it will. Edited April 20, 2015 by Fallout2AM Link to comment Share on other sites More sharing options...
TheBlob2 Posted April 20, 2015 Author Share Posted April 20, 2015 (edited) I know this is off topic, and it may seem like a stupid question, but are references in scripts self contained? Like, if I put a set command in a script. Will every script that uses the reference that I just 'set', use what I have 'set' it as? Or if I put an 'if' statement in a script, and the qualifications of the 'if' statement is met in an actor, will every actor also be affected by the effects of the 'if' statement if they have the script on them too even if they don't meet the qualifications of it? Edited April 20, 2015 by TheBlob2 Link to comment Share on other sites More sharing options...
Ladez Posted April 20, 2015 Share Posted April 20, 2015 I know this is off topic, and it may seem like a stupid question, but are references in scripts self contained?Like, if I put a set command in a script. Will every script that uses the reference that I just 'set', use what I have 'set' it as? The scope of reference variables, as well as all other types of script variables, only extends to the script itself. In other words, they are self contained in the script in which they're declared. A variable called actor may contain one actor in one script and a different actor in another. A script attached to two actors with the variable friendshipPoints can have different values for each actor. You can be good friends with one and not so good friends with the other. Or if I put an 'if' statement in a script, and the qualifications of the 'if' statement is met in an actor, will every actor also be affected by the effects of the 'if' statement if they have the script on them too even if they don't meet the qualifications of it? I think this could have been worded better, but I think I understand what you mean. Using the example with the two friends above, each would have their own version of the script running seperately with their own set of variables. Also, reference functions usually only affect either the reference that the script is currently running on (using implied reference syntax) or the reference that the function is called on (using explicit reference syntax.) Link to comment Share on other sites More sharing options...
Recommended Posts