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 04-25-2009, 08:08 PM   #16
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

Err, I have approved this, leaves and unitlist, but I am only going to post this notice here.
__________________
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
Sponsored Links - Login to hide this ad!
Old 04-26-2009, 05:06 AM   #17
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,186

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Shouldn't the AutoIndex returned by the create method be explicitly typecast to integer before being assigned as the unit's custom value, or did we stop enforcing that? Will JassHelper ever report errors on implicit struct to integer typecasting or is it considered correct usage now?
__________________
Anitarf is offline   Reply With Quote
Old 04-26-2009, 05:29 AM   #18
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

Fact is if it was ever "fixed" it would break a lot of things.
grim001 is offline   Reply With Quote
Old 04-26-2009, 05:36 AM   #19
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,186

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by grim001
Fact is if it was ever "fixed" it would break a lot of things.
Yes it would, which, depending on Vex's mood, could also be interpreted as "people suffering the consequences of doing things wrong". That's why I'd like to hear a final decision on this matter so we can all know what to do from there on.
__________________
Anitarf is offline   Reply With Quote
Old 04-26-2009, 12:36 PM   #20
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

Quote:
Originally Posted by grim001
Fact is if it was ever "fixed" it would break a lot of things.
And it will.

Type safety is our collective friend. Code is shorter but you pay a huge price.

Edit:
Quote:
Shouldn't the AutoIndex returned by the create method be explicitly typecast to integer before being assigned as the unit's custom value
Actually:

custom type -> integer , should work as implicit cast, the same with children->parent. Though it would probably show a warning "implicit cast!!!"

The opposite: integer->custom type or parent -> children would need an explicit cast.

So, this script is probably valid vJass. But if it did something like:

Collapse JASS:
    static method unitLeavesMap takes unit u returns nothing
     local AutoIndex a = GetUnitUserData(u)
        call a.destroy()
    endmethod
It would be invalid.
__________________
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 05-02-2009, 06:54 AM   #21
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

Huge update, AutoIndex has now absorbed the functionality of UnitEntersMapModule and UnitLeavesMapModule. The undefend method of removal detection has been improved a lot, since multiple defend-based skills on the same unit will no longer break it.

Also now gives you a filterfunc for ignoring stuff like dummy casters or private system units.

Last edited by grim001 : 05-02-2009 at 02:13 PM.
grim001 is offline   Reply With Quote
Old 05-04-2009, 04:06 AM   #22
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

I was able to move it.
__________________
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 05-04-2009, 02:08 PM   #23
Tyrande_ma3x
User
 
Tyrande_ma3x's Avatar
 
Join Date: Feb 2009
Posts: 185

Submissions (1)

Tyrande_ma3x is on a distinguished road (12)

Default

I get a compile error when I try to save my map with this:
Expected: "type", "struct", "interface", "function", "keyword" or "scope"
on this line:
Collapse JASS:
    private static method unitLeavesMapCaller takes nothing returns boolean

and I have no idea why...

EDIT: Nvm, I was using an old jasshelper...

Last edited by Tyrande_ma3x : 05-04-2009 at 02:11 PM.
Tyrande_ma3x is offline   Reply With Quote
Old 05-05-2009, 06:09 PM   #24
Tyrande_ma3x
User
 
Tyrande_ma3x's Avatar
 
Join Date: Feb 2009
Posts: 185

Submissions (1)

Tyrande_ma3x is on a distinguished road (12)

Default

Is it me or this script doesn't work? I always get a 0 when I use GetUnitId()...
Collapse JASS:
    local integer id = GetUnitId(cast)
    call BJDebugMsg(I2S(id))
    // Always inputs 0

Last edited by Tyrande_ma3x : 05-05-2009 at 06:10 PM.
Tyrande_ma3x is offline   Reply With Quote
Old 05-05-2009, 07:18 PM   #25
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

I had a GetFilterUnit() where there should have been a GetTriggerUnit(), leftover from some change. It wasn't indexing units that enter the map after init, but that's been fixed. If you were one of the (one? two?) people using this you should go update.
grim001 is offline   Reply With Quote
Old 05-09-2009, 04:06 PM   #26
Tyrande_ma3x
User
 
Tyrande_ma3x's Avatar
 
Join Date: Feb 2009
Posts: 185

Submissions (1)

Tyrande_ma3x is on a distinguished road (12)

Default

It worked after that one but now it seems like it returns a different index every time...

Let me show you the situation:
Collapse JASS:
private function AssignAsHero takes nothing returns boolean
    local unit cast = GetTriggerUnit()
    local integer id = GetUnitId(cast)
    if IsUnitType(cast, UNIT_TYPE_HERO) == true and (IS_HERO[id] == false or IS_HERO[id] == null) then
        call BJDebugMsg(I2S(id)) 
// That one printed 0.
        set IS_HERO[id] = true 
// This boolean should identify if a unit is a Hero.
// So far IS_HERO[0] should be = true.
    endif
    set cast = null
    return false
endfunction

...............
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterEnterRectSimple(trig, bj_mapInitialPlayableArea)
    call TriggerAddCondition(trig, Condition(function AssignAsHero))
endfunction
I store a "property" to show if a specific unit is a Hero.

Then I have a function that picks some units in a rect and attempts to move them somewhere:
Collapse JASS:
private function ChooseArena takes nothing returns nothing
    local timer tim = GetExpiredTimer()
    local integer a = GetRandomInt(0, 1)
    local rect temp 
    call GroupEnumUnitsInRange(ENUM_GROUP, GetRectCenterX(gg_rct_Hero_Selection), GetRectCenterY(gg_rct_Hero_Selection), 3500., Condition(function GetHeroes))
    if a == 0 then
        set temp = gg_rct_Arena_One
    else
        set temp = gg_rct_Arena_Two
    endif
    loop
        set fir = FirstOfGroup(ENUM_GROUP)
        exitwhen fir == null
        call SetUnitX(fir, GetRandomReal(GetRectMinX(temp), GetRectMaxX(temp)))
        call SetUnitY(fir, GetRandomReal(GetRectMinY(temp), GetRectMaxY(temp)))
        call IssueImmediateOrder(fir, "stop")
        call UnitResetCooldown(fir)
        call SetWidgetLife(fir, 999999.)
        call SetUnitState(fir, UNIT_STATE_MANA, 999999.)
        call UnitRemoveBuffs(fir, true, true)
        call GroupRemoveUnit(ENUM_GROUP, fir)
    endloop
    call ReleaseTimer(tim)
    set tim = null
    set temp = null
endfunction

As it seems, units never get moved to the other rect.
Collapse JASS:
private function GetHeroes takes nothing returns boolean
    local integer a = GetUnitIndex(GetFilterUnit())
    call BJDebugMsg(I2S(a))
    return IS_HERO[GetUnitIndex(GetFilterUnit())] == true
endfunction

In my test I had only 1 Hero in gg_rct_Hero_Selection - a Warden which was assigned index 0. But when I enum the rect it returns a different value for it - 6...

Last edited by Tyrande_ma3x : 05-09-2009 at 04:07 PM.
Tyrande_ma3x is offline   Reply With Quote
Old 05-09-2009, 08:57 PM   #27
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

Anytime you get 0 for the index, that means the unit hasn't been indexed yet. You are using a "Unit Enters Map" trigger that's executing before the "Unit Enters Map" trigger of AutoIndex.

Since I can't control the execution of triggers that you create, you've got two solutions: use UnitEntersMapModule to notice units entering the map, or wait until later tonight, I will add a couple new functions to register when units enter and leave the map using normal trigger syntax.
grim001 is offline   Reply With Quote
Old 05-11-2009, 11:51 PM   #28
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

I'm going to give this one more overhaul sometime in the next day or two, then it should be stable. I will probably just get rid of UnitEnters/LeavesMap modules, which will significantly shorten the script and documentation, and get it under the 20k character limit. I will change RegisterUnitEntersMap and RegisterUnitLeavesMap to RegisterUnitIndexed and RegisterUnitDeindexed, respectively. They will be able to replace the functionality of the modules once function interfaces work with static methods.

Last edited by grim001 : 05-12-2009 at 10:47 AM.
grim001 is offline   Reply With Quote
Old 05-13-2009, 04:45 AM   #29
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

It is updated with the previously mentioned changed, and it should stay this way now. I wasn't able to get it under the 20k character limit so I am still stuck with the lame .txt files. If for some reason you miss the modules, remember that soon function interfaces will work with static methods, meaning you will be able to accomplish the same thing without them.
grim001 is offline   Reply With Quote
Old 05-13-2009, 12:01 PM   #30
Mr.Malte
User
 
Mr.Malte's Avatar
 
Join Date: Apr 2008
Posts: 286

Submissions (2)

Mr.Malte is on a distinguished road (11)

Default

Hmm...
You should make a possibilty to detect whether the units UserData are affected, for people who are unsure.
I made a system a few days ago that allows this:
http://peeeq.de/code.php?id=1635
It is a bit buggy when you make AllowDummies true, but it doesn't matter, since the system is not public.
Mr.Malte 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:32 PM.


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

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