• 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.

[JASS] Local Tree Fade

Status
Not open for further replies.
Level 22
Joined
Jun 24, 2008
Messages
3,050
Will anybody be able to create a Tree Fade system, that changes the Opacity of 'Trees' in

900 range, to 90.
800 range, to 80.
700 range, to 70.
600 range, to 60.
500 range, to 50.
400 range, to 40.
300 range, to 30.
200 range, to 20.
100 range, to 10.

Use a custom model (Not trees!, but Units with the models!).

This would be really neat, and surely usefull for more than me.

(Must be Local, so that it only changes to the owner of the unit in range.)

Ps. Mustn't leak.
 
Last edited:
Level 23
Joined
Nov 29, 2006
Messages
2,482
You're trying to do this for every unit in the map or only an array of heroes or something? It will lag like hell for all the units.
There are certain natives to avoid that.

Anyways, here is the code.
JASS:
library FDT

globals
    private constant integer treeId = 101 //Use your dummy unittree point value id.
    private constant real fadeRange = 1000. //The fade range.
    //---
    private group tempEnum = CreateGroup()
endglobals

private function IsDummyTree takes nothing returns boolean
    return GetUnitPointValue(GetFilterUnit()) == treeId
endfunction

function SetTreeTransparency takes unit fromWho returns nothing
    local unit u
    local real x0 = GetUnitX(fromWho)
    local real y0 = GetUnitY(fromWho)
    local real dx
    local real dy
    call GroupEnumUnitsInRange(tempEnum, x0, y0, fadeRange+100, Filter(function IsDummyTree))
    loop
        set u = FirstOfGroup(tempEnum)
        exitwhen u == null
        call GroupRemoveUnit(tempEnum, u)
        set dx = GetUnitX(u)-x0
        set dx = dx*dx
        set dy = GetUnitY(u)-y0
        set dy = dy*dy
        if GetLocalPlayer() == GetOwningPlayer(fromWho) then
            call SetUnitVertexColor(u, 255, 255, 255, R2I(SquareRoot(dx+dy)/1000*255))
        endif
    endloop
endfunction

endlibrary

And here is a testmap...

~Eccho~
 

Attachments

  • DummyTreeFading.w3x
    15.3 KB · Views: 55
Status
Not open for further replies.
Top