#include #include #include #include #include #include #define PLUGIN "NPC" #define VERSION "1.0" #define AUTHOR "Dias" #define NPC_CLASSNAME "witch" #define NPC_HEALTH 1000.0 #define TASK_CRY 11111 #define TASK_STARTATTACK 11112 #define TASK_ATTACKING 11113 #define TASK_AURA 11114 #define MAX_WITCH 3 const MAX_NPC = 512 new npc_modelindex, g_hamnpc, Float:g_myorigin[3], g_ena new const npc_model[] = "models/player/zombie_witch/zombie_witch.mdl" new npc_victim[MAX_NPC] new g_think[MAX_NPC], g_madness[MAX_NPC] new cache_blood, cache_bloodspray // spawns & way points new const SPAWNS_FILE[] = "%s/npc_witch/%s.cfg" const MAX_SPAWNS = 128 new Float:g_spawns[MAX_SPAWNS][3], g_total_spawns enum { THINK_DEATH = 1, THINK_REMOVE } new const witch_cry[][] = { "npc_witch/female_cry_1.wav", "npc_witch/female_cry_2.wav", "npc_witch/female_cry_3.wav" } new const witch_madness[][] = { "npc_witch/female_ls_d_madscream01.wav", "npc_witch/female_ls_d_madscream02.wav", "npc_witch/female_ls_d_madscream03.wav" } new const witch_startattack[][] = { "npc_witch/female_distantscream1.wav", "npc_witch/female_distantscream2.wav" } new const witch_death[][] = { "npc_witch/female_death_1.wav", "npc_witch/headshot_death_1.wav", "npc_witch/headshot_death_2.wav", "npc_witch/headshot_death_3.wav" } new const witch_pain[][] = { "npc_witch/witch_pain_1.wav", "npc_witch/witch_pain_2.wav", "npc_witch/witch_pain_3.wav" } new const killed_by_witch[] = "npc_witch/killed_by_witch.wav" public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd("dias_make_witch", "event_newround") register_clcmd("dias_get_origin", "get_origin") } public plugin_precache() { npc_modelindex = engfunc(EngFunc_PrecacheModel, npc_model) cache_blood = engfunc(EngFunc_PrecacheModel, "sprites/blood.spr") cache_bloodspray = engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr") new i for(i = 0; i < sizeof(witch_cry); i++) engfunc(EngFunc_PrecacheSound, witch_cry[i]) for(i = 0; i < sizeof(witch_madness); i++) engfunc(EngFunc_PrecacheSound, witch_madness[i]) for(i = 0; i < sizeof(witch_startattack); i++) engfunc(EngFunc_PrecacheSound, witch_startattack[i]) for(i = 0; i < sizeof(witch_death); i++) engfunc(EngFunc_PrecacheSound, witch_death[i]) for(i = 0; i < sizeof(witch_pain); i++) engfunc(EngFunc_PrecacheSound, witch_pain[i]) engfunc(EngFunc_PrecacheSound, killed_by_witch) load_spawn_points() } public event_newround(id) { create_npc() client_print(id, print_chat, "CREATED") } stock collect_spawn(Float:origin[3]) { for (new i=1; i<=g_total_spawns*3; i++) { origin = g_spawns[random(g_total_spawns)] if (check_spawn(origin)) return 1; } return 0; } stock check_spawn(Float:origin[3]) { new Float:originE[3], Float:origin1[3], Float:origin2[3] new ent = -1 while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", NPC_CLASSNAME)) != 0) { pev(ent, pev_origin, originE) // xoy origin1 = origin origin2 = originE origin1[2] = origin2[2] = 0.0 if (vector_distance(origin1, origin2) <= 2 * 16.0) { // oz origin1 = origin origin2 = originE origin1[0] = origin2[0] = origin1[1] = origin2[1] = 0.0 if (vector_distance(origin1, origin2) <= 36.0) return 0; } } return 1; } // load spawn points load_spawn_points() { // Check for spawns points of the current map new cfgdir[32], mapname[32], filepath[100], linedata[64] get_configsdir(cfgdir, charsmax(cfgdir)) get_mapname(mapname, charsmax(mapname)) formatex(filepath, charsmax(filepath), SPAWNS_FILE, cfgdir, mapname) // Load spawns points if (file_exists(filepath)) { new file = fopen(filepath,"rt"), row[4][6] while (file && !feof(file)) { fgets(file, linedata, charsmax(linedata)) // invalid spawn if(!linedata[0] || str_count(linedata,' ') < 2) continue; // get spawn point data parse(linedata,row[0],5,row[1],5,row[2],5,row[3],5) // origin if (g_total_spawns 60.0) { new Float:fl_Time = distance_f / Speed fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time } else { fl_Velocity[0] = 0.0 fl_Velocity[1] = 0.0 fl_Velocity[2] = 0.0 } entity_set_vector(ent, EV_VEC_velocity, fl_Velocity) }