查看: 5|回复: 5

【教程】【NPC】【AI-Walker】配合aiwalker创建一个NPC 新手教程

[复制链接]

5

主题

4

回帖

23

积分

新手上路

积分
23
发表于 9 小时前 | 显示全部楼层 |阅读模式
例子在此
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <aiwalker>
  4. #include <fakemeta_util>
  5. #include <fakemeta>
  6. #include <engine>
  7. #include <hamsandwich>
  8. #define PLUGIN_NAME"LB‘s NPC"
  9. #define PLUGIN_VERSION"1.0"
  10. #define PLUGIN_AUTHOR"LB"
  11. new g_szmodel[] = { "models/ai/normal_zombie.mdl" }//模型路径
  12. new g_modelid
  13. new g_fTime
  14. public plugin_init()
  15. {
  16. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  17. register_forward(FM_StartFrame, "fw_StartFrame_Post", 1)//fakemeta
  18. register_clcmd("say /t","te")//创建NPC的命令
  19. }
  20. public plugin_precache()
  21. {
  22. g_modelid = precache_model(g_szmodel)
  23. }
  24. public te(id)
  25. {
  26. new Float<img src="static/image/smiley/default/shocked.gif" border="0" smilieid="6" alt=":o">rigin[3]
  27. new Float:g_fTime = 0.0
  28. pev(id, pev_origin, origin)
  29. origin[2] += 40.0
  30. for(new i=1;i<=40;i++)
  31. {
  32. new ientity = CreateAi(origin, "sb", g_modelid, { -16.0, -10.0, -36.0 }, { 16.0, 10.0, 36.0 }, 200.0, 200.0, 0.1, 5.0, 75.0, 6.0, 0.01, 2.0, 3)//NPC属性(例:生命,速度,详情见下面INC)
  33. SetAiAnim(ientity, 0, 2, 3, 4, { 5, 6, 7 })//NPC模型动作(不懂就用小飞本来的僵尸模型,然后这个直接复制)
  34. }
  35. }
  36. public fw_StartFrame_Post()
  37. {
  38. if (get_gametime() - g_fTime > 2.0)
  39. {
  40. g_fTime = get_gametime()
  41. }
  42. }
  43. 源码完
  44. 以下节选自AI-Walker.inc
  45. {
  46. /*
  47. 以下是自定义pev,只是为了用起来方便,用原来的pev值也无所谓
  48. AI静止动作:pev_idle
  49. AI移动动作:pev_move
  50. AI跳跃动作:pev_jump
  51. AI攻击动作:pev_attack
  52. AI死亡动作[3]:pev_die
  53. AI名字:pev_ainame
  54. AI最大生命:pev_max_health
  55. AI最大速度:pev_maxspeed
  56. AI重力:pev_gravity
  57. AI队伍:pev_team
  58. AI攻击伤害:pev_damage
  59. AI攻击范围:pev_distance
  60. AI攻击速度:pev_attackrate
  61. AI反应时间:pev_thinkrate
  62. AI播放死亡动作的时间:pev_dyingtime
  63. */
  64. /*以下是数据接口---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
  65. //获取该实体是否是AI
  66. native bool:IsAi(iEntity)
  67. //创建一个AI(创建坐标,AI名字,AI模型缓存索引,AI体型Max[3],AI体型Min[3],AI最大生命,AI最大速度,AI重力,AI伤害,AI伤害距离,AI攻击速度,AI反应时间,AI播放死亡动作的时间,AI队伍),返回AI的实体索引
  68. native CreateAi(Float<img src="static/image/smiley/default/shocked.gif" border="0" smilieid="6" alt=":o">rigin[3], AiName[], modelindex, Float:maxhull[3], Float:minhull[3], Float:maxhealth, Float:maxspeed, Float:gravity, Float:damage, Float:distance, Float:attackrate, Float:thinkrate, Float:dyingtime, team)
  69. //设置该AI实体的动作(ID索引, 静止动作, 移动动作, 跳跃动作, 攻击动作, 死亡动作[3个])
  70. native SetAiAnim(iEntity, idle, move, jump, attack, die[3])
  71. /*
  72. 在创建AI的时候设置动作就可以了
  73. new modelindex
  74. public plugin_precache() modelindex = engfunc(EngFunc_PrecacheModel, "models/zombie.mdl")
  75. makezombie()
  76. {
  77. new Float:MAX_HULL[3], Float:MIN_HULL[3]
  78. MAX_HULL[0] = -16.0
  79. MAX_HULL[1] = -10.0
  80. MAX_HULL[2] = -36.0
  81. MIN_HULL[0] = 16.0
  82. MIN_HULL[1] = 10.0
  83. MIN_HULL[2] = 36.0
  84. new iEntity = CreateAi(origin, "SB僵尸", modelindex, MAX_HULL, MIN_HULL, 100.0, 240.0, 1.0, 5.0, 70.0, 1.0, 0.5, 2.0, 1)
  85. SetAiAnim(iEntity, 1, 2, 3, 4, {5, 6, 7})
  86. }
  87. */
  88. //移除该名字的所有AI
  89. native RemoveAi(const ainame[])
  90. //移除所有AI
  91. native RemoveAllAi()
  92. //获取该名字的所有AI数量
  93. native GetAIAmount(const ainame[])
  94. //获取所有AI的数量
  95. native GetAllAIAmount()
  96. //播放AI的动作
  97. native SendAiAnim(iEntity, anim)
  98. }
