Advertisement
Mauzen

RNPC 0.4 Damage test include

Jun 26th, 2014
1,919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.26 KB | None | 0 0
  1. // ------------- NPC zombie test and example script
  2. // RNPC 0.4 (26.6.2014) - Mauzen
  3.  
  4. // Use ConnectZombieBots(playerid, amount)
  5. // to create <amount> zombie bots that keep following <playerid>
  6. // They wont attack but can be killed for tests and stuff
  7. // Either initialize MapAndreas properly, or go to line 78
  8. // and change the last 1 in MoveRNPC to a 0
  9.  
  10. new rnpcZombie[MAX_PLAYERS];
  11. new rnpcZTimer[MAX_PLAYERS];
  12.  
  13. stock ConnectZombieBots(playerid, amount) {
  14.     new name[24];
  15.     new id;
  16.     // spawn the given amount of NPCs
  17.     while(amount-- > 0) {
  18.         format(name, 24, "Zombie_%d", 500-amount);
  19.         id = ConnectRNPC(name);
  20.         // Store their target player
  21.         rnpcZombie[id] = playerid;     
  22.     }
  23. }
  24.  
  25.  
  26. public OnPlayerSpawn(playerid) {   
  27.    
  28.     if (rnpcZombie[playerid] > 0) {
  29.         // Enable RNPC damage management
  30.         RNPC_SetShootable(playerid, 1);
  31.         RNPC_ToggleVehicleCollisionCheck(playerid, 1);
  32.        
  33.         // Random skin for datz fun
  34.         SetPlayerSkin(playerid, random(299));
  35.        
  36.         // Change name to avoid name collisions
  37.         new name[24];
  38.         format(name, 24, "Zombie_%d", playerid);
  39.         SetPlayerName(playerid, name);
  40.        
  41.         // Spawn zombie somewhere in area around player
  42.         new Float:x, Float:y, Float:z;
  43.         GetPlayerPos(rnpcZombie[playerid], x, y, z);
  44.         x = x - 30.0 + random(60);
  45.         y = y - 30.0 + random(60);
  46.         // Set to position on ground
  47.         MapAndreas_FindZ_For2DCoord(x, y, z);
  48.         SetPlayerPos(playerid, x, y, z+0.7);
  49.        
  50.         // If it was a respawn, kill the old timer
  51.         if (rnpcZTimer[playerid] > 0) KillTimer(rnpcZTimer[playerid]);
  52.         // Make him follow the player
  53.         rnpcZTimer[playerid] = SetTimerEx("RFollowPlayer", 500, 1, "i", playerid);
  54.     }
  55.    
  56.     #if defined RNPCZ_OnPlayerSpawn
  57.         return RNPCZ_OnPlayerSpawn(playerid);
  58.     #else
  59.         return 1;
  60.     #endif
  61. }
  62. #if defined _ALS_OnPlayerSpawn
  63.     #undef OnPlayerSpawn
  64. #else
  65.     #define _ALS_OnPlayerSpawn
  66. #endif
  67. #define OnPlayerSpawn RNPCZ_OnPlayerSpawn
  68. forward RNPCZ_OnPlayerSpawn(playerid);
  69.  
  70.  
  71. forward RFollowPlayer(npcid);
  72. public RFollowPlayer(npcid) {
  73.     if (IsPlayerConnected(rnpcZombie[npcid])) {
  74.         new Float:x, Float:y, Float:z;
  75.         GetPlayerPos(rnpcZombie[npcid], x, y, z);
  76.         // Move RNPC to random point in area around target player
  77.         MoveRNPC(npcid, x - 3.0 + random(600) / 100.0,
  78.             y - 3.0 + random(600) / 100.0, z, RNPC_SPEED_RUN, 1);
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement