zealvurte / SimSimMissionWin

WoW addon for the Shadowlands command table
GNU General Public License v3.0
4 stars 2 forks source link

Effect.Target logic #5

Open zealvurte opened 3 years ago

zealvurte commented 3 years ago

Effect.Target values are somewhat complex, unintuitive, and hindered with some errors in the game's implementation.

I've attempted to document and implement them in a way that helps me visualise and debug them easier. This is very much an incomplete work in progress and somewhat speculative in places.

{
    [0]={   -- NONE
        text="nothing"
    },
    [1]={   -- SELF
        text="self",
        targets=function (source) return source end,
    },
    [2]={   -- ADJACENT_FRIENDLY
        text="closest ally",
        targets={
            -- [source]=targetByPriority
            [-1]={5,6,7,8,9,10,11,12},
            [0]={2,3,1,4},          {0,3,4,2},
            {0,3,1,4},          {2,0,1,4},      {3,1,2,0},
            {5,6,10,7,9,11,8,12},       {5,10,7,11,6,9,12,8},   {6,11,10,12,8,7,5,9},   {7,6,8,11,12,9,5,10},
            {5,10,6,9,7,8,11,12},       {9,6,11,5,7,10,8,12},   {10,7,8,12,6,9,11,5},   {8,11,7,12,6,5,10,9},
        },
    },
    [3]={   -- ADJACENT_HOSTILE
        text="closest enemy",
        targets={
            -- [source]=targetByPriority
            [-1]={0,1,2,3,4},
            [0]={5,6,10,7,9,11,8,12},   {6,7,11,8,10,12,5,9},
            {5,6,9,10,7,11,8,12},       {6,7,5,10,9,11,8,12},   {7,8,6,11,10,12,5,9},
            {2,0,3,1,4},            {2,3,0,1,4},        {3,4,2,0,1},        {4,3,1,2,0},
            {2,3,0,1,4},            {2,3,4,0,1},        {2,3,4,0,1},        {4,3,2,0,1},
        },
    },
    [4]={   -- RANGED_FRIENDLY  (Unused)
        text="furthest ally",
        targets={
            -- [source]=targetByPriority

        },
    },
    [5]={   -- RANGED_HOSTILE
        text="furthest enemy",
        targets={
            -- [source]=targetByPriority
            [-1]={4,3,2,1,0},
            [0]={12,8,9,11,10,5,7,6},   {9,5,10,12,11,6,8,7},
            {12,8,11,7,9,10,5,6},       {9,12,5,8,10,11,6,7},   {9,5,10,6,11,12,7,8},
            {4,1,3,0,2},            {4,1,0,2,3},        {2,0,1,3,4},        {2,0,3,1,4},
            {4,1,0,3,2},            {1,0,4,2,3},        {0,1,2,3,4},        {2,0,1,3,4},
        },
    },
    [6]={   -- ALL_FRIENDLIES
        text="all allies",
        targets={
            -- [source.type(environment|follower|encounter)]=targets
            [-1]={-1}
            [0]={0,1,2,3,4}
            [1]={5,6,7,8,9,10,11,12}
        },
    },
    [7]={   -- ALL_HOSTILES
        text="all enemies",
        targets={
            -- [source.type(environment|follower|encounter)]=targets
            [-1]={0,1,2,3,4}
            [0]={5,6,7,8,9,10,11,12}
            [1]={0,1,2,3,4}
        },
    },
    [8]={   -- ALL_ADJACENT_FRIENDLIES  (closest ally, then additional targets)
        text="closest allies",
        targets={
            -- [source]={[target]=additionalTargets}
        }
    },
    [9]={
        text="closest enemies", -- ALL_ADJACENT_HOSTILES    (closest enemy, then additional targets)
        targets={
            -- [source]={[target]=additionalTargets}
            [0]={[5]=6, [10]={7,9,11},  [7]={9,11}, [9]=11,     [8]=12},
            [1]={[6]=7, [11]={8,10,12}, [8]={10,12},    [10]=12,    [5]=9},
            [2]={[5]=6, [9]=10,     [7]=11,     [8]=12},
            [3]={[6]=7, [5]={9,10,11},  [10]={9,11},    [9]=11,     [8]=12},
            [4]={[7]=8, [6]={10,11,12}, [11]={10,12},   [10]=12,    [5]=9}
            [5]={[2]=nil,   [0]=3,      [1]=4},
            [6]={[2]=3, [0]=nil,    [1]=4},
            [7]={[3]=4, [2]={0,1},  [0]=1},
            [8]={[4]=nil,   [3]=1,      [2]=0},
            [9]={[2]=nil,   [3]=nil,    [0]=nil,    [1]=4},
            [10]={[2]=nil,  [3]=nil,    [0]=1,      [4]=nil},
            [11]={[2]=3,    [4]=nil,    [0]=1},
            [12]={[3]=4,    [2]=nil,    [0]=1},
        },
    },
    [10]="closest cone of allies",  -- CONE_FRIENDLIES  (closest ally, then cone selection) #Note: All known cases are from encounters where the closest ally is in the back row with the cone targeting towards the back of the encounters side, so this just acts like closest ally for those
    [11]="closest cone of enemies", -- CONE_HOSTILES    (closest enemy, then cone selection)
    [12]="closest column of allies",    -- LINE_FRIENDLIES  (closest ally, then column selection)
    [13]="closest column of enemies",   -- LINE_HOSTILES    (closest enemy, then column selection) #Bug: Column does not work on followers, so this acts like closest enemy for encounters
    [14]="frontmost row of allies", -- ALL_FRONT_ROW_FRIENDLIES (closest row with allies selection)
    [15]="frontmost row of enemies",    -- ALL_FRONT_ROW_HOSTILES   (closest row with enemies selection)
    [16]="backmost row of allies",  -- ALL_BACK_ROW_FRIENDLIES  (furthest row with allies selection)
    [17]="backmost row of enemies", -- ALL_BACK_ROW_HOSTILES    (furthest row with enemies selection)
    [18]="all targets", -- ALL_TARGETS
    [19]="random target",   -- RANDOM_TARGET
    [20]="random follower", -- RANDOM_ALLY
    [21]="random encounter",    -- RANDOM_ENEMY
    [22]="all-other allies",    -- ALL_FRIENDLIES_BUT_SELF
    [23]="all followers",   -- UNKNOWN
    [24]="all encounters",  -- UNKNOWN
}

