Skip to content

Commit

Permalink
Add eventTransporterDisembarked
Browse files Browse the repository at this point in the history
Need this for when the player removes a unit from a transporter for reticule updating.
  • Loading branch information
KJeff01 committed Sep 28, 2023
1 parent 00ca99a commit 19b0a8c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions data/base/script/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,15 @@ function eventTransporterEmbarked(transport)
}
}

//Maybe no more truck/commanders on the map.
function eventTransporterDisembarked(transport)
{
if (transport.player === selectedPlayer)
{
reticuleUpdate(transport, TRANSFER_LIKE_EVENT);
}
}

function eventResearched(research, structure, player)
{
// NOTE: Research upgrades are handled by the C++ core game engine since 4.1.0
Expand Down
8 changes: 8 additions & 0 deletions data/mp/multiplay/script/rules/events/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ function eventTransporterEmbarked(transport)
reticuleUpdate(transport, TRANSFER_LIKE_EVENT);
}
}

function eventTransporterDisembarked(transport)
{
if (transport.player === selectedPlayer)
{
reticuleUpdate(transport, TRANSFER_LIKE_EVENT);
}
}
3 changes: 3 additions & 0 deletions src/qtscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,9 @@ bool triggerEvent(SCRIPT_TRIGGER_TYPE trigger, BASE_OBJECT *psObj)
case TRIGGER_TRANSPORTER_EMBARKED:
instance->handle_eventTransporterEmbarked(psObj);
break;
case TRIGGER_TRANSPORTER_DISEMBARKED:
instance->handle_eventTransporterDisembarked(psObj);
break;
case TRIGGER_MISSION_TIMEOUT:
instance->handle_eventMissionTimeout();
break;
Expand Down
1 change: 1 addition & 0 deletions src/qtscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum SCRIPT_TRIGGER_TYPE
TRIGGER_START_LEVEL,
TRIGGER_TRANSPORTER_ARRIVED,
TRIGGER_TRANSPORTER_EMBARKED,
TRIGGER_TRANSPORTER_DISEMBARKED,
TRIGGER_TRANSPORTER_LANDED,
TRIGGER_TRANSPORTER_LAUNCH,
TRIGGER_TRANSPORTER_EXIT,
Expand Down
7 changes: 7 additions & 0 deletions src/quickjs_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ class quickjs_scripting_instance : public wzapi::scripting_instance
//__
virtual bool handle_eventTransporterEmbarked(const BASE_OBJECT *psTransport) override;

//__ ## eventTransporterDisembarked(transport)
//__
//__ An event that is run when a unit disembarks from a transporter.
//__
virtual bool handle_eventTransporterDisembarked(const BASE_OBJECT *psTransport) override;

public:
// MARK: UI-related events (intended for the tutorial)

Expand Down Expand Up @@ -2948,6 +2954,7 @@ IMPL_EVENT_HANDLER(eventTransporterExit, const BASE_OBJECT *)
IMPL_EVENT_HANDLER(eventTransporterDone, const BASE_OBJECT *)
IMPL_EVENT_HANDLER(eventTransporterLanded, const BASE_OBJECT *)
IMPL_EVENT_HANDLER(eventTransporterEmbarked, const BASE_OBJECT *)
IMPL_EVENT_HANDLER(eventTransporterDisembarked, const BASE_OBJECT *)

// MARK: UI-related events (intended for the tutorial)
IMPL_EVENT_HANDLER(eventDeliveryPointMoving, const BASE_OBJECT *)
Expand Down
5 changes: 5 additions & 0 deletions src/transporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,11 @@ void transporterRemoveDroid(DROID *psTransport, DROID *psDroid, QUEUE_MODE mode)
//make sure the button isn't flashing
stopMissionButtonFlash(IDTRANS_LAUNCH);
}

// Fire off disembark event
transporterSetScriptCurrent(psTransport);
triggerEvent(TRIGGER_TRANSPORTER_DISEMBARKED, psTransport);
transporterSetScriptCurrent(nullptr);
}

/*adds a droid to the current transporter via the interface*/
Expand Down
6 changes: 6 additions & 0 deletions src/wzapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ namespace wzapi
//__
virtual bool handle_eventTransporterEmbarked(const BASE_OBJECT *psTransport) SCRIPTING_EVENT_NON_REQUIRED

//__ ## eventTransporterDisembarked(transport)
//__
//__ An event that is run when a unit disembarks from a transporter.
//__
virtual bool handle_eventTransporterDisembarked(const BASE_OBJECT *psTransport) SCRIPTING_EVENT_NON_REQUIRED

public:
// MARK: UI-related events (intended for the tutorial)

Expand Down

0 comments on commit 19b0a8c

Please sign in to comment.