(bmtrick) add bmtrick.h

This commit is contained in:
Stan H 2019-03-20 20:36:36 +01:00
parent af09635668
commit 2983cff0e7
9 changed files with 141 additions and 132 deletions

111
include/bmtrick.h Normal file
View File

@ -0,0 +1,111 @@
#ifndef GUARD_BMTRICK_H
#define GUARD_BMTRICK_H
enum
{
TRAP_MAX_COUNT = 64,
};
enum
{
TRAP_NONE = 0,
TRAP_BALLISTA = 1,
TRAP_OBSTACLE = 2, // walls & snags
TRAP_MAPCHANGE = 3,
TRAP_FIRETILE = 4,
TRAP_GAS = 5,
TRAP_MAPCHANGE2 = 6, // TODO: figure out
TRAP_LIGHTARROW = 7,
TRAP_8 = 8,
TRAP_9 = 9,
TRAP_TORCHLIGHT = 10,
TRAP_MINE = 11,
TRAP_GORGON_EGG = 12, // TODO: figure out
TRAP_LIGHT_RUNE = 13,
};
enum
{
// Ballista extdata definitions
TRAP_EXTDATA_BLST_ITEMID = 0, // ballista item id
TRAP_EXTDATA_BLST_RIDDEN = 2, // "is ridden" boolean
TRAP_EXTDATA_BLST_ITEMUSES = 3, // ballista item uses
// Obstacle (Snags and Walls) extdata definitions
TRAP_EXTDATA_OBSTACLE_HP = 0, // hp left
// Map Change extdata definitions
TRAP_EXTDATA_MAPCHANGE_ID = 0, // map change id
// Trap (Fire/Gas/Arrow) extdata definitions
TRAP_EXTDATA_TRAP_TURNFIRST = 1, // start turn countdown
TRAP_EXTDATA_TRAP_TURNNEXT = 2, // repeat turn countdown
TRAP_EXTDATA_TRAP_COUNTER = 3, // turn counter
TRAP_EXTDATA_TRAP_DAMAGE = 4, // trap damage (needs confirmation)
// Gas Trap exdata definition (in addition to the above)
TRAP_EXTDATA_GAS_FACING = 0,
// Torchlight extdata definitions
TRAP_EXTDATA_LIGHT_TURNSLEFT = 0, // turns left before wearing out
// Light Rune extdata definitions
TRAP_EXTDATA_RUNE_REPLACINGTERRAIN = 0, // terrain id of the replaced tile
TRAP_EXTDATA_RUNE_TURNSLEFT = 3, // turns left beofre wearing out
};
struct Trap
{
/* 00 */ u8 xPos;
/* 01 */ u8 yPos;
/* 02 */ u8 type;
/* 03 */ u8 data[5]; // extdata (see above enum for per trap type entry allocations)
};
#define TRAP_INDEX(aTrap) ((aTrap) - GetTrap(0))
void ResetTraps(void);
struct Trap* GetTrapAt(int x, int y);
struct Trap* GetSpecificTrapAt(int x, int y, int trapType);
struct Trap* AddTrap(int x, int y, int trapType, int meta);
struct Trap* AddTrapExt(int x, int y, int trapType, int meta, int turnCountdown, int turnInterval, int damage);
struct Trap* RemoveTrap(struct Trap* trap);
void AddFireTrap(int x, int y, int turnCountdown, int turnInterval);
void AddGasTrap(int x, int y, int facing, int turnCountdown, int turnInterval);
void AddArrowTrap(int x, int turnCountdown, int turnInterval);
void sub_802E36C(int x, int y, int turnCountdown, int turnInterval);
void AddTrap8(int x, int y);
void AddTrap9(int x, int y, int meta);
void AddSnagsAndWalls(void);
void ApplyTrapMapChanges(void);
void UpdateAllLightRunes(void);
int GetTrapExt1At(int x, int y);
const struct MapChange* GetMapChangesPointerById(int id);
int GetMapChangesIdAt(int x, int y);
void ApplyMapChangesById(int mapChangeId);
void AddMapChange(int mapChangeId);
void UntriggerMapChange(int id);
s8 AreMapChangeTriggered(int id);
void UnitHideIfUnderRoof(struct Unit* unit);
void sub_802E690(void);
void AddToTargetListFromPos(int x, int y, int damage);
void AddArrowTrapTargetsToTargetList(int x, int y, int damage);
void sub_802E754(int x, int y, int damage, int facing);
s8 sub_802E7D4(int x, int y, int facing);
void MakeTargetListForTurnTrapDamage(void);
void sub_802E8A8(void);
void CountDownTraps(void);
void ResetCounterForCountedDownTraps(void);
void sub_802EA00(void);
void sub_802EA1C(void);
void sub_802EA28(void);
struct Trap* AddLightRune(int x, int y);
struct Trap* RemoveLightRune(struct Trap* trap);
void HandleTrapDecay(void);
void BattleSomethingTrapChangeTerrain(void);
void NullAllLightRunesTerrain(void);
struct Trap* GetTrap(int id);
#endif // GUARD_BMTRICK_H

View File

@ -1506,47 +1506,6 @@ s8 CanUnitUseItem(struct Unit* unit, int item);
// ??? sub_802E168(???);
// ??? sub_802E188(???);
// ??? sub_802E1A8(???);
void ResetTraps(void);
struct Trap* GetTrapAt(int x, int y);
// ??? GetSpecificTrapAt(???);
// ??? AddTrap(???);
// ??? AddTrapExt(???);
// ??? RemoveTrap(???);
// ??? AddFireTrap(???);
// ??? AddGasTrap(???);
// ??? AddArrowTrap(???);
// ??? sub_802E36C(???);
// ??? AddTrap8(???);
// ??? AddTrap9(???);
void AddSnagsAndWalls(void);
void ApplyTrapMapChanges(void);
void UpdateAllLightRunes(void);
// ??? GetTrapExt1At(???);
const struct MapChange* GetMapChangesPointerById(int id);
int GetMapChangesIdAt(int x, int y);
void ApplyMapChangesById(int mapChangeId);
void AddMapChange(int mapChangeId);
// ??? UntriggerMapChange(???);
// ??? AreMapChangeTriggered(???);
void UnitHideIfUnderRoof(struct Unit* unit);
void sub_802E690(void);
// ??? AddToTargetListFromPos(???);
// ??? AddArrowTrapTargetsToTargetList(???);
// ??? sub_802E754(???);
// ??? sub_802E7D4(???);
// ??? MakeTargetListForTurnTrapDamage(???);
// ??? sub_802E8A8(???);
// ??? CountDownTraps(???);
// ??? ResetCounterForCountedDownTraps(???);
// ??? sub_802EA00(???);
// ??? sub_802EA1C(???);
// ??? sub_802EA28(???);
// ??? AddLightRune(???);
// ??? RemoveLightRune(???);
// ??? HandleTrapDecay(???);
void BattleSomethingTrapChangeTerrain(void);
void NullAllLightRunesTerrain(void);
struct Trap* GetTrap(int id);
// ??? ExecStandardHeal(???);
// ??? ExecRestore(???);
// ??? sub_802EC8C(???);

View File

@ -364,64 +364,6 @@ struct SMSHandle
/* 0B */ s8 config;
};
enum
{
TRAP_NONE = 0,
TRAP_BALLISTA = 1,
TRAP_OBSTACLE = 2, // walls & snags
TRAP_MAPCHANGE = 3,
TRAP_FIRETILE = 4,
TRAP_GAS = 5,
TRAP_MAPCHANGE2 = 6, // TODO: figure out
TRAP_LIGHTARROW = 7,
TRAP_8 = 8,
TRAP_9 = 9,
TRAP_TORCHLIGHT = 10,
TRAP_MINE = 11,
TRAP_GORGON_EGG = 12, // TODO: figure out
TRAP_LIGHT_RUNE = 13,
};
enum
{
// Ballista extdata definitions
TRAP_EXTDATA_BLST_ITEMID = 0, // ballista item id
TRAP_EXTDATA_BLST_RIDDEN = 2, // "is ridden" boolean
TRAP_EXTDATA_BLST_ITEMUSES = 3, // ballista item uses
// Obstacle (Snags and Walls) extdata definitions
TRAP_EXTDATA_OBSTACLE_HP = 0, // hp left
// Map Change extdata definitions
TRAP_EXTDATA_MAPCHANGE_ID = 0, // map change id
// Trap (Fire/Gas/Arrow) extdata definitions
TRAP_EXTDATA_TRAP_TURNFIRST = 1, // start turn countdown
TRAP_EXTDATA_TRAP_TURNNEXT = 2, // repeat turn countdown
TRAP_EXTDATA_TRAP_COUNTER = 3, // turn counter
TRAP_EXTDATA_TRAP_DAMAGE = 4, // trap damage (needs confirmation)
// Gas Trap exdata definition (in addition to the above)
TRAP_EXTDATA_GAS_FACING = 0,
// Torchlight extdata definitions
TRAP_EXTDATA_LIGHT_TURNSLEFT = 0, // turns left before wearing out
// Light Rune extdata definitions
TRAP_EXTDATA_RUNE_REPLACINGTERRAIN = 0, // terrain id of the replaced tile
TRAP_EXTDATA_RUNE_TURNSLEFT = 3, // turns left beofre wearing out
};
struct Trap
{
/* 00 */ u8 xPos;
/* 01 */ u8 yPos;
/* 02 */ u8 type;
/* 03 */ u8 data[5]; // extdata (see above enum for per trap type entry allocations)
};
struct MapAnimActorState
{
/* 00 */ struct Unit* pUnit;

View File

@ -10,6 +10,7 @@
#include "bmunit.h"
#include "bmmap.h"
#include "chapterdata.h"
#include "bmtrick.h"
#include "m4a.h"
#include "soundwrapper.h"
#include "hardware.h"

View File

@ -13,8 +13,8 @@
#include "bmunit.h"
#include "bmmap.h"
#include "bmbattle.h"
#include "bmtrick.h"
#include "mu.h"
#include "bmio.h"
// General Battle Map System Stuff, mostly low level hardware stuff but also more

View File

@ -9,6 +9,7 @@
#include "bmunit.h"
#include "bmmap.h"
#include "bmidoten.h"
#include "bmtrick.h"
static void BmMapInit(void* buffer, u8*** outHandle, int width, int height);

View File

@ -7,17 +7,11 @@
#include "chapterdata.h"
#include "proc.h"
#include "event.h"
enum
{
TRAP_MAX_COUNT = 64,
};
#include "bmtrick.h"
EWRAM_DATA struct Trap gUnknown_0203A614[TRAP_MAX_COUNT] = {};
EWRAM_DATA struct Trap gUnknown_0203A814 = {};
#define TRAP_INDEX(aTrap) ((aTrap) - GetTrap(0))
inline struct Trap* GetTrap(int id)
{
return gUnknown_0203A614 + id;
@ -87,7 +81,7 @@ struct Trap* GetSpecificTrapAt(int x, int y, int trapType)
return NULL;
}
struct Trap* AddTrap(int x, int y, int trapType, int data0)
struct Trap* AddTrap(int x, int y, int trapType, int meta)
{
struct Trap* trap;
@ -97,19 +91,19 @@ struct Trap* AddTrap(int x, int y, int trapType, int data0)
trap->xPos = x;
trap->yPos = y;
trap->type = trapType;
trap->data[0] = data0;
trap->data[0] = meta;
return trap;
}
struct Trap* AddTrapExt(int x, int y, int trapType, int data0, int data1, int data2, int data3)
struct Trap* AddTrapExt(int x, int y, int trapType, int meta, int turnCountdown, int turnInterval, int damage)
{
struct Trap* trap = AddTrap(x, y, trapType, data0);
struct Trap* trap = AddTrap(x, y, trapType, meta);
trap->data[1] = data1;
trap->data[2] = data2;
trap->data[3] = data1;
trap->data[4] = data3;
trap->data[1] = turnCountdown;
trap->data[2] = turnInterval;
trap->data[3] = turnCountdown;
trap->data[4] = damage;
return trap;
}
@ -154,24 +148,24 @@ struct Trap* RemoveTrap(struct Trap* trap)
#endif // NONMATCHING
void AddFireTrap(int x, int y, int arg2, int arg3)
void AddFireTrap(int x, int y, int turnCountdown, int turnInterval)
{
AddTrapExt(x, y, TRAP_FIRETILE, 0, arg2, arg3, 10);
AddTrapExt(x, y, TRAP_FIRETILE, 0, turnCountdown, turnInterval, 10);
}
void AddGasTrap(int x, int y, int arg2, int arg3, int arg4)
void AddGasTrap(int x, int y, int facing, int turnCountdown, int turnInterval)
{
AddTrapExt(x, y, TRAP_GAS, arg2, arg3, arg4, 3);
AddTrapExt(x, y, TRAP_GAS, facing, turnCountdown, turnInterval, 3);
}
void AddArrowTrap(int x, int arg1, int arg2)
void AddArrowTrap(int x, int turnCountdown, int turnInterval)
{
AddTrapExt(x, 0, TRAP_LIGHTARROW, 0, arg1, arg2, 10);
AddTrapExt(x, 0, TRAP_LIGHTARROW, 0, turnCountdown, turnInterval, 10);
}
void sub_802E36C(int x, int y, int arg2, int arg3)
void sub_802E36C(int x, int y, int turnCountdown, int turnInterval)
{
AddTrapExt(x, y, TRAP_MAPCHANGE2, 0, arg2, arg3, 0);
AddTrapExt(x, y, TRAP_MAPCHANGE2, 0, turnCountdown, turnInterval, 0);
}
void AddTrap8(int x, int y)
@ -179,9 +173,9 @@ void AddTrap8(int x, int y)
AddTrap(x, y, TRAP_8, 0);
}
void AddTrap9(int x, int y, int arg2)
void AddTrap9(int x, int y, int meta)
{
AddTrap(x, y, TRAP_9, arg2);
AddTrap(x, y, TRAP_9, meta);
}
void AddSnagsAndWalls(void)
@ -398,23 +392,23 @@ void sub_802E690(void)
SMS_UpdateFromGameData();
}
void AddToTargetListFromPos(int x, int y, int tId)
void AddToTargetListFromPos(int x, int y, int damage)
{
AddTarget(x, y, gBmMapUnit[y][x], tId);
AddTarget(x, y, gBmMapUnit[y][x], damage);
}
void AddArrowTrapTargetsToTargetList(int x, int y, int tId)
void AddArrowTrapTargetsToTargetList(int x, int y, int damage)
{
int iy;
for (iy = 0; iy < gBmMapSize.y; ++iy)
{
if (gBmMapUnit[iy][x])
AddTarget(x, iy, gBmMapUnit[iy][x], tId);
AddTarget(x, iy, gBmMapUnit[iy][x], damage);
}
}
void sub_802E754(int x, int y, int tId, int facing)
void sub_802E754(int x, int y, int damage, int facing)
{
int i;
@ -456,7 +450,7 @@ void sub_802E754(int x, int y, int tId, int facing)
y += yInc;
if (gBmMapUnit[y][x])
AddTarget(x, y, gBmMapUnit[y][x], tId);
AddTarget(x, y, gBmMapUnit[y][x], damage);
}
}

View File

@ -12,6 +12,7 @@
#include "bmmap.h"
#include "bmidoten.h"
#include "bmbattle.h"
#include "bmtrick.h"
EWRAM_DATA u8 gActiveUnitId = 0;
EWRAM_DATA struct Vec2 gActiveUnitMoveOrigin = {};

View File

@ -11,8 +11,8 @@
#include "bmio.h"
#include "bmunit.h"
#include "bmmap.h"
#include "bmtrick.h"
#include "bmbattle.h"
#include "mu.h"
/*