• 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] if then else question

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Hi,

i have to filter like 50 unit types, i wonder if there is a difference in coding process or memory between many elseif with 1 condition or 1 elseif but with 50 A or B or C or etc...

what i mean is that the condition will happen if any of those 50 unit types are true.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
what i mean is that the condition will happen if any of those 50 unit types are true.

since the condition will be true if ANY of those 50 unit types are true then use OR, like
JASS:
function checkType takes nothing returns boolean
    return unitType == Type1 or unitType == Type2 or unitType == Type3 or ... or unitType == Type50
endfunction
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
i am not sure i can use this, the check is inside a first of group loop...

[Jass=]
library Weather
globals
private group g=CreateGroup()
endglobals

public function Rain takes nothing returns nothing
local real x
local real y
local real time
local unit u=null
local unit flower
local unit array ztarget
local rect area
local integer count=0
local integer t
local integer chance
// ===== Start Rain Weather =====
call EnableWeatherEffect( udg_Rain_day, true )
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, "|c009966ffOld Troll:|r|c00ffff64Oh, It'z rainin'. That'z good for the herbz and iz bad for me old bonez...|r" )
set udg_Rain = true
set udg_MB_Weather = "Rain"
// ========== Rain makes plants grow ==========
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetUnitTypeId(u) == ARIA_ID then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(1.00, 10.00) ))
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
elseif GetUnitTypeId(u) == BARDANE_ID then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(1.00, 10.00) ))
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
elseif GetUnitTypeId(u) == CORIAN_ID then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(1.00, 10.00) ))
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
elseif GetUnitTypeId(u) == DRAXIMOR_ID then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(1.00, 10.00) ))
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
elseif GetUnitTypeId(u) == BERRYSAPPLING_ID then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(1.00, 10.00) ))
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
elseif GetUnitTypeId(u) == BERRYBUSH_ID then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(5.00, 20.00) ))
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
elseif GetUnitTypeId(u) == BEEHIVE_ID then
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) - GetRandomReal(25.00, 50.00) ))
elseif GetUnitTypeId(u) == CARNIVORPLANT_ID then
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) * 0.90 ))
elseif GetUnitTypeId(u) == INVENTOR_ID or GetUnitTypeId(u) == HUNTER_ID or GetUnitTypeId(u) == SHAMAN_ID or GetUnitTypeId(u) == WARRIOR_ID or GetUnitTypeId(u) == TOTEM_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == TOWER_A_ID or GetUnitTypeId(u) == TOWER_B_ID or GetUnitTypeId(u) == TOWER_C_ID or GetUnitTypeId(u) == TOWER_D_ID or GetUnitTypeId(u) == HUTT_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == ARMORY_A_ID or GetUnitTypeId(u) == ARMORY_B_ID or GetUnitTypeId(u) == MERCHANT_A_ID or GetUnitTypeId(u) == MERCHANT_B_ID or GetUnitTypeId(u) == MERCHANT_C_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == VOODOO_A_ID or GetUnitTypeId(u) == VOODOO_B_ID or GetUnitTypeId(u) == VOODOO_C_ID or GetUnitTypeId(u) == WORKSHOP_A_ID or GetUnitTypeId(u) == WORKSHOP_B_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == TANNER_A_ID or GetUnitTypeId(u) == TANNER_B_ID or GetUnitTypeId(u) == FORGE_A_ID or GetUnitTypeId(u) == FORGE_S_ID or GetUnitTypeId(u) == CAULDRON_A_ID or GetUnitTypeId(u) == CAULDRON_C_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == TENTB_ID or GetUnitTypeId(u) == TENTHB_ID or GetUnitTypeId(u) == TENTS_ID or GetUnitTypeId(u) == TENTHS_ID or GetUnitTypeId(u) == TENTP_ID or GetUnitTypeId(u) == TENTHP_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == PIGLET_ID or GetUnitTypeId(u) == BOAR_ID or GetUnitTypeId(u) == FATHOG_ID or GetUnitTypeId(u) == ANTELOPEFAWN_ID or GetUnitTypeId(u) == ANTELOPE_ID or GetUnitTypeId(u) == ANTELOPESTAG_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == BEARCUB_ID or GetUnitTypeId(u) == BEAR_ID or GetUnitTypeId(u) == OLDBEAR_ID or GetUnitTypeId(u) == SABERKITTEN_ID or GetUnitTypeId(u) == SABERCAT_ID or GetUnitTypeId(u) == OLDSABERCAT_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == RACOONCUB_ID or GetUnitTypeId(u) == RACOON_ID or GetUnitTypeId(u) == FATRACOON_ID or GetUnitTypeId(u) == BUNNY_ID or GetUnitTypeId(u) == RABBIT_ID or GetUnitTypeId(u) == FATRABBIT_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == HERMITCRAB_ID or GetUnitTypeId(u) == RIVERCRAB_ID or GetUnitTypeId(u) == IMPERCRAB_ID or GetUnitTypeId(u) == ALLIGATORHATCHLING_ID or GetUnitTypeId(u) == ALLIGATOR_ID or GetUnitTypeId(u) == GIANTALLIGATOR_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == FROG_ID or GetUnitTypeId(u) == BULLFROG_ID or GetUnitTypeId(u) == TORTOISE_ID or GetUnitTypeId(u) == GIANTTORTOISE_ID or GetUnitTypeId(u) == ANCIENTTORTOISE_ID or GetUnitTypeId(u) == FROLL_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == JUNGLEBIRD_ID or GetUnitTypeId(u) == BIGJUNGLEBIRD_ID or GetUnitTypeId(u) == VULTURE_ID or GetUnitTypeId(u) == GRIFFONVULTURE_ID or GetUnitTypeId(u) == RAT_ID or GetUnitTypeId(u) == MANGYRAT_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == JUNGLEASPIC_ID or GetUnitTypeId(u) == JUNGLEVIPER_ID or GetUnitTypeId(u) == ANACONDA_ID or GetUnitTypeId(u) == BLACKWIDOW_ID or GetUnitTypeId(u) == TARENTULA_ID or GetUnitTypeId(u) == TARENTULAQUEEN_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == DOG1_ID or GetUnitTypeId(u) == DOG2_ID or GetUnitTypeId(u) == DOG3_ID or GetUnitTypeId(u) == DOG4_ID or GetUnitTypeId(u) == DOG5_ID or GetUnitTypeId(u) == DOG6_ID then
set ztarget[count] = u
set count = count + 1
elseif GetUnitTypeId(u) == HAWK1_ID or GetUnitTypeId(u) == HAWK2_ID or GetUnitTypeId(u) == HAWK3_ID or GetUnitTypeId(u) == HAWK4_ID or GetUnitTypeId(u) == FROLLHUTT_ID or GetUnitTypeId(u) == FROLLVILLAGE_ID then
set ztarget[count] = u
set count = count + 1
endif
call GroupRemoveUnit(g, u)
endloop
call DisplayTimedTextToPlayer( Player(0), 0, 0, 6.00, ( "Units: " + I2S(count) ) )
call TriggerSleepAction( GetRandomReal(5.00, 15.00) )
// ===== Lightning 1 =====
if ( GetRandomInt(1, chance) == 1 ) then
set t = GetRandomInt(0, count)
if GetUnitState(t, UNIT_STATE_LIFE) > 0.00 then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call TriggerSleepAction( 0.10 )
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call IssueTargetOrder( gg_unit_h02R_0618, "thunderbolt", ztarget[t] )
call DisplayTimedTextToPlayer( Player(0), 0, 0, 6.00, ( "Units: " + GetUnitName(ztarget[t]) ) )
endif
else
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call TriggerSleepAction( 0.10 )
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
call TriggerExecute( gg_trg_Lightning_Tree_JASS )
endif
endfunction
endlibrary
[/code]
 
u should set this to a variable GetUnitTypeId(u)
and then use the variable to check the integers

i shortened one portion of ur code so far here it is tho
u might want to start using arrays more u can loop through them checking if unittype == unit[1] instead of the 1 u replace it w ur loop variable
JASS:
library Weather
    globals
        private group g=CreateGroup()
    endglobals

    public function Rain takes nothing returns nothing
        local real x
        local real y
        local real time
        local unit u=null
        local unit flower
        local unit array ztarget
        local rect area
        local integer count=0
        local integer t
        local integer chance
        local integer i
        // =====  Start Rain Weather  =====
        call EnableWeatherEffect( udg_Rain_day, true )
        call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 6.00, "|c009966ffOld Troll:|r|c00ffff64Oh, It'z rainin'. That'z good for the herbz and iz bad for me old bonez...|r" )
        set udg_Rain = true
        set udg_MB_Weather = "Rain"
        // ==========   Rain makes plants grow   ==========
        call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
        loop
            set u = FirstOfGroup(g)
            set i = GetUnitTypeId(u)
            exitwhen u == null
            if i == ARIA_ID or i == BARDANE_ID or i == CORIAN_ID or i == DRAXIMOR_ID or i == BERRYSAPPLING_ID then
                call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(1.00, 10.00) ))
                call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
            elseif i == BERRYBUSH_ID then
                call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(5.00, 20.00) ))
                call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
            elseif i == BEEHIVE_ID then
                call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) - GetRandomReal(25.00, 50.00) ))
            elseif i == CARNIVORPLANT_ID then
                call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) * 0.90 ))
            elseif i == INVENTOR_ID or i == HUNTER_ID or i == SHAMAN_ID or i == WARRIOR_ID or i == TOTEM_ID or i == TOWER_A_ID or i == TOWER_B_ID or i == TOWER_C_ID or i == TOWER_D_ID or i == HUTT_ID or i == ARMORY_A_ID or i == ARMORY_B_ID or i == MERCHANT_A_ID or i == MERCHANT_B_ID or i == MERCHANT_C_ID or i == VOODOO_A_ID or i == VOODOO_B_ID or i == VOODOO_C_ID or i == WORKSHOP_A_ID or i == WORKSHOP_B_ID or i == TANNER_A_ID or i == TANNER_B_ID or i == FORGE_A_ID or i == FORGE_S_ID or i == CAULDRON_A_ID or i == CAULDRON_C_ID or i == TENTB_ID or i == TENTHB_ID or i == TENTS_ID or i == TENTHS_ID or i == TENTP_ID or i == TENTHP_ID or i == PIGLET_ID or i == BOAR_ID or i == FATHOG_ID or i == ANTELOPEFAWN_ID or i == ANTELOPE_ID or i == ANTELOPESTAG_ID or i == BEARCUB_ID or i == BEAR_ID or i == OLDBEAR_ID or i == SABERKITTEN_ID or i == SABERCAT_ID or i == OLDSABERCAT_ID or i == RACOONCUB_ID or i == RACOON_ID or i == FATRACOON_ID or i == BUNNY_ID or i == RABBIT_ID or i == FATRABBIT_ID or i == HERMITCRAB_ID or i == RIVERCRAB_ID or i == IMPERCRAB_ID or i == ALLIGATORHATCHLING_ID or i == ALLIGATOR_ID or i == GIANTALLIGATOR_ID or i == FROG_ID or i == BULLFROG_ID or i == TORTOISE_ID or i == GIANTTORTOISE_ID or i == ANCIENTTORTOISE_ID or i == FROLL_ID or i == JUNGLEBIRD_ID or i == BIGJUNGLEBIRD_ID or i == VULTURE_ID or i == GRIFFONVULTURE_ID or i == RAT_ID or i == MANGYRAT_ID or i == JUNGLEASPIC_ID or i == JUNGLEVIPER_ID or i == ANACONDA_ID or i == BLACKWIDOW_ID or i == TARENTULA_ID or i == TARENTULAQUEEN_ID or i == DOG1_ID or i == DOG2_ID or i == DOG3_ID or i == DOG4_ID or i == DOG5_ID or i == DOG6_ID or i == HAWK1_ID or i == HAWK2_ID or i == HAWK3_ID or i == HAWK4_ID or i == FROLLHUTT_ID or i == FROLLVILLAGE_ID then
                set ztarget[count] = u
                set count = count + 1
            endif
            call GroupRemoveUnit(g, u)
        endloop
        call DisplayTimedTextToPlayer( Player(0), 0, 0, 6.00, ( "Units: " + I2S(count) ) )
        call TriggerSleepAction( GetRandomReal(5.00, 15.00) )
        // =====  Lightning 1 =====
        if ( GetRandomInt(1, chance) == 1 ) then
            set t = GetRandomInt(0, count)
            if GetUnitState(t, UNIT_STATE_LIFE) > 0.00 then
                call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
                call TriggerSleepAction( 0.10 )
                call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )            
                call IssueTargetOrder( gg_unit_h02R_0618, "thunderbolt", ztarget[t] )
                call DisplayTimedTextToPlayer( Player(0), 0, 0, 6.00, ( "Units: " + GetUnitName(ztarget[t]) ) )
            endif
        else
            call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
            call TriggerSleepAction( 0.10 )
            call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 0.10, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.00, 100.00, 90.00, 0 )
            call TriggerExecute( gg_trg_Lightning_Tree_JASS )
        endif
    endfunction
