PhoenixICE
New Member
- Reaction score
- 0
i've looked through the forums and couldn't find an trigger that i needed (got up to like page 7) this is what i'm trying to do:
Setup an array then using random function pick an item from the array, but each item has a different ratio % of dropping and each creep has a different chance of dropped an item or not dropping one, so in short multiple items and multiple types of creeps, i need a efficent trigger in storing about 30-100 items and then a trigger to drop the items depending on its drop ratio.
i had this -
then i used a drop function
but that gonna be crazy storing 1 item 20 times in one array isn't the best way of doing this so does anyone have a good system?
Setup an array then using random function pick an item from the array, but each item has a different ratio % of dropping and each creep has a different chance of dropped an item or not dropping one, so in short multiple items and multiple types of creeps, i need a efficent trigger in storing about 30-100 items and then a trigger to drop the items depending on its drop ratio.
i had this -
Code:
function Trig_item_store_lvl_1_Actions takes nothing returns nothing
set bj_forLoopAIndex = 99
set bj_forLoopAIndexEnd = 100
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I001'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 96
set bj_forLoopAIndexEnd = 98
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I009'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 90
set bj_forLoopAIndexEnd = 95
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I007'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 83
set bj_forLoopAIndexEnd = 89
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I005'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 76
set bj_forLoopAIndexEnd = 82
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I004'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 71
set bj_forLoopAIndexEnd = 75
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I003'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 61
set bj_forLoopAIndexEnd = 70
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I002'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 41
set bj_forLoopAIndexEnd = 60
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I008'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 40
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_Item_list_Town_1[GetForLoopIndexA()] = 'I006'
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
//===========================================================================
function InitTrig_item_store_lvl_1 takes nothing returns nothing
set gg_trg_item_store_lvl_1 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_item_store_lvl_1, 5.00 )
call TriggerAddAction( gg_trg_item_store_lvl_1, function Trig_item_store_lvl_1_Actions )
endfunction
then i used a drop function
Code:
function Trig_Death_of_noraml_unit_lvl_6_and_below_Conditions takes nothing returns boolean
if ( not ( GetUnitLevel(GetDyingUnit()) <= 6 ) ) then
return false
endif
if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == false ) ) then
return false
endif
return true
endfunction
function Trig_Death_of_noraml_unit_lvl_6_and_below_Func004C takes nothing returns boolean
if ( not ( udg_Random_Percentage <= udg_Item_Drop_Ratio ) ) then
return false
endif
return true
endfunction
function Trig_Death_of_noraml_unit_lvl_6_and_below_Actions takes nothing returns nothing
set udg_Item_Drop_Ratio = ( GetRandomReal(0, 30.00) / I2R(GetUnitLevel(GetDyingUnit())) )
set udg_Random_Percentage = GetRandomReal(0, 100.00)
if ( Trig_Death_of_noraml_unit_lvl_6_and_below_Func004C() ) then
call CreateItemLoc( udg_Item_list_Town_1[GetRandomInt(1, 100)], GetUnitLoc(GetDyingUnit()) )
else
call DoNothing( )
endif
endfunction
//===========================================================================
function InitTrig_Death_of_noraml_unit_lvl_6_and_below takes nothing returns nothing
set gg_trg_Death_of_noraml_unit_lvl_6_and_below = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Death_of_noraml_unit_lvl_6_and_below, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Death_of_noraml_unit_lvl_6_and_below, Condition( function Trig_Death_of_noraml_unit_lvl_6_and_below_Conditions ) )
call TriggerAddAction( gg_trg_Death_of_noraml_unit_lvl_6_and_below, function Trig_Death_of_noraml_unit_lvl_6_and_below_Actions )
endfunction
but that gonna be crazy storing 1 item 20 times in one array isn't the best way of doing this so does anyone have a good system?