Open Luashine opened 8 months ago
I double checked it, the list is almost complete:
"NONE" is missing from table above = value 1
"TERRAIN" returns 0 -- a bug?
"Non-Sapper" in WE, "NonSuicidal" name by Arxos
"Sapper" in WE, "Suicidal" name by Arxos
<NONE SELECTED>
aka WE enforces some default = -36573170 = Ground | Air | Structure | Self | PlayerUnits | Allied | Neutral | Enemy | Vulnerable | Hero | NonHero | Alive | Organic | Mech | NonSapper | Sapper | NonAncient | Ancient
I've done some more testing with NONE and TERRAIN. "NONE" seems to be a legit target flag, if its ON (i've only tested it alone) then the unit will not have an attack nor an attack icon. However all UI order buttons will be present. Except when you click a target unit (frost arrow with NONE) then your unit will just "attack move" to that position (actually just move)
With only "TERRAIN" enabled I think the game resets it to default from above. Everything works. I am not sure if TERRAIN is supposed to be there or do anything special. I thought they had just swapped terrain & none.
Here's one old post asking about terrain not working, no further explanation: https://www.hiveworkshop.com/threads/help-can-cold-arrows-target-terrain.217982/
BlzGetUnitWeaponIntegerField(u, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
because in this lookup code I don't specify anything, the confusion is ought to be on WorldEditors end.
unit - weapon1 / weapon2 h000 - air/alive 4,16777216 h001 - allies/ancient 16384,-2147483648 h002 - bridge/dead 1024,33554432 h003 - debris/deco 256,512 h004 - enemy/friend 65536,24576 h005 - ground/hero 2,4194304 h006 - invul/item 2097152,32 h007 - mech/neutr 134217728,32768 h008 - non-ancient/none 1073741824,1 h009 - non-hero/non-sapper 8388608,268435456 h00A - not self/organic 122880,67108864 h00B - player/sapper 8192,536870912 h00C - self/structure 4096,8 h00D - terrain/tree 0,64 h00E - vulnerable/wall 1048576,128 h00F - ward/NONE SELECTED 16,-36573170
--[[
unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED
native BlzGetUnitWeaponIntegerField takes unit whichUnit, unitweaponintegerfield whichField, integer index returns integer
native BlzSetUnitWeaponIntegerField takes unit whichUnit, unitweaponintegerfield whichField, integer index, integer value returns boolean
]]
function printUnitAttacks(unitType)
local u = CreateUnit(Player(0), FourCC(unitType), -30, 0, 90)
local wpn0 = BlzGetUnitWeaponIntegerField(u, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
local wpn1 = BlzGetUnitWeaponIntegerField(u, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 1)
local wpn2 = BlzGetUnitWeaponIntegerField(u, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 2)
print(string.format("%4s: %14d %14d %6d", unitType, wpn0, wpn1, wpn2))
RemoveUnit(u)
end
print("unitType | idx0, idx1, idx2 (if buggy)")
unitRawcodes = {
"h000","h001",
"h002","h003",
"h004","h005",
"h006","h007",
"h008","h009",
"h00A","h00B",
"h00C","h00D",
"h00E","h00F",
}
for _, rawcode in ipairs(unitRawcodes) do
printUnitAttacks(rawcode)
end
I don't know if either TERRAIN/NONE have some special behavior when used with other natives or orders. If anyone has any ideas, feel free. I will attach the map with units having one target type per attack and the tests with none/terrain. It will save you some time setting it up.
By Arxos in Hive Discord