endlibrary
 
What about creating a list?
JASS:
function AllowUnit takes integer utype returns nothing
    call SaveBoolean(MyHash,utype,StringHash("Unit Allowed"),true)
endfunction

function AllowUnitList takes nothing returns nothing
    call AllowUnit('hfoo')
    call AllowUnit('hpea')
endfunction

function UseIt takes nothing returns nothing
    local boolean b = LoadInteger(MyHash,GetUnitTypeId(MyUnit),StringHash("Unit Allowed"))
    if b == true then
        //Effects of the unit
        //eg
        call RemoveUnit(MyUnit)
    endif
endfunction
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
u should set this to a variable GetUnitTypeId(u)
and then use the variable to check the integers

Indeed, you are spamming the function GetUnitTypeId many times. Anyways this needs an optimization, look at the first 5 conditions and you will find that their then actions are the same so you could use an OR for the first 5 types like this:

JASS:
set ut = GetUnitTypeId(u)
  if  ut == ARIA_ID or ut == BARDANE_ID or ut == CORIAN_ID or ut == DRAXIMOR_ID or ut == BERRYSAPPLING_ID then
     call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + GetRandomReal(1.00, 10.00) ))
     call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + GetRandomReal(5.00, 20.00) ))
 
Last edited:

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
well hashtable would be great but i cannot use them because of WEU.
i am stuck to finish Jassing the map before to be able to remove WEU and finally use hashtable.

