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

ability request

Status
Not open for further replies.
Level 5
Joined
Aug 25, 2010
Messages
120
Hy!

I need an ability, that a building produce lumber every 30 seconds.

Can somebody help me about that?

Thanks!
 
JASS:
library Ability initializer Init
    globals
        private constant real INTERVAL = 30.00
        private constant integer ABILITY ='A000' //Add Lumber Ability Raw Code
        private constant integer LUMBER = 3
    endglobals

    private function IncreaseLumber takes nothing returns boolean
        local unit u
        call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, null)
        loop
            set u = FirstOfGroup(bj_lastCreatedGroup)
            exitwhen u == null
            if GetUnitAbilityLevel(u, ABILITY) > 0 then
                call SetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER) + LUMBER)
            endif
            call GroupRemoveUnit(bj_lastCreatedGroup, u)
        endloop
        return false
    endfunction

    function Init takes nothing returns nothing
        local trigger T = CreateTrigger()
        call TriggerRegisterTimerEvent(T, INTERVAL, true)
        call TriggerAddCondition( T, Condition( function IncreaseLumber ) )
        set T = null
    endfunction
endlibrary
 
Level 5
Joined
Aug 25, 2010
Messages
120
Thx, thats perfect!!

I need a little modification: when gather the lumber, can it show it green numbers?
 
JASS:
library Ability initializer Init
    globals
        private constant real INTERVAL = 3.00
        private constant integer ABILITY ='A000' //Add Lumber Ability Raw Code
        private constant integer LUMBER = 3
    endglobals

    // Create floating text for player. Basically I made the system working in multiplayer...
    public function AddFT takes player p , string s , real x , real y, real speed, real angle, real scale returns nothing
        local texttag FT
        if GetLocalPlayer( ) == p then
            set FT = CreateTextTag( )
            call SetTextTagPos( FT , x , y , 128 )
            call SetTextTagPermanent( FT , false )
            call SetTextTagVelocity( FT, (speed * 0.071 / 128) * Cos(angle * bj_DEGTORAD), (speed * 0.071 / 128) * Sin(angle * bj_DEGTORAD) )
            call SetTextTagFadepoint( FT , 90. )
            call SetTextTagLifespan( FT , 2. )
            call SetTextTagText( FT , s , scale )
            call SetTextTagVisibility( FT , true )
        endif
        set FT = null
    endfunction
    
    private function IncreaseLumber takes nothing returns boolean
        local unit u
        call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, null)
        loop
            set u = FirstOfGroup(bj_lastCreatedGroup)
            exitwhen u == null
            if GetUnitAbilityLevel(u, ABILITY) > 0 then
                call SetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER) + LUMBER)
                call AddFT(GetOwningPlayer(u), "|c0020C000+ " + I2S(LUMBER), GetUnitX(u), GetUnitY(u), 65., 90., 0.02)
            endif
            call GroupRemoveUnit(bj_lastCreatedGroup, u)
        endloop
        return false
    endfunction

    function Init takes nothing returns nothing
        local trigger T = CreateTrigger()
        call TriggerRegisterTimerEvent(T, INTERVAL, true)
        call TriggerAddCondition( T, Condition( function IncreaseLumber ) )
        set T = null
    endfunction
endlibrary

AddFT is public function, you can use it from any trigger you want, just copy that line of text into custom script and don't forget to add udg_ to GUI global variables
  • Custom script: call AddFT(GetOwningPlayer(udg_u), "udg_TEMP_STRING", GetUnitX(udg_u), GetUnitY(udg_u), 65., 90., 0.02)
It's MPI, so if you want text displayed to all players remove that if GetLocalPlayer line, also you can change it to private if you don't need it outside this ability.
 

Attachments

  • aaaa.w3x
    17.9 KB · Views: 41
Level 5
Joined
Aug 25, 2010
Messages
120
Good job!
It's more than what I expected. Very thanks about the quick help, it's perfect work.

THX a lot!
 
Trigger variable doesn't need to be nulled here, also no need to null FT if you don't create a text tag :)
Ah just that, dude I'm pwning, I remember when half on my code was fail ^_^
I like how that don't need sound, usually there was word like must :D
 
Last edited:
Status
Not open for further replies.
Top