Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <FCNPC>
- #include <a_angles>
- #include <YSI\y_iterate>
- #define MAX_ZOMBIES 50
- enum ZombieEnum
- {
- zID,
- zAttack,
- zLevel,
- zIDPlayer,
- Float: zHealth,
- }
- new ZombieInfo[MAX_ZOMBIES][ZombieEnum];
- new Iterator:Zombies<MAX_ZOMBIES>;
- stock ZombieLevelBas[] = {159, 160, 162};
- stock ZombieLevelHaut[] = {5, 182};
- new Float:gRandomSpawns_LosSantos[][4] = {
- {1751.1097,-2106.4529,13.5469,183.1979}, // El-Corona - Outside random house
- {2652.6418,-1989.9175,13.9988,182.7107}, // Random house in willowfield - near playa de seville and stadium
- {2489.5225,-1957.9258,13.5881,2.3440}, // Hotel in willowfield - near cluckin bell
- {2689.5203,-1695.9354,10.0517,39.5312}, // Outside stadium - lots of cars
- {2770.5393,-1628.3069,12.1775,4.9637}, // South in east beach - north of stadium - carparks nearby
- {2807.9282,-1176.8883,25.3805,173.6018}, // North in east beach - near apartments
- {2552.5417,-958.0850,82.6345,280.2542}, // Random house north of Las Colinas
- {2232.1309,-1159.5679,25.8906,103.2939}, // Jefferson motel
- {2388.1003,-1279.8933,25.1291,94.3321}, // House south of pig pen
- {2481.1885,-1536.7186,24.1467,273.4944}, // East LS - near clucking bell and car wash
- {2495.0720,-1687.5278,13.5150,359.6696}, // Outside CJ's house - lots of cars nearby
- {2306.8252,-1675.4340,13.9221,2.6271}, // House in ganton - lots of cars nearby
- {2191.8403,-1455.8251,25.5391,267.9925}, // House in south jefferson - lots of cars nearby
- {1830.1359,-1092.1849,23.8656,94.0113}, // Mulholland intersection carpark
- {2015.3630,-1717.2535,13.5547,93.3655}, // Idlewood house
- {1654.7091,-1656.8516,22.5156,177.9729}, // Right next to PD
- {1219.0851,-1812.8058,16.5938,190.0045}, // Conference Center
- {1508.6849,-1059.0846,25.0625,1.8058}, // Across the street of BANK - lots of cars in intersection carpark
- {1421.0819,-885.3383,50.6531,3.6516}, // Outside house in vinewood
- {1133.8237,-1272.1558,13.5469,192.4113}, // Near hospital
- {1235.2196,-1608.6111,13.5469,181.2655}, // Backalley west of mainstreet
- {590.4648,-1252.2269,18.2116,25.0473}, // Outside "BAnk of San Andreas"
- {842.5260,-1007.7679,28.4185,213.9953}, // North of Graveyard
- {911.9332,-1232.6490,16.9766,5.2999}, // LS Film Studio
- {477.6021,-1496.6207,20.4345,266.9252}, // Rodeo Place
- {255.4621,-1366.3256,53.1094,312.0852}, // Outside propery in richman
- {281.5446,-1261.4562,73.9319,305.0017}, // Another richman property
- {790.1918,-839.8533,60.6328,191.9514}, // Mulholland house
- {1299.1859,-801.4249,84.1406,269.5274}, // Maddoggs
- {1240.3170,-2036.6886,59.9575,276.4659}, // Verdant Bluffs
- {2215.5181,-2627.8174,13.5469,273.7786}, // Ocean docks 1
- {2509.4346,-2637.6543,13.6453,358.3565} // Ocean Docks spawn 2
- };
- public OnFilterScriptInit()
- {
- for(new i = 0 ;i<MAX_ZOMBIES;i++)
- {
- ZombieInfo[i][zID] = -1;
- ZombieInfo[i][zAttack] = -1;
- ZombieInfo[i][zIDPlayer] = -1;
- new randSpawn = random(sizeof(gRandomSpawns_LosSantos));
- new rand = randomEx(1,2);
- CreateZombie(rand, gRandomSpawns_LosSantos[randSpawn][0], gRandomSpawns_LosSantos[randSpawn][1], gRandomSpawns_LosSantos[randSpawn][2]);
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- new Float: Pos[3];
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- CreateZombie(1, Pos[0], Pos[1]+5.0, Pos[2]);
- SetTimer("ZombieLook", 1000, 1);
- return 1;
- }
- public CreateZombie(Level, Float: PosX, Float: PosY, Float: PosZ)
- {
- for(new i = 0 ;i<MAX_ZOMBIES;i++)
- {
- if(ZombieInfo[i][zID] == -1)
- {
- new NameZombie[MAX_PLAYER_NAME+1];
- format(NameZombie, sizeof(NameZombie), "Zombie%d", i);
- ZombieInfo[i][zID] = FCNPC_Create(NameZombie);
- ZombieInfo[i][zAttack] = -1;
- ZombieInfo[i][zLevel] = randomEx(1, 2);
- FCNPC_Spawn(ZombieInfo[i][zID], 0, PosX, PosY, PosZ);
- if(ZombieInfo[i][zLevel] == 1) FCNPC_SetSkin(ZombieInfo[i][zID], ZombieLevelBas[randomEx(0, 3)]);
- if(ZombieInfo[i][zLevel] == 2) FCNPC_SetSkin(ZombieInfo[i][zID], ZombieLevelHaut[randomEx(0, 2)]);
- ZombieInfo[i][zHealth] = 100.0*ZombieInfo[i][zLevel];
- FCNPC_SetHealth(ZombieInfo[i][zID], ZombieInfo[i][zHealth]);
- Iter_Add(Zombies, i);
- return 1;
- }
- }
- printf("[Zombie]: Attention tous les slots des zombies sont utilisé.");
- return 1;
- }
- public ZombieLook()
- {
- foreach(new i : Zombies)
- {
- if(ZombieInfo[i][zID] != -1)
- {
- foreach(new player : Player)
- {
- if(IsPlayerConnected(player))
- {
- new Float: Position[3];
- FCNPC_GetPosition(ZombieInfo[i][zID], Position[0], Position[1], Position[2]);
- if(IsPlayerInRangeOfPoint(player, 20.0, Position[0], Position[1], Position[2]) && !IsPlayerNPC(player))
- {
- new randomdiagonal = randomEx(-5, 5);
- if(ZombieInfo[i][zAttack] == -1)
- {
- GetPlayerPos(player, Position[0], Position[1], Position[2]);
- FCNPC_GoTo(ZombieInfo[i][zID], Position[0]+randomdiagonal, Position[1]+randomdiagonal, Position[2], MOVE_TYPE_RUN, 0, 1);
- ZombieInfo[i][zAttack] = player;
- }
- else
- {
- GetPlayerPos(player, Position[0], Position[1], Position[2]);
- FCNPC_GoTo(ZombieInfo[i][zID], Position[0]+randomdiagonal, Position[1]+randomdiagonal, Position[2], MOVE_TYPE_RUN, 0, 1);
- }
- GetPlayerPos(ZombieInfo[i][zAttack], Position[0], Position[1], Position[2]);
- if(IsPlayerInRangeOfPoint(ZombieInfo[i][zID], 2.0, Position[0], Position[1], Position[2]) && !IsPlayerNPC(player) && !IsPlayerInAnyVehicle(player))
- {
- new Float: Health;
- GetPlayerHealth(ZombieInfo[i][zAttack], Health);
- SetPlayerHealth(ZombieInfo[i][zAttack], Health-20*ZombieInfo[i][zLevel]);
- }
- }
- else
- {
- ZombieInfo[i][zAttack] = -1;
- }
- }
- }
- }
- }
- return 1;
- }
- stock randomEx(min, max)
- {
- //Credits to y_less
- new rand = random(max-min)+min;
- return rand;
- }
- stock GetPlayerID(const Name[])
- {
- foreach(new i : Player)
- {
- if(IsPlayerConnected(i))
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(i, pName, sizeof(pName));
- if(strcmp(Name, pName, true)==0)
- {
- return i;
- }
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement