• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Help! Redeclared Functions

Status
Not open for further replies.
Level 7
Joined
Sep 2, 2011
Messages
350
I want to import both these spells but they use the same function.
Here it is.

Storm Spiral
JASS:
    function GetNearestUnit takes real locx, real locy, real radius, boolexpr unitfilter returns unit
        local unit p
        local unit p2
        local real discurrent = 0.
        local real dist = 0.
        call GroupEnumUnitsInArea(Enumer,locx,locy,radius,unitfilter)
        set bj_lastCreatedUnit = null
        set discurrent = radius
        loop
            set p = FirstOfGroup(Enumer)
            exitwhen p == null
            call GroupRemoveUnit(Enumer,p)
            set dist = DistanceXY( locx, locy, GetUnitX(p), GetUnitY(p) )
            if dist < discurrent then
                set discurrent = dist
                set bj_lastCreatedUnit = p
            endif
            set p = null
        endloop
        
        call GroupRefresh( Enumer )
        
        return bj_lastCreatedUnit
    endfunction

Flesh Eating Plant

JASS:
function GetNearestUnit takes location attach , location loc , location loc2, real radius , unit attachunit returns unit
    local unit ret = null
    local real x1 = GetLocationX(loc)
    local real x2 = 0.00
    local real x3 = GetLocationX(loc2)
    local real y1 = GetLocationY(loc)
    local real y2 = 0.00
    local real y3 = GetLocationY(loc2)
    local unit a = null
    local unit b = null
    local real MinD = radius
    local real D = 0.00
    local real r = 0.00
    call GroupEnumUnitsInRangeOfLoc(g, loc, radius, filter)
    loop
    set a = FirstOfGroup(g)
    exitwhen a==null
    call GroupRemoveUnit(g,a)
        set r = SquareRoot((GetLocationX(attach)-GetUnitX(a))*(GetLocationX(attach)-GetUnitX(a))+(GetLocationY(attach)-GetUnitY(a))*(GetLocationY(attach)-GetUnitY(a)))
        set x2 = GetUnitX(a)
        set y2 = GetUnitY(a)
        set D = SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
        if r >= (TendrilLength * TendrilDefaultPosition) and (D < MinD) and (SquareRoot((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)) < TendrilLength ) and not(IsUnitInGroup(a,PulledUnits)) and GrapCondition(a,attachunit) == true then
           set MinD = D
           set b = a
        endif
    endloop
    call GroupClear(g)
    set a = null
    return b
endfunction

Deleting one of them will cause so many damn errors. I want them both in my map, but is it possible?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Give one of the functions (or both) some prefix.

For example for the Storm Spiral spell, add SS_ to the function name.

JASS:
function SS_GetNearestUnit takes real locx, real locy, real radius, boolexpr unitfilter returns unit

Change all function calls from GetNearestUnit to SS_GetNearestUnit for that spell.
 
Level 7
Joined
Sep 2, 2011
Messages
350
OMG. All of this time, this is the only solution to that problem? My god. Thanks! :D

Mark this thread, solved.
 
Status
Not open for further replies.
Top