跳至主要内容

NPC_AimAt

注意

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

Description

Makes an NPC aim at specified coordinates.

NameDescription
npcidThe ID of the NPC
Float:pointXThe X coordinate to aim at
Float:pointYThe Y coordinate to aim at
Float:pointZThe Z coordinate to aim at
bool:shootWhether to shoot while aiming
shootDelayDelay between shots in milliseconds
bool:updateAngleWhether to update the NPC's facing angle
Float:offsetFromXThe X offset from the NPC's shooting position
Float:offsetFromYThe Y offset from the NPC's shooting position
Float:offsetFromZThe Z offset from the NPC's shooting position
checkInBetweenFlagsEntity check flags for collision detection

Returns

Returns true if the operation was successful, false otherwise.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/aim", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);

NPC_AimAt(npcid, x, y, z, false, 0, true, 0.0, 0.0, 0.6, NPC_ENTITY_CHECK_NONE);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d is now aiming at your position.", npcid);
return 1;
}

if (!strcmp(cmdtext, "/aimfire", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);

NPC_AimAt(npcid, x, y, z, true, 800, true, 0.0, 0.0, 0.6, NPC_ENTITY_CHECK_NONE);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d is now firing at your position.", npcid);
return 1;
}
return 0;
}

Notes

  • The NPC will continuously aim at the specified position until NPC_StopAim is called
  • If shoot is true, the NPC will fire at the target position with the specified delay
  • The updateAngle parameter controls whether the NPC turns to face the target
  • Offset parameters adjust the shooting origin point relative to the NPC's position