Libraries???

elpini0

New Member
Reaction score
1
Hi, im working on a new map and I was looking for a trigger to make trees respawn.

I found this:

JASS:
library REGROWTREES initializer Init
globals
    private constant real RegrowAfter = 23.0 // seconds to wait until tree regrows
    private constant real Range = 250.0      // distance around tree that needs to be free of units before regrowing
    private unit u
    private group g = CreateGroup()
    private boolexpr b
    private boolean ok
endglobals
private function IsTree takes nothing returns boolean
    local boolean b
    call SetUnitX(u, GetWidgetX(GetFilterDestructable()))
    call SetUnitY(u, GetWidgetY(GetFilterDestructable()))
    set b = IssueTargetOrder(u, "harvest", GetFilterDestructable())
    call IssueImmediateOrder(u, "stop")
    return b
endfunction
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction
private function IsUnitNear takes nothing returns boolean
    if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.5 then
        set ok = false
    endif
    return false
endfunction
private function Regrow takes nothing returns nothing
    local widget t = GetTriggerWidget()
    call TriggerSleepAction(RegrowAfter)
    loop
        set ok = true
        call GroupClear(g)
        call GroupEnumUnitsInRange(g, GetWidgetX(t), GetWidgetY(t), Range, b)
        exitwhen ok
        call TriggerSleepAction(3.0)
    endloop
    call DestructableRestoreLife(W2D(t), GetDestructableMaxLife(W2D(t)), true)
    set t = null
endfunction
private function Register takes nothing returns nothing
    call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
endfunction
private function Init takes nothing returns nothing
    set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'nmpe', 0, 0, 0) // Mur'gul Slave...
    call SetUnitInvulnerable(u, true)
    call ShowUnit(u, false)
    call UnitAddAbility(u, 'Aloc') // Locust
    call UnitAddAbility(u, 'Ahrl') // Harvest Lumber
    set bj_destInRegionDiesTrig = CreateTrigger()
    call EnumDestructablesInRect(bj_mapInitialPlayableArea, Condition(function IsTree), function Register)
    call TriggerAddAction(bj_destInRegionDiesTrig, function Regrow)
    set b = Condition(function IsUnitNear)
    call RemoveUnit(u)
    set u = null
endfunction
endlibrary


Well, my problem is that i searched a lot and couldn't find HOW THE HELL DO I MAKE THIS USEFUL!

I tried making a new trigger called "regrowth", converted to personally edited text and copypasted (after erasing the previous text)

And when i test the map with World Editor, TFT opens its main screen... Not the map. So, i switched off the trigger with the library and it worked fine.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
This seems to be a quite old "system", as it still uses 'return bugs'...
JASS:
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction


That kind of return behavior isn't allowed anymore, just replace the "Regrow" function with this:
JASS:
private function Regrow takes nothing returns nothing
    local destructable t = GetTriggerDestructable()
    call TriggerSleepAction(RegrowAfter)
    loop
        set ok = true
        call GroupClear(g)
        call GroupEnumUnitsInRange(g, GetWidgetX(t), GetWidgetY(t), Range, b)
        exitwhen ok
        call TriggerSleepAction(3.0)
    endloop
    call DestructableRestoreLife(t, GetDestructableMaxLife(t), true)
    set t = null
endfunction


(Freehanded :S)
 

elpini0

New Member
Reaction score
1
Thank you for your response.

The problem is that i don't know how to "add a library" to my map.

I copy-paste the whole library into a new empty trigger and test the map, but in stead of play the map, the main manu of TFT shows up. So, i switch off the "trigger" or whatever that is (where i pasted the library) and it works fine, obviously not applying the desired effect that the library would have done.
 

elpini0

New Member
Reaction score
1
well, my newgen pack is updated from 2007, which is the latest version (as far as i know...)

And i think it has the latest version of the jasshelper too, doesn't it?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
No it doesn't...
Download the file here, and extract it in the "jasshelper" folder in the Newgen folder :D
http://www.wc3c.net/showthread.php?t=88142

