Advertisement
Guest User

Untitled

a guest
Jul 6th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 16.75 KB | None | 0 0
  1. #include <a_samp>
  2. #include <FCNPC>
  3. #include <LocalPlugin>
  4. #include <ColAndreas>
  5.  
  6. #define NPC_NUM     25
  7.  
  8. new NPC[NPC_NUM] = {-1};
  9.  
  10. new LocalPlayer = -1, formation = 0, forming = 0, specid = -1, bool:moveall = false;
  11.  
  12. #define fornpcs(%1) for(new %1 = 0; %1 < sizeof(NPC); %1 ++)
  13.  
  14. new weaps[] =
  15. {
  16.     WEAPON_DEAGLE,
  17.     WEAPON_RIFLE,
  18.     WEAPON_SHOTGSPA,
  19.     WEAPON_SHOTGUN,
  20.     WEAPON_M4,
  21.     WEAPON_AK47,
  22.     WEAPON_SILENCED,
  23.     WEAPON_MP5,
  24.     WEAPON_SNIPER,
  25.     WEAPON_MINIGUN,
  26.     WEAPON_FLAMETHROWER
  27. };
  28.  
  29. main()
  30. {
  31. }
  32.  
  33. public OnGameModeInit()
  34. {
  35.     // Direct Control
  36.     ToggleKey(VK_C); // Crouch
  37.     ToggleKey(VK_J); // Jetpack
  38.     ToggleKey(VK_Q); // Prev Weapon
  39.     ToggleKey(VK_E); // Next Weapon
  40.    
  41.     // Management
  42.     ToggleKey(VK_P);
  43.     ToggleKey(VK_O);
  44.     ToggleKey(VK_I);
  45.     ToggleKey(VK_U);
  46.     ToggleKey(VK_KEYB0);
  47.     ToggleKey(VK_KEYB1);
  48.     ToggleKey(VK_KEYB2);
  49.     ToggleKey(VK_KEYB3);
  50.     ToggleKey(VK_KEYB4);
  51.     ToggleKey(VK_KEYB5);
  52.     ToggleKey(VK_KEYB6);
  53.     ToggleKey(VK_KEYB7);
  54.     ToggleKey(VK_KEYB8);
  55.     ToggleKey(VK_KEYB9);
  56.    
  57.     // Modifiers
  58.     ToggleKey(VK_LCONTROL);
  59.    
  60.     // Help/Meta
  61.     ToggleKey(VK_F2);
  62.    
  63.     CA_Init();
  64.    
  65.     FCNPC_SetUpdateRate(40);
  66.    
  67.     new Float:sx, Float:sy, Float:sz, ret, Float:x, Float:y, Float:z;
  68.    
  69.     do
  70.     {
  71.         sx = (random(60000)-30000)/10.0;
  72.         sy = (random(60000)-30000)/10.0;
  73.         ret = CA_RayCastLine(sx, sy, 700.0, sx, sy, -5.0, sx, sy, sz);
  74.     } while(ret == 0 || ret == WATER_OBJECT);
  75.    
  76.     AddPlayerClass(0, sx, sy, sz+1.0, 0.0, WEAPON_DEAGLE, 9999, WEAPON_M4, 9999, WEAPON_MINIGUN, 9999);
  77.    
  78.     fornpcs(i)
  79.     {
  80.         new name[10] = {0, ...};
  81.         for(new j = 0; j < sizeof(name)-1; j ++) name[j] = (random(2) == 0 ? 'a' + random(26) : 'A' + random(26));
  82.         NPC[i] = FCNPC_Create(name);
  83.        
  84.         x = sx + random(sizeof(NPC)) * 1.3, y =  sy + (random(sizeof(NPC))+random(5)) * 0.8;
  85.         CA_RayCastLine(x, y, 700.0, x, y, -5.0, x, y, z);
  86.        
  87.         FCNPC_Spawn(NPC[i], random(311), x, y, z+1.0);
  88.         FCNPC_SetWeapon(NPC[i], weaps[0]);
  89.         FCNPC_SetAmmo(NPC[i], 9000);
  90.        
  91.         for(new j = 0; j < sizeof(weaps); j ++) FCNPC_SetWeaponSkillLevel(NPC[i], weaps[j], 1000);
  92.     }
  93.    
  94.     SetTimer("ControlTimer", 100, 1);
  95.     return 1;
  96. }
  97.  
  98. public OnGameModeExit()
  99. {
  100.     fornpcs(i) if(FCNPC_IsValid(NPC[i])) FCNPC_Destroy(NPC[i]);
  101.     return 1;
  102. }
  103.  
  104. public OnPlayerConnect(playerid)
  105. {
  106.     if(IsPlayerNPC(playerid)) return 1;
  107.    
  108.     if(LocalPlayer != -1) return 1;
  109.    
  110.     new IP[16];
  111.     GetPlayerIp(playerid, IP, 16);
  112.    
  113.     if(strlen(IP) != 9) return 1;
  114.    
  115.     if(strcmp(IP, "127.0.0.1") != 0) return 1;
  116.    
  117.     LocalPlayer = playerid;
  118.    
  119.     return 1;
  120. }
  121.  
  122. public OnPlayerSpawn(playerid)
  123. {
  124.     if(IsPlayerNPC(playerid)) return 1;
  125.  
  126.     return 1;
  127. }
  128.  
  129. public OnLocalKeyStateChange(key, newstate)
  130. {
  131.     //printf("%d", key);
  132.     if((LocalPlayer == -1 || !IsSAMPFocused()) && newstate) return 1;
  133.    
  134.     if(key == VK_F2 && newstate)
  135.     {
  136.         SendClientMessage(LocalPlayer, -1, "--- HNPC Controls ---");
  137.         SendClientMessage(LocalPlayer, -1, "  W/A/S/D - Move");
  138.         SendClientMessage(LocalPlayer, -1, "  C - Crouch");
  139.         SendClientMessage(LocalPlayer, -1, "  Q - Previous Weapon");
  140.         SendClientMessage(LocalPlayer, -1, "  E - Next Weapon");
  141.         SendClientMessage(LocalPlayer, -1, "  J - Toggle Jetpack");
  142.         SendClientMessage(LocalPlayer, -1, "  LCTRL + [0-8] - Build Formation");
  143.         SendClientMessage(LocalPlayer, -1, "  LCTRL + P - Switich to next NPC");
  144.         SendClientMessage(LocalPlayer, -1, "  LCTRL + O - Go Back to CJ");
  145.         SendClientMessage(LocalPlayer, -1, "  LCTRL + I - Reset");
  146.         SendClientMessage(LocalPlayer, -1, "  LCTRL + U - Toggle Move All");
  147.         SendClientMessage(LocalPlayer, -1, "---");
  148.         return 1;
  149.     }
  150.    
  151.     fornpcs(i) if(NPC[i] == -1) return 1;
  152.  
  153.     if(key == VK_I && newstate && IsLocalKeyDown(VK_LCONTROL))
  154.     {
  155.         fornpcs(i)
  156.         {
  157.             FCNPC_SetPosition(NPC[i], 0.0, 0.0, 0.0);
  158.             FCNPC_Respawn(NPC[i]);
  159.         }
  160.         return 1;
  161.     }
  162.  
  163.     if(key == VK_P && newstate && IsLocalKeyDown(VK_LCONTROL))
  164.     {
  165.         if(specid == -1) TogglePlayerSpectating(LocalPlayer, 1);
  166.        
  167.         specid ++;
  168.         if(specid == NPC_NUM) specid = 0;
  169.        
  170.         if(GetPlayerState(NPC[specid]) == PLAYER_STATE_ONFOOT) PlayerSpectatePlayer(LocalPlayer, NPC[specid]);
  171.         else PlayerSpectateVehicle(LocalPlayer, 1);
  172.         return 1;
  173.     }
  174.    
  175.     if(key == VK_O && newstate && IsLocalKeyDown(VK_LCONTROL) && specid != -1)
  176.     {
  177.         TogglePlayerSpectating(LocalPlayer, 0);
  178.        
  179.         specid = -1;
  180.         return 1;
  181.     }
  182.    
  183.     if(key == VK_U && newstate && IsLocalKeyDown(VK_LCONTROL))
  184.     {
  185.         moveall = !moveall;
  186.  
  187.         if(moveall) SendClientMessage(LocalPlayer, -1, "Moving all NPCs.");
  188.         else
  189.         {
  190.             SendClientMessage(LocalPlayer, -1, "Moving selected NPC only.");
  191.        
  192.             fornpcs(i)
  193.             {
  194.                 if(FCNPC_IsMoving(NPC[i])) FCNPC_Stop(NPC[i]);
  195.                 if(FCNPC_IsAiming(NPC[i])) FCNPC_StopAim(NPC[i]);
  196.                 FCNPC_SetKeys(NPC[i], 0, 0, 0);
  197.             }
  198.         }
  199.        
  200.         forming = 0;
  201.         return 1;
  202.     }
  203.  
  204.     if(specid == -1 && newstate) return 1;
  205.    
  206.     if(key == VK_C && newstate)
  207.     {
  208.         fornpcs(i)
  209.         {
  210.             if(!moveall) i = specid;
  211.            
  212.             new cursact = FCNPC_GetSpecialAction(NPC[i]);
  213.            
  214.             if(cursact == 2) continue;
  215.  
  216.             if(cursact == 0) FCNPC_SetSpecialAction(NPC[i], 1);
  217.             else if(cursact == 1) FCNPC_SetSpecialAction(NPC[i], 0);
  218.            
  219.             if(!moveall) break;
  220.         }
  221.         return 1;
  222.     }
  223.    
  224.     if(key == VK_J && newstate)
  225.     {
  226.         fornpcs(i)
  227.         {
  228.             if(!moveall) i = specid;
  229.            
  230.             new cursact = FCNPC_GetSpecialAction(NPC[i]);
  231.  
  232.             if(cursact == 1) continue;
  233.  
  234.             if(cursact == 0) FCNPC_SetSpecialAction(NPC[i], 2);
  235.             else if(cursact == 2)
  236.             {
  237.                 FCNPC_SetSpecialAction(NPC[i], 0);
  238.                 FCNPC_SetWeapon(NPC[i], FCNPC_GetWeapon(NPC[i]));
  239.             }
  240.            
  241.             if(!moveall) break;
  242.         }
  243.         return 1;
  244.     }
  245.    
  246.     if(key == VK_Q && newstate && !moveall)
  247.     {
  248.         new slot = -1, wid = FCNPC_GetWeapon(NPC[specid]);
  249.        
  250.         for(new i = 0; i < sizeof(weaps); i ++) if(weaps[i] == wid)
  251.         {
  252.             slot = i;
  253.             break;
  254.         }
  255.        
  256.         if(slot == -1) return 1;
  257.        
  258.         slot --;
  259.         if(slot < 0) slot = sizeof(weaps)-1;
  260.        
  261.         FCNPC_SetWeapon(NPC[specid], weaps[slot]);
  262.         FCNPC_SetAmmo(NPC[specid], 10000);
  263.        
  264.         return 1;
  265.     }
  266.    
  267.     if(key == VK_E && newstate && !moveall)
  268.     {
  269.         new slot = -1, wid = FCNPC_GetWeapon(NPC[specid]);
  270.  
  271.         for(new i = 0; i < sizeof(weaps); i ++) if(weaps[i] == wid)
  272.         {
  273.             slot = i;
  274.             break;
  275.         }
  276.  
  277.         if(slot == -1) return 1;
  278.  
  279.         slot ++;
  280.         if(slot == sizeof(weaps)) slot = 0;
  281.  
  282.         FCNPC_SetWeapon(NPC[specid], weaps[slot]);
  283.         FCNPC_SetAmmo(NPC[specid], 10000);
  284.  
  285.         return 1;
  286.     }
  287.  
  288.     if(key == VK_LCONTROL && newstate) return 1;
  289.  
  290.     new movingnpcs = 0;
  291.     fornpcs(i)
  292.     {
  293.         if(!moveall && i == specid) continue;
  294.        
  295.         if(FCNPC_IsMoving(NPC[i])) movingnpcs ++;
  296.     }
  297.  
  298.     if(key >= VK_KEYB0 && key <= VK_KEYB9 && newstate && IsLocalKeyDown(VK_LCONTROL) && (forming == 0 || movingnpcs == 0))
  299.     {
  300.         formation = key - VK_KEYB0;
  301.        
  302.         forming = 0;
  303.        
  304.         new Float:bx, Float:by, Float:bz, Float:tx, Float:ty, Float:tz;
  305.        
  306.         if(formation == 0)
  307.         {
  308.             SendClientMessageToAll(-1, "Building Random Group");
  309.            
  310.             if(moveall) FCNPC_GetPosition(NPC[0], bx, by, bz);
  311.             else FCNPC_GetPosition(NPC[specid], bx, by, bz);
  312.            
  313.             fornpcs(i)
  314.             {
  315.                 tx = bx + random(sizeof(NPC)) * 1.3;
  316.                 ty = by + (random(sizeof(NPC))+random(5));
  317.                
  318.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  319.                
  320.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  321.                
  322.                 if(moveall || (!moveall && i != specid)) forming ++;
  323.             }
  324.         }
  325.        
  326.         if(formation == 1)
  327.         {
  328.             SendClientMessageToAll(-1, "Building Formation 1 - Line X");
  329.  
  330.             if(moveall) FCNPC_GetPosition(NPC[0], bx, by, bz);
  331.             else FCNPC_GetPosition(NPC[specid], bx, by, bz);
  332.  
  333.             fornpcs(i)
  334.             {
  335.                 tx = bx + (i) * 2.0;
  336.                 ty = by;
  337.    
  338.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  339.  
  340.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  341.                
  342.                 if(moveall || (!moveall && i != specid)) forming ++;
  343.             }
  344.         }
  345.        
  346.         if(formation == 2)
  347.         {
  348.             SendClientMessageToAll(-1, "Building Formation 2 - Line Y");
  349.  
  350.             if(moveall) FCNPC_GetPosition(NPC[0], bx, by, bz);
  351.             else FCNPC_GetPosition(NPC[specid], bx, by, bz);
  352.  
  353.             fornpcs(i)
  354.             {
  355.                 tx = bx;
  356.                 ty = by + (i) * 2.0;
  357.  
  358.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  359.  
  360.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  361.                
  362.                 if(moveall || (!moveall && i != specid)) forming ++;
  363.             }
  364.         }
  365.        
  366.         if(formation == 3)
  367.         {
  368.             SendClientMessageToAll(-1, "Building Formation 3 - Circle");
  369.            
  370.             FCNPC_GetPosition(NPC[specid], bx, by, bz);
  371.            
  372.             new num = sizeof(NPC);
  373.  
  374.             fornpcs(i)
  375.             {
  376.                 tx = bx + (num * 0.4)*floatsin((360.0 / num) * i, degrees);
  377.                 ty = by + (num * 0.4)*floatcos((360.0 / num) * i, degrees);
  378.  
  379.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  380.  
  381.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  382.  
  383.                 if(moveall || (!moveall && i != specid)) forming ++;
  384.             }
  385.         }
  386.        
  387.         if(formation == 4)
  388.         {
  389.             SendClientMessageToAll(-1, "Building Formation 4 - Circle Around");
  390.  
  391.             FCNPC_GetPosition(NPC[specid], bx, by, bz);
  392.  
  393.             new num = sizeof(NPC) - 1, idx = 0;
  394.  
  395.             fornpcs(i)
  396.             {
  397.                 if(i != specid)
  398.                 {
  399.                     tx = bx + (num * 0.4)*floatsin((360.0 / num) * idx, degrees);
  400.                     ty = by + (num * 0.4)*floatcos((360.0 / num) * idx, degrees);
  401.                    
  402.                     idx ++;
  403.                 }
  404.                 else
  405.                 {
  406.                     tx = bx;
  407.                     ty = by;
  408.                 }
  409.  
  410.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  411.  
  412.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  413.  
  414.                 if(moveall || (!moveall && i != specid)) forming ++;
  415.             }
  416.         }
  417.        
  418.         if(formation == 5)
  419.         {
  420.             SendClientMessageToAll(-1, "Building Formation 5 - Pair");
  421.  
  422.             if(moveall) FCNPC_GetPosition(NPC[0], bx, by, bz);
  423.             else FCNPC_GetPosition(NPC[specid], bx, by, bz);
  424.  
  425.             fornpcs(i)
  426.             {
  427.                 if(i % 2 == 0)
  428.                 {
  429.                     tx = bx;
  430.                     ty = by + i;
  431.                 }
  432.                 else
  433.                 {
  434.                     tx = bx + 2.0;
  435.                     ty = by + i-1;
  436.                 }
  437.                
  438.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  439.  
  440.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  441.  
  442.                 if(moveall || (!moveall && i != specid)) forming ++;
  443.             }
  444.         }
  445.        
  446.         if(formation == 6)
  447.         {
  448.             SendClientMessageToAll(-1, "Building Formation 6 - Trio");
  449.  
  450.             if(moveall) FCNPC_GetPosition(NPC[0], bx, by, bz);
  451.             else FCNPC_GetPosition(NPC[specid], bx, by, bz);
  452.  
  453.             fornpcs(i)
  454.             {
  455.                 if(i % 3 == 0)
  456.                 {
  457.                     tx = bx;
  458.                     ty = by + (i);
  459.                 }
  460.                 else if(i % 3 == 1)
  461.                 {
  462.                     tx = bx + 2.0;
  463.                     ty = by + (i-1);
  464.                 }
  465.                 else
  466.                 {
  467.                     tx = bx + 4.0;
  468.                     ty = by + (i-2);
  469.                 }
  470.  
  471.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  472.  
  473.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  474.  
  475.                 if(moveall || (!moveall && i != specid)) forming ++;
  476.             }
  477.         }
  478.        
  479.         if(formation == 7)
  480.         {
  481.             SendClientMessageToAll(-1, "Building Formation 7 - Stuffed");
  482.  
  483.             FCNPC_GetPosition(NPC[specid], tx, ty, bz);
  484.             if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  485.  
  486.             fornpcs(i)
  487.             {
  488.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  489.  
  490.                 if(moveall || (!moveall && i != specid)) forming ++;
  491.             }
  492.         }
  493.        
  494.         if(formation == 8)
  495.         {
  496.             SendClientMessageToAll(-1, "Building Formation 8 - Random Row");
  497.  
  498.             new Float:a = random(360000)/1000.0, adir = random(2);
  499.  
  500.             FCNPC_GetPosition(NPC[specid], tx, ty, bz);
  501.  
  502.             fornpcs(i)
  503.             {
  504.                 tx += 1.5 * floatsin(a, degrees);
  505.                 ty += 1.5 * floatcos(a, degrees);
  506.                
  507.                 if(adir) a += random(14000)/1000.0;
  508.                 else a -= random(14000)/1000.0;
  509.                
  510.                 if(!random(25)) adir = (adir == 1 ? 0 : 1);
  511.                
  512.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  513.                
  514.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  515.  
  516.                 if(moveall || (!moveall && i != specid)) forming ++;
  517.             }
  518.         }
  519.        
  520.         if(formation == 9)
  521.         {
  522.             SendClientMessageToAll(-1, "Building Formation 9 - Spiral");
  523.  
  524.             new Float:a = 14.0;
  525.  
  526.             FCNPC_GetPosition(NPC[specid], bx, by, bz);
  527.  
  528.             fornpcs(i)
  529.             {
  530.                 new Float:rad = (3.5 + i * 0.085);
  531.                
  532.                 tx = bx + rad * floatsin(i*a, degrees);
  533.                 ty = by + rad * floatcos(i*a, degrees);
  534.  
  535.                 if(CA_RayCastLine(tx, ty, 700.0, tx, ty, -5.0, tx, ty, tz) == WATER_OBJECT) tz -= 1.6;
  536.  
  537.                 FCNPC_GoTo(NPC[i], tx, ty, tz + 1.0, MOVE_TYPE_SPRINT, 0.5, false, 0.0, true);
  538.  
  539.                 if(moveall || (!moveall && i != specid)) forming ++;
  540.             }
  541.         }
  542.        
  543.         return 1;
  544.     }
  545.    
  546.     return 1;
  547. }
  548.  
  549. public FCNPC_OnReachDestination(npcid)
  550. {
  551.     if(forming > 0)
  552.     {
  553.         forming --;
  554.         FCNPC_SetKeys(npcid, 0, 0, 0);
  555.     }
  556.     return 1;
  557. }
  558.  
  559. forward ControlTimer();
  560. public ControlTimer()
  561. {
  562.     if(LocalPlayer == -1 || NPC[0] == -1 || (forming > 0 && moveall) || specid == -1) return 1;
  563.    
  564.     new ud, lr;
  565.    
  566.     if(IsLocalKeyDown(VK_W) && !IsLocalKeyDown(VK_S)) ud = 1;
  567.     else if(!IsLocalKeyDown(VK_W) && IsLocalKeyDown(VK_S)) ud = -1;
  568.    
  569.     if(IsLocalKeyDown(VK_D) && !IsLocalKeyDown(VK_A)) lr = 1;
  570.     else if(!IsLocalKeyDown(VK_D) && IsLocalKeyDown(VK_A)) lr = -1;
  571.    
  572.     new Float:cx, Float:cy, Float:cz, Float:aorg, Float:a, Float:xo, Float:yo;
  573.  
  574.     GetPlayerCameraFrontVector(LocalPlayer, cx, cy, cz);
  575.     cx *= 5.0, cy *= 5.0, cz *= 5.0;
  576.    
  577.     aorg = atan2(cx, cy);
  578.     a = aorg;
  579.  
  580.     if(ud > 0)
  581.     {
  582.         if(lr > 0) a += 45.0;
  583.         else if(lr < 0) a -= 45.0;
  584.     }
  585.     else if(ud < 0)
  586.     {
  587.         if(lr > 0) a += 135.0;
  588.         else if(lr < 0) a -= 135.0;
  589.         else a += 180.0;
  590.     }
  591.     else
  592.     {
  593.         if(lr > 0) a += 90.0;
  594.         else if(lr < 0) a -= 90.0;
  595.     }
  596.  
  597.     xo = 5.0 * floatsin(a, degrees);
  598.     yo = 5.0 * floatcos(a, degrees);
  599.  
  600.     fornpcs(i)
  601.     {
  602.         if(!moveall) i = specid;
  603.        
  604.         new Float:x, Float:y, Float:z;
  605.         FCNPC_GetPosition(NPC[i], x, y, z);
  606.  
  607.         if(ud == 0 && lr == 0)
  608.         {
  609.             if(FCNPC_IsMoving(NPC[i])) FCNPC_Stop(NPC[i]);
  610.             FCNPC_SetKeys(NPC[i], 0, 0, 0);
  611.         }
  612.         else
  613.         {
  614.             x += xo;
  615.             y += yo;
  616.         }
  617.  
  618.         new special = FCNPC_GetSpecialAction(NPC[i]);
  619.  
  620.         if(special != 2)
  621.         {
  622.             new Float:speed, movetype, aim;
  623.  
  624.             if(IsLocalKeyDown(VK_RMB))
  625.             {
  626.                 FCNPC_AimAt(NPC[i], x + (cx*100.0), y + (cy*100.0), z + (cz*100.0), (IsLocalKeyDown(VK_LMB) ? true : false), 0, true);
  627.                 aim = 1;
  628.  
  629.                 if(IsLocalKeyDown(VK_LMB)) FCNPC_SetKeys(NPC[i], 0, 0, 128 | KEY_FIRE);
  630.                 else FCNPC_SetKeys(NPC[i], 0, 0, 128);
  631.  
  632.                 speed = 0.005;
  633.                 movetype = MOVE_TYPE_WALK;
  634.             }
  635.             else if(IsLocalKeyDown(VK_LSHIFT) && special != 1)
  636.             {
  637.                 FCNPC_SetKeys(NPC[i], 0, 0, KEY_SPRINT);
  638.                 speed = 0.5;
  639.                 movetype = MOVE_TYPE_SPRINT;
  640.             }
  641.             else if(IsLocalKeyDown(VK_ALT) && special != 1)
  642.             {
  643.                 FCNPC_SetKeys(NPC[i], 0, 0, KEY_WALK);
  644.                 speed = 0.005;
  645.                 movetype = MOVE_TYPE_WALK;
  646.             }
  647.             else
  648.             {
  649.                 FCNPC_SetKeys(NPC[i], 0, 0, 0);
  650.                 speed = 0.05;
  651.                 movetype = MOVE_TYPE_RUN;
  652.             }
  653.  
  654.             if(!aim && FCNPC_IsAiming(NPC[i])) FCNPC_StopAim(NPC[i]);
  655.  
  656.             new ret = CA_RayCastLine(x, y, z + 700.0, x, y, -5.0, x, y, z);
  657.             if(ret != WATER_OBJECT) z += 1.0;
  658.             else z = -0.6;
  659.  
  660.             if(aim) FCNPC_SetAngle(NPC[i], -aorg);
  661.  
  662.             if(ud != 0 || lr != 0)
  663.             {
  664.                 FCNPC_GoTo(NPC[i], x, y, z, movetype, speed, false, 0.0, false);
  665.                 if(!aim) FCNPC_SetAngle(NPC[i], -a);
  666.             }
  667.         }
  668.         else
  669.         {
  670.             new move;
  671.  
  672.             if(IsLocalKeyDown(VK_RMB))
  673.             {
  674.                 FCNPC_AimAt(NPC[i], x + (cx*100.0), y + (cy*100.0), z + (cz*100.0), (IsLocalKeyDown(VK_LMB) ? true : false), 0, true);
  675.  
  676.                 if(IsLocalKeyDown(VK_LMB)) FCNPC_SetKeys(NPC[i], 0, 0, 128 | KEY_FIRE);
  677.                 else FCNPC_SetKeys(NPC[i], 0, 0, 128);
  678.             }
  679.             else
  680.             {
  681.                 FCNPC_SetKeys(NPC[i], 0, 0, 0);
  682.                 if(FCNPC_IsAiming(NPC[i])) FCNPC_StopAim(NPC[i]);
  683.             }
  684.  
  685.             if(IsLocalKeyDown(VK_SPACE) && !IsLocalKeyDown(VK_LSHIFT)) { z -= 1.7; move = 1; }
  686.             else if(!IsLocalKeyDown(VK_SPACE) && IsLocalKeyDown(VK_LSHIFT)) { z += 1.7; move = 1; }
  687.  
  688.             FCNPC_SetAngle(NPC[i], -aorg);
  689.  
  690.             if(move || ud != 0 || lr != 0)
  691.             {
  692.                 FCNPC_GoTo(NPC[i], x, y, z, MOVE_TYPE_RUN, 0.1, false, 0.0, false);
  693.             }
  694.         }
  695.        
  696.         if(!moveall) break;
  697.     }
  698.    
  699.     return 1;
  700. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement