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 01-20-2010, 04:05 AM   #166
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Do you have the latest version of JassHelper?

The only way that's possible is if GetIndexDebug is being called rather than GetIndex. Try inserting your own debug message into the GetUnitId function to check what the static if is compiling to when you have debug mode enabled/disabled.
grim001 is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-20-2010, 04:35 AM   #167
Sinnergy
User
 
Sinnergy's Avatar
 
Join Date: Apr 2009
Posts: 173

Sinnergy has little to show at this moment (8)

Default

I have the latest jasshelper
Ok, so I added my own debug message:
Code:
function GetUnitId takes unit u returns integer
    static if DEBUG_MODE then
        call BJDebugMsg("debug")
        return AutoIndex.getIndexDebug(u)
    else
        call BJDebugMsg("not debug")
        return AutoIndex.getIndex(u)
    endif
endfunction

it displays the right message when I disabled/enabled debug mode, then I did this:
-Enabled Debug Mode
-Saved map
-Closed New Gen
-Optimized map with wc3optimizer 4.9
-Opened Warcraft 3 TFT
-Played the optimized map
....then I get the message "debug", so this means saving the map while debug mode is enabled in new gen still retains the debug mode inside the map even without new gen opened?

also got another question: I found xecast using GetUnitUserData and SetUnitUserData, do I have to disable UseUnitUseData in AutoIndex?
__________________
Current Project:
Rise of Sinnergy v1.00
Sinnergy is offline   Reply With Quote
Old 01-20-2010, 06:44 AM   #168
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by Sinnergy
so this means saving the map while debug mode is enabled in new gen still retains the debug mode inside the map even without new gen opened?
That's right. Debug mode is just causing the map script to compile differently when it saves. You need to save it in non-debug mode for the debug messages to go away. Of course the debug messages only appear when you have a problem in your code, so maybe you should fix that too...

Quote:
Originally Posted by Sinnergy
also got another question: I found xecast using GetUnitUserData and SetUnitUserData, do I have to disable UseUnitUseData in AutoIndex?
No, AutoIndex is fully compatible with xe even with UseUnitUserData enabled. AutoIndex ignores xe dummy units to avoid overwriting their userdata. If you encounter any other systems that use unitdata internally, you can use the UnitFilter to deal with that.
grim001 is offline   Reply With Quote
Old 01-28-2010, 11:45 AM   #169
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Massive update. With this update, I have been able to complete the feature set I've been wanting for a long time. This will likely be the last update that adds new functionality. Everything from here forward should be only tweaks and fixes as necessary.

AutoStruct has been done away with. Although it was neat, it was oftentimes impractical because it locked you into a specific style of coding with the implementing struct. Instead, 3 new modules have been added. For detailed information of these modules, read the documentation in the script.

AutoData:
  • Allows you to associate struct instances with units. You may associate one or more instances with a single unit.
  • If you associate one instance per unit, you may use StructName[unit] syntax to retrieve instances. This is extremely fast.
  • If you associate multiple instances to a single unit, you may use StructName[unit][index] syntax to iterate through each of the unit's instances. The 2d syntax is awesome.
  • This thing effectively replaces the functionality of UnitListModule. This is better because it doesn't need a whole API for iteration, adding, removal, etc.

AutoCreate:
  • This module automatically creates instances for units as they enter the map. You can declare a createFilter method to decide which units get instances.
  • This is useful for structs that should always be available for a unit, such as data fields and event handlers.
  • You can now use this in conjunction with allocate() that takes parameters (i.e. full support for extends).
  • You can manually create instances too, if you want to.

AutoDestroy
  • When a unit leaves the game, all instances associated with it are destroyed.
  • You can manually destroy instances too, if you want to.
*You can combine AutoCreate and AutoDestroy to effectively recreate AutoStruct, but now you have more flexibility.

The rest of the code got some improvements in this update, too:
  • Updated and rewrote some old documentation.
  • Improved comment readability and compactness throughout the code.
  • The main detectStatus method has had several optional textmacros removed from it and looks nicer. As a result, you must update AutoEvents if you use it.

Edit: Update to AutoData.
  • Got rid of the static method .getCount and replaced it with the instance member .size to more closely simulate array behavior.
  • Made the .index member readonly and accessible to the user, which enables you to avoid using a local counting variable during iterations.
  • Improved the iteration example and demonstrated how to get a random instance from a unit.
  • Made AutoData faster, at the cost of one hashtable per time it is implemented. I doubt anyone will hit the 255 hashtable limit.
  • Added the AutoDataFastMode constant, which forces AutoData to use only one hashtable if set to false, but makes iteration about 12.5% slower.
  • Made AutoData's non-static method operator inline properly. The inliner is really picky.

Edit: Another update.
  • Added the SafeMode configuration constant, true by default. You can set this to false for a performance boost if you heed the instructions.
  • Got rid of the TransportUnloadCheck textmacro and the UnitListDestroy textmacro. Now, AutoIndex has no textmacros used within it except for ones from AutoEvents.
  • You need to update AutoEvents again if you use it. UnitListModule has been deprecated and is no longer supported by AutoIndex.
  • This update may be a significant performance boost if you disable SafeMode and/or if you used AutoEvents.

Last edited by grim001 : 02-05-2010 at 04:49 PM.
grim001 is offline   Reply With Quote
Old 02-21-2010, 09:54 AM   #170
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

I'm also waiting for method onDestroy supported for modules.
Since method onDestroy is called when .deallocate is called, i need to use an extra boolean to avoid an onDestroy call, technically this method is still called but ended at the first line, it will be far better if i could declare destroy instead of onDestroy.

EDIT : Oh and again i ask you to plz move the object merger call on the top of the library.

EDIT 2 : Here is my code if you are curious (only useful for groups needed than more than instantly)

Collapse JASS:
library UnitList requires AutoIndex

struct UnitList

    readonly integer Count = 0
    readonly thistype First = 0
    readonly thistype Next = 0
    readonly thistype Prev = 0
    readonly thistype Last = 0
    
    implement AutoDestroy
    
    method clear takes nothing returns nothing
        local thistype s = .First
        
        set thistype.ignoreOnDestroy = true
        loop
        exitwhen s == 0
            call s.destroy()
            set s = s.Next
        endloop
        set .Count = 0
        call FlushChildHashtable(thistype.hashT,.whichList)
        set thistype.ignoreOnDestroy = false
    endmethod
    
    method onDestroy takes nothing returns nothing

        if thistype.ignoreOnDestroy then
            return
        endif
        
        if this == .whichList then // the whole group is destroyed
            call .clear()
            return
        endif
        
        set .whichList.Count = .whichList.Count-1
        call RemoveSavedInteger(thistype.hashT,.whichList,GetUnitId(.me))
        
        if this == .whichList.First then
            set .Prev = 0
            set .whichList.First = .Next
        elseif this == .whichList.Last then
            set .Prev.Next = 0
            set .whichList.Last = .Prev
        else
            set .Prev.Next = .Next
            set .Next.Prev = .Prev
        endif
    endmethod
    
    method addUnit takes unit u returns boolean
    
        if LoadInteger(thistype.hashT,this,GetUnitId(u)) != 0 then // the unit is already inside the group
            return false
        endif
        
        if .Count == 0 then // the group was empty
            set .First = thistype.allocate()
            set .Last = .First
        else
            set .Last.Next = thistype.allocate()
            set .Last.Next.Prev = .Last
            set .Last = .Last.Next
        endif
        set .Last.me = u
        set .Last.whichList = this
        call SaveInteger(thistype.hashT,this,GetUnitId(u),integer(.Last))
        set .Count = .Count+1
        
        return true
        
    endmethod
    
    //implement AutoDestroy
    
    method removeUnit takes unit u returns boolean
    
        if LoadInteger(thistype.hashT,this,GetUnitId(u)) == 0 then // the unit wasn't inside the group
            return false
        endif
        call thistype(LoadInteger(thistype.hashT,this,GetUnitId(u))).destroy()
        return true
    endmethod
    
    method isUnitInList takes unit u returns boolean
        return LoadInteger(thistype.hashT,this,GetUnitId(u)) != 0
    endmethod
    
    method addUnitList takes UnitList whichUnitList returns nothing
        set whichUnitList = whichUnitList.First
        loop
        exitwhen whichUnitList == 0
            call .addUnit(whichUnitList.me)
            set whichUnitList = whichUnitList.Next
        endloop
    endmethod
    
    static method wrap takes group g returns UnitList
        if not SaveGroupHandle(thistype.hashT,0,0,g) then // group invalid
            return 0
        endif
        set thistype.wrapList = thistype.allocate()
        call ForGroup(g,function thistype.WrapList)

        return thistype.wrapList
    endmethod
    
    
    private static method WrapList takes nothing returns nothing
        call thistype.wrapList.addUnit(GetEnumUnit())
    endmethod
    
    private thistype whichList = 0
    private static hashtable hashT
    private static boolean ignoreOnDestroy = false
    private static thistype wrapList = 0
    
    private static method onInit takes nothing returns nothing
        set thistype.hashT = InitHashtable()
    endmethod
    
endstruct

endlibrary
__________________
Cool != Useful

Last edited by Troll-Brain : 03-02-2010 at 11:01 AM. Reason: cleaned up the code
Troll-Brain is offline   Reply With Quote
Old 02-22-2010, 08:46 PM   #171
Ignitedstar
Moderator
 
Ignitedstar's Avatar


RP Section Moderator
 
Join Date: Jul 2005
Posts: 1,755

Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)

Send a message via MSN to Ignitedstar Send a message via Yahoo to Ignitedstar
Default

I really don't get why this is happening. I've never gotten an error using AutoIndex, before. Apparently, Dusk's buff detection system triggers JassHelper:

Click image for larger version

Name:	Error.JPG
Views:	31
Size:	70.3 KB
ID:	48141

The error is in AutoIndex, not in IBS, so I decided to put it here.
__________________
Current Activity: It's a secret, now.
Evaluation: I actually logged in?!?!
"If I speak in the tongues of men and of angels, but have not love,
I am only a resounding gong or a clanging cymbal.
If I have the gift of prophecy and can fathom all mysteries and all knowledge,
and if I have a faith that can move mountains, but have not love, I am nothing."

1 Corinthians 13:1-2

Current Works:
None.

Last edited by Ignitedstar : 02-22-2010 at 08:47 PM.
Ignitedstar is offline   Reply With Quote
Old 02-23-2010, 07:08 PM   #172
Deaod
User
 
Join Date: Jan 2007
Posts: 542

Submissions (11)

Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)

Default

Try updating your JassHelper to the latest version.
For some reason or another, youre missing optional textmacros.
__________________
Deaod is offline   Reply With Quote
Old 03-03-2010, 06:45 PM   #173
Ignitedstar
Moderator
 
Ignitedstar's Avatar


RP Section Moderator
 
Join Date: Jul 2005
Posts: 1,755

Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)Ignitedstar has a spectacular aura about (102)

Send a message via MSN to Ignitedstar Send a message via Yahoo to Ignitedstar
Default

Mmm, I had a feeling it was something like that. Thanks, Deaod. This also explains why a number of other things don't work.
__________________
Current Activity: It's a secret, now.
Evaluation: I actually logged in?!?!
"If I speak in the tongues of men and of angels, but have not love,
I am only a resounding gong or a clanging cymbal.
If I have the gift of prophecy and can fathom all mysteries and all knowledge,
and if I have a faith that can move mountains, but have not love, I am nothing."

1 Corinthians 13:1-2

Current Works:
None.
Ignitedstar is offline   Reply With Quote
Old 03-24-2010, 01:30 PM   #174
Magentix
User
 
Join Date: Mar 2007
Posts: 70

Magentix is on a distinguished road (16)

Default

Out of curiosity:
  1. Howcome "undefend" allows you to see if a unit left the map?
  2. Does it also catch removed/decaying units?
  3. What if a decaying unit is revived?
  4. How on earth can you still have a unit use the Defend spell? I thought it was a big no-no to have 2 identical order IDs on one unit...


