02.10.2010, 15:24
hey how to detect this cord for make explosion
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
CreateExplosion(X+4, Y, Z, 2, 10);
public GetPlayerRelativeCoords(playerid, Float:angle, Float:distance, &Float:x, &Float:y, &Float:z)
{
new Float:rot;
GetPlayerFacingAngle(playerid, rot);
rot = 360 - rot + angle;
GetPlayerPos(playerid, x, y, z);
x = x + floatsin(rot, degrees) * distance;
y = y + floatcos(rot, degrees) * distance;
return 1;
}
#define EXPLOSION_OFFSET (3.5)
new
Float:x,
Float:y,
Float:z;
GetPlayerPos(playerid, x, y, z);
CreateExplosion(x, y - EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x, y + EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x - EXPLOSION_OFFSET, y - EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x + EXPLOSION_OFFSET, y + EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x - EXPLOSION_OFFSET, y + EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x + EXPLOSION_OFFSET, y - EXPLOSION_OFFSET, z, 2, 3.0);
Samp rotations seem to be incopatible to the pawn sin/cos values, I have no idea why.
This means, at first, you need to invert the players facing angle. The inverted angle now points to the front of the player, if you want to get a point e.g. 100° right of him or so, add an offset. I think -degrees to go right, and +degrees to go left (-90 would point to the right of the player, 180 to the back, ...) Now you can use floatsin, floatcos and some basic math knowledge to calculate the point you want to have. The result could look like this: pawn Код:
|
#define EXPLOSION_DISTANCE 3.5
#define EXPLOSION_TYPE 8
#define EXPLOSION_RADIUS 7.0
new Float:playerPos[4];
for (new angle = 0; angle < 360; angle += 45) {
// Get the player's position and angle
GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
GetPlayerFacingAngle(playerid, playerPos[3]);
// Store the new position calculated by our function
GetPlayerRelativeCoords(playerid, playerPos[3], EXPLOSION_DISTANCE, playerPos[0], playerPos[1], playerPos[2]);
// Create the explosion
CreateExplosion(playerPos[0], playerPos[1], playerPos[2], EXPLOSION_TYPE, EXPLOSION_RADIUS);
}