- Scripting Tips and Tricks
- 28 Jan 2010 12:26:00 am
- Last edited by elfprince13 on 17 Apr 2014 04:12:05 pm; edited 1 time in total
Feel free to post in this thread. Just label the category of function it is, and explain what it is.
For starters, I just incorporated the proximity resource by Orion Elenzil.
AI Behavior Scripting
Code:
For starters, I just incorporated the proximity resource by Orion Elenzil.
AI Behavior Scripting
Code:
// Basically these allow you to get a value between two players
// which is based on the distance between the players and how much each one is facing the other.
// the value is the same from each player's point of view.
//
// this is really just two workhorse functions and a bunch of conveniences on top.
// the two workhorses are:
//
// rangeRadial : distance = 0 yields: 1.
// : distance = range yields: 0.
// : distance > range yields: negative values.
//
// rangeAngular : angle = 0 yields: 1.
// : angle = range yields: 0.
// : angle > range yields: negative values.
//
// the rest of the functions are just combinations of these.
//
// "directed" is just rangeRadial * rangeAngular, with negative values pre-clamped to zero.
// "mutual" is just the average of the given range function for each point of view.
//
// So for example the mutual directed range of two players is highest when they're near and facing each other,
// and gets smaller as either one turns or moves away.
//
// The functions behave well in degenerate situations. (ie, they don't divide by zero)
proxRangeRadial(%posA, %posB, %rangeA);
proxRangeDirected(%transformA, %posB, %rangeAngA);
proxRangeDirected(%transformA, %posB, %rangeA, %rangeAngA);
proxRangeMutualRadial(%posA, %posB, %rangeA, %rangeB);
proxRangeMutualDirected(%transformA, %transformB, %rangeA, %rangeB, %rangeAngA, %rangeAngB);