Anyone know how to cost this:
Given two objects in the same area, I need to find a random location on a straight line between them. I’ve been playing around with this for several hours and can’t get my head around how to do it.
This is what I have so far:
// Gets a random location on a straight line between two objects
#include "x0_i0_position"
void main()
{
object oOrig = GetObjectByTag("ORIGIN");
object oDest = GetObjectByTag("DESTINATION");
location lOrig = GetLocation(oOrig);
location lDest = GetLocation(oDest);
float fAngle = GetAngleBetweenLocations(lOrig, lDest);
float fDist = GetDistanceBetweenLocations(lOrig, lDest);
int nDist = Random(FloatToInt(fDist));
if (nDist == 0) nDist = 1;
fDist = IntToFloat(nDist);
GenerateNewLocationFromLocation(lOrig, fDist, fAngle, 90.0);
//orientation set to 90 deg. so icon appears rightside up
CreateObject(OBJECT_TYPE_PLACEABLE, "tent", lSpawn, FALSE, "WP_CAMPSITE_ICON");
}
It generates the random location between the two objects but when I use it, the angle to the target object is wrong. For example, if the angle between the objects is 100 deg., the campsite icon is not created at a location that is 100 deg. angled from the origin.