I put together a function that will determine what type of parley (incite, interview, entertain, gossip, convince) is available on an npc at the icon coordinates specified. It does this by reading pixel RGB values.
Usage:
function determineParleyType(x as integer, y as integer)
where X,Y is the coordinate of the center of the inkwell on the inkwell icon for the parley you want analyzed. There is about a +/- 4 pixel vertical tolerance from the horizontal centerline through the expression icons.
Returns the following integer:
0: Could not determine (probably bad icon location)
1: Interview
2: Entertain
3: Gossip
4: Convince
5: Incite
In my tests, it worked for all five types, although an Interview was erroneously reported as Entertain at one of the vertical boundaries. It was still reliable within a 9 vertical pixel range in all tests.
The only requirement is the default /parleyassess window. Obviously, pixel analysis is touchy if people start messing with positions or colors.
My suggestion is to have this procedure called four times before each parley after the /parleyasses command is given, one at each possible icon position for four parleys (the locations won't change, just add x pixels to the base loc for each of the three others)
fyi, all local variables have been declared in case you are using option explicit.
Code: Register to unlock hidden link
function determineParleyPixelColor(x,y) 'Support function for determineParleyType(x,y) -- returns 1 if found red button, 2 for green, 3 for blue, 4 for yellow. Returns 0 if no match
dim pixelColor
dim rval, bval, gval
dim csum
dim rratio, bratio, gratio
dim rtest, btest, gtest
determineParleyPixelColor = 0
pixelColor = GetPixelColor(x,y)
rval= ExtractRGB_Red(pixelColor)
bval= ExtractRGB_Blue(pixelColor)
gval= ExtractRGB_Green(pixelColor)
csum = rval + bval + gval
if csum > 200 AND csum < 430 then 'filter dark pixels and most light background pixels to save processing time
rratio = rval / csum
bratio = bval / csum
gratio = gval / csum
'red (demand) check
rtest = ABS(rratio - 0.66) - 0.015
gtest = ABS(gratio - 0.19) - 0.015
btest = ABS(bratio - 0.15) - 0.02
if (rtest <= 0) AND (gtest <= 0) AND (btest <= 0) then
determineParleyPixelColor = 1
exit function
end if
'green (reason) check
rtest = ABS(rratio - 0.28) - 0.015
gtest = ABS(gratio - 0.47) - 0.02
btest = ABS(bratio - 0.25) - 0.01
if (rtest <= 0) AND (gtest <= 0) AND (btest <= 0) then
determineParleyPixelColor = 2
exit function
end if
'blue (inspire) check
rtest = ABS(rratio - 0.27) - 0.01
gtest = ABS(gratio - 0.31) - 0.015
btest = ABS(bratio - 0.42) - 0.01
if (rtest <= 0) AND (gtest <= 0) AND (btest <= 0) then
determineParleyPixelColor = 3
exit function
end if
'yellow (flattery) check
rtest = ABS(rratio - 0.47) - 0.015
gtest = ABS(gratio - 0.42) - 0.015
btest = ABS(bratio - 0.13) - 0.025
if (rtest <= 0) AND (gtest <= 0) AND (btest <= 0) then
determineParleyPixelColor = 4
exit function
end if
end if
end function
function determineParleyType(x,y) 'Takes x,y coordinate of center of inkwell in inkwell icon. Returns 1 if interview, 2 if entertain, 3 if gossip, 4 if convince, 5 if incite. Returns 0 if no match (error)
dim foundDemand, foundReason, foundInspire, foundFlattery
dim i
dim pixelColor
determineParleyType = 0
foundDemand = FALSE
foundReason = FALSE
foundInspire = FALSE
foundFlattery = FALSE
for i = 66 to 206
pixelColor = determineParleyPixelColor(x+i, y)
' debugLog pixelColor
select case pixelColor
case 1 foundDemand = TRUE
case 2 foundReason = TRUE
case 3 foundInspire = TRUE
case 4 foundFlattery = TRUE
end select
next
if foundDemand AND foundReason AND foundInspire AND foundFlattery then
determineParleyType = 1
exit function
elseif foundReason AND foundInspire AND foundFlattery then
determineParleyType = 2
exit function
elseif foundDemand AND foundInspire AND foundFlattery then
determineParleyType = 3
exit function
elseif foundDemand AND foundReason AND foundFlattery then
determineParleyType = 4
exit function
elseif foundDemand AND foundReason AND foundInspire then
determineParleyType = 5
exit function
else
debugLog "Could not determine parley type! Possibly the X,Y coordinates aren't correct."
end if
end function