~幻想恋空~
|
分享:
▼
x0
|
[1.6][插件] 请教懂写NPC高手一些变更锁定目标的问题..
原本写法是选择全部玩家其中之一永久锁定目标攻击除非目标死亡否则不会变更其他目标 若如果想修改成NPC自动搜寻离自身最近的敌人而且视距离变更适当目标的话请问要怎么修改.. 拜托恳请各位NPC高手能够解答或者+QQ:2487720951 ^^" 复制程式
public Think_Boss(Ent)
{
if (pev(Ent, pev_deadflag) == DEAD_DYING)
return
static bool:one
switch ( Ability )
{
case IDLE:
{
Ability = WALK
set_task(10.0, "RandomAbility", 1337, _, _, "b")
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
return
}
case WALK:
{
static Float:Origin[3], Float:Origin2[3], Float:Vector[3], Float:Angle[3]
if (!is_user_alive(g_BossTarget))
{
g_BossTarget = GetRandomAlive(random_num(1, GetAliveCount()))
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
return
}
if (one)
{
set_pev(Ent, pev_movetype, MOVETYPE_PUSHSTEP)
Anim(Ent, 3)
one = false
}
pev(Ent, pev_origin, Origin)
pev(g_BossTarget, pev_origin, Origin2)
xs_vec_sub(Origin2, Origin, Vector)
vector_to_angle(Vector, Angle)
new Float:num = floatsqroot(float(boss_speed)*float(boss_speed) / (Vector[0]*Vector[0] + Vector[1]*Vector[1] + Vector[2]*Vector[2]))
Vector[0] *= num
Vector[1] *= num
Vector[2] ? (Vector[2] = 0.0) : (Vector[2] *= num)
set_pev(Ent, pev_velocity, Vector)
Angle[0] = 0.0
Angle[2] = 0.0
set_pev(Ent, pev_angles, Angle)
set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
return
}
case ATTACK:
{
static num
switch (num)
{
case 0:
{
Anim(Ent, 6)
num++
set_pev(Ent, pev_nextthink, get_gametime() + 1.0)
return
}
case 1:
{
static Float:OriginA[3], Float:OriginA2[3], Float:LenA, Float:Vector[3], Float:Velocity[3]
pev(g_Alien, pev_origin, OriginA)
pev(VictimID, pev_origin, OriginA2)
xs_vec_sub(OriginA2, OriginA, Velocity)
xs_vec_sub(OriginA, OriginA2, Vector)
LenA = xs_vec_len(Vector)
if (LenA <= 170)
{
xs_vec_normalize(Velocity, Velocity)
Velocity[2] = 0.5
xs_vec_mul_scalar(Velocity, 1000.0, Velocity)
ExecuteHamB(Ham_TakeDamage, VictimID, 0, VictimID, float(dmg_attack), DMG_BULLET)
ScreenFade(VictimID, 3, {255, 0, 0}, 120)
ScreenShake(VictimID)
set_pev(VictimID, pev_velocity, Velocity)
emit_sound(Ent, CHAN_VOICE, g_AlienSound[2], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
}
num = 0
one = true
Ability = WALK
set_pev(Ent, pev_nextthink, get_gametime() + 0.2)
}
}
}
GetRandomAlive(target_index)
{
new iAlive
for (new id = 1; id <= get_maxplayers(); id++) {
if (is_user_alive(id)) iAlive++
if (iAlive == target_index) return id
}
return -1
}
[ 此文章被~幻想恋空~在2012-10-01 16:54重新编辑 ]
|
|
x0
[楼 主]
From:台湾中华电信股份有限公司 | Posted:2012-10-01 13:00 |
|
|
|