• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Request

Status
Not open for further replies.
Level 4
Joined
May 27, 2012
Messages
85
How can I make that a unit that is on higher place have more shooting range than the unit in lower place, Like ramps,tower or something else...
And if a units that on higher place doesn't shoot the unit in the lower place, he wouldn't see the first unit untill he shoots.

Kind of realistic modern warfare war.
Need for my map.
 
Level 4
Joined
Mar 3, 2010
Messages
68
What you request isn't exactly easy to do. But I think the best method would be to make every unit's attack deal zero damage and spawn a dummy unit with the appropriate range. In the triggers, you can use event - unit comes within range, then do the height check, spawn the invisible dummy if the enemy unit can be attacked, and order the dummy unit to attack whilst playing the regular unit's attack animations.

I've never done something like this but I think it could be feasible.

Here is a simple JASS function that detects the difference in height between 2 units and returns the value in a real variable. You will need to declare a global point variable for this function to use (udg_ZLoc in this example).

JASS:
function HeightDamageCalculation takes unit Source, unit Target returns real
    
    local real D
    set udg_ZLoc = GetUnitLoc( Source )
    set D = GetLocationZ( udg_ZLoc )
    call RemoveLocation( udg_ZLoc )
    set udg_ZLoc = GetUnitLoc( Target )
    set D = D-GetLocationZ( udg_ZLoc )
    call RemoveLocation( udg_ZLoc )

return D
endfunction

Paste it into your map-specific custom script code section. You can call it by using:

  • Custom script: set Real_Variable = HeightDamageCalculation( Unit_Variable1, Unit_Variable2 )
Edit: On second thought, there is probably no need to spawn dummy units, you could just trigger the damage to simulate an attack at the appropriate range.
 
Last edited:
Status
Not open for further replies.
Top