Compare commits
2 Commits
a23057c2fd
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bfc212ab42 | |||
| 9e1577b1dc |
1
samp-npcs/NPC.cpp
Normal file
1
samp-npcs/NPC.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "NPC.h"
|
||||||
7
samp-npcs/NPC.h
Normal file
7
samp-npcs/NPC.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
class NPC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Update() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
13
samp-npcs/NPCManager.cpp
Normal file
13
samp-npcs/NPCManager.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "NPCManager.h"
|
||||||
|
|
||||||
|
NPCZone::NPCZone(float radius) {
|
||||||
|
this->radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
NPCZone::~NPCZone() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NPCZone::Update() {
|
||||||
|
this->npcs.push_back(new NPCVehicle());
|
||||||
|
}
|
||||||
23
samp-npcs/NPCManager.h
Normal file
23
samp-npcs/NPCManager.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include "NPC.h"
|
||||||
|
#include "NPCVehicle.h"
|
||||||
|
|
||||||
|
#define SPAWN_RADIUS 300
|
||||||
|
#define DESPAWN_RADIUS SPAWN_RADIUS + 100
|
||||||
|
|
||||||
|
class NPCManager
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class NPCZone {
|
||||||
|
public:
|
||||||
|
NPCZone(float radius);
|
||||||
|
~NPCZone();
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
private:
|
||||||
|
float radius;
|
||||||
|
std::vector<NPC*> npcs;
|
||||||
|
};
|
||||||
13
samp-npcs/NPCVehicle.cpp
Normal file
13
samp-npcs/NPCVehicle.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "NPCVehicle.h"
|
||||||
|
|
||||||
|
NPCVehicle::NPCVehicle() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NPCVehicle::~NPCVehicle() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NPCVehicle::Update() {
|
||||||
|
|
||||||
|
}
|
||||||
11
samp-npcs/NPCVehicle.h
Normal file
11
samp-npcs/NPCVehicle.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "NPC.h"
|
||||||
|
|
||||||
|
class NPCVehicle : public NPC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NPCVehicle();
|
||||||
|
~NPCVehicle();
|
||||||
|
void Update();
|
||||||
|
};
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ void parseNode(FILE* file, PathNode* node) {
|
|||||||
node->node = serializedNode.node;
|
node->node = serializedNode.node;
|
||||||
node->width = serializedNode.width;
|
node->width = serializedNode.width;
|
||||||
node->flood_fill = serializedNode.flood_fill;
|
node->flood_fill = serializedNode.flood_fill;
|
||||||
node->flags = serializedNode.flags;
|
node->flags = *(NodeFlags*)&serializedNode.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseNav(FILE* file, NavNode* node) {
|
void parseNav(FILE* file, NavNode* node) {
|
||||||
@@ -109,7 +109,7 @@ void parseNav(FILE* file, NavNode* node) {
|
|||||||
node->node = serializedNode.node;
|
node->node = serializedNode.node;
|
||||||
node->direction_x = serializedNode.direction_x / 100.f;
|
node->direction_x = serializedNode.direction_x / 100.f;
|
||||||
node->direction_y = serializedNode.direction_y / 100.f;
|
node->direction_y = serializedNode.direction_y / 100.f;
|
||||||
node->flags = serializedNode.flags;
|
node->flags = *(NavNodeFlags*)&serializedNode.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseLink(FILE* file, Link* link) {
|
void parseLink(FILE* file, Link* link) {
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
#define PATH "plugins/samp-npcs/Paths/"
|
#define PATH "plugins/samp-npcs/Paths/"
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(E) typedef char __static_assert_[(E)?1:-1]
|
||||||
|
#define EXPECT_SIZE(S,SIZE) STATIC_ASSERT(sizeof(S)==(SIZE))
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct SerializedHeader {
|
struct SerializedHeader {
|
||||||
unsigned int num_nodes;
|
unsigned int num_nodes;
|
||||||
@@ -49,6 +52,40 @@ struct SerializedIntersectionFlags {
|
|||||||
bool road_cross : 1;
|
bool road_cross : 1;
|
||||||
bool ped_traffic_light : 1;
|
bool ped_traffic_light : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct NodeFlags {
|
||||||
|
unsigned char link_count : 4;
|
||||||
|
unsigned char traffic_level : 2;
|
||||||
|
unsigned char roadblocks : 1;
|
||||||
|
unsigned char boats : 1;
|
||||||
|
unsigned char emergency_vehicles_only : 1;
|
||||||
|
unsigned char _unknown_D : 1;
|
||||||
|
unsigned char _unknown_E : 1;
|
||||||
|
unsigned char _unknown_F : 1;
|
||||||
|
unsigned char not_highway : 1;
|
||||||
|
unsigned char highway : 1;
|
||||||
|
unsigned char _unknown_I : 1;
|
||||||
|
unsigned char _unknown_J : 1;
|
||||||
|
unsigned char spawn_probability : 4;
|
||||||
|
unsigned char _unknown_roadblock_O : 1;
|
||||||
|
unsigned char parking : 1;
|
||||||
|
unsigned char _unknown_Q : 1;
|
||||||
|
unsigned char _unknown_R : 1;
|
||||||
|
unsigned char _unknown_S : 8;
|
||||||
|
};
|
||||||
|
EXPECT_SIZE(NodeFlags, 4);
|
||||||
|
|
||||||
|
struct NavNodeFlags {
|
||||||
|
unsigned int width : 8;
|
||||||
|
unsigned int num_left_lanes : 3;
|
||||||
|
unsigned int num_right_lanes : 3;
|
||||||
|
unsigned int traffic_lights_direction_behavior : 1;
|
||||||
|
unsigned int _unused_F : 1;
|
||||||
|
unsigned int traffic_lights_behavior : 2;
|
||||||
|
unsigned int train_crossing : 1;
|
||||||
|
unsigned int _unused_M : 13;
|
||||||
|
};
|
||||||
|
EXPECT_SIZE(NavNodeFlags, 4);
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
struct PathNode {
|
struct PathNode {
|
||||||
@@ -57,14 +94,14 @@ struct PathNode {
|
|||||||
unsigned short link, area, node;
|
unsigned short link, area, node;
|
||||||
unsigned char width;
|
unsigned char width;
|
||||||
unsigned char flood_fill;
|
unsigned char flood_fill;
|
||||||
unsigned int flags;
|
NodeFlags flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NavNode {
|
struct NavNode {
|
||||||
float position_x, position_y;
|
float position_x, position_y;
|
||||||
unsigned short area, node;
|
unsigned short area, node;
|
||||||
float direction_x, direction_y;
|
float direction_x, direction_y;
|
||||||
unsigned int flags;
|
NavNodeFlags flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Link : SerializedLink {};
|
struct Link : SerializedLink {};
|
||||||
|
|||||||
@@ -20,12 +20,18 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="NPC.cpp" />
|
||||||
|
<ClCompile Include="NPCManager.cpp" />
|
||||||
|
<ClCompile Include="NPCVehicle.cpp" />
|
||||||
<ClCompile Include="paths.cpp" />
|
<ClCompile Include="paths.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="DEFINE.def" />
|
<None Include="DEFINE.def" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="NPC.h" />
|
||||||
|
<ClInclude Include="NPCManager.h" />
|
||||||
|
<ClInclude Include="NPCVehicle.h" />
|
||||||
<ClInclude Include="paths.h" />
|
<ClInclude Include="paths.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
|
|||||||
@@ -21,6 +21,15 @@
|
|||||||
<ClCompile Include="paths.cpp">
|
<ClCompile Include="paths.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="NPCManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="NPCVehicle.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="NPC.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="DEFINE.def">
|
<None Include="DEFINE.def">
|
||||||
@@ -31,5 +40,14 @@
|
|||||||
<ClInclude Include="paths.h">
|
<ClInclude Include="paths.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="NPCManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="NPCVehicle.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="NPC.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user