廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2676 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
xuqiang52133
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x1 鮮花 x32
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[其他] NPC(带源码)为什么我建立不出来这些文件夹呢。不能保存自动保存NPC,我见里完了 NPC文件夹也没有啊。求帮助
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <xs>


#define PLUGIN_NAME "建立NPC"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Leech"


new g_bloodSpr, g_bloodSpr2
new Float:g_cooldown[32]
new g_charge[512], Float:g_delay[512]


new const npc_model[] = "models/player/Antlion/Antlion.mdl"
new const npc_model2[] = "models/player/Antlion_Guard/Antlion_Guard.mdl"


new const g_NpcSoundPain[][] = 
{
"AntlionMod/pain1.wav",
"AntlionMod/pain2.wav"
}


new const g_NpcSoundDeath[][] =
{
"AntlionMod/headshot.wav"
}


public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)


register_clcmd("say npcmenu", "ClCmd_NPC")
register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")


RegisterHam(Ham_Killed, "info_target", "NPC_Killed1")
RegisterHam(Ham_Killed, "info_target", "NPC_Killed2")
RegisterHam(Ham_TakeDamage, "info_target", "NPC_TakeDamage1")
RegisterHam(Ham_TakeDamage, "info_target", "NPC_TakeDamage2")
RegisterHam(Ham_TraceAttack, "info_target", "NPC_TraceAttack1")
RegisterHam(Ham_TraceAttack, "info_target", "NPC_TraceAttack2")
RegisterHam(Ham_Think, "info_target", "NPC_Think1")
RegisterHam(Ham_Think, "info_target", "NPC_Think2")
RegisterHam(Ham_ObjectCaps, "player", "npc_ObjectCaps", 1)
}


public plugin_precache()
{
precache_model(npc_model)
precache_model(npc_model2)


g_bloodSpr = precache_model("sprites/blood.spr")
g_bloodSpr2= precache_model("sprites/bloodspray.spr")


precache_sound("AntlionMod/bite1.wav")
precache_sound("AntlionMod/bitehit1.wav")
new i
for(i=0;i<sizeof g_NpcSoundPain;i++)
precache_sound(g_NpcSoundPain)


for(i=0;i<sizeof g_NpcSoundDeath;i++)
precache_sound(g_NpcSoundDeath)
}


Load_Npc()
{
new ConfigDir[256], File[256]


// 得到configs文件夹的路径
get_configsdir(ConfigDir, charsmax(ConfigDir))


new MapName[32]
// 得到当前地图名称
get_mapname(MapName, charsmax(MapName))
// 读取当前地图的cfg文件路径
formatex(File, charsmax(File), "%s\NPC\Antlion\%s.cfg", any:ConfigDir, any:MapName)


// 如果没有这个文件夹,自动建立
if (!dir_exists("addons\amxmodx\configs\NPC\Antlion"))
mkdir("addons\amxmodx\configs\NPC\Antlion")


// 如果没有地图cfg文件,自动建立
if (!file_exists(File)) write_file(File, "")


new FileOrigin[3][32]
new sOrigin[128], sAngle[128]
new Float:fOrigin[3], Float:fAngles[3]
new iLine, iLength, sBuffer[256]


while (read_file(File, iLine++, sBuffer, charsmax(sBuffer), iLength))
{
if((sBuffer[0]== ';') || !iLength) continue


strtok(sBuffer, sOrigin, charsmax(sOrigin), sAngle, charsmax(sAngle), '|', 0)
parse(sOrigin, FileOrigin[0], charsmax(FileOrigin[]), FileOrigin[1], charsmax(FileOrigin[]), FileOrigin[2], charsmax(FileOrigin[]))


fOrigin[0] = str_to_float(FileOrigin[0])
fOrigin[1] = str_to_float(FileOrigin[1])
fOrigin[2] = str_to_float(FileOrigin[2])


fAngles[1] = str_to_float(sAngle[1])
Create_Npc(0, fOrigin, fAngles)
}
}


Load_Npc2()
{
new ConfigDir[256], File[256]


// 得到configs文件夹的路径
get_configsdir(ConfigDir, charsmax(ConfigDir))


new MapName[32]
// 得到当前地图名称
get_mapname(MapName, charsmax(MapName))
// 读取当前地图的cfg文件路径
formatex(File, charsmax(File), "%s\NPC\AntlionGuard\%s.cfg", any:ConfigDir, any:MapName)


// 如果没有这个文件夹,自动建立
if (!dir_exists("addons\amxmodx\configs\NPC\AntlionGuard"))
mkdir("addons\amxmodx\configs\NPC\AntlionGuard")


// 如果没有地图cfg文件,自动建立
if (!file_exists(File)) write_file(File, "")


new FileOrigin[3][32]
new sOrigin[128], sAngle[128]
new Float:fOrigin[3], Float:fAngles[3]
new iLine, iLength, sBuffer[256]


while (read_file(File, iLine++, sBuffer, charsmax(sBuffer), iLength))
{
if((sBuffer[0]== ';') || !iLength) continue


strtok(sBuffer, sOrigin, charsmax(sOrigin), sAngle, charsmax(sAngle), '|', 0)
parse(sOrigin, FileOrigin[0], charsmax(FileOrigin[]), FileOrigin[1], charsmax(FileOrigin[]), FileOrigin[2], charsmax(FileOrigin[]))


fOrigin[0] = str_to_float(FileOrigin[0])
fOrigin[1] = str_to_float(FileOrigin[1])
fOrigin[2] = str_to_float(FileOrigin[2])


fAngles[1] = str_to_float(sAngle[1])
Create_Npc2(0, fOrigin, fAngles)
}
}


Save_Npc(id)
{
new ConfigsDir[256], File[256]
get_configsdir(ConfigsDir, charsmax(ConfigsDir))


new MapName[32]
get_mapname(MapName, charsmax(MapName))


formatex(File, charsmax(File), "%s\NPC\Antlion\%s.cfg", any:ConfigsDir, any:MapName)


//if (file_exists(File)) delete_file(File)


new Float:org[3], Float:ang[3], org2[3], ang2[3]
new buffer[256]


entity_get_vector(id, EV_VEC_origin, org)
org2[0]=floatround(org[0])
org2[1]=floatround(org[1])
org2[2]=floatround(org[2])
entity_get_vector(id, EV_VEC_angles, ang)
ang2[1]=floatround(ang[1])
formatex(buffer, charsmax(buffer), "%d %d %d | %d", any:org2[0], any:org2[1], any:org2[2], any:ang2[1])


write_file(File, buffer, -1)


}