VP switches up some of the target values, uses different names for others, and simply doesn't implement some that see no usage. The targeting logic it used for effect.target=9 is (now?) incorrect and has required changes, which are also reflected above. For VP I decided to rewrite the handling for this and use a single table of target values similar to the above, which ends up being the below:

{
        -- #Mod-Start: Improve cleave targeting
        [0x05]=6,   [0x0a]={7,9,11},    [0x07]={9,11},  [0x09]=11,  [0x08]=12,
        [0x16]=7,   [0x1b]={8,10,12},   [0x18]={10,12}, [0x1a]=12,  [0x15]=9,
        [0x25]=6,   [0x29]=10,      [0x27]=11,  [0x28]=12,
        [0x36]=7,   [0x35]={9,10,11},   [0x3a]={9,11},  [0x39]=11,  [0x38]=12,
        [0x47]=8,   [0x46]={10,11,12},  [0x4b]={10,12}, [0x4a]=12,  [0x45]=9,
        [0x52]=nil, [0x50]=3,       [0x51]=4,
        [0x62]=3,   [0x60]=nil,     [0x61]=4,
        -- #Bug: [0x63]=2 is unused (VERIFIED)
        -- #Fix: Remove [0x63] (VERIFIED)
        -- #Bug: [0x61]=4 is missing (UNVERIFIED)
        -- #Fix: Add [0x61]=4 (UNVERIFIED)
        [0x73]=4,   [0x72]={0,1},       [0x70]=1,
        [0x84]=nil, [0x83]=1,       [0x82]=0,
        [0x92]=nil, [0x93]=nil,     [0x90]=nil, [0x91]=4,
        -- #Bug: [0x91]=4 is missing (VERIFIED)
        -- #Fix: Add [0x91]=4 (VERIFIED)
        [0xa2]=nil, [0xa3]=nil,     [0xa0]=1,   [0xa4]=nil,
        -- #Bug: [0xa2]=3 is incorrect (VERIFIED)
        -- #Fix: Change to [0xa2]=nil (VERIFIED)
        -- #Bug: [0xa3]=2 is incorrect (UNVERIFIED)
        -- #Fix: Change to [0xa3]=nil (UNVERIFIED)
        -- #Bug: [0xa0]=1 is missing (UNVERIFIED)
        -- #Fix: Add [0xa0]=1 (UNVERIFIED)
        [0xb2]=3,   [0xb4]=nil,     [0xb0]=1,
        -- #Bug: [0xb2]=3 is missing (VERIFIED)
        -- #Fix: Add [0xb2]=3 (VERIFIED)
        -- #Bug: [0xb3]=4 is incorrect (VERIFIED)
        -- #Fix: Remove [0xb3] (VERIFIED)
        -- #Bug: [0xb4]=3 is incorrect (VERIFIED)
        -- #Fix: Remove [0xb4] (VERIFIED)
        -- #Bug: [0xb0]=1 is missing (VERIFIED)
        -- #Fix: Add [0xb0]=1 (VERIFIED)
        [0xc3]=4,   [0xc2]=nil,     [0xc0]=1,
        -- #Bug: [0xc3]=4 is missing (VERIFIED)
        -- #Fix: Add [0xc3]=4 (VERIFIED)
        -- #Bug: [0xc0]=1 is missing (VERIFIED)
        -- #Fix: Add [0xc0]=1 (VERIFIED)
        -- #Mod-End: Improve cleave targeting
}
zealvurte commented 3 years ago

If you have any mission logs that show this logic to be incorrect or lacking, please submit it in a new issue.