Skip to content

Commit 0227a89

Browse files
authored
Merge pull request #55 from itsneufox/NPC-changes
NPC include
2 parents ae817cb + fe9d57e commit 0227a89

1 file changed

Lines changed: 162 additions & 20 deletions

File tree

omp_npc.inc

Lines changed: 162 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@
4646
const INVALID_NPC_ID = -1;
4747
#define INVALID_NPC_ID (-1)
4848

49+
/**
50+
* <library>omp_npc</library>
51+
*/
52+
const INVALID_PATH_ID = -1;
53+
#define INVALID_PATH_ID (-1)
54+
55+
/**
56+
* <library>omp_npc</library>
57+
*/
58+
const INVALID_NODE_ID = -1;
59+
#define INVALID_NODE_ID (-1)
60+
61+
/**
62+
* <library>omp_npc</library>
63+
*/
64+
const INVALID_RECORD_ID = -1;
65+
#define INVALID_RECORD_ID (-1)
66+
4967
/**
5068
* <library>omp_npc</library>
5169
*/
@@ -203,6 +221,17 @@ native NPC_Spawn(npcid);
203221
*/
204222
native NPC_Respawn(npcid);
205223

224+
/**
225+
* <library>omp_npc</library>
226+
* <summary>Checks if an NPC is spawned in the game world.</summary>
227+
* <param name="npcid">The ID of the NPC to check</param>
228+
* <returns>Returns true if the NPC is spawned, false otherwise.</returns>
229+
* <seealso name="NPC_Spawn" />
230+
* <seealso name="NPC_Respawn" />
231+
* <seealso name="NPC_IsDead" />
232+
*/
233+
native bool:NPC_IsSpawned(npcid);
234+
206235
/**
207236
* <library>omp_npc</library>
208237
* <summary>Gets all NPC IDs and stores them in an array.</summary>
@@ -270,7 +299,7 @@ native NPC_GetFacingAngle(npcid, &Float:angle);
270299
/**
271300
* <library>omp_npc</library>
272301
*/
273-
native NPC_SetVirtualWorld(npcid, vw);
302+
native NPC_SetVirtualWorld(npcid, virtualWorld);
274303

275304
/**
276305
* <library>omp_npc</library>
@@ -319,6 +348,43 @@ native bool:NPC_StopMove(npcid);
319348
*/
320349
native bool:NPC_IsMoving(npcid);
321350

351+
/**
352+
* <library>omp_npc</library>
353+
* <summary>Checks if an NPC is moving toward a specific player.</summary>
354+
* <param name="npcid">The ID of the NPC</param>
355+
* <param name="playerid">The ID of the player to check</param>
356+
* <returns>Returns true if the NPC is moving toward the specified player, false otherwise.</returns>
357+
* <seealso name="NPC_MoveToPlayer" />
358+
* <seealso name="NPC_IsMoving" />
359+
*/
360+
native bool:NPC_IsMovingToPlayer(npcid, playerid);
361+
362+
/**
363+
* <library>omp_npc</library>
364+
* <summary>Sets the velocity of an NPC.</summary>
365+
* <param name="npcid">The ID of the NPC</param>
366+
* <param name="x">The X velocity component</param>
367+
* <param name="y">The Y velocity component</param>
368+
* <param name="z">The Z velocity component</param>
369+
* <returns>Returns true on success, false on failure.</returns>
370+
* <seealso name="NPC_GetVelocity" />
371+
* <seealso name="NPC_SetPos" />
372+
*/
373+
native NPC_SetVelocity(npcid, Float:x, Float:y, Float:z);
374+
375+
/**
376+
* <library>omp_npc</library>
377+
* <summary>Gets the velocity of an NPC.</summary>
378+
* <param name="npcid">The ID of the NPC</param>
379+
* <param name="x">Variable to store the X velocity component, passed by reference</param>
380+
* <param name="y">Variable to store the Y velocity component, passed by reference</param>
381+
* <param name="z">Variable to store the Z velocity component, passed by reference</param>
382+
* <returns>Returns true on success, false on failure.</returns>
383+
* <seealso name="NPC_SetVelocity" />
384+
* <seealso name="NPC_GetPos" />
385+
*/
386+
native NPC_GetVelocity(npcid, &Float:x, &Float:y, &Float:z);
387+
322388
/*
323389
native # Appearance();
324390
native Appearance(
@@ -329,7 +395,17 @@ native
329395
/**
330396
* <library>omp_npc</library>
331397
*/
332-
native NPC_SetSkin(npcid, model);
398+
native NPC_SetSkin(npcid, skinid);
399+
400+
/**
401+
* <library>omp_npc</library>
402+
* <summary>Gets the skin/model ID of an NPC.</summary>
403+
* <param name="npcid">The ID of the NPC</param>
404+
* <returns>Returns the skin/model ID of the NPC, or -1 if invalid.</returns>
405+
* <seealso name="NPC_SetSkin" />
406+
* <seealso name="NPC_IsValid" />
407+
*/
408+
native NPC_GetSkin(npcid);
333409

