To get the position your player is looking to, try this:
https://github.com/kungfooman/cod2_s...utils.gsc#L203
PHP Code:
getRealEye()
{
player = self;
stance = player getStance();
offset = 0;
switch (stance)
{
case "stand": offset = 20; break;
case "duck": offset = 0; break;
case "lie": offset = -30; break;
//default: offset = getcvarint("offset");
}
realEye = player getEye() + (0,0,offset);
return realEye;
}
lookAtRaw()
{
player = self;
originStart = player getRealEye();
//originStart = player getTagOrigin("j_head");
//originStart = player getTagOrigin("tag_aim");
angles = player getPlayerAngles();
forward = anglesToForward(angles);
originEnd = originStart + vectorScale(forward, 100000);
trace = bullettrace(originStart, originEnd, false, undefined);
if (trace["fraction"] == 1)
return undefined;
return trace;
}
The getStance() function needs libcod though.
You still need to add a distance check, like replacing
PHP Code:
originEnd = originStart + vectorScale(forward, 100000);
with
PHP Code:
originEnd = originStart + vectorScale(forward, 100);
If you can't run libcod, replace getRealEye() with getEye().