forward DestroyBlood(objectid); public DestroyBlood(objectid) { DestroyDynamicObject(objectid); } stock CreateGroundBlood(playerid) { new Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz; GetPlayerPos(playerid, x, y, z); if(CA_RayCastLineAngle(x, y, z, x, y, z - 2.0, x, y, z, rx, ry, rz)) return SetTimerEx("DestroyBlood", 1500, false, "d", CreateDynamicObject(19836, x, y, z, rx, ry, rz)), 1; return 0; } public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { if(hittype == BULLET_HIT_TYPE_PLAYER) { new Float:sx, Float:sy, Float:sz, Float:rx, Float:ry, Float:rz; GetPlayerCameraPos(playerid, sx, sy, sz); new Float:x = fX - sx, Float:y = fY - sy, Float:z = fZ - sz; new Float:d = VectorSize(x, y, z); x /= d; y /= d; z /= d; x *= 10.0; y *= 10.0; z *= 10.0; if(CA_RayCastLineAngle(fX, fY, fZ, fX + x, fY + y, fZ + z, x, y, z, rx, ry, rz)) SetTimerEx("DestroyBlood", 1500, false, "d", CreateDynamicObject(19836, x, y, z, rx, ry, rz)); } return 1; } public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart) { CreateGroundBlood(playerid); return 1; }
You have static values for where the blood object is supposed to be created and I don't think the script can know the distance to the closest wall in order to create the blood on it.
|
That's why I use ColAndreas and the RayCastLineAngle function?
|
// OnPlayerWeaponShot
if(hittype == BULLET_HIT_TYPE_PLAYER)
{
new
Float: vX,
Float: vY,
Float: vZ
;
GetPlayerLastShotVectors(playerid, vX, vY, vZ, fX, fY, fZ);
vX = fX - vX;
vY = fY - vY;
vZ = fZ - vZ;
(Float: hittype) = 5.0 / VectorSize(vX, vY, vZ);
vX *= Float: hittype;
vY *= Float: hittype;
vZ *= Float: hittype;
if(CA_RayCastLineAngle(fX, fY, fZ, fX + vX, fY + vY, fZ + vZ, vX, vY, vZ, fX, fY, fZ))
SetTimerEx("DestroyBlood", 1500, false, "d", CreateDynamicObject(19836, vX, vY, vZ, fX, fY, fZ));
}
@Nero_3D: Yeah when I wrote that code I forgot 'f' was offsets... xD
Basically what I was doing was calculating the unit vector with it and the camera position. Now... Why are you dividing 5 by the distance...? I'm confused... |
Code:
new Float:d = VectorSize(x, y, z); x /= d; y /= d; z /= d; x *= 10.0; y *= 10.0; z *= 10.0; |