wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 11-01-2009, 02:24 PM   #16
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Rising_Dusk
I do not support TriggerSleepAction, even if it is 'fine.'

Most of the time i don't use it (like 99,9%), but it can't fuck up your map if you use only one time inside a not dynamic trigger.
Who care about the lack of accuracy here, or the minimal time about 0.3 s ?

Anyway he could still use a periodic timer instead.
Troll-Brain is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 11-04-2009, 06:20 PM   #17
D3zmodos
User
 
Join Date: Feb 2009
Posts: 13

D3zmodos has little to show at this moment (8)

Default

I tested, they only leave the mini-tome if the item is used when acquired, so this would only ever need to be activated when a unit acquires a tome that gets used as he picks it up.

I also checked, if you leave the trigger as is (where it works) and you just change the trigger to when it uses an item as opposed to acquiring an item, it does not remove the mini-tome that is left behind.
D3zmodos is offline   Reply With Quote
Old 11-04-2009, 07:04 PM   #18
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

How funny the event USE_ITEM doesn't fire for such items (auto using when acquire), but drop fire.

Seems to work like a charm, and much cleaner imho :

Collapse JASS:
library PowerupSentinel initializer onInit
//* ============================================================================
//*  PowerupSentinel by Vexorian
//*  ------------
//*    Placing this library in your map will automatically fix all rune/tome
//* memory leaks in your map.
//*
//*    Powerup items don't get removed automatically by the game, they instead
//*    just leave a small item in the map, this causes memory leaks but - worse -
//*    it also makes areas of your map where a lot of tomes have been used lag.
//*
//* ===========================================================================
        
    private function Clean takes nothing returns nothing
        if IsItemPowerup(GetManipulatedItem()) then
            call TriggerSleepAction(0) // but you can use a timer(0), a trigger condition and the loop thin if you hate TSA that much
            // note that the wait isn't required but like i've said the user might want to play with this item on drop_event
            call RemoveItem(GetManipulatedItem())
        endif
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        local integer i = 0
        loop
            call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_DROP_ITEM,null)
            set i = i + 1
            exitwhen i == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddAction(t,function Clean)
    endfunction

endlibrary
Troll-Brain is offline   Reply With Quote
Old 11-05-2009, 02:39 AM   #19
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,905

Submissions (37)

Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)Vexorian has a reputation beyond repute (1060)

Hero Contest #3 - 2nd Place

Default

both things look the same to me, except in yours you use the completely non-clean TriggerSleepAction, and you for some odd reason inline RegisterAnyUnitEventBJ ...
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 11-05-2009, 03:20 AM   #20
weaaddar
User


Respected User
 
Join Date: Apr 2002
Posts: 2,372

Submissions (3)

weaaddar has a spectacular aura about (131)

Default

Holy crap, you implemented anonymous functions! When I get my laptop back, I'm going to once again try to write the Y combinator in Zinc.
weaaddar is offline   Reply With Quote
Old 11-05-2009, 02:58 PM   #21
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Vexorian
both things look the same to me, except in yours you use the completely non-clean TriggerSleepAction, and you for some odd reason inline RegisterAnyUnitEventBJ ...

For the BJ inline it's because i copied D3zmodos's code, but i'm agree it's useless, i simply thought you did the same and i didn't really care about it.
For the TSA thing i said you can still use the timer instead if you hate it that much.

At least my version only check with drop_events which would be happen less than pickup_item, and also there is no need anymore to check all items, neither their life.
Definitely cleaner.

Last edited by Troll-Brain : 11-05-2009 at 03:09 PM.
Troll-Brain is offline   Reply With Quote
Old 11-12-2009, 09:38 PM   #22
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

bump
Troll-Brain is offline   Reply With Quote
Old 11-13-2009, 08:35 AM   #23
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Collapse JASS:
library PowerupSentinel initializer init

    private function useTome takes nothing returns nothing
        private unit u = GetTriggerUnit()
        private item i = GetManipulatedItem()
        
        if GetItemType(i) == ITEM_TYPE_POWERUP then
            call RemoveItem(i)
        endif

        set u = null
        set i = null
    endfunction
    
    private function cond takes nothing returns boolean
        return true
    endfunction
    
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        local boolexpr b = Condition(function cond)
        
        call TriggerAddAction(t, function useTome)
        loop
            exitwhen i >= 15
            
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, b)
            
            set i = i + 1
        endloop

        set b = null
        set t = null
    endfunction

endlibrary
I can't test right now, but doesn't this work too?
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]

Last edited by Anachron : 11-13-2009 at 10:35 AM.
Anachron is offline   Reply With Quote
Old 11-13-2009, 10:23 AM   #24
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

What about if the user want to deal with the item on DROP_EVENT ?
The variable boolexpr b is useless, same for "u" and "i", and the true boolexpr.

Also why you use GetItemType when we have the function IsItemPowerup.

And finally you need to use TriggerRegisterPlayerUnitEvent.

Last edited by Troll-Brain : 11-13-2009 at 10:34 AM.
Troll-Brain is offline   Reply With Quote
Old 11-13-2009, 10:30 AM   #25
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Quote:
Ofc, but what about if the user want to deal with the item on DROP_EVENT ?
So it is
Collapse JASS:
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_UNIT_DROP_ITEM, b)
?

Quote:
The variable boolexpr b is useless, same for "u" and "i".
I thought locals are faster as method calls?

Quote:
Also why you use GetItemType when we have the function IsItemPowerup.
Because its more general? I like generalization, abstract methods are attractive to me.

Edit:
Quote:
TriggerRegisterPlayerUnitEvent
Yeah, sorry, my mistake, just fucked up with that.
(Coding out of the head atm)
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]

Last edited by Anachron : 11-13-2009 at 10:35 AM.
Anachron is offline   Reply With Quote
Old 11-13-2009, 10:47 AM   #26
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

No you don't get it.

If the user have a trigger with drop event, in order to get informations on the manipulated items, he needs to make this library needs his one, else the item will be already removed hwen the event in the user library fire, pretty lame.
And you won't be able to use scopes with this event, which is also lame for me.

I've fixed you code, the TriggerRegister thing and also the keyword "local" instead of private.
IsItemPowerup works where GetItemType(i) == ITEM_TYPE_POWERUP fails, it returns false.

Also for you code i mean that :

Collapse JASS:
library PowerupSentinel initializer init

    private function UseTome takes nothing returns boolean
        
        if IsItemPowerup(GetManipulatedItem()) then // or you can also use a local variable, i'm agree it's irrevelant
            call RemoveItem(GetManipulatedItem())
        endif
        return false

    endfunction
    
    
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        
        loop
            exitwhen i >= 15
            
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null) // the null boolexpr thing is only for GroupEnum
            
            set i = i + 1
        endloop
        call TriggerAddCondition(t,Condition(function UseTome))

    endfunction

endlibrary

Last edited by Troll-Brain : 11-13-2009 at 10:49 AM.
Troll-Brain is offline   Reply With Quote
Old 11-13-2009, 10:59 AM   #27
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Quote:
If the user have a trigger with drop event, in order to get informations on the manipulated items, he needs to make this library needs his one, else the item will be already removed hwen the event in the user library fire, pretty lame.
And you won't be able to use scopes with this event, which is also lame for me.
That's why Vex used timers. So just create a single onetime timer expiring after 0.001 seconds?

Quote:
I've fixed you code, the TriggerRegister thing and also the keyword "local" instead of private.
IsItemPowerup works where GetItemType(i) == ITEM_TYPE_POWERUP fails, it returns false.
Why does it fail?

Collapse JASS:
library PowerupSentinel initializer init

    private function UseTome takes nothing returns boolean
        
        if IsItemPowerup(GetManipulatedItem()) then // or you can also use a local variable, i'm agree it's irrevelant
            call RemoveItem(GetManipulatedItem())
        endif
        return false

    endfunction
    
    
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        
        loop
            exitwhen i >= 15
            
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null) // the null boolexpr thing is only for GroupEnum
            
            set i = i + 1
        endloop
        call TriggerAddCondition(t,Condition(function UseTome))

    endfunction

endlibrary
But the null boolexpr leaks.
Clever use of the condition.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 11-13-2009, 11:09 AM   #28
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Anachron
That's why Vex used timers. So just create a single onetime timer expiring after 0.001 seconds?
I've already explained you can do that instead of TSA ...

Quote:
Why does it fail?
No idea, it just doesn't work.
An other Blizzard fail on a native function, i guess *shrugs*

Quote:
But the null boolexpr leaks.
No.

Quote:
Clever use of the condition.
No.
It's kinda a standard now, since a condition is faster than an action (really irrelevant here though)

Last edited by Troll-Brain : 11-13-2009 at 11:11 AM.
Troll-Brain is offline   Reply With Quote
Old 11-13-2009, 11:18 AM   #29
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Quote:
Quote:
But the null boolexpr leaks.
No.
Who told you that? I have been teached by many guys that null boolexpr leak.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 11-13-2009, 11:24 AM   #30
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by Anachron
Who told you that? I have been teached by many guys that null boolexpr leak.
As for me, but i decided to test it myself because it didn't makes sense, even for Blizzard coders, guess what, it doesn't leak ...
Most of guys were confused with the GroupEnum thingy showed by Captain Griffen.

Anyway it's easy to make a code which will prove it doesn't leak, i've already did it here :

http://www.thehelper.net/forums/show...24&postcount=7

Last edited by Troll-Brain : 11-13-2009 at 11:25 AM.
Troll-Brain is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 03:08 PM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services