Also, have you made the changes I showed you ? :S
You do add that library correctly (I'd believe) itäs just that that library isn't compatible with the latest version of WC3, that's why you need to alter the code there, to make it work :D
 

elpini0

New Member
Reaction score
1
Thank you for your attention.

I tried to follow the steps to update the jasshelper, but i just can't understand how to do it...

What files should i upgrade? I downloaded the 0.A.2.B.jasshelper.7z file and then i'm lost...
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Extract the file by using Winrar or 7-zip.
Copy clijasshelper.exe and jasshelper.exe into your NewGen/Jasshelper/ folder.
 

Jesus4Lyf

Good Idea™
Reaction score
397
I copy-paste the whole library into a new empty trigger and test the map, but in stead of play the map, the main manu of TFT shows up.
Save the map before hitting test map. ie. immediately before you hit test map, save it first.
Let us know any syntax errors if there are any... after making sure you remove that W2D function.
 

elpini0

New Member
Reaction score
1
Extract the file by using Winrar or 7-zip.
Copy clijasshelper.exe and jasshelper.exe into your NewGen/Jasshelper/ folder.

Well, I actually did that and at first it showed an error message of "missing bin/SFmpq.dll".

I picked up both .exe to the NewGen folder where the IS a folder called "bin".

Then the error message turns into "JASSHelper Error // Missing arguments: <commonj> <blizzardj> <mappath>"
 

elpini0

New Member
Reaction score
1
Save the map before hitting test map. ie. immediately before you hit test map, save it first.
Let us know any syntax errors if there are any... after making sure you remove that W2D function.

Actually there are syntax problems... from line 1 to line 57...

Line 1: syntax error
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 1: Statement outside of function
Line 2: Statement outside of function
Line 2: Statement outside of function
Line 3: Statement outside of function
Line 3: Statement outside of function
Line 3: Statement outside of function
Line 3: Statement outside of function
[...]

Mixed with other types of error...
 

tooltiperror

Super Moderator
Reaction score
231
First of all, you can make a copy of your bin folder found inside of the NewGen folder and put it inside your NewGen folder, in case you need to run it as a command line utility.

Second, you should get an updated common.j and blizzard.j by extracting it from the patch.mpq.

Third, you should have the .DLL in both bin's.
 

elpini0

New Member
Reaction score
1
First of all, you can make a copy of your bin folder found inside of the NewGen folder and put it inside your NewGen folder, in case you need to run it as a command line utility.

Second, you should get an updated common.j and blizzard.j by extracting it from the patch.mpq.

Third, you should have the .DLL in both bin's.

But why am i having all these problems when people can actually use lirbaries without any problem??

I reinstalled NewGen pack, updated both .exe files, copied the bin folder and still doesn't work...

JASS:
library REGROWTREES initializer Init
globals
    private constant real RegrowAfter = 8.0 // seconds to wait until tree regrows
    private constant real Range = 80.0      // distance around tree that needs to be free of units before regrowing
    private unit u
    private group g = CreateGroup()
    private boolexpr b
    private boolean ok
endglobals
private function IsTree takes nothing returns boolean
    local boolean b
    call SetUnitX(u, GetWidgetX(GetFilterDestructable()))
    call SetUnitY(u, GetWidgetY(GetFilterDestructable()))
    set b = IssueTargetOrder(u, &quot;harvest&quot;, GetFilterDestructable())
    call IssueImmediateOrder(u, &quot;stop&quot;)
    return b
endfunction
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction
private function IsUnitNear takes nothing returns boolean
    if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) &gt; 0.5 then
        set ok = false
    endif
    return false
endfunction
private function Regrow takes nothing returns nothing
    local destructable t = GetTriggerDestructable()
    call TriggerSleepAction(RegrowAfter)
    loop
        set ok = true
        call GroupClear(g)
        call GroupEnumUnitsInRange(g, GetWidgetX(t), GetWidgetY(t), Range, b)
        exitwhen ok
        call TriggerSleepAction(3.0)
    endloop
    call DestructableRestoreLife(t, GetDestructableMaxLife(t), true)
    set t = null
endfunction
private function Register takes nothing returns nothing
    call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
endfunction
private function Init takes nothing returns nothing
    set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), &#039;nmpe&#039;, 0, 0, 0) // Mur&#039;gul Slave...
    call SetUnitInvulnerable(u, true)
    call ShowUnit(u, false)
    call UnitAddAbility(u, &#039;Aloc&#039;) // Locust
    call UnitAddAbility(u, &#039;Ahrl&#039;) // Harvest Lumber
    set bj_destInRegionDiesTrig = CreateTrigger()
    call EnumDestructablesInRect(bj_mapInitialPlayableArea, Condition(function IsTree), function Register)
    call TriggerAddAction(bj_destInRegionDiesTrig, function Regrow)
    set b = Condition(function IsUnitNear)
    call RemoveUnit(u)
    set u = null
endfunction
endlibrary


That's the library, again...
 

elpini0

New Member
Reaction score
1
I forgot to add that the "Enable Jasshelper" text has a tick next to it... Maybe that means it is enabled...
 

Komaqtion

You can change this now in User CP.
Reaction score
469
As I said, you need to remove this:
JASS:
private function W2D takes widget w returns destructable
    return w // do not inline
    return null
endfunction


And could you then also comment the lines which have an error in them ? :O
 

elpini0

New Member
Reaction score
1
I downloaded the map Damage.w3x whcih contains the libraries Damage, AIDS and Event. I tested the map without toching anything. It doesnt work, for which I guess my NewGen WE is badly installed, or my JassHelper out of date...

[EDIT]
I think JassHelper is not working... I click on "show previous errors" and it gives the message "JassHelper didn't find any syntax error the last time it was called". Maybe it has never been called
 
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