I'll send you a cookie if you answer these questions.
Thanks
Magentix is offline   Reply With Quote
Old 03-24-2010, 05:39 PM   #175
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by Magentix
  • Howcome "undefend" allows you to see if a unit left the map?
Most likely, Blizzard turns off / cleans up data related to certain abilities as a unit leaves the map. The undefend order seems to get issued as a byproduct of that whenever a unit ceases to exist.

Quote:
Originally Posted by Magentix
  • Does it also catch removed/decaying units?
It catches everything.

Quote:
Originally Posted by Magentix
  • What if a decaying unit is revived?
It works fine. AutoIndex keeps track of the current status of all units and knows when they are resurrected. You can even use AutoEvents to notice when units get resurrected.

Quote:
Originally Posted by Magentix
  • How on earth can you still have a unit use the Defend spell? I thought it was a big no-no to have 2 identical order IDs on one unit...
The defend-based skill that AutoIndex puts onto units is disabled, therefore it can't interfere with anything. Somehow the skill still emits undefend orders when it's disabled, even though a unit can't be ordered to defend.
grim001 is offline   Reply With Quote
Old 03-24-2010, 05:44 PM   #176
Magentix
User
 
Join Date: Mar 2007
Posts: 70

Magentix is on a distinguished road (16)

Default

Cool thanks, you deserve your cookie!

P.S.: How the hell did you ever find out about this undefend thingy o.O
Magentix is offline   Reply With Quote
Old 03-24-2010, 05:54 PM   #177
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

The undefend detection method was originally used in this script: Reincarnation/Resurrection/Out of Scope Events

Then I got the idea to combine enter/leave detection with indexing to create an automatic indexing system.

I used the idea from that script as a starting point, and made gradual improvements over time. Most notably removing the restriction of only one defend-based skill per unit, and fixing every possible loophole until the detection was unbreakable.
grim001 is offline   Reply With Quote
Old 03-29-2010, 08:03 PM   #178
TheKid
User
 
TheKid's Avatar
 
Join Date: Mar 2009
Posts: 195

TheKid will become famous soon enough (37)TheKid will become famous soon enough (37)

Default

I have copied your library to my map script, including AutoEvents. I have a struct that implements both AutoCreate and AutoDestroy. It also has a method named onCreate that is supposed to display a message whenever a struct instance, well, is created.

The problem is that message is never displayed, the only messages that are displayed are the ones from debug saying "AutoIndex error: Wisp is a filtered unit". Wisp is just an example, as every unit I create with CreateUnit() has its own line in the debug --not to mention onCreate is never called.

Okay, my mistake on the first debug message. Although, it still displays that certain units are of filtered types despite the UnitFilter function always returning true. There are no methods for createFilter declared.

The problem seems to be AutoEvents causing the message to be displayed. If AutoEvents is disabled, the error message ceases --though I would like to be able to use AutoEvents properly in association with AutoIndex.
__________________

Last edited by TheKid : 03-29-2010 at 08:39 PM.
TheKid is offline   Reply With Quote
Old 03-29-2010, 09:39 PM   #179
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

You're most likely having a problem with JassHelper not detecting the existence of your onCreate method. Static ifs are buggy, and Vexorian hasn't felt like fixing them. Try declaring onCreate before declaring the module in your struct.

I haven't seen any issues with AutoIndex + AutoEvents. Please send me the map with the errors occuring and I'll figure out what the problem is.
grim001 is offline   Reply With Quote
Old 04-01-2010, 07:35 AM   #180
TheKid
User
 
TheKid's Avatar
 
Join Date: Mar 2009
Posts: 195

TheKid will become famous soon enough (37)TheKid will become famous soon enough (37)

Default

I believe it was something like:

Collapse JASS:
struct example
    implement AutoCreate
    implement AutoDestroy
endstruct

scope test initializer init
public function init takes nothing returns nothing
    call CreateUnit(Player(0), 'hfoo', 0, 0, 0)
endfunction
endscope

I have the test-map on my desktop though I have my laptop with me now. I will post it as soon as I'm able to but this is similar if not an exact duplication of what I had in that test-map. The following would display the message "Footman is a filtered unit.".
__________________
TheKid 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 06:52 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

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