~幻想戀空~
|
分享:
▼
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 |
|
|
|