Skip to content

Commit 8a0ecc0

Browse files
committed
Init stuff for pathfinding, breaking changes for GoTo functions
1 parent 5b2f835 commit 8a0ecc0

File tree

12 files changed

+169
-43
lines changed

12 files changed

+169
-43
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is a fork of the [original repository](https://github.com/OrMisicL/FCNPC) b
1010

1111
If you encounter a bug or a crash, create an issue in the [issues section](../../issues) with your **crashlog** and your **Pawn script**.
1212

13-
For more elaborate discussions see the [forum thread](http://forum.sa-mp.com/showthread.php?t=428066), or the [Russian forum thread](http://forum.sa-mp.com/showthread.php?t=602965).
13+
For more elaborate discussions see the [forum thread](http://forum.sa-mp.com/showthread.php?t=428066) *(isn't working now, but we hope)*, or the [Russian forum thread](http://forum.sa-mp.com/showthread.php?t=602965).
1414

1515
See the [wiki](../../wiki) for documentation.
1616

@@ -82,6 +82,12 @@ Constants
8282
#define FCNPC_MOVE_MODE_AUTO (-1)
8383
#define FCNPC_MOVE_MODE_NONE (0)
8484
#define FCNPC_MOVE_MODE_MAPANDREAS (1)
85+
#define FCNPC_MOVE_MODE_COLANDREAS (2)
86+
87+
#define FCNPC_MOVE_PATHFINDING_AUTO (-1)
88+
#define FCNPC_MOVE_PATHFINDING_NONE (0)
89+
#define FCNPC_MOVE_PATHFINDING_Z (1)
90+
#define FCNPC_MOVE_PATHFINDING_RAYCAST (2)
8591
8692
#define FCNPC_MOVE_SPEED_AUTO (-1.0)
8793
#define FCNPC_MOVE_SPEED_WALK (0.1552086)
@@ -143,6 +149,8 @@ native FCNPC_SetTickRate(rate);
143149
native FCNPC_GetTickRate();
144150
native FCNPC_UseMoveMode(mode, bool:use = true);
145151
native bool:FCNPC_IsMoveModeUsed(mode);
152+
native FCNPC_UseMovePathfinding(pathfinding, bool:use = true);
153+
native bool:FCNPC_IsMovePathfindingUsed(pathfinding);
146154
native FCNPC_UseCrashLog(bool:use = true);
147155
native bool:FCNPC_IsCrashLogUsed();
148156
@@ -245,8 +253,8 @@ native bool:FCNPC_IsReloadingUsed(npcid);
245253
native FCNPC_UseInfiniteAmmo(npcid, bool:use = true);
246254
native bool:FCNPC_IsInfiniteAmmoUsed(npcid);
247255
248-
native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, stopdelay = 250);
249-
native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, Float:dist_check = 1.5, stopdelay = 250);
256+
native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, stopdelay = 250);
257+
native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, Float:dist_check = 1.5, stopdelay = 250);
250258
native FCNPC_Stop(npcid);
251259
native bool:FCNPC_IsMoving(npcid);
252260
native bool:FCNPC_IsMovingAtPlayer(npcid, playerid);
@@ -331,7 +339,7 @@ native FCNPC_RemovePointFromMovePath(pathid, pointid);
331339
native bool:FCNPC_IsValidMovePathPoint(pathid, pointid);
332340
native FCNPC_GetMovePathPoint(pathid, pointid, &Float:x, &Float:y, &Float:z);
333341
native FCNPC_GetNumberMovePathPoint(pathid);
334-
native FCNPC_GoByMovePath(npcid, pathid, pointid = 0, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0);
342+
native FCNPC_GoByMovePath(npcid, pathid, pointid = 0, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0);
335343
336344
native FCNPC_SetMoveMode(npcid, mode);
337345
native FCNPC_GetMoveMode(npcid);
@@ -346,4 +354,9 @@ native FCNPC_HideInTabListForPlayer(npcid, forplayerid);
346354
For some reasons FCNPC includes some another plugins. You don't need to use this plugins separately.
347355

348356
## MapAndreas
349-
http://forum.sa-mp.com/showthread.php?t=275492
357+
358+
MapAndreas 1.2.1 included.
359+
360+
## ColAndreas
361+
362+
Latest ColAndreas version included.

sampsvr_files/FCNPC.inc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public FCNPC_IncludeVersion = FCNPC_INCLUDE_VERSION;
4747
#define FCNPC_MOVE_MODE_MAPANDREAS (1)
4848
#define FCNPC_MOVE_MODE_COLANDREAS (2)
4949

50+
#define FCNPC_MOVE_PATHFINDING_AUTO (-1)
51+
#define FCNPC_MOVE_PATHFINDING_NONE (0)
52+
#define FCNPC_MOVE_PATHFINDING_Z (1)
53+
#define FCNPC_MOVE_PATHFINDING_RAYCAST (2)
54+
5055
#define FCNPC_MOVE_SPEED_AUTO (-1.0)
5156
#define FCNPC_MOVE_SPEED_WALK (0.1552086)
5257
#define FCNPC_MOVE_SPEED_RUN (0.56444)
@@ -99,6 +104,8 @@ native FCNPC_SetTickRate(rate);
99104
native FCNPC_GetTickRate();
100105
native FCNPC_UseMoveMode(mode, bool:use = true);
101106
native bool:FCNPC_IsMoveModeUsed(mode);
107+
native FCNPC_UseMovePathfinding(pathfinding, bool:use = true);
108+
native bool:FCNPC_IsMovePathfindingUsed(pathfinding);
102109
native FCNPC_UseCrashLog(bool:use = true);
103110
native bool:FCNPC_IsCrashLogUsed();
104111

@@ -201,8 +208,8 @@ native bool:FCNPC_IsReloadingUsed(npcid);
201208
native FCNPC_UseInfiniteAmmo(npcid, bool:use = true);
202209
native bool:FCNPC_IsInfiniteAmmoUsed(npcid);
203210

204-
native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, stopdelay = 250);
205-
native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, Float:dist_check = 1.5, stopdelay = 250);
211+
native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, stopdelay = 250);
212+
native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, Float:dist_check = 1.5, stopdelay = 250);
206213
native FCNPC_Stop(npcid);
207214
native bool:FCNPC_IsMoving(npcid);
208215
native bool:FCNPC_IsMovingAtPlayer(npcid, playerid);
@@ -293,7 +300,7 @@ native FCNPC_RemovePointFromMovePath(pathid, pointid);
293300
native bool:FCNPC_IsValidMovePathPoint(pathid, pointid);
294301
native FCNPC_GetMovePathPoint(pathid, pointid, &Float:x, &Float:y, &Float:z);
295302
native FCNPC_GetNumberMovePathPoint(pathid);
296-
native FCNPC_GoByMovePath(npcid, pathid, pointid = 0, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0);
303+
native FCNPC_GoByMovePath(npcid, pathid, pointid = 0, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0);
297304

298305
native FCNPC_SetMoveMode(npcid, mode);
299306
native FCNPC_GetMoveMode(npcid);

src/CPlayerData.cpp

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ CPlayerData::CPlayerData(WORD playerId, char *szName)
6868
m_iMovePoint = 0;
6969
m_iMoveType = MOVE_TYPE_AUTO;
7070
m_iMoveMode = MOVE_MODE_AUTO;
71+
m_iMovePathfinding = MOVE_PATHFINDING_AUTO;
7172
m_fMoveRadius = 0.0f;
7273
m_bMoveSetAngle = false;
7374
m_fMoveSpeed = MOVE_SPEED_AUTO;
@@ -1605,7 +1606,7 @@ void CPlayerData::GetKeys(WORD *pwUDAnalog, WORD *pwLRAnalog, DWORD *pdwKeys)
16051606
*pdwKeys = m_pPlayer->dwKeys;
16061607
}
16071608

1608-
bool CPlayerData::GoTo(const CVector &vecPoint, int iType, int iMode, float fRadius, bool bSetAngle, float fSpeed, float fDistOffset, DWORD dwStopDelay)
1609+
bool CPlayerData::GoTo(const CVector &vecPoint, int iType, int iMode, int iPathfinding, float fRadius, bool bSetAngle, float fSpeed, float fDistOffset, DWORD dwStopDelay)
16091610
{
16101611
// Validate the movement
16111612
if (iType == MOVE_TYPE_AUTO && GetState() == PLAYER_STATE_DRIVER) {
@@ -1676,15 +1677,16 @@ bool CPlayerData::GoTo(const CVector &vecPoint, int iType, int iMode, float fRad
16761677
m_bMoving = true;
16771678
// Save the data
16781679
SetMoveMode(iMode);
1680+
SetMovePathfinding(iPathfinding);
16791681
m_iMoveType = iType;
16801682
m_dwMoveStopDelay = dwStopDelay;
16811683
return true;
16821684
}
16831685

1684-
bool CPlayerData::GoToPlayer(WORD wPlayerId, int iType, int iMode, float fRadius, bool bSetAngle, float fSpeed, float fDistOffset, float fDistCheck, DWORD dwStopDelay)
1686+
bool CPlayerData::GoToPlayer(WORD wPlayerId, int iType, int iMode, int iPathfinding, float fRadius, bool bSetAngle, float fSpeed, float fDistOffset, float fDistCheck, DWORD dwStopDelay)
16851687
{
16861688
CVector vecPos = pNetGame->pPlayerPool->pPlayer[wPlayerId]->vecPosition;
1687-
if (GoTo(vecPos, iType, iMode, fRadius, bSetAngle, fSpeed, fDistOffset)) {
1689+
if (GoTo(vecPos, iType, iMode, iPathfinding, fRadius, bSetAngle, fSpeed, fDistOffset)) {
16881690
m_wMoveId = wPlayerId;
16891691
m_vecMovePlayerPosition = vecPos;
16901692
m_fDistCheck = fDistCheck;
@@ -1694,10 +1696,10 @@ bool CPlayerData::GoToPlayer(WORD wPlayerId, int iType, int iMode, float fRadius
16941696
return false;
16951697
}
16961698

1697-
bool CPlayerData::GoByMovePath(int iPathId, int iPointId, int iType, int iMode, float fRadius, bool bSetAngle, float fSpeed, float fDistOffset)
1699+
bool CPlayerData::GoByMovePath(int iPathId, int iPointId, int iType, int iMode, int iPathfinding, float fRadius, bool bSetAngle, float fSpeed, float fDistOffset)
16981700
{
16991701
CVector *vecPos = pServer->GetMovePath()->GetPoint(iPathId, 0);
1700-
if (GoTo(*vecPos, iType, iMode, fRadius, bSetAngle, fSpeed, fDistOffset)) {
1702+
if (GoTo(*vecPos, iType, iMode, iPathfinding, fRadius, bSetAngle, fSpeed, fDistOffset)) {
17011703
m_iMovePath = iPathId;
17021704
m_iMovePoint = iPointId;
17031705
return true;
@@ -1774,6 +1776,7 @@ void CPlayerData::StopMoving()
17741776
m_iMovePath = INVALID_MOVEPATH_ID;
17751777
m_iMovePoint = 0;
17761778
m_iMoveMode = MOVE_MODE_AUTO;
1779+
m_iMovePathfinding = MOVE_PATHFINDING_AUTO;
17771780
// Reset the player data
17781781
SetVelocity(CVector(0.0f, 0.0f, 0.0f));
17791782
SetTrainSpeed(0.0f);
@@ -2146,7 +2149,7 @@ bool CPlayerData::EnterVehicle(WORD wVehicleId, BYTE byteSeatId, int iType)
21462149
CFunctions::PlayerEnterVehicle(m_pPlayer, m_wVehicleToEnter, m_byteSeatToEnter);
21472150
} else {
21482151
// Go to the vehicle
2149-
GoTo(vecDestination, iType, GetMoveMode());
2152+
GoTo(vecDestination, iType, GetMoveMode(), GetMovePathfinding());
21502153
}
21512154

21522155
return true;
@@ -2518,7 +2521,7 @@ bool CPlayerData::PlayNode(int iNodeId, int iMoveType, int iMode, float fRadius,
25182521
UpdateNodePoint(m_wNodePoint);
25192522

25202523
m_pNode->GetPosition(&vecPos);
2521-
GoTo(vecPos, iMoveType, iMode, fRadius, bSetAngle, fSpeed);
2524+
GoTo(vecPos, iMoveType, iMode, MOVE_PATHFINDING_NONE, fRadius, bSetAngle, fSpeed);
25222525
return true;
25232526
}
25242527

@@ -2569,7 +2572,7 @@ void CPlayerData::ResumePlayingNode()
25692572
}
25702573

25712574
m_bIsPlayingNodePaused = false;
2572-
GoTo(m_vecNodeLastPos, m_iNodeMoveType, m_iNodeMoveMode, m_fNodeMoveRadius, m_bNodeMoveSetAngle, m_fNodeMoveSpeed);
2575+
GoTo(m_vecNodeLastPos, m_iNodeMoveType, m_iNodeMoveMode, MOVE_PATHFINDING_NONE, m_fNodeMoveRadius, m_bNodeMoveSetAngle, m_fNodeMoveSpeed);
25732576
}
25742577

25752578
bool CPlayerData::IsPlayingNodePaused()
@@ -2641,6 +2644,32 @@ int CPlayerData::GetMoveMode()
26412644
return m_iMoveMode;
26422645
}
26432646

2647+
bool CPlayerData::SetMovePathfinding(int iMovePathfinding)
2648+
{
2649+
if (iMovePathfinding == MOVE_PATHFINDING_AUTO) {
2650+
if (pServer->IsMovePathfindingEnabled(MOVE_PATHFINDING_RAYCAST)) {
2651+
m_iMovePathfinding = MOVE_PATHFINDING_RAYCAST;
2652+
} else if (pServer->IsMovePathfindingEnabled(MOVE_PATHFINDING_Z)) {
2653+
m_iMovePathfinding = MOVE_PATHFINDING_Z;
2654+
} else {
2655+
m_iMovePathfinding = MOVE_PATHFINDING_NONE;
2656+
}
2657+
} else {
2658+
if (!pServer->IsMovePathfindingEnabled(iMovePathfinding)) {
2659+
m_iMovePathfinding = MOVE_PATHFINDING_NONE;
2660+
return false;
2661+
}
2662+
2663+
m_iMovePathfinding = iMovePathfinding;
2664+
}
2665+
return true;
2666+
}
2667+
2668+
int CPlayerData::GetMovePathfinding()
2669+
{
2670+
return m_iMovePathfinding;
2671+
}
2672+
26442673
void CPlayerData::SetMinHeightPosCall(float fHeight)
26452674
{
26462675
m_fMinHeightPos = fHeight;

src/CPlayerData.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ class CPlayerData
132132
void ApplyAnimation(char *szAnimationLib, char *szAnimationName, float fDelta, bool bLoop, bool bLockX, bool bLockY, bool bFreeze, int iTime);
133133
void ClearAnimations();
134134

135-
bool GoTo(const CVector &vecPoint, int iType, int iMode, float fRadius = 0.0f, bool bSetAngle = true, float fSpeed = -1.0f, float fDistOffset = 0.0f, DWORD dwStopDelay = 250);
136-
bool GoToPlayer(WORD wPlayerId, int iType, int iMode, float fRadius = 0.0f, bool bSetAngle = true, float fSpeed = -1.0f, float fDistOffset = 0.0f, float fDistCheck = 1.5f, DWORD dwStopDelay = 250);
137-
bool GoByMovePath(int iPathId, int iPointId, int iType, int iMode, float fRadius = 0.0f, bool bSetAngle = true, float fSpeed = -1.0f, float fDistOffset = 0.0f);
135+
bool GoTo(const CVector &vecPoint, int iType, int iMode, int iPathfinding, float fRadius = 0.0f, bool bSetAngle = true, float fSpeed = -1.0f, float fDistOffset = 0.0f, DWORD dwStopDelay = 250);
136+
bool GoToPlayer(WORD wPlayerId, int iType, int iMode, int iPathfinding, float fRadius = 0.0f, bool bSetAngle = true, float fSpeed = -1.0f, float fDistOffset = 0.0f, float fDistCheck = 1.5f, DWORD dwStopDelay = 250);
137+
bool GoByMovePath(int iPathId, int iPointId, int iType, int iMode, int iPathfinding, float fRadius = 0.0f, bool bSetAngle = true, float fSpeed = -1.0f, float fDistOffset = 0.0f);
138138
void UpdateMovingData(CVector vecDestination, float fRadius, bool bSetAngle, float fSpeed, float fDistOffset);
139139
void GetDestination(CVector *pvecDestination);
140140
void StopMoving();
@@ -214,6 +214,8 @@ class CPlayerData
214214

215215
bool SetMoveMode(int iMoveMode);
216216
int GetMoveMode();
217+
bool SetMovePathfinding(int iMovePathfinding);
218+
int GetMovePathfinding();
217219
void SetMinHeightPosCall(float fHeight);
218220
float GetMinHeightPosCall();
219221

@@ -284,6 +286,7 @@ class CPlayerData
284286
int m_iMovePoint;
285287
int m_iMoveType;
286288
int m_iMoveMode;
289+
int m_iMovePathfinding;
287290
float m_fMoveRadius;
288291
bool m_bMoveSetAngle;
289292
float m_fMoveSpeed;

src/CServer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ CServer::CServer(eSAMPVersion version)
3434
for (int i = MOVE_MODE_NONE + 1; i < MOVE_MODE_SIZE; i++) {
3535
m_bMoveModeEnabled[i] = true;
3636
}
37+
// init pathfinding mode
38+
for (int i = MOVE_PATHFINDING_NONE + 1; i < MOVE_PATHFINDING_SIZE; i++) {
39+
m_bMovePathfindingEnabled[i] = true;
40+
}
3741
// Initialize random seed
3842
srand(static_cast<unsigned int>(time(NULL)));
3943
}
@@ -46,6 +50,7 @@ CServer::~CServer()
4650
SAFE_DELETE(m_pMovePath);
4751
SAFE_DELETE(m_pRecordManager);
4852
SAFE_DELETE(m_pMapAndreas);
53+
SAFE_DELETE(m_pColAndreas);
4954
}
5055

5156
BYTE CServer::Initialize(AMX *pAMX)
@@ -258,6 +263,16 @@ bool CServer::IsMoveModeEnabled(int iMoveMode)
258263
return m_bMoveModeEnabled[iMoveMode];
259264
}
260265

266+
void CServer::ToggleMovePathfinding(int iMovePathfinding, bool bIsEnabled)
267+
{
268+
m_bMovePathfindingEnabled[iMovePathfinding] = bIsEnabled;
269+
}
270+
271+
bool CServer::IsMovePathfindingEnabled(int iMovePathfinding)
272+
{
273+
return m_bMovePathfindingEnabled[iMovePathfinding];
274+
}
275+
261276
bool CServer::IsVehicleSeatOccupied(WORD wPlayerId, WORD wVehicleId, BYTE byteSeatId)
262277
{
263278
WORD wSeatPlayerId = GetVehicleSeatPlayerId(wVehicleId, byteSeatId);

src/CServer.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class CServer
5353

5454
void ToggleMoveMode(int iMoveMode, bool bIsEnabled);
5555
bool IsMoveModeEnabled(int iMoveMode);
56+
void ToggleMovePathfinding(int iMovePathfinding, bool bIsEnabled);
57+
bool IsMovePathfindingEnabled(int iMovePathfinding);
5658

5759
bool IsVehicleSeatOccupied(WORD wPlayerId, WORD wVehicleId, BYTE byteSeatId);
5860
WORD GetVehicleSeatPlayerId(WORD wVehicleId, BYTE byteSeatId);
@@ -73,6 +75,7 @@ class CServer
7375
DWORD m_dwUpdateRate;
7476
bool m_bCrashLogCreation;
7577
bool m_bMoveModeEnabled[MOVE_MODE_SIZE];
78+
bool m_bMovePathfindingEnabled[MOVE_PATHFINDING_SIZE];
7679

7780
int m_iTicks;
7881
int m_iTickRate;

src/Common.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ enum MOVE_MODE {
7777
MOVE_MODE_COLANDREAS,
7878
MOVE_MODE_SIZE,
7979
};
80+
// Pathfinding mode
81+
enum MOVE_PATHFINDING {
82+
MOVE_PATHFINDING_AUTO = -1,
83+
MOVE_PATHFINDING_NONE = 0,
84+
MOVE_PATHFINDING_Z,
85+
MOVE_PATHFINDING_RAYCAST,
86+
MOVE_PATHFINDING_SIZE,
87+
};
8088
// Moving velocity
8189
#define MOVE_SPEED_AUTO -1.0f
8290
#define MOVE_SPEED_WALK 0.1552086f

src/FCNPC.inc.in

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public FCNPC_IncludeVersion = FCNPC_INCLUDE_VERSION;
4747
#define FCNPC_MOVE_MODE_MAPANDREAS (1)
4848
#define FCNPC_MOVE_MODE_COLANDREAS (2)
4949

50+
#define FCNPC_MOVE_PATHFINDING_AUTO (-1)
51+
#define FCNPC_MOVE_PATHFINDING_NONE (0)
52+
#define FCNPC_MOVE_PATHFINDING_Z (1)
53+
#define FCNPC_MOVE_PATHFINDING_RAYCAST (2)
54+
5055
#define FCNPC_MOVE_SPEED_AUTO (-1.0)
5156
#define FCNPC_MOVE_SPEED_WALK (0.1552086)
5257
#define FCNPC_MOVE_SPEED_RUN (0.56444)
@@ -99,6 +104,8 @@ native FCNPC_SetTickRate(rate);
99104
native FCNPC_GetTickRate();
100105
native FCNPC_UseMoveMode(mode, bool:use = true);
101106
native bool:FCNPC_IsMoveModeUsed(mode);
107+
native FCNPC_UseMovePathfinding(pathfinding, bool:use = true);
108+
native bool:FCNPC_IsMovePathfindingUsed(pathfinding);
102109
native FCNPC_UseCrashLog(bool:use = true);
103110
native bool:FCNPC_IsCrashLogUsed();
104111

@@ -201,8 +208,8 @@ native bool:FCNPC_IsReloadingUsed(npcid);
201208
native FCNPC_UseInfiniteAmmo(npcid, bool:use = true);
202209
native bool:FCNPC_IsInfiniteAmmoUsed(npcid);
203210

204-
native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, stopdelay = 250);
205-
native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, Float:dist_check = 1.5, stopdelay = 250);
211+
native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, stopdelay = 250);
212+
native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0, Float:dist_check = 1.5, stopdelay = 250);
206213
native FCNPC_Stop(npcid);
207214
native bool:FCNPC_IsMoving(npcid);
208215
native bool:FCNPC_IsMovingAtPlayer(npcid, playerid);
@@ -293,7 +300,7 @@ native FCNPC_RemovePointFromMovePath(pathid, pointid);
293300
native bool:FCNPC_IsValidMovePathPoint(pathid, pointid);
294301
native FCNPC_GetMovePathPoint(pathid, pointid, &Float:x, &Float:y, &Float:z);
295302
native FCNPC_GetNumberMovePathPoint(pathid);
296-
native FCNPC_GoByMovePath(npcid, pathid, pointid = 0, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0);
303+
native FCNPC_GoByMovePath(npcid, pathid, pointid = 0, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, mode = FCNPC_MOVE_MODE_AUTO, pathfinding = FCNPC_MOVE_PATHFINDING_AUTO, Float:radius = 0.0, bool:set_angle = true, Float:min_distance = 0.0);
297304

298305
native FCNPC_SetMoveMode(npcid, mode);
299306
native FCNPC_GetMoveMode(npcid);

src/Main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ AMX_NATIVE_INFO PluginNatives[] = {
135135
{ "FCNPC_GetTickRate", CNatives::FCNPC_GetTickRate },
136136
{ "FCNPC_UseMoveMode", CNatives::FCNPC_UseMoveMode },
137137
{ "FCNPC_IsMoveModeUsed", CNatives::FCNPC_IsMoveModeUsed },
138+
{ "FCNPC_UseMovePathfinding", CNatives::FCNPC_UseMovePathfinding },
139+
{ "FCNPC_IsMovePathfindingUsed", CNatives::FCNPC_IsMovePathfindingUsed },
138140
{ "FCNPC_TriggerWeaponShot", CNatives::FCNPC_TriggerWeaponShot },
139141
{ "FCNPC_UseCrashLog", CNatives::FCNPC_UseCrashLog },
140142
{ "FCNPC_IsCrashLogUsed", CNatives::FCNPC_IsCrashLogUsed },

0 commit comments

Comments
 (0)