Open TorakWolf opened 10 years ago
It's not implemented. Sounds like good idea, may implement later. But we decided to freeze 1.6.4 (no new features, bugfixes only), so this one may be done after 1.7 port.
Is that hard to implement? I have a lot of mods that will not be upgraded to 1.6.4 by a good timme.
I am not sure, but can I use the yaw, yawHeah, and pitch to trace the vision target?
If yes, how can I do that? ( Sorry, no edit button on Android )
Create a 'ray' (vector) from the head position in the direction of yaw and pitch. Then check if it intersects the bounding box of the entity, if the bounding box information is not given by OpenP you'll have to do this yourself, for the record, zombies and skeletons are apx 1.6 meters tall, as are players, spiders are 0.6 tall, ish. 1.5 wide. I think players are apx 1 meter wide.
Create an Axis Aligned bounding box in Lua, by taking the position of the entity, and subtracting/adding half the dimension in each direction to get two vectors, minXYZ and maxXYZ.
From here you want to check for a Ray-Box intersection. This all depends on how good your understanding of 3D constructs and trigonometry is.
Here is a paper on Ray Box intersection. http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/
Pseudo-Code is provided on this article; if your programming ability and understanding are strong enough, you should be able to implement this in Lua without too much trouble. Note this takes no consideration of distance or occlusion (An object in front of the entity blocking the view). You'll have to decide how to handle that yourself.
So, I transform whatever angle information it is on degrees, then use tangent that for every x position, for example, the z must be x times the tangent of the angle between the distance ray and the x distance, then if isLookingAtBlock == false, the nearest mob that matches the x and z conditions is choosen as the target.
I think that would work yes :)
I'm guessing you worked this out, @TorakWolf I'm going to leave this issue open as a reminder to consider implementing this in the future.
I am not sure if this is propositional, but without that function I can't make one aim assistant program, or one "spider sense" warning program that alerts you about unwanted scrutinize of hostile hobs.
When the player/mob is looking at one block, all is ok...