Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. #include <a_samp>
  2. #include <FCNPC>
  3. #include <a_angles>
  4. #include <YSI\y_iterate>
  5.  
  6.  
  7. #define MAX_ZOMBIES 50
  8.  
  9. enum ZombieEnum
  10. {
  11. zID,
  12. zAttack,
  13. zLevel,
  14. zIDPlayer,
  15.  
  16. Float: zHealth,
  17. }
  18. new ZombieInfo[MAX_ZOMBIES][ZombieEnum];
  19. new Iterator:Zombies<MAX_ZOMBIES>;
  20.  
  21. stock ZombieLevelBas[] = {159, 160, 162};
  22. stock ZombieLevelHaut[] = {5, 182};
  23.  
  24. new Float:gRandomSpawns_LosSantos[][4] = {
  25. {1751.1097,-2106.4529,13.5469,183.1979}, // El-Corona - Outside random house
  26. {2652.6418,-1989.9175,13.9988,182.7107}, // Random house in willowfield - near playa de seville and stadium
  27. {2489.5225,-1957.9258,13.5881,2.3440}, // Hotel in willowfield - near cluckin bell
  28. {2689.5203,-1695.9354,10.0517,39.5312}, // Outside stadium - lots of cars
  29. {2770.5393,-1628.3069,12.1775,4.9637}, // South in east beach - north of stadium - carparks nearby
  30. {2807.9282,-1176.8883,25.3805,173.6018}, // North in east beach - near apartments
  31. {2552.5417,-958.0850,82.6345,280.2542}, // Random house north of Las Colinas
  32. {2232.1309,-1159.5679,25.8906,103.2939}, // Jefferson motel
  33. {2388.1003,-1279.8933,25.1291,94.3321}, // House south of pig pen
  34. {2481.1885,-1536.7186,24.1467,273.4944}, // East LS - near clucking bell and car wash
  35. {2495.0720,-1687.5278,13.5150,359.6696}, // Outside CJ's house - lots of cars nearby
  36. {2306.8252,-1675.4340,13.9221,2.6271}, // House in ganton - lots of cars nearby
  37. {2191.8403,-1455.8251,25.5391,267.9925}, // House in south jefferson - lots of cars nearby
  38. {1830.1359,-1092.1849,23.8656,94.0113}, // Mulholland intersection carpark
  39. {2015.3630,-1717.2535,13.5547,93.3655}, // Idlewood house
  40. {1654.7091,-1656.8516,22.5156,177.9729}, // Right next to PD
  41. {1219.0851,-1812.8058,16.5938,190.0045}, // Conference Center
  42. {1508.6849,-1059.0846,25.0625,1.8058}, // Across the street of BANK - lots of cars in intersection carpark
  43. {1421.0819,-885.3383,50.6531,3.6516}, // Outside house in vinewood
  44. {1133.8237,-1272.1558,13.5469,192.4113}, // Near hospital
  45. {1235.2196,-1608.6111,13.5469,181.2655}, // Backalley west of mainstreet
  46. {590.4648,-1252.2269,18.2116,25.0473}, // Outside "BAnk of San Andreas"
  47. {842.5260,-1007.7679,28.4185,213.9953}, // North of Graveyard
  48. {911.9332,-1232.6490,16.9766,5.2999}, // LS Film Studio
  49. {477.6021,-1496.6207,20.4345,266.9252}, // Rodeo Place
  50. {255.4621,-1366.3256,53.1094,312.0852}, // Outside propery in richman
  51. {281.5446,-1261.4562,73.9319,305.0017}, // Another richman property
  52. {790.1918,-839.8533,60.6328,191.9514}, // Mulholland house
  53. {1299.1859,-801.4249,84.1406,269.5274}, // Maddoggs
  54. {1240.3170,-2036.6886,59.9575,276.4659}, // Verdant Bluffs
  55. {2215.5181,-2627.8174,13.5469,273.7786}, // Ocean docks 1
  56. {2509.4346,-2637.6543,13.6453,358.3565} // Ocean Docks spawn 2
  57. };
  58.  
  59.  
  60.  
  61. public OnFilterScriptInit()
  62. {
  63. for(new i = 0 ;i<MAX_ZOMBIES;i++)
  64. {
  65. ZombieInfo[i][zID] = -1;
  66. ZombieInfo[i][zAttack] = -1;
  67. ZombieInfo[i][zIDPlayer] = -1;
  68.  
  69. new randSpawn = random(sizeof(gRandomSpawns_LosSantos));
  70. new rand = randomEx(1,2);
  71. CreateZombie(rand, gRandomSpawns_LosSantos[randSpawn][0], gRandomSpawns_LosSantos[randSpawn][1], gRandomSpawns_LosSantos[randSpawn][2]);
  72. }
  73. return 1;
  74. }
  75.  
  76.  
  77. public OnPlayerSpawn(playerid)
  78. {
  79. new Float: Pos[3];
  80. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  81. CreateZombie(1, Pos[0], Pos[1]+5.0, Pos[2]);
  82.  
  83. SetTimer("ZombieLook", 1000, 1);
  84. return 1;
  85. }
  86.  
  87. public CreateZombie(Level, Float: PosX, Float: PosY, Float: PosZ)
  88. {
  89. for(new i = 0 ;i<MAX_ZOMBIES;i++)
  90. {
  91. if(ZombieInfo[i][zID] == -1)
  92. {
  93. new NameZombie[MAX_PLAYER_NAME+1];
  94. format(NameZombie, sizeof(NameZombie), "Zombie%d", i);
  95.  
  96. ZombieInfo[i][zID] = FCNPC_Create(NameZombie);
  97. ZombieInfo[i][zAttack] = -1;
  98. ZombieInfo[i][zLevel] = randomEx(1, 2);
  99.  
  100. FCNPC_Spawn(ZombieInfo[i][zID], 0, PosX, PosY, PosZ);
  101.  
  102. if(ZombieInfo[i][zLevel] == 1) FCNPC_SetSkin(ZombieInfo[i][zID], ZombieLevelBas[randomEx(0, 3)]);
  103. if(ZombieInfo[i][zLevel] == 2) FCNPC_SetSkin(ZombieInfo[i][zID], ZombieLevelHaut[randomEx(0, 2)]);
  104.  
  105. ZombieInfo[i][zHealth] = 100.0*ZombieInfo[i][zLevel];
  106. FCNPC_SetHealth(ZombieInfo[i][zID], ZombieInfo[i][zHealth]);
  107. Iter_Add(Zombies, i);
  108. return 1;
  109. }
  110. }
  111. printf("[Zombie]: Attention tous les slots des zombies sont utilisé.");
  112. return 1;
  113. }
  114.  
  115.  
  116.  
  117. public ZombieLook()
  118. {
  119. foreach(new i : Zombies)
  120. {
  121. if(ZombieInfo[i][zID] != -1)
  122. {
  123. foreach(new player : Player)
  124. {
  125. if(IsPlayerConnected(player))
  126. {
  127. new Float: Position[3];
  128. FCNPC_GetPosition(ZombieInfo[i][zID], Position[0], Position[1], Position[2]);
  129. if(IsPlayerInRangeOfPoint(player, 20.0, Position[0], Position[1], Position[2]) && !IsPlayerNPC(player))
  130. {
  131.  
  132. new randomdiagonal = randomEx(-5, 5);
  133. if(ZombieInfo[i][zAttack] == -1)
  134. {
  135. GetPlayerPos(player, Position[0], Position[1], Position[2]);
  136. FCNPC_GoTo(ZombieInfo[i][zID], Position[0]+randomdiagonal, Position[1]+randomdiagonal, Position[2], MOVE_TYPE_RUN, 0, 1);
  137. ZombieInfo[i][zAttack] = player;
  138. }
  139. else
  140. {
  141. GetPlayerPos(player, Position[0], Position[1], Position[2]);
  142. FCNPC_GoTo(ZombieInfo[i][zID], Position[0]+randomdiagonal, Position[1]+randomdiagonal, Position[2], MOVE_TYPE_RUN, 0, 1);
  143. }
  144. GetPlayerPos(ZombieInfo[i][zAttack], Position[0], Position[1], Position[2]);
  145. if(IsPlayerInRangeOfPoint(ZombieInfo[i][zID], 2.0, Position[0], Position[1], Position[2]) && !IsPlayerNPC(player) && !IsPlayerInAnyVehicle(player))
  146. {
  147. new Float: Health;
  148. GetPlayerHealth(ZombieInfo[i][zAttack], Health);
  149. SetPlayerHealth(ZombieInfo[i][zAttack], Health-20*ZombieInfo[i][zLevel]);
  150. }
  151.  
  152. }
  153. else
  154. {
  155. ZombieInfo[i][zAttack] = -1;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. return 1;
  162. }
  163.  
  164.  
  165.  
  166. stock randomEx(min, max)
  167. {
  168. //Credits to y_less
  169. new rand = random(max-min)+min;
  170. return rand;
  171. }
  172.  
  173.  
  174. stock GetPlayerID(const Name[])
  175. {
  176. foreach(new i : Player)
  177. {
  178. if(IsPlayerConnected(i))
  179. {
  180. new pName[MAX_PLAYER_NAME];
  181. GetPlayerName(i, pName, sizeof(pName));
  182. if(strcmp(Name, pName, true)==0)
  183. {
  184. return i;
  185. }
  186. }
  187. }
  188. return -1;
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement