Advertisement
Guest User

Untitled

a guest
May 26th, 2014
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. /*
  2. Useful NPC Functions v1.0 by [uL]Pottus
  3. v1.0
  4. FCNPC_Punch(npcid, Float:x, Float:y, Float:z, PunchResetDelay = 125) - Allows the NPC to punch and resets correctly to punch again
  5. FCNPC_GoToPlayer(npcid, playerid, movetype = MOVE_TYPE_WALK, UseZMap = 0) - Goes to a players exact position
  6. FCNPC_GoToPlayerEx(npcid, playerid, Float:dist, Float:rangle, movetype = MOVE_TYPE_WALK, UseZMap = 0) - Goes to a player from a set distance and angle that
  7. is realtive to the players facing angle
  8. v1.1
  9. FCNPC_StartRNPCPlayBack(npcid) start a FCNPC recording playback
  10. */
  11.  
  12. //------------------------------------------------------------------------------
  13. // Punching Function
  14. //------------------------------------------------------------------------------
  15. stock FCNPC_Punch(npcid, Float:x, Float:y, Float:z, PunchResetDelay = 125)
  16. {
  17. FCNPC_AimAt(npcid, x, y, z, 0);
  18. FCNPC_StopAim(npcid);
  19. FCNPC_SetKeys(npcid, 0x80 + 4);
  20. SetTimerEx("ResetNPCKeys", PunchResetDelay, false, "i", npcid);
  21. }
  22. //------------------------------------------------------------------------------
  23.  
  24.  
  25. //------------------------------------------------------------------------------
  26. // Go to a players position
  27. //------------------------------------------------------------------------------
  28. stock FCNPC_GoToPlayer(npcid, playerid, movetype = MOVE_TYPE_WALK, UseZMap = 0)
  29. {
  30. new Float:x, Float:y, Float:z;
  31. GetPlayerPos(playerid, x, y, z);
  32. FCNPC_GoTo(npcid, x, y, z, movetype, UseZMap);
  33. }
  34. //------------------------------------------------------------------------------
  35.  
  36.  
  37. //------------------------------------------------------------------------------
  38. // Go to a players position specify a distance from player and realtive angle from
  39. // the players facing angle
  40. //------------------------------------------------------------------------------
  41. stock FCNPC_GoToPlayerEx(npcid, playerid, Float:dist, Float:rangle, movetype = MOVE_TYPE_WALK, UseZMap = 0)
  42. {
  43. new Float:x, Float:y, Float:z, Float:fa;
  44. GetPlayerPos(playerid, x, y, z);
  45. GetPlayerFacingAngle(playerid, fa);
  46. rangle += fa;
  47. x = (x + dist * floatsin(-rangle,degrees));
  48. y = (y + dist * floatcos(-rangle,degrees));
  49. FCNPC_GoTo(npcid, x, y, z, movetype, UseZMap);
  50. }
  51. //------------------------------------------------------------------------------
  52.  
  53.  
  54. //------------------------------------------------------------------------------
  55. // Resets NPC Keys
  56. //------------------------------------------------------------------------------
  57. forward ResetNPCKeys(npcid);
  58. public ResetNPCKeys(npcid) { FCNPC_SetKeys(npcid, 0); }
  59. //------------------------------------------------------------------------------
  60.  
  61. //------------------------------------------------------------------------------
  62. // Play a RNPC recording
  63. //------------------------------------------------------------------------------
  64. stock FCNPC_StartRNPCPlayBack(npcid)
  65. {
  66. new recname[16];
  67. format(recname, sizeof(recname), "rnpc%03d-00", npcid);
  68.  
  69. FCNPC_StopRecordingPlayback(npcid);
  70. FCNPC_StartRecordingPlayback(npcid, recname);
  71.  
  72. return 1;
  73. }
  74. //------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement