From: Holger Schemel Date: Fri, 10 Nov 2023 19:44:27 +0000 (+0100) Subject: added using trigger element position for CE triggered global animations X-Git-Tag: 4.3.7.1~1 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=60d09459a7974a32142b51e737b4e94d7491cdc9;p=rocksndiamonds.git added using trigger element position for CE triggered global animations When using global animations that are triggered by custom elements, using ".position: ce_trigger" instead of ".position: ce" will use the position of the CE trigger element instead of the CE itself. --- diff --git a/src/anim.c b/src/anim.c index ee2e1ede..39ed3772 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1434,7 +1434,9 @@ static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part, } static void InitGlobalAnim_Triggered_ByCustomElement(int nr, int page, - int x, int y) + int x, int y, + int trigger_x, + int trigger_y) { struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[GAME_MODE_PLAYING]; @@ -1459,11 +1461,12 @@ static void InitGlobalAnim_Triggered_ByCustomElement(int nr, int page, { struct GraphicInfo *c = &part2->control_info; - if (c->position == POS_CE) + if (c->position == POS_CE || + c->position == POS_CE_TRIGGER) { // store CE tile and offset position to handle scrolling - part2->tile_x = x; - part2->tile_y = y; + part2->tile_x = (c->position == POS_CE_TRIGGER ? trigger_x : x); + part2->tile_y = (c->position == POS_CE_TRIGGER ? trigger_y : y); part2->tile_xoffset = c->x; part2->tile_yoffset = c->y; @@ -1796,7 +1799,8 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, } #endif - if (c->position == POS_CE) + if (c->position == POS_CE || + c->position == POS_CE_TRIGGER) { SetGlobalAnimPartTileXY(part); } @@ -2260,12 +2264,13 @@ int getGlobalAnimSyncFrame(void) return anim_sync_frame; } -void HandleGlobalAnimEventByElementChange(int element, int page, int x, int y) +void HandleGlobalAnimEventByElementChange(int element, int page, int x, int y, + int trigger_x, int trigger_y) { if (!IS_CUSTOM_ELEMENT(element)) return; // custom element stored as 0 to 255, change page stored as 1 to 32 InitGlobalAnim_Triggered_ByCustomElement(element - EL_CUSTOM_START, page + 1, - x, y); + x, y, trigger_x, trigger_y); } diff --git a/src/anim.h b/src/anim.h index 992f5010..274cade9 100644 --- a/src/anim.h +++ b/src/anim.h @@ -23,7 +23,7 @@ void RestartGlobalAnimsByStatus(int); void SetAnimStatusBeforeFading(int); boolean HandleGlobalAnimClicks(int, int, int, boolean); -void HandleGlobalAnimEventByElementChange(int, int, int, int); +void HandleGlobalAnimEventByElementChange(int, int, int, int, int, int); int getGlobalAnimSyncFrame(void); diff --git a/src/files.c b/src/files.c index 17a5fa8d..1514d4e6 100644 --- a/src/files.c +++ b/src/files.c @@ -11826,6 +11826,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) strEqual(value, "bottom") ? POS_BOTTOM : strEqual(value, "any") ? POS_ANY : strEqual(value, "ce") ? POS_CE : + strEqual(value, "ce_trigger") ? POS_CE_TRIGGER : strEqual(value, "last") ? POS_LAST : POS_UNDEFINED); } else if (strEqual(suffix, ".align")) diff --git a/src/game.c b/src/game.c index 94b74f78..51633eb1 100644 --- a/src/game.c +++ b/src/game.c @@ -3279,6 +3279,8 @@ static void InitGameEngine(void) change->actual_trigger_side = CH_SIDE_NONE; change->actual_trigger_ce_value = 0; change->actual_trigger_ce_score = 0; + change->actual_trigger_x = -1; + change->actual_trigger_y = -1; } } @@ -10759,6 +10761,8 @@ static boolean ChangeElement(int x, int y, int element, int page) change->actual_trigger_side = CH_SIDE_NONE; change->actual_trigger_ce_value = 0; change->actual_trigger_ce_score = 0; + change->actual_trigger_x = -1; + change->actual_trigger_y = -1; } // do not change elements more than a specified maximum number of changes @@ -10768,7 +10772,9 @@ static boolean ChangeElement(int x, int y, int element, int page) ChangeCount[x][y]++; // count number of changes in the same frame if (ei->has_anim_event) - HandleGlobalAnimEventByElementChange(element, page, x, y); + HandleGlobalAnimEventByElementChange(element, page, x, y, + change->actual_trigger_x, + change->actual_trigger_y); if (change->explode) { @@ -11098,6 +11104,8 @@ static boolean CheckTriggeredElementChangeExt(int trigger_x, int trigger_y, change->actual_trigger_side = trigger_side; change->actual_trigger_ce_value = CustomValue[trigger_x][trigger_y]; change->actual_trigger_ce_score = GET_CE_SCORE(trigger_element); + change->actual_trigger_x = trigger_x; + change->actual_trigger_y = trigger_y; if ((change->can_change && !change_done) || change->has_action) { @@ -11212,6 +11220,8 @@ static boolean CheckElementChangeExt(int x, int y, change->actual_trigger_side = trigger_side; change->actual_trigger_ce_value = CustomValue[x][y]; change->actual_trigger_ce_score = GET_CE_SCORE(trigger_element); + change->actual_trigger_x = x; + change->actual_trigger_y = y; // special case: trigger element not at (x,y) position for some events if (check_trigger_element) @@ -11235,6 +11245,8 @@ static boolean CheckElementChangeExt(int x, int y, change->actual_trigger_ce_value = CustomValue[xx][yy]; change->actual_trigger_ce_score = GET_CE_SCORE(trigger_element); + change->actual_trigger_x = xx; + change->actual_trigger_y = yy; } if (change->can_change && !change_done) diff --git a/src/libgame/system.h b/src/libgame/system.h index f321f217..b2f95e35 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -482,7 +482,8 @@ #define POS_BOTTOM 6 #define POS_ANY 7 #define POS_CE 8 -#define POS_LAST 9 +#define POS_CE_TRIGGER 9 +#define POS_LAST 10 // values for text alignment #define ALIGN_LEFT (1 << 0) diff --git a/src/main.h b/src/main.h index af5bed97..2b2d2b2c 100644 --- a/src/main.h +++ b/src/main.h @@ -3477,6 +3477,8 @@ struct ElementChangeInfo void (*post_change_function)(int x, int y); short actual_trigger_element; // element that actually triggered change + int actual_trigger_x; // element x position that triggered change + int actual_trigger_y; // element y position that triggered change int actual_trigger_side; // element side that triggered the change int actual_trigger_player; // player which actually triggered change int actual_trigger_player_bits; // player bits of triggering players