Save_Npc2(id)
{
new ConfigsDir[256], File[256]
get_configsdir(ConfigsDir, charsmax(ConfigsDir))


new MapName[32]
get_mapname(MapName, charsmax(MapName))


formatex(File, charsmax(File), "%s\NPC\AntlionGuard\%s.cfg", any:ConfigsDir, any:MapName)


//if (file_exists(File)) delete_file(File)


new Float:org[3], Float:ang[3], org2[3], ang2[3]
new buffer[256]


entity_get_vector(id, EV_VEC_origin, org)
org2[0]=floatround(org[0])
org2[1]=floatround(org[1])
org2[2]=floatround(org[2])
entity_get_vector(id, EV_VEC_angles, ang)
ang2[1]=floatround(ang[1])
formatex(buffer, charsmax(buffer), "%d %d %d | %d", any:org2[0], any:org2[1], any:org2[2], any:ang2[1])


write_file(File, buffer, -1)


}


public ClCmd_NPC(id)
{
if (get_user_flags(id) & ADMIN_MENU && get_user_flags(id) & ADMIN_LEVEL_A)
{
new menu = menu_create("NPC菜单", "Menu_Handler")


menu_additem(menu, "建立蚁狮NPC", "1")
menu_additem(menu, "建立蚁狮守卫NPC", "2")
menu_additem(menu, "删除瞄准的NPC", "3")
menu_additem(menu, "删除所有蚁狮NPC", "4")
menu_additem(menu, "删除所有蚁狮卫兵NPC", "5")
menu_additem(menu, "保存坐标为蚁狮出生点", "6")
menu_additem(menu, "保存坐标为蚁狮卫兵出生点", "7")
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu)
}
else client_print(id, print_chat, "[提示]你没有管理猿的m、u权限")
}


public Menu_Handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}


new info[6], szName[64]
new access, callback


menu_item_getinfo(menu, item, access, info, charsmax(info), szName, charsmax(szName), callback)


new key = str_to_num(info)
switch(key)
{
case 1:
{
Create_Npc(id)
client_print(id, print_chat, "[提示]建立一个蚁狮NPC,按E使用")
}
case 2:
{
Create_Npc2(id)
client_print(id, print_chat, "[提示]建立一个蚁狮卫兵NPC,按E使用")
}
case 3:
{
new ent, body, class[32]
get_user_aiming(id, ent, body)
if (pev_valid(ent)) 
{
entity_get_string(ent, EV_SZ_classname, class, charsmax(class))
if (equal(class, "antlion_npc") || equal(class, "antlionguard_npc"))
{
remove_entity(ent)
client_print(id, print_chat, "[提示]删除瞄准NPC")
}
}
}
case 4:
{
remove_entity_name("antlion_npc")
client_print(id, print_chat, "[提示]删除所有蚁狮NPC")
}
case 5:
{
remove_entity_name("antlionguard_npc")
client_print(id, print_chat, "[提示]删除所有蚁狮卫兵NPC")
}
case 6:
{
Save_Npc(id)
client_print(id, print_chat, "[提示]蚁狮NPC出生坐标保存成功")
}
case 7:
{
Save_Npc2(id)
client_print(id, print_chat, "[提示]蚁狮卫兵NPC出生坐标保存成功")
}
}


menu_display(id, menu)
return PLUGIN_HANDLED
}


Create_Npc(id, Float:origin[3]={0.0,0.0,0.0}, Float:angle[3]={0.0,0.0,0.0})
{
new ent = create_entity("info_target")
if (!pev_valid(ent)) return


entity_set_model(ent, npc_model)
entity_set_string(ent, EV_SZ_netname, "Antlion")
new Float:mins[3]={-16.0, -16.0, -36.0}
new Float:maxs[3]={16.0, 16.0, 30.0}
entity_set_size(ent, mins, maxs)
set_sequence(ent, 1, 1.0)


entity_set_int(ent, EV_INT_solid, 3)
entity_set_int(ent, EV_INT_iuser1, 0)
entity_set_int(ent, EV_INT_iuser2, 0)
entity_set_int(ent, EV_INT_iuser3, 0)
entity_set_int(ent, EV_INT_movetype, 13)
entity_set_int(ent, EV_INT_rendermode, 0)


entity_set_float(ent, EV_FL_health, 200.0)
entity_set_float(ent, EV_FL_takedamage, 2.0)
entity_set_float(ent, EV_FL_renderamt, 255.0)
entity_set_float(ent, EV_FL_fuser1, get_gametime())
entity_set_float(ent, EV_FL_fuser2, get_gametime())
entity_set_float(ent, EV_FL_fuser3, get_gametime())
entity_set_float(ent, EV_FL_fuser4, get_gametime())


entity_set_string(ent, EV_SZ_classname, "antlion_npc")


if (is_user_connected(id))
{
entity_set_edict(ent, EV_ENT_euser1, id)
entity_get_vector(id, EV_VEC_angles, angle)
pev(id, pev_origin, any:origin)
}
entity_set_vector(ent, EV_VEC_angles, angle)
entity_set_vector(ent, EV_VEC_v_angle, angle)
entity_set_origin(ent, origin)
check_origin(ent, origin)


entity_set_float(ent, EV_FL_nextthink, (get_gametime()+0.01))
}


Create_Npc2(id, Float:origin[3]={0.0,0.0,0.0}, Float:angle[3]={0.0,0.0,0.0})
{
new ent = create_entity("info_target")
if (!pev_valid(ent)) return


entity_set_model(ent, npc_model2)
new Float:mins[3]={-30.0, -30.0, -36.0}
new Float:maxs[3]={30.0, 30.0, 30.0}
entity_set_size(ent, mins, maxs)
set_sequence(ent, 1, 1.0)


entity_set_int(ent, EV_INT_solid, 3)
entity_set_int(ent, EV_INT_iuser1, 0)
entity_set_int(ent, EV_INT_iuser2, 0)
entity_set_int(ent, EV_INT_iuser3, 0)
entity_set_int(ent, EV_INT_movetype, 13)
entity_set_int(ent, EV_INT_rendermode, 0)


entity_set_float(ent, EV_FL_health, 5000.0)
entity_set_float(ent, EV_FL_takedamage, 2.0)
entity_set_float(ent, EV_FL_renderamt, 255.0)
entity_set_float(ent, EV_FL_fuser1, get_gametime())
entity_set_float(ent, EV_FL_fuser2, get_gametime())
entity_set_float(ent, EV_FL_fuser3, get_gametime())
entity_set_float(ent, EV_FL_fuser4, get_gametime())


entity_set_string(ent, EV_SZ_classname, "antlionguard_npc")


if (is_user_connected(id))
{
entity_set_edict(ent, EV_ENT_euser1, id)
entity_get_vector(id, EV_VEC_angles, angle)
pev(id, pev_origin, any:origin)
}
entity_set_vector(ent, EV_VEC_angles, angle)
entity_set_vector(ent, EV_VEC_v_angle, angle)
entity_set_origin(ent, origin)
check_origin2(ent, origin)


g_charge[ent]=false
g_delay[ent]=get_gametime()
entity_set_float(ent, EV_FL_nextthink, (get_gametime()+0.01))
}


public check_origin(ent, Float:origin[3])
{
if (is_player_stuck(ent)) set_origin(ent, 0, 0, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 0, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 0, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 36, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, -36, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, -36, 0, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 36, 0, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, -36, 36, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 36, 36, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, -36, -36, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 36, -36, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 36, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 36, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, -36, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, -36, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, -36, 0, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 36, 0, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, -36, 0, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, 36, 0, -36, origin)
if (is_player_stuck(ent))
{
new id = entity_get_edict(ent, EV_ENT_euser1)
if (id!=ent) client_print(id, print_chat, "[提示]这里的位置不足够建立蚁狮NPC,请换个地方")
remove_entity(ent)
}
entity_set_edict(ent, EV_ENT_euser1, ent)
}


public check_origin2(ent, Float:origin[3])
{
if (is_player_stuck(ent)) set_origin(ent, 0, 0, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 0, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 0, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 60, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, -60, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, -60, 0, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 60, 0, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, -60, 60, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 60, 60, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, -60, -60, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 60, -60, 0, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 60, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, 60, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, -60, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 0, -60, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, -60, 0, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, 60, 0, 36, origin)
if (is_player_stuck(ent)) set_origin(ent, -60, 0, -36, origin)
if (is_player_stuck(ent)) set_origin(ent, 60, 0, -36, origin)
if (is_player_stuck(ent))
{
new id = entity_get_edict(ent, EV_ENT_euser1)
if (id!=ent) client_print(id, print_chat, "[提示]这里的位置不足够建立蚁狮卫兵NPC,请换个地方")
remove_entity(ent)
}
entity_set_edict(ent, EV_ENT_euser1, ent)
}


public set_origin(ent, x, y, z, Float:origin[3])
{
new Float:origin2[3]
origin2[0]=float(x)+origin[0]
origin2[1]=float(y)+origin[1]
origin2[2]=float(z)+origin[2]
entity_set_origin(ent, origin2)
}


public Event_NewRound()
{
new ent = -1


while ((ent = find_ent_by_class(ent, "antlion_npc")))
remove_entity(ent)
while ((ent = find_ent_by_class(ent, "antlionguard_npc")))
remove_entity(ent)
Load_Npc()
Load_Npc2()
}


