Difference between revisions of "IS WORLD POINT WITHIN BRAIN ACTIVATION RANGE"

From GTAMods Wiki
Jump to navigation Jump to search
m
Line 15: Line 15:
 
The startup script calls [[REGISTER_WORLD_POINT_SCRIPT_BRAIN]] to register the world points to their scripts, which will allow the scripts to automatically start when the player gets close to the point.
 
The startup script calls [[REGISTER_WORLD_POINT_SCRIPT_BRAIN]] to register the world points to their scripts, which will allow the scripts to automatically start when the player gets close to the point.
  
 
+
== Example ==
 
One example is the ambSaveBed script, which handles letting the player walk up to a bed and hit a key to save the game.
 
One example is the ambSaveBed script, which handles letting the player walk up to a bed and hit a key to save the game.
 
Multiple world points are defined in ambient.ipl desiring this script as the points' "brain":
 
Multiple world points are defined in ambient.ipl desiring this script as the points' "brain":
 
+
<syntaxhighlight lang=cpp>
 
world, 890.9609375, -494.855957, 18.40229988, 13, -0, -0, 0.7071068287, -0.7071067691, ambSaveBed, 0,  
 
world, 890.9609375, -494.855957, 18.40229988, 13, -0, -0, 0.7071068287, -0.7071067691, ambSaveBed, 0,  
  
Line 28: Line 28:
  
 
world, 599.4763184, 1416.846558, 18.07299995, 13, -0, -0, -0, -1, ambsavebed, 0,  
 
world, 599.4763184, 1416.846558, 18.07299995, 13, -0, -0, -0, -1, ambsavebed, 0,  
 
+
</syntaxhighlight>
 
+
== Original using ==
 
When the game starts, the startup script calls [[REGISTER_WORLD_POINT_SCRIPT_BRAIN]]("AmbSaveBed", 50.0f);
 
When the game starts, the startup script calls [[REGISTER_WORLD_POINT_SCRIPT_BRAIN]]("AmbSaveBed", 50.0f);
 
This makes the game start monitoring all the world points associated with the ambSaveBed script, and whenever the player is within 50.0 meters of one of those points, the game runs an instance of the ambSaveBed script and associates that instance to the world point. It will not execute a new instance for this world point until the existing one terminates. Scripts are not automatically terminated when the player leaves the range again.
 
This makes the game start monitoring all the world points associated with the ambSaveBed script, and whenever the player is within 50.0 meters of one of those points, the game runs an instance of the ambSaveBed script and associates that instance to the world point. It will not execute a new instance for this world point until the existing one terminates. Scripts are not automatically terminated when the player leaves the range again.
  
 
The executed script can now call IS_WORLD_POINT_WITHIN_BRAIN_ACTIVATION_RANGE which will tell it whether the player is still within range (50.0 meters), and terminate itself if not.
 
The executed script can now call IS_WORLD_POINT_WITHIN_BRAIN_ACTIVATION_RANGE which will tell it whether the player is still within range (50.0 meters), and terminate itself if not.
 
  
 
When a script with a registered world point calls IS_WORLD_POINT_WITHIN_BRAIN_ACTIVATION_RANGE, the function retrieves the script's registered world point and checks whether the player is currently within the range specified in the call to [[REGISTER_WORLD_POINT_SCRIPT_BRAIN]].
 
When a script with a registered world point calls IS_WORLD_POINT_WITHIN_BRAIN_ACTIVATION_RANGE, the function retrieves the script's registered world point and checks whether the player is currently within the range specified in the call to [[REGISTER_WORLD_POINT_SCRIPT_BRAIN]].

Revision as of 10:44, 2 January 2015

IS_WORLD_POINT_WITHIN_BRAIN_ACTIVATION_RANGE
Number of parameters: 0
Return value:
TypeDescription
booleantrue, if within range; otherwise, false.

Returns whether the calling script's world point is within its desired range from the player. World point refers to a position defined in ambient*.ipl.

The world points specify a position and the name of a script.

The startup script calls REGISTER_WORLD_POINT_SCRIPT_BRAIN to register the world points to their scripts, which will allow the scripts to automatically start when the player gets close to the point.

Example

One example is the ambSaveBed script, which handles letting the player walk up to a bed and hit a key to save the game. Multiple world points are defined in ambient.ipl desiring this script as the points' "brain":

world, 890.9609375, -494.855957, 18.40229988, 13, -0, -0, 0.7071068287, -0.7071067691, ambSaveBed, 0, 

world, 102.5900879, 845.9500122, 48.84000015, 13, -0, -0, 0.7071067691, -0.7071068287, AmbSaveBed, 0, 

world, -971.0100098, 891.1799316, 18.78000069, 13, -0, -0, -1, 7.549790126e-008, AmbSaveBed, 0, 

world, -430.3599854, 1460.829956, 38.77999878, 13, -0, -0, -0.7071067691, -0.7071068287, AmbSaveBed, 0, 

world, 599.4763184, 1416.846558, 18.07299995, 13, -0, -0, -0, -1, ambsavebed, 0,

Original using

When the game starts, the startup script calls REGISTER_WORLD_POINT_SCRIPT_BRAIN("AmbSaveBed", 50.0f); This makes the game start monitoring all the world points associated with the ambSaveBed script, and whenever the player is within 50.0 meters of one of those points, the game runs an instance of the ambSaveBed script and associates that instance to the world point. It will not execute a new instance for this world point until the existing one terminates. Scripts are not automatically terminated when the player leaves the range again.

The executed script can now call IS_WORLD_POINT_WITHIN_BRAIN_ACTIVATION_RANGE which will tell it whether the player is still within range (50.0 meters), and terminate itself if not.

When a script with a registered world point calls IS_WORLD_POINT_WITHIN_BRAIN_ACTIVATION_RANGE, the function retrieves the script's registered world point and checks whether the player is currently within the range specified in the call to REGISTER_WORLD_POINT_SCRIPT_BRAIN.