summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2017-12-27 09:33:58 -0600
committerGitHub <noreply@github.com>2017-12-27 09:33:58 -0600
commit86a36767dba19e84297047addf1d1d776e2efdec (patch)
treef2aaa9e93f8b8671491eda458963aee1027924c2 /src
parente3078400bbdb3e8416806127290b9a2d68cfb3b8 (diff)
parentd34de50d34d18ee64c95232202751532534c2ed9 (diff)
Merge pull request #501 from huderlem/event_macros
New map event macros
Diffstat (limited to 'src')
-rw-r--r--src/battle/battle_3.c11
-rw-r--r--src/field/coord_event_weather.c87
-rw-r--r--src/field/field_control_avatar.c4
-rw-r--r--src/field/field_specials.c4
-rw-r--r--src/field/field_weather.c25
-rw-r--r--src/field/field_weather_effects.c1
-rw-r--r--src/field/item_use.c5
7 files changed, 71 insertions, 66 deletions
diff --git a/src/battle/battle_3.c b/src/battle/battle_3.c
index f627e50f0..b21ec1572 100644
--- a/src/battle/battle_3.c
+++ b/src/battle/battle_3.c
@@ -7,6 +7,7 @@
#include "event_data.h"
#include "constants/hold_effects.h"
#include "constants/species.h"
+#include "constants/weather.h"
#include "pokemon.h"
#include "data2.h"
#include "random.h"
@@ -1500,9 +1501,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
//_08018586
switch (weather_get_current())
{
- case 3:
- case 5:
- case 13:
+ case WEATHER_RAIN_LIGHT:
+ case WEATHER_RAIN_MED:
+ case WEATHER_RAIN_HEAVY:
if (!(gBattleWeather & WEATHER_RAIN_ANY))
{
gBattleWeather = (WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_PERMANENT);
@@ -1511,7 +1512,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
effect++;
}
break;
- case 8:
+ case WEATHER_SANDSTORM:
if (!(gBattleWeather & WEATHER_SANDSTORM_ANY))
{
gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY);
@@ -1520,7 +1521,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
effect++;
}
break;
- case 12:
+ case WEATHER_DROUGHT:
if (!(gBattleWeather & WEATHER_SUN_ANY))
{
gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY);
diff --git a/src/field/coord_event_weather.c b/src/field/coord_event_weather.c
index 9c5a1ca4d..db4e9c161 100644
--- a/src/field/coord_event_weather.c
+++ b/src/field/coord_event_weather.c
@@ -1,115 +1,116 @@
#include "global.h"
+#include "constants/weather.h"
#include "coord_event_weather.h"
#include "field_weather.h"
struct CoordEventWeather
{
- u8 weather;
+ u8 coordEventWeather;
void (*func)(void);
};
-static void CoordEventWeather_Indoor(void);
+static void CoordEventWeather_Clouds(void);
static void CoordEventWeather_Sunny(void);
-static void CoordEventWeather_Rain(void);
-static void CoordEventWeather_Snowflakes(void);
+static void CoordEventWeather_LightRain(void);
+static void CoordEventWeather_Snow(void);
static void CoordEventWeather_Thunderstorm(void);
static void CoordEventWeather_Fog(void);
static void CoordEventWeather_DiagonalFog(void);
-static void CoordEventWeather_Snow(void);
+static void CoordEventWeather_Ash(void);
static void CoordEventWeather_Sandstorm(void);
-static void CoordEventWeather_Cloudy(void);
+static void CoordEventWeather_Dark(void);
static void CoordEventWeather_Drought(void);
-static void CoordEventWeather_UnderwaterFog(void);
-static void CoordEventWeather_UnderwaterBubbles(void);
+static void CoordEventWeather_Route119Cycle(void);
+static void CoordEventWeather_Route123Cycle(void);
static const struct CoordEventWeather sCoordEventWeatherFuncs[] =
{
- { 0x1, CoordEventWeather_Indoor },
- { 0x2, CoordEventWeather_Sunny },
- { 0x3, CoordEventWeather_Rain },
- { 0x4, CoordEventWeather_Snowflakes },
- { 0x5, CoordEventWeather_Thunderstorm },
- { 0x6, CoordEventWeather_Fog },
- { 0x7, CoordEventWeather_DiagonalFog },
- { 0x8, CoordEventWeather_Snow },
- { 0x9, CoordEventWeather_Sandstorm },
- { 0xa, CoordEventWeather_Cloudy },
- { 0xb, CoordEventWeather_Drought },
- { 0x14, CoordEventWeather_UnderwaterFog },
- { 0x15, CoordEventWeather_UnderwaterBubbles },
+ { COORD_EVENT_WEATHER_CLOUDS, CoordEventWeather_Clouds },
+ { COORD_EVENT_WEATHER_SUNNY, CoordEventWeather_Sunny },
+ { COORD_EVENT_WEATHER_RAIN_LIGHT, CoordEventWeather_LightRain },
+ { COORD_EVENT_WEATHER_SNOW, CoordEventWeather_Snow },
+ { COORD_EVENT_WEATHER_RAIN_MED, CoordEventWeather_Thunderstorm },
+ { COORD_EVENT_WEATHER_FOG_1, CoordEventWeather_Fog },
+ { COORD_EVENT_WEATHER_FOG_2, CoordEventWeather_DiagonalFog },
+ { COORD_EVENT_WEATHER_ASH, CoordEventWeather_Ash },
+ { COORD_EVENT_WEATHER_SANDSTORM, CoordEventWeather_Sandstorm },
+ { COORD_EVENT_WEATHER_DARK, CoordEventWeather_Dark },
+ { COORD_EVENT_WEATHER_DROUGHT, CoordEventWeather_Drought },
+ { COORD_EVENT_WEATHER_ROUTE119_CYCLE, CoordEventWeather_Route119Cycle },
+ { COORD_EVENT_WEATHER_ROUTE123_CYCLE, CoordEventWeather_Route123Cycle },
};
-static void CoordEventWeather_Indoor(void)
+static void CoordEventWeather_Clouds(void)
{
- SetWeather(1);
+ SetWeather(WEATHER_CLOUDS);
}
static void CoordEventWeather_Sunny(void)
{
- SetWeather(2);
+ SetWeather(WEATHER_SUNNY);
}
-static void CoordEventWeather_Rain(void)
+static void CoordEventWeather_LightRain(void)
{
- SetWeather(3);
+ SetWeather(WEATHER_RAIN_LIGHT);
}
-static void CoordEventWeather_Snowflakes(void)
+static void CoordEventWeather_Snow(void)
{
- SetWeather(4);
+ SetWeather(WEATHER_SNOW);
}
static void CoordEventWeather_Thunderstorm(void)
{
- SetWeather(5);
+ SetWeather(WEATHER_RAIN_MED);
}
static void CoordEventWeather_Fog(void)
{
- SetWeather(6);
+ SetWeather(WEATHER_FOG_1);
}
static void CoordEventWeather_DiagonalFog(void)
{
- SetWeather(9);
+ SetWeather(WEATHER_FOG_2);
}
-static void CoordEventWeather_Snow(void)
+static void CoordEventWeather_Ash(void)
{
- SetWeather(7);
+ SetWeather(WEATHER_ASH);
}
static void CoordEventWeather_Sandstorm(void)
{
- SetWeather(8);
+ SetWeather(WEATHER_SANDSTORM);
}
-static void CoordEventWeather_Cloudy(void)
+static void CoordEventWeather_Dark(void)
{
- SetWeather(11);
+ SetWeather(WEATHER_DARK);
}
static void CoordEventWeather_Drought(void)
{
- SetWeather(12);
+ SetWeather(WEATHER_DROUGHT);
}
-static void CoordEventWeather_UnderwaterFog(void)
+static void CoordEventWeather_Route119Cycle(void)
{
- SetWeather(20);
+ SetWeather(WEATHER_ROUTE119_CYCLE);
}
-static void CoordEventWeather_UnderwaterBubbles(void)
+static void CoordEventWeather_Route123Cycle(void)
{
- SetWeather(21);
+ SetWeather(WEATHER_ROUTE123_CYCLE);
}
-void DoCoordEventWeather(u8 n)
+void DoCoordEventWeather(u8 coordEventWeather)
{
u8 i;
for (i = 0; i < ARRAY_COUNT(sCoordEventWeatherFuncs); i++)
{
- if (sCoordEventWeatherFuncs[i].weather == n)
+ if (sCoordEventWeatherFuncs[i].coordEventWeather == coordEventWeather)
{
sCoordEventWeatherFuncs[i].func();
return;
diff --git a/src/field/field_control_avatar.c b/src/field/field_control_avatar.c
index cd7d3a2e2..947dc3e56 100644
--- a/src/field/field_control_avatar.c
+++ b/src/field/field_control_avatar.c
@@ -355,7 +355,7 @@ static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unuse
case 5:
case 6:
case 7:
- gSpecialVar_0x8004 = ((u32)bgEvent->bgUnion.script >> 16) + 0x258;
+ gSpecialVar_0x8004 = ((u32)bgEvent->bgUnion.script >> 16) + FLAG_HIDDEN_ITEMS_START;
gSpecialVar_0x8005 = (u32)bgEvent->bgUnion.script;
if (FlagGet(gSpecialVar_0x8004) == TRUE)
return NULL;
@@ -363,7 +363,7 @@ static u8 *TryGetInvisibleMapObjectScript(struct MapPosition *position, u8 unuse
case 8:
if (c == 2)
{
- gSpecialVar_0x8004 = (u32)bgEvent->bgUnion.script;
+ gSpecialVar_0x8004 = bgEvent->bgUnion.secretBaseId;
if (sub_80BC050())
return gUnknown_081A2C51;
}
diff --git a/src/field/field_specials.c b/src/field/field_specials.c
index 8cb1ba487..1a4ebe1af 100644
--- a/src/field/field_specials.c
+++ b/src/field/field_specials.c
@@ -1995,9 +1995,9 @@ static void sub_810F814(u8 taskId)
EnableBothScriptContexts();
}
-bool8 sub_810F828(void)
+bool8 FoundBlackGlasses(void)
{
- return FlagGet(FLAG_UNKNOWN_2B8);
+ return FlagGet(FLAG_HIDDEN_ITEM_BLACK_GLASSES);
}
void SetRoute119Weather(void)
diff --git a/src/field/field_weather.c b/src/field/field_weather.c
index 19ccca3bf..4a819bddf 100644
--- a/src/field/field_weather.c
+++ b/src/field/field_weather.c
@@ -5,6 +5,7 @@
#include "palette.h"
#include "random.h"
#include "script.h"
+#include "constants/weather.h"
#include "constants/songs.h"
#include "sound.h"
#include "sprite.h"
@@ -397,31 +398,31 @@ void sub_807CCAC(void)
case WEATHER_RAIN_MED:
case WEATHER_RAIN_HEAVY:
case WEATHER_SNOW:
- case 11:
+ case WEATHER_DARK:
if (sub_807CDC4() == 0)
{
gWeatherPtr->unknown_6C0 = 3;
gWeatherPtr->unknown_6C6 = 3;
}
break;
- case 12:
+ case WEATHER_DROUGHT:
if (sub_807CE24() == 0)
{
gWeatherPtr->unknown_6C0 = -6;
gWeatherPtr->unknown_6C6 = 3;
}
break;
- case 6:
+ case WEATHER_FOG_1:
if (sub_807CE7C() == 0)
{
gWeatherPtr->unknown_6C0 = 0;
gWeatherPtr->unknown_6C6 = 3;
}
break;
- case 7:
- case 8:
- case 9:
- case 10:
+ case WEATHER_ASH:
+ case WEATHER_SANDSTORM:
+ case WEATHER_FOG_2:
+ case WEATHER_FOG_3:
default:
if (!gPaletteFade.active)
{
@@ -807,9 +808,9 @@ void fade_screen(u8 a, u8 delay)
case WEATHER_RAIN_MED:
case WEATHER_RAIN_HEAVY:
case WEATHER_SNOW:
- case 6:
- case 11:
- case 12:
+ case WEATHER_FOG_1:
+ case WEATHER_DARK:
+ case WEATHER_DROUGHT:
r2 = 1;
break;
default:
@@ -854,7 +855,7 @@ void sub_807D78C(u8 a)
case 1:
if (gWeatherPtr->unknown_6CA != 0)
{
- if (gWeatherPtr->currWeather == 6)
+ if (gWeatherPtr->currWeather == WEATHER_FOG_1)
sub_807D540(r4);
r4 *= 16;
for (i = 0; i < 16; i++)
@@ -867,7 +868,7 @@ void sub_807D78C(u8 a)
BlendPalette(r4, 16, gPaletteFade.y, gPaletteFade.blendColor);
break;
default:
- if (gWeatherPtr->currWeather != 6)
+ if (gWeatherPtr->currWeather != WEATHER_FOG_1)
{
sub_807CEBC(r4, 1, gWeatherPtr->unknown_6C0);
}
diff --git a/src/field/field_weather_effects.c b/src/field/field_weather_effects.c
index 31eda4393..5a59d6c2a 100644
--- a/src/field/field_weather_effects.c
+++ b/src/field/field_weather_effects.c
@@ -4,6 +4,7 @@
#include "overworld.h"
#include "random.h"
#include "script.h"
+#include "constants/weather.h"
#include "constants/songs.h"
#include "sound.h"
#include "sprite.h"
diff --git a/src/field/item_use.c b/src/field/item_use.c
index cf5f05eb9..e1fdddce0 100644
--- a/src/field/item_use.c
+++ b/src/field/item_use.c
@@ -14,6 +14,7 @@
#include "fieldmap.h"
#include "item.h"
#include "item_menu.h"
+#include "constants/flags.h"
#include "constants/items.h"
#include "mail.h"
#include "main.h"
@@ -328,7 +329,7 @@ bool8 ItemfinderCheckForHiddenItems(struct MapEvents *events, u8 taskId)
for (i = 0; i < events->bgEventCount; i++)
{
- if ((events -> bgEvents[i].kind == 7) && !FlagGet(events -> bgEvents[i].bgUnion.hiddenItem.hiddenItemId + 600))
+ if ((events -> bgEvents[i].kind == 7) && !FlagGet(events -> bgEvents[i].bgUnion.hiddenItem.hiddenItemId + FLAG_HIDDEN_ITEMS_START))
{
// do a distance lookup of each item so long as the index remains less than the objects on the current map.
distanceX = (u16)events -> bgEvents[i].x + 7;
@@ -360,7 +361,7 @@ bool8 HiddenItemAtPos(struct MapEvents *events, s16 x, s16 y)
{
if (bgEvent[i].kind == 7 && x == (u16)bgEvent[i].x && y == (u16)bgEvent[i].y) // hidden item and coordinates matches x and y passed?
{
- if (!FlagGet(bgEvent[i].bgUnion.hiddenItem.hiddenItemId + 600))
+ if (!FlagGet(bgEvent[i].bgUnion.hiddenItem.hiddenItemId + FLAG_HIDDEN_ITEMS_START))
return TRUE;
else
return FALSE;