Advertisement
Kuddy

[Cod] Boia assassina v2 - Menos burra

Aug 16th, 2012
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.89 KB | None | 0 0
  1. #include    a_samp
  2. #include    mapandreas
  3.  
  4.  
  5. main()
  6. {
  7.     printf("Gamemode KoIntelligence powered by Kuddy carregado");
  8.     printf("Todos os direitos reservados a KomanZ");
  9. }
  10.  
  11.  
  12. new KoB;
  13. public OnGameModeInit()
  14. {
  15.     printf("Iniciando KoIntelligence...");
  16.  
  17.     SetGameModeText("KoIntelligence");
  18.     AddPlayerClass(0,2034.9125,1336.2625,10.8203,349.3566,0,0,0,0,0,0);
  19.     KoB = CreateObject(1243, 2043.06, 1354.30, 7.37,   0.00, 0.00, 0.00);
  20.     SetTimer("UpdateNPC", 500, true);
  21.     MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
  22.  
  23.     /*new time = GetTickCount();
  24.     new Float:loopar;
  25.     for(new i; i < 1000000; i++)
  26.     {
  27.         loopar = loopar + random(10);
  28.         MapAndreas_FindZ_For2DCoord(loopar,loopar,pz);
  29.     }
  30.     time = GetTickCount() - time;
  31.     printf("%d MS", time);
  32.     Resultado: 118 MS
  33.     */
  34.  
  35.  
  36.     return 1;
  37. }
  38.  
  39. forward UpdateNPC();
  40. public UpdateNPC()
  41. {
  42.     new Float:x, Float:y, Float:z, Float:px, Float:py, Float:pz;
  43.     GetPlayerPos(0, px, py, pz);
  44.  
  45.     //MoveObject(KoB, px, py, pz, 2);
  46.     GetObjectPos(KoB, x,y,z);
  47.     MapAndreas_FindZ_For2DCoord(x,y,z);
  48.     //MapAndreas_FindZ_For2DCoord(px,py,pz);
  49.     AtualizarPos(x,y,z,px,py,pz);
  50.     return 1;
  51. }
  52.  
  53. stock AtualizarPos(Float:x, Float:y, Float:z, Float:fx, Float:fy, Float:fz)
  54. {
  55.     // Getar direção que o objeto está em relação ao player:
  56.     new Float:valorx = x - fx, Float:valory = y - fy, Float:outX,Float:outY, Float:outZ;
  57.     outX = x; outY = y; outZ = z;
  58.  
  59.     if(valorx < 0)
  60.     {
  61.         //SendClientMessageToAll(-1, "valorx > x");
  62.         new Float:preview = x + 1, Float:zprev;
  63.         MapAndreas_FindZ_For2DCoord(preview, y, zprev);
  64.         if(zprev < z + 2 && zprev > z - 2)
  65.         {
  66.             outX = x + 1;
  67.         }
  68.     }
  69.     if(valorx > 0)
  70.     {
  71.         //SendClientMessageToAll(-1, "valorx < x");
  72.         new Float:preview = x - 1, Float:zprev;
  73.         MapAndreas_FindZ_For2DCoord(preview, y, zprev);
  74.         if(zprev < z + 2 && zprev > z - 2)
  75.         {
  76.              outX = x - 1;
  77.         }
  78.  
  79.     }
  80.     if(valory < 0)
  81.     {
  82.         //SendClientMessageToAll(-1, "valorx > y");
  83.         new Float:preview = y + 1, Float:zprev;
  84.         MapAndreas_FindZ_For2DCoord(x, preview, zprev);
  85.         if(zprev < z + 2 && zprev > z - 2)
  86.         {
  87.             outY = y + 1;
  88.             outZ = zprev;
  89.         }
  90.     }
  91.     if(valory > 0)
  92.     {
  93.         //SendClientMessageToAll(-1, "valorx < y");
  94.         new Float:preview = y - 1, Float:zprev;
  95.         MapAndreas_FindZ_For2DCoord(x, preview, zprev);
  96.         if(zprev < z + 2 && zprev > z - 2)
  97.         {
  98.             outY = y - 1;
  99.             outZ = zprev;
  100.         }
  101.     }
  102.     MapAndreas_FindZ_For2DCoord(outX, outY, outZ);
  103.     // debug
  104.     new str[128];
  105.     format(str,128,"Movendo para: {0000FF}%f, {FF0000}%f, {00FF00}%f",outX, outY, outZ);
  106.     SendClientMessageToAll(-1, str);
  107.     MoveObject(KoB, outX, outY, outZ, 2);
  108.     return 1;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement