• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

BotL - Coding & Systems

Status
Not open for further replies.
Level 22
Joined
Sep 24, 2005
Messages
4,821
The Table calls.

EDIT: It would be best to just use TimerUtils for this, since it's for a hero spell. 0.8 isn't friendly with 0.062500...
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Division, not multiplication. Did you look at Malhorne's code?
0.8/0.0625 = 12.8
EDIT: There shouldn't be a remainder.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Don't bother, this is from your map, using your Transparency version:
JASS:
library Transparency requires Table
    globals
        private constant real FPS = 0.062500
    endglobals
   
    struct Transparency extends array
        private unit target
        private real temp
        private integer delta
        private thistype next
        private thistype prev
        private static integer count
        private static timer period
        private static HandleTable tab
       
        static method GetUnitAlpha takes unit u returns integer
            if tab.exists(u) then
                return tab[u]
            else
                return 255
            endif
        endmethod
       
        private static method cond takes nothing returns boolean
            local unit u = GetTriggerUnit()
            if tab.exists(u) then
                call tab.flush(u)
            endif
            set u = null
            return false
        endmethod
       
        private static method periodic takes nothing returns nothing
            local thistype this = thistype(0).next
            local integer i
            loop
                exitwhen this == 0
                set this.temp = this.temp - FPS
                if this.temp <= 0 then
                    if this.delta < 0 then
                        call SetUnitVertexColor(this.target, 255, 255, 255, 255)
                    else
                        call SetUnitVertexColor(this.target, 255, 255, 255, 0)
                    endif
                    call this.destroy()
                else
                    set i = GetUnitAlpha(this.target)-this.delta
                    call SetUnitVertexColor(this.target, 255, 255, 255, i)
                    set tab[this.target] = i
                endif
                set this = this.next
            endloop
        endmethod
       
        static method fadeOut takes unit targ, real dur returns nothing
            local thistype this
            local integer i
            if thistype(0).prev == 0 then
                set count = count + 1
                set this = count
            else
                set this = thistype(0).prev
                set thistype(0).prev = thistype(0).prev.prev
            endif
            if thistype(0).next == 0 then
                call TimerStart(period, FPS, true, function thistype.periodic)
            else
                set thistype(0).next.prev = this
            endif
            set this.next = thistype(0).next
            set thistype(0).next = this
            set this.prev = thistype(0).prev
            set this.target = targ
            set this.temp = dur - FPS
            @set this.delta = - R2I(255/(dur/FPS))@
            set tab[this.target] = 0
            set i = GetUnitAlpha(targ)-this.delta
            call SetUnitVertexColor(targ, 255, 255, 255, i)
            set tab[targ] = i
        endmethod
       
        static method fadeIn takes unit targ, real dur returns nothing
            local thistype this
            local integer i
            if thistype(0).prev == 0 then
                set count = count + 1
                set this = count
            else
                set this = thistype(0).prev
                set thistype(0).prev = thistype(0).prev.prev
            endif
            if thistype(0).next == 0 then
                call TimerStart(period, FPS, true, function thistype.periodic)
            else
                set thistype(0).next.prev = this
            endif
            set this.next = thistype(0).next
            set thistype(0).next = this
            set this.prev = thistype(0).prev
            set this.target = targ
            set this.temp = dur - FPS
            @set this.delta = R2I(255/(dur/FPS))@
            set tab[this.target] = 255
            set i = GetUnitAlpha(targ)-this.delta
            call SetUnitVertexColor(targ, 255, 255, 255, i)
            set tab[targ] = i
        endmethod
       
        private method destroy takes nothing returns nothing
            if this.next != 0 then
                set this.next.prev = this.prev
            endif
            set this.prev.next = this.next
            set this.prev = thistype(0).prev
            set thistype(0).prev = this
            if thistype(0).next == 0 then
                call PauseTimer(period)
            endif
            set this.target = null
        endmethod

        private static method onInit takes nothing returns nothing
            local trigger t = CreateTrigger()
            call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
            call TriggerAddCondition(t, Condition(function thistype.cond))
            set tab = HandleTable.create()
            set count = 0
            set period = CreateTimer()
            set t = null
        endmethod
    endstruct
endlibrary

EDIT again: rework the computation, I don't want to work on it anymore. I'm going skirt hunting.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
No, I'm talking about the group lol, Jad seems busy with other things, I guess he's abandoning the project... too bad...
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Don't kid yourself man!!! Get the guns, he's become a zombie! I'm gonna setup perimeter. Stay indoors dude!
 
Level 7
Joined
Jun 21, 2011
Messages
674
Why... Oh why my Jad
Have you abandoned it(the project) in its sobriety
Behind the old façade
It is your bewildered child
So take it cross the river wide
 
Status
Not open for further replies.
Top