Merge pull request #12 from Clownacy/master
Makefile, readme, and NPC000 improvements
This commit is contained in:
commit
0d8179e98c
4 changed files with 114 additions and 104 deletions
36
Makefile
36
Makefile
|
@ -1,19 +1,18 @@
|
||||||
RELEASE = 0
|
ifeq ($(RELEASE), 1)
|
||||||
|
CXXFLAGS := -O3 -s
|
||||||
ifeq ($(RELEASE), 0)
|
|
||||||
CXXFLAGS := -O0 -g -static -mconsole
|
|
||||||
FILENAME := debug
|
|
||||||
else
|
|
||||||
CXXFLAGS := -O3 -s -static
|
|
||||||
FILENAME := release
|
FILENAME := release
|
||||||
|
else
|
||||||
|
CXXFLAGS := -O0 -g -mconsole
|
||||||
|
FILENAME := debug
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(JAPANESE), 1)
|
ifeq ($(JAPANESE), 1)
|
||||||
CXXFLAGS += -DJAPANESE
|
CXXFLAGS += -DJAPANESE
|
||||||
ifeq ($(RELEASE), 0)
|
LIBS += -liconv
|
||||||
FILENAME := debugjp
|
ifeq ($(RELEASE), 1)
|
||||||
else
|
|
||||||
FILENAME := releasejp
|
FILENAME := releasejp
|
||||||
|
else
|
||||||
|
FILENAME := debugjp
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -22,7 +21,12 @@ CXXFLAGS += -DFIX_BUGS
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CXXFLAGS += `sdl2-config --cflags` `pkg-config freetype2 --cflags`
|
CXXFLAGS += `sdl2-config --cflags` `pkg-config freetype2 --cflags`
|
||||||
LIBS += `sdl2-config --static-libs` -lfreetype -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 -lRpcrt4 -lDwrite -lusp10 -liconv
|
LIBS += `sdl2-config --static-libs` `pkg-config freetype2 --libs`
|
||||||
|
|
||||||
|
ifeq ($(STATIC), 1)
|
||||||
|
CXXFLAGS += -static
|
||||||
|
LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 -lRpcrt4 -lDwrite -lusp10
|
||||||
|
endif
|
||||||
|
|
||||||
# For an accurate result to the original's code, compile in alphabetical order
|
# For an accurate result to the original's code, compile in alphabetical order
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
|
@ -130,9 +134,9 @@ endif
|
||||||
|
|
||||||
OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES)))
|
OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES)))
|
||||||
|
|
||||||
all: build/$(FILENAME).exe
|
all: build/$(FILENAME)
|
||||||
|
|
||||||
build/$(FILENAME).exe: $(OBJECTS)
|
build/$(FILENAME): $(OBJECTS)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@g++ $(CXXFLAGS) $^ -o $@ $(LIBS)
|
@g++ $(CXXFLAGS) $^ -o $@ $(LIBS)
|
||||||
@echo Finished compiling: $@
|
@echo Finished compiling: $@
|
||||||
|
@ -147,12 +151,12 @@ obj/$(FILENAME)/Resource.o: src/Resource.cpp $(addprefix src/Resource/, $(addsuf
|
||||||
@echo Compiling $<
|
@echo Compiling $<
|
||||||
@g++ $(CXXFLAGS) $< -o $@ -c
|
@g++ $(CXXFLAGS) $< -o $@ -c
|
||||||
|
|
||||||
src/Resource/%.h: res/% obj/bin2h.exe
|
src/Resource/%.h: res/% obj/bin2h
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@echo Converting $<
|
@echo Converting $<
|
||||||
@obj/bin2h.exe $< $@
|
@obj/bin2h $< $@
|
||||||
|
|
||||||
obj/bin2h.exe: res/bin2h.c
|
obj/bin2h: res/bin2h.c
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@echo Compiling $^
|
@echo Compiling $^
|
||||||
@gcc -O3 -s -static $^ -o $@
|
@gcc -O3 -s -static $^ -o $@
|
||||||
|
|
20
README.md
20
README.md
|
@ -1,20 +1,22 @@
|
||||||
# Cave Story Engine 2
|
# Cave Story Engine 2
|
||||||
I'm rewriting Cave Story Engine from scratch, to be more accurate than before!
|
|
||||||
|
|
||||||
Cave Story Engine is a recompilation of Cave Story (freeware release), also porting it from DirectX to SDL2
|
Cave Story Engine is an in-progress decompilation of Cave Story (freeware release), ported from DirectX to SDL2.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
How to build:
|
## Dependencies
|
||||||
|
|
||||||
Create "build" directory
|
This project currently depends on SDL2 and Freetype2.
|
||||||
|
|
||||||
cd to the base directory,
|
## Building
|
||||||
|
|
||||||
make (RELEASE=1 for release build)
|
Just run 'make' in the base directory, preferably with some of the following optional settings:
|
||||||
|
|
||||||
|
* RELEASE=1 to compile a release build (optimised, stripped, etc.)
|
||||||
|
* STATIC=1 to produce a statically-linked executable (good for Windows builds)
|
||||||
|
* JAPANESE=1 to enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)
|
||||||
|
* FIX_BUGS=1 to fix certain bugs (see [src/Bug Fixes.txt](https://github.com/cuckydev/Cave-Story-Engine-2/blob/master/src/Bug%20Fixes.txt))
|
||||||
|
|
||||||
|
## Licensing
|
||||||
|
|
||||||
JAPANESE=1 to enable certain Japanese differences
|
Being a decompilation, the majority of the code in this project belongs to Daisuke "Pixel" Amaya - not us. We've yet to agree on a license for our own code.
|
||||||
|
|
||||||
FIX_BUGS=1 to fix certain bugs (see src/Bug Fixes.txt)
|
|
||||||
|
|
|
@ -43,23 +43,23 @@ bool LoadEvent(char *path_event)
|
||||||
{
|
{
|
||||||
char path[PATH_LENGTH];
|
char path[PATH_LENGTH];
|
||||||
sprintf(path, "%s/%s", gDataPath, path_event);
|
sprintf(path, "%s/%s", gDataPath, path_event);
|
||||||
|
|
||||||
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
|
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Read "PXE" check
|
//Read "PXE" check
|
||||||
char code[4];
|
char code[4];
|
||||||
fp->read(fp, code, 1, 4);
|
fp->read(fp, code, 1, 4);
|
||||||
if (memcmp(code, gPassPixEve, 3))
|
if (memcmp(code, gPassPixEve, 3))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Get amount of npcs
|
//Get amount of NPCs
|
||||||
int count = SDL_ReadLE32(fp);
|
int count = SDL_ReadLE32(fp);
|
||||||
|
|
||||||
//Load npcs
|
//Load NPCs
|
||||||
memset(gNPC, 0, sizeof(gNPC));
|
memset(gNPC, 0, sizeof(gNPC));
|
||||||
|
|
||||||
int n = 170;
|
int n = 170;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ bool LoadEvent(char *path_event)
|
||||||
eve.code_event = SDL_ReadLE16(fp);
|
eve.code_event = SDL_ReadLE16(fp);
|
||||||
eve.code_char = SDL_ReadLE16(fp);
|
eve.code_char = SDL_ReadLE16(fp);
|
||||||
eve.bits = SDL_ReadLE16(fp);
|
eve.bits = SDL_ReadLE16(fp);
|
||||||
|
|
||||||
//Set NPC parameters
|
//Set NPC parameters
|
||||||
if (eve.bits & npc_altDir)
|
if (eve.bits & npc_altDir)
|
||||||
gNPC[n].direct = 2;
|
gNPC[n].direct = 2;
|
||||||
|
@ -86,7 +86,7 @@ bool LoadEvent(char *path_event)
|
||||||
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
|
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
|
||||||
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
|
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
|
||||||
SetUniqueParameter(&gNPC[n]);
|
SetUniqueParameter(&gNPC[n]);
|
||||||
|
|
||||||
//Check flags
|
//Check flags
|
||||||
if (gNPC[n].bits & npc_appearSet)
|
if (gNPC[n].bits & npc_appearSet)
|
||||||
{
|
{
|
||||||
|
@ -102,11 +102,11 @@ bool LoadEvent(char *path_event)
|
||||||
{
|
{
|
||||||
gNPC[n].cond = 0x80;
|
gNPC[n].cond = 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Increase index
|
//Increase index
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ void SetDestroyNpChar(int x, int y, int w, int num)
|
||||||
int offset_y = Random(-wa, wa) << 9;
|
int offset_y = Random(-wa, wa) << 9;
|
||||||
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 0, NULL, 0x100);
|
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 0, NULL, 0x100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Flash effect
|
//Flash effect
|
||||||
//SetCaret(x, y, 12, 0);
|
//SetCaret(x, y, 12, 0);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ void SetDestroyNpCharUp(int x, int y, int w, int num)
|
||||||
int offset_y = Random(-wa, wa) << 9;
|
int offset_y = Random(-wa, wa) << 9;
|
||||||
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 1, NULL, 0x100);
|
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 1, NULL, 0x100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Flash effect
|
//Flash effect
|
||||||
//SetCaret(x, y, 12, 0);
|
//SetCaret(x, y, 12, 0);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ void SetExpObjects(int x, int y, int exp)
|
||||||
if (!gNPC[n].cond)
|
if (!gNPC[n].cond)
|
||||||
{
|
{
|
||||||
memset(&gNPC[n], 0, sizeof(NPCHAR));
|
memset(&gNPC[n], 0, sizeof(NPCHAR));
|
||||||
|
|
||||||
int sub_exp = 0;
|
int sub_exp = 0;
|
||||||
if (exp < 20)
|
if (exp < 20)
|
||||||
{
|
{
|
||||||
|
@ -194,7 +194,7 @@ void SetExpObjects(int x, int y, int exp)
|
||||||
exp -= 20;
|
exp -= 20;
|
||||||
sub_exp = 20;
|
sub_exp = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
gNPC[n].cond |= 0x80u;
|
gNPC[n].cond |= 0x80u;
|
||||||
gNPC[n].direct = 0;
|
gNPC[n].direct = 0;
|
||||||
gNPC[n].code_char = 1;
|
gNPC[n].code_char = 1;
|
||||||
|
@ -222,10 +222,10 @@ bool SetBulletObject(int x, int y, int val)
|
||||||
else
|
else
|
||||||
tamakazu_ari[t] = 0;
|
tamakazu_ari[t] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!t)
|
if (!t)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int n = Random(1, 10 * t);
|
int n = Random(1, 10 * t);
|
||||||
int bullet_no = tamakazu_ari[n % t];
|
int bullet_no = tamakazu_ari[n % t];
|
||||||
for (n = 0x100; n < NPC_MAX; n++)
|
for (n = 0x100; n < NPC_MAX; n++)
|
||||||
|
@ -245,7 +245,7 @@ bool SetBulletObject(int x, int y, int val)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ bool SetLifeObject(int x, int y, int val)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ void PutNpChar(int fx, int fy)
|
||||||
if (gNPC[n].cond & 0x80)
|
if (gNPC[n].cond & 0x80)
|
||||||
{
|
{
|
||||||
int8_t a;
|
int8_t a;
|
||||||
|
|
||||||
if (gNPC[n].shock)
|
if (gNPC[n].shock)
|
||||||
{
|
{
|
||||||
a = 2 * ((gNPC[n].shock >> 1) & 1) - 1;
|
a = 2 * ((gNPC[n].shock >> 1) & 1) - 1;
|
||||||
|
@ -308,13 +308,13 @@ void PutNpChar(int fx, int fy)
|
||||||
gNPC[n].damage_view = 0;
|
gNPC[n].damage_view = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int side;
|
int side;
|
||||||
if (gNPC[n].direct)
|
if (gNPC[n].direct)
|
||||||
side = gNPC[n].view.back;
|
side = gNPC[n].view.back;
|
||||||
else
|
else
|
||||||
side = gNPC[n].view.front;
|
side = gNPC[n].view.front;
|
||||||
|
|
||||||
PutBitmap3(
|
PutBitmap3(
|
||||||
&grcGame,
|
&grcGame,
|
||||||
(gNPC[n].x - side) / 0x200 - fx / 0x200 + a,
|
(gNPC[n].x - side) / 0x200 - fx / 0x200 + a,
|
||||||
|
|
|
@ -10,14 +10,18 @@
|
||||||
//Null
|
//Null
|
||||||
void ActNpc000(NPCHAR *npc)
|
void ActNpc000(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
|
RECT rect[1];
|
||||||
|
rect[0] = {0x00, 0x00, 0x10, 0x10};
|
||||||
|
|
||||||
if (!npc->act_no)
|
if (!npc->act_no)
|
||||||
{
|
{
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
|
|
||||||
if (npc->direct == 2)
|
if (npc->direct == 2)
|
||||||
npc->y += 0x2000;
|
npc->y += 0x2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
npc->rect = {0, 0, 16, 16};
|
npc->rect = rect[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Experience
|
//Experience
|
||||||
|
@ -31,34 +35,34 @@ void ActNpc001(NPCHAR *npc)
|
||||||
//Set state
|
//Set state
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
npc->ani_no = Random(0, 4);
|
npc->ani_no = Random(0, 4);
|
||||||
|
|
||||||
//Random speed
|
//Random speed
|
||||||
npc->xm = Random(-0x200, 0x200);
|
npc->xm = Random(-0x200, 0x200);
|
||||||
npc->ym = Random(-0x400, 0);
|
npc->ym = Random(-0x400, 0);
|
||||||
|
|
||||||
//Random direction (reverse animation or not)
|
//Random direction (reverse animation or not)
|
||||||
if (Random(0, 1) != 0)
|
if (Random(0, 1) != 0)
|
||||||
npc->direct = 0;
|
npc->direct = 0;
|
||||||
else
|
else
|
||||||
npc->direct = 2;
|
npc->direct = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gravity
|
//Gravity
|
||||||
if (npc->flag & 0x100)
|
if (npc->flag & 0x100)
|
||||||
npc->ym += 21;
|
npc->ym += 21;
|
||||||
else
|
else
|
||||||
npc->ym += 42;
|
npc->ym += 42;
|
||||||
|
|
||||||
//Bounce off walls
|
//Bounce off walls
|
||||||
if (npc->flag & 1 && npc->xm < 0)
|
if (npc->flag & 1 && npc->xm < 0)
|
||||||
npc->xm = -npc->xm;
|
npc->xm = -npc->xm;
|
||||||
if (npc->flag & 4 && npc->xm > 0)
|
if (npc->flag & 4 && npc->xm > 0)
|
||||||
npc->xm = -npc->xm;
|
npc->xm = -npc->xm;
|
||||||
|
|
||||||
//Bounce off ceiling
|
//Bounce off ceiling
|
||||||
if (npc->flag & 2 && npc->ym < 0)
|
if (npc->flag & 2 && npc->ym < 0)
|
||||||
npc->ym = -npc->ym;
|
npc->ym = -npc->ym;
|
||||||
|
|
||||||
//Bounce off floor
|
//Bounce off floor
|
||||||
if (npc->flag & 8)
|
if (npc->flag & 8)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +70,7 @@ void ActNpc001(NPCHAR *npc)
|
||||||
npc->ym = -0x280;
|
npc->ym = -0x280;
|
||||||
npc->xm = 2 * npc->xm / 3;
|
npc->xm = 2 * npc->xm / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Play bounce song (and try to clip out of floor if stuck)
|
//Play bounce song (and try to clip out of floor if stuck)
|
||||||
if (npc->flag & 0xD)
|
if (npc->flag & 0xD)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +82,7 @@ void ActNpc001(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
npc->count2 = 0;
|
npc->count2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Limit speed
|
//Limit speed
|
||||||
if (npc->xm < -0x5FF)
|
if (npc->xm < -0x5FF)
|
||||||
npc->xm = -0x5FF;
|
npc->xm = -0x5FF;
|
||||||
|
@ -96,23 +100,23 @@ void ActNpc001(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
//Set state
|
//Set state
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
|
|
||||||
//Set random speed
|
//Set random speed
|
||||||
npc->ym = Random(-0x80, 0x80);
|
npc->ym = Random(-0x80, 0x80);
|
||||||
npc->xm = Random(0x7F, 0x100);
|
npc->xm = Random(0x7F, 0x100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Blow to the left
|
//Blow to the left
|
||||||
npc->xm -= 8;
|
npc->xm -= 8;
|
||||||
|
|
||||||
//Destroy when off-screen
|
//Destroy when off-screen
|
||||||
if (npc->x <= 0x9FFF)
|
if (npc->x <= 0x9FFF)
|
||||||
npc->cond = 0;
|
npc->cond = 0;
|
||||||
|
|
||||||
//Limit speed (except pixel applied it to the X position)
|
//Limit speed (except pixel applied it to the X position)
|
||||||
if (npc->x < -0x5FF)
|
if (npc->x < -0x5FF)
|
||||||
npc->x = -0x5FF;
|
npc->x = -0x5FF;
|
||||||
|
|
||||||
//Bounce off walls
|
//Bounce off walls
|
||||||
if (npc->flag & 1)
|
if (npc->flag & 1)
|
||||||
npc->xm = 0x100;
|
npc->xm = 0x100;
|
||||||
|
@ -121,11 +125,11 @@ void ActNpc001(NPCHAR *npc)
|
||||||
if (npc->flag & 8)
|
if (npc->flag & 8)
|
||||||
npc->ym = -0x40;
|
npc->ym = -0x40;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Move
|
//Move
|
||||||
npc->x += npc->xm;
|
npc->x += npc->xm;
|
||||||
npc->y += npc->ym;
|
npc->y += npc->ym;
|
||||||
|
|
||||||
//Get framerects
|
//Get framerects
|
||||||
RECT rect[6];
|
RECT rect[6];
|
||||||
rect[0] = {0x00, 0x10, 0x10, 0x20};
|
rect[0] = {0x00, 0x10, 0x10, 0x20};
|
||||||
|
@ -134,12 +138,12 @@ void ActNpc001(NPCHAR *npc)
|
||||||
rect[3] = {0x30, 0x10, 0x40, 0x20};
|
rect[3] = {0x30, 0x10, 0x40, 0x20};
|
||||||
rect[4] = {0x40, 0x10, 0x50, 0x20};
|
rect[4] = {0x40, 0x10, 0x50, 0x20};
|
||||||
rect[5] = {0x50, 0x10, 0x60, 0x20};
|
rect[5] = {0x50, 0x10, 0x60, 0x20};
|
||||||
|
|
||||||
RECT rcNo = {0, 0, 0, 0};
|
RECT rcNo = {0, 0, 0, 0};
|
||||||
|
|
||||||
//Animate
|
//Animate
|
||||||
++npc->ani_wait;
|
++npc->ani_wait;
|
||||||
|
|
||||||
if (npc->direct)
|
if (npc->direct)
|
||||||
{
|
{
|
||||||
if (npc->ani_wait > 2)
|
if (npc->ani_wait > 2)
|
||||||
|
@ -155,9 +159,9 @@ void ActNpc001(NPCHAR *npc)
|
||||||
if (++npc->ani_no > 5)
|
if (++npc->ani_no > 5)
|
||||||
npc->ani_no = 0;
|
npc->ani_no = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
npc->rect = rect[npc->ani_no];
|
npc->rect = rect[npc->ani_no];
|
||||||
|
|
||||||
//Size
|
//Size
|
||||||
if (npc->act_no)
|
if (npc->act_no)
|
||||||
{
|
{
|
||||||
|
@ -171,14 +175,14 @@ void ActNpc001(NPCHAR *npc)
|
||||||
npc->rect.top += 32;
|
npc->rect.top += 32;
|
||||||
npc->rect.bottom += 32;
|
npc->rect.bottom += 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete after 500 frames
|
//Delete after 500 frames
|
||||||
if (++npc->count1 > 500 && npc->ani_no == 5 && npc->ani_wait == 2)
|
if (++npc->count1 > 500 && npc->ani_no == 5 && npc->ani_wait == 2)
|
||||||
npc->cond = 0;
|
npc->cond = 0;
|
||||||
|
|
||||||
//Blink after 400 frames
|
//Blink after 400 frames
|
||||||
if (npc->count1 > 400)
|
if (npc->count1 > 400)
|
||||||
{
|
{
|
||||||
|
@ -208,18 +212,18 @@ void ActNpc002(NPCHAR *npc)
|
||||||
rcUp[4] = {96, 24, 128, 48};
|
rcUp[4] = {96, 24, 128, 48};
|
||||||
rcUp[5] = {128, 24, 160, 48};
|
rcUp[5] = {128, 24, 160, 48};
|
||||||
rcUp[6] = {160, 24, 192, 48};
|
rcUp[6] = {160, 24, 192, 48};
|
||||||
|
|
||||||
//Turn when touching a wall
|
//Turn when touching a wall
|
||||||
if (npc->flag & 1)
|
if (npc->flag & 1)
|
||||||
npc->direct = 2;
|
npc->direct = 2;
|
||||||
else if (npc->flag & 4)
|
else if (npc->flag & 4)
|
||||||
npc->direct = 0;
|
npc->direct = 0;
|
||||||
|
|
||||||
switch (npc->act_no)
|
switch (npc->act_no)
|
||||||
{
|
{
|
||||||
case 1: //Shot
|
case 1: //Shot
|
||||||
npc->xm = 7 * npc->xm / 8;
|
npc->xm = 7 * npc->xm / 8;
|
||||||
|
|
||||||
if (++npc->count1 > 40)
|
if (++npc->count1 > 40)
|
||||||
{
|
{
|
||||||
if (npc->shock)
|
if (npc->shock)
|
||||||
|
@ -242,19 +246,19 @@ void ActNpc002(NPCHAR *npc)
|
||||||
npc->xm = 0x400;
|
npc->xm = 0x400;
|
||||||
else
|
else
|
||||||
npc->xm = -0x400;
|
npc->xm = -0x400;
|
||||||
|
|
||||||
if (++npc->count1 > 200)
|
if (++npc->count1 > 200)
|
||||||
{
|
{
|
||||||
npc->act_no = 0;
|
npc->act_no = 0;
|
||||||
npc->damage = 1;
|
npc->damage = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++npc->ani_wait > 5)
|
if (++npc->ani_wait > 5)
|
||||||
{
|
{
|
||||||
npc->ani_wait = 0;
|
npc->ani_wait = 0;
|
||||||
++npc->ani_no;
|
++npc->ani_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (npc->ani_no > 6)
|
if (npc->ani_no > 6)
|
||||||
npc->ani_no = 5;
|
npc->ani_no = 5;
|
||||||
break;
|
break;
|
||||||
|
@ -263,16 +267,16 @@ void ActNpc002(NPCHAR *npc)
|
||||||
npc->xm = 0x100;
|
npc->xm = 0x100;
|
||||||
else
|
else
|
||||||
npc->xm = -0x100;
|
npc->xm = -0x100;
|
||||||
|
|
||||||
if (++npc->ani_wait > 8)
|
if (++npc->ani_wait > 8)
|
||||||
{
|
{
|
||||||
npc->ani_wait = 0;
|
npc->ani_wait = 0;
|
||||||
++npc->ani_no;
|
++npc->ani_no;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (npc->ani_no > 3)
|
if (npc->ani_no > 3)
|
||||||
npc->ani_no = 0;
|
npc->ani_no = 0;
|
||||||
|
|
||||||
if (npc->shock)
|
if (npc->shock)
|
||||||
{
|
{
|
||||||
npc->count1 = 0;
|
npc->count1 = 0;
|
||||||
|
@ -281,16 +285,16 @@ void ActNpc002(NPCHAR *npc)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gravity
|
//Gravity
|
||||||
npc->ym += 0x40;
|
npc->ym += 0x40;
|
||||||
if (npc->ym > 0x5FF)
|
if (npc->ym > 0x5FF)
|
||||||
npc->ym = 0x5FF;
|
npc->ym = 0x5FF;
|
||||||
|
|
||||||
//Move
|
//Move
|
||||||
npc->x += npc->xm;
|
npc->x += npc->xm;
|
||||||
npc->y += npc->ym;
|
npc->y += npc->ym;
|
||||||
|
|
||||||
//Set framerect
|
//Set framerect
|
||||||
if (npc->direct)
|
if (npc->direct)
|
||||||
npc->rect = rcUp[npc->ani_no];
|
npc->rect = rcUp[npc->ani_no];
|
||||||
|
@ -303,7 +307,7 @@ void ActNpc003(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
if (++npc->count1 > 100)
|
if (++npc->count1 > 100)
|
||||||
npc->cond = 0;
|
npc->cond = 0;
|
||||||
|
|
||||||
npc->rect = {0, 0, 0, 0};
|
npc->rect = {0, 0, 0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +316,7 @@ void ActNpc004(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
RECT rcLeft[8];
|
RECT rcLeft[8];
|
||||||
RECT rcUp[8];
|
RECT rcUp[8];
|
||||||
|
|
||||||
rcLeft[0] = {16, 0, 17, 1};
|
rcLeft[0] = {16, 0, 17, 1};
|
||||||
rcLeft[1] = {16, 0, 32, 16};
|
rcLeft[1] = {16, 0, 32, 16};
|
||||||
rcLeft[2] = {32, 0, 48, 16};
|
rcLeft[2] = {32, 0, 48, 16};
|
||||||
|
@ -330,13 +334,13 @@ void ActNpc004(NPCHAR *npc)
|
||||||
rcUp[5] = {48, 128, 64, 144};
|
rcUp[5] = {48, 128, 64, 144};
|
||||||
rcUp[6] = {64, 128, 80, 144};
|
rcUp[6] = {64, 128, 80, 144};
|
||||||
rcUp[7] = {80, 128, 96, 144};
|
rcUp[7] = {80, 128, 96, 144};
|
||||||
|
|
||||||
if (npc->act_no)
|
if (npc->act_no)
|
||||||
{
|
{
|
||||||
//Slight drag
|
//Slight drag
|
||||||
npc->xm = 20 * npc->xm / 21;
|
npc->xm = 20 * npc->xm / 21;
|
||||||
npc->ym = 20 * npc->ym / 21;
|
npc->ym = 20 * npc->ym / 21;
|
||||||
|
|
||||||
//Move
|
//Move
|
||||||
npc->x += npc->xm;
|
npc->x += npc->xm;
|
||||||
npc->y += npc->ym;
|
npc->y += npc->ym;
|
||||||
|
@ -350,20 +354,20 @@ void ActNpc004(NPCHAR *npc)
|
||||||
npc->xm = GetCos(deg) * Random(0x200, 0x5FF) / 0x200;
|
npc->xm = GetCos(deg) * Random(0x200, 0x5FF) / 0x200;
|
||||||
npc->ym = GetSin(deg) * Random(0x200, 0x5FF) / 0x200;
|
npc->ym = GetSin(deg) * Random(0x200, 0x5FF) / 0x200;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set state
|
//Set state
|
||||||
npc->ani_no = Random(0, 4);
|
npc->ani_no = Random(0, 4);
|
||||||
npc->ani_wait = Random(0, 3);
|
npc->ani_wait = Random(0, 3);
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Animate
|
//Animate
|
||||||
if (++npc->ani_wait > 4)
|
if (++npc->ani_wait > 4)
|
||||||
{
|
{
|
||||||
npc->ani_wait = 0;
|
npc->ani_wait = 0;
|
||||||
npc->ani_no++;
|
npc->ani_no++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set framerect
|
//Set framerect
|
||||||
if (npc->ani_no < 8)
|
if (npc->ani_no < 8)
|
||||||
{
|
{
|
||||||
|
@ -390,24 +394,24 @@ void ActNpc005(NPCHAR *npc)
|
||||||
rcLeft[0] = {0, 48, 16, 64};
|
rcLeft[0] = {0, 48, 16, 64};
|
||||||
rcLeft[1] = {16, 48, 32, 64};
|
rcLeft[1] = {16, 48, 32, 64};
|
||||||
rcLeft[2] = {32, 48, 48, 64};
|
rcLeft[2] = {32, 48, 48, 64};
|
||||||
|
|
||||||
rcRight[0] = {0, 64, 16, 80};
|
rcRight[0] = {0, 64, 16, 80};
|
||||||
rcRight[1] = {16, 64, 32, 80};
|
rcRight[1] = {16, 64, 32, 80};
|
||||||
rcRight[2] = {32, 64, 48, 80};
|
rcRight[2] = {32, 64, 48, 80};
|
||||||
|
|
||||||
switch (npc->act_no)
|
switch (npc->act_no)
|
||||||
{
|
{
|
||||||
case 0: //Init
|
case 0: //Init
|
||||||
npc->y += 0x600;
|
npc->y += 0x600;
|
||||||
npc->act_no = 1;
|
npc->act_no = 1;
|
||||||
|
|
||||||
case 1: //Waiting
|
case 1: //Waiting
|
||||||
//Look at player
|
//Look at player
|
||||||
if (npc->x <= gMC.x)
|
if (npc->x <= gMC.x)
|
||||||
npc->direct = 2;
|
npc->direct = 2;
|
||||||
else
|
else
|
||||||
npc->direct = 0;
|
npc->direct = 0;
|
||||||
|
|
||||||
//Open eyes near player
|
//Open eyes near player
|
||||||
if (npc->act_wait < 8 || npc->x - 0xE000 >= gMC.x || npc->x + 0xE000 <= gMC.x || npc->y - 0xA000 >= gMC.y || npc->y + 0xA000 <= gMC.y)
|
if (npc->act_wait < 8 || npc->x - 0xE000 >= gMC.x || npc->x + 0xE000 <= gMC.x || npc->y - 0xA000 >= gMC.y || npc->y + 0xA000 <= gMC.y)
|
||||||
{
|
{
|
||||||
|
@ -419,7 +423,7 @@ void ActNpc005(NPCHAR *npc)
|
||||||
{
|
{
|
||||||
npc->ani_no = 1;
|
npc->ani_no = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Jump if attacked
|
//Jump if attacked
|
||||||
if (npc->shock)
|
if (npc->shock)
|
||||||
{
|
{
|
||||||
|
@ -427,7 +431,7 @@ void ActNpc005(NPCHAR *npc)
|
||||||
npc->ani_no = 0;
|
npc->ani_no = 0;
|
||||||
npc->act_wait = 0;
|
npc->act_wait = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Jump if player is nearby
|
//Jump if player is nearby
|
||||||
if (npc->act_wait >= 8 && npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y)
|
if (npc->act_wait >= 8 && npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y)
|
||||||
{
|
{
|
||||||
|
@ -436,18 +440,18 @@ void ActNpc005(NPCHAR *npc)
|
||||||
npc->act_wait = 0;
|
npc->act_wait = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: //Going to jump
|
case 2: //Going to jump
|
||||||
if (++npc->act_wait > 8)
|
if (++npc->act_wait > 8)
|
||||||
{
|
{
|
||||||
//Set jump state
|
//Set jump state
|
||||||
npc->act_no = 3;
|
npc->act_no = 3;
|
||||||
npc->ani_no = 2;
|
npc->ani_no = 2;
|
||||||
|
|
||||||
//Jump
|
//Jump
|
||||||
npc->ym = -0x5FF;
|
npc->ym = -0x5FF;
|
||||||
PlaySoundObject(30, 1);
|
PlaySoundObject(30, 1);
|
||||||
|
|
||||||
//Jump in facing direction
|
//Jump in facing direction
|
||||||
if (npc->direct)
|
if (npc->direct)
|
||||||
npc->xm = 0x100;
|
npc->xm = 0x100;
|
||||||
|
@ -455,7 +459,7 @@ void ActNpc005(NPCHAR *npc)
|
||||||
npc->xm = -0x100;
|
npc->xm = -0x100;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: //Jumping
|
case 3: //Jumping
|
||||||
//Land
|
//Land
|
||||||
if (npc->flag & 8)
|
if (npc->flag & 8)
|
||||||
|
@ -468,16 +472,16 @@ void ActNpc005(NPCHAR *npc)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gravity
|
//Gravity
|
||||||
npc->ym += 64;
|
npc->ym += 64;
|
||||||
if (npc->ym > 0x5FF)
|
if (npc->ym > 0x5FF)
|
||||||
npc->ym = 0x5FF;
|
npc->ym = 0x5FF;
|
||||||
|
|
||||||
//Move
|
//Move
|
||||||
npc->x += npc->xm;
|
npc->x += npc->xm;
|
||||||
npc->y += npc->ym;
|
npc->y += npc->ym;
|
||||||
|
|
||||||
//Set framerect
|
//Set framerect
|
||||||
if (npc->direct)
|
if (npc->direct)
|
||||||
npc->rect = rcRight[npc->ani_no];
|
npc->rect = rcRight[npc->ani_no];
|
||||||
|
|
Loading…
Add table
Reference in a new issue