From a67c5b5cd7a9631bfce13b6ed6ae8d659f5415bb Mon Sep 17 00:00:00 2001 From: Helodity Date: Sun, 10 Aug 2025 11:25:59 -0400 Subject: [PATCH] Add camera options to `get_area_info` --- manual/content/changelog.html | 1 + manual/content/events_and_actions.html | 4 ++ .../content/other/mob_script_action.cpp | 40 ++++++++++++++++++- .../source/content/other/mob_script_action.h | 12 ++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/manual/content/changelog.html b/manual/content/changelog.html index 59577bd91..cba2d5a84 100644 --- a/manual/content/changelog.html +++ b/manual/content/changelog.html @@ -149,6 +149,7 @@

Content-making changes

  • Added a global block to scripts. Events in this block will have their actions run regardless of the current state.
  • Added an argument to the play_sound object script action for the sound ID.
  • Added an argument to the set_animation script action that makes the animation speed depend on the object's speed.
  • +
  • Added the camera_min_x, camera_max_x, camera_min_y, and camera_max_y data types to the get_area_info action. (Thanks Helodity)
  • diff --git a/manual/content/events_and_actions.html b/manual/content/events_and_actions.html index 5130c38eb..7e6bea87a 100644 --- a/manual/content/events_and_actions.html +++ b/manual/content/events_and_actions.html @@ -561,6 +561,10 @@

    Obtaining information

    Sets the variable <destination_variable_name> to some special information about the area. The possible data are:
      +
    • camera_max_x: The max x bound of player 1's camera.
    • +
    • camera_mix_x: The min x bound of player 1's camera.
    • +
    • camera_max_y: The max y bound of player 1's camera.
    • +
    • camera_mix_y: The min y bound of player 1's camera.
    • day_minutes: What time of the in-game day it is, in minutes.
    • field_pikmin: How many Pikmin are currently on the field.
    diff --git a/source/source/content/other/mob_script_action.cpp b/source/source/content/other/mob_script_action.cpp index dbae2041f..a46709a09 100644 --- a/source/source/content/other/mob_script_action.cpp +++ b/source/source/content/other/mob_script_action.cpp @@ -278,7 +278,15 @@ bool MobActionLoaders::focus(MobActionCall& call) { * @return Whether it succeeded. */ bool MobActionLoaders::getAreaInfo(MobActionCall& call) { - if(call.args[1] == "day_minutes") { + if(call.args[1] == "camera_max_x") { + call.args[1] = i2s(MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MAX_X); + } else if(call.args[1] == "camera_min_x") { + call.args[1] = i2s(MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MIN_X); + } else if(call.args[1] == "camera_max_y") { + call.args[1] = i2s(MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MAX_Y); + } else if(call.args[1] == "camera_min_y") { + call.args[1] = i2s(MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MIN_Y); + } else if(call.args[1] == "day_minutes") { call.args[1] = i2s(MOB_ACTION_GET_AREA_INFO_TYPE_DAY_MINUTES); } else if(call.args[1] == "field_pikmin") { call.args[1] = i2s(MOB_ACTION_GET_AREA_INFO_TYPE_FIELD_PIKMIN); @@ -1028,7 +1036,35 @@ void MobActionRunners::getAreaInfo(MobActionRunData& data) { (MOB_ACTION_GET_AREA_INFO_TYPE) s2i(data.args[1]); switch (t) { - case MOB_ACTION_GET_AREA_INFO_TYPE_DAY_MINUTES: { + case MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MAX_X: { + *var = i2s( + game.states.gameplay->players[0].view.box[1].x + - game.states.gameplay->players[0].view.boxMargin.x + ); + break; + + } case MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MIN_X: { + *var = i2s( + game.states.gameplay->players[0].view.box[0].x + + game.states.gameplay->players[0].view.boxMargin.x + ); + break; + + } case MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MAX_Y: { + *var = i2s( + game.states.gameplay->players[0].view.box[1].y + - game.states.gameplay->players[0].view.boxMargin.y + ); + break; + + } case MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MIN_Y: { + *var = i2s( + game.states.gameplay->players[0].view.box[0].y + + game.states.gameplay->players[0].view.boxMargin.y + ); + break; + + } case MOB_ACTION_GET_AREA_INFO_TYPE_DAY_MINUTES: { *var = i2s(game.states.gameplay->dayMinutes); break; diff --git a/source/source/content/other/mob_script_action.h b/source/source/content/other/mob_script_action.h index a14cfe85e..440eaa3f2 100644 --- a/source/source/content/other/mob_script_action.h +++ b/source/source/content/other/mob_script_action.h @@ -360,6 +360,18 @@ enum MOB_ACTION_MOB_TARGET_TYPE { //Get area info action info types. enum MOB_ACTION_GET_AREA_INFO_TYPE { + //Get current max x bound on the camera. + MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MAX_X, + + //Get current min x bound on the camera. + MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MIN_X, + + //Get current max y bound on the camera. + MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MAX_Y, + + //Get current min y bound on the camera. + MOB_ACTION_GET_AREA_INFO_TYPE_CAMERA_MIN_Y, + //Get time of day, in minutes. MOB_ACTION_GET_AREA_INFO_TYPE_DAY_MINUTES,