|
|
- new Float:maxspeed, Float:velocity2[3]
- pev(iEntity, pev_maxspeed, maxspeed)
- get_speed_vector(start, hullend, maxspeed, velocity2)
- velocity2[2] = velocity[2]
- set_pev(iEntity, pev_velocity, velocity2)
- pev(iEntity, pev_angles, dest)
- engfunc(EngFunc_WalkMove, iEntity, dest[1], 0.5, WALKMOVE_NORMAL)
- SetEntityTurn(iEntity, hullend)
- NativeSendAiAnim(iEntity, pev(iEntity, pev_move))
- }
- else
- {
- new Float:v_angle[3]
- pev(iEntity, pev_v_angle, v_angle)
- v_angle[1] += random_float(-90.0, 90.0)
- set_pev(iEntity, pev_v_angle, v_angle)
- velocity[0] = 0.0
- velocity[1] = 0.0
- set_pev(iEntity, pev_velocity, velocity)
- NativeSendAiAnim(iEntity, pev(iEntity, pev_idle))
- }
- }
- set_pev(iEntity, pev_enemy, 0)
- ExecuteForward(g_fwPostThink, g_fwDummyResult, iEntity)
- return HAM_SUPERCEDE
- }
- public HAM_AiTraceAttack(iEntity, attacker, Float:damage, Float:direction[3], tracehandle, damagetype)
- {
- new classname[33]
- pev(iEntity, pev_classname, classname, charsmax(classname))
- if(strcmp(classname, AI))
- return HAM_IGNORED
- new HitGroup = get_tr2(tracehandle, TR_iHitgroup)
- new Float:Ndamage = damage
- if(HitGroup == HIT_HEAD) Ndamage *= random_float(1.5, 2.0)
- else if(HIT_CHEST <= HitGroup <= HIT_RIGHTARM) Ndamage *= random_float(0.8, 1.0)
- else if(HitGroup != HIT_GENERIC) Ndamage *= random_float(0.6, 0.8)
- ExecuteForward(g_fwPreHurted, g_fwDummyResult, iEntity, attacker, Ndamage, tracehandle, damagetype)
- if(g_fwDummyResult == 1)
- return HAM_SUPERCEDE
- new Float:origin_end[3]
- get_tr2(tracehandle, TR_vecEndPos, origin_end)
- new Float:velocity[3]
- pev(iEntity, pev_velocity, velocity)
- velocity[0] *= 0.3
- velocity[1] *= 0.3
- set_pev(iEntity, pev_velocity, velocity)
- set_pev(iEntity, pev_nextthink, get_gametime()+0.1)
- NativeSendAiAnim(iEntity, pev(iEntity, pev_idle))
- SpawnBlood(origin_end, 247, floatround(Ndamage))
- SetHamParamFloat(3, damage)
- ExecuteForward(g_fwPostHurted, g_fwDummyResult, iEntity, attacker, Ndamage, tracehandle, damagetype)
- return HAM_IGNORED
- }
- public HAM_AiKilled(iEntity, attacker, gib)
- {
- new classname[33]
- pev(iEntity, pev_classname, classname, charsmax(classname))
- if(strcmp(classname, AI))
- return HAM_IGNORED
- ExecuteForward(g_fwPreKilled, g_fwDummyResult, iEntity, attacker)
- if(g_fwDummyResult == 1)
- return HAM_SUPERCEDE
- set_pev(iEntity, pev_deadflag, DEAD_DYING)
- new Float:fdie[3], die[3]
- pev(iEntity, pev_die, fdie)
- FVecIVec(fdie, die)
- NativeSendAiAnim(iEntity, die[random_num(0, 2)])
- set_pev(iEntity, pev_velocity, {0.0, 0.0, 0.01})
- set_pev(iEntity, pev_takedamage, DAMAGE_NO)
- set_pev(iEntity, pev_solid, SOLID_NOT)
- new Float:dyingtime
- pev(iEntity, pev_dyingtime, dyingtime)
- set_pev(iEntity, pev_nextthink, get_gametime()+dyingtime)
- ExecuteForward(g_fwPostKilled, g_fwDummyResult, iEntity, attacker)
- return HAM_SUPERCEDE
- }
- public NativeCreateAi(plugin, param)
- {
- static AiName[33]
- get_string(2, AiName, charsmax(AiName))
- new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
- set_pev(iEntity, pev_solid, SOLID_BBOX)
- set_pev(iEntity, pev_movetype, MOVETYPE_PUSHSTEP)
- set_pev(iEntity, pev_takedamage, DAMAGE_YES)
- set_pev(iEntity, pev_classname, AI)
- set_pev(iEntity, pev_deadflag, DEAD_NO)
- set_pev(iEntity, pev_targetname, AiName)
- set_pev(iEntity, pev_team, get_param(14))
- set_pev(iEntity, pev_max_health, get_param_f(6))
- set_pev(iEntity, pev_health, get_param_f(6))
- set_pev(iEntity, pev_maxspeed, get_param_f(7))
- set_pev(iEntity, pev_gravity, get_param_f(8))
- set_pev(iEntity, pev_damage, get_param_f(9))
- set_pev(iEntity, pev_distance, get_param_f(10))
- set_pev(iEntity, pev_attackrate, get_param_f(11))
- set_pev(iEntity, pev_thinkrate, get_param_f(12))
- set_pev(iEntity, pev_dyingtime, get_param_f(13))
- set_pev(iEntity, pev_nextthink, get_gametime()+get_param_f(12))
- set_pev(iEntity, pev_modelindex, get_param(3))
- set_pev(iEntity, pev_gamestate, 1)
- new Float:origin[3], Float:maxhull[3], Float:minhull[3]
- get_array_f(1, origin, 3)
- get_array_f(4, maxhull, 3)
- get_array_f(5, minhull, 3)
- engfunc(EngFunc_SetSize, iEntity, maxhull, minhull)
- engfunc(EngFunc_SetOrigin, iEntity, origin)
- return iEntity
- }
- public NativeSetAiAnim(plugin, param)
- {
- new iEntity = get_param(1)
- set_pev(iEntity, pev_idle, get_param(2))
- set_pev(iEntity, pev_move, get_param(3))
- set_pev(iEntity, pev_jump, get_param(4))
- set_pev(iEntity, pev_attack, get_param(5))
- new die[3], Float:fdie[3]
- get_array(6, die, 3)
- IVecFVec(die, fdie)
- set_pev(iEntity, pev_die, fdie)
- }
- public NativeRemoveAi(const AiName[])
- {
- new targetname[33], iEntity = -1
- while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
- {
- if(!pev_valid(iEntity))
- continue
- pev(iEntity, pev_targetname, targetname, charsmax(targetname))
- if(strcmp(targetname, AiName))
- continue
- engfunc(EngFunc_RemoveEntity, iEntity)
- }
- }
- public NativeRemoveAllAi()
- {
- new iEntity = -1
- while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
- {
- if(!pev_valid(iEntity))
- continue
- engfunc(EngFunc_RemoveEntity, iEntity)
- }
- }
- public NativeGetAIAmount(const AiName[])
- {
- new targetname[33], iEntity = -1, Amount
- while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
- {
- if(!pev_valid(iEntity))
- continue
- pev(iEntity, pev_targetname, targetname, charsmax(targetname))
- if(strcmp(targetname, AiName))
- continue
- Amount ++
- }
- return Amount
- }
- public NativeGetAllAIAmount()
- {
- new iEntity = -1, Amount
- while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
- {
- if(!pev_valid(iEntity))
- continue
- Amount ++
- }
- return Amount
- }
- public NativeSendAiAnim(iEntity, anim)
- {
- if(pev(iEntity, pev_sequence) == anim)
- return
- set_pev(iEntity, pev_sequence, anim)
- set_pev(iEntity, pev_animtime, get_gametime())
- set_pev(iEntity, pev_frame, 0.0)
- set_pev(iEntity, pev_framerate, 1.0)
- }
- public bool:NativeIsAi(iEntity)
- {
- if(!pev_valid(iEntity))
- return false
- new classname[33]
- pev(iEntity, pev_classname, classname, charsmax(classname))
- if(strcmp(classname, AI))
- return false
- return true
- }
- stock SetEntityTurn(iEntity, Float:target[3])
- {
- new Float:angle[3], Float:origin[3]
- pev(iEntity, pev_angles, angle)
- pev(iEntity, pev_origin, origin)
- new Float:x = origin[0] - target[0]
- new Float:z = origin[1] - target[1]
- new Float:radians = floatatan(z/x, radian)
- angle[1] = radians * 180.0/3.141592654
- if(target[0] < origin[0]) angle[1] -= 180.0
- set_pev(iEntity, pev_angles, angle)
- set_pev(iEntity, pev_v_angle, angle)
- }
- stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
- {
- new_velocity[0] = origin2[0] - origin1[0]
- new_velocity[1] = origin2[1] - origin1[1]
- new_velocity[2] = origin2[2] - origin1[2]
- new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
- new_velocity[0] *= num
- new_velocity[1] *= num
- new_velocity[2] *= num
- return 1
- }
- stock Float:FootPlaneNormal(iEntity)
- {
- new Float:start[3], Float:end[3]
- pev(iEntity, pev_origin, start)
- xs_vec_sub(start, Float:{0.0, 0.0, 9999.0}, end)
- engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, iEntity, 0)
- get_tr2(0, TR_vecPlaneNormal, end)
- return end[2]
- }
- stock SpawnBlood(const Float:vecOrigin[3], iColor, iAmount)
- {
- if(iAmount == 0)
- return
- iAmount *= 2
- if(iAmount > 255) iAmount = 255
- engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin)
- write_byte(TE_BLOODSPRITE)
- engfunc(EngFunc_WriteCoord, vecOrigin[0])
- engfunc(EngFunc_WriteCoord, vecOrigin[1])
- engfunc(EngFunc_WriteCoord, vecOrigin[2])
- write_short(spr_blood_spray)
- write_short(spr_blood_drop)
- write_byte(iColor)
- write_byte(min(max(3, iAmount / 10), 16))
- message_end()
- }
复制代码
|
|