334410
/**
335411
* <library>omp_npc</library>
@@ -388,6 +464,18 @@ native NPC_SetInvulnerable(npcid, bool:toggle);
388464
*/
389465
native bool:NPC_IsInvulnerable(npcid);
390466

467+
/**
468+
* <library>omp_npc</library>
469+
* <summary>Kills an NPC with a specific weapon/reason.</summary>
470+
* <param name="npcid">The ID of the NPC to kill</param>
471+
* <param name="killerid">The ID of the player who killed the NPC (optional, use INVALID_PLAYER_ID for no killer)</param>
472+
* <param name="reason">The weapon ID or reason for death (default: 255 for suicide)</param>
473+
* <returns>Returns true on success, false on failure.</returns>
474+
* <seealso name="NPC_IsDead" />
475+
* <seealso name="NPC_SetHealth" />
476+
*/
477+
native NPC_Kill(npcid, killerid = INVALID_PLAYER_ID, WEAPON:reason = 255);
478+
391479
/*
392480
native # Weapons & Combat();
393481
native Weapons & Combat(
@@ -398,7 +486,7 @@ native
398486
/**
399487
* <library>omp_npc</library>
400488
*/
401-
native NPC_SetWeapon(npcid, weapon);
489+
native NPC_SetWeapon(npcid, WEAPON:weaponid);
402490

403491
/**
404492
* <library>omp_npc</library>
@@ -453,7 +541,7 @@ native bool:NPC_IsMeleeAttacking(npcid);
453541
/**
454542
* <library>omp_npc</library>
455543
*/
456-
native NPC_SetFightingStyle(npcid, style);
544+
native NPC_SetFightingStyle(npcid, FIGHT_STYLE:style);
457545

458546
/**
459547
* <library>omp_npc</library>
@@ -490,11 +578,22 @@ native bool:NPC_IsInfiniteAmmoEnabled(npcid);
490578
*/
491579
native NPC_GetWeaponState(npcid);
492580

581+
/**
582+
* <library>omp_npc</library>
583+
* <summary>Sets the weapon state of an NPC.</summary>
584+
* <param name="npcid">The ID of the NPC</param>
585+
* <param name="weaponState">The weapon state to set</param>
586+
* <returns>Returns true on success, false on failure.</returns>
587+
* <seealso name="NPC_GetWeaponState" />
588+
* <seealso name="NPC_SetWeapon" />
589+
*/
590+
native NPC_SetWeaponState(npcid, WEAPONSTATE:weaponState);
591+
493592
/**
494593
* <library>omp_npc</library>
495594
* <summary>Makes an NPC fire a weapon shot.</summary>
496595
* <param name="npcid">The ID of the NPC</param>
497-
* <param name="weapon">The weapon ID to use for shooting</param>
596+
* <param name="weaponid">The weapon ID to use for shooting</param>
498597
* <param name="hitId">The ID of the target entity being shot</param>
499598
* <param name="hitType">The type of entity being hit (player, NPC, vehicle, etc.)</param>
500599
* <param name="endPointX">X coordinate of the bullet end point</param>
@@ -509,7 +608,7 @@ native NPC_GetWeaponState(npcid);
509608
* <seealso name="NPC_AimAt" />
510609
* <seealso name="NPC_SetWeapon" />
511610
*/
512-
native NPC_Shoot(npcid, weapon, hitId, hitType, Float:endPointX, Float:endPointY, Float:endPointZ, Float:offsetX, Float:offsetY, Float:offsetZ, bool:isHit, NPC_ENTITY_CHECK:checkInBetweenFlags = NPC_ENTITY_CHECK_ALL);
611+
native NPC_Shoot(npcid, WEAPON:weaponid, hitId, hitType, Float:endPointX, Float:endPointY, Float:endPointZ, Float:offsetX, Float:offsetY, Float:offsetZ, bool:isHit, NPC_ENTITY_CHECK:checkInBetweenFlags = NPC_ENTITY_CHECK_ALL);
513612

514613
/**
515614
* <library>omp_npc</library>
@@ -541,55 +640,98 @@ native bool:NPC_IsAiming(npcid);
541640
*/
542641
native bool:NPC_IsAimingAtPlayer(npcid, playerid);
543642

643+
/**
644+
* <library>omp_npc</library>
645+
* <summary>Gets the ID of the player that an NPC is currently aiming at.</summary>
646+
* <param name="npcid">The ID of the NPC</param>
647+
* <returns>Returns the ID of the player being aimed at, or INVALID_PLAYER_ID if not aiming at anyone.</returns>
648+
* <seealso name="NPC_AimAtPlayer" />
649+
* <seealso name="NPC_IsAiming" />
650+
* <seealso name="NPC_GetPlayerMovingTo" />
651+
*/
652+
native NPC_GetPlayerAimingAt(npcid);
653+
654+
/**
655+
* <library>omp_npc</library>
656+
* <summary>Gets the ID of the player that an NPC is currently moving toward.</summary>
657+
* <param name="npcid">The ID of the NPC</param>
658+
* <returns>Returns the ID of the player being moved toward, or INVALID_PLAYER_ID if not moving toward anyone.</returns>
659+
* <seealso name="NPC_MoveToPlayer" />
660+
* <seealso name="NPC_IsMovingToPlayer" />
661+
* <seealso name="NPC_GetPlayerAimingAt" />
662+
*/
663+
native NPC_GetPlayerMovingTo(npcid);
664+
665+
/**
666+
* <library>omp_npc</library>
667+
*/
668+
native NPC_SetWeaponAccuracy(npcid, WEAPON:weaponid, Float:accuracy);
669+
670+
/**
671+
* <library>omp_npc</library>
672+
*/
673+
native Float:NPC_GetWeaponAccuracy(npcid, WEAPON:weaponid);
674+
544675
/**
545676
* <library>omp_npc</library>
546677
*/
547-
native NPC_SetWeaponAccuracy(npcid, weaponid, Float:accuracy);
678+
native NPC_SetWeaponReloadTime(npcid, WEAPON:weaponid, time);
548679

549680
/**
550681
* <library>omp_npc</library>
551682
*/
552-
native Float:NPC_GetWeaponAccuracy(npcid, weaponid);
683+
native NPC_GetWeaponReloadTime(npcid, WEAPON:weaponid);
553684

554685
/**
555686
* <library>omp_npc</library>
556687
*/
557-
native NPC_SetWeaponReloadTime(npcid, weaponid, time);
688+
native NPC_GetWeaponActualReloadTime(npcid, WEAPON:weaponid);
558689

559690
/**
560691
* <library>omp_npc</library>
561692
*/
562-
native NPC_GetWeaponReloadTime(npcid, weaponid);
693+
native NPC_SetWeaponShootTime(npcid, WEAPON:weaponid, time);
563694

