Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- forward attack();
- public attack()
- {
- new Float:min_dist,
- Float:curr_dist;
- for (new npcid = 0; npcid < sizeof(npc); npcid++) {
- GetNPCPos(npc[npcid][npc_ID], ftmp[0], ftmp[1], ftmp[2]);
- npc[npcid][npc_TargetID] = -1;
- min_dist = 99999.0;
- // get closest player
- for (new playerid = 0; playerid < maxplayers; playerid++) {
- if (!IsPlayerConnected(playerid) || IsPlayerNPC(playerid)) {
- continue;
- }
- curr_dist = GetPlayerDistanceFromPoint(playerid, ftmp[0], ftmp[1], ftmp[2]);
- if (min_dist > curr_dist && curr_dist < npc[npcid][npc_TargetDist]) {
- min_dist = curr_dist;
- npc[npcid][npc_TargetID] = playerid;
- }
- }
- // shoot in closest player
- if (npc[npcid][npc_TargetID] != -1) {
- pNPC_ShootAt(npc[npcid][npc_ID], npc[npcid][npc_TargetID]);
- } else {
- StopNPC(npc[npcid][npc_ID]);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement