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:
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.
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: