Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <cnpc>
- #include <cnpc_controller>
- #include <vip>
- enum npcInfo {
- npc_Skin,
- npc_Weapon,
- Float:npc_TargetDist,
- Float:npc_X,
- Float:npc_Y,
- Float:npc_Z,
- Float:npc_A,
- npc_ID,
- npc_TargetID,
- }
- new npc[][npcInfo] = {
- {105, 33, 45.0, 2494.3379, 2762.0728, 10.8203, 82.6969},
- {106, 33, 45.0, 2494.3379, 2782.0728, 10.8203, 92.4103},
- {107, 34, 350.0, 2503.8342, 2693.0327, 74.8277, 60.8794},
- {108, 34, 350.0, 2629.5791, 2830.3835, 122.9219, 122.1029},
- {109, 34, 350.0, 2629.2607, 2833.8516, 122.9219, 123.6696},
- {110, 34, 350.0, 2632.1509, 2828.6719, 122.9219, 120.5362},
- {110, 34, 350.0, 2632.1509, 2828.6719, 122.9219, 120.5362},
- {110, 34, 350.0, 2509.7610, 2691.3679, 74.8281, 324.5181},
- {110, 34, 350.0, 2507.0632, 2694.1550, 74.8281, 343.0050},
- {110, 34, 350.0, 2566.1340, 2671.0398, 36.4252, 32.8254},
- {110, 30, 350.0, 2572.6440, 2721.6748, 22.9507, 54.1323},
- {110, 30, 350.0, 2582.9189, 2721.2813, 22.9507, 45.0455},
- {110, 34, 350.0, 2595.3552, 2721.4360, 25.8222, 60.0856},
- {110, 30, 350.0, 2594.8645, 2732.3953, 23.8222, 84.2125},
- {110, 30, 350.0, 2594.8845, 2758.3169, 23.8222, 81.0791},
- {110, 30, 350.0, 2595.4187, 2781.5964, 23.8222, 92.3592},
- {110, 30, 350.0, 2539.7051, 2803.9167, 27.8203, 132.7797},
- {110, 37, 70.0, 2559.0647, 2820.2732, 10.8203, 93.4537},
- {110, 33, 70.0, 2556.9497, 2835.6948, 10.8203, 178.0544},
- {110, 33, 70.0, 2568.3921, 2842.4070, 14.2559, 126.6673},
- {110, 33, 70.0, 2589.8901, 2842.2651, 14.2559, 113.8205},
- {110, 34, 70.0, 2594.8040, 2834.4480, 10.8203, 103.1671}
- };
- new Float:ftmp[3];
- new maxplayers = MAX_PLAYERS;
- public OnFilterScriptInit()
- {
- maxplayers = GetMaxPlayers();
- zmap_Init("SAfull.hmap",ZMAP_MODE_CHACHE);
- nodes_Init();
- paths_Init();
- for (new npcid = 0; npcid < sizeof(npc); npcid++) {
- npc[npcid][npc_ID] = FindLastFreeSlot();
- CreateNPC(npc[npcid][npc_ID], "Vagos");
- SpawnNPC(npc[npcid][npc_ID]);
- SetNPCPos(npc[npcid][npc_ID], npc[npcid][npc_X], npc[npcid][npc_Y], npc[npcid][npc_Z]);
- SetNPCFacingAngle(npc[npcid][npc_ID], npc[npcid][npc_A]);
- SetNPCSkin(npc[npcid][npc_ID], npc[npcid][npc_Skin]);
- SetNPCWeapon(npc[npcid][npc_ID], npc[npcid][npc_Weapon]);
- }
- SetTimer("attack", 500, 1);
- }
- public OnFilterScriptExit()
- {
- paths_Exit();
- nodes_Exit();
- zmap_Exit();
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- controller_OnPlayerUpdate(playerid);
- return 1;
- }
- public OnNPCGetDamage(npcid, playerid, Float:health_loss)
- {
- return 1;
- }
- public OnNPCSpawn(npcid)
- {
- controller_OnNPCSpawn(npcid);
- }
- public OnNPCMovingComplete(npcid)
- {
- controller_OnNPCMovingComplete(npcid);
- }
- public OnNPCDeath(npcid,killerid,reason)
- {
- StopNPC(npcid);
- SetTimer("RespawnCitizen", 15000, 1);
- controller_OnNPCDeath(npcid, killerid, reason);
- }
- public OnPathCalculated(pathid)
- {
- paths_OnPathCalculated(pathid);
- }
- public OnCompleteCalcPathForNPC(npcid)
- {
- controller_OnCompCalcPathForNPC(npcid);
- }
- public OnStartCalcPathForNPC(npcid)
- {
- }
- 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) {
- GetPlayerPos(npc[npcid][npc_TargetID], ftmp[0], ftmp[1], ftmp[2]);
- NPC_ShootAt(npc[npcid][npc_ID], ftmp[0], ftmp[1], ftmp[2]);
- } else {
- StopNPC(npc[npcid][npc_ID]);
- }
- }
- return 1;
- }
- forward RespawnCitizen(npcid);
- public RespawnCitizen(npcid)
- {
- DestroyNPC(npcid);
- }
Advertisement
Add Comment
Please, Sign In to add comment