Advertisement
Guest User

MoveZombie

a guest
Jul 4th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.94 KB | None | 0 0
  1. public MoveZombie(zombieid)
  2. {
  3.     if(GetRNPCHealth(dZombie[zombieid][dZombieID]) > 0 && dZombie[zombieid][dZombieID] != INVALID_PLAYER_ID)
  4.     {
  5.         new Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2;
  6.         new dDirection;
  7.         new victim = GetZombieVictim(zombieid);
  8.         if(victim == INVALID_PLAYER_ID)
  9.         {
  10.             GetPlayerPos(dZombie[zombieid][dZombieID], x, y, z);
  11.             dDirection = RandomEx(1, 9);
  12.             RNPC_FinishBuild(0);
  13.             RNPC_StopPlayback(dZombie[zombieid][dZombieID]);//RNPC_PauseRecordingPlayback(dZombie[zombieid][dZombieID]);
  14.             RNPC_CreateBuild(dZombie[zombieid][dZombieID], PLAYER_RECORDING_TYPE_ONFOOT, zombieid);
  15.             new dPathTries = 0;
  16.             new dNode = 0;
  17.             createbuild:
  18.             dPathTries ++;
  19.             for(new i = 0; i < 5; i ++)
  20.             {
  21.                 new dTries = 0;
  22.                 takepos:
  23.                 if(dTries == 5)
  24.                 {
  25.                     break;
  26.                 }
  27.                 z2 = z;
  28.                 switch(dDirection)
  29.                 {
  30.                     case 1://N
  31.                     {
  32.                         x2 = x + floatrand(-0.2, 0.2);
  33.                         y2 = y + floatrand(0.5, 1.5);
  34.                         CA_FindZ_For2DCoord(x2, y2, z2);
  35.                     }
  36.                     case 2://NO
  37.                     {
  38.                         x2 = x + floatrand(-0.3, -0.7);
  39.                         y2 = y + floatrand(0.3, 0.7);
  40.                         CA_FindZ_For2DCoord(x2, y2, z2);
  41.                     }
  42.                     case 3://O
  43.                     {
  44.                         x2 = x + floatrand(-0.5, -1.5);
  45.                         y2 = y + floatrand(-0.2, 0.2);
  46.                         CA_FindZ_For2DCoord(x2, y2, z2);
  47.                     }
  48.                     case 4://SO
  49.                     {
  50.                         x2 = x + floatrand(-0.3, -0.7);
  51.                         y2 = y + floatrand(-0.3, -0.7);
  52.                         CA_FindZ_For2DCoord(x2, y2, z2);
  53.                     }
  54.                     case 5://S
  55.                     {
  56.                         x2 = x + floatrand(-0.2, 0.2);
  57.                         y2 = y + floatrand(-0.5, -1.5);
  58.                         CA_FindZ_For2DCoord(x2, y2, z2);
  59.                     }
  60.                     case 6://SE
  61.                     {
  62.                         x2 = x + floatrand(0.3, 0.7);
  63.                         y2 = y + floatrand(-0.3, -0.7);
  64.                         CA_FindZ_For2DCoord(x2, y2, z2);
  65.                     }
  66.                     case 7://E
  67.                     {
  68.                         x2 = x + floatrand(0.5, 1.5);
  69.                         y2 = y + floatrand(-0.2, 0.2);
  70.                         CA_FindZ_For2DCoord(x2, y2, z2);
  71.                     }
  72.                     case 8://NE
  73.                     {
  74.                         x2 = x + floatrand(0.3, 0.7);
  75.                         y2 = y + floatrand(0.3, 0.7);
  76.                         CA_FindZ_For2DCoord(x2, y2, z2);
  77.                     }
  78.                 }
  79.                 dTries ++;
  80.                 z2 += 1.0;
  81.                 if(z2 == 1.0 || z > z2 + 2.0 && dTries != 5) goto takepos;
  82.                 RNPC_AddMovement(x, y, z, x2, y2, z2, RNPC_SPEED_WALK, 0);
  83.                 x = x2, y = y2, z = z2;
  84.                 dNode = i;
  85.                 printf("Zombie %d -  %d", zombieid, i);
  86.             }
  87.             if(dNode == 0) RNPC_AddMovement(x, y, z, x, y, z, RNPC_SPEED_WALK, 0), printf("Zombie %d dNode = 0", zombieid);
  88.             RNPC_FinishBuild();
  89.             printf("Zombie %d FinishBuild", zombieid);
  90.             if(dNode == 0)
  91.             {
  92.                 printf("Zombie %d dNodes = 0", zombieid);
  93.                 if(dPathTries == 3) SetRNPCHealth(dZombie[zombieid][dZombieID], 0.0, INVALID_PLAYER_ID, 51), printf("Zombie %d Killed", zombieid);
  94.                 else { printf("Zombie %d goto createbuild", zombieid); goto createbuild; }
  95.             }
  96.             else
  97.             {
  98.                 RNPC_StartBuildPlayback(dZombie[zombieid][dZombieID], zombieid);
  99.                 printf("Zombie %d StartBuildPlayback", zombieid);
  100.             }
  101.         }
  102.     }
  103.     return 1;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement