MrxTaskObjectiveDestroy
Module: mrxtaskobjectivedestroy.lua
Overview
The MrxTaskObjectiveDestroy module is a specific type of task objective that requires the player to destroy certain game objects. It inherits from MrxTaskObjective and adds functionality to handle object destruction events, manage target lists, and provide appropriate icons for different UI elements.
Inheritance
- Inherits from:
MrxTaskObjective - Imports:
none
Instance pattern
Not per-uGuid β inherits MrxTaskObjectiveβs class-factory pattern (itself inherited from MrxTask; see that page for the general mechanism), identified by name/lineage rather than a world-object GUID. Key fields:
_tEvents: A table to store event handles._uTgtObjFilter: A filter for target objects.
Functions
Activated(self)
Called when the task objective is activated. It sets up persistent events to listen for object deaths and client kills, and registers them in the _tEvents table. It also asserts that the death event handle is valid.
_TargetDestroyed(self, uGuid, uCause, uKiller)
The Event.ObjectDeath handler. If config bHeroOnly is set, it only counts the kill when uKiller matches one of the playersβ hero characters (loops Player.GetAllPlayers() β Player.GetCharacter); otherwise any death of a valid userdata target counts. On a counted kill it RemoveTarget + CompletePart. This is the mirror image of MrxTaskObjectiveProtect, which shares this exact shape but calls CancelPart (a protected target dying is a failure).
_GetShortDescription()
Returns a short description string for the task objective.
GetInlineIcon(self)
Returns an inline icon based on whether the objective is optional or not.
_GetTargetRadarIcon()
Returns the radar icon for the target object.
_GetTargetPdaIcon(bOptional)
Returns the PDA (Personal Digital Assistant) icon for the target object, depending on whether itβs optional or not.
_GetTargetGameSpaceIcon()
Returns the game space icon for the target object.
_IsValidTarget(uGuid)
A private function that checks if a given GUID is a valid target. It verifies if the GUID corresponds to any player character or an alive object.
Events
Both Event.CreatePersistent, created in Activated and stored in _tEvents:
Event.ObjectDeath(onself._uTgtObjFilter) β_TargetDestroyed.Event.ScriptEventwith name"ClientKill", filtered byObjectFilter.Evalon the target filter β an inline handler thatRemoveTarget+CompletePartfor the reported GUID. This is the co-op path so a kill made on a client still counts.
Inherits MrxTaskObjectiveβs Event.TimerRelative initial-notes timer.
Notes for modders
bHeroOnly(config) restricts credit to kills where a playerβs hero character was the killer β use it for βyou personally must destroy Xβ objectives so an AI or environment kill doesnβt count.- Choose targets via the filter, not by editing this module: config
sTgtLabelFilter/vTgtInclude/vTgtExclude/nQuotaall flow into the inherited_uTgtObjFilterand quota. - Destroy-specific art overrides: radar
"objective_destroy", world"HUD_objective_destroy", PDA"icon_destroy_1_mc"/"icon_destroy_2_mc", inline"[objdestroy]"/"[objdestroy2]".