@@ -146,6 +146,26 @@ def handle_data(self, ts, data):
146146 idx , entity = sre .groups ()
147147 entity = self .parse_entity_or_player (entity )
148148 self ._metadata_node .info .append (entity )
149+ elif opcode == "Source" :
150+ sre = tokens .SUB_SPELL_START_SOURCE_RE .match (data )
151+ if not sre :
152+ raise RegexParsingError (data )
153+ entity , = sre .groups ()
154+ entity = self .parse_entity_or_player (entity )
155+ if not isinstance (self .current_block , packets .SubSpell ):
156+ logging .warning ("SubSpell Source outside of SUB_SPELL: %r" , data )
157+ return
158+ self .current_block .source = entity
159+ elif opcode .startswith ("Targets[" ):
160+ sre = tokens .SUB_SPELL_START_TARGETS_RE .match (data )
161+ if not sre :
162+ raise RegexParsingError (data )
163+ idx , entity = sre .groups ()
164+ entity = self .parse_entity_or_player (entity )
165+ if not isinstance (self .current_block , packets .SubSpell ):
166+ logging .warning ("SubSpell Target outside of SUB_SPELL: %r" , data )
167+ return
168+ self .current_block .targets .append (entity )
149169 else :
150170 raise NotImplementedError (data )
151171
@@ -211,6 +231,10 @@ def handle_power(self, ts, opcode, data):
211231 regex , callback = tokens .META_DATA_RE , self .meta_data
212232 elif opcode == "RESET_GAME" :
213233 regex , callback = tokens .RESET_GAME_RE , self .reset_game
234+ elif opcode == "SUB_SPELL_START" :
235+ regex , callback = tokens .SUB_SPELL_START_RE , self .sub_spell_start
236+ elif opcode == "SUB_SPELL_END" :
237+ regex , callback = tokens .SUB_SPELL_END_RE , self .sub_spell_end
214238 else :
215239 raise NotImplementedError (data )
216240
@@ -337,6 +361,25 @@ def reset_game(self, ts):
337361 self .register_packet (packet )
338362 return packet
339363
364+ def sub_spell_start (self , ts , spell_prefab_guid , source , target_count ):
365+ id = int (source )
366+ target_count = int (target_count )
367+
368+ sub_spell = packets .SubSpell (ts , spell_prefab_guid , id , target_count )
369+ sub_spell .parent = self .current_block
370+ self .register_packet (sub_spell )
371+ self .current_block = sub_spell
372+ return sub_spell
373+
374+ def sub_spell_end (self , ts ):
375+ if not self .current_block .parent :
376+ logging .warning ("[%s] Orphaned SUB_SPELL_END detected" , ts )
377+ return self .current_block
378+ self .current_block .end ()
379+ sub_spell = self .current_block
380+ self .current_block = self .current_block .parent
381+ return sub_spell
382+
340383
341384class OptionsHandler :
342385 def __init__ (self ):
0 commit comments