public NPC_Killed1(ent, attacker, shouldgib)
{
if (!pev_valid(ent)) return HAM_IGNORED


new classname[32]
entity_get_string(ent, EV_SZ_classname, classname, charsmax(classname))
if (!equal(classname, "antlion_npc")) return HAM_IGNORED


if (!entity_get_int(ent, EV_INT_iuser2))
{
set_sequence(ent, random_num(101,109), 1.0)
entity_set_int(ent, EV_INT_solid, 0)
entity_set_int(ent, EV_INT_iuser2, 1)
entity_set_float(ent, EV_FL_nextthink, (get_gametime()+15.1))
entity_set_size(ent, Float:{-16.0, -16.0, -36.0}, Float:{16.0, 16.0, 10.0})
emit_sound(ent, CHAN_BODY, g_NpcSoundDeath[random(sizeof g_NpcSoundDeath)],  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
return HAM_SUPERCEDE 
}


public NPC_Killed2(ent, attacker, shouldgib)
{
if (!pev_valid(ent)) return HAM_IGNORED


new classname[32]
entity_get_string(ent, EV_SZ_classname, classname, charsmax(classname))
if (!equal(classname, "antlionguard_npc")) return HAM_IGNORED


if (!entity_get_int(ent, EV_INT_iuser2))
{
set_sequence(ent, random_num(101,109), 1.0)
entity_set_int(ent, EV_INT_solid, 0)
entity_set_int(ent, EV_INT_iuser2, 1)
entity_set_float(ent, EV_FL_nextthink, (get_gametime()+15.1))
entity_set_size(ent, Float:{-30.0, -30.0, -36.0}, Float:{30.0, 30.0, 36.0})
emit_sound(ent, CHAN_BODY, g_NpcSoundDeath[random(sizeof g_NpcSoundDeath)],  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
return HAM_SUPERCEDE 
}


public NPC_TakeDamage1(ent, inflictor, attacker, Float:damage, bits)
{
if (!pev_valid(ent)) return HAM_IGNORED


new class[32]
entity_get_string(ent, EV_SZ_classname, class, charsmax(class))


if (!equal(class, "antlion_npc")) return HAM_IGNORED
if (!entity_get_int(ent, EV_INT_solid)) return HAM_SUPERCEDE


new Float:hp = entity_get_float(ent, EV_FL_health)
if (hp<=0.0) return HAM_SUPERCEDE
if (damage>=(hp*0.2) && damage<hp)
set_sequence(ent, random_num(99,100), 1.0)


if (!entity_get_int(ent, EV_INT_iuser3))
{
new Float:org[3], Float:ang[3], Float:vec[3]
pev(attacker, pev_origin, any:org)
aim_origin(ent, org)
pev(ent, pev_angles, any:ang)
velocity_by_aim(ent, 300, vec)
vec[2]=0.0
set_pev(ent, pev_velocity, any:vec)
engfunc(EngFunc_WalkMove, any:ent, any:ang[1], any:1.0, any:WALKMOVE_NORMAL)
}
emit_sound(ent, CHAN_BODY, g_NpcSoundPain[random(sizeof g_NpcSoundPain)],  VOL_NORM, ATTN_NORM, 0, PITCH_HIGH)
return HAM_HANDLED
}


public NPC_TakeDamage2(ent, inflictor, attacker, Float:damage, bits)
{
if (!pev_valid(ent)) return HAM_IGNORED


new class[32]
entity_get_string(ent, EV_SZ_classname, class, charsmax(class))


if (!equal(class, "antlionguard_npc")) return HAM_IGNORED
if (!entity_get_int(ent, EV_INT_solid)) return HAM_SUPERCEDE


new Float:hp = entity_get_float(ent, EV_FL_health)
if (hp<=0.0) return HAM_SUPERCEDE
if (damage>=(hp*0.2) && damage<hp)
set_sequence(ent, random_num(99,100), 1.0)


if (!entity_get_int(ent, EV_INT_iuser3))
{
new Float:org[3], Float:ang[3], Float:vec[3]
pev(attacker, pev_origin, any:org)
aim_origin(ent, org)
pev(ent, pev_angles, any:ang)
velocity_by_aim(ent, 450, vec)
vec[2]=0.0
set_pev(ent, pev_velocity, any:vec)
engfunc(EngFunc_WalkMove, any:ent, any:ang[1], any:1.0, any:WALKMOVE_NORMAL)
}
emit_sound(ent, CHAN_BODY, g_NpcSoundPain[random(sizeof g_NpcSoundPain)],  VOL_NORM, ATTN_NORM, 0, PITCH_HIGH)
return HAM_HANDLED
}


public NPC_TraceAttack1(ent, attacker, Float:damage, Float:direction[3], trace, damageBits)
{
if(!pev_valid(ent)) return


new class[32]
entity_get_string(ent, EV_SZ_classname, class, 31)


new Float:end[3], Float:org[3]
get_tr2(trace, TR_vecEndPos, any:end)
if (!equal(class, "antlion_npc")) return


get_user_startpos(ent, 0.0, 0.0, 20.0, org)
if (end[2]>=org[2])
{
Make_BloodSprite(end, 195, 15)
Make_Blood(end, direction, 195, 30)


SetHamParamFloat(3, (damage*5.0))
}
Make_BloodSprite(end, 195, random_num(4, 6))
return
}


public NPC_TraceAttack2(ent, attacker, Float:dmg, Float:direction[3], trace, damageBits)
{
if(!pev_valid(ent)) return


new class[32]
entity_get_string(ent, EV_SZ_classname, class, 31)
if (!equal(class, "antlionguard_npc")) return


new Float:end[3], Float:org[3], Float:ang[3]
get_tr2(trace, TR_vecEndPos, any:end)
new hit = find_closest_bone(ent, 40, end)
if (hit==1) SetHamParamFloat(3, dmg*1.1)
if (hit==2) SetHamParamFloat(3, dmg*1.2)
if (hit==3) SetHamParamFloat(3, dmg*1.3)
if (hit==4) SetHamParamFloat(3, dmg*1.4)
if (hit==5) SetHamParamFloat(3, dmg*1.5)
if (hit==6) SetHamParamFloat(3, dmg*0.9)
if (hit==7) SetHamParamFloat(3, dmg*0.9)
if (hit==8) SetHamParamFloat(3, dmg*0.9)
if (hit==9) SetHamParamFloat(3, dmg*1.3)
if (hit==10) SetHamParamFloat(3, dmg*1.2)
if (hit==11) SetHamParamFloat(3, dmg*1.3)
if (hit==12) SetHamParamFloat(3, dmg*1.0)
if (hit==13) SetHamParamFloat(3, dmg*1.3)
if (hit==14) SetHamParamFloat(3, dmg*1.3)
if (hit==15) SetHamParamFloat(3, dmg*1.2)
if (hit==16) SetHamParamFloat(3, dmg*0.8)
if (hit==17) SetHamParamFloat(3, dmg*0.7)
if (hit==18) SetHamParamFloat(3, dmg*0.6)
if (hit==19) SetHamParamFloat(3, dmg*1.3)
if (hit==20) SetHamParamFloat(3, dmg*0.8)
if (hit==21) SetHamParamFloat(3, dmg*0.7)
if (hit==22) SetHamParamFloat(3, dmg*0.6)
if (hit==23) SetHamParamFloat(3, dmg*1.1)
if (hit==24) SetHamParamFloat(3, dmg*1.0)
if (hit==25) SetHamParamFloat(3, dmg*1.0)
if (hit==26) SetHamParamFloat(3, dmg*1.0)
if (hit==27) SetHamParamFloat(3, dmg*1.0)
if (hit==28) SetHamParamFloat(3, dmg*1.0)
if (hit==29) SetHamParamFloat(3, dmg*0.9)
if (hit==30) SetHamParamFloat(3, dmg*0.9)
if (hit==31) SetHamParamFloat(3, dmg*0.6)
if (hit==32) SetHamParamFloat(3, dmg*1.0)
if (hit==33) SetHamParamFloat(3, dmg*0.9)
if (hit==34) SetHamParamFloat(3, dmg*0.9)
if (hit==35) SetHamParamFloat(3, dmg*0.6)
if (hit==36) SetHamParamFloat(3, dmg*1.1)
if (hit==37) SetHamParamFloat(3, dmg*1.0)
if (hit==38) SetHamParamFloat(3, dmg*1.0)
if (hit==39) SetHamParamFloat(3, dmg*1.0)
if (hit==40) SetHamParamFloat(3, dmg*1.0)
engfunc(EngFunc_GetBonePosition, any:ent, any:hit, any:org, any:ang)
set_tr2(trace, TR_vecEndPos, org)
Make_BloodSprite(org, 195, random_num(6, 10))
Make_Blood(org, direction, 195, 10)
return
}


public Make_BloodSprite(Float:org[3], color, size)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BLOODSPRITE)
write_coord(floatround(org[0]))
write_coord(floatround(org[1]))
write_coord(floatround(org[2]))
write_short(g_bloodSpr2)
write_short(g_bloodSpr)
write_byte(color)
write_byte(size)
message_end()
}


public Make_Blood(Float:org[3], Float:vec[3], color, speed)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BLOOD)
write_coord(floatround(org[0]))
write_coord(floatround(org[1]))
write_coord(floatround(org[2]))
write_coord(floatround(vec[0]))
write_coord(floatround(vec[1]))
write_coord(floatround(vec[2]))
write_byte(color)
write_byte(speed)
message_end()
}


