Is there any function to get unit scale?

Romek

Super Moderator
Reaction score
963
No, there isn't.
You could make your own SetScaleEx that stores the unit scale as well as making the unit smaller/bigger though.
 

DrEvil

FCRI Associate!
Reaction score
111
nope.

But you could set arrays at a map init trig.

like :

JASS:
globals
   real array SCALE_SIZE
   integer array SCALE_UNIT
   constant integer MAX_INDEX = 1 // <--e.t.c
endglobals

function GetUnitScale takes unit u returns real
   local integer i = 1
   loop
      exitwhen i > MAX_INDEX
      if SCALE_UNIT<i> == GetUnitTypeId(u) then
         return SCALE_SIZE<i>
      endif
      set i = i + 1
   endloop
   return 0
endfunction

function Init...
   set SCALE_UNIT[1] = &#039;HMkg&#039;
   set SCALE_SIZE[1] = 1.00 // &lt;-- change it to the size in OE ?
endfunction</i></i>


Just a little rough , but that's how id plan it out.
 

Romek

Super Moderator
Reaction score
963
Or just use Table.
JASS:
library Scale initializer Init needs Table
    globals
        private HandleTable Tab
    endglobals
    
    private struct Data
        real scale
    endstruct
    
    function SetUnitScaleEx takes unit u, real scale returns nothing
        local Data d
        if not Tab.exists(u) then
            set d = Data.create()
            set Tab<u> = d
        else
            set d = Tab<u>
        endif
        set d.scale = scale
        call SetUnitScale(u, scale, scale, scale)
    endfunction
    
    function GetUnitScale takes unit u returns real
        return Data(Tab<u>).scale
    endfunction
    
    private function Cond takes nothing returns boolean    
        local unit u = GetTriggerUnit()
        if Tab.exists(u) then
            call Data(Tab<u>).destroy()
            call Tab.flush(u)
        endif
        set u = null
        return false
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
        call TriggerAddCondition(t, Filter(function Cond))
        set Tab = HandleTable.create()
    endfunction
endlibrary</u></u></u></u>
 

Viikuna

No Marlo no game.
Reaction score
265
I dont think that creating a Data instances every time you change units scale is a good idea.
edit. You should check if unit allready has a Data instance.

And when I last tested this, only x value did something and y & z were completely useless.
 

Romek

Super Moderator
Reaction score
963
> I dont think that creating a Data struct wihout ever destroying it is a good idea.
Destroy it when the unit dies. :)

> And when I last tested this, only x value did something and y & z were completely useless.
Really? I've never tried SetUnitScale with different values.
If this is true, then it'd make things very simple. :D

Changed that code a bit.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
It's the time of hooks. :D

EDIT : Oh didn't saw it is a such old thread, sorry.
 

Viikuna

No Marlo no game.
Reaction score
265
Heh, well since someone ressurected this..

You should use UnitProperties for this. I dont know if the version thats uploaded in wc3c.net supports scale yet, buts its pretty easy to modify it to do so.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top