NPC_SetFightingStyle
注意
这个函数是在omp v1.5.8.3079中添加的,在以前的版本中不起作用!
描述
设置 NPC 的战斗风格,用于近身战斗。
| 参数 | 说明 |
|---|---|
| npcid | NPC 的 ID |
| style | 战斗风格 ID |
返回值
如果操作成功则返回true,否则返回false。
示例
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/setfightingstyle ", true, 18))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "你没有在调试NPC。");
if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "无效的NPC。");
new styleid = strval(cmdtext[18]);
// 有效的战斗风格: 4, 5, 6, 7, 15, 16
if (styleid != 4 && styleid != 5 && styleid != 6 && styleid != 7 && styleid != 15 && styleid != 16)
return SendClientMessage(playerid, 0xFF0000FF, "无效的风格。有效:4(普通),5(拳击),6(功夫),7(膝击),15(抓踢),16(肘击)");
NPC_SetFightingStyle(npcid, FIGHT_STYLE:styleid);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d 战斗风格设置为 %d", npcid, styleid);
return 1;
}
return 0;
}
注意事项
- 战斗风格影响近身攻击动画和伤害
- 使用 NPC_GetFightingStyle 检查当前风格
- 风格影响攻击动画和战斗效果
相关函数
- NPC_GetFightingStyle: 获取战斗风格
- NPC_MeleeAttack: 让 NPC 攻击
- NPC_IsMeleeAttacking: 检查是否正在攻击
- NPC_StopMeleeAttack: 停止攻击
相关资源
相关回调
- OnNPCGiveDamage: NPC 对他人造成伤害时调用