Wc3C.net (http://www.wc3c.net/forums.php)
-   Scripts (http://www.wc3c.net/forumdisplay.php?f=737)
-   -   AutoIndex (http://www.wc3c.net/showthread.php?t=105643)

Vexorian 04-25-2009 09:08 PM

Err, I have approved this, leaves and unitlist, but I am only going to post this notice here.

Anitarf 04-26-2009 06:06 AM

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?

grim001 04-26-2009 06:29 AM

Fact is if it was ever "fixed" it would break a lot of things.

Anitarf 04-26-2009 06:36 AM


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.

Vexorian 04-26-2009 01:36 PM


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.


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

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()
It would be invalid.

grim001 05-02-2009 07:54 AM

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.

Vexorian 05-04-2009 05:06 AM

I was able to move it.

Tyrande_ma3x 05-04-2009 03:08 PM

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

Tyrande_ma3x 05-05-2009 07:09 PM

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

grim001 05-05-2009 08:18 PM

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.

Tyrande_ma3x 05-09-2009 05:06 PM

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.
    set cast = null
    return false

private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterEnterRectSimple(trig, bj_mapInitialPlayableArea)
    call TriggerAddCondition(trig, Condition(function AssignAsHero))
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
        set temp = gg_rct_Arena_Two
        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)
    call ReleaseTimer(tim)
    set tim = null
    set temp = null

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

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

grim001 05-09-2009 09:57 PM

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 05-12-2009 12:51 AM

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.

grim001 05-13-2009 05:45 AM

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.

Mr.Malte 05-13-2009 01:01 PM

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:
It is a bit buggy when you make AllowDummies true, but it doesn't matter, since the system is not public.

All times are GMT. The time now is 12:53 PM.

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