复制代码

在此感谢
@我是那鸡
@小飞CS
大神别吐槽,此帖给新手看。

[表情]

吧主给个精呗!

@MS一B

[表情]

5

主题

4

回帖

23

积分

新手上路

积分
23
 楼主| 发表于 9 小时前 | 显示全部楼层
  1. AI-Walker源码在此
  2. #include <amxmodx>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <xs>
  6. #define PLUGIN "AI Walker"
  7. #define VERSION "1.0"
  8. #define AUTHOR "DSHGFHDS"
  9. #define AI "ai_walker"
  10. #define pev_idle pev_iuser1
  11. #define pev_move pev_iuser2
  12. #define pev_jump pev_iuser3
  13. #define pev_attack pev_iuser4
  14. #define pev_die pev_vuser4
  15. #define pev_damage pev_speed
  16. #define pev_distance pev_fuser1
  17. #define pev_attackrate pev_fuser2
  18. #define pev_thinkrate pev_fuser3
  19. #define pev_dyingtime pev_fuser4
  20. #define ISJUMPING 1312
  21. new g_fwDummyResult, g_fwPreThink, g_fwPostThink, g_fwPreKilled, g_fwPostKilled, g_fwPreHurted, g_fwPostHurted
  22. new cvar_bodytime
  23. new spr_blood_spray, spr_blood_drop
  24. public plugin_init()
  25. {
  26. register_plugin(PLUGIN, VERSION, AUTHOR)
  27. RegisterHam(Ham_Think, "info_target", "HAM_AiThink")
  28. RegisterHam(Ham_TraceAttack, "info_target", "HAM_AiTraceAttack")
  29. RegisterHam(Ham_Killed, "info_target", "HAM_AiKilled")
  30. g_fwPreThink = CreateMultiForward("AI_PreThink", ET_CONTINUE, FP_CELL)
  31. g_fwPostThink = CreateMultiForward("AI_PostThink", ET_IGNORE, FP_CELL)
  32. g_fwPreHurted = CreateMultiForward("AI_PreHurted", ET_CONTINUE, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL)
  33. g_fwPostHurted = CreateMultiForward("AI_PostHurted", ET_IGNORE, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL)
  34. g_fwPreKilled = CreateMultiForward("AI_PreKilled", ET_CONTINUE, FP_CELL, FP_CELL)
  35. g_fwPostKilled = CreateMultiForward("AI_PostKilled", ET_IGNORE, FP_CELL, FP_CELL)
  36. cvar_bodytime = register_cvar("ai_body_time", "5.0") //灏镐綋瀛桦湪镄勬椂闂?
  37. }
  38. public plugin_natives()
  39. {
  40. register_native("IsAi", "NativeIsAi", 1)
  41. register_native("CreateAi", "NativeCreateAi")
  42. register_native("SetAiAnim", "NativeSetAiAnim")
  43. register_native("RemoveAi", "NativeRemoveAi", 1)
  44. register_native("RemoveAllAi", "NativeRemoveAllAi", 1)
  45. register_native("GetAIAmount", "NativeGetAIAmount", 1)
  46. register_native("GetAllAIAmount", "NativeGetAllAIAmount", 1)
  47. register_native("SendAiAnim", "NativeSendAiAnim", 1)
  48. }
  49. public plugin_precache()
  50. {
  51. spr_blood_spray = engfunc(EngFunc_PrecacheModel, "sprites/bloodspray.spr")
  52. spr_blood_drop = engfunc(EngFunc_PrecacheModel, "sprites/blood.spr")
  53. }
  54. public HAM_AiThink(iEntity)
  55. {
  56. new classname[33]
  57. pev(iEntity, pev_classname, classname, charsmax(classname))
  58. if(strcmp(classname, AI))
  59. return HAM_IGNORED
  60. ExecuteForward(g_fwPreThink, g_fwDummyResult, iEntity)
  61. if(g_fwDummyResult == 1)
  62. return HAM_SUPERCEDE
  63. new deadflag = pev(iEntity, pev_deadflag)
  64. if(deadflag == DEAD_DEAD)
  65. {
  66. engfunc(EngFunc_RemoveEntity, iEntity)
  67. return HAM_SUPERCEDE
  68. }
  69. new Float:fCurTime
  70. global_get(glb_time, fCurTime)
  71. if(deadflag == DEAD_DYING)
  72. {
  73. set_pev(iEntity, pev_deadflag, DEAD_DEAD)
  74. set_pev(iEntity, pev_nextthink, fCurTime+get_pcvar_float(cvar_bodytime))
  75. return HAM_SUPERCEDE
  76. }
  77. new Float:szThinkRate
  78. pev(iEntity, pev_thinkrate, szThinkRate)
  79. set_pev(iEntity, pev_nextthink, fCurTime+szThinkRate)
  80. new iPlayer = pev(iEntity, pev_enemy)
  81. if(!iPlayer)
  82. {
  83. iPlayer = engfunc(EngFunc_FindClientInPVS, iEntity)
  84. set_pev(iEntity, pev_enemy, iPlayer)
  85. }
  86. if(iPlayer && get_pdata_int(iPlayer, 114, 5) != pev(iEntity, pev_team))
  87. {
  88. new Float:start[3], Float:end[3]
  89. pev(iEntity, pev_origin, start)
  90. pev(iPlayer, pev_origin, end)
  91. engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, iEntity, 0)
  92. new blocker = get_tr2(0, TR_pHit)
  93. if(0 < blocker < 33 && blocker != iPlayer)
  94. {
  95. iPlayer = blocker
  96. set_pev(iEntity, pev_enemy, iPlayer)
  97. pev(iPlayer, pev_origin, end)
  98. }
  99. if(blocker == iPlayer)
  100. {
  101. SetEntityTurn(iEntity, end)
  102. new Float:distance, Float:velocity[3], Float:velocity2[3]
  103. pev(iEntity, pev_distance, distance)
  104. pev(iEntity, pev_velocity, velocity)
  105. if(get_distance_f(start, end) <= distance)
  106. {
  107. velocity2[2] = velocity[2]
  108. set_pev(iEntity, pev_velocity, velocity2)
  109. new Float:damage, Float:attackrate
  110. pev(iEntity, pev_damage, damage)
  111. ExecuteHamB(Ham_TakeDamage, iPlayer, iEntity, iEntity, damage, DMG_CLUB)
  112. pev(iEntity, pev_attackrate, attackrate)
  113. set_pev(iEntity, pev_nextthink, fCurTime+attackrate)
  114. NativeSendAiAnim(iEntity, pev(iEntity, pev_attack))
  115. }
  116. else
  117. if(pev(iEntity, pev_playerclass) == ISJUMPING)
  118. {
  119. get_speed_vector(start, end, 50.0, velocity2)
  120. velocity2[0] += velocity[0]
  121. velocity2[1] += velocity[1]
  122. velocity2[2] = velocity[2]
  123. set_pev(iEntity, pev_velocity, velocity2)
  124. set_pev(iEntity, pev_playerclass, 0)
  125. }
  126. else
  127. if(pev(iEntity, pev_flags) & FL_ONGROUND)
  128. {
  129. new Float:dest[3], Float:size[3]
  130. pev(iEntity, pev_origin, start)
  131. pev(iEntity, pev_v_angle, dest)
  132. engfunc(EngFunc_MakeVectors, dest)
  133. global_get(glb_v_forward, dest)
  134. pev(iEntity, pev_size, size)
  135. xs_vec_mul_scalar(dest, 1.5*size[0], dest)
  136. xs_vec_add(start, dest, dest)
  137. engfunc(EngFunc_TraceHull, dest, dest, IGNORE_MONSTERS, HULL_HUMAN, iEntity, 0)
  138. new Float:maxspeed
  139. pev(iEntity, pev_maxspeed, maxspeed)
  140. get_speed_vector(start, end, maxspeed, velocity2)
  141. if(get_tr2(0, TR_StartSolid) && get_tr2(0, TR_AllSolid) && !get_tr2(0, TR_InOpen) && FootPlaneNormal(iEntity) == 1.0)
  142. {
  143. velocity2[0] *= 0.5
  144. velocity2[1] *= 0.5
  145. velocity2[2] = 300.0
  146. NativeSendAiAnim(iEntity, pev(iEntity, pev_jump))
  147. set_pev(iEntity, pev_nextthink, fCurTime+0.2)
  148. set_pev(iEntity, pev_playerclass, ISJUMPING)
  149. }
  150. else
  151. {
  152. velocity2[2] = velocity[2]
  153. NativeSendAiAnim(iEntity, pev(iEntity, pev_move))
  154. }
  155. set_pev(iEntity, pev_velocity, velocity2)
  156. if(pev(iEntity, pev_playerclass) != ISJUMPING)
  157. {
  158. pev(iEntity, pev_angles, dest)
  159. engfunc(EngFunc_WalkMove, iEntity, dest[1], 0.5, WALKMOVE_NORMAL)
  160. }
  161. }
  162. ExecuteForward(g_fwPostThink, g_fwDummyResult, iEntity)
  163. return HAM_SUPERCEDE
  164. }
  165. }
  166. if(pev(iEntity, pev_flags) & FL_ONGROUND)
  167. {
  168. new Float:start[3], Float:dest[3], Float:hullend[3]
  169. pev(iEntity, pev_origin, start)
  170. pev(iEntity, pev_v_angle, dest)
  171. engfunc(EngFunc_MakeVectors, dest)
  172. global_get(glb_v_forward, dest)
  173. new Float:size[3]
  174. pev(iEntity, pev_size, size)
  175. xs_vec_mul_scalar(dest, 1.5*size[0], hullend)
  176. xs_vec_add(start, hullend, hullend)
  177. engfunc(EngFunc_TraceHull, hullend, hullend, DONT_IGNORE_MONSTERS, HULL_HUMAN, 0, 0)
  178. new Float:velocity[3]
  179. pev(iEntity, pev_velocity, velocity)
  180. if((!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen)) || FootPlaneNormal(iEntity) != 1.0)
  181. {
复制代码


7

主题

2

回帖

35

积分

新手上路

积分
35
发表于 9 小时前 | 显示全部楼层
  1. new Float:maxspeed, Float:velocity2[3]
  2. pev(iEntity, pev_maxspeed, maxspeed)
  3. get_speed_vector(start, hullend, maxspeed, velocity2)
  4. velocity2[2] = velocity[2]
  5. set_pev(iEntity, pev_velocity, velocity2)
  6. pev(iEntity, pev_angles, dest)
  7. engfunc(EngFunc_WalkMove, iEntity, dest[1], 0.5, WALKMOVE_NORMAL)
  8. SetEntityTurn(iEntity, hullend)
  9. NativeSendAiAnim(iEntity, pev(iEntity, pev_move))
  10. }
  11. else
  12. {
  13. new Float:v_angle[3]
  14. pev(iEntity, pev_v_angle, v_angle)
  15. v_angle[1] += random_float(-90.0, 90.0)
  16. set_pev(iEntity, pev_v_angle, v_angle)
  17. velocity[0] = 0.0
  18. velocity[1] = 0.0
  19. set_pev(iEntity, pev_velocity, velocity)
  20. NativeSendAiAnim(iEntity, pev(iEntity, pev_idle))
  21. }
  22. }
  23. set_pev(iEntity, pev_enemy, 0)
  24. ExecuteForward(g_fwPostThink, g_fwDummyResult, iEntity)
  25. return HAM_SUPERCEDE
  26. }
  27. public HAM_AiTraceAttack(iEntity, attacker, Float:damage, Float:direction[3], tracehandle, damagetype)
  28. {
  29. new classname[33]
  30. pev(iEntity, pev_classname, classname, charsmax(classname))
  31. if(strcmp(classname, AI))
  32. return HAM_IGNORED
  33. new HitGroup = get_tr2(tracehandle, TR_iHitgroup)
  34. new Float:Ndamage = damage
  35. if(HitGroup == HIT_HEAD) Ndamage *= random_float(1.5, 2.0)
  36. else if(HIT_CHEST <= HitGroup <= HIT_RIGHTARM) Ndamage *= random_float(0.8, 1.0)
  37. else if(HitGroup != HIT_GENERIC) Ndamage *= random_float(0.6, 0.8)
  38. ExecuteForward(g_fwPreHurted, g_fwDummyResult, iEntity, attacker, Ndamage, tracehandle, damagetype)
  39. if(g_fwDummyResult == 1)
  40. return HAM_SUPERCEDE
  41. new Float:origin_end[3]
  42. get_tr2(tracehandle, TR_vecEndPos, origin_end)
  43. new Float:velocity[3]
  44. pev(iEntity, pev_velocity, velocity)
  45. velocity[0] *= 0.3
  46. velocity[1] *= 0.3
  47. set_pev(iEntity, pev_velocity, velocity)
  48. set_pev(iEntity, pev_nextthink, get_gametime()+0.1)
  49. NativeSendAiAnim(iEntity, pev(iEntity, pev_idle))
  50. SpawnBlood(origin_end, 247, floatround(Ndamage))
  51. SetHamParamFloat(3, damage)
  52. ExecuteForward(g_fwPostHurted, g_fwDummyResult, iEntity, attacker, Ndamage, tracehandle, damagetype)
  53. return HAM_IGNORED
  54. }
  55. public HAM_AiKilled(iEntity, attacker, gib)
  56. {
  57. new classname[33]
  58. pev(iEntity, pev_classname, classname, charsmax(classname))
  59. if(strcmp(classname, AI))
  60. return HAM_IGNORED
  61. ExecuteForward(g_fwPreKilled, g_fwDummyResult, iEntity, attacker)
  62. if(g_fwDummyResult == 1)
  63. return HAM_SUPERCEDE
  64. set_pev(iEntity, pev_deadflag, DEAD_DYING)
  65. new Float:fdie[3], die[3]
  66. pev(iEntity, pev_die, fdie)
  67. FVecIVec(fdie, die)
  68. NativeSendAiAnim(iEntity, die[random_num(0, 2)])
  69. set_pev(iEntity, pev_velocity, {0.0, 0.0, 0.01})
  70. set_pev(iEntity, pev_takedamage, DAMAGE_NO)
  71. set_pev(iEntity, pev_solid, SOLID_NOT)
  72. new Float:dyingtime
  73. pev(iEntity, pev_dyingtime, dyingtime)
  74. set_pev(iEntity, pev_nextthink, get_gametime()+dyingtime)
  75. ExecuteForward(g_fwPostKilled, g_fwDummyResult, iEntity, attacker)
  76. return HAM_SUPERCEDE
  77. }
  78. public NativeCreateAi(plugin, param)
  79. {
  80. static AiName[33]
  81. get_string(2, AiName, charsmax(AiName))
  82. new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  83. set_pev(iEntity, pev_solid, SOLID_BBOX)
  84. set_pev(iEntity, pev_movetype, MOVETYPE_PUSHSTEP)
  85. set_pev(iEntity, pev_takedamage, DAMAGE_YES)
  86. set_pev(iEntity, pev_classname, AI)
  87. set_pev(iEntity, pev_deadflag, DEAD_NO)
  88. set_pev(iEntity, pev_targetname, AiName)
  89. set_pev(iEntity, pev_team, get_param(14))
  90. set_pev(iEntity, pev_max_health, get_param_f(6))
  91. set_pev(iEntity, pev_health, get_param_f(6))
  92. set_pev(iEntity, pev_maxspeed, get_param_f(7))
  93. set_pev(iEntity, pev_gravity, get_param_f(8))
  94. set_pev(iEntity, pev_damage, get_param_f(9))
  95. set_pev(iEntity, pev_distance, get_param_f(10))
  96. set_pev(iEntity, pev_attackrate, get_param_f(11))
  97. set_pev(iEntity, pev_thinkrate, get_param_f(12))
  98. set_pev(iEntity, pev_dyingtime, get_param_f(13))
  99. set_pev(iEntity, pev_nextthink, get_gametime()+get_param_f(12))
  100. set_pev(iEntity, pev_modelindex, get_param(3))
  101. set_pev(iEntity, pev_gamestate, 1)
  102. new Float:origin[3], Float:maxhull[3], Float:minhull[3]
  103. get_array_f(1, origin, 3)
  104. get_array_f(4, maxhull, 3)
  105. get_array_f(5, minhull, 3)
  106. engfunc(EngFunc_SetSize, iEntity, maxhull, minhull)
  107. engfunc(EngFunc_SetOrigin, iEntity, origin)
  108. return iEntity
  109. }
  110. public NativeSetAiAnim(plugin, param)
  111. {
  112. new iEntity = get_param(1)
  113. set_pev(iEntity, pev_idle, get_param(2))
  114. set_pev(iEntity, pev_move, get_param(3))
  115. set_pev(iEntity, pev_jump, get_param(4))
  116. set_pev(iEntity, pev_attack, get_param(5))
  117. new die[3], Float:fdie[3]
  118. get_array(6, die, 3)
  119. IVecFVec(die, fdie)
  120. set_pev(iEntity, pev_die, fdie)
  121. }
  122. public NativeRemoveAi(const AiName[])
  123. {
  124. new targetname[33], iEntity = -1
  125. while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
  126. {
  127. if(!pev_valid(iEntity))
  128. continue
  129. pev(iEntity, pev_targetname, targetname, charsmax(targetname))
  130. if(strcmp(targetname, AiName))
  131. continue
  132. engfunc(EngFunc_RemoveEntity, iEntity)
  133. }
  134. }
  135. public NativeRemoveAllAi()
  136. {
  137. new iEntity = -1
  138. while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
  139. {
  140. if(!pev_valid(iEntity))
  141. continue
  142. engfunc(EngFunc_RemoveEntity, iEntity)
  143. }
  144. }
  145. public NativeGetAIAmount(const AiName[])
  146. {
  147. new targetname[33], iEntity = -1, Amount
  148. while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
  149. {
  150. if(!pev_valid(iEntity))
  151. continue
  152. pev(iEntity, pev_targetname, targetname, charsmax(targetname))
  153. if(strcmp(targetname, AiName))
  154. continue
  155. Amount ++
  156. }
  157. return Amount
  158. }
  159. public NativeGetAllAIAmount()
  160. {
  161. new iEntity = -1, Amount
  162. while((iEntity = engfunc(EngFunc_FindEntityByString, iEntity, "classname", AI)))
  163. {
  164. if(!pev_valid(iEntity))
  165. continue
  166. Amount ++
  167. }
  168. return Amount
  169. }
  170. public NativeSendAiAnim(iEntity, anim)
  171. {
  172. if(pev(iEntity, pev_sequence) == anim)
  173. return
  174. set_pev(iEntity, pev_sequence, anim)
  175. set_pev(iEntity, pev_animtime, get_gametime())
  176. set_pev(iEntity, pev_frame, 0.0)
  177. set_pev(iEntity, pev_framerate, 1.0)
  178. }
  179. public bool:NativeIsAi(iEntity)
  180. {
  181. if(!pev_valid(iEntity))
  182. return false
  183. new classname[33]
  184. pev(iEntity, pev_classname, classname, charsmax(classname))
  185. if(strcmp(classname, AI))
  186. return false
  187. return true
  188. }
  189. stock SetEntityTurn(iEntity, Float:target[3])
  190. {
  191. new Float:angle[3], Float:origin[3]
  192. pev(iEntity, pev_angles, angle)
  193. pev(iEntity, pev_origin, origin)
  194. new Float:x = origin[0] - target[0]
  195. new Float:z = origin[1] - target[1]
  196. new Float:radians = floatatan(z/x, radian)
  197. angle[1] = radians * 180.0/3.141592654
  198. if(target[0] < origin[0]) angle[1] -= 180.0
  199. set_pev(iEntity, pev_angles, angle)
  200. set_pev(iEntity, pev_v_angle, angle)
  201. }
  202. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  203. {
  204. new_velocity[0] = origin2[0] - origin1[0]
  205. new_velocity[1] = origin2[1] - origin1[1]
  206. new_velocity[2] = origin2[2] - origin1[2]
  207. new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  208. new_velocity[0] *= num
  209. new_velocity[1] *= num
  210. new_velocity[2] *= num
  211. return 1
  212. }
  213. stock Float:FootPlaneNormal(iEntity)
  214. {
  215. new Float:start[3], Float:end[3]
  216. pev(iEntity, pev_origin, start)
  217. xs_vec_sub(start, Float:{0.0, 0.0, 9999.0}, end)
  218. engfunc(EngFunc_TraceLine, start, end, DONT_IGNORE_MONSTERS, iEntity, 0)
  219. get_tr2(0, TR_vecPlaneNormal, end)
  220. return end[2]
  221. }
  222. stock SpawnBlood(const Float:vecOrigin[3], iColor, iAmount)
  223. {
  224. if(iAmount == 0)
  225. return
  226. iAmount *= 2
  227. if(iAmount > 255) iAmount = 255
  228. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecOrigin)
  229. write_byte(TE_BLOODSPRITE)
  230. engfunc(EngFunc_WriteCoord, vecOrigin[0])
  231. engfunc(EngFunc_WriteCoord, vecOrigin[1])
  232. engfunc(EngFunc_WriteCoord, vecOrigin[2])
  233. write_short(spr_blood_spray)
  234. write_short(spr_blood_drop)
  235. write_byte(iColor)
  236. write_byte(min(max(3, iAmount / 10), 16))
  237. message_end()
  238. }
复制代码


5

主题

4

回帖

23

积分

新手上路

积分
23
 楼主| 发表于 9 小时前 | 显示全部楼层
不对,新手请把NPC源码里的那句for(new i=1;i<=40;i++)删掉,不然会有40只僵尸卡在一起

5

主题

4

回帖

23

积分

新手上路

积分
23
 楼主| 发表于 9 小时前 | 显示全部楼层
这不就是DS的ZR吗?
早期版本是在一起的,后来里面的NPC插件独立出来了可以提取出来用于其它地方。
如果是想用NPC的话,个人觉得csoldjb老大的不错,毕竟DS这个专门为Zombie准备的…

5

主题

4

回帖

23

积分

新手上路

积分
23
 楼主| 发表于 9 小时前 | 显示全部楼层
没有没有,当初是独立写出来的AI核心,跟ZR没关,只是没事附加上去的而已
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:admin@discuz.vip

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|青ICP备2025004122号-1

在本版发帖
关注公众号
返回顶部