public NPC_Think1(ent)
{
if (!pev_valid(ent)) return


new classname[32]
entity_get_string(ent, EV_SZ_classname, classname, charsmax(classname))


if (!equal(classname, "antlion_npc")) return


if (pev(ent, pev_health)<=0.0 && entity_get_int(ent, EV_INT_iuser2))
{
remove_entity(ent)
return
}


new i = get_closest_player(ent)
new id = entity_get_edict(ent, EV_ENT_euser1)
new enemy = entity_get_edict(ent, EV_ENT_enemy)
new think = entity_get_int(ent, EV_INT_iuser1)
new Float:time = entity_get_float(ent, EV_FL_fuser2)
new Float:time2= entity_get_float(ent, EV_FL_fuser3)
new Float:time3= entity_get_float(ent, EV_FL_fuser3)
new Float:org[3], Float:org2[3]


if (is_player_stuck(ent))
{
pev(ent, pev_origin, any:org)
check_origin(ent, org)
}
if (id!=ent)
{
if (pev(id,pev_button)&IN_ATTACK)
attach_view(id, ent)
if (pev(id,pev_button)&IN_ATTACK2)
attach_view(id, id)
if (!is_user_alive(id))
{
attach_view(id, id)
entity_set_edict(ent, EV_ENT_euser1, ent)
}
}
if (think==0 && fm_get_speed(ent)==0.0)
set_sequence(ent, 1, 1.0)
if (think==0 && fm_get_speed(ent)>0)
{
if (time+1.05<=get_gametime())
{
set_sequence(ent, 3, 1.0)
entity_set_float(ent, EV_FL_fuser2, get_gametime())
}
}
if (think==0 && fm_get_speed(ent)>90)
{
if (time2+(1.0/3.0)<=get_gametime())
{
set_sequence(ent, 4, 1.0)
entity_set_float(ent, EV_FL_fuser3, get_gametime())
}
}


if (is_user_alive(i) && get_user_team(i)!=1)
{
pev(i, pev_origin, any:org)
pev(ent, pev_origin, any:org2)
aim_origin(ent, org)
entity_set_int(ent, EV_INT_iuser3, 1)
entity_set_edict(ent, EV_ENT_enemy, i)
entity_set_float(ent, EV_FL_fuser1, get_gametime())
if (!think && (pev(ent, pev_flags)&FL_ONGROUND))
{
if (entity_range(ent, i)<=110.0)
{
aim_origin(ent, org)
if (random_num(1,2)==1)
{
set_sequence(ent, 6, 1.0)
set_task(0.4, "Npc_attack", ent)
set_task(0.75, "Npc_think_allow", ent)
}
else
{
new Float:m = 26.0/30.0
set_sequence(ent, 76, 1.0)
set_task(0.2, "Npc_attack2", ent)
set_task(m, "Npc_think_allow", ent)
}
entity_set_int(ent, EV_INT_iuser1, 1)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
if ((org[2]>(org2[2]+30.0) && fm_get_speed(ent)<150) || (time3+1.05>get_gametime() && fm_get_speed(ent)<150))
{
set_task(0.1, "Npc_jump", ent)
set_task(0.4, "Npc_attack", ent)
set_task(0.75, "Npc_think_allow", ent)
set_sequence(ent, 6, 1.0)
entity_set_int(ent, EV_INT_iuser1, 1)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
NPC_Run(ent, 300)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
entity_set_int(ent, EV_INT_iuser3, 0)
if (is_user_alive(enemy))
{
if (entity_get_float(ent, EV_FL_fuser1)+3.0<=get_gametime())
{
entity_set_int(ent, EV_INT_iuser3, 0)
entity_set_edict(ent, EV_ENT_enemy, 0)
entity_set_edict(ent, EV_ENT_euser1, ent)
}
if (can_see(ent, enemy))
{
pev(enemy, pev_origin, any:org)
aim_origin(ent, org)
}
if (think==0 && (pev(ent, pev_flags)&FL_ONGROUND))
NPC_Run(ent, 90)


set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
if (id!=ent && entity_range(id,ent)>100.0)
{
if (!is_user_alive(id))
{
attach_view(id, id)
entity_set_edict(ent, EV_ENT_euser1, ent)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
pev(id, pev_origin, any:org)
pev(ent, pev_origin, any:org2)
aim_origin(ent, org)
if ((pev(ent, pev_flags) & FL_ONGROUND) && think==0)
{
if ((org[2]>(org2[2]+30.0) && fm_get_speed(ent)<150) || (time3+1.05>get_gametime() && fm_get_speed(ent)<150))
{
set_task(0.1, "Npc_jump", ent)
set_task(0.75, "Npc_think_allow", ent)
set_sequence(ent, 6, 1.0)
entity_set_int(ent, EV_INT_iuser1, 1)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
NPC_Run(ent, 300)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
}


public NPC_Run(ent, spd)
{
new Float:ang[3], Float:vec[3]
pev(ent, pev_angles, any:ang)
velocity_by_aim(ent, spd, vec)
vec[2]=0.0
set_pev(ent, pev_velocity, any:vec)
if (entity_get_float(ent, EV_FL_fuser4)<get_gametime())
entity_set_float(ent, EV_FL_fuser4, get_gametime())
engfunc(EngFunc_WalkMove, any:ent, any:ang[1], any:1.0, any:WALKMOVE_NORMAL)
}


public Npc_attack(ent)
{
if (!pev_valid(ent) || entity_get_int(ent, EV_INT_sequence)!=6) return


new Float:start[3], Float:ofs[3]
pev(ent, pev_origin, any:start)
pev(ent, pev_view_ofs, any:ofs)
xs_vec_add(start, ofs, start)


new Float:dest[3]
pev(ent, pev_v_angle, any:dest)
engfunc(EngFunc_MakeVectors, any:dest)


new Float:vfwd[3]
global_get(glb_v_forward, any:vfwd)
xs_vec_mul_scalar(vfwd, 110.0, dest)
xs_vec_add(start, dest, dest)
new Float:end[3]
engfunc(EngFunc_TraceLine, any:start, any:dest, any:0, any:ent, any:0)
get_tr2(0, TR_vecEndPos, end)


new i = get_tr2(0, TR_pHit)
if (i>0 && pev_valid(i) && pev(i, pev_takedamage))
{
new Float:dmg, Float:origin[3]
if (is_user_alive(i) && get_user_team(i)!=1)
{
new hit = get_tr2(0, TR_iHitgroup)
if (hit==1) dmg = 60.0
else if (hit==2) dmg = 45.0
else if (hit==3) dmg = 35.0
else if (hit==4 || hit==5 || hit==6 || hit==7) dmg = 30.5
else dmg = 35.0


velocity_by_aim(ent, 100, origin)
Make_BloodSprite(end, 247, 10)
engfunc(EngFunc_TraceLine, any:start, any:dest, any:1, any:-1, any:0)
get_tr2(0, TR_vecEndPos, end)
pev(i, pev_origin, any:origin)
if (get_distance_f(end,origin)<=200.0)
{
engfunc(EngFunc_MessageBegin, any:MSG_PAS, any:SVC_TEMPENTITY, any:end, any:0)
write_byte(TE_WORLDDECAL)
engfunc(EngFunc_WriteCoord, any:end[0])
engfunc(EngFunc_WriteCoord, any:end[1])
engfunc(EngFunc_WriteCoord, any:end[2])
write_byte(random_num(192,197))
message_end()
}
}
else dmg = 50.0
ExecuteHamB(Ham_TakeDamage, i, any:0, any:ent, any:dmg, any:DMG_CLUB)
emit_sound(ent, CHAN_VOICE, "AntlionMod/bite1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
else emit_sound(ent, CHAN_VOICE, "AntlionMod/bitehit1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}


public Npc_attack2(ent)
{
if (!pev_valid(ent) || entity_get_int(ent, EV_INT_sequence)!=76) return


new Float:start[3], Float:ofs[3]
pev(ent, pev_origin, any:start)
pev(ent, pev_view_ofs, any:ofs)
xs_vec_add(start, ofs, start)


new Float:dest[3]
pev(ent, pev_v_angle, any:dest)
engfunc(EngFunc_MakeVectors, any:dest)


new Float:vfwd[3]
global_get(glb_v_forward, any:vfwd)
xs_vec_mul_scalar(vfwd, 100.0, dest)
xs_vec_add(start, dest, dest)
new Float:end[3]
engfunc(EngFunc_TraceLine, any:start, any:dest, any:0, any:ent, any:0)
get_tr2(0, TR_vecEndPos, end)


new i = get_tr2(0, TR_pHit)
if (i>0 && pev_valid(i) && pev(i, pev_takedamage))
{
new Float:dmg, Float:origin[3]
if (is_user_alive(i) && get_user_team(i)!=1)
{
new hit = get_tr2(0, TR_iHitgroup)
if (hit==1) dmg = 60.0
else if (hit==2) dmg = 40.0
else if (hit==3) dmg = 30.0
else if (hit==4 || hit==5 || hit==6 || hit==7) dmg = 28.0
else dmg = 30.0


velocity_by_aim(ent, 100, origin)
Make_BloodSprite(end, 247, 10)
engfunc(EngFunc_TraceLine, any:start, any:dest, any:1, any:-1, any:0)
get_tr2(0, TR_vecEndPos, end)
pev(i, pev_origin, any:origin)
if (get_distance_f(end,origin)<=200.0)
{
engfunc(EngFunc_MessageBegin, any:MSG_PAS, any:SVC_TEMPENTITY, any:end, any:0)
write_byte(TE_WORLDDECAL)
engfunc(EngFunc_WriteCoord, any:end[0])
engfunc(EngFunc_WriteCoord, any:end[1])
engfunc(EngFunc_WriteCoord, any:end[2])
write_byte(random_num(192,197))
message_end()
}
}
else dmg = 45.0
ExecuteHamB(Ham_TakeDamage, i, any:0, any:ent, any:dmg, any:DMG_CLUB)
emit_sound(ent, CHAN_VOICE, "AntlionMod/bite1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
else emit_sound(ent, CHAN_VOICE, "AntlionMod/bitehit1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}


public Npc_jump(ent)
{
if (!pev_valid(ent) || entity_get_int(ent, EV_INT_sequence)!=6) return


new Float:vec[3]
velocity_by_aim(ent, 350, vec)
vec[2]=280.0
set_pev(ent, pev_velocity, any:vec)
set_task(0.3, "Npc_jump_move", ent)
}


public Npc_jump_move(ent)
{
if (!pev_valid(ent) || entity_get_int(ent, EV_INT_sequence)!=6 || pev(ent,pev_flags) & FL_ONGROUND) return
new Float:vec[3], Float:high, spd=fm_get_speed(ent)
pev(ent, pev_velocity, any:vec)
high=vec[2]
velocity_by_aim(ent, spd==0?50:spd, vec)
vec[2]=high*0.7
set_pev(ent, pev_velocity, any:vec)
}


public Npc_think_allow(ent)
{
if (!pev_valid(ent)) return
g_charge[ent]=false
set_sequence(ent, 1, 1.0)
entity_set_int(ent, EV_INT_iuser1, 0)
}


public NPC_Think2(ent)
{
if (!pev_valid(ent)) return


new classname[32]
entity_get_string(ent, EV_SZ_classname, classname, charsmax(classname))


if (!equal(classname, "antlionguard_npc")) return


if (pev(ent, pev_health)<=0.0 && entity_get_int(ent, EV_INT_iuser2))
{
remove_entity(ent)
return
}


new i = get_closest_player(ent)
new id = entity_get_edict(ent, EV_ENT_euser1)
new enemy = entity_get_edict(ent, EV_ENT_enemy)
new think = entity_get_int(ent, EV_INT_iuser1)
new seq = pev(ent,pev_sequence)
new Float:time = entity_get_float(ent, EV_FL_fuser2)
new Float:time2= entity_get_float(ent, EV_FL_fuser3)
new Float:time3= entity_get_float(ent, EV_FL_fuser4)
new Float:org[3], Float:org2[3]


if (is_player_stuck(ent))
{
pev(ent, pev_origin, any:org)
check_origin(ent, org)
}
if (id!=ent)
{
if (pev(id,pev_button)&IN_ATTACK)
attach_view(id, ent)
if (pev(id,pev_button)&IN_ATTACK2)
attach_view(id, id)
if (!is_user_alive(id))
{
attach_view(id, id)
entity_set_edict(ent, EV_ENT_euser1, ent)
}
}
if (think==0 && fm_get_speed(ent)==0 && seq!=12 && seq!=76)
{
g_charge[ent]=false
if (pev(ent,pev_frame)>=375.0 || seq!=11)
{
set_sequence(ent, 1, 1.0)
entity_set_float(ent, EV_FL_fuser2, get_gametime()-1.0)
entity_set_float(ent, EV_FL_fuser3, get_gametime()-1.0)
}
}
if (think==0 && fm_get_speed(ent)>0 && fm_get_speed(ent)<=150)
{
if (time+0.7<=get_gametime() && seq!=12)
{
set_sequence(ent, 3, 1.0)
entity_set_float(ent, EV_FL_fuser2, get_gametime())
entity_set_float(ent, EV_FL_fuser3, get_gametime()-1.0)
}
}
if (think==0 && fm_get_speed(ent)>150 && seq!=12)
{
if (g_charge[ent] && (time2+(13.0/24.0)<=get_gametime() || seq!=11))
{
set_sequence(ent, 11, 1.0)
entity_set_float(ent, EV_FL_fuser2, get_gametime()-1.0)
entity_set_float(ent, EV_FL_fuser3, get_gametime())
}
if (!g_charge[ent] && (time2+(13.0/30.0)<=get_gametime() || seq==11))
{
set_sequence(ent, pev(ent,pev_health)<=300?14:4, 1.0)
entity_set_float(ent, EV_FL_fuser2, get_gametime()-1.0)
entity_set_float(ent, EV_FL_fuser3, get_gametime())
}
}


if (is_user_alive(i) && get_user_team(i)!=1)
{
pev(i, pev_origin, any:org)
pev(ent, pev_origin, any:org2)
if (seq!=76 && seq!=12) aim_origin(ent, org)
entity_set_int(ent, EV_INT_iuser3, 1)
entity_set_edict(ent, EV_ENT_enemy, i)
entity_set_float(ent, EV_FL_fuser1, get_gametime())
if (!think && (pev(ent, pev_flags)&FL_ONGROUND))
{
if (!g_charge[ent] && entity_range(ent, i)<=130.0 && seq!=12)
{
aim_origin(ent, org)
remove_task(ent+99999)
set_sequence(ent, 76, 1.0)
set_task(0.5, "Npc2_attack", ent)
set_task(2.15, "Npc_think_allow", ent)
entity_set_int(ent, EV_INT_iuser1, 1)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
if (g_charge[ent] && entity_range(ent, i)<=140.0 && seq!=12)
{
remove_task(ent+99999)
set_sequence(ent, 12, 1.0)
set_task(0.4, "Npc_charge_hit", ent)
set_task(0.5, "Npc_think_disable", ent)
set_task(1.5, "Npc_think_allow", ent)
}
if (g_delay[ent]+3.0<=get_gametime() && !g_charge[ent] && entity_range(ent, i)<=800.0)
{
if (random_num(1,3)==2 && seq!=12)
{
g_charge[ent]=true
remove_task(ent+99999)
set_task(3.0, "Npc_charge_stop", ent+99999)
}
g_delay[ent]=get_gametime()
}
if ((org[2]>(org2[2]+36.0) && fm_get_speed(ent)<150) || (org[2]!=org2[2] && time3+1.05>get_gametime() && fm_get_speed(ent)<150))
{
if (!g_charge[ent])
{
set_task(0.1, "Npc2_jump", ent)
set_task(0.5, "Npc_think_allow", ent)
set_sequence(ent, 6, 1.0)
entity_set_int(ent, EV_INT_iuser1, 1)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
}
NPC_Run(ent, g_charge[ent]?500:450)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
entity_set_int(ent, EV_INT_iuser3, 0)
if (is_user_alive(enemy))
{
if (entity_get_float(ent, EV_FL_fuser1)+3.0<=get_gametime())
{
entity_set_int(ent, EV_INT_iuser3, 0)
entity_set_edict(ent, EV_ENT_enemy, 0)
}
if (can_see(ent, enemy))
{
pev(enemy, pev_origin, any:org)
aim_origin(ent, org)
}
if (think==0 && (pev(ent, pev_flags)&FL_ONGROUND))
{
NPC_Run(ent, g_charge[ent]?500:150)
}
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
if (id!=ent && entity_range(id,ent)>150.0)
{
if (!is_user_alive(id))
{
attach_view(id, id)
entity_set_edict(ent, EV_ENT_euser1, ent)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
pev(id, pev_origin, any:org)
pev(ent, pev_origin, any:org2)
aim_origin(ent, org)
if ((pev(ent, pev_flags) & FL_ONGROUND) && think==0)
{
if ((org[2]>(org2[2]+30.0) && fm_get_speed(ent)<150) || (time3+1.05>get_gametime() && fm_get_speed(ent)<150))
{
set_task(0.1, "Npc2_jump", ent)
set_task(0.5, "Npc_think_allow", ent)
set_sequence(ent, 6, 1.0)
entity_set_int(ent, EV_INT_iuser1, 1)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
NPC_Run(ent, g_charge[ent]?500:450)
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
return
}
set_pev(ent, pev_nextthink, any:(get_gametime()+0.01))
}


public Npc2_attack(ent)
{
if (!pev_valid(ent) || entity_get_int(ent, EV_INT_sequence)!=76) return


for (new i=0;i<512;i++) if (pev_valid(i) && pev(i, pev_takedamage))
{
if (is_user_alive(i))
{
new Float:org[3], Float:org2[3]
get_user_startpos(i, 0.0, 0.0, 0.0, org)
get_user_startpos(ent, 75.0, 0.0, 0.0, org2)
if (get_distance_f(org, org2)<=75.0 && org[2]>=org2[2]-30.0 && entity_range(ent, i)<=150.0)
{
new id = entity_get_edict(ent, EV_ENT_euser1)
ExecuteHamB(Ham_TakeDamage, i, any:0, any:id, any:random_float(45.0,50.0), any:DMG_CLUB)
new Float:vec[3]
get_speed_vector_to(ent, id, 800.0, vec)
vec[2]+=150.0
set_pev(i, pev_velocity, any:vec)
Make_BloodSprite(org, 247, 10)
emit_sound(ent, CHAN_VOICE, "AntlionMod/bite1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
else
{
new target = get_tr2(0, TR_pHit)
if (pev_valid(target) && pev(i, pev_takedamage) && entity_range(ent,target)<=150.0)
{
ExecuteHamB(Ham_TakeDamage, i, any:0, any:ent, any:random_float(45.0,50.0), any:DMG_CLUB)
emit_sound(ent, CHAN_VOICE, "AntlionMod/bitehit1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
}
}


public Npc_charge_hit(ent)
{
if (!pev_valid(ent) || pev(ent, pev_sequence)!=12) return


for (new i=0;i<512;i++) if (pev_valid(i) && pev(i, pev_takedamage))
{
if (is_user_alive(i))
{
new Float:org[3], Float:org2[3]
get_user_startpos(i, 0.0, 0.0, 0.0, org)
get_user_startpos(ent, 80.0, 0.0, 0.0, org2)
if (get_distance_f(org, org2)<=80.0 && org[2]>=org2[2]-30.0 && entity_range(ent, i)<=160.0)
{
new id = entity_get_edict(ent, EV_ENT_euser1)
ExecuteHamB(Ham_TakeDamage, i, any:0, any:id, any:random_float(75.0,90.0), any:DMG_CLUB)
new Float:vec[3]
get_speed_vector_to(ent, id, 800.0, vec)
vec[2]+=150.0
set_pev(i, pev_velocity, any:vec)
Make_BloodSprite(org, 247, 11)
emit_sound(ent, CHAN_VOICE, "AntlionMod/bite1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
else
{
new target = get_tr2(0, TR_pHit)
if (pev_valid(target) && pev(i, pev_takedamage) && entity_range(ent,target)<=160.0)
{
ExecuteHamB(Ham_TakeDamage, i, any:0, any:ent, any:random_float(75.0,90.0), any:DMG_CLUB)
emit_sound(ent, CHAN_VOICE, "AntlionMod/bitehit1.wav",  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
}
}


public Npc_think_disable(ent)
{
if (!pev_valid(ent)) return
entity_set_int(ent, EV_INT_iuser1, 1)
}


public Npc_charge_stop(ENT)
{
new ent=ENT-99999
if (!pev_valid(ent)) return
g_charge[ent]=false
}


public Npc2_jump(ent)
{
if (!pev_valid(ent) || entity_get_int(ent, EV_INT_sequence)!=6) return


new Float:vec[3]
velocity_by_aim(ent, 500, vec)
vec[2]=300.0
set_pev(ent, pev_velocity, any:vec)
set_task(0.3, "Npc_jump_move", ent)
}


public npc_ObjectCaps(id)
{
if (!is_user_alive(id) || get_user_team(id)!=1) return


if (pev(id, pev_button) & IN_USE && get_gametime()-1.0>g_cooldown[id])
{
new target, body, class[32]
get_user_aiming(id, target, body, 500)
entity_get_string(target, EV_SZ_classname, class, charsmax(class))


if (equal(class, "antlion_npc") || equal(class, "antlionguard_npc"))
{
new ent = entity_get_edict(target, EV_ENT_euser1)
if (ent==target)
{
client_print(id, print_chat, "[提示]你使用了NPC")
entity_set_edict(target, EV_ENT_euser1, id)
g_cooldown[id]=get_gametime()
return
}
else if (id==ent)
{
client_print(id, print_chat, "[提示]你关闭了NPC")
entity_set_edict(target, EV_ENT_euser1, target)
g_cooldown[id]=get_gametime()
return
}
else
{
client_print(id, print_chat, "[提示]这个NPC已经被人使用了")
g_cooldown[id]=get_gametime()
return
}
}
}
}


stock set_sequence(ent, sequence, Float:rate)
{
entity_set_int(ent, EV_INT_sequence, sequence)
entity_set_float(ent, EV_FL_frame, 0.0)
entity_set_float(ent, EV_FL_framerate, rate)
entity_set_float(ent, EV_FL_animtime, get_gametime())
}


stock find_closest_bone(id, num, Float:endtrace[3]) 

new Float:ang[3], Float:org[3], Float:dist = 100.0, Float:curorigin[3], bone_nr 
for (new i=1;i<=num;i++) 
{
engfunc(EngFunc_GetBonePosition, any:id, any:i, any:curorigin, any:ang)
xs_vec_sub(curorigin, endtrace, ang)


if (xs_vec_len(ang)<=dist)
{
org = curorigin
dist = xs_vec_len(ang)
bone_nr = i
}
if (dist<=2.0) break
}
return bone_nr
}


stock is_player_stuck(id)
{
static Float:originF[3]
pev(id, pev_origin, any:originF)
engfunc(EngFunc_TraceHull, any:originF, any:originF, any:0, any:HULL_HUMAN, any:id, any:0)


if (get_tr2(0, TraceResult:TR_StartSolid) || get_tr2(0, TraceResult:TR_AllSolid) || !get_tr2(0, TraceResult:TR_InOpen))
return true


return false;
}


stock get_closest_player(ent)
{
new players[32], num
get_players(players, num, "a")
new id=0, Float:closestdist = 2000.0
new player, Float:dist
new owner = entity_get_edict(ent, EV_ENT_euser1)
for (new i=0;i<num;i++)
{
player = players
if (player!=owner && !get_user_godmode(player) && is_user_alive(player) && get_user_team(player)!=1)
{
if (can_see(ent, player))
{
dist = entity_range(player, ent)
if (dist < closestdist)
{
id = player
closestdist = dist
}
}
}
}
if (id) return id


return 0
}


stock can_see(ent1, ent2)
{
if (pev_valid(ent1) && pev_valid(ent2))
{
new flags = pev(ent1, pev_flags)
if (flags & EF_NODRAW || flags & FL_NOTARGET) return 0


new Float:lookerOrig[3]
new Float:targetOrig[3]
new Float:temp[3]


pev(ent1, pev_origin, any:lookerOrig)
pev(ent1, pev_view_ofs, any:temp)
lookerOrig[0] += temp[0]
lookerOrig[1] += temp[1]
lookerOrig[2] += temp[2]


pev(ent2, pev_origin, any:targetOrig)
pev(ent2, pev_view_ofs, any:temp)
targetOrig[0] += temp[0]
targetOrig[1] += temp[1]
targetOrig[2] += temp[2]


engfunc(EngFunc_TraceLine, any:lookerOrig, any:targetOrig, any:0, any:ent1, any:0)
if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater)) return 0
else
{
new Float:flFraction
get_tr2(0, TraceResult:TR_flFraction, any:flFraction)
if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == ent2)) return 1
}
}
return 0
}


stock aim_origin(ent, Float:origin[3]) 
{
static Float:org[3], Float:vec[3], Float:ang[3], Float:num
pev(ent, pev_origin, any:org)


vec[0] = origin[0] - org[0] + random_float(-10.0, 10.0)
vec[1] = origin[1] - org[1] + random_float(-10.0, 10.0)
vec[2] = origin[2] - org[2] + random_float(-10.0, 30.0)


num = 300.0/vector_length(vec)


vec[0] *= num
vec[1] *= num
vec[2] *= -num
vector_to_angle(vec, ang)
entity_set_vector(ent, EV_VEC_v_angle, ang)
ang[0]=0.0
entity_set_vector(ent, EV_VEC_angles, ang)
}


stock fm_get_speed(id)
{
new Float:vec[3]
pev(id, pev_velocity, any:vec)
return floatround(vector_length(vec))
}


stock get_user_startpos(id,Float:forw,Float:right,Float:up,Float:vStart[])
{
new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]


entity_get_vector(id, EV_VEC_origin, vOrigin)
pev(id, pev_v_angle, any:vAngle)


engfunc(EngFunc_MakeVectors, any:vAngle)


global_get(glb_v_forward, any:vForward)
global_get(glb_v_right, any:vRight)
global_get(glb_v_up, any:vUp)


vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up


return 5
}


stock get_speed_vector_to(ent1, ent2, Float:speed, Float:vec[3])
{
if (!pev_valid(ent1) || !pev_valid(ent2)) return 0


static Float:org[3], Float:org2[3], Float:num
pev(ent1, pev_origin, any:org)
pev(ent2, pev_origin, any:org2)


vec[0] = org2[0]-org[0]
vec[1] = org2[1]-org[1]
vec[2] = org2[2]-org[2]
num = speed/vector_length(vec)


vec[0]*=num
vec[1]*=num
vec[2]*=num

return 1;
}


NPC(带源码)为什么我建立不出来这些文件夹呢。不能保存自动保存NPC,我见里完了 NPC文件夹也没有啊。求帮助



我要暴你头。。。。。
獻花 x0 回到頂端 [樓 主] From:沒有資料 | Posted:2014-03-29 22:10 |
xuqiang52133
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x1 鮮花 x32
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

为什么我输入了命令不自动生成文件夹呢?文件也没有,谁能帮我一下。谢谢大家了。都需要一些什么文件夹告诉,帮我把文件夹的民写出来好吗,放在哪里。。。。我先感谢大家了。


我要暴你头。。。。。
獻花 x0 回到頂端 [1 樓] From:沒有資料 | Posted:2014-03-29 22:13 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.091500 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言