@@ -17,6 +17,9 @@ status_effects = {
1717 party_player_ids = {},
1818
1919 current_tick = 1 ,
20+
21+ -- incrementing unique identifier used by some buffs to make them unique in the composite key
22+ current_buff_id = 1
2023}
2124
2225function status_effects :initialize ()
@@ -31,6 +34,7 @@ function status_effects:destroy()
3134 self .bard_highest_known_max = {}
3235 self .party_player_ids = {}
3336 self .current_tick = 1
37+ self .current_buff_id = 1
3438end
3539
3640function status_effects :get_id_from_player_name (player_name )
@@ -289,7 +293,41 @@ function status_effects:find_buffs_in_action(data)
289293 -- PUPPET OVERLOAD
290294 ---- ----------------------------------------------------------------------------
291295 elseif message_id == 799 then
292- self :add_buff_pup (target .id , nil , 299 )
296+ self :add_buff_pup (target .id , 299 )
297+
298+
299+ ---- ----------------------------------------------------------------------------
300+ -- PUPPET MANEUVER
301+ ---- ----------------------------------------------------------------------------
302+ elseif message_id == 798 then
303+ source = ' ABILITY'
304+ local ability_id = data .param -- data.param will capture ${ability} in original message
305+ local type = res .job_abilities [ability_id ].type
306+ local buff_id
307+
308+ if ability_id == 141 then
309+ buff_id = 300
310+ elseif ability_id == 141 then
311+ buff_id = 300
312+ elseif ability_id == 142 then
313+ buff_id = 301
314+ elseif ability_id == 143 then
315+ buff_id = 302
316+ elseif ability_id == 144 then
317+ buff_id = 303
318+ elseif ability_id == 145 then
319+ buff_id = 304
320+ elseif ability_id == 146 then
321+ buff_id = 305
322+ elseif ability_id == 147 then
323+ buff_id = 306
324+ elseif ability_id == 148 then
325+ buff_id = 307
326+ end
327+
328+ if buff_id then
329+ self :add_buff (target .id , source , ability_id , buff_id , type , actor_id )
330+ end
293331
294332 ---- ----------------------------------------------------------------------------
295333 -- MAGIC REMOVE BUFF
@@ -916,10 +954,10 @@ function status_effects:add_buff(target_id, source_type, source_id, buff_id, typ
916954 self :update_target_zone (target_id , self .current_zone )
917955end
918956
919- function status_effects :get_known_duration (spell_id )
920- if spell_id == 112 then
957+ function status_effects :get_known_spell_duration (spell_id )
958+ if spell_id == 112 then -- flash
921959 return 6
922- elseif spell_id == 136 then
960+ elseif spell_id == 136 then -- invis/sneak/deodorize
923961 return 600
924962 elseif spell_id == 137 then
925963 return 600
@@ -928,9 +966,15 @@ function status_effects:get_known_duration(spell_id)
928966 end
929967end
930968
969+ function status_effects :get_known_ability_duration (ability_id )
970+ if ability_id >= 141 and ability_id <= 148 then -- manuevers
971+ return 60
972+ end
973+ end
974+
931975function status_effects :add_buff_ma (target_id , spell_id , buff_id , type , actor_id )
932976 local spell = res .spells [spell_id ]
933- local duration = spell .duration or self :get_known_duration (spell_id ) or 60
977+ local duration = spell .duration or self :get_known_spell_duration (spell_id ) or 60
934978
935979 if spell then
936980 -- Prepare composite key
@@ -1139,6 +1183,7 @@ function status_effects:add_buff_ma(target_id, spell_id, buff_id, type, actor_id
11391183 type = type ,
11401184 category = buff_types [buff_id ] or " " ,
11411185 }
1186+ self .current_buff_id = self .current_buff_id + 1
11421187 end
11431188end
11441189
@@ -1182,12 +1227,15 @@ function status_effects:add_buff_ws(target_id, ability_id, buff_id, type, actor_
11821227 type = type ,
11831228 category = buff_types [buff_id ] or " "
11841229 }
1230+ self .current_buff_id = self .current_buff_id + 1
11851231 end
11861232end
11871233
11881234function status_effects :add_buff_ja (target_id , ability_id , buff_id , type , actor_id )
11891235 local ability = res .job_abilities [ability_id ]
1190- if ability and ability .duration then
1236+ local duration = ability .duration or self :get_known_ability_duration (ability_id )
1237+
1238+ if ability and duration then
11911239 -- Prepare composite key
11921240 local composite_key = ' ja:' .. ability_id
11931241
@@ -1207,7 +1255,6 @@ function status_effects:add_buff_ja(target_id, ability_id, buff_id, type, actor_
12071255 end
12081256 end
12091257
1210-
12111258 -- Corsair rolls logic
12121259 if type == ' CorsairRoll' then
12131260 local corsair_id = actor_id
@@ -1281,6 +1328,42 @@ function status_effects:add_buff_ja(target_id, ability_id, buff_id, type, actor_
12811328 end
12821329 end
12831330
1331+ -- Puppet maneuver logic
1332+ if type == ' PetCommand' and ability .id >= 141 and ability .id <= 148 then
1333+ type = ' Maneuver' -- rename type
1334+
1335+ local puppet_id = actor_id
1336+ local target_buffs = self .buffs [target_id ]
1337+
1338+ -- Count manuevers
1339+ local puppet_manus = {}
1340+
1341+ for b_id , spell_table in pairs (target_buffs ) do
1342+ for c_id , buff in pairs (spell_table ) do
1343+ if buff .type == ' Maneuver' then
1344+ if buff .actor_id == puppet_id and buff .type == ' Maneuver' then
1345+ table.insert (puppet_manus , { buff_id = b_id , composite_key = c_id , duration = buff .end_time - os.clock () })
1346+ end
1347+ end
1348+ end
1349+ end
1350+
1351+ -- add unique composite key portion
1352+ composite_key = composite_key .. " :" .. self .current_buff_id
1353+
1354+ -- If Puppet has reached max manus
1355+ if # puppet_manus >= 3 then
1356+ -- Find the shortest duration manu
1357+ table.sort (puppet_manus , function (a , b ) return a .duration < b .duration end )
1358+ local shortest_manu = puppet_manus [1 ]
1359+ self .buffs [target_id ][shortest_manu .buff_id ][shortest_manu .composite_key ] = nil -- Replace it
1360+
1361+ -- Clean up if the spell table is empty
1362+ if next (self .buffs [target_id ][shortest_manu .buff_id ]) == nil then
1363+ self .buffs [target_id ][shortest_manu .buff_id ] = nil
1364+ end
1365+ end
1366+ end
12841367
12851368 -- Ensure the table structure exists
12861369 if not self .buffs [target_id ] then
@@ -1293,47 +1376,46 @@ function status_effects:add_buff_ja(target_id, ability_id, buff_id, type, actor_
12931376 -- Add the new buff
12941377 self .buffs [target_id ][buff_id ][composite_key ] = {
12951378 buff_id = buff_id ,
1296- end_time = os.clock () + ability . duration ,
1379+ end_time = os.clock () + duration ,
12971380 originating_spell = ability .en ,
12981381 originating_id = composite_key ,
12991382 actor_id = actor_id ,
13001383 target_id = target_id ,
13011384 type = type ,
13021385 category = buff_types [buff_id ] or " "
13031386 }
1387+ self .current_buff_id = self .current_buff_id + 1
13041388 end
13051389end
13061390
1307- function status_effects :add_buff_pup (target_id , ability_id , buff_id )
1308- if ability_id == nil then
1309- -- Prepare composite key
1310- local composite_key = ' ja:' .. ability_id
1391+ function status_effects :add_buff_pup (target_id , buff_id )
1392+ -- Prepare composite key
1393+ local composite_key = ' ja:-1'
13111394
1312- -- overloaded status
1313- -- remove all maneuvers
1314- for _ , overwritten_id in pairs ({ 141 , 142 , 143 , 144 , 145 , 146 , 147 , 148 }) do
1315- self :remove_buff_given_by_id (target_id , ' ja:' .. overwritten_id )
1316- end
1317-
1318- -- add overloaded
1319- if not self .buffs [target_id ] then
1320- self .buffs [target_id ] = {}
1321- end
1322- if not self .buffs [target_id ][buff_id ][0 ] then
1323- self .buffs [target_id ][buff_id ] = {}
1324- end
1395+ -- overloaded status
1396+ -- remove all maneuvers
1397+ for _ , maneuver_buff_id in pairs ({ 300 , 301 , 302 , 303 , 304 , 305 , 306 , 307 }) do
1398+ self :remove_buff_with_priority (target_id , maneuver_buff_id , true )
1399+ end
13251400
1326- self .buffs [target_id ][buff_id ][composite_key ] = {
1327- buff_id = buff_id ,
1328- end_time = os.clock () + 60 ,
1329- originating_spell = ' Maneuver' ,
1330- originating_id = composite_key ,
1331- actor_id = target_id ,
1332- target_id = target_id ,
1333- type = ' Maneuver' ,
1334- category = buff_types [buff_id ] or " "
1335- }
1401+ -- add overloaded
1402+ if not self .buffs [target_id ] then
1403+ self .buffs [target_id ] = {}
1404+ end
1405+ if not self .buffs [target_id ][buff_id ] then
1406+ self .buffs [target_id ][buff_id ] = {}
13361407 end
1408+
1409+ self .buffs [target_id ][buff_id ][composite_key ] = {
1410+ buff_id = buff_id ,
1411+ end_time = os.clock () + 60 ,
1412+ originating_spell = ' Maneuver' ,
1413+ originating_id = composite_key ,
1414+ actor_id = target_id ,
1415+ target_id = target_id ,
1416+ type = ' Overload' ,
1417+ category = buff_types [buff_id ] or " "
1418+ }
13371419end
13381420
13391421function status_effects :remove_buff_given_by_id (target_id , composite_id )
0 commit comments