Skip to content

Commit 7e47c96

Browse files
Merge pull request #305 from MiranDMC/master
Added CTaskComplexSeekEntityMove class
2 parents 6125b97 + c6b1c44 commit 7e47c96

7 files changed

Lines changed: 143 additions & 44 deletions

File tree

plugin_sa/game_sa/CPed.h

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,28 @@
77
#pragma once
88

99
#include "PluginBase.h"
10-
#include "ePedType.h"
11-
#include "CPhysical.h"
10+
#include "AnimBlendFrameData.h"
1211
#include "CAEPedAudioEntity.h"
1312
#include "CAEPedSpeechAudioEntity.h"
1413
#include "CAEWeaponAudioEntity.h"
15-
#include "CPedIntelligence.h"
16-
#include "CPlayerData.h"
17-
#include "AnimBlendFrameData.h"
14+
#include "CAnimBlendAssociation.h"
15+
#include "CFire.h"
1816
#include "CPedAcquaintance.h"
1917
#include "CPedIK.h"
20-
#include "CWeapon.h"
18+
#include "CPedIntelligence.h"
19+
#include "CPhysical.h"
20+
#include "CPlayerData.h"
2121
#include "CVector2D.h"
22-
#include "eWeaponType.h"
22+
#include "CWeapon.h"
23+
#include "eMoveState.h"
2324
#include "ePedState.h"
24-
#include "CAnimBlendAssociation.h"
25-
#include "CFire.h"
25+
#include "ePedType.h"
26+
#include "eWeaponType.h"
2627

2728
enum PLUGIN_API ePedStats {
2829

2930
};
3031

31-
enum PLUGIN_API eMoveState {
32-
PEDMOVE_NONE = 0,
33-
PEDMOVE_STILL,
34-
PEDMOVE_TURN_L,
35-
PEDMOVE_TURN_R,
36-
PEDMOVE_WALK,
37-
PEDMOVE_JOG,
38-
PEDMOVE_RUN,
39-
PEDMOVE_SPRINT
40-
};
41-
4232
enum PLUGIN_API eFightingStyle : char
4333
{
4434
STYLE_STANDARD = 4,

plugin_sa/game_sa/CTask.h

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,32 @@
55
Do not delete this comment block. Respect others' work!
66
*/
77
#pragma once
8-
98
#include "PluginBase.h"
9+
#include "eAbortPriority.h"
1010
#include "eTaskType.h"
1111

12-
enum eAbortPriority
13-
{
14-
ABORT_PRIORITY_LEISURE = 0,
15-
ABORT_PRIORITY_URGENT,
16-
ABORT_PRIORITY_IMMEDIATE
17-
};
12+
class CEvent;
13+
class CPed;
1814

1915
class PLUGIN_API CTask {
20-
CTask() = delete;
2116
protected:
2217
CTask(plugin::dummy_func_t) {}
18+
CTask() = delete;
19+
2320
public:
24-
class CTask *m_pParentTask;
21+
CTask* m_pParentTask;
2522

26-
void *operator new(unsigned int size);
27-
void operator delete(void *object);
23+
void* operator new(unsigned int size);
24+
void operator delete(void* object);
2825

2926
virtual ~CTask() {}
30-
virtual class CTask *Clone();//=0
31-
virtual class CTask *GetSubTask();//=0
32-
virtual bool IsSimple();//=0
33-
virtual eTaskType GetId();//=0
34-
virtual void StopTimer(class CEvent *_event);
35-
virtual bool MakeAbortable(class CPed *ped, eAbortPriority priority, class CEvent *_event);//=0
27+
virtual class CTask* Clone();
28+
virtual class CTask* GetSubTask();
29+
virtual bool IsSimple();
30+
virtual eTaskType GetId();
31+
virtual void StopTimer(CEvent* event);
32+
virtual bool MakeAbortable(CPed* ped, eAbortPriority priority, CEvent* event);
3633
};
3734

38-
VALIDATE_SIZE(CTask, 8);
35+
VALIDATE_OFFSET(CTask, m_pParentTask, 0x4);
36+
VALIDATE_SIZE(CTask, 0x8);

plugin_sa/game_sa/CTaskComplex.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
class PLUGIN_API CTaskComplex : public CTask {
1313
protected:
1414
CTaskComplex(plugin::dummy_func_t a) : CTask(a) {}
15+
1516
public:
17+
CTask* m_pSubTask;
18+
1619
CTaskComplex();
17-
CTask *m_pSubTask;
1820

19-
// vtable
20-
virtual void SetSubTask(CTask *subTask);
21-
virtual CTask *CreateNextSubTask(class CPed *ped);//=0
22-
virtual CTask *CreateFirstSubTask(class CPed *ped);//=0
23-
virtual CTask *ControlSubTask(class CPed *ped);//=0
21+
// vtable
22+
virtual void SetSubTask(CTask* subTask);
23+
virtual CTask* CreateNextSubTask(CPed* ped);
24+
virtual CTask* CreateFirstSubTask(CPed* ped);
25+
virtual CTask* ControlSubTask(CPed* ped);
2426
};
2527

28+
VALIDATE_OFFSET(CTaskComplex, m_pSubTask, 0x8);
2629
VALIDATE_SIZE(CTaskComplex, 0xC);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
Plugin-SDK (Grand Theft Auto San Andreas) source file
3+
Authors: GTA Community. See more here
4+
https://github.com/DK22Pac/plugin-sdk
5+
Do not delete this comment block. Respect others' work!
6+
*/
7+
#include "CTaskComplexSeekEntityMove.h"
8+
9+
CTaskComplexSeekEntityMove::CTaskComplexSeekEntityMove(CEntity* entity,
10+
uint32_t time, uint32_t scanInterval,
11+
float maxEntityDist2D, float moveStateRadius, float followNodeThresholdHeightChange,
12+
bool playTiredAnim, bool faceEntityWhenDone)
13+
{
14+
plugin::CallMethod<0x46AC10, CTaskComplexSeekEntityMove*, CEntity*, uint32_t, uint32_t, float, float, float, bool, bool>
15+
(this, entity, time, scanInterval, maxEntityDist2D, moveStateRadius, followNodeThresholdHeightChange, playTiredAnim, faceEntityWhenDone);
16+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Plugin-SDK (Grand Theft Auto San Andreas) header file
3+
Authors: GTA Community. See more here
4+
https://github.com/DK22Pac/plugin-sdk
5+
Do not delete this comment block. Respect others' work!
6+
*/
7+
#pragma once
8+
#include "PluginBase.h"
9+
#include "CTaskComplex.h"
10+
#include "CTaskTimer.h"
11+
#include "eMoveState.h"
12+
13+
class CEntity;
14+
15+
class PLUGIN_API CTaskComplexSeekEntityMove : public CTaskComplex {
16+
protected:
17+
CTaskComplexSeekEntityMove(plugin::dummy_func_t a) : CTaskComplex(a) {}
18+
19+
public:
20+
CEntity* m_entity;
21+
uint32_t m_time;
22+
uint32_t m_scanInterval;
23+
float m_maxEntityDist2D;
24+
float m_moveStateRadius;
25+
float m_minEntityDist2D;
26+
float m_followNodeThresholdHeightChange;
27+
CTaskTimer m_scanTimer;
28+
CTaskTimer m_timer;
29+
30+
// position calculator
31+
void* posCalculatorVTable; // TODO: add posCalculator classes
32+
33+
eMoveState m_moveState;
34+
bool m_playTiredAnim : 1;
35+
bool m_faceEntityWhenDone : 1;
36+
bool m_achievedSeekEntity : 1; // distance lesser than m_maxEntityDist2D
37+
bool m_trackingEntity : 1;
38+
39+
CTaskComplexSeekEntityMove(
40+
CEntity* entity, // target entity
41+
uint32_t time, // task timeout
42+
uint32_t scanInterval, // target position refresh period
43+
float maxEntityDist2D, // goal distance
44+
float moveStateRadius, // switch from run to walk
45+
float followNodeThresholdHeightChange,
46+
bool playTiredAnim, // if timeouted play tired animation
47+
bool faceEntityWhenDone);
48+
};
49+
50+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_entity, 0xC);
51+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_time, 0x10);
52+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_scanInterval, 0x14);
53+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_maxEntityDist2D, 0x18);
54+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_moveStateRadius, 0x1C);
55+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_minEntityDist2D, 0x20);
56+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_followNodeThresholdHeightChange, 0x24);
57+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_scanTimer, 0x28);
58+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_timer, 0x34);
59+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, posCalculatorVTable, 0x40);
60+
VALIDATE_OFFSET(CTaskComplexSeekEntityMove, m_moveState, 0x44);
61+
VALIDATE_SIZE(CTaskComplexSeekEntityMove, 0x4C);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
Plugin-SDK (Grand Theft Auto San Andreas) header file
3+
Authors: GTA Community. See more here
4+
https://github.com/DK22Pac/plugin-sdk
5+
Do not delete this comment block. Respect others' work!
6+
*/
7+
#pragma once
8+
9+
enum eAbortPriority {
10+
ABORT_PRIORITY_LEISURE = 0,
11+
ABORT_PRIORITY_URGENT = 1,
12+
ABORT_PRIORITY_IMMEDIATE = 2
13+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Plugin-SDK (Grand Theft Auto San Andreas) header file
3+
Authors: GTA Community. See more here
4+
https://github.com/DK22Pac/plugin-sdk
5+
Do not delete this comment block. Respect others' work!
6+
*/
7+
#pragma once
8+
9+
enum eMoveState {
10+
PEDMOVE_NONE = 0,
11+
PEDMOVE_STILL = 1,
12+
PEDMOVE_TURN_L = 2,
13+
PEDMOVE_TURN_R = 3,
14+
PEDMOVE_WALK = 4,
15+
PEDMOVE_JOG = 5,
16+
PEDMOVE_RUN = 6,
17+
PEDMOVE_SPRINT = 7
18+
};

0 commit comments

Comments
 (0)