deathismyfriend
great ideas i=GetUnitTypeId(u) , so basically i doesn't matter to put 100 of variable on same line, i was afraid to do that because it make it harder to read the code but if it is more efficient and faster i will do like this
 
it makes it a lot harder to read thts y i suggested putting them into arrays and then looping through the array to make it more readable but hopefully the code i uploaded will help lol. y not switch over to jngp right now ? also putting them into arrays and looping through them is an alternative to hastables but im not sure if its more efficient
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
JASS:
function AllowUnit takes integer utype returns nothing
    call SaveBoolean(MyHash,utype,0,true)
endfunction

function AllowUnitList takes nothing returns nothing
    call AllowUnit('hfoo')
    call AllowUnit('hpea')
endfunction

function UseIt takes nothing returns nothing
    if HaveSavedBoolean(MyHash,GetUnitTypeId(MyUnit),0)
        //Effects of the unit
        //eg
        call RemoveUnit(MyUnit)
    endif
endfunction
^That is how I would do Almia's solution.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
he said he cant use hashtable because of WEU

also there is difference between having multiple ors in one if and having multiple nested ifs

the thing is that if the code runs the if ... or ... or ... then, then he goes from the first code check to last and if he finds a result he abandons the rest and goes into then block while having multiple ifelses means system will be forced to run over all the checks

Almia, never use StringHash unless you are forced to, its veeery slow function

deathismyfriend's version is great if you cant use hashtable, just do:

JASS:
library InitMyStuff initializer onInit
    globals
        integer array listofIds
        integer listofIdsmax = 0
    endglobals

    private function onInit takes nothing returns nothing
        set listofIds[0] = 'hfoo'
        set listofIds[1] = 'Hmkg'
        set listofIds[2] = 'Hpal'
        set listofIds[3] = 'hpea'
        set listofIdsmax = 3 //highest index
    endfunction
endlibrary

usage:

(lest pretend this function is registered to some trigger)
JASS:
function doSomething takes nothing returns nothing
    local integer u = GetUnitTypeId(GetTriggerUnit())
    local boolean found = false
    local integer itt = 0
    loop
        if u == listofIds[itt] then
            set found = true
        endif
        exitwhen itt == listofIdsmax or found
        set itt = itt + 1
    endloop
    if found then
        //do some shit
    endif
endfunction

this is only usable if you want the same stuff done for any of those units tho so if you want different stuff for different units you have to filter it the way it was mentioned in first reply, long if () or () or () then block
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
thanks for all the answers ^^
edo494
this way is interesting, i will keep it in mind for it might be usefull in some triggers.
for now, even if long or or block is annoying, i will keep to deathismyfriend solution.

the hashtable is great and when i manage to completly remove WEU from the map, and clean the map from all annoying things.
i will definitly try to get some hashtable to clean and speed up things.
 
well u got most of what i meant edo but u can have multiple arrays and thus do different things for different arrays he can do it like this
JASS:
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
    local integer Loop
    loop 
        exitwhen u == null // set this to null cause he had it null
        //these should all be integers since u r using GetUnitTypeId(u)
        if array1[Loop] == u then 
        elseif array2[Loop] == u then
        elseif array3[Loop] == u then
        elseif array4[Loop] == u then
        elseif array5[Loop] == u then
        endif 
        //this way u can have multiple actions but only one simple loop
        set Loop = Loop + 1
    endloop
endfunction
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
JASS:
function doSomething takes nothing returns nothing
    local integer u = GetUnitTypeId(GetTriggerUnit())
    local boolean found = false
    local integer itt = 0
    loop
        if u == listofIds[itt] then
            set found = true
        endif
        exitwhen itt == listofIdsmax or found
        set itt = itt + 1
    endloop
    if found then
        //do some shit
    endif
endfunction

I wanted to cut out some variables for no purpose so I chaged it to this:
JASS:
function doSomething takes nothing returns nothing
        local integer u = GetUnitTypeId(GetTriggerUnit())
        local integer itt = 0
        loop
            exitwhen listofIds[itt] == null or u == listofIds[itt]
            set itt = itt + 1
        endloop
        if listofIds[itt] != null then
            call BJDebugMsg("true")
        endif
    endfunction
 
Status
Not open for further replies.
Top