• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Custom EnumDestructable functions does not work?!

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
Hey guys,

Thanks for taking the time to read through this.

Well, so basically I am trying to create a custom EnumDestructable Function - which evoids creating a location each time, because I am calling it every 0.3 seconds.

First, here are blizzards functions to do this:
JASS:
function GetRectFromCircleBJ takes location center, real radius returns rect
    local real centerX = GetLocationX(center)
    local real centerY = GetLocationY(center)
    return Rect(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
endfunction

function EnumDestructablesInCircleBJ takes real radius, location loc, code actionFunc returns nothing
    local rect r

    if (radius >= 0) then
        set bj_enumDestructableCenter = loc
        set bj_enumDestructableRadius = radius
        set r = GetRectFromCircleBJ(loc, radius)
        call EnumDestructablesInRect(r, filterEnumDestructablesInCircleBJ, actionFunc)
        call RemoveRect(r)
    endif
endfunction

This is my Own Code to mimic this BJs (which is as I said basically everything, they did but without a location).

JASS:
function DestructableConditions takes destructable Temp returns boolean
    // My conditions
endfunction

function HM_DestructableCloseUpCameraDecision takes nothing returns nothing
    local destructable Temp = GetEnumDestructable()
    local integer playerId = udg_KAMERA_TempInteger
    if DestructableConditions(Temp) == false then
        // if no tree, do nothing
    else
        // set camera for playerId
    endif
    set Temp = null
endfunction

function HM_DestructableManager takes real radius, integer playerId, real centerX, real centerY returns nothing
    
    local rect r = Rect(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
    set udg_KAMERA_TempInteger = playerId
   
        // preset camera and enum destructables
        call EnumDestructablesInRect(r, null, function HM_DestructableCloseUpCameraDecision)

    // Remove Leaks
    call RemoveRect( r)
    set r = null
        
endfunction

The action function and condition function are exactly the same in BJs and my own enum function, so I really do not get, where the problem is :vw_wtf: :vw_wtf:

Could you maybe point out, what I might have missed?

Problem in short:
JASS:
What happens, when I come closer to a desired destructable:

A) BJ FUNCTION: CAMERA CHANGES

B) MY OWN FUNCTION: NO REACTION

I am grateful for any help :)

Good evening, everyone!
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
You could try to place some call BJDebugMsg("test 1") in it (using a different number each time).
Then you can know what runs and what not.

Maybe also display the values of the rect (loading from the rect): call BJDebugMsg("minX: " + R2S(GetRectMinX(r)))
For all the values of rect.

At least it should work.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
You could try to place some call BJDebugMsg("test 1") in it (using a different number each time).
Then you can know what runs and what not.

Maybe also display the values of the rect (loading from the rect): call BJDebugMsg("minX: " + R2S(GetRectMinX(r)))
For all the values of rect.

At least it should work.

Thanks for your thoughts. I actually had a lot of Debug messages in there, and from what I found out, the Destructable Ids did not match strangly enough. I didnt see any point in this, so I searched for something other.

Thanks for the advice with the rect, I will try this :)

I thought, maybe there is a hidden knowledge like with a lot of Blizzards functions behind this strange bug ..
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
Can't see the problem but if you're periodically calling it every 1/32 second and the rect size doesn't change, you might wanna use native MoveRectTo takes rect whichRect, real newCenterX, real newCenterY returns nothing instead of creating a new rect every periodic action. So if it's for a spell, when the spell effect start, create the rect and periodically use MoveRectTo, when the spell effect finished, remove the rect.

Now for the problem, what values are you inputting in the function?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Good evening people.

Thank you all for your suggestions. Good to know, that there is no general problem like "Bro u cant use this native cause it kinda buggs" :grin:

The conditions did work properly, it was
JASS:
return ( GetDestructableId(Temp) == 'XYxy' )
but anyway I checked it by reversing it and so on ...

I did give it up and just used the location version (which works as well), though I applied the neat trick with moving the rect to save up that way :)

I am quite sure now, the problem must have been somewhere else in the map ... It just would have been pretty cool to chose the perfect match, maybe I'll try it again another day.

Anyway, Thanks guys! :thumbs_up:

I'm trying to rep all of you but I guess I can't?
 
Status
Not open for further replies.
Top