- Joined
- Feb 8, 2015
- Messages
- 687
Hello there, the native BlzSetUnitWeaponRealFieldBJ is bugged for setting the range (UNIT_WEAPON_RF_ATTACK_RANGE).
☼ Doesn't work for the weapon index 2
☼ For weapon index 1, will add the new range minus the difference between the base value of weapon 1 and 2
Also some getter/setter are based on index 0 and 1, as other are based on 1 and 2 which can be confusing.
For example, setting a peasant range to 100 will add 100 - (90-66) = 34 instead, so we go from 90 to 124. Setting it again to 100 will add 34 again and again.
This is a tiny snippet to fix this for at least 1.36 and for weapon index 1.
No need to credit me in your map.
If someone has other solutions, even about similar cases, feel free to pursue this topic.
This snipped will be rendered useless once it is fixed, or broken in another way.
☼ Doesn't work for the weapon index 2
☼ For weapon index 1, will add the new range minus the difference between the base value of weapon 1 and 2
Also some getter/setter are based on index 0 and 1, as other are based on 1 and 2 which can be confusing.
For example, setting a peasant range to 100 will add 100 - (90-66) = 34 instead, so we go from 90 to 124. Setting it again to 100 will add 34 again and again.
This is a tiny snippet to fix this for at least 1.36 and for weapon index 1.
JASS:
// Getter is based on index 0 and 1
// Setter is based on index 1 and 2
// WHY BLIZZARD WHYYYYY
function SetUnitRange takes unit u, real newRange returns nothing
call BlzSetUnitWeaponRealFieldBJ(u,UNIT_WEAPON_RF_ATTACK_RANGE,1,newRange-BlzGetUnitWeaponRealField(u,UNIT_WEAPON_RF_ATTACK_RANGE,0)+BlzGetUnitWeaponRealField(u,UNIT_WEAPON_RF_ATTACK_RANGE,1))
endfunction
No need to credit me in your map.
If someone has other solutions, even about similar cases, feel free to pursue this topic.
This snipped will be rendered useless once it is fixed, or broken in another way.