PC drops items
#1
Posté 10 juin 2011 - 02:22
#2
Posté 10 juin 2011 - 03:29
#3
Posté 10 juin 2011 - 04:11
In case you don't hve something for it, this ugly script is my random location generator:
// (5/14/2011) - FB
//// returns a random location fDistance from lTarget
location FB_GetRandomLocation (location lTarget, float fDistance)
{
int nTemp = FloatToInt (fDistance * 20.0);
int nRandomX = (Random (nTemp) + 1) - (nTemp / 2);
int nRandomY = (Random (nTemp) + 1) - (nTemp / 2);
float ModX = IntToFloat (nRandomX) / 10.0;
float ModY = IntToFloat (nRandomY) / 10.0;
vector vPos = GetPositionFromLocation (lTarget);
float fPosX = vPos.x;
float fPosY = vPos.y;
float fPosZ = vPos.z;
vPos = Vector (fPosX + ModX, fPosY + ModY, fPosZ);
lTarget = Location (GetAreaFromLocation (lTarget), vPos, 0.0);
return lTarget;
}
Likely there are more efficient ones about on the vault or this site, but it's worked well so far for me.
Modifié par Failed.Bard, 10 juin 2011 - 04:14 .
#4
Posté 10 juin 2011 - 04:31
Its silly that one can't simply jump items to locations in the same way that creatures are.
Regarding position: that randomizing position could be fun. Given your interest in this sort of thing however you should check out the functions in "x0_i0_position". Its a handy include. I'll likely be using some functions from that include to calculate location a little to the left, right, and away from the pc depending on which slot the items were equipped in.
Modifié par henesua, 10 juin 2011 - 04:33 .
#5
Posté 12 juin 2011 - 05:06
When You first posted the thread I got an itch to write this function. I finally found the time.
//Gets a random location around an object.
// - oObject : The object to get the random location around
// - fMaxDist: The maximum distance from oObject.
// - fMinDist: The mininum distance from oObject, Defaults to 0.
// - nAngle : The angle offset from the orintation of oObject. defaults to 0.
// 0 would be the direction that oObject is facing.
// - nAngleSpread: defines the size of the arc that the location fall into.
// The spread is on both sides of nAngle.Defaults to 180 that would
// be the full 360 deg around oObject
// - examples: If nAngle is 0 and nAngleSpread is 15. the location returned will
// be in the 30deg arc in front of the object. 15deg to the right
// and left.
// If nAngle is 90 and nAngleSpread is 90 the location returned will
// be Anywhere to the left of oObject. Angel 0 - 180 from objects orintation.
location GetRndLocRoundObject( object oObject, float fMaxDist, float fMinDist=0.0, int nAngle=0,int nAngleSpread=180);
location GetRndLocRoundObject( object oObject, float fMaxDist, float fMinDist=0.0, int nAngle=0,int nAngleSpread=180)
{
vector vDir;
// Set fMaxDist to random distance in range. Prescion 2 decimal places.
fMaxDist =(fMaxDist - fMinDist)*100;
fMaxDist = Random(FloatToInt(fMaxDist)) / 100.0 + fMinDist;
// Set nAngle to a random angle offest.
nAngle = Random(nAngleSpread*2)-nAngle;
// Get the direction our random location is in from oObject.
vDir = AngleToVector(GetFacing( oObject) + nAngle);
// Adjust the magnitude to the correct distance.
vDir.x *= fMaxDist;
vDir.y *= fMaxDist;
//construct and return our location.
return Location(GetArea(oObject), GetPosition(oObject)+vDir, VectorToAngle(vDir)+180);
}
#6
Posté 14 juin 2011 - 10:01
Copy Item is working well for me.
For the placement of objects I am using functions from "x0_i0_position" Its a useful include. I use it often.
#7
Posté 22 juin 2011 - 06:44
#8
Posté 22 juin 2011 - 07:22
henesua wrote...
I wanted to add that after testing the items created by CopyObject, I have determined that Name, Description and local variables are all copied to the new item.
Did you check dynamic vs. static variables? (created in toolset vs. created by script)
If so, Cool.
#9
Posté 23 juin 2011 - 01:06





Retour en haut







