Get Location on opposite side of door
#1
Posté 24 janvier 2012 - 03:37
The two pieces of data are:
(1) the PC that used the door
(2) the door itself.
I've tried manipulating vectors, but then realized that I don't know how to convert a vector to a location.
Another approach could identifying two locations, each directly in front of the door but on opposite sides, and then determining which is clsest to the PC. But that seems like more than is necessary. I'm looking for another solution if possible.
#2
Posté 24 janvier 2012 - 05:29
and Spawn in Front
IT has been explaind a few other times on the boards, If you are still having trouble when I get home Ill help more then.
#3
Posté 24 janvier 2012 - 05:34
henesua wrote...
I've tried manipulating vectors, but then realized that I don't know how to convert a vector to a location.
Input three floats (x, y, and z location in area) to make a vector with
vector Vector(float x=0.0f, float y=0.0f, float z=0.0f):
vector vVec = vector(2.0, 18.2, 0.0);
Then you just need facing and area to get a location with
location Location(object oArea, vector vPosition, float fOrientation)
Area is usually gotten with GetArea from OBJECT_SELF or whatever is handy (like the door, here). Facing often doesn't matter, you can just enter 0.0 unless you 're spawning in something you want facing a particular way:
object oArea = GetArea(OBJECT_SELF); location lLoc1 = Location(oArea, vVec, 0.0);
Funky
Modifié par FunkySwerve, 24 janvier 2012 - 05:35 .
#4
Posté 24 janvier 2012 - 06:30
And now mice can squeeze under doors! Perhaps it will make for a Pass Door spell too.
#5
Posté 24 janvier 2012 - 11:21
void RunRatUnderDoor(object oRat, object oDoor)
{
// Get the posistion for the rat.
vector vRat = GetPosition(oRat);
// Get the position for the door
vector vDoor = GetPosition(oDoor);
// Subtract the position of the rat from the position of the door.
// To get the vector representing the position of the rat from the door.
// basicly what we are doing is both the rat and the door have (X,Y) positions
// (Rx,Ry) and (Dx,Dy)
// if we subtract the position of the rat from both of them in effect moving
// the line segment to where the rat is at cords (0,0) the
// (Rx,Ry) - (Rx,Ry) = (0,0)
// (Dx,Dy) - (Rx-Ry) = (Dx-Rx,Dy-Ry)
// in effect moving the line segment to where the rat is at cords (0,0) the
// the (Dx-Rx,Dy-Ry) Is in effect the vector showing both distance and
//Direction that the door is from the rat.
vector vDoorFromRat = vDoor-vRat;
//To get the position 1 unit beyond the door in a stright line from where
// the rat currently is, all we have to do is normilize the vector and add
// it to the position of the door.
vector vPastDoor1M = vDoor + VectorNormalize(vDoorFromRat);
//Build a location with the new vector and have the rat face in the same
//Direction that the door was from him. .
location lPastDoor = Location(
GetArea(oRat),
vPastDoor1M,
VectorToAngle(vDoorFromRat)
);
// Clear rats action que
AssignCommand(oRat,ClearAllActions(TRUE));
//Run to the door
AssignCommand(oRat,ActionMoveToObject(oDoor,TRUE));
//Lay flat
AssignCommand(oRat,ActionPlayAnimation( ANIMATION_LOOPING_DEAD_FRONT,1.0,2.0));
// Squezze under.
AssignCommand(oRat,ActionJumpToLocation(lPastDoor));
}
EDIT: Yes, I used more vars then I need to. That was just to make it easier to see what was going on.
Modifié par Lightfoot8, 24 janvier 2012 - 11:24 .
#6
Posté 24 janvier 2012 - 11:27
#7
Posté 24 janvier 2012 - 11:31
One thing however... can you jump a rat that is in the LOOPING_DEAD_FRONT animation? I'll try it. But my assumption was that no jumping would work while a character is busy in an animation.
#8
Posté 24 janvier 2012 - 11:35
henesua wrote...
Awesome! Thanks! That is very similar to what I am doing. I may modify my function to resemble yours.
One thing however... can you jump a rat that is in the LOOPING_DEAD_FRONT animation? I'll try it. But my assumption was that no jumping would work while a character is busy in an animation.
When I ran the function above, Iexpected the rat to stay down then jump. I was amazed when I watched him slide under the gate I was testing with.
#9
Posté 24 janvier 2012 - 11:37
I'll try different models. Snakes, oozes, that tiny mouse, the rat. I hope they all behave the same way so that they can all take advantage of this ability. Would be an interesting add on for the blocked event.
But for now it will be tested in game play for possessed mouse familiars.
#10
Posté 27 janvier 2012 - 02:09
Very small jumps (a few meters) result in a sliding animation rather than a disappear/appear.Lightfoot8 wrote...
henesua wrote...
Awesome! Thanks! That is very similar to what I am doing. I may modify my function to resemble yours.
One thing however... can you jump a rat that is in the LOOPING_DEAD_FRONT animation? I'll try it. But my assumption was that no jumping would work while a character is busy in an animation.
When I ran the function above, Iexpected the rat to stay down then jump. I was amazed when I watched him slide under the gate I was testing with.
Funky
#11
Posté 02 février 2012 - 01:57
Thanks a lot for the help everyone. The function is working very well, Lightfoot8.
Modifié par henesua, 02 février 2012 - 02:43 .
#12
Posté 03 février 2012 - 12:50
118. float fFace = GetFacing(oDest);
119.
120. if (fFace<180.0)
121. fFace=fFace+179.9;
122. else
123. fFace=fFace-179.9;
I can see the point if the doors are always on the external boarders of the area. But what happens if it is a door that is comming out of a building in the middle of an area? or am I reading this wrong?
#13
Posté 03 février 2012 - 01:07
All the doors in question have had that arrow symbol facing into the area. Basically the arrow appears to point in the opposite direction of the door's facing. I hope that this is 100% consistent behavior. If not, I'll have to write a more sophisticated script.
#14
Posté 03 février 2012 - 02:42
...
// No reason to worry about it being out of range. if it bugs you a simple %360 would do the trick
float fFace = GetFacing(oDest)+180;
//AngleToVector(fFace) will give you the a vector that is already normilized with a length of 1.
// From there all you need to do is add it to the position of the door.
vector vNewPos = GetPosition(oDest) + AngleToVector(fFace);
//Then right back to what you had.
location lPastDoor = Location(
GetArea(oDest),
vNewPos,
fFace
);
...
Modifié par Lightfoot8, 03 février 2012 - 02:44 .
#15
Posté 03 février 2012 - 03:52
I didn't know about AngleToVector. There are many vector functions in NWN that I am not aware of. Its taking some getting used to.





Retour en haut







