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]