AGS: Engine: Complete "object interaction events take obj pointer and mode as params" commit

This completes cb6cce267d75ccdbca452873693a1ccadf0f688b
This commit is contained in:
Walter Agazzi authored and Filippos Karapetis committed 2024-10-30 18:07:42 +02:00
1 parent dcd7be5b2d
commit 57464f3dce
6 files changed
+22 -8

No files matched your search

+4 -1
View File
@@ -41,10 +41,12 @@
#include "ags/engine/ac/properties.h"
#include "ags/engine/ac/screen_overlay.h"
#include "ags/engine/ac/string.h"
#include "ags/engine/ac/dynobj/cc_character.h"
#include "ags/engine/debugging/debug_log.h"
#include "ags/shared/game/room_struct.h"
#include "ags/engine/main/game_run.h"
#include "ags/engine/script/script.h"
#include "ags/globals.h"
namespace AGS3 {
@@ -388,7 +390,8 @@ void RunCharacterInteraction(int cc, int mood) {
_GP(play).usedinv = _G(playerchar)->activeinv;
}
const auto obj_evt = ObjectEvent("character%d", cc);
const auto obj_evt = ObjectEvent("character%d", cc,
RuntimeScriptValue().SetScriptObject(&_GP(game).chars[cc], &_GP(ccDynamicCharacter)), mood);
if (_G(loaded_game_file_version) > kGameVersion_272) {
if ((evnt >= 0) &&
run_interaction_script(obj_evt, _GP(game).charScripts[cc].get(), evnt, anyclick_evt) < 0)
+4 -3
View File
@@ -33,9 +33,11 @@
#include "ags/engine/ac/properties.h"
#include "ags/engine/ac/room_status.h"
#include "ags/engine/ac/string.h"
#include "ags/engine/ac/dynobj/cc_hotspot.h"
#include "ags/engine/debugging/debug_log.h"
#include "ags/shared/game/room_struct.h"
#include "ags/engine/script/script.h"
#include "ags/globals.h"
namespace AGS3 {
@@ -118,9 +120,8 @@ void RunHotspotInteraction(int hotspothere, int mood) {
else if ((mood != MODE_WALK) && (_GP(play).check_interaction_only == 0))
MoveCharacterToHotspot(_GP(game).playercharacter, hotspothere);
// can't use the setevent functions because this ProcessClick is only
// executed once in a eventlist
const auto obj_evt = ObjectEvent("hotspot%d", hotspothere);
const auto obj_evt = ObjectEvent("hotspot%d", hotspothere,
RuntimeScriptValue().SetScriptObject(&_G(scrHotspot)[hotspothere], &_GP(ccDynamicHotspot)), mood);
if (_G(loaded_game_file_version) > kGameVersion_272) {
if ((evnt >= 0) &&
@@ -30,9 +30,11 @@
#include "ags/engine/ac/inv_window.h"
#include "ags/engine/ac/properties.h"
#include "ags/engine/ac/string.h"
#include "ags/engine/ac/dynobj/cc_inventory.h"
#include "ags/shared/gui/gui_main.h"
#include "ags/shared/gui/gui_inv.h"
#include "ags/engine/script/script.h"
#include "ags/globals.h"
namespace AGS3 {
@@ -116,7 +118,9 @@ void RunInventoryInteraction(int iit, int mood) {
if (evnt < 0) // on any non-supported mode - use "other-click"
evnt = otherclick_evt;
auto obj_evt = ObjectEvent("inventory%d", iit);
const auto obj_evt = ObjectEvent("inventory%d", iit,
RuntimeScriptValue().SetScriptObject(&_G(scrInv)[iit], &_GP(ccDynamicInv)), mood);
if (_G(loaded_game_file_version) > kGameVersion_272) {
run_interaction_script(obj_evt, _GP(game).invScripts[iit].get(), evnt);
} else {
+4 -1
View File
@@ -37,6 +37,7 @@
#include "ags/engine/ac/room_object.h"
#include "ags/engine/ac/room_status.h"
#include "ags/engine/ac/string.h"
#include "ags/engine/ac/dynobj/cc_object.h"
#include "ags/engine/ac/view_frame.h"
#include "ags/engine/debugging/debug_log.h"
#include "ags/engine/main/game_run.h"
@@ -433,7 +434,9 @@ void RunObjectInteraction(int aa, int mood) {
_GP(play).usedinv = _G(playerchar)->activeinv;
}
const auto obj_evt = ObjectEvent("object%d", aa);
const auto obj_evt = ObjectEvent("object%d", aa,
RuntimeScriptValue().SetScriptObject(&_G(scrObj)[aa], &_GP(ccDynamicObject)), mood);
if (_G(loaded_game_file_version) > kGameVersion_272) {
if ((evnt >= 0) &&
run_interaction_script(obj_evt, _GP(thisroom).Objects[aa].EventHandlers.get(), evnt, anyclick_evt) < 0)
+4 -1
View File
@@ -26,6 +26,7 @@
#include "ags/engine/ac/region.h"
#include "ags/engine/ac/room.h"
#include "ags/engine/ac/room_status.h"
#include "ags/engine/ac/dynobj/cc_region.h"
#include "ags/engine/debugging/debug_log.h"
#include "ags/shared/game/room_struct.h"
#include "ags/shared/gfx/bitmap.h"
@@ -145,7 +146,9 @@ void RunRegionInteraction(int regnum, int mood) {
// NOTE: for Regions the mode has specific meanings (NOT verbs):
// 0 - stands on region, 1 - walks onto region, 2 - walks off region
const auto obj_evt = ObjectEvent("region%d", regnum);
const auto obj_evt = ObjectEvent("region%d", regnum,
RuntimeScriptValue().SetScriptObject(&_G(scrRegion)[regnum], &_GP(ccDynamicRegion)), mood);
if (_G(loaded_game_file_version) > kGameVersion_272) {
run_interaction_script(obj_evt, _GP(thisroom).Regions[regnum].EventHandlers.get(), mood);
} else {
+1 -1
View File
@@ -164,7 +164,7 @@ int run_interaction_script(const ObjectEvent &obj_evt, InteractionScripts *nint,
return -1;
}
int room_was = _GP(play).room_changes;
const int room_was = _GP(play).room_changes;
// TODO: find a way to generalize all the following hard-coded behavior