Skip to content

Commit

Permalink
更新:大地图遇怪物数据更新!大地图怪物分布更新。添加所有挂物组合。
Browse files Browse the repository at this point in the history
  • Loading branch information
park671 committed Jun 5, 2023
1 parent 3eaf8b1 commit 7098a0f
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 11 deletions.
6 changes: 2 additions & 4 deletions app/src/main/cpp/logic/render_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ void renderInfoMenu(byte *screenBuffer) {
__memset_aarch64(screenBuffer, 3, 256 * 256);
}

BattleRender::BattleRender() {

BattleRender::BattleRender(int monsterId) {
monsterIdx = monsterId;
}

void BattleRender::tikLogic() {
Expand All @@ -50,8 +50,6 @@ void BattleRender::tikLogic() {
}
}

int monsterIdx = 0;

byte * BattleRender::render(byte *screenBuffer) {
if(enterBattle) {
renderBackground(screenBuffer);
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/cpp/logic/render_battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class BattleRender : public BaseRender {
volatile bool enterBattle = false;
volatile int splashClk = 0;
volatile int splashCount = 0;
int monsterIdx = 0;
public:
BattleRender();
BattleRender(int monsterId);
byte * render(byte *screenBuffer);
void tikLogic();
void processKeyClick(byte directKey, byte functionKey);
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/cpp/logic/render_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "../audio/mm_sound.h"
#include "../graphic/native_graphic.h"
#include "../graphic/palette_data.h"
#include "../monster/monster_data/monster_data.h"

const char chinese_demo[4] = {0, 1, 2, 3};

Expand Down Expand Up @@ -49,7 +50,7 @@ inline void DebugRender::processSelection() {
Character *player = getDefaultPlayer();
if (selectPos == 0) {
pop();
BattleRender *battleRender = new BattleRender;
BattleRender *battleRender = new BattleRender(rand() % monster_count);
push(battleRender);
} else if (selectPos == 1) {
changeAudio(getAudioIdx() + 1);
Expand Down
36 changes: 32 additions & 4 deletions app/src/main/cpp/logic/render_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "../graphic/palette_data.h"
#include "../audio/mm_sound.h"
#include "../graphic/native_graphic.h"
#include "../monster/monster_data/monster_data.h"

#define ANIMATION_DURATION 20

Expand All @@ -43,6 +44,7 @@ void MapRender::updateMap(int newMapId, int x, int y) {

MapRender::MapRender() {
logd("MapRender", "new!");
srand((unsigned)time(nullptr));
}

int MapRender::getMapId() {
Expand Down Expand Up @@ -237,18 +239,44 @@ bool MapRender::processKey(byte directKey, byte functionKey) {
} else {
player->x = targetX;
player->y = targetY;
triggerMonster();
}
} else {
player->direct = nextDirect;
}
return functionKey == 0;
}

void MapRender::triggerMonster() const {
//fixme this is only test for world map!!!
//todo impl all maps
if (mapId == 0) {
if (rand() % 100 > 10) {
return;
}
int monsterArea = (getDefaultPlayer()->y / 16) * 16 + (getDefaultPlayer()->x / 16);
char info[10];
sprintf(info, "%d", monsterArea);
logd("monsterArea", info);
int monsterGroupId = monster_distribution_0[monsterArea];
if (monsterGroupId == 0) {
return;
}
int hitMonsterIdx = rand() % 0x0A;
int monsterId = monster_group[monsterGroupId * 0x0A + hitMonsterIdx];
if (monsterId == 0) {
return;
}
BattleRender *battleRender = new BattleRender(monsterId);
push(battleRender);
}
}

bool MapRender::checkOutOfMap(Character *player, int targetX, int targetY) {
byte startX = movable_offset[mapId*2];
byte startY = movable_offset[mapId*2+1];
byte endX = startX+movable_size[mapId*2];
byte endY = startY+movable_size[mapId*2+1];
byte startX = movable_offset[mapId * 2];
byte startY = movable_offset[mapId * 2 + 1];
byte endX = startX + movable_size[mapId * 2];
byte endY = startY + movable_size[mapId * 2 + 1];
if (targetX < startX
|| targetY < startY
|| targetX > endX
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/logic/render_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MapRender : public BaseRender {
void fadeOut() const;
void fadeIn() const;
void refreshMusic() const;
void triggerMonster() const;
public:
MapRender();
void updateMap(int newMapId, int x, int y);
Expand Down
30 changes: 29 additions & 1 deletion app/src/main/cpp/maps/map_data/map_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,32 @@ unsigned char entrances_0[79*5]={
201,102,12,15,40,
};

unsigned char entrance_count_0=79;
unsigned char entrance_count_0=79;

unsigned char monster_distribution_0[256] = {
55,55,55,55,55,55,55,56,26,25,
25,24,24,24,24,24,55,55,55,56,
58,58,55,56,26,26,25,24,24,24,
24,24,55,55,54,56,58,58,57,27,
26,26,22,23,24,24,24,24,53,53,
53,54,56,56,57,27,27,22,22,23,
23,23,23,23,52,49,51,51,53,53,
28,28,28,30,22,22,21,21,21,21,
52,61,61,50,50,50,28,29,29,30,
18,19,21,20,20,20,52,61,61,49,
49,50,59,29,29,18,18,19,19,20,
20,20,52,48,48,48,49,41,41,31,
33,34,35,19,19,20,20,20,42,42,
40,40,48,39,39,31,34,34,35,18,
18,20,20,20,42,42,42,38,39,39,
39,31,31,35,35,35,15,15,20,20,
42,42,42,38,38,39,32,0,0,0,
13,36,15,15,15,15,42,42,42,38,
37,0,5,6,6,10,14,14,14,15,
15,15,47,47,43,37,37,3,5,5,
6,7,7,9,9,16,17,17,46,46,
43,43,3,3,4,6,6,7,7,9,
9,17,17,17,45,45,45,44,1,1,
2,5,12,8,8,60,60,11,11,11,
45,45,45,44,1,2,2,5,12,8,
8,11,11,11,11,11,};
1 change: 1 addition & 0 deletions app/src/main/cpp/maps/map_data/map_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ extern "C" unsigned short map_0[256][256];
extern "C" unsigned short fill_0;
extern "C" unsigned char entrances_0[];
extern "C" unsigned char entrance_count_0;
extern "C" unsigned char monster_distribution_0[256];
#endif
96 changes: 96 additions & 0 deletions app/src/main/cpp/monster/monster_data/monster_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,99 @@ int monster_size[131*2] = {128,96,
128,96,
128,96,
};

unsigned char monster_group[930] = {
25,25,24,0,24,26,24,0,0,0,
29,25,24,24,26,29,0,0,0,25,
28,27,0,0,29,26,0,0,24,0,
31,31,0,0,0,0,29,28,0,0,
39,33,32,0,34,34,33,32,0,0,
39,0,0,24,39,24,32,0,33,34,
41,0,36,0,36,39,0,0,34,32,
35,35,0,0,46,0,33,32,36,30,
37,37,0,34,34,34,34,37,37,37,
0,0,40,0,40,0,0,40,40,0,
45,46,0,0,43,43,37,40,46,0,
44,0,44,36,0,44,0,32,33,36,
48,49,0,0,53,0,0,0,38,0,
53,49,40,0,48,48,37,38,36,0,
55,48,0,49,55,53,50,45,38,44,
48,48,0,0,55,55,0,0,45,45,
52,0,51,0,58,57,49,47,46,26,
55,50,51,50,61,59,51,0,59,51,
63,59,55,53,61,63,59,0,50,0,
63,63,59,48,61,55,61,0,57,58,
65,65,66,66,64,64,63,0,44,44,
67,67,0,44,64,0,65,65,66,66,
52,64,66,66,67,0,65,60,44,0,
69,68,72,70,68,72,69,0,61,50,
68,72,69,68,0,70,70,69,0,0,
76,79,0,0,70,0,76,71,70,73,
78,76,79,0,76,78,79,0,73,0,
81,76,74,79,77,78,0,0,74,0,
81,74,0,74,77,78,73,0,70,74,
74,74,52,34,34,37,74,0,37,52,
91,78,70,65,75,0,0,0,70,0,
91,0,0,44,0,91,73,70,0,0,
78,0,0,0,77,0,39,0,64,0,
72,51,69,65,78,0,64,39,50,0,
24,24,38,38,71,24,44,24,44,38,
92,68,68,47,101,101,76,70,57,58,
75,70,69,53,98,91,0,70,92,92,
93,81,0,0,62,95,95,82,0,0,
82,81,101,0,95,101,79,79,80,0,
62,83,90,0,83,97,0,0,95,0,
82,83,0,0,62,95,97,80,0,0,
85,99,0,66,93,0,87,97,97,90,
66,66,66,66,71,66,74,97,44,71,
29,24,0,0,26,50,46,90,0,0,
70,61,61,25,64,0,51,61,39,0,
100,89,61,38,102,88,87,61,89,64,
92,42,89,61,102,100,87,64,64,87,
93,105,90,0,85,87,97,0,87,99,
103,91,105,83,109,94,95,95,91,105,
94,93,99,105,103,94,85,97,90,109,
96,96,44,83,94,103,96,83,94,89,
82,97,97,83,97,97,97,80,73,73,
96,110,103,95,96,110,0,85,94,109,
104,56,70,97,104,106,109,90,93,56,
56,104,84,105,0,0,109,106,70,71,
107,104,0,0,106,84,83,70,56,56,
98,96,110,94,96,110,56,97,84,71,
108,104,109,70,107,111,70,105,111,101,
81,76,74,79,77,78,0,0,74,0,
46,0,0,43,0,0,0,0,43,43,
93,81,83,97,93,85,44,98,60,71,
29,24,0,0,26,50,46,90,0,0,
0,0,0,0,0,0,0,0,0,0,
26,25,24,0,25,26,24,0,0,0,
29,26,25,24,29,26,25,24,0,24,
28,27,26,25,27,0,25,26,0,24,
25,0,26,29,29,26,25,24,0,24,
28,28,27,0,28,0,25,26,0,24,
28,31,31,27,30,26,31,24,30,0,
0,0,31,30,0,0,28,30,26,0,
45,56,25,0,45,0,25,51,0,56,
0,56,34,25,56,0,46,0,0,34,
37,34,37,34,0,52,34,0,37,0,
53,0,0,24,45,53,24,24,26,26,
53,0,47,0,53,47,30,30,0,0,
68,68,43,43,68,68,43,43,0,0,
61,72,72,61,0,61,63,72,38,38,
119,0,49,51,0,0,119,0,64,50,
44,0,0,44,0,0,119,51,64,50,
110,110,0,0,0,110,0,110,0,110,
0,32,0,26,110,72,0,0,0,32,
0,44,56,0,112,0,65,0,69,0,
0,24,0,24,0,44,0,24,44,33,
0,52,37,34,52,60,34,0,37,0,
54,120,54,120,0,54,112,54,120,0,
121,54,54,0,115,116,112,0,127,54,
127,127,54,54,112,121,116,54,121,120,
127,0,0,0,121,121,54,54,0,127,
21,21,0,0,21,0,124,118,112,120,
21,21,123,0,21,118,124,56,123,117,
60,60,97,97,109,97,109,0,80,0,
125,21,123,123,125,125,124,0,116,117,
122,122,0,0,122,125,0,0,125,125,
};
1 change: 1 addition & 0 deletions app/src/main/cpp/monster/monster_data/monster_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

extern int monster_count;
extern int monster_size[];
extern unsigned char monster_group[930];
extern byte *monster_model[];

#endif //METALMAX_MONSTER_DATA_H

0 comments on commit 7098a0f

Please sign in to comment.