[FS/INC] Attacking NPCs
#1

For those of you whom like to complain that NPCs don't have the potential to attack, stop complaining. You might want to edit your own script to place stationary NPCs around the server. The default way to set a NPC's position is with "/getnpc". Also, if you wish to throw off his accuracy a bit, just go to line 89 and change the dOffset value to whatever you want.

EDIT: Players can now shoot at and kill the NPC, though be warned, he has a nice chunk of hp.

What he does: he faces the closest player that is within 30 units to him, and shoots at said player.


It was requested that I simply turn this into a function, and so I did such. I've also left up the old one for those of you whom don't want to bother with the include.



Function-
CreateAttackingNPC
Create an attacking npc at a specific location.

Parameters-
npcname, the NPC you wish to make an attacking NPC
Float, the NPC's X position
Float:y, the NPC's Y position
Float:z, the NPC's Z position
Float:AttackRadius (default: 60 units), the npc's firing distance
Float:Accuracy (default: 10 degrees), the npc's firing accuracy


Example on how to use it (you MUST use a timer):
pawn Код:
#include <a_samp>
#include <attacking_npc>

#define FILTERSCRIPT

public OnFilterScriptInit()
{
    ConnectNPC("Attack_NPC", "1");
    return 0;
}

//We make sure that the NPC spawns before we make it an attacking NPC
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
      if(playerid == GetPlayerID("Attack_NPC")) SetTimer("AttackNPC", 5000, 0);
    }
    return 0;
}

forward AttackNPC();
public AttackNPC()
{
    CreateAttackingNPC("Attack_NPC", 0.0, 0.0, 0.0);
    return 0;
}

Video (sorry, no audio!):
SAMP Attacking NPC

Download (old):


Download (new):


You also need this include (a_angles):


EDIT: some people have had some problems regarding the creation of their own attacking NPCs, due to the lack of a NPC file, so I'll provide you all with one here:


Have any suggestions for any future updates? Post em' here.

Enjoy.
Reply


Messages In This Thread
[FS/INC] Attacking NPCs - by Tannz0rz - 01.11.2009, 22:55
Re: [FS] Attacking NPCs - by joemomma53 - 01.11.2009, 22:58
Re: [FS] Attacking NPCs - by SergiKirov - 01.11.2009, 23:01
Re: [FS] Attacking NPCs - by [TG]Chase - 01.11.2009, 23:02
Re: [FS] Attacking NPCs - by Tannz0rz - 01.11.2009, 23:07
Re: [FS] Attacking NPCs - by Tannz0rz - 01.11.2009, 23:40
Re: [FS] Attacking NPCs - by Striker_Moe - 02.11.2009, 06:54
Re: [FS] Attacking NPCs - by mini-d - 02.11.2009, 07:01
Re: [FS] Attacking NPCs - by Striker_Moe - 02.11.2009, 07:02
Re: [FS] Attacking NPCs - by Matthew_Murdoch - 02.11.2009, 09:12
Re: [FS] Attacking NPCs - by Tannz0rz - 02.11.2009, 09:51
Re: [FS] Attacking NPCs - by Striker_Moe - 02.11.2009, 14:05
Re: [FS] Attacking NPCs - by Burridge - 02.11.2009, 14:11
Re: [FS] Attacking NPCs - by [03]Garsino - 02.11.2009, 14:15
Re: [FS] Attacking NPCs - by Zigulys400 - 02.11.2009, 14:40
Re: [FS] Attacking NPCs - by SpiderPork - 02.11.2009, 15:04
Re: [FS] Attacking NPCs - by Tez2k7 - 02.11.2009, 15:33
Re: [FS] Attacking NPCs - by Tannz0rz - 02.11.2009, 19:07
Re: [FS] Attacking NPCs - by lolumadd - 02.11.2009, 19:08
Re: [FS] Attacking NPCs - by Evoturk - 02.11.2009, 19:12
Re: [FS] Attacking NPCs - by Correlli - 02.11.2009, 19:16
Re: [FS] Attacking NPCs - by [HUN]Woozie - 02.11.2009, 19:19
Re: [FS] Attacking NPCs - by HydraX - 02.11.2009, 20:14
Re: [FS] Attacking NPCs - by Striker_Moe - 02.11.2009, 20:19
Re: [FS] Attacking NPCs - by Blantas - 02.11.2009, 20:28
Re: [FS] Attacking NPCs - by Tannz0rz - 02.11.2009, 21:53
Re: [FS] Attacking NPCs - by joemomma53 - 02.11.2009, 22:45
Re: [FS] Attacking NPCs - by Tannz0rz - 02.11.2009, 23:02
Re: [FS] Attacking NPCs - by Guedes747 - 02.11.2009, 23:02
Re: [FS] Attacking NPCs - by addysnow1 - 04.11.2009, 14:24
Re: [FS/INC] Attacking NPCs - by Ky_Bob - 03.10.2010, 12:44
Re: [FS/INC] Attacking NPCs - by nicoud - 10.10.2010, 22:42
Re: [FS/INC] Attacking NPCs - by nicoud - 13.10.2010, 20:53
Re: [FS/INC] Attacking NPCs - by Johny_James - 15.10.2010, 19:28
Re: [FS/INC] Attacking NPCs - by Ali_Dumi - 24.10.2010, 18:47

Forum Jump:


Users browsing this thread: 6 Guest(s)