Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by zhiJiaN ( 6 years ago )
#include <amxmodx>
#include <fakemeta>
enum RouteType
{
FASTEST_ROUTE,
SAFEST_ROUTE,
}
enum NavAttributeType
{
NAV_CROUCH = 0x01, // must crouch to use this node/area
NAV_JUMP = 0x02, // must jump to traverse this area
NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area
NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping
}
/*
执行寻路(起点,终点,路径类型) 返回路点数量
注:内部由数组存储路点,每次寻路前会重置,所以get只能用在下次find前
*/
native navmesh_find(Float:start[3], Float:ent[3], iRouteType)
/*
通过数组索引获取路点坐标(数组索引0-路点数量)
注:索引超过路点数组只会返回0,0,0坐标
*/
native navmesh_get(pathIndex, Float:origin[3])
/*
通过数组索引获取路点类型(数组索引0-路点数量)
注:索引超过路点数组返回0
*/
native navmesh_attribute(pathIndex)
/*
寻找里路径最近的点(当前位置,起点,终点,最近点)
*/
native navmesh_closetpoint(Float:position[3], start, end, Float:out[3])
/*
调整目标位置(angle1,眼睛位置,目标位置) * 暂时别用好像没啥卵用
*/
native navmesh_feeleradjustment(Float:yaw, Float:eyeOrigin[3], Float:goal[3])
new Float:origin1[33][3], Float:origin2[33][3]
public plugin_init()
{
register_clcmd("say start", "start")
register_clcmd("say go", "go")
register_clcmd("say d", "d")
register_clcmd("say t", "t")
}
new sw[33]
public t(id){
sw[id] = sw[id]?0:1
loop(id)
}
public loop(id){
if(!sw[id] || !is_user_alive(id)){
remove_task(id)
}
else{
new Float:pos[3], Float:s[3], Float:e[3]
pev(id, pev_origin, pos)
new len = navmesh_find(pos, origin2[id], FASTEST_ROUTE)
new Float:angles[3]
pev(id, pev_angles, angles)
new Float:first[3]
navmesh_closetpoint(pos, 1, len, first)
if(len>0){
navmesh_get(1, s)
DrawLine(first, s, 1)
}
for(new i = 1 ; i < len ; ++ i){
navmesh_get(i, s)
//if(i<=3){ // 调整近距离几个点
// navmesh_feeleradjustment(angles[1], pos, s)
//}
if(i != len - 1){
navmesh_get(i+1, e)
DrawLine(s, e, 1)
}
}
set_task(0.4, "loop",id)
}
}
public start(id){
pev(id, pev_origin, origin1[id])
}
public go(id){
pev(id, pev_origin, origin2[id])
}
public d(id){
new len = navmesh_find(origin1[id], origin2[id], FASTEST_ROUTE)
//client_print(id, print_console, "========> Path length:%d", len)
new Float:s[3], Float:e[3]
for(new i = 0 ; i < len ; ++ i){
navmesh_get(i, s)
if(i != len - 1){
navmesh_get(i+1, e)
DrawLine(s, e)
}
client_print(id, print_console, "========> Path %d (Type:%d): %.2f,%.2f,%.2f", i,navmesh_attribute(i), s[0], s[1], s[2])
}
}
new laser
public plugin_precache(){
laser = precache_model("sprites/laserbeam.spr")
}
DrawLine(const Float:sorigin[3],const Float:eorigin[3], type=0)
{
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, sorigin, 0)
write_byte(TE_BEAMPOINTS) // temp entity event
engfunc(EngFunc_WriteCoord, sorigin[0]) // x
engfunc(EngFunc_WriteCoord, sorigin[1]) // y
engfunc(EngFunc_WriteCoord, sorigin[2]+15.0) // z
engfunc(EngFunc_WriteCoord, eorigin[0]) // x axis
engfunc(EngFunc_WriteCoord, eorigin[1]) // y axis
engfunc(EngFunc_WriteCoord, eorigin[2]+15.0) // z axis
write_short(laser) // sprite index
write_byte(0) // start frame
write_byte(0) // framerate
write_byte(type?4:100) // life in 0.1's
write_byte(20) // line width in 0.1's
write_byte(0) // noise amplitude in 0.01's
write_byte(type?255:120) // color: red
write_byte(type?75:220) // color: green
write_byte(type?0:120) // color: blue
write_byte(120) // brightness
write_byte(0) // scroll speed in 0.1's
message_end()
}
Revise this Paste