564695
/**
565696
* <library>omp_npc</library>
566697
*/
567-
native NPC_GetWeaponActualReloadTime(npcid, weaponid);
698+
native NPC_GetWeaponShootTime(npcid, WEAPON:weaponid);
568699

569700
/**
570701
* <library>omp_npc</library>
571702
*/
572-
native NPC_SetWeaponShootTime(npcid, weaponid, time);
703+
native NPC_SetWeaponClipSize(npcid, WEAPON:weaponid, size);
573704

574705
/**
575706
* <library>omp_npc</library>
576707
*/
577-
native NPC_GetWeaponShootTime(npcid, weaponid);
708+
native NPC_GetWeaponClipSize(npcid, WEAPON:weaponid);
578709

579710
/**
580711
* <library>omp_npc</library>
581712
*/
582-
native NPC_SetWeaponClipSize(npcid, weaponid, size);
713+
native NPC_GetWeaponActualClipSize(npcid, WEAPON:weaponid);
583714

584715
/**
585716
* <library>omp_npc</library>
717+
* <summary>Sets the weapon skill level for an NPC.</summary>
718+
* <param name="npcid">The ID of the NPC</param>
719+
* <param name="skill">The weapon skill type (WEAPONSKILL)</param>
720+
* <param name="level">The skill level to set (0-999)</param>
721+
* <returns>Returns true on success, false on failure.</returns>
722+
* <seealso name="NPC_GetWeaponSkillLevel" />
586723
*/
587-
native NPC_GetWeaponClipSize(npcid, weaponid);
724+
native bool:NPC_SetWeaponSkillLevel(npcid, WEAPONSKILL:skill, level);
588725

589726
/**
590727
* <library>omp_npc</library>
728+
* <summary>Gets the weapon skill level of an NPC.</summary>
729+
* <param name="npcid">The ID of the NPC</param>
730+
* <param name="skill">The weapon skill type (WEAPONSKILL)</param>
731+
* <returns>Returns the weapon skill level (0-999), or UNKNOWN_WEAPONSKILL on failure.</returns>
732+
* <seealso name="NPC_SetWeaponSkillLevel" />
591733
*/
592-
native NPC_GetWeaponActualClipSize(npcid, weaponid);
734+
native NPC_GetWeaponSkillLevel(npcid, WEAPONSKILL:skill);
593735

594736
/*
595737
native # Vehicles();
@@ -601,7 +743,7 @@ native
601743
/**
602744
* <library>omp_npc</library>
603745
*/
604-
native bool:NPC_EnterVehicle(npcid, vehicleid, seatid, NPC_MOVE_TYPE:moveType);
746+
native bool:NPC_EnterVehicle(npcid, vehicleid, seatid, NPC_MOVE_TYPE:moveType = NPC_MOVE_TYPE_JOG);
605747

606748
/**
607749
* <library>omp_npc</library>
@@ -738,7 +880,7 @@ native NPC_ClearAnimations(npcid);
738880
/**
739881
* <library>omp_npc</library>
740882
*/
741-
native NPC_SetSpecialAction(npcid, action);
883+
native NPC_SetSpecialAction(npcid, SPECIAL_ACTION:actionid);
742884

743885
/**
744886
* <library>omp_npc</library>
@@ -1065,12 +1207,12 @@ forward OnNPCWeaponStateChange(npcid, newState, oldState);
10651207
/**
10661208
* <library>omp_npc</library>
10671209
*/
1068-
forward OnNPCTakeDamage(npcid, damagerid, Float:damage, WEAPON:weapon, bodypart);
1210+
forward OnNPCTakeDamage(npcid, issuerid, Float:amount, WEAPON:weaponid, bodypart);
10691211

10701212
/**
10711213
* <library>omp_npc</library>
10721214
*/
1073-
forward OnNPCGiveDamage(npcid, damagedid, Float:damage, WEAPON:weapon, bodypart);
1215+
forward OnNPCGiveDamage(npcid, damagedid, Float:amount, WEAPON:weaponid, bodypart);
10741216

10751217
/**
10761218
* <library>omp_npc</library>

0 commit comments

Comments
 (0)