- Joined
- Oct 17, 2012
- Messages
- 859
Instead of forcing the use of Acquisition Range, which is important for game play, you could use the new native to get the unit's actual range.
The added benefit is that for maps well on their way to finalizing won't need all their units to have their Acquisition Range changed. Otherwise, this could become a hassle for these developers. For maps in the early phrase of development, less unnecessary work would be granted to them. Of course, third party tools could also circumvent this somewhat tedious work, but to install a third party tool for just this may not be well received as the past have dictated.
At the same time, the native makes it possible to get the ranges of both Attacks if the unit has a second one. In addition, via standalone functions, one could display range in any situation, not just during a spell cast.
A while back, the new native was mentioned as dysfunctional in List of non-working object data constants. I have tested the new native in the latest patch, and it is working fine.
For spell cast, just code a demo that peeps can copy to their map like so.
Aniki, at one point, also made a similar system, using images for the display. His could benefit from automatic range detection.
The added benefit is that for maps well on their way to finalizing won't need all their units to have their Acquisition Range changed. Otherwise, this could become a hassle for these developers. For maps in the early phrase of development, less unnecessary work would be granted to them. Of course, third party tools could also circumvent this somewhat tedious work, but to install a third party tool for just this may not be well received as the past have dictated.
At the same time, the native makes it possible to get the ranges of both Attacks if the unit has a second one. In addition, via standalone functions, one could display range in any situation, not just during a spell cast.
A while back, the new native was mentioned as dysfunctional in List of non-working object data constants. I have tested the new native in the latest patch, and it is working fine.
JASS:
library RangeShower
globals
// ---------------- CONFIGURATION
// Default values for sfx coloring in decimal format
private constant integer RED = 0
private constant integer GREEN = 0
private constant integer BLUE = 255
// Model displayed to show range
private constant string FX_MODEL = "RangeCircle.mdx"
// Value to adjust size of sfx with
private constant real FX_SCALE_ADJUSTMENT = 50.
// ---------------- END OF CONFIGURATION
endglobals
globals
private effect sfx
endglobals
// Use 0 for weaponIndex to get the range of Attack 1
// Use 1 for Attack 2
function ShowRangeEx takes unit u, integer weaponIndex, integer red, integer green, integer blue returns effect
local string path = ""
if GetLocalPlayer() == GetOwningPlayer(u) then
set path = FX_MODEL
endif
set sfx = null
set sfx = AddSpecialEffect(path, GetUnitX(u), GetUnitY(u))
call BlzSetSpecialEffectX(sfx, GetUnitX(u))
call BlzSetSpecialEffectY(sfx, GetUnitY(u))
call BlzSetSpecialEffectZ(sfx, 0)
call BlzSetSpecialEffectScale(sfx, BlzGetUnitWeaponRealField(u, UNIT_WEAPON_RF_ATTACK_RANGE, weaponIndex) / FX_SCALE_ADJUSTMENT)
call BlzSetSpecialEffectColor(sfx, red, green, blue) // SET TEXTURE COLOR
return sfx
endfunction
function ShowRange takes unit u, integer weaponIndex returns effect
return ShowRangeEx(u, weaponIndex, RED, GREEN, BLUE)
endfunction
endlibrary
For spell cast, just code a demo that peeps can copy to their map like so.
JASS:
scope RangeDemo initializer Init
globals
private constant real DEATH_TIME = 10.0
private constant integer SPELL_ID = 'A000'
endglobals
globals
private hashtable hash = InitHashtable()
endglobals
private function RemoveEffect takes nothing returns nothing
local integer id = GetHandleid(GetExpiredTimer())
local effect sfx = LoadEffectHandle(hash, id, 0)
// Move effect to edge of map, so it is not seen by players
call BlzSetSpecialEffectPosition(sfx, GetRectMaxX(GetWorldBounds()), GetRectMaxY(GetWorldBounds()), 0)
// Clean up
call FlushChildHashtable(hash, id)
call DestroyEffect(sfx)
call DestroyTimer(GetExpiredTimer())
set sfx = null
endfunction
private function Display takes nothing returns nothing
local timer t
local effect sfx
if GetSpellAbilityId() == SPELL_ID then
set sfx = ShowRange(GetTriggerUnit(), 0)
if DEATH_TIME == 5 then
// Effect disappears after 5 seconds after this function call since model has a 5 seconds death animation
call DestroyEffect(sfx)
else
set t = CreateTimer()
call SaveEffectHandle(hash, GetHandleId(t), 0, sfx)
call TimerStart(t, DEATH_TIME, false, function RemoveEffect)
set t = null
endif
set sfx = null
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t, function Display)
endfunction
endscope
Aniki, at one point, also made a similar system, using images for the display. His could benefit from automatic range detection.
Last edited: