Szerző Téma: Body include probléma  (Megtekintve 1104 alkalommal)

Nem elérhető myke

  • 213
    • Profil megtekintése
Body include probléma
« Dátum: 2015. Október 11. - 16:13:01 »
0 Show voters
Sziasztok!
Adott egy body inc, amivel az lenne a problémám, hogy csak pár méterről tevékenykedik. Szóval 5 méterről még éppen animot ad a gyereknek, de 6 méterről már nem. Állítottam a \"MAX_DISTANCE_UNIT\"-on, de így se jó. Hogy lehetne növelni a lövés hatótávját?
 
/*
                     Body Part Detection - Detect a player\'ss body part
                                     By Seif
*/
/*x---------------------------------Important-------------------------------------x*/
//**INCLUDES**//
#include <a_samp>
/*x---------------------------------Defining-------------------------------------x*/
#define MAX_DISTANCE_UNIT   100.0   // maximum distance a player can shoot from
//**BODY PARTS**//
#define BODY_PART_HEAD  1
#define BODY_PART_TORSO 2
#define BODY_PART_LEGS  3
/*x---------------------------------CallBacks-------------------------------------x*/
/*
                           ---[isPlayerAimingBodyPart]---
   »playerid: the player
   »bodypart: the body part you want to check
   *Return: 1 if true, 0 if false
*-------------------------------------------------------------------*
| Checks if the player is aiming at any player\'s certain body part.   |
*-------------------------------------------------------------------*
*/
stock IsPlayerAimingBodyPart(playerid, bodypart)
{
// Get the camera\'s positions
new Float:x, Float:y, Float:z;
new Float:vx, Float:vy, Float:vz;
new Float:cx, Float:cy, Float:cz;
GetPlayerCameraFrontVector(playerid, vx, vy, vz);
GetPlayerCameraPos(playerid, cx, cy, cz);
// Check if the player is aiming in a certain distance
for(new Float:d; d < MAX_DISTANCE_UNIT; d += 1.5)
{
    x = vx*d+cx;
    y = vy*d+cy;
    z = vz*d+cz;
    new Float:dist = floatsqroot((x-cx)*(x-cx)+(y-cy)*(y-cy));
new Float:offset;
switch (GetPlayerWeapon(playerid))
{
    case 24, 29, 22, 23, 25, 26, 27, 28, 32: offset = 1.1122047500310059125919013005129;
    case 30, 31: offset = 1.07867820613690007867820613690008;
    case 33, 34: offset = 1.0;
}
new Float:height;
if (z > cz) height = z-cz;
else height = cz-z;
offset *= dist;
height /= dist;
new Float:part;
if (bodypart == BODY_PART_HEAD) part = -0.4;
else if (bodypart == BODY_PART_TORSO) part = 0.3;
else if (bodypart == BODY_PART_LEGS) part = 1.0;
z = z+offset-height+part;
    for(new i, m = GetMaxPlayers(); i < m; i++)
    {
   if (!IsPlayerConnected(i)) continue;
   if (playerid == i) continue;
   if (IsPlayerInRangeOfPoint(i, 1.5, x, y, z-1.5)) return 1;
    }
}
return 0;
}
/*
                           ---[isPlayerAimingTargetBodyPart]---
   »playerid: the player
   »targetid: the target
   »bodypart: the body part you want to check
   *Return: 1 if true, 0 if false
*-------------------------------------------------------------------*
| Checks if the player is aiming at target\'s specific body part.   |
*-------------------------------------------------------------------*
*/
stock IsPlayerAimingTargetBodyPart(playerid, targetid, bodypart)
{
// Get the camera\'s positions
new Float:x, Float:y, Float:z;
new Float:vx, Float:vy, Float:vz;
new Float:cx, Float:cy, Float:cz;
GetPlayerCameraFrontVector(playerid, vx, vy, vz);
GetPlayerCameraPos(playerid, cx, cy, cz);
// Check if the player is aiming in a certain distance
new Float:px, Float:py, Float:pz;
GetPlayerPos(targetid, px, py, pz);
new Float:dist = floatsqroot(((cx-px)*(cx-px)) + ((cy-py)*(cy-py)) + ((cz-pz)*(cz-pz)));
    x = vx*dist+cx;
    y = vy*dist+cy;
    z = vz*dist+cz;
    new Float:offset;
switch (GetPlayerWeapon(playerid))
{
    case 24, 29, 22, 23, 25, 26, 27, 28, 32: offset = 0.1122047500310059125919013005129;
    case 30, 31: offset = 0.07867820613690007867820613690008;
    case 33, 34: offset = 0.0;
}
new Float:height;
if (z > cz) height = z-cz;
else height = cz-z;
offset *= dist;
height /= dist;
new Float:part;
if (bodypart == BODY_PART_HEAD) part = -0.4;
else if (bodypart == BODY_PART_TORSO) part = 0.3;
else if (bodypart == BODY_PART_LEGS) part = 1.0;
z = z+offset-height+part;
    if (IsPlayerInRangeOfPoint(targetid, 0.5, x, y, z-0.5)) return 1;
   
return 0;
}

 
Illetve, hamár itt vagyok lenne ezzel kapcsolatba még egy kérdésem. A lábon lövés csak a bal combnál működik. Ezt hogy lehetne kijavítani? A válaszokat előre is köszönöm!

Body include probléma
« Válasz #1 Dátum: 2015. Október 11. - 16:36:55 »
0 Show voters
Miért nem a beépített SA-MP-s OnPlayerTakeDamage-t vagy OnPlayerGiveDamage-t használod?

Nem elérhető myke

  • 213
    • Profil megtekintése
Body include probléma
« Válasz #2 Dátum: 2015. Október 11. - 17:26:21 »
0 Show voters
OnPlayerGiveDamage-t használom, csak ott tudtommal simán nem lehet lekérni testrészeket.
Viszont, wikipédián látom, hogy elvileg van ilyen: (playerid, damagedid, Float:amount, weaponid, bodypart).
« Utoljára szerkesztve: 2015. Október 11. - 17:30:11 írta myke »

Body include probléma
« Válasz #3 Dátum: 2015. Október 11. - 17:43:36 »
0 Show voters
bodypart = testrész. Ha rákattintasz ki is hozza pontosabban a számokat + definíciókat.

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal