void Player::Shoot()
{
// calculate world position and direction vectors
Vec pos, dir;
ScreenToPosDir(Vec2(0,0),pos,dir);
PhysHit phys_hit;
Bool temp=ctrl.actor.ray();
ctrl.actor.ray(false);
OrientP &head = cskel.getPoint("head");
if(Physics.ray(head.pos,head.dir*D.viewRange(),&phys_hit))//, IndexToFlag(OBJ_CHR))) // if ray test hit an actor
{
if(phys_hit.obj) // if the actor comes from an object
{
if(Player *plr=CAST(Player,phys_hit.obj))// if the object is an item
{
chatGui.ChatAddMessage(S+"Player hit");
plr->Hit();
}
else // the actor doesn't have an object set, so most probably it's a terrain actor
{
// add a decal to the world terrain
Game::World.terrainAddDecal(WHITE,*Materials("Decal/bullet.mtrl"),Matrix().setPosDir(phys_hit.plane.pos, phys_hit.plane.normal).scaleOrn(0.05f));
}
}
}
ctrl.actor.ray(temp);
}