Help ColAndreas
#1

I use this.
Code:
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;
}
There is blood on the ground but not in the wall as supposed to , what is wrong with this code? I have never worked with ColAndreas before any help is appreciated!
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by [NWA]Hannes
View Post
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?
Reply
#4

Quote:
Originally Posted by Wizzard2H
View Post
That's why I use ColAndreas and the RayCastLineAngle function?
As I said, I've never used the plugin, it was just a mere suggestion to why your script might not have been working properly. Perhaps RayCastLineAngle does not work for custom wall objects if that what you're using, apologies for trying to help you with your problem.
Reply
#5

fX, fY and fZ are offsets and not the target position
Anyways for the weapon pos you need GetPlayerLastShotVectors
PHP Code:
// OnPlayerWeaponShot
    
if(hittype == BULLET_HIT_TYPE_PLAYER
    {
        new
            
FloatvX,
            
FloatvY,
            
FloatvZ
        
;
        
GetPlayerLastShotVectors(playeridvXvYvZfXfYfZ);
        
vX fX vX;
        
vY fY vY;
        
vZ fZ vZ;
        (
Floathittype) = 5.0 VectorSize(vXvYvZ);
        
vX *= Floathittype;
        
vY *= Floathittype;
        
vZ *= Floathittype;
        if(
CA_RayCastLineAngle(fXfYfZfX vXfY vYfZ vZvXvYvZfXfYfZ))
            
SetTimerEx("DestroyBlood"1500false"d"CreateDynamicObject(19836vXvYvZfXfYfZ));
    } 
Reply
#6

@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...
Reply
#7

Quote:
Originally Posted by Crayder
View Post
@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...
Normalization and multiplied by 5, pretty much the same as
Quote:
Originally Posted by Wizzard2H
View Post
Code:
		new Float:d = VectorSize(x, y, z);
		x /= d;
		y /= d;
		z /= d;

		x *= 10.0;
		y *= 10.0;
		z *= 10.0;
Reply
#8

Updated the code in the useful functions thread.

Thanks Wizzard2H for pointing out that it was failing. As noted there, I hadn